@vzn/vx 0.0.314 → 0.0.315

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.314",
3
+ "version": "0.0.315",
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.314",
21
- "@vzn/vx-linux-arm64": "0.0.314",
22
- "@vzn/vx-darwin-x64": "0.0.314",
23
- "@vzn/vx-darwin-arm64": "0.0.314"
20
+ "@vzn/vx-linux-x64": "0.0.315",
21
+ "@vzn/vx-linux-arm64": "0.0.315",
22
+ "@vzn/vx-darwin-x64": "0.0.315",
23
+ "@vzn/vx-darwin-arm64": "0.0.315"
24
24
  },
25
25
  "dependencies": {
26
26
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
@@ -254,6 +254,33 @@ function upstreamBuildOnWorker(tasks: GeneratedTask[]): void {
254
254
  const RUNS_MEMBERS =
255
255
  /(^|[\s;&|(])(turbo|nx|lerna|ultra|wireit|nps|moon|rush|vx)(\s|$)|\s(-r|--recursive|--filter|-F|--workspaces|-ws|--workspace|-w|-C|--dir|--cwd|--prefix|--if-present|--parallel|--stream)(\s|=|$)|\bworkspaces?\s+(foreach|run)\b|\bvp\s+run\s|\bcd\s/
256
256
 
257
+ /** A package manager running a script by name: `pnpm build`, `npm run x`, `bun run x`. */
258
+ const RUNS_SCRIPT =
259
+ /(?:^|[\s;&|(])(?:pnpm|npm|yarn|bun)\s+(?:run(?:-script)?\s+)?([^\s;&|()'"-][^\s;&|()'"]*)/g
260
+
261
+ /**
262
+ * The scripts that run the members, directly or through another of these
263
+ * scripts: vite's `ci-docs` (`pnpm build && pnpm docs-build`) runs each
264
+ * member's build through the root's own `build` (`pnpm -r … run build`).
265
+ */
266
+ function runningMembers(scripts: Readonly<Record<string, unknown>>): Set<string> {
267
+ const text = Object.entries(scripts).filter(
268
+ (e): e is [string, string] => typeof e[1] === 'string',
269
+ )
270
+ const out = new Set(text.filter(([, v]) => RUNS_MEMBERS.test(` ${v}`)).map(([n]) => n))
271
+ for (let grew = true; grew;) {
272
+ grew = false
273
+ for (const [n, v] of text) {
274
+ if (out.has(n)) continue
275
+ if ([...v.matchAll(RUNS_SCRIPT)].some((m) => out.has(m[1]!))) {
276
+ out.add(n)
277
+ grew = true
278
+ }
279
+ }
280
+ }
281
+ return out
282
+ }
283
+
257
284
  /**
258
285
  * `outside`: the root manifest when the root is no member (pnpm's and
259
286
  * Yarn's default), whose own scripts (`lint: eslint .`) went unmapped
@@ -296,12 +323,15 @@ export function migrateScripts(
296
323
  .filter(([, v]) => typeof v === 'string' && v !== '')
297
324
  .map(([n]) => n),
298
325
  )
299
- const rootScripts = (meta: ProjectMeta): Record<string, unknown> =>
300
- Object.fromEntries(
301
- Object.entries(scriptsOf(meta)).filter(
302
- ([n, v]) => typeof v === 'string' && !memberTasks.has(n) && !RUNS_MEMBERS.test(` ${v}`),
326
+ const rootScripts = (meta: ProjectMeta): Record<string, unknown> => {
327
+ const scripts = scriptsOf(meta)
328
+ const runs = runningMembers(scripts)
329
+ return Object.fromEntries(
330
+ Object.entries(scripts).filter(
331
+ ([n, v]) => typeof v === 'string' && !memberTasks.has(n) && !runs.has(n),
303
332
  ),
304
333
  )
334
+ }
305
335
  const rootMapped =
306
336
  rootMeta === undefined
307
337
  ? 0