@vltpkg/cli-sdk 1.0.0-rc.9 → 1.0.1

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 (227) hide show
  1. package/dist/commands/access.d.ts +23 -0
  2. package/dist/commands/access.js +251 -0
  3. package/dist/{esm/commands → commands}/bugs.d.ts +0 -1
  4. package/dist/{esm/commands → commands}/bugs.js +0 -1
  5. package/dist/{esm/commands → commands}/build.d.ts +1 -1
  6. package/dist/{esm/commands → commands}/build.js +1 -1
  7. package/dist/{esm/commands → commands}/cache.d.ts +1 -1
  8. package/dist/{esm/commands → commands}/cache.js +1 -1
  9. package/dist/{esm/commands → commands}/ci.d.ts +1 -1
  10. package/dist/{esm/commands → commands}/ci.js +12 -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 +9 -0
  14. package/dist/commands/create.js +103 -0
  15. package/dist/commands/deprecate.d.ts +14 -0
  16. package/dist/commands/deprecate.js +142 -0
  17. package/dist/commands/dist-tag.d.ts +22 -0
  18. package/dist/commands/dist-tag.js +179 -0
  19. package/dist/{esm/commands → commands}/docs.d.ts +0 -1
  20. package/dist/{esm/commands → commands}/docs.js +0 -1
  21. package/dist/{esm/commands → commands}/exec-cache.d.ts +1 -1
  22. package/dist/{esm/commands → commands}/exec-cache.js +1 -1
  23. package/dist/{esm/commands/run-exec.d.ts → 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 +1 -1
  26. package/dist/{esm/commands → commands}/exec.js +85 -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 +22 -3
  34. package/dist/commands/install.js +152 -0
  35. package/dist/{esm/commands → commands}/list.d.ts +5 -2
  36. package/dist/{esm/commands → commands}/list.js +9 -10
  37. package/dist/{esm/commands → commands}/login.d.ts +0 -1
  38. package/dist/commands/login.js +35 -0
  39. package/dist/{esm/commands → commands}/logout.d.ts +1 -1
  40. package/dist/commands/logout.js +27 -0
  41. package/dist/{esm/commands → commands}/pack.d.ts +1 -1
  42. package/dist/{esm/commands → commands}/pack.js +91 -32
  43. package/dist/commands/ping.d.ts +18 -0
  44. package/dist/commands/ping.js +117 -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 +14 -0
  48. package/dist/commands/profile.js +106 -0
  49. package/dist/{esm/commands → commands}/publish.d.ts +2 -2
  50. package/dist/{esm/commands → commands}/publish.js +70 -16
  51. package/dist/{esm/commands → commands}/query.d.ts +5 -2
  52. package/dist/{esm/commands → commands}/query.js +54 -11
  53. package/dist/commands/registry.d.ts +26 -0
  54. package/dist/commands/registry.js +99 -0
  55. package/dist/commands/repo.d.ts +17 -0
  56. package/dist/commands/repo.js +157 -0
  57. package/dist/{esm/commands/exec-local.d.ts → commands/run-exec.d.ts} +1 -1
  58. package/dist/commands/run-exec.js +41 -0
  59. package/dist/{esm/commands → commands}/run.d.ts +0 -1
  60. package/dist/{esm/commands → commands}/run.js +27 -1
  61. package/dist/commands/setup.d.ts +25 -0
  62. package/dist/commands/setup.js +142 -0
  63. package/dist/commands/token.d.ts +32 -0
  64. package/dist/commands/token.js +193 -0
  65. package/dist/{esm/commands → commands}/uninstall.d.ts +1 -1
  66. package/dist/{esm/commands → commands}/uninstall.js +15 -1
  67. package/dist/commands/unpublish.d.ts +16 -0
  68. package/dist/commands/unpublish.js +203 -0
  69. package/dist/{esm/commands → commands}/update.d.ts +1 -1
  70. package/dist/{esm/commands → commands}/update.js +7 -1
  71. package/dist/{esm/commands → commands}/version.d.ts +0 -1
  72. package/dist/{esm/commands → commands}/version.js +27 -1
  73. package/dist/commands/view.d.ts +23 -0
  74. package/dist/commands/view.js +335 -0
  75. package/dist/{esm/commands → commands}/whoami.d.ts +1 -1
  76. package/dist/commands/whoami.js +33 -0
  77. package/dist/{esm/config → config}/definition.d.ts +72 -19
  78. package/dist/{esm/config → config}/definition.js +157 -50
  79. package/dist/{esm/config → config}/index.d.ts +0 -1
  80. package/dist/{esm/config → config}/index.js +43 -2
  81. package/dist/{esm/config → config}/merge.d.ts +0 -1
  82. package/dist/{esm/config → config}/merge.js +0 -1
  83. package/dist/{esm/config → config}/usage.d.ts +0 -1
  84. package/dist/{esm/config → config}/usage.js +0 -1
  85. package/dist/{esm/custom-help.d.ts → custom-help.d.ts} +0 -1
  86. package/dist/{esm/custom-help.js → custom-help.js} +95 -120
  87. package/dist/{esm/exec-command.d.ts → exec-command.d.ts} +0 -1
  88. package/dist/{esm/exec-command.js → exec-command.js} +14 -8
  89. package/dist/{esm/index.d.ts → index.d.ts} +0 -1
  90. package/dist/{esm/index.js → index.js} +5 -2
  91. package/dist/{esm/load-command.d.ts → load-command.d.ts} +6 -1
  92. package/dist/{esm/load-command.js → load-command.js} +0 -1
  93. package/dist/mermaid-image-view.d.ts +18 -0
  94. package/dist/mermaid-image-view.js +36 -0
  95. package/dist/{esm/output.d.ts → output.d.ts} +2 -2
  96. package/dist/{esm/output.js → output.js} +70 -3
  97. package/dist/{esm/pack-tarball.d.ts → pack-tarball.d.ts} +15 -1
  98. package/dist/{esm/pack-tarball.js → pack-tarball.js} +133 -91
  99. package/dist/{esm/parse-add-remove-args.d.ts → parse-add-remove-args.d.ts} +0 -1
  100. package/dist/{esm/parse-add-remove-args.js → parse-add-remove-args.js} +65 -12
  101. package/dist/{esm/print-err.d.ts → print-err.d.ts} +0 -1
  102. package/dist/{esm/print-err.js → print-err.js} +28 -4
  103. package/dist/query-diff-files.d.ts +17 -0
  104. package/dist/query-diff-files.js +63 -0
  105. package/dist/{esm/query-host-contexts.d.ts → query-host-contexts.d.ts} +0 -1
  106. package/dist/{esm/query-host-contexts.js → query-host-contexts.js} +8 -7
  107. package/dist/{esm/read-password.d.ts → read-password.d.ts} +0 -1
  108. package/dist/{esm/read-password.js → read-password.js} +0 -1
  109. package/dist/read-project-folders.d.ts +17 -0
  110. package/dist/read-project-folders.js +100 -0
  111. package/dist/registry-error-message.d.ts +2 -0
  112. package/dist/registry-error-message.js +29 -0
  113. package/dist/reload-config.d.ts +2 -0
  114. package/dist/reload-config.js +11 -0
  115. package/dist/render-mermaid.d.ts +22 -0
  116. package/dist/render-mermaid.js +68 -0
  117. package/dist/require-registry.d.ts +48 -0
  118. package/dist/require-registry.js +122 -0
  119. package/dist/select-registry.d.ts +23 -0
  120. package/dist/select-registry.js +40 -0
  121. package/dist/telemetry.d.ts +58 -0
  122. package/dist/telemetry.js +170 -0
  123. package/dist/verbose-log.d.ts +31 -0
  124. package/dist/verbose-log.js +62 -0
  125. package/dist/{esm/view.d.ts → view.d.ts} +0 -1
  126. package/dist/{esm/view.js → view.js} +1 -2
  127. package/package.json +75 -82
  128. package/dist/esm/commands/bugs.d.ts.map +0 -1
  129. package/dist/esm/commands/bugs.js.map +0 -1
  130. package/dist/esm/commands/build.d.ts.map +0 -1
  131. package/dist/esm/commands/build.js.map +0 -1
  132. package/dist/esm/commands/cache.d.ts.map +0 -1
  133. package/dist/esm/commands/cache.js.map +0 -1
  134. package/dist/esm/commands/ci.d.ts.map +0 -1
  135. package/dist/esm/commands/ci.js.map +0 -1
  136. package/dist/esm/commands/config.d.ts.map +0 -1
  137. package/dist/esm/commands/config.js.map +0 -1
  138. package/dist/esm/commands/docs.d.ts.map +0 -1
  139. package/dist/esm/commands/docs.js.map +0 -1
  140. package/dist/esm/commands/exec-cache.d.ts.map +0 -1
  141. package/dist/esm/commands/exec-cache.js.map +0 -1
  142. package/dist/esm/commands/exec-local.d.ts.map +0 -1
  143. package/dist/esm/commands/exec-local.js.map +0 -1
  144. package/dist/esm/commands/exec.d.ts.map +0 -1
  145. package/dist/esm/commands/exec.js.map +0 -1
  146. package/dist/esm/commands/help.d.ts.map +0 -1
  147. package/dist/esm/commands/help.js.map +0 -1
  148. package/dist/esm/commands/init.d.ts.map +0 -1
  149. package/dist/esm/commands/init.js.map +0 -1
  150. package/dist/esm/commands/install/reporter.d.ts.map +0 -1
  151. package/dist/esm/commands/install/reporter.js.map +0 -1
  152. package/dist/esm/commands/install.d.ts.map +0 -1
  153. package/dist/esm/commands/install.js +0 -46
  154. package/dist/esm/commands/install.js.map +0 -1
  155. package/dist/esm/commands/list.d.ts.map +0 -1
  156. package/dist/esm/commands/list.js.map +0 -1
  157. package/dist/esm/commands/login.d.ts.map +0 -1
  158. package/dist/esm/commands/login.js +0 -13
  159. package/dist/esm/commands/login.js.map +0 -1
  160. package/dist/esm/commands/logout.d.ts.map +0 -1
  161. package/dist/esm/commands/logout.js +0 -13
  162. package/dist/esm/commands/logout.js.map +0 -1
  163. package/dist/esm/commands/pack.d.ts.map +0 -1
  164. package/dist/esm/commands/pack.js.map +0 -1
  165. package/dist/esm/commands/pkg.d.ts.map +0 -1
  166. package/dist/esm/commands/pkg.js.map +0 -1
  167. package/dist/esm/commands/publish.d.ts.map +0 -1
  168. package/dist/esm/commands/publish.js.map +0 -1
  169. package/dist/esm/commands/query.d.ts.map +0 -1
  170. package/dist/esm/commands/query.js.map +0 -1
  171. package/dist/esm/commands/run-exec.d.ts.map +0 -1
  172. package/dist/esm/commands/run-exec.js +0 -14
  173. package/dist/esm/commands/run-exec.js.map +0 -1
  174. package/dist/esm/commands/run.d.ts.map +0 -1
  175. package/dist/esm/commands/run.js.map +0 -1
  176. package/dist/esm/commands/serve.d.ts +0 -14
  177. package/dist/esm/commands/serve.d.ts.map +0 -1
  178. package/dist/esm/commands/serve.js +0 -103
  179. package/dist/esm/commands/serve.js.map +0 -1
  180. package/dist/esm/commands/token.d.ts +0 -4
  181. package/dist/esm/commands/token.d.ts.map +0 -1
  182. package/dist/esm/commands/token.js +0 -30
  183. package/dist/esm/commands/token.js.map +0 -1
  184. package/dist/esm/commands/uninstall.d.ts.map +0 -1
  185. package/dist/esm/commands/uninstall.js.map +0 -1
  186. package/dist/esm/commands/update.d.ts.map +0 -1
  187. package/dist/esm/commands/update.js.map +0 -1
  188. package/dist/esm/commands/version.d.ts.map +0 -1
  189. package/dist/esm/commands/version.js.map +0 -1
  190. package/dist/esm/commands/whoami.d.ts.map +0 -1
  191. package/dist/esm/commands/whoami.js +0 -19
  192. package/dist/esm/commands/whoami.js.map +0 -1
  193. package/dist/esm/config/definition.d.ts.map +0 -1
  194. package/dist/esm/config/definition.js.map +0 -1
  195. package/dist/esm/config/index.d.ts.map +0 -1
  196. package/dist/esm/config/index.js.map +0 -1
  197. package/dist/esm/config/merge.d.ts.map +0 -1
  198. package/dist/esm/config/merge.js.map +0 -1
  199. package/dist/esm/config/usage.d.ts.map +0 -1
  200. package/dist/esm/config/usage.js.map +0 -1
  201. package/dist/esm/custom-help.d.ts.map +0 -1
  202. package/dist/esm/custom-help.js.map +0 -1
  203. package/dist/esm/exec-command.d.ts.map +0 -1
  204. package/dist/esm/exec-command.js.map +0 -1
  205. package/dist/esm/index.d.ts.map +0 -1
  206. package/dist/esm/index.js.map +0 -1
  207. package/dist/esm/load-command.d.ts.map +0 -1
  208. package/dist/esm/load-command.js.map +0 -1
  209. package/dist/esm/output.d.ts.map +0 -1
  210. package/dist/esm/output.js.map +0 -1
  211. package/dist/esm/pack-tarball.d.ts.map +0 -1
  212. package/dist/esm/pack-tarball.js.map +0 -1
  213. package/dist/esm/package.json +0 -3
  214. package/dist/esm/parse-add-remove-args.d.ts.map +0 -1
  215. package/dist/esm/parse-add-remove-args.js.map +0 -1
  216. package/dist/esm/print-err.d.ts.map +0 -1
  217. package/dist/esm/print-err.js.map +0 -1
  218. package/dist/esm/query-host-contexts.d.ts.map +0 -1
  219. package/dist/esm/query-host-contexts.js.map +0 -1
  220. package/dist/esm/read-password.d.ts.map +0 -1
  221. package/dist/esm/read-password.js.map +0 -1
  222. package/dist/esm/start-gui.d.ts +0 -10
  223. package/dist/esm/start-gui.d.ts.map +0 -1
  224. package/dist/esm/start-gui.js +0 -60
  225. package/dist/esm/start-gui.js.map +0 -1
  226. package/dist/esm/view.d.ts.map +0 -1
  227. package/dist/esm/view.js.map +0 -1
@@ -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
@@ -0,0 +1,14 @@
1
+ import type { JSONField } from '@vltpkg/types';
2
+ import type { CommandFn, CommandUsage } from '../index.ts';
3
+ export declare const needsRegistry = true;
4
+ export declare const usage: CommandUsage;
5
+ export type ProfileData = Record<string, JSONField>;
6
+ export type ProfileResult = ProfileData | {
7
+ property: string;
8
+ value: JSONField;
9
+ };
10
+ export declare const views: {
11
+ readonly human: (result: ProfileResult) => string;
12
+ readonly json: (r: ProfileResult) => ProfileResult;
13
+ };
14
+ export declare const command: CommandFn<ProfileResult>;
@@ -0,0 +1,106 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { RegistryClient } from '@vltpkg/registry-client';
3
+ import { commandUsage } from "../config/usage.js";
4
+ import { resolveRegistry } from "../require-registry.js";
5
+ export const needsRegistry = true;
6
+ export const usage = () => commandUsage({
7
+ command: 'profile',
8
+ usage: '<command> [<args>]',
9
+ description: `Get or set profile properties for the authenticated user
10
+ on the configured registry.`,
11
+ subcommands: {
12
+ get: {
13
+ usage: '[<property>]',
14
+ description: 'Display profile information. Optionally pass a property name to get a single value.',
15
+ },
16
+ set: {
17
+ usage: '<property> <value>',
18
+ description: 'Set a profile property to the given value.',
19
+ },
20
+ },
21
+ options: {
22
+ registry: {
23
+ value: '<url>',
24
+ description: 'Registry URL to query for profile info.',
25
+ },
26
+ identity: {
27
+ value: '<name>',
28
+ description: 'Identity namespace used to look up auth tokens.',
29
+ },
30
+ otp: {
31
+ description: 'Provide an OTP to use when updating profile properties.',
32
+ value: '<otp>',
33
+ },
34
+ },
35
+ });
36
+ const stringify = (v) => typeof v === 'string' ? v
37
+ : typeof v === 'number' || typeof v === 'boolean' ? `${v}`
38
+ : v === null ? 'null'
39
+ : JSON.stringify(v);
40
+ export const views = {
41
+ human: result => {
42
+ if ('property' in result) {
43
+ return stringify(result.value);
44
+ }
45
+ return Object.entries(result)
46
+ .map(([k, v]) => `${k}: ${stringify(v)}`)
47
+ .join('\n');
48
+ },
49
+ json: r => r,
50
+ };
51
+ export const command = async (conf) => {
52
+ const [sub, ...args] = conf.positionals;
53
+ switch (sub) {
54
+ case 'get':
55
+ return getProfile(conf, args);
56
+ case 'set':
57
+ return setProfile(conf, args);
58
+ default: {
59
+ throw error('Invalid profile subcommand', {
60
+ found: sub,
61
+ validOptions: ['get', 'set'],
62
+ code: 'EUSAGE',
63
+ });
64
+ }
65
+ }
66
+ };
67
+ const getProfile = async (conf, args) => {
68
+ const rc = new RegistryClient(conf.options);
69
+ const registryUrl = new URL(await resolveRegistry(conf));
70
+ const url = new URL('-/npm/v1/user', registryUrl);
71
+ const response = await rc.request(url, { useCache: false });
72
+ const data = response.json();
73
+ const [property] = args;
74
+ if (property) {
75
+ if (!(property in data)) {
76
+ throw error('Property not found in profile', {
77
+ found: property,
78
+ validOptions: Object.keys(data),
79
+ code: 'EUSAGE',
80
+ });
81
+ }
82
+ return { property, value: data[property] };
83
+ }
84
+ return data;
85
+ };
86
+ const setProfile = async (conf, args) => {
87
+ const [property, ...rest] = args;
88
+ const value = rest.join(' ');
89
+ if (!property || !value) {
90
+ throw error('set requires a property name and value', {
91
+ code: 'EUSAGE',
92
+ });
93
+ }
94
+ const rc = new RegistryClient(conf.options);
95
+ const registryUrl = new URL(await resolveRegistry(conf));
96
+ const url = new URL('-/npm/v1/user', registryUrl);
97
+ const response = await rc.request(url, {
98
+ method: 'POST',
99
+ headers: { 'content-type': 'application/json' },
100
+ body: JSON.stringify({ [property]: value }),
101
+ otp: conf.options.otp,
102
+ useCache: false,
103
+ });
104
+ const data = response.json();
105
+ return { property, value: data[property] };
106
+ };
@@ -1,4 +1,5 @@
1
1
  import type { CommandFn, CommandUsage } from '../index.ts';
2
+ export declare const needsRegistry = true;
2
3
  export declare const usage: CommandUsage;
3
4
  export type CommandResultSingle = {
4
5
  id: string;
@@ -9,7 +10,7 @@ export type CommandResultSingle = {
9
10
  shasum?: string;
10
11
  integrity?: string;
11
12
  size: number;
12
- access: string;
13
+ access?: string;
13
14
  unpackedSize: number;
14
15
  files: string[];
15
16
  };
@@ -19,4 +20,3 @@ export declare const views: {
19
20
  readonly json: (r: CommandResult) => CommandResult;
20
21
  };
21
22
  export declare const command: CommandFn<CommandResult>;
22
- //# sourceMappingURL=publish.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { error } from '@vltpkg/error-cause';
2
- import { RegistryClient } from '@vltpkg/registry-client';
2
+ import { RegistryClient, oidc, registryBase, } from '@vltpkg/registry-client';
3
3
  import { run } from '@vltpkg/run';
4
4
  import { commandUsage } from "../config/usage.js";
5
5
  import { packTarball } from "../pack-tarball.js";
@@ -10,6 +10,10 @@ import prettyBytes from 'pretty-bytes';
10
10
  import { actual } from '@vltpkg/graph';
11
11
  import { Query } from '@vltpkg/query';
12
12
  import { createHostContextsMap } from "../query-host-contexts.js";
13
+ import { minimatch } from 'minimatch';
14
+ import { resolveRegistry } from "../require-registry.js";
15
+ import { registryErrorMessage } from "../registry-error-message.js";
16
+ export const needsRegistry = true;
13
17
  export const usage = () => commandUsage({
14
18
  command: 'publish',
15
19
  usage: '',
@@ -35,6 +39,24 @@ export const usage = () => commandUsage({
35
39
  The directory must exist and nothing will be copied to it.`,
36
40
  value: '<path>',
37
41
  },
42
+ 'dry-run': {
43
+ description: 'Show what would be published without actually publishing.',
44
+ },
45
+ scope: {
46
+ value: '<query>',
47
+ description: 'Filter packages to publish using a DSS query selector.',
48
+ },
49
+ workspace: {
50
+ value: '<path|glob>',
51
+ description: 'Limit publish targets to matching workspaces.',
52
+ },
53
+ 'workspace-group': {
54
+ value: '<name>',
55
+ description: 'Limit publish targets to workspace groups.',
56
+ },
57
+ recursive: {
58
+ description: 'Publish all workspaces in the monorepo.',
59
+ },
38
60
  },
39
61
  });
40
62
  export const views = {
@@ -102,6 +124,15 @@ export const command = async (conf) => {
102
124
  }
103
125
  else if (paths?.length || groups?.length || recursive) {
104
126
  for (const workspace of options.monorepo ?? []) {
127
+ if (paths?.length) {
128
+ const matches = paths.some((p) => workspace.path === p ||
129
+ workspace.name === p ||
130
+ workspace.fullpath === p ||
131
+ resolve(projectRoot, p) === workspace.fullpath ||
132
+ minimatch(workspace.path, p));
133
+ if (!matches)
134
+ continue;
135
+ }
105
136
  locations.push(workspace.fullpath);
106
137
  }
107
138
  }
@@ -118,14 +149,26 @@ export const command = async (conf) => {
118
149
  }
119
150
  return results;
120
151
  };
152
+ const getPublishConfig = (manifest) => {
153
+ const pc = manifest
154
+ .publishConfig;
155
+ if (pc && typeof pc === 'object') {
156
+ return pc;
157
+ }
158
+ return undefined;
159
+ };
121
160
  const commandSingle = async (location, conf) => {
122
161
  const manifestPath = conf.options.packageJson.find(location);
123
162
  assert(manifestPath, 'No package.json found');
124
163
  const manifestDir = dirname(manifestPath);
125
164
  const manifest = conf.options.packageJson.read(manifestDir);
126
165
  assert(!manifest.private, error('Package has been marked as private'));
127
- const { tag = 'latest', access, registry, 'dry-run': dry = false, otp, } = conf.options;
128
- const registryUrl = new URL(registry);
166
+ const { 'dry-run': dry = false, otp } = conf.options;
167
+ const publishConfig = getPublishConfig(manifest);
168
+ const tag = publishConfig?.tag ?? conf.options.tag;
169
+ const access = publishConfig?.access ?? conf.options.access;
170
+ const registry = publishConfig?.registry ?? (await resolveRegistry(conf));
171
+ const registryUrl = new URL(registryBase(registry));
129
172
  const runOptions = {
130
173
  cwd: manifestDir,
131
174
  projectRoot: conf.projectRoot,
@@ -150,7 +193,11 @@ const commandSingle = async (location, conf) => {
150
193
  ...runOptions,
151
194
  arg0: 'prepare',
152
195
  });
153
- const { name, version, tarballName, tarballData, unpackedSize, files, integrity, shasum, } = await packTarball(manifest, manifestDir, conf);
196
+ // Re-read the manifest after lifecycle scripts, which may have modified package.json.
197
+ const updatedManifest = conf.options.packageJson.read(manifestDir, {
198
+ reload: true,
199
+ });
200
+ const { name, version, tarballName, tarballData, unpackedSize, files, integrity, shasum, resolvedManifest, } = await packTarball(updatedManifest, manifestDir, conf);
154
201
  await run({
155
202
  ...runOptions,
156
203
  arg0: 'postpack',
@@ -162,17 +209,17 @@ const commandSingle = async (location, conf) => {
162
209
  const publishMetadata = {
163
210
  _id: name,
164
211
  name,
165
- description: manifest.description || '',
212
+ description: resolvedManifest.description || '',
166
213
  'dist-tags': {
167
214
  [tag]: version,
168
215
  },
169
216
  versions: {
170
217
  [version]: {
171
- ...manifest,
218
+ ...resolvedManifest,
172
219
  _id: `${name}@${version}`,
173
220
  _nodeVersion: process.versions.node,
174
221
  dist: {
175
- ...manifest.dist,
222
+ ...resolvedManifest.dist,
176
223
  integrity,
177
224
  shasum,
178
225
  tarball: new URL(`${name}/-/${tarballName}`, registryUrl)
@@ -180,7 +227,7 @@ const commandSingle = async (location, conf) => {
180
227
  },
181
228
  },
182
229
  },
183
- access,
230
+ ...(access ? { access } : {}),
184
231
  _attachments: {
185
232
  [tarballName]: {
186
233
  content_type: 'application/octet-stream',
@@ -190,6 +237,12 @@ const commandSingle = async (location, conf) => {
190
237
  },
191
238
  };
192
239
  const rc = new RegistryClient(conf.options);
240
+ // Attempt OIDC token exchange for CI environments (GitHub Actions, GitLab, CircleCI).
241
+ // This is always optional — failures are silent and won't affect local publishing.
242
+ await oidc({
243
+ packageName: name,
244
+ registry: registryUrl.href,
245
+ });
193
246
  const publishUrl = new URL(name.startsWith('@') ? name.replace('/', '%2F') : name, registryUrl);
194
247
  if (!dry) {
195
248
  let response;
@@ -212,13 +265,15 @@ const commandSingle = async (location, conf) => {
212
265
  });
213
266
  }
214
267
  if (response.statusCode !== 200 && response.statusCode !== 201) {
215
- let extraMsg = '';
216
- // special case 404 errors to provide a better hint to the user
217
- if (response.statusCode === 404) {
218
- extraMsg =
219
- ".\n⚠️ Make sure you're logged in and have access to publish the package.";
268
+ let advice = '';
269
+ if (response.statusCode === 409) {
270
+ advice = `\n⚠️ ${name}@${version} already exists in the registry. Bump the version and try again.`;
271
+ }
272
+ else if (response.statusCode === 404) {
273
+ advice =
274
+ "\n⚠️ Make sure you're logged in and have access to publish the package.";
220
275
  }
221
- throw error(`Failed to publish package${extraMsg}`, {
276
+ throw error(`Failed to publish package: ${registryErrorMessage(response)}${advice}`, {
222
277
  url: publishUrl,
223
278
  response,
224
279
  });
@@ -233,7 +288,7 @@ const commandSingle = async (location, conf) => {
233
288
  name,
234
289
  version,
235
290
  tag,
236
- access,
291
+ ...(access ? { access } : {}),
237
292
  registry: registryUrl.origin,
238
293
  integrity,
239
294
  shasum,
@@ -242,4 +297,3 @@ const commandSingle = async (location, conf) => {
242
297
  files,
243
298
  };
244
299
  };
245
- //# sourceMappingURL=publish.js.map
@@ -1,6 +1,8 @@
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';
5
+ export declare const needsRegistry = true;
4
6
  export declare const usage: CommandUsage;
5
7
  type QueryResult = JSONOutputGraph & MermaidOutputGraph & HumanReadableOutputGraph & {
6
8
  queryString: string;
@@ -9,8 +11,9 @@ export declare const views: {
9
11
  readonly json: typeof jsonOutput;
10
12
  readonly mermaid: typeof mermaidOutput;
11
13
  readonly human: typeof humanReadableOutput;
12
- readonly gui: ({ queryString }: QueryResult, _: import("../view.ts").ViewOptions, conf: import("../config/index.ts").ParsedConfig) => Promise<void>;
14
+ readonly count: (result: QueryResult) => number;
15
+ readonly svg: typeof MermaidImageView;
16
+ readonly png: typeof MermaidImageView;
13
17
  };
14
18
  export declare const command: CommandFn<QueryResult>;
15
19
  export {};
16
- //# sourceMappingURL=query.d.ts.map
@@ -1,18 +1,20 @@
1
1
  import { actual, asNode, humanReadableOutput, jsonOutput, mermaidOutput, GraphModifier, } from '@vltpkg/graph';
2
- import { error } from '@vltpkg/error-cause';
3
- import LZString from 'lz-string';
4
2
  import { Query } from '@vltpkg/query';
3
+ import { stdout } from "../output.js";
4
+ import { error } from '@vltpkg/error-cause';
5
+ import { createDiffFilesProvider } from "../query-diff-files.js";
5
6
  import { SecurityArchive } from '@vltpkg/security-archive';
6
- import { startGUI } from "../start-gui.js";
7
7
  import { commandUsage } from "../config/usage.js";
8
8
  import { createHostContextsMap } from "../query-host-contexts.js";
9
+ import { MermaidImageView } from "../mermaid-image-view.js";
10
+ export const needsRegistry = true;
9
11
  export const usage = () => commandUsage({
10
12
  command: 'query',
11
13
  usage: [
12
14
  '',
13
- '<query> --view=<human | json | mermaid | gui>',
15
+ '<query> --view=<human | json | mermaid | svg | png | count>',
14
16
  '<query> --expect-results=<comparison string>',
15
- '--target=<query> --view=<human | json | mermaid | gui>',
17
+ '--target=<query> --view=<human | json | mermaid | svg | png | count>',
16
18
  ],
17
19
  description: `List installed dependencies matching the provided query.
18
20
 
@@ -68,8 +70,8 @@ export const usage = () => commandUsage({
68
70
  description: 'Query selector to filter packages using DSS syntax.',
69
71
  },
70
72
  view: {
71
- value: '[human | json | mermaid | gui]',
72
- description: 'Output format. Defaults to human-readable or json if no tty.',
73
+ value: '[human | json | mermaid | svg | png | count]',
74
+ 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.',
73
75
  },
74
76
  },
75
77
  });
@@ -96,9 +98,9 @@ export const views = {
96
98
  json: jsonOutput,
97
99
  mermaid: mermaidOutput,
98
100
  human: humanReadableOutput,
99
- gui: async ({ queryString }, _, conf) => {
100
- await startGUI(conf, `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`);
101
- },
101
+ count: (result) => result.edges.length,
102
+ svg: MermaidImageView,
103
+ png: MermaidImageView,
102
104
  };
103
105
  export const command = async (conf) => {
104
106
  const modifiers = GraphModifier.maybeLoad(conf.options);
@@ -127,6 +129,7 @@ export const command = async (conf) => {
127
129
  const scopeQueryString = conf.get('scope');
128
130
  const queryString = targetQueryString || positionalQueryString;
129
131
  const hostContexts = await createHostContextsMap(conf);
132
+ const diffFiles = createDiffFilesProvider(conf.options.projectRoot);
130
133
  const importers = new Set();
131
134
  const scopeIDs = [];
132
135
  // Handle --scope option to add scope nodes as importers
@@ -146,11 +149,24 @@ export const command = async (conf) => {
146
149
  importers,
147
150
  securityArchive,
148
151
  hostContexts,
152
+ diffFiles,
149
153
  });
150
154
  const { nodes: resultNodes } = await scopeQuery.search(scopeQueryString, {
151
155
  signal: new AbortController().signal,
152
156
  });
153
157
  scopeNodes = resultNodes;
158
+ if (scopeNodes.length === 0) {
159
+ if (conf.values.view === 'human') {
160
+ stdout('No packages found matching scope query:', scopeQueryString);
161
+ }
162
+ return {
163
+ importers: new Set(),
164
+ edges: [],
165
+ nodes: [],
166
+ highlightSelection: false,
167
+ queryString: scopeQueryString,
168
+ };
169
+ }
154
170
  }
155
171
  if (scopeQueryString && scopeNodes) {
156
172
  // Add all scope nodes to importers Set (treat them as top-level items)
@@ -170,6 +186,18 @@ export const command = async (conf) => {
170
186
  }
171
187
  }
172
188
  }
189
+ if (importers.size === 0) {
190
+ if (conf.values.view === 'human') {
191
+ stdout('No matching workspaces found:', conf.values.workspace);
192
+ }
193
+ return {
194
+ importers: new Set(),
195
+ edges: [],
196
+ nodes: [],
197
+ highlightSelection: false,
198
+ queryString: queryString ?? '',
199
+ };
200
+ }
173
201
  }
174
202
  // retrieve the selected nodes and edges
175
203
  const edges_ = graph?.edges ?? new Set();
@@ -185,6 +213,7 @@ export const command = async (conf) => {
185
213
  importers: importers_,
186
214
  securityArchive,
187
215
  hostContexts,
216
+ diffFiles,
188
217
  });
189
218
  const query = queryString ||
190
219
  (graph ? defaultProjectQueryString : defaultLocalScopeQueryString);
@@ -198,6 +227,21 @@ export const command = async (conf) => {
198
227
  wanted: conf.values['expect-results'],
199
228
  });
