workspace-tools 0.40.4 → 0.41.1
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/README.md +39 -1
- package/lib/dependencies/index.d.ts +2 -2
- package/lib/dependencies/index.js +31 -12
- package/lib/dependencies/index.js.map +1 -1
- package/lib/dependencies/transitiveDeps.d.ts +1 -1
- package/lib/dependencies/transitiveDeps.js +59 -38
- package/lib/dependencies/transitiveDeps.js.map +1 -1
- package/lib/getPackageInfo.d.ts +7 -5
- package/lib/getPackageInfo.js +46 -39
- package/lib/getPackageInfo.js.map +1 -1
- package/lib/getPackageInfos.d.ts +31 -8
- package/lib/getPackageInfos.js +41 -41
- package/lib/getPackageInfos.js.map +1 -1
- package/lib/git/config.d.ts +1 -1
- package/lib/git/config.js +15 -12
- package/lib/git/config.js.map +1 -1
- package/lib/git/getDefaultRemote.js +45 -30
- package/lib/git/getDefaultRemote.js.map +1 -1
- package/lib/git/getDefaultRemoteBranch.d.ts +1 -1
- package/lib/git/getDefaultRemoteBranch.js +35 -24
- package/lib/git/getDefaultRemoteBranch.js.map +1 -1
- package/lib/git/getRepositoryName.d.ts +1 -1
- package/lib/git/getRepositoryName.js +17 -19
- package/lib/git/getRepositoryName.js.map +1 -1
- package/lib/git/git.d.ts +2 -5
- package/lib/git/git.js +62 -64
- package/lib/git/git.js.map +1 -1
- package/lib/git/gitUtilities.d.ts +3 -3
- package/lib/git/gitUtilities.js +377 -147
- package/lib/git/gitUtilities.js.map +1 -1
- package/lib/git/index.d.ts +5 -5
- package/lib/git/index.js +50 -28
- package/lib/git/index.js.map +1 -1
- package/lib/git/types.js +4 -3
- package/lib/git/types.js.map +1 -1
- package/lib/graph/createDependencyMap.d.ts +12 -2
- package/lib/graph/createDependencyMap.js +18 -10
- package/lib/graph/createDependencyMap.js.map +1 -1
- package/lib/graph/createPackageGraph.d.ts +10 -6
- package/lib/graph/createPackageGraph.js +58 -42
- package/lib/graph/createPackageGraph.js.map +1 -1
- package/lib/graph/getPackageDependencies.d.ts +2 -2
- package/lib/graph/getPackageDependencies.js +24 -53
- package/lib/graph/getPackageDependencies.js.map +1 -1
- package/lib/graph/index.d.ts +4 -4
- package/lib/graph/index.js +25 -27
- package/lib/graph/index.js.map +1 -1
- package/lib/index.d.ts +29 -27
- package/lib/index.js +154 -75
- package/lib/index.js.map +1 -1
- package/lib/isCachingEnabled.js +17 -6
- package/lib/isCachingEnabled.js.map +1 -1
- package/lib/lockfile/nameAtVersion.js +9 -4
- package/lib/lockfile/nameAtVersion.js.map +1 -1
- package/lib/lockfile/parseBerryLock.d.ts +1 -1
- package/lib/lockfile/parseBerryLock.js +13 -11
- package/lib/lockfile/parseBerryLock.js.map +1 -1
- package/lib/lockfile/parseLockFile.d.ts +2 -0
- package/lib/lockfile/parseLockFile.js +87 -0
- package/lib/lockfile/parseLockFile.js.map +1 -0
- package/lib/lockfile/parseNpmLock.d.ts +1 -1
- package/lib/lockfile/parseNpmLock.js +15 -7
- package/lib/lockfile/parseNpmLock.js.map +1 -1
- package/lib/lockfile/parsePnpmLock.d.ts +1 -1
- package/lib/lockfile/parsePnpmLock.js +14 -9
- package/lib/lockfile/parsePnpmLock.js.map +1 -1
- package/lib/lockfile/queryLockFile.d.ts +1 -1
- package/lib/lockfile/queryLockFile.js +11 -6
- package/lib/lockfile/queryLockFile.js.map +1 -1
- package/lib/lockfile/readYaml.js +17 -9
- package/lib/lockfile/readYaml.js.map +1 -1
- package/lib/lockfile/types.js +3 -2
- package/lib/lockfile/types.js.map +1 -1
- package/lib/logging.js +10 -6
- package/lib/logging.js.map +1 -1
- package/lib/paths.d.ts +4 -1
- package/lib/paths.js +60 -58
- package/lib/paths.js.map +1 -1
- package/lib/scope.js +30 -21
- package/lib/scope.js.map +1 -1
- package/lib/types/Catalogs.js +8 -3
- package/lib/types/Catalogs.js.map +1 -1
- package/lib/types/PackageGraph.d.ts +5 -1
- package/lib/types/PackageGraph.js +4 -3
- package/lib/types/PackageGraph.js.map +1 -1
- package/lib/types/PackageInfo.d.ts +1 -1
- package/lib/types/PackageInfo.js +3 -2
- package/lib/types/PackageInfo.js.map +1 -1
- package/lib/types/WorkspaceInfo.d.ts +3 -5
- package/lib/types/WorkspaceInfo.js +3 -2
- package/lib/types/WorkspaceInfo.js.map +1 -1
- package/lib/types/WorkspaceManager.js +4 -0
- package/lib/types/WorkspaceManager.js.map +1 -0
- package/lib/workspaces/catalogsToYaml.d.ts +1 -1
- package/lib/workspaces/catalogsToYaml.js +12 -10
- package/lib/workspaces/catalogsToYaml.js.map +1 -1
- package/lib/workspaces/findWorkspacePath.d.ts +2 -1
- package/lib/workspaces/findWorkspacePath.js +10 -12
- package/lib/workspaces/findWorkspacePath.js.map +1 -1
- package/lib/workspaces/getAllPackageJsonFiles.d.ts +10 -4
- package/lib/workspaces/getAllPackageJsonFiles.js +32 -22
- package/lib/workspaces/getAllPackageJsonFiles.js.map +1 -1
- package/lib/workspaces/getCatalogVersion.d.ts +1 -1
- package/lib/workspaces/getCatalogVersion.js +19 -32
- package/lib/workspaces/getCatalogVersion.js.map +1 -1
- package/lib/workspaces/getCatalogs.d.ts +8 -2
- package/lib/workspaces/getCatalogs.js +23 -15
- package/lib/workspaces/getCatalogs.js.map +1 -1
- package/lib/workspaces/getChangedPackages.d.ts +1 -1
- package/lib/workspaces/getChangedPackages.js +47 -30
- package/lib/workspaces/getChangedPackages.js.map +1 -1
- package/lib/workspaces/getPackagesByFiles.js +29 -24
- package/lib/workspaces/getPackagesByFiles.js.map +1 -1
- package/lib/workspaces/getWorkspaceInfos.d.ts +36 -0
- package/lib/workspaces/getWorkspaceInfos.js +60 -0
- package/lib/workspaces/getWorkspaceInfos.js.map +1 -0
- package/lib/workspaces/getWorkspaceManagerRoot.d.ts +16 -0
- package/lib/workspaces/getWorkspaceManagerRoot.js +32 -0
- package/lib/workspaces/getWorkspaceManagerRoot.js.map +1 -0
- package/lib/workspaces/getWorkspacePackagePaths.d.ts +17 -2
- package/lib/workspaces/getWorkspacePackagePaths.js +138 -24
- package/lib/workspaces/getWorkspacePackagePaths.js.map +1 -1
- package/lib/workspaces/getWorkspacePatterns.d.ts +11 -0
- package/lib/workspaces/getWorkspacePatterns.js +25 -0
- package/lib/workspaces/getWorkspacePatterns.js.map +1 -0
- package/lib/workspaces/implementations/WorkspaceUtilities.d.ts +27 -0
- package/lib/workspaces/implementations/WorkspaceUtilities.js +4 -0
- package/lib/workspaces/implementations/WorkspaceUtilities.js.map +1 -0
- package/lib/workspaces/implementations/getPackageJsonWorkspacePatterns.d.ts +9 -0
- package/lib/workspaces/implementations/getPackageJsonWorkspacePatterns.js +38 -0
- package/lib/workspaces/implementations/getPackageJsonWorkspacePatterns.js.map +1 -0
- package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.d.ts +19 -5
- package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.js +38 -40
- package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.js.map +1 -1
- package/lib/workspaces/implementations/getWorkspaceUtilities.d.ts +4 -36
- package/lib/workspaces/implementations/getWorkspaceUtilities.js +35 -20
- package/lib/workspaces/implementations/getWorkspaceUtilities.js.map +1 -1
- package/lib/workspaces/implementations/index.d.ts +2 -2
- package/lib/workspaces/implementations/index.js +19 -7
- package/lib/workspaces/implementations/index.js.map +1 -1
- package/lib/workspaces/implementations/lerna.d.ts +2 -20
- package/lib/workspaces/implementations/lerna.js +77 -62
- package/lib/workspaces/implementations/lerna.js.map +1 -1
- package/lib/workspaces/implementations/npm.d.ts +3 -17
- package/lib/workspaces/implementations/npm.js +12 -43
- package/lib/workspaces/implementations/npm.js.map +1 -1
- package/lib/workspaces/implementations/pnpm.d.ts +2 -30
- package/lib/workspaces/implementations/pnpm.js +32 -89
- package/lib/workspaces/implementations/pnpm.js.map +1 -1
- package/lib/workspaces/implementations/rush.d.ts +2 -22
- package/lib/workspaces/implementations/rush.js +26 -69
- package/lib/workspaces/implementations/rush.js.map +1 -1
- package/lib/workspaces/implementations/yarn.d.ts +2 -35
- package/lib/workspaces/implementations/yarn.js +33 -85
- package/lib/workspaces/implementations/yarn.js.map +1 -1
- package/lib/workspaces/wrapWorkspaceUtility.d.ts +31 -0
- package/lib/workspaces/wrapWorkspaceUtility.js +47 -0
- package/lib/workspaces/wrapWorkspaceUtility.js.map +1 -0
- package/package.json +21 -12
- package/lib/getPackagePaths.d.ts +0 -10
- package/lib/getPackagePaths.js +0 -49
- package/lib/getPackagePaths.js.map +0 -1
- package/lib/infoFromPackageJson.d.ts +0 -17
- package/lib/infoFromPackageJson.js +0 -11
- package/lib/infoFromPackageJson.js.map +0 -1
- package/lib/lockfile/index.d.ts +0 -6
- package/lib/lockfile/index.js +0 -105
- package/lib/lockfile/index.js.map +0 -1
- package/lib/workspaces/WorkspaceManager.js +0 -3
- package/lib/workspaces/WorkspaceManager.js.map +0 -1
- package/lib/workspaces/getWorkspacePackageInfo.d.ts +0 -26
- package/lib/workspaces/getWorkspacePackageInfo.js +0 -76
- package/lib/workspaces/getWorkspacePackageInfo.js.map +0 -1
- package/lib/workspaces/getWorkspaceRoot.d.ts +0 -25
- package/lib/workspaces/getWorkspaceRoot.js +0 -35
- package/lib/workspaces/getWorkspaceRoot.js.map +0 -1
- package/lib/workspaces/getWorkspaces.d.ts +0 -20
- package/lib/workspaces/getWorkspaces.js +0 -39
- package/lib/workspaces/getWorkspaces.js.map +0 -1
- package/lib/workspaces/implementations/packageJsonWorkspaces.d.ts +0 -31
- package/lib/workspaces/implementations/packageJsonWorkspaces.js +0 -104
- package/lib/workspaces/implementations/packageJsonWorkspaces.js.map +0 -1
- package/lib/workspaces/listOfWorkspacePackageNames.d.ts +0 -5
- package/lib/workspaces/listOfWorkspacePackageNames.js +0 -11
- package/lib/workspaces/listOfWorkspacePackageNames.js.map +0 -1
- /package/lib/{workspaces → types}/WorkspaceManager.d.ts +0 -0
|
@@ -1,101 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const index_1 = require("./index");
|
|
10
|
-
const packageJsonWorkspaces_1 = require("./packageJsonWorkspaces");
|
|
11
|
-
const getPackageInfo_1 = require("../../getPackageInfo");
|
|
12
|
-
const logging_1 = require("../../logging");
|
|
13
|
-
const readYaml_1 = require("../../lockfile/readYaml");
|
|
14
|
-
/** @deprecated Use `getWorkspaceManagerRoot` */
|
|
15
|
-
function getYarnWorkspaceRoot(cwd) {
|
|
16
|
-
const root = (0, index_1.getWorkspaceManagerAndRoot)(cwd, undefined, "yarn")?.root;
|
|
17
|
-
if (!root) {
|
|
18
|
-
throw new Error("Could not find yarn root from " + cwd);
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "yarnUtilities", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return yarnUtilities;
|
|
19
9
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
|
|
32
|
-
/**
|
|
33
|
-
* Get paths for each package ("workspace") in a yarn monorepo.
|
|
34
|
-
* @returns Array of monorepo package paths, or an empty array on error
|
|
35
|
-
*/
|
|
36
|
-
function getWorkspacePackagePathsAsync(cwd) {
|
|
37
|
-
const root = getYarnWorkspaceRoot(cwd);
|
|
38
|
-
return (0, packageJsonWorkspaces_1.getPackagePathsFromWorkspaceRootAsync)(root);
|
|
10
|
+
});
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
const _getPackageInfo = require("../../getPackageInfo.js");
|
|
14
|
+
const _readYaml = require("../../lockfile/readYaml.js");
|
|
15
|
+
const _getPackageJsonWorkspacePatterns = require("./getPackageJsonWorkspacePatterns.js");
|
|
16
|
+
function _interop_require_default(obj) {
|
|
17
|
+
return obj && obj.__esModule ? obj : {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
39
20
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const root = getYarnWorkspaceRoot(cwd);
|
|
48
|
-
return (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRoot)(root);
|
|
49
|
-
}
|
|
50
|
-
exports.getYarnWorkspaces = getYarnWorkspaces;
|
|
51
|
-
exports.getWorkspaces = getYarnWorkspaces;
|
|
52
|
-
/**
|
|
53
|
-
* Get an array with names, paths, and package.json contents for each package ("workspace")
|
|
54
|
-
* in a yarn monorepo.
|
|
55
|
-
* @returns Array of monorepo package infos, or an empty array on error
|
|
56
|
-
*/
|
|
57
|
-
function getYarnWorkspacesAsync(cwd) {
|
|
58
|
-
const root = getYarnWorkspaceRoot(cwd);
|
|
59
|
-
return (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRootAsync)(root);
|
|
60
|
-
}
|
|
61
|
-
exports.getYarnWorkspacesAsync = getYarnWorkspacesAsync;
|
|
62
|
-
exports.getWorkspacesAsync = getYarnWorkspacesAsync;
|
|
63
|
-
/**
|
|
64
|
-
* Get version catalogs if present.
|
|
65
|
-
* Returns undefined if there's no catalog, or any issue reading or parsing.
|
|
66
|
-
* @see https://yarnpkg.com/features/catalogs
|
|
67
|
-
*/
|
|
68
|
-
function getYarnCatalogs(cwd) {
|
|
69
|
-
try {
|
|
70
|
-
const root = getYarnWorkspaceRoot(cwd);
|
|
71
|
-
const yarnrcYmlPath = path_1.default.join(root, ".yarnrc.yml");
|
|
72
|
-
if (fs_1.default.existsSync(yarnrcYmlPath)) {
|
|
73
|
-
const yarnrcYml = (0, readYaml_1.readYaml)(yarnrcYmlPath);
|
|
21
|
+
const yarnUtilities = {
|
|
22
|
+
getWorkspacePatterns: _getPackageJsonWorkspacePatterns.getPackageJsonWorkspacePatterns,
|
|
23
|
+
// See https://yarnpkg.com/features/catalogs
|
|
24
|
+
getCatalogs: ({ root })=>{
|
|
25
|
+
const yarnrcYmlPath = _path.default.join(root, ".yarnrc.yml");
|
|
26
|
+
if (_fs.default.existsSync(yarnrcYmlPath)) {
|
|
27
|
+
const yarnrcYml = (0, _readYaml.readYaml)(yarnrcYmlPath);
|
|
74
28
|
if (yarnrcYml?.catalog || yarnrcYml?.catalogs) {
|
|
75
29
|
// Yarn v4+ format
|
|
76
|
-
return {
|
|
30
|
+
return {
|
|
31
|
+
default: yarnrcYml.catalog,
|
|
32
|
+
named: yarnrcYml.catalogs
|
|
33
|
+
};
|
|
77
34
|
}
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
35
|
+
} else {
|
|
80
36
|
// Check for midgard-yarn-strict definition of catalogs in package.json
|
|
81
|
-
const workspaceSettings = (0,
|
|
82
|
-
if (workspaceSettings &&
|
|
83
|
-
!Array.isArray(workspaceSettings) &&
|
|
84
|
-
(workspaceSettings?.catalog || workspaceSettings?.catalogs)) {
|
|
37
|
+
const workspaceSettings = (0, _getPackageInfo.getPackageInfo)(root)?.workspaces;
|
|
38
|
+
if (workspaceSettings && !Array.isArray(workspaceSettings) && (workspaceSettings?.catalog || workspaceSettings?.catalogs)) {
|
|
85
39
|
// This probably handles a catalog named "default" as the default catalog
|
|
86
40
|
const { default: namedDefaultCatalog, ...namedCatalogs } = workspaceSettings.catalogs || {};
|
|
87
41
|
return {
|
|
88
42
|
default: workspaceSettings.catalog || namedDefaultCatalog,
|
|
89
|
-
named: Object.keys(namedCatalogs).length ? namedCatalogs : undefined
|
|
43
|
+
named: Object.keys(namedCatalogs).length ? namedCatalogs : undefined
|
|
90
44
|
};
|
|
91
45
|
}
|
|
92
46
|
}
|
|
93
|
-
}
|
|
94
|
-
catch (err) {
|
|
95
|
-
(0, logging_1.logVerboseWarning)(`Error getting yarn catalogs for ${cwd}`, err);
|
|
96
47
|
return undefined;
|
|
97
48
|
}
|
|
98
|
-
}
|
|
99
|
-
exports.getYarnCatalogs = getYarnCatalogs;
|
|
100
|
-
exports.getCatalogs = getYarnCatalogs;
|
|
101
|
-
//# sourceMappingURL=yarn.js.map
|
|
49
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/workspaces/implementations/yarn.ts"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { getPackageInfo } from \"../../getPackageInfo.js\";\nimport type { Catalog, NamedCatalogs } from \"../../types/Catalogs.js\";\nimport { readYaml } from \"../../lockfile/readYaml.js\";\nimport type { WorkspaceUtilities } from \"./WorkspaceUtilities.js\";\nimport { getPackageJsonWorkspacePatterns } from \"./getPackageJsonWorkspacePatterns.js\";\n\nexport const yarnUtilities: WorkspaceUtilities = {\n getWorkspacePatterns: getPackageJsonWorkspacePatterns,\n\n // See https://yarnpkg.com/features/catalogs\n getCatalogs: ({ root }) => {\n const yarnrcYmlPath = path.join(root, \".yarnrc.yml\");\n if (fs.existsSync(yarnrcYmlPath)) {\n const yarnrcYml = readYaml<{ catalog?: Catalog; catalogs?: NamedCatalogs }>(yarnrcYmlPath);\n if (yarnrcYml?.catalog || yarnrcYml?.catalogs) {\n // Yarn v4+ format\n return { default: yarnrcYml.catalog, named: yarnrcYml.catalogs };\n }\n } else {\n // Check for midgard-yarn-strict definition of catalogs in package.json\n const workspaceSettings = getPackageInfo(root)?.workspaces;\n if (\n workspaceSettings &&\n !Array.isArray(workspaceSettings) &&\n (workspaceSettings?.catalog || workspaceSettings?.catalogs)\n ) {\n // This probably handles a catalog named \"default\" as the default catalog\n const { default: namedDefaultCatalog, ...namedCatalogs } = workspaceSettings.catalogs || {};\n return {\n default: workspaceSettings.catalog || namedDefaultCatalog,\n named: Object.keys(namedCatalogs).length ? namedCatalogs : undefined,\n };\n }\n }\n return undefined;\n },\n};\n"],"names":["yarnUtilities","getWorkspacePatterns","getPackageJsonWorkspacePatterns","getCatalogs","root","yarnrcYmlPath","path","join","fs","existsSync","yarnrcYml","readYaml","catalog","catalogs","default","named","workspaceSettings","getPackageInfo","workspaces","Array","isArray","namedDefaultCatalog","namedCatalogs","Object","keys","length","undefined"],"mappings":";;;;+BAQaA;;;eAAAA;;;2DARE;6DACE;gCACc;0BAEN;iDAEuB;;;;;;AAEzC,MAAMA,gBAAoC;IAC/CC,sBAAsBC,gEAA+B;IAErD,4CAA4C;IAC5CC,aAAa,CAAC,EAAEC,IAAI,EAAE;QACpB,MAAMC,gBAAgBC,aAAI,CAACC,IAAI,CAACH,MAAM;QACtC,IAAII,WAAE,CAACC,UAAU,CAACJ,gBAAgB;YAChC,MAAMK,YAAYC,IAAAA,kBAAQ,EAAkDN;YAC5E,IAAIK,WAAWE,WAAWF,WAAWG,UAAU;gBAC7C,kBAAkB;gBAClB,OAAO;oBAAEC,SAASJ,UAAUE,OAAO;oBAAEG,OAAOL,UAAUG,QAAQ;gBAAC;YACjE;QACF,OAAO;YACL,uEAAuE;YACvE,MAAMG,oBAAoBC,IAAAA,8BAAc,EAACb,OAAOc;YAChD,IACEF,qBACA,CAACG,MAAMC,OAAO,CAACJ,sBACdA,CAAAA,mBAAmBJ,WAAWI,mBAAmBH,QAAO,GACzD;gBACA,yEAAyE;gBACzE,MAAM,EAAEC,SAASO,mBAAmB,EAAE,GAAGC,eAAe,GAAGN,kBAAkBH,QAAQ,IAAI,CAAC;gBAC1F,OAAO;oBACLC,SAASE,kBAAkBJ,OAAO,IAAIS;oBACtCN,OAAOQ,OAAOC,IAAI,CAACF,eAAeG,MAAM,GAAGH,gBAAgBI;gBAC7D;YACF;QACF;QACA,OAAOA;IACT;AACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { WorkspaceManager } from "../types/WorkspaceManager.js";
|
|
2
|
+
import { type WorkspaceManagerAndRoot } from "./implementations";
|
|
3
|
+
interface WrappedUtilityParams {
|
|
4
|
+
/** Search for the root from here */
|
|
5
|
+
cwd: string;
|
|
6
|
+
/** Optional manager to use instead of auto-detecting */
|
|
7
|
+
managerOverride: WorkspaceManager | undefined;
|
|
8
|
+
/** What the utility is getting (for logging) */
|
|
9
|
+
description: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Wrap a workspace utility function with common error handling and messaging.
|
|
13
|
+
* Also handle getting the manager and root.
|
|
14
|
+
*
|
|
15
|
+
* @returns The utility's return value, or undefined on error (will verbose log on error)
|
|
16
|
+
*/
|
|
17
|
+
export declare function wrapWorkspaceUtility<TReturn>(params: WrappedUtilityParams & {
|
|
18
|
+
/** Implementation of the utility, which receives the detected manager and root */
|
|
19
|
+
impl: (params: WorkspaceManagerAndRoot) => TReturn | undefined;
|
|
20
|
+
}): TReturn | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Wrap a workspace utility function with common error handling and messaging.
|
|
23
|
+
* Also handle getting the manager and root.
|
|
24
|
+
*
|
|
25
|
+
* @returns The utility's return value, or undefined on error (will verbose log on error)
|
|
26
|
+
*/
|
|
27
|
+
export declare function wrapAsyncWorkspaceUtility<TReturn>(params: WrappedUtilityParams & {
|
|
28
|
+
/** Implementation of the utility, which receives the detected manager and root */
|
|
29
|
+
impl: (params: WorkspaceManagerAndRoot) => Promise<TReturn | undefined>;
|
|
30
|
+
}): Promise<TReturn | undefined>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get wrapAsyncWorkspaceUtility () {
|
|
13
|
+
return wrapAsyncWorkspaceUtility;
|
|
14
|
+
},
|
|
15
|
+
get wrapWorkspaceUtility () {
|
|
16
|
+
return wrapWorkspaceUtility;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _logging = require("../logging.js");
|
|
20
|
+
const _implementations = require("./implementations");
|
|
21
|
+
function wrapWorkspaceUtility(params) {
|
|
22
|
+
const { cwd, description, impl } = params;
|
|
23
|
+
let managerInfo;
|
|
24
|
+
try {
|
|
25
|
+
managerInfo = (0, _implementations.getWorkspaceManagerAndRoot)(cwd, undefined, params.managerOverride);
|
|
26
|
+
if (managerInfo) {
|
|
27
|
+
return impl(managerInfo);
|
|
28
|
+
}
|
|
29
|
+
} catch (err) {
|
|
30
|
+
const manager = params.managerOverride || managerInfo?.manager || "unknown manager";
|
|
31
|
+
(0, _logging.logVerboseWarning)(`Error getting ${manager} ${description} for ${cwd}:`, err);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function wrapAsyncWorkspaceUtility(params) {
|
|
35
|
+
const { cwd, description, impl } = params;
|
|
36
|
+
let managerInfo;
|
|
37
|
+
try {
|
|
38
|
+
managerInfo = (0, _implementations.getWorkspaceManagerAndRoot)(cwd, undefined, params.managerOverride);
|
|
39
|
+
if (managerInfo) {
|
|
40
|
+
return await impl(managerInfo);
|
|
41
|
+
}
|
|
42
|
+
} catch (err) {
|
|
43
|
+
const manager = params.managerOverride || managerInfo?.manager || "unknown manager";
|
|
44
|
+
(0, _logging.logVerboseWarning)(`Error getting ${manager} ${description} for ${cwd}:`, err);
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/workspaces/wrapWorkspaceUtility.ts"],"sourcesContent":["import { logVerboseWarning } from \"../logging.js\";\nimport type { WorkspaceManager } from \"../types/WorkspaceManager.js\";\nimport { getWorkspaceManagerAndRoot, type WorkspaceManagerAndRoot } from \"./implementations\";\n\ninterface WrappedUtilityParams {\n /** Search for the root from here */\n cwd: string;\n /** Optional manager to use instead of auto-detecting */\n managerOverride: WorkspaceManager | undefined;\n /** What the utility is getting (for logging) */\n description: string;\n}\n\n/**\n * Wrap a workspace utility function with common error handling and messaging.\n * Also handle getting the manager and root.\n *\n * @returns The utility's return value, or undefined on error (will verbose log on error)\n */\nexport function wrapWorkspaceUtility<TReturn>(\n params: WrappedUtilityParams & {\n /** Implementation of the utility, which receives the detected manager and root */\n impl: (params: WorkspaceManagerAndRoot) => TReturn | undefined;\n }\n): TReturn | undefined {\n const { cwd, description, impl } = params;\n let managerInfo: WorkspaceManagerAndRoot | undefined;\n try {\n managerInfo = getWorkspaceManagerAndRoot(cwd, undefined, params.managerOverride);\n if (managerInfo) {\n return impl(managerInfo);\n }\n } catch (err) {\n const manager = params.managerOverride || managerInfo?.manager || \"unknown manager\";\n logVerboseWarning(`Error getting ${manager} ${description} for ${cwd}:`, err);\n }\n}\n\n/**\n * Wrap a workspace utility function with common error handling and messaging.\n * Also handle getting the manager and root.\n *\n * @returns The utility's return value, or undefined on error (will verbose log on error)\n */\nexport async function wrapAsyncWorkspaceUtility<TReturn>(\n params: WrappedUtilityParams & {\n /** Implementation of the utility, which receives the detected manager and root */\n impl: (params: WorkspaceManagerAndRoot) => Promise<TReturn | undefined>;\n }\n): Promise<TReturn | undefined> {\n const { cwd, description, impl } = params;\n let managerInfo: WorkspaceManagerAndRoot | undefined;\n try {\n managerInfo = getWorkspaceManagerAndRoot(cwd, undefined, params.managerOverride);\n if (managerInfo) {\n return await impl(managerInfo);\n }\n } catch (err) {\n const manager = params.managerOverride || managerInfo?.manager || \"unknown manager\";\n logVerboseWarning(`Error getting ${manager} ${description} for ${cwd}:`, err);\n }\n return undefined;\n}\n"],"names":["wrapAsyncWorkspaceUtility","wrapWorkspaceUtility","params","cwd","description","impl","managerInfo","getWorkspaceManagerAndRoot","undefined","managerOverride","err","manager","logVerboseWarning"],"mappings":";;;;;;;;;;;QA4CsBA;eAAAA;;QAzBNC;eAAAA;;;yBAnBkB;iCAEuC;AAiBlE,SAASA,qBACdC,MAGC;IAED,MAAM,EAAEC,GAAG,EAAEC,WAAW,EAAEC,IAAI,EAAE,GAAGH;IACnC,IAAII;IACJ,IAAI;QACFA,cAAcC,IAAAA,2CAA0B,EAACJ,KAAKK,WAAWN,OAAOO,eAAe;QAC/E,IAAIH,aAAa;YACf,OAAOD,KAAKC;QACd;IACF,EAAE,OAAOI,KAAK;QACZ,MAAMC,UAAUT,OAAOO,eAAe,IAAIH,aAAaK,WAAW;QAClEC,IAAAA,0BAAiB,EAAC,CAAC,cAAc,EAAED,QAAQ,CAAC,EAAEP,YAAY,KAAK,EAAED,IAAI,CAAC,CAAC,EAAEO;IAC3E;AACF;AAQO,eAAeV,0BACpBE,MAGC;IAED,MAAM,EAAEC,GAAG,EAAEC,WAAW,EAAEC,IAAI,EAAE,GAAGH;IACnC,IAAII;IACJ,IAAI;QACFA,cAAcC,IAAAA,2CAA0B,EAACJ,KAAKK,WAAWN,OAAOO,eAAe;QAC/E,IAAIH,aAAa;YACf,OAAO,MAAMD,KAAKC;QACpB;IACF,EAAE,OAAOI,KAAK;QACZ,MAAMC,UAAUT,OAAOO,eAAe,IAAIH,aAAaK,WAAW;QAClEC,IAAAA,0BAAiB,EAAC,CAAC,cAAc,EAAED,QAAQ,CAAC,EAAEP,YAAY,KAAK,EAAED,IAAI,CAAC,CAAC,EAAEO;IAC3E;IACA,OAAOF;AACT"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "workspace-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/microsoft/
|
|
7
|
+
"url": "https://github.com/microsoft/lage",
|
|
8
|
+
"directory": "packages/workspace-tools"
|
|
8
9
|
},
|
|
9
10
|
"main": "lib/index.js",
|
|
10
11
|
"types": "lib/index.d.ts",
|
|
@@ -13,21 +14,29 @@
|
|
|
13
14
|
"lib/!(__*)/**/*"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|
|
16
|
-
"api": "
|
|
17
|
-
"build": "
|
|
18
|
-
"
|
|
19
|
-
"
|
|
17
|
+
"api": "monorepo-scripts api",
|
|
18
|
+
"build": "yarn types && yarn transpile",
|
|
19
|
+
"transpile": "monorepo-scripts transpile",
|
|
20
|
+
"types": "yarn run -T tsc",
|
|
21
|
+
"test": "yarn run -T jest",
|
|
22
|
+
"lint": "monorepo-scripts lint"
|
|
20
23
|
},
|
|
21
24
|
"dependencies": {
|
|
22
25
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
23
|
-
"fast-glob": "^3.3.
|
|
24
|
-
"git-url-parse": "^16.
|
|
25
|
-
"globby": "^11.0.0",
|
|
26
|
+
"fast-glob": "^3.3.3",
|
|
27
|
+
"git-url-parse": "^16.1.0",
|
|
26
28
|
"jju": "^1.4.0",
|
|
27
|
-
"js-yaml": "^4.1.
|
|
28
|
-
"micromatch": "^4.0.
|
|
29
|
+
"js-yaml": "^4.1.1",
|
|
30
|
+
"micromatch": "^4.0.8"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
|
-
"@
|
|
33
|
+
"@lage-run/monorepo-scripts": "^1.0.0",
|
|
34
|
+
"@lage-run/test-utilities": "^0.1.0",
|
|
35
|
+
"@types/git-url-parse": "^16.0.0",
|
|
36
|
+
"@types/jju": "^1.4.2",
|
|
37
|
+
"@types/js-yaml": "^4.0.5",
|
|
38
|
+
"@types/micromatch": "^4.0.0",
|
|
39
|
+
"@types/yarnpkg__lockfile": "^1.1.5",
|
|
40
|
+
"ts-dedent": "^2.2.0"
|
|
32
41
|
}
|
|
33
42
|
}
|
package/lib/getPackagePaths.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Given package folder globs (such as those from package.json `workspaces`) and a monorepo root
|
|
3
|
-
* directory, get absolute 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 monorepo root
|
|
8
|
-
* directory, get absolute paths to actual package folders.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getPackagePathsAsync(root: string, packageGlobs: string[]): Promise<string[]>;
|
package/lib/getPackagePaths.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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.getPackagePathsAsync = exports.getPackagePaths = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
9
|
-
const isCachingEnabled_1 = require("./isCachingEnabled");
|
|
10
|
-
const packagePathsCache = {};
|
|
11
|
-
const globOptions = {
|
|
12
|
-
absolute: true,
|
|
13
|
-
ignore: ["**/node_modules/**", "**/__fixtures__/**"],
|
|
14
|
-
stats: false,
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Given package folder globs (such as those from package.json `workspaces`) and a monorepo root
|
|
18
|
-
* directory, get absolute paths to actual package folders.
|
|
19
|
-
*/
|
|
20
|
-
function getPackagePaths(root, packageGlobs) {
|
|
21
|
-
if ((0, isCachingEnabled_1.isCachingEnabled)() && packagePathsCache[root]) {
|
|
22
|
-
return packagePathsCache[root];
|
|
23
|
-
}
|
|
24
|
-
packagePathsCache[root] = fast_glob_1.default
|
|
25
|
-
.sync(getPackageJsonGlobs(packageGlobs), { cwd: root, ...globOptions })
|
|
26
|
-
.map(getResultPackagePath);
|
|
27
|
-
return packagePathsCache[root];
|
|
28
|
-
}
|
|
29
|
-
exports.getPackagePaths = getPackagePaths;
|
|
30
|
-
/**
|
|
31
|
-
* Given package folder globs (such as those from package.json `workspaces`) and a monorepo root
|
|
32
|
-
* directory, get absolute paths to actual package folders.
|
|
33
|
-
*/
|
|
34
|
-
async function getPackagePathsAsync(root, packageGlobs) {
|
|
35
|
-
if ((0, isCachingEnabled_1.isCachingEnabled)() && packagePathsCache[root]) {
|
|
36
|
-
return packagePathsCache[root];
|
|
37
|
-
}
|
|
38
|
-
packagePathsCache[root] = (await (0, fast_glob_1.default)(getPackageJsonGlobs(packageGlobs), { cwd: root, ...globOptions })).map(getResultPackagePath);
|
|
39
|
-
return packagePathsCache[root];
|
|
40
|
-
}
|
|
41
|
-
exports.getPackagePathsAsync = getPackagePathsAsync;
|
|
42
|
-
function getPackageJsonGlobs(packageGlobs) {
|
|
43
|
-
return packageGlobs.map((glob) => path_1.default.join(glob, "package.json").replace(/\\/g, "/"));
|
|
44
|
-
}
|
|
45
|
-
function getResultPackagePath(packageJsonPath) {
|
|
46
|
-
const packagePath = path_1.default.dirname(packageJsonPath);
|
|
47
|
-
return path_1.default.sep === "/" ? packagePath : packagePath.replace(/\//g, path_1.default.sep);
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=getPackagePaths.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPackagePaths.js","sourceRoot":"","sources":["../src/getPackagePaths.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,0DAA8D;AAC9D,yDAAsD;AAEtD,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,IAAA,mCAAgB,GAAE,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE;QACjD,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,IAAA,mCAAgB,GAAE,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE;QACjD,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"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PackageInfo } from "./types/PackageInfo";
|
|
2
|
-
export declare function infoFromPackageJson(packageJson: {
|
|
3
|
-
name: string;
|
|
4
|
-
version: string;
|
|
5
|
-
dependencies?: {
|
|
6
|
-
[dep: string]: string;
|
|
7
|
-
};
|
|
8
|
-
devDependencies?: {
|
|
9
|
-
[dep: string]: string;
|
|
10
|
-
};
|
|
11
|
-
peerDependencies?: {
|
|
12
|
-
[dep: string]: string;
|
|
13
|
-
};
|
|
14
|
-
private?: boolean;
|
|
15
|
-
pipeline?: any;
|
|
16
|
-
scripts?: any;
|
|
17
|
-
}, packageJsonPath: string): PackageInfo;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.infoFromPackageJson = void 0;
|
|
4
|
-
function infoFromPackageJson(packageJson, packageJsonPath) {
|
|
5
|
-
return {
|
|
6
|
-
packageJsonPath,
|
|
7
|
-
...packageJson,
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
exports.infoFromPackageJson = infoFromPackageJson;
|
|
11
|
-
//# sourceMappingURL=infoFromPackageJson.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"infoFromPackageJson.js","sourceRoot":"","sources":["../src/infoFromPackageJson.ts"],"names":[],"mappings":";;;AAEA,SAAgB,mBAAmB,CACjC,WAeC,EACD,eAAuB;IAEvB,OAAO;QACL,eAAe;QACf,GAAG,WAAW;KACf,CAAC;AACJ,CAAC;AAvBD,kDAuBC"}
|
package/lib/lockfile/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ParsedLock } from "./types";
|
|
2
|
-
import { nameAtVersion } from "./nameAtVersion";
|
|
3
|
-
export declare function parseLockFile(packageRoot: string): Promise<ParsedLock>;
|
|
4
|
-
export { nameAtVersion };
|
|
5
|
-
export { queryLockFile } from "./queryLockFile";
|
|
6
|
-
export * from "./types";
|
package/lib/lockfile/index.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
-
};
|
|
28
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.queryLockFile = exports.nameAtVersion = exports.parseLockFile = void 0;
|
|
33
|
-
// NOTE: never place the import of lockfile implementation here, as it slows down the library as a whole
|
|
34
|
-
const fs_1 = __importDefault(require("fs"));
|
|
35
|
-
const path_1 = __importDefault(require("path"));
|
|
36
|
-
const nameAtVersion_1 = require("./nameAtVersion");
|
|
37
|
-
Object.defineProperty(exports, "nameAtVersion", { enumerable: true, get: function () { return nameAtVersion_1.nameAtVersion; } });
|
|
38
|
-
const paths_1 = require("../paths");
|
|
39
|
-
const parsePnpmLock_1 = require("./parsePnpmLock");
|
|
40
|
-
const parseNpmLock_1 = require("./parseNpmLock");
|
|
41
|
-
const readYaml_1 = require("./readYaml");
|
|
42
|
-
const parseBerryLock_1 = require("./parseBerryLock");
|
|
43
|
-
const memoization = {};
|
|
44
|
-
async function parseLockFile(packageRoot) {
|
|
45
|
-
const yarnLockPath = (0, paths_1.searchUp)(["yarn.lock", "common/config/rush/yarn.lock"], packageRoot);
|
|
46
|
-
// First, test out whether this works for yarn
|
|
47
|
-
if (yarnLockPath) {
|
|
48
|
-
if (memoization[yarnLockPath]) {
|
|
49
|
-
return memoization[yarnLockPath];
|
|
50
|
-
}
|
|
51
|
-
const yarnLock = fs_1.default.readFileSync(yarnLockPath, "utf-8");
|
|
52
|
-
const isBerry = yarnLock.includes("__metadata") || fs_1.default.existsSync(path_1.default.resolve(yarnLock.replace("yarn.lock", ".yarnrc.yml")));
|
|
53
|
-
let parsed = {
|
|
54
|
-
type: "success",
|
|
55
|
-
object: {},
|
|
56
|
-
};
|
|
57
|
-
if (isBerry) {
|
|
58
|
-
const yaml = (0, readYaml_1.readYaml)(yarnLockPath);
|
|
59
|
-
parsed = (0, parseBerryLock_1.parseBerryLock)(yaml);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
const parseYarnLock = (await Promise.resolve().then(() => __importStar(require("@yarnpkg/lockfile")))).parse;
|
|
63
|
-
parsed = parseYarnLock(yarnLock);
|
|
64
|
-
}
|
|
65
|
-
memoization[yarnLockPath] = parsed;
|
|
66
|
-
return parsed;
|
|
67
|
-
}
|
|
68
|
-
// Second, test out whether this works for pnpm
|
|
69
|
-
let pnpmLockPath = (0, paths_1.searchUp)(["pnpm-lock.yaml", "common/config/rush/pnpm-lock.yaml"], packageRoot);
|
|
70
|
-
if (pnpmLockPath) {
|
|
71
|
-
if (memoization[pnpmLockPath]) {
|
|
72
|
-
return memoization[pnpmLockPath];
|
|
73
|
-
}
|
|
74
|
-
const yaml = (0, readYaml_1.readYaml)(pnpmLockPath);
|
|
75
|
-
const parsed = (0, parsePnpmLock_1.parsePnpmLock)(yaml);
|
|
76
|
-
memoization[pnpmLockPath] = parsed;
|
|
77
|
-
return memoization[pnpmLockPath];
|
|
78
|
-
}
|
|
79
|
-
// Third, try for npm workspaces
|
|
80
|
-
let npmLockPath = (0, paths_1.searchUp)("package-lock.json", packageRoot);
|
|
81
|
-
if (npmLockPath) {
|
|
82
|
-
if (memoization[npmLockPath]) {
|
|
83
|
-
return memoization[npmLockPath];
|
|
84
|
-
}
|
|
85
|
-
let npmLockJson;
|
|
86
|
-
try {
|
|
87
|
-
npmLockJson = fs_1.default.readFileSync(npmLockPath, "utf-8");
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
throw new Error("Couldn't read package-lock.json");
|
|
91
|
-
}
|
|
92
|
-
const npmLock = JSON.parse(npmLockJson.toString());
|
|
93
|
-
if (!npmLock?.lockfileVersion || npmLock.lockfileVersion < 2) {
|
|
94
|
-
throw new Error(`Your package-lock.json version is not supported: lockfileVersion is ${npmLock.lockfileVersion}. You need npm version 7 or above and package-lock version 2 or above. Please, upgrade npm or choose a different package manager.`);
|
|
95
|
-
}
|
|
96
|
-
memoization[npmLockPath] = (0, parseNpmLock_1.parseNpmLock)(npmLock);
|
|
97
|
-
return memoization[npmLockPath];
|
|
98
|
-
}
|
|
99
|
-
throw new Error("You do not have yarn.lock, pnpm-lock.yaml or package-lock.json. Please use one of these package managers.");
|
|
100
|
-
}
|
|
101
|
-
exports.parseLockFile = parseLockFile;
|
|
102
|
-
var queryLockFile_1 = require("./queryLockFile");
|
|
103
|
-
Object.defineProperty(exports, "queryLockFile", { enumerable: true, get: function () { return queryLockFile_1.queryLockFile; } });
|
|
104
|
-
__exportStar(require("./types"), exports);
|
|
105
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lockfile/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspaceManager.js","sourceRoot":"","sources":["../../src/workspaces/WorkspaceManager.ts"],"names":[],"mappings":""}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { WorkspaceInfos } from "../types/WorkspaceInfo";
|
|
2
|
-
/**
|
|
3
|
-
* Get an array with names, paths, and package.json contents for each of the given package paths
|
|
4
|
-
* ("workspace" paths in npm/yarn/pnpm terms) within a monorepo.
|
|
5
|
-
*
|
|
6
|
-
* This is an internal helper used by `getWorkspaces` implementations for different managers.
|
|
7
|
-
*
|
|
8
|
-
* @param packagePaths Paths to packages within a monorepo
|
|
9
|
-
* @returns Array of monorepo package infos
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export declare function getWorkspacePackageInfo(packagePaths: string[]): WorkspaceInfos;
|
|
13
|
-
/**
|
|
14
|
-
* Get an array with names, paths, and package.json contents for each of the given package paths
|
|
15
|
-
* ("workspace" paths in npm/yarn/pnpm terms) within a monorepo.
|
|
16
|
-
*
|
|
17
|
-
* NOTE: As of writing, this will start promises to read all package.json files in parallel,
|
|
18
|
-
* without direct concurrency control.
|
|
19
|
-
*
|
|
20
|
-
* This is an internal helper used by `getWorkspaces` implementations for different managers.
|
|
21
|
-
*
|
|
22
|
-
* @param packagePaths Paths to packages within a monorepo
|
|
23
|
-
* @returns Array of monorepo package infos
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
export declare function getWorkspacePackageInfoAsync(packagePaths: string[]): Promise<WorkspaceInfos>;
|
|
@@ -1,76 +0,0 @@
|
|
|
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.getWorkspacePackageInfoAsync = exports.getWorkspacePackageInfo = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
-
const logging_1 = require("../logging");
|
|
10
|
-
const infoFromPackageJson_1 = require("../infoFromPackageJson");
|
|
11
|
-
const getPackageInfo_1 = require("../getPackageInfo");
|
|
12
|
-
/**
|
|
13
|
-
* Get an array with names, paths, and package.json contents for each of the given package paths
|
|
14
|
-
* ("workspace" paths in npm/yarn/pnpm terms) within a monorepo.
|
|
15
|
-
*
|
|
16
|
-
* This is an internal helper used by `getWorkspaces` implementations for different managers.
|
|
17
|
-
*
|
|
18
|
-
* @param packagePaths Paths to packages within a monorepo
|
|
19
|
-
* @returns Array of monorepo package infos
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
function getWorkspacePackageInfo(packagePaths) {
|
|
23
|
-
if (!packagePaths) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
return packagePaths
|
|
27
|
-
.map((workspacePath) => {
|
|
28
|
-
const packageJson = (0, getPackageInfo_1.getPackageInfo)(workspacePath);
|
|
29
|
-
if (!packageJson) {
|
|
30
|
-
return null; // getPackageInfo already logged a warning
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
name: packageJson.name,
|
|
34
|
-
path: workspacePath,
|
|
35
|
-
packageJson,
|
|
36
|
-
};
|
|
37
|
-
})
|
|
38
|
-
.filter(Boolean);
|
|
39
|
-
}
|
|
40
|
-
exports.getWorkspacePackageInfo = getWorkspacePackageInfo;
|
|
41
|
-
/**
|
|
42
|
-
* Get an array with names, paths, and package.json contents for each of the given package paths
|
|
43
|
-
* ("workspace" paths in npm/yarn/pnpm terms) within a monorepo.
|
|
44
|
-
*
|
|
45
|
-
* NOTE: As of writing, this will start promises to read all package.json files in parallel,
|
|
46
|
-
* without direct concurrency control.
|
|
47
|
-
*
|
|
48
|
-
* This is an internal helper used by `getWorkspaces` implementations for different managers.
|
|
49
|
-
*
|
|
50
|
-
* @param packagePaths Paths to packages within a monorepo
|
|
51
|
-
* @returns Array of monorepo package infos
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
async function getWorkspacePackageInfoAsync(packagePaths) {
|
|
55
|
-
if (!packagePaths) {
|
|
56
|
-
return [];
|
|
57
|
-
}
|
|
58
|
-
const workspacePkgPromises = packagePaths.map(async (workspacePath) => {
|
|
59
|
-
const packageJsonPath = path_1.default.join(workspacePath, "package.json");
|
|
60
|
-
try {
|
|
61
|
-
const packageJson = JSON.parse(await promises_1.default.readFile(packageJsonPath, "utf-8"));
|
|
62
|
-
return {
|
|
63
|
-
name: packageJson.name,
|
|
64
|
-
path: workspacePath,
|
|
65
|
-
packageJson: (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
(0, logging_1.logVerboseWarning)(`Error reading or parsing ${packageJsonPath} while getting monorepo package info`, err);
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
return (await Promise.all(workspacePkgPromises)).filter(Boolean);
|
|
74
|
-
}
|
|
75
|
-
exports.getWorkspacePackageInfoAsync = getWorkspacePackageInfoAsync;
|
|
76
|
-
//# sourceMappingURL=getWorkspacePackageInfo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getWorkspacePackageInfo.js","sourceRoot":"","sources":["../../src/workspaces/getWorkspacePackageInfo.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,2DAAqC;AAGrC,wCAA+C;AAC/C,gEAA6D;AAC7D,sDAAmD;AAEnD;;;;;;;;;GASG;AACH,SAAgB,uBAAuB,CAAC,YAAsB;IAC5D,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,EAAE,CAAC;KACX;IAED,OAAO,YAAY;SAChB,GAAG,CAA8B,CAAC,aAAa,EAAE,EAAE;QAClD,MAAM,WAAW,GAAG,IAAA,+BAAc,EAAC,aAAa,CAAC,CAAC;QAClD,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,IAAI,CAAC,CAAC,0CAA0C;SACxD;QAED,OAAO;YACL,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,aAAa;YACnB,WAAW;SACZ,CAAC;IACJ,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAmB,CAAC;AACvC,CAAC;AAnBD,0DAmBC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,4BAA4B,CAAC,YAAsB;IACvE,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,oBAAoB,GAAG,YAAY,CAAC,GAAG,CAAuC,KAAK,EAAE,aAAa,EAAE,EAAE;QAC1G,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QAEjE,IAAI;YACF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,kBAAU,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAgB,CAAC;YACnG,OAAO;gBACL,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,IAAA,yCAAmB,EAAC,WAAW,EAAE,eAAe,CAAC;aAC/D,CAAC;SACH;QAAC,OAAO,GAAG,EAAE;YACZ,IAAA,2BAAiB,EAAC,4BAA4B,eAAe,sCAAsC,EAAE,GAAG,CAAC,CAAC;YAC1G,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAmB,CAAC;AACrF,CAAC;AAtBD,oEAsBC"}
|