@rushstack/lockfile-explorer 1.7.41 → 1.8.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.
- package/CHANGELOG.json +55 -0
- package/CHANGELOG.md +21 -1
- package/build/lfx-shared/IAppContext.d.ts +32 -0
- package/build/lfx-shared/IAppContext.js +5 -0
- package/build/lfx-shared/IAppContext.js.map +1 -0
- package/build/lfx-shared/IJsonLfxGraph.d.ts +51 -0
- package/build/lfx-shared/IJsonLfxGraph.js +19 -0
- package/build/lfx-shared/IJsonLfxGraph.js.map +1 -0
- package/build/lfx-shared/IJsonLfxWorkspace.d.ts +59 -0
- package/build/lfx-shared/IJsonLfxWorkspace.js +5 -0
- package/build/lfx-shared/IJsonLfxWorkspace.js.map +1 -0
- package/build/lfx-shared/LfxGraph.d.ts +96 -0
- package/build/lfx-shared/LfxGraph.js +67 -0
- package/build/lfx-shared/LfxGraph.js.map +1 -0
- package/build/lfx-shared/index.d.ts +6 -0
- package/build/lfx-shared/index.js +12 -0
- package/build/lfx-shared/index.js.map +1 -0
- package/build/lfx-shared/lfxGraphSerializer.d.ts +5 -0
- package/build/lfx-shared/lfxGraphSerializer.js +121 -0
- package/build/lfx-shared/lfxGraphSerializer.js.map +1 -0
- package/dist/531.0e5a24ca1399529aa975.js +2 -0
- package/dist/{964.4bbaf68a6f1467df6770.js.LICENSE.txt → 531.0e5a24ca1399529aa975.js.LICENSE.txt} +13 -0
- package/dist/app.22259b754540a899e03d.js +1 -0
- package/dist/index.html +1 -1
- package/lib/cli/explorer/ExplorerCommandLineParser.d.ts.map +1 -1
- package/lib/cli/explorer/ExplorerCommandLineParser.js +61 -22
- package/lib/cli/explorer/ExplorerCommandLineParser.js.map +1 -1
- package/lib/cli/lint/actions/CheckAction.d.ts.map +1 -1
- package/lib/cli/lint/actions/CheckAction.js.map +1 -1
- package/lib/graph/IPnpmfileModule.d.ts +15 -0
- package/lib/graph/IPnpmfileModule.d.ts.map +1 -0
- package/lib/graph/IPnpmfileModule.js +5 -0
- package/lib/graph/IPnpmfileModule.js.map +1 -0
- package/lib/graph/PnpmfileRunner.d.ts +19 -0
- package/lib/graph/PnpmfileRunner.d.ts.map +1 -0
- package/lib/graph/PnpmfileRunner.js +123 -0
- package/lib/graph/PnpmfileRunner.js.map +1 -0
- package/lib/graph/lfxGraphLoader.d.ts +9 -0
- package/lib/graph/lfxGraphLoader.d.ts.map +1 -0
- package/lib/graph/lfxGraphLoader.js +408 -0
- package/lib/graph/lfxGraphLoader.js.map +1 -0
- package/lib/graph/lockfilePath.d.ts +37 -0
- package/lib/graph/lockfilePath.d.ts.map +1 -0
- package/lib/graph/lockfilePath.js +123 -0
- package/lib/graph/lockfilePath.js.map +1 -0
- package/lib/graph/pnpmfileRunnerWorkerThread.d.ts +23 -0
- package/lib/graph/pnpmfileRunnerWorkerThread.d.ts.map +1 -0
- package/lib/graph/pnpmfileRunnerWorkerThread.js +94 -0
- package/lib/graph/pnpmfileRunnerWorkerThread.js.map +1 -0
- package/lib/state/index.d.ts +4 -22
- package/lib/state/index.d.ts.map +1 -1
- package/lib/state/index.js +0 -6
- package/lib/state/index.js.map +1 -1
- package/lib/utils/init.d.ts +2 -2
- package/lib/utils/init.d.ts.map +1 -1
- package/lib/utils/init.js +73 -29
- package/lib/utils/init.js.map +1 -1
- package/lib/utils/shrinkwrap.d.ts.map +1 -1
- package/lib/utils/shrinkwrap.js.map +1 -1
- package/package.json +14 -12
- package/dist/964.4bbaf68a6f1467df6770.js +0 -2
- package/dist/app.acf2b912c3f02793012c.js +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For example, retrieves `d` from `/a/b/c/d`.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getBaseNameOf(importerPath: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* For example, retrieves `/a/b/c` from `/a/b/c/d`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getParentOf(importerPath: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Cheaply resolves a relative path against a base path, assuming the paths are delimited by `/`,
|
|
11
|
+
* and assuming the basePath is already in normal form. An error occurs if the relative path
|
|
12
|
+
* goes above the root folder.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* getAbsolutePath(`a/b/c`, `d/e`) === `a/b/c/d/e`
|
|
17
|
+
* getAbsolutePath(`/a/b/c`, `d/e`) === `/a/b/c/d/e`
|
|
18
|
+
* getAbsolutePath(`/a/b/c`, `/d/e`) === `/d/e`
|
|
19
|
+
* getAbsolutePath(`a/b/c`, `../../f`) === `a/f`
|
|
20
|
+
* getAbsolutePath(`a/b/c`, `.././/f`) === `a/b/f`
|
|
21
|
+
* getAbsolutePath(`a/b/c`, `../../..`) === `.`
|
|
22
|
+
* getAbsolutePath(`C:/a/b`, `../d`) === `C:/a/d`
|
|
23
|
+
* getAbsolutePath(`a/b/c`, `../../../..`) === ERROR
|
|
24
|
+
*
|
|
25
|
+
* // Degenerate cases:
|
|
26
|
+
* getAbsolutePath(`a/b/c/`, `d/`) === `a/b/c/d` // trailing slashes are discarded
|
|
27
|
+
* getAbsolutePath(`./../c`, `d`) === `./../c/d` // basePath assumed to be normal form
|
|
28
|
+
* getAbsolutePath(`C:\\`, `\\a`) === `C:\\/\\a` // backslashes not supported
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function getAbsolute(basePath: string, relativePath: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the two parts joined by exactly one `/`, assuming the parts are already
|
|
34
|
+
* in normalized form. The `/` is not added if either part is an empty string.
|
|
35
|
+
*/
|
|
36
|
+
export declare function join(leftPart: string, rightPart: string): string;
|
|
37
|
+
//# sourceMappingURL=lockfilePath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lockfilePath.d.ts","sourceRoot":"","sources":["../../src/graph/lockfilePath.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAa1D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAgBxD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAiC1E;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAkBhE"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.getBaseNameOf = getBaseNameOf;
|
|
6
|
+
exports.getParentOf = getParentOf;
|
|
7
|
+
exports.getAbsolute = getAbsolute;
|
|
8
|
+
exports.join = join;
|
|
9
|
+
/**
|
|
10
|
+
* For example, retrieves `d` from `/a/b/c/d`.
|
|
11
|
+
*/
|
|
12
|
+
function getBaseNameOf(importerPath) {
|
|
13
|
+
if (importerPath.length === 0) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
const index = importerPath.lastIndexOf('/');
|
|
17
|
+
if (index === importerPath.length - 1) {
|
|
18
|
+
throw new Error('Error: Path has a trailing slash');
|
|
19
|
+
}
|
|
20
|
+
if (index >= 0) {
|
|
21
|
+
return importerPath.substring(index + 1);
|
|
22
|
+
}
|
|
23
|
+
return importerPath;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* For example, retrieves `/a/b/c` from `/a/b/c/d`.
|
|
27
|
+
*/
|
|
28
|
+
function getParentOf(importerPath) {
|
|
29
|
+
if (importerPath === '' || importerPath === '.' || importerPath === '/') {
|
|
30
|
+
throw new Error('Error: Path has no parent');
|
|
31
|
+
}
|
|
32
|
+
const index = importerPath.lastIndexOf('/');
|
|
33
|
+
if (index === importerPath.length - 1) {
|
|
34
|
+
throw new Error('Error: Path has a trailing slash');
|
|
35
|
+
}
|
|
36
|
+
if (index === 0) {
|
|
37
|
+
return '/';
|
|
38
|
+
}
|
|
39
|
+
if (index < 0) {
|
|
40
|
+
return '.';
|
|
41
|
+
}
|
|
42
|
+
return importerPath.substring(0, index);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Cheaply resolves a relative path against a base path, assuming the paths are delimited by `/`,
|
|
46
|
+
* and assuming the basePath is already in normal form. An error occurs if the relative path
|
|
47
|
+
* goes above the root folder.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* getAbsolutePath(`a/b/c`, `d/e`) === `a/b/c/d/e`
|
|
52
|
+
* getAbsolutePath(`/a/b/c`, `d/e`) === `/a/b/c/d/e`
|
|
53
|
+
* getAbsolutePath(`/a/b/c`, `/d/e`) === `/d/e`
|
|
54
|
+
* getAbsolutePath(`a/b/c`, `../../f`) === `a/f`
|
|
55
|
+
* getAbsolutePath(`a/b/c`, `.././/f`) === `a/b/f`
|
|
56
|
+
* getAbsolutePath(`a/b/c`, `../../..`) === `.`
|
|
57
|
+
* getAbsolutePath(`C:/a/b`, `../d`) === `C:/a/d`
|
|
58
|
+
* getAbsolutePath(`a/b/c`, `../../../..`) === ERROR
|
|
59
|
+
*
|
|
60
|
+
* // Degenerate cases:
|
|
61
|
+
* getAbsolutePath(`a/b/c/`, `d/`) === `a/b/c/d` // trailing slashes are discarded
|
|
62
|
+
* getAbsolutePath(`./../c`, `d`) === `./../c/d` // basePath assumed to be normal form
|
|
63
|
+
* getAbsolutePath(`C:\\`, `\\a`) === `C:\\/\\a` // backslashes not supported
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
function getAbsolute(basePath, relativePath) {
|
|
67
|
+
let leadingSlash;
|
|
68
|
+
let stack;
|
|
69
|
+
// Discard intermediary slashes
|
|
70
|
+
const relativeParts = relativePath.split('/').filter((part) => part.length > 0);
|
|
71
|
+
if (relativePath.startsWith('/')) {
|
|
72
|
+
stack = [];
|
|
73
|
+
leadingSlash = true;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// Discard intermediary slashes
|
|
77
|
+
stack = basePath.split('/').filter((part) => part.length > 0);
|
|
78
|
+
leadingSlash = basePath.startsWith('/');
|
|
79
|
+
}
|
|
80
|
+
for (const part of relativeParts) {
|
|
81
|
+
if (part === '.') {
|
|
82
|
+
// current directory, do nothing
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
else if (part === '..') {
|
|
86
|
+
if (stack.length === 0) {
|
|
87
|
+
throw new Error('getAbsolutePath(): relativePath goes above the root folder');
|
|
88
|
+
}
|
|
89
|
+
stack.pop();
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
stack.push(part);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (leadingSlash) {
|
|
96
|
+
return '/' + stack.join('/');
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
return stack.length === 0 ? '.' : stack.join('/');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns the two parts joined by exactly one `/`, assuming the parts are already
|
|
104
|
+
* in normalized form. The `/` is not added if either part is an empty string.
|
|
105
|
+
*/
|
|
106
|
+
function join(leftPart, rightPart) {
|
|
107
|
+
if (leftPart.length === 0) {
|
|
108
|
+
return rightPart;
|
|
109
|
+
}
|
|
110
|
+
if (rightPart.length === 0) {
|
|
111
|
+
return leftPart;
|
|
112
|
+
}
|
|
113
|
+
const leftEndsWithSlash = leftPart[leftPart.length - 1] === '/';
|
|
114
|
+
const rightStartsWithSlash = rightPart[0] === '/';
|
|
115
|
+
if (leftEndsWithSlash && rightStartsWithSlash) {
|
|
116
|
+
return leftPart + rightPart.substring(1);
|
|
117
|
+
}
|
|
118
|
+
if (leftEndsWithSlash || rightStartsWithSlash) {
|
|
119
|
+
return leftPart + rightPart;
|
|
120
|
+
}
|
|
121
|
+
return leftPart + '/' + rightPart;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=lockfilePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lockfilePath.js","sourceRoot":"","sources":["../../src/graph/lockfilePath.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAK3D,sCAaC;AAKD,kCAgBC;AAwBD,kCAiCC;AAMD,oBAkBC;AAtHD;;GAEG;AACH,SAAgB,aAAa,CAAC,YAAoB;IAChD,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAW,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACpD,IAAI,KAAK,KAAK,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QACf,OAAO,YAAY,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,YAAoB;IAC9C,IAAI,YAAY,KAAK,EAAE,IAAI,YAAY,KAAK,GAAG,IAAI,YAAY,KAAK,GAAG,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,KAAK,GAAW,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACpD,IAAI,KAAK,KAAK,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAA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G,EAAE,CAAC;QACd,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IACD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,IAAI,CAAC,QAAgB,EAAE,SAAiB;IACtD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,iBAAiB,GAAY,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;IACzE,MAAM,oBAAoB,GAAY,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;IAE3D,IAAI,iBAAiB,IAAI,oBAAoB,EAAE,CAAC;QAC9C,OAAO,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,iBAAiB,IAAI,oBAAoB,EAAE,CAAC;QAC9C,OAAO,QAAQ,GAAG,SAAS,CAAC;IAC9B,CAAC;IACD,OAAO,QAAQ,GAAG,GAAG,GAAG,SAAS,CAAC;AACpC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * For example, retrieves `d` from `/a/b/c/d`.\n */\nexport function getBaseNameOf(importerPath: string): string {\n if (importerPath.length === 0) {\n return '';\n }\n\n const index: number = importerPath.lastIndexOf('/');\n if (index === importerPath.length - 1) {\n throw new Error('Error: Path has a trailing slash');\n }\n if (index >= 0) {\n return importerPath.substring(index + 1);\n }\n return importerPath;\n}\n\n/**\n * For example, retrieves `/a/b/c` from `/a/b/c/d`.\n */\nexport function getParentOf(importerPath: string): string {\n if (importerPath === '' || importerPath === '.' || importerPath === '/') {\n throw new Error('Error: Path has no parent');\n }\n\n const index: number = importerPath.lastIndexOf('/');\n if (index === importerPath.length - 1) {\n throw new Error('Error: Path has a trailing slash');\n }\n if (index === 0) {\n return '/';\n }\n if (index < 0) {\n return '.';\n }\n return importerPath.substring(0, index);\n}\n\n/**\n * Cheaply resolves a relative path against a base path, assuming the paths are delimited by `/`,\n * and assuming the basePath is already in normal form. An error occurs if the relative path\n * goes above the root folder.\n *\n * @example\n * ```ts\n * getAbsolutePath(`a/b/c`, `d/e`) === `a/b/c/d/e`\n * getAbsolutePath(`/a/b/c`, `d/e`) === `/a/b/c/d/e`\n * getAbsolutePath(`/a/b/c`, `/d/e`) === `/d/e`\n * getAbsolutePath(`a/b/c`, `../../f`) === `a/f`\n * getAbsolutePath(`a/b/c`, `.././/f`) === `a/b/f`\n * getAbsolutePath(`a/b/c`, `../../..`) === `.`\n * getAbsolutePath(`C:/a/b`, `../d`) === `C:/a/d`\n * getAbsolutePath(`a/b/c`, `../../../..`) === ERROR\n *\n * // Degenerate cases:\n * getAbsolutePath(`a/b/c/`, `d/`) === `a/b/c/d` // trailing slashes are discarded\n * getAbsolutePath(`./../c`, `d`) === `./../c/d` // basePath assumed to be normal form\n * getAbsolutePath(`C:\\\\`, `\\\\a`) === `C:\\\\/\\\\a` // backslashes not supported\n * ```\n */\nexport function getAbsolute(basePath: string, relativePath: string): string {\n let leadingSlash: boolean;\n let stack: string[];\n\n // Discard intermediary slashes\n const relativeParts: string[] = relativePath.split('/').filter((part: string) => part.length > 0);\n if (relativePath.startsWith('/')) {\n stack = [];\n leadingSlash = true;\n } else {\n // Discard intermediary slashes\n stack = basePath.split('/').filter((part: string) => part.length > 0);\n leadingSlash = basePath.startsWith('/');\n }\n\n for (const part of relativeParts) {\n if (part === '.') {\n // current directory, do nothing\n continue;\n } else if (part === '..') {\n if (stack.length === 0) {\n throw new Error('getAbsolutePath(): relativePath goes above the root folder');\n }\n stack.pop();\n } else {\n stack.push(part);\n }\n }\n if (leadingSlash) {\n return '/' + stack.join('/');\n } else {\n return stack.length === 0 ? '.' : stack.join('/');\n }\n}\n\n/**\n * Returns the two parts joined by exactly one `/`, assuming the parts are already\n * in normalized form. The `/` is not added if either part is an empty string.\n */\nexport function join(leftPart: string, rightPart: string): string {\n if (leftPart.length === 0) {\n return rightPart;\n }\n if (rightPart.length === 0) {\n return leftPart;\n }\n\n const leftEndsWithSlash: boolean = leftPart[leftPart.length - 1] === '/';\n const rightStartsWithSlash: boolean = rightPart[0] === '/';\n\n if (leftEndsWithSlash && rightStartsWithSlash) {\n return leftPart + rightPart.substring(1);\n }\n if (leftEndsWithSlash || rightStartsWithSlash) {\n return leftPart + rightPart;\n }\n return leftPart + '/' + rightPart;\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IPackageJson } from '@rushstack/node-core-library';
|
|
2
|
+
export interface IRequestMessage {
|
|
3
|
+
id: number;
|
|
4
|
+
packageJson: IPackageJson;
|
|
5
|
+
packageJsonFullPath: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IResponseMessageLog {
|
|
8
|
+
kind: 'log';
|
|
9
|
+
id: number;
|
|
10
|
+
log: string;
|
|
11
|
+
}
|
|
12
|
+
export interface IResponseMessageError {
|
|
13
|
+
kind: 'error';
|
|
14
|
+
id: number;
|
|
15
|
+
error: string;
|
|
16
|
+
}
|
|
17
|
+
export interface IResponseMessageReturn {
|
|
18
|
+
kind: 'return';
|
|
19
|
+
id: number;
|
|
20
|
+
result?: unknown;
|
|
21
|
+
}
|
|
22
|
+
export type ResponseMessage = IResponseMessageLog | IResponseMessageError | IResponseMessageReturn;
|
|
23
|
+
//# sourceMappingURL=pnpmfileRunnerWorkerThread.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnpmfileRunnerWorkerThread.d.ts","sourceRoot":"","sources":["../../src/graph/pnpmfileRunnerWorkerThread.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAIjE,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,YAAY,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,KAAK,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AACD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AACD,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
|
+
// debugger;
|
|
41
|
+
const { pnpmfilePath } = node_worker_threads_1.workerData;
|
|
42
|
+
const resolvedPath = path.resolve(pnpmfilePath);
|
|
43
|
+
let pnpmfileModule = undefined;
|
|
44
|
+
let pnpmfileModuleError = undefined;
|
|
45
|
+
try {
|
|
46
|
+
pnpmfileModule = require(resolvedPath);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
pnpmfileModuleError = error;
|
|
50
|
+
}
|
|
51
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
|
52
|
+
const threadParentPort = node_worker_threads_1.parentPort;
|
|
53
|
+
if (!threadParentPort) {
|
|
54
|
+
throw new Error('Not running in a worker thread');
|
|
55
|
+
}
|
|
56
|
+
threadParentPort.on('message', async (message) => {
|
|
57
|
+
const { id, packageJson } = message;
|
|
58
|
+
if (pnpmfileModuleError) {
|
|
59
|
+
threadParentPort.postMessage({
|
|
60
|
+
kind: 'error',
|
|
61
|
+
id,
|
|
62
|
+
error: pnpmfileModuleError.message
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
if (!pnpmfileModule || !pnpmfileModule.hooks || typeof pnpmfileModule.hooks.readPackage !== 'function') {
|
|
68
|
+
// No transformation needed
|
|
69
|
+
threadParentPort.postMessage({
|
|
70
|
+
kind: 'return',
|
|
71
|
+
id,
|
|
72
|
+
result: packageJson
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const pnpmContext = {
|
|
77
|
+
log: (logMessage) => threadParentPort.postMessage({
|
|
78
|
+
kind: 'log',
|
|
79
|
+
id,
|
|
80
|
+
log: logMessage
|
|
81
|
+
})
|
|
82
|
+
};
|
|
83
|
+
const result = await pnpmfileModule.hooks.readPackage({ ...packageJson }, pnpmContext);
|
|
84
|
+
threadParentPort.postMessage({ kind: 'return', id, result });
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
threadParentPort.postMessage({
|
|
88
|
+
kind: 'error',
|
|
89
|
+
id,
|
|
90
|
+
error: e.message
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=pnpmfileRunnerWorkerThread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnpmfileRunnerWorkerThread.js","sourceRoot":"","sources":["../../src/graph/pnpmfileRunnerWorkerThread.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;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,EAAE,EAAE,CAClB,gBAAgB,CAAC,WAAW,CAAC;gBAC3B,IAAI,EAAE,KAAK;gBACX,EAAE;gBACF,GAAG,EAAE,UAAU;aACc,CAAC;SACnC,CAAC;QAEF,MAAM,MAAM,GAAiB,MAAM,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,GAAG,WAAW,EAAE,EAAE,WAAW,CAAC,CAAC;QAErG,gBAAgB,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAmC,CAAC,CAAC;IAChG,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,gBAAgB,CAAC,WAAW,CAAC;YAC3B,IAAI,EAAE,OAAO;YACb,EAAE;YACF,KAAK,EAAG,CAAW,CAAC,OAAO;SACI,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { parentPort, workerData, type MessagePort } from 'node:worker_threads';\nimport * as path from 'node:path';\nimport type { IPackageJson } from '@rushstack/node-core-library';\n\nimport type { IPnpmfileModule, IReadPackageContext } from './IPnpmfileModule';\n\nexport interface IRequestMessage {\n id: number;\n packageJson: IPackageJson;\n packageJsonFullPath: string;\n}\n\nexport interface IResponseMessageLog {\n kind: 'log';\n id: number;\n log: string;\n}\nexport interface IResponseMessageError {\n kind: 'error';\n id: number;\n error: string;\n}\nexport interface IResponseMessageReturn {\n kind: 'return';\n id: number;\n result?: unknown;\n}\nexport type ResponseMessage = IResponseMessageLog | IResponseMessageError | IResponseMessageReturn;\n\n// debugger;\n\nconst { pnpmfilePath } = workerData;\nconst resolvedPath: string = path.resolve(pnpmfilePath);\n\nlet pnpmfileModule: IPnpmfileModule | undefined = undefined;\nlet pnpmfileModuleError: Error | undefined = undefined;\n\ntry {\n pnpmfileModule = require(resolvedPath);\n} catch (error) {\n pnpmfileModuleError = error;\n}\n\n// eslint-disable-next-line @rushstack/no-new-null\nconst threadParentPort: null | MessagePort = parentPort;\n\nif (!threadParentPort) {\n throw new Error('Not running in a worker thread');\n}\n\nthreadParentPort.on('message', async (message: IRequestMessage) => {\n const { id, packageJson } = message;\n\n if (pnpmfileModuleError) {\n threadParentPort.postMessage({\n kind: 'error',\n id,\n error: pnpmfileModuleError.message\n } satisfies IResponseMessageError);\n return;\n }\n\n try {\n if (!pnpmfileModule || !pnpmfileModule.hooks || typeof pnpmfileModule.hooks.readPackage !== 'function') {\n // No transformation needed\n threadParentPort.postMessage({\n kind: 'return',\n id,\n result: packageJson\n } satisfies IResponseMessageReturn);\n return;\n }\n\n const pnpmContext: IReadPackageContext = {\n log: (logMessage) =>\n threadParentPort.postMessage({\n kind: 'log',\n id,\n log: logMessage\n } satisfies IResponseMessageLog)\n };\n\n const result: IPackageJson = await pnpmfileModule.hooks.readPackage({ ...packageJson }, pnpmContext);\n\n threadParentPort.postMessage({ kind: 'return', id, result } satisfies IResponseMessageReturn);\n } catch (e) {\n threadParentPort.postMessage({\n kind: 'error',\n id,\n error: (e as Error).message\n } satisfies IResponseMessageError);\n }\n});\n"]}
|
package/lib/state/index.d.ts
CHANGED
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
PNPM_WORKSPACE = 1
|
|
4
|
-
}
|
|
5
|
-
export interface IRushProjectDetails {
|
|
6
|
-
projectName: string;
|
|
7
|
-
projectFolder: string;
|
|
8
|
-
}
|
|
9
|
-
export interface IAppStateBase {
|
|
1
|
+
import type { IJsonLfxWorkspace } from '../../build/lfx-shared';
|
|
2
|
+
export interface IAppState {
|
|
10
3
|
lockfileExplorerProjectRoot: string;
|
|
11
|
-
|
|
4
|
+
currentWorkingDirectory: string;
|
|
12
5
|
projectRoot: string;
|
|
13
|
-
projectType: ProjectType;
|
|
14
6
|
pnpmLockfileLocation: string;
|
|
15
7
|
pnpmfileLocation: string;
|
|
16
8
|
appVersion: string;
|
|
17
9
|
debugMode: boolean;
|
|
10
|
+
lfxWorkspace: IJsonLfxWorkspace;
|
|
18
11
|
}
|
|
19
|
-
export interface IRushAppState extends IAppStateBase {
|
|
20
|
-
projectType: ProjectType.RUSH_PROJECT;
|
|
21
|
-
rush: {
|
|
22
|
-
rushJsonPath: string;
|
|
23
|
-
projectsByProjectFolder: Map<string, IRushProjectDetails>;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export interface IPnpmWorkspaceAppState extends IAppStateBase {
|
|
27
|
-
projectType: ProjectType.PNPM_WORKSPACE;
|
|
28
|
-
}
|
|
29
|
-
export type IAppState = IRushAppState | IPnpmWorkspaceAppState;
|
|
30
12
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/state/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,WAAW,SAAS;IACxB,2BAA2B,EAAE,MAAM,CAAC;IACpC,uBAAuB,EAAE,MAAM,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,iBAAiB,CAAC;CACjC"}
|
package/lib/state/index.js
CHANGED
|
@@ -2,10 +2,4 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.ProjectType = void 0;
|
|
6
|
-
var ProjectType;
|
|
7
|
-
(function (ProjectType) {
|
|
8
|
-
ProjectType[ProjectType["RUSH_PROJECT"] = 0] = "RUSH_PROJECT";
|
|
9
|
-
ProjectType[ProjectType["PNPM_WORKSPACE"] = 1] = "PNPM_WORKSPACE";
|
|
10
|
-
})(ProjectType || (exports.ProjectType = ProjectType = {}));
|
|
11
5
|
//# sourceMappingURL=index.js.map
|
package/lib/state/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { IJsonLfxWorkspace } from '../../build/lfx-shared';\n\nexport interface IAppState {\n lockfileExplorerProjectRoot: string;\n currentWorkingDirectory: string;\n projectRoot: string;\n pnpmLockfileLocation: string;\n pnpmfileLocation: string;\n appVersion: string;\n debugMode: boolean;\n lfxWorkspace: IJsonLfxWorkspace;\n}\n"]}
|
package/lib/utils/init.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IAppState } from '../state';
|
|
2
2
|
export declare const init: (options: {
|
|
3
3
|
lockfileExplorerProjectRoot: string;
|
|
4
4
|
appVersion: string;
|
|
5
5
|
debugMode: boolean;
|
|
6
6
|
subspaceName: string;
|
|
7
|
-
}) => IAppState
|
|
7
|
+
}) => Omit<IAppState, "graph">;
|
|
8
8
|
//# sourceMappingURL=init.d.ts.map
|
package/lib/utils/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/utils/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/utils/init.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,eAAO,MAAM,IAAI,GAAI,SAAS;IAC5B,2BAA2B,EAAE,MAAM,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB,KAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CA+E1B,CAAC"}
|
package/lib/utils/init.js
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
4
37
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
38
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
39
|
};
|
|
@@ -11,58 +44,69 @@ exports.init = void 0;
|
|
|
11
44
|
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
12
45
|
const RushConfiguration_1 = require("@microsoft/rush-lib/lib/api/RushConfiguration");
|
|
13
46
|
const path_1 = __importDefault(require("path"));
|
|
14
|
-
const
|
|
47
|
+
const lockfilePath = __importStar(require("../graph/lockfilePath"));
|
|
15
48
|
const init = (options) => {
|
|
16
49
|
const { lockfileExplorerProjectRoot, appVersion, debugMode, subspaceName } = options;
|
|
17
|
-
const
|
|
50
|
+
const currentWorkingDirectory = path_1.default.resolve(process.cwd());
|
|
18
51
|
let appState;
|
|
19
|
-
let
|
|
20
|
-
while (
|
|
52
|
+
let currentFolder = node_core_library_1.Path.convertToSlashes(currentWorkingDirectory);
|
|
53
|
+
while (currentFolder.includes('/')) {
|
|
21
54
|
// Look for a rush.json [rush project] or pnpm-lock.yaml file [regular pnpm workspace]
|
|
22
|
-
const rushJsonPath =
|
|
23
|
-
const pnpmLockPath =
|
|
55
|
+
const rushJsonPath = currentFolder + '/rush.json';
|
|
56
|
+
const pnpmLockPath = currentFolder + '/pnpm-lock.yaml';
|
|
24
57
|
if (node_core_library_1.FileSystem.exists(rushJsonPath)) {
|
|
25
58
|
console.log('Found a Rush workspace: ', rushJsonPath);
|
|
26
|
-
const rushConfiguration = RushConfiguration_1.RushConfiguration.
|
|
59
|
+
const rushConfiguration = RushConfiguration_1.RushConfiguration.loadFromConfigurationFile(rushJsonPath);
|
|
27
60
|
const subspace = rushConfiguration.getSubspace(subspaceName);
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
61
|
+
const commonTempFolder = subspace.getSubspaceTempFolderPath();
|
|
62
|
+
const pnpmLockfileAbsolutePath = path_1.default.join(commonTempFolder, 'pnpm-lock.yaml');
|
|
63
|
+
const relativeCommonTempFolder = node_core_library_1.Path.convertToSlashes(path_1.default.relative(currentFolder, subspace.getSubspaceTempFolderPath()));
|
|
64
|
+
const pnpmLockfileRelativePath = lockfilePath.join(relativeCommonTempFolder, 'pnpm-lock.yaml');
|
|
65
|
+
const pnpmFileRelativePath = lockfilePath.join(relativeCommonTempFolder, '.pnpmfile.cjs');
|
|
66
|
+
const relativeCommonConfigFolder = node_core_library_1.Path.convertToSlashes(path_1.default.relative(currentFolder, subspace.getSubspaceConfigFolderPath()));
|
|
67
|
+
const rushPnpmFileRelativePath = lockfilePath.join(relativeCommonConfigFolder, '.pnpmfile.cjs');
|
|
36
68
|
appState = {
|
|
37
|
-
|
|
69
|
+
currentWorkingDirectory,
|
|
38
70
|
appVersion,
|
|
39
71
|
debugMode,
|
|
40
72
|
lockfileExplorerProjectRoot,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
73
|
+
pnpmLockfileLocation: pnpmLockfileAbsolutePath,
|
|
74
|
+
pnpmfileLocation: commonTempFolder + '/.pnpmfile.cjs',
|
|
75
|
+
projectRoot: currentFolder,
|
|
76
|
+
lfxWorkspace: {
|
|
77
|
+
workspaceRootFullPath: currentFolder,
|
|
78
|
+
pnpmLockfilePath: node_core_library_1.Path.convertToSlashes(pnpmLockfileRelativePath),
|
|
79
|
+
pnpmLockfileFolder: node_core_library_1.Path.convertToSlashes(path_1.default.dirname(pnpmLockfileRelativePath)),
|
|
80
|
+
pnpmfilePath: node_core_library_1.Path.convertToSlashes(pnpmFileRelativePath),
|
|
81
|
+
rushConfig: {
|
|
82
|
+
rushVersion: rushConfiguration.rushConfigurationJson.rushVersion,
|
|
83
|
+
subspaceName: subspaceName !== null && subspaceName !== void 0 ? subspaceName : '',
|
|
84
|
+
rushPnpmfilePath: rushPnpmFileRelativePath
|
|
85
|
+
}
|
|
48
86
|
}
|
|
49
87
|
};
|
|
50
88
|
break;
|
|
51
89
|
}
|
|
52
90
|
else if (node_core_library_1.FileSystem.exists(pnpmLockPath)) {
|
|
53
91
|
appState = {
|
|
54
|
-
|
|
92
|
+
currentWorkingDirectory,
|
|
55
93
|
appVersion,
|
|
56
94
|
debugMode,
|
|
57
95
|
lockfileExplorerProjectRoot,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
96
|
+
pnpmLockfileLocation: currentFolder + '/pnpm-lock.yaml',
|
|
97
|
+
pnpmfileLocation: currentFolder + '/.pnpmfile.cjs',
|
|
98
|
+
projectRoot: currentFolder,
|
|
99
|
+
lfxWorkspace: {
|
|
100
|
+
workspaceRootFullPath: currentFolder,
|
|
101
|
+
pnpmLockfilePath: node_core_library_1.Path.convertToSlashes(path_1.default.relative(currentFolder, pnpmLockPath)),
|
|
102
|
+
pnpmLockfileFolder: '',
|
|
103
|
+
pnpmfilePath: '.pnpmfile.cjs',
|
|
104
|
+
rushConfig: undefined
|
|
105
|
+
}
|
|
62
106
|
};
|
|
63
107
|
break;
|
|
64
108
|
}
|
|
65
|
-
|
|
109
|
+
currentFolder = currentFolder.substring(0, currentFolder.lastIndexOf('/'));
|
|
66
110
|
}
|
|
67
111
|
if (!appState) {
|
|
68
112
|
throw new Error('Could not find a Rush or PNPM workspace!');
|
package/lib/utils/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/utils/init.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/utils/init.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,uHAAuH;AACvH,6DAA6D;AAE7D,oEAAgE;AAChE,qFAAkF;AAElF,gDAAwB;AAExB,oEAAsD;AAG/C,MAAM,IAAI,GAAG,CAAC,OAKpB,EAA4B,EAAE;IAC7B,MAAM,EAAE,2BAA2B,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACrF,MAAM,uBAAuB,GAAW,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAEpE,IAAI,QAA+B,CAAC;IACpC,IAAI,aAAa,GAAW,wBAAI,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;IAC3E,OAAO,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,sFAAsF;QACtF,MAAM,YAAY,GAAW,aAAa,GAAG,YAAY,CAAC;QAC1D,MAAM,YAAY,GAAW,aAAa,GAAG,iBAAiB,CAAC;QAC/D,IAAI,8BAAU,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,YAAY,CAAC,CAAC;YAEtD,MAAM,iBAAiB,GAAsB,qCAAiB,CAAC,yBAAyB,CAAC,YAAY,CAAC,CAAC;YACvG,MAAM,QAAQ,GAAa,iBAAiB,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;YACvE,MAAM,gBAAgB,GAAW,QAAQ,CAAC,yBAAyB,EAAE,CAAC;YACtE,MAAM,wBAAwB,GAAW,cAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,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CAAC,EAAE,CAAC;YAC3C,QAAQ,GAAG;gBACT,uBAAuB;gBACvB,UAAU;gBACV,SAAS;gBACT,2BAA2B;gBAC3B,oBAAoB,EAAE,aAAa,GAAG,iBAAiB;gBACvD,gBAAgB,EAAE,aAAa,GAAG,gBAAgB;gBAClD,WAAW,EAAE,aAAa;gBAC1B,YAAY,EAAE;oBACZ,qBAAqB,EAAE,aAAa;oBACpC,gBAAgB,EAAE,wBAAI,CAAC,gBAAgB,CAAC,cAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;oBACnF,kBAAkB,EAAE,EAAE;oBACtB,YAAY,EAAE,eAAe;oBAC7B,UAAU,EAAE,SAAS;iBACtB;aACF,CAAC;YAEF,MAAM;QACR,CAAC;QAED,aAAa,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AApFW,QAAA,IAAI,QAoFf","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n// This function will read the current directory and try to figure out if it's a rush project or regular pnpm workspace\n// Currently it will throw error if neither can be determined\n\nimport { FileSystem, Path } from '@rushstack/node-core-library';\nimport { RushConfiguration } from '@microsoft/rush-lib/lib/api/RushConfiguration';\nimport type { Subspace } from '@microsoft/rush-lib/lib/api/Subspace';\nimport path from 'path';\n\nimport * as lockfilePath from '../graph/lockfilePath';\nimport type { IAppState } from '../state';\n\nexport const init = (options: {\n lockfileExplorerProjectRoot: string;\n appVersion: string;\n debugMode: boolean;\n subspaceName: string;\n}): Omit<IAppState, 'graph'> => {\n const { lockfileExplorerProjectRoot, appVersion, debugMode, subspaceName } = options;\n const currentWorkingDirectory: string = path.resolve(process.cwd());\n\n let appState: IAppState | undefined;\n let currentFolder: string = Path.convertToSlashes(currentWorkingDirectory);\n while (currentFolder.includes('/')) {\n // Look for a rush.json [rush project] or pnpm-lock.yaml file [regular pnpm workspace]\n const rushJsonPath: string = currentFolder + '/rush.json';\n const pnpmLockPath: string = currentFolder + '/pnpm-lock.yaml';\n if (FileSystem.exists(rushJsonPath)) {\n console.log('Found a Rush workspace: ', rushJsonPath);\n\n const rushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile(rushJsonPath);\n const subspace: Subspace = rushConfiguration.getSubspace(subspaceName);\n const commonTempFolder: string = subspace.getSubspaceTempFolderPath();\n const pnpmLockfileAbsolutePath: string = path.join(commonTempFolder, 'pnpm-lock.yaml');\n\n const relativeCommonTempFolder: string = Path.convertToSlashes(\n path.relative(currentFolder, subspace.getSubspaceTempFolderPath())\n );\n const pnpmLockfileRelativePath: string = lockfilePath.join(relativeCommonTempFolder, 'pnpm-lock.yaml');\n const pnpmFileRelativePath: string = lockfilePath.join(relativeCommonTempFolder, '.pnpmfile.cjs');\n\n const relativeCommonConfigFolder: string = Path.convertToSlashes(\n path.relative(currentFolder, subspace.getSubspaceConfigFolderPath())\n );\n const rushPnpmFileRelativePath: string = lockfilePath.join(relativeCommonConfigFolder, '.pnpmfile.cjs');\n\n appState = {\n currentWorkingDirectory,\n appVersion,\n debugMode,\n lockfileExplorerProjectRoot,\n pnpmLockfileLocation: pnpmLockfileAbsolutePath,\n pnpmfileLocation: commonTempFolder + '/.pnpmfile.cjs',\n projectRoot: currentFolder,\n lfxWorkspace: {\n workspaceRootFullPath: currentFolder,\n pnpmLockfilePath: Path.convertToSlashes(pnpmLockfileRelativePath),\n pnpmLockfileFolder: Path.convertToSlashes(path.dirname(pnpmLockfileRelativePath)),\n pnpmfilePath: Path.convertToSlashes(pnpmFileRelativePath),\n rushConfig: {\n rushVersion: rushConfiguration.rushConfigurationJson.rushVersion,\n subspaceName: subspaceName ?? '',\n rushPnpmfilePath: rushPnpmFileRelativePath\n }\n }\n };\n break;\n } else if (FileSystem.exists(pnpmLockPath)) {\n appState = {\n currentWorkingDirectory,\n appVersion,\n debugMode,\n lockfileExplorerProjectRoot,\n pnpmLockfileLocation: currentFolder + '/pnpm-lock.yaml',\n pnpmfileLocation: currentFolder + '/.pnpmfile.cjs',\n projectRoot: currentFolder,\n lfxWorkspace: {\n workspaceRootFullPath: currentFolder,\n pnpmLockfilePath: Path.convertToSlashes(path.relative(currentFolder, pnpmLockPath)),\n pnpmLockfileFolder: '',\n pnpmfilePath: '.pnpmfile.cjs',\n rushConfig: undefined\n }\n };\n\n break;\n }\n\n currentFolder = currentFolder.substring(0, currentFolder.lastIndexOf('/'));\n }\n\n if (!appState) {\n throw new Error('Could not find a Rush or PNPM workspace!');\n }\n\n return appState;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shrinkwrap.d.ts","sourceRoot":"","sources":["../../src/utils/shrinkwrap.ts"],"names":[],"mappings":"AAKA,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,mCAAmC,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"shrinkwrap.d.ts","sourceRoot":"","sources":["../../src/utils/shrinkwrap.ts"],"names":[],"mappings":"AAKA,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,mCAAmC,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAM9E;AAED,wBAAgB,mBAAmB,CAAC,0BAA0B,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,YAAY,CAYxG;AAED,wBAAgB,6BAA6B,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAmBtF;AAED,wBAAgB,wBAAwB,CACtC,0BAA0B,EAAE,MAAM,EAClC,qBAAqB,EAAE,MAAM,EAC7B,wBAAwB,EAAE,MAAM,GAC/B,MAAM,CAIR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shrinkwrap.js","sourceRoot":"","sources":["../../src/utils/shrinkwrap.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAU3D,
|
|
1
|
+
{"version":3,"file":"shrinkwrap.js","sourceRoot":"","sources":["../../src/utils/shrinkwrap.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAU3D,kFAMC;AAED,kDAYC;AAED,sEAmBC;AAED,4DAQC;AA3DD,mGAAqF;AAQrF,SAAgB,mCAAmC,CAAC,UAAkB;IACpE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,UAAU,CAAC;IACtF,MAAM,KAAK,GAAW,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5E,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,GAAG,2BAA2B,CAAC,kBAAkB,CAAC,UAAU,CAAC;QAChG,OAAO,UAAU,CAAC;IACpB,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;AAChF,CAAC;AAED,SAAgB,mBAAmB,CAAC,0BAAkC,EAAE,UAAkB;IACxF,IAAI,cAAc,GAAW,UAAU,C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EAAE,CAAC;AAChC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as dependencyPathLockfilePreV9 from '@pnpm/dependency-path-lockfile-pre-v9';\n\ninterface IPackageInfo {\n name: string;\n peersSuffix: string | undefined;\n version: string;\n}\n\nexport function convertLockfileV6DepPathToV5DepPath(newDepPath: string): string {\n if (!newDepPath.includes('@', 2) || newDepPath.startsWith('file:')) return newDepPath;\n const index: number = newDepPath.indexOf('@', newDepPath.indexOf('/@') + 2);\n if (newDepPath.includes('(') && index > dependencyPathLockfilePreV9.indexOfPeersSuffix(newDepPath))\n return newDepPath;\n return `${newDepPath.substring(0, index)}/${newDepPath.substring(index + 1)}`;\n}\n\nexport function parseDependencyPath(shrinkwrapFileMajorVersion: number, newDepPath: string): IPackageInfo {\n let dependencyPath: string = newDepPath;\n if (shrinkwrapFileMajorVersion === 6) {\n dependencyPath = convertLockfileV6DepPathToV5DepPath(newDepPath);\n }\n const packageInfo: ReturnType<typeof dependencyPathLockfilePreV9.parse> =\n dependencyPathLockfilePreV9.parse(dependencyPath);\n return {\n name: packageInfo.name as string,\n peersSuffix: packageInfo.peersSuffix,\n version: packageInfo.version as string\n };\n}\n\nexport function getShrinkwrapFileMajorVersion(lockfileVersion: string | number): number {\n let shrinkwrapFileMajorVersion: number;\n if (typeof lockfileVersion === 'string') {\n const isDotIncluded: boolean = lockfileVersion.includes('.');\n shrinkwrapFileMajorVersion = parseInt(\n lockfileVersion.substring(0, isDotIncluded ? lockfileVersion.indexOf('.') : undefined),\n 10\n );\n } else if (typeof lockfileVersion === 'number') {\n shrinkwrapFileMajorVersion = Math.floor(lockfileVersion);\n } else {\n shrinkwrapFileMajorVersion = 0;\n }\n\n if (shrinkwrapFileMajorVersion < 5 || shrinkwrapFileMajorVersion > 6) {\n throw new Error('The current lockfile version is not supported.');\n }\n\n return shrinkwrapFileMajorVersion;\n}\n\nexport function splicePackageWithVersion(\n shrinkwrapFileMajorVersion: number,\n dependencyPackageName: string,\n dependencyPackageVersion: string\n): string {\n return `/${dependencyPackageName}${\n shrinkwrapFileMajorVersion === 6 ? '@' : '/'\n }${dependencyPackageVersion}`;\n}\n"]}
|