@vltpkg/cli-sdk 1.1.0 → 1.1.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.
- package/dist/commands/setup.d.ts +7 -0
- package/dist/commands/setup.js +32 -6
- package/package.json +25 -25
package/dist/commands/setup.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ export declare const VLT_REGISTRY_BASE = "https://registry.vlt.io";
|
|
|
10
10
|
export declare const accountRegistries: readonly ["npm", "main"];
|
|
11
11
|
/** Build the per-account registry URL for a given registry name. */
|
|
12
12
|
export declare const accountRegistryURL: (account: string, name: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Path-scoped keychain keys do not match sibling registries
|
|
15
|
+
* (`…/<account>/main` vs `…/<account>/npm`). One account token covers
|
|
16
|
+
* both, so when the keychain holds it for only one alias, copy it to
|
|
17
|
+
* the other.
|
|
18
|
+
*/
|
|
19
|
+
export declare const persistAccountTokens: (account: string, identity: string) => Promise<void>;
|
|
13
20
|
export type SetupResult = {
|
|
14
21
|
/** the account slug the registries were built for */
|
|
15
22
|
account: string;
|
package/dist/commands/setup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { RegistryClient } from '@vltpkg/registry-client';
|
|
2
|
+
import { getKC, normalizeRegistryKey, RegistryClient, } from '@vltpkg/registry-client';
|
|
3
3
|
import { defaultRegistries } from '@vltpkg/spec';
|
|
4
4
|
import { asError, isErrorWithCause, isObject } from '@vltpkg/types';
|
|
5
5
|
import { createInterface } from 'node:readline/promises';
|
|
@@ -19,6 +19,27 @@ export const VLT_REGISTRY_BASE = 'https://registry.vlt.io';
|
|
|
19
19
|
export const accountRegistries = ['npm', 'main'];
|
|
20
20
|
/** Build the per-account registry URL for a given registry name. */
|
|
21
21
|
export const accountRegistryURL = (account, name) => `${VLT_REGISTRY_BASE}/${encodeURIComponent(account)}/${name}/`;
|
|
22
|
+
/**
|
|
23
|
+
* Path-scoped keychain keys do not match sibling registries
|
|
24
|
+
* (`…/<account>/main` vs `…/<account>/npm`). One account token covers
|
|
25
|
+
* both, so when the keychain holds it for only one alias, copy it to
|
|
26
|
+
* the other.
|
|
27
|
+
*/
|
|
28
|
+
export const persistAccountTokens = async (account, identity) => {
|
|
29
|
+
// keychain only: getToken() also returns env/runtime tokens
|
|
30
|
+
const kc = getKC(identity);
|
|
31
|
+
const keys = accountRegistries.map(name => normalizeRegistryKey(accountRegistryURL(account, name)));
|
|
32
|
+
const tokens = await Promise.all(keys.map(k => kc.get(k)));
|
|
33
|
+
const token = tokens.find(Boolean);
|
|
34
|
+
if (!token)
|
|
35
|
+
return;
|
|
36
|
+
// fill gaps only: never overwrite an existing (maybe newer) token
|
|
37
|
+
for (const [i, key] of keys.entries()) {
|
|
38
|
+
if (!tokens[i])
|
|
39
|
+
kc.set(key, token);
|
|
40
|
+
}
|
|
41
|
+
await kc.save();
|
|
42
|
+
};
|
|
22
43
|
/**
|
|
23
44
|
* The account registries live at `${VLT_REGISTRY_BASE}/<account>/<name>/`, so
|
|
24
45
|
* an account slug that doesn't exist is a 404 from the login endpoint. Say
|
|
@@ -61,9 +82,10 @@ export const usage = () => commandUsage({
|
|
|
61
82
|
that \`vlt install\` and \`vlx\` work out of the box.
|
|
62
83
|
|
|
63
84
|
Sign up or log in at ${VLT_SIGNUP_URL} first. The wizard
|
|
64
|
-
authenticates against your account
|
|
65
|
-
\`npm\` and \`main\`
|
|
66
|
-
aliases you add) to
|
|
85
|
+
authenticates against your account, stores the token
|
|
86
|
+
for both the \`npm\` and \`main\` registries, and writes
|
|
87
|
+
those aliases (and any additional aliases you add) to
|
|
88
|
+
your user \`vlt.json\`.`,
|
|
67
89
|
options: {
|
|
68
90
|
config: {
|
|
69
91
|
value: '<user | project>',
|
|
@@ -128,8 +150,8 @@ export const command = async (conf) => {
|
|
|
128
150
|
if (!yes) {
|
|
129
151
|
const doAuth = await ask('Authenticate with your vlt.io account now? (Y/n) ');
|
|
130
152
|
if (!/^n/i.test(doAuth)) {
|
|
131
|
-
// one
|
|
132
|
-
//
|
|
153
|
+
// one login covers both account registries; the token is stored
|
|
154
|
+
// for each of them so path-scoped keychain lookups match.
|
|
133
155
|
stdout(`Authenticating your account registries (${accountRegistries.join(', ')})...`);
|
|
134
156
|
try {
|
|
135
157
|
await rc.login(accountRegistries.map(name => accountRegistryURL(account, name)));
|
|
@@ -167,6 +189,10 @@ export const command = async (conf) => {
|
|
|
167
189
|
}
|
|
168
190
|
// 6. persist the staged registries (merged, not clobbered)
|
|
169
191
|
await conf.addConfigToFile(which, { registries });
|
|
192
|
+
// 7. fill a missing `npm`/`main` keychain entry from the other.
|
|
193
|
+
// no-op after login(), which already wrote both. runs after the
|
|
194
|
+
// config write so a keychain failure can't block it.
|
|
195
|
+
await persistAccountTokens(account, conf.options.identity);
|
|
170
196
|
// writing the user config from inside a project that configures its own
|
|
171
197
|
// registries has no effect here, so say so rather than looking like it
|
|
172
198
|
// worked.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/cli-sdk",
|
|
3
3
|
"description": "The source for the vlt CLI",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -14,30 +14,30 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@resvg/resvg-wasm": "^2.6.2",
|
|
17
|
-
"@vltpkg/config": "1.1.
|
|
18
|
-
"@vltpkg/dep-id": "1.1.
|
|
19
|
-
"@vltpkg/dot-prop": "1.1.
|
|
20
|
-
"@vltpkg/error-cause": "1.1.
|
|
21
|
-
"@vltpkg/git": "1.1.
|
|
22
|
-
"@vltpkg/graph": "1.1.
|
|
23
|
-
"@vltpkg/graph-run": "1.1.
|
|
24
|
-
"@vltpkg/init": "1.1.
|
|
25
|
-
"@vltpkg/output": "1.1.
|
|
26
|
-
"@vltpkg/package-info": "1.1.
|
|
27
|
-
"@vltpkg/package-json": "1.1.
|
|
28
|
-
"@vltpkg/promise-spawn": "1.1.
|
|
29
|
-
"@vltpkg/query": "1.1.
|
|
30
|
-
"@vltpkg/registry-client": "1.1.
|
|
31
|
-
"@vltpkg/rollback-remove": "1.1.
|
|
32
|
-
"@vltpkg/run": "1.1.
|
|
33
|
-
"@vltpkg/security-archive": "1.1.
|
|
34
|
-
"@vltpkg/spec": "1.1.
|
|
35
|
-
"@vltpkg/types": "1.1.
|
|
36
|
-
"@vltpkg/url-open": "1.1.
|
|
37
|
-
"@vltpkg/vlt-json": "1.1.
|
|
38
|
-
"@vltpkg/vlx": "1.1.
|
|
39
|
-
"@vltpkg/workspaces": "1.1.
|
|
40
|
-
"@vltpkg/xdg": "1.1.
|
|
17
|
+
"@vltpkg/config": "1.1.1",
|
|
18
|
+
"@vltpkg/dep-id": "1.1.1",
|
|
19
|
+
"@vltpkg/dot-prop": "1.1.1",
|
|
20
|
+
"@vltpkg/error-cause": "1.1.1",
|
|
21
|
+
"@vltpkg/git": "1.1.1",
|
|
22
|
+
"@vltpkg/graph": "1.1.1",
|
|
23
|
+
"@vltpkg/graph-run": "1.1.1",
|
|
24
|
+
"@vltpkg/init": "1.1.1",
|
|
25
|
+
"@vltpkg/output": "1.1.1",
|
|
26
|
+
"@vltpkg/package-info": "1.1.1",
|
|
27
|
+
"@vltpkg/package-json": "1.1.1",
|
|
28
|
+
"@vltpkg/promise-spawn": "1.1.1",
|
|
29
|
+
"@vltpkg/query": "1.1.1",
|
|
30
|
+
"@vltpkg/registry-client": "1.1.1",
|
|
31
|
+
"@vltpkg/rollback-remove": "1.1.1",
|
|
32
|
+
"@vltpkg/run": "1.1.1",
|
|
33
|
+
"@vltpkg/security-archive": "1.1.1",
|
|
34
|
+
"@vltpkg/spec": "1.1.1",
|
|
35
|
+
"@vltpkg/types": "1.1.1",
|
|
36
|
+
"@vltpkg/url-open": "1.1.1",
|
|
37
|
+
"@vltpkg/vlt-json": "1.1.1",
|
|
38
|
+
"@vltpkg/vlx": "1.1.1",
|
|
39
|
+
"@vltpkg/workspaces": "1.1.1",
|
|
40
|
+
"@vltpkg/xdg": "1.1.1",
|
|
41
41
|
"ansi-to-pre": "^1.0.6",
|
|
42
42
|
"beautiful-mermaid": "^1.1.3",
|
|
43
43
|
"chalk": "^5.6.2",
|