Skip to content

Commit dac58e7

Browse files
committed
feat: support migration command with no pattern
1 parent e01d5d2 commit dac58e7

3 files changed

Lines changed: 20 additions & 33 deletions

File tree

.changeset/migrate-default-glob.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@zmod/migrate": patch
3+
---
4+
5+
Default to scanning all JS/TS files when no pattern is provided
6+
7+
- `npx @zmod/migrate` now works from the project root without arguments
8+
- Defaults to `**/*.{ts,tsx,js,jsx}` with `node_modules` excluded
9+
- Removes the interactive prompt for glob input

README.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,6 @@ Start with jscodeshift compatibility. Go further with pluggable parsers, pluggab
1919
[![jscodeshift compat](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/NaamuKim/zmod/main/.github/badges/compat.json)](./scripts/compat-check.ts)
2020
[![vs jscodeshift](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/NaamuKim/zmod/main/.github/badges/benchmark.json)](./benchmark/jscodeshift-compat.bench.ts)
2121

22-
## Why zmod?
23-
24-
| | jscodeshift | zmod |
25-
| ----------------- | ---------------- | --------------------- |
26-
| Speed | baseline | ~8x faster (oxc/Rust) |
27-
| Pluggable printer | ❌ (recast only) ||
28-
| Format-preserving || ✅ (span patching) |
29-
| Migration tooling || `@zmod/migrate` |
30-
| TypeScript-first | partial ||
31-
32-
## Install
33-
34-
```bash
35-
npm install zmod
36-
```
37-
3822
## Usage
3923

4024
### jscodeshift-compatible API
@@ -83,13 +67,19 @@ export const parser: Parser = {
8367

8468
`run()` picks up `export const parser` automatically — same pattern as jscodeshift.
8569

86-
### Migrate from jscodeshift
70+
## Install & Migrate from jscodeshift
71+
72+
```bash
73+
npm install zmod
74+
```
75+
76+
Run the migration tool from your project root — no glob needed:
8777

8878
```bash
89-
npx @zmod/migrate "codemods/**/*.ts"
79+
npx @zmod/migrate
9080
```
9181

92-
Automatically converts jscodeshift imports, renames, and string parser aliases.
82+
Automatically scans `**/*.{ts,tsx,js,jsx}` (excluding `node_modules`) and converts jscodeshift imports, renames, and string parser aliases.
9383

9484
## Benchmark
9585

packages/migrate/src/cli.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,9 @@ const main = defineCommand({
5454

5555
p.intro("@zmod/migrate");
5656

57-
let pattern = args.pattern as string | undefined;
58-
if (!pattern) {
59-
const input = await p.text({
60-
message: "Which files do you want to migrate?",
61-
placeholder: "codemods/**/*.ts",
62-
validate: (v) => (!v ? "Please enter a glob pattern" : undefined),
63-
});
64-
if (p.isCancel(input)) {
65-
p.cancel("Cancelled.");
66-
process.exit(0);
67-
}
68-
pattern = input;
69-
}
57+
const pattern = (args.pattern as string | undefined) ?? "**/*.{ts,tsx,js,jsx}";
7058

71-
const files = await glob([pattern], { absolute: true });
59+
const files = await glob([pattern], { absolute: true, ignore: ["**/node_modules/**"] });
7260

7361
if (files.length === 0) {
7462
p.outro("No files matched the pattern.");

0 commit comments

Comments
 (0)