@vltpkg/cli-sdk 1.0.0-rc.22 → 1.0.0-rc.24

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.
Files changed (103) hide show
  1. package/dist/commands/bugs.d.ts +17 -0
  2. package/dist/commands/bugs.js +163 -0
  3. package/dist/commands/build.d.ts +24 -0
  4. package/dist/commands/build.js +101 -0
  5. package/dist/commands/cache.d.ts +64 -0
  6. package/dist/commands/cache.js +256 -0
  7. package/dist/commands/ci.d.ts +10 -0
  8. package/dist/commands/ci.js +40 -0
  9. package/dist/commands/config.d.ts +5 -0
  10. package/dist/commands/config.js +429 -0
  11. package/dist/commands/create.d.ts +8 -0
  12. package/dist/commands/create.js +102 -0
  13. package/dist/commands/docs.d.ts +17 -0
  14. package/dist/commands/docs.js +153 -0
  15. package/dist/commands/exec-cache.d.ts +48 -0
  16. package/dist/commands/exec-cache.js +145 -0
  17. package/dist/commands/exec-local.d.ts +5 -0
  18. package/dist/commands/exec-local.js +46 -0
  19. package/dist/commands/exec.d.ts +8 -0
  20. package/dist/commands/exec.js +161 -0
  21. package/dist/commands/help.d.ts +3 -0
  22. package/dist/commands/help.js +43 -0
  23. package/dist/commands/init.d.ts +7 -0
  24. package/dist/commands/init.js +116 -0
  25. package/dist/commands/install/reporter.d.ts +10 -0
  26. package/dist/commands/install/reporter.js +93 -0
  27. package/dist/commands/install.d.ts +27 -0
  28. package/dist/commands/install.js +80 -0
  29. package/dist/commands/list.d.ts +17 -0
  30. package/dist/commands/list.js +197 -0
  31. package/dist/commands/login.d.ts +3 -0
  32. package/dist/commands/login.js +22 -0
  33. package/dist/commands/logout.d.ts +3 -0
  34. package/dist/commands/logout.js +22 -0
  35. package/dist/commands/pack.d.ts +31 -0
  36. package/dist/commands/pack.js +205 -0
  37. package/dist/commands/ping.d.ts +17 -0
  38. package/dist/commands/ping.js +114 -0
  39. package/dist/commands/pkg.d.ts +6 -0
  40. package/dist/commands/pkg.js +232 -0
  41. package/dist/commands/publish.d.ts +21 -0
  42. package/dist/commands/publish.js +282 -0
  43. package/dist/commands/query.d.ts +18 -0
  44. package/dist/commands/query.js +216 -0
  45. package/dist/commands/repo.d.ts +17 -0
  46. package/dist/commands/repo.js +157 -0
  47. package/dist/commands/run-exec.d.ts +5 -0
  48. package/dist/commands/run-exec.js +40 -0
  49. package/dist/commands/run.d.ts +5 -0
  50. package/dist/commands/run.js +62 -0
  51. package/dist/commands/token.d.ts +3 -0
  52. package/dist/commands/token.js +39 -0
  53. package/dist/commands/uninstall.d.ts +15 -0
  54. package/dist/commands/uninstall.js +39 -0
  55. package/dist/commands/update.d.ts +13 -0
  56. package/dist/commands/update.js +46 -0
  57. package/dist/commands/version.d.ts +25 -0
  58. package/dist/commands/version.js +252 -0
  59. package/dist/commands/view.d.ts +22 -0
  60. package/dist/commands/view.js +334 -0
  61. package/dist/commands/whoami.d.ts +12 -0
  62. package/dist/commands/whoami.js +28 -0
  63. package/dist/config/definition.d.ts +407 -0
  64. package/dist/config/definition.js +684 -0
  65. package/dist/config/index.d.ts +218 -0
  66. package/dist/config/index.js +488 -0
  67. package/dist/config/merge.d.ts +3 -0
  68. package/dist/config/merge.js +27 -0
  69. package/dist/config/usage.d.ts +18 -0
  70. package/dist/config/usage.js +39 -0
  71. package/dist/custom-help.d.ts +8 -0
  72. package/dist/custom-help.js +419 -0
  73. package/dist/exec-command.d.ts +52 -0
  74. package/dist/exec-command.js +313 -0
  75. package/dist/index.d.ts +3 -0
  76. package/dist/index.js +72 -0
  77. package/dist/load-command.d.ts +15 -0
  78. package/dist/load-command.js +20 -0
  79. package/dist/mermaid-image-view.d.ts +18 -0
  80. package/dist/mermaid-image-view.js +36 -0
  81. package/dist/output.d.ts +20 -0
  82. package/dist/output.js +125 -0
  83. package/dist/pack-tarball.d.ts +23 -0
  84. package/dist/pack-tarball.js +256 -0
  85. package/dist/parse-add-remove-args.d.ts +28 -0
  86. package/dist/parse-add-remove-args.js +103 -0
  87. package/dist/print-err.d.ts +13 -0
  88. package/dist/print-err.js +193 -0
  89. package/dist/query-diff-files.d.ts +17 -0
  90. package/dist/query-diff-files.js +63 -0
  91. package/dist/query-host-contexts.d.ts +15 -0
  92. package/dist/query-host-contexts.js +136 -0
  93. package/dist/read-password.d.ts +7 -0
  94. package/dist/read-password.js +32 -0
  95. package/dist/read-project-folders.d.ts +17 -0
  96. package/dist/read-project-folders.js +100 -0
  97. package/dist/reload-config.d.ts +2 -0
  98. package/dist/reload-config.js +11 -0
  99. package/dist/render-mermaid.d.ts +22 -0
  100. package/dist/render-mermaid.js +68 -0
  101. package/dist/view.d.ts +29 -0
  102. package/dist/view.js +30 -0
  103. package/package.json +30 -30
