workspace-tools 0.41.5 → 0.41.7
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/lib/git/branchRefs.d.ts +36 -0
- package/lib/git/branchRefs.js +84 -0
- package/lib/git/branchRefs.js.map +1 -0
- package/lib/git/config.d.ts +16 -0
- package/lib/git/config.js +39 -4
- package/lib/git/config.js.map +1 -1
- package/lib/git/fetchRemote.d.ts +13 -0
- package/lib/git/fetchRemote.js +56 -0
- package/lib/git/fetchRemote.js.map +1 -0
- package/lib/git/getChanges.d.ts +54 -0
- package/lib/git/getChanges.js +138 -0
- package/lib/git/getChanges.js.map +1 -0
- package/lib/git/getCurrentHash.d.ts +8 -0
- package/lib/git/getCurrentHash.js +24 -0
- package/lib/git/getCurrentHash.js.map +1 -0
- package/lib/git/getDefaultRemote.d.ts +14 -3
- package/lib/git/getDefaultRemote.js +92 -53
- package/lib/git/getDefaultRemote.js.map +1 -1
- package/lib/git/getDefaultRemoteBranch.d.ts +29 -2
- package/lib/git/getDefaultRemoteBranch.js +61 -21
- package/lib/git/getDefaultRemoteBranch.js.map +1 -1
- package/lib/git/getFileAddedHash.d.ts +10 -0
- package/lib/git/getFileAddedHash.js +24 -0
- package/lib/git/getFileAddedHash.js.map +1 -0
- package/lib/git/getFileFromRef.d.ts +11 -0
- package/lib/git/getFileFromRef.js +22 -0
- package/lib/git/getFileFromRef.js.map +1 -0
- package/lib/git/getRecentCommitMessages.d.ts +10 -0
- package/lib/git/getRecentCommitMessages.js +27 -0
- package/lib/git/getRecentCommitMessages.js.map +1 -0
- package/lib/git/getRemotes.d.ts +14 -0
- package/lib/git/getRemotes.js +53 -0
- package/lib/git/getRemotes.js.map +1 -0
- package/lib/git/gitUtilities.d.ts +12 -212
- package/lib/git/gitUtilities.js +38 -448
- package/lib/git/gitUtilities.js.map +1 -1
- package/lib/git/index.d.ts +17 -5
- package/lib/git/index.js +123 -17
- package/lib/git/index.js.map +1 -1
- package/lib/git/init.d.ts +11 -0
- package/lib/git/init.js +48 -0
- package/lib/git/init.js.map +1 -0
- package/lib/git/listAllTrackedFiles.d.ts +12 -0
- package/lib/git/listAllTrackedFiles.js +25 -0
- package/lib/git/listAllTrackedFiles.js.map +1 -0
- package/lib/git/parseRemoteBranch.d.ts +26 -0
- package/lib/git/parseRemoteBranch.js +77 -0
- package/lib/git/parseRemoteBranch.js.map +1 -0
- package/lib/git/revertLocalChanges.d.ts +9 -0
- package/lib/git/revertLocalChanges.js +42 -0
- package/lib/git/revertLocalChanges.js.map +1 -0
- package/lib/git/stageAndCommit.d.ts +21 -0
- package/lib/git/stageAndCommit.js +69 -0
- package/lib/git/stageAndCommit.js.map +1 -0
- package/lib/git/types.d.ts +5 -2
- package/lib/git/types.js.map +1 -1
- package/lib/workspaces/getCatalogVersion.d.ts +8 -3
- package/lib/workspaces/getCatalogVersion.js +9 -3
- package/lib/workspaces/getCatalogVersion.js.map +1 -1
- package/package.json +1 -1
|
@@ -25,11 +25,14 @@ function isCatalogVersion(version) {
|
|
|
25
25
|
return version.startsWith(catalogPrefix);
|
|
26
26
|
}
|
|
27
27
|
function getCatalogVersion(params) {
|
|
28
|
-
const { name, version, catalogs } = params;
|
|
28
|
+
const { name, version, catalogs, allowNotFound } = params;
|
|
29
29
|
if (!isCatalogVersion(version)) {
|
|
30
30
|
return undefined;
|
|
31
31
|
}
|
|
32
32
|
if (!catalogs) {
|
|
33
|
+
if (allowNotFound) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
33
36
|
throw new Error(`Dependency "${name}" uses a catalog version "${version}" but no catalogs are defined.`);
|
|
34
37
|
}
|
|
35
38
|
const catalogName = version.slice(catalogPrefix.length);
|
|
@@ -39,11 +42,14 @@ function getCatalogVersion(params) {
|
|
|
39
42
|
// and yarn install would have errored if a named catalog "default" was referenced but not defined.)
|
|
40
43
|
catalogName === "default" ? catalogs.named?.default || catalogs.default : catalogName ? catalogs.named?.[catalogName] : catalogs.default;
|
|
41
44
|
const catalogNameStr = catalogName ? `catalogs.${catalogName}` : "the default catalog";
|
|
42
|
-
if (!checkCatalog) {
|
|
45
|
+
if (!checkCatalog && !allowNotFound) {
|
|
43
46
|
throw new Error(`Dependency "${name}" uses a catalog version "${version}" but ${catalogNameStr} is not defined.`);
|
|
44
47
|
}
|
|
45
|
-
const actualSpec = checkCatalog[name];
|
|
48
|
+
const actualSpec = checkCatalog?.[name];
|
|
46
49
|
if (!actualSpec) {
|
|
50
|
+
if (allowNotFound) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
47
53
|
throw new Error(`Dependency "${name}" uses a catalog version "${version}", but ${catalogNameStr} doesn't define a version for "${name}".`);
|
|
48
54
|
}
|
|
49
55
|
if (isCatalogVersion(actualSpec)) {
|
|
@@ -1 +1 @@
|
|
|
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 * @
|
|
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 * If `allowNotFound` is true, it will return undefined if no match instead.\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 * @returns Actual version spec from the catalog, or undefined if not a catalog version\n * (or undefined if `allowNotFound` is true and the package isn't in the catalog)\n */\nexport function getCatalogVersion(params: {\n /** Dependency package name */\n name: string;\n /**\n * Dependency version spec, e.g. `catalog:my-catalog` or `catalog:`, or some non-catalog\n * spec like `^1.2.3`\n */\n version: string;\n catalogs: Catalogs | undefined;\n allowNotFound?: boolean;\n}): string | undefined {\n const { name, version, catalogs, allowNotFound } = params;\n\n if (!isCatalogVersion(version)) {\n return undefined;\n }\n\n if (!catalogs) {\n if (allowNotFound) {\n return undefined;\n }\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 && !allowNotFound) {\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 if (allowNotFound) {\n return undefined;\n }\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","allowNotFound","undefined","Error","catalogName","slice","length","checkCatalog","named","default","catalogNameStr","actualSpec"],"mappings":";;;;;;;;;;;;;;;QA0BgBA;eAAAA;;QAnBAC;eAAAA;;;AALhB,MAAMC,gBAAgB;AAKf,SAASD,iBAAiBE,OAAe;IAC9C,OAAOA,QAAQC,UAAU,CAACF;AAC5B;AAiBO,SAASF,kBAAkBK,MAUjC;IACC,MAAM,EAAEC,IAAI,EAAEH,OAAO,EAAEI,QAAQ,EAAEC,aAAa,EAAE,GAAGH;IAEnD,IAAI,CAACJ,iBAAiBE,UAAU;QAC9B,OAAOM;IACT;IAEA,IAAI,CAACF,UAAU;QACb,IAAIC,eAAe;YACjB,OAAOC;QACT;QACA,MAAM,IAAIC,MAAM,CAAC,YAAY,EAAEJ,KAAK,0BAA0B,EAAEH,QAAQ,8BAA8B,CAAC;IACzG;IAEA,MAAMQ,cAAcR,QAAQS,KAAK,CAACV,cAAcW,MAAM;IACtD,MAAMC,eACJ,+FAA+F;IAC/F,8FAA8F;IAC9F,6FAA6F;IAC7F,oGAAoG;IACpGH,gBAAgB,YACZJ,SAASQ,KAAK,EAAEC,WAAWT,SAASS,OAAO,GAE3CL,cACEJ,SAASQ,KAAK,EAAE,CAACJ,YAAY,GAC7BJ,SAASS,OAAO;IACxB,MAAMC,iBAAiBN,cAAc,CAAC,SAAS,EAAEA,aAAa,GAAG;IAEjE,IAAI,CAACG,gBAAgB,CAACN,eAAe;QACnC,MAAM,IAAIE,MAAM,CAAC,YAAY,EAAEJ,KAAK,0BAA0B,EAAEH,QAAQ,MAAM,EAAEc,eAAe,gBAAgB,CAAC;IAClH;IAEA,MAAMC,aAAaJ,cAAc,CAACR,KAAK;IACvC,IAAI,CAACY,YAAY;QACf,IAAIV,eAAe;YACjB,OAAOC;QACT;QACA,MAAM,IAAIC,MACR,CAAC,YAAY,EAAEJ,KAAK,0BAA0B,EAAEH,QAAQ,OAAO,EAAEc,eAAe,+BAA+B,EAAEX,KAAK,EAAE,CAAC;IAE7H;IAEA,IAAIL,iBAAiBiB,aAAa;QAChC,MAAM,IAAIR,MACR,CAAC,YAAY,EAAEJ,KAAK,2CAA2C,EAAEY,WAAW,0BAA0B,CAAC;IAE3G;IAEA,OAAOA;AACT"}
|