@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
@@ -0,0 +1,31 @@
1
+ import type { CommandFn, CommandUsage } from '../index.ts';
2
+ export type TokenInfo = {
3
+ /** The server-side key/id for the token */
4
+ key: string;
5
+ /** A truncated prefix of the token value */
6
+ token: string;
7
+ /** ISO date when the token was created */
8
+ created: string;
9
+ /** Whether this token is read-only */
10
+ readonly: boolean;
11
+ /** CIDR whitelist, if any */
12
+ cidr_whitelist?: string[];
13
+ };
14
+ export type RegistryTokens = {
15
+ registry: string;
16
+ alias?: string;
17
+ /** Masked local keychain token, if stored */
18
+ localToken?: string;
19
+ tokens: TokenInfo[];
20
+ error?: string;
21
+ };
22
+ export type TokenListResult = {
23
+ identity: string;
24
+ registries: RegistryTokens[];
25
+ };
26
+ export declare const usage: CommandUsage;
27
+ export declare const views: {
28
+ readonly human: (r: TokenListResult | void) => string | undefined;
29
+ readonly json: (r: TokenListResult | void) => TokenListResult | undefined;
30
+ };
31
+ export declare const command: CommandFn<TokenListResult | void>;
@@ -0,0 +1,186 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { deleteToken, getKC, getToken, normalizeRegistryKey, registryBase, RegistryClient, setToken, } from '@vltpkg/registry-client';
3
+ import { commandUsage } from "../config/usage.js";
4
+ import { readPassword } from "../read-password.js";
5
+ export const usage = () => commandUsage({
6
+ command: 'token',
7
+ usage: ['list', 'add', 'rm'],
8
+ description: `Manage registry authentication tokens in the vlt keychain.`,
9
+ subcommands: {
10
+ list: {
11
+ usage: '',
12
+ description: `List tokens for configured registries. Shows
13
+ locally stored auth tokens and queries each
14
+ registry's token API for remote token metadata.`,
15
+ },
16
+ add: {
17
+ usage: '',
18
+ description: `Add a token for the specified registry.
19
+ You will be prompted to paste the bearer token.`,
20
+ },
21
+ rm: {
22
+ usage: '',
23
+ description: `Remove the stored token for the specified registry.`,
24
+ },
25
+ },
26
+ options: {
27
+ registry: {
28
+ value: '<url>',
29
+ description: 'Registry URL to manage tokens for.',
30
+ },
31
+ registries: {
32
+ value: '<alias=url>',
33
+ description: 'Named registry aliases (used by the list subcommand).',
34
+ },
35
+ identity: {
36
+ value: '<name>',
37
+ description: 'Identity namespace used to store auth tokens.',
38
+ },
39
+ },
40
+ });
41
+ const formatDate = (iso) => {
42
+ const d = new Date(iso);
43
+ return d.toLocaleDateString('en-US', {
44
+ year: 'numeric',
45
+ month: 'short',
46
+ day: 'numeric',
47
+ });
48
+ };
49
+ const maskToken = (token) => {
50
+ const bare = token.replace(/^(Bearer|Basic)\s+/i, '');
51
+ if (bare.length <= 8)
52
+ return bare + '…';
53
+ return bare.slice(0, 8) + '…';
54
+ };
55
+ const formatTokenEntry = (t) => {
56
+ const parts = [
57
+ `key: ${t.key}`,
58
+ `token: ${t.token}…`,
59
+ `created: ${formatDate(t.created)}`,
60
+ `readonly: ${t.readonly ? 'yes' : 'no'}`,
61
+ ];
62
+ if (t.cidr_whitelist && t.cidr_whitelist.length > 0) {
63
+ parts.push(`cidr: ${t.cidr_whitelist.join(', ')}`);
64
+ }
65
+ return parts.join(' │ ');
66
+ };
67
+ const formatRegistryTokens = (r) => {
68
+ const header = r.alias ? `${r.alias} (${r.registry})` : r.registry;
69
+ const lines = [header];
70
+ lines.push(` local: ${r.localToken ? maskToken(r.localToken) : '(none)'}`);
71
+ if (!r.localToken) {
72
+ lines.push(' (skipped remote query — no auth token)');
73
+ }
74
+ else if (r.error) {
75
+ lines.push(` error: ${r.error}`);
76
+ }
77
+ else if (r.tokens.length === 0) {
78
+ lines.push(' (no remote tokens found)');
79
+ }
80
+ else {
81
+ for (const t of r.tokens) {
82
+ lines.push(` ${formatTokenEntry(t)}`);
83
+ }
84
+ }
85
+ return lines.join('\n');
86
+ };
87
+ export const views = {
88
+ human: (r) => {
89
+ if (!r)
90
+ return;
91
+ const header = r.identity ? `identity: ${r.identity}` : 'identity: (default)';
92
+ return [header, ...r.registries.map(formatRegistryTokens)].join('\n\n');
93
+ },
94
+ json: (r) => {
95
+ if (!r)
96
+ return;
97
+ return r;
98
+ },
99
+ };
100
+ const listTokens = async (rc, registry, identity, alias) => {
101
+ const localTok = await getToken(normalizeRegistryKey(registry), identity);
102
+ if (!localTok) {
103
+ return { registry, alias, tokens: [] };
104
+ }
105
+ const tokensUrl = new URL('-/npm/v1/tokens', registryBase(registry));
106
+ try {
107
+ const objects = await rc.scroll(tokensUrl, {
108
+ useCache: false,
109
+ });
110
+ return {
111
+ registry,
112
+ alias,
113
+ localToken: localTok,
114
+ tokens: objects.map(o => ({
115
+ key: o.key,
116
+ token: o.token,
117
+ created: o.created,
118
+ readonly: o.readonly,
119
+ cidr_whitelist: o.cidr_whitelist,
120
+ })),
121
+ };
122
+ }
123
+ catch (err) {
124
+ return {
125
+ registry,
126
+ alias,
127
+ localToken: localTok,
128
+ tokens: [],
129
+ error: err instanceof Error ? err.message : String(err),
130
+ };
131
+ }
132
+ };
133
+ export const command = async (conf) => {
134
+ const reg = normalizeRegistryKey(conf.options.registry);
135
+ switch (conf.positionals[0]) {
136
+ case 'list': {
137
+ const rc = new RegistryClient(conf.options);
138
+ const identity = conf.options.identity;
139
+ const registries = [];
140
+ const seen = new Set();
141
+ // Always query the default registry first
142
+ const defaultReg = conf.options.registry;
143
+ seen.add(normalizeRegistryKey(defaultReg));
144
+ registries.push(await listTokens(rc, defaultReg, identity, 'default'));
145
+ // Then query all configured registry aliases
146
+ const configuredRegistries = conf.options.registries;
147
+ for (const [alias, registry] of Object.entries(configuredRegistries)) {
148
+ const key = normalizeRegistryKey(registry);
149
+ if (!seen.has(key)) {
150
+ seen.add(key);
151
+ registries.push(await listTokens(rc, registry, identity, alias));
152
+ }
153
+ }
154
+ // Also show any keychain entries for registries not
155
+ // already covered (e.g. added via `vlt token add --registry`)
156
+ const kc = getKC(identity);
157
+ for (const key of await kc.keys()) {
158
+ if (!seen.has(key)) {
159
+ seen.add(key);
160
+ const tok = await kc.get(key);
161
+ registries.push({
162
+ registry: key,
163
+ localToken: tok ?? undefined,
164
+ tokens: [],
165
+ });
166
+ }
167
+ }
168
+ return { identity, registries };
169
+ }
170
+ case 'add': {
171
+ await setToken(reg, `Bearer ${await readPassword('Paste bearer token: ')}`, conf.options.identity);
172
+ break;
173
+ }
174
+ case 'rm': {
175
+ await deleteToken(reg, conf.options.identity);
176
+ break;
177
+ }
178
+ default: {
179
+ throw error('Invalid token subcommand', {
180
+ found: conf.positionals[0],
181
+ validOptions: ['list', 'add', 'rm'],
182
+ code: 'EUSAGE',
183
+ });
184
+ }
185
+ }
186
+ };
@@ -13,4 +13,3 @@ export declare const views: {
13
13
  readonly human: typeof InstallReporter;
14
14
  };
