@virmator/deps 14.32.0 → 14.33.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.
@@ -16,6 +16,7 @@ export const typeDocConfig: Partial<TypeDocOptions> = {
16
16
  defaultCategory: 'MISSING CATEGORY',
17
17
  categoryOrder: [
18
18
  'Main',
19
+ 'Util',
19
20
  'Internal',
20
21
  ],
21
22
  };
package/dist/deps.d.ts CHANGED
@@ -1,12 +1,27 @@
1
1
  import { type MonoRepoPackage, NpmDepType, PackageType } from '@virmator/core';
2
- /** Lists package directories that should be checked for unused dependencies. */
2
+ /**
3
+ * Lists package directories that should be checked for unused dependencies.
4
+ *
5
+ * @category Util
6
+ */
3
7
  export declare function getUnusedPackageDirPaths({ cwdPackagePath, monoRepoPackages, monoRepoRootPath, packageType, }: Readonly<{
4
8
  cwdPackagePath: string;
5
9
  monoRepoPackages: ReadonlyArray<Readonly<MonoRepoPackage>>;
6
10
  monoRepoRootPath: string;
7
11
  packageType: PackageType;
8
12
  }>): string[];
9
- /** A virmator plugin for checking package TS dependencies. */
13
+ /** @category Internal */
14
+ export declare function buildNcuCommand({ configPath, cwd, monoRepoPackages, monoRepoRootPath, }: Readonly<{
15
+ configPath: string;
16
+ cwd: string;
17
+ monoRepoPackages: ReadonlyArray<Readonly<MonoRepoPackage>>;
18
+ monoRepoRootPath: string;
19
+ }>): string;
20
+ /**
21
+ * A virmator plugin for checking package TS dependencies.
22
+ *
23
+ * @category Main
24
+ */
10
25
  export declare const virmatorDepsPlugin: Readonly<Readonly<{
11
26
  name: string;
12
27
  cliCommands: NoInfer<{
package/dist/deps.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { check } from '@augment-vir/assert';
2
2
  import { awaitedBlockingMap, RuntimeEnv } from '@augment-vir/common';
3
3
  import { toPosixPath } from '@augment-vir/node';
4
- import { copyConfigFile, defineVirmatorPlugin, JsModuleType, NpmDepType, PackageType, VirmatorNoTraceError, withCompiledTsFile, withImportedTsFile, } from '@virmator/core';
4
+ import { copyConfigFile, defineVirmatorPlugin, JsModuleType, NpmDepType, PackageType, VirmatorNoTraceError, withCompiledTsFile, } from '@virmator/core';
5
5
  import mri from 'mri';
6
- import { rm } from 'node:fs/promises';
6
+ import { appendFile, rm } from 'node:fs/promises';
7
7
  import { join, relative } from 'node:path';
8
8
  import { findUnusedPackageDependencies } from './find-unused-package-dependencies.js';
9
9
  import { listRegenNodeModulesDirs } from './regen-node-modules.js';
@@ -21,7 +21,11 @@ const dependencyCruiserNpmDeps = {
21
21
  },
22
22
  },
23
23
  };
24
- /** Lists package directories that should be checked for unused dependencies. */
24
+ /**
25
+ * Lists package directories that should be checked for unused dependencies.
26
+ *
27
+ * @category Util
28
+ */
25
29
  export function getUnusedPackageDirPaths({ cwdPackagePath, monoRepoPackages, monoRepoRootPath, packageType, }) {
26
30
  return packageType === PackageType.MonoRoot
27
31
  ? [
@@ -32,7 +36,25 @@ export function getUnusedPackageDirPaths({ cwdPackagePath, monoRepoPackages, mon
32
36
  ]
33
37
  : [cwdPackagePath];
34
38
  }
35
- /** A virmator plugin for checking package TS dependencies. */
39
+ /** @category Internal */
40
+ export function buildNcuCommand({ configPath, cwd, monoRepoPackages, monoRepoRootPath, }) {
41
+ return [
42
+ 'npx',
43
+ 'npm-check-updates',
44
+ '--configFileName',
45
+ toPosixPath(relative(cwd, configPath)),
46
+ '--cwd',
47
+ toPosixPath(relative(cwd, monoRepoRootPath)) || '.',
48
+ '--format',
49
+ 'no-group',
50
+ ...(monoRepoPackages.length ? ['--workspaces'] : []),
51
+ ].join(' ');
52
+ }
53
+ /**
54
+ * A virmator plugin for checking package TS dependencies.
55
+ *
56
+ * @category Main
57
+ */
36
58
  export const virmatorDepsPlugin = defineVirmatorPlugin(import.meta.dirname, {
37
59
  name: 'Deps',
38
60
  cliCommands: {
@@ -317,22 +339,17 @@ export const virmatorDepsPlugin = defineVirmatorPlugin(import.meta.dirname, {
317
339
  config: configs.deps.subCommands.upgrade.configs.ncu,
318
340
  log,
319
341
  });
320
- await withImportedTsFile({
342
+ await withCompiledTsFile({
321
343
  inputPath: join(monoRepoRootPath, configs.deps.subCommands.upgrade.configs.ncu.copyToPath),
322
- outputPath: join(cwdPackagePath, 'node_modules', '.virmator', 'dep-cruiser.config.mjs'),
323
- }, JsModuleType.Esm, async (configFile) => {
324
- const config = configFile.ncuConfig;
325
- /** C8 incorrectly thinks these imports are uncovered branches. */
326
- /* node:coverage ignore next */
327
- const ncu = await import('npm-check-updates');
328
- await ncu.run({
329
- ...config,
330
- cwd: monoRepoRootPath,
331
- workspaces: !!monoRepoPackages.length,
332
- format: [],
333
- }, {
334
- cli: true,
335
- });
344
+ outputPath: join(cwdPackagePath, 'node_modules', '.virmator', 'ncu.config.mjs'),
345
+ }, JsModuleType.Esm, async (configPath) => {
346
+ await appendFile(configPath, '\nconst {filter, ...ncuConfigWithoutFilter} = ncuConfig;\nexport default filter?.length ? ncuConfig : ncuConfigWithoutFilter;\n');
347
+ await runShellCommand(buildNcuCommand({
348
+ configPath,
349
+ cwd,
350
+ monoRepoPackages,
351
+ monoRepoRootPath,
352
+ }));
336
353
  });
337
354
  }
338
355
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virmator/deps",
3
- "version": "14.32.0",
3
+ "version": "14.33.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": "^32.2.2",
38
- "@augment-vir/common": "^32.2.2",
39
- "@augment-vir/node": "^32.2.2",
37
+ "@augment-vir/assert": "^32.2.3",
38
+ "@augment-vir/common": "^32.2.3",
39
+ "@augment-vir/node": "^32.2.3",
40
40
  "@npm/types": "^2.1.0",
41
- "@virmator/core": "^14.32.0",
42
- "date-vir": "^9.1.0",
41
+ "@virmator/core": "^14.33.0",
42
+ "date-vir": "^9.1.1",
43
43
  "mri": "^1.2.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@augment-vir/test": "^32.2.2",
46
+ "@augment-vir/test": "^32.2.3",
47
47
  "@types/node": "^26.2.0",
48
48
  "c8": "^12.0.0",
49
49
  "dependency-cruiser": "^18.2.0",
50
50
  "esbuild": "^0.28.2",
51
51
  "istanbul-smart-text-reporter": "^1.1.5",
52
- "npm-check-updates": "^23.0.2"
52
+ "npm-check-updates": "^23.1.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "dependency-cruiser": ">=18",