@vzn/vx 0.0.204 → 0.0.205

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.204",
3
+ "version": "0.0.205",
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.204",
21
- "@vzn/vx-linux-arm64": "0.0.204",
22
- "@vzn/vx-darwin-x64": "0.0.204",
23
- "@vzn/vx-darwin-arm64": "0.0.204"
20
+ "@vzn/vx-linux-x64": "0.0.205",
21
+ "@vzn/vx-linux-arm64": "0.0.205",
22
+ "@vzn/vx-darwin-x64": "0.0.205",
23
+ "@vzn/vx-darwin-arm64": "0.0.205"
24
24
  },
25
25
  "dependencies": {
26
26
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
@@ -15,7 +15,6 @@ import {
15
15
  buildPackageGraph,
16
16
  computeWorkspaceFingerprint,
17
17
  FROZEN_WITHOUT_LOCK,
18
- loadWorkspaceConfig,
19
18
  type Workspace,
20
19
  type ProjectEntry,
21
20
  type ProjectMeta,
@@ -40,13 +39,11 @@ export async function loadCliWorkspace(workspaceRoot: string): Promise<CliWorksp
40
39
 
41
40
  /**
42
41
  * The workspace's projects as a run discovers them: core's, then the
43
- * plugin `discover` stage. Only the plugin list is read; the `config`
44
- * stage cannot change it.
42
+ * plugin `discover` stage, with the cache dir the run uses.
45
43
  */
46
44
  export async function discoverCliProjects(workspace: Workspace): Promise<ProjectMeta[]> {
47
- const plugins = ((await loadWorkspaceConfig(workspace.root))?.plugins ??
48
- []) as readonly VxPlugin[]
49
- return await discoverProjects(workspace, plugins, warnToStderr)
45
+ const { plugins, cacheDir } = await loadCliWorkspace(workspace.root)
46
+ return await discoverProjects(workspace, plugins, cacheDir, warnToStderr)
50
47
  }
51
48
 
52
49
  /**
@@ -114,11 +114,11 @@ export async function collectInfo(cwd: string, opts: CollectInfoOptions = {}): P
114
114
  const reads: LoadReads = new Map()
115
115
  const root = await findWorkspaceRoot(cwd, reads)
116
116
  const { workspaceConfig, plugins } = await loadWorkspacePlugins(root, warn)
117
- const metas = await discoverProjects(await loadWorkspace(root, reads), plugins, warn)
118
117
  const cacheDir =
119
118
  opts.cacheDir === undefined
120
119
  ? resolveCacheDir(root, workspaceConfig)
121
120
  : path.resolve(cwd, opts.cacheDir)
121
+ const metas = await discoverProjects(await loadWorkspace(root, reads), plugins, cacheDir, warn)
122
122
  const cache = Cache.inspect(cacheDir)
123
123
  noteSchemaReset(cache, warn)
124
124
  let stats
@@ -14,6 +14,7 @@ import type { ProjectConfig, WorkspaceConfig } from '../config.js'
14
14
  import { checkGraph, type TaskNode } from '../graph/index.js'
15
15
  import type {
16
16
  CacheContext,
17
+ DiscoverContext,
17
18
  ExecutorContext,
18
19
  FingerprintChange,
19
20
  FingerprintContext,
@@ -128,7 +129,7 @@ export async function applyConfigHooks(
128
129
  export async function applyDiscoverHooks(
129
130
  plugins: readonly VxPlugin[],
130
131
  projects: ProjectMeta[],
131
- ctx: WorkspaceHookContext,
132
+ ctx: Omit<DiscoverContext, 'projects'>,
132
133
  add: (named: NamedProject, plugin: VxPlugin) => Promise<ProjectMeta | null>,
133
134
  ): Promise<void> {
134
135
  for (const plugin of plugins) {
@@ -255,6 +255,8 @@ export interface WorkspaceHookContext {
255
255
  }
256
256
 
257
257
  export interface DiscoverContext extends WorkspaceHookContext {
258
+ /** Where vx's cache lives: a plugin may keep what it read to answer here. */
259
+ readonly cacheDir: string
258
260
  /** The projects found so far: core's, then earlier plugins'. */
259
261
  readonly projects: readonly ProjectMeta[]
260
262
  }
@@ -188,10 +188,15 @@ export async function prepareRun(options: RunOptions, log: Logger): Promise<Prep
188
188
  log.status(m),
189
189
  )
