@vltpkg/cli-sdk 1.0.0-rc.31 → 1.0.0-rc.32
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/token.js +3 -1
- package/dist/parse-add-remove-args.js +65 -11
- package/package.json +25 -25
package/dist/commands/token.js
CHANGED
|
@@ -133,6 +133,7 @@ const listTokens = async (rc, registry, identity, alias) => {
|
|
|
133
133
|
export const command = async (conf) => {
|
|
134
134
|
const reg = normalizeRegistryKey(conf.options.registry);
|
|
135
135
|
switch (conf.positionals[0]) {
|
|
136
|
+
case 'ls':
|
|
136
137
|
case 'list': {
|
|
137
138
|
const rc = new RegistryClient(conf.options);
|
|
138
139
|
const identity = conf.options.identity;
|
|
@@ -171,6 +172,7 @@ export const command = async (conf) => {
|
|
|
171
172
|
await setToken(reg, `Bearer ${await readPassword('Paste bearer token: ')}`, conf.options.identity);
|
|
172
173
|
break;
|
|
173
174
|
}
|
|
175
|
+
case 'remove':
|
|
174
176
|
case 'rm': {
|
|
175
177
|
await deleteToken(reg, conf.options.identity);
|
|
176
178
|
break;
|
|
@@ -178,7 +180,7 @@ export const command = async (conf) => {
|
|
|
178
180
|
default: {
|
|
179
181
|
throw error('Invalid token subcommand', {
|
|
180
182
|
found: conf.positionals[0],
|
|
181
|
-
validOptions: ['list', 'add', 'rm'],
|
|
183
|
+
validOptions: ['list', 'ls', 'add', 'rm', 'remove'],
|
|
182
184
|
code: 'EUSAGE',
|
|
183
185
|
});
|
|
184
186
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { asDependency } from '@vltpkg/graph';
|
|
2
|
-
import { joinDepIDTuple } from '@vltpkg/dep-id';
|
|
2
|
+
import { joinDepIDTuple, splitDepID } from '@vltpkg/dep-id';
|
|
3
3
|
import { Spec } from '@vltpkg/spec';
|
|
4
|
+
import { isAbsolute, relative, resolve } from 'node:path';
|
|
4
5
|
const rootDepID = joinDepIDTuple(['file', '.']);
|
|
5
6
|
/**
|
|
6
7
|
* Compute a DepID for the current working directory relative to the project
|
|
@@ -45,6 +46,36 @@ class AddImportersDependenciesMapImpl extends Map {
|
|
|
45
46
|
class RemoveImportersDependenciesMapImpl extends Map {
|
|
46
47
|
modifiedDependencies = false;
|
|
47
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Rebase a file: spec's relative path from process.cwd() to the
|
|
51
|
+
* importer's location. CLI positional args are relative to cwd,
|
|
52
|
+
* but the graph resolver resolves file: paths relative to the
|
|
53
|
+
* importer node's location. When these differ (e.g. `-w` flag),
|
|
54
|
+
* the path must be rebased.
|
|
55
|
+
*
|
|
56
|
+
* Also detects when the target path is a workspace and converts
|
|
57
|
+
* the spec to `workspace:*`.
|
|
58
|
+
*/
|
|
59
|
+
const rebaseFileSpec = (spec, importerPath, scurryCwd, specOptions, monorepo) => {
|
|
60
|
+
if (spec.type !== 'file' || !spec.file || isAbsolute(spec.file)) {
|
|
61
|
+
return spec;
|
|
62
|
+
}
|
|
63
|
+
const targetAbs = resolve(process.cwd(), spec.file);
|
|
64
|
+
if (monorepo) {
|
|
65
|
+
for (const ws of monorepo.values()) {
|
|
66
|
+
if (ws.fullpath === targetAbs) {
|
|
67
|
+
return Spec.parse(ws.name, 'workspace:*', specOptions);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const importerAbs = resolve(scurryCwd, importerPath);
|
|
72
|
+
const rebasedPath = relative(importerAbs, targetAbs)
|
|
73
|
+
.split('\\')
|
|
74
|
+
.join('/');
|
|
75
|
+
if (rebasedPath === spec.file)
|
|
76
|
+
return spec;
|
|
77
|
+
return Spec.parseArgs(rebasedPath, specOptions);
|
|
78
|
+
};
|
|
48
79
|
/**
|
|
49
80
|
* Parses the positional arguments into {@link AddImportersDependenciesMap}.
|
|
50
81
|
*/
|
|
@@ -53,7 +84,6 @@ export const parseAddArgs = (config, scurry, monorepo) => {
|
|
|
53
84
|
const items = config.positionals;
|
|
54
85
|
const type = getType(config.values);
|
|
55
86
|
const importers = getWorkspaceImporters(config.values, monorepo);
|
|
56
|
-
const newDependencies = new Map();
|
|
57
87
|
const specOptions = config.options;
|
|
58
88
|
// nameless spec definitions will need to use their full
|
|
59
89
|
// stringified spec result instead of their name in order
|
|
@@ -61,21 +91,45 @@ export const parseAddArgs = (config, scurry, monorepo) => {
|
|
|
61
91
|
const getName = (s) => s.name === '(unknown)' ? s.spec : s.name;
|
|
62
92
|
// parses each positional argument into a Spec and
|
|
63
93
|
// adds it to the new dependencies Map
|
|
94
|
+
const parsedItems = [];
|
|
95
|
+
let hasFileSpecs = false;
|
|
64
96
|
for (const item of items) {
|
|
65
97
|
const spec = Spec.parseArgs(item, specOptions);
|
|
66
|
-
|
|
98
|
+
parsedItems.push({ spec, type });
|
|
99
|
+
if (spec.type === 'file')
|
|
100
|
+
hasFileSpecs = true;
|
|
67
101
|
add.modifiedDependencies = true;
|
|
68
102
|
}
|
|
69
103
|
// assigns the new dependencies to each selected workspace importer
|
|
70
|
-
|
|
71
|
-
|
|
104
|
+
// file: specs need per-importer rebasing since CLI paths are relative
|
|
105
|
+
// to process.cwd() but get resolved relative to the importer's location
|
|
106
|
+
if (hasFileSpecs && importers.size) {
|
|
107
|
+
const scurryCwd = scurry.cwd.fullpath();
|
|
108
|
+
for (const importer of importers) {
|
|
109
|
+
const [, importerPath] = splitDepID(importer);
|
|
110
|
+
const importerDeps = new Map();
|
|
111
|
+
for (const { spec, type: depType } of parsedItems) {
|
|
112
|
+
const rebased = rebaseFileSpec(spec, importerPath, scurryCwd, specOptions, monorepo);
|
|
113
|
+
importerDeps.set(getName(rebased), asDependency({ spec: rebased, type: depType }));
|
|
114
|
+
}
|
|
115
|
+
add.set(importer, importerDeps);
|
|
116
|
+
}
|
|
72
117
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
118
|
+
else {
|
|
119
|
+
const newDependencies = new Map();
|
|
120
|
+
for (const { spec, type: depType } of parsedItems) {
|
|
121
|
+
newDependencies.set(getName(spec), asDependency({ spec, type: depType }));
|
|
122
|
+
}
|
|
123
|
+
for (const importer of importers) {
|
|
124
|
+
add.set(importer, newDependencies);
|
|
125
|
+
}
|
|
126
|
+
// if no workspaces were selected, default to the cwd importer which
|
|
127
|
+
// can be either the root or a nested folder in case the user is installing
|
|
128
|
+
// from a subfolder that is also a file: type dependency
|
|
129
|
+
if (!importers.size) {
|
|
130
|
+
const cwdDepID = getCwdDepID(scurry);
|
|
131
|
+
add.set(cwdDepID, newDependencies);
|
|
132
|
+
}
|
|
79
133
|
}
|
|
80
134
|
return {
|
|
81
135
|
add,
|
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.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.32",
|
|
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.0.0-rc.
|
|
18
|
-
"@vltpkg/dep-id": "1.0.0-rc.
|
|
19
|
-
"@vltpkg/dot-prop": "1.0.0-rc.
|
|
20
|
-
"@vltpkg/error-cause": "1.0.0-rc.
|
|
21
|
-
"@vltpkg/git": "1.0.0-rc.
|
|
22
|
-
"@vltpkg/graph": "1.0.0-rc.
|
|
23
|
-
"@vltpkg/graph-run": "1.0.0-rc.
|
|
24
|
-
"@vltpkg/init": "1.0.0-rc.
|
|
25
|
-
"@vltpkg/output": "1.0.0-rc.
|
|
26
|
-
"@vltpkg/package-info": "1.0.0-rc.
|
|
27
|
-
"@vltpkg/package-json": "1.0.0-rc.
|
|
28
|
-
"@vltpkg/promise-spawn": "1.0.0-rc.
|
|
29
|
-
"@vltpkg/query": "1.0.0-rc.
|
|
30
|
-
"@vltpkg/registry-client": "1.0.0-rc.
|
|
31
|
-
"@vltpkg/rollback-remove": "1.0.0-rc.
|
|
32
|
-
"@vltpkg/run": "1.0.0-rc.
|
|
33
|
-
"@vltpkg/security-archive": "1.0.0-rc.
|
|
34
|
-
"@vltpkg/spec": "1.0.0-rc.
|
|
35
|
-
"@vltpkg/types": "1.0.0-rc.
|
|
36
|
-
"@vltpkg/url-open": "1.0.0-rc.
|
|
37
|
-
"@vltpkg/vlt-json": "1.0.0-rc.
|
|
38
|
-
"@vltpkg/vlx": "1.0.0-rc.
|
|
39
|
-
"@vltpkg/workspaces": "1.0.0-rc.
|
|
40
|
-
"@vltpkg/xdg": "1.0.0-rc.
|
|
17
|
+
"@vltpkg/config": "1.0.0-rc.32",
|
|
18
|
+
"@vltpkg/dep-id": "1.0.0-rc.32",
|
|
19
|
+
"@vltpkg/dot-prop": "1.0.0-rc.32",
|
|
20
|
+
"@vltpkg/error-cause": "1.0.0-rc.32",
|
|
21
|
+
"@vltpkg/git": "1.0.0-rc.32",
|
|
22
|
+
"@vltpkg/graph": "1.0.0-rc.32",
|
|
23
|
+
"@vltpkg/graph-run": "1.0.0-rc.32",
|
|
24
|
+
"@vltpkg/init": "1.0.0-rc.32",
|
|
25
|
+
"@vltpkg/output": "1.0.0-rc.32",
|
|
26
|
+
"@vltpkg/package-info": "1.0.0-rc.32",
|
|
27
|
+
"@vltpkg/package-json": "1.0.0-rc.32",
|
|
28
|
+
"@vltpkg/promise-spawn": "1.0.0-rc.32",
|
|
29
|
+
"@vltpkg/query": "1.0.0-rc.32",
|
|
30
|
+
"@vltpkg/registry-client": "1.0.0-rc.32",
|
|
31
|
+
"@vltpkg/rollback-remove": "1.0.0-rc.32",
|
|
32
|
+
"@vltpkg/run": "1.0.0-rc.32",
|
|
33
|
+
"@vltpkg/security-archive": "1.0.0-rc.32",
|
|
34
|
+
"@vltpkg/spec": "1.0.0-rc.32",
|
|
35
|
+
"@vltpkg/types": "1.0.0-rc.32",
|
|
36
|
+
"@vltpkg/url-open": "1.0.0-rc.32",
|
|
37
|
+
"@vltpkg/vlt-json": "1.0.0-rc.32",
|
|
38
|
+
"@vltpkg/vlx": "1.0.0-rc.32",
|
|
39
|
+
"@vltpkg/workspaces": "1.0.0-rc.32",
|
|
40
|
+
"@vltpkg/xdg": "1.0.0-rc.32",
|
|
41
41
|
"ansi-to-pre": "^1.0.6",
|
|
42
42
|
"beautiful-mermaid": "^1.1.3",
|
|
43
43
|
"chalk": "^5.6.2",
|