@vzn/vx-migrate 0.0.553 → 0.0.555

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vzn/vx-migrate",
3
- "version": "0.0.553",
3
+ "version": "0.0.555",
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.553"
42
+ "@vzn/vx": "^0.0.555"
43
43
  },
44
44
  "repository": {
45
45
  "type": "git",
@@ -61,3 +61,25 @@ function classMembers(body: string): string[] | null {
61
61
  }
62
62
  return [...out]
63
63
  }
64
+
65
+ /**
66
+ * `list` without a literal that one of its `!` entries takes back. Turbo,
67
+ * Nx and vx all subtract an exclusion wherever it sits, so such a file was
68
+ * never an input there either; vx refuses it at load, which would stop an
69
+ * unchanged repo's run, so the adapters drop it.
70
+ */
71
+ export function withoutTakenBack<T>(list: readonly T[]): T[] {
72
+ const wild = /[*?{}]/
73
+ const negative = list.flatMap((e) =>
74
+ typeof e === 'string' && e.startsWith('!') ? [e.slice(1)] : [],
75
+ )
76
+ if (negative.length === 0) return [...list]
77
+ const globs = negative
78
+ .flatMap((n) => (wild.test(n) ? [n] : [n, `${n.replace(/\/+$/, '')}/**`]))
79
+ .map((g) => new Bun.Glob(g.replace(/^\.\//, '')))
80
+ return list.filter((e) => {
81
+ if (typeof e !== 'string' || e.startsWith('!') || wild.test(e)) return true
82
+ const lit = e.replace(/^\.\//, '').replace(/\/+$/, '')
83
+ return !globs.some((g) => g.match(lit))
84
+ })
85
+ }
package/src/nx/nx-map.ts CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  type ProjectMeta,
24
24
  UserError,
25
25
  } from '@vzn/vx'
26
+ import { withoutTakenBack } from '../glob-grammar.js'
26
27
  import { mapRunCommands, shellQuote } from '../nx-command.js'
27
28
  import { scriptCommand, yarnPnp } from '../script-command.js'
28
29
  import {
@@ -937,8 +938,8 @@ function buildTask(
937
938
  const task: Record<string, unknown> = { exec }
938
939
  if (deps.length > 0) task.dependsOn = deps
939
940
  if (cacheEnabled) {
940
- const cacheInputs: Record<string, unknown> = { files: inputs.files }
941
- if (inputs.wsFiles.length > 0) cacheInputs.workspaceFiles = inputs.wsFiles
941
+ const cacheInputs: Record<string, unknown> = { files: withoutTakenBack(inputs.files) }
942
+ if (inputs.wsFiles.length > 0) cacheInputs.workspaceFiles = withoutTakenBack(inputs.wsFiles)
942
943
  if (inputs.envNames.length > 0) cacheInputs.env = inputs.envNames
943
944
  // The `.env` files the task loads are inputs, and gitignored ones
944
945
  // (`.env.local`) are invisible to a glob: their bytes, read per run.
@@ -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 } from '../glob-grammar.js'
16
+ import { 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 {
@@ -1956,8 +1956,9 @@ function buildTask(
1956
1956
  wsFiles.unshift(...files.splice(0))
1957
1957
  wsOutFiles.unshift(...outFiles.splice(0))
1958
1958
  }
1959
- const inputs: Record<string, unknown> = { files }
1960
- if (wsFiles.length > 0) inputs.workspaceFiles = uniq(wsFiles, hidden('inputs'))
1959
+ const inputs: Record<string, unknown> = { files: withoutTakenBack(files) }
1960
+ if (wsFiles.length > 0)
1961
+ inputs.workspaceFiles = withoutTakenBack(uniq(wsFiles, hidden('inputs')))
1961
1962
  if (cacheEnv.length > 0) inputs.env = cacheEnv
1962
1963
  if (pkgDotenv) inputs.runtime = [pkgDotenvDeep ? DOTENV_PROBE : DOTENV_PROBE_TOP]
1963
1964
  if (wsDotenv.length > 0) inputs.workspaceRuntime = [dotenvGlobsProbe(wsDotenv) ?? DOTENV_PROBE]