@vzn/vx 0.0.38 → 0.0.40

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.38",
3
+ "version": "0.0.40",
4
4
  "description": "An open, extensible monorepo task runner.",
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.38",
21
- "@vzn/vx-linux-arm64": "0.0.38",
22
- "@vzn/vx-darwin-x64": "0.0.38",
23
- "@vzn/vx-darwin-arm64": "0.0.38"
20
+ "@vzn/vx-linux-x64": "0.0.40",
21
+ "@vzn/vx-linux-arm64": "0.0.40",
22
+ "@vzn/vx-darwin-x64": "0.0.40",
23
+ "@vzn/vx-darwin-arm64": "0.0.40"
24
24
  },
25
25
  "dependencies": {
26
26
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
package/src/cli/help.ts CHANGED
@@ -49,7 +49,7 @@ export function helpText(pluginCommands: readonly string[] = []): string {
49
49
  ' vx why [TASK | PKG#TASK] [--run <runId>] [--format pretty|json] [--cache-dir <path>]',
50
50
  ' vx last [RUNID] [--list[=N]] [--format pretty|json] [--cache-dir <path>]',
51
51
  ' vx completions bash|zsh|fish',
52
- ' vx help',
52
+ ' vx help [VERB]',
53
53
  ' vx version',
54
54
  '',
55
55
  'Selection (for run):',
package/src/cli/index.ts CHANGED
@@ -32,9 +32,17 @@ export async function run(argv: readonly string[]): Promise<number> {
32
32
  case undefined:
33
33
  case '--help':
34
34
  case '-h':
35
- case 'help':
36
35
  printHelp(await pluginCommandHelp())
37
36
  return 0
37
+ case 'help': {
38
+ // `vx help run` is the same question as `vx run --help`. A plugin verb
39
+ // owns its own help, so anything but a core verb gets the whole
40
+ // reference, which lists the plugin verbs.
41
+ const verb = rest[0]
42
+ const core = verb !== undefined && (CORE_VERBS as readonly string[]).includes(verb)
43
+ printHelp(await pluginCommandHelp(), core ? verb : undefined)
44
+ return 0
45
+ }
38
46
  case '--version':
39
47
  case 'version':
40
48
  process.stdout.write(`vx ${VERSION}\n`)
package/src/cli/last.ts CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  listInvocations,
15
15
  type RunSummaryRow,
16
16
  } from '../orchestrator/index.js'
17
- import { UserError } from '../util/index.js'
17
+ import { formatElapsed, UserError } from '../util/index.js'
18
18
  import { findWorkspaceRoot } from '../workspace/index.js'
19
19
  import { cliCacheDir, parseCacheDirFlag, warnToStderr } from './workspace-config.js'
20
20
 
@@ -78,12 +78,7 @@ export function parseLastArgs(args: readonly string[]): LastArgs {
78
78
 
79
79
  const fmtWhen = (ms: number): string => new Date(ms).toISOString()
80
80
 
81
- function fmtMs(ms: number): string {
82
- if (ms < 1000) return `${Math.round(ms)}ms`
83
- if (ms < 60_000) return `${(ms / 1000).toFixed(2)}s`
84
- const m = Math.floor(ms / 60_000)
85
- return `${m}m ${Math.round((ms - m * 60_000) / 1000)}s`
86
- }
81
+ const fmtMs = (ms: number): string => formatElapsed(ms, true)
87
82
 
88
83
  /**
89
84
  * What an executed task used — its peak RSS and its CPU parallelism (CPU
@@ -8,6 +8,7 @@ import type { FlakyFinding } from './failure-mode.js'
8
8
  import { paint, type ColorSupport } from './colors.js'
9
9
  import { tallyOutcomes } from './tally.js'
10
10
  import { isGroupTask } from '../graph/index.js'
11
+ import { formatElapsed } from '../util/index.js'
11
12
 
12
13
  const NO_COLOR: ColorSupport = { enabled: false }
13
14
 
@@ -421,6 +422,5 @@ export function formatFlakySection(findings: readonly FlakyFinding[]): string[]
421
422
  }
422
423
 
423
424
  export function formatDuration(ms: number): string {
424
- if (ms < 1000) return `${Math.round(ms)}ms`
425
- return `${(ms / 1000).toFixed(2)}s`
425
+ return formatElapsed(ms)
426
426
  }
package/src/util/index.ts CHANGED
@@ -17,7 +17,7 @@ export {
17
17
  } from './errors.js'
18
18
  export { xxh3, xxh3hex } from './hash.js'
19
19
  export { mark, printTimings, span } from './timing.js'
20
- export { clampInt, MAX_TIMEOUT_MS, parseDecimalInt } from './num.js'
20
+ export { clampInt, formatElapsed, MAX_TIMEOUT_MS, parseDecimalInt } from './num.js'
21
21
  export {
22
22
  asTrees,
23
23
  BUN_GLOB_WILDCARDS,
package/src/util/num.ts CHANGED
@@ -35,3 +35,17 @@ export function parseDecimalInt(input: string): number | null {
35
35
  const n = Number(input)
36
36
  return Number.isSafeInteger(n) ? n : null
37
37
  }
38
+
39
+ /**
40
+ * `ms` as vx prints a duration: whole milliseconds below a second, seconds
41
+ * to two places, and with `minutes` whole minutes and seconds from a
42
+ * minute on. Rounded to the unit shown BEFORE the unit is chosen: 999.6 ms
43
+ * printed `1000ms`, 59,996 ms `60.00s` and 119,600 ms `1m 60s` (item 1034).
44
+ */
45
+ export function formatElapsed(ms: number, minutes = false): string {
46
+ if (Math.round(ms) < 1000) return `${Math.round(ms)}ms`
47
+ const hundredths = Math.round(ms / 10)
48
+ if (!minutes || hundredths < 6000) return `${(hundredths / 100).toFixed(2)}s`
49
+ const s = Math.round(ms / 1000)
50
+ return `${Math.floor(s / 60)}m ${s % 60}s`
51
+ }