node-modules-tools 0.6.0 → 0.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.
@@ -42,7 +42,7 @@ async function getPnpmVersion(options) {
42
42
  }
43
43
  }
44
44
  async function getDependenciesTree(options) {
45
- const args = ["ls", "--json", "--no-optional", "--depth", String(options.depth)];
45
+ const args = ["ls", "--json", "--depth", String(options.depth)];
46
46
  if (options.monorepo)
47
47
  args.push("--recursive");
48
48
  if (options.workspace === false)
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import { P as PackageNodeRaw, a as PackageNodeBase, b as PackageNode } from './s
3
3
  export { d as CLUSTER_DEP_DEV, e as CLUSTER_DEP_OPTIONAL, C as CLUSTER_DEP_PROD, F as FileCategory, N as NpmMeta, h as NpmMetaLatest, i as PackageInstallSizeInfo, g as PackageModuleType, f as PackageModuleTypeSimple, c as PackageModuleTypes } from './shared/node-modules-tools.rYmxZoRW.mjs';
4
4
  export { PackageJson } from 'pkg-types';
5
5
  export { Message as PublintMessage } from 'publint';
6
- export { NormalizedFunding, PackageNodeLike, ParsedFunding, constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgRepository, parseAuthor, parseFunding } from './utils.mjs';
6
+ export { NormalizedFunding, PackageNodeLike, ParsedFunding, ParsedLicense, constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgLicense, normalizePkgRepository, parseAuthor, parseFunding } from './utils.mjs';
7
7
 
8
8
  interface BaseOptions {
9
9
  /**
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { P as PackageNodeRaw, a as PackageNodeBase, b as PackageNode } from './s
3
3
  export { d as CLUSTER_DEP_DEV, e as CLUSTER_DEP_OPTIONAL, C as CLUSTER_DEP_PROD, F as FileCategory, N as NpmMeta, h as NpmMetaLatest, i as PackageInstallSizeInfo, g as PackageModuleType, f as PackageModuleTypeSimple, c as PackageModuleTypes } from './shared/node-modules-tools.rYmxZoRW.js';
4
4
  export { PackageJson } from 'pkg-types';
5
5
  export { Message as PublintMessage } from 'publint';
6
- export { NormalizedFunding, PackageNodeLike, ParsedFunding, constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgRepository, parseAuthor, parseFunding } from './utils.js';
6
+ export { NormalizedFunding, PackageNodeLike, ParsedFunding, ParsedLicense, constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgLicense, normalizePkgRepository, parseAuthor, parseFunding } from './utils.js';
7
7
 
8
8
  interface BaseOptions {
9
9
  /**
package/dist/index.mjs CHANGED
@@ -2,8 +2,8 @@ export { CLUSTER_DEP_DEV, CLUSTER_DEP_OPTIONAL, CLUSTER_DEP_PROD, PackageModuleT
2
2
  import pLimit from 'p-limit';
3
3
  import { detect } from 'package-manager-detector';
4
4
  import fs from 'node:fs/promises';
5
- import { o as objectPick } from './shared/node-modules-tools.ByQH5a4n.mjs';
6
- export { c as constructPackageFilter, a as constructPackageFilters, d as normalizePkgAuthors, n as normalizePkgFundings, e as normalizePkgRepository, b as parseAuthor, p as parseFunding } from './shared/node-modules-tools.ByQH5a4n.mjs';
5
+ import { o as objectPick } from './shared/node-modules-tools.CC43M-MZ.mjs';
6
+ export { c as constructPackageFilter, a as constructPackageFilters, e as normalizePkgAuthors, b as normalizePkgFundings, n as normalizePkgLicense, f as normalizePkgRepository, d as parseAuthor, p as parseFunding } from './shared/node-modules-tools.CC43M-MZ.mjs';
7
7
  import { join as join$1 } from 'pathe';
8
8
  import { relative, join } from 'node:path';
9
9
  import 'semver';
@@ -308,6 +308,7 @@ const PACKAGE_JSON_KEYS = [
308
308
  "imports",
309
309
  "keywords",
310
310
  "license",
311
+ "licenses",
311
312
  "main",
312
313
  "module",
313
314
  "name",
@@ -68,6 +68,23 @@ function parseFunding(funding) {
68
68
  avatar
69
69
  };
70
70
  }
71
+ function normalizePkgLicense(json) {
72
+ const _json = json;
73
+ switch (typeof _json.license) {
74
+ case "string":
75
+ return _json.license;
76
+ case "object":
77
+ return _json.license.type;
78
+ }
79
+ if (Array.isArray(_json.licenses)) {
80
+ if (!_json.licenses.length)
81
+ return;
82
+ if (_json.licenses.length === 1) {
83
+ return _json.licenses[0].type;
84
+ }
85
+ return `(${_json.licenses.map((l) => l.type).join(" OR ")})`;
86
+ }
87
+ }
71
88
  function normalizePkgFundings(json) {
72
89
  const rawFunding = json.funding;
73
90
  let fundings;
@@ -144,4 +161,4 @@ function normalizePkgRepository(json) {
144
161
  };
145
162
  }
146
163
 
147
- export { constructPackageFilters as a, parseAuthor as b, constructPackageFilter as c, normalizePkgAuthors as d, normalizePkgRepository as e, normalizePkgFundings as n, objectPick as o, parseFunding as p };
164
+ export { constructPackageFilters as a, normalizePkgFundings as b, constructPackageFilter as c, parseAuthor as d, normalizePkgAuthors as e, normalizePkgRepository as f, normalizePkgLicense as n, objectPick as o, parseFunding as p };
package/dist/utils.d.mts CHANGED
@@ -28,6 +28,8 @@ interface ParsedFunding {
28
28
  avatar?: string;
29
29
  }
30
30
  declare function parseFunding(funding: NormalizedFunding): ParsedFunding;
31
+ type ParsedLicense = string;
32
+ declare function normalizePkgLicense(json: PackageJson): ParsedLicense | undefined;
31
33
  declare function normalizePkgFundings(json: PackageJson): ParsedFunding[] | undefined;
32
34
  declare function parseAuthor(author?: string): undefined;
33
35
  declare function normalizePkgAuthors(json: PackageJson): {
@@ -41,4 +43,4 @@ declare function normalizePkgRepository(json: PackageJson): {
41
43
  org: string | undefined;
42
44
  } | undefined;
43
45
 
44
- export { type NormalizedFunding, type PackageNodeLike, type ParsedFunding, constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgRepository, parseAuthor, parseFunding };
46
+ export { type NormalizedFunding, type PackageNodeLike, type ParsedFunding, type ParsedLicense, constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgLicense, normalizePkgRepository, parseAuthor, parseFunding };
package/dist/utils.d.ts CHANGED
@@ -28,6 +28,8 @@ interface ParsedFunding {
28
28
  avatar?: string;
29
29
  }
30
30
  declare function parseFunding(funding: NormalizedFunding): ParsedFunding;
31
+ type ParsedLicense = string;
32
+ declare function normalizePkgLicense(json: PackageJson): ParsedLicense | undefined;
31
33
  declare function normalizePkgFundings(json: PackageJson): ParsedFunding[] | undefined;
32
34
  declare function parseAuthor(author?: string): undefined;
33
35
  declare function normalizePkgAuthors(json: PackageJson): {
@@ -41,4 +43,4 @@ declare function normalizePkgRepository(json: PackageJson): {
41
43
  org: string | undefined;
42
44
  } | undefined;
43
45
 
44
- export { type NormalizedFunding, type PackageNodeLike, type ParsedFunding, constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgRepository, parseAuthor, parseFunding };
46
+ export { type NormalizedFunding, type PackageNodeLike, type ParsedFunding, type ParsedLicense, constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgLicense, normalizePkgRepository, parseAuthor, parseFunding };
package/dist/utils.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export { c as constructPackageFilter, a as constructPackageFilters, d as normalizePkgAuthors, n as normalizePkgFundings, e as normalizePkgRepository, b as parseAuthor, p as parseFunding } from './shared/node-modules-tools.ByQH5a4n.mjs';
1
+ export { c as constructPackageFilter, a as constructPackageFilters, e as normalizePkgAuthors, b as normalizePkgFundings, n as normalizePkgLicense, f as normalizePkgRepository, d as parseAuthor, p as parseFunding } from './shared/node-modules-tools.CC43M-MZ.mjs';
2
2
  import 'semver';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-modules-tools",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.6.2",
5
5
  "description": "Tools for inspecting node_modules",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -32,13 +32,13 @@
32
32
  "package-manager-detector": "^1.1.0",
33
33
  "pathe": "^2.0.3",
34
34
  "pkg-types": "^2.1.0",
35
- "publint": "^0.3.9",
35
+ "publint": "^0.3.10",
36
36
  "semver": "^7.7.1",
37
- "tinyexec": "^1.0.0"
37
+ "tinyexec": "^1.0.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@pnpm/list": "^1000.0.12",
41
- "@pnpm/types": "^1000.2.1",
40
+ "@pnpm/list": "^1000.0.13",
41
+ "@pnpm/types": "^1000.3.0",
42
42
  "@types/js-yaml": "^4.0.9",
43
43
  "@types/stream-json": "^1.7.8",
44
44
  "stream-json": "^1.9.1",