@@ -10,19 +10,19 @@ Automated code transformations for Suites projects. Built on [jscodeshift](https
1010## Usage
1111
1212``` bash
13- npx @suites/codemod < path> [options]
13+ npx @suites/codemod < transform > < path> [options]
1414```
1515
1616** Example:**
1717``` bash
18- npx @suites/codemod src/** /* .spec.ts
18+ npx @suites/codemod automock/2/to-suites-v3 src/** /* .spec.ts
1919```
2020
2121Run with ` --dry-run ` to preview changes without modifying files.
2222
2323## Available Transforms
2424
25- - ** ` automock- to-suites ` ** (default) - Migrate test files from Automock to Suites testing framework
25+ - ** ` automock/2/ to-suites-v3 ` ** - Migrate test files from Automock v2 to Suites v3 testing framework
2626
2727## Example
2828
@@ -79,20 +79,20 @@ describe('UserService', () => {
7979** More examples:**
8080``` bash
8181# Preview changes
82- npx @suites/codemod src --dry-run
82+ npx @suites/codemod automock/2/to-suites-v3 src --dry-run
8383
8484# Ignore certain files
85- npx @suites/codemod src --ignore " **/*.integration.ts"
85+ npx @suites/codemod automock/2/to-suites-v3 src --ignore " **/*.integration.ts"
8686
8787# List all transforms
8888npx @suites/codemod --list-transforms
8989```
9090
9191## Transform Details
9292
93- ### ` automock- to-suites `
93+ ### ` automock/2/ to-suites-v3 `
9494
95- Intelligently migrates Automock test files to Suites framework.
95+ Intelligently migrates Automock v2 test files to Suites v3 framework.
9696
9797** What it transforms:**
9898- Import statements: ` @automock/jest ` -> ` @suites/unit `
@@ -154,6 +154,32 @@ The codemod uses [jscodeshift](https://github.com/facebook/jscodeshift) to:
154154
155155** TypeScript Support:** First-class support with fallback parser for complex syntax (generics, type guards, decorators, JSX/TSX).
156156
157+ ## Architecture
158+
159+ This codemod follows the ** Codemod Registry** pattern used by React, Next.js, and other major frameworks:
160+
161+ ** Transform Naming:** ` <framework>/<version>/<transform> `
162+ - ` automock/2/to-suites-v3 ` - Current migration
163+ - ` automock/3/to-suites-v4 ` - Future migrations
164+ - Supports multiple transforms per version
165+ - Extensible to other frameworks (e.g., ` jest/28/to-v29 ` )
166+
167+ ** Directory Structure:**
168+ ```
169+ src/transforms/
170+ automock/ # Framework namespace
171+ 2/ # Source version
172+ to-suites-v3.ts # Migration transform
173+ 3/ # Future: next version
174+ to-suites-v4.ts
175+ ```
176+
177+ ** Design Benefits:**
178+ - No default transform - explicit selection prevents mistakes
179+ - Version-based organization supports migration chains
180+ - Framework namespacing allows multi-framework support
181+ - Clear source → target versioning
182+
157183## Contributing
158184
159185Contributions welcome! To contribute:
@@ -167,18 +193,36 @@ Contributions welcome! To contribute:
167193
168194### Adding New Transforms
169195
170- 1 . Create transform file in ` src/transforms/ `
171- 2 . Register in ` src/transforms/index.ts `
172- 3 . Add test fixtures in ` fixtures/ `
173- 4 . Add integration tests in ` test/integration/ `
174- 5 . Update this README
196+ 1 . Create transform directory: ` src/transforms/<framework>/<version>/<transform-name>.ts `
197+ 2 . Export ` applyTransform ` function from your transform
198+ 3 . Register in ` src/transforms/index.ts ` :
199+ ``` typescript
200+ {
201+ name : ' framework/version/transform-name' ,
202+ description : ' Description of what it does' ,
203+ path : ' ./transforms/framework/version/transform-name' ,
204+ }
205+ ```
206+ 4 . Add test fixtures in ` fixtures/ `
207+ 5 . Add integration tests in ` test/integration/ `
208+ 6 . Update this README
209+
210+ ** Example:**
211+ ``` typescript
212+ // src/transforms/automock/3/to-suites-v4.ts
213+ export { applyTransform } from ' ../../../transform' ;
214+ ```
175215
176216### Project Structure
177217
178218```
179219src/
180220 analyzers/ # Code analysis utilities
181221 transforms/ # Transform implementations
222+ automock/ # Framework namespace
223+ 2/ # Version-specific transforms
224+ to-suites-v3.ts
225+ index.ts # Transform registry
182226 validators/ # Post-transform validation
183227 utils/ # Shared utilities
184228 cli.ts # CLI interface
@@ -191,6 +235,52 @@ test/
191235 fixtures/ # Test fixtures (before/after)
192236```
193237
238+ ## Local Development
239+
240+ ### Running Locally
241+
242+ From within the codemod repository:
243+
244+ ``` bash
245+ # Build first
246+ pnpm build
247+
248+ # Run on a target repository
249+ node dist/cli.js automock/2/to-suites-v3 /path/to/repo --dry-run
250+
251+ # Run on test fixtures
252+ node dist/cli.js automock/2/to-suites-v3 fixtures/simple-final --dry-run
253+
254+ # Verbose output for debugging
255+ node dist/cli.js automock/2/to-suites-v3 /path/to/repo --dry-run --verbose
256+ ```
257+
258+ ### Using npm link for Testing
259+
260+ ``` bash
261+ # In the codemod repo
262+ npm link
263+
264+ # Now use it anywhere like npx
265+ codemod automock/2/to-suites-v3 /path/to/repo --dry-run
266+
267+ # Unlink when done
268+ npm unlink -g @suites/codemod
269+ ```
270+
271+ ### Running Tests
272+
273+ ``` bash
274+ # All tests
275+ pnpm test
276+
277+ # Specific test file
278+ pnpm test path/to/test.spec.ts
279+
280+ # With coverage
281+ pnpm test --coverage
282+ ```
283+
194284## License
195285
196286MIT (c) [ Omer Morad] ( https://github.com/omermorad )
0 commit comments