|
| 1 | +--- |
| 2 | +title: 'Codemod CLI' |
| 3 | +description: 'Orchestrate large-scale code migrations with Codemod CLI.' |
| 4 | +icon: 'terminal' |
| 5 | +--- |
| 6 | + |
| 7 | +Codemod CLI (new) is accessible using the `npx codemod@next` command. The following commands and options are available: |
| 8 | + |
| 9 | +- `workflow` — Manage workflows (see subcommands below) |
| 10 | +- `jssg` — JavaScript ast-grep execution (see subcommands below) |
| 11 | +- `init` — Initialize a new workflow project |
| 12 | +- `login` — Login to a registry |
| 13 | +- `logout` — Logout from a registry |
| 14 | +- `whoami` — Show current authentication status |
| 15 | +- `publish` — Publish a workflow |
| 16 | +- `search` — Search for packages in the registry |
| 17 | +- `run` — Run a codemod from the registry |
| 18 | +- `cache` — Manage package cache (see subcommands below) |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +### `codemod@next workflow` |
| 23 | + |
| 24 | +Manage and execute workflow YAMLs. |
| 25 | + |
| 26 | +<ResponseField name="workflow run"> |
| 27 | + Run a workflow. |
| 28 | +</ResponseField> |
| 29 | +```bash |
| 30 | +npx codemod@next workflow run -w <workflow.yaml|directory> [--param key=value] |
| 31 | +``` |
| 32 | +- `-w, --workflow <PATH>` (string) — Path to workflow file or directory. (required) |
| 33 | +- `--param <KEY=VALUE>` (string) — Workflow parameters (format: key=value). |
| 34 | + |
| 35 | +<ResponseField name="workflow resume"> |
| 36 | + Resume a paused workflow. |
| 37 | +</ResponseField> |
| 38 | +```bash |
| 39 | +npx codemod@next workflow resume -i <ID> [-t <TASK>] [--trigger-all] |
| 40 | +``` |
| 41 | +- `-i, --id <ID>` (string) — Workflow run ID. (required) |
| 42 | +- `-t, --task <TASK>` (string) — Task ID to trigger (can be specified multiple times). |
| 43 | +- `--trigger-all` (boolean) — Trigger all awaiting tasks. |
| 44 | + |
| 45 | +<ResponseField name="workflow validate"> |
| 46 | + Validate a workflow file. |
| 47 | +</ResponseField> |
| 48 | +```bash |
| 49 | +npx codemod@next workflow validate -w <workflow.yaml> |
| 50 | +``` |
| 51 | +- `-w, --workflow <FILE>` (string) — Path to workflow file. (required) |
| 52 | + |
| 53 | +| Check | Ensures | |
| 54 | +|-----------------------------|-----------------------------------------| |
| 55 | +| Schema validation | YAML matches the workflow spec | |
| 56 | +| Unique IDs | Node & template IDs are unique | |
| 57 | +| Dependency validation | Every `depends_on` exists | |
| 58 | +| Cyclic dependency detection | DAG has no cycles | |
| 59 | +| Template references | All `template:` IDs exist | |
| 60 | +| Matrix validation | `from_state` matches schema | |
| 61 | +| State schema validation | `state.schema` is valid | |
| 62 | +| Variable syntax | `${{…}}` uses `params`, `env`, `state` | |
| 63 | + |
| 64 | +<Info> |
| 65 | + <b>Why validate?</b> Validation catches issues before execution, saving time and preventing runtime errors. |
| 66 | +</Info> |
| 67 | + |
| 68 | +<ResponseField name="workflow status"> |
| 69 | + Show workflow run status. |
| 70 | +</ResponseField> |
| 71 | +```bash |
| 72 | +npx codemod@next workflow status -i <ID> |
| 73 | +``` |
| 74 | +- `-i, --id <ID>` (string) — Workflow run ID. (required) |
| 75 | + |
| 76 | +<ResponseField name="workflow list"> |
| 77 | + List workflow runs. |
| 78 | +</ResponseField> |
| 79 | +```bash |
| 80 | +npx codemod@next workflow list [-l <LIMIT>] |
| 81 | +``` |
| 82 | +- `-l, --limit <LIMIT>` (number) — Number of workflow runs to show. (default: 10) |
| 83 | + |
| 84 | +<ResponseField name="workflow cancel"> |
| 85 | + Cancel a workflow run. |
| 86 | +</ResponseField> |
| 87 | +```bash |
| 88 | +npx codemod@next workflow cancel -i <ID> |
| 89 | +``` |
| 90 | +- `-i, --id <ID>` (string) — Workflow run ID. (required) |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +### `codemod@next jssg` |
| 95 | + |
| 96 | +See [this page](/cli/jssg) for full details and options for running and testing jssg codemods. |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +### `codemod@next init` |
| 101 | + |
| 102 | +Initialize a new workflow project. |
| 103 | +```bash |
| 104 | +npx codemod@next init [PATH] [options] |
| 105 | +``` |
| 106 | +<ResponseField name="[PATH]" type="string"> |
| 107 | + Project directory name. |
| 108 | +</ResponseField> |
| 109 | +<ResponseField name="--name <NAME>" type="string"> |
| 110 | + Project name (defaults to directory name). |
| 111 | +</ResponseField> |
| 112 | +<ResponseField name="--project-type <PROJECT_TYPE>" type="string"> |
| 113 | + Project type: `shell`, `ast-grep-js`, `ast-grep-yaml`. |
| 114 | +</ResponseField> |
| 115 | +<ResponseField name="--language <LANGUAGE>" type="string"> |
| 116 | + Target language. |
| 117 | +</ResponseField> |
| 118 | +<ResponseField name="--description <DESCRIPTION>" type="string"> |
| 119 | + Project description. |
| 120 | +</ResponseField> |
| 121 | +<ResponseField name="--author <AUTHOR>" type="string"> |
| 122 | + Author name and email. |
| 123 | +</ResponseField> |
| 124 | +<ResponseField name="--license <LICENSE>" type="string"> |
| 125 | + License. |
| 126 | +</ResponseField> |
| 127 | +<ResponseField name="--private" type="boolean"> |
| 128 | + Make package private. |
| 129 | +</ResponseField> |
| 130 | +<ResponseField name="--force" type="boolean"> |
| 131 | + Overwrite existing files. |
| 132 | +</ResponseField> |
| 133 | +<ResponseField name="--no-interactive" type="boolean"> |
| 134 | + Use defaults without prompts. |
| 135 | +</ResponseField> |
| 136 | + |
| 137 | +### `codemod@next login` |
| 138 | + |
| 139 | +Login to a registry. |
| 140 | +```bash |
| 141 | +npx codemod@next login [--registry <REGISTRY>] [--scope <SCOPE>] |
| 142 | +``` |
| 143 | +<ResponseField name="--registry <REGISTRY>" type="string"> |
| 144 | + Registry URL. |
| 145 | +</ResponseField> |
| 146 | +<ResponseField name="--scope <SCOPE>" type="string"> |
| 147 | + Organization or user scope for publishing. |
| 148 | +</ResponseField> |
| 149 | + |
| 150 | +### `codemod@next logout` |
| 151 | + |
| 152 | +Logout from a registry. |
| 153 | +```bash |
| 154 | +npx codemod@next logout [--registry <REGISTRY>] [--all] |
| 155 | +``` |
| 156 | +<ResponseField name="--registry <REGISTRY>" type="string"> |
| 157 | + Registry URL to logout from. |
| 158 | +</ResponseField> |
| 159 | +<ResponseField name="--all" type="boolean"> |
| 160 | + Logout from all registries. |
| 161 | +</ResponseField> |
| 162 | + |
| 163 | +### `codemod@next whoami` |
| 164 | + |
| 165 | +Show current authentication status. |
| 166 | +```bash |
| 167 | +npx codemod@next whoami [--registry <REGISTRY>] [--detailed] |
| 168 | +``` |
| 169 | +<ResponseField name="--registry <REGISTRY>" type="string"> |
| 170 | + Registry URL to check. |
| 171 | +</ResponseField> |
| 172 | +<ResponseField name="--detailed" type="boolean"> |
| 173 | + Show detailed information including token scopes. |
| 174 | +</ResponseField> |
| 175 | + |
| 176 | +### `codemod@next publish` |
| 177 | + |
| 178 | +Publish a workflow to a registry. |
| 179 | +```bash |
| 180 | +npx codemod@next publish [PATH] [options] |
| 181 | +``` |
| 182 | +<ResponseField name="[PATH]" type="string"> |
| 183 | + Path to codemod directory. |
| 184 | +</ResponseField> |
| 185 | +<ResponseField name="--version <VERSION>" type="string"> |
| 186 | + Explicit version override. |
| 187 | +</ResponseField> |
| 188 | +<ResponseField name="--registry <REGISTRY>" type="string"> |
| 189 | + Target registry URL. |
| 190 | +</ResponseField> |
| 191 | +<ResponseField name="--tag <TAG>" type="string"> |
| 192 | + Tag for the release. |
| 193 | +</ResponseField> |
| 194 | +<ResponseField name="--access <ACCESS>" type="string"> |
| 195 | + Access level (`public`, `private`). |
| 196 | +</ResponseField> |
| 197 | +<ResponseField name="--dry-run" type="boolean"> |
| 198 | + Validate and pack without uploading. |
| 199 | +</ResponseField> |
| 200 | + |
| 201 | +### `codemod@next search` |
| 202 | + |
| 203 | +#### `codemod@next search` |
| 204 | + |
| 205 | +Search for packages in the registry. |
| 206 | +```bash |
| 207 | +npx codemod@next search [QUERY] [options] |
| 208 | +``` |
0 commit comments