node-modules-tools 0.2.9 → 0.3.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.
@@ -1,5 +1,8 @@
1
- import { relative, dirname } from 'pathe';
1
+ import fs from 'node:fs';
2
+ import YAML from 'js-yaml';
3
+ import { relative, dirname, join } from 'pathe';
2
4
  import { x } from 'tinyexec';
5
+ import { CLUSTER_DEP_PROD, CLUSTER_DEP_DEV } from '../constants.mjs';
3
6
 
4
7
  async function resolveRoot(options) {
5
8
  let raw;
@@ -52,9 +55,20 @@ async function getDependenciesTree(options) {
52
55
  throw new Error(`Failed to parse \`pnpm ls\` output, expected an array but got: ${String(json)}`);
53
56
  return json;
54
57
  }
58
+ async function getCatalogs(root) {
59
+ if (!fs.existsSync(join(root, "pnpm-workspace.yaml")))
60
+ return {};
61
+ const raw = await fs.promises.readFile(join(root, "pnpm-workspace.yaml"), "utf-8");
62
+ const data = YAML.load(raw) || {};
63
+ return {
64
+ ...data.catalogs || {},
65
+ default: data.catalog
66
+ };
67
+ }
55
68
  async function listPackageDependencies(options) {
56
69
  const root = await resolveRoot(options) || options.cwd;
57
70
  const tree = await getDependenciesTree(options);
71
+ const catalogsMap = await getCatalogs(root);
58
72
  const packages = /* @__PURE__ */ new Map();
59
73
  const workspacePackages = tree.map((pkg) => {
60
74
  let name = pkg.name;
@@ -72,7 +86,8 @@ async function listPackageDependencies(options) {
72
86
  version,
73
87
  filepath: pkg.path,
74
88
  dependencies: /* @__PURE__ */ new Set(),
75
- workspace: true
89
+ workspace: true,
90
+ clusters: /* @__PURE__ */ new Set()
76
91
  };
77
92
  if (pkg.private)
78
93
  node.private = true;
@@ -99,20 +114,24 @@ async function listPackageDependencies(options) {
99
114
  name: raw.from,
100
115
  version,
101
116
  filepath: raw.path,
102
- dependencies: /* @__PURE__ */ new Set()
117
+ dependencies: /* @__PURE__ */ new Set(),
118
+ clusters: /* @__PURE__ */ new Set()
103
119
  };
104
120
  mapNormalize.set(raw, node);
105
121
  return node;
106
122
  }
107
- function traverse(raw, level, mode) {
123
+ function traverse(raw, level, clusters) {
108
124
  const node = normalize(raw);
109
125
  if (!node.workspace) {
110
- if (mode === "dev")
111
- node.dev = true;
112
- if (mode === "prod")
113
- node.prod = true;
114
- if (mode === "optional")
115
- node.optional = true;
126
+ for (const cluster of clusters) {
127
+ node.clusters.add(cluster);
128
+ }
129
+ }
130
+ if (!node.workspace && level === 1) {
131
+ const catalogs = Object.entries(catalogsMap).filter(([_, catalog]) => catalog?.[node.name]).map(([name]) => name);
132
+ for (const catalog of catalogs) {
133
+ node.clusters.add(`catalog:${catalog}`);
134
+ }
116
135
  }
117
136
  if (options.traverseFilter?.(node) === false)
118
137
  return node;
@@ -121,7 +140,7 @@ async function listPackageDependencies(options) {
121
140
  packages.set(node.spec, node);
122
141
  if (options.dependenciesFilter?.(node) !== false) {
123
142
  for (const dep of Object.values(raw.dependencies || {})) {
124
- const resolvedDep = traverse(dep, level + 1, mode);
143
+ const resolvedDep = traverse(dep, level + 1, clusters);
125
144
  node.dependencies.add(resolvedDep.spec);
126
145
  }
127
146
  }
@@ -129,11 +148,11 @@ async function listPackageDependencies(options) {
129
148
  }
130
149
  for (const { pkg, node } of workspacePackages) {
131
150
  for (const dep of Object.values(pkg.dependencies || {})) {
132
- const result = traverse(dep, 1, "prod");
151
+ const result = traverse(dep, 1, [CLUSTER_DEP_PROD]);
133
152
  node.dependencies.add(result.spec);
134
153
  }
135
154
  for (const dep of Object.values(pkg.devDependencies || {})) {
136
- const result = traverse(dep, 1, "dev");
155
+ const result = traverse(dep, 1, [CLUSTER_DEP_DEV]);
137
156
  node.dependencies.add(result.spec);
138
157
  }
139
158
  }
@@ -0,0 +1,3 @@
1
+ export { d as CLUSTER_DEP_DEV, e as CLUSTER_DEP_OPTIONAL, C as CLUSTER_DEP_PROD, c as PackageModuleTypes } from './shared/node-modules-tools.BxS2oEP2.mjs';
2
+ import 'pkg-types';
3
+ import 'publint';
@@ -0,0 +1,3 @@
1
+ export { d as CLUSTER_DEP_DEV, e as CLUSTER_DEP_OPTIONAL, C as CLUSTER_DEP_PROD, c as PackageModuleTypes } from './shared/node-modules-tools.BxS2oEP2.js';
2
+ import 'pkg-types';
3
+ import 'publint';
@@ -0,0 +1,6 @@
1
+ const PackageModuleTypes = Object.freeze(["cjs", "esm", "dual", "faux", "dts"]);
2
+ const CLUSTER_DEP_PROD = "dep:prod";
3
+ const CLUSTER_DEP_DEV = "dep:dev";
4
+ const CLUSTER_DEP_OPTIONAL = "dep:optional";
5
+
6
+ export { CLUSTER_DEP_DEV, CLUSTER_DEP_OPTIONAL, CLUSTER_DEP_PROD, PackageModuleTypes };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { AgentName } from 'package-manager-detector';
2
- import { Message } from 'publint';
2
+ import { P as PackageNodeRaw, a as PackageNodeBase, b as PackageNode } from './shared/node-modules-tools.BxS2oEP2.mjs';
3
+ export { d as CLUSTER_DEP_DEV, e as CLUSTER_DEP_OPTIONAL, C as CLUSTER_DEP_PROD, F as FileCategory, h as PackageInstallSizeInfo, g as PackageModuleType, f as PackageModuleTypeSimple, c as PackageModuleTypes } from './shared/node-modules-tools.BxS2oEP2.mjs';
3
4
  export { PackageNodeLike, constructPackageFilter, constructPackageFilters } from './utils.mjs';
5
+ import 'pkg-types';
6
+ import 'publint';
4
7
 
5
8
  interface BaseOptions {
6
9
  /**
@@ -9,67 +12,6 @@ interface BaseOptions {
9
12
  cwd: string;
10
13
  }
11
14
 
12
- interface PackageInstallSizeInfo {
13
- bytes: number;
14
- categories: Partial<Record<FileCategory, {
15
- bytes: number;
16
- count: number;
17
- }>>;
18
- }
19
- type FileCategory = 'comp' | 'css' | 'doc' | 'dts' | 'html' | 'image' | 'js' | 'json' | 'other' | 'test' | 'ts' | 'bin' | 'map' | 'wasm' | 'flow' | 'font';
20
-
21
- type PackageModuleTypeSimple = 'cjs' | 'esm';
22
- type PackageModuleType = 'cjs' | 'esm' | 'dual' | 'faux' | 'dts';
23
- interface PackageNodeRaw {
24
- /** Package Name */
25
- name: string;
26
- /** Version */
27
- version: string;
28
- /** Combined name and version using `@` */
29
- spec: string;
30
- /** Absolute file path of the package */
31
- filepath: string;
32
- /** Direct dependencies of this package */
33
- dependencies: Set<string>;
34
- /** Is this package from local workspace */
35
- workspace?: boolean;
36
- /** Is this package private */
37
- private?: boolean;
38
- /** Is this package part of devDependencies */
39
- dev?: boolean;
40
- /** Is this package part of dependencies */
41
- prod?: boolean;
42
- /** Is this package part of optionalDependencies */
43
- optional?: boolean;
44
- }
45
- interface PackageNodeBase extends PackageNodeRaw {
46
- /** Direct dependents of this package */
47
- dependents: Set<string>;
48
- /** The lowest depth of this package */
49
- depth: number;
50
- /** All nested dependencies of this package */
51
- flatDependencies: Set<string>;
52
- /** All nested dependents of this package */
53
- flatDependents: Set<string>;
54
- }
55
- interface PackageNode extends PackageNodeBase {
56
- resolved: {
57
- module: PackageModuleType;
58
- license?: string;
59
- author?: string;
60
- repository?: string;
61
- funding?: {
62
- url?: string;
63
- type?: string;
64
- };
65
- homepage?: string;
66
- engines?: Record<string, string>;
67
- installSize?: PackageInstallSizeInfo;
68
- publishTime?: string;
69
- publint?: Message[];
70
- };
71
- }
72
-
73
15
  interface ListPackageDependenciesOptions extends BaseOptions {
74
16
  /**
75
17
  * Depeth of the dependency tree
@@ -114,8 +56,6 @@ declare function getPackageManager(options: BaseOptions): Promise<AgentName>;
114
56
  */
115
57
  declare function listPackageDependenciesRaw(manager: AgentName, options: ListPackageDependenciesOptions): Promise<ListPackageDependenciesRawResult>;
116
58
 
117
- declare const PackageModuleTypes: readonly PackageModuleType[];
118
-
119
59
  declare function listPackageDependencies(options: ListPackageDependenciesOptions): Promise<ListPackageDependenciesResult>;
120
60
 
121
61
  /**
@@ -126,4 +66,4 @@ declare function listPackageDependencies(options: ListPackageDependenciesOptions
126
66
  */
127
67
  declare function resolvePackage(_packageManager: AgentName, pkg: PackageNodeBase, _options: BaseOptions): Promise<PackageNode>;
128
68
 
129
- export { type BaseOptions, type FileCategory, type ListPackageDependenciesBaseResult, type ListPackageDependenciesOptions, type ListPackageDependenciesRawResult, type ListPackageDependenciesResult, type PackageInstallSizeInfo, type PackageModuleType, type PackageModuleTypeSimple, PackageModuleTypes, type PackageNode, type PackageNodeBase, type PackageNodeRaw, getPackageManager, listPackageDependencies, listPackageDependenciesRaw, resolvePackage };
69
+ export { type BaseOptions, type ListPackageDependenciesBaseResult, type ListPackageDependenciesOptions, type ListPackageDependenciesRawResult, type ListPackageDependenciesResult, PackageNode, PackageNodeBase, PackageNodeRaw, getPackageManager, listPackageDependencies, listPackageDependenciesRaw, resolvePackage };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { AgentName } from 'package-manager-detector';
2
- import { Message } from 'publint';
2
+ import { P as PackageNodeRaw, a as PackageNodeBase, b as PackageNode } from './shared/node-modules-tools.BxS2oEP2.js';
3
+ export { d as CLUSTER_DEP_DEV, e as CLUSTER_DEP_OPTIONAL, C as CLUSTER_DEP_PROD, F as FileCategory, h as PackageInstallSizeInfo, g as PackageModuleType, f as PackageModuleTypeSimple, c as PackageModuleTypes } from './shared/node-modules-tools.BxS2oEP2.js';
3
4
  export { PackageNodeLike, constructPackageFilter, constructPackageFilters } from './utils.js';
5
+ import 'pkg-types';
6
+ import 'publint';
4
7
 
5
8
  interface BaseOptions {
6
9
  /**
@@ -9,67 +12,6 @@ interface BaseOptions {
9
12
  cwd: string;
10
13
  }
11
14
 
12
- interface PackageInstallSizeInfo {
13
- bytes: number;
14
- categories: Partial<Record<FileCategory, {
15
- bytes: number;
16
- count: number;
17
- }>>;
18
- }
19
- type FileCategory = 'comp' | 'css' | 'doc' | 'dts' | 'html' | 'image' | 'js' | 'json' | 'other' | 'test' | 'ts' | 'bin' | 'map' | 'wasm' | 'flow' | 'font';
20
-
21
- type PackageModuleTypeSimple = 'cjs' | 'esm';
22
- type PackageModuleType = 'cjs' | 'esm' | 'dual' | 'faux' | 'dts';
23
- interface PackageNodeRaw {
24
- /** Package Name */
25
- name: string;
26
- /** Version */
27
- version: string;
28
- /** Combined name and version using `@` */
29
- spec: string;
30
- /** Absolute file path of the package */
31
- filepath: string;
32
- /** Direct dependencies of this package */
33
- dependencies: Set<string>;
34
- /** Is this package from local workspace */
35
- workspace?: boolean;
36
- /** Is this package private */
37
- private?: boolean;
38
- /** Is this package part of devDependencies */
39
- dev?: boolean;
40
- /** Is this package part of dependencies */
41
- prod?: boolean;
42
- /** Is this package part of optionalDependencies */
43
- optional?: boolean;
44
- }
45
- interface PackageNodeBase extends PackageNodeRaw {
46
- /** Direct dependents of this package */
47
- dependents: Set<string>;
48
- /** The lowest depth of this package */
49
- depth: number;
50
- /** All nested dependencies of this package */
51
- flatDependencies: Set<string>;
52
- /** All nested dependents of this package */
53
- flatDependents: Set<string>;
54
- }
55
- interface PackageNode extends PackageNodeBase {
56
- resolved: {
57
- module: PackageModuleType;
58
- license?: string;
59
- author?: string;
60
- repository?: string;
61
- funding?: {
62
- url?: string;
63
- type?: string;
64
- };
65
- homepage?: string;
66
- engines?: Record<string, string>;
67
- installSize?: PackageInstallSizeInfo;
68
- publishTime?: string;
69
- publint?: Message[];
70
- };
71
- }
72
-
73
15
  interface ListPackageDependenciesOptions extends BaseOptions {
74
16
  /**
75
17
  * Depeth of the dependency tree
@@ -114,8 +56,6 @@ declare function getPackageManager(options: BaseOptions): Promise<AgentName>;
114
56
  */
115
57
  declare function listPackageDependenciesRaw(manager: AgentName, options: ListPackageDependenciesOptions): Promise<ListPackageDependenciesRawResult>;
116
58
 
117
- declare const PackageModuleTypes: readonly PackageModuleType[];
118
-
119
59
  declare function listPackageDependencies(options: ListPackageDependenciesOptions): Promise<ListPackageDependenciesResult>;
120
60
 
121
61
  /**
@@ -126,4 +66,4 @@ declare function listPackageDependencies(options: ListPackageDependenciesOptions
126
66
  */
127
67
  declare function resolvePackage(_packageManager: AgentName, pkg: PackageNodeBase, _options: BaseOptions): Promise<PackageNode>;
128
68
 
129
- export { type BaseOptions, type FileCategory, type ListPackageDependenciesBaseResult, type ListPackageDependenciesOptions, type ListPackageDependenciesRawResult, type ListPackageDependenciesResult, type PackageInstallSizeInfo, type PackageModuleType, type PackageModuleTypeSimple, PackageModuleTypes, type PackageNode, type PackageNodeBase, type PackageNodeRaw, getPackageManager, listPackageDependencies, listPackageDependenciesRaw, resolvePackage };
69
+ export { type BaseOptions, type ListPackageDependenciesBaseResult, type ListPackageDependenciesOptions, type ListPackageDependenciesRawResult, type ListPackageDependenciesResult, PackageNode, PackageNodeBase, PackageNodeRaw, getPackageManager, listPackageDependencies, listPackageDependenciesRaw, resolvePackage };
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ export { CLUSTER_DEP_DEV, CLUSTER_DEP_OPTIONAL, CLUSTER_DEP_PROD, PackageModuleTypes } from './constants.mjs';
1
2
  import pLimit from 'p-limit';
2
3
  import { detect } from 'package-manager-detector';
3
4
  import fs from 'node:fs/promises';
@@ -33,8 +34,12 @@ function populateRawResult(input) {
33
34
  dependents: /* @__PURE__ */ new Set(),
34
35
  flatDependencies: /* @__PURE__ */ new Set(),
35
36
  flatDependents: /* @__PURE__ */ new Set(),
37
+ flatClusters: /* @__PURE__ */ new Set(),
36
38
  depth: pkg.workspace ? 0 : Infinity
37
39
  });
40
+ for (const cluster of pkg.clusters) {
41
+ node.flatClusters.add(cluster);
42
+ }
38
43
  result.packages.set(spec, node);
39
44
  }
40
45
  for (const pkg of result.packages.values()) {
@@ -51,12 +56,9 @@ function populateRawResult(input) {
51
56
  if (!depNode)
52
57
  continue;
53
58
  if (!node.workspace) {
54
- if (node.dev)
55
- depNode.dev = true;
56
- if (node.prod)
57
- depNode.prod = true;
58
- if (node.optional)
59
- depNode.optional = true;
59
+ for (const cluster of node.flatClusters) {
60
+ depNode.flatClusters.add(cluster);
61
+ }
60
62
  }
61
63
  if (depNode.depth > level)
62
64
  depNode.depth = level;
@@ -92,8 +94,6 @@ function populateRawResult(input) {
92
94
  return result;
93
95
  }
94
96
 
95
- const PackageModuleTypes = Object.freeze(["cjs", "esm", "dual", "faux", "dts"]);
96
-
97
97
  function analyzePackageModuleType(pkgJson) {
98
98
  if (pkgJson.name?.startsWith("@types/"))
99
99
  return "dts";
@@ -298,15 +298,22 @@ async function resolvePackage(_packageManager, pkg, _options) {
298
298
  repository = `https://${repository.slice(6)}`;
299
299
  if (json.repository && typeof json.repository !== "string" && json.repository.directory)
300
300
  repository += `/tree/HEAD/${json.repository.directory}`;
301
- let funding = json.funding;
302
- if (typeof funding === "string")
303
- funding = { url: funding };
301
+ const rawFunding = json.funding;
302
+ let fundings;
303
+ if (typeof rawFunding === "string") {
304
+ fundings = [{ url: rawFunding }];
305
+ } else if (Array.isArray(rawFunding)) {
306
+ fundings = rawFunding.map((f) => typeof f === "string" ? { url: f } : f);
307
+ } else {
308
+ fundings = rawFunding ? [rawFunding] : [];
309
+ }
304
310
  _pkg.resolved = {
305
311
  module: analyzePackageModuleType(json),
306
312
  engines: json.engines,
307
313
  license: json.license,
308
314
  author: typeof json.author === "string" ? json.author : json.author?.url,
309
- funding,
315
+ fundings,
316
+ exports: json.exports,
310
317
  repository,
311
318
  homepage: json.homepage,
312
319
  installSize: await getPackageInstallSize(_pkg)
@@ -328,4 +335,4 @@ async function listPackageDependencies(options) {
328
335
  return result;
329
336
  }
330
337
 
331
- export { PackageModuleTypes, getPackageManager, listPackageDependencies, listPackageDependenciesRaw, resolvePackage };
338
+ export { getPackageManager, listPackageDependencies, listPackageDependenciesRaw, resolvePackage };
@@ -0,0 +1,78 @@
1
+ import { PackageJsonExports } from 'pkg-types';
2
+ import { Message } from 'publint';
3
+
4
+ interface PackageInstallSizeInfo {
5
+ bytes: number;
6
+ categories: Partial<Record<FileCategory, {
7
+ bytes: number;
8
+ count: number;
9
+ }>>;
10
+ }
11
+ type FileCategory = 'comp' | 'css' | 'doc' | 'dts' | 'html' | 'image' | 'js' | 'json' | 'other' | 'test' | 'ts' | 'bin' | 'map' | 'wasm' | 'flow' | 'font';
12
+
13
+ type PackageModuleTypeSimple = 'cjs' | 'esm';
14
+ type PackageModuleType = 'cjs' | 'esm' | 'dual' | 'faux' | 'dts';
15
+ interface PackageNodeRaw {
16
+ /** Package Name */
17
+ name: string;
18
+ /** Version */
19
+ version: string;
20
+ /** Combined name and version using `@` */
21
+ spec: string;
22
+ /** Absolute file path of the package */
23
+ filepath: string;
24
+ /** Direct dependencies of this package */
25
+ dependencies: Set<string>;
26
+ /** Is this package from local workspace */
27
+ workspace?: boolean;
28
+ /** Is this package private */
29
+ private?: boolean;
30
+ /**
31
+ * Cluster of this package.
32
+ * Cluster is a set of labels that will inherits to all nested dependencies.
33
+ *
34
+ * Typically it would includes things like `dep:dev` or `dep:prod`,
35
+ * or catalogs like `catalog:default` or `catalog:custom-named`.
36
+ */
37
+ clusters: Set<string>;
38
+ }
39
+ interface PackageNodeBase extends PackageNodeRaw {
40
+ /** Direct dependents of this package */
41
+ dependents: Set<string>;
42
+ /** The lowest depth of this package */
43
+ depth: number;
44
+ /** All nested dependencies of this package */
45
+ flatDependencies: Set<string>;
46
+ /** All nested dependents of this package */
47
+ flatDependents: Set<string>;
48
+ /** All clusters of this package */
49
+ flatClusters: Set<string>;
50
+ }
51
+ interface PackageNode extends PackageNodeBase {
52
+ resolved: {
53
+ module: PackageModuleType;
54
+ license?: string;
55
+ author?: string;
56
+ repository?: string;
57
+ fundings?: {
58
+ url: string;
59
+ type?: string;
60
+ }[];
61
+ exports?: PackageJsonExports;
62
+ homepage?: string;
63
+ engines?: Record<string, string>;
64
+ installSize?: PackageInstallSizeInfo;
65
+ publishTime?: string;
66
+ /**
67
+ * Result for publint, null for invalid, undefined for not checked yet, empty array for all good
68
+ */
69
+ publint?: Message[] | null;
70
+ };
71
+ }
72
+
73
+ declare const PackageModuleTypes: readonly PackageModuleType[];
74
+ declare const CLUSTER_DEP_PROD = "dep:prod";
75
+ declare const CLUSTER_DEP_DEV = "dep:dev";
76
+ declare const CLUSTER_DEP_OPTIONAL = "dep:optional";
77
+
78
+ export { CLUSTER_DEP_PROD as C, type FileCategory as F, type PackageNodeRaw as P, type PackageNodeBase as a, type PackageNode as b, PackageModuleTypes as c, CLUSTER_DEP_DEV as d, CLUSTER_DEP_OPTIONAL as e, type PackageModuleTypeSimple as f, type PackageModuleType as g, type PackageInstallSizeInfo as h };
@@ -0,0 +1,78 @@
1
+ import { PackageJsonExports } from 'pkg-types';
2
+ import { Message } from 'publint';
3
+
4
+ interface PackageInstallSizeInfo {
5
+ bytes: number;
6
+ categories: Partial<Record<FileCategory, {
7
+ bytes: number;
8
+ count: number;
9
+ }>>;
10
+ }
11
+ type FileCategory = 'comp' | 'css' | 'doc' | 'dts' | 'html' | 'image' | 'js' | 'json' | 'other' | 'test' | 'ts' | 'bin' | 'map' | 'wasm' | 'flow' | 'font';
12
+
13
+ type PackageModuleTypeSimple = 'cjs' | 'esm';
14
+ type PackageModuleType = 'cjs' | 'esm' | 'dual' | 'faux' | 'dts';
15
+ interface PackageNodeRaw {
16
+ /** Package Name */
17
+ name: string;
18
+ /** Version */
19
+ version: string;
20
+ /** Combined name and version using `@` */
21
+ spec: string;
22
+ /** Absolute file path of the package */
23
+ filepath: string;
24
+ /** Direct dependencies of this package */
25
+ dependencies: Set<string>;
26
+ /** Is this package from local workspace */
27
+ workspace?: boolean;
28
+ /** Is this package private */
29
+ private?: boolean;
30
+ /**
31
+ * Cluster of this package.
32
+ * Cluster is a set of labels that will inherits to all nested dependencies.
33
+ *
34
+ * Typically it would includes things like `dep:dev` or `dep:prod`,
35
+ * or catalogs like `catalog:default` or `catalog:custom-named`.
36
+ */
37
+ clusters: Set<string>;
38
+ }
39
+ interface PackageNodeBase extends PackageNodeRaw {
40
+ /** Direct dependents of this package */
41
+ dependents: Set<string>;
42
+ /** The lowest depth of this package */
43
+ depth: number;
44
+ /** All nested dependencies of this package */
45
+ flatDependencies: Set<string>;
46
+ /** All nested dependents of this package */
47
+ flatDependents: Set<string>;
48
+ /** All clusters of this package */
49
+ flatClusters: Set<string>;
50
+ }
51
+ interface PackageNode extends PackageNodeBase {
52
+ resolved: {
53
+ module: PackageModuleType;
54
+ license?: string;
55
+ author?: string;
56
+ repository?: string;
57
+ fundings?: {
58
+ url: string;
59
+ type?: string;
60
+ }[];
61
+ exports?: PackageJsonExports;
62
+ homepage?: string;
63
+ engines?: Record<string, string>;
64
+ installSize?: PackageInstallSizeInfo;
65
+ publishTime?: string;
66
+ /**
67
+ * Result for publint, null for invalid, undefined for not checked yet, empty array for all good
68
+ */
69
+ publint?: Message[] | null;
70
+ };
71
+ }
72
+
73
+ declare const PackageModuleTypes: readonly PackageModuleType[];
74
+ declare const CLUSTER_DEP_PROD = "dep:prod";
75
+ declare const CLUSTER_DEP_DEV = "dep:dev";
76
+ declare const CLUSTER_DEP_OPTIONAL = "dep:optional";
77
+
78
+ export { CLUSTER_DEP_PROD as C, type FileCategory as F, type PackageNodeRaw as P, type PackageNodeBase as a, type PackageNode as b, PackageModuleTypes as c, CLUSTER_DEP_DEV as d, CLUSTER_DEP_OPTIONAL as e, type PackageModuleTypeSimple as f, type PackageModuleType as g, type PackageInstallSizeInfo as h };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-modules-tools",
3
3
  "type": "module",
4
- "version": "0.2.9",
4
+ "version": "0.3.0",
5
5
  "description": "Tools for inspecting node_modules",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -17,7 +17,8 @@
17
17
  "sideEffects": false,
18
18
  "exports": {
19
19
  ".": "./dist/index.mjs",
20
- "./utils": "./dist/utils.mjs"
20
+ "./utils": "./dist/utils.mjs",
21
+ "./constants": "./dist/constants.mjs"
21
22
  },
22
23
  "main": "./dist/index.mjs",
23
24
  "module": "./dist/index.mjs",
@@ -26,18 +27,20 @@
26
27
  "dist"
27
28
  ],
28
29
  "dependencies": {
30
+ "js-yaml": "^4.1.0",
29
31
  "p-limit": "^6.2.0",
30
32
  "package-manager-detector": "^0.2.11",
31
33
  "pathe": "^2.0.3",
34
+ "pkg-types": "^2.1.0",
32
35
  "publint": "^0.3.8",
33
36
  "semver": "^7.7.1",
34
37
  "tinyexec": "^0.3.2"
35
38
  },
36
39
  "devDependencies": {
37
- "@pnpm/list": "^1000.0.9",
38
- "@pnpm/types": "^1000.2.0",
40
+ "@pnpm/list": "^1000.0.10",
41
+ "@pnpm/types": "^1000.2.1",
42
+ "@types/js-yaml": "^4.0.9",
39
43
  "@types/stream-json": "^1.7.8",
40
- "pkg-types": "^2.1.0",
41
44
  "stream-json": "^1.9.1",
42
45
  "unbuild": "^3.5.0"
43
46
  },