@virmator/deps 14.24.0 → 14.26.0

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/README.md CHANGED
@@ -47,8 +47,5 @@ A default plugin for [virmator](https://www.npmjs.com/package/virmator).
47
47
 
48
48
  Force regeneration of all all dependencies by deleting all node_modules directories and package-lock.json and then running 'npm i'.
49
49
 
50
- Reads 'configs/deps-regen.config.ts' for a list of packages (exact names or globs) to exempt from min-release-age during the install, via npm's '--min-release-age-exclude' flag.
51
-
52
50
  - Examples
53
51
  - `virmator deps regen`
54
- - use a custom deps-regen allow list: `virmator deps regen --config ./configs/deps-regen.config.ts`
package/dist/deps.d.ts CHANGED
@@ -122,12 +122,9 @@ export declare const virmatorDepsPlugin: Readonly<Readonly<{
122
122
  };
123
123
  readonly regen: {
124
124
  readonly doc: {
125
- readonly sections: readonly ["\n Force regeneration of all all dependencies by deleting all\n node_modules directories and package-lock.json and then\n running 'npm i'.\n ", "\n Reads 'configs/deps-regen.config.ts' for a list of packages\n (exact names or globs) to exempt from min-release-age during the\n install, via npm's '--min-release-age-exclude' flag.\n "];
125
+ readonly sections: readonly ["\n Force regeneration of all all dependencies by deleting all\n node_modules directories and package-lock.json and then\n running 'npm i'.\n "];
126
126
  readonly examples: readonly [{
127
127
  readonly content: "virmator deps regen";
128
- }, {
129
- readonly title: "use a custom deps-regen allow list";
130
- readonly content: "virmator deps regen --config ./configs/deps-regen.config.ts";
131
128
  }];
132
129
  };
133
130
  };
@@ -256,12 +253,9 @@ export declare const virmatorDepsPlugin: Readonly<Readonly<{
256
253
  };
257
254
  readonly regen: {
258
255
  readonly doc: {
259
- readonly sections: readonly ["\n Force regeneration of all all dependencies by deleting all\n node_modules directories and package-lock.json and then\n running 'npm i'.\n ", "\n Reads 'configs/deps-regen.config.ts' for a list of packages\n (exact names or globs) to exempt from min-release-age during the\n install, via npm's '--min-release-age-exclude' flag.\n "];
256
+ readonly sections: readonly ["\n Force regeneration of all all dependencies by deleting all\n node_modules directories and package-lock.json and then\n running 'npm i'.\n "];
260
257
  readonly examples: readonly [{
261
258
  readonly content: "virmator deps regen";
262
- }, {
263
- readonly title: "use a custom deps-regen allow list";
264
- readonly content: "virmator deps regen --config ./configs/deps-regen.config.ts";
265
259
  }];
266
260
  };
267
261
  };
package/dist/deps.js CHANGED
@@ -5,7 +5,7 @@ import { copyConfigFile, defineVirmatorPlugin, JsModuleType, NpmDepType, Package
5
5
  import mri from 'mri';
6
6
  import { rm } from 'node:fs/promises';
7
7
  import { join, relative } from 'node:path';
8
- import { buildMinReleaseAgeExcludeFlags, extractRegenConfigArg, listRegenNodeModulesDirs, resolveRegenConfigPath, resolveRegenExcludes, } from './regen-recent-deps.js';
8
+ import { listRegenNodeModulesDirs } from './regen-node-modules.js';
9
9
  import { runArgBasedUpgrade } from './upgrade-deps.js';
10
10
  /** A virmator plugin for checking package TS dependencies. */
11
11
  export const virmatorDepsPlugin = defineVirmatorPlugin(import.meta.dirname, {
@@ -177,20 +177,11 @@ export const virmatorDepsPlugin = defineVirmatorPlugin(import.meta.dirname, {
177
177
  node_modules directories and package-lock.json and then
178
178
  running 'npm i'.
179
179
  `,
180
- `
181
- Reads 'configs/deps-regen.config.ts' for a list of packages
182
- (exact names or globs) to exempt from min-release-age during the
183
- install, via npm's '--min-release-age-exclude' flag.
184
- `,
185
180
  ],
186
181
  examples: [
187
182
  {
188
183
  content: 'virmator deps regen',
189
184
  },
190
- {
191
- title: 'use a custom deps-regen allow list',
192
- content: 'virmator deps regen --config ./configs/deps-regen.config.ts',
193
- },
194
185
  ],
195
186
  },
196
187
  },
@@ -277,20 +268,6 @@ export const virmatorDepsPlugin = defineVirmatorPlugin(import.meta.dirname, {
277
268
  }
278
269
  }
279
270
  else if (usedCommands.deps?.subCommands.regen) {
280
- /** Strip '--config <path>' so it isn't forwarded to 'npm i'. */
281
- const { configValue, passthroughArgs } = extractRegenConfigArg(filteredArgs);
282
- /**
283
- * Allow-listed packages (exact names or globs) that bypass min-release-age during the
284
- * install via npm's '--min-release-age-exclude' flag. Empty when there is no config.
285
- */
286
- const regenExcludes = await resolveRegenExcludes({
287
- configPath: resolveRegenConfigPath({
288
- configValue,
289
- cwd,
290
- monoRepoRootPath,
291
- }),
292
- configIsExplicit: check.isTruthy(configValue),
293
- });
294
271
  const allNodeModulesDirectories = listRegenNodeModulesDirs({
295
272
  monoRepoRootPath,
296
273
  monoRepoPackages,
@@ -309,8 +286,7 @@ export const virmatorDepsPlugin = defineVirmatorPlugin(import.meta.dirname, {
309
286
  const installCommand = [
310
287
  'npm',
311
288
  'i',
312
- ...passthroughArgs,
313
- ...buildMinReleaseAgeExcludeFlags(regenExcludes),
289
+ ...filteredArgs,
314
290
  ].join(' ');
315
291
  await runShellCommand(installCommand);
316
292
  /** Run twice because npm needs this sometimes. */
@@ -0,0 +1,10 @@
1
+ import { type MonoRepoPackage } from '@virmator/core';
2
+ /**
3
+ * All `node_modules` directories deleted before a regen install: one per mono-repo package plus the
4
+ * mono-repo root. For a single (non-mono) package, `monoRepoPackages` is empty so only the root is
5
+ * returned.
6
+ */
7
+ export declare function listRegenNodeModulesDirs({ monoRepoRootPath, monoRepoPackages, }: {
8
+ monoRepoRootPath: string;
9
+ monoRepoPackages: ReadonlyArray<Pick<MonoRepoPackage, 'relativePath'>>;
10
+ }): string[];
@@ -0,0 +1,12 @@
1
+ import { join } from 'node:path';
2
+ /**
3
+ * All `node_modules` directories deleted before a regen install: one per mono-repo package plus the
4
+ * mono-repo root. For a single (non-mono) package, `monoRepoPackages` is empty so only the root is
5
+ * returned.
6
+ */
7
+ export function listRegenNodeModulesDirs({ monoRepoRootPath, monoRepoPackages, }) {
8
+ return [
9
+ ...monoRepoPackages.map((monoPackage) => join(monoRepoRootPath, monoPackage.relativePath, 'node_modules')),
10
+ join(monoRepoRootPath, 'node_modules'),
11
+ ];
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virmator/deps",
3
- "version": "14.24.0",
3
+ "version": "14.26.0",
4
4
  "description": "Default TS deps plugin for virmator.",
5
5
  "keywords": [
6
6
  "virmator",
@@ -34,22 +34,22 @@
34
34
  "test:update": "npm test update"
35
35
  },
36
36
  "dependencies": {
37
- "@augment-vir/assert": "^31.71.3",
38
- "@augment-vir/common": "^31.71.3",
39
- "@augment-vir/node": "^31.71.3",
37
+ "@augment-vir/assert": "^31.72.1",
38
+ "@augment-vir/common": "^31.72.1",
39
+ "@augment-vir/node": "^31.72.1",
40
40
  "@npm/types": "^2.1.0",
41
- "@virmator/core": "^14.24.0",
42
- "date-vir": "^8.3.2",
41
+ "@virmator/core": "^14.26.0",
42
+ "date-vir": "^8.4.0",
43
43
  "mri": "^1.2.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@augment-vir/test": "^31.71.3",
47
- "@types/node": "^25.9.1",
46
+ "@augment-vir/test": "^31.72.1",
47
+ "@types/node": "^25.9.2",
48
48
  "c8": "^11.0.0",
49
- "dependency-cruiser": "^17.4.2",
49
+ "dependency-cruiser": "^17.4.3",
50
50
  "esbuild": "^0.28.0",
51
51
  "istanbul-smart-text-reporter": "^1.1.5",
52
- "npm-check-updates": "^22.2.1"
52
+ "npm-check-updates": "^22.2.3"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "npm-check-updates": ">=19"
@@ -1,64 +0,0 @@
1
- /** These packages bypass min-release-age when running `virmator deps regen`. */
2
- export type RecentDepsAllowList = ReadonlyArray<string>;
3
-
4
- const electrovirPackages: RecentDepsAllowList = [
5
- '@augment-vir/*',
6
- '@date-vir/*',
7
- '@electrovir/*',
8
- '@rest-vir/*',
9
- '@review-vir/*',
10
- '@updating-secrets/*',
11
- '@virmator/*',
12
- 'auth-vir',
13
- 'catch-exit',
14
- 'cli-vir',
15
- 'cron-vir',
16
- 'date-vir',
17
- 'deploy-vir',
18
- 'detect-activity',
19
- 'docker-vir',
20
- 'element-book',
21
- 'element-vir',
22
- 'execute-in-browser',
23
- 'i18n-vir',
24
- 'indexed-vir',
25
- 'istanbul-smart-text-reporter',
26
- 'lit-css-vars',
27
- 'local-db-client',
28
- 'markdown-code-example-inserter',
29
- 'mock-vir',
30
- 'mono-vir',
31
- 'object-shape-tester',
32
- 'observavir',
33
- 'parse-email-address',
34
- 'pdf-vir',
35
- 'pglite-cli',
36
- 'prettier-plugin-interpolated-html-tags',
37
- 'prettier-plugin-multiline-arrays',
38
- 'prevent-navigation',
39
- 'prisma-pglite',
40
- 'prisma-vir',
41
- 'pull-request-vir',
42
- 'runstorm',
43
- 'schema-vir',
44
- 'sentry-vir',
45
- 'spa-router-vir',
46
- 'structured-render',
47
- 'theme-vir',
48
- 'tidy-tsc',
49
- 'typed-event-target',
50
- 'updating-secrets',
51
- 'url-vir',
52
- 'vira',
53
- 'virmator',
54
- 'web-snaps',
55
- ];
56
-
57
- /**
58
- * The default allow list: electrovir's own commonly-used packages. Each entry is an exact package
59
- * name or a `minimatch` glob pattern matched against the package name (forwarded to npm's
60
- * `min-release-age-exclude`).
61
- */
62
- export const baseAllowedRecentDeps: RecentDepsAllowList = [
63
- ...electrovirPackages,
64
- ];
@@ -1,74 +0,0 @@
1
- import { type MonoRepoPackage } from '@virmator/core';
2
- /**
3
- * All `node_modules` directories deleted before a regen install: one per mono-repo package plus the
4
- * mono-repo root. For a single (non-mono) package, `monoRepoPackages` is empty so only the root is
5
- * returned.
6
- */
7
- export declare function listRegenNodeModulesDirs({ monoRepoRootPath, monoRepoPackages, }: {
8
- monoRepoRootPath: string;
9
- monoRepoPackages: ReadonlyArray<Pick<MonoRepoPackage, 'relativePath'>>;
10
- }): string[];
11
- /**
12
- * Whether an allow-list entry is safe to interpolate (single-quoted) into a shell command. Allows
13
- * npm package names and `minimatch` glob patterns (the `*` wildcard) while rejecting anything that
14
- * could smuggle shell metacharacters or quotes out of an (untrusted) config file.
15
- */
16
- export declare function isSafeExcludePattern(pattern: string): boolean;
17
- /**
18
- * Pulls an optional `--config <path>` (or `--config=<path>`) flag out of the raw `deps regen` args,
19
- * returning the config value and the remaining args to forward to `npm i`.
20
- */
21
- export declare function extractRegenConfigArg(filteredArgs: ReadonlyArray<string>): {
22
- configValue: string | undefined;
23
- passthroughArgs: string[];
24
- };
25
- /**
26
- * Resolves the deps-regen config path: the explicit `--config` value relative to the cwd, or the
27
- * default `configs/deps-regen.config.ts` at the mono-repo root (as placed by `virmator init`).
28
- */
29
- export declare function resolveRegenConfigPath({ configValue, cwd, monoRepoRootPath, }: {
30
- configValue: string | undefined;
31
- cwd: string;
32
- monoRepoRootPath: string;
33
- }): string;
34
- /**
35
- * Structural copy of the allow list type defined in `configs/deps-regen.config.base.ts`. It is
36
- * re-declared here because `configs` lives outside this package's compiled `src` root, so it cannot
37
- * be type-imported. Each entry is an exact npm package name or a `minimatch` glob pattern matched
38
- * against the package name (forwarded directly to npm's `min-release-age-exclude`).
39
- */
40
- export type RecentDepsAllowList = ReadonlyArray<string>;
41
- /**
42
- * Injectable IO used by {@link resolveRegenExcludes}. Defaults to real implementations; overridden
43
- * in tests so the orchestration can be exercised without touching the filesystem.
44
- */
45
- export type RegenExcludesIo = {
46
- fileExists: (filePath: string) => Promise<boolean>;
47
- loadAllowList: (configPath: string) => Promise<RecentDepsAllowList | undefined>;
48
- };
49
- export declare function fileExists(filePath: string): Promise<boolean>;
50
- export declare function loadAllowList(configPath: string): Promise<RecentDepsAllowList | undefined>;
51
- /** The real (filesystem) IO used by {@link resolveRegenExcludes}. */
52
- export declare const defaultRegenExcludesIo: RegenExcludesIo;
53
- /**
54
- * Loads the deps-regen allow list and returns the deduped package names / glob patterns that should
55
- * bypass `min-release-age` during the regen install. A missing explicit config (from `--config`)
56
- * throws; a missing default config is silently skipped (returns `[]`). Unsafe entries (which can't
57
- * be safely interpolated into a shell command) throw rather than being silently dropped.
58
- */
59
- export declare function resolveRegenExcludes({ configPath, configIsExplicit, io, }: {
60
- configPath: string;
61
- /**
62
- * Whether `configPath` came from an explicit `--config` flag. A missing explicit config throws,
63
- * while a missing default config is silently skipped.
64
- */
65
- configIsExplicit: boolean;
66
- io?: RegenExcludesIo | undefined;
67
- }): Promise<string[]>;
68
- /**
69
- * Builds the `--min-release-age-exclude='<pattern>'` flags appended to the regen `npm i` so the
70
- * allow-listed packages can install their newest versions even while a release-age window is set.
71
- * Each pattern is single-quoted; combined with {@link isSafeExcludePattern} validation, this
72
- * prevents shell injection from config values.
73
- */
74
- export declare function buildMinReleaseAgeExcludeFlags(patterns: ReadonlyArray<string>): string[];
@@ -1,133 +0,0 @@
1
- import { check } from '@augment-vir/assert';
2
- import { removeDuplicates, wrapInTry } from '@augment-vir/common';
3
- import { JsModuleType, VirmatorNoTraceError, withImportedTsFile, } from '@virmator/core';
4
- import { stat } from 'node:fs/promises';
5
- import { join, resolve } from 'node:path';
6
- const defaultDepsRegenConfigRelativePath = join('configs', 'deps-regen.config.ts');
7
- /**
8
- * All `node_modules` directories deleted before a regen install: one per mono-repo package plus the
9
- * mono-repo root. For a single (non-mono) package, `monoRepoPackages` is empty so only the root is
10
- * returned.
11
- */
12
- export function listRegenNodeModulesDirs({ monoRepoRootPath, monoRepoPackages, }) {
13
- return [
14
- ...monoRepoPackages.map((monoPackage) => join(monoRepoRootPath, monoPackage.relativePath, 'node_modules')),
15
- join(monoRepoRootPath, 'node_modules'),
16
- ];
17
- }
18
- /**
19
- * Whether an allow-list entry is safe to interpolate (single-quoted) into a shell command. Allows
20
- * npm package names and `minimatch` glob patterns (the `*` wildcard) while rejecting anything that
21
- * could smuggle shell metacharacters or quotes out of an (untrusted) config file.
22
- */
23
- export function isSafeExcludePattern(pattern) {
24
- return /^@?[a-z0-9*][a-z0-9._*-]*(\/[a-z0-9*][a-z0-9._*-]*)?$/i.test(pattern);
25
- }
26
- /**
27
- * Pulls an optional `--config <path>` (or `--config=<path>`) flag out of the raw `deps regen` args,
28
- * returning the config value and the remaining args to forward to `npm i`.
29
- */
30
- export function extractRegenConfigArg(filteredArgs) {
31
- const { configValue, passthroughArgs, skipNext } = filteredArgs.reduce((accum, arg) => {
32
- if (accum.skipNext) {
33
- return {
34
- configValue: arg,
35
- skipNext: false,
36
- passthroughArgs: accum.passthroughArgs,
37
- };
38
- }
39
- else if (arg === '--config') {
40
- return {
41
- ...accum,
42
- skipNext: true,
43
- };
44
- }
45
- else if (arg.startsWith('--config=')) {
46
- return {
47
- ...accum,
48
- configValue: arg.slice('--config='.length),
49
- };
50
- }
51
- return {
52
- ...accum,
53
- passthroughArgs: [
54
- ...accum.passthroughArgs,
55
- arg,
56
- ],
57
- };
58
- }, {
59
- configValue: undefined,
60
- skipNext: false,
61
- passthroughArgs: [],
62
- });
63
- /** A dangling '--config' (skipNext) or an empty '--config='/'--config ""' value is an error. */
64
- if (skipNext || configValue === '') {
65
- throw new VirmatorNoTraceError('The --config flag requires a file path value.');
66
- }
67
- return {
68
- configValue,
69
- passthroughArgs,
70
- };
71
- }
72
- /**
73
- * Resolves the deps-regen config path: the explicit `--config` value relative to the cwd, or the
74
- * default `configs/deps-regen.config.ts` at the mono-repo root (as placed by `virmator init`).
75
- */
76
- export function resolveRegenConfigPath({ configValue, cwd, monoRepoRootPath, }) {
77
- return configValue
78
- ? resolve(cwd, configValue)
79
- : join(monoRepoRootPath, defaultDepsRegenConfigRelativePath);
80
- }
81
- export async function fileExists(filePath) {
82
- return await wrapInTry(async () => {
83
- await stat(filePath);
84
- return true;
85
- }, {
86
- fallbackValue: false,
87
- });
88
- }
89
- export async function loadAllowList(configPath) {
90
- return await withImportedTsFile({
91
- inputPath: configPath,
92
- }, JsModuleType.Esm, (loadedConfig) => {
93
- const list = loadedConfig.depsRegenAllowList ?? loadedConfig.default;
94
- return check.isArray(list) ? list.filter(check.isString) : undefined;
95
- });
96
- }
97
- /** The real (filesystem) IO used by {@link resolveRegenExcludes}. */
98
- export const defaultRegenExcludesIo = {
99
- fileExists,
100
- loadAllowList,
101
- };
102
- /**
103
- * Loads the deps-regen allow list and returns the deduped package names / glob patterns that should
104
- * bypass `min-release-age` during the regen install. A missing explicit config (from `--config`)
105
- * throws; a missing default config is silently skipped (returns `[]`). Unsafe entries (which can't
106
- * be safely interpolated into a shell command) throw rather than being silently dropped.
107
- */
108
- export async function resolveRegenExcludes({ configPath, configIsExplicit, io = defaultRegenExcludesIo, }) {
109
- if (!(await io.fileExists(configPath))) {
110
- if (configIsExplicit) {
111
- throw new VirmatorNoTraceError(`deps-regen config file not found: ${configPath}`);
112
- }
113
- return [];
114
- }
115
- const allowList = await io.loadAllowList(configPath);
116
- if (!allowList?.length) {
117
- return [];
118
- }
119
- const unsafePatterns = allowList.filter((pattern) => !isSafeExcludePattern(pattern));
120
- if (unsafePatterns.length) {
121
- throw new VirmatorNoTraceError(`deps-regen allow list contains unsafe package patterns: ${unsafePatterns.join(', ')}`);
122
- }
123
- return removeDuplicates([...allowList]);
124
- }
125
- /**
126
- * Builds the `--min-release-age-exclude='<pattern>'` flags appended to the regen `npm i` so the
127
- * allow-listed packages can install their newest versions even while a release-age window is set.
128
- * Each pattern is single-quoted; combined with {@link isSafeExcludePattern} validation, this
129
- * prevents shell injection from config values.
130
- */
131
- export function buildMinReleaseAgeExcludeFlags(patterns) {
132
- return patterns.map((pattern) => `--min-release-age-exclude='${pattern}'`);
133
- }