workspace-tools 0.38.4 → 0.38.5

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.
Files changed (73) hide show
  1. package/lib/getPackageInfos.d.ts +14 -0
  2. package/lib/getPackageInfos.js +17 -20
  3. package/lib/getPackageInfos.js.map +1 -1
  4. package/lib/getPackagePaths.d.ts +2 -2
  5. package/lib/getPackagePaths.js +2 -2
  6. package/lib/git/gitUtilities.d.ts +132 -3
  7. package/lib/git/gitUtilities.js +141 -4
  8. package/lib/git/gitUtilities.js.map +1 -1
  9. package/lib/graph/createDependencyMap.d.ts +1 -1
  10. package/lib/graph/createDependencyMap.js.map +1 -1
  11. package/lib/graph/getPackageDependencies.d.ts +10 -1
  12. package/lib/graph/getPackageDependencies.js +17 -5
  13. package/lib/graph/getPackageDependencies.js.map +1 -1
  14. package/lib/index.d.ts +17 -14
  15. package/lib/index.js +40 -15
  16. package/lib/index.js.map +1 -1
  17. package/lib/lockfile/parseBerryLock.d.ts +3 -0
  18. package/lib/lockfile/parseBerryLock.js +3 -0
  19. package/lib/lockfile/parseBerryLock.js.map +1 -1
  20. package/lib/lockfile/types.d.ts +3 -0
  21. package/lib/paths.d.ts +3 -0
  22. package/lib/paths.js +4 -1
  23. package/lib/paths.js.map +1 -1
  24. package/lib/tsdoc-metadata.json +1 -1
  25. package/lib/types/Catalogs.d.ts +30 -0
  26. package/lib/types/Catalogs.js +3 -0
  27. package/lib/types/Catalogs.js.map +1 -0
  28. package/lib/types/PackageInfo.d.ts +19 -1
  29. package/lib/types/WorkspaceInfo.d.ts +15 -6
  30. package/lib/workspaces/catalogs.d.ts +28 -0
  31. package/lib/workspaces/catalogs.js +57 -0
  32. package/lib/workspaces/catalogs.js.map +1 -0
  33. package/lib/workspaces/findWorkspacePath.d.ts +5 -5
  34. package/lib/workspaces/findWorkspacePath.js +3 -3
  35. package/lib/workspaces/findWorkspacePath.js.map +1 -1
  36. package/lib/workspaces/getWorkspacePackageInfo.d.ts +12 -9
  37. package/lib/workspaces/getWorkspacePackageInfo.js +14 -16
  38. package/lib/workspaces/getWorkspacePackageInfo.js.map +1 -1
  39. package/lib/workspaces/getWorkspaceRoot.d.ts +18 -2
  40. package/lib/workspaces/getWorkspaceRoot.js +23 -4
  41. package/lib/workspaces/getWorkspaceRoot.js.map +1 -1
  42. package/lib/workspaces/getWorkspaces.d.ts +11 -14
  43. package/lib/workspaces/getWorkspaces.js +8 -11
  44. package/lib/workspaces/getWorkspaces.js.map +1 -1
  45. package/lib/workspaces/implementations/getWorkspaceUtilities.d.ts +16 -9
  46. package/lib/workspaces/implementations/getWorkspaceUtilities.js.map +1 -1
  47. package/lib/workspaces/implementations/index.d.ts +2 -2
  48. package/lib/workspaces/implementations/index.js.map +1 -1
  49. package/lib/workspaces/implementations/lerna.d.ts +8 -8
  50. package/lib/workspaces/implementations/lerna.js +5 -5
  51. package/lib/workspaces/implementations/lerna.js.map +1 -1
  52. package/lib/workspaces/implementations/npm.d.ts +9 -9
  53. package/lib/workspaces/implementations/npm.js +6 -6
  54. package/lib/workspaces/implementations/npm.js.map +1 -1
  55. package/lib/workspaces/implementations/packageJsonWorkspaces.d.ts +21 -10
  56. package/lib/workspaces/implementations/packageJsonWorkspaces.js +34 -23
  57. package/lib/workspaces/implementations/packageJsonWorkspaces.js.map +1 -1
  58. package/lib/workspaces/implementations/pnpm.d.ts +17 -9
  59. package/lib/workspaces/implementations/pnpm.js +37 -11
  60. package/lib/workspaces/implementations/pnpm.js.map +1 -1
  61. package/lib/workspaces/implementations/rush.d.ts +8 -8
  62. package/lib/workspaces/implementations/rush.js +5 -5
  63. package/lib/workspaces/implementations/rush.js.map +1 -1
  64. package/lib/workspaces/implementations/yarn.d.ts +18 -10
  65. package/lib/workspaces/implementations/yarn.js +51 -10
  66. package/lib/workspaces/implementations/yarn.js.map +1 -1
  67. package/lib/workspaces/listOfWorkspacePackageNames.d.ts +5 -2
  68. package/lib/workspaces/listOfWorkspacePackageNames.js +3 -0
  69. package/lib/workspaces/listOfWorkspacePackageNames.js.map +1 -1
  70. package/lib/workspaces/readPackageInfo.d.ts +13 -0
  71. package/lib/workspaces/readPackageInfo.js +52 -0
  72. package/lib/workspaces/readPackageInfo.js.map +1 -0
  73. package/package.json +2 -3
