@vzn/vx 0.0.244 → 0.0.245

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",
3
- "version": "0.0.244",
3
+ "version": "0.0.245",
4
4
  "description": "A fast, correct task runner and build cache for JavaScript monorepos.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,10 +17,10 @@
17
17
  "node": ">=18"
18
18
  },
19
19
  "optionalDependencies": {
20
- "@vzn/vx-linux-x64": "0.0.244",
21
- "@vzn/vx-linux-arm64": "0.0.244",
22
- "@vzn/vx-darwin-x64": "0.0.244",
23
- "@vzn/vx-darwin-arm64": "0.0.244"
20
+ "@vzn/vx-linux-x64": "0.0.245",
21
+ "@vzn/vx-linux-arm64": "0.0.245",
22
+ "@vzn/vx-darwin-x64": "0.0.245",
23
+ "@vzn/vx-darwin-arm64": "0.0.245"
24
24
  },
25
25
  "dependencies": {
26
26
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
@@ -96,8 +96,8 @@ const OWN_COMMANDS: Readonly<Record<string, ReadonlySet<string>>> = {
96
96
  }
97
97
 
98
98
  /**
99
- * Whether the package manager that owns `dir` runs `pre` / `post` hooks
100
- * around a script. The manager is the nearest `packageManager` field or
99
+ * The package manager that owns `dir`, when it runs `pre` / `post` hooks
100
+ * around a script; null when it runs none. The manager is the nearest `packageManager` field or
101
101
  * lockfile, and its settings are read beside it, as each reads them for a
102
102
  * member too. Probed with a `prebuild` / `build` / `postbuild` trio: Yarn
103
103
  * 2+ runs none (D-31); npm runs none under `ignore-scripts=true` in
@@ -105,7 +105,7 @@ const OWN_COMMANDS: Readonly<Record<string, ReadonlySet<string>>> = {
105
105
  * `enablePrePostScripts: false` in `pnpm-workspace.yaml` (D-33); Bun and
106
106
  * Yarn 1 run them whatever those say. No manager found is npm's default.
107
107
  */
108
- function runsScriptHooks(dir: string, memo: Map<string, boolean>): boolean {
108
+ function runsScriptHooks(dir: string, memo: Map<string, string | null>): string | null {
109
109
  const known = memo.get(dir)
110
110
  if (known !== undefined) return known
111
111
  const read = (f: string): string | undefined => {
@@ -129,15 +129,15 @@ function runsScriptHooks(dir: string, memo: Map<string, boolean>): boolean {
129
129
  else if (existsSync(path.join(dir, 'package-lock.json'))) manager = 'npm'
130
130
  else if (['bun.lock', 'bun.lockb'].some((f) => existsSync(path.join(dir, f)))) manager = 'bun'
131
131
  }
132
- let answer: boolean
132
+ let answer: string | null
133
133
  if (manager === undefined) {
134
134
  const up = path.dirname(dir)
135
- answer = up === dir ? true : runsScriptHooks(up, memo)
135
+ answer = up === dir ? 'npm' : runsScriptHooks(up, memo)
136
136
  } else {
137
137
  const npmrc = read('.npmrc') ?? ''
138
138
  const set = (key: string, value: string): boolean =>
139
139
  new RegExp(`^\\s*${key}\\s*=\\s*${value}\\s*$`, 'm').test(npmrc)
140
- answer =
140
+ const runs =
141
141
  manager === 'berry'
142
142
  ? false
143
143
  : manager === 'npm'
@@ -146,6 +146,7 @@ function runsScriptHooks(dir: string, memo: Map<string, boolean>): boolean {
146
146
  ? !set('enable-pre-post-scripts', 'false') &&
147
147
  !/^enablePrePostScripts:\s*false\s*$/m.test(read('pnpm-workspace.yaml') ?? '')
148
148
  : true
149
+ answer = runs ? manager : null
149
150
  }
150
151
  memo.set(dir, answer)
151
152
  return answer
@@ -242,7 +243,7 @@ function upstreamBuildOnWorker(tasks: GeneratedTask[]): void {
242
243
 
243
244
  export function migrateScripts(metas: readonly ProjectMeta[]): MigrationPlan {
244
245
  const projects: GeneratedProject[] = []
245
- const hookMemo = new Map<string, boolean>()
246
+ const hookMemo = new Map<string, string | null>()
246
247
  // The workspace root among members: its scripts run the workspace
247
248
  // (`npm run build --workspaces`, `pnpm -r build`), and a root task made
248
249
  // of one ran every member's build again under `--all`. Since D-39 a
@@ -258,7 +259,8 @@ export function migrateScripts(metas: readonly ProjectMeta[]): MigrationPlan {
258
259
  for (const meta of metas) {
259
260
  if (meta === root) continue
260
261
  const scripts = scriptsOf(meta)
261
- const runsHooks = runsScriptHooks(meta.dir, hookMemo)
262
+ const hooksBy = runsScriptHooks(meta.dir, hookMemo)
263
+ const runsHooks = hooksBy !== null
262
264
  const runnable = Object.keys(scripts).filter(
263
265
  (n) => typeof scripts[n] === 'string' && scripts[n] !== '',
264
266
  )
@@ -314,7 +316,7 @@ export function migrateScripts(metas: readonly ProjectMeta[]): MigrationPlan {
314
316
  )
315
317
  if (hooks.length > 0) {
316
318
  todos.push(
317
- `npm ran ${hooks.map((h) => `\`${h}\``).join(' and ')} around this script without being asked; folded into the command in that order`,
319
+ `${hooksBy} ran ${hooks.map((h) => `\`${h}\``).join(' and ')} around this script without being asked; folded into the command in that order`,
318
320
  )
319
321
  }
320
322
  const exec: Record<string, unknown> = { command }