@vzn/vx 0.0.475 → 0.0.476

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.475",
3
+ "version": "0.0.476",
4
4
  "description": "The fastest task runner and build cache for JavaScript monorepos.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,10 +21,10 @@
21
21
  "node": ">=18"
22
22
  },
23
23
  "optionalDependencies": {
24
- "@vzn/vx-linux-x64": "0.0.475",
25
- "@vzn/vx-linux-arm64": "0.0.475",
26
- "@vzn/vx-darwin-x64": "0.0.475",
27
- "@vzn/vx-darwin-arm64": "0.0.475"
24
+ "@vzn/vx-linux-x64": "0.0.476",
25
+ "@vzn/vx-linux-arm64": "0.0.476",
26
+ "@vzn/vx-darwin-x64": "0.0.476",
27
+ "@vzn/vx-darwin-arm64": "0.0.476"
28
28
  },
29
29
  "dependencies": {
30
30
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
package/src/cli/index.ts CHANGED
@@ -165,9 +165,15 @@ export async function run(argv: readonly string[]): Promise<number> {
165
165
  }
166
166
  // A task typed where the verb goes (`turbo build`, `nx build app`),
167
167
  // `turbo dev` included: a repo's own `dev` task beats the no-service note.
168
+ const declaredVerbs =
169
+ resolved !== null && 'declaredVerbs' in resolved ? resolved.declaredVerbs : []
170
+ const guess = didYouMeanVerb(command, declaredVerbs)
171
+ // A typo of a task (`vx biuld`) names the task, unless a verb is closer.
168
172
  const task =
169
173
  loadNote === ''
170
- ? await (await import('./task-verb.js')).taskVerbHint(command, rest, process.cwd())
174
+ ? await (
175
+ await import('./task-verb.js')
176
+ ).taskVerbHint(command, rest, process.cwd(), guess === '' && !command.startsWith('-'))
171
177
  : null
172
178
  if (task !== null) {
173
179
  process.stderr.write(`vx: ${task}\n`)
@@ -207,9 +213,6 @@ export async function run(argv: readonly string[]): Promise<number> {
207
213
  )
208
214
  return 1
209
215
  }
210
- const declaredVerbs =
211
- resolved !== null && 'declaredVerbs' in resolved ? resolved.declaredVerbs : []
212
- const guess = didYouMeanVerb(command, declaredVerbs)
213
216
  process.stderr.write(
214
217
  `vx: unknown command: ${command}${guess}${loadNote} (see \`vx help\`)\n` +
215
218
  (guess === '' && loadNote === '' ? verbSourceNote(resolved, declaredVerbs) : ''),
@@ -6,28 +6,39 @@
6
6
 
7
7
  import { nxProjectTarget, projectNamed } from '../orchestrator/index.js'
8
8
  import { findWorkspaceRoot, loadWorkspace } from '../workspace/index.js'
9
+ import { nearest } from '../util/index.js'
9
10
  import { findCwdProject } from './select.js'
10
11
  import { discoverCliProjects, loadCliProjects } from './workspace-config.js'
11
12
 
12
- /** The `vx run` a task typed as a verb means, or null when no project declares it. */
13
+ /**
14
+ * The `vx run` a task typed as a verb means, or null when no project
15
+ * declares it. With `typo`, a word a few edits from a task (`vx biuld`)
16
+ * names that task: the caller passes it only when no verb is closer.
17
+ */
13
18
  export async function taskVerbHint(
14
19
  command: string,
15
20
  rest: readonly string[],
16
21
  cwd: string,
22
+ typo = false,
17
23
  ): Promise<string | null> {
18
24
  if (command.includes('#')) return `\`${command}\` is a task: vx run ${command}`
19
25
  const projects = await workspaceProjects(cwd)
20
26
  if (projects === null) return null
21
- if (![...projects.values()].some((p) => p.config.tasks?.[command] !== undefined)) return null
27
+ const tasks = new Set<string>()
28
+ for (const p of projects.values()) for (const t of Object.keys(p.config.tasks ?? {})) tasks.add(t)
29
+ const task = tasks.has(command) ? command : typo ? nearest(command, tasks) : undefined
30
+ if (task === undefined) return null
22
31
  // Nx's `nx build app`: the word after the target is its project.
23
32
  const project = rest[0] === undefined ? undefined : projectNamed(rest[0], projects)
24
33
  const run =
25
34
  project !== undefined
26
- ? `vx run ${command} --filter ${project}`
35
+ ? `vx run ${task} --filter ${project}`
27
36
  : (await findCwdProject(cwd)) === null
28
- ? `vx run ${command} --all`
29
- : `vx run ${command}`
30
- return `\`${command}\` is a task here, not a command: ${run}`
37
+ ? `vx run ${task} --all`
38
+ : `vx run ${task}`
39
+ return task === command
40
+ ? `\`${command}\` is a task here, not a command: ${run}`
41
+ : `unknown command: ${command}; did you mean the task \`${task}\`? ${run}`
31
42
  }
32
43
 
33
44
  /**