@vltpkg/cli-sdk 1.3.7 → 1.3.8

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.
@@ -44,6 +44,11 @@ export const usage = () => commandUsage({
44
44
  If the appropriate excutable cannot be determined, then
45
45
  an error will be raised.
46
46
 
47
+ If the package is a path to a local directory (eg, \`.\`
48
+ or \`../pkg\`, relative to the current directory), its
49
+ bins are run in place. Nothing is installed, and its own
50
+ \`node_modules\` is used as-is.
51
+
47
52
  At no point will \`vlt exec\` change the locally installed
48
53
  dependencies. Any installs it performs is done in vlt's XDG
49
54
  data directory.
@@ -58,6 +63,9 @@ export const usage = () => commandUsage({
58
63
  'eslint@9.24 src/file.js': {
59
64
  description: 'Run the default bin provided by eslint version 9.24',
60
65
  },
66
+ '.': {
67
+ description: 'Run the default bin of the package in the current directory',
68
+ },
61
69
  'create-react-app --call="echo $PWD"': {
62
70
  description: 'Install create-react-app and run an arbitrary command with its bins in PATH',
63
71
  },
@@ -166,7 +166,9 @@ const explain = (entry) => {
166
166
  };
167
167
  /**
168
168
  * The commands that perform the upgrades, one `vlt install` per set of
169
- * flags so that the specs can be combined.
169
+ * flags so that the specs can be combined. Several entries can call
170
+ * for the same step, such as every workspace that shares a catalog
171
+ * entry, so each step is listed once.
170
172
  */
171
173
  const suggestActions = (result) => {
172
174
  const lines = [];
@@ -175,26 +177,28 @@ const suggestActions = (result) => {
175
177
  lines.push(`Run \`vlt update\` to pick up ${plural(updates, 'in-range update')}.`);
176
178
  }
177
179
  const installs = new Map();
180
+ const edits = new Set();
178
181
  for (const { action } of result) {
179
- if (!action?.startsWith('vlt install '))
182
+ if (!action)
180
183
  continue;
181
- const [spec = '', ...flags] = action
182
- .slice('vlt install '.length)
183
- .split(' ');
184
- const key = flags.join(' ');
185
- const specs = installs.get(key) ?? [];
186
- specs.push(spec);
187
- installs.set(key, specs);
184
+ if (action.startsWith('vlt install ')) {
185
+ const [spec = '', ...flags] = action
186
+ .slice('vlt install '.length)
187
+ .split(' ');
188
+ const key = flags.join(' ');
189
+ const specs = installs.get(key) ?? new Set();
190
+ specs.add(spec);
191
+ installs.set(key, specs);
192
+ }
193
+ else if (!action.startsWith('vlt ')) {
194
+ edits.add(`${action.charAt(0).toUpperCase()}${action.slice(1)}.`);
195
+ }
188
196
  }
189
197
  for (const [flags, specs] of installs) {
190
198
  const args = [...specs, ...(flags ? [flags] : [])].join(' ');
191
199
  lines.push(`Run \`vlt install ${args}\` to move to latest.`);
192
200
  }
193
- for (const { action } of result) {
194
- if (action && !action.startsWith('vlt ')) {
195
- lines.push(`${action.charAt(0).toUpperCase()}${action.slice(1)}.`);
196
- }
197
- }
201
+ lines.push(...edits);
198
202
  return lines;
199
203
  };
