@vltpkg/cli-sdk 1.0.9 → 1.0.10
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/publish.js +15 -0
- package/dist/commands/version.js +19 -9
- package/dist/config/definition.d.ts +12 -0
- package/dist/config/definition.js +18 -0
- package/dist/print-err.js +22 -0
- package/package.json +25 -25
package/dist/commands/publish.js
CHANGED
|
@@ -262,6 +262,9 @@ const commandSingle = async (location, conf) => {
|
|
|
262
262
|
}
|
|
263
263
|
catch (err) {
|
|
264
264
|
throw error('Failed to publish package', {
|
|
265
|
+
code: 'EREQUEST',
|
|
266
|
+
url: publishUrl,
|
|
267
|
+
method: 'PUT',
|
|
265
268
|
cause: asError(err),
|
|
266
269
|
});
|
|
267
270
|
}
|
|
@@ -269,6 +272,10 @@ const commandSingle = async (location, conf) => {
|
|
|
269
272
|
// respond with a 202 Accepted when processing is deferred (e.g. for
|
|
270
273
|
// publish-time malware scanning).
|
|
271
274
|
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
275
|
+
// the registry turning down our credentials is the user's to fix,
|
|
276
|
+
// not a bug to report, so it gets told apart from a registry that
|
|
277
|
+
// is simply broken.
|
|
278
|
+
const denied = response.statusCode === 401 || response.statusCode === 403;
|
|
272
279
|
let advice = '';
|
|
273
280
|
if (response.statusCode === 409) {
|
|
274
281
|
advice = `\n⚠️ ${name}@${version} already exists in the registry. Bump the version and try again.`;
|
|
@@ -277,8 +284,16 @@ const commandSingle = async (location, conf) => {
|
|
|
277
284
|
advice =
|
|
278
285
|
"\n⚠️ Make sure you're logged in and have access to publish the package.";
|
|
279
286
|
}
|
|
287
|
+
else if (response.statusCode === 401) {
|
|
288
|
+
advice = `\n⚠️ Not logged in to ${registryUrl.origin}. Run \`vlt login\` and try again.`;
|
|
289
|
+
}
|
|
290
|
+
else if (response.statusCode === 403) {
|
|
291
|
+
advice = `\n⚠️ ${name} cannot be published by this account. Run \`vlt whoami\` to see who you are logged in as, and \`vlt login\` to switch accounts. A name already taken by someone else cannot be reused.`;
|
|
292
|
+
}
|
|
280
293
|
throw error(`Failed to publish package: ${registryErrorMessage(response)}${advice}`, {
|
|
294
|
+
code: denied ? 'ENEEDAUTH' : 'EREQUEST',
|
|
281
295
|
url: publishUrl,
|
|
296
|
+
method: 'PUT',
|
|
282
297
|
response,
|
|
283
298
|
});
|
|
284
299
|
}
|
package/dist/commands/version.js
CHANGED
|
@@ -9,11 +9,16 @@ import { actual } from '@vltpkg/graph';
|
|
|
9
9
|
import { Query } from '@vltpkg/query';
|
|
10
10
|
import { createHostContextsMap } from "../query-host-contexts.js";
|
|
11
11
|
import { minimatch } from 'minimatch';
|
|
12
|
+
/**
|
|
13
|
+
* `--no-git-tag-version` skips the whole git dance, matching npm.
|
|
14
|
+
* `--no-commit` only skips the commit, leaving the bump uncommitted.
|
|
15
|
+
*/
|
|
16
|
+
const gitOptions = (conf) => {
|
|
17
|
+
const tag = conf.get('git-tag-version');
|
|
18
|
+
return { tag, commit: tag && conf.get('commit') };
|
|
19
|
+
};
|
|
12
20
|
const isValidVersionIncrement = (value) => versionIncrements.includes(value);
|
|
13
|
-
const version = async (conf, increment, cwd, {
|
|
14
|
-
// Hardcode happy path options for now.
|
|
15
|
-
// TODO: make these config definitions
|
|
16
|
-
prereleaseId = 'pre', commit = true, tag = true, message = 'v%s', tagMessage = 'v%s', includeNameInCommit = false, includeNameInTag = false, } = {}) => {
|
|
21
|
+
const version = async (conf, increment, cwd, { prereleaseId = 'pre', commit = true, tag = true, message = 'v%s', tagMessage = 'v%s', includeNameInCommit = false, includeNameInTag = false, } = {}) => {
|
|
17
22
|
assert(increment, error('Version increment argument is required', {
|
|
18
23
|
code: 'EUSAGE',
|
|
19
24
|
validOptions: versionIncrements,
|
|
@@ -66,9 +71,7 @@ prereleaseId = 'pre', commit = true, tag = true, message = 'v%s', tagMessage = '
|
|
|
66
71
|
dir: manifestDir,
|
|
67
72
|
};
|
|
68
73
|
// Handle git operations if we're in a git repository
|
|
69
|
-
if (
|
|
70
|
-
/* c8 ignore next -- commit and tag are always true for now */
|
|
71
|
-
(commit || tag) &&
|
|
74
|
+
if ((commit || tag) &&
|
|
72
75
|
(await isGit({ cwd: conf.options.projectRoot }))) {
|
|
73
76
|
// Check for uncommitted changes (excluding package.json since we just modified it)
|
|
74
77
|
if (!(await isClean({ cwd: conf.options.projectRoot }))) {
|
|
@@ -146,7 +149,7 @@ export const usage = () => {
|
|
|
146
149
|
|
|
147
150
|
The \`<newversion>\` argument should be a valid semver string or a valid increment type (one of patch, minor, major, prepatch, preminor, premajor, prerelease).
|
|
148
151
|
|
|
149
|
-
If run in a git repository, it will also create a version commit and tag.`,
|
|
152
|
+
If run in a git repository, it will also create a version commit and tag. Use \`--no-git-tag-version\` to skip both, or \`--no-commit\` to skip only the commit.`,
|
|
150
153
|
options: {
|
|
151
154
|
scope: {
|
|
152
155
|
value: '<query>',
|
|
@@ -163,6 +166,12 @@ export const usage = () => {
|
|
|
163
166
|
recursive: {
|
|
164
167
|
description: 'Run version bump across all workspaces in the monorepo.',
|
|
165
168
|
},
|
|
169
|
+
'no-git-tag-version': {
|
|
170
|
+
description: 'Bump the version without creating a git commit or tag.',
|
|
171
|
+
},
|
|
172
|
+
'no-commit': {
|
|
173
|
+
description: 'Create the git tag, but leave the version bump uncommitted.',
|
|
174
|
+
},
|
|
166
175
|
},
|
|
167
176
|
});
|
|
168
177
|
};
|
|
@@ -238,12 +247,13 @@ export const command = async (conf) => {
|
|
|
238
247
|
}
|
|
239
248
|
else {
|
|
240
249
|
const cwd = options.packageJson.find(process.cwd()) ?? projectRoot;
|
|
241
|
-
return version(conf, positionals[0], cwd);
|
|
250
|
+
return version(conf, positionals[0], cwd, gitOptions(conf));
|
|
242
251
|
}
|
|
243
252
|
assert(locations.length > 0, error('No workspaces or query results found'));
|
|
244
253
|
const results = [];
|
|
245
254
|
for (const location of locations) {
|
|
246
255
|
results.push(await version(conf, positionals[0], location, {
|
|
256
|
+
...gitOptions(conf),
|
|
247
257
|
includeNameInCommit: true,
|
|
248
258
|
includeNameInTag: true,
|
|
249
259
|
}));
|
|
@@ -413,6 +413,18 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
413
413
|
};
|
|
414
414
|
} & {
|
|
415
415
|
access: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
416
|
+
} & {
|
|
417
|
+
'git-tag-version': {
|
|
418
|
+
description: string;
|
|
419
|
+
default: true;
|
|
420
|
+
};
|
|
421
|
+
commit: {
|
|
422
|
+
description: string;
|
|
423
|
+
default: true;
|
|
424
|
+
};
|
|
425
|
+
} & {
|
|
426
|
+
'git-tag-version': import("jackspeak").ConfigOption<"boolean", false, undefined>;
|
|
427
|
+
commit: import("jackspeak").ConfigOption<"boolean", false, undefined>;
|
|
416
428
|
} & {
|
|
417
429
|
otp: {
|
|
418
430
|
description: string;
|
|
@@ -716,6 +716,24 @@ export const definition = j
|
|
|
716
716
|
description: 'Set the access level of the package',
|
|
717
717
|
validOptions: ['public', 'restricted'],
|
|
718
718
|
},
|
|
719
|
+
})
|
|
720
|
+
.flag({
|
|
721
|
+
'git-tag-version': {
|
|
722
|
+
description: `Commit and tag the version change made by \`vlt version\`.
|
|
723
|
+
|
|
724
|
+
Set \`--no-git-tag-version\` to bump the version in
|
|
725
|
+
\`package.json\` without touching git at all, so that a
|
|
726
|
+
series of bumps can be committed together.`,
|
|
727
|
+
default: true,
|
|
728
|
+
},
|
|
729
|
+
commit: {
|
|
730
|
+
description: `Create the version commit in \`vlt version\`.
|
|
731
|
+
|
|
732
|
+
Set \`--no-commit\` to leave the bumped \`package.json\`
|
|
733
|
+
uncommitted while still creating the git tag. Implied by
|
|
734
|
+
\`--no-git-tag-version\`.`,
|
|
735
|
+
default: true,
|
|
736
|
+
},
|
|
719
737
|
})
|
|
720
738
|
.opt({
|
|
721
739
|
otp: {
|
package/dist/print-err.js
CHANGED
|
@@ -166,6 +166,14 @@ const printCode = (err, usage, stderr, format) => {
|
|
|
166
166
|
}
|
|
167
167
|
return { file: true };
|
|
168
168
|
}
|
|
169
|
+
case 'ENEEDAUTH': {
|
|
170
|
+
const { url } = err.cause;
|
|
171
|
+
stderr(`Authentication Error: ${err.message}`);
|
|
172
|
+
if (url) {
|
|
173
|
+
stderr(indent(`URL: ${formatURL(url, format)}`));
|
|
174
|
+
}
|
|
175
|
+
return {};
|
|
176
|
+
}
|
|
169
177
|
case 'EREQUEST': {
|
|
170
178
|
const { url, method } = err.cause;
|
|
171
179
|
const { code, syscall } = err.cause.cause ?? {};
|
|
@@ -184,6 +192,20 @@ const printCode = (err, usage, stderr, format) => {
|
|
|
184
192
|
}
|
|
185
193
|
return { file: true };
|
|
186
194
|
}
|
|
195
|
+
case 'EQUERY': {
|
|
196
|
+
const { found, wanted, validOptions } = err.cause;
|
|
197
|
+
stderr(`Query Error: ${err.message}`);
|
|
198
|
+
if (found) {
|
|
199
|
+
stderr(indent(`Found: ${format(found)}`));
|
|
200
|
+
}
|
|
201
|
+
if (wanted) {
|
|
202
|
+
stderr(indent(`Did you mean: ${format(wanted)}`));
|
|
203
|
+
}
|
|
204
|
+
if (validOptions) {
|
|
205
|
+
stderr(indent(`Valid Options: ${format(validOptions)}`));
|
|
206
|
+
}
|
|
207
|
+
return {};
|
|
208
|
+
}
|
|
187
209
|
case 'ECONFIG': {
|
|
188
210
|
const { found, wanted, validOptions } = err.cause;
|
|
189
211
|
stderr(`Config Error: ${err.message}`);
|
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.
|
|
4
|
+
"version": "1.0.10",
|
|
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.
|
|
18
|
-
"@vltpkg/dep-id": "1.0.
|
|
19
|
-
"@vltpkg/dot-prop": "1.0.
|
|
20
|
-
"@vltpkg/error-cause": "1.0.
|
|
21
|
-
"@vltpkg/git": "1.0.
|
|
22
|
-
"@vltpkg/graph": "1.0.
|
|
23
|
-
"@vltpkg/graph-run": "1.0.
|
|
24
|
-
"@vltpkg/init": "1.0.
|
|
25
|
-
"@vltpkg/output": "1.0.
|
|
26
|
-
"@vltpkg/package-info": "1.0.
|
|
27
|
-
"@vltpkg/package-json": "1.0.
|
|
28
|
-
"@vltpkg/promise-spawn": "1.0.
|
|
29
|
-
"@vltpkg/query": "1.0.
|
|
30
|
-
"@vltpkg/registry-client": "1.0.
|
|
31
|
-
"@vltpkg/rollback-remove": "1.0.
|
|
32
|
-
"@vltpkg/run": "1.0.
|
|
33
|
-
"@vltpkg/security-archive": "1.0.
|
|
34
|
-
"@vltpkg/spec": "1.0.
|
|
35
|
-
"@vltpkg/types": "1.0.
|
|
36
|
-
"@vltpkg/url-open": "1.0.
|
|
37
|
-
"@vltpkg/vlt-json": "1.0.
|
|
38
|
-
"@vltpkg/vlx": "1.0.
|
|
39
|
-
"@vltpkg/workspaces": "1.0.
|
|
40
|
-
"@vltpkg/xdg": "1.0.
|
|
17
|
+
"@vltpkg/config": "1.0.10",
|
|
18
|
+
"@vltpkg/dep-id": "1.0.10",
|
|
19
|
+
"@vltpkg/dot-prop": "1.0.10",
|
|
20
|
+
"@vltpkg/error-cause": "1.0.10",
|
|
21
|
+
"@vltpkg/git": "1.0.10",
|
|
22
|
+
"@vltpkg/graph": "1.0.10",
|
|
23
|
+
"@vltpkg/graph-run": "1.0.10",
|
|
24
|
+
"@vltpkg/init": "1.0.10",
|
|
25
|
+
"@vltpkg/output": "1.0.10",
|
|
26
|
+
"@vltpkg/package-info": "1.0.10",
|
|
27
|
+
"@vltpkg/package-json": "1.0.10",
|
|
28
|
+
"@vltpkg/promise-spawn": "1.0.10",
|
|
29
|
+
"@vltpkg/query": "1.0.10",
|
|
30
|
+
"@vltpkg/registry-client": "1.0.10",
|
|
31
|
+
"@vltpkg/rollback-remove": "1.0.10",
|
|
32
|
+
"@vltpkg/run": "1.0.10",
|
|
33
|
+
"@vltpkg/security-archive": "1.0.10",
|
|
34
|
+
"@vltpkg/spec": "1.0.10",
|
|
35
|
+
"@vltpkg/types": "1.0.10",
|
|
36
|
+
"@vltpkg/url-open": "1.0.10",
|
|
37
|
+
"@vltpkg/vlt-json": "1.0.10",
|
|
38
|
+
"@vltpkg/vlx": "1.0.10",
|
|
39
|
+
"@vltpkg/workspaces": "1.0.10",
|
|
40
|
+
"@vltpkg/xdg": "1.0.10",
|
|
41
41
|
"ansi-to-pre": "^1.0.6",
|
|
42
42
|
"beautiful-mermaid": "^1.1.3",
|
|
43
43
|
"chalk": "^5.6.2",
|