@vzn/vx-migrate 0.0.651 → 0.0.653

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.
@@ -1,12 +1,13 @@
1
1
  // What the written configs leave to .vx/workspace.ts, said once by both
2
2
  // migrators: the adoption plugin `vx init` declared still reads the old
3
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()`).
4
+ // lockfile entries where core keys no lockfile (#3562): without a
5
+ // lockfile plugin a dependency bump re-runs nothing, and a cached task
6
+ // replays output built on the old versions.
7
7
 
8
8
  import { existsSync } from 'node:fs'
9
9
  import path from 'node:path'
10
+ import type { PackageManager } from './adopt.js'
10
11
 
11
12
  /** Each lockfile and the `@vzn/vx-lockfile` plugin that claims it. */
12
13
  const LOCKFILES: ReadonlyArray<readonly [file: string, plugin: string]> = [
@@ -18,9 +19,18 @@ const LOCKFILES: ReadonlyArray<readonly [file: string, plugin: string]> = [
18
19
  ['yarn.lock', 'yarn'],
19
20
  ]
20
21
 
21
- /** The lockfile at `root` and the `@vzn/vx-lockfile` factory that claims it. */
22
- export function lockfilePlugin(root: string): { file: string; factory: string } | undefined {
23
- const lock = LOCKFILES.find(([file]) => existsSync(path.join(root, file)))
22
+ /**
23
+ * The lockfile at `root` and the `@vzn/vx-lockfile` factory that claims it.
24
+ * With none there, `installer`'s: the manager this run installs with
25
+ * writes it, and the lock that follows needs its plugin for `^` edges.
26
+ */
27
+ export function lockfilePlugin(
28
+ root: string,
29
+ installer?: PackageManager,
30
+ ): { file: string; factory: string } | undefined {
31
+ const lock =
32
+ LOCKFILES.find(([file]) => existsSync(path.join(root, file))) ??
33
+ LOCKFILES.find(([, factory]) => factory === installer)
24
34
  return lock === undefined ? undefined : { file: lock[0], factory: lock[1] }
25
35
  }
26
36
 
@@ -58,8 +68,9 @@ export async function adoptedToolNotes(root: string, tool: AdoptedTool): Promise
58
68
  const lock = lockfilePlugin(root)
59
69
  if (lock !== undefined && !new RegExp(`\\b${lock.factory}\\s*\\(`).test(declared))
60
70
  notes.push(
61
- `${tool.keys(lock.file)}; vx keys every task on the whole ` +
62
- `file, so a dependency bump re-runs them all. Declare ${lock.factory}() from @vzn/vx-lockfile ` +
71
+ `${tool.keys(lock.file)}; vx keys no lockfile by itself, so a dependency bump re-runs ` +
72
+ 'nothing and a cached task replays output built on the old versions. ' +
73
+ `Declare ${lock.factory}() from @vzn/vx-lockfile ` +
63
74
  "in .vx/workspace.ts to key each task on its package's dependency closure",
64
75
  )
65
76
  return notes
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { existsSync } from 'node:fs'
8
8
  import path from 'node:path'
9
+ import type { PackageManager } from './adopt.js'
9
10
  import { REMOTE_CACHE, remoteCacheSignal } from './remote-cache.js'
10
11
  import { lockfilePlugin } from './workspace-notes.js'
11
12
 
@@ -16,12 +17,19 @@ export interface WorkspacePlugin {
16
17
  readonly factory: string
17
18
  }
18
19
 
19
- /** `runner`: the Turbo or Nx repo's own remote cache, where the repo shows one. */
20
- export function workspacePlugins(root: string, runner?: 'turbo' | 'nx'): WorkspacePlugin[] {
20
+ /**
21
+ * `runner`: the Turbo or Nx repo's own remote cache, where the repo shows
22
+ * one. `installer`: the manager this run installs with (`lockfilePlugin`).
23
+ */
24
+ export function workspacePlugins(
25
+ root: string,
26
+ runner?: 'turbo' | 'nx',
27
+ installer?: PackageManager,
28
+ ): WorkspacePlugin[] {
21
29
  const out: WorkspacePlugin[] = []
22
30
  if (runner !== undefined && remoteCacheSignal(root, runner) !== undefined)
23
31
  out.push({ pkg: '@vzn/vx-migrate', factory: REMOTE_CACHE[runner] })
24
- const lock = lockfilePlugin(root)
32
+ const lock = lockfilePlugin(root, installer)
25
33
  if (lock !== undefined) out.push({ pkg: '@vzn/vx-lockfile', factory: lock.factory })
26
34
  out.push({ pkg: '@vzn/vx-history', factory: 'vxHistory' })
27
35
  if (existsSync(path.join(root, '.github', 'workflows')))