15
15
  export declare const command: CommandFn<UninstallResult>;
16
- //# sourceMappingURL=uninstall.d.ts.map
@@ -7,14 +7,28 @@ export const usage = () => commandUsage({
7
7
  usage: '[package ...]',
8
8
  description: `The opposite of \`vlt install\`. Removes deps and updates
9
9
  vlt-lock.json and package.json appropriately.`,
10
+ options: {
11
+ workspace: {
12
+ value: '<path|glob>',
13
+ description: 'Limit uninstall targets to matching workspaces.',
14
+ },
15
+ 'workspace-group': {
16
+ value: '<name>',
17
+ description: 'Limit uninstall targets to workspace groups.',
18
+ },
19
+ 'allow-scripts': {
20
+ value: '<query>',
21
+ description: 'Filter which packages are allowed to run lifecycle scripts using DSS query syntax.',
22
+ },
23
+ },
10
24
  });
11
25
  export const views = {
12
26
  json: i => i.graph.toJSON(),
13
27
  human: InstallReporter,
14
28
  };
15
29
  export const command = async (conf) => {
16
- const monorepo = conf.options.monorepo;
17
- const { remove } = parseRemoveArgs(conf, monorepo);
30
+ const { monorepo, scurry } = conf.options;
31
+ const { remove } = parseRemoveArgs(conf, scurry, monorepo);
18
32
  /* c8 ignore start */
19
33
  const allowScripts = conf.get('allow-scripts') ?
20
34
  String(conf.get('allow-scripts'))
@@ -23,4 +37,3 @@ export const command = async (conf) => {
23
37
  const { graph } = await uninstall({ ...conf.options, allowScripts }, remove);
24
38
  return { graph };
25
39
  };
26
- //# sourceMappingURL=uninstall.js.map
@@ -0,0 +1,15 @@
1
+ import type { CommandFn, CommandUsage } from '../index.ts';
2
+ export declare const usage: CommandUsage;
3
+ export type CommandResult = {
4
+ /** The package name */
5
+ name: string;
6
+ /** The version that was unpublished, or undefined for entire package */
7
+ version?: string;
8
+ /** The registry URL */
9
+ registry: string;
10
+ };
11
+ export declare const views: {
12
+ readonly human: (result: CommandResult) => string;
13
+ readonly json: (r: CommandResult) => CommandResult;
14
+ };
15
+ export declare const command: CommandFn<CommandResult>;
@@ -0,0 +1,200 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { RegistryClient } from '@vltpkg/registry-client';
3
+ import { Spec } from '@vltpkg/spec';
4
+ import { asError } from '@vltpkg/types';
5
+ import { commandUsage } from "../config/usage.js";
6
+ export const usage = () => commandUsage({
7
+ command: 'unpublish',
8
+ usage: ['<package>@<version>', '<package> --force'],
9
+ description: `Remove a package version from the registry.
10
+
11
+ To unpublish a single version, specify the package name and version.
12
+ To unpublish an entire package, specify the package name and use --force.
13
+
14
+ ⚠️ Unpublishing is a destructive action that cannot be undone.
15
+ Consider using \`vlt deprecate\` instead if you want to discourage
16
+ usage of a package without removing it.`,
17
+ examples: {
18
+ 'my-package@1.0.0': {
19
+ description: 'Unpublish a specific version',
20
+ },
21
+ '@scope/my-package@1.0.0': {
22
+ description: 'Unpublish a specific version of a scoped package',
23
+ },
24
+ 'my-package --force': {
25
+ description: 'Unpublish an entire package (requires --force)',
26
+ },
27
+ },
28
+ options: {
29
+ force: {
30
+ description: 'Required to unpublish an entire package (all versions).',
31
+ },
32
+ otp: {
33
+ description: 'Provide a one-time password for authentication.',
34
+ value: '<otp>',
35
+ },
36
+ },
37
+ });
38
+ export const views = {
39
+ human: (result) => {
40
+ if (result.version) {
41
+ return `⚠️ ${result.name}@${result.version} has been unpublished from ${result.registry}.`;
42
+ }
43
+ return `⚠️ ${result.name} (all versions) has been unpublished from ${result.registry}.`;
44
+ },
45
+ json: (r) => r,
46
+ };
47
+ export const command = async (conf) => {
48
+ const specArg = conf.positionals[0];
49
+ if (!specArg) {
50
+ throw error('unpublish requires a package spec argument (e.g. pkg@version)', { code: 'EUSAGE' });
51
+ }
52
+ const { registry, otp, force } = conf.options;
53
+ const registryUrl = new URL(registry);
54
+ const spec = Spec.parseArgs(specArg, conf.options);
55
+ const name = spec.name;
56
+ /* c8 ignore start - Spec.parseArgs always produces a name for valid input */
57
+ if (!name) {
58
+ throw error('Package name is required', {
59
+ found: specArg,
60
+ });
61
+ }
62
+ /* c8 ignore stop */
63
+ const version = spec.bareSpec;
64
+ // If no version specified, require --force to unpublish the entire package
65
+ if (!version) {
66
+ if (!force) {
67
+ throw error('Refusing to unpublish entire package without --force.\n' +
68
+ 'To unpublish a specific version, use: vlt unpublish <package>@<version>\n' +
69
+ 'To unpublish all versions, use: vlt unpublish <package> --force');
70
+ }
71
+ }
72
+ const rc = new RegistryClient(conf.options);
73
+ const encodedName = name.startsWith('@') ? name.replace('/', '%2F') : name;
74
+ if (version) {
75
+ // Unpublish a specific version:
76
+ // 1. Fetch the packument
77
+ // 2. Remove the version from the packument
78
+ // 3. PUT the updated packument back
79
+ const packumentUrl = new URL(encodedName, registryUrl);
80
+ let packumentResponse;
81
+ try {
82
+ packumentResponse = await rc.request(packumentUrl, {
83
+ useCache: false,
84
+ });
85
+ }
86
+ catch (err) {
87
+ throw error('Failed to fetch package metadata', {
88
+ cause: asError(err),
89
+ });
90
+ }
91
+ if (packumentResponse.statusCode !== 200) {
92
+ throw error('Package not found on the registry', {
93
+ url: packumentUrl,
94
+ response: packumentResponse,
95
+ });
96
+ }
97
+ const packument = packumentResponse.json();
98
+ const versions = packument.versions;
99
+ const distTags = packument['dist-tags'];
100
+ if (!versions?.[version]) {
101
+ throw error(`Version ${version} not found in package ${name}`, {
102
+ found: version,
103
+ wanted: Object.keys(versions ?? {}),
104
+ });
105
+ }
106
+ // Remove the version
107
+ delete versions[version];
108
+ // Remove any dist-tags pointing to this version
109
+ if (distTags) {
110
+ for (const [tag, tagVersion] of Object.entries(distTags)) {
111
+ if (tagVersion === version) {
112
+ delete distTags[tag];
113
+ }
114
+ }
115
+ }
116
+ // Remove the version from the time field if present
117
+ const time = packument.time;
118
+ if (time?.[version]) {
119
+ delete time[version];
120
+ }
121
+ // PUT the updated packument
122
+ const putUrl = new URL(`${encodedName}/-rev/${packument._rev}`, registryUrl);
123
+ let response;
124
+ try {
125
+ response = await rc.request(putUrl, {
126
+ method: 'PUT',
127
+ headers: {
128
+ 'content-type': 'application/json',
129
+ 'npm-auth-type': 'web',
130
+ 'npm-command': 'unpublish',
131
+ },
132
+ body: JSON.stringify(packument),
133
+ otp,
134
+ });
135
+ }
136
+ catch (err) {
137
+ throw error('Failed to unpublish package version', {
138
+ cause: asError(err),
139
+ });
140
+ }
141
+ if (response.statusCode !== 200 && response.statusCode !== 201) {
142
+ throw error('Failed to unpublish package version', {
143
+ url: putUrl,
144
+ response,
145
+ });
146
+ }
147
+ }
148
+ else {
149
+ // Unpublish entire package — DELETE the packument
150
+ // First fetch the packument to get the _rev
151
+ const packumentUrl = new URL(encodedName, registryUrl);
152
+ let packumentResponse;
153
+ try {
154
+ packumentResponse = await rc.request(packumentUrl, {
155
+ useCache: false,
156
+ });
157
+ }
158
+ catch (err) {
159
+ throw error('Failed to fetch package metadata', {
160
+ cause: asError(err),
161
+ });
162
+ }
163
+ if (packumentResponse.statusCode !== 200) {
164
+ throw error('Package not found on the registry', {
165
+ url: packumentUrl,
166
+ response: packumentResponse,
167
+ });
168
+ }
169
+ const packument = packumentResponse.json();
170
+ const deleteUrl = new URL(`${encodedName}/-rev/${packument._rev}`, registryUrl);
171
+ let response;
172
+ try {
173
+ response = await rc.request(deleteUrl, {
174
+ method: 'DELETE',
175
+ headers: {
176
+ 'content-type': 'application/json',
177
+ 'npm-auth-type': 'web',
178
+ 'npm-command': 'unpublish',
179
+ },
180
+ otp,
181
+ });
182
+ }
183
+ catch (err) {
184
+ throw error('Failed to unpublish package', {
185
+ cause: asError(err),
186
+ });
187
+ }
188
+ if (response.statusCode !== 200 && response.statusCode !== 201) {
189
+ throw error('Failed to unpublish package', {
190
+ url: deleteUrl,
191
+ response,
192
+ });
193
+ }
194
+ }
195
+ return {
196
+ name,
197
+ ...(version ? { version } : {}),
198
+ registry: registryUrl.origin,
199
+ };
200
+ };
@@ -11,4 +11,3 @@ export declare const views: {
11
11
  readonly human: typeof InstallReporter;
12
12
  };
13
13
  export declare const command: CommandFn<InstallResult>;
14
- //# sourceMappingURL=update.d.ts.map
@@ -7,6 +7,12 @@ export const usage = () => commandUsage({
7
7
  usage: '',
8
8
  description: `Update dependencies to their latest in-range versions.
9
9
  Discards the lockfile and resolves dependencies from scratch.`,
10
+ options: {
11
+ 'allow-scripts': {
12
+ value: '<query>',
13
+ description: 'Filter which packages are allowed to run lifecycle scripts using DSS query syntax.',
14
+ },
15
+ },
10
16
  });
11
17
  export const views = {
12
18
  json: i => ({
@@ -38,4 +44,3 @@ export const command = async (conf) => {
38
44
  });
39
45
  return { buildQueue, graph };
40
46
  };
41
- //# sourceMappingURL=update.js.map
@@ -23,4 +23,3 @@ export declare const views: {
23
23
  readonly human: (results: CommandResult) => string;
24
24
  };
25
25
  export declare const command: CommandFn<CommandResult>;
26
- //# sourceMappingURL=version.d.ts.map
@@ -8,6 +8,7 @@ import assert from 'node:assert';
8
8
  import { actual } from '@vltpkg/graph';
9
9
  import { Query } from '@vltpkg/query';
10
10
  import { createHostContextsMap } from "../query-host-contexts.js";
11
+ import { minimatch } from 'minimatch';
11
12
  const isValidVersionIncrement = (value) => versionIncrements.includes(value);
12
13
  const version = async (conf, increment, cwd, {
13
14
  // Hardcode happy path options for now.
@@ -146,6 +147,23 @@ export const usage = () => {
146
147
  The \`<newversion>\` argument should be a valid semver string or a valid increment type (one of patch, minor, major, prepatch, preminor, premajor, prerelease).
147
148
 
148
149
  If run in a git repository, it will also create a version commit and tag.`,
150
+ options: {
151
+ scope: {
152
+ value: '<query>',
153
+ description: 'Filter version bump targets using a DSS query.',
154
+ },
155
+ workspace: {
156
+ value: '<path|glob>',
157
+ description: 'Limit version bump targets to matching workspaces.',
158
+ },
159
+ 'workspace-group': {
160
+ value: '<name>',
161
+ description: 'Limit version bump targets to workspace groups.',
162
+ },
163
+ recursive: {
164
+ description: 'Run version bump across all workspaces in the monorepo.',
165
+ },
166
+ },
149
167
  });
150
168
  };
151
169
  export const views = {
@@ -206,6 +224,15 @@ export const command = async (conf) => {
206
224
  }
207
225
  else if (paths?.length || groups?.length || recursive) {
208
226
  for (const workspace of options.monorepo ?? []) {
227
+ if (paths?.length) {
228
+ const matches = paths.some((p) => workspace.path === p ||
229
+ workspace.name === p ||
230
+ workspace.fullpath === p ||
231
+ resolve(projectRoot, p) === workspace.fullpath ||
232
+ minimatch(workspace.path, p));
233
+ if (!matches)
234
+ continue;
235
+ }
209
236
  locations.push(workspace.fullpath);
210
237
  }
211
238
  }
@@ -223,4 +250,3 @@ export const command = async (conf) => {
223
250
  }
224
251
  return results;
225
252
  };
226
- //# sourceMappingURL=version.js.map
@@ -0,0 +1,22 @@
1
+ import type { Manifest, Packument } from '@vltpkg/types';
2
+ import type { PackageReportData } from '@vltpkg/security-archive';
3
+ import type { CommandFn, CommandUsage } from '../index.ts';
4
+ import type { ViewOptions } from '../view.ts';
5
+ export declare const usage: CommandUsage;
6
+ export type ViewResult = {
7
+ /** The full packument data from the registry */
8
+ packument: Packument;
9
+ /** The resolved manifest for the requested version */
10
+ manifest: Manifest;
11
+ /** Security report data, if available */
12
+ security?: PackageReportData;
13
+ /** The specific field value if a field was requested */
14
+ fieldValue?: unknown;
15
+ /** The field path that was requested */
16
+ fieldPath?: string;
17
+ };
18
+ export declare const views: {
19
+ readonly human: (result: ViewResult, _options: ViewOptions, _conf: import("../config/index.ts").ParsedConfig) => string;
20
+ readonly json: (result: ViewResult, _options: ViewOptions, _conf: import("../config/index.ts").ParsedConfig) => unknown;
21
+ };
22
+ export declare const command: CommandFn<ViewResult>;