@vltpkg/cli-js 1.0.0-rc.29 → 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 (64) hide show
  1. package/{access-6HRR4HXE.js → access-I7Q5S4HE.js} +1 -1
  2. package/{bugs-2CAZQ32S.js → bugs-XJDVOIWV.js} +4 -4
  3. package/{build-OAWTNBMS.js → build-KFMSG6YJ.js} +1 -1
  4. package/{cache-JTAFST6T.js → cache-RL4MUZZ4.js} +1 -1
  5. package/{chunk-K3RN3BGU.js → chunk-6SMCDBB5.js} +1 -1
  6. package/{chunk-CPM47YUH.js → chunk-AAO77QBG.js} +1 -1
  7. package/{chunk-ZINDEKAU.js → chunk-BCS77CZK.js} +72 -72
  8. package/{chunk-M7HPHM7B.js → chunk-CX6CSVSZ.js} +1 -1
  9. package/{chunk-HAGUS4HI.js → chunk-DPQWORL7.js} +1 -1
  10. package/{chunk-7RZL7BZI.js → chunk-E76YOTJF.js} +45 -9
  11. package/{chunk-VPKJNCKL.js → chunk-EGIFRSA7.js} +1 -1
  12. package/{chunk-CLDF5XLG.js → chunk-FXFN5J74.js} +2 -2
  13. package/chunk-HDWMQCAC.js +73 -0
  14. package/{chunk-WX2DCAG2.js → chunk-I626GJCR.js} +2 -2
  15. package/{chunk-VRIS5HAW.js → chunk-LUL76G2K.js} +2 -2
  16. package/chunk-QI6JZT5E.js +781 -0
  17. package/{chunk-3MWZTKGK.js → chunk-UUE6D7ZK.js} +52 -20
  18. package/{chunk-D2MVJDUA.js → chunk-YXHBZAYO.js} +1 -1
  19. package/{ci-TOJJVHI4.js → ci-25PDKMKT.js} +2 -2
  20. package/cli-package.json +5 -4
  21. package/{config-DVAPEE5D.js → config-EUN3UG63.js} +3 -3
  22. package/{config-GOV4E2KK.js → config-SGKD6FN7.js} +3 -3
  23. package/{create-NGJD7K4L.js → create-7MBL7X4J.js} +6 -6
  24. package/{deprecate-WROL4AHK.js → deprecate-RXSOKRB6.js} +2 -2
  25. package/{devtools-TPMVKPB5.js → devtools-6NFQDW4L.js} +29 -29
  26. package/{dist-tag-WZXXWXMB.js → dist-tag-TR6YTPWB.js} +1 -1
  27. package/{docs-YCOZFMZG.js → docs-SXJQN3VK.js} +4 -4
  28. package/{exec-URG5OWLH.js → exec-GZUI7N7U.js} +6 -6
  29. package/{exec-cache-KHDOEH2F.js → exec-cache-ERIWZB3O.js} +4 -4
  30. package/{exec-local-52TVUL5K.js → exec-local-5EIXJDU2.js} +3 -3
  31. package/{help-LNSDVBGJ.js → help-VZXBYP36.js} +1 -1
  32. package/{init-XNMWYATA.js → init-B3GRYNH5.js} +2 -2
  33. package/{install-SKUZERZJ.js → install-GFUAOCU3.js} +3 -3
  34. package/{list-XEDVFUD5.js → list-SWSGDOS2.js} +3 -3
  35. package/{login-52SA2DSI.js → login-2QU5SPGP.js} +1 -1
  36. package/{logout-5YYHNV5W.js → logout-DVW3KZKJ.js} +1 -1
  37. package/{pack-B7QZHMYP.js → pack-GNYL35NY.js} +3 -3
  38. package/package.json +1 -1
  39. package/{ping-PRGDYDRI.js → ping-5NKJAV3C.js} +1 -1
  40. package/{pkg-UEIQIVVD.js → pkg-XGXCIZCS.js} +3 -3
  41. package/{profile-46FKVQEL.js → profile-OZYH6GL2.js} +1 -1
  42. package/{publish-HBYHOSKH.js → publish-PUXCD3CT.js} +23 -14
  43. package/{query-5A4YLS2C.js → query-TUQMPQGD.js} +3 -3
  44. package/registry-client-package.json +1 -1
  45. package/registry-client-src-revalidate.js +46 -16
  46. package/{repo-I6X66PHD.js → repo-ALXGJFIG.js} +4 -4
  47. package/{reporter-NUXJTV4G.js → reporter-MSQWYN76.js} +1 -1
  48. package/{run-VEZMUMVH.js → run-GM2E5WHJ.js} +3 -3
  49. package/{run-exec-6ADY4BKH.js → run-exec-3AMM56A3.js} +3 -3
  50. package/{src-O32QL33R.js → src-QQVS7FWK.js} +4 -4
  51. package/{token-YK6L74PA.js → token-MW32RFPW.js} +73 -24
  52. package/{uninstall-UBUZBV7E.js → uninstall-QTAVWQNB.js} +3 -3
  53. package/{unpublish-ZHJEKT7A.js → unpublish-B5JROG62.js} +1 -1
  54. package/{update-WO4BHJF4.js → update-P274ATK3.js} +2 -2
  55. package/{version-RLESYHML.js → version-23AKGCGL.js} +2 -2
  56. package/{view-UA5HXFXG.js → view-Q35LCZGS.js} +2 -2
  57. package/vlr.js +1 -1
  58. package/vlrx.js +1 -1
  59. package/vlt.js +1 -1
  60. package/vlx.js +1 -1
  61. package/vlxl.js +1 -1
  62. package/{whoami-7H3FPR2O.js → whoami-XH64UEWS.js} +1 -1
  63. package/chunk-7WHVJ56C.js +0 -73
  64. package/chunk-BW6C3YUV.js +0 -301