200
204
  export const views = {
@@ -336,7 +340,10 @@ const actionFor = (edge, entry, { savePrefix }) => {
336
340
  return 'vlt update';
337
341
  const newRange = `${savePrefix}${latest}`;
338
342
  if (edge.spec.type === 'catalog') {
339
- return `set the catalog entry for ${edge.name} in vlt.json to ${newRange}`;
343
+ const catalog = edge.spec.catalog ?
344
+ `"${edge.spec.catalog}" catalog`
345
+ : 'catalog';
346
+ return `set the ${catalog} entry for ${edge.name} in vlt.json to ${newRange}`;
340
347
  }
341
348
  const workspace = edge.from.mainImporter ?
342
349
  ''
@@ -10,8 +10,17 @@ export const usage = () => commandUsage({
10
10
  command: 'update',
11
11
  usage: '',
12
12
  description: `Update dependencies to their latest in-range versions.
13
- Discards the lockfile and resolves dependencies from scratch.`,
13
+ Discards the lockfile and resolves dependencies from scratch
14
+ (with -w: only matching workspaces' dependencies).`,
14
15
  options: {
16
+ workspace: {
17
+ value: '<path|glob>',
18
+ description: 'Limit update to matching workspaces. Others, and deps they share, keep their locked versions.',
19
+ },
20
+ 'workspace-group': {
21
+ value: '<name>',
22
+ description: 'Limit update to workspace groups. Others, and deps they share, keep their locked versions.',
23
+ },
15
24
  'save-config': {
16
25
  description: 'Save registry and git host options given on the command line or via env (e.g. `--registries name=url`) to the project vlt.json, or the user vlt.json with --config=user.',
17
26
  },
@@ -22,7 +22,11 @@ export const usage = () => commandUsage({
22
22
  (e.g., \`dist-tags.latest\`, \`dependencies.lodash\`).
23
23
 
24
24
  Security data from the vlt security archive is shown when
25
- available, including scores and alerts.`,
25
+ available, including scores and alerts.
26
+
27
+ Use \`.\` (or no args) for the package in the current directory
28
+ (nearest package.json), \`.@<version>\` to pick a version.
29
+ Private packages show local package.json info.`,
26
30
  examples: {
27
31
  express: {
28
32
  description: 'View info about the latest version of express',
@@ -42,6 +46,12 @@ export const usage = () => commandUsage({
42
46
  'express dist-tags.latest': {
43
47
  description: 'Show the latest dist-tag value',
44
48
  },
49
+ '.': {
50
+ description: 'View the package in the current directory',
51
+ },
52
+ '. version': {
53
+ description: 'Show the latest published version of the current package',
54
+ },
45
55
  },
46
56
  options: {
47
57
  view: {
@@ -114,7 +124,7 @@ const formatHuman = (result) => {
114
124
  // Name and version
115
125
  const name = manifest.name ?? packument.name;
116
126
  const version = manifest.version ?? '';
117
- lines.push(`${name}@${version}`);
127
+ lines.push(version ? `${name}@${version}` : name);
118
128
  // Description
119
129
  if (manifest.description) {
120
130
  lines.push(manifest.description);
@@ -263,15 +273,30 @@ const lookupField = (result, path) => {
263
273
  // Default: look up in manifest
264
274
  return dotProp.get(result.manifest, path);
265
275
  };
266
- export const command = async (conf) => {
267
- const specArg = conf.positionals[0];
268
- if (!specArg) {
269
- throw error('view requires a package spec argument', {
276
+ const readLocalManifest = (conf) => {
277
+ const file = conf.options.packageJson.find(process.cwd());
278
+ if (!file) {
279
+ throw error('No local package.json found', {
270
280
  code: 'EUSAGE',
281
+ path: process.cwd(),
271
282
  });
272
283
  }
273
- const fieldPath = conf.positionals[1];
274
- const spec = Spec.parseArgs(specArg, conf.options);
284
+ const manifest = conf.options.packageJson.read(file);
285
+ const { name } = manifest;
286
+ if (!name) {
287
+ throw error('No package name found in package.json', {
288
+ code: 'EUSAGE',
289
+ found: file,
290
+ });
291
+ }
292
+ return { name, manifest };
293
+ };
294
+ // nothing published: no dist-tags or versions
295
+ const localView = (name, manifest) => ({
296
+ manifest,
297
+ packument: { name, 'dist-tags': {}, versions: {} },
298
+ });
299
+ const fetchView = async (spec, conf) => {
275
300
  const pic = new PackageInfoClient(conf.options);
276
301
  // Fetch the full packument (needs time, maintainers) and resolved manifest
277
302
  const [packument, resolvedManifest] = await Promise.all([
@@ -295,11 +320,34 @@ export const command = async (conf) => {
295
320
  // Security data is optional, don't fail the command
296
321
  }
297
322
  }
298
- const result = {
299
- packument,
300
- manifest,
301
- security,
302
- };
323
+ return { packument, manifest, security };
324
+ };
325
+ export const command = async (conf) => {
326
+ // `.` (or no args) is the package in the current directory
327
+ const specArg = conf.positionals[0] || '.';
328
+ const fieldPath = conf.positionals[1];
329
+ let result;
330
+ if (specArg === '.' || specArg.startsWith('.@')) {
331
+ const { name, manifest } = readLocalManifest(conf);
332
+ const rest = specArg.slice(1);
333
+ if (manifest.private) {
334
+ // never query the registry for private pkgs
335
+ if (rest) {
336
+ throw error('Cannot select a version of a private package', {
337
+ code: 'EUSAGE',
338
+ found: specArg,
339
+ });
340
+ }
341
+ result = localView(name, manifest);
342
+ }
343
+ else {
344
+ // keep name literal; rest is '' or '@<spec>'
345
+ result = await fetchView(Spec.parse(name, rest.slice(1), conf.options), conf);
346
+ }
347
+ }
348
+ else {
349
+ result = await fetchView(Spec.parseArgs(specArg, conf.options), conf);
350
+ }
303
351
  // If a field path is provided, resolve it
304
352
  if (fieldPath !== undefined) {
305
353
  result.fieldPath = fieldPath;
@@ -2,7 +2,8 @@ import type { GetAuthHeader } from '@vltpkg/query';
2
2
  import type { LoadedConfig } from './config/index.ts';
3
3
  /**
4
4
  * Returns a {@link GetAuthHeader} implementation that looks up
5
- * authorization tokens from the local keychain / env, used by
5
+ * authorization tokens from the local keychain / env (incl.
6
+ * `VLT_TOKEN_<key>` for configured registries), used by
6
7
  * network-reliant query selectors, e.g: `:outdated()`.
7
8
  */
8
9
  export declare const createGetAuthHeader: (conf: LoadedConfig) => GetAuthHeader;
@@ -1,7 +1,11 @@
1
- import { getTokenByURL } from '@vltpkg/registry-client';
1
+ import { getTokenByURL, registryKeys } from '@vltpkg/registry-client';
2
2
  /**
3
3
  * Returns a {@link GetAuthHeader} implementation that looks up
4
- * authorization tokens from the local keychain / env, used by
4
+ * authorization tokens from the local keychain / env (incl.
5
+ * `VLT_TOKEN_<key>` for configured registries), used by
5
6
  * network-reliant query selectors, e.g: `:outdated()`.
6
7
  */
7
- export const createGetAuthHeader = (conf) => async (url) => getTokenByURL(url, conf.options.identity);
8
+ export const createGetAuthHeader = (conf) => {
9
+ const keys = registryKeys(conf.options);
10
+ return async (url) => getTokenByURL(url, conf.options.identity, keys);
11
+ };
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.3.7",
4
+ "version": "1.3.8",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -14,33 +14,33 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@resvg/resvg-wasm": "^2.6.2",
17
- "@vltpkg/config": "1.3.7",
18
- "@vltpkg/dep-id": "1.3.7",
19
- "@vltpkg/dot-prop": "1.3.7",
20
- "@vltpkg/error-cause": "1.3.7",
21
- "@vltpkg/git": "1.3.7",
22
- "@vltpkg/graph": "1.3.7",
23
- "@vltpkg/graph-run": "1.3.7",
24
- "@vltpkg/init": "1.3.7",
25
- "@vltpkg/output": "1.3.7",
26
- "@vltpkg/package-info": "1.3.7",
27
- "@vltpkg/package-json": "1.3.7",
28
- "@vltpkg/pick-manifest": "1.3.7",
29
- "@vltpkg/promise-spawn": "1.3.7",
30
- "@vltpkg/query": "1.3.7",
31
- "@vltpkg/registry-client": "1.3.7",
32
- "@vltpkg/rollback-remove": "1.3.7",
33
- "@vltpkg/run": "1.3.7",
34
- "@vltpkg/security-archive": "1.3.7",
35
- "@vltpkg/semver": "1.3.7",
36
- "@vltpkg/spec": "1.3.7",
37
- "@vltpkg/tar": "1.3.7",
38
- "@vltpkg/types": "1.3.7",
39
- "@vltpkg/url-open": "1.3.7",
40
- "@vltpkg/vlt-json": "1.3.7",
41
- "@vltpkg/vlx": "1.3.7",
42
- "@vltpkg/workspaces": "1.3.7",
43
- "@vltpkg/xdg": "1.3.7",
17
+ "@vltpkg/config": "1.3.8",
18
+ "@vltpkg/dep-id": "1.3.8",
19
+ "@vltpkg/dot-prop": "1.3.8",
20
+ "@vltpkg/error-cause": "1.3.8",
21
+ "@vltpkg/git": "1.3.8",
22
+ "@vltpkg/graph": "1.3.8",
23
+ "@vltpkg/graph-run": "1.3.8",
24
+ "@vltpkg/init": "1.3.8",
25
+ "@vltpkg/output": "1.3.8",
26
+ "@vltpkg/package-info": "1.3.8",
27
+ "@vltpkg/package-json": "1.3.8",
28
+ "@vltpkg/pick-manifest": "1.3.8",
29
+ "@vltpkg/promise-spawn": "1.3.8",
30
+ "@vltpkg/query": "1.3.8",
31
+ "@vltpkg/registry-client": "1.3.8",
32
+ "@vltpkg/rollback-remove": "1.3.8",
33
+ "@vltpkg/run": "1.3.8",
34
+ "@vltpkg/security-archive": "1.3.8",
35
+ "@vltpkg/semver": "1.3.8",
36
+ "@vltpkg/spec": "1.3.8",
37
+ "@vltpkg/tar": "1.3.8",
38
+ "@vltpkg/types": "1.3.8",
39
+ "@vltpkg/url-open": "1.3.8",
40
+ "@vltpkg/vlt-json": "1.3.8",
41
+ "@vltpkg/vlx": "1.3.8",
42
+ "@vltpkg/workspaces": "1.3.8",
43
+ "@vltpkg/xdg": "1.3.8",
44
44
  "ansi-to-pre": "^1.0.6",
45
45
  "beautiful-mermaid": "^1.1.3",
46
46
  "chalk": "^5.6.2",