190
190
  mark('workspace config')
191
+ // `--cache-dir <path>` (RunOptions.cacheDir) overrides the workspace
192
+ // `cacheDir` field + the `.vx/cache` default; resolved relative to cwd.
193
+ const cacheDir = options.cacheDir
194
+ ? path.resolve(options.cwd, options.cacheDir)
195
+ : resolveCacheDir(workspaceRoot, workspaceConfig)
191
196
  const projectMetas =
192
197
  options.discovered?.root === workspaceRoot
193
198
  ? options.discovered.projects
194
- : await discoverProjects(workspace, plugins, (m) => log.status(m))
199
+ : await discoverProjects(workspace, plugins, cacheDir, (m) => log.status(m))
195
200
  mark('discover projects')
196
201
 
197
202
  // SCOPED config loading: configs are programs, and evaluating 1090
@@ -224,13 +229,8 @@ export async function prepareRun(options: RunOptions, log: Logger): Promise<Prep
224
229
  mark('package graph')
225
230
 
226
231
  // The local cache opens BEFORE the configs load: it is also where their
227
- // cached evaluations live. `--cache-dir <path>` (RunOptions.cacheDir)
228
- // overrides the workspace `cacheDir` field + the `.vx/cache` default;
229
- // resolved relative to cwd.
232
+ // cached evaluations live.
230
233
  const policy: CachePolicy = options.cache ?? FULL_CACHE_POLICY
231
- const cacheDir = options.cacheDir
232
- ? path.resolve(options.cwd, options.cacheDir)
233
- : resolveCacheDir(workspaceRoot, workspaceConfig)
234
234
  const localCache = new Cache(
235
235
  cacheDir,
236
236
  { read: policy.localRead, write: policy.localWrite },
@@ -63,6 +63,7 @@ export async function loadWorkspacePlugins(
63
63
  export async function discoverProjects(
64
64
  workspace: Workspace,
65
65
  plugins: readonly VxPlugin[],
66
+ cacheDir: string,
66
67
  warn: (message: string) => void,
67
68
  ): Promise<ProjectMeta[]> {
68
69
  const projects = await listProjects(workspace)
@@ -70,7 +71,7 @@ export async function discoverProjects(
70
71
  await applyDiscoverHooks(
71
72
  plugins,
72
73
  projects,
73
- { workspaceRoot: workspace.root, warn },
74
+ { workspaceRoot: workspace.root, cacheDir, warn },
74
75
  (named, plugin) => namedProject(workspace, projects, named, plugin.name),
75
76
  )
76
77
  return projects.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))
@@ -272,8 +273,13 @@ export async function loadResolvedProjects(
272
273
  const warn = opts.warn ?? ((): void => {})
273
274
  const reads: LoadReads = new Map()
274
275
  const { workspaceConfig, plugins } = await loadWorkspacePlugins(workspaceRoot, warn)
275
- const metas = await discoverProjects(await loadWorkspace(workspaceRoot, reads), plugins, warn)
276
276
  const cacheDir = resolveCacheDir(workspaceRoot, workspaceConfig)
277
+ const metas = await discoverProjects(
278
+ await loadWorkspace(workspaceRoot, reads),
279
+ plugins,
280
+ cacheDir,
281
+ warn,
282
+ )
277
283
  // Opened as `vx last` opens it: a reader makes no index where there is
278
284
  // none and never resets an earlier schema's (C-5). One it cannot read
279
285
  // serves nothing; the configs evaluate live.
@@ -646,7 +646,9 @@ export async function namedProject(
646
646
  ) {
647
647
  throw new UserError(`${where} "${named.name}" at ${shown}: no such directory`)
648
648
  }
649
- const pkg = text === null ? { name: named.name } : parsePackageJson(text, pkgJsonPath)
649
+ const parsed: Partial<PackageJson> = text === null ? {} : parsePackageJson(text, pkgJsonPath)
650
+ // A nameless manifest names nothing to disagree with (Nx's own projects).
651
+ const pkg: PackageJson = { ...parsed, name: parsed.name ?? named.name }
650
652
  if (pkg.name !== named.name) {
651
653
  throw new UserError(
652
654
  `${where} "${named.name}" at ${shown}: its package.json names it "${pkg.name ?? ''}"`,