@vzn/vx-migrate 0.0.0 → 0.0.484
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/LICENSE +21 -0
- package/README.md +306 -0
- package/index.ts +4 -0
- package/package.json +44 -6
- package/src/adoption-plugin.ts +125 -0
- package/src/bin.ts +18 -0
- package/src/dotenv-probe.ts +86 -0
- package/src/glob-grammar.ts +63 -0
- package/src/index.ts +15 -0
- package/src/mapping-cache.ts +101 -0
- package/src/migrate-nx.ts +154 -0
- package/src/migrate-turbo.ts +400 -0
- package/src/migrate.ts +165 -0
- package/src/nx/export-graph.ts +29 -0
- package/src/nx/index.ts +638 -0
- package/src/nx/nx-deps.ts +272 -0
- package/src/nx/nx-dotenv.ts +106 -0
- package/src/nx/nx-inputs.ts +210 -0
- package/src/nx/nx-map.ts +1430 -0
- package/src/nx/nx-outputs.ts +231 -0
- package/src/nx/nx-upstream.ts +356 -0
- package/src/nx-cache/index.ts +236 -0
- package/src/nx-command.ts +458 -0
- package/src/nx-dotenv.cjs +41 -0
- package/src/nx-env.cjs +152 -0
- package/src/nx-exec.cjs +294 -0
- package/src/paths.ts +36 -0
- package/src/plugin-gaps.ts +48 -0
- package/src/remote-deadline.ts +11 -0
- package/src/remote-retry.ts +52 -0
- package/src/remote-token.ts +18 -0
- package/src/script-command.ts +69 -0
- package/src/shared-outputs.ts +373 -0
- package/src/tracked-outputs.ts +248 -0
- package/src/turbo/index.ts +291 -0
- package/src/turbo/turbo-map.ts +1976 -0
- package/src/turbo-cache/index.ts +661 -0
- package/src/workspace-notes.ts +54 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// What the written configs leave to vx.workspace.ts, said once by both
|
|
2
|
+
// migrators: the adoption plugin `vx init` declared still reads the old
|
|
3
|
+
// tool's file every run, and the old tool keyed each package on its own
|
|
4
|
+
// lockfile entries where core keys every task on the whole lockfile.
|
|
5
|
+
// Without a lockfile plugin a dependency bump re-ran every task (hey-api:
|
|
6
|
+
// a `pnpm-lock.yaml` edit re-keyed all 42 builds, none with `pnpm()`).
|
|
7
|
+
|
|
8
|
+
import { existsSync, readdirSync } from 'node:fs'
|
|
9
|
+
import path from 'node:path'
|
|
10
|
+
|
|
11
|
+
/** Each lockfile and the `@vzn/vx-lockfile` plugin that claims it. */
|
|
12
|
+
const LOCKFILES: ReadonlyArray<readonly [file: string, plugin: string]> = [
|
|
13
|
+
['pnpm-lock.yaml', 'pnpm'],
|
|
14
|
+
['bun.lock', 'bun'],
|
|
15
|
+
['bun.lockb', 'bun'],
|
|
16
|
+
['package-lock.json', 'npm'],
|
|
17
|
+
['npm-shrinkwrap.json', 'npm'],
|
|
18
|
+
['yarn.lock', 'yarn'],
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
export interface AdoptedTool {
|
|
22
|
+
/** The adoption plugin `vx init` declares: `turbo`, `nx`. */
|
|
23
|
+
readonly plugin: string
|
|
24
|
+
/** The file it reads every run: `turbo.json`, `nx.json`. */
|
|
25
|
+
readonly config: string
|
|
26
|
+
/** How the tool keys a package on the lockfile, as the note's opening. */
|
|
27
|
+
readonly keys: (lockfile: string) => string
|
|
28
|
+
/** What `vx run` replaces, in the note: `turbo`, `nx`. */
|
|
29
|
+
readonly runner: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function adoptedToolNotes(root: string, tool: AdoptedTool): Promise<string[]> {
|
|
33
|
+
const notes: string[] = []
|
|
34
|
+
let declared = ''
|
|
35
|
+
for (const name of readdirSync(root)) {
|
|
36
|
+
if (!/^vx\.workspace\.(ts|mts|js|mjs|cts|cjs)$/.test(name)) continue
|
|
37
|
+
declared = await Bun.file(path.join(root, name)).text()
|
|
38
|
+
if (new RegExp(`\\b${tool.plugin}\\s*\\(`).test(declared))
|
|
39
|
+
notes.push(
|
|
40
|
+
`${name} still declares ${tool.plugin}(), which reads ${tool.config} every run and fills any task ` +
|
|
41
|
+
'a vx.config does not declare; the configs written here declare them all. Once ' +
|
|
42
|
+
`\`vx run\` does what ${tool.runner} did, remove ${tool.plugin}() (and its import), then ${tool.config}`,
|
|
43
|
+
)
|
|
44
|
+
break
|
|
45
|
+
}
|
|
46
|
+
const lock = LOCKFILES.find(([file]) => existsSync(path.join(root, file)))
|
|
47
|
+
if (lock !== undefined && !declared.includes('@vzn/vx-lockfile'))
|
|
48
|
+
notes.push(
|
|
49
|
+
`${tool.keys(lock[0])}; vx keys every task on the whole ` +
|
|
50
|
+
`file, so a dependency bump re-runs them all. Declare ${lock[1]}() from @vzn/vx-lockfile ` +
|
|
51
|
+
"in vx.workspace.ts to key each task on its package's dependency closure",
|
|
52
|
+
)
|
|
53
|
+
return notes
|
|
54
|
+
}
|