@vzn/vx-migrate 0.0.510 → 0.0.512

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -213,9 +213,8 @@ It is the one command a repo needs (`pnpx @vzn/vx-migrate` in a pnpm repo works
213
213
 
214
214
  - In a terminal it asks which adoption you want: **native** (the default, a `vx.config.ts` per package) or **keep** (the workspace file `vx init` writes, declaring `turbo()` or `nx()`). `--native` / `--keep` answer it; with no terminal (CI, a pipe) it is native.
215
215
  - It installs what the written files import with the repo's own manager (`packageManager`, else the lockfile): `@vzn/vx`, plus `@vzn/vx-migrate` for keep (`pnpm add -D -w`, `yarn add -D -W` on Yarn 1 and without `-W` on Yarn 2+, `bun add -d`, `npm install -D`). A package already listed or installed is left alone; `--no-install` skips it.
216
- - A root `package.json` script that is only `turbo run <tasks>` or `nx run-many -t <tasks>` becomes `vx run <tasks> --all`, so `pnpm run build` runs vx. A script with flags or a chain is left as it is.
217
216
 
218
- `--dry` does none of the three, and says what it would install and change.
217
+ Your `package.json` scripts are never edited. `--dry` installs nothing and says what it would install.
219
218
 
220
219
  `--dry` prints the files instead of writing them; `--force` overwrites existing ones; `--mjs` writes `vx.config.mjs` (and `vx-preset.mjs`) instead of `.ts` — the same objects with no type import and no `satisfies`, for a package whose own `tsconfig` includes every `.ts` under it and would compile the config into its dist (TanStack/query, 2026-09-11).
221
220
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vzn/vx-migrate",
3
- "version": "0.0.510",
3
+ "version": "0.0.512",
4
4
  "license": "MIT",
5
5
  "description": "Adopt @vzn/vx from Turborepo or Nx: run the repo unchanged, migrate it to vx.config.ts, and keep your Turbo or Nx remote cache",
6
6
  "keywords": [
@@ -39,7 +39,7 @@
39
39
  "access": "public"
40
40
  },
41
41
  "peerDependencies": {
42
- "@vzn/vx": "^0.0.510"
42
+ "@vzn/vx": "^0.0.512"
43
43
  },
44
44
  "repository": {
45
45
  "type": "git",
package/src/adopt.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  // What `vx-migrate` does around the mapping so the repo runs vx after it:
2
2
  // which kind of adoption (native configs, or the runner's config read live),
3
- // installing vx with the repo's own package manager, and pointing the root
4
- // scripts that called the runner at vx (solidjs/solid, 2026-10-04: the
5
- // configs were written, and `pnpm run build` still ran turbo, with no vx
6
- // installed to run them).
3
+ // and installing vx with the repo's own package manager (solidjs/solid,
4
+ // 2026-10-04: the configs were written with no vx installed to run them).
5
+ // The repo's own scripts are never edited (owner, 2026-10-06).
7
6
 
8
7
  import { existsSync, readFileSync } from 'node:fs'
9
8
  import path from 'node:path'
@@ -122,55 +121,3 @@ export async function install(root: string, packages: readonly string[]): Promis
122
121
  }
123
122
  return line
124
123
  }