@@ -1,17 +1,25 @@
1
- import { WorkspaceInfo } from "../../types/WorkspaceInfo";
2
- /** @deprecated Use `getWorkspaceRoot` */
1
+ import type { WorkspaceInfos } from "../../types/WorkspaceInfo";
2
+ import type { Catalogs } from "../../types/Catalogs";
3
+ /** @deprecated Use `getWorkspaceManagerRoot` */
3
4
  export declare function getPnpmWorkspaceRoot(cwd: string): string;
4
- /** Get package paths for a pnpm workspace. */
5
+ /** Get paths for each package ("workspace") in a pnpm monorepo. */
5
6
  export declare function getWorkspacePackagePaths(cwd: string): string[];
6
7
  /**
7
- * Get an array with names, paths, and package.json contents for each package in a pnpm workspace.
8
- * (See `../getWorkspaces` for why it's named this way.)
8
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
9
+ * in a pnpm monorepo.
9
10
  */
10
- export declare function getPnpmWorkspaces(cwd: string): WorkspaceInfo;
11
+ export declare function getPnpmWorkspaces(cwd: string): WorkspaceInfos;
11
12
  /**
12
- * Get an array with names, paths, and package.json contents for each package in a pnpm workspace.
13
- * (See `../getWorkspaces` for why it's named this way.)
13
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
14
+ * in a pnpm monorepo.
14
15
  */
15
- export declare function getPnpmWorkspacesAsync(cwd: string): Promise<WorkspaceInfo>;
16
+ export declare function getPnpmWorkspacesAsync(cwd: string): Promise<WorkspaceInfos>;
17
+ /**
18
+ * Get version catalogs if present.
19
+ * Returns undefined if there's no catalog, or any issue reading or parsing.
20
+ * @see https://pnpm.io/catalogs
21
+ */
22
+ export declare function getPnpmCatalogs(cwd: string): Catalogs | undefined;
16
23
  export { getPnpmWorkspaces as getWorkspaces };
17
24
  export { getPnpmWorkspacesAsync as getWorkspacesAsync };
25
+ export { getPnpmCatalogs as getCatalogs };
@@ -3,14 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getWorkspacesAsync = exports.getWorkspaces = exports.getPnpmWorkspacesAsync = exports.getPnpmWorkspaces = exports.getWorkspacePackagePaths = exports.getPnpmWorkspaceRoot = void 0;
6
+ exports.getCatalogs = exports.getWorkspacesAsync = exports.getWorkspaces = exports.getPnpmCatalogs = exports.getPnpmWorkspacesAsync = exports.getPnpmWorkspaces = exports.getWorkspacePackagePaths = exports.getPnpmWorkspaceRoot = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const getPackagePaths_1 = require("../../getPackagePaths");
9
9
  const getWorkspacePackageInfo_1 = require("../getWorkspacePackageInfo");
10
10
  const readYaml_1 = require("../../lockfile/readYaml");
11
11
  const logging_1 = require("../../logging");
12
12
  const getWorkspaceManagerAndRoot_1 = require("./getWorkspaceManagerAndRoot");
