@vzn/vx-migrate 0.0.594 → 0.0.595
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 +8 -6
- package/package.json +2 -2
- package/src/glob-grammar.ts +20 -6
- package/src/migrate-nx.ts +37 -17
- package/src/migrate.ts +115 -15
- package/src/nx/nx-inputs.ts +3 -7
- package/src/nx-env.cjs +4 -1
- package/src/nx-exec.cjs +4 -1
- package/src/tracked-outputs.ts +36 -2
- package/src/turbo/turbo-map.ts +11 -18
- package/src/turbo-cache/index.ts +18 -2
- package/src/workspace-plugins.ts +2 -0
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ Rules:
|
|
|
55
55
|
- **Definition order**: root `pkg#name` if there is one, else root `name` (the first replaces the second whole, as Turbo looks it up), then each package config its own `turbo.json` extends (`"extends": ["//", "shared"]`, read by Turbo 2.11, refused by 2.5; nearest last, a parent missing or a cycle refused as Turbo refuses it) and its own, each winning field by field, except an overlay array holding `$TURBO_EXTENDS$` (Turbo 2.5+), which is the inherited list plus the overlay's other entries (`inputs: ["$TURBO_EXTENDS$", "config.json"]`).
|
|
56
56
|
- **The command is the script body** with its `pre<name>` / `post<name>` hooks folded in, in that order, through core's `foldScriptHooks`: each part in its own subshell, the chain stopping at the first that fails, forwarded `--` args reaching the body alone (npm and pnpm run them around `<name>` without being asked; novu's `prebuild` copies the CSS its `build` inlines), one process less per task than `pnpm run <name>` — except a body that calls yarn's `run` builtin (`run -T rollup -c`, `run clean && run build`; yarn ≥ 2 runs scripts in its own shell), which is `run: command not found` in sh: it runs as `yarn run <name>`, as Turbo and Nx run it, and yarn ≥ 2 runs no hooks, so none are folded there. A Yarn Plug'n'Play workspace (`.yarnrc.yml` with no `nodeLinker`, or `pnp`) has no `node_modules`: a dependency resolves only through `.pnp.cjs` and a bin only through yarn's shims, so there every script runs as `yarn run <name>`, and a `nodeLinker` change maps afresh. Same rules for `nx:run-script` below (strapi and novu, 2026-09-11).
|
|
57
57
|
- **Turbo 2.11's task `command`** (`futureFlags.experimentalTaskCommand`) wins over the script, as Turbo holds it: an argv is the command — each word quoted, run from the package dir, no `pre`/`post` hooks — and gives the package the task even with no script (turborepo's `@turbo/types#build`, `docs#schema`); `null` or `[]` is Turbo's no-op node, no task even where the script exists, its edges passed through; a per-toolchain map applies its `javascript` entry (or `typescript`, Turbo's alias), and without one the script runs. A shape Turbo would refuse keeps the script, with a todo.
|
|
58
|
-
- `dependsOn`: `^x` passes through when some package runs `x
|
|
58
|
+
- `dependsOn`: `^x` passes through when some package runs `x` or turbo.json defines it, and is dropped otherwise (core refuses a `^x` no project declares as a typo); `pkg#task` is kept only when `pkg` emits `task` (else a todo: edge dropped); a same-package task Turbo defines but the package has no script for is Turbo's no-op node, so its own edges pass through in its place (`test → codegen → ^build` with no `codegen` script is `test → ^build`); another package's `^x` or `pkg#x` reaches such a node through a group task when its edges name a task of its own package or another (with-tailwind's `ui` has no `build` script; its `build` builds `build:styles` and `build:components`, and `web#build` waits on them), and so does one whose `^` edge names another task (rallly's script-less `build` holds `^db:generate`), while one whose only edge is `^` to its own name needs none, since core's `^x` walks past a package without `x`; a no-op node nothing else reaches runs nothing, its own edges included, where Turbo still runs them (kitchen-sink's `turbo run test` builds `@repo/ui` for `admin`, which has no `test` script; `vx run test --all` does not, and `vx run build test --all` does both); a name Turbo does not define has no edge; `$TURBO_ROOT$` deps are a todo. A task turbo.json defines and no package has a script for (documenso's `lint`, shadcn-ui's `check`) is a group task in each package that defines it, its edges kept (a `pkg#task` edge only in `pkg`), so `vx run lint` runs Turbo's no-op nodes and exits 0 as `turbo run lint` does. Root `//#task`s run in the workspace root, as under Turbo: `turbo()` names the root a project through core's `discover` stage when turbo.json declares one (no `vx.config` needed; a root no member glob lists), and `//#x` in `dependsOn` is an edge to it, named by the root `package.json` `name`; a root task's globs are the workspace's (`workspaceFiles`), since Turbo hashes a root task over the whole repo; with no root project (a root `package.json` with no `name`, or one a package holds) they are a note and such an edge a todo. Turbo runs no plain task in the root package of a monorepo, and neither does `turbo()`; in a single-package repo (no workspaces, Turbo's `non-monorepo` example) turbo.json's plain tasks run on the root package, as under Turbo.
|
|
59
59
|
- A transit node (Turbo's documented pattern, its with-vitest example: `transit: { dependsOn: ["^transit"] }` with no script anywhere, and `test: { dependsOn: ["transit"] }`) is a key-only task in each package that defines it: it runs `true`, cached and keyed on its inputs, with its `^transit` edge, so a dependant's `test` re-keys on its dependencies' sources as Turbo re-hashes it. A `^` task that some package has a script for, or that nothing depends on, is no transit node. A package without the script of a `^` task others run gets the same key-only task, as Turbo hashes a no-op node there: an edit to it re-keys its dependants. A `build` whose only edge is `^build` is not written: core gives every project with no `build` that node (solid's three script-less packages each got a `build` running `true`).
|
|
60
60
|
- `with` (tasks Turbo runs alongside, `web#dev` with `api#dev`): an edge to each sidecar that is persistent, so vx starts the task once the sidecar has spawned and runs the sidecar only when the task runs; a sidecar that ends would be waited for, so it is a todo instead, and a pair that names each other keeps one edge (two would be a cycle). A task with no script whose `with` names persistent sidecars (Turbo's with-tailwind example: `ui` has no `dev` script, its `dev` starts `dev:styles` and `dev:components`) is a group task that depends on them.
|
|
61
61
|
- `inputs`: a structured entry (Turbo 2.11) is its `globs`, plus `**/*` with `withDefaults`, for `startup` and `jit` alike; `dependencyOutputs` adds none where the producer is cached (vx folds each dependency's key); from a `cache: false` producer (vercel/vercel's `//#generate:cache-keys`, which records the host) the named files, or its outputs, are a `cache.inputs.workspaceRuntime` probe, and `cache.inputs.tasks` leaves the producer out, so core answers the probe after it ran. Then: absent or `[]` → `**/*` (Turbo's default); `$TURBO_DEFAULT$` → `**/*`; exclusions alone narrow `**/*`; `$TURBO_ROOT$/<path>` → `cache.inputs.workspaceFiles` (negation kept); any other `$TURBO_ROOT$` use is a todo. `globalDependencies` and Turbo 1's `globalDotEnv` land in `workspaceFiles` too, and a task's Turbo 1 `dotEnv` in its `files`. Turbo 1's `$NAME` entries, in `globalDependencies` or a task's `dependsOn`, are env vars: they join `cache.inputs.env` and `exec.env.passThrough`. A package nested in the task's package (cal.com's apps inside `@calcom/app-store`) is hashed by Turbo with its parent, and core's globs stop at a project: each glob that reaches one is also listed in `cache.inputs.workspaceFiles`. Turbo's glob grammar is translated as Nx's is (`*.[jt]s` is `*.{[jt],j,t}s`); an input with no safe form widens to `**/*` with a todo. A `.env`-shaped input (`.env*`, `.env.local`, a task's Turbo 1 `dotEnv`, create-turbo's `globalDependencies: ["**/.env.*local"]`) is gitignored as a rule, so it is keyed by a probe that hashes the `.env` files it can name (`cache.inputs.runtime`) or, for a root entry, the files its root-relative globs name, hidden ones too, as Turbo's `*` matches them (`workspaceRuntime`; `**/<name>` is a `find -name` that skips `node_modules`, and another `**` walks the workspace), rather than as a file glob git never reports. A package whose `.env` globs all sit at its root gets a one-shell probe of that directory; one below the root walks the package.
|
|
@@ -64,7 +64,7 @@ Rules:
|
|
|
64
64
|
- Framework inference (Turbo hashes and passes Next's `NEXT_PUBLIC_*`, Vite's `VITE_*`, … for a package that depends on the framework): `turbo()` expands the prefix over the run's environment; the CLI writes the names the tracked source and `.env.example` of the package and its workspace dependencies spell (the bare prefix, as a `startsWith` test spells it, is none) (Next bundles theirs: cal.com's web, 23 alone, 58 with them), and a note asks for any only an installed dependency reads.
|
|
65
65
|
|
|
66
66
|
- **Two tasks of one package on one output path** (strapi's `build`, `build:code` and `build:types`, all on `dist/**`): vx cleans a task's outputs before it runs and before a restore, so the loader refuses two cached tasks whose outputs provably overlap. Under vx's default `rules.exclusiveOutputs` an edge between the two changes nothing (twenty's `build:individual` writing into `build`'s `dist`). The mapping resolves it before the file is written — the task with a `^` edge keeps its cache (the first declared when none has one); the rest run uncached with a todo naming the keeper and the fix, their own output path. Same rule for Nx targets.
|
|
67
|
-
- **A task whose inputs read another task's outputs** (a `test` keyed on `**/*` beside a `build` writing `dist/**`): vx's default `rules.upfrontKeys` refuses it, since such a key cannot be known before the producer ran. Each overlapping output is taken back from the reader's inputs with `!` (`['**/*', '!dist/**']`), in package and workspace inputs alike; Turbo and Nx hash what git tracks, and a build's outputs are not, so the key reads what the adopted tool read. A literal input another task writes cannot be taken back: that task runs uncached with a todo. A committed file under such an output is still a source: a reader the `!` would hide it from runs uncached with a todo. Same for Nx targets.
|
|
67
|
+
- **A task whose inputs read another task's outputs** (a `test` keyed on `**/*` beside a `build` writing `dist/**`): vx's default `rules.upfrontKeys` refuses it, since such a key cannot be known before the producer ran. Each overlapping output is taken back from the reader's inputs with `!` (`['**/*', '!dist/**']`), in package and workspace inputs alike; Turbo and Nx hash what git tracks, and a build's outputs are not, so the key reads what the adopted tool read. A literal input another task writes cannot be taken back: that task runs uncached with a todo. A committed file under such an output is still a source: a reader the `!` would hide it from runs uncached with a todo. An output that names one committed file (eslint's `eslint-suppressions.json` in a `lint` task's outputs) is dropped, and so is the `!` each reader got for it: the file stays in every key, as Turbo and Nx hash it, and the readers stay cached. Same for Nx targets.
|
|
68
68
|
- **Two packages' tasks on one workspace output** (cal.com's shared `post-install` writes `../../node_modules/@prisma/client/**` from every package with the script): core refuses two cached tasks on one path with no edge between them, so `turbo()` (and `nx()`) keeps the first (in package and task order) cached and runs the rest uncached, each with a todo naming the keeper. A package's own outputs count at their workspace path: typescript-eslint's root project caches `dist` and each package's typecheck `dist/packages/<name>`, one path twice. Edges across packages are not read, so an ordered pair loses its cache too.
|
|
69
69
|
- `cache: false` or `persistent: true` → no `cache` block; a persistent task gets `exec.persistent: {}` and, when some task depends on it, the consumer's `persistentTodo`.
|
|
70
70
|
- A task's `description` (Turbo 2.11.5's schema) is the vx task's `description`.
|
|
@@ -88,7 +88,7 @@ import { nx } from '@vzn/vx-migrate'
|
|
|
88
88
|
export default defineWorkspace({ plugins: [nx()] })
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
Until `bunx @vzn/vx-migrate` writes native config, `vx run build --all` maps every project's `build` target the way `nx run-many -t build` would. The plugin reads Nx's **resolved** project graph — where Nx has already applied `targetDefaults`, expanded `namedInputs`, inferred targets through its plugins and interpolated `{projectRoot}` and friends — so nothing is re-derived here. Per target: `nx:run-commands` and a plain `command` run as one shell line that does what Nx's run-commands does (below); `nx:run-script` is the package script, with the `$npm_package_name`, `$npm_package_version` and `$npm_lifecycle_event` it reads defined as `<pm> run` sets them (a migration reads the name and version from the manifest it imports, so a bump reaches them; any other `$npm_*` is a todo); `nx:noop` is a group task, and so is a target with neither an executor nor a command that has dependencies, as Nx normalizes it (one with none is dropped, as Nx drops it); **every other executor runs through `nx-exec`** with the executor and its options on the command line. A target Nx caches (`cache: true`, or the legacy `cacheableOperations` list in `nx.json`) gets its `inputs` / `outputs` as the cache block, with no `inputs` meaning Nx's `default` and `^default`, named inputs resolved per project (nx.json's under the project's own; one neither defines, such as an `extends` preset not installed, keys the whole project with a todo, never an empty list that keys the task on its config alone), `{workspaceRoot}` / `{projectRoot}` / `{projectName}` interpolated anywhere in a path as Nx does (`{workspaceRoot}/coverage/{projectRoot}`), Nx's glob grammar translated (`*.[jt]s` is `*.{j,t}s`; the default `production` negation `?(*.)+(spec|test).[jt]s?(x)` becomes brace sets, a narrowing only a negation may take; what has no safe form is a todo), a project fileset of negations alone (nx-recipes' `noMarkdown`) starting from every project file, as Nx reads it, and an output outside the project dir (`dist/<project>` at the workspace root, Nx's default layout) a `workspaceFiles` output, an output outside the workspace (an old generator's `reportsDirectory: "../../coverage/<lib>"`) a todo and dropped, as vx caches only inside it, an output whose first segment is a wildcard (`{projectRoot}/**/*.d.ts`) cached, with each committed file it reaches taken back by `!` and the rest cleaned before the run (typescript-eslint's `**/*.shot`, 3,656 committed snapshots, is past sixteen and runs uncached with a todo), and an output that covers the project's own `package.json` or vx.config cached with the file taken back by `!`; `dependsOn` becomes the edges (`^build` — dropped when no project has the target, as Nx gives it no edges and core refuses a `^name` nothing declares — `build`, `project:target` → `project#target`, everything past `project:` one target name, as Nx joins it (`ui:build:esm` is ui's `build:esm`; `ui:build:ci` names target `build:ci`, never `build`'s `ci` configuration, and is no edge where ui lacks it), this project's own target winning over a project name, `{ target, projects }` → each matched project's task, `projects` read as Nx's `findMatchingProjects` reads it: a name or a list of names, globs over names and over project directories (`libs/*`), `name:` / `tag:` / `directory:` labels, a bare word as a word in a name, and `!` exclusions; an edge to a target its project lacks is dropped without a word, as Nx drops it — `targetDefaults` that give every `typecheck` a `codegen` one project has; `^name` is every dependency's `name` whatever it holds, `^rsbuild:typecheck` included; a target glob — `test:e2e--*`, `^build-*`, `ui:build-{esm,cjs}`, a `{ target }` object's — expands over every target name in the workspace, as Nx 19.5+ does, before those rules; a same-project glob keeps its own project's matches), `{ env }` inputs pass through, `{ runtime }` inputs run at the workspace root as Nx runs them (`cache.inputs.workspaceRuntime`), a `{ fileset, includeIgnored: true }` literal (Nx 23 hashes it from disk, gitignored or missing) is read by such a probe, since vx's globs see only what git lists, and a glob of one is a todo, a target that says `continuous` — or, in a graph from an Nx older than that field, runs a server executor (`@nx/vite:dev-server`, `@nx/next:server`, …) — is a persistent task and never cached, ready on spawn as Nx has it (Nx starts the dependents once it has started; a run-commands `readyWhen` gates them, below). The target's name never decides: a cached `dev` caches like any other target (nx#32610). `parallelism: false` (Nx runs the target alone) has no vx form and is a todo naming `--concurrency 1`; `syncGenerators` (Nx runs them first) is one workspace note per generator list, counting its tasks and naming `nx sync`; nx.json's `sync.globalGenerators` is one note per run naming `nx sync`. A target with `configurations` is one task per configuration (one whose name another target holds, `vite`'s `build` beside an inferred `vite:build`, is not written, with a todo, as Nx resolves `a:vite:build` to the target): `build` carries the default configuration's options, `build:ci` the `ci` one, and an edge of `build:ci` (own, named or `^`) reaches each target's `ci` task where it declares one, else its default, as Nx's `resolveConfiguration` does; a `^build` there becomes one edge per dependency Nx links. A `^name` input (`^production`, `{ input, dependencies: true }`, the pre-17 `{ input, projects: "dependencies" }`; `projects: "self"` is the own input, as Nx 23 still reads both) is what Nx hashes: each dependency's `name`, over the project graph, whether or not a task edge exists. A `{ input, projects }` list is read as `dependsOn`'s `projects` is. Each project some reader reaches gets an `nx-input:<name>` task — `true`, cached, keyed on its own `name` input, depending on its Nx dependencies' twins (a project nothing reaches gets none) — and a task that reads `^name` depends on its direct dependencies' twins, so the whole closure folds into its key with each project hashed once. A dependency FILESET (`^{projectRoot}/tsconfig.lib.json`, `{ fileset, dependencies: true }`, which Nx's own inferred `typecheck` writes) folds the same way: its twin, `nx-input:fileset-<hash>` (a glob's `*` is no task name; the task's description names the fileset), keys on that fileset in each project. The twins show in a run's output; each costs about 0.16 ms of a warm run. A path input inside an output one of the project's own targets declares (TanStack/table's `public` input lists `{projectRoot}/dist`) is generated:
|
|
91
|
+
Until `bunx @vzn/vx-migrate` writes native config, `vx run build --all` maps every project's `build` target the way `nx run-many -t build` would. The plugin reads Nx's **resolved** project graph — where Nx has already applied `targetDefaults`, expanded `namedInputs`, inferred targets through its plugins and interpolated `{projectRoot}` and friends — so nothing is re-derived here. Per target: `nx:run-commands` and a plain `command` run as one shell line that does what Nx's run-commands does (below); `nx:run-script` is the package script, with the `$npm_package_name`, `$npm_package_version` and `$npm_lifecycle_event` it reads defined as `<pm> run` sets them (a migration reads the name and version from the manifest it imports, so a bump reaches them; any other `$npm_*` is a todo); `nx:noop` is a group task, and so is a target with neither an executor nor a command that has dependencies, as Nx normalizes it (one with none is dropped, as Nx drops it); **every other executor runs through `nx-exec`** with the executor and its options on the command line. A target Nx caches (`cache: true`, or the legacy `cacheableOperations` list in `nx.json`) gets its `inputs` / `outputs` as the cache block, with no `inputs` meaning Nx's `default` and `^default`, named inputs resolved per project (nx.json's under the project's own; one neither defines, such as an `extends` preset not installed, keys the whole project with a todo, never an empty list that keys the task on its config alone), `{workspaceRoot}` / `{projectRoot}` / `{projectName}` interpolated anywhere in a path as Nx does (`{workspaceRoot}/coverage/{projectRoot}`), Nx's glob grammar translated (`*.[jt]s` is `*.{j,t}s`; the default `production` negation `?(*.)+(spec|test).[jt]s?(x)` becomes brace sets, a narrowing only a negation may take; what has no safe form is a todo), a project fileset of negations alone (nx-recipes' `noMarkdown`) starting from every project file, as Nx reads it, and an output outside the project dir (`dist/<project>` at the workspace root, Nx's default layout) a `workspaceFiles` output, an output outside the workspace (an old generator's `reportsDirectory: "../../coverage/<lib>"`) a todo and dropped, as vx caches only inside it, an output whose first segment is a wildcard (`{projectRoot}/**/*.d.ts`) cached, with each committed file it reaches taken back by `!` and the rest cleaned before the run (typescript-eslint's `**/*.shot`, 3,656 committed snapshots, is past sixteen and runs uncached with a todo), and an output that covers the project's own `package.json` or vx.config cached with the file taken back by `!`; `dependsOn` becomes the edges (`^build` — dropped when no project has the target, as Nx gives it no edges and core refuses a `^name` nothing declares — `build`, `project:target` → `project#target`, everything past `project:` one target name, as Nx joins it (`ui:build:esm` is ui's `build:esm`; `ui:build:ci` names target `build:ci`, never `build`'s `ci` configuration, and is no edge where ui lacks it), this project's own target winning over a project name, `{ target, projects }` → each matched project's task, `projects` read as Nx's `findMatchingProjects` reads it: a name or a list of names, globs over names and over project directories (`libs/*`), `name:` / `tag:` / `directory:` labels, a bare word as a word in a name, and `!` exclusions; an edge to a target its project lacks is dropped without a word, as Nx drops it — `targetDefaults` that give every `typecheck` a `codegen` one project has; `^name` is every dependency's `name` whatever it holds, `^rsbuild:typecheck` included; a target glob — `test:e2e--*`, `^build-*`, `ui:build-{esm,cjs}`, a `{ target }` object's — expands over every target name in the workspace, as Nx 19.5+ does, before those rules; a same-project glob keeps its own project's matches), `{ env }` inputs pass through, `{ runtime }` inputs run at the workspace root as Nx runs them (`cache.inputs.workspaceRuntime`), a `{ fileset, includeIgnored: true }` literal (Nx 23 hashes it from disk, gitignored or missing) is read by such a probe, since vx's globs see only what git lists, and a glob of one is a todo, a target that says `continuous` — or, in a graph from an Nx older than that field, runs a server executor (`@nx/vite:dev-server`, `@nx/next:server`, …) — is a persistent task and never cached, ready on spawn as Nx has it (Nx starts the dependents once it has started; a run-commands `readyWhen` gates them, below). The target's name never decides: a cached `dev` caches like any other target (nx#32610). `parallelism: false` (Nx runs the target alone) has no vx form and is a todo naming `--concurrency 1`; `syncGenerators` (Nx runs them first) is one workspace note per generator list, counting its tasks and naming `nx sync`; nx.json's `sync.globalGenerators` is one note per run naming `nx sync`. A target with `configurations` is one task per configuration (one whose name another target holds, `vite`'s `build` beside an inferred `vite:build`, is not written, with a todo, as Nx resolves `a:vite:build` to the target): `build` carries the default configuration's options, `build:ci` the `ci` one, and an edge of `build:ci` (own, named or `^`) reaches each target's `ci` task where it declares one, else its default, as Nx's `resolveConfiguration` does; a `^build` there becomes one edge per dependency Nx links. A `^name` input (`^production`, `{ input, dependencies: true }`, the pre-17 `{ input, projects: "dependencies" }`; `projects: "self"` is the own input, as Nx 23 still reads both) is what Nx hashes: each dependency's `name`, over the project graph, whether or not a task edge exists. A `{ input, projects }` list is read as `dependsOn`'s `projects` is. Each project some reader reaches gets an `nx-input:<name>` task — `true`, cached, keyed on its own `name` input, depending on its Nx dependencies' twins (a project nothing reaches gets none) — and a task that reads `^name` depends on its direct dependencies' twins, so the whole closure folds into its key with each project hashed once. A dependency FILESET (`^{projectRoot}/tsconfig.lib.json`, `{ fileset, dependencies: true }`, which Nx's own inferred `typecheck` writes) folds the same way: its twin, `nx-input:fileset-<hash>` (a glob's `*` is no task name; the task's description names the fileset), keys on that fileset in each project. The twins show in a run's output; each costs about 0.16 ms of a warm run. A path input inside an output one of the project's own targets declares (TanStack/table's `public` input lists `{projectRoot}/dist`) is generated, and gitignored where Nx caches it: Nx's file map skips gitignored files, so Nx hashes nothing there (a changed `dist` file is a cache hit under Nx 23.3), and it is dropped without a todo, and the task that writes it keys its dependants through `dependsOn`.
|
|
92
92
|
|
|
93
93
|
| Option | Meaning |
|
|
94
94
|
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -202,7 +202,7 @@ Why the command carries the options: vx's key sees them (resolved-config hashing
|
|
|
202
202
|
## `bunx @vzn/vx-migrate` — write the configs
|
|
203
203
|
|
|
204
204
|
```bash
|
|
205
|
-
bunx @vzn/vx-migrate # auto-detect: turbo.json, .nx/workspace-data/project-graph.json or
|
|
205
|
+
bunx @vzn/vx-migrate # auto-detect: turbo.json, .nx/workspace-data/project-graph.json, nx.json or lerna.json
|
|
206
206
|
bunx @vzn/vx-migrate --dry # print the generated files + the report instead of writing
|
|
207
207
|
bunx @vzn/vx-migrate --force # overwrite existing vx.config.* / vx-preset.ts
|
|
208
208
|
bunx @vzn/vx-migrate --from nx # disambiguate when both runners are checked in
|
|
@@ -217,6 +217,8 @@ It is the one command a repo needs (`pnpx @vzn/vx-migrate` in a pnpm repo works
|
|
|
217
217
|
- With no `vx.workspace.*` yet, it writes one declaring the plugins the repo calls for (`src/workspace-plugins.ts`): the `@vzn/vx-lockfile` factory for the lockfile (`pnpm()`, `bun()`, `npm()`, `yarn()`), `scheduleHistoryPlugin()`, and `github()` when `.github/workflows` exists, from `@vzn/vx-ci`, each installed beside `@vzn/vx` at vx-migrate's own version. Keep adds them to the file `vx init` writes, or to one already in that shape; any other workspace file is the user's and left alone.
|
|
218
218
|
- 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 (the declared plugins are built into the vx binary, so none is installed) (`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 the root both lists and has installed at vx-migrate's own version is left alone; any other is installed at that version. `--no-install` skips it.
|
|
219
219
|
|
|
220
|
+
A Lerna repo is an Nx one: Lerna 6+ runs `lerna run` on Nx's task runner over the graph `nx graph` exports, nx.json or not, so a `lerna.json` with no nx.json and no turbo.json is mapped from that graph, and keep writes the workspace file declaring `nx()` (`vx init` adopts by nx.json, and would map the scripts). Lerna is the installed one, else the root manifest's range; with neither, the lerna.json is another tool's (lerna-lite reads it too, and runs no Nx). A root whose scripts never `lerna run` runs its tasks another way and publishes with Lerna (webdriverio: `run-s`, `pnpm -r`), so its scripts stay the source. Not where Lerna runs its own runner: `useNx: false`, or Lerna 5 without `useNx: true`; those are `vx init`'s scripts mapping. Beside turbo.json, Turbo runs the tasks and Lerna only publishes: turbo.json is the source.
|
|
221
|
+
|
|
220
222
|
Your `package.json` scripts are never edited. `--dry` installs nothing and says what it would install.
|
|
221
223
|
|
|
222
224
|
`--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).
|
|
@@ -238,7 +240,7 @@ Reads the root pipeline (`tasks` in Turbo 2, `pipeline` in Turbo 1), per-package
|
|
|
238
240
|
|
|
239
241
|
### Nx
|
|
240
242
|
|
|
241
|
-
Reads the **resolved** project graph only (`.nx/workspace-data/project-graph.json` when exported, else the one the workspace's own `nx graph` exports into a temp file, as `nx()` does), through the same mapper `nx()` runs live, executors aside (below). Targets Nx plugins infer at runtime are frozen as the snapshot saw them. `nx:run-commands` is the one shell line `nx()` runs (see [`nx:run-commands`](#nxrun-commands) above: where, parallel or in order, forwarded arguments, `env`, `readyWhen`) — storybook's `compile` is `cd ../../.. && node ./scripts/build/build-package.ts --cwd code/lib/cli`; a plain `command` is that shorthand; `nx:run-script` is the package's script body with its `pre<name>` / `post<name>` hooks folded in (or `yarn run <name>` when the body calls yarn's `run` builtin; an empty script is the placeholder with a todo), `nx:noop` is a group task; Nx 15–16's `@nrwl/workspace:run-commands` and `run-script` (and their `@nx/workspace:` names) are the `nx:` executors they re-exported; **an executor target is its `nx-exec` line**, as `nx()` runs it: the migrator translates no executor, so Nx and `@vzn/vx-migrate` stay installed until each such line is rewritten as the command it runs (a server executor Nx knows, `@nx/js:node` or a dev server, is still a persistent task). The report also says what `vx.workspace.ts` still holds, as the Turbo migration does: the `nx()` `vx init` declared, which keeps reading nx.json, and a lockfile with no `@vzn/vx-lockfile` plugin, where Nx keyed each project on the npm packages it depends on. A written command that still runs Nx itself (a run-commands `nx run b:build`, `npx nx test b`, a script's `nx exec -- tsc`) carries a TODO: it works only while Nx is installed. An Nx project no workspace glob lists (an integrated repo's `project.json` library) gets a `package.json` (`name`, `private`) where it has none, and a note names the directories to add to `workspaces` (or `pnpm-workspace.yaml`): core finds a project only through those globs, and the migrator never edits the root manifest. A target with `configurations` writes one task per configuration (`build`, `build:ci`). A project's Nx `tags` are written as its `tags`. Named inputs expand from `nx.json` when readable. An output path is kept as written, a `!` one too (`{projectRoot}/dist` → `dist`, `{projectRoot}/bin/tool` → `bin/tool`; one naming an unset `{options.x}` is dropped, as Nx drops it; a dotted `{options.outputPath.base}` walks the options, as Nx does; an extglob is put in vx's grammar: Next's inferred `.next/!(cache)/**/*` is `.next/*/**/*` with `!.next/cache/**/*`, `@(js|map)` is `{js,map}`, and a form with no vx spelling is dropped with a TODO): vx reads a bare path as the file or the whole tree under it, so a directory and an extensionless binary both save and restore. nx.json's `parallel`, `defaultBase` and `maxCacheSize`, which `nx()` applies live, are each a
|
|
243
|
+
Reads the **resolved** project graph only (`.nx/workspace-data/project-graph.json` when exported, else the one the workspace's own `nx graph` exports into a temp file, as `nx()` does), through the same mapper `nx()` runs live, executors aside (below). Targets Nx plugins infer at runtime are frozen as the snapshot saw them. `nx:run-commands` is the one shell line `nx()` runs (see [`nx:run-commands`](#nxrun-commands) above: where, parallel or in order, forwarded arguments, `env`, `readyWhen`) — storybook's `compile` is `cd ../../.. && node ./scripts/build/build-package.ts --cwd code/lib/cli`; a plain `command` is that shorthand; `nx:run-script` is the package's script body with its `pre<name>` / `post<name>` hooks folded in (or `yarn run <name>` when the body calls yarn's `run` builtin; an empty script is the placeholder with a todo), `nx:noop` is a group task; Nx 15–16's `@nrwl/workspace:run-commands` and `run-script` (and their `@nx/workspace:` names) are the `nx:` executors they re-exported; **an executor target is its `nx-exec` line**, as `nx()` runs it: the migrator translates no executor, so Nx and `@vzn/vx-migrate` stay installed until each such line is rewritten as the command it runs (a server executor Nx knows, `@nx/js:node` or a dev server, is still a persistent task). The report also says what `vx.workspace.ts` still holds, as the Turbo migration does: the `nx()` `vx init` declared, which keeps reading nx.json, and a lockfile with no `@vzn/vx-lockfile` plugin, where Nx keyed each project on the npm packages it depends on. A written command that still runs Nx itself (a run-commands `nx run b:build`, `npx nx test b`, a script's `nx exec -- tsc`) carries a TODO: it works only while Nx is installed. An Nx project no workspace glob lists (an integrated repo's `project.json` library) gets a `package.json` (`name`, `private`) where it has none, and a note names the directories to add to `workspaces` (or `pnpm-workspace.yaml`): core finds a project only through those globs, and the migrator never edits the root manifest. A target with `configurations` writes one task per configuration (`build`, `build:ci`). A project's Nx `tags` are written as its `tags`. Named inputs expand from `nx.json` when readable. An output path is kept as written, a `!` one too (`{projectRoot}/dist` → `dist`, `{projectRoot}/bin/tool` → `bin/tool`; one naming an unset `{options.x}` is dropped, as Nx drops it; a dotted `{options.outputPath.base}` walks the options, as Nx does; an extglob is put in vx's grammar: Next's inferred `.next/!(cache)/**/*` is `.next/*/**/*` with `!.next/cache/**/*`, `@(js|map)` is `{js,map}`, and a form with no vx spelling is dropped with a TODO): vx reads a bare path as the file or the whole tree under it, so a directory and an extensionless binary both save and restore. nx.json's `parallel`, `defaultBase` and `maxCacheSize`, which `nx()` applies live, are each a field of the `vx.workspace.ts` it writes (`concurrency`, `affectedBase`, `cacheRetention.maxSize`), read from nx.json alone, never the environment; beside a workspace file already there, or for a size vx cannot read (`1.5 GB`), each is a note naming the field to add. vx derives package edges from `package.json`; an Nx graph edge with no manifest path (`implicitDependencies`, a tsconfig path) becomes, for each `^target` of the dependant, an explicit `pkg#target` edge to what Nx's own walk reaches — each dependency that has the target, and through one that lacks it, its dependencies — so the order and the key are Nx's. The reverse too: where a project's manifest names a workspace package its Nx graph does not reach (an `implicitDependencies: ["!a"]` that breaks a manifest cycle), its `^target` becomes the explicit edges Nx draws, since vx's `^` would follow the manifest and bring the cycle back.
|
|
242
244
|
|
|
243
245
|
## `turboCache()` — a Turbo remote cache
|
|
244
246
|
|
|
@@ -309,7 +311,7 @@ The Nx spec has no existence probe, so `has` (the `--dry` prediction; the prefet
|
|
|
309
311
|
- A remote error degrades to a **miss** and a warning that names the request, the artifact and the server — `vx/turbo-cache: upload 32248a2a7c89e241 to https://cache.example.com/v8/artifacts failed: no answer within 60000 ms` — never the token. The run never fails because of the cache.
|
|
310
312
|
- The same failure is said once per run: an unreachable server fails the probe, the download and the upload alike, and the run prints the first and, at its end, `vx/turbo-cache: 2 more requests failed the same way: Unable to connect. Is the computer able to access the url?` (core's `LayeredCache` does the counting, for every cache plugin).
|
|
311
313
|
- A request answered `429` or `5xx` (not `501`), or one that never connected (a refused port, an unresolved host), is sent again after 2 s — a `429` after its `Retry-After`, capped at 10 s — as Turbo's client does. A spent deadline is not: it has already cost its wait.
|
|
312
|
-
- A refused token (`401`/`403`) warns **once** and turns the layer off for the rest of the process (
|
|
314
|
+
- A refused token (`401`/`403`) warns **once** and turns the layer off for the rest of the process (a `403` on an upload is a read-only token — Nx's spec, or turborepo-remote-cache's `READ_ONLY` and write-less JWTs: it turns off uploads alone, and reads go on) — including the requests already in flight when the refusal lands, which degrade in silence rather than repeating it (a six-project run printed five identical lines before 2026-09-20).
|
|
313
315
|
- Policy (`--cache=remote:r`, …) is enforced by core's `LayeredCache`, which the plugins wrap — a read-only token pairs naturally with `remote:r`.
|
|
314
316
|
- Each tool's own switches narrow that policy, never widen it, as they do for the tool: `TURBO_CACHE` (`--cache`'s syntax, an omitted source off) and `TURBO_REMOTE_CACHE_READ_ONLY` for `turboCache()`, `NX_SKIP_REMOTE_CACHE` / `NX_DISABLE_REMOTE_CACHE` (`true`) for `nxCache()`. A CI that keeps untrusted pull requests off the shared cache that way keeps vx off it too.
|
|
315
317
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vzn/vx-migrate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.595",
|
|
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.
|
|
42
|
+
"@vzn/vx": "^0.0.595"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
package/src/glob-grammar.ts
CHANGED
|
@@ -63,17 +63,21 @@ function classMembers(body: string): string[] | null {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
* `list` without a literal that one of its `!` entries takes back
|
|
67
|
-
* Nx and vx all subtract an exclusion wherever it
|
|
68
|
-
* never an input there either; vx refuses it at
|
|
69
|
-
* unchanged repo's run, so the adapters drop it.
|
|
66
|
+
* `list` without a literal that one of its `!` entries takes back, and
|
|
67
|
+
* without a repeat. Turbo, Nx and vx all subtract an exclusion wherever it
|
|
68
|
+
* sits, so such a file was never an input there either; vx refuses it at
|
|
69
|
+
* load, which would stop an unchanged repo's run, so the adapters drop it.
|
|
70
|
+
* A repeat adds nothing in any order: TanStack Query's `test:eslint` named
|
|
71
|
+
* `eslint.config.js` twice (`sharedGlobals` and its own), and the written
|
|
72
|
+
* config listed it twice.
|
|
70
73
|
*/
|
|
71
|
-
export function withoutTakenBack<T>(
|
|
74
|
+
export function withoutTakenBack<T>(entries: readonly T[]): T[] {
|
|
75
|
+
const list = [...new Set(entries)]
|
|
72
76
|
const wild = /[*?{}]/
|
|
73
77
|
const negative = list.flatMap((e) =>
|
|
74
78
|
typeof e === 'string' && e.startsWith('!') ? [e.slice(1)] : [],
|
|
75
79
|
)
|
|
76
|
-
if (negative.length === 0) return
|
|
80
|
+
if (negative.length === 0) return list
|
|
77
81
|
const globs = negative
|
|
78
82
|
.flatMap((n) => (wild.test(n) ? [n] : [n, `${n.replace(/\/+$/, '')}/**`]))
|
|
79
83
|
.map((g) => new Bun.Glob(g.replace(/^\.\//, '')))
|
|
@@ -83,3 +87,13 @@ export function withoutTakenBack<T>(list: readonly T[]): T[] {
|
|
|
83
87
|
return !globs.some((g) => g.match(lit))
|
|
84
88
|
})
|
|
85
89
|
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A path from the file system as a task glob that names only itself: a dir
|
|
93
|
+
* named `my{app}` read as a brace matched `myapp` instead. `[` `]` are
|
|
94
|
+
* literal in a task glob already; `*` and `?` stay, since the schema reads
|
|
95
|
+
* `\*` as a Windows separator, and they match the name too (a superset).
|
|
96
|
+
*/
|
|
97
|
+
export function literalGlob(p: string): string {
|
|
98
|
+
return p.replace(/^!|[{}]/g, '\\$&')
|
|
99
|
+
}
|
package/src/migrate-nx.ts
CHANGED
|
@@ -19,6 +19,8 @@ export async function migrateNx(
|
|
|
19
19
|
metas: readonly ProjectMeta[],
|
|
20
20
|
format: MigrationFormat = 'ts',
|
|
21
21
|
snapshot = path.join(root, NX_GRAPH_REL),
|
|
22
|
+
/** This run writes `vx.workspace.ts`, with nx.json's run settings as fields. */
|
|
23
|
+
writesWorkspace = false,
|
|
22
24
|
): Promise<MigrationPlan> {
|
|
23
25
|
const graph = parseNxGraph(await Bun.file(snapshot).text(), path.relative(root, snapshot))
|
|
24
26
|
const tracked = await trackedFiles(root)
|
|
@@ -64,7 +66,9 @@ export async function migrateNx(
|
|
|
64
66
|
notes: [
|
|
65
67
|
...mapped.notes,
|
|
66
68
|
...unlisted.notes,
|
|
67
|
-
...
|
|
69
|
+
...nxWorkspaceFields((await readNxJson(root).catch(() => null))?.json)
|
|
70
|
+
.filter((f) => !writesWorkspace || f.source === undefined)
|
|
71
|
+
.map((f) => f.note),
|
|
68
72
|
],
|
|
69
73
|
}
|
|
70
74
|
}
|
|
@@ -117,14 +121,24 @@ async function unlistedProjects(
|
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
123
|
|
|
124
|
+
/** A `vx.workspace.ts` field nx.json's run settings call for. */
|
|
125
|
+
export interface NxWorkspaceField {
|
|
126
|
+
readonly field: 'concurrency' | 'affectedBase' | 'cacheRetention'
|
|
127
|
+
/** The value as TypeScript source; undefined when vx cannot read it. */
|
|
128
|
+
readonly source: string | undefined
|
|
129
|
+
/** What to tell a user whose workspace file this run does not write. */
|
|
130
|
+
readonly note: string
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const quoted = (s: string) => `'${s.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`
|
|
134
|
+
|
|
120
135
|
/**
|
|
121
|
-
* nx.json's run-wide settings `nx()` applies live
|
|
122
|
-
* `vx.workspace.ts
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* for every machine, so `NX_PARALLEL` and friends are not read.
|
|
136
|
+
* nx.json's run-wide settings `nx()` applies live: each a field of the
|
|
137
|
+
* written `vx.workspace.ts`, or a migrated repo that ran one task at a time
|
|
138
|
+
* for a shared database ran on every core. nx.json only: the files are
|
|
139
|
+
* written for every machine, so `NX_PARALLEL` and friends are not read.
|
|
126
140
|
*/
|
|
127
|
-
function
|
|
141
|
+
export function nxWorkspaceFields(json: Record<string, unknown> | undefined): NxWorkspaceField[] {
|
|
128
142
|
const nx = json as
|
|
129
143
|
| {
|
|
130
144
|
parallel?: unknown
|
|
@@ -134,21 +148,27 @@ function workspaceNotes(json: Record<string, unknown> | undefined): string[] {
|
|
|
134
148
|
maxCacheSize?: unknown
|
|
135
149
|
}
|
|
136
150
|
| undefined
|
|
137
|
-
const out:
|
|
151
|
+
const out: NxWorkspaceField[] = []
|
|
138
152
|
const parallel = nx?.parallel ?? nx?.tasksRunnerOptions?.default?.options?.parallel
|
|
139
153
|
if (typeof parallel === 'number' && Number.isInteger(parallel) && parallel > 0)
|
|
140
|
-
out.push(
|
|
141
|
-
|
|
142
|
-
|
|
154
|
+
out.push({
|
|
155
|
+
field: 'concurrency',
|
|
156
|
+
source: String(parallel),
|
|
157
|
+
note: `nx.json \`parallel: ${parallel}\`: add \`concurrency: ${parallel}\` to vx.workspace.ts`,
|
|
158
|
+
})
|
|
143
159
|
const base = nx?.defaultBase ?? nx?.affected?.defaultBase
|
|
144
160
|
if (typeof base === 'string' && base.trim() !== '')
|
|
145
|
-
out.push(
|
|
146
|
-
|
|
147
|
-
|
|
161
|
+
out.push({
|
|
162
|
+
field: 'affectedBase',
|
|
163
|
+
source: quoted(base.trim()),
|
|
164
|
+
note: `nx.json \`defaultBase\` ${JSON.stringify(base.trim())}: add \`affectedBase: ${JSON.stringify(base.trim())}\` to vx.workspace.ts`,
|
|
165
|
+
})
|
|
148
166
|
const size = nxSizeText(nx?.maxCacheSize)
|
|
149
167
|
if (size !== undefined)
|
|
150
|
-
out.push(
|
|
151
|
-
|
|
152
|
-
|
|
168
|
+
out.push({
|
|
169
|
+
field: 'cacheRetention',
|
|
170
|
+
source: /^\d+[KMG]?B$/.test(size) ? `{ maxSize: ${quoted(size)} }` : undefined,
|
|
171
|
+
note: `nx.json \`maxCacheSize\`: add \`cacheRetention: { maxSize: ${JSON.stringify(size)} }\` to vx.workspace.ts`,
|
|
172
|
+
})
|
|
153
173
|
return out
|
|
154
174
|
}
|
package/src/migrate.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// live instead, as `vx init` writes it), and vx installed with the repo's
|
|
5
5
|
// manager.
|
|
6
6
|
// Without either mode flag a terminal is asked; anything else is native. Source auto-detect: turbo.json → Turbo;
|
|
7
|
-
// .nx/workspace-data/project-graph.json or
|
|
7
|
+
// .nx/workspace-data/project-graph.json, nx.json or a Lerna-on-Nx lerna.json → Nx (the resolved
|
|
8
|
+
// graph, exported by nx if absent);
|
|
8
9
|
// The mappers return a plan; core's migration seam
|
|
9
10
|
// (`applyMigration`) renders, guards, writes and reports, so what this
|
|
10
11
|
// package writes reads exactly like what `vx init` writes.
|
|
@@ -23,8 +24,9 @@ import {
|
|
|
23
24
|
type MigrationPlan,
|
|
24
25
|
UserError,
|
|
25
26
|
} from '@vzn/vx'
|
|
26
|
-
import { migrateNx, NX_GRAPH_REL } from './migrate-nx.js'
|
|
27
|
+
import { migrateNx, NX_GRAPH_REL, nxWorkspaceFields } from './migrate-nx.js'
|
|
27
28
|
import { exportGraph } from './nx/export-graph.js'
|
|
29
|
+
import { readNxJson } from './nx/nx-map.js'
|
|
28
30
|
import {
|
|
29
31
|
type AdoptionMode,
|
|
30
32
|
install,
|
|
@@ -41,6 +43,7 @@ import {
|
|
|
41
43
|
renderWorkspaceFile,
|
|
42
44
|
workspaceFileAt,
|
|
43
45
|
workspacePlugins,
|
|
46
|
+
type WorkspacePlugin,
|
|
44
47
|
} from './workspace-plugins.js'
|
|
45
48
|
|
|
46
49
|
export interface MigrateArgs {
|
|
@@ -124,13 +127,15 @@ export async function migrateCmd(args: readonly string[]): Promise<number> {
|
|
|
124
127
|
const hasTurbo = turboFile !== null
|
|
125
128
|
const hasGraph = await Bun.file(path.join(root, NX_GRAPH_REL)).exists()
|
|
126
129
|
const hasNxJson = await Bun.file(path.join(root, 'nx.json')).exists()
|
|
130
|
+
// A Turbo repo's lerna.json publishes; Turbo runs its tasks.
|
|
131
|
+
const lerna = !hasTurbo && !hasGraph && !hasNxJson && lernaOnNx(root)
|
|
127
132
|
|
|
128
133
|
// Evaluating teams routinely have two runners checked in — never
|
|
129
134
|
// ask anyone to delete anything; --from disambiguates.
|
|
130
135
|
const found = (
|
|
131
136
|
[
|
|
132
137
|
['turbo', hasTurbo, 'turbo.json'],
|
|
133
|
-
['nx', hasGraph || hasNxJson, 'an nx workspace'],
|
|
138
|
+
['nx', hasGraph || hasNxJson || lerna, 'an nx workspace'],
|
|
134
139
|
] as const
|
|
135
140
|
).filter(([, present]) => present)
|
|
136
141
|
if (parsed.from === undefined && found.length > 1) {
|
|
@@ -148,23 +153,26 @@ export async function migrateCmd(args: readonly string[]): Promise<number> {
|
|
|
148
153
|
}
|
|
149
154
|
|
|
150
155
|
const runner: 'turbo' | 'nx' | undefined =
|
|
151
|
-
parsed.from ?? (hasTurbo ? 'turbo' : hasGraph || hasNxJson ? 'nx' : undefined)
|
|
156
|
+
parsed.from ?? (hasTurbo ? 'turbo' : hasGraph || hasNxJson || lerna ? 'nx' : undefined)
|
|
152
157
|
if (runner === undefined) {
|
|
153
158
|
throw new UserError(
|
|
154
159
|
'nothing to migrate: no turbo.json and no Nx workspace — ' +
|
|
155
160
|
'for package.json scripts, run `vx init`',
|
|
156
161
|
)
|
|
157
162
|
}
|
|
158
|
-
const mode = parsed.mode ?? (await askMode(runner, parsed.dry))
|
|
159
|
-
if (mode === 'keep') return keep(root, runner, hasTurbo, parsed)
|
|
163
|
+
const mode = parsed.mode ?? (await askMode(runner, lerna ? 'lerna.json' : undefined, parsed.dry))
|
|
164
|
+
if (mode === 'keep') return keep(root, runner, hasTurbo, lerna, parsed)
|
|
160
165
|
|
|
161
166
|
const format: MigrationFormat = parsed.mjs ? 'mjs' : 'ts'
|
|
167
|
+
// No workspace file yet: this run writes one, declaring the plugins the
|
|
168
|
+
// repo calls for and the run settings nx.json holds.
|
|
169
|
+
const writesWorkspace = workspaceFileAt(root) === undefined
|
|
162
170
|
let source: string
|
|
163
171
|
let plan: MigrationPlan
|
|
164
172
|
if (runner === 'nx') {
|
|
165
173
|
if (hasGraph) {
|
|
166
174
|
source = NX_GRAPH_REL
|
|
167
|
-
plan = await migrateNx(root, metas, format)
|
|
175
|
+
plan = await migrateNx(root, metas, format, undefined, writesWorkspace)
|
|
168
176
|
} else {
|
|
169
177
|
// Modern Nx stores the graph in SQLite, so the JSON snapshot exists only
|
|
170
178
|
// when exported. The workspace's own nx exports it, as `nx()` does, into
|
|
@@ -180,7 +188,7 @@ export async function migrateCmd(args: readonly string[]): Promise<number> {
|
|
|
180
188
|
)
|
|
181
189
|
}
|
|
182
190
|
source = 'nx graph'
|
|
183
|
-
plan = await migrateNx(root, metas, format, snapshot)
|
|
191
|
+
plan = await migrateNx(root, metas, format, snapshot, writesWorkspace)
|
|
184
192
|
} finally {
|
|
185
193
|
await rm(tmp, { recursive: true, force: true })
|
|
186
194
|
}
|
|
@@ -201,16 +209,24 @@ export async function migrateCmd(args: readonly string[]): Promise<number> {
|
|
|
201
209
|
existsSync(path.join(p.dir, configName))),
|
|
202
210
|
) ||
|
|
203
211
|
plan.extraFiles.some((f) => existsSync(path.join(root, f.relPath))))
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
212
|
+
// Drop the note that told the user to declare the lockfile plugin.
|
|
213
|
+
const plugins = writesWorkspace ? workspacePlugins(root) : []
|
|
214
|
+
if (writesWorkspace) {
|
|
215
|
+
const fields =
|
|
216
|
+
runner === 'nx'
|
|
217
|
+
? nxWorkspaceFields((await readNxJson(root).catch(() => null))?.json).flatMap((f) =>
|
|
218
|
+
f.source === undefined ? [] : [{ field: f.field, source: f.source }],
|
|
219
|
+
)
|
|
220
|
+
: []
|
|
208
221
|
plan = {
|
|
209
222
|
...plan,
|
|
210
223
|
headerNotes: plan.headerNotes.filter((n) => !n.includes('from @vzn/vx-lockfile')),
|
|
211
224
|
extraFiles: [
|
|
212
225
|
...plan.extraFiles,
|
|
213
|
-
{
|
|
226
|
+
{
|
|
227
|
+
relPath: `vx.workspace.${format}`,
|
|
228
|
+
contents: renderWorkspaceFile(plugins, format, fields),
|
|
229
|
+
},
|
|
214
230
|
],
|
|
215
231
|
}
|
|
216
232
|
}
|
|
@@ -231,9 +247,13 @@ export async function migrateCmd(args: readonly string[]): Promise<number> {
|
|
|
231
247
|
}
|
|
232
248
|
|
|
233
249
|
/** A terminal is asked which adoption it wants; anything else gets native. */
|
|
234
|
-
async function askMode(
|
|
250
|
+
async function askMode(
|
|
251
|
+
runner: 'turbo' | 'nx',
|
|
252
|
+
file: string | undefined,
|
|
253
|
+
dry: boolean,
|
|
254
|
+
): Promise<AdoptionMode> {
|
|
235
255
|
if (dry || !process.stdin.isTTY || !process.stdout.isTTY) return 'native'
|
|
236
|
-
const source = runner === 'turbo' ? 'turbo.json' : 'nx.json'
|
|
256
|
+
const source = file ?? (runner === 'turbo' ? 'turbo.json' : 'nx.json')
|
|
237
257
|
for (;;) {
|
|
238
258
|
const mode = parseModeAnswer(prompt(MODE_QUESTION(runner, source)))
|
|
239
259
|
if (mode !== undefined) return mode
|
|
@@ -268,6 +288,7 @@ async function keep(
|
|
|
268
288
|
root: string,
|
|
269
289
|
runner: 'turbo' | 'nx',
|
|
270
290
|
hasTurbo: boolean,
|
|
291
|
+
lerna: boolean,
|
|
271
292
|
args: MigrateArgs,
|
|
272
293
|
): Promise<number> {
|
|
273
294
|
// `vx init` reads turbo.json first.
|
|
@@ -291,6 +312,9 @@ async function keep(
|
|
|
291
312
|
)) {
|
|
292
313
|
process.stdout.write(`vx-migrate: ${note}\n`)
|
|
293
314
|
}
|
|
315
|
+
// `vx init` adopts nx() by nx.json, and a Lerna repo may have none: it
|
|
316
|
+
// would map the scripts instead, so the file is written here.
|
|
317
|
+
if (lerna) return keepLerna(root, plugins, args)
|
|
294
318
|
// A resolve that misses from a directory with no node_modules is an
|
|
295
319
|
// auto-install under Bun: ask the root only where it has the package.
|
|
296
320
|
const installed = path.join(root, 'node_modules', '@vzn', 'vx')
|
|
@@ -316,3 +340,79 @@ async function keep(
|
|
|
316
340
|
}
|
|
317
341
|
return code
|
|
318
342
|
}
|
|
343
|
+
|
|
344
|
+
/** `--keep` in a Lerna repo with no nx.json: the workspace file declaring `nx()`. */
|
|
345
|
+
async function keepLerna(
|
|
346
|
+
root: string,
|
|
347
|
+
plugins: readonly WorkspacePlugin[],
|
|
348
|
+
args: MigrateArgs,
|
|
349
|
+
): Promise<number> {
|
|
350
|
+
const format = args.mjs ? 'mjs' : 'ts'
|
|
351
|
+
const name = `vx.workspace.${format}`
|
|
352
|
+
const existing = workspaceFileAt(root)
|
|
353
|
+
const all = [{ pkg: '@vzn/vx-migrate', factory: 'nx' }, ...plugins]
|
|
354
|
+
if (existing !== undefined && !args.force) {
|
|
355
|
+
const text = readFileSync(path.join(root, existing), 'utf8')
|
|
356
|
+
const extended = extendWorkspaceFile(text, all)
|
|
357
|
+
if (extended === null) {
|
|
358
|
+
throw new UserError(
|
|
359
|
+
`${existing} exists; add nx() from @vzn/vx-migrate to its plugins, or --force replaces it`,
|
|
360
|
+
)
|
|
361
|
+
}
|
|
362
|
+
if (!args.dry && extended !== text) await Bun.write(path.join(root, existing), extended)
|
|
363
|
+
const names = undeclared(text, all).map((p) => `${p.factory}()`)
|
|
364
|
+
if (names.length > 0)
|
|
365
|
+
process.stdout.write(
|
|
366
|
+
`vx-migrate: ${args.dry ? 'would declare' : 'declared'} ${names.join(', ')} in ${existing}\n`,
|
|
367
|
+
)
|
|
368
|
+
return 0
|
|
369
|
+
}
|
|
370
|
+
const text = renderWorkspaceFile(all, format)
|
|
371
|
+
if (args.dry) {
|
|
372
|
+
process.stdout.write(`── ${name} ──\n${text}\nvx-migrate: would write ${name} (dry run)\n`)
|
|
373
|
+
return 0
|
|
374
|
+
}
|
|
375
|
+
if (existing !== undefined && existing !== name) await rm(path.join(root, existing))
|
|
376
|
+
await Bun.write(path.join(root, name), text)
|
|
377
|
+
process.stdout.write(`vx-migrate: lerna.json found — wrote ${name} declaring nx()\n`)
|
|
378
|
+
return 0
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Lerna 6+ runs `lerna run` on Nx's task runner over the graph `nx graph`
|
|
383
|
+
* exports, nx.json or not, unless lerna.json says `useNx: false`; Lerna 5
|
|
384
|
+
* ran its own unless it said `useNx: true`. Lerna is the installed one,
|
|
385
|
+
* else the root manifest's range; with neither, the lerna.json is another
|
|
386
|
+
* tool's (lerna-lite reads it too, and runs no Nx). A repo whose root
|
|
387
|
+
* scripts never `lerna run` runs its tasks some other way and publishes
|
|
388
|
+
* with Lerna (webdriverio: `run-s`, `pnpm -r`): its scripts are the source.
|
|
389
|
+
*/
|
|
390
|
+
const LERNA_RUN = /(?:^|[\s;&|(])lerna\s+run\s/
|
|
391
|
+
|
|
392
|
+
function lernaOnNx(root: string): boolean {
|
|
393
|
+
const json = (file: string): Record<string, unknown> | undefined => {
|
|
394
|
+
try {
|
|
395
|
+
return JSON.parse(readFileSync(file, 'utf8')) as Record<string, unknown>
|
|
396
|
+
} catch {
|
|
397
|
+
return undefined
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
const config = json(path.join(root, 'lerna.json'))
|
|
401
|
+
if (config === undefined) return false
|
|
402
|
+
const installed = json(path.join(root, 'node_modules', 'lerna', 'package.json'))?.['version']
|
|
403
|
+
const manifest = json(path.join(root, 'package.json'))
|
|
404
|
+
const declared = ['devDependencies', 'dependencies']
|
|
405
|
+
.map((k) => (manifest?.[k] as Record<string, unknown> | undefined)?.['lerna'])
|
|
406
|
+
.find((v): v is string => typeof v === 'string')
|
|
407
|
+
const version = typeof installed === 'string' ? installed : declared
|
|
408
|
+
if (version === undefined) return false
|
|
409
|
+
const scripts = manifest?.['scripts']
|
|
410
|
+
const runs =
|
|
411
|
+
scripts !== null &&
|
|
412
|
+
typeof scripts === 'object' &&
|
|
413
|
+
Object.values(scripts).some((v) => typeof v === 'string' && LERNA_RUN.test(v))
|
|
414
|
+
if (!runs) return false
|
|
415
|
+
if (typeof config['useNx'] === 'boolean') return config['useNx']
|
|
416
|
+
const major = /\d+/.exec(version)?.[0]
|
|
417
|
+
return major === undefined || Number(major) >= 6
|
|
418
|
+
}
|
package/src/nx/nx-inputs.ts
CHANGED
|
@@ -68,13 +68,9 @@ export function expandNxInputs(
|
|
|
68
68
|
todos.push(`input ${JSON.stringify(entry)} uses a token vx does not support`)
|
|
69
69
|
return
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'list it, so vx cannot key on it — dropped; the task that writes it keys its dependants through dependsOn',
|
|
75
|
-
)
|
|
76
|
-
return
|
|
77
|
-
}
|
|
71
|
+
// Nx's file map skips gitignored files, so it hashes nothing here
|
|
72
|
+
// either: a changed `dist` file is a cache hit under Nx 23.3 (YL-1).
|
|
73
|
+
if (neg === '' && at.outputs?.some((o) => p === o || p.startsWith(`${o}/`))) return
|
|
78
74
|
const g = minimatchToVx(p, neg !== '')
|
|
79
75
|
if (g === null) {
|
|
80
76
|
todos.push(`input ${JSON.stringify(entry)}: glob syntax vx cannot take — map manually`)
|
package/src/nx-env.cjs
CHANGED
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
const { spawn, spawnSync } = require('node:child_process')
|
|
26
26
|
const { createRequire } = require('node:module')
|
|
27
27
|
const path = require('node:path')
|
|
28
|
-
const {
|
|
28
|
+
const { realpathSync } = require('node:fs')
|
|
29
|
+
// Through npm's `.bin` symlink under `--preserve-symlinks-main`, Node keeps
|
|
30
|
+
// the link as the main module, so a relative require would look in `.bin`.
|
|
31
|
+
const { loadTaskEnv } = require(path.join(path.dirname(realpathSync(__filename)), 'nx-dotenv.cjs'))
|
|
29
32
|
|
|
30
33
|
// `--envFile`, Nx's own option name, and not `--env-file`: Node 22 takes
|
|
31
34
|
// `--env-file` from anywhere on its command line, the script's arguments
|
package/src/nx-exec.cjs
CHANGED
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
|
|
22
22
|
const { createRequire, enableCompileCache } = require('node:module')
|
|
23
23
|
const path = require('node:path')
|
|
24
|
-
const {
|
|
24
|
+
const { realpathSync } = require('node:fs')
|
|
25
|
+
// Through npm's `.bin` symlink under `--preserve-symlinks-main`, Node keeps
|
|
26
|
+
// the link as the main module, so a relative require would look in `.bin`.
|
|
27
|
+
const { loadTaskEnv } = require(path.join(path.dirname(realpathSync(__filename)), 'nx-dotenv.cjs'))
|
|
25
28
|
|
|
26
29
|
// Nx's module graph is ~150 ms of every executed task; Node's on-disk
|
|
27
30
|
// compile cache (22.1+, a no-op below) takes ~30 of them back on the
|
package/src/tracked-outputs.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { lstat, readFile } from 'node:fs/promises'
|
|
11
11
|
import path from 'node:path'
|
|
12
|
-
import { outputsOverlap } from '@vzn/vx'
|
|
12
|
+
import { isLiteralPattern, outputsOverlap } from '@vzn/vx'
|
|
13
13
|
|
|
14
14
|
/** The files git tracks under `root`, root-relative; null outside a repo or without git. */
|
|
15
15
|
export async function trackedFiles(root: string): Promise<string[] | null> {
|
|
@@ -216,6 +216,27 @@ export function spareTrackedOutputs(
|
|
|
216
216
|
tracked: readonly string[],
|
|
217
217
|
): [string, string][] {
|
|
218
218
|
const todos: [string, string][] = []
|
|
219
|
+
const trackedSet = new Set(tracked)
|
|
220
|
+
/** Drop the `!` entries readers carry for a committed file no output names any more. */
|
|
221
|
+
const unhide = (owner: (typeof projects)[number] | null, rooted: string) => {
|
|
222
|
+
for (const q of projects) {
|
|
223
|
+
const qrel = path.relative(root, q.dir).split(path.sep).join('/')
|
|
224
|
+
for (const r of q.tasks) {
|
|
225
|
+
const inputs = (r.task?.['cache'] as { inputs?: Outputs } | undefined)?.inputs
|
|
226
|
+
if (inputs === undefined) continue
|
|
227
|
+
const own =
|
|
228
|
+
q === owner &&
|
|
229
|
+
Array.isArray(inputs.files) &&
|
|
230
|
+
(qrel === '' || rooted.startsWith(`${qrel}/`))
|
|
231
|
+
? rooted.slice(qrel === '' ? 0 : qrel.length + 1)
|
|
232
|
+
: undefined
|
|
233
|
+
if (own !== undefined)
|
|
234
|
+
inputs.files = (inputs.files as unknown[]).filter((g) => g !== `!${own}`)
|
|
235
|
+
if (Array.isArray(inputs.workspaceFiles))
|
|
236
|
+
inputs.workspaceFiles = inputs.workspaceFiles.filter((g) => g !== `!${rooted}`)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
219
240
|
for (const p of projects) {
|
|
220
241
|
const rel = path.relative(root, p.dir).split(path.sep).join('/')
|
|
221
242
|
const own = rel === '' ? tracked : filesUnder(tracked, rel).map((f) => f.slice(rel.length + 1))
|
|
@@ -229,7 +250,20 @@ export function spareTrackedOutputs(
|
|
|
229
250
|
] as const) {
|
|
230
251
|
const globs = outputs[key]
|
|
231
252
|
if (!Array.isArray(globs) || globs.length === 0) continue
|
|
232
|
-
|
|
253
|
+
let strings = globs.filter((g): g is string => typeof g === 'string')
|
|
254
|
+
// An output naming one committed file (eslint's
|
|
255
|
+
// `eslint-suppressions.json`) is a source: its `!` would take the
|
|
256
|
+
// whole entry back, so the entry goes, and so does the `!` a
|
|
257
|
+
// reader's inputs got for it, or every reader ran uncached (hono).
|
|
258
|
+
const rootedOf = (g: string) => (key === 'files' && rel !== '' ? `${rel}/${g}` : g)
|
|
259
|
+
const sources = new Set(
|
|
260
|
+
strings.filter((g) => isLiteralPattern(g) && trackedSet.has(rootedOf(g))),
|
|
261
|
+
)
|
|
262
|
+
if (sources.size > 0) {
|
|
263
|
+
strings = strings.filter((g) => !sources.has(g.startsWith('!') ? g.slice(1) : g))
|
|
264
|
+
outputs[key] = strings
|
|
265
|
+
for (const g of sources) unhide(key === 'files' ? p : null, rootedOf(g))
|
|
266
|
+
}
|
|
233
267
|
const hit = coveredTracked(strings, base)
|
|
234
268
|
if (hit.length > 0) hits.push([key, strings, hit])
|
|
235
269
|
}
|
package/src/turbo/turbo-map.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { existsSync, readFileSync } from 'node:fs'
|
|
14
14
|
import path from 'node:path'
|
|
15
15
|
import { pruneOrphanPersistentNotes, type ProjectMeta, UserError } from '@vzn/vx'
|
|
16
|
-
import { minimatchToVx, withoutTakenBack } from '../glob-grammar.js'
|
|
16
|
+
import { literalGlob, minimatchToVx, withoutTakenBack } from '../glob-grammar.js'
|
|
17
17
|
import { shellQuote } from '../nx-command.js'
|
|
18
18
|
import { scriptCommand, yarnPnp } from '../script-command.js'
|
|
19
19
|
import {
|
|
@@ -842,7 +842,7 @@ function rootDependencyGlobs(
|
|
|
842
842
|
const out: string[] = []
|
|
843
843
|
for (const name of seen) {
|
|
844
844
|
const rel = relPosix(root, byName.get(name)!.dir)
|
|
845
|
-
if (rel !== '' && rel !== '.') out.push(`${rel}/**`)
|
|
845
|
+
if (rel !== '' && rel !== '.') out.push(`${literalGlob(rel)}/**`)
|
|
846
846
|
}
|
|
847
847
|
return out.sort()
|
|
848
848
|
}
|
|
@@ -1110,22 +1110,15 @@ export async function mapTurboWorkspace(
|
|
|
1110
1110
|
// A name no package has a script for is an entry point of its own:
|
|
1111
1111
|
// `turbo run ci` over `ci: { dependsOn: ["lint", "build"] }`, or
|
|
1112
1112
|
// cal.com's `deploy` → `@calcom/web#build`, runs its edges, and vx
|
|
1113
|
-
// said no project declares it.
|
|
1114
|
-
//
|
|
1115
|
-
//
|
|
1116
|
-
//
|
|
1113
|
+
// said no project declares it. With no edge left (documenso's `lint`,
|
|
1114
|
+
// shadcn-ui's `check`) Turbo still runs a no-op node per package and
|
|
1115
|
+
// exits 0, so a CI step `vx run lint` must too. Its `pkg#task` edges
|
|
1116
|
+
// stay in that package alone: core's `--filter`/`--affected` reach
|
|
1117
|
+
// follows a task edge across packages, and cal.com's `deploy` in all
|
|
1118
|
+
// 116 would have made every package a dependent of web.
|
|
1117
1119
|
else if (!scripted.has(name)) {
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
if (envDependency(d) !== null || d.includes('$TURBO_ROOT$')) return false
|
|
1121
|
-
if (d.startsWith('^'))
|
|
1122
|
-
return d !== `^${name}` && [...runnable.values()].some((r) => r.has(d.slice(1)))
|
|
1123
|
-
return d !== name && (own.has(d) || defined.has(d))
|
|
1124
|
-
})
|
|
1125
|
-
if (keeps) {
|
|
1126
|
-
emitted.get(meta.name)!.add(name)
|
|
1127
|
-
entry.add(`${meta.name}#${name}`)
|
|
1128
|
-
}
|
|
1120
|
+
emitted.get(meta.name)!.add(name)
|
|
1121
|
+
entry.add(`${meta.name}#${name}`)
|
|
1129
1122
|
}
|
|
1130
1123
|
}
|
|
1131
1124
|
}
|
|
@@ -1730,7 +1723,7 @@ function buildTask(
|
|
|
1730
1723
|
const climbed = (glob: string): string | null => {
|
|
1731
1724
|
const body = glob.startsWith('!') ? glob.slice(1) : glob
|
|
1732
1725
|
if (!body.startsWith('../')) return null
|
|
1733
|
-
const anchored = path.posix.normalize(path.posix.join(pkgDir, body))
|
|
1726
|
+
const anchored = path.posix.normalize(path.posix.join(literalGlob(pkgDir), body))
|
|
1734
1727
|
if (anchored.startsWith('../')) return null
|
|
1735
1728
|
return (glob.startsWith('!') ? '!' : '') + anchored
|
|
1736
1729
|
}
|
package/src/turbo-cache/index.ts
CHANGED
|
@@ -353,7 +353,8 @@ const MAX_SIGNED_BODY = 2 * 1024 ** 3 + ((2 * 1024 ** 3) >> 8) + 64 * 1024
|
|
|
353
353
|
* The seam implementation: `has` is HEAD, `hasMany` is the batch query,
|
|
354
354
|
* `get`/`put` carry `x-artifact-duration` (and the tag when signing). An
|
|
355
355
|
* auth failure (401/403) throws ONCE — LayeredCache reports it — and then
|
|
356
|
-
* turns the layer off for the rest of the process
|
|
356
|
+
* turns the layer off for the rest of the process (an upload's 403 turns off
|
|
357
|
+
* uploads alone: the read-only token), so a bad token costs one
|
|
357
358
|
* line, not one per task — the requests already in flight when it lands
|
|
358
359
|
* degrade in silence rather than repeating it.
|
|
359
360
|
*
|
|
@@ -364,6 +365,13 @@ const MAX_SIGNED_BODY = 2 * 1024 ** 3 + ((2 * 1024 ** 3) >> 8) + 64 * 1024
|
|
|
364
365
|
*/
|
|
365
366
|
export class TurboRemoteCache implements RemoteCacheLayer {
|
|
366
367
|
private disabled = false
|
|
368
|
+
/**
|
|
369
|
+
* A `403` on an upload is a read-only token or server
|
|
370
|
+
* (turborepo-remote-cache's `READ_ONLY` and its JWTs without the write
|
|
371
|
+
* scope): uploads stop, reads go on. Read as a refused token, it turned
|
|
372
|
+
* the reads off too, and every task after the first upload missed.
|
|
373
|
+
*/
|
|
374
|
+
private writesRefused = false
|
|
367
375
|
private readonly key: Uint8Array | undefined
|
|
368
376
|
readonly endpoint: string
|
|
369
377
|
constructor(
|
|
@@ -422,6 +430,14 @@ export class TurboRemoteCache implements RemoteCacheLayer {
|
|
|
422
430
|
).catch((err: unknown) => {
|
|
423
431
|
throw deadlineNamed(err, timeoutMs)
|
|
424
432
|
})
|
|
433
|
+
if (method === 'PUT' && res.status === 403) {
|
|
434
|
+
const first = !this.writesRefused
|
|
435
|
+
this.writesRefused = true
|
|
436
|
+
if (!first) return undefined
|
|
437
|
+
throw new Error(
|
|
438
|
+
'HTTP 403: the upload was refused (a read-only token or server); uploads off for this run, reads go on',
|
|
439
|
+
)
|
|
440
|
+
}
|
|
425
441
|
if (res.status === 401 || res.status === 403) {
|
|
426
442
|
const first = !this.disabled
|
|
427
443
|
this.disabled = true
|
|
@@ -520,7 +536,7 @@ export class TurboRemoteCache implements RemoteCacheLayer {
|
|
|
520
536
|
}
|
|
521
537
|
|
|
522
538
|
async put(hash: string, body: Blob, meta: { durationMs: number }): Promise<void> {
|
|
523
|
-
if (this.disabled) return
|
|
539
|
+
if (this.disabled || this.writesRefused) return
|
|
524
540
|
const headers: Record<string, string> = {
|
|
525
541
|
'Content-Type': 'application/octet-stream',
|
|
526
542
|
'Content-Length': String(body.size),
|
package/src/workspace-plugins.ts
CHANGED
|
@@ -45,6 +45,7 @@ function entries(plugins: readonly WorkspacePlugin[], indent: string): string[]
|
|
|
45
45
|
export function renderWorkspaceFile(
|
|
46
46
|
plugins: readonly WorkspacePlugin[],
|
|
47
47
|
format: 'ts' | 'mjs',
|
|
48
|
+
fields: readonly { readonly field: string; readonly source: string }[] = [],
|
|
48
49
|
): string {
|
|
49
50
|
return [
|
|
50
51
|
...(format === 'ts' ? ["import type { WorkspaceConfig } from '@vzn/vx/config'"] : []),
|
|
@@ -54,6 +55,7 @@ export function renderWorkspaceFile(
|
|
|
54
55
|
' plugins: [',
|
|
55
56
|
...entries(plugins, ' '),
|
|
56
57
|
' ],',
|
|
58
|
+
...fields.map((f) => ` ${f.field}: ${f.source},`),
|
|
57
59
|
`}${format === 'ts' ? ' satisfies WorkspaceConfig' : ''}`,
|
|
58
60
|
'',
|
|
59
61
|
].join('\n')
|