node-modules-tools 2.0.0-beta.2 → 2.1.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.
@@ -173,7 +173,8 @@ async function listPackageDependencies(options) {
173
173
  root,
174
174
  packageManager: "pnpm",
175
175
  packageManagerVersion: await getPnpmVersion(options),
176
- packages
176
+ packages,
177
+ catalogs: catalogsMap
177
178
  };
178
179
  }
179
180
 
@@ -1618,7 +1618,6 @@ class JsonParseStreamError extends Error {
1618
1618
  super(message);
1619
1619
  this.data = data;
1620
1620
  }
1621
- data;
1622
1621
  }
1623
1622
  function parseJsonStream(stream) {
1624
1623
  const assembler = new Assembler();
@@ -1,3 +1,4 @@
1
- export { C as CLUSTER_DEP_DEV, d as CLUSTER_DEP_OPTIONAL, e as CLUSTER_DEP_PROD, i as PackageModuleTypes } from './shared/node-modules-tools.BWZx79LE.mjs';
1
+ export { C as CLUSTER_DEP_DEV, a as CLUSTER_DEP_OPTIONAL, b as CLUSTER_DEP_PROD, f as PackageModuleTypes } from './shared/node-modules-tools.w8TD_NJZ.mjs';
2
2
  import 'pkg-types';
3
3
  import 'publint';
4
+ import './shared/node-modules-tools.BUfYtQgm.mjs';
@@ -1,3 +1,4 @@
1
- export { C as CLUSTER_DEP_DEV, d as CLUSTER_DEP_OPTIONAL, e as CLUSTER_DEP_PROD, i as PackageModuleTypes } from './shared/node-modules-tools.BWZx79LE.js';
1
+ export { C as CLUSTER_DEP_DEV, a as CLUSTER_DEP_OPTIONAL, b as CLUSTER_DEP_PROD, f as PackageModuleTypes } from './shared/node-modules-tools.B4jDG218.js';
2
2
  import 'pkg-types';
3
3
  import 'publint';
4
+ import './shared/node-modules-tools.BUfYtQgm.js';
package/dist/index.d.mts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { AgentName } from 'package-manager-detector';
2
- import { P as PackageNodeRaw, a as PackageNodeBase, b as PackageNode, c as PackageModuleType } from './shared/node-modules-tools.BWZx79LE.mjs';
3
- export { A as AuditLevelString, C as CLUSTER_DEP_DEV, d as CLUSTER_DEP_OPTIONAL, e as CLUSTER_DEP_PROD, F as FileCategory, N as NpmMeta, f as NpmMetaLatest, g as PackageInstallSizeInfo, h as PackageModuleTypeSimple, i as PackageModuleTypes } from './shared/node-modules-tools.BWZx79LE.mjs';
2
+ import { i as PackageNodeRaw, h as PackageNodeBase, g as PackageNode, d as PackageModuleType } from './shared/node-modules-tools.w8TD_NJZ.mjs';
3
+ export { A as AuditLevelString, C as CLUSTER_DEP_DEV, a as CLUSTER_DEP_OPTIONAL, b as CLUSTER_DEP_PROD, F as FileCategory, N as NpmMeta, c as NpmMetaLatest, P as PackageInstallSizeInfo, e as PackageModuleTypeSimple, f as PackageModuleTypes } from './shared/node-modules-tools.w8TD_NJZ.mjs';
4
4
  import { PackageJson } from 'pkg-types';
5
5
  export { PackageJson } from 'pkg-types';
6
- export { NormalizedFunding, PackageNodeLike, ParsedFunding, ParsedLicense, constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgLicense, normalizePkgRepository, parseAuthor, parseFunding } from './utils.mjs';
6
+ export { N as NormalizedFunding, P as ParsedAuthor, a as ParsedFunding, b as ParsedLicense, c as ParsedRepository, R as RawAuthor, n as normalizePkgAuthors, d as normalizePkgFundings, e as normalizePkgLicense, f as normalizePkgRepository, p as parseAuthor, g as parseFunding } from './shared/node-modules-tools.BUfYtQgm.mjs';
7
+ export { PackageNodeLike, constructPackageFilter, constructPackageFilters } from './utils.mjs';
7
8
  export { Message as PublintMessage } from 'publint';
8
9
 
9
10
  interface BaseOptions {
@@ -40,6 +41,12 @@ interface ListPackageDependenciesRawResult {
40
41
  packageManager: string;
41
42
  packageManagerVersion?: string;
42
43
  packages: Map<string, PackageNodeRaw>;
44
+ /**
45
+ * Catalog name → (dep name → range), as declared by the workspace manifest
46
+ * (e.g. `pnpm-workspace.yaml`). Used to resolve `catalog:<name>` ranges back
47
+ * to actual semver ranges.
48
+ */
49
+ catalogs?: Record<string, Record<string, string>>;
43
50
  }
44
51
  interface ListPackageDependenciesBaseResult extends ListPackageDependenciesRawResult {
45
52
  packages: Map<string, PackageNodeBase>;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { AgentName } from 'package-manager-detector';
2
- import { P as PackageNodeRaw, a as PackageNodeBase, b as PackageNode, c as PackageModuleType } from './shared/node-modules-tools.BWZx79LE.js';
3
- export { A as AuditLevelString, C as CLUSTER_DEP_DEV, d as CLUSTER_DEP_OPTIONAL, e as CLUSTER_DEP_PROD, F as FileCategory, N as NpmMeta, f as NpmMetaLatest, g as PackageInstallSizeInfo, h as PackageModuleTypeSimple, i as PackageModuleTypes } from './shared/node-modules-tools.BWZx79LE.js';
2
+ import { i as PackageNodeRaw, h as PackageNodeBase, g as PackageNode, d as PackageModuleType } from './shared/node-modules-tools.B4jDG218.js';
3
+ export { A as AuditLevelString, C as CLUSTER_DEP_DEV, a as CLUSTER_DEP_OPTIONAL, b as CLUSTER_DEP_PROD, F as FileCategory, N as NpmMeta, c as NpmMetaLatest, P as PackageInstallSizeInfo, e as PackageModuleTypeSimple, f as PackageModuleTypes } from './shared/node-modules-tools.B4jDG218.js';
4
4
  import { PackageJson } from 'pkg-types';
5
5
  export { PackageJson } from 'pkg-types';
6
- export { NormalizedFunding, PackageNodeLike, ParsedFunding, ParsedLicense, constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgLicense, normalizePkgRepository, parseAuthor, parseFunding } from './utils.js';
6
+ export { N as NormalizedFunding, P as ParsedAuthor, a as ParsedFunding, b as ParsedLicense, c as ParsedRepository, R as RawAuthor, n as normalizePkgAuthors, d as normalizePkgFundings, e as normalizePkgLicense, f as normalizePkgRepository, p as parseAuthor, g as parseFunding } from './shared/node-modules-tools.BUfYtQgm.js';
7
+ export { PackageNodeLike, constructPackageFilter, constructPackageFilters } from './utils.js';
7
8
  export { Message as PublintMessage } from 'publint';
8
9
 
9
10
  interface BaseOptions {
@@ -40,6 +41,12 @@ interface ListPackageDependenciesRawResult {
40
41
  packageManager: string;
41
42
  packageManagerVersion?: string;
42
43
  packages: Map<string, PackageNodeRaw>;
44
+ /**
45
+ * Catalog name → (dep name → range), as declared by the workspace manifest
46
+ * (e.g. `pnpm-workspace.yaml`). Used to resolve `catalog:<name>` ranges back
47
+ * to actual semver ranges.
48
+ */
49
+ catalogs?: Record<string, Record<string, string>>;
43
50
  }
44
51
  interface ListPackageDependenciesBaseResult extends ListPackageDependenciesRawResult {
45
52
  packages: Map<string, PackageNodeBase>;
package/dist/index.mjs CHANGED
@@ -3,8 +3,8 @@ import pLimit from 'p-limit';
3
3
  import { detect } from 'package-manager-detector';
4
4
  import { existsSync } from 'node:fs';
5
5
  import fs, { readFile } from 'node:fs/promises';
6
- import { o as objectPick } from './shared/node-modules-tools.Cc0OH9G4.mjs';
7
- export { c as constructPackageFilter, a as constructPackageFilters, n as normalizePkgAuthors, b as normalizePkgFundings, d as normalizePkgLicense, e as normalizePkgRepository, p as parseAuthor, f as parseFunding } from './shared/node-modules-tools.Cc0OH9G4.mjs';
6
+ import { b as normalizePkgFundings, d as normalizePkgLicense, e as normalizePkgRepository, n as normalizePkgAuthors, o as objectPick } from './shared/node-modules-tools.VxxuULZa.mjs';
7
+ export { c as constructPackageFilter, a as constructPackageFilters, p as parseAuthor, f as parseFunding } from './shared/node-modules-tools.VxxuULZa.mjs';
8
8
  import { join as join$1 } from 'pathe';
9
9
  import { relative, join } from 'node:path';
10
10
  import 'semver';
@@ -295,6 +295,8 @@ const PACKAGE_JSON_KEYS = [
295
295
  "module",
296
296
  "name",
297
297
  "optionalDependencies",
298
+ "peerDependencies",
299
+ "peerDependenciesMeta",
298
300
  "repository",
299
301
  "types",
300
302
  "version"
@@ -310,7 +312,11 @@ async function resolvePackage(_packageManager, pkg, _options) {
310
312
  _pkg.resolved = {
311
313
  module: analyzePackageModuleType(json),
312
314
  packageJson: objectPick(json, PACKAGE_JSON_KEYS),
313
- installSize: await getPackageInstallSize(_pkg)
315
+ installSize: await getPackageInstallSize(_pkg),
316
+ authors: normalizePkgAuthors(json),
317
+ repository: normalizePkgRepository(json),
318
+ license: normalizePkgLicense(json),
319
+ fundings: normalizePkgFundings(json)
314
320
  };
315
321
  } else {
316
322
  _pkg.filepath = "";
@@ -336,4 +342,4 @@ async function listPackageDependencies(options) {
336
342
  return result;
337
343
  }
338
344
 
339
- export { analyzePackageModuleType, getPackageManager, listPackageDependencies, listPackageDependenciesRaw, resolvePackage };
345
+ export { analyzePackageModuleType, getPackageManager, listPackageDependencies, listPackageDependenciesRaw, normalizePkgAuthors, normalizePkgFundings, normalizePkgLicense, normalizePkgRepository, resolvePackage };
@@ -1,5 +1,6 @@
1
1
  import { PackageJson } from 'pkg-types';
2
2
  import { Message } from 'publint';
3
+ import { P as ParsedAuthor, c as ParsedRepository, b as ParsedLicense, a as ParsedFunding } from './node-modules-tools.BUfYtQgm.js';
3
4
 
4
5
  interface PackageInstallSizeInfo {
5
6
  bytes: number;
@@ -61,6 +62,14 @@ interface PackageNode extends PackageNodeBase {
61
62
  * Result for publint, null for invalid, undefined for not checked yet, empty array for all good
62
63
  */
63
64
  publint?: Message[] | null;
65
+ /** Parsed authors / maintainers, including GitHub-handle detection and repo-URL inference */
66
+ authors?: ParsedAuthor[];
67
+ /** Parsed repository info (normalized URL, GitHub org/repo when applicable) */
68
+ repository?: ParsedRepository;
69
+ /** Normalized license string (SPDX or combined expression) */
70
+ license?: ParsedLicense;
71
+ /** Parsed funding entries with avatars when known */
72
+ fundings?: ParsedFunding[];
64
73
  };
65
74
  }
66
75
  type AuditLevelString = 'low' | 'moderate' | 'high' | 'critical';
@@ -97,5 +106,5 @@ declare const CLUSTER_DEP_PROD = "dep:prod";
97
106
  declare const CLUSTER_DEP_DEV = "dep:dev";
98
107
  declare const CLUSTER_DEP_OPTIONAL = "dep:optional";
99
108
 
100
- export { CLUSTER_DEP_DEV as C, CLUSTER_DEP_OPTIONAL as d, CLUSTER_DEP_PROD as e, PackageModuleTypes as i };
101
- export type { AuditLevelString as A, FileCategory as F, NpmMeta as N, PackageNodeRaw as P, PackageNodeBase as a, PackageNode as b, PackageModuleType as c, NpmMetaLatest as f, PackageInstallSizeInfo as g, PackageModuleTypeSimple as h };
109
+ export { CLUSTER_DEP_DEV as C, CLUSTER_DEP_OPTIONAL as a, CLUSTER_DEP_PROD as b, PackageModuleTypes as f };
110
+ export type { AuditLevelString as A, FileCategory as F, NpmMeta as N, PackageInstallSizeInfo as P, NpmMetaLatest as c, PackageModuleType as d, PackageModuleTypeSimple as e, PackageNode as g, PackageNodeBase as h, PackageNodeRaw as i };
@@ -0,0 +1,45 @@
1
+ import { PackageJson } from 'pkg-types';
2
+
3
+ interface NormalizedFunding {
4
+ url: string;
5
+ type?: string;
6
+ }
7
+ interface ParsedFunding {
8
+ url: string;
9
+ type: string;
10
+ name: string;
11
+ entry: string;
12
+ avatar?: string;
13
+ }
14
+ declare function parseFunding(funding: NormalizedFunding): ParsedFunding;
15
+ type ParsedLicense = string;
16
+ declare function normalizePkgLicense(json: PackageJson): ParsedLicense | undefined;
17
+ declare function normalizePkgFundings(json: PackageJson): ParsedFunding[] | undefined;
18
+ interface RawAuthor {
19
+ name?: string;
20
+ email?: string;
21
+ url?: string;
22
+ }
23
+ type ParsedAuthor = {
24
+ type: 'github';
25
+ github: string;
26
+ avatar: string;
27
+ inferred?: boolean;
28
+ } | {
29
+ type: 'text';
30
+ name: string;
31
+ url?: string;
32
+ email?: string;
33
+ };
34
+ declare function parseAuthor(author: string): RawAuthor;
35
+ declare function normalizePkgAuthors(json: PackageJson): ParsedAuthor[] | undefined;
36
+ interface ParsedRepository {
37
+ url: string;
38
+ repo?: string;
39
+ repoName?: string;
40
+ org?: string;
41
+ }
42
+ declare function normalizePkgRepository(json: PackageJson): ParsedRepository | undefined;
43
+
44
+ export { normalizePkgFundings as d, normalizePkgLicense as e, normalizePkgRepository as f, parseFunding as g, normalizePkgAuthors as n, parseAuthor as p };
45
+ export type { NormalizedFunding as N, ParsedAuthor as P, RawAuthor as R, ParsedFunding as a, ParsedLicense as b, ParsedRepository as c };
@@ -0,0 +1,45 @@
1
+ import { PackageJson } from 'pkg-types';
2
+
3
+ interface NormalizedFunding {
4
+ url: string;
5
+ type?: string;
6
+ }
7
+ interface ParsedFunding {
8
+ url: string;
9
+ type: string;
10
+ name: string;
11
+ entry: string;
12
+ avatar?: string;
13
+ }
14
+ declare function parseFunding(funding: NormalizedFunding): ParsedFunding;
15
+ type ParsedLicense = string;
16
+ declare function normalizePkgLicense(json: PackageJson): ParsedLicense | undefined;
17
+ declare function normalizePkgFundings(json: PackageJson): ParsedFunding[] | undefined;
18
+ interface RawAuthor {
19
+ name?: string;
20
+ email?: string;
21
+ url?: string;
22
+ }
23
+ type ParsedAuthor = {
24
+ type: 'github';
25
+ github: string;
26
+ avatar: string;
27
+ inferred?: boolean;
28
+ } | {
29
+ type: 'text';
30
+ name: string;
31
+ url?: string;
32
+ email?: string;
33
+ };
34
+ declare function parseAuthor(author: string): RawAuthor;
35
+ declare function normalizePkgAuthors(json: PackageJson): ParsedAuthor[] | undefined;
36
+ interface ParsedRepository {
37
+ url: string;
38
+ repo?: string;
39
+ repoName?: string;
40
+ org?: string;
41
+ }
42
+ declare function normalizePkgRepository(json: PackageJson): ParsedRepository | undefined;
43
+
44
+ export { normalizePkgFundings as d, normalizePkgLicense as e, normalizePkgRepository as f, parseFunding as g, normalizePkgAuthors as n, parseAuthor as p };
45
+ export type { NormalizedFunding as N, ParsedAuthor as P, RawAuthor as R, ParsedFunding as a, ParsedLicense as b, ParsedRepository as c };
@@ -14,40 +14,46 @@ function objectPick(obj, keys, omitUndefined = false) {
14
14
  }, {});
15
15
  }
16
16
 
17
- function constructPackageFilter(range) {
18
- const [name, version = "*"] = range.split(/\b@/);
19
- const hasWildcard = name?.includes("*");
20
- const nameMatch = hasWildcard ? new RegExp(`^${Array.from(name).map((char) => char === "*" ? ".*" : char === "." ? "\\." : char).join("")}$`) : name;
21
- return (pkg) => {
22
- const isNameMatch = nameMatch instanceof RegExp ? nameMatch.test(pkg.name) : pkg.name === name;
23
- const isVersionMatch = version === "*" || pkg.version === version || satisfies(pkg.version, version);
24
- return isNameMatch && isVersionMatch;
25
- };
17
+ const RE_GITHUB_SPONSORS = /^(?:https?:\/\/)?(?:www\.)?github\.com\/sponsors\/([\w.-]+)/i;
18
+ const RE_GITHUB_USER_URL = /^(?:https?:\/\/)?(?:www\.)?github\.com\/([\w.-]+)\/?$/i;
19
+ const RE_GITHUB_PROFILE_LIKE = /^(?:https?:\/\/)?(?:www\.)?github\.com\/([\w.-]+)/i;
20
+ const RE_GITHUB_NOREPLY = /^(?:\d+\+)?([\w.-]+)@users\.noreply\.github\.com$/i;
21
+ const RE_OPENCOLLECTIVE = /^(?:https?:\/\/)?(?:www\.)?opencollective\.com\/([\w.-]+)/i;
22
+ function githubAvatar(handle) {
23
+ return `https://avatars.antfu.dev/gh/${handle}`;
26
24
  }
27
- function constructPackageFilters(ranges, mode) {
28
- const filters = ranges.map((x) => typeof x === "string" ? constructPackageFilter(x) : x);
29
- return (pkg) => mode === "some" ? filters.some((filter) => filter(pkg)) : filters.every((filter) => filter(pkg));
25
+ function extractGitHubHandle(input) {
26
+ if (input.url) {
27
+ const match = input.url.match(RE_GITHUB_USER_URL);
28
+ if (match)
29
+ return match[1];
30
+ }
31
+ if (input.email) {
32
+ const match = input.email.match(RE_GITHUB_NOREPLY);
33
+ if (match)
34
+ return match[1];
35
+ }
36
+ return void 0;
30
37
  }
31
-
32
38
  function parseFunding(funding) {
33
39
  const url = funding.url;
34
40
  let name = "";
35
41
  let type = funding.type || "link";
36
42
  let avatar;
37
- let match = url.match(/^(?:https?:\/\/)?(?:www\.)?github\.com\/sponsors\/([\w.-]+)/i);
43
+ let match = url.match(RE_GITHUB_SPONSORS);
38
44
  if (match) {
39
45
  name = match[1];
40
46
  type = "github";
41
47
  }
42
48
  if (!name) {
43
- match = url.match(/^(?:https?:\/\/)?(?:www\.)?github\.com\/([\w.-]+)/i);
49
+ match = url.match(RE_GITHUB_PROFILE_LIKE);
44
50
  if (match) {
45
51
  name = match[1];
46
52
  type = "github";
47
53
  }
48
54
  }
49
55
  if (!name) {
50
- match = url.match(/^(?:https?:\/\/)?(?:www\.)?opencollective\.com\/([\w.-]+)/i);
56
+ match = url.match(RE_OPENCOLLECTIVE);
51
57
  if (match) {
52
58
  name = match[1];
53
59
  type = "opencollective";
@@ -56,7 +62,7 @@ function parseFunding(funding) {
56
62
  if (!name)
57
63
  name = url.replace(/^(?:https?:\/\/)?(?:www\.)?/, "").replace(/\/$/, "");
58
64
  if (type === "github" && name)
59
- avatar = `https://avatars.antfu.dev/gh/${name}`;
65
+ avatar = githubAvatar(name);
60
66
  if (type === "opencollective" && name)
61
67
  avatar = `https://opencollective.com/${name}/avatar.png`;
62
68
  const entry = `${type}@${name}`;
@@ -99,32 +105,70 @@ function normalizePkgFundings(json) {
99
105
  return void 0;
100
106
  return fundings.map((f) => parseFunding(f)).filter(Boolean);
101
107
  }
108
+ const RE_AUTHOR_EMAIL = /<([^>]+)>/;
109
+ const RE_AUTHOR_URL = /\(([^)]+)\)/;
102
110
  function parseAuthor(author) {
103
- if (!author)
111
+ let rest = author;
112
+ let email;
113
+ let url;
114
+ const emailMatch = rest.match(RE_AUTHOR_EMAIL);
115
+ if (emailMatch) {
116
+ email = emailMatch[1].trim() || void 0;
117
+ rest = rest.replace(emailMatch[0], "");
118
+ }
119
+ const urlMatch = rest.match(RE_AUTHOR_URL);
120
+ if (urlMatch) {
121
+ url = urlMatch[1].trim() || void 0;
122
+ rest = rest.replace(urlMatch[0], "");
123
+ }
124
+ const name = rest.trim() || void 0;
125
+ return { name, email, url };
126
+ }
127
+ function toParsedAuthor(raw) {
128
+ const github = extractGitHubHandle({ url: raw.url, email: raw.email });
129
+ if (github) {
130
+ return {
131
+ type: "github",
132
+ github,
133
+ avatar: githubAvatar(github)
134
+ };
135
+ }
136
+ if (!raw.name)
104
137
  return void 0;
138
+ return {
139
+ type: "text",
140
+ name: raw.name,
141
+ url: raw.url,
142
+ email: raw.email
143
+ };
105
144
  }
106
145
  function normalizePkgAuthors(json) {
107
- const authors = [
146
+ const rawList = [
108
147
  ...toArray(json.authors),
109
148
  ...toArray(json.author)
110
149
  ].filter(Boolean);
111
- if (!authors.length)
150
+ const parsed = [];
151
+ for (const author of rawList) {
152
+ const raw = typeof author === "string" ? parseAuthor(author) : { name: author.name, email: author.email, url: author.url };
153
+ const entry = toParsedAuthor(raw);
154
+ if (entry)
155
+ parsed.push(entry);
156
+ }
157
+ const githubEntries = parsed.filter((a) => a.type === "github");
158
+ if (githubEntries.length)
159
+ return githubEntries;
160
+ const org = normalizePkgRepository(json)?.org;
161
+ if (org) {
162
+ return [{
163
+ type: "github",
164
+ github: org,
165
+ avatar: githubAvatar(org),
166
+ inferred: true
167
+ }];
168
+ }
169
+ if (!parsed.length)
112
170
  return void 0;
113
- return authors.map((author) => {
114
- if (typeof author === "string") {
115
- let url;
116
- const name = author.replace(/<.*>/, "").replace(/\(.*\)/, "").replace(/^https?:\/\//, "").trim();
117
- return {
118
- name,
119
- url
120
- };
121
- } else {
122
- return {
123
- name: author.name,
124
- url: author.url
125
- };
126
- }
127
- });
171
+ return parsed;
128
172
  }
129
173
  function normalizePkgRepository(json) {
130
174
  if (!json.repository && !json.bugs)
@@ -161,4 +205,19 @@ function normalizePkgRepository(json) {
161
205
  };
162
206
  }
163
207
 
208
+ function constructPackageFilter(range) {
209
+ const [name, version = "*"] = range.split(/\b@/);
210
+ const hasWildcard = name?.includes("*");
211
+ const nameMatch = hasWildcard ? new RegExp(`^${Array.from(name).map((char) => char === "*" ? ".*" : char === "." ? "\\." : char).join("")}$`) : name;
212
+ return (pkg) => {
213
+ const isNameMatch = nameMatch instanceof RegExp ? nameMatch.test(pkg.name) : pkg.name === name;
214
+ const isVersionMatch = version === "*" || pkg.version === version || satisfies(pkg.version, version);
215
+ return isNameMatch && isVersionMatch;
216
+ };
217
+ }
218
+ function constructPackageFilters(ranges, mode) {
219
+ const filters = ranges.map((x) => typeof x === "string" ? constructPackageFilter(x) : x);
220
+ return (pkg) => mode === "some" ? filters.some((filter) => filter(pkg)) : filters.every((filter) => filter(pkg));
221
+ }
222
+
164
223
  export { constructPackageFilters as a, normalizePkgFundings as b, constructPackageFilter as c, normalizePkgLicense as d, normalizePkgRepository as e, parseFunding as f, normalizePkgAuthors as n, objectPick as o, parseAuthor as p };
@@ -1,5 +1,6 @@
1
1
  import { PackageJson } from 'pkg-types';
2
2
  import { Message } from 'publint';
3
+ import { P as ParsedAuthor, c as ParsedRepository, b as ParsedLicense, a as ParsedFunding } from './node-modules-tools.BUfYtQgm.mjs';
3
4
 
4
5
  interface PackageInstallSizeInfo {
5
6
  bytes: number;
@@ -61,6 +62,14 @@ interface PackageNode extends PackageNodeBase {
61
62
  * Result for publint, null for invalid, undefined for not checked yet, empty array for all good
62
63
  */
63
64
  publint?: Message[] | null;
65
+ /** Parsed authors / maintainers, including GitHub-handle detection and repo-URL inference */
66
+ authors?: ParsedAuthor[];
67
+ /** Parsed repository info (normalized URL, GitHub org/repo when applicable) */
68
+ repository?: ParsedRepository;
69
+ /** Normalized license string (SPDX or combined expression) */
70
+ license?: ParsedLicense;
71
+ /** Parsed funding entries with avatars when known */
72
+ fundings?: ParsedFunding[];
64
73
  };
65
74
  }
66
75
  type AuditLevelString = 'low' | 'moderate' | 'high' | 'critical';
@@ -97,5 +106,5 @@ declare const CLUSTER_DEP_PROD = "dep:prod";
97
106
  declare const CLUSTER_DEP_DEV = "dep:dev";
98
107
  declare const CLUSTER_DEP_OPTIONAL = "dep:optional";
99
108
 
100
- export { CLUSTER_DEP_DEV as C, CLUSTER_DEP_OPTIONAL as d, CLUSTER_DEP_PROD as e, PackageModuleTypes as i };
101
- export type { AuditLevelString as A, FileCategory as F, NpmMeta as N, PackageNodeRaw as P, PackageNodeBase as a, PackageNode as b, PackageModuleType as c, NpmMetaLatest as f, PackageInstallSizeInfo as g, PackageModuleTypeSimple as h };
109
+ export { CLUSTER_DEP_DEV as C, CLUSTER_DEP_OPTIONAL as a, CLUSTER_DEP_PROD as b, PackageModuleTypes as f };
110
+ export type { AuditLevelString as A, FileCategory as F, NpmMeta as N, PackageInstallSizeInfo as P, NpmMetaLatest as c, PackageModuleType as d, PackageModuleTypeSimple as e, PackageNode as g, PackageNodeBase as h, PackageNodeRaw as i };
package/dist/utils.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- import { PackageJson } from 'pkg-types';
1
+ export { N as NormalizedFunding, P as ParsedAuthor, a as ParsedFunding, b as ParsedLicense, c as ParsedRepository, R as RawAuthor, n as normalizePkgAuthors, d as normalizePkgFundings, e as normalizePkgLicense, f as normalizePkgRepository, p as parseAuthor, g as parseFunding } from './shared/node-modules-tools.BUfYtQgm.mjs';
2
+ import 'pkg-types';
2
3
 
3
4
  interface PackageNodeLike {
4
5
  name: string;
@@ -16,32 +17,5 @@ interface PackageNodeLike {
16
17
  declare function constructPackageFilter(range: string): (pkg: PackageNodeLike) => boolean;
17
18
  declare function constructPackageFilters<Node extends PackageNodeLike = PackageNodeLike>(ranges: (string | ((pkg: Node) => boolean))[], mode: 'some' | 'every'): (pkg: Node) => boolean;
18
19
 
19
- interface NormalizedFunding {
20
- url: string;
21
- type?: string;
22
- }
23
- interface ParsedFunding {
24
- url: string;
25
- type: string;
26
- name: string;
27
- entry: string;
28
- avatar?: string;
29
- }
30
- declare function parseFunding(funding: NormalizedFunding): ParsedFunding;
31
- type ParsedLicense = string;
32
- declare function normalizePkgLicense(json: PackageJson): ParsedLicense | undefined;
33
- declare function normalizePkgFundings(json: PackageJson): ParsedFunding[] | undefined;
34
- declare function parseAuthor(author?: string): undefined;
35
- declare function normalizePkgAuthors(json: PackageJson): {
36
- name: any;
37
- url: any;
38
- }[] | undefined;
39
- declare function normalizePkgRepository(json: PackageJson): {
40
- url: string;
41
- repo: string | undefined;
42
- repoName: string | undefined;
43
- org: string | undefined;
44
- } | undefined;
45
-
46
- export { constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgLicense, normalizePkgRepository, parseAuthor, parseFunding };
47
- export type { NormalizedFunding, PackageNodeLike, ParsedFunding, ParsedLicense };
20
+ export { constructPackageFilter, constructPackageFilters };
21
+ export type { PackageNodeLike };
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { PackageJson } from 'pkg-types';
1
+ export { N as NormalizedFunding, P as ParsedAuthor, a as ParsedFunding, b as ParsedLicense, c as ParsedRepository, R as RawAuthor, n as normalizePkgAuthors, d as normalizePkgFundings, e as normalizePkgLicense, f as normalizePkgRepository, p as parseAuthor, g as parseFunding } from './shared/node-modules-tools.BUfYtQgm.js';
2
+ import 'pkg-types';
2
3
 
3
4
  interface PackageNodeLike {
4
5
  name: string;
@@ -16,32 +17,5 @@ interface PackageNodeLike {
16
17
  declare function constructPackageFilter(range: string): (pkg: PackageNodeLike) => boolean;
17
18
  declare function constructPackageFilters<Node extends PackageNodeLike = PackageNodeLike>(ranges: (string | ((pkg: Node) => boolean))[], mode: 'some' | 'every'): (pkg: Node) => boolean;
18
19
 
19
- interface NormalizedFunding {
20
- url: string;
21
- type?: string;
22
- }
23
- interface ParsedFunding {
24
- url: string;
25
- type: string;
26
- name: string;
27
- entry: string;
28
- avatar?: string;
29
- }
30
- declare function parseFunding(funding: NormalizedFunding): ParsedFunding;
31
- type ParsedLicense = string;
32
- declare function normalizePkgLicense(json: PackageJson): ParsedLicense | undefined;
33
- declare function normalizePkgFundings(json: PackageJson): ParsedFunding[] | undefined;
34
- declare function parseAuthor(author?: string): undefined;
35
- declare function normalizePkgAuthors(json: PackageJson): {
36
- name: any;
37
- url: any;
38
- }[] | undefined;
39
- declare function normalizePkgRepository(json: PackageJson): {
40
- url: string;
41
- repo: string | undefined;
42
- repoName: string | undefined;
43
- org: string | undefined;
44
- } | undefined;
45
-
46
- export { constructPackageFilter, constructPackageFilters, normalizePkgAuthors, normalizePkgFundings, normalizePkgLicense, normalizePkgRepository, parseAuthor, parseFunding };
47
- export type { NormalizedFunding, PackageNodeLike, ParsedFunding, ParsedLicense };
20
+ export { constructPackageFilter, constructPackageFilters };
21
+ export type { PackageNodeLike };
package/dist/utils.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export { c as constructPackageFilter, a as constructPackageFilters, n as normalizePkgAuthors, b as normalizePkgFundings, d as normalizePkgLicense, e as normalizePkgRepository, p as parseAuthor, f as parseFunding } from './shared/node-modules-tools.Cc0OH9G4.mjs';
1
+ export { c as constructPackageFilter, a as constructPackageFilters, n as normalizePkgAuthors, b as normalizePkgFundings, d as normalizePkgLicense, e as normalizePkgRepository, p as parseAuthor, f as parseFunding } from './shared/node-modules-tools.VxxuULZa.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": "2.0.0-beta.2",
4
+ "version": "2.1.0",
5
5
  "description": "Tools for inspecting node_modules",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -32,8 +32,8 @@
32
32
  "package-manager-detector": "^1.6.0",
33
33
  "pathe": "^2.0.3",
34
34
  "pkg-types": "^2.3.1",
35
- "publint": "^0.3.19",
36
- "semver": "^7.7.4",
35
+ "publint": "^0.3.21",
36
+ "semver": "^7.8.0",
37
37
  "tinyexec": "^1.1.2"
38
38
  },
39
39
  "devDependencies": {