@vltpkg/cli-js 1.0.9 → 1.1.0
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.
- package/{access-5DJJIIGD.js → access-GLWBGQLN.js} +41 -10
- package/{bugs-NRHU4ENC.js → bugs-OCQYFWFE.js} +18 -18
- package/{build-5VZJTEBD.js → build-CPWGNTCM.js} +7 -8
- package/{cache-QZ5XII4U.js → cache-SL7DQMY2.js} +20 -14
- package/chunk-2IMBYPYC.js +190 -0
- package/{chunk-5JFRXIK2.js → chunk-2PWSMJD7.js} +20 -1
- package/{chunk-LHMEJF6J.js → chunk-47M7IZ5P.js} +94 -39
- package/{chunk-6NQBG3ZR.js → chunk-6LEMBT22.js} +30 -5
- package/chunk-A75UYRJC.js +75 -0
- package/{chunk-HAYXR3MW.js → chunk-APMYKJI2.js} +1 -1
- package/{chunk-A6TBJ4AB.js → chunk-BUXPKRYB.js} +4 -4
- package/{chunk-PTR5IGFQ.js → chunk-CBASIDQH.js} +1 -1
- package/{chunk-XISRK3R5.js → chunk-CEHPRPGQ.js} +38 -0
- package/{chunk-KCXN2GTX.js → chunk-CF5EGH4W.js} +12 -2
- package/{chunk-HRY5MJCA.js → chunk-CTQSUNNE.js} +35 -19
- package/{chunk-ATYE2HQV.js → chunk-GJGQTRAT.js} +165 -30
- package/{chunk-YAIKXFLN.js → chunk-HYCYL4RX.js} +1 -1
- package/{chunk-EBXBZ2Y5.js → chunk-J2XWQVDK.js} +98 -6
- package/{chunk-SBEZ7RUC.js → chunk-JSQUYHU7.js} +5 -5
- package/{chunk-GKCU7R4B.js → chunk-S6Y57MUS.js} +4 -4
- package/chunk-SNOBGFNM.js +129 -0
- package/{chunk-MXCWH7WC.js → chunk-TNEMFBP5.js} +41 -10
- package/{chunk-USRMYD4F.js → chunk-TUXWDPCQ.js} +1 -1
- package/{chunk-2HDWM6AD.js → chunk-TXTK2PKN.js} +2 -2
- package/{chunk-LPIBYUMT.js → chunk-U7TEQCBN.js} +27 -1
- package/{chunk-XFI4THXZ.js → chunk-WE2TQN32.js} +1 -1
- package/{chunk-USTJECVS.js → chunk-X2AWQGYG.js} +1 -1
- package/{chunk-6WMR7BLF.js → chunk-YKCGWKUE.js} +3 -3
- package/{chunk-2YJ5MESP.js → chunk-ZDQJWRCU.js} +1 -1
- package/{ci-MBYD4AGJ.js → ci-O2RSLTBX.js} +9 -10
- package/cli-package.json +1 -1
- package/{config-DTZ7EWQF.js → config-ZBIF32GS.js} +11 -11
- package/{config-RQKPUW5B.js → config-ZPH7V77F.js} +8 -6
- package/{create-CYTNZ66Z.js → create-2JX4RV5U.js} +17 -17
- package/{deprecate-H3L4MPZS.js → deprecate-XJLP2TUW.js} +21 -18
- package/{dist-tag-CZHTW7C6.js → dist-tag-F6ZFWGQU.js} +23 -25
- package/{docs-Z76UCNLH.js → docs-IJCZZ4V6.js} +18 -18
- package/{exec-PGPFYCAM.js → exec-IWSS2LUA.js} +17 -17
- package/{exec-cache-HPILZWUY.js → exec-cache-AG77OOEE.js} +15 -15
- package/{exec-local-VKDC6XAQ.js → exec-local-QXPWC4QG.js} +13 -14
- package/{help-QPZESL4Y.js → help-TGNDNWLP.js} +4 -4
- package/{init-MMQV6UC5.js → init-WU7BRPKR.js} +7 -8
- package/{install-KZPDV66V.js → install-74XKB5N7.js} +37 -14
- package/{list-PJ2U4FE7.js → list-TOEC6Q3A.js} +41 -29
- package/{login-L3D5FQGT.js → login-WJYMAFSL.js} +11 -11
- package/{logout-SRZ574SQ.js → logout-MTRQWI3L.js} +7 -7
- package/{pack-OI5JLA3R.js → pack-FFWGLSNC.js} +11 -12
- package/package.json +1 -1
- package/{ping-VQ662NAP.js → ping-DWUVTCJB.js} +7 -7
- package/{pkg-HNPRMTWV.js → pkg-KNZW5FIA.js} +10 -11
- package/{profile-Z7IOODZ4.js → profile-6W2ABNXL.js} +20 -7
- package/{publish-KTUUX25U.js → publish-HGNUONU3.js} +35 -65
- package/{query-MV5HKRIT.js → query-FSCYPETX.js} +35 -23
- package/{registry-BMWXMQS4.js → registry-YTJZ3AQD.js} +3 -3
- package/registry-client-package.json +6 -1
- package/registry-client-src-revalidate.js +241 -43
- package/{repo-ZBCD65WE.js → repo-OVIKYYWA.js} +18 -18
- package/{reporter-SDMDYYMJ.js → reporter-ZW7OMRZT.js} +23 -1
- package/{run-QJK5LA6Q.js → run-UPV3RPQJ.js} +13 -14
- package/{run-exec-EAASMT5O.js → run-exec-YJSMWMMP.js} +13 -14
- package/{setup-Q7NTAV26.js → setup-7DPMAPUY.js} +20 -19
- package/{src-YVODDQYK.js → src-BNCFK4FH.js} +15 -15
- package/{src-MEEFRFWA.js → src-XJT4IJSV.js} +11 -4
- package/{token-NQRHTTKG.js → token-GA73ER5V.js} +8 -8
- package/{uninstall-E2SVGYI3.js → uninstall-E3VKSC3B.js} +11 -11
- package/{unpublish-IE4KYVM4.js → unpublish-Q6MQHBPQ.js} +43 -40
- package/{update-KZOWARII.js → update-4CC44TR5.js} +34 -12
- package/{version-T6PTPZPR.js → version-CRZBXNDG.js} +23 -18
- package/{view-MVYV7YZ2.js → view-ILUULGSO.js} +9 -9
- package/vlr.js +1 -1
- package/vlrx.js +1 -1
- package/vlt.js +1 -1
- package/vlx.js +1 -1
- package/vlxl.js +1 -1
- package/{whoami-A5RM2Z7Z.js → whoami-Z4TSLYTR.js} +28 -12
- package/chunk-UBLFPJHV.js +0 -40
- package/chunk-XEPCV7DP.js +0 -75
|
@@ -11,19 +11,21 @@ import {createRequire as _vlt_createRequire} from "node:module";
|
|
|
11
11
|
var require = _vlt_createRequire(import.meta.filename);
|
|
12
12
|
import {
|
|
13
13
|
resolveRegistry
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2PWSMJD7.js";
|
|
15
15
|
import {
|
|
16
16
|
commandUsage
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-CBASIDQH.js";
|
|
18
18
|
import "./chunk-XKVU23NC.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-CEHPRPGQ.js";
|
|
20
20
|
import {
|
|
21
21
|
RegistryClient
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-GJGQTRAT.js";
|
|
23
|
+
import "./chunk-APMYKJI2.js";
|
|
24
|
+
import {
|
|
25
|
+
assertOk
|
|
26
|
+
} from "./chunk-SNOBGFNM.js";
|
|
24
27
|
import "./chunk-E74WGW5C.js";
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-UBLFPJHV.js";
|
|
28
|
+
import "./chunk-U7TEQCBN.js";
|
|
27
29
|
import "./chunk-VFBCWAOC.js";
|
|
28
30
|
import "./chunk-XNLSTHDK.js";
|
|
29
31
|
import "./chunk-BHJT53TP.js";
|
|
@@ -116,6 +118,7 @@ var command = async (conf) => {
|
|
|
116
118
|
}
|
|
117
119
|
};
|
|
118
120
|
var encodePkgName = (name) => name.startsWith("@") ? `@${encodeURIComponent(name.slice(1))}` : encodeURIComponent(name);
|
|
121
|
+
var accessAdvice = (what) => (statusCode) => statusCode === 401 ? "Run `vlt login` and try again." : statusCode === 403 ? `This account cannot ${what}. Run \`vlt whoami\` to see who you are logged in as.` : statusCode === 404 ? "Not found. Check the name, and that this account has access to it." : void 0;
|
|
119
122
|
var listPackages = async (conf, args) => {
|
|
120
123
|
const [keyword, entity] = args;
|
|
121
124
|
if (keyword !== "packages") {
|
|
@@ -132,6 +135,11 @@ var listPackages = async (conf, args) => {
|
|
|
132
135
|
registryUrl
|
|
133
136
|
);
|
|
134
137
|
const response = await rc.request(url, { useCache: false });
|
|
138
|
+
assertOk(response, {
|
|
139
|
+
message: "Failed to list packages",
|
|
140
|
+
url,
|
|
141
|
+
advice: accessAdvice("list packages for this scope")
|
|
142
|
+
});
|
|
135
143
|
const data = response.json();
|
|
136
144
|
return { packages: data };
|
|
137
145
|
};
|
|
@@ -155,6 +163,11 @@ var getStatus = async (conf, args) => {
|
|
|
155
163
|
registryUrl
|
|
156
164
|
);
|
|
157
165
|
const response = await rc.request(url, { useCache: false });
|
|
166
|
+
assertOk(response, {
|
|
167
|
+
message: "Failed to get package access status",
|
|
168
|
+
url,
|
|
169
|
+
advice: accessAdvice("read access for this package")
|
|
170
|
+
});
|
|
158
171
|
const data = response.json();
|
|
159
172
|
return { package: pkg, access: data.access };
|
|
160
173
|
};
|
|
@@ -185,13 +198,19 @@ var setStatus = async (conf, args) => {
|
|
|
185
198
|
`-/package/${encodePkgName(pkg)}/access`,
|
|
186
199
|
registryUrl
|
|
187
200
|
);
|
|
188
|
-
await rc.request(url, {
|
|
201
|
+
const response = await rc.request(url, {
|
|
189
202
|
method: "PUT",
|
|
190
203
|
headers: { "content-type": "application/json" },
|
|
191
204
|
body: JSON.stringify({ access: accessLevel }),
|
|
192
205
|
otp: conf.options.otp,
|
|
193
206
|
useCache: false
|
|
194
207
|
});
|
|
208
|
+
assertOk(response, {
|
|
209
|
+
message: "Failed to set package access status",
|
|
210
|
+
url,
|
|
211
|
+
method: "PUT",
|
|
212
|
+
advice: accessAdvice("change access for this package")
|
|
213
|
+
});
|
|
195
214
|
return { package: pkg, access: accessLevel };
|
|
196
215
|
};
|
|
197
216
|
var grant = async (conf, args) => {
|
|
@@ -223,7 +242,7 @@ var grant = async (conf, args) => {
|
|
|
223
242
|
`-/team/${encodeURIComponent(scope)}/${encodeURIComponent(team)}/package`,
|
|
224
243
|
registryUrl
|
|
225
244
|
);
|
|
226
|
-
await rc.request(url, {
|
|
245
|
+
const response = await rc.request(url, {
|
|
227
246
|
method: "PUT",
|
|
228
247
|
headers: { "content-type": "application/json" },
|
|
229
248
|
body: JSON.stringify({
|
|
@@ -233,6 +252,12 @@ var grant = async (conf, args) => {
|
|
|
233
252
|
otp: conf.options.otp,
|
|
234
253
|
useCache: false
|
|
235
254
|
});
|
|
255
|
+
assertOk(response, {
|
|
256
|
+
message: "Failed to grant team access",
|
|
257
|
+
url,
|
|
258
|
+
method: "PUT",
|
|
259
|
+
advice: accessAdvice("grant access for this team")
|
|
260
|
+
});
|
|
236
261
|
return {
|
|
237
262
|
granted: {
|
|
238
263
|
team: `${scope}:${team}`,
|
|
@@ -262,13 +287,19 @@ var revoke = async (conf, args) => {
|
|
|
262
287
|
`-/team/${encodeURIComponent(scope)}/${encodeURIComponent(team)}/package`,
|
|
263
288
|
registryUrl
|
|
264
289
|
);
|
|
265
|
-
await rc.request(url, {
|
|
290
|
+
const response = await rc.request(url, {
|
|
266
291
|
method: "DELETE",
|
|
267
292
|
headers: { "content-type": "application/json" },
|
|
268
293
|
body: JSON.stringify({ package: pkgName }),
|
|
269
294
|
otp: conf.options.otp,
|
|
270
295
|
useCache: false
|
|
271
296
|
});
|
|
297
|
+
assertOk(response, {
|
|
298
|
+
message: "Failed to revoke team access",
|
|
299
|
+
url,
|
|
300
|
+
method: "DELETE",
|
|
301
|
+
advice: accessAdvice("revoke access for this team")
|
|
302
|
+
});
|
|
272
303
|
return {
|
|
273
304
|
revoked: {
|
|
274
305
|
team: `${scope}:${team}`
|
|
@@ -14,42 +14,42 @@ import {
|
|
|
14
14
|
} from "./chunk-CLVRCGOZ.js";
|
|
15
15
|
import {
|
|
16
16
|
openUrl
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TXTK2PKN.js";
|
|
18
18
|
import {
|
|
19
19
|
createHostContextsMap
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-6LEMBT22.js";
|
|
21
|
+
import "./chunk-TNEMFBP5.js";
|
|
22
|
+
import "./chunk-HYCYL4RX.js";
|
|
23
|
+
import "./chunk-G2YT2GWF.js";
|
|
24
|
+
import "./chunk-GDJ7JT2R.js";
|
|
21
25
|
import {
|
|
22
26
|
PackageInfoClient
|
|
23
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-CTQSUNNE.js";
|
|
24
28
|
import "./chunk-ZWKI5OSF.js";
|
|
25
|
-
import "./chunk-MXCWH7WC.js";
|
|
26
|
-
import "./chunk-YAIKXFLN.js";
|
|
27
|
-
import "./chunk-G2YT2GWF.js";
|
|
28
|
-
import "./chunk-GDJ7JT2R.js";
|
|
29
|
-
import "./chunk-5JFRXIK2.js";
|
|
30
29
|
import "./chunk-WGDTG44V.js";
|
|
30
|
+
import "./chunk-2PWSMJD7.js";
|
|
31
31
|
import {
|
|
32
32
|
Query,
|
|
33
33
|
actual
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-47M7IZ5P.js";
|
|
35
35
|
import {
|
|
36
36
|
SecurityArchive
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import "./chunk-USTJECVS.js";
|
|
39
|
-
import "./chunk-YOE3VZFX.js";
|
|
37
|
+
} from "./chunk-ZDQJWRCU.js";
|
|
40
38
|
import {
|
|
41
39
|
commandUsage
|
|
42
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-CBASIDQH.js";
|
|
41
|
+
import "./chunk-X2AWQGYG.js";
|
|
42
|
+
import "./chunk-4KCU2KZL.js";
|
|
43
|
+
import "./chunk-YOE3VZFX.js";
|
|
43
44
|
import {
|
|
44
45
|
Spec
|
|
45
46
|
} from "./chunk-XKVU23NC.js";
|
|
46
|
-
import "./chunk-
|
|
47
|
-
import "./chunk-4KCU2KZL.js";
|
|
47
|
+
import "./chunk-CEHPRPGQ.js";
|
|
48
48
|
import "./chunk-HTOTG4TS.js";
|
|
49
|
-
import "./chunk-
|
|
49
|
+
import "./chunk-APMYKJI2.js";
|
|
50
|
+
import "./chunk-SNOBGFNM.js";
|
|
50
51
|
import "./chunk-E74WGW5C.js";
|
|
51
|
-
import "./chunk-
|
|
52
|
-
import "./chunk-UBLFPJHV.js";
|
|
52
|
+
import "./chunk-U7TEQCBN.js";
|
|
53
53
|
import "./chunk-VFBCWAOC.js";
|
|
54
54
|
import "./chunk-XNLSTHDK.js";
|
|
55
55
|
import "./chunk-BHJT53TP.js";
|
|
@@ -11,19 +11,18 @@ import {createRequire as _vlt_createRequire} from "node:module";
|
|
|
11
11
|
var require = _vlt_createRequire(import.meta.filename);
|
|
12
12
|
import {
|
|
13
13
|
build
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-USTJECVS.js";
|
|
17
|
-
import "./chunk-YOE3VZFX.js";
|
|
14
|
+
} from "./chunk-47M7IZ5P.js";
|
|
15
|
+
import "./chunk-ZDQJWRCU.js";
|
|
18
16
|
import {
|
|
19
17
|
commandUsage
|
|
20
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-CBASIDQH.js";
|
|
19
|
+
import "./chunk-X2AWQGYG.js";
|
|
20
|
+
import "./chunk-YOE3VZFX.js";
|
|
21
21
|
import "./chunk-XKVU23NC.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-CEHPRPGQ.js";
|
|
23
23
|
import "./chunk-HTOTG4TS.js";
|
|
24
24
|
import "./chunk-E74WGW5C.js";
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-UBLFPJHV.js";
|
|
25
|
+
import "./chunk-U7TEQCBN.js";
|
|
27
26
|
import {
|
|
28
27
|
isErrorWithCause
|
|
29
28
|
} from "./chunk-VFBCWAOC.js";
|
|
@@ -15,30 +15,32 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
stderr,
|
|
17
17
|
stdout
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-TNEMFBP5.js";
|
|
19
|
+
import "./chunk-HYCYL4RX.js";
|
|
20
20
|
import "./chunk-G2YT2GWF.js";
|
|
21
21
|
import "./chunk-GDJ7JT2R.js";
|
|
22
|
-
import "./chunk-5JFRXIK2.js";
|
|
23
22
|
import "./chunk-WGDTG44V.js";
|
|
24
|
-
import "./chunk-
|
|
23
|
+
import "./chunk-2PWSMJD7.js";
|
|
25
24
|
import {
|
|
26
25
|
commandUsage
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import {
|
|
29
|
-
Spec
|
|
30
|
-
} from "./chunk-XKVU23NC.js";
|
|
31
|
-
import "./chunk-XISRK3R5.js";
|
|
26
|
+
} from "./chunk-CBASIDQH.js";
|
|
32
27
|
import {
|
|
33
28
|
ViewClass
|
|
34
29
|
} from "./chunk-4KCU2KZL.js";
|
|
30
|
+
import "./chunk-YOE3VZFX.js";
|
|
31
|
+
import {
|
|
32
|
+
Spec
|
|
33
|
+
} from "./chunk-XKVU23NC.js";
|
|
34
|
+
import "./chunk-CEHPRPGQ.js";
|
|
35
35
|
import {
|
|
36
36
|
CacheEntry
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import "./chunk-
|
|
37
|
+
} from "./chunk-GJGQTRAT.js";
|
|
38
|
+
import "./chunk-APMYKJI2.js";
|
|
39
|
+
import {
|
|
40
|
+
assertOk
|
|
41
|
+
} from "./chunk-SNOBGFNM.js";
|
|
39
42
|
import "./chunk-E74WGW5C.js";
|
|
40
|
-
import "./chunk-
|
|
41
|
-
import "./chunk-UBLFPJHV.js";
|
|
43
|
+
import "./chunk-U7TEQCBN.js";
|
|
42
44
|
import "./chunk-VFBCWAOC.js";
|
|
43
45
|
import "./chunk-XNLSTHDK.js";
|
|
44
46
|
import "./chunk-BHJT53TP.js";
|
|
@@ -297,12 +299,16 @@ var add = async (conf, specs, view2) => {
|
|
|
297
299
|
staleWhileRevalidate: false
|
|
298
300
|
}).then(async (r) => {
|
|
299
301
|
const { resolved, integrity } = r;
|
|
300
|
-
await (await packageInfo.getRegistryClient()).request(resolved, {
|
|
302
|
+
const response = await (await packageInfo.getRegistryClient()).request(resolved, {
|
|
301
303
|
...conf.options,
|
|
302
304
|
integrity,
|
|
303
305
|
staleWhileRevalidate: false,
|
|
304
306
|
query: void 0
|
|
305
307
|
});
|
|
308
|
+
assertOk(response, {
|
|
309
|
+
message: `Failed to cache ${spec}`,
|
|
310
|
+
url: resolved
|
|
311
|
+
});
|
|
306
312
|
view2?.stdout("+", spec, r.resolved);
|
|
307
313
|
});
|
|
308
314
|
promises.push(p);
|
|
@@ -0,0 +1,190 @@
|
|
|
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
|
+
assertRegistryKeys,
|
|
14
|
+
configWriteTarget,
|
|
15
|
+
pairsToRecords,
|
|
16
|
+
registrySelectionFields,
|
|
17
|
+
registrySelectors
|
|
18
|
+
} from "./chunk-J2XWQVDK.js";
|
|
19
|
+
import {
|
|
20
|
+
normalizeRegistryURL
|
|
21
|
+
} from "./chunk-2PWSMJD7.js";
|
|
22
|
+
import {
|
|
23
|
+
getCommand,
|
|
24
|
+
isRecordField
|
|
25
|
+
} from "./chunk-CEHPRPGQ.js";
|
|
26
|
+
import {
|
|
27
|
+
find
|
|
28
|
+
} from "./chunk-HTOTG4TS.js";
|
|
29
|
+
import {
|
|
30
|
+
defaultGitHostArchives,
|
|
31
|
+
defaultGitHosts,
|
|
32
|
+
defaultJsrRegistries,
|
|
33
|
+
defaultRegistries,
|
|
34
|
+
defaultRegistryName,
|
|
35
|
+
isObject
|
|
36
|
+
} from "./chunk-VFBCWAOC.js";
|
|
37
|
+
import {
|
|
38
|
+
error
|
|
39
|
+
} from "./chunk-WZWDS3W4.js";
|
|
40
|
+
|
|
41
|
+
// ../../src/cli-sdk/src/persist-spec-config.ts
|
|
42
|
+
var specConfigFields = [
|
|
43
|
+
"registry",
|
|
44
|
+
"registries",
|
|
45
|
+
"default-registry-alias",
|
|
46
|
+
"scoped-registries",
|
|
47
|
+
"jsr-registries",
|
|
48
|
+
"git-hosts",
|
|
49
|
+
"git-host-archives"
|
|
50
|
+
];
|
|
51
|
+
var builtins = {
|
|
52
|
+
registries: defaultRegistries,
|
|
53
|
+
"jsr-registries": defaultJsrRegistries,
|
|
54
|
+
"git-hosts": defaultGitHosts,
|
|
55
|
+
"git-host-archives": defaultGitHostArchives
|
|
56
|
+
};
|
|
57
|
+
var urlFields = /* @__PURE__ */ new Set([
|
|
58
|
+
"registry",
|
|
59
|
+
"registries",
|
|
60
|
+
"scoped-registries",
|
|
61
|
+
"jsr-registries"
|
|
62
|
+
]);
|
|
63
|
+
var norm = (field, v) => urlFields.has(field) ? normalizeRegistryURL(v) : v;
|
|
64
|
+
var redact = (value) => {
|
|
65
|
+
if (!URL.canParse(value)) return value;
|
|
66
|
+
const url = new URL(value);
|
|
67
|
+
if (!url.username && !url.password) return value;
|
|
68
|
+
url.username = "";
|
|
69
|
+
url.password = "";
|
|
70
|
+
return url.href.replace("://", "://***@");
|
|
71
|
+
};
|
|
72
|
+
var fromLayer = (layer, field, key) => {
|
|
73
|
+
const v = layer?.[field];
|
|
74
|
+
const r = key === void 0 ? v : v && typeof v === "object" ? v[key] : void 0;
|
|
75
|
+
return typeof r === "string" ? r : void 0;
|
|
76
|
+
};
|
|
77
|
+
var isNulled = (layer, field, key) => {
|
|
78
|
+
const v = layer?.[field];
|
|
79
|
+
return key === void 0 ? v === null : isObject(v) && v[key] === null;
|
|
80
|
+
};
|
|
81
|
+
var conflictError = (field, key, current, wanted, file, block) => {
|
|
82
|
+
const name = (block ? `command.${block}.` : "") + (key === void 0 ? field : `${field}.${key}`);
|
|
83
|
+
const cur = redact(current);
|
|
84
|
+
const flag = key === void 0 ? `--${field}=${cur}` : `--${field} ${key}=${cur}`;
|
|
85
|
+
return error(
|
|
86
|
+
[
|
|
87
|
+
`${name} is already set to ${cur} in ${file}.`,
|
|
88
|
+
"",
|
|
89
|
+
`Pass \`${flag}\`${key === void 0 ? "" : ", use another name,"} or run`,
|
|
90
|
+
block ? "`vlt config edit` to change it first." : `\`vlt config set ${name}=${redact(wanted)}\` first.`
|
|
91
|
+
].join("\n"),
|
|
92
|
+
{ code: "ECONFIG", found: wanted, wanted: current }
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
var ownsSelection = (layer) => registrySelectionFields.some((f) => f in (layer ?? {}));
|
|
96
|
+
var planSpecConfigPersist = (conf) => {
|
|
97
|
+
if (!conf.get("save-config")) return void 0;
|
|
98
|
+
const explicit = pairsToRecords(conf.explicit);
|
|
99
|
+
if (!specConfigFields.some((f) => f in explicit)) return void 0;
|
|
100
|
+
const which = configWriteTarget(conf, "project");
|
|
101
|
+
const target = conf.layers[which];
|
|
102
|
+
const other = conf.layers[which === "project" ? "user" : "project"];
|
|
103
|
+
const otherSelectors = which === "user" || !ownsSelection(target);
|
|
104
|
+
const blocks = target?.command ?? {};
|
|
105
|
+
const blockName = Object.keys(blocks).filter((n) => getCommand(n) === conf.command).at(-1);
|
|
106
|
+
const block = blockName ? blocks[blockName] : void 0;
|
|
107
|
+
const staged = {};
|
|
108
|
+
for (const field of specConfigFields) {
|
|
109
|
+
const v = explicit[field];
|
|
110
|
+
if (v === void 0) continue;
|
|
111
|
+
const entries2 = isRecordField(field) ? Object.entries(v) : [[void 0, v]];
|
|
112
|
+
for (const [key, raw] of entries2) {
|
|
113
|
+
if (key === "") {
|
|
114
|
+
throw error(`${field} has an entry with no name.`, {
|
|
115
|
+
code: "ECONFIG",
|
|
116
|
+
found: `=${raw}`,
|
|
117
|
+
wanted: `<name>=${raw}`
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (key !== void 0 && field === "registries") {
|
|
121
|
+
assertRegistryKeys({ [key]: raw }, `--${field}`);
|
|
122
|
+
}
|
|
123
|
+
if (key !== void 0 && !raw) {
|
|
124
|
+
throw error(`${field}.${key} has no value.`, {
|
|
125
|
+
code: "ECONFIG",
|
|
126
|
+
found: key,
|
|
127
|
+
wanted: `${key}=<value>`
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (!raw) continue;
|
|
131
|
+
const value = norm(field, raw);
|
|
132
|
+
const inBlock = fromLayer(block, field, key);
|
|
133
|
+
if (inBlock !== void 0) {
|
|
134
|
+
if (norm(field, inBlock) === value) continue;
|
|
135
|
+
throw conflictError(
|
|
136
|
+
field,
|
|
137
|
+
key,
|
|
138
|
+
inBlock,
|
|
139
|
+
value,
|
|
140
|
+
find(which),
|
|
141
|
+
blockName
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
const toBlock = key !== void 0 && isObject(block?.[field]) ? blockName : void 0;
|
|
145
|
+
const current = toBlock === void 0 ? fromLayer(target, field, key) : void 0;
|
|
146
|
+
if (current !== void 0) {
|
|
147
|
+
if (norm(field, current) === value) continue;
|
|
148
|
+
throw conflictError(field, key, current, value, find(which));
|
|
149
|
+
}
|
|
150
|
+
const inOther = toBlock !== void 0 || isNulled(target, field, key) || key === void 0 && !otherSelectors ? void 0 : fromLayer(other, field, key);
|
|
151
|
+
const builtin = key !== void 0 ? builtins[field]?.[key] : field === "default-registry-alias" ? defaultRegistryName : void 0;
|
|
152
|
+
const inEffect = inOther ?? builtin;
|
|
153
|
+
if (inEffect !== void 0 && norm(field, inEffect) === value) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
let dest = staged;
|
|
157
|
+
if (toBlock !== void 0) {
|
|
158
|
+
const cmds = staged.command ??= {};
|
|
159
|
+
dest = cmds[toBlock] ??= {};
|
|
160
|
+
}
|
|
161
|
+
if (key === void 0) dest[field] = value;
|
|
162
|
+
else {
|
|
163
|
+
const rec = dest[field] ??= {};
|
|
164
|
+
rec[key] = value;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (!Object.keys(staged).length) return void 0;
|
|
169
|
+
const { user } = conf.layers;
|
|
170
|
+
if (which === "project" && ownsSelection(staged) && !ownsSelection(target)) {
|
|
171
|
+
for (const f of registrySelectors) {
|
|
172
|
+
const v = fromLayer(user, f);
|
|
173
|
+
if (v !== void 0 && !(f in staged)) staged[f] = v;
|
|
174
|
+
}
|
|
175
|
+
const alias = staged["default-registry-alias"];
|
|
176
|
+
const url = alias && fromLayer(user, "registries", alias);
|
|
177
|
+
const regs = staged.registries ?? {};
|
|
178
|
+
if (url && !(alias in regs)) {
|
|
179
|
+
staged.registries = { ...regs, [alias]: url };
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return { which, values: staged };
|
|
183
|
+
};
|
|
184
|
+
var entries = (path, v) => isObject(v) ? Object.entries(v).flatMap(([k, x]) => entries(`${path}.${k}`, x)) : [`${path}=${redact(String(v))}`];
|
|
185
|
+
var persistedEntries = (values) => Object.entries(values).flatMap(([f, v]) => entries(f, v));
|
|
186
|
+
|
|
187
|
+
export {
|
|
188
|
+
planSpecConfigPersist,
|
|
189
|
+
persistedEntries
|
|
190
|
+
};
|
|
@@ -11,7 +11,9 @@ import {createRequire as _vlt_createRequire} from "node:module";
|
|
|
11
11
|
var require = _vlt_createRequire(import.meta.filename);
|
|
12
12
|
import {
|
|
13
13
|
defaultRegistries,
|
|
14
|
-
defaultRegistryName
|
|
14
|
+
defaultRegistryName,
|
|
15
|
+
isErrorWithCause,
|
|
16
|
+
isObject
|
|
15
17
|
} from "./chunk-VFBCWAOC.js";
|
|
16
18
|
import {
|
|
17
19
|
error
|
|
@@ -68,6 +70,21 @@ var missingRegistryError = () => error(
|
|
|
68
70
|
].join("\n"),
|
|
69
71
|
{ code: "ECONFIG" }
|
|
70
72
|
);
|
|
73
|
+
var normalizeRegistryURL = (url) => url.replace(/\/*$/, "/");
|
|
74
|
+
var unknownSpecPrefixError = (prefix, spec, validOptions) => error(
|
|
75
|
+
[
|
|
76
|
+
`Unknown spec prefix "${prefix}:" in "${spec}".`,
|
|
77
|
+
"",
|
|
78
|
+
`Define it with \`--registries ${prefix}=<url>\` or`,
|
|
79
|
+
`\`--git-hosts ${prefix}=<template>\` (add \`--save-config\` to keep`,
|
|
80
|
+
`it in vlt.json), or run \`vlt config set registries.${prefix}=<url>\`.`
|
|
81
|
+
].join("\n"),
|
|
82
|
+
{ code: "ECONFIG", found: `${prefix}:`, validOptions }
|
|
83
|
+
);
|
|
84
|
+
var asUnknownSpecPrefix = (er) => {
|
|
85
|
+
const { found, spec, validOptions } = isErrorWithCause(er) && isObject(er.cause) ? er.cause : {};
|
|
86
|
+
return typeof found === "string" && /^[^:]+:$/.test(found) && typeof spec === "string" && er.message.startsWith("Protocol ") ? unknownSpecPrefixError(found.slice(0, -1), spec, validOptions) : er;
|
|
87
|
+
};
|
|
71
88
|
var missingNpmRegistryError = (alias = defaultRegistryName) => error(
|
|
72
89
|
[
|
|
73
90
|
`Missing ${alias} registry configuration.`,
|
|
@@ -144,6 +161,8 @@ var resolveRegistry = async (conf, {
|
|
|
144
161
|
|
|
145
162
|
export {
|
|
146
163
|
missingRegistryError,
|
|
164
|
+
normalizeRegistryURL,
|
|
165
|
+
asUnknownSpecPrefix,
|
|
147
166
|
missingNpmRegistryError,
|
|
148
167
|
hasConfiguredRegistry,
|
|
149
168
|
hasNpmRegistry,
|