@vltpkg/cli-sdk 1.6.0 → 1.6.2

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.
@@ -76,7 +76,7 @@ export const command = async (conf) => {
76
76
  // create the folder in case it's missing
77
77
  mkdirSync(cwd, { recursive: true });
78
78
  // run the initialization script and collect results
79
- results.push(await init({ cwd }));
79
+ results.push(await init({ cwd, packageJson: conf.options.packageJson }));
80
80
  // Check if this workspace path is covered by existing workspace patterns
81
81
  const isMatched = Object.values(parsedWSConfig).some((group) => {
82
82
  const { patterns, ignore } = splitNegatedPatterns(group);
@@ -136,7 +136,10 @@ export const command = async (conf) => {
136
136
  await install({ ...conf.options, allowScripts });
137
137
  return results;
138
138
  }
139
- const result = await init({ cwd: process.cwd() });
139
+ const result = await init({
140
+ cwd: process.cwd(),
141
+ packageJson: conf.options.packageJson,
142
+ });
140
143
  // run install to set up node_modules and vlt-lock.json
141
144
  await install({ ...conf.options, allowScripts });
142
145
  return result;
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ import { Config } from "./config/index.js";
8
8
  import { flushAndExit, outputCommand, stderr, stdout, } from "./output.js";
9
9
  import { indent } from "./print-err.js";
10
10
  import { loadCommand } from "./load-command.js";
11
+ import { mark } from '@vltpkg/output/trace';
11
12
  const { version } = loadPackageJson(import.meta.filename, process.env.__VLT_INTERNAL_CLI_PACKAGE_JSON);
12
13
  const loadVlt = async (cwd, argv) => {
13
14
  try {
@@ -85,6 +86,7 @@ const run = async () => {
85
86
  const { dispatchRegistry } = await import("./commands/registry.js");
86
87
  await dispatchRegistry(vlt);
87
88
  }
89
+ mark('command', { command: vlt.command });
88
90
  const command = await loadCommand(vlt.command);
89
91
  await outputCommand(command, vlt, { start, vltVersion: version });
90
92
  };
package/dist/output.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { error } from '@vltpkg/error-cause';
2
+ import { mark } from '@vltpkg/output/trace';
2
3
  import { formatWithOptions, styleText as utilStyleText, } from 'node:util';
3
4
  import { createSupportsColor } from 'supports-color';
4
5
  import { defaultView } from "./config/definition.js";
@@ -181,7 +182,10 @@ export const outputCommand = async (cliCommand, conf, { start, vltVersion } = {
181
182
  }
182
183
  if (conf.globalRoot)
183
184
  await sweepPendingRemove(conf.globalRoot);
184
- const output = await onDone(await command(conf));
185
+ const result = await command(conf);
186
+ mark('command:done');
187
+ const output = await onDone(result);
188
+ mark('view:done');
185
189
  stopRequestLog();
186
190
  const duration_ms = Date.now() - start;
187
191
  trackCommand({
@@ -208,6 +212,7 @@ export const outputCommand = async (cliCommand, conf, { start, vltVersion } = {
208
212
  // timer is unreffed so even if this is not awaited the process
209
213
  // can still exit promptly.
210
214
  await flushTelemetry();
215
+ mark('telemetry:flushed');
211
216
  }
212
217
  catch (err) {
213
218
  stopRequestLog();
@@ -1,4 +1,6 @@
1
1
  import type { NormalizedManifest } from '@vltpkg/types';
2
+ import type { Stats } from 'node:fs';
3
+ import type { ReadEntry } from 'tar';
2
4
  import type { LoadedConfig } from './config/index.ts';
3
5
  export type PackTarballResult = {
4
6
  name: string;
@@ -27,7 +29,7 @@ export type PackTarballResult = {
27
29
  * .npmrc, vlt.json, etc.) are excluded and always-included files (package.json,
28
30
  * README, LICENSE, etc.) are included.
29
31
  */
30
- export declare const buildPackFilter: (manifest: NormalizedManifest, packDir: string) => ((path: string) => boolean);
32
+ export declare const buildPackFilter: (manifest: NormalizedManifest, packDir: string) => ((path: string, entry: Stats | ReadEntry) => boolean);
31
33
  /**
32
34
  * Create a tarball from a package directory
33
35
  * @param {NormalizedManifest} manifest - The manifest of the package to pack
@@ -3,7 +3,7 @@ import { minimatch } from 'minimatch';
3
3
  import { error } from '@vltpkg/error-cause';
4
4
  import * as ssri from 'ssri';
5
5
  import assert from 'node:assert';
6
- import { existsSync, readFileSync, statSync } from 'node:fs';
6
+ import { existsSync, readdirSync, readFileSync, statSync, } from 'node:fs';
7
7
  import { Spec } from '@vltpkg/spec';
8
8
  import { join } from 'node:path';
9
9
  import { parse, stringify } from 'polite-json';
@@ -155,7 +155,24 @@ export const buildPackFilter = (manifest, packDir) => {
155
155
  }
156
156
  }
157
157
  }
158
- return (path) => {
158
+ // `files` entries are normalized like npm does: a leading `./` or `/`
159
+ // and trailing slashes are dropped, empty entries are skipped
160
+ const files = (manifestWithFiles.files ?? [])
161
+ .map(pattern => pattern.replace(/^\.?\//, '').replace(/\/+$/, ''))
162
+ .filter(Boolean);
163
+ // dirs that only partially match a `files` glob (e.g. `dist/nested` for
164
+ // `dist/**/*.js`) are descended, unless unreadable: npm's glob expansion
165
+ // skips those too
166
+ const isReadableDir = (dir) => {
167
+ try {
168
+ readdirSync(join(packDir, dir));
169
+ return true;
170
+ }
171
+ catch {
172
+ return false;
173
+ }
174
+ };
175
+ return (path, entry) => {
159
176
  const normalizedPath = path.replace(/^\.\//, '');
160
177
  if (path === '.' || normalizedPath === '') {
161
178
  return true;
@@ -173,23 +190,16 @@ export const buildPackFilter = (manifest, packDir) => {
173
190
  if (hasEmptyFilesField) {
174
191
  return false;
175
192
  }
176
- if (hasFilesField && manifestWithFiles.files) {
177
- return manifestWithFiles.files.some((pattern) => {
178
- if (pattern.endsWith('/')) {
179
- const dirName = pattern.slice(0, -1);
180
- const globPattern = pattern.replace(/\/$/, '/**');
181
- const matchesDir = normalizedPath === dirName;
182
- const matchesContents = minimatch(normalizedPath, globPattern, { dot: true });
183
- return matchesDir || matchesContents;
184
- }
185
- const directMatch = minimatch(normalizedPath, pattern, {
186
- dot: true,
187
- });
188
- const isParentDir = pattern.includes('/') &&
189
- pattern.startsWith(normalizedPath + '/');
190
- const isChildOfPattern = minimatch(normalizedPath, pattern + '/**', { dot: true });
191
- return directMatch || isParentDir || isChildOfPattern;
192
- });
193
+ if (hasFilesField) {
194
+ const isDir = 'isDirectory' in entry && entry.isDirectory();
195
+ return (files.some(pattern => minimatch(normalizedPath, pattern, { dot: true }) ||
196
+ minimatch(normalizedPath, `${pattern}/**`, { dot: true })) ||
197
+ (isDir &&
198
+ files.some(pattern => minimatch(normalizedPath, pattern, {
199
+ dot: true,
200
+ partial: true,
201
+ })) &&
202
+ isReadableDir(normalizedPath)));
193
203
  }
194
204
  // Ignore-file mode: apply .npmignore or .gitignore deny patterns
195
205
  if (ig?.ignores(normalizedPath)) {
package/dist/telemetry.js CHANGED
@@ -73,9 +73,16 @@ const getClient = () => {
73
73
  // call shutdown at the end so this is just a safety net.
74
74
  flushAt: 20,
75
75
  flushInterval: 10_000,
76
+ // one attempt, capped like flush(); failed sends resolve as 204
77
+ // so offline or erroring runs neither wait nor log
78
+ fetchRetryCount: 0,
79
+ requestTimeout: SHUTDOWN_TIMEOUT_MS,
80
+ fetch: async (url, init) => {
81
+ const res = await fetch(url, init).catch(() => undefined);
82
+ return res?.ok ? res : new Response(null, { status: 204 });
83
+ },
76
84
  });
77
85
  return _posthog;
78
- /* c8 ignore next 4 */
79
86
  }
80
87
  catch {
81
88
  _initFailed = true;
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.6.0",
4
+ "version": "1.6.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -14,35 +14,35 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@resvg/resvg-wasm": "^2.6.2",
17
- "@vltpkg/cmd-shim": "1.6.0",
18
- "@vltpkg/config": "1.6.0",
19
- "@vltpkg/dep-id": "1.6.0",
20
- "@vltpkg/dot-prop": "1.6.0",
21
- "@vltpkg/error-cause": "1.6.0",
22
- "@vltpkg/git": "1.6.0",
23
- "@vltpkg/graph": "1.6.0",
24
- "@vltpkg/graph-run": "1.6.0",
25
- "@vltpkg/init": "1.6.0",
26
- "@vltpkg/output": "1.6.0",
27
- "@vltpkg/package-info": "1.6.0",
28
- "@vltpkg/package-json": "1.6.0",
29
- "@vltpkg/pick-manifest": "1.6.0",
30
- "@vltpkg/promise-spawn": "1.6.0",
31
- "@vltpkg/query": "1.6.0",
32
- "@vltpkg/registry-client": "1.6.0",
33
- "@vltpkg/rollback-remove": "1.6.0",
34
- "@vltpkg/run": "1.6.0",
35
- "@vltpkg/security-archive": "1.6.0",
36
- "@vltpkg/semver": "1.6.0",
37
- "@vltpkg/spec": "1.6.0",
38
- "@vltpkg/tar": "1.6.0",
39
- "@vltpkg/types": "1.6.0",
40
- "@vltpkg/url-open": "1.6.0",
41
- "@vltpkg/vlt-json": "1.6.0",
42
- "@vltpkg/vlx": "1.6.0",
43
- "@vltpkg/which": "1.6.0",
44
- "@vltpkg/workspaces": "1.6.0",
45
- "@vltpkg/xdg": "1.6.0",
17
+ "@vltpkg/cmd-shim": "1.6.2",
18
+ "@vltpkg/config": "1.6.2",
19
+ "@vltpkg/dep-id": "1.6.2",
20
+ "@vltpkg/dot-prop": "1.6.2",
21
+ "@vltpkg/error-cause": "1.6.2",
22
+ "@vltpkg/git": "1.6.2",
23
+ "@vltpkg/graph": "1.6.2",
24
+ "@vltpkg/graph-run": "1.6.2",
25
+ "@vltpkg/init": "1.6.2",
26
+ "@vltpkg/output": "1.6.2",
27
+ "@vltpkg/package-info": "1.6.2",
28
+ "@vltpkg/package-json": "1.6.2",
29
+ "@vltpkg/pick-manifest": "1.6.2",
30
+ "@vltpkg/promise-spawn": "1.6.2",
31
+ "@vltpkg/query": "1.6.2",
32
+ "@vltpkg/registry-client": "1.6.2",
33
+ "@vltpkg/rollback-remove": "1.6.2",
34
+ "@vltpkg/run": "1.6.2",
35
+ "@vltpkg/security-archive": "1.6.2",
36
+ "@vltpkg/semver": "1.6.2",
37
+ "@vltpkg/spec": "1.6.2",
38
+ "@vltpkg/tar": "1.6.2",
39
+ "@vltpkg/types": "1.6.2",
40
+ "@vltpkg/url-open": "1.6.2",
41
+ "@vltpkg/vlt-json": "1.6.2",
42
+ "@vltpkg/vlx": "1.6.2",
43
+ "@vltpkg/which": "1.6.2",
44
+ "@vltpkg/workspaces": "1.6.2",
45
+ "@vltpkg/xdg": "1.6.2",
46
46
  "ansi-to-pre": "^1.0.6",
47
47
  "beautiful-mermaid": "^1.1.3",
48
48
  "chalk": "^5.6.2",