125
-
126
- /**
127
- * A root script that is only `turbo run <tasks>`, or
128
- * Nx's `nx run-many -t <tasks>`, as the same run under vx. Flags, a chain or
129
- * anything else is left alone: only what reads the same both ways is moved.
130
- */
131
- export function vxScript(command: string): string | undefined {
132
- const words = command.trim().split(/\s+/)
133
- let tasks: string[] | undefined
134
- // `turbo <tasks>` is left: `turbo watch dev` is a verb, not a task.
135
- if (words[0] === 'turbo' && words[1] === 'run') {
136
- const rest = words.slice(2)
137
- if (rest.length > 0 && rest.every((w) => /^[\w:.@/-]+$/.test(w) && !w.startsWith('-')))
138
- tasks = rest
139
- } else if (words[0] === 'nx' && words[1] === 'run-many') {
140
- const rest = words.slice(2)
141
- if (
142
- (rest[0] === '-t' || rest[0] === '--target' || rest[0] === '--targets') &&
143
- rest.length === 2
144
- )
145
- tasks = rest[1]!.split(',')
146
- else if (rest.length === 1 && /^--targets?=/.test(rest[0]!))
147
- tasks = rest[0]!.replace(/^--targets?=/, '').split(',')
148
- if (tasks?.some((t) => !/^[\w:.@/-]+$/.test(t))) tasks = undefined
149
- }
150
- return tasks === undefined ? undefined : `vx run ${tasks.join(' ')} --all`
151
- }
152
-
153
- /**
154
- * Point the root package.json scripts that call the runner at vx, editing
155
- * the text in place (key order, indent and the rest kept). Returns each
156
- * `name: old → new`; writes nothing under `dry`.
157
- */
158
- export async function rewriteRootScripts(root: string, dry: boolean): Promise<string[]> {
159
- const file = path.join(root, 'package.json')
160
- let text = readText(file)
161
- const scripts = (JSON.parse(text || '{}') as { scripts?: Record<string, unknown> }).scripts ?? {}
162
- const changed: string[] = []
163
- for (const [name, value] of Object.entries(scripts)) {
164
- if (typeof value !== 'string') continue
165
- const next = vxScript(value)
166
- if (next === undefined) continue
167
- const key = JSON.stringify(name).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
168
- const old = JSON.stringify(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
169
- const re = new RegExp(`(${key}\\s*:\\s*)${old}`)
170
- if (!re.test(text)) continue
171
- text = text.replace(re, (_, lead: string) => `${lead}${JSON.stringify(next)}`)
172
- changed.push(`${name}: ${value} → ${next}`)
173
- }
174
- if (!dry && changed.length > 0) await Bun.write(file, text)
175
- return changed
176
- }
package/src/migrate.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  // `vx-migrate [--from turbo|nx] [--native|--keep] [--no-install] [--dry]
2
2
  // [--force] [--mjs]` — one vx.config.ts per workspace package from an
3
3
  // existing Turbo or Nx setup (`--keep`: the workspace file that reads it
4
- // live instead, as `vx init` writes it), vx installed with the repo's
5
- // manager, and the root scripts that called the runner pointed at vx.
4
+ // live instead, as `vx init` writes it), and vx installed with the repo's
5
+ // manager.
6
6
  // Without either mode flag a terminal is asked; anything else is native. Source auto-detect: turbo.json → Turbo;
7
7
  // .nx/workspace-data/project-graph.json or nx.json → Nx (the resolved graph, exported by nx if absent);
8
8
  // The mappers return a plan; core's migration seam
@@ -31,7 +31,6 @@ import {
31
31
  missingPackages,
32
32
  MODE_QUESTION,
33
33
  parseModeAnswer,
34
- rewriteRootScripts,
35
34
  } from './adopt.js'
36
35
  import { migrateTurbo } from './migrate-turbo.js'
37
36
  import { turboConfigFile } from './turbo/turbo-map.js'
@@ -219,9 +218,8 @@ async function askMode(runner: 'turbo' | 'nx', dry: boolean): Promise<AdoptionMo
219
218
  }
220
219
 
221
220
  /**
222
- * Install what the written files import and point the root scripts at vx.
223
- * Returns the report's lines for both; does neither under `--dry` (the
224
- * script lines say what would change).
221
+ * Install what the written files import. Returns the report's line;
222
+ * installs nothing under `--dry`.
225
223
  */
226
224
  async function prepareRepo(root: string, mode: AdoptionMode, args: MigrateArgs): Promise<string[]> {
227
225
  const notes: string[] = []
@@ -230,12 +228,6 @@ async function prepareRepo(root: string, mode: AdoptionMode, args: MigrateArgs):
230
228
  if (args.dry) notes.push(`would install ${missing.join(' ')} (dry run)`)
231
229
  else notes.push(`installed ${missing.join(' ')} (${await install(root, missing)})`)
232
230
  }
233
- const scripts = await rewriteRootScripts(root, args.dry)
234
- if (scripts.length > 0) {
235
- notes.push(
236
- `${args.dry ? 'would point' : 'pointed'} root package.json scripts at vx: ${scripts.join('; ')}`,
237
- )
238
- }
239
231
  return notes
240
232
  }
241
233