@@ -0,0 +1,684 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { XDG } from '@vltpkg/xdg';
3
+ import { jack } from 'jackspeak';
4
+ export const defaultView =
5
+ // If stdout is a TTY, use human output
6
+ process.stdout.isTTY ? 'human'
7
+ // If its not a TTY but is a CI environment, use human output
8
+ // TODO: make a better view option for CI environments
9
+ : process.env.CI ? 'human'
10
+ // Otherwise, use json output
11
+ : 'json';
12
+ export const defaultEditor = () => process.env.EDITOR ||
13
+ process.env.VISUAL ||
14
+ (process.platform === 'win32' ?
15
+ `${process.env.SYSTEMROOT}\\notepad.exe`
16
+ : 'vi');
17
+ const canonicalCommands = {
18
+ bugs: 'bugs',
19
+ build: 'build',
20
+ cache: 'cache',
21
+ ci: 'ci',
22
+ config: 'config',
23
+ create: 'create',
24
+ docs: 'docs',
25
+ exec: 'exec',
26
+ 'exec-local': 'exec-local',
27
+ help: 'help',
28
+ init: 'init',
29
+ install: 'install',
30
+ login: 'login',
31
+ logout: 'logout',
32
+ list: 'list',
33
+ ls: 'ls',
34
+ pack: 'pack',
35
+ ping: 'ping',
36
+ pkg: 'pkg',
37
+ publish: 'publish',
38
+ query: 'query',
39
+ repo: 'repo',
40
+ 'run-exec': 'run-exec',
41
+ run: 'run',
42
+ token: 'token',
43
+ uninstall: 'uninstall',
44
+ update: 'update',
45
+ 'exec-cache': 'exec-cache',
46
+ version: 'version',
47
+ view: 'view',
48
+ whoami: 'whoami',
49
+ };
50
+ const aliases = {
51
+ i: 'install',
52
+ add: 'install',
53
+ rm: 'uninstall',
54
+ u: 'update',
55
+ p: 'pkg',
56
+ pub: 'publish',
57
+ q: 'query',
58
+ b: 'build',
59
+ r: 'run',
60
+ 'run-script': 'run',
61
+ rx: 'run-exec',
62
+ x: 'exec',
63
+ xl: 'exec-local',
64
+ h: 'help',
65
+ '?': 'help',
66
+ info: 'view',
67
+ ls: 'list',
68
+ show: 'view',
69
+ xc: 'exec-cache',
70
+ };
71
+ /**
72
+ * Command aliases mapped to their canonical names
73
+ */
74
+ export const commands = {
75
+ ...canonicalCommands,
76
+ ...aliases,
77
+ };
78
+ /**
79
+ * Canonical command names mapped to an array of its aliases
80
+ */
81
+ export const commandAliases = Object.entries(aliases).reduce((acc, [alias, canonical]) => {
82
+ const commandAliases = acc.get(canonical);
83
+ if (commandAliases) {
84
+ commandAliases.push(alias);
85
+ }
86
+ else {
87
+ acc.set(canonical, [alias]);
88
+ }
89
+ return acc;
90
+ }, new Map());
91
+ export const getCommand = (s) => s && s in commands ? commands[s] : undefined;
92
+ const xdg = new XDG('vlt');
93
+ const cacheDir = xdg.cache();
94
+ /**
95
+ * Fields that are parsed as a set of key=value pairs
96
+ */
97
+ export const recordFields = [
98
+ 'git-hosts',
99
+ 'registries',
100
+ 'git-host-archives',
101
+ 'scope-registries',
102
+ 'jsr-registries',
103
+ ];
104
+ export const isRecordField = (s) => recordFields.includes(s);
105
+ const stopParsingCommands = [
106
+ 'create',
107
+ 'run',
108
+ 'run-exec',
109
+ 'exec-local',
110
+ 'exec',
111
+ ];
112
+ let stopParsing = undefined;
113
+ const j = jack({
114
+ envPrefix: 'VLT',
115
+ allowPositionals: true,
116
+ usage: `vlt [<options>] [<cmd> [<args> ...]]`,
117
+ stopAtPositionalTest: arg => {
118
+ if (stopParsing)
119
+ return true;
120
+ const a = arg;
121
+ // we stop parsing AFTER the thing, so you can do
122
+ // vlt run --vlt --configs scriptName --args --for --script
123
+ // or
124
+ // vlt exec --vlt --configs command --args --for --command
125
+ if (stopParsingCommands.includes(commands[a])) {
126
+ stopParsing = true;
127
+ }
128
+ return false;
129
+ },
130
+ })
131
+ .heading('vlt')
132
+ .description(`More documentation available at <https://docs.vlt.sh>`)
133
+ .heading('Subcommands');
134
+ j.description(Object.keys(canonicalCommands).join(', '), {
135
+ pre: true,
136
+ }).description('Run `vlt <cmd> --help` for more information about a specific command');
137
+ export const definition = j
138
+ /**
139
+ * Definition of all configuration values used by vlt.
140
+ */
141
+ .heading('Configuration')
142
+ .description(`If a \`vlt.json\` file is present in the root of the current project,
143
+ then that will be used as a source of configuration information.
144
+
145
+ Next, the \`vlt.json\` file in the XDG specified config directory
146
+ will be checked, and loaded for any fields not set in the local project.
147
+
148
+ Object type values will be merged together. Set a field to \`null\` in
149
+ the JSON configuration to explicitly remove it.
150
+
151
+ Command-specific fields may be set in a nested \`command\` object that
152
+ overrides any options defined at the top level.
153
+ `)
154
+ .flag({
155
+ color: {
156
+ short: 'c',
157
+ description: 'Use colors (Default for TTY)',
158
+ },
159
+ 'no-color': {
160
+ short: 'C',
161
+ description: 'Do not use colors (Default for non-TTY)',
162
+ },
163
+ })
164
+ .opt({
165
+ registry: {
166
+ hint: 'url',
167
+ default: 'https://registry.npmjs.org/',
168
+ description: `Sets the registry for fetching packages, when no registry
169
+ is explicitly set on a specifier.
170
+
171
+ For example, \`express@latest\` will be resolved by looking
172
+ up the metadata from this registry.
173
+
174
+ Note that alias specifiers starting with \`npm:\` will
175
+ still map to \`https://registry.npmjs.org/\` if this is
176
+ changed, unless the a new mapping is created via the
177
+ \`--registries\` option.
178
+ `,
179
+ },
180
+ })
181
+ .optList({
182
+ registries: {
183
+ hint: 'name=url',
184
+ description: `Specify named registry hosts by their prefix. To set the
185
+ default registry used for non-namespaced specifiers,
186
+ use the \`--registry\` option.
187
+
188
+ Prefixes can be used as a package alias. For example:
189
+
190
+ \`\`\`
191
+ vlt --registries loc=http://reg.local install foo@loc:foo@1.x
192
+ \`\`\`
193
+
194
+ By default, the public npm registry is registered to the
195
+ \`npm:\` prefix. It is not recommended to change this
196
+ mapping in most cases.
197
+ `,
198
+ },
199
+ 'scope-registries': {
200
+ hint: '@scope=url',
201
+ description: `Map package name scopes to registry URLs.
202
+
203
+ For example,
204
+ \`--scope-registries @acme=https://registry.acme/\`
205
+ would tell vlt to fetch any packages named
206
+ \`@acme/...\` from the \`https://registry.acme/\`
207
+ registry.
208
+
209
+ Note: this way of specifying registries is more ambiguous,
210
+ compared with using the \`--registries\` field and explicit
211
+ prefixes, because instead of failing when the configuration
212
+ is absent, it will instead attempt to fetch from the
213
+ default registry.
214
+
215
+ By comparison, using
216
+ \`--registries acme=https://registry.acme/\` and then
217
+ specifying dependencies such as \`"foo": "acme:foo@1.x"\`
218
+ means that regardless of the name, the package will be
219
+ fetched from the explicitly named registry, or fail if
220
+ no registry is defined with that name.
221
+
222
+ However, custom registry aliases are not supported by other
223
+ package managers.`,
224
+ },
225
+ 'jsr-registries': {
226
+ hint: 'name=url',
227
+ description: `Map alias names to JSR.io registry urls.
228
+
229
+ For example,
230
+ \`--jsr-registries acme=https://jsr.acme.io/\` would
231
+ tell vlt to fetch any packages with the \`acme:\` registry
232
+ prefix from the \`https://jsr.acme.io/\` registry, using
233
+ the "npm Compatibility" translation. So for example,
234
+ the package \`acme:@foo/bar\` would fetch the
235
+ \`@jsr/foo__bar\` package from the \`jsr.acme.io\`
236
+ registry.
237
+
238
+ By default the \`jsr\` alias is always mapped to
239
+ \`https://npm.jsr.io/\`, so existing \`jsr:\` packages will
240
+ be fetched from the public \`jsr\` registry appropriately.
241
+ `,
242
+ },
243
+ 'git-hosts': {
244
+ hint: `name=template`,
245
+ short: 'G',
246
+ description: `Map a shorthand name to a git remote URL template.
247
+
248
+ The \`template\` may contain placeholders, which will be
249
+ swapped with the relevant values.
250
+
251
+ \`$1\`, \`$2\`, etc. are replaced with the appropriate
252
+ n-th path portion. For example, \`github:user/project\`
253
+ would replace the \`$1\` in the template with \`user\`,
254
+ and \`$2\` with \`project\`.`,
255
+ },
256
+ 'git-host-archives': {
257
+ hint: `name=template`,
258
+ short: 'A',
259
+ description: `Similar to the \`--git-host <name>=<template>\` option,
260
+ this option can define a template string that will be
261
+ expanded to provide the URL to download a pre-built
262
+ tarball of the git repository.
263
+
264
+ In addition to the n-th path portion expansions performed
265
+ by \`--git-host\`, this field will also expand the
266
+ string \`$committish\` in the template, replacing it with
267
+ the resolved git committish value to be fetched.`,
268
+ },
269
+ })
270
+ .opt({
271
+ cache: {
272
+ hint: 'path',
273
+ description: `
274
+ Location of the vlt on-disk cache. Defaults to the platform-specific
275
+ directory recommended by the XDG specification.
276
+ `,
277
+ default: cacheDir,
278
+ },
279
+ tag: {
280
+ description: `Default \`dist-tag\` to install or publish`,
281
+ default: 'latest',
282
+ },
283
+ before: {
284
+ hint: 'date',
285
+ description: `Do not install any packages published after this date`,
286
+ },
287
+ os: {
288
+ description: `The operating system to use as the selector when choosing
289
+ packages based on their \`os\` value.`,
290
+ default: process.platform,
291
+ },
292
+ arch: {
293
+ description: `CPU architecture to use as the selector when choosing
294
+ packages based on their \`cpu\` value.`,
295
+ default: process.arch,
296
+ },
297
+ libc: {
298
+ description: `Override the libc family to use as the selector when choosing
299
+ packages based on their \`libc\` value (e.g. glibc, musl).
300
+ By default, this is auto-detected on Linux systems.`,
301
+ },
302
+ 'node-version': {
303
+ hint: 'version',
304
+ description: `Node version to use when choosing packages based on
305
+ their \`engines.node\` value.`,
306
+ default: process.version,
307
+ },
308
+ })
309
+ .flag({
310
+ 'git-shallow': {
311
+ description: `Set to force \`--depth=1\` on all git clone actions.
312
+ When set explicitly to false with --no-git-shallow,
313
+ then \`--depth=1\` will not be used.
314
+
315
+ When not set explicitly, \`--depth=1\` will be used for
316
+ git hosts known to support this behavior.`,
317
+ },
318
+ })
319
+ .num({
320
+ 'fetch-retries': {
321
+ hint: 'n',
322
+ description: `Number of retries to perform when encountering network
323
+ errors or likely-transient errors from git hosts.`,
324
+ default: 3,
325
+ },
326
+ 'fetch-retry-factor': {
327
+ hint: 'n',
328
+ description: `The exponential backoff factor to use when retrying
329
+ requests due to network issues.`,
330
+ default: 2,
331
+ },
332
+ 'fetch-retry-mintimeout': {
333
+ hint: 'n',
334
+ description: `Number of milliseconds before starting first retry`,
335
+ default: 0,
336
+ },
337
+ 'fetch-retry-maxtimeout': {
338
+ hint: 'n',
339
+ description: `Maximum number of milliseconds between two retries`,
340
+ default: 30_000,
341
+ },
342
+ 'stale-while-revalidate-factor': {
343
+ hint: 'n',
344
+ default: 60,
345
+ description: `If the server does not serve a \`stale-while-revalidate\`
346
+ value in the \`cache-control\` header, then this multiplier
347
+ is applied to the \`max-age\` or \`s-maxage\` values.
348
+
349
+ By default, this is \`60\`, so for example a response that
350
+ is cacheable for 5 minutes will allow a stale response
351
+ while revalidating for up to 5 hours.
352
+
353
+ If the server *does* provide a \`stale-while-revalidate\`
354
+ value, then that is always used.
355
+
356
+ Set to 0 to prevent any \`stale-while-revalidate\` behavior
357
+ unless explicitly allowed by the server's \`cache-control\`
358
+ header.
359
+ `,
360
+ },
361
+ })
362
+ .opt({
363
+ identity: {
364
+ short: 'i',
365
+ validate: (v) => typeof v === 'string' && /^[a-z0-9]*$/.test(v),
366
+ hint: 'name',
367
+ default: '',
368
+ description: `Provide a string to define an identity for storing auth
369
+ information when logging into registries.
370
+
371
+ Authentication tokens will be stored in the XDG data
372
+ directory, in \`vlt/auth/$\{identity}/keychain.json\`.
373
+
374
+ If no identity is provided, then the default \`''\` will
375
+ be used, storing the file at \`vlt/auth/keychain.json\`.
376
+
377
+ May only contain lowercase alphanumeric characters.
378
+ `,
379
+ },
380
+ })
381
+ .optList({
382
+ workspace: {
383
+ hint: 'ws',
384
+ short: 'w',
385
+ description: `Set to limit the spaces being worked on when working on
386
+ workspaces.
387
+
388
+ Can be paths or glob patterns matching paths.
389
+
390
+ Specifying workspaces by package.json name is not
391
+ supported.`,
392
+ },
393
+ 'workspace-group': {
394
+ description: `Specify named workspace group names to load and operate on
395
+ when doing recursive operations on workspaces.`,
396
+ },
397
+ })
398
+ .opt({
399
+ scope: {
400
+ short: 's',
401
+ hint: 'query',
402
+ description: 'Set to filter the scope of an operation using a DSS Query.',
403
+ },
404
+ target: {
405
+ short: 't',
406
+ hint: 'query',
407
+ description: 'Set to select packages using a DSS Query selector.',
408
+ },
409
+ })
410
+ .flag({
411
+ 'if-present': {
412
+ description: `When running scripts across multiple packages,
413
+ only include packages that have the script.
414
+
415
+ If this is not set, then the run will fail if any
416
+ packages do not have the script.
417
+
418
+ This will default to true if --scope, --workspace,
419
+ --workspace-group, or --recursive is set. Otherwise,
420
+ it will default to false.`,
421
+ },
422
+ })
423
+ .flag({
424
+ recursive: {
425
+ short: 'r',
426
+ description: `Run an operation across multiple workspaces.
427
+
428
+ No effect when used in non-monorepo projects.
429
+
430
+ Implied by setting --workspace or --workspace-group. If
431
+ not set, then the action is run on the project root.`,
432
+ },
433
+ bail: {
434
+ short: 'b',
435
+ description: `When running scripts across multiple workspaces, stop
436
+ on the first failure.`,
437
+ default: true,
438
+ },
439
+ 'no-bail': {
440
+ short: 'B',
441
+ description: `When running scripts across multiple workspaces, continue
442
+ on failure, running the script for all workspaces.`,
443
+ },
444
+ })
445
+ .opt({
446
+ config: {
447
+ hint: 'all | user | project',
448
+ description: `Specify which configuration to show or operate on when running
449
+ \`vlt config\` commands. For read operations (get, pick, list):
450
+ \`all\` shows merged configuration from both user and project
451
+ files (default). For write operations (set, delete, edit):
452
+ defaults to \`project\`. \`user\` shows/modifies only user-level
453
+ configuration, \`project\` shows/modifies only project-level
454
+ configuration.`,
455
+ validOptions: ['all', 'user', 'project'],
456
+ default: 'all',
457
+ },
458
+ editor: {
459
+ hint: 'program',
460
+ description: `The blocking editor to use for \`vlt config edit\` and
461
+ any other cases where a file should be opened for
462
+ editing.
463
+
464
+ Defaults to the \`EDITOR\` or \`VISUAL\` env if set, or
465
+ \`notepad.exe\` on Windows, or \`vi\` elsewhere.`,
466
+ default: defaultEditor(),
467
+ },
468
+ 'script-shell': {
469
+ hint: 'program',
470
+ description: `The shell to use when executing \`package.json#scripts\`.
471
+
472
+ For \`vlt exec\` and \`vlt exec-local\`, this is never set,
473
+ meaning that command arguments are run exactly as provided.
474
+
475
+ For \`vlt run\` (and other things that run lifecycle
476
+ scripts in \`package.json#scripts\`), the entire command
477
+ with all arguments is provided as a single string, meaning
478
+ that some value must be provided for shell interpretation,
479
+ and so for these contexts, the \`script-shell\` value will
480
+ default to \`/bin/sh\` on POSIX systems or \`cmd.exe\` on
481
+ Windows.
482
+ `,
483
+ },
484
+ 'fallback-command': {
485
+ hint: 'command',
486
+ description: `The command to run when the first argument doesn't
487
+ match any known commands.
488
+
489
+ For pnpm-style behavior, set this to 'run-exec'. e.g:
490
+ \`\`\`
491
+ vlt config set fallback-command=run-exec
492
+ \`\`\``,
493
+ default: 'help',
494
+ validOptions: Object.keys(canonicalCommands),
495
+ },
496
+ })
497
+ .opt({
498
+ package: {
499
+ hint: 'p',
500
+ description: `When running \`vlt exec\`, this allows you to explicitly
501
+ set the package to search for bins. If not provided, then
502
+ vlt will interpret the first argument as the package, and
503
+ attempt to run the default executable.`,
504
+ },
505
+ })
506
+ .opt({
507
+ call: {
508
+ hint: 'cmd',
509
+ description: `When running \`vlt exec\`, provide an arbitrary command
510
+ string to execute after installing and adding any specified
511
+ package bins to the PATH.
512
+
513
+ If a package is specified (via positionals or
514
+ \`--package\`), it will be installed and its executables
515
+ added to the PATH before the \`--call\` command runs.
516
+
517
+ The command string is executed via the configured
518
+ \`script-shell\`, or the \`SHELL\` environment variable,
519
+ falling back to \`/bin/sh\` on Unix or \`cmd.exe\` on
520
+ Windows. On Unix, the shell is invoked with \`-c\`; on
521
+ Windows with \`/c\`.
522
+
523
+ Example:
524
+ \`vlt exec create-react-app --call="echo $PWD"\`
525
+ \`vlt exec --call="echo $PWD" --scope=":workspace"\``,
526
+ },
527
+ })
528
+ .opt({
529
+ view: {
530
+ hint: 'output',
531
+ default: defaultView,
532
+ description: `Configures the output format for commands.
533
+
534
+ Defaults to \`human\` if stdout is a TTY, or \`json\`
535
+ if it is not.
536
+
537
+ - human: Maximally ergonomic output reporting for human
538
+ consumption.
539
+ - json: Parseable JSON output for machines.
540
+ - inspect: Output results with \`util.inspect\`.
541
+ - mermaid: Output mermaid diagramming syntax. (Only
542
+ relevant for certain commands.)
543
+ - svg: Render the dependency graph as an SVG image and
544
+ open it. (Only relevant for certain commands.)
545
+ - png: Render the dependency graph as a PNG image and
546
+ open it. (Only relevant for certain commands.)
547
+ - count: Output the number of dependency relationships in
548
+ the result set.
549
+ - silent: Suppress all output to stdout.
550
+
551
+ If the requested view format is not supported for the
552
+ current command, or if no option is provided, then it
553
+ will fall back to the default.
554
+ `,
555
+ validOptions: [
556
+ 'human',
557
+ 'json',
558
+ 'mermaid',
559
+ 'svg',
560
+ 'png',
561
+ 'count',
562
+ 'inspect',
563
+ 'silent',
564
+ ],
565
+ },
566
+ })
567
+ .optList({
568
+ 'dashboard-root': {
569
+ hint: 'path',
570
+ description: `The root directory to use for the dashboard browser-based UI.
571
+ If not set, the user home directory is used.`,
572
+ },
573
+ })
574
+ .flag({
575
+ 'save-dev': {
576
+ short: 'D',
577
+ description: `Save installed packages to a package.json file as
578
+ devDependencies`,
579
+ },
580
+ 'save-optional': {
581
+ short: 'O',
582
+ description: `Save installed packages to a package.json file as
583
+ optionalDependencies`,
584
+ },
585
+ 'save-peer': {
586
+ description: `Save installed packages to a package.json file as
587
+ peerDependencies`,
588
+ },
589
+ 'save-prod': {
590
+ short: 'P',
591
+ description: `Save installed packages into dependencies specifically.
592
+ This is useful if a package already exists in
593
+ devDependencies or optionalDependencies, but you want to
594
+ move it to be a non-optional production dependency.`,
595
+ },
596
+ })
597
+ .opt({
598
+ 'expect-results': {
599
+ hint: 'value',
600
+ validate: (v) => typeof v === 'string' && /^([<>]=?)?[0-9]+$/.test(v),
601
+ description: `When running \`vlt query\`, this option allows you to
602
+ set a expected number of resulting items.
603
+
604
+ Accepted values are numbers and strings.
605
+
606
+ Strings starting with \`>\`, \`<\`, \`>=\` or \`<=\`
607
+ followed by a number can be used to check if the result
608
+ is greater than or less than a specific number.`,
609
+ },
610
+ })
611
+ .flag({
612
+ 'dry-run': {
613
+ description: 'Run command without making any changes',
614
+ },
615
+ 'expect-lockfile': {
616
+ description: 'Fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.',
617
+ },
618
+ 'frozen-lockfile': {
619
+ description: 'Fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications.',
620
+ },
621
+ 'lockfile-only': {
622
+ description: 'Only update the lockfile (vlt-lock.json) and package.json files, skip all node_modules operations including package extraction and filesystem changes.',
623
+ },
624
+ })
625
+ .opt({
626
+ 'allow-scripts': {
627
+ hint: 'query',
628
+ description: `Filter which packages are allowed to run lifecycle scripts using DSS query syntax.
629
+ When provided, only packages matching the query will execute their
630
+ install, preinstall, postinstall, prepare, preprepare, and postprepare scripts.
631
+ Defaults to ':not(*)' which means no scripts will be run.
632
+
633
+ Example: --allow-scripts=":root > *, #my-package"
634
+ Runs scripts only for direct dependencies of the current project and any occurrences
635
+ of a specific dependency with the name "my-package" anywhere in the dependency graph.`,
636
+ },
637
+ })
638
+ .opt({
639
+ access: {
640
+ description: 'Set the access level of the package',
641
+ validOptions: ['public', 'restricted'],
642
+ },
643
+ })
644
+ .opt({
645
+ otp: {
646
+ description: `Provide an OTP to use when publishing a package.`,
647
+ },
648
+ 'publish-directory': {
649
+ hint: 'path',
650
+ description: `Directory to use for pack and publish operations instead of the current directory.
651
+ The directory must exist and nothing will be copied to it.`,
652
+ },
653
+ })
654
+ .flag({
655
+ yes: {
656
+ short: 'y',
657
+ description: `Automatically accept any confirmation prompts`,
658
+ },
659
+ version: {
660
+ short: 'v',
661
+ description: 'Print the version',
662
+ },
663
+ help: {
664
+ short: 'h',
665
+ description: 'Print helpful information',
666
+ },
667
+ all: {
668
+ short: 'a',
669
+ description: 'Show all commands, bins, and flags',
670
+ },
671
+ });
672
+ export const getSortedCliOptions = () => {
673
+ const defs = definition.toJSON();
674
+ return getSortedKeys().map((k) => {
675
+ const def = defs[k];
676
+ /* c8 ignore next */
677
+ if (!def)
678
+ throw error('invalid key found', { found: k });
679
+ if (def.type === 'boolean')
680
+ return `--${k}`;
681
+ return `--${k}=<${def.hint ?? k}>`;
682
+ });
683
+ };
684
+ export const getSortedKeys = () => Object.keys(definition.toJSON()).sort((a, b) => a.localeCompare(b));