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
package/lib/scope.js
CHANGED
|
@@ -1,49 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getScopedPackages", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getScopedPackages;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _micromatch = /*#__PURE__*/ _interop_require_default(require("micromatch"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
12
17
|
function getScopedPackages(search, packages) {
|
|
13
18
|
const packageNames = Array.isArray(packages) ? packages : Object.keys(packages);
|
|
14
19
|
const results = new Set();
|
|
15
20
|
// perform a package-scoped search (e.g. search is @scope/foo*)
|
|
16
|
-
const scopedSearch = search.filter((needle)
|
|
21
|
+
const scopedSearch = search.filter((needle)=>needle.startsWith("@") || needle.startsWith("!@"));
|
|
17
22
|
if (scopedSearch.length > 0) {
|
|
18
|
-
const matched = (0,
|
|
19
|
-
|
|
23
|
+
const matched = (0, _micromatch.default)(packageNames, scopedSearch, {
|
|
24
|
+
nocase: true
|
|
25
|
+
});
|
|
26
|
+
for (const pkg of matched){
|
|
20
27
|
results.add(pkg);
|
|
21
28
|
}
|
|
22
29
|
}
|
|
23
30
|
// perform a package-unscoped search (e.g. search is foo*)
|
|
24
|
-
const unscopedSearch = search.filter((needle)
|
|
31
|
+
const unscopedSearch = search.filter((needle)=>!needle.startsWith("@") && !needle.startsWith("!@"));
|
|
25
32
|
if (unscopedSearch.length > 0) {
|
|
26
33
|
// only generate the bare package map if there ARE unscoped searches
|
|
27
34
|
const barePackageMap = generateBarePackageMap(packageNames);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
const matched = (0, _micromatch.default)(Object.keys(barePackageMap), unscopedSearch, {
|
|
36
|
+
nocase: true
|
|
37
|
+
});
|
|
38
|
+
for (const bare of matched){
|
|
39
|
+
for (const pkg of barePackageMap[bare]){
|
|
31
40
|
results.add(pkg);
|
|
32
41
|
}
|
|
33
42
|
}
|
|
34
43
|
}
|
|
35
|
-
return [
|
|
44
|
+
return [
|
|
45
|
+
...results
|
|
46
|
+
];
|
|
36
47
|
}
|
|
37
|
-
exports.getScopedPackages = getScopedPackages;
|
|
38
48
|
function generateBarePackageMap(packageNames) {
|
|
39
49
|
const barePackageMap = {};
|
|
40
50
|
// create a map of bare package name -> list of full package names
|
|
41
51
|
// NOTE: do not perform barePackageMap lookup if any of the "scopes" arg starts with "@"
|
|
42
|
-
for (const pkg of packageNames)
|
|
52
|
+
for (const pkg of packageNames){
|
|
43
53
|
const bare = pkg.replace(/^@[^/]+\//, "");
|
|
44
54
|
barePackageMap[bare] = barePackageMap[bare] || [];
|
|
45
55
|
barePackageMap[bare].push(pkg);
|
|
46
56
|
}
|
|
47
57
|
return barePackageMap;
|
|
48
58
|
}
|
|
49
|
-
//# sourceMappingURL=scope.js.map
|
package/lib/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/scope.ts"],"sourcesContent":["import micromatch from \"micromatch\";\n\n/**\n * Searches all package names based on \"scoping\" (i.e. \"scope\" in the sense of inclusion).\n * NOTE: this is not the same as package scopes (`@scope/package`).\n */\nexport function getScopedPackages(search: string[], packages: { [pkg: string]: unknown } | string[]): string[] {\n const packageNames = Array.isArray(packages) ? packages : Object.keys(packages);\n\n const results = new Set<string>();\n\n // perform a package-scoped search (e.g. search is @scope/foo*)\n const scopedSearch = search.filter((needle) => needle.startsWith(\"@\") || needle.startsWith(\"!@\"));\n if (scopedSearch.length > 0) {\n const matched = micromatch(packageNames, scopedSearch, { nocase: true });\n for (const pkg of matched) {\n results.add(pkg);\n }\n }\n\n // perform a package-unscoped search (e.g. search is foo*)\n const unscopedSearch = search.filter((needle) => !needle.startsWith(\"@\") && !needle.startsWith(\"!@\"));\n if (unscopedSearch.length > 0) {\n // only generate the bare package map if there ARE unscoped searches\n const barePackageMap = generateBarePackageMap(packageNames);\n\n const matched = micromatch(Object.keys(barePackageMap), unscopedSearch, { nocase: true });\n for (const bare of matched) {\n for (const pkg of barePackageMap[bare]) {\n results.add(pkg);\n }\n }\n }\n\n return [...results];\n}\n\nfunction generateBarePackageMap(packageNames: string[]) {\n const barePackageMap: { [key: string]: string[] } = {};\n\n // create a map of bare package name -> list of full package names\n // NOTE: do not perform barePackageMap lookup if any of the \"scopes\" arg starts with \"@\"\n for (const pkg of packageNames) {\n const bare = pkg.replace(/^@[^/]+\\//, \"\");\n barePackageMap[bare] = barePackageMap[bare] || [];\n barePackageMap[bare].push(pkg);\n }\n\n return barePackageMap;\n}\n"],"names":["getScopedPackages","search","packages","packageNames","Array","isArray","Object","keys","results","Set","scopedSearch","filter","needle","startsWith","length","matched","micromatch","nocase","pkg","add","unscopedSearch","barePackageMap","generateBarePackageMap","bare","replace","push"],"mappings":";;;;+BAMgBA;;;eAAAA;;;mEANO;;;;;;AAMhB,SAASA,kBAAkBC,MAAgB,EAAEC,QAA+C;IACjG,MAAMC,eAAeC,MAAMC,OAAO,CAACH,YAAYA,WAAWI,OAAOC,IAAI,CAACL;IAEtE,MAAMM,UAAU,IAAIC;IAEpB,+DAA+D;IAC/D,MAAMC,eAAeT,OAAOU,MAAM,CAAC,CAACC,SAAWA,OAAOC,UAAU,CAAC,QAAQD,OAAOC,UAAU,CAAC;IAC3F,IAAIH,aAAaI,MAAM,GAAG,GAAG;QAC3B,MAAMC,UAAUC,IAAAA,mBAAU,EAACb,cAAcO,cAAc;YAAEO,QAAQ;QAAK;QACtE,KAAK,MAAMC,OAAOH,QAAS;YACzBP,QAAQW,GAAG,CAACD;QACd;IACF;IAEA,0DAA0D;IAC1D,MAAME,iBAAiBnB,OAAOU,MAAM,CAAC,CAACC,SAAW,CAACA,OAAOC,UAAU,CAAC,QAAQ,CAACD,OAAOC,UAAU,CAAC;IAC/F,IAAIO,eAAeN,MAAM,GAAG,GAAG;QAC7B,oEAAoE;QACpE,MAAMO,iBAAiBC,uBAAuBnB;QAE9C,MAAMY,UAAUC,IAAAA,mBAAU,EAACV,OAAOC,IAAI,CAACc,iBAAiBD,gBAAgB;YAAEH,QAAQ;QAAK;QACvF,KAAK,MAAMM,QAAQR,QAAS;YAC1B,KAAK,MAAMG,OAAOG,cAAc,CAACE,KAAK,CAAE;gBACtCf,QAAQW,GAAG,CAACD;YACd;QACF;IACF;IAEA,OAAO;WAAIV;KAAQ;AACrB;AAEA,SAASc,uBAAuBnB,YAAsB;IACpD,MAAMkB,iBAA8C,CAAC;IAErD,kEAAkE;IAClE,wFAAwF;IACxF,KAAK,MAAMH,OAAOf,aAAc;QAC9B,MAAMoB,OAAOL,IAAIM,OAAO,CAAC,aAAa;QACtCH,cAAc,CAACE,KAAK,GAAGF,cAAc,CAACE,KAAK,IAAI,EAAE;QACjDF,cAAc,CAACE,KAAK,CAACE,IAAI,CAACP;IAC5B;IAEA,OAAOG;AACT"}
|
package/lib/types/Catalogs.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Mapping from package name to package version.
|
|
3
|
+
* @see https://pnpm.io/catalogs#default-catalog
|
|
4
|
+
* @see https://yarnpkg.com/features/catalogs#basic-usage
|
|
5
|
+
*/ "use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/types/Catalogs.ts"],"sourcesContent":["/**\n * Mapping from package name to package version.\n * @see https://pnpm.io/catalogs#default-catalog\n * @see https://yarnpkg.com/features/catalogs#basic-usage\n */\nexport interface Catalog {\n [packageName: string]: string;\n}\n\n/**\n * Mapping from catalog name (non-default) to catalog definition\n * @see https://pnpm.io/catalogs#named-catalogs\n * @see https://yarnpkg.com/features/catalogs#named-catalogs\n */\nexport interface NamedCatalogs {\n [catalogName: string]: Catalog;\n}\n\n/**\n * Package version catalogs\n * @see https://pnpm.io/catalogs\n * @see https://yarnpkg.com/features/catalogs\n */\nexport interface Catalogs {\n /**\n * The default catalog (`catalog:`) if present.\n *\n * Whether this is equivalent to `catalogs.default` depends on the package manager:\n * they're the same in pnpm, but different in yarn. If there was a pnpm catalog named \"default\",\n * it will be stored under this property instead (but `getCatalogVersion` supports either syntax).\n */\n default?: Catalog;\n\n /**\n * Mapping from catalog name to catalog definition, if present.\n *\n * (For pnpm, if there was a catalog named \"default\", it will be under `Catalogs.default`\n * and omitted here.)\n */\n named?: NamedCatalogs;\n}\n"],"names":[],"mappings":"AAAA;;;;CAIC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/** A package graph edge that defines a single package name and one of its dependency */
|
|
2
2
|
export interface PackageDependency {
|
|
3
|
+
/** Name of a package */
|
|
3
4
|
name: string;
|
|
5
|
+
/** A dependency of `name` */
|
|
4
6
|
dependency: string;
|
|
5
7
|
}
|
|
6
|
-
/** The graph is defined by as a list of package names as nodes, and a list of
|
|
8
|
+
/** The graph is defined by as a list of package names as nodes, and a list of dependencies as edges */
|
|
7
9
|
export interface PackageGraph {
|
|
10
|
+
/** Nodes: list of package names */
|
|
8
11
|
packages: string[];
|
|
12
|
+
/** Edges: list of package dependencies */
|
|
9
13
|
dependencies: PackageDependency[];
|
|
10
14
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
1
|
+
/** A package graph edge that defines a single package name and one of its dependency */ "use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/types/PackageGraph.ts"],"sourcesContent":["/** A package graph edge that defines a single package name and one of its dependency */\nexport interface PackageDependency {\n /** Name of a package */\n name: string;\n /** A dependency of `name` */\n dependency: string;\n}\n\n/** The graph is defined by as a list of package names as nodes, and a list of dependencies as edges */\nexport interface PackageGraph {\n /** Nodes: list of package names */\n packages: string[];\n\n /** Edges: list of package dependencies */\n dependencies: PackageDependency[];\n}\n"],"names":[],"mappings":"AAAA,sFAAsF"}
|
package/lib/types/PackageInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PackageInfo } from "./PackageInfo";
|
|
1
|
+
import { type PackageInfo } from "./PackageInfo.js";
|
|
2
2
|
/**
|
|
3
3
|
* Info about a single package ("workspace" in npm/yarn/pnpm terms) within a monorepo.
|
|
4
4
|
*
|
|
5
|
-
* Ideally this should be called just `WorkspaceInfo`,
|
|
6
|
-
* aggregate type.
|
|
5
|
+
* (Ideally this should be called just `WorkspaceInfo`, since "workspace" and "package" mean
|
|
6
|
+
* the same thing, but that name was previously used for the aggregate type.)
|
|
7
7
|
*/
|
|
8
8
|
export interface WorkspacePackageInfo {
|
|
9
9
|
/** Package name */
|
|
@@ -18,5 +18,3 @@ export interface WorkspacePackageInfo {
|
|
|
18
18
|
* npm/yarn/pnpm terms) within a monorepo.
|
|
19
19
|
*/
|
|
20
20
|
export type WorkspaceInfos = WorkspacePackageInfo[];
|
|
21
|
-
/** @deprecated Use `WorkspaceInfos` */
|
|
22
|
-
export type WorkspaceInfo = WorkspaceInfos;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "catalogsToYaml", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return catalogsToYaml;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
7
11
|
function catalogsToYaml(catalogs, options = {}) {
|
|
8
12
|
const { named, default: defaultCatalog } = catalogs;
|
|
9
13
|
const lines = [];
|
|
10
14
|
const indent = typeof options.indent === "string" ? options.indent : " ".repeat(options.indent ?? 2);
|
|
11
15
|
if (defaultCatalog) {
|
|
12
16
|
lines.push("catalog:");
|
|
13
|
-
for (const [pkg, version] of Object.entries(defaultCatalog))
|
|
17
|
+
for (const [pkg, version] of Object.entries(defaultCatalog)){
|
|
14
18
|
lines.push(`${indent}${pkg}: ${version}`);
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
21
|
if (named) {
|
|
18
22
|
lines.push("catalogs:");
|
|
19
|
-
for (const [catalogName, catalogEntries] of Object.entries(named))
|
|
23
|
+
for (const [catalogName, catalogEntries] of Object.entries(named)){
|
|
20
24
|
lines.push(`${indent}${catalogName}:`);
|
|
21
|
-
for (const [pkg, version] of Object.entries(catalogEntries))
|
|
25
|
+
for (const [pkg, version] of Object.entries(catalogEntries)){
|
|
22
26
|
lines.push(`${indent}${indent}${pkg}: ${version}`);
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
return lines.join("\n");
|
|
27
31
|
}
|
|
28
|
-
exports.catalogsToYaml = catalogsToYaml;
|
|
29
|
-
//# sourceMappingURL=catalogsToYaml.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/workspaces/catalogsToYaml.ts"],"sourcesContent":["import type { Catalogs } from \"../types/Catalogs.js\";\n\n/**\n * Convert catalogs to the yaml format used by yarn v4 and pnpm.\n */\nexport function catalogsToYaml(\n catalogs: Catalogs,\n options: {\n /** Number of spaces (default 2), or another indentation character */\n indent?: number | string;\n } = {}\n): string {\n const { named, default: defaultCatalog } = catalogs;\n const lines: string[] = [];\n const indent = typeof options.indent === \"string\" ? options.indent : \" \".repeat(options.indent ?? 2);\n\n if (defaultCatalog) {\n lines.push(\"catalog:\");\n for (const [pkg, version] of Object.entries(defaultCatalog)) {\n lines.push(`${indent}${pkg}: ${version}`);\n }\n }\n\n if (named) {\n lines.push(\"catalogs:\");\n for (const [catalogName, catalogEntries] of Object.entries(named)) {\n lines.push(`${indent}${catalogName}:`);\n for (const [pkg, version] of Object.entries(catalogEntries)) {\n lines.push(`${indent}${indent}${pkg}: ${version}`);\n }\n }\n }\n\n return lines.join(\"\\n\");\n}\n"],"names":["catalogsToYaml","catalogs","options","named","default","defaultCatalog","lines","indent","repeat","push","pkg","version","Object","entries","catalogName","catalogEntries","join"],"mappings":";;;;+BAKgBA;;;eAAAA;;;AAAT,SAASA,eACdC,QAAkB,EAClBC,UAGI,CAAC,CAAC;IAEN,MAAM,EAAEC,KAAK,EAAEC,SAASC,cAAc,EAAE,GAAGJ;IAC3C,MAAMK,QAAkB,EAAE;IAC1B,MAAMC,SAAS,OAAOL,QAAQK,MAAM,KAAK,WAAWL,QAAQK,MAAM,GAAG,IAAIC,MAAM,CAACN,QAAQK,MAAM,IAAI;IAElG,IAAIF,gBAAgB;QAClBC,MAAMG,IAAI,CAAC;QACX,KAAK,MAAM,CAACC,KAAKC,QAAQ,IAAIC,OAAOC,OAAO,CAACR,gBAAiB;YAC3DC,MAAMG,IAAI,CAAC,GAAGF,SAASG,IAAI,EAAE,EAAEC,SAAS;QAC1C;IACF;IAEA,IAAIR,OAAO;QACTG,MAAMG,IAAI,CAAC;QACX,KAAK,MAAM,CAACK,aAAaC,eAAe,IAAIH,OAAOC,OAAO,CAACV,OAAQ;YACjEG,MAAMG,IAAI,CAAC,GAAGF,SAASO,YAAY,CAAC,CAAC;YACrC,KAAK,MAAM,CAACJ,KAAKC,QAAQ,IAAIC,OAAOC,OAAO,CAACE,gBAAiB;gBAC3DT,MAAMG,IAAI,CAAC,GAAGF,SAASA,SAASG,IAAI,EAAE,EAAEC,SAAS;YACnD;QACF;IACF;IAEA,OAAOL,MAAMU,IAAI,CAAC;AACpB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { WorkspaceInfos } from "../types/WorkspaceInfo";
|
|
1
|
+
import type { WorkspaceInfos } from "../types/WorkspaceInfo.js";
|
|
2
2
|
/**
|
|
3
3
|
* Find the path for a particular package name from an array of info about packages ("workspaces"
|
|
4
4
|
* in npm/yarn/pnpm terms) within a monorepo.
|
|
5
5
|
* @param workspaces Array of info about packages within a monorepo
|
|
6
6
|
* @param packageName Package name to find
|
|
7
7
|
* @returns Package path if found, or undefined
|
|
8
|
+
* @deprecated Just write `workspaces.find(({ name }) => name === packageName)?.path` instead
|
|
8
9
|
*/
|
|
9
10
|
export declare function findWorkspacePath(workspaces: WorkspaceInfos, packageName: string): string | undefined;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "findWorkspacePath", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return findWorkspacePath;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
11
|
function findWorkspacePath(workspaces, packageName) {
|
|
12
|
-
return workspaces.find(({ name })
|
|
12
|
+
return workspaces.find(({ name })=>name === packageName)?.path;
|
|
13
13
|
}
|
|
14
|
-
exports.findWorkspacePath = findWorkspacePath;
|
|
15
|
-
//# sourceMappingURL=findWorkspacePath.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/workspaces/findWorkspacePath.ts"],"sourcesContent":["import type { WorkspaceInfos } from \"../types/WorkspaceInfo.js\";\n\n/**\n * Find the path for a particular package name from an array of info about packages (\"workspaces\"\n * in npm/yarn/pnpm terms) within a monorepo.\n * @param workspaces Array of info about packages within a monorepo\n * @param packageName Package name to find\n * @returns Package path if found, or undefined\n * @deprecated Just write `workspaces.find(({ name }) => name === packageName)?.path` instead\n */\nexport function findWorkspacePath(workspaces: WorkspaceInfos, packageName: string): string | undefined {\n return workspaces.find(({ name }) => name === packageName)?.path;\n}\n"],"names":["findWorkspacePath","workspaces","packageName","find","name","path"],"mappings":";;;;+BAUgBA;;;eAAAA;;;AAAT,SAASA,kBAAkBC,UAA0B,EAAEC,WAAmB;IAC/E,OAAOD,WAAWE,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASF,cAAcG;AAC9D"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Get paths to every package.json in the monorepo, given a cwd.
|
|
2
|
+
* Get paths to every package.json in the monorepo, given a cwd, with caching.
|
|
3
|
+
*
|
|
4
|
+
* @returns Array of package.json paths, or undefined if there's any issue
|
|
5
|
+
* (logs verbose warnings instead of throwing on error)
|
|
3
6
|
*/
|
|
4
|
-
export declare function getAllPackageJsonFiles(cwd: string): string[];
|
|
7
|
+
export declare function getAllPackageJsonFiles(cwd: string): string[] | undefined;
|
|
5
8
|
export declare function _resetPackageJsonFilesCache(): void;
|
|
6
9
|
/**
|
|
7
|
-
* Get paths to every package.json in the monorepo, given a cwd.
|
|
10
|
+
* Get paths to every package.json in the monorepo, given a cwd, with caching.
|
|
11
|
+
*
|
|
12
|
+
* @returns Array of package.json paths, or undefined if there's any issue
|
|
13
|
+
* (logs verbose warnings instead of throwing on error)
|
|
8
14
|
*/
|
|
9
|
-
export declare function getAllPackageJsonFilesAsync(cwd: string): Promise<string[]>;
|
|
15
|
+
export declare function getAllPackageJsonFilesAsync(cwd: string): Promise<string[] | undefined>;
|
|
@@ -1,39 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 _resetPackageJsonFilesCache () {
|
|
13
|
+
return _resetPackageJsonFilesCache;
|
|
14
|
+
},
|
|
15
|
+
get getAllPackageJsonFiles () {
|
|
16
|
+
return getAllPackageJsonFiles;
|
|
17
|
+
},
|
|
18
|
+
get getAllPackageJsonFilesAsync () {
|
|
19
|
+
return getAllPackageJsonFilesAsync;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
23
|
+
const _getWorkspacePackagePaths = require("./getWorkspacePackagePaths.js");
|
|
24
|
+
const _isCachingEnabled = require("../isCachingEnabled.js");
|
|
25
|
+
function _interop_require_default(obj) {
|
|
26
|
+
return obj && obj.__esModule ? obj : {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
10
30
|
const cache = new Map();
|
|
11
|
-
/**
|
|
12
|
-
* Get paths to every package.json in the monorepo, given a cwd.
|
|
13
|
-
*/
|
|
14
31
|
function getAllPackageJsonFiles(cwd) {
|
|
15
|
-
if ((0,
|
|
32
|
+
if ((0, _isCachingEnabled.isCachingEnabled)() && cache.has(cwd)) {
|
|
16
33
|
return cache.get(cwd);
|
|
17
34
|
}
|
|
18
|
-
const packageJsonFiles = (0,
|
|
35
|
+
const packageJsonFiles = (0, _getWorkspacePackagePaths.getWorkspacePackagePaths)(cwd)?.map((packagePath)=>_path.default.join(packagePath, "package.json"));
|
|
19
36
|
cache.set(cwd, packageJsonFiles);
|
|
20
37
|
return packageJsonFiles;
|
|
21
38
|
}
|
|
22
|
-
exports.getAllPackageJsonFiles = getAllPackageJsonFiles;
|
|
23
39
|
function _resetPackageJsonFilesCache() {
|
|
24
40
|
cache.clear();
|
|
25
41
|
}
|
|
26
|
-
exports._resetPackageJsonFilesCache = _resetPackageJsonFilesCache;
|
|
27
|
-
/**
|
|
28
|
-
* Get paths to every package.json in the monorepo, given a cwd.
|
|
29
|
-
*/
|
|
30
42
|
async function getAllPackageJsonFilesAsync(cwd) {
|
|
31
|
-
if ((0,
|
|
43
|
+
if ((0, _isCachingEnabled.isCachingEnabled)() && cache.has(cwd)) {
|
|
32
44
|
return cache.get(cwd);
|
|
33
45
|
}
|
|
34
|
-
const packageJsonFiles = (await (0,
|
|
46
|
+
const packageJsonFiles = (await (0, _getWorkspacePackagePaths.getWorkspacePackagePathsAsync)(cwd))?.map((packagePath)=>_path.default.join(packagePath, "package.json"));
|
|
35
47
|
cache.set(cwd, packageJsonFiles);
|
|
36
48
|
return packageJsonFiles;
|
|
37
49
|
}
|
|
38
|
-
exports.getAllPackageJsonFilesAsync = getAllPackageJsonFilesAsync;
|
|
39
|
-
//# sourceMappingURL=getAllPackageJsonFiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/workspaces/getAllPackageJsonFiles.ts"],"sourcesContent":["import path from \"path\";\nimport { getWorkspacePackagePaths, getWorkspacePackagePathsAsync } from \"./getWorkspacePackagePaths.js\";\nimport { isCachingEnabled } from \"../isCachingEnabled.js\";\n\nconst cache = new Map<string, string[] | undefined>();\n\n/**\n * Get paths to every package.json in the monorepo, given a cwd, with caching.\n *\n * @returns Array of package.json paths, or undefined if there's any issue\n * (logs verbose warnings instead of throwing on error)\n */\nexport function getAllPackageJsonFiles(cwd: string): string[] | undefined {\n if (isCachingEnabled() && cache.has(cwd)) {\n return cache.get(cwd)!;\n }\n\n const packageJsonFiles = getWorkspacePackagePaths(cwd)?.map((packagePath) => path.join(packagePath, \"package.json\"));\n\n cache.set(cwd, packageJsonFiles);\n\n return packageJsonFiles;\n}\n\nexport function _resetPackageJsonFilesCache(): void {\n cache.clear();\n}\n\n/**\n * Get paths to every package.json in the monorepo, given a cwd, with caching.\n *\n * @returns Array of package.json paths, or undefined if there's any issue\n * (logs verbose warnings instead of throwing on error)\n */\nexport async function getAllPackageJsonFilesAsync(cwd: string): Promise<string[] | undefined> {\n if (isCachingEnabled() && cache.has(cwd)) {\n return cache.get(cwd)!;\n }\n\n const packageJsonFiles = (await getWorkspacePackagePathsAsync(cwd))?.map((packagePath) =>\n path.join(packagePath, \"package.json\")\n );\n\n cache.set(cwd, packageJsonFiles);\n\n return packageJsonFiles;\n}\n"],"names":["_resetPackageJsonFilesCache","getAllPackageJsonFiles","getAllPackageJsonFilesAsync","cache","Map","cwd","isCachingEnabled","has","get","packageJsonFiles","getWorkspacePackagePaths","map","packagePath","path","join","set","clear","getWorkspacePackagePathsAsync"],"mappings":";;;;;;;;;;;QAwBgBA;eAAAA;;QAZAC;eAAAA;;QAsBMC;eAAAA;;;6DAlCL;0CACuD;kCACvC;;;;;;AAEjC,MAAMC,QAAQ,IAAIC;AAQX,SAASH,uBAAuBI,GAAW;IAChD,IAAIC,IAAAA,kCAAgB,OAAMH,MAAMI,GAAG,CAACF,MAAM;QACxC,OAAOF,MAAMK,GAAG,CAACH;IACnB;IAEA,MAAMI,mBAAmBC,IAAAA,kDAAwB,EAACL,MAAMM,IAAI,CAACC,cAAgBC,aAAI,CAACC,IAAI,CAACF,aAAa;IAEpGT,MAAMY,GAAG,CAACV,KAAKI;IAEf,OAAOA;AACT;AAEO,SAAST;IACdG,MAAMa,KAAK;AACb;AAQO,eAAed,4BAA4BG,GAAW;IAC3D,IAAIC,IAAAA,kCAAgB,OAAMH,MAAMI,GAAG,CAACF,MAAM;QACxC,OAAOF,MAAMK,GAAG,CAACH;IACnB;IAEA,MAAMI,mBAAoB,CAAA,MAAMQ,IAAAA,uDAA6B,EAACZ,IAAG,GAAIM,IAAI,CAACC,cACxEC,aAAI,CAACC,IAAI,CAACF,aAAa;IAGzBT,MAAMY,GAAG,CAACV,KAAKI;IAEf,OAAOA;AACT"}
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
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 getCatalogVersion () {
|
|
13
|
+
return getCatalogVersion;
|
|
14
|
+
},
|
|
15
|
+
get isCatalogVersion () {
|
|
16
|
+
return isCatalogVersion;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
4
19
|
const catalogPrefix = "catalog:";
|
|
5
|
-
/**
|
|
6
|
-
* Returns true if the version starts with `catalog:`.
|
|
7
|
-
*/
|
|
8
20
|
function isCatalogVersion(version) {
|
|
9
21
|
return version.startsWith(catalogPrefix);
|
|
10
22
|
}
|
|
11
|
-
exports.isCatalogVersion = isCatalogVersion;
|
|
12
|
-
/**
|
|
13
|
-
* Given a dependency package name and a version spec string, if the version starts with `catalog:`,
|
|
14
|
-
* look up the actual version spec (not the final resolved version) from the given catalogs.
|
|
15
|
-
*
|
|
16
|
-
* Throws an error if there's anything invalid about the catalog spec (no catalogs defined,
|
|
17
|
-
* no matching catalog, catalog doesn't contain `name`, recursive catalog version).
|
|
18
|
-
*
|
|
19
|
-
* Returns undefined if the version doesn't start with `catalog:`.
|
|
20
|
-
* @see https://pnpm.io/catalogs
|
|
21
|
-
* @see https://yarnpkg.com/features/catalogs
|
|
22
|
-
*
|
|
23
|
-
* @param name - Dependency package name
|
|
24
|
-
* @param version - Dependency version spec, e.g. `catalog:my-catalog` or `catalog:`,
|
|
25
|
-
* or some non-catalog spec like `^1.2.3`
|
|
26
|
-
* @returns Actual version spec from the catalog, or undefined if not a catalog version
|
|
27
|
-
*/
|
|
28
23
|
function getCatalogVersion(params) {
|
|
29
24
|
const { name, version, catalogs } = params;
|
|
30
25
|
if (!isCatalogVersion(version)) {
|
|
@@ -34,17 +29,11 @@ function getCatalogVersion(params) {
|
|
|
34
29
|
throw new Error(`Dependency "${name}" uses a catalog version "${version}" but no catalogs are defined.`);
|
|
35
30
|
}
|
|
36
31
|
const catalogName = version.slice(catalogPrefix.length);
|
|
37
|
-
const checkCatalog =
|
|
38
|
-
// Explicit catalog:default refers to the default catalog in pnpm, or a catalog named "default"
|
|
32
|
+
const checkCatalog = // Explicit catalog:default refers to the default catalog in pnpm, or a catalog named "default"
|
|
39
33
|
// in yarn... Check for the yarn case first or fall back to .default. (getCatalogs should have
|
|
40
34
|
// removed the named "default" catalog from namedCatalogs in managers where they're the same,
|
|
41
35
|
// and yarn install would have errored if a named catalog "default" was referenced but not defined.)
|
|
42
|
-
catalogName === "default"
|
|
43
|
-
? catalogs.named?.default || catalogs.default
|
|
44
|
-
: // Otherwise use either the given named catalog, or the default if no name was specified
|
|
45
|
-
catalogName
|
|
46
|
-
? catalogs.named?.[catalogName]
|
|
47
|
-
: catalogs.default;
|
|
36
|
+
catalogName === "default" ? catalogs.named?.default || catalogs.default : catalogName ? catalogs.named?.[catalogName] : catalogs.default;
|
|
48
37
|
const catalogNameStr = catalogName ? `catalogs.${catalogName}` : "the default catalog";
|
|
49
38
|
if (!checkCatalog) {
|
|
50
39
|
throw new Error(`Dependency "${name}" uses a catalog version "${version}" but ${catalogNameStr} is not defined.`);
|
|
@@ -58,5 +47,3 @@ function getCatalogVersion(params) {
|
|
|
58
47
|
}
|
|
59
48
|
return actualSpec;
|
|
60
49
|
}
|
|
61
|
-
exports.getCatalogVersion = getCatalogVersion;
|
|
62
|
-
//# sourceMappingURL=getCatalogVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/workspaces/getCatalogVersion.ts"],"sourcesContent":["import type { Catalogs } from \"../types/Catalogs.js\";\n\nconst catalogPrefix = \"catalog:\";\n\n/**\n * Returns true if the version starts with `catalog:`.\n */\nexport function isCatalogVersion(version: string): boolean {\n return version.startsWith(catalogPrefix);\n}\n\n/**\n * Given a dependency package name and a version spec string, if the version starts with `catalog:`,\n * look up the actual version spec (not the final resolved version) from the given catalogs.\n *\n * Throws an error if there's anything invalid about the catalog spec (no catalogs defined,\n * no matching catalog, catalog doesn't contain `name`, recursive catalog version).\n *\n * Returns undefined if the version doesn't start with `catalog:`.\n * @see https://pnpm.io/catalogs\n * @see https://yarnpkg.com/features/catalogs\n *\n * @param name - Dependency package name\n * @param version - Dependency version spec, e.g. `catalog:my-catalog` or `catalog:`,\n * or some non-catalog spec like `^1.2.3`\n * @returns Actual version spec from the catalog, or undefined if not a catalog version\n */\nexport function getCatalogVersion(params: {\n name: string;\n version: string;\n catalogs: Catalogs | undefined;\n}): string | undefined {\n const { name, version, catalogs } = params;\n\n if (!isCatalogVersion(version)) {\n return undefined;\n }\n\n if (!catalogs) {\n throw new Error(`Dependency \"${name}\" uses a catalog version \"${version}\" but no catalogs are defined.`);\n }\n\n const catalogName = version.slice(catalogPrefix.length);\n const checkCatalog =\n // Explicit catalog:default refers to the default catalog in pnpm, or a catalog named \"default\"\n // in yarn... Check for the yarn case first or fall back to .default. (getCatalogs should have\n // removed the named \"default\" catalog from namedCatalogs in managers where they're the same,\n // and yarn install would have errored if a named catalog \"default\" was referenced but not defined.)\n catalogName === \"default\"\n ? catalogs.named?.default || catalogs.default\n : // Otherwise use either the given named catalog, or the default if no name was specified\n catalogName\n ? catalogs.named?.[catalogName]\n : catalogs.default;\n const catalogNameStr = catalogName ? `catalogs.${catalogName}` : \"the default catalog\";\n\n if (!checkCatalog) {\n throw new Error(`Dependency \"${name}\" uses a catalog version \"${version}\" but ${catalogNameStr} is not defined.`);\n }\n\n const actualSpec = checkCatalog[name];\n if (!actualSpec) {\n throw new Error(\n `Dependency \"${name}\" uses a catalog version \"${version}\", but ${catalogNameStr} doesn't define a version for \"${name}\".`\n );\n }\n\n if (isCatalogVersion(actualSpec)) {\n throw new Error(\n `Dependency \"${name}\" resolves to a recursive catalog version \"${actualSpec}\", which is not supported.`\n );\n }\n\n return actualSpec;\n}\n"],"names":["getCatalogVersion","isCatalogVersion","catalogPrefix","version","startsWith","params","name","catalogs","undefined","Error","catalogName","slice","length","checkCatalog","named","default","catalogNameStr","actualSpec"],"mappings":";;;;;;;;;;;QA2BgBA;eAAAA;;QApBAC;eAAAA;;;AALhB,MAAMC,gBAAgB;AAKf,SAASD,iBAAiBE,OAAe;IAC9C,OAAOA,QAAQC,UAAU,CAACF;AAC5B;AAkBO,SAASF,kBAAkBK,MAIjC;IACC,MAAM,EAAEC,IAAI,EAAEH,OAAO,EAAEI,QAAQ,EAAE,GAAGF;IAEpC,IAAI,CAACJ,iBAAiBE,UAAU;QAC9B,OAAOK;IACT;IAEA,IAAI,CAACD,UAAU;QACb,MAAM,IAAIE,MAAM,CAAC,YAAY,EAAEH,KAAK,0BAA0B,EAAEH,QAAQ,8BAA8B,CAAC;IACzG;IAEA,MAAMO,cAAcP,QAAQQ,KAAK,CAACT,cAAcU,MAAM;IACtD,MAAMC,eACJ,+FAA+F;IAC/F,8FAA8F;IAC9F,6FAA6F;IAC7F,oGAAoG;IACpGH,gBAAgB,YACZH,SAASO,KAAK,EAAEC,WAAWR,SAASQ,OAAO,GAE3CL,cACEH,SAASO,KAAK,EAAE,CAACJ,YAAY,GAC7BH,SAASQ,OAAO;IACxB,MAAMC,iBAAiBN,cAAc,CAAC,SAAS,EAAEA,aAAa,GAAG;IAEjE,IAAI,CAACG,cAAc;QACjB,MAAM,IAAIJ,MAAM,CAAC,YAAY,EAAEH,KAAK,0BAA0B,EAAEH,QAAQ,MAAM,EAAEa,eAAe,gBAAgB,CAAC;IAClH;IAEA,MAAMC,aAAaJ,YAAY,CAACP,KAAK;IACrC,IAAI,CAACW,YAAY;QACf,MAAM,IAAIR,MACR,CAAC,YAAY,EAAEH,KAAK,0BAA0B,EAAEH,QAAQ,OAAO,EAAEa,eAAe,+BAA+B,EAAEV,KAAK,EAAE,CAAC;IAE7H;IAEA,IAAIL,iBAAiBgB,aAAa;QAChC,MAAM,IAAIR,MACR,CAAC,YAAY,EAAEH,KAAK,2CAA2C,EAAEW,WAAW,0BAA0B,CAAC;IAE3G;IAEA,OAAOA;AACT"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import type { Catalogs } from "../types/Catalogs";
|
|
1
|
+
import type { Catalogs } from "../types/Catalogs.js";
|
|
2
|
+
import type { WorkspaceManager } from "../types/WorkspaceManager.js";
|
|
2
3
|
/**
|
|
3
4
|
* Get version catalogs, if supported by the manager (only pnpm and yarn v4 as of writing).
|
|
4
5
|
* Returns undefined if no catalogs are present or the manager doesn't support them.
|
|
5
6
|
* @see https://pnpm.io/catalogs
|
|
6
7
|
* @see https://yarnpkg.com/features/catalogs
|
|
8
|
+
*
|
|
7
9
|
* @param cwd - Current working directory. It will search up from here to find the root, with caching.
|
|
10
|
+
* @param managerOverride Workspace/monorepo manager to use instead of auto-detecting
|
|
11
|
+
*
|
|
12
|
+
* @returns Catalogs if defined, or undefined if not available
|
|
13
|
+
* (logs verbose warnings instead of throwing on error)
|
|
8
14
|
*/
|
|
9
|
-
export declare function getCatalogs(cwd: string): Catalogs | undefined;
|
|
15
|
+
export declare function getCatalogs(cwd: string, managerOverride?: WorkspaceManager): Catalogs | undefined;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getCatalogs", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getCatalogs;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _implementations = require("./implementations");
|
|
12
|
+
const _wrapWorkspaceUtility = require("./wrapWorkspaceUtility.js");
|
|
13
|
+
function getCatalogs(cwd, managerOverride) {
|
|
14
|
+
return (0, _wrapWorkspaceUtility.wrapWorkspaceUtility)({
|
|
15
|
+
cwd,
|
|
16
|
+
managerOverride,
|
|
17
|
+
description: "catalogs",
|
|
18
|
+
impl: ({ manager, root })=>{
|
|
19
|
+
// There is no default implementation for catalogs, since not all managers support it
|
|
20
|
+
return (0, _implementations.getWorkspaceUtilities)(manager).getCatalogs?.({
|
|
21
|
+
root
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
15
25
|
}
|
|
16
|
-
exports.getCatalogs = getCatalogs;
|
|
17
|
-
//# sourceMappingURL=getCatalogs.js.map
|