workspace-tools 0.32.0 → 0.34.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 +63 -1
- package/CHANGELOG.md +28 -2
- package/README.md +4 -0
- package/lib/getPackageInfos.js +37 -49
- package/lib/getPackageInfos.js.map +1 -1
- package/lib/getPackagePaths.d.ts +10 -2
- package/lib/getPackagePaths.js +32 -33
- package/lib/getPackagePaths.js.map +1 -1
- package/lib/index.d.ts +5 -4
- package/lib/index.js +12 -4
- package/lib/index.js.map +1 -1
- package/lib/lockfile/index.js +1 -1
- package/lib/lockfile/index.js.map +1 -1
- package/lib/logging.d.ts +5 -0
- package/lib/logging.js +15 -0
- package/lib/logging.js.map +1 -0
- package/lib/paths.js +7 -1
- package/lib/paths.js.map +1 -1
- package/lib/types/WorkspaceInfo.d.ts +7 -0
- package/lib/workspaces/findWorkspacePath.d.ts +7 -0
- package/lib/workspaces/findWorkspacePath.js +9 -4
- package/lib/workspaces/findWorkspacePath.js.map +1 -1
- package/lib/workspaces/{workspaces.d.ts → getAllPackageJsonFiles.d.ts} +5 -3
- package/lib/workspaces/getAllPackageJsonFiles.js +38 -0
- package/lib/workspaces/getAllPackageJsonFiles.js.map +1 -0
- package/lib/workspaces/getWorkspacePackageInfo.d.ts +22 -2
- package/lib/workspaces/getWorkspacePackageInfo.js +45 -28
- package/lib/workspaces/getWorkspacePackageInfo.js.map +1 -1
- package/lib/workspaces/getWorkspacePackagePaths.d.ts +10 -0
- package/lib/workspaces/getWorkspacePackagePaths.js +31 -0
- package/lib/workspaces/getWorkspacePackagePaths.js.map +1 -0
- package/lib/workspaces/getWorkspaceRoot.d.ts +8 -1
- package/lib/workspaces/getWorkspaceRoot.js +9 -18
- package/lib/workspaces/getWorkspaceRoot.js.map +1 -1
- package/lib/workspaces/getWorkspaces.d.ts +16 -0
- package/lib/workspaces/getWorkspaces.js +25 -28
- package/lib/workspaces/getWorkspaces.js.map +1 -1
- package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.d.ts +22 -0
- package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.js +63 -0
- package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.js.map +1 -0
- package/lib/workspaces/implementations/getWorkspaceUtilities.d.ts +26 -0
- package/lib/workspaces/implementations/getWorkspaceUtilities.js +26 -0
- package/lib/workspaces/implementations/getWorkspaceUtilities.js.map +1 -0
- package/lib/workspaces/implementations/index.d.ts +2 -14
- package/lib/workspaces/implementations/index.js +5 -55
- package/lib/workspaces/implementations/index.js.map +1 -1
- package/lib/workspaces/implementations/lerna.d.ts +8 -2
- package/lib/workspaces/implementations/lerna.js +29 -12
- package/lib/workspaces/implementations/lerna.js.map +1 -1
- package/lib/workspaces/implementations/npm.d.ts +14 -1
- package/lib/workspaces/implementations/npm.js +31 -8
- package/lib/workspaces/implementations/npm.js.map +1 -1
- package/lib/workspaces/implementations/packageJsonWorkspaces.d.ts +14 -1
- package/lib/workspaces/implementations/packageJsonWorkspaces.js +50 -24
- package/lib/workspaces/implementations/packageJsonWorkspaces.js.map +1 -1
- package/lib/workspaces/implementations/pnpm.d.ts +8 -0
- package/lib/workspaces/implementations/pnpm.js +30 -11
- package/lib/workspaces/implementations/pnpm.js.map +1 -1
- package/lib/workspaces/implementations/rush.d.ts +8 -0
- package/lib/workspaces/implementations/rush.js +30 -9
- package/lib/workspaces/implementations/rush.js.map +1 -1
- package/lib/workspaces/implementations/yarn.d.ts +15 -0
- package/lib/workspaces/implementations/yarn.js +32 -7
- package/lib/workspaces/implementations/yarn.js.map +1 -1
- package/package.json +1 -1
- package/lib/workspaces/workspaces.js +0 -34
- package/lib/workspaces/workspaces.js.map +0 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,69 @@
|
|
|
2
2
|
"name": "workspace-tools",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Thu,
|
|
5
|
+
"date": "Thu, 13 Apr 2023 20:39:55 GMT",
|
|
6
|
+
"tag": "workspace-tools_v0.34.0",
|
|
7
|
+
"version": "0.34.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "elcraig@microsoft.com",
|
|
12
|
+
"package": "workspace-tools",
|
|
13
|
+
"commit": "43b7ce01968702903163327b0cad889a0d3d84d3",
|
|
14
|
+
"comment": "Fix `getPackageInfos` to only read package.jsons once, and `getAllPackageJsonFiles` (which only returns paths) to not read the files at all. There's also a new API `getWorkspacePackagePaths` which allows consumers to make the same optimization."
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Thu, 13 Apr 2023 08:01:43 GMT",
|
|
21
|
+
"tag": "workspace-tools_v0.33.0",
|
|
22
|
+
"version": "0.33.0",
|
|
23
|
+
"comments": {
|
|
24
|
+
"minor": [
|
|
25
|
+
{
|
|
26
|
+
"author": "elcraig@microsoft.com",
|
|
27
|
+
"package": "workspace-tools",
|
|
28
|
+
"commit": "2826670b707d724b5bddbdf67c06e307c87620d5",
|
|
29
|
+
"comment": "Improve workspace manager utility naming. None of the modified methods/types are exported from the root, but if you were deep importing them, the changes are as follows:\n - Change `getWorkspaceImplementationAndLockFile` to `getWorkspaceManagerAndRoot`, with return type `WorkspaceManagerAndRoot` (replacing `ImplementationAndLockFile`) to be more relevant for actual usage.\n - Remove `WorkspaceImplementations` type (use the identical existing type `WorkspaceManager` instead)"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"author": "elcraig@microsoft.com",
|
|
33
|
+
"package": "workspace-tools",
|
|
34
|
+
"commit": "2826670b707d724b5bddbdf67c06e307c87620d5",
|
|
35
|
+
"comment": "Rename `_resetCache` to `_resetPackageJsonFilesCache` to reflect what it does"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"patch": [
|
|
39
|
+
{
|
|
40
|
+
"author": "elcraig@microsoft.com",
|
|
41
|
+
"package": "workspace-tools",
|
|
42
|
+
"commit": "bdfbb181a70336b2c53aa443edcf91c4ae858185",
|
|
43
|
+
"comment": "Add optional verbose logging for getWorkspaces helpers"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"author": "elcraig@microsoft.com",
|
|
47
|
+
"package": "workspace-tools",
|
|
48
|
+
"commit": "18d27beb3d030f2d482b1cd9bd2031fc9b1149d3",
|
|
49
|
+
"comment": "Add more doc comments for getWorkspaces and related"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"author": "elcraig@microsoft.com",
|
|
53
|
+
"package": "workspace-tools",
|
|
54
|
+
"commit": "b697288732789f631f51cbdc85fb48e41b3b0a76",
|
|
55
|
+
"comment": "Simplify workspace root utilities, and deprecate individual manager `get___WorkspaceRoot` utilities (use `getWorkspaceRoot` instead). This includes moving, deleting, or renaming certain private methods, but has no public-facing changes."
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"author": "elcraig@microsoft.com",
|
|
59
|
+
"package": "workspace-tools",
|
|
60
|
+
"commit": "1dc1125ea5bd87a7496c8b7a1d1d317a5ec74dc1",
|
|
61
|
+
"comment": "Minor fixes to new async workspace/package methods"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"date": "Thu, 06 Apr 2023 22:06:24 GMT",
|
|
6
68
|
"tag": "workspace-tools_v0.32.0",
|
|
7
69
|
"version": "0.32.0",
|
|
8
70
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
# Change Log - workspace-tools
|
|
2
2
|
|
|
3
|
-
This log was last generated on Thu,
|
|
3
|
+
This log was last generated on Thu, 13 Apr 2023 20:39:55 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.34.0
|
|
8
|
+
|
|
9
|
+
Thu, 13 Apr 2023 20:39:55 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Fix `getPackageInfos` to only read package.jsons once, and `getAllPackageJsonFiles` (which only returns paths) to not read the files at all. There's also a new API `getWorkspacePackagePaths` which allows consumers to make the same optimization. (elcraig@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 0.33.0
|
|
16
|
+
|
|
17
|
+
Thu, 13 Apr 2023 08:01:43 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- Improve workspace manager utility naming. None of the modified methods/types are exported from the root, but if you were deep importing them, the changes are as follows:
|
|
22
|
+
- Change `getWorkspaceImplementationAndLockFile` to `getWorkspaceManagerAndRoot`, with return type `WorkspaceManagerAndRoot` (replacing `ImplementationAndLockFile`) to be more relevant for actual usage.
|
|
23
|
+
- Remove `WorkspaceImplementations` type (use the identical existing type `WorkspaceManager` instead) (elcraig@microsoft.com)
|
|
24
|
+
- Rename `_resetCache` to `_resetPackageJsonFilesCache` to reflect what it does (elcraig@microsoft.com)
|
|
25
|
+
|
|
26
|
+
### Patches
|
|
27
|
+
|
|
28
|
+
- Add optional verbose logging for getWorkspaces helpers (elcraig@microsoft.com)
|
|
29
|
+
- Add more doc comments for getWorkspaces and related (elcraig@microsoft.com)
|
|
30
|
+
- Simplify workspace root utilities, and deprecate individual manager `get___WorkspaceRoot` utilities (use `getWorkspaceRoot` instead). This includes moving, deleting, or renaming certain private methods, but has no public-facing changes. (elcraig@microsoft.com)
|
|
31
|
+
- Minor fixes to new async workspace/package methods (elcraig@microsoft.com)
|
|
32
|
+
|
|
7
33
|
## 0.32.0
|
|
8
34
|
|
|
9
|
-
Thu, 06 Apr 2023 22:06:
|
|
35
|
+
Thu, 06 Apr 2023 22:06:24 GMT
|
|
10
36
|
|
|
11
37
|
### Minor changes
|
|
12
38
|
|
package/README.md
CHANGED
|
@@ -21,3 +21,7 @@ Override the `maxBuffer` value for git processes, for example if the repo is ver
|
|
|
21
21
|
### PREFERRED_WORKSPACE_MANAGER
|
|
22
22
|
|
|
23
23
|
Sometimes if multiple workspace manager files are checked in, it's necessary to hint which manager is used: `npm`, `yarn`, `pnpm`, `rush`, or `lerna`.
|
|
24
|
+
|
|
25
|
+
### VERBOSE
|
|
26
|
+
|
|
27
|
+
Log additional output from certain functions.
|
package/lib/getPackageInfos.js
CHANGED
|
@@ -5,66 +5,54 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getPackageInfosAsync = exports.getPackageInfos = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
8
|
const path_1 = __importDefault(require("path"));
|
|
10
9
|
const infoFromPackageJson_1 = require("./infoFromPackageJson");
|
|
11
|
-
const
|
|
10
|
+
const getWorkspaces_1 = require("./workspaces/getWorkspaces");
|
|
12
11
|
function getPackageInfos(cwd) {
|
|
13
|
-
let packageJsonFiles = (0, workspaces_1.getAllPackageJsonFiles)(cwd);
|
|
14
|
-
if (packageJsonFiles.length === 0 && fs_1.default.existsSync(path_1.default.join(cwd, "package.json"))) {
|
|
15
|
-
packageJsonFiles = [path_1.default.join(cwd, "package.json")];
|
|
16
|
-
}
|
|
17
12
|
const packageInfos = {};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
else {
|
|
30
|
-
throw e;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return packageInfos;
|
|
13
|
+
const workspacePackages = (0, getWorkspaces_1.getWorkspaces)(cwd);
|
|
14
|
+
if (workspacePackages.length) {
|
|
15
|
+
for (const pkg of workspacePackages) {
|
|
16
|
+
packageInfos[pkg.name] = pkg.packageJson;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const rootInfo = tryReadRootPackageJson(cwd);
|
|
21
|
+
if (rootInfo) {
|
|
22
|
+
packageInfos[rootInfo.name] = rootInfo;
|
|
23
|
+
}
|
|
35
24
|
}
|
|
36
|
-
return
|
|
25
|
+
return packageInfos;
|
|
37
26
|
}
|
|
38
27
|
exports.getPackageInfos = getPackageInfos;
|
|
39
28
|
async function getPackageInfosAsync(cwd) {
|
|
40
|
-
let packageJsonFiles = await (0, workspaces_1.getAllPackageJsonFilesAsync)(cwd);
|
|
41
|
-
if (packageJsonFiles.length === 0 && fs_1.default.existsSync(path_1.default.join(cwd, "package.json"))) {
|
|
42
|
-
packageJsonFiles = [path_1.default.join(cwd, "package.json")];
|
|
43
|
-
}
|
|
44
29
|
const packageInfos = {};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath);
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
if (e instanceof Error) {
|
|
53
|
-
// Pass, the package.json is invalid
|
|
54
|
-
throw new Error(`Invalid package.json file detected ${packageJsonPath}: ${e.message}`);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
throw e;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
const results = await Promise.all(packageInfoPromises);
|
|
62
|
-
for (const packageInfo of results) {
|
|
63
|
-
packageInfos[packageInfo.name] = packageInfo;
|
|
30
|
+
const workspacePackages = await (0, getWorkspaces_1.getWorkspacesAsync)(cwd);
|
|
31
|
+
if (workspacePackages.length) {
|
|
32
|
+
for (const pkg of workspacePackages) {
|
|
33
|
+
packageInfos[pkg.name] = pkg.packageJson;
|
|
64
34
|
}
|
|
65
|
-
return packageInfos;
|
|
66
35
|
}
|
|
67
|
-
|
|
36
|
+
else {
|
|
37
|
+
const rootInfo = tryReadRootPackageJson(cwd);
|
|
38
|
+
if (rootInfo) {
|
|
39
|
+
packageInfos[rootInfo.name] = rootInfo;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return packageInfos;
|
|
68
43
|
}
|
|
69
44
|
exports.getPackageInfosAsync = getPackageInfosAsync;
|
|
45
|
+
function tryReadRootPackageJson(cwd) {
|
|
46
|
+
var _a;
|
|
47
|
+
const packageJsonPath = path_1.default.join(cwd, "package.json");
|
|
48
|
+
if (fs_1.default.existsSync(packageJsonPath)) {
|
|
49
|
+
try {
|
|
50
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf-8"));
|
|
51
|
+
return (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath);
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
throw new Error(`Invalid package.json file detected ${packageJsonPath}: ${((_a = e) === null || _a === void 0 ? void 0 : _a.message) || e}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
70
58
|
//# sourceMappingURL=getPackageInfos.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageInfos.js","sourceRoot":"","sources":["../src/getPackageInfos.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,
|
|
1
|
+
{"version":3,"file":"getPackageInfos.js","sourceRoot":"","sources":["../src/getPackageInfos.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,+DAA4D;AAC5D,8DAA+E;AAE/E,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,YAAY,GAAiB,EAAE,CAAC;IACtC,MAAM,iBAAiB,GAAG,IAAA,6BAAa,EAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,iBAAiB,CAAC,MAAM,EAAE;QAC5B,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE;YACnC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC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CAAC,CAAC;SACzG;KACF;AACH,CAAC"}
|
package/lib/getPackagePaths.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Given package folder globs (such as those from package.json `workspaces`) and a workspace root
|
|
3
|
+
* directory, get paths to actual package folders.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getPackagePaths(root: string, packageGlobs: string[]): string[];
|
|
6
|
+
/**
|
|
7
|
+
* Given package folder globs (such as those from package.json `workspaces`) and a workspace root
|
|
8
|
+
* directory, get paths to actual package folders.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getPackagePathsAsync(root: string, packageGlobs: string[]): Promise<string[]>;
|
package/lib/getPackagePaths.js
CHANGED
|
@@ -7,43 +7,42 @@ exports.getPackagePathsAsync = exports.getPackagePaths = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
9
9
|
const packagePathsCache = {};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (path_1.default.sep === "/") {
|
|
23
|
-
packagePathsCache[workspacesRoot] = packagePaths;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
packagePathsCache[workspacesRoot] = packagePaths.map((p) => p.replace(/\//g, path_1.default.sep));
|
|
10
|
+
const globOptions = {
|
|
11
|
+
absolute: true,
|
|
12
|
+
ignore: ["**/node_modules/**", "**/__fixtures__/**"],
|
|
13
|
+
stats: false,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Given package folder globs (such as those from package.json `workspaces`) and a workspace root
|
|
17
|
+
* directory, get paths to actual package folders.
|
|
18
|
+
*/
|
|
19
|
+
function getPackagePaths(root, packageGlobs) {
|
|
20
|
+
if (packagePathsCache[root]) {
|
|
21
|
+
return packagePathsCache[root];
|
|
27
22
|
}
|
|
28
|
-
|
|
23
|
+
packagePathsCache[root] = fast_glob_1.default
|
|
24
|
+
.sync(getPackageJsonGlobs(packageGlobs), { cwd: root, ...globOptions })
|
|
25
|
+
.map(getResultPackagePath);
|
|
26
|
+
return packagePathsCache[root];
|
|
29
27
|
}
|
|
30
28
|
exports.getPackagePaths = getPackagePaths;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
stats: false,
|
|
39
|
-
})).map((p) => path_1.default.join(workspacesRoot, path_1.default.dirname(p)));
|
|
40
|
-
if (path_1.default.sep === "/") {
|
|
41
|
-
packagePathsCache[workspacesRoot] = packagePaths;
|
|
29
|
+
/**
|
|
30
|
+
* Given package folder globs (such as those from package.json `workspaces`) and a workspace root
|
|
31
|
+
* directory, get paths to actual package folders.
|
|
32
|
+
*/
|
|
33
|
+
async function getPackagePathsAsync(root, packageGlobs) {
|
|
34
|
+
if (packagePathsCache[root]) {
|
|
35
|
+
return packagePathsCache[root];
|
|
42
36
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
return packagePathsCache[workspacesRoot];
|
|
37
|
+
packagePathsCache[root] = (await (0, fast_glob_1.default)(getPackageJsonGlobs(packageGlobs), { cwd: root, ...globOptions })).map(getResultPackagePath);
|
|
38
|
+
return packagePathsCache[root];
|
|
47
39
|
}
|
|
48
40
|
exports.getPackagePathsAsync = getPackagePathsAsync;
|
|
41
|
+
function getPackageJsonGlobs(packageGlobs) {
|
|
42
|
+
return packageGlobs.map((glob) => path_1.default.join(glob, "package.json").replace(/\\/g, "/"));
|
|
43
|
+
}
|
|
44
|
+
function getResultPackagePath(packageJsonPath) {
|
|
45
|
+
const packagePath = path_1.default.dirname(packageJsonPath);
|
|
46
|
+
return path_1.default.sep === "/" ? packagePath : packagePath.replace(/\//g, path_1.default.sep);
|
|
47
|
+
}
|
|
49
48
|
//# sourceMappingURL=getPackagePaths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackagePaths.js","sourceRoot":"","sources":["../src/getPackagePaths.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"getPackagePaths.js","sourceRoot":"","sources":["../src/getPackagePaths.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,0DAA8D;AAE9D,MAAM,iBAAiB,GAAiC,EAAE,CAAC;AAC3D,MAAM,WAAW,GAAgB;IAC/B,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IACpD,KAAK,EAAE,KAAK;CACb,CAAC;AAEF;;;GAGG;AACH,SAAgB,eAAe,CAAC,IAAY,EAAE,YAAsB;IAClE,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE;QAC3B,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;KAChC;IAED,iBAAiB,CAAC,IAAI,CAAC,GAAG,mBAAI;SAC3B,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,WAAW,EAAE,CAAC;SACtE,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAE7B,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAVD,0CAUC;AAED;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CAAC,IAAY,EAAE,YAAsB;IAC7E,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE;QAC3B,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;KAChC;IAED,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAA,mBAAI,EAAC,mBAAmB,CAAC,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC,GAAG,CAC1G,oBAAoB,CACrB,CAAC;IAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAVD,oDAUC;AAED,SAAS,mBAAmB,CAAC,YAAsB;IACjD,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,oBAAoB,CAAC,eAAuB;IACnD,MAAM,WAAW,GAAG,cAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAClD,OAAO,cAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,cAAI,CAAC,GAAG,CAAC,CAAC;AAC/E,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -10,11 +10,12 @@ export * from "./types/PackageInfo";
|
|
|
10
10
|
export * from "./types/WorkspaceInfo";
|
|
11
11
|
export * from "./workspaces/findWorkspacePath";
|
|
12
12
|
export * from "./workspaces/getWorkspaces";
|
|
13
|
+
export * from "./workspaces/getWorkspacePackagePaths";
|
|
13
14
|
export * from "./workspaces/getWorkspaceRoot";
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
15
|
+
export { getPnpmWorkspaceRoot, getPnpmWorkspaces } from "./workspaces/implementations/pnpm";
|
|
16
|
+
export { getRushWorkspaceRoot, getRushWorkspaces } from "./workspaces/implementations/rush";
|
|
17
|
+
export { getYarnWorkspaceRoot, getYarnWorkspaces } from "./workspaces/implementations/yarn";
|
|
17
18
|
export * from "./workspaces/getChangedPackages";
|
|
18
19
|
export * from "./workspaces/getPackagesByFiles";
|
|
19
20
|
export * from "./workspaces/listOfWorkspacePackageNames";
|
|
20
|
-
export * from "./workspaces/
|
|
21
|
+
export * from "./workspaces/getAllPackageJsonFiles";
|
package/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.getYarnWorkspaces = exports.getYarnWorkspaceRoot = exports.getRushWorkspaces = exports.getRushWorkspaceRoot = exports.getPnpmWorkspaces = exports.getPnpmWorkspaceRoot = void 0;
|
|
13
14
|
__exportStar(require("./dependencies/index"), exports);
|
|
14
15
|
__exportStar(require("./getPackageInfos"), exports);
|
|
15
16
|
__exportStar(require("./git"), exports);
|
|
@@ -22,12 +23,19 @@ __exportStar(require("./types/PackageInfo"), exports);
|
|
|
22
23
|
__exportStar(require("./types/WorkspaceInfo"), exports);
|
|
23
24
|
__exportStar(require("./workspaces/findWorkspacePath"), exports);
|
|
24
25
|
__exportStar(require("./workspaces/getWorkspaces"), exports);
|
|
26
|
+
__exportStar(require("./workspaces/getWorkspacePackagePaths"), exports);
|
|
25
27
|
__exportStar(require("./workspaces/getWorkspaceRoot"), exports);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
var pnpm_1 = require("./workspaces/implementations/pnpm");
|
|
29
|
+
Object.defineProperty(exports, "getPnpmWorkspaceRoot", { enumerable: true, get: function () { return pnpm_1.getPnpmWorkspaceRoot; } });
|
|
30
|
+
Object.defineProperty(exports, "getPnpmWorkspaces", { enumerable: true, get: function () { return pnpm_1.getPnpmWorkspaces; } });
|
|
31
|
+
var rush_1 = require("./workspaces/implementations/rush");
|
|
32
|
+
Object.defineProperty(exports, "getRushWorkspaceRoot", { enumerable: true, get: function () { return rush_1.getRushWorkspaceRoot; } });
|
|
33
|
+
Object.defineProperty(exports, "getRushWorkspaces", { enumerable: true, get: function () { return rush_1.getRushWorkspaces; } });
|
|
34
|
+
var yarn_1 = require("./workspaces/implementations/yarn");
|
|
35
|
+
Object.defineProperty(exports, "getYarnWorkspaceRoot", { enumerable: true, get: function () { return yarn_1.getYarnWorkspaceRoot; } });
|
|
36
|
+
Object.defineProperty(exports, "getYarnWorkspaces", { enumerable: true, get: function () { return yarn_1.getYarnWorkspaces; } });
|
|
29
37
|
__exportStar(require("./workspaces/getChangedPackages"), exports);
|
|
30
38
|
__exportStar(require("./workspaces/getPackagesByFiles"), exports);
|
|
31
39
|
__exportStar(require("./workspaces/listOfWorkspacePackageNames"), exports);
|
|
32
|
-
__exportStar(require("./workspaces/
|
|
40
|
+
__exportStar(require("./workspaces/getAllPackageJsonFiles"), exports);
|
|
33
41
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,uDAAqC;AACrC,oDAAkC;AAClC,wCAAsB;AACtB,gDAA8B;AAC9B,6CAA2B;AAC3B,0CAAwB;AACxB,0CAAwB;AACxB,uDAAqC;AACrC,sDAAoC;AACpC,wDAAsC;AACtC,iEAA+C;AAC/C,6DAA2C;AAC3C,wEAAsD;AACtD,gEAA8C;AAC9C,0DAA4F;AAAnF,4GAAA,oBAAoB,OAAA;AAAE,yGAAA,iBAAiB,OAAA;AAChD,0DAA4F;AAAnF,4GAAA,oBAAoB,OAAA;AAAE,yGAAA,iBAAiB,OAAA;AAChD,0DAA4F;AAAnF,4GAAA,oBAAoB,OAAA;AAAE,yGAAA,iBAAiB,OAAA;AAChD,kEAAgD;AAChD,kEAAgD;AAChD,2EAAyD;AACzD,sEAAoD"}
|
package/lib/lockfile/index.js
CHANGED
|
@@ -83,7 +83,7 @@ async function parseLockFile(packageRoot) {
|
|
|
83
83
|
npmLockJson = fs_1.default.readFileSync(npmLockPath, "utf-8");
|
|
84
84
|
}
|
|
85
85
|
catch {
|
|
86
|
-
throw new Error("Couldn
|
|
86
|
+
throw new Error("Couldn't read package-lock.json");
|
|
87
87
|
}
|
|
88
88
|
const npmLock = JSON.parse(npmLockJson.toString());
|
|
89
89
|
if (!(npmLock === null || npmLock === void 0 ? void 0 : npmLock.lockfileVersion) || npmLock.lockfileVersion < 2) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lockfile/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wGAAwG;AACxG,4CAAoB;AACpB,gDAAwB;AAExB,mDAAgD;AA2FvC,8FA3FA,6BAAa,OA2FA;AA1FtB,oCAAoC;AACpC,mDAAgD;AAChD,iDAA8C;AAC9C,yCAAsC;AACtC,qDAAkD;AAElD,MAAM,WAAW,GAAmC,EAAE,CAAC;AAEhD,KAAK,UAAU,aAAa,CAAC,WAAmB;IACrD,MAAM,YAAY,GAAG,IAAA,gBAAQ,EAAC,CAAC,WAAW,EAAE,8BAA8B,CAAC,EAAE,WAAW,CAAC,CAAC;IAE1F,8CAA8C;IAC9C,IAAI,YAAY,EAAE;QAChB,IAAI,WAAW,CAAC,YAAY,CAAC,EAAE;YAC7B,OAAO,WAAW,CAAC,YAAY,CAAC,CAAC;SAClC;QAED,MAAM,QAAQ,GAAG,YAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAExD,MAAM,OAAO,GACX,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;QAE/G,IAAI,MAAM,GAGN;YACF,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,EAAE;SACX,CAAC;QAEF,IAAI,OAAO,EAAE;YACX,M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K,CACb,2GAA2G,CAC5G,CAAC;AACJ,CAAC;AAhFD,sCAgFC;AAGD,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,0CAAwB"}
|
package/lib/logging.d.ts
ADDED
package/lib/logging.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logVerboseWarning = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Helper that logs an error to `console.warn` if `process.env.VERBOSE` is set.
|
|
6
|
+
* This should be replaced with a proper logging system eventually.
|
|
7
|
+
*/
|
|
8
|
+
function logVerboseWarning(description, err) {
|
|
9
|
+
var _a;
|
|
10
|
+
if (process.env.VERBOSE) {
|
|
11
|
+
console.warn(`${description}${err ? ":\n" : ""}`, ((_a = err) === null || _a === void 0 ? void 0 : _a.stack) || err || "");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.logVerboseWarning = logVerboseWarning;
|
|
15
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,WAAmB,EAAE,GAAa;;IAClE,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE;QACvB,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAA,MAAC,GAAyB,0CAAE,KAAK,KAAI,GAAG,IAAI,EAAE,CAAC,CAAC;KACnG;AACH,CAAC;AAJD,8CAIC"}
|
package/lib/paths.js
CHANGED
|
@@ -8,6 +8,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const getWorkspaceRoot_1 = require("./workspaces/getWorkspaceRoot");
|
|
10
10
|
const git_1 = require("./git");
|
|
11
|
+
const logging_1 = require("./logging");
|
|
11
12
|
/**
|
|
12
13
|
* Starting from `cwd`, searches up the directory hierarchy for `filePath`.
|
|
13
14
|
* If multiple strings are given, searches each directory level for any of them.
|
|
@@ -56,7 +57,12 @@ function findProjectRoot(cwd) {
|
|
|
56
57
|
try {
|
|
57
58
|
workspaceRoot = (0, getWorkspaceRoot_1.getWorkspaceRoot)(cwd);
|
|
58
59
|
}
|
|
59
|
-
catch {
|
|
60
|
+
catch (err) {
|
|
61
|
+
(0, logging_1.logVerboseWarning)(`Error getting workspace root for ${cwd}`, err);
|
|
62
|
+
}
|
|
63
|
+
if (!workspaceRoot) {
|
|
64
|
+
(0, logging_1.logVerboseWarning)(`Could not find workspace root for ${cwd}. Falling back to git root.`);
|
|
65
|
+
}
|
|
60
66
|
return workspaceRoot || findGitRoot(cwd);
|
|
61
67
|
}
|
|
62
68
|
exports.findProjectRoot = findProjectRoot;
|
package/lib/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,oEAAiE;AACjE,+BAA4B;
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,oEAAiE;AACjE,+BAA4B;AAC5B,uCAA8C;AAE9C;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,QAA2B,EAAE,GAAW;IAC/D,MAAM,KAAK,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACnE,MAAM,IAAI,GAAG,cAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAElC,IAAI,SAA6B,CAAC;IAElC,OAAO,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,GAAG,CAAC,CAAC;KACnE;IAED,IAAI,CAAC,aAAa,EAAE;QAClB,IAAA,2BAAiB,EAAC,qCAAqC,GAAG,6BAA6B,CAAC,CAAC;KAC1F;IACD,OAAO,aAAa,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC;AAC3C,CAAC;AAZD,0CAYC;AAED,SAAgB,SAAS,CAAC,KAAa,EAAE,MAAc;IACrD,MAAM,YAAY,GAAG,cAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAClD,OAAO,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC;AAHD,8BAGC"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { PackageInfo } from "./PackageInfo";
|
|
2
|
+
/**
|
|
3
|
+
* Array with names, paths, and package.json contents for each package in a workspace.
|
|
4
|
+
*
|
|
5
|
+
* The method name is somewhat misleading due to the double meaning of "workspace", but it's retained
|
|
6
|
+
* for compatibility. "Workspace" here refers to an individual package, in the sense of the `workspaces`
|
|
7
|
+
* package.json config used by npm/yarn (instead of referring to the entire monorepo).
|
|
8
|
+
*/
|
|
2
9
|
export declare type WorkspaceInfo = {
|
|
3
10
|
name: string;
|
|
4
11
|
path: string;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { WorkspaceInfo } from "../types/WorkspaceInfo";
|
|
2
|
+
/**
|
|
3
|
+
* Find the path for a particular package name from an array of info about packages within a workspace.
|
|
4
|
+
* (See `../getWorkspaces` for why it's named this way.)
|
|
5
|
+
* @param workspaces Array of info about packages within a workspace
|
|
6
|
+
* @param packageName Package name to find
|
|
7
|
+
* @returns Package path if found, or undefined
|
|
8
|
+
*/
|
|
2
9
|
export declare function findWorkspacePath(workspaces: WorkspaceInfo, packageName: string): string | undefined;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findWorkspacePath = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Find the path for a particular package name from an array of info about packages within a workspace.
|
|
6
|
+
* (See `../getWorkspaces` for why it's named this way.)
|
|
7
|
+
* @param workspaces Array of info about packages within a workspace
|
|
8
|
+
* @param packageName Package name to find
|
|
9
|
+
* @returns Package path if found, or undefined
|
|
10
|
+
*/
|
|
4
11
|
function findWorkspacePath(workspaces, packageName) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return workspace.path;
|
|
8
|
-
}
|
|
12
|
+
var _a;
|
|
13
|
+
return (_a = workspaces.find(({ name }) => name === packageName)) === null || _a === void 0 ? void 0 : _a.path;
|
|
9
14
|
}
|
|
10
15
|
exports.findWorkspacePath = findWorkspacePath;
|
|
11
16
|
//# sourceMappingURL=findWorkspacePath.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findWorkspacePath.js","sourceRoot":"","sources":["../../src/workspaces/findWorkspacePath.ts"],"names":[],"mappings":";;;AAEA,SAAgB,iBAAiB,CAAC,UAAyB,EAAE,WAAmB
|
|
1
|
+
{"version":3,"file":"findWorkspacePath.js","sourceRoot":"","sources":["../../src/workspaces/findWorkspacePath.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,UAAyB,EAAE,WAAmB;;IAC9E,OAAO,MAAA,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,WAAW,CAAC,0CAAE,IAAI,CAAC;AACnE,CAAC;AAFD,8CAEC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Get paths to every package.json in the workspace, given a cwd
|
|
3
|
-
* @param cwd
|
|
2
|
+
* Get paths to every package.json in the workspace, given a cwd.
|
|
4
3
|
*/
|
|
5
4
|
export declare function getAllPackageJsonFiles(cwd: string): string[];
|
|
6
|
-
export declare function
|
|
5
|
+
export declare function _resetPackageJsonFilesCache(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Get paths to every package.json in the workspace, given a cwd.
|
|
8
|
+
*/
|
|
7
9
|
export declare function getAllPackageJsonFilesAsync(cwd: string): Promise<string[]>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getAllPackageJsonFilesAsync = exports._resetPackageJsonFilesCache = exports.getAllPackageJsonFiles = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const getWorkspacePackagePaths_1 = require("./getWorkspacePackagePaths");
|
|
9
|
+
const cache = new Map();
|
|
10
|
+
/**
|
|
11
|
+
* Get paths to every package.json in the workspace, given a cwd.
|
|
12
|
+
*/
|
|
13
|
+
function getAllPackageJsonFiles(cwd) {
|
|
14
|
+
if (cache.has(cwd)) {
|
|
15
|
+
return cache.get(cwd);
|
|
16
|
+
}
|
|
17
|
+
const packageJsonFiles = (0, getWorkspacePackagePaths_1.getWorkspacePackagePaths)(cwd).map((packagePath) => path_1.default.join(packagePath, "package.json"));
|
|
18
|
+
cache.set(cwd, packageJsonFiles);
|
|
19
|
+
return packageJsonFiles;
|
|
20
|
+
}
|
|
21
|
+
exports.getAllPackageJsonFiles = getAllPackageJsonFiles;
|
|
22
|
+
function _resetPackageJsonFilesCache() {
|
|
23
|
+
cache.clear();
|
|
24
|
+
}
|
|
25
|
+
exports._resetPackageJsonFilesCache = _resetPackageJsonFilesCache;
|
|
26
|
+
/**
|
|
27
|
+
* Get paths to every package.json in the workspace, given a cwd.
|
|
28
|
+
*/
|
|
29
|
+
async function getAllPackageJsonFilesAsync(cwd) {
|
|
30
|
+
if (cache.has(cwd)) {
|
|
31
|
+
return cache.get(cwd);
|
|
32
|
+
}
|
|
33
|
+
const packageJsonFiles = (await (0, getWorkspacePackagePaths_1.getWorkspacePackagePathsAsync)(cwd)).map((packagePath) => path_1.default.join(packagePath, "package.json"));
|
|
34
|
+
cache.set(cwd, packageJsonFiles);
|
|
35
|
+
return packageJsonFiles;
|
|
36
|
+
}
|
|
37
|
+
exports.getAllPackageJsonFilesAsync = getAllPackageJsonFilesAsync;
|
|
38
|
+
//# sourceMappingURL=getAllPackageJsonFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAllPackageJsonFiles.js","sourceRoot":"","sources":["../../src/workspaces/getAllPackageJsonFiles.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,yEAAqG;AAErG,MAAM,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;AAE1C;;GAEG;AACH,SAAgB,sBAAsB,CAAC,GAAW;IAChD,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;KACxB;IAED,MAAM,gBAAgB,GAAG,IAAA,mDAAwB,EAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;IAEpH,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAEjC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAVD,wDAUC;AAED,SAAgB,2BAA2B;IACzC,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC;AAFD,kEAEC;AAED;;GAEG;AACI,KAAK,UAAU,2BAA2B,CAAC,GAAW;IAC3D,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;KACxB;IAED,MAAM,gBAAgB,GAAG,CAAC,MAAM,IAAA,wDAA6B,EAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CACtF,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CACvC,CAAC;IAEF,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAEjC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAZD,kEAYC"}
|