@kaynooo/cli-kit 0.15.0 → 0.15.2

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-kit",
3
3
  "type": "module",
4
- "version": "0.15.0",
4
+ "version": "0.15.2",
5
5
  "description": "What every @kaynooo CLI shares: argument parsing with --help, a command dispatcher with typo hints and shell completion, and output formatting.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -33,6 +33,6 @@
33
33
  "registry": "https://git.kaynooo.fr/api/packages/kaynooo/npm/"
34
34
  },
35
35
  "dependencies": {
36
- "@kaynooo/utils": "^2.31.0"
36
+ "@kaynooo/utils": "^2.31.2"
37
37
  }
38
38
  }
package/src/format.ts CHANGED
@@ -30,6 +30,11 @@ export function formatDuration(ms: number): string {
30
30
  return ms < 60_000 ? `${(Math.max(0, ms) / 1000).toFixed(1)}s` : formatSeconds(ms / 1000)
31
31
  }
32
32
 
33
+ // Whole seconds counted like a clock, for a counter redrawn while it runs: tenths would change on every frame.
34
+ export function formatElapsed(ms: number): string {
35
+ return formatSeconds(Math.floor(Math.max(0, ms) / 1000))
36
+ }
37
+
33
38
  // The text up to the first separator, or all of it.
34
39
  export function upTo(text: string, separator: string): string {
35
40
  const end = text.indexOf(separator)
package/src/progress.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Colors } from './style'
2
2
  import process from 'node:process'
3
- import { formatDuration } from './format'
3
+ import { formatDuration, formatElapsed } from './format'
4
4
  import { holdSignals } from './process'
5
5
  import { marked, paint, takesControlCodes } from './style'
6
6
 
@@ -52,7 +52,7 @@ export interface ProgressLine {
52
52
  type Env = Record<string, string | undefined>
53
53
 
54
54
  const FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
55
- const FRAME_MS = 80
55
+ const FRAME_MS = 200
56
56
  const BAR_WIDTH = 20
57
57
  // Back to the start of the line, then erases it.
58
58
  const CLEAR_LINE = '\r\x1B[2K'
@@ -245,7 +245,7 @@ function progressParts({ step, done, total, unit }: Progress, spinner: string, m
245
245
  )
246
246
  }
247
247
 
248
- parts.push({ text: ` ${(ms / 1000).toFixed(1)}s`, tint: colors => colors.dim })
248
+ parts.push({ text: ` ${formatElapsed(ms)}`, tint: colors => colors.dim })
249
249
 
250
250
  return parts
251
251
  }