Skip to content

Commit 7fbf559

Browse files
Merge pull request #78 from contentstack/development
DX | 06-04-2026 | Release
2 parents 827e5ee + edd6412 commit 7fbf559

File tree

36 files changed

+4428
-68
lines changed

36 files changed

+4428
-68
lines changed

.cursor/commands/code-review.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
name: code-review
3+
description: Automated PR review using comprehensive checklist tailored for modularized Contentstack CLI
4+
---
5+
6+
# Code Review Command
7+
8+
## Usage Patterns
9+
10+
### Scope-Based Reviews
11+
- `/code-review` - Review all current changes with full checklist
12+
- `/code-review --scope typescript` - Focus on TypeScript configuration and patterns
13+
- `/code-review --scope testing` - Focus on Mocha/Chai test patterns
14+
- `/code-review --scope oclif` - Focus on command structure and OCLIF patterns
15+
- `/code-review --scope packages` - Focus on package structure and organization
16+
17+
### Severity Filtering
18+
- `/code-review --severity critical` - Show only critical issues (security, breaking changes)
19+
- `/code-review --severity high` - Show high and critical issues
20+
- `/code-review --severity all` - Show all issues including suggestions
21+
22+
### Package-Aware Reviews
23+
- `/code-review --package contentstack-import` - Review changes in import package
24+
- `/code-review --package contentstack-export` - Review changes in export package
25+
- `/code-review --package-type plugin` - Review all plugin packages (all 12 packages are plugins)
26+
- `/code-review --package-scope cm` - Review CM (content management) related packages
27+
28+
### File Type Focus
29+
- `/code-review --files commands` - Review command files only
30+
- `/code-review --files tests` - Review test files only
31+
- `/code-review --files utils` - Review utility files
32+
33+
## Comprehensive Review Checklist
34+
35+
### Monorepo Structure Compliance
36+
- **Package organization**: 12 plugin packages under `packages/contentstack-*`
37+
- **pnpm workspace**: Correct `pnpm-workspace.yaml` configuration
38+
- **Build artifacts**: No `lib/` directories committed to version control
39+
- **Dependencies**: Proper use of shared utilities (`@contentstack/cli-command`, `@contentstack/cli-utilities`)
40+
- **Scripts**: Consistent build, test, and lint scripts across packages
41+
42+
### Package-Specific Structure
43+
- **All packages are plugins**: Each has `oclif.commands` configuration pointing to `./lib/commands`
44+
- **Plugin topics**: All commands under `cm:` topic (content management)
45+
- **Base commands**: Each plugin defines its own `BaseCommand` extending `@contentstack/cli-command` Command
46+
- **Inter-plugin dependencies**: Some plugins depend on others (e.g., import depends on audit)
47+
- **Dependency versions**: Using consistent versions across plugins
48+
49+
### TypeScript Standards
50+
- **Configuration compliance**: Follows package TypeScript config (`strict: false`, `target: es2017`)
51+
- **Naming conventions**: kebab-case files, PascalCase classes, camelCase functions
52+
- **Import patterns**: ES modules with proper default/named exports
53+
- **Type safety**: No unnecessary `any` types in production code
54+
55+
### OCLIF Command Patterns
56+
- **Base class usage**: Extends plugin-specific `BaseCommand` or `@contentstack/cli-command` Command
57+
- **Command structure**: Proper `static id`, `static description`, `static examples`, `static flags`
58+
- **Topic organization**: Uses `cm:stacks:*` structure (`cm:stacks:import`, `cm:stacks:export`, `cm:stacks:audit`)
59+
- **Error handling**: Uses `handleAndLogError` from utilities with context
60+
- **Flag validation**: Early validation and user-friendly error messages
61+
- **Service delegation**: Commands are thin, services handle business logic
62+
63+
### Testing Excellence (Mocha/Chai Stack)
64+
- **Framework compliance**: Uses Mocha + Chai (not Jest)
65+
- **File patterns**: Follows `*.test.ts` naming convention
66+
- **Directory structure**: Proper placement in `test/unit/`
67+
- **Test organization**: Arrange-Act-Assert pattern consistently used
68+
- **Isolation**: Proper setup/teardown with beforeEach/afterEach
69+
- **No real API calls**: All external dependencies properly mocked
70+
71+
### Error Handling Standards
72+
- **Consistent patterns**: Use `handleAndLogError` from utilities
73+
- **User-friendly messages**: Clear error descriptions for end users
74+
- **Logging**: Proper use of `log.debug` for diagnostic information
75+
- **Status messages**: Use `cliux` for user feedback (success, error, info)
76+
77+
### Build and Compilation
78+
- **TypeScript compilation**: Clean compilation with no errors
79+
- **OCLIF manifest**: Generated for command discovery
80+
- **README generation**: Commands documented in package README
81+
- **Source maps**: Properly configured for debugging
82+
- **No build artifacts in commit**: `.gitignore` excludes `lib/` directories
83+
84+
### Testing Coverage
85+
- **Test structure**: Tests in `test/unit/` with descriptive names
86+
- **Command testing**: Uses @oclif/test for command validation
87+
- **Error scenarios**: Tests for both success and failure paths
88+
- **Mocking**: All dependencies properly mocked
89+
90+
### Package.json Compliance
91+
- **Correct metadata**: name, description, version, author
92+
- **Script definitions**: build, compile, test, lint scripts present
93+
- **Dependencies**: Correct versions of shared packages
94+
- **Main/types**: Properly configured for library packages
95+
- **OCLIF config**: Present for plugin packages
96+
97+
### Security and Best Practices
98+
- **No secrets**: No API keys or tokens in code or tests
99+
- **Input validation**: Proper validation of user inputs and flags
100+
- **Process management**: Appropriate use of error codes
101+
- **File operations**: Safe handling of file system operations
102+
103+
### Code Quality
104+
- **Naming consistency**: Follow established conventions
105+
- **Comments**: Only for non-obvious logic (no "narration" comments)
106+
- **Error messages**: Clear, actionable messages for users
107+
- **Module organization**: Proper separation of concerns
108+
109+
## Review Execution
110+
111+
### Automated Checks
112+
1. **Lint compliance**: ESLint checks for code style
113+
2. **TypeScript compiler**: Successful compilation to `lib/` directories
114+
3. **Test execution**: All tests pass successfully
115+
4. **Build verification**: Build scripts complete without errors
116+
117+
### Manual Review Focus Areas
118+
1. **Command usability**: Clear help text and realistic examples
119+
2. **Error handling**: Appropriate error messages and recovery options
120+
3. **Test quality**: Comprehensive test coverage for critical paths
121+
4. **Monorepo consistency**: Consistent patterns across all packages
122+
5. **Flag design**: Intuitive flag names and combinations
123+
124+
### Common Issues to Flag
125+
- **Inconsistent TypeScript settings**: Mixed strict mode without reason
126+
- **Real API calls in tests**: Unmocked external dependencies
127+
- **Missing error handling**: Commands that fail silently
128+
- **Poor test organization**: Tests without clear Arrange-Act-Assert
129+
- **Build artifacts committed**: `lib/` directories in version control
130+
- **Unclear error messages**: Non-actionable error descriptions
131+
- **Inconsistent flag naming**: Similar flags with different names
132+
- **Missing command examples**: Examples not showing actual usage
133+
134+
## Repository-Specific Checklist
135+
136+
### For Modularized CLI
137+
- [ ] Command properly extends `@contentstack/cli-command` Command
138+
- [ ] Flags defined with proper types from `@contentstack/cli-utilities`
139+
- [ ] Error handling uses `handleAndLogError` utility
140+
- [ ] User feedback uses `cliux` utilities
141+
- [ ] Tests use Mocha + Chai pattern with mocked dependencies
142+
- [ ] Package.json has correct scripts (build, compile, test, lint)
143+
- [ ] TypeScript compiles with no errors
144+
- [ ] Tests pass: `pnpm test`
145+
- [ ] No `.only` or `.skip` in test files
146+
- [ ] Build succeeds: `pnpm run build`
147+
- [ ] OCLIF manifest generated successfully
148+
149+
### Before Merge
150+
- [ ] All review items addressed
151+
- [ ] No build artifacts in commit
152+
- [ ] Tests added for new functionality
153+
- [ ] Documentation updated if needed
154+
- [ ] No console.log() statements (use log.debug instead)
155+
- [ ] Error messages are user-friendly
156+
- [ ] No secrets or credentials in code

0 commit comments

Comments
 (0)