13
- /** @deprecated Use `getWorkspaceRoot` */
13
+ function getPnpmWorkspaceRootAndYaml(cwd) {
14
+ const root = getPnpmWorkspaceRoot(cwd);
15
+ const pnpmWorkspacesFile = path_1.default.join(root, "pnpm-workspace.yaml");
16
+ return { root, workspaceYaml: (0, readYaml_1.readYaml)(pnpmWorkspacesFile) };
17
+ }
18
+ /** @deprecated Use `getWorkspaceManagerRoot` */
14
19
  function getPnpmWorkspaceRoot(cwd) {
15
20
  const root = (0, getWorkspaceManagerAndRoot_1.getWorkspaceManagerAndRoot)(cwd, undefined, "pnpm")?.root;
16
21
  if (!root) {
@@ -19,13 +24,11 @@ function getPnpmWorkspaceRoot(cwd) {
19
24
  return root;
20
25
  }
21
26
  exports.getPnpmWorkspaceRoot = getPnpmWorkspaceRoot;
22
- /** Get package paths for a pnpm workspace. */
27
+ /** Get paths for each package ("workspace") in a pnpm monorepo. */
23
28
  function getWorkspacePackagePaths(cwd) {
24
29
  try {
25
- const pnpmWorkspacesRoot = getPnpmWorkspaceRoot(cwd);
26
- const pnpmWorkspacesFile = path_1.default.join(pnpmWorkspacesRoot, "pnpm-workspace.yaml");
27
- const pnpmWorkspaces = (0, readYaml_1.readYaml)(pnpmWorkspacesFile);
28
- return (0, getPackagePaths_1.getPackagePaths)(pnpmWorkspacesRoot, pnpmWorkspaces.packages);
30
+ const { root, workspaceYaml } = getPnpmWorkspaceRootAndYaml(cwd);
31
+ return (0, getPackagePaths_1.getPackagePaths)(root, workspaceYaml.packages);
29
32
  }
30
33
  catch (err) {
31
34
  (0, logging_1.logVerboseWarning)(`Error getting pnpm workspace package paths for ${cwd}`, err);
@@ -34,8 +37,8 @@ function getWorkspacePackagePaths(cwd) {
34
37
  }
35
38
  exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
36
39
  /**
37
- * Get an array with names, paths, and package.json contents for each package in a pnpm workspace.
38
- * (See `../getWorkspaces` for why it's named this way.)
40
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
41
+ * in a pnpm monorepo.
39
42
  */
40
43
  function getPnpmWorkspaces(cwd) {
41
44
  try {
@@ -50,8 +53,8 @@ function getPnpmWorkspaces(cwd) {
50
53
  exports.getPnpmWorkspaces = getPnpmWorkspaces;
51
54
  exports.getWorkspaces = getPnpmWorkspaces;
52
55
  /**
53
- * Get an array with names, paths, and package.json contents for each package in a pnpm workspace.
54
- * (See `../getWorkspaces` for why it's named this way.)
56
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
57
+ * in a pnpm monorepo.
55
58
  */
56
59
  async function getPnpmWorkspacesAsync(cwd) {
57
60
  try {
@@ -65,4 +68,27 @@ async function getPnpmWorkspacesAsync(cwd) {
65
68
  }
66
69
  exports.getPnpmWorkspacesAsync = getPnpmWorkspacesAsync;
67
70
  exports.getWorkspacesAsync = getPnpmWorkspacesAsync;
71
+ /**
72
+ * Get version catalogs if present.
73
+ * Returns undefined if there's no catalog, or any issue reading or parsing.
74
+ * @see https://pnpm.io/catalogs
75
+ */
76
+ function getPnpmCatalogs(cwd) {
77
+ try {
78
+ const { workspaceYaml } = getPnpmWorkspaceRootAndYaml(cwd);
79
+ if (!workspaceYaml.catalog && !workspaceYaml.catalogs) {
80
+ return undefined;
81
+ }
82
+ return {
83
+ default: workspaceYaml.catalog,
84
+ named: workspaceYaml.catalogs,
85
+ };
86
+ }
87
+ catch (err) {
88
+ (0, logging_1.logVerboseWarning)(`Error getting pnpm catalogs for ${cwd}`, err);
89
+ return undefined;
90
+ }
91
+ }
92
+ exports.getPnpmCatalogs = getPnpmCatalogs;
93
+ exports.getCatalogs = getPnpmCatalogs;
68
94
  //# sourceMappingURL=pnpm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pnpm.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/pnpm.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,2DAAwD;AAExD,wEAAmG;AACnG,sDAAmD;AACnD,2CAAkD;AAClD,6EAA0E;AAM1E,yCAAyC;AACzC,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,MAAM,IAAI,GAAG,IAAA,uDAA0B,EAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC;IACtE,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,0CAA0C,GAAG,GAAG,CAAC,CAAC;KACnE;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAND,oDAMC;AAED,8CAA8C;AAC9C,SAAgB,wBAAwB,CAAC,GAAW;IAClD,IAAI;QACF,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACrD,MAAM,kBAAkB,GAAG,cAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;QAEhF,MAAM,cAAc,GAAG,IAAA,mBAAQ,EAAC,kBAAkB,CAAsB,CAAC;QAEzE,OAAO,IAAA,iCAAe,EAAC,kBAAkB,EAAE,cAAc,CAAC,Q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nD;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,qCAAqC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QACnE,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,wDAQC;AAwBkC,oDAAkB;AAtBrD;;;;GAIG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,IAAI;QACF,MAAM,EAAE,aAAa,EAAE,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAC;QAC3D,IAAI,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;YACrD,OAAO,SAAS,CAAC;SAClB;QACD,OAAO;YACL,OAAO,EAAE,aAAa,CAAC,OAAO;YAC9B,KAAK,EAAE,aAAa,CAAC,QAAQ;SAC9B,CAAC;KACH;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,mCAAmC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QACjE,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAdD,0CAcC;AAI2B,sCAAW"}
@@ -1,17 +1,17 @@
1
- import { WorkspaceInfo } from "../../types/WorkspaceInfo";
1
+ import type { WorkspaceInfos } from "../../types/WorkspaceInfo";
2
2
  /** @deprecated Use getWorkspaceRoot */
3
3
  export declare function getRushWorkspaceRoot(cwd: string): string;
4
- /** Get package paths for a rush workspace. */
4
+ /** Get paths for each package ("workspace") in a rush monorepo. */
5
5
  export declare function getWorkspacePackagePaths(cwd: string): string[];
6
6
  /**
7
- * Get an array with names, paths, and package.json contents for each package in a rush workspace.
8
- * (See `../getWorkspaces` for why it's named this way.)
7
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
8
+ * in a rush monorepo.
9
9
  */
10
- export declare function getRushWorkspaces(cwd: string): WorkspaceInfo;
10
+ export declare function getRushWorkspaces(cwd: string): WorkspaceInfos;
11
11
  /**
12
- * Get an array with names, paths, and package.json contents for each package in a rush workspace.
13
- * (See `../getWorkspaces` for why it's named this way.)
12
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
13
+ * in a rush monorepo.
14
14
  */
15
- export declare function getRushWorkspacesAsync(cwd: string): Promise<WorkspaceInfo>;
15
+ export declare function getRushWorkspacesAsync(cwd: string): Promise<WorkspaceInfos>;
16
16
  export { getRushWorkspaces as getWorkspaces };
17
17
  export { getRushWorkspacesAsync as getWorkspacesAsync };
@@ -19,7 +19,7 @@ function getRushWorkspaceRoot(cwd) {
19
19
  return root;
20
20
  }
21
21
  exports.getRushWorkspaceRoot = getRushWorkspaceRoot;
22
- /** Get package paths for a rush workspace. */
22
+ /** Get paths for each package ("workspace") in a rush monorepo. */
23
23
  function getWorkspacePackagePaths(cwd) {
24
24
  try {
25
25
  const rushWorkspaceRoot = getRushWorkspaceRoot(cwd);
@@ -35,8 +35,8 @@ function getWorkspacePackagePaths(cwd) {
35
35
  }
36
36
  exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
37
37
  /**
38
- * Get an array with names, paths, and package.json contents for each package in a rush workspace.
39
- * (See `../getWorkspaces` for why it's named this way.)
38
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
39
+ * in a rush monorepo.
40
40
  */
41
41
  function getRushWorkspaces(cwd) {
42
42
  try {
@@ -51,8 +51,8 @@ function getRushWorkspaces(cwd) {
51
51
  exports.getRushWorkspaces = getRushWorkspaces;
52
52
  exports.getWorkspaces = getRushWorkspaces;
53
53
  /**
54
- * Get an array with names, paths, and package.json contents for each package in a rush workspace.
55
- * (See `../getWorkspaces` for why it's named this way.)
54
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
55
+ * in a rush monorepo.
56
56
  */
57
57
  async function getRushWorkspacesAsync(cwd) {
58
58
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"rush.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/rush.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,8CAAsB;AACtB,4CAAoB;AAGpB,wEAAmG;AACnG,2CAAkD;AAClD,6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AG,CAAC,CAAC;QACnE,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,8CAQC;AAgB6B,0CAAa;AAd3C;;;GAGG;AACI,KAAK,UAAU,sBAAsB,CAAC,GAAW;IACtD,IAAI;QACF,MAAM,YAAY,GAAG,wBAAwB,CAAC,GAAG,CAAC,CAAC;QACnD,OAAO,IAAA,sDAA4B,EAAC,YAAY,CAAC,CAAC;KACnD;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,qCAAqC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QACnE,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,wDAQC;AAGkC,oDAAkB"}
1
+ {"version":3,"file":"rush.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/rush.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,8CAAsB;AACtB,4CAAoB;AAGpB,wEAAmG;AACnG,2CAAkD;AAClD,6EAA0E;AAE1E,uCAAuC;AACvC,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,MAAM,IAAI,GAAG,IAAA,uDAA0B,EAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC;IACtE,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,0CAA0C,GAAG,GAAG,CAAC,CAAC;KACnE;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAND,oDAMC;AAED,mEAAmE;AACnE,SAAgB,wBAAwB,CAAC,GAAW;IAClD,IAAI;QACF,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACpD,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;QAE/D,MAAM,UAAU,GAAmD,aAAG,CAAC,KAAK,CAC1E,YAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CACvC,CAAC;QACF,MAAM,IAAI,GAAG,cAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KACrF;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,kDAAkD,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QAChF,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAdD,4DAcC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,IAAI;QACF,MAAM,YAAY,GAAG,wBAAwB,CAAC,GAAG,CAAC,CAAC;QACnD,OAAO,IAAA,iDAAuB,EAAC,YAAY,CAAC,CAAC;KAC9C;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,qCAAqC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QACnE,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,8CAQC;AAgB6B,0CAAa;AAd3C;;;GAGG;AACI,KAAK,UAAU,sBAAsB,CAAC,GAAW;IACtD,IAAI;QACF,MAAM,YAAY,GAAG,wBAAwB,CAAC,GAAG,CAAC,CAAC;QACnD,OAAO,IAAA,sDAA4B,EAAC,YAAY,CAAC,CAAC;KACnD;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,qCAAqC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QACnE,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,wDAQC;AAGkC,oDAAkB"}
@@ -1,19 +1,27 @@
1
- import { WorkspaceInfo } from "../../types/WorkspaceInfo";
2
- /** @deprecated Use `getWorkspaceRoot` */
1
+ import type { WorkspaceInfos } from "../../types/WorkspaceInfo";
2
+ import type { Catalogs } from "../../types/Catalogs";
3
+ /** @deprecated Use `getWorkspaceManagerRoot` */
3
4
  export declare function getYarnWorkspaceRoot(cwd: string): string;
4
- /** Get package paths for a yarn workspace. */
5
+ /** Get paths for each package ("workspace") in a yarn monorepo. */
5
6
  export declare function getWorkspacePackagePaths(cwd: string): string[];
6
- /** Get package paths for a yarn workspace. */
7
+ /** Get paths for each package ("workspace") in a yarn monorepo. */
7
8
  export declare function getWorkspacePackagePathsAsync(cwd: string): Promise<string[]>;
8
9
  /**
9
- * Get an array with names, paths, and package.json contents for each package in a yarn workspace.
10
- * (See `../getWorkspaces` for why it's named this way.)
10
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
11
+ * in a yarn monorepo.
11
12
  */
12
- export declare function getYarnWorkspaces(cwd: string): WorkspaceInfo;
13
+ export declare function getYarnWorkspaces(cwd: string): WorkspaceInfos;
13
14
  /**
14
- * Get an array with names, paths, and package.json contents for each package in a yarn workspace.
15
- * (See `../getWorkspaces` for why it's named this way.)
15
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
16
+ * in a yarn monorepo.
16
17
  */
17
- export declare function getYarnWorkspacesAsync(cwd: string): Promise<WorkspaceInfo>;
18
+ export declare function getYarnWorkspacesAsync(cwd: string): Promise<WorkspaceInfos>;
19
+ /**
20
+ * Get version catalogs if present.
21
+ * Returns undefined if there's no catalog, or any issue reading or parsing.
22
+ * @see https://yarnpkg.com/features/catalogs
23
+ */
24
+ export declare function getYarnCatalogs(cwd: string): Catalogs | undefined;
18
25
  export { getYarnWorkspaces as getWorkspaces };
19
26
  export { getYarnWorkspacesAsync as getWorkspacesAsync };
27
+ export { getYarnCatalogs as getCatalogs };
@@ -1,32 +1,40 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWorkspacesAsync = exports.getWorkspaces = exports.getYarnWorkspacesAsync = exports.getYarnWorkspaces = exports.getWorkspacePackagePathsAsync = exports.getWorkspacePackagePaths = exports.getYarnWorkspaceRoot = void 0;
4
- const _1 = require(".");
6
+ exports.getCatalogs = exports.getWorkspacesAsync = exports.getWorkspaces = exports.getYarnCatalogs = exports.getYarnWorkspacesAsync = exports.getYarnWorkspaces = exports.getWorkspacePackagePathsAsync = exports.getWorkspacePackagePaths = exports.getYarnWorkspaceRoot = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const index_1 = require("./index");
5
10
  const packageJsonWorkspaces_1 = require("./packageJsonWorkspaces");
6
- /** @deprecated Use `getWorkspaceRoot` */
11
+ const readPackageInfo_1 = require("../readPackageInfo");
12
+ const logging_1 = require("../../logging");
13
+ const readYaml_1 = require("../../lockfile/readYaml");
14
+ /** @deprecated Use `getWorkspaceManagerRoot` */
7
15
  function getYarnWorkspaceRoot(cwd) {
8
- const root = (0, _1.getWorkspaceManagerAndRoot)(cwd, undefined, "yarn")?.root;
16
+ const root = (0, index_1.getWorkspaceManagerAndRoot)(cwd, undefined, "yarn")?.root;
9
17
  if (!root) {
10
18
  throw new Error("Could not find yarn workspace root from " + cwd);
11
19
  }
12
20
  return root;
13
21
  }
14
22
  exports.getYarnWorkspaceRoot = getYarnWorkspaceRoot;
15
- /** Get package paths for a yarn workspace. */
23
+ /** Get paths for each package ("workspace") in a yarn monorepo. */
16
24
  function getWorkspacePackagePaths(cwd) {
17
25
  const yarnWorkspacesRoot = getYarnWorkspaceRoot(cwd);
18
26
  return (0, packageJsonWorkspaces_1.getPackagePathsFromWorkspaceRoot)(yarnWorkspacesRoot);
19
27
  }
20
28
  exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
21
- /** Get package paths for a yarn workspace. */
29
+ /** Get paths for each package ("workspace") in a yarn monorepo. */
22
30
  function getWorkspacePackagePathsAsync(cwd) {
23
31
  const yarnWorkspacesRoot = getYarnWorkspaceRoot(cwd);
24
32
  return (0, packageJsonWorkspaces_1.getPackagePathsFromWorkspaceRootAsync)(yarnWorkspacesRoot);
25
33
  }
26
34
  exports.getWorkspacePackagePathsAsync = getWorkspacePackagePathsAsync;
27
35
  /**
28
- * Get an array with names, paths, and package.json contents for each package in a yarn workspace.
29
- * (See `../getWorkspaces` for why it's named this way.)
36
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
37
+ * in a yarn monorepo.
30
38
  */
31
39
  function getYarnWorkspaces(cwd) {
32
40
  const yarnWorkspacesRoot = getYarnWorkspaceRoot(cwd);
@@ -35,8 +43,8 @@ function getYarnWorkspaces(cwd) {
35
43
  exports.getYarnWorkspaces = getYarnWorkspaces;
36
44
  exports.getWorkspaces = getYarnWorkspaces;
37
45
  /**
38
- * Get an array with names, paths, and package.json contents for each package in a yarn workspace.
39
- * (See `../getWorkspaces` for why it's named this way.)
46
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
47
+ * in a yarn monorepo.
40
48
  */
41
49
  function getYarnWorkspacesAsync(cwd) {
42
50
  const yarnWorkspacesRoot = getYarnWorkspaceRoot(cwd);
@@ -44,4 +52,37 @@ function getYarnWorkspacesAsync(cwd) {
44
52
  }
45
53
  exports.getYarnWorkspacesAsync = getYarnWorkspacesAsync;
46
54
  exports.getWorkspacesAsync = getYarnWorkspacesAsync;
55
+ /**
56
+ * Get version catalogs if present.
57
+ * Returns undefined if there's no catalog, or any issue reading or parsing.
58
+ * @see https://yarnpkg.com/features/catalogs
59
+ */
60
+ function getYarnCatalogs(cwd) {
61
+ try {
62
+ const root = getYarnWorkspaceRoot(cwd);
63
+ const yarnrcYmlPath = path_1.default.join(root, ".yarnrc.yml");
64
+ if (fs_1.default.existsSync(yarnrcYmlPath)) {
65
+ const yarnrcYml = (0, readYaml_1.readYaml)(yarnrcYmlPath);
66
+ if (yarnrcYml?.catalog || yarnrcYml?.catalogs) {
67
+ // Yarn v4+ format
68
+ return { default: yarnrcYml.catalog, named: yarnrcYml.catalogs };
69
+ }
70
+ }
71
+ else {
72
+ // Check for midgard-yarn-strict definition of catalogs in package.json
73
+ const workspaceSettings = (0, readPackageInfo_1.readPackageInfo)(root)?.workspaces;
74
+ if (workspaceSettings &&
75
+ !Array.isArray(workspaceSettings) &&
76
+ (workspaceSettings?.catalog || workspaceSettings?.catalogs)) {
77
+ return { named: workspaceSettings.catalogs, default: workspaceSettings.catalog };
78
+ }
79
+ }
80
+ }
81
+ catch (err) {
82
+ (0, logging_1.logVerboseWarning)(`Error getting yarn catalogs for ${cwd}`, err);
83
+ return undefined;
84
+ }
85
+ }
86
+ exports.getYarnCatalogs = getYarnCatalogs;
87
+ exports.getCatalogs = getYarnCatalogs;
47
88
  //# sourceMappingURL=yarn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"yarn.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/yarn.ts"],"names":[],"mappings":";;;AAAA,wBAA+C;AAE/C,mEAKiC;AAEjC,yCAAyC;AACzC,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,MAAM,IAAI,GAAG,IAAA,6BAA0B,EAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC;IACtE,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,0CAA0C,GAAG,GAAG,CAAC,CAAC;KACnE;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAND,oDAMC;AAED,8CAA8C;AAC9C,SAAgB,wBAAwB,CAAC,GAAW;IAClD,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;IACrD,OAAO,IAAA,wDAAgC,EAAC,kBAAkB,CAAC,CAAC;AAC9D,CAAC;AAHD,4DAGC;AAED,8CAA8C;AAC9C,SAAgB,6BAA6B,CAAC,GAAW;IACvD,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;IACrD,OAAO,IAAA,6DAAqC,EAAC,kBAAkB,CAAC,CAAC;AACnE,CAAC;AAHD,sEAGC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,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2BAAiB,EAAC,mCAAmC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QACjE,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAzBD,0CAyBC;AAI2B,sCAAW"}
@@ -1,2 +1,5 @@
1
- import { WorkspaceInfo } from "../types/WorkspaceInfo";
2
- export declare function listOfWorkspacePackageNames(workspaces: WorkspaceInfo): string[];
1
+ import type { WorkspaceInfos } from "../types/WorkspaceInfo";
2
+ /**
3
+ * @deprecated Just write `workspaces.map(w => w.name)` directly
4
+ */
5
+ export declare function listOfWorkspacePackageNames(workspaces: WorkspaceInfos): string[];
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listOfWorkspacePackageNames = void 0;
4
+ /**
5
+ * @deprecated Just write `workspaces.map(w => w.name)` directly
6
+ */
4
7
  function listOfWorkspacePackageNames(workspaces) {
5
8
  return workspaces.map(({ name }) => name);
6
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"listOfWorkspacePackageNames.js","sourceRoot":"","sources":["../../src/workspaces/listOfWorkspacePackageNames.ts"],"names":[],"mappings":";;;AAEA,SAAgB,2BAA2B,CAAC,UAAyB;IACnE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC;AAFD,kEAEC"}
1
+ {"version":3,"file":"listOfWorkspacePackageNames.js","sourceRoot":"","sources":["../../src/workspaces/listOfWorkspacePackageNames.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,SAAgB,2BAA2B,CAAC,UAA0B;IACpE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC;AAFD,kEAEC"}
@@ -0,0 +1,13 @@
1
+ import type { PackageInfo } from "../types/PackageInfo";
2
+ /**
3
+ * Read package.json from the given path if it exists.
4
+ * Logs a warning if it doesn't exist, or there's an error reading or parsing it.
5
+ * @returns The package info, or undefined if it doesn't exist or can't be read
6
+ */
7
+ export declare function readPackageInfo(cwd: string): PackageInfo | undefined;
8
+ /**
9
+ * Read package.json from the given path if it exists.
10
+ * Logs a warning if it doesn't exist, or there's an error reading or parsing it.
11
+ * @returns The package info, or undefined if it doesn't exist or can't be read
12
+ */
13
+ export declare function readPackageInfoAsync(cwd: string): Promise<PackageInfo | undefined>;
@@ -0,0 +1,52 @@
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.readPackageInfoAsync = exports.readPackageInfo = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const infoFromPackageJson_1 = require("../infoFromPackageJson");
11
+ const logging_1 = require("../logging");
12
+ /**
13
+ * Read package.json from the given path if it exists.
14
+ * Logs a warning if it doesn't exist, or there's an error reading or parsing it.
15
+ * @returns The package info, or undefined if it doesn't exist or can't be read
16
+ */
17
+ function readPackageInfo(cwd) {
18
+ const packageJsonPath = path_1.default.join(cwd, "package.json");
19
+ try {
20
+ if (!fs_1.default.existsSync(packageJsonPath)) {
21
+ (0, logging_1.logVerboseWarning)(`File does not exist: ${packageJsonPath}`);
22
+ return undefined;
23
+ }
24
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf-8"));
25
+ return (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath);
26
+ }
27
+ catch (e) {
28
+ (0, logging_1.logVerboseWarning)(`Error reading or parsing ${packageJsonPath}: ${e?.message || e}`);
29
+ }
30
+ }
31
+ exports.readPackageInfo = readPackageInfo;
32
+ /**
33
+ * Read package.json from the given path if it exists.
34
+ * Logs a warning if it doesn't exist, or there's an error reading or parsing it.
35
+ * @returns The package info, or undefined if it doesn't exist or can't be read
36
+ */
37
+ async function readPackageInfoAsync(cwd) {
38
+ const packageJsonPath = path_1.default.join(cwd, "package.json");
39
+ try {
40
+ if (!fs_1.default.existsSync(packageJsonPath)) {
41
+ (0, logging_1.logVerboseWarning)(`File does not exist: ${packageJsonPath}`);
42
+ return undefined;
43
+ }
44
+ const packageJson = JSON.parse(await promises_1.default.readFile(packageJsonPath, "utf-8"));
45
+ return (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath);
46
+ }
47
+ catch (e) {
48
+ (0, logging_1.logVerboseWarning)(`Error reading or parsing ${packageJsonPath}: ${e?.message || e}`);
49
+ }
50
+ }
51
+ exports.readPackageInfoAsync = readPackageInfoAsync;
52
+ //# sourceMappingURL=readPackageInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readPackageInfo.js","sourceRoot":"","sources":["../../src/workspaces/readPackageInfo.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,2DAAqC;AACrC,gDAAwB;AAExB,gEAA6D;AAC7D,wCAA+C;AAE/C;;;;GAIG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IACvD,IAAI;QACF,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;YACnC,IAAA,2BAAiB,EAAC,wBAAwB,eAAe,EAAE,CAAC,CAAC;YAC7D,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1E,OAAO,IAAA,yCAAmB,EAAC,WAAW,EAAE,eAAe,CAAC,CAAC;KAC1D;IAAC,OAAO,CAAC,EAAE;QACV,IAAA,2BAAiB,EAAC,4BAA4B,eAAe,KAAM,CAAW,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;KACjG;AACH,CAAC;AAbD,0CAaC;AAED;;;;GAIG;AACI,KAAK,UAAU,oBAAoB,CAAC,GAAW;IACpD,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IACvD,IAAI;QACF,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;YACnC,IAAA,2BAAiB,EAAC,wBAAwB,eAAe,EAAE,CAAC,CAAC;YAC7D,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,kBAAU,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;QACpF,OAAO,IAAA,yCAAmB,EAAC,WAAW,EAAE,eAAe,CAAC,CAAC;KAC1D;IAAC,OAAO,CAAC,EAAE;QACV,IAAA,2BAAiB,EAAC,4BAA4B,eAAe,KAAM,CAAW,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;KACjG;AACH,CAAC;AAbD,oDAaC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workspace-tools",
3
- "version": "0.38.4",
3
+ "version": "0.38.5",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "scripts": {
16
16
  "api": "ws-tools-scripts api",
17
- "build": "tsc",
17
+ "build": "tsc --pretty",
18
18
  "start": "tsc -w --preserveWatchOutput",
19
19
  "test": "jest"
20
20
  },
@@ -28,7 +28,6 @@
28
28
  "micromatch": "^4.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "lodash": "^4.17.21",
32
31
  "@ws-tools/scripts": "*"
33
32
  }
34
33
  }