@@ -15,9 +15,12 @@ import {
15
15
  import {
16
16
  RegistryClient,
17
17
  deleteToken,
18
+ getKC,
19
+ getToken,
18
20
  normalizeRegistryKey,
21
+ registryBase,
19
22
  setToken
20
- } from "./chunk-3MWZTKGK.js";
23
+ } from "./chunk-UUE6D7ZK.js";
21
24
  import "./chunk-YCQTLBWF.js";
22
25
  import "./chunk-R44FR7BY.js";
23
26
  import "./chunk-2V4AQPBR.js";
@@ -64,10 +67,9 @@ var usage = () => commandUsage({
64
67
  subcommands: {
65
68
  list: {
66
69
  usage: "",
67
- description: `List all tokens for configured registries.
68
- Queries each registry's token API and displays
69
- token metadata including key, creation date,
70
- and permissions.`
70
+ description: `List tokens for configured registries. Shows
71
+ locally stored auth tokens and queries each
72
+ registry's token API for remote token metadata.`
71
73
  },
72
74
  add: {
73
75
  usage: "",
@@ -102,6 +104,11 @@ var formatDate = (iso) => {
102
104
  day: "numeric"
103
105
  });
104
106
  };
107
+ var maskToken = (token) => {
108
+ const bare = token.replace(/^(Bearer|Basic)\s+/i, "");
109
+ if (bare.length <= 8) return bare + "\u2026";
110
+ return bare.slice(0, 8) + "\u2026";
111
+ };
105
112
  var formatTokenEntry = (t) => {
106
113
  const parts = [
107
114
  `key: ${t.key}`,
@@ -116,27 +123,45 @@ var formatTokenEntry = (t) => {
116
123
  };
117
124
  var formatRegistryTokens = (r) => {
118
125
  const header = r.alias ? `${r.alias} (${r.registry})` : r.registry;
119
- if (r.error) return `${header}
120
- error: ${r.error}`;
121
- if (r.tokens.length === 0) return `${header}
122
- (no tokens found)`;
123
- return [
124
- header,
125
- ...r.tokens.map((t) => ` ${formatTokenEntry(t)}`)
126
- ].join("\n");
126
+ const lines = [header];
127
+ lines.push(
128
+ ` local: ${r.localToken ? maskToken(r.localToken) : "(none)"}`
129
+ );
130
+ if (!r.localToken) {
131
+ lines.push(" (skipped remote query \u2014 no auth token)");
132
+ } else if (r.error) {
133
+ lines.push(` error: ${r.error}`);
134
+ } else if (r.tokens.length === 0) {
135
+ lines.push(" (no remote tokens found)");
136
+ } else {
137
+ for (const t of r.tokens) {
138
+ lines.push(` ${formatTokenEntry(t)}`);
139
+ }
140
+ }
141
+ return lines.join("\n");
127
142
  };
128
143
  var views = {
129
144
  human: (r) => {
130
145
  if (!r) return;
131
- return r.map(formatRegistryTokens).join("\n\n");
146
+ const header = r.identity ? `identity: ${r.identity}` : "identity: (default)";
147
+ return [header, ...r.registries.map(formatRegistryTokens)].join(
148
+ "\n\n"
149
+ );
132
150
  },
133
151
  json: (r) => {
134
152
  if (!r) return;
135
153
  return r;
136
154
  }
137
155
  };
138
- var listTokens = async (rc, registry, alias) => {
139
- const tokensUrl = new URL("-/npm/v1/tokens", registry);
156
+ var listTokens = async (rc, registry, identity, alias) => {
157
+ const localTok = await getToken(
158
+ normalizeRegistryKey(registry),
159
+ identity
160
+ );
161
+ if (!localTok) {
162
+ return { registry, alias, tokens: [] };
163
+ }
164
+ const tokensUrl = new URL("-/npm/v1/tokens", registryBase(registry));
140
165
  try {
141
166
  const objects = await rc.scroll(tokensUrl, {
142
167
  useCache: false
@@ -144,6 +169,7 @@ var listTokens = async (rc, registry, alias) => {
144
169
  return {
145
170
  registry,
146
171
  alias,
172
+ localToken: localTok,
147
173
  tokens: objects.map((o) => ({
148
174
  key: o.key,
149
175
  token: o.token,
@@ -156,6 +182,7 @@ var listTokens = async (rc, registry, alias) => {
156
182
  return {
157
183
  registry,
158
184
  alias,
185
+ localToken: localTok,
159
186
  tokens: [],
160
187
  error: err instanceof Error ? err.message : String(err)
161
188
  };
@@ -166,17 +193,39 @@ var command = async (conf) => {
166
193
  switch (conf.positionals[0]) {
167
194
  case "list": {
168
195
  const rc = new RegistryClient(conf.options);
169
- const results = [];
170
- results.push(
171
- await listTokens(rc, conf.options.registry, "default")
196
+ const identity = conf.options.identity;
197
+ const registries = [];
198
+ const seen = /* @__PURE__ */ new Set();
199
+ const defaultReg = conf.options.registry;
200
+ seen.add(normalizeRegistryKey(defaultReg));
201
+ registries.push(
202
+ await listTokens(rc, defaultReg, identity, "default")
172
203
  );
173
- const registries = conf.options.registries;
174
- for (const [alias, registry] of Object.entries(registries)) {
175
- if (registry !== conf.options.registry) {
176
- results.push(await listTokens(rc, registry, alias));
204
+ const configuredRegistries = conf.options.registries;
205
+ for (const [alias, registry] of Object.entries(
206
+ configuredRegistries
207
+ )) {
208
+ const key = normalizeRegistryKey(registry);
209
+ if (!seen.has(key)) {
210
+ seen.add(key);
211
+ registries.push(
212
+ await listTokens(rc, registry, identity, alias)
213
+ );
214
+ }
215
+ }
216
+ const kc = getKC(identity);
217
+ for (const key of await kc.keys()) {
218
+ if (!seen.has(key)) {
219
+ seen.add(key);
220
+ const tok = await kc.get(key);
221
+ registries.push({
222
+ registry: key,
223
+ localToken: tok ?? void 0,
224
+ tokens: []
225
+ });
177
226
  }
178
227
  }
179
- return results;
228
+ return { identity, registries };
180
229
  }
181
230
  case "add": {
182
231
  await setToken(
@@ -11,13 +11,13 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  parseRemoveArgs
14
- } from "./chunk-CPM47YUH.js";
14
+ } from "./chunk-AAO77QBG.js";
15
15
  import {
16
16
  InstallReporter
17
- } from "./chunk-ZINDEKAU.js";
17
+ } from "./chunk-BCS77CZK.js";
18
18
  import {
19
19
  uninstall
20
- } from "./chunk-7RZL7BZI.js";
20
+ } from "./chunk-E76YOTJF.js";
21
21
  import "./chunk-MAIQR5GM.js";
22
22
  import "./chunk-VTEFO2FT.js";
23
23
  import "./chunk-RXNA2XCX.js";
@@ -17,7 +17,7 @@ import {
17
17
  } from "./chunk-FBTBHRPG.js";
18
18
  import {
19
19
  RegistryClient
20
- } from "./chunk-3MWZTKGK.js";
20
+ } from "./chunk-UUE6D7ZK.js";
21
21
  import "./chunk-YCQTLBWF.js";
22
22
  import "./chunk-R44FR7BY.js";
23
23
  import "./chunk-2V4AQPBR.js";
@@ -11,10 +11,10 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  InstallReporter
14
- } from "./chunk-ZINDEKAU.js";
14
+ } from "./chunk-BCS77CZK.js";
15
15
  import {
16
16
  update
17
- } from "./chunk-7RZL7BZI.js";
17
+ } from "./chunk-E76YOTJF.js";
18
18
  import "./chunk-MAIQR5GM.js";
19
19
  import "./chunk-VTEFO2FT.js";
20
20
  import "./chunk-RXNA2XCX.js";
@@ -11,11 +11,11 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  createHostContextsMap
14
- } from "./chunk-VRIS5HAW.js";
14
+ } from "./chunk-LUL76G2K.js";
15
15
  import {
16
16
  Query,
17
17
  actual
18
- } from "./chunk-7RZL7BZI.js";
18
+ } from "./chunk-E76YOTJF.js";
19
19
  import "./chunk-MAIQR5GM.js";
20
20
  import {
21
21
  is,
@@ -17,7 +17,7 @@ import {
17
17
  } from "./chunk-MAIQR5GM.js";
18
18
  import {
19
19
  PackageInfoClient
20
- } from "./chunk-HAGUS4HI.js";
20
+ } from "./chunk-DPQWORL7.js";
21
21
  import "./chunk-HQ4US6G3.js";
22
22
  import "./chunk-XYCCQT7N.js";
23
23
  import {
@@ -30,7 +30,7 @@ import "./chunk-HTOTG4TS.js";
30
30
  import {
31
31
  commandUsage
32
32
  } from "./chunk-FBTBHRPG.js";
33
- import "./chunk-3MWZTKGK.js";
33
+ import "./chunk-UUE6D7ZK.js";
34
34
  import "./chunk-YCQTLBWF.js";
35
35
  import "./chunk-R44FR7BY.js";
36
36
  import "./chunk-2V4AQPBR.js";
package/vlr.js CHANGED
@@ -12,7 +12,7 @@ import {createRequire as _vlt_createRequire} from "node:module";
12
12
  var require = _vlt_createRequire(import.meta.filename);
13
13
  import {
14
14
  run
15
- } from "./chunk-D2MVJDUA.js";
15
+ } from "./chunk-YXHBZAYO.js";
16
16
  import "./chunk-PZLD7RTK.js";
17
17
 
18
18
  // ../build/src/bins/vlr.ts
package/vlrx.js CHANGED
@@ -12,7 +12,7 @@ import {createRequire as _vlt_createRequire} from "node:module";
12
12
  var require = _vlt_createRequire(import.meta.filename);
13
13
  import {
14
14
  run
15
- } from "./chunk-D2MVJDUA.js";
15
+ } from "./chunk-YXHBZAYO.js";
16
16
  import "./chunk-PZLD7RTK.js";
17
17
 
18
18
  // ../build/src/bins/vlrx.ts
package/vlt.js CHANGED
@@ -12,7 +12,7 @@ import {createRequire as _vlt_createRequire} from "node:module";
12
12
  var require = _vlt_createRequire(import.meta.filename);
13
13
  import {
14
14
  run
15
- } from "./chunk-D2MVJDUA.js";
15
+ } from "./chunk-YXHBZAYO.js";
16
16
  import "./chunk-PZLD7RTK.js";
17
17
 
18
18
  // ../build/src/bins/vlt.ts
package/vlx.js CHANGED
@@ -12,7 +12,7 @@ import {createRequire as _vlt_createRequire} from "node:module";
12
12
  var require = _vlt_createRequire(import.meta.filename);
13
13
  import {
14
14
  run
15
- } from "./chunk-D2MVJDUA.js";
15
+ } from "./chunk-YXHBZAYO.js";
16
16
  import "./chunk-PZLD7RTK.js";
17
17
 
18
18
  // ../build/src/bins/vlx.ts
package/vlxl.js CHANGED
@@ -12,7 +12,7 @@ import {createRequire as _vlt_createRequire} from "node:module";
12
12
  var require = _vlt_createRequire(import.meta.filename);
13
13
  import {
14
14
  run
15
- } from "./chunk-D2MVJDUA.js";
15
+ } from "./chunk-YXHBZAYO.js";
16
16
  import "./chunk-PZLD7RTK.js";
17
17
 
18
18
  // ../build/src/bins/vlxl.ts
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-FBTBHRPG.js";
15
15
  import {
16
16
  RegistryClient
17
- } from "./chunk-3MWZTKGK.js";
17
+ } from "./chunk-UUE6D7ZK.js";
18
18
  import "./chunk-YCQTLBWF.js";
19
19
  import "./chunk-R44FR7BY.js";
20
20
  import "./chunk-2V4AQPBR.js";
package/chunk-7WHVJ56C.js DELETED
@@ -1,73 +0,0 @@
1
- var global = globalThis;
2
- import {Buffer} from "node:buffer";
3
- import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
4
- globalThis.setTimeout = _vlt_setTimeout;
5
- globalThis.clearTimeout = _vlt_clearTimeout;
6
- globalThis.setImmediate = _vlt_setImmediate;
7
- globalThis.clearImmediate = _vlt_clearImmediate;
8
- globalThis.setInterval = _vlt_setInterval;
9
- globalThis.clearInterval = _vlt_clearInterval;
10
- import {createRequire as _vlt_createRequire} from "node:module";
11
- var require = _vlt_createRequire(import.meta.filename);
12
- import {
13
- error
14
- } from "./chunk-WZWDS3W4.js";
15
- import {
16
- __glob
17
- } from "./chunk-PZLD7RTK.js";
18
-
19
- // import("./commands/**/*.ts") in ../../src/cli-sdk/src/load-command.ts
20
- var globImport_commands_ts = __glob({
21
- "./commands/access.ts": () => import("./access-6HRR4HXE.js"),
22
- "./commands/bugs.ts": () => import("./bugs-2CAZQ32S.js"),
23
- "./commands/build.ts": () => import("./build-OAWTNBMS.js"),
24
- "./commands/cache.ts": () => import("./cache-JTAFST6T.js"),
25
- "./commands/ci.ts": () => import("./ci-TOJJVHI4.js"),
26
- "./commands/config.ts": () => import("./config-GOV4E2KK.js"),
27
- "./commands/create.ts": () => import("./create-NGJD7K4L.js"),
28
- "./commands/deprecate.ts": () => import("./deprecate-WROL4AHK.js"),
29
- "./commands/dist-tag.ts": () => import("./dist-tag-WZXXWXMB.js"),
30
- "./commands/docs.ts": () => import("./docs-YCOZFMZG.js"),
31
- "./commands/exec-cache.ts": () => import("./exec-cache-KHDOEH2F.js"),
32
- "./commands/exec-local.ts": () => import("./exec-local-52TVUL5K.js"),
33
- "./commands/exec.ts": () => import("./exec-URG5OWLH.js"),
34
- "./commands/help.ts": () => import("./help-LNSDVBGJ.js"),
35
- "./commands/init.ts": () => import("./init-XNMWYATA.js"),
36
- "./commands/install.ts": () => import("./install-SKUZERZJ.js"),
37
- "./commands/install/reporter.ts": () => import("./reporter-NUXJTV4G.js"),
38
- "./commands/list.ts": () => import("./list-XEDVFUD5.js"),
39
- "./commands/login.ts": () => import("./login-52SA2DSI.js"),
40
- "./commands/logout.ts": () => import("./logout-5YYHNV5W.js"),
41
- "./commands/pack.ts": () => import("./pack-B7QZHMYP.js"),
42
- "./commands/ping.ts": () => import("./ping-PRGDYDRI.js"),
43
- "./commands/pkg.ts": () => import("./pkg-UEIQIVVD.js"),
44
- "./commands/profile.ts": () => import("./profile-46FKVQEL.js"),
45
- "./commands/publish.ts": () => import("./publish-HBYHOSKH.js"),
46
- "./commands/query.ts": () => import("./query-5A4YLS2C.js"),
47
- "./commands/repo.ts": () => import("./repo-I6X66PHD.js"),
48
- "./commands/run-exec.ts": () => import("./run-exec-6ADY4BKH.js"),
49
- "./commands/run.ts": () => import("./run-VEZMUMVH.js"),
50
- "./commands/token.ts": () => import("./token-YK6L74PA.js"),
51
- "./commands/uninstall.ts": () => import("./uninstall-UBUZBV7E.js"),
52
- "./commands/unpublish.ts": () => import("./unpublish-ZHJEKT7A.js"),
53
- "./commands/update.ts": () => import("./update-WO4BHJF4.js"),
54
- "./commands/version.ts": () => import("./version-RLESYHML.js"),
55
- "./commands/view.ts": () => import("./view-UA5HXFXG.js"),
56
- "./commands/whoami.ts": () => import("./whoami-7H3FPR2O.js")
57
- });
58
-
59
- // ../../src/cli-sdk/src/load-command.ts
60
- var loadCommand = async (command) => {
61
- try {
62
- return await globImport_commands_ts(`./commands/${command}.ts`);
63
- } catch (e) {
64
- throw error("Could not load command", {
65
- found: command,
66
- cause: e
67
- });
68
- }
69
- };
70
-
71
- export {
72
- loadCommand
73
- };
package/chunk-BW6C3YUV.js DELETED
@@ -1,301 +0,0 @@
1
- var global = globalThis;
2
- import {Buffer} from "node:buffer";
3
- import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
4
- globalThis.setTimeout = _vlt_setTimeout;
5
- globalThis.clearTimeout = _vlt_clearTimeout;
6
- globalThis.setImmediate = _vlt_setImmediate;
7
- globalThis.clearImmediate = _vlt_clearImmediate;
8
- globalThis.setInterval = _vlt_setInterval;
9
- globalThis.clearInterval = _vlt_clearInterval;
10
- import {createRequire as _vlt_createRequire} from "node:module";
11
- var require = _vlt_createRequire(import.meta.filename);
12
- import {
13
- It,
14
- Zn,
15
- require_lib
16
- } from "./chunk-HQ4US6G3.js";
17
- import {
18
- minimatch
19
- } from "./chunk-XYCCQT7N.js";
20
- import {
21
- Spec2 as Spec
22
- } from "./chunk-IEISSXS4.js";
23
- import {
24
- parse,
25
- stringify
26
- } from "./chunk-HTOTG4TS.js";
27
- import {
28
- error
29
- } from "./chunk-WZWDS3W4.js";
30
- import {
31
- __toESM
32
- } from "./chunk-PZLD7RTK.js";
33
-
34
- // ../../src/cli-sdk/src/pack-tarball.ts
35
- var ssri = __toESM(require_lib(), 1);
36
- import assert from "node:assert";
37
- import { existsSync, statSync } from "node:fs";
38
- import { join } from "node:path";
39
- var replaceWorkspaceAndCatalogSpecs = (manifest_, config) => {
40
- const manifest = parse(stringify(manifest_));
41
- const { monorepo, catalog = {}, catalogs = {} } = config.options;
42
- const depTypes = [
43
- "dependencies",
44
- "devDependencies",
45
- "optionalDependencies",
46
- "peerDependencies"
47
- ];
48
- for (const depType of depTypes) {
49
- const deps = manifest[depType];
50
- if (!deps || typeof deps !== "object") continue;
51
- const depsObj = deps;
52
- for (const [depName, depSpec] of Object.entries(depsObj)) {
53
- if (typeof depSpec !== "string") continue;
54
- const spec = Spec.parse(`${depName}@${depSpec}`, {
55
- catalog,
56
- catalogs
57
- });
58
- switch (spec.type) {
59
- case "workspace": {
60
- assert(
61
- monorepo,
62
- error(`No workspace configuration found for ${depName}`, {
63
- found: depName
64
- })
65
- );
66
- const workspaceName = spec.workspace;
67
- assert(
68
- workspaceName,
69
- error(`No workspace name found for ${depName}`, {
70
- found: depName
71
- })
72
- );
73
- const workspace = monorepo.get(workspaceName);
74
- assert(
75
- workspace,
76
- error(`Workspace '${workspaceName}' not found`, {
77
- found: workspaceName,
78
- validOptions: Array.from(monorepo.keys())
79
- })
80
- );
81
- const actualVersion = workspace.manifest.version;
82
- assert(
83
- actualVersion,
84
- error(
85
- `No version found for workspace '${workspaceName}'`,
86
- {
87
- found: workspaceName,
88
- wanted: "package version"
89
- }
90
- )
91
- );
92
- depsObj[depName] = actualVersion;
93
- break;
94
- }
95
- case "catalog": {
96
- const catalogName = spec.catalog || "";
97
- const targetCatalog = catalogName ? catalogs[catalogName] : catalog;
98
- assert(
99
- targetCatalog,
100
- error(`Catalog '${catalogName}' not found`, {
101
- found: catalogName,
102
- validOptions: Object.keys(catalogs)
103
- })
104
- );
105
- const actualVersion = targetCatalog[depName];
106
- assert(
107
- actualVersion,
108
- error(
109
- `Package '${depName}' not found in catalog '${catalogName || "default"}'`,
110
- {
111
- found: depName,
112
- validOptions: Object.keys(targetCatalog)
113
- }
114
- )
115
- );
116
- depsObj[depName] = actualVersion;
117
- break;
118
- }
119
- }
120
- }
121
- }
122
- return manifest;
123
- };
124
- var packTarball = async (manifest, dir, config) => {
125
- let packDir = dir;
126
- const cliPublishDir = config.get("publish-directory");
127
- const manifestPublishDir = manifest.publishConfig?.directory;
128
- const publishDirectory = cliPublishDir ?? manifestPublishDir;
129
- if (publishDirectory) {
130
- const resolvedPublishDir = cliPublishDir ? publishDirectory : join(dir, publishDirectory);
131
- assert(
132
- existsSync(resolvedPublishDir),
133
- error(
134
- `Publish directory does not exist: ${resolvedPublishDir}`,
135
- {
136
- found: resolvedPublishDir
137
- }
138
- )
139
- );
140
- assert(
141
- statSync(resolvedPublishDir).isDirectory(),
142
- error(
143
- `Publish directory is not a directory: ${resolvedPublishDir}`,
144
- {
145
- found: resolvedPublishDir,
146
- wanted: "directory"
147
- }
148
- )
149
- );
150
- if (existsSync(join(resolvedPublishDir, "package.json"))) {
151
- manifest = config.options.packageJson.read(resolvedPublishDir);
152
- }
153
- packDir = resolvedPublishDir;
154
- }
155
- assert(
156
- manifest.name && manifest.version,
157
- error("Package must have a name and version")
158
- );
159
- const processedManifest = replaceWorkspaceAndCatalogSpecs(
160
- manifest,
161
- config
162
- );
163
- const filename = `${manifest.name.replace("@", "").replace("/", "-")}-${manifest.version}.tgz`;
164
- const tarballName = `${manifest.name}-${manifest.version}.tgz`;
165
- try {
166
- config.options.packageJson.write(packDir, processedManifest);
167
- const tarballData = await Zn(
168
- {
169
- cwd: packDir,
170
- gzip: true,
171
- portable: true,
172
- prefix: "package/",
173
- filter: (path) => {
174
- const normalizedPath = path.replace(/^\.\//, "");
175
- if (path === "." || normalizedPath === "") {
176
- return true;
177
- }
178
- const alwaysExcludePatterns = [
179
- /^\.?\/?\.git(\/|$)/,
180
- /^\.?\/?node_modules(\/|$)/,
181
- /^\.?\/?\.nyc_output(\/|$)/,
182
- /^\.?\/?coverage(\/|$)/,
183
- /^\.?\/?\.DS_Store$/,
184
- /^\.?\/?\.npmrc$/,
185
- /^\.?\/?package-lock\.json$/,
186
- /^\.?\/?yarn\.lock$/,
187
- /^\.?\/?pnpm-lock\.yaml$/,
188
- /^\.?\/?bun\.lockb$/,
189
- /^\.?\/?bun\.lock$/,
190
- /^\.?\/?vlt-lock\.json$/,
191
- /~$/,
192
- /\.swp$/,
193
- /\.tgz$/
194
- ];
195
- if (alwaysExcludePatterns.some(
196
- (pattern) => pattern.test(normalizedPath)
197
- )) {
198
- return false;
199
- }
200
- const alwaysIncludePatterns = [
201
- /^README(\..*)?$/i,
202
- /^CHANGELOG(\..*)?$/i,
203
- /^HISTORY(\..*)?$/i,
204
- /^LICENSE(\..*)?$/i,
205
- /^LICENCE(\..*)?$/i
206
- ];
207
- if (alwaysIncludePatterns.some(
208
- (pattern) => pattern.test(normalizedPath)
209
- )) {
210
- return true;
211
- }
212
- if (normalizedPath === "package.json") {
213
- return true;
214
- }
215
- const manifestWithFiles = manifest;
216
- if (manifestWithFiles.files && Array.isArray(manifestWithFiles.files)) {
217
- if (manifestWithFiles.files.length === 0) {
218
- return false;
219
- }
220
- return manifestWithFiles.files.some((pattern) => {
221
- if (pattern.endsWith("/")) {
222
- const dirName = pattern.slice(0, -1);
223
- const globPattern = pattern.replace(/\/$/, "/**");
224
- const matchesDir = normalizedPath === dirName;
225
- const matchesContents = minimatch(
226
- normalizedPath,
227
- globPattern,
228
- {
229
- dot: true
230
- }
231
- );
232
- return matchesDir || matchesContents;
233
- }
234
- const directMatch = minimatch(normalizedPath, pattern, {
235
- dot: true
236
- });
237
- const isParentDir = pattern.includes("/") && pattern.startsWith(normalizedPath + "/");
238
- const isChildOfPattern = minimatch(
239
- normalizedPath,
240
- pattern + "/**",
241
- { dot: true }
242
- );
243
- return directMatch || isParentDir || isChildOfPattern;
244
- });
245
- }
246
- const defaultExcludePatterns = [
247
- /^\.?\/?\.vscode(\/|$)/,
248
- /^\.?\/?\.idea(\/|$)/,
249
- /^\.?\/?\.gitignore$/,
250
- /^\.?\/?\.npmignore$/,
251
- /^\.?\/?\.editorconfig$/
252
- ];
253
- return !defaultExcludePatterns.some(
254
- (pattern) => pattern.test(normalizedPath)
255
- );
256
- }
257
- },
258
- ["."]
259
- ).concat();
260
- let unpackedSize = 0;
261
- const files = [];
262
- await new Promise((resolve, reject) => {
263
- const stream = It({
264
- onentry: (entry) => {
265
- if (entry.type === "File") {
266
- unpackedSize += entry.size;
267
- const cleanPath = entry.path.replace(/^[^/]+\//, "");
268
- if (cleanPath) {
269
- files.push(cleanPath);
270
- }
271
- }
272
- }
273
- });
274
- stream.on("end", () => resolve()).on("error", reject).write(tarballData);
275
- stream.end();
276
- });
277
- const integrityMap = ssri.fromData(tarballData, {
278
- algorithms: [.../* @__PURE__ */ new Set(["sha1", "sha512"])]
279
- });
280
- const integrity = integrityMap.sha512?.[0]?.toString();
281
- const shasum = integrityMap.sha1?.[0]?.hexDigest();
282
- return {
283
- name: manifest.name,
284
- version: manifest.version,
285
- filename,
286
- tarballName,
287
- tarballData,
288
- unpackedSize,
289
- files,
290
- integrity,
291
- shasum,
292
- resolvedManifest: processedManifest
293
- };
294
- } finally {
295
- config.options.packageJson.write(packDir, manifest);
296
- }
297
- };
298
-
299
- export {
300
- packTarball
301
- };