@rsdoctor/graph 0.3.4 → 0.3.5
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/dist/cjs/graph/package-graph/graph.js +7 -32
- package/dist/cjs/graph/package-graph/utils.js +34 -2
- package/dist/esm/graph/package-graph/graph.js +5 -31
- package/dist/esm/graph/package-graph/utils.js +32 -1
- package/dist/type/graph/package-graph/graph.d.ts +1 -0
- package/dist/type/graph/package-graph/graph.d.ts.map +1 -1
- package/dist/type/graph/package-graph/utils.d.ts +2 -0
- package/dist/type/graph/package-graph/utils.d.ts.map +1 -1
- package/package.json +4 -3
@@ -18,15 +18,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
19
|
var graph_exports = {};
|
20
20
|
__export(graph_exports, {
|
21
|
-
PackageGraph: () => PackageGraph
|
21
|
+
PackageGraph: () => PackageGraph,
|
22
|
+
readPackageJson: () => import_utils2.readPackageJson
|
22
23
|
});
|
23
24
|
module.exports = __toCommonJS(graph_exports);
|
24
25
|
var import_lodash = require("lodash");
|
25
26
|
var import_path = require("path");
|
26
27
|
var import_types = require("@rsdoctor/types");
|
27
|
-
var import_common = require("@rsdoctor/utils/common");
|
28
28
|
var import_package = require("./package");
|
29
29
|
var import_dependency = require("./dependency");
|
30
|
+
var import_utils = require("./utils");
|
31
|
+
var import_utils2 = require("./utils");
|
30
32
|
class PackageGraph {
|
31
33
|
constructor(root) {
|
32
34
|
this._dependencies = [];
|
@@ -76,40 +78,12 @@ class PackageGraph {
|
|
76
78
|
pkgsMap.set(file, pkg2);
|
77
79
|
return pkg2;
|
78
80
|
}
|
79
|
-
const readPackageJson = (file2, readFile2) => {
|
80
|
-
let result;
|
81
|
-
let current = file2;
|
82
|
-
while (current !== "/" && !result) {
|
83
|
-
if ((0, import_path.dirname)(current) === current) {
|
84
|
-
break;
|
85
|
-
}
|
86
|
-
current = (0, import_path.dirname)(current);
|
87
|
-
if (readFile2) {
|
88
|
-
result = readFile2((0, import_path.join)(current, "package.json"));
|
89
|
-
}
|
90
|
-
if (!readFile2) {
|
91
|
-
result = import_common.Package.getPackageMetaFromModulePath(file2);
|
92
|
-
} else if (!result?.name) {
|
93
|
-
result = void 0;
|
94
|
-
}
|
95
|
-
}
|
96
|
-
if (!result) {
|
97
|
-
return;
|
98
|
-
}
|
99
|
-
if (readFile2 && (!result.name || !result.version)) {
|
100
|
-
return readPackageJson((0, import_path.dirname)(current), readFile2);
|
101
|
-
}
|
102
|
-
return {
|
103
|
-
...result,
|
104
|
-
root: current
|
105
|
-
};
|
106
|
-
};
|
107
81
|
const cache = this.getPackageContainFile(file);
|
108
82
|
if (cache) {
|
109
83
|
pkgsMap.set(file, cache);
|
110
84
|
return cache;
|
111
85
|
}
|
112
|
-
const data = readPackageJson(file, readFile);
|
86
|
+
const data = (0, import_utils.readPackageJson)(file, readFile);
|
113
87
|
if (!data) {
|
114
88
|
return;
|
115
89
|
}
|
@@ -174,5 +148,6 @@ class PackageGraph {
|
|
174
148
|
}
|
175
149
|
// Annotate the CommonJS export names for ESM import in node:
|
176
150
|
0 && (module.exports = {
|
177
|
-
PackageGraph
|
151
|
+
PackageGraph,
|
152
|
+
readPackageJson
|
178
153
|
});
|
@@ -18,13 +18,45 @@ var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
19
|
var utils_exports = {};
|
20
20
|
__export(utils_exports, {
|
21
|
-
isPackagePath: () => isPackagePath
|
21
|
+
isPackagePath: () => isPackagePath,
|
22
|
+
readPackageJson: () => readPackageJson
|
22
23
|
});
|
23
24
|
module.exports = __toCommonJS(utils_exports);
|
25
|
+
var import_path = require("path");
|
26
|
+
var import_common = require("@rsdoctor/utils/common");
|
24
27
|
function isPackagePath(path) {
|
25
28
|
return /(^|[/\\])node_modules[/\\]/.test(path);
|
26
29
|
}
|
30
|
+
const readPackageJson = (file, readFile) => {
|
31
|
+
let result;
|
32
|
+
let current = file;
|
33
|
+
while (current !== "/" && !result) {
|
34
|
+
if ((0, import_path.dirname)(current) === current) {
|
35
|
+
break;
|
36
|
+
}
|
37
|
+
current = (0, import_path.dirname)(current);
|
38
|
+
if (readFile) {
|
39
|
+
result = readFile((0, import_path.join)(current, "package.json"));
|
40
|
+
}
|
41
|
+
if (!readFile) {
|
42
|
+
result = import_common.Package.getPackageMetaFromModulePath(file);
|
43
|
+
} else if (!result?.name) {
|
44
|
+
result = void 0;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
if (!result) {
|
48
|
+
return;
|
49
|
+
}
|
50
|
+
if (readFile && (!result.name || !result.version)) {
|
51
|
+
return readPackageJson((0, import_path.dirname)(current), readFile);
|
52
|
+
}
|
53
|
+
return {
|
54
|
+
...result,
|
55
|
+
root: current
|
56
|
+
};
|
57
|
+
};
|
27
58
|
// Annotate the CommonJS export names for ESM import in node:
|
28
59
|
0 && (module.exports = {
|
29
|
-
isPackagePath
|
60
|
+
isPackagePath,
|
61
|
+
readPackageJson
|
30
62
|
});
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { unionBy } from "lodash";
|
2
|
-
import {
|
2
|
+
import { resolve } from "path";
|
3
3
|
import { SDK } from "@rsdoctor/types";
|
4
|
-
import { Package as PackageUtil } from "@rsdoctor/utils/common";
|
5
4
|
import { Package } from "./package";
|
6
5
|
import { PackageDependency } from "./dependency";
|
6
|
+
import { readPackageJson } from "./utils";
|
7
|
+
import { readPackageJson as readPackageJson2 } from "./utils";
|
7
8
|
class PackageGraph {
|
8
9
|
constructor(root) {
|
9
10
|
this._dependencies = [];
|
@@ -53,34 +54,6 @@ class PackageGraph {
|
|
53
54
|
pkgsMap.set(file, pkg2);
|
54
55
|
return pkg2;
|
55
56
|
}
|
56
|
-
const readPackageJson = (file2, readFile2) => {
|
57
|
-
let result;
|
58
|
-
let current = file2;
|
59
|
-
while (current !== "/" && !result) {
|
60
|
-
if (dirname(current) === current) {
|
61
|
-
break;
|
62
|
-
}
|
63
|
-
current = dirname(current);
|
64
|
-
if (readFile2) {
|
65
|
-
result = readFile2(join(current, "package.json"));
|
66
|
-
}
|
67
|
-
if (!readFile2) {
|
68
|
-
result = PackageUtil.getPackageMetaFromModulePath(file2);
|
69
|
-
} else if (!result?.name) {
|
70
|
-
result = void 0;
|
71
|
-
}
|
72
|
-
}
|
73
|
-
if (!result) {
|
74
|
-
return;
|
75
|
-
}
|
76
|
-
if (readFile2 && (!result.name || !result.version)) {
|
77
|
-
return readPackageJson(dirname(current), readFile2);
|
78
|
-
}
|
79
|
-
return {
|
80
|
-
...result,
|
81
|
-
root: current
|
82
|
-
};
|
83
|
-
};
|
84
57
|
const cache = this.getPackageContainFile(file);
|
85
58
|
if (cache) {
|
86
59
|
pkgsMap.set(file, cache);
|
@@ -150,5 +123,6 @@ class PackageGraph {
|
|
150
123
|
}
|
151
124
|
}
|
152
125
|
export {
|
153
|
-
PackageGraph
|
126
|
+
PackageGraph,
|
127
|
+
readPackageJson2 as readPackageJson
|
154
128
|
};
|
@@ -1,6 +1,37 @@
|
|
1
|
+
import { dirname, join } from "path";
|
2
|
+
import { Package as PackageUtil } from "@rsdoctor/utils/common";
|
1
3
|
function isPackagePath(path) {
|
2
4
|
return /(^|[/\\])node_modules[/\\]/.test(path);
|
3
5
|
}
|
6
|
+
const readPackageJson = (file, readFile) => {
|
7
|
+
let result;
|
8
|
+
let current = file;
|
9
|
+
while (current !== "/" && !result) {
|
10
|
+
if (dirname(current) === current) {
|
11
|
+
break;
|
12
|
+
}
|
13
|
+
current = dirname(current);
|
14
|
+
if (readFile) {
|
15
|
+
result = readFile(join(current, "package.json"));
|
16
|
+
}
|
17
|
+
if (!readFile) {
|
18
|
+
result = PackageUtil.getPackageMetaFromModulePath(file);
|
19
|
+
} else if (!result?.name) {
|
20
|
+
result = void 0;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
if (!result) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
if (readFile && (!result.name || !result.version)) {
|
27
|
+
return readPackageJson(dirname(current), readFile);
|
28
|
+
}
|
29
|
+
return {
|
30
|
+
...result,
|
31
|
+
root: current
|
32
|
+
};
|
33
|
+
};
|
4
34
|
export {
|
5
|
-
isPackagePath
|
35
|
+
isPackagePath,
|
36
|
+
readPackageJson
|
6
37
|
};
|
@@ -2,6 +2,7 @@ import { SDK } from '@rsdoctor/types';
|
|
2
2
|
import type { ModuleGraph, Module } from '../module-graph';
|
3
3
|
import { Package } from './package';
|
4
4
|
import { PackageDependency } from './dependency';
|
5
|
+
export { readPackageJson } from './utils';
|
5
6
|
export declare class PackageGraph implements SDK.PackageGraphInstance {
|
6
7
|
static fromModuleGraph(graph: ModuleGraph, root: string, getPackageFile?: SDK.GetPackageFile): PackageGraph;
|
7
8
|
private _root;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../../src/graph/package-graph/graph.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../../src/graph/package-graph/graph.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,qBAAa,YAAa,YAAW,GAAG,CAAC,oBAAoB;IAC3D,MAAM,CAAC,eAAe,CACpB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,GAAG,CAAC,cAAc,GAClC,YAAY;IAmCf,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,aAAa,CAA2B;IAEhD,OAAO,CAAC,SAAS,CAAiB;IAElC,OAAO,CAAC,WAAW,CAAgC;IAEnD,OAAO,CAAC,WAAW,CAA8B;gBAErC,IAAI,EAAE,MAAM;IAIxB,WAAW;IAIX,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,cAAc;IA2ChE,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAI7B,qBAAqB,CAAC,IAAI,EAAE,MAAM;IAIlC,iBAAiB,CAAC,IAAI,EAAE,MAAM;IAI9B,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,gBAAgB;IAQ3C,UAAU,CAAC,GAAG,EAAE,OAAO;IAcvB,0BAA0B,CAAC,GAAG,EAAE,OAAO;IAIvC,aAAa,CAAC,GAAG,EAAE,iBAAiB;IAMpC,yBAAyB;IAIzB,oBAAoB,IAAI,OAAO,EAAE,EAAE;IAWnC,MAAM,IAAI,GAAG,CAAC,gBAAgB;CAM/B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/graph/package-graph/utils.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/graph/package-graph/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAGtC,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,WAEzC;AAGD,eAAO,MAAM,eAAe,SACpB,MAAM,aACD,IAAI,cAAc,KAC5B,IAAI,gBAAgB,GAAG,SAgCzB,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rsdoctor/graph",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.5",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
@@ -17,14 +17,15 @@
|
|
17
17
|
"lodash": "^4.17.21",
|
18
18
|
"socket.io": "4.7.2",
|
19
19
|
"source-map": "^0.7.4",
|
20
|
-
"@rsdoctor/types": "0.3.
|
21
|
-
"@rsdoctor/utils": "0.3.
|
20
|
+
"@rsdoctor/types": "0.3.5",
|
21
|
+
"@rsdoctor/utils": "0.3.5"
|
22
22
|
},
|
23
23
|
"devDependencies": {
|
24
24
|
"@types/body-parser": "1.19.2",
|
25
25
|
"@types/estree": "1.0.0",
|
26
26
|
"@types/lodash": "^4.17.0",
|
27
27
|
"@types/node": "^16",
|
28
|
+
"fs-extra": "^11.1.1",
|
28
29
|
"tslib": "2.4.1",
|
29
30
|
"typescript": "^5.2.2"
|
30
31
|
},
|