@vzn/vx 0.0.278 → 0.0.279

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.278",
3
+ "version": "0.0.279",
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.278",
21
- "@vzn/vx-linux-arm64": "0.0.278",
22
- "@vzn/vx-darwin-x64": "0.0.278",
23
- "@vzn/vx-darwin-arm64": "0.0.278"
20
+ "@vzn/vx-linux-x64": "0.0.279",
21
+ "@vzn/vx-linux-arm64": "0.0.279",
22
+ "@vzn/vx-darwin-x64": "0.0.279",
23
+ "@vzn/vx-darwin-arm64": "0.0.279"
24
24
  },
25
25
  "dependencies": {
26
26
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
package/src/bin.ts CHANGED
@@ -1,26 +1,25 @@
1
1
  #!/usr/bin/env -S bun --no-env-file --no-install
2
- import { registerCoreAlias, run } from './cli/index.js'
3
- import {
4
- fsRefusalHint,
5
- isFsRefusal,
6
- isOutOfFds,
7
- isUserError,
8
- OUT_OF_FDS_HINT,
9
- } from './util/index.js'
10
-
11
- // Every `import … from '@vzn/vx'` this process evaluates — a plugin
12
- // package, a workspace or project config — resolves to THIS core, not to
13
- // a second copy from node_modules (core-alias.ts says why and what it
14
- // costs). Registered before any verb runs; the façade loads on first use.
15
- registerCoreAlias(() => import('./index.js') as Promise<Record<string, unknown>>)
16
-
17
2
  // Wrapped in an explicit async main so `bun build --compile` accepts
18
3
  // the file. The compile target doesn't allow top-level await.
19
4
  let settled = false
20
5
 
21
6
  async function main(): Promise<void> {
7
+ const argv = process.argv.slice(2)
22
8
  try {
23
- const code = await run(process.argv.slice(2))
9
+ // `vx --version` needs one leaf module; the dispatcher and the util
10
+ // barrel it pulled in were 20 ms of its 28 (2026-10-01).
11
+ if (argv.length === 1 && (argv[0] === '--version' || argv[0] === 'version')) {
12
+ process.stdout.write(`vx ${(await import('./version.js')).VERSION}\n`)
13
+ settled = true
14
+ return
15
+ }
16
+ const { registerCoreAlias, run } = await import('./cli/index.js')
17
+ // Every `import … from '@vzn/vx'` this process evaluates — a plugin
18
+ // package, a workspace or project config — resolves to THIS core, not to
19
+ // a second copy from node_modules (core-alias.ts says why and what it
20
+ // costs). Registered before any verb runs; the façade loads on first use.
21
+ registerCoreAlias(() => import('./index.js') as Promise<Record<string, unknown>>)
22
+ const code = await run(argv)
24
23
  // NOTHING calls `process.exit` here, and that is the fix rather than a
25
24
  // simplification. Bun drops what a pipe has not yet taken when
26
25
  // `process.exit` follows a large write: 300 KB written then exit
@@ -34,6 +33,8 @@ async function main(): Promise<void> {
34
33
  // several hundred spawns of this binary would show at once.
35
34
  process.exitCode = code
36
35
  } catch (err) {
36
+ const { fsRefusalHint, isFsRefusal, isOutOfFds, isUserError, OUT_OF_FDS_HINT } =
37
+ await import('./util/index.js')
37
38
  // UserError (workspace not found, cycle, config invalid, ...) —
38
39
  // print the message only; the stack is noise the user can't act
39
40
  // on. Everything else gets the full stack so internal bugs are
package/src/cli/init.ts CHANGED
@@ -180,7 +180,9 @@ async function adopt(
180
180
  : `wrote ${name}.`
181
181
  const cacheLine =
182
182
  remote === undefined
183
- ? ''
183
+ ? runner === 'nx' && usesNxCloud(root)
184
+ ? 'nx.json connects Nx Cloud, whose cache vx cannot share: runs cache on this machine (nxCache() serves a self-hosted Nx cache).\n'
185
+ : ''
184
186
  : kept && !readFileSync(path.join(root, existing), 'utf8').includes(`${cache}(`)
185
187
  ? `${remote}: add ${cache}() from @vzn/vx-migrate to its plugins and vx shares that remote cache.\n`
186
188
  : kept
@@ -195,6 +197,31 @@ async function adopt(
195
197
 
196
198
  const REMOTE_CACHE = { turbo: 'turboCache', nx: 'nxCache' } as const
197
199
 
200
+ /**
201
+ * nx.json names an Nx Cloud workspace (`nxCloudId`, `nxCloudAccessToken`,
202
+ * or the legacy `nx-cloud` runner). Its wire is Nx's own, so a user who
203
+ * expected their remote cache under vx heard nothing and ran cold.
204
+ */
205
+ function usesNxCloud(root: string): boolean {
206
+ let json: {
207
+ nxCloudId?: unknown
208
+ nxCloudAccessToken?: unknown
209
+ tasksRunnerOptions?: { default?: { runner?: unknown } }
210
+ } | null
211
+ try {
212
+ json = Bun.JSONC.parse(readFileSync(path.join(root, 'nx.json'), 'utf8')) as typeof json
213
+ } catch {
214
+ return false
215
+ }
216
+ const set = (v: unknown) => typeof v === 'string' && v !== ''
217
+ const runner = json?.tasksRunnerOptions?.default?.runner
218
+ return (
219
+ set(json?.nxCloudId) ||
220
+ set(json?.nxCloudAccessToken) ||
221
+ (typeof runner === 'string' && /(^|\/)nx-cloud$/.test(runner))
222
+ )
223
+ }
224
+
198
225
  /** The variable each runner's self-hosted remote cache is set by, as its plugin reads it. */
199
226
  const REMOTE_CACHE_ENV = { turbo: 'TURBO_TOKEN', nx: 'NX_SELF_HOSTED_REMOTE_CACHE_SERVER' } as const
200
227
 
@@ -202,7 +229,7 @@ const CI_FILES = ['.gitlab-ci.yml', '.circleci/config.yml']
202
229
 
203
230
  /**
204
231
  * Where the repo shows a remote cache its runner uses, or undefined: turbo.json's
205
- * enabled `remoteCache`, or a CI file that sets the runner's cache variable (a
232
+ * enabled `remoteCache`, a `turbo link`ed `.turbo/config.json`, or a CI file that sets the runner's cache variable (a
206
233
  * local repo holds no token; CI does).
207
234
  */
208
235
  function remoteCacheSignal(root: string, runner: 'turbo' | 'nx'): string | undefined {
@@ -222,6 +249,21 @@ function remoteCacheSignal(root: string, runner: 'turbo' | 'nx'): string | undef
222
249
  return `${f} names a remoteCache`
223
250
  }
224
251
  }
252
+ // `turbo link` writes the team here (gitignored, on the machine that
253
+ // linked); turboCache() reads it, so a linked repo has a remote cache.
254
+ let linked: unknown
255
+ try {
256
+ linked = JSON.parse(readFileSync(path.join(root, '.turbo', 'config.json'), 'utf8'))
257
+ } catch {}
258
+ if (
259
+ typeof linked === 'object' &&
260
+ linked !== null &&
261
+ Object.entries(linked).some(
262
+ ([k, v]) => /^(teamid|teamslug|token)$/i.test(k) && typeof v === 'string' && v !== '',
263
+ )
264
+ ) {
265
+ return '.turbo/config.json links a team (turbo link)'
266
+ }
225
267
  }
226
268
  const variable = REMOTE_CACHE_ENV[runner]
227
269
  // A line that sets it (`TURBO_TOKEN: …`, `TURBO_TOKEN=…`), not one that