@vzn/vx 0.0.299 → 0.0.300

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.299",
3
+ "version": "0.0.300",
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.299",
21
- "@vzn/vx-linux-arm64": "0.0.299",
22
- "@vzn/vx-darwin-x64": "0.0.299",
23
- "@vzn/vx-darwin-arm64": "0.0.299"
20
+ "@vzn/vx-linux-x64": "0.0.300",
21
+ "@vzn/vx-linux-arm64": "0.0.300",
22
+ "@vzn/vx-darwin-x64": "0.0.300",
23
+ "@vzn/vx-darwin-arm64": "0.0.300"
24
24
  },
25
25
  "dependencies": {
26
26
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
package/src/index.ts CHANGED
@@ -118,6 +118,7 @@ export {
118
118
  applyMigration,
119
119
  foldScriptHooks,
120
120
  PERSISTENT_TODO,
121
+ pruneOrphanPersistentNotes,
121
122
  quoteTsLiteral,
122
123
  } from './workspace/index.js'
123
124
  export type {
@@ -64,6 +64,7 @@ export {
64
64
  foldScriptHooks,
65
65
  PERSISTENT_TASK_NAMES,
66
66
  PERSISTENT_TODO,
67
+ pruneOrphanPersistentNotes,
67
68
  quoteTsLiteral,
68
69
  type ApplyMigrationArgs,
69
70
  type MigrationFormat,
@@ -39,6 +39,7 @@ import {
39
39
  PERSISTENT_TASK_NAMES,
40
40
  PERSISTENT_TODO,
41
41
  cacheTodo,
42
+ pruneOrphanPersistentNotes,
42
43
  } from './migration.js'
43
44
 
44
45
  // `lint` is not here: a linter reads sources, and an edge to `build`
@@ -379,6 +380,7 @@ export function migrateScripts(
379
380
  }
380
381
  }
381
382
  breakBuildCycles(projects, metas)
383
+ pruneOrphanPersistentNotes(projects, PERSISTENT_TODO)
382
384
  return {
383
385
  headerNotes: [
384
386
  // Where to add one is the TODO's to say, when there is one: an Nx repo
@@ -97,6 +97,47 @@ export const PERSISTENT_TODO =
97
97
  'persistent task — set persistent.readyWhen (regex matched against output) so ' +
98
98
  'dependents unblock on readiness, and consider exec.timeout to bound the wait'
99
99
 
100
+ // The readiness note a persistent task carries ("add `readyWhen` to gate
101
+ // dependents") is moot for a task nothing depends on: no one waits for it,
102
+ // so there is nothing to gate. refine printed it for 375 `dev` and `start`
103
+ // tasks on every run, none of them anyone's dependency (item 602), and
104
+ // `vx init` wrote it on hoppscotch's 24 `dev`-shaped scripts. Every mapper
105
+ // runs this last, over the whole mapping, since a dependent may sit in
106
+ // another package.
107
+
108
+ /** Strips the note from every persistent task no `dependsOn` in the mapping names. */
109
+ export function pruneOrphanPersistentNotes(
110
+ projects: readonly {
111
+ readonly tasks: readonly {
112
+ readonly name: string
113
+ readonly todos: string[]
114
+ readonly task: Record<string, unknown> | null
115
+ }[]
116
+ }[],
117
+ note: string,
118
+ ): void {
119
+ const referenced = new Set<string>()
120
+ for (const project of projects) {
121
+ for (const t of project.tasks) {
122
+ const deps = t.task?.['dependsOn']
123
+ if (!Array.isArray(deps)) continue
124
+ for (const d of deps) {
125
+ if (typeof d !== 'string') continue
126
+ // `^name`, `pkg#name` and `name` all name the same task.
127
+ const hash = d.indexOf('#')
128
+ referenced.add(hash === -1 ? d.replace(/^\^/, '') : d.slice(hash + 1))
129
+ }
130
+ }
131
+ }
132
+ for (const project of projects) {
133
+ for (const t of project.tasks) {
134
+ if (referenced.has(t.name)) continue
135
+ const at = t.todos.indexOf(note)
136
+ if (at !== -1) t.todos.splice(at, 1)
137
+ }
138
+ }
139
+ }
140
+
100
141
  /** Verbatim TS expression spliced into a generated array (preset spreads). */
101
142
  export interface RawExpr {
102
143
  readonly raw: string