200
229
  }
230
+ if (graph &&
231
+ nodes.length === 0 &&
232
+ edges.length === 0 &&
233
+ !conf.values['expect-results']) {
234
+ if (conf.values.view === 'human') {
235
+ stdout('No packages found matching query:', query);
236
+ }
237
+ return {
238
+ importers: new Set(),
239
+ edges: [],
240
+ nodes: [],
241
+ highlightSelection: false,
242
+ queryString: query,
243
+ };
244
+ }
201
245
  return {
202
246
  importers: importers.size === 0 ?
203
247
  new Set(queryResultImporters)
@@ -211,4 +255,3 @@ export const command = async (conf) => {
211
255
  : defaultLocalScopeQueryString),
212
256
  };
213
257
  };
214
- //# sourceMappingURL=query.js.map
@@ -0,0 +1,26 @@
1
+ import type { LoadedConfig } from '../config/index.ts';
2
+ import type { CommandFn, CommandUsage } from '../index.ts';
3
+ /**
4
+ * The account/auth commands that can be scoped to a named registry
5
+ * alias via `vlt registry <alias> <command>`.
6
+ */
7
+ export declare const registrySubcommands: ["whoami", "logout", "login", "token", "access", "publish", "unpublish", "deprecate", "dist-tag", "profile", "ping"];
8
+ export declare const usage: CommandUsage;
9
+ export declare const views: {
10
+ readonly human: () => void;
11
+ };
12
+ /**
13
+ * Resolve `vlt registry <alias> <command>` in place: determine the
14
+ * target subcommand and registry, then rewrite `conf` so the outer
15
+ * runner dispatches the real command with the resolved registry
16
+ * injected. When invoked with `--help` or without a subcommand, `conf`
17
+ * is left untouched so the `registry` usage/error is shown instead.
18
+ *
19
+ * Streams / interactivity are injectable for tests.
20
+ */
21
+ export declare const dispatchRegistry: (conf: LoadedConfig, { interactive, input, output, }?: {
22
+ interactive?: boolean;
23
+ input?: NodeJS.ReadableStream;
24
+ output?: NodeJS.WritableStream;
25
+ }) => Promise<void>;
26
+ export declare const command: CommandFn<void>;
@@ -0,0 +1,99 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { getCommand } from "../config/definition.js";
3
+ import { commandUsage } from "../config/usage.js";
4
+ import { resolveRegistry } from "../require-registry.js";
5
+ /**
6
+ * The account/auth commands that can be scoped to a named registry
7
+ * alias via `vlt registry <alias> <command>`.
8
+ */
9
+ export const registrySubcommands = [
10
+ 'whoami',
11
+ 'logout',
12
+ 'login',
13
+ 'token',
14
+ 'access',
15
+ 'publish',
16
+ 'unpublish',
17
+ 'deprecate',
18
+ 'dist-tag',
19
+ 'profile',
20
+ 'ping',
21
+ ];
22
+ const isRegistrySubcommand = (s) => {
23
+ const canonical = getCommand(s);
24
+ return (canonical !== undefined &&
25
+ registrySubcommands.includes(canonical));
26
+ };
27
+ export const usage = () => commandUsage({
28
+ command: 'registry',
29
+ usage: '<alias> <command> [<args>]',
30
+ description: `Run an account command against a specific configured
31
+ registry, selected by its \`registries\` alias instead
32
+ of a full URL.
33
+
34
+ For example, \`vlt registry main whoami\` runs \`whoami\`
35
+ against the registry configured as \`main\`. Omit the
36
+ alias (e.g. \`vlt registry whoami\`) to be prompted to
37
+ choose from the configured registries, or to fall back
38
+ to \`--default-registry-alias\` when non-interactive.
39
+
40
+ \`<command>\` is one of:
41
+ ${registrySubcommands.join(', ')}.`,
42
+ });
43
+ export const views = {
44
+ human: () => { },
45
+ };
46
+ /**
47
+ * Resolve `vlt registry <alias> <command>` in place: determine the
48
+ * target subcommand and registry, then rewrite `conf` so the outer
49
+ * runner dispatches the real command with the resolved registry
50
+ * injected. When invoked with `--help` or without a subcommand, `conf`
51
+ * is left untouched so the `registry` usage/error is shown instead.
52
+ *
53
+ * Streams / interactivity are injectable for tests.
54
+ */
55
+ export const dispatchRegistry = async (conf, { interactive, input, output, } = {}) => {
56
+ if (conf.get('help'))
57
+ return;
58
+ const [first, ...restArgs] = conf.positionals;
59
+ if (first === undefined)
60
+ return;
61
+ let alias;
62
+ let subRaw;
63
+ let args;
64
+ if (isRegistrySubcommand(first)) {
65
+ subRaw = first;
66
+ args = restArgs;
67
+ }
68
+ else {
69
+ alias = first;
70
+ subRaw = restArgs[0];
71
+ args = restArgs.slice(1);
72
+ }
73
+ if (!isRegistrySubcommand(subRaw)) {
74
+ throw error('Unknown registry subcommand', {
75
+ found: subRaw,
76
+ validOptions: [...registrySubcommands],
77
+ code: 'EUSAGE',
78
+ });
79
+ }
80
+ const registry = await resolveRegistry(conf, {
81
+ alias,
82
+ interactive,
83
+ input,
84
+ output,
85
+ });
86
+ conf.options.registry = registry;
87
+ conf.values.registry = registry;
88
+ conf.command = subRaw;
89
+ conf.positionals = args;
90
+ };
91
+ export const command = async (conf) => {
92
+ // Reached only when dispatchRegistry did not rewrite conf, i.e. no
93
+ // subcommand was provided (help is handled by the runner earlier).
94
+ throw error('Missing registry subcommand', {
95
+ found: conf.positionals[0],
96
+ validOptions: [...registrySubcommands],
97
+ code: 'EUSAGE',
98
+ });
99
+ };
@@ -0,0 +1,17 @@
1
+ import type { CommandFn, CommandUsage } from '../index.ts';
2
+ export declare const usage: CommandUsage;
3
+ type CommandResultSingle = {
4
+ url: string;
5
+ name: string;
6
+ };
7
+ type CommandResultMultiple = {
8
+ url: string;
9
+ name: string;
10
+ }[];
11
+ export type CommandResult = CommandResultSingle | CommandResultMultiple;
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 {};