@vltpkg/cli-sdk 1.0.0-rc.3 → 1.0.0-rc.30

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 (210) hide show
  1. package/dist/commands/access.d.ts +22 -0
  2. package/dist/commands/access.js +246 -0
  3. package/dist/commands/bugs.d.ts +17 -0
  4. package/dist/commands/bugs.js +163 -0
  5. package/dist/{esm/commands → commands}/build.d.ts +0 -1
  6. package/dist/{esm/commands → commands}/build.js +0 -1
  7. package/dist/{esm/commands → commands}/cache.d.ts +0 -1
  8. package/dist/{esm/commands → commands}/cache.js +0 -1
  9. package/dist/{esm/commands → commands}/ci.d.ts +0 -1
  10. package/dist/{esm/commands → commands}/ci.js +11 -3
  11. package/dist/{esm/commands → commands}/config.d.ts +0 -1
  12. package/dist/{esm/commands → commands}/config.js +6 -1
  13. package/dist/commands/create.d.ts +8 -0
  14. package/dist/commands/create.js +102 -0
  15. package/dist/commands/deprecate.d.ts +13 -0
  16. package/dist/commands/deprecate.js +139 -0
  17. package/dist/commands/dist-tag.d.ts +21 -0
  18. package/dist/commands/dist-tag.js +177 -0
  19. package/dist/{esm/commands → commands}/docs.d.ts +0 -1
  20. package/dist/{esm/commands → commands}/docs.js +2 -3
  21. package/dist/{esm/commands → commands}/exec-cache.d.ts +0 -1
  22. package/dist/{esm/commands → commands}/exec-cache.js +0 -1
  23. package/dist/{esm/commands → commands}/exec-local.d.ts +0 -1
  24. package/dist/{esm/commands → commands}/exec-local.js +23 -1
  25. package/dist/{esm/commands → commands}/exec.d.ts +0 -1
  26. package/dist/{esm/commands → commands}/exec.js +84 -10
  27. package/dist/{esm/commands → commands}/help.d.ts +0 -1
  28. package/dist/{esm/commands → commands}/help.js +5 -1
  29. package/dist/{esm/commands → commands}/init.d.ts +0 -1
  30. package/dist/{esm/commands → commands}/init.js +31 -10
  31. package/dist/{esm/commands → commands}/install/reporter.d.ts +0 -1
  32. package/dist/{esm/commands → commands}/install/reporter.js +0 -1
  33. package/dist/{esm/commands → commands}/install.d.ts +21 -3
  34. package/dist/commands/install.js +140 -0
  35. package/dist/{esm/commands → commands}/list.d.ts +4 -2
  36. package/dist/{esm/commands → commands}/list.js +8 -10
  37. package/dist/{esm/commands → commands}/login.d.ts +0 -1
  38. package/dist/{esm/commands → commands}/login.js +10 -1
  39. package/dist/{esm/commands/token.d.ts → commands/logout.d.ts} +0 -1
  40. package/dist/{esm/commands → commands}/logout.js +10 -1
  41. package/dist/{esm/commands → commands}/pack.d.ts +0 -1
  42. package/dist/{esm/commands → commands}/pack.js +90 -32
  43. package/dist/commands/ping.d.ts +17 -0
  44. package/dist/commands/ping.js +114 -0
  45. package/dist/{esm/commands → commands}/pkg.d.ts +0 -1
  46. package/dist/{esm/commands → commands}/pkg.js +27 -1
  47. package/dist/commands/profile.d.ts +13 -0
  48. package/dist/commands/profile.js +104 -0
  49. package/dist/{esm/commands → commands}/publish.d.ts +1 -2
  50. package/dist/{esm/commands → commands}/publish.js +63 -12
  51. package/dist/{esm/commands → commands}/query.d.ts +4 -2
  52. package/dist/{esm/commands → commands}/query.js +12 -10
  53. package/dist/commands/repo.d.ts +17 -0
  54. package/dist/commands/repo.js +157 -0
  55. package/dist/{esm/commands → commands}/run-exec.d.ts +0 -1
  56. package/dist/commands/run-exec.js +40 -0
  57. package/dist/{esm/commands → commands}/run.d.ts +0 -1
  58. package/dist/{esm/commands → commands}/run.js +27 -1
  59. package/dist/commands/token.d.ts +31 -0
  60. package/dist/commands/token.js +186 -0
  61. package/dist/{esm/commands → commands}/uninstall.d.ts +0 -1
  62. package/dist/{esm/commands → commands}/uninstall.js +16 -3
  63. package/dist/commands/unpublish.d.ts +15 -0
  64. package/dist/commands/unpublish.js +200 -0
  65. package/dist/{esm/commands → commands}/update.d.ts +0 -1
  66. package/dist/{esm/commands → commands}/update.js +6 -1
  67. package/dist/{esm/commands → commands}/version.d.ts +0 -1
  68. package/dist/{esm/commands → commands}/version.js +27 -1
  69. package/dist/commands/view.d.ts +22 -0
  70. package/dist/commands/view.js +334 -0
  71. package/dist/{esm/commands → commands}/whoami.d.ts +0 -1
  72. package/dist/{esm/commands → commands}/whoami.js +10 -1
  73. package/dist/{esm/config → config}/definition.d.ts +39 -19
  74. package/dist/{esm/config → config}/definition.js +74 -39
  75. package/dist/{esm/config → config}/index.d.ts +0 -1
  76. package/dist/{esm/config → config}/index.js +37 -2
  77. package/dist/{esm/config → config}/merge.d.ts +0 -1
  78. package/dist/{esm/config → config}/merge.js +0 -1
  79. package/dist/{esm/config → config}/usage.d.ts +0 -1
  80. package/dist/{esm/config → config}/usage.js +0 -1
  81. package/dist/{esm/custom-help.d.ts → custom-help.d.ts} +0 -1
  82. package/dist/{esm/custom-help.js → custom-help.js} +35 -9
  83. package/dist/{esm/exec-command.d.ts → exec-command.d.ts} +0 -1
  84. package/dist/{esm/exec-command.js → exec-command.js} +14 -8
  85. package/dist/{esm/index.d.ts → index.d.ts} +0 -1
  86. package/dist/{esm/index.js → index.js} +1 -2
  87. package/dist/{esm/load-command.d.ts → load-command.d.ts} +0 -1
  88. package/dist/{esm/load-command.js → load-command.js} +0 -1
  89. package/dist/mermaid-image-view.d.ts +18 -0
  90. package/dist/mermaid-image-view.js +36 -0
  91. package/dist/{esm/output.d.ts → output.d.ts} +2 -2
  92. package/dist/{esm/output.js → output.js} +55 -2
  93. package/dist/{esm/pack-tarball.d.ts → pack-tarball.d.ts} +15 -1
  94. package/dist/{esm/pack-tarball.js → pack-tarball.js} +133 -91
  95. package/dist/{esm/parse-add-remove-args.d.ts → parse-add-remove-args.d.ts} +9 -3
  96. package/dist/{esm/parse-add-remove-args.js → parse-add-remove-args.js} +43 -11
  97. package/dist/{esm/print-err.d.ts → print-err.d.ts} +0 -1
  98. package/dist/{esm/print-err.js → print-err.js} +18 -3
  99. package/dist/query-diff-files.d.ts +17 -0
  100. package/dist/query-diff-files.js +63 -0
  101. package/dist/{esm/query-host-contexts.d.ts → query-host-contexts.d.ts} +0 -1
  102. package/dist/{esm/query-host-contexts.js → query-host-contexts.js} +8 -7
  103. package/dist/{esm/read-password.d.ts → read-password.d.ts} +0 -1
  104. package/dist/{esm/read-password.js → read-password.js} +0 -1
  105. package/dist/read-project-folders.d.ts +17 -0
  106. package/dist/read-project-folders.js +100 -0
  107. package/dist/reload-config.d.ts +2 -0
  108. package/dist/reload-config.js +11 -0
  109. package/dist/render-mermaid.d.ts +22 -0
  110. package/dist/render-mermaid.js +68 -0
  111. package/dist/telemetry.d.ts +58 -0
  112. package/dist/telemetry.js +170 -0
  113. package/dist/{esm/view.d.ts → view.d.ts} +0 -1
  114. package/dist/{esm/view.js → view.js} +1 -2
  115. package/package.json +69 -83
  116. package/dist/esm/commands/build.d.ts.map +0 -1
  117. package/dist/esm/commands/build.js.map +0 -1
  118. package/dist/esm/commands/cache.d.ts.map +0 -1
  119. package/dist/esm/commands/cache.js.map +0 -1
  120. package/dist/esm/commands/ci.d.ts.map +0 -1
  121. package/dist/esm/commands/ci.js.map +0 -1
  122. package/dist/esm/commands/config.d.ts.map +0 -1
  123. package/dist/esm/commands/config.js.map +0 -1
  124. package/dist/esm/commands/docs.d.ts.map +0 -1
  125. package/dist/esm/commands/docs.js.map +0 -1
  126. package/dist/esm/commands/exec-cache.d.ts.map +0 -1
  127. package/dist/esm/commands/exec-cache.js.map +0 -1
  128. package/dist/esm/commands/exec-local.d.ts.map +0 -1
  129. package/dist/esm/commands/exec-local.js.map +0 -1
  130. package/dist/esm/commands/exec.d.ts.map +0 -1
  131. package/dist/esm/commands/exec.js.map +0 -1
  132. package/dist/esm/commands/help.d.ts.map +0 -1
  133. package/dist/esm/commands/help.js.map +0 -1
  134. package/dist/esm/commands/init.d.ts.map +0 -1
  135. package/dist/esm/commands/init.js.map +0 -1
  136. package/dist/esm/commands/install/reporter.d.ts.map +0 -1
  137. package/dist/esm/commands/install/reporter.js.map +0 -1
  138. package/dist/esm/commands/install.d.ts.map +0 -1
  139. package/dist/esm/commands/install.js +0 -45
  140. package/dist/esm/commands/install.js.map +0 -1
  141. package/dist/esm/commands/list.d.ts.map +0 -1
  142. package/dist/esm/commands/list.js.map +0 -1
  143. package/dist/esm/commands/login.d.ts.map +0 -1
  144. package/dist/esm/commands/login.js.map +0 -1
  145. package/dist/esm/commands/logout.d.ts +0 -4
  146. package/dist/esm/commands/logout.d.ts.map +0 -1
  147. package/dist/esm/commands/logout.js.map +0 -1
  148. package/dist/esm/commands/pack.d.ts.map +0 -1
  149. package/dist/esm/commands/pack.js.map +0 -1
  150. package/dist/esm/commands/pkg.d.ts.map +0 -1
  151. package/dist/esm/commands/pkg.js.map +0 -1
  152. package/dist/esm/commands/publish.d.ts.map +0 -1
  153. package/dist/esm/commands/publish.js.map +0 -1
  154. package/dist/esm/commands/query.d.ts.map +0 -1
  155. package/dist/esm/commands/query.js.map +0 -1
  156. package/dist/esm/commands/run-exec.d.ts.map +0 -1
  157. package/dist/esm/commands/run-exec.js +0 -14
  158. package/dist/esm/commands/run-exec.js.map +0 -1
  159. package/dist/esm/commands/run.d.ts.map +0 -1
  160. package/dist/esm/commands/run.js.map +0 -1
  161. package/dist/esm/commands/serve.d.ts +0 -14
  162. package/dist/esm/commands/serve.d.ts.map +0 -1
  163. package/dist/esm/commands/serve.js +0 -103
  164. package/dist/esm/commands/serve.js.map +0 -1
  165. package/dist/esm/commands/token.d.ts.map +0 -1
  166. package/dist/esm/commands/token.js +0 -30
  167. package/dist/esm/commands/token.js.map +0 -1
  168. package/dist/esm/commands/uninstall.d.ts.map +0 -1
  169. package/dist/esm/commands/uninstall.js.map +0 -1
  170. package/dist/esm/commands/update.d.ts.map +0 -1
  171. package/dist/esm/commands/update.js.map +0 -1
  172. package/dist/esm/commands/version.d.ts.map +0 -1
  173. package/dist/esm/commands/version.js.map +0 -1
  174. package/dist/esm/commands/whoami.d.ts.map +0 -1
  175. package/dist/esm/commands/whoami.js.map +0 -1
  176. package/dist/esm/config/definition.d.ts.map +0 -1
  177. package/dist/esm/config/definition.js.map +0 -1
  178. package/dist/esm/config/index.d.ts.map +0 -1
  179. package/dist/esm/config/index.js.map +0 -1
  180. package/dist/esm/config/merge.d.ts.map +0 -1
  181. package/dist/esm/config/merge.js.map +0 -1
  182. package/dist/esm/config/usage.d.ts.map +0 -1
  183. package/dist/esm/config/usage.js.map +0 -1
  184. package/dist/esm/custom-help.d.ts.map +0 -1
  185. package/dist/esm/custom-help.js.map +0 -1
  186. package/dist/esm/exec-command.d.ts.map +0 -1
  187. package/dist/esm/exec-command.js.map +0 -1
  188. package/dist/esm/index.d.ts.map +0 -1
  189. package/dist/esm/index.js.map +0 -1
  190. package/dist/esm/load-command.d.ts.map +0 -1
  191. package/dist/esm/load-command.js.map +0 -1
  192. package/dist/esm/output.d.ts.map +0 -1
  193. package/dist/esm/output.js.map +0 -1
  194. package/dist/esm/pack-tarball.d.ts.map +0 -1
  195. package/dist/esm/pack-tarball.js.map +0 -1
  196. package/dist/esm/package.json +0 -3
  197. package/dist/esm/parse-add-remove-args.d.ts.map +0 -1
  198. package/dist/esm/parse-add-remove-args.js.map +0 -1
  199. package/dist/esm/print-err.d.ts.map +0 -1
  200. package/dist/esm/print-err.js.map +0 -1
  201. package/dist/esm/query-host-contexts.d.ts.map +0 -1
  202. package/dist/esm/query-host-contexts.js.map +0 -1
  203. package/dist/esm/read-password.d.ts.map +0 -1
  204. package/dist/esm/read-password.js.map +0 -1
  205. package/dist/esm/start-gui.d.ts +0 -10
  206. package/dist/esm/start-gui.d.ts.map +0 -1
  207. package/dist/esm/start-gui.js +0 -60
  208. package/dist/esm/start-gui.js.map +0 -1
  209. package/dist/esm/view.d.ts.map +0 -1
  210. package/dist/esm/view.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { InstallReporter } from './install/reporter.ts';
2
2
  import type { DepID } from '@vltpkg/dep-id';
3
- import type { Graph } from '@vltpkg/graph';
3
+ import type { Diff, Graph } from '@vltpkg/graph';
4
4
  import type { CommandFn, CommandUsage } from '../index.ts';
5
5
  /**
6
6
  * The resulting object of an install operation. To be used by the view impl.
@@ -14,15 +14,33 @@ export type InstallResult = {
14
14
  * The resulting graph structure at the end of an install.
15
15
  */
16
16
  graph: Graph;
17
+ /**
18
+ * The diff between the actual and ideal graphs, if available.
19
+ */
20
+ diff?: Diff;
17
21
  };
18
22
  export declare const usage: CommandUsage;
19
23
  export declare const views: {
20
24
  readonly json: (i: InstallResult) => {
21
- graph: import("@vltpkg/graph").LockfileData;
22
25
  buildQueue?: DepID[] | undefined;
23
26
  message?: string | undefined;
27
+ add: {
28
+ name: string;
29
+ version?: string;
30
+ }[];
31
+ added: number;
32
+ change: {
33
+ name: string;
34
+ from?: string;
35
+ to?: string;
36
+ }[];
37
+ changed: number;
38
+ remove: {
39
+ name: string;
40
+ version?: string;
41
+ }[];
42
+ removed: number;
24
43
  };
25
44
  readonly human: typeof InstallReporter;
26
45
  };
27
46
  export declare const command: CommandFn<InstallResult>;
28
- //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,140 @@
1
+ import { commandUsage } from "../config/usage.js";
2
+ import { install } from '@vltpkg/graph';
3
+ import { parseAddArgs } from "../parse-add-remove-args.js";
4
+ import { InstallReporter } from "./install/reporter.js";
5
+ import { trackInstall } from "../telemetry.js";
6
+ export const usage = () => commandUsage({
7
+ command: 'install',
8
+ usage: '[packages ...]',
9
+ description: `Install the specified packages, updating package.json and
10
+ vlt-lock.json appropriately.`,
11
+ options: {
12
+ 'save-dev': {
13
+ description: 'Save installed packages to package.json as devDependencies.',
14
+ },
15
+ 'save-optional': {
16
+ description: 'Save installed packages to package.json as optionalDependencies.',
17
+ },
18
+ 'save-peer': {
19
+ description: 'Save installed packages to package.json as peerDependencies.',
20
+ },
21
+ 'save-prod': {
22
+ description: 'Save installed packages to package.json as dependencies.',
23
+ },
24
+ workspace: {
25
+ value: '<path|glob>',
26
+ description: 'Limit installation targets to matching workspaces.',
27
+ },
28
+ 'workspace-group': {
29
+ value: '<name>',
30
+ description: 'Limit installation targets to workspace groups.',
31
+ },
32
+ 'expect-lockfile': {
33
+ description: 'Fail if lockfile is missing or out of date.',
34
+ },
35
+ 'frozen-lockfile': {
36
+ description: 'Fail if lockfile is missing or out of sync with package.json.',
37
+ },
38
+ 'lockfile-only': {
39
+ description: 'Only update lockfile and package.json files; skip node_modules operations.',
40
+ },
41
+ 'allow-scripts': {
42
+ value: '<query>',
43
+ description: 'Filter which packages are allowed to run lifecycle scripts using DSS query syntax.',
44
+ },
45
+ },
46
+ });
47
+ export const views = {
48
+ json: i => {
49
+ const added = i.diff?.nodes.add ?? new Set();
50
+ const deleted = i.diff?.nodes.delete ?? new Set();
51
+ // The actual (from) graph represents what was on disk before the install.
52
+ // Used to filter out optional deps that were never installed (e.g.
53
+ // platform-specific binaries). These end up in the delete set via
54
+ // optionalFail but should not be reported as removals.
55
+ const actual = i.diff?.from;
56
+ // Build a map of deleted nodes by name for detecting changes
57
+ const deletedByName = new Map();
58
+ for (const node of deleted) {
59
+ if (node.importer)
60
+ continue;
61
+ // Skip nodes that were never on disk — these are optional deps
62
+ // that failed during install (e.g. wrong platform) and were moved
63
+ // to the delete set by optionalFail.
64
+ if (actual && !actual.nodes.has(node.id))
65
+ continue;
66
+ deletedByName.set(node.name, {
67
+ name: node.name,
68
+ version: node.version,
69
+ });
70
+ }
71
+ const add = [];
72
+ const change = [];
73
+ for (const node of added) {
74
+ if (node.importer)
75
+ continue;
76
+ const prev = deletedByName.get(node.name);
77
+ if (prev) {
78
+ // Package exists in both add and delete = changed
79
+ change.push({
80
+ name: node.name,
81
+ from: prev.version,
82
+ to: node.version,
83
+ });
84
+ deletedByName.delete(node.name);
85
+ }
86
+ else {
87
+ add.push({ name: node.name, version: node.version });
88
+ }
89
+ }
90
+ // Remaining deleted nodes that weren't matched = pure removals
91
+ const remove = [...deletedByName.values()];
92
+ return {
93
+ add,
94
+ added: add.length,
95
+ change,
96
+ changed: change.length,
97
+ remove,
98
+ removed: remove.length,
99
+ ...(i.buildQueue?.length ?
100
+ {
101
+ buildQueue: i.buildQueue,
102
+ message: `${i.buildQueue.length} packages that will need to be built, run "vlt build" to complete the install.`,
103
+ }
104
+ : null),
105
+ };
106
+ },
107
+ human: InstallReporter,
108
+ };
109
+ export const command = async (conf) => {
110
+ // TODO: we should probably throw an error if the user
111
+ // tries to install using view=mermaid
112
+ const monorepo = conf.options.monorepo;
113
+ const scurry = conf.options.scurry;
114
+ const { add } = parseAddArgs(conf, scurry, monorepo);
115
+ const frozenLockfile = conf.options['frozen-lockfile'];
116
+ const expectLockfile = conf.options['expect-lockfile'];
117
+ const lockfileOnly = conf.options['lockfile-only'];
118
+ /* c8 ignore start */
119
+ const allowScripts = conf.get('allow-scripts') ?
120
+ String(conf.get('allow-scripts'))
121
+ : ':not(*)';
122
+ /* c8 ignore stop */
123
+ const installStart = Date.now();
124
+ const { buildQueue, graph, diff } = await install({
125
+ ...conf.options,
126
+ frozenLockfile,
127
+ expectLockfile,
128
+ allowScripts,
129
+ lockfileOnly,
130
+ }, add);
131
+ /* c8 ignore next 9 - telemetry is best-effort */
132
+ try {
133
+ trackInstall({
134
+ dependency_count: graph.nodes.size,
135
+ duration_ms: Date.now() - installStart,
136
+ }, conf.values.telemetry);
137
+ }
138
+ catch { }
139
+ return { buildQueue, graph, diff };
140
+ };
@@ -1,5 +1,6 @@
1
1
  import { humanReadableOutput, jsonOutput, mermaidOutput } from '@vltpkg/graph';
2
2
  import type { HumanReadableOutputGraph, JSONOutputGraph, MermaidOutputGraph } from '@vltpkg/graph';
3
+ import { MermaidImageView } from '../mermaid-image-view.ts';
3
4
  import type { CommandFn, CommandUsage } from '../index.ts';
4
5
  export declare const usage: CommandUsage;
5
6
  export type ListResult = JSONOutputGraph & MermaidOutputGraph & HumanReadableOutputGraph & {
@@ -9,7 +10,8 @@ export declare const views: {
9
10
  readonly json: typeof jsonOutput;
10
11
  readonly mermaid: typeof mermaidOutput;
11
12
  readonly human: typeof humanReadableOutput;
12
- readonly gui: ({ queryString }: ListResult, _: import("../view.ts").ViewOptions, conf: import("../config/index.ts").ParsedConfig) => Promise<void>;
13
+ readonly count: (result: ListResult) => number;
14
+ readonly svg: typeof MermaidImageView;
15
+ readonly png: typeof MermaidImageView;
13
16
  };
14
17
  export declare const command: CommandFn<ListResult>;
15
- //# sourceMappingURL=list.d.ts.map
@@ -1,17 +1,16 @@
1
1
  import { actual, asNode, humanReadableOutput, jsonOutput, mermaidOutput, GraphModifier, } from '@vltpkg/graph';
2
- import LZString from 'lz-string';
3
2
  import { Query } from '@vltpkg/query';
4
3
  import { SecurityArchive } from '@vltpkg/security-archive';
5
4
  import { error } from '@vltpkg/error-cause';
6
5
  import { commandUsage } from "../config/usage.js";
7
- import { startGUI } from "../start-gui.js";
8
6
  import { createHostContextsMap } from "../query-host-contexts.js";
7
+ import { MermaidImageView } from "../mermaid-image-view.js";
9
8
  export const usage = () => commandUsage({
10
9
  command: 'ls',
11
10
  usage: [
12
11
  '',
13
- '[package-names...] [--view=human | json | mermaid | gui]',
14
- '[--scope=<query>] [--target=<query>] [--view=human | json | mermaid | gui]',
12
+ '[package-names...] [--view=human | json | mermaid | svg | png | count]',
13
+ '[--scope=<query>] [--target=<query>] [--view=human | json | mermaid | svg | png | count]',
15
14
  ],
16
15
  description: `List installed dependencies matching given package names or query selectors.
17
16
 
@@ -53,8 +52,8 @@ export const usage = () => commandUsage({
53
52
  description: 'Query selector to filter packages using the DSS query language syntax.',
54
53
  },
55
54
  view: {
56
- value: '[human | json | mermaid | gui]',
57
- description: 'Output format. Defaults to human-readable or json if no tty.',
55
+ value: '[human | json | mermaid | svg | png | count]',
56
+ description: 'Output format. Defaults to human-readable or json if no tty. Use svg or png to render the dependency graph as an image and open it. Count outputs the number of dependency relationships in the result.',
58
57
  },
59
58
  },
60
59
  });
@@ -62,9 +61,9 @@ export const views = {
62
61
  json: jsonOutput,
63
62
  mermaid: mermaidOutput,
64
63
  human: humanReadableOutput,
65
- gui: async ({ queryString }, _, conf) => {
66
- await startGUI(conf, `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`);
67
- },
64
+ count: (result) => result.edges.length,
65
+ svg: MermaidImageView,
66
+ png: MermaidImageView,
68
67
  };
69
68
  export const command = async (conf) => {
70
69
  const modifiers = GraphModifier.maybeLoad(conf.options);
@@ -196,4 +195,3 @@ export const command = async (conf) => {
196
195
  : defaultLocalScopeQueryString),
197
196
  };
198
197
  };
199
- //# sourceMappingURL=list.js.map
@@ -1,4 +1,3 @@
1
1
  import type { CommandFn, CommandUsage } from '../index.ts';
2
2
  export declare const usage: CommandUsage;
3
3
  export declare const command: CommandFn<void>;
4
- //# sourceMappingURL=login.d.ts.map
@@ -5,9 +5,18 @@ export const usage = () => commandUsage({
5
5
  usage: [''],
6
6
  description: `Authenticate against a registry, and store the token in
7
7
  the appropriate config file for later use.`,
8
+ options: {
9
+ registry: {
10
+ value: '<url>',
11
+ description: 'Registry URL to authenticate against.',
12
+ },
13
+ identity: {
14
+ value: '<name>',
15
+ description: 'Identity namespace used to store auth tokens.',
16
+ },
17
+ },
8
18
  });
9
19
  export const command = async (conf) => {
10
20
  const rc = new RegistryClient(conf.options);
11
21
  await rc.login(conf.options.registry);
12
22
  };
13
- //# sourceMappingURL=login.js.map
@@ -1,4 +1,3 @@
1
1
  import type { CommandFn, CommandUsage } from '../index.ts';
2
2
  export declare const usage: CommandUsage;
3
3
  export declare const command: CommandFn<void>;
4
- //# sourceMappingURL=token.d.ts.map
@@ -5,9 +5,18 @@ export const usage = () => commandUsage({
5
5
  usage: [''],
6
6
  description: `Log out of the default registry, deleting the token from
7
7
  the local keychain, as well as destroying it on the server.`,
8
+ options: {
9
+ registry: {
10
+ value: '<url>',
11
+ description: 'Registry URL to log out from.',
12
+ },
13
+ identity: {
14
+ value: '<name>',
15
+ description: 'Identity namespace used to look up auth tokens.',
16
+ },
17
+ },
8
18
  });
9
19
  export const command = async (conf) => {
10
20
  const rc = new RegistryClient(conf.options);
11
21
  await rc.logout(conf.options.registry);
12
22
  };
13
- //# sourceMappingURL=logout.js.map
@@ -29,4 +29,3 @@ export declare const commandSingle: (location: string, conf: LoadedConfig) => Pr
29
29
  shasum: string | undefined;
30
30
  integrity: string | undefined;
31
31
  }>;
32
- //# sourceMappingURL=pack.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { writeFile } from 'node:fs/promises';
2
- import { dirname, join, resolve } from 'node:path';
2
+ import { dirname, join, relative, resolve } from 'node:path';
3
3
  import assert from 'node:assert';
4
4
  import { run } from '@vltpkg/run';
5
5
  import { commandUsage } from "../config/usage.js";
@@ -9,6 +9,7 @@ import { actual } from '@vltpkg/graph';
9
9
  import { Query } from '@vltpkg/query';
10
10
  import { error } from '@vltpkg/error-cause';
11
11
  import { createHostContextsMap } from "../query-host-contexts.js";
12
+ import { minimatch } from 'minimatch';
12
13
  export const usage = () => commandUsage({
13
14
  command: 'pack',
14
15
  usage: '',
@@ -20,6 +21,21 @@ export const usage = () => commandUsage({
20
21
  'dry-run': {
21
22
  description: 'Show what would be packed without creating a tarball',
22
23
  },
24
+ scope: {
25
+ value: '<query>',
26
+ description: 'Filter packages to pack using a DSS query selector.',
27
+ },
28
+ workspace: {
29
+ value: '<path|glob>',
30
+ description: 'Limit pack targets to matching workspaces.',
31
+ },
32
+ 'workspace-group': {
33
+ value: '<name>',
34
+ description: 'Limit pack targets to workspace groups.',
35
+ },
36
+ recursive: {
37
+ description: 'Pack all workspaces in the monorepo.',
38
+ },
23
39
  },
24
40
  });
25
41
  export const views = {
@@ -45,6 +61,43 @@ export const views = {
45
61
  },
46
62
  json: r => r,
47
63
  };
64
+ /**
65
+ * Resolve a scope query string to workspace locations using the DSS query system.
66
+ */
67
+ const scopeLocations = async (queryString, conf) => {
68
+ const { options, projectRoot } = conf;
69
+ const mainManifest = options.packageJson.maybeRead(projectRoot);
70
+ let graph;
71
+ if (mainManifest) {
72
+ graph = actual.load({
73
+ ...options,
74
+ mainManifest,
75
+ monorepo: options.monorepo,
76
+ loadManifests: false,
77
+ });
78
+ }
79
+ const hostContexts = await createHostContextsMap(conf);
80
+ const query = new Query({
81
+ /* c8 ignore next */
82
+ nodes: graph ? new Set(graph.nodes.values()) : new Set(),
83
+ edges: graph?.edges ?? new Set(),
84
+ importers: graph?.importers ?? new Set(),
85
+ securityArchive: undefined,
86
+ hostContexts,
87
+ });
88
+ const { nodes } = await query.search(queryString, {
89
+ signal: new AbortController().signal,
90
+ });
91
+ const locations = [];
92
+ for (const node of nodes) {
93
+ const { location } = node.toJSON();
94
+ assert(location, error(`node ${node.id} has no location`, {
95
+ found: node,
96
+ }));
97
+ locations.push(resolve(projectRoot, location));
98
+ }
99
+ return locations;
100
+ };
48
101
  export const command = async (conf) => {
49
102
  const { options, projectRoot } = conf;
50
103
  const queryString = conf.get('scope');
@@ -54,41 +107,43 @@ export const command = async (conf) => {
54
107
  const locations = [];
55
108
  let single = null;
56
109
  if (queryString) {
57
- const mainManifest = options.packageJson.maybeRead(projectRoot);
58
- let graph;
59
- if (mainManifest) {
60
- graph = actual.load({
61
- ...options,
62
- mainManifest,
63
- monorepo: options.monorepo,
64
- loadManifests: false,
65
- });
66
- }
67
- const hostContexts = await createHostContextsMap(conf);
68
- const query = new Query({
69
- /* c8 ignore next */
70
- nodes: graph ? new Set(graph.nodes.values()) : new Set(),
71
- edges: graph?.edges ?? new Set(),
72
- importers: graph?.importers ?? new Set(),
73
- securityArchive: undefined,
74
- hostContexts,
75
- });
76
- const { nodes } = await query.search(queryString, {
77
- signal: new AbortController().signal,
78
- });
79
- for (const node of nodes) {
80
- const { location } = node.toJSON();
81
- assert(location, error(`node ${node.id} has no location`, {
82
- found: node,
83
- }));
84
- locations.push(resolve(projectRoot, location));
85
- }
110
+ locations.push(...(await scopeLocations(queryString, conf)));
86
111
  }
87
112
  else if (paths?.length || groups?.length || recursive) {
88
113
  for (const workspace of options.monorepo ?? []) {
114
+ // When specific workspace paths are set (including auto-inferred from cwd),
115
+ // filter to only matching workspaces. Without this, all monorepo workspaces
116
+ // would be operated on even when only one was specified.
117
+ if (paths?.length) {
118
+ const matches = paths.some((p) => workspace.path === p ||
119
+ workspace.name === p ||
120
+ workspace.fullpath === p ||
121
+ resolve(projectRoot, p) === workspace.fullpath ||
122
+ minimatch(workspace.path, p));
123
+ if (!matches)
124
+ continue;
125
+ }
89
126
  locations.push(workspace.fullpath);
90
127
  }
91
128
  }
129
+ else if (options.monorepo) {
130
+ const cwd = process.cwd();
131
+ if (cwd === projectRoot) {
132
+ for (const workspace of options.monorepo) {
133
+ locations.push(workspace.fullpath);
134
+ }
135
+ }
136
+ else {
137
+ const ws = options.monorepo.get(cwd);
138
+ if (ws) {
139
+ locations.push(ws.fullpath);
140
+ }
141
+ else {
142
+ const rel = relative(projectRoot, cwd).replaceAll('\\', '/');
143
+ locations.push(...(await scopeLocations(`:path("${rel}")`, conf)));
144
+ }
145
+ }
146
+ }
92
147
  else {
93
148
  single = options.packageJson.find(process.cwd()) ?? projectRoot;
94
149
  }
@@ -124,7 +179,11 @@ export const commandSingle = async (location, conf) => {
124
179
  ...runOptions,
125
180
  arg0: 'prepare',
126
181
  });
127
- const { name, version, filename, tarballData, unpackedSize, files, integrity, shasum, } = await packTarball(manifest, manifestDir, conf);
182
+ // Re-read the manifest after lifecycle scripts, which may have modified package.json.
183
+ const updatedManifest = conf.options.packageJson.read(manifestDir, {
184
+ reload: true,
185
+ });
186
+ const { name, version, filename, tarballData, unpackedSize, files, integrity, shasum, } = await packTarball(updatedManifest, manifestDir, conf);
128
187
  if (!isDryRun) {
129
188
  await writeFile(join(manifestDir, filename), tarballData);
130
189
  }
@@ -144,4 +203,3 @@ export const commandSingle = async (location, conf) => {
144
203
  integrity,
145
204
  };
146
205
  };
147
- //# sourceMappingURL=pack.js.map
@@ -0,0 +1,17 @@
1
+ import type { CommandFn, CommandUsage } from '../index.ts';
2
+ export declare const usage: CommandUsage;
3
+ type PingResult = {
4
+ registry: string;
5
+ alias?: string;
6
+ status: 'ok' | 'error';
7
+ time: number;
8
+ statusCode?: number;
9
+ error?: string;
10
+ };
11
+ type CommandResult = PingResult | PingResult[];
12
+ export declare const views: {
13
+ readonly human: (r: CommandResult) => string;
14
+ readonly json: (r: CommandResult) => CommandResult;
15
+ };
16
+ export declare const command: CommandFn<CommandResult>;
17
+ export {};
@@ -0,0 +1,114 @@
1
+ import { RegistryClient } from '@vltpkg/registry-client';
2
+ import { error } from '@vltpkg/error-cause';
3
+ import { commandUsage } from "../config/usage.js";
4
+ export const usage = () => commandUsage({
5
+ command: 'ping',
6
+ usage: ['', '[<registry-alias>]'],
7
+ description: `Ping configured registries to verify connectivity
8
+ and check registry health.
9
+
10
+ By default, pings all configured registries including
11
+ the default registry.
12
+
13
+ If a registry alias is provided, ping only that specific
14
+ registry. Registry aliases are configured via the
15
+ \`registries\` field in vlt.json or with the
16
+ \`--registries\` option.`,
17
+ options: {
18
+ registry: {
19
+ value: '<url>',
20
+ description: 'The default registry URL to ping.',
21
+ },
22
+ registries: {
23
+ value: '<alias=url>',
24
+ description: 'Named registry aliases to ping.',
25
+ },
26
+ },
27
+ });
28
+ const formatPingResult = (r) => {
29
+ const prefix = r.alias ? `${r.alias} (${r.registry})` : r.registry;
30
+ if (r.status === 'ok') {
31
+ return `Ping successful: ${prefix} (${r.time}ms)`;
32
+ }
33
+ else {
34
+ return `Ping failed: ${prefix} - ${r.error}`;
35
+ }
36
+ };
37
+ export const views = {
38
+ human: r => {
39
+ if (Array.isArray(r)) {
40
+ return r.map(formatPingResult).join('\n');
41
+ }
42
+ return formatPingResult(r);
43
+ },
44
+ json: r => r,
45
+ };
46
+ const pingRegistry = async (rc, registry, alias) => {
47
+ const url = new URL('-/ping?write=true', registry);
48
+ const start = Date.now();
49
+ try {
50
+ const response = await rc.request(url, { useCache: false });
51
+ const time = Date.now() - start;
52
+ if (response.statusCode >= 200 && response.statusCode < 300) {
53
+ return {
54
+ registry,
55
+ alias,
56
+ status: 'ok',
57
+ time,
58
+ statusCode: response.statusCode,
59
+ };
60
+ }
61
+ else {
62
+ return {
63
+ registry,
64
+ alias,
65
+ status: 'error',
66
+ time,
67
+ statusCode: response.statusCode,
68
+ error: `Registry returned status ${response.statusCode}`,
69
+ };
70
+ }
71
+ }
72
+ catch (err) {
73
+ const time = Date.now() - start;
74
+ return {
75
+ registry,
76
+ alias,
77
+ status: 'error',
78
+ time,
79
+ error: err instanceof Error ? err.message : String(err),
80
+ };
81
+ }
82
+ };
83
+ export const command = async (conf) => {
84
+ const rc = new RegistryClient(conf.options);
85
+ const registryAlias = conf.positionals[0];
86
+ if (registryAlias) {
87
+ // Ping a specific registry by alias
88
+ const registries = conf.options.registries;
89
+ const registry = registries[registryAlias];
90
+ if (!registry) {
91
+ const availableAliases = Object.keys(registries);
92
+ throw error('Unknown registry alias', {
93
+ found: registryAlias,
94
+ wanted: availableAliases.length > 0 ? availableAliases : undefined,
95
+ });
96
+ }
97
+ return await pingRegistry(rc, registry, registryAlias);
98
+ }
99
+ else {
100
+ // Ping all configured registries
101
+ const registries = conf.options.registries;
102
+ const results = [];
103
+ // Always ping the default registry first
104
+ results.push(await pingRegistry(rc, conf.options.registry, 'default'));
105
+ // Then ping all configured registry aliases
106
+ for (const [alias, registry] of Object.entries(registries)) {
107
+ // Skip if it's the same as the default registry
108
+ if (registry !== conf.options.registry) {
109
+ results.push(await pingRegistry(rc, registry, alias));
110
+ }
111
+ }
112
+ return results;
113
+ }
114
+ };
@@ -4,4 +4,3 @@ export declare const views: {
4
4
  };
5
5
  export declare const usage: CommandUsage;
6
6
  export declare const command: CommandFn;
7
- //# sourceMappingURL=pkg.d.ts.map
@@ -9,6 +9,7 @@ import { SecurityArchive } from '@vltpkg/security-archive';
9
9
  import { views as initViews } from "./init.js";
10
10
  import { commandUsage } from "../config/usage.js";
11
11
  import { createHostContextsMap } from "../query-host-contexts.js";
12
+ import { minimatch } from 'minimatch';
12
13
  export const views = {
13
14
  human: (results, _, config) => {
14
15
  // `vlt pkg init` is an alias for `vlt init`
@@ -58,6 +59,23 @@ export const usage = () => commandUsage({
58
59
  description: 'Append a value to an array',
59
60
  },
60
61
  },
62
+ options: {
63
+ scope: {
64
+ value: '<query>',
65
+ description: 'Filter package.json targets using a DSS query.',
66
+ },
67
+ workspace: {
68
+ value: '<path|glob>',
69
+ description: 'Limit package.json targets to matching workspaces.',
70
+ },
71
+ 'workspace-group': {
72
+ value: '<name>',
73
+ description: 'Limit package.json targets to workspace groups.',
74
+ },
75
+ recursive: {
76
+ description: 'Operate across all workspaces in the current monorepo.',
77
+ },
78
+ },
61
79
  });
62
80
  export const command = async (conf) => {
63
81
  const [sub, ...args] = conf.positionals;
@@ -123,6 +141,15 @@ export const command = async (conf) => {
123
141
  }
124
142
  else if (paths?.length || groups?.length || recursive) {
125
143
  for (const workspace of options.monorepo ?? []) {
144
+ if (paths?.length) {
145
+ const matches = paths.some((p) => workspace.path === p ||
146
+ workspace.name === p ||
147
+ workspace.fullpath === p ||
148
+ resolve(projectRoot, p) === workspace.fullpath ||
149
+ minimatch(workspace.path, p));
150
+ if (!matches)
151
+ continue;
152
+ }
126
153
  locations.push(workspace.fullpath);
127
154
  }
128
155
  }
@@ -203,4 +230,3 @@ const rm = (manifest, location, pkg, args) => {
203
230
  location,
204
231
  };
205
232
  };
206
- //# sourceMappingURL=pkg.js.map