workspace-tools 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.json +63 -1
  2. package/CHANGELOG.md +28 -2
  3. package/README.md +4 -0
  4. package/lib/getPackageInfos.js +37 -49
  5. package/lib/getPackageInfos.js.map +1 -1
  6. package/lib/getPackagePaths.d.ts +10 -2
  7. package/lib/getPackagePaths.js +32 -33
  8. package/lib/getPackagePaths.js.map +1 -1
  9. package/lib/index.d.ts +5 -4
  10. package/lib/index.js +12 -4
  11. package/lib/index.js.map +1 -1
  12. package/lib/lockfile/index.js +1 -1
  13. package/lib/lockfile/index.js.map +1 -1
  14. package/lib/logging.d.ts +5 -0
  15. package/lib/logging.js +15 -0
  16. package/lib/logging.js.map +1 -0
  17. package/lib/paths.js +7 -1
  18. package/lib/paths.js.map +1 -1
  19. package/lib/types/WorkspaceInfo.d.ts +7 -0
  20. package/lib/workspaces/findWorkspacePath.d.ts +7 -0
  21. package/lib/workspaces/findWorkspacePath.js +9 -4
  22. package/lib/workspaces/findWorkspacePath.js.map +1 -1
  23. package/lib/workspaces/{workspaces.d.ts → getAllPackageJsonFiles.d.ts} +5 -3
  24. package/lib/workspaces/getAllPackageJsonFiles.js +38 -0
  25. package/lib/workspaces/getAllPackageJsonFiles.js.map +1 -0
  26. package/lib/workspaces/getWorkspacePackageInfo.d.ts +22 -2
  27. package/lib/workspaces/getWorkspacePackageInfo.js +45 -28
  28. package/lib/workspaces/getWorkspacePackageInfo.js.map +1 -1
  29. package/lib/workspaces/getWorkspacePackagePaths.d.ts +10 -0
  30. package/lib/workspaces/getWorkspacePackagePaths.js +31 -0
  31. package/lib/workspaces/getWorkspacePackagePaths.js.map +1 -0
  32. package/lib/workspaces/getWorkspaceRoot.d.ts +8 -1
  33. package/lib/workspaces/getWorkspaceRoot.js +9 -18
  34. package/lib/workspaces/getWorkspaceRoot.js.map +1 -1
  35. package/lib/workspaces/getWorkspaces.d.ts +16 -0
  36. package/lib/workspaces/getWorkspaces.js +25 -28
  37. package/lib/workspaces/getWorkspaces.js.map +1 -1
  38. package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.d.ts +22 -0
  39. package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.js +63 -0
  40. package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.js.map +1 -0
  41. package/lib/workspaces/implementations/getWorkspaceUtilities.d.ts +26 -0
  42. package/lib/workspaces/implementations/getWorkspaceUtilities.js +26 -0
  43. package/lib/workspaces/implementations/getWorkspaceUtilities.js.map +1 -0
  44. package/lib/workspaces/implementations/index.d.ts +2 -14
  45. package/lib/workspaces/implementations/index.js +5 -55
  46. package/lib/workspaces/implementations/index.js.map +1 -1
  47. package/lib/workspaces/implementations/lerna.d.ts +8 -2
  48. package/lib/workspaces/implementations/lerna.js +29 -12
  49. package/lib/workspaces/implementations/lerna.js.map +1 -1
  50. package/lib/workspaces/implementations/npm.d.ts +14 -1
  51. package/lib/workspaces/implementations/npm.js +31 -8
  52. package/lib/workspaces/implementations/npm.js.map +1 -1
  53. package/lib/workspaces/implementations/packageJsonWorkspaces.d.ts +14 -1
  54. package/lib/workspaces/implementations/packageJsonWorkspaces.js +50 -24
  55. package/lib/workspaces/implementations/packageJsonWorkspaces.js.map +1 -1
  56. package/lib/workspaces/implementations/pnpm.d.ts +8 -0
  57. package/lib/workspaces/implementations/pnpm.js +30 -11
  58. package/lib/workspaces/implementations/pnpm.js.map +1 -1
  59. package/lib/workspaces/implementations/rush.d.ts +8 -0
  60. package/lib/workspaces/implementations/rush.js +30 -9
  61. package/lib/workspaces/implementations/rush.js.map +1 -1
  62. package/lib/workspaces/implementations/yarn.d.ts +15 -0
  63. package/lib/workspaces/implementations/yarn.js +32 -7
  64. package/lib/workspaces/implementations/yarn.js.map +1 -1
  65. package/package.json +1 -1
  66. package/lib/workspaces/workspaces.js +0 -34
  67. package/lib/workspaces/workspaces.js.map +0 -1
@@ -3,33 +3,50 @@ 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.getLernaWorkspaces = exports.getLernaWorkspaceRoot = void 0;
6
+ exports.getWorkspaces = exports.getLernaWorkspaces = exports.getWorkspacePackagePaths = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const jju_1 = __importDefault(require("jju"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const getPackagePaths_1 = require("../../getPackagePaths");
11
- const paths_1 = require("../../paths");
12
11
  const getWorkspacePackageInfo_1 = require("../getWorkspacePackageInfo");
12
+ const logging_1 = require("../../logging");
13
+ const getWorkspaceManagerAndRoot_1 = require("./getWorkspaceManagerAndRoot");
13
14
  function getLernaWorkspaceRoot(cwd) {
14
- const lernaJsonPath = (0, paths_1.searchUp)("lerna.json", cwd);
15
- if (!lernaJsonPath) {
16
- throw new Error("Could not find lerna workspace root");
15
+ var _a;
16
+ const root = (_a = (0, getWorkspaceManagerAndRoot_1.getWorkspaceManagerAndRoot)(cwd, undefined, "lerna")) === null || _a === void 0 ? void 0 : _a.root;
17
+ if (!root) {
18
+ throw new Error("Could not find lerna workspace root from " + cwd);
17
19
  }
18
- return path_1.default.dirname(lernaJsonPath);
20
+ return root;
19
21
  }
20
- exports.getLernaWorkspaceRoot = getLernaWorkspaceRoot;
21
- function getLernaWorkspaces(cwd, ignorePatterns) {
22
+ /** Get package paths for a lerna workspace. */
23
+ function getWorkspacePackagePaths(cwd) {
22
24
  try {
23
25
  const lernaWorkspaceRoot = getLernaWorkspaceRoot(cwd);
24
26
  const lernaJsonPath = path_1.default.join(lernaWorkspaceRoot, "lerna.json");
25
27
  const lernaConfig = jju_1.default.parse(fs_1.default.readFileSync(lernaJsonPath, "utf-8"));
26
- const packagePaths = (0, getPackagePaths_1.getPackagePaths)(lernaWorkspaceRoot, lernaConfig.packages, ignorePatterns);
27
- const workspaceInfo = (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths);
28
- return workspaceInfo;
28
+ return (0, getPackagePaths_1.getPackagePaths)(lernaWorkspaceRoot, lernaConfig.packages);
29
29
  }
30
- catch {
30
+ catch (err) {
31
+ (0, logging_1.logVerboseWarning)(`Error getting lerna workspace package paths for ${cwd}`, err);
32
+ return [];
33
+ }
34
+ }
35
+ exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
36
+ /**
37
+ * Get an array with names, paths, and package.json contents for each package in a lerna workspace.
38
+ * (See `../getWorkspaces` for why it's named this way.)
39
+ */
40
+ function getLernaWorkspaces(cwd) {
41
+ try {
42
+ const packagePaths = getWorkspacePackagePaths(cwd);
43
+ return (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths);
44
+ }
45
+ catch (err) {
46
+ (0, logging_1.logVerboseWarning)(`Error getting lerna workspaces for ${cwd}`, err);
31
47
  return [];
32
48
  }
33
49
  }
34
50
  exports.getLernaWorkspaces = getLernaWorkspaces;
51
+ exports.getWorkspaces = getLernaWorkspaces;
35
52
  //# sourceMappingURL=lerna.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lerna.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/lerna.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,8CAAsB;AACtB,gDAAwB;AACxB,2DAAwD;AACxD,uCAAuC;AAEvC,wEAAqE;AAErE,SAAgB,qBAAqB,CAAC,GAAW;IAC/C,MAAM,aAAa,GAAG,IAAA,gBAAQ,EAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAElD,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAED,OAAO,cAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACrC,CAAC;AARD,sDAQC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,cAAyB;IACvE,IAAI;QACF,MAA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AAa,EAAE,OAAO,CAAC,CAAC,CAAC;QACvE,OAAO,IAAA,iCAAe,EAAC,kBAAkB,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;KAClE;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,mDAAmD,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QACjF,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAVD,4DAUC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,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,sCAAsC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QACpE,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,gDAQC;AAE8B,2CAAa"}
@@ -1,4 +1,17 @@
1
1
  import { WorkspaceInfo } from "../../types/WorkspaceInfo";
2
- export declare function getNpmWorkspaceRoot(cwd: string): string;
2
+ /** Get package paths for an npm workspace. */
3
+ export declare function getWorkspacePackagePaths(cwd: string): string[];
4
+ /** Get package paths for an npm workspace. */
5
+ export declare function getWorkspacePackagePathsAsync(cwd: string): Promise<string[]>;
6
+ /**
7
+ * Get an array with names, paths, and package.json contents for each package in an npm workspace.
8
+ * (See `../getWorkspaces` for why it's named this way.)
9
+ */
3
10
  export declare function getNpmWorkspaces(cwd: string): WorkspaceInfo;
11
+ /**
12
+ * Get an array with names, paths, and package.json contents for each package in an npm workspace.
13
+ * (See `../getWorkspaces` for why it's named this way.)
14
+ */
4
15
  export declare function getNpmWorkspacesAsync(cwd: string): Promise<WorkspaceInfo>;
16
+ export { getNpmWorkspaces as getWorkspaces };
17
+ export { getNpmWorkspacesAsync as getWorkspacesAsync };
@@ -1,23 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNpmWorkspacesAsync = exports.getNpmWorkspaces = exports.getNpmWorkspaceRoot = void 0;
3
+ exports.getWorkspacesAsync = exports.getWorkspaces = exports.getNpmWorkspacesAsync = exports.getNpmWorkspaces = exports.getWorkspacePackagePathsAsync = exports.getWorkspacePackagePaths = void 0;
4
+ const _1 = require(".");
4
5
  const packageJsonWorkspaces_1 = require("./packageJsonWorkspaces");
5
6
  function getNpmWorkspaceRoot(cwd) {
6
- const npmWorkspacesRoot = (0, packageJsonWorkspaces_1.getPackageJsonWorkspaceRoot)(cwd);
7
- if (!npmWorkspacesRoot) {
8
- throw new Error("Could not find NPM workspaces root");
7
+ var _a;
8
+ const root = (_a = (0, _1.getWorkspaceManagerAndRoot)(cwd, undefined, "npm")) === null || _a === void 0 ? void 0 : _a.root;
9
+ if (!root) {
10
+ throw new Error("Could not find npm workspace root from " + cwd);
9
11
  }
10
- return npmWorkspacesRoot;
12
+ return root;
11
13
  }
12
- exports.getNpmWorkspaceRoot = getNpmWorkspaceRoot;
14
+ /** Get package paths for an npm workspace. */
15
+ function getWorkspacePackagePaths(cwd) {
16
+ const npmWorkspacesRoot = getNpmWorkspaceRoot(cwd);
17
+ return (0, packageJsonWorkspaces_1.getPackagePathsFromWorkspaceRoot)(npmWorkspacesRoot);
18
+ }
19
+ exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
20
+ /** Get package paths for an npm workspace. */
21
+ function getWorkspacePackagePathsAsync(cwd) {
22
+ const npmWorkspacesRoot = getNpmWorkspaceRoot(cwd);
23
+ return (0, packageJsonWorkspaces_1.getPackagePathsFromWorkspaceRootAsync)(npmWorkspacesRoot);
24
+ }
25
+ exports.getWorkspacePackagePathsAsync = getWorkspacePackagePathsAsync;
26
+ /**
27
+ * Get an array with names, paths, and package.json contents for each package in an npm workspace.
28
+ * (See `../getWorkspaces` for why it's named this way.)
29
+ */
13
30
  function getNpmWorkspaces(cwd) {
14
31
  const npmWorkspacesRoot = getNpmWorkspaceRoot(cwd);
15
32
  return (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRoot)(npmWorkspacesRoot);
16
33
  }
17
34
  exports.getNpmWorkspaces = getNpmWorkspaces;
18
- async function getNpmWorkspacesAsync(cwd) {
35
+ exports.getWorkspaces = getNpmWorkspaces;
36
+ /**
37
+ * Get an array with names, paths, and package.json contents for each package in an npm workspace.
38
+ * (See `../getWorkspaces` for why it's named this way.)
39
+ */
40
+ function getNpmWorkspacesAsync(cwd) {
19
41
  const npmWorkspacesRoot = getNpmWorkspaceRoot(cwd);
20
- return await (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRootAsync)(npmWorkspacesRoot);
42
+ return (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRootAsync)(npmWorkspacesRoot);
21
43
  }
22
44
  exports.getNpmWorkspacesAsync = getNpmWorkspacesAsync;
45
+ exports.getWorkspacesAsync = getNpmWorkspacesAsync;
23
46
  //# sourceMappingURL=npm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"npm.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/npm.ts"],"names":[],"mappings":";;;AACA,mEAIiC;AAEjC,SAAgB,mBAAmB,CAAC,GAAW;IAC7C,MAAM,iBAAiB,GAAG,IAAA,mDAA2B,EAAC,GAAG,CAAC,CAAC;IAE3D,IAAI,CAAC,iBAAiB,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;KACvD;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AARD,kDAQC;AAED,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACnD,OAAO,IAAA,yDAAiC,EAAC,iBAAiB,CAAC,CAAC;AAC9D,CAAC;AAHD,4CAGC;AAEM,KAAK,UAAU,qBAAqB,CAAC,GAAW;IACrD,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;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,mDAAkB"}
@@ -1,3 +1,16 @@
1
- export declare function getPackageJsonWorkspaceRoot(cwd: string): string | null;
1
+ export declare function getPackagePathsFromWorkspaceRoot(packageJsonWorkspacesRoot: string): string[];
2
+ /**
3
+ * Get an array with names, paths, and package.json contents for each package in an npm/yarn workspace.
4
+ * (See `../getWorkspaces` for why it's named this way.)
5
+ */
6
+ export declare function getPackagePathsFromWorkspaceRootAsync(packageJsonWorkspacesRoot: string): Promise<string[]>;
7
+ /**
8
+ * Get an array with names, paths, and package.json contents for each package in an npm/yarn workspace.
9
+ * (See `../getWorkspaces` for why it's named this way.)
10
+ */
2
11
  export declare function getWorkspaceInfoFromWorkspaceRoot(packageJsonWorkspacesRoot: string): import("../..").WorkspaceInfo;
12
+ /**
13
+ * Get an array with names, paths, and package.json contents for each package in an npm/yarn workspace.
14
+ * (See `../getWorkspaces` for why it's named this way.)
15
+ */
3
16
  export declare function getWorkspaceInfoFromWorkspaceRootAsync(packageJsonWorkspacesRoot: string): Promise<import("../..").WorkspaceInfo>;
@@ -3,59 +3,85 @@ 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.getWorkspaceInfoFromWorkspaceRootAsync = exports.getWorkspaceInfoFromWorkspaceRoot = exports.getPackageJsonWorkspaceRoot = void 0;
6
+ exports.getWorkspaceInfoFromWorkspaceRootAsync = exports.getWorkspaceInfoFromWorkspaceRoot = exports.getPackagePathsFromWorkspaceRootAsync = exports.getPackagePathsFromWorkspaceRoot = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
- const _1 = require(".");
10
9
  const getPackagePaths_1 = require("../../getPackagePaths");
11
10
  const getWorkspacePackageInfo_1 = require("../getWorkspacePackageInfo");
12
- function getPackageJsonWorkspaceRoot(cwd) {
13
- var _a;
14
- const lockFile = (_a = (0, _1.getWorkspaceImplementationAndLockFile)(cwd)) === null || _a === void 0 ? void 0 : _a.lockFile;
15
- const packageJsonWorkspacesRoot = lockFile ? path_1.default.dirname(lockFile) : cwd;
16
- return packageJsonWorkspacesRoot;
17
- }
18
- exports.getPackageJsonWorkspaceRoot = getPackageJsonWorkspaceRoot;
19
- function getRootPackageJson(packageJsonWorkspacesRoot) {
11
+ const logging_1 = require("../../logging");
12
+ /**
13
+ * Read the workspace root package.json and get the list of package globs from its `workspaces` property.
14
+ */
15
+ function getPackages(packageJsonWorkspacesRoot) {
20
16
  const packageJsonFile = path_1.default.join(packageJsonWorkspacesRoot, "package.json");
17
+ let packageJson;
21
18
  try {
22
- const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonFile, "utf-8"));
23
- return packageJson;
19
+ packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonFile, "utf-8"));
24
20
  }
25
21
  catch (e) {
26
22
  throw new Error("Could not load package.json from workspaces root");
27
23
  }
28
- }
29
- function getPackages(packageJson) {
30
24
  const { workspaces } = packageJson;
31
- if (workspaces && Array.isArray(workspaces)) {
25
+ if (Array.isArray(workspaces)) {
32
26
  return workspaces;
33
27
  }
34
- if (!workspaces || !workspaces.packages) {
28
+ if (!(workspaces === null || workspaces === void 0 ? void 0 : workspaces.packages)) {
35
29
  throw new Error("Could not find a workspaces object in package.json");
36
30
  }
37
31
  return workspaces.packages;
38
32
  }
33
+ function getPackagePathsFromWorkspaceRoot(packageJsonWorkspacesRoot) {
34
+ try {
35
+ const packageGlobs = getPackages(packageJsonWorkspacesRoot);
36
+ return packageGlobs ? (0, getPackagePaths_1.getPackagePaths)(packageJsonWorkspacesRoot, packageGlobs) : [];
37
+ }
38
+ catch (err) {
39
+ (0, logging_1.logVerboseWarning)(`Error getting package paths for ${packageJsonWorkspacesRoot}`, err);
40
+ return [];
41
+ }
42
+ }
43
+ exports.getPackagePathsFromWorkspaceRoot = getPackagePathsFromWorkspaceRoot;
44
+ /**
45
+ * Get an array with names, paths, and package.json contents for each package in an npm/yarn workspace.
46
+ * (See `../getWorkspaces` for why it's named this way.)
47
+ */
48
+ async function getPackagePathsFromWorkspaceRootAsync(packageJsonWorkspacesRoot) {
49
+ try {
50
+ const packageGlobs = getPackages(packageJsonWorkspacesRoot);
51
+ return packageGlobs ? (0, getPackagePaths_1.getPackagePathsAsync)(packageJsonWorkspacesRoot, packageGlobs) : [];
52
+ }
53
+ catch (err) {
54
+ (0, logging_1.logVerboseWarning)(`Error getting package paths for ${packageJsonWorkspacesRoot}`, err);
55
+ return [];
56
+ }
57
+ }
58
+ exports.getPackagePathsFromWorkspaceRootAsync = getPackagePathsFromWorkspaceRootAsync;
59
+ /**
60
+ * Get an array with names, paths, and package.json contents for each package in an npm/yarn workspace.
61
+ * (See `../getWorkspaces` for why it's named this way.)
62
+ */
39
63
  function getWorkspaceInfoFromWorkspaceRoot(packageJsonWorkspacesRoot) {
40
64
  try {
41
- const rootPackageJson = getRootPackageJson(packageJsonWorkspacesRoot);
42
- const packages = getPackages(rootPackageJson);
43
- const packagePaths = (0, getPackagePaths_1.getPackagePaths)(packageJsonWorkspacesRoot, packages);
65
+ const packagePaths = getPackagePathsFromWorkspaceRoot(packageJsonWorkspacesRoot);
44
66
  return (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths);
45
67
  }
46
- catch {
68
+ catch (err) {
69
+ (0, logging_1.logVerboseWarning)(`Error getting workspace info for ${packageJsonWorkspacesRoot}`, err);
47
70
  return [];
48
71
  }
49
72
  }
50
73
  exports.getWorkspaceInfoFromWorkspaceRoot = getWorkspaceInfoFromWorkspaceRoot;
74
+ /**
75
+ * Get an array with names, paths, and package.json contents for each package in an npm/yarn workspace.
76
+ * (See `../getWorkspaces` for why it's named this way.)
77
+ */
51
78
  async function getWorkspaceInfoFromWorkspaceRootAsync(packageJsonWorkspacesRoot) {
52
79
  try {
53
- const rootPackageJson = getRootPackageJson(packageJsonWorkspacesRoot);
54
- const packages = getPackages(rootPackageJson);
55
- const packagePaths = await (0, getPackagePaths_1.getPackagePathsAsync)(packageJsonWorkspacesRoot, packages);
80
+ const packagePaths = await getPackagePathsFromWorkspaceRootAsync(packageJsonWorkspacesRoot);
56
81
  return (0, getWorkspacePackageInfo_1.getWorkspacePackageInfoAsync)(packagePaths);
57
82
  }
58
- catch {
83
+ catch (err) {
84
+ (0, logging_1.logVerboseWarning)(`Error getting workspace info for ${packageJsonWorkspacesRoot}`, err);
59
85
  return [];
60
86
  }
61
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"packageJsonWorkspaces.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/packageJsonWorkspaces.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,wBAA0D;AAC1D,2DAA8E;AAC9E,wEAAmG;AAWnG,SAAgB,2BAA2B,CAAC,GAAW;;IACrD,MAAM,QAAQ,GAAG,MAAA,IAAA,wCAAqC,EAAC,GAAG,CAAC,0CAAE,QAAQ,CAAC;IACtE,MAAM,yBAAyB,GAAG,QAAQ,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1E,OAAO,yBAAyB,CAAC;AACnC,CAAC;AAJD,kEAIC;AAED,SAAS,kBAAkB,CAAC,yBAAiC;IAC3D,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,cAAc,CAAC,CAAC;IAE7E,IAAI;QACF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1E,OAAO,WAAW,CAAC;KACpB;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;KACrE;AACH,CAAC;AAED,SAAS,WAAW,CAAC,WAAkC;IACrD,MAAM,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;IAEnC,IAAI,UAAU,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC3C,OAAO,UAAU,CAAC;KACnB;IAED,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;KACvE;IAED,OAAO,UAAU,CAAC,QAAQ,CAAC;AAC7B,CAAC;AAED,SAAgB,iCAAiC,CAAC,yBAAiC;IACjF,IAAI;QACF,MAAM,eAAe,GAAG,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;QACtE,MAAM,QAAQ,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;QAC9C,MAAM,YAAY,GAAG,IAAA,iCAAe,EAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;QAC1E,OAAO,IAAA,iDAAuB,EAAC,YAAY,CAAC,CAAC;KAC9C;IAAC,MAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AATD,8EASC;AAEM,KAAK,UAAU,sCAAsC,CAAC,yBAAiC;IAC5F,IAAI;QACF,MAAM,eAAe,GAAG,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;QACtE,MAAM,QAAQ,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;QAC9C,MAAM,YAAY,GAAG,MAAM,IAAA,sCAAoB,EAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;QACrF,OAAO,IAAA,sDAA4B,EAAC,YAAY,CAAC,CAAC;KACnD;IAAC,MAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AATD,wFASC"}
1
+ {"version":3,"file":"packageJsonWorkspaces.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/packageJsonWorkspaces.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,2DAA8E;AAC9E,wEAAmG;AACnG,2CAAkD;AAWlD;;GAEG;AACH,SAAS,WAAW,CAAC,yBAAiC;IACpD,MAAM,eAAe,GAAG,cAAI,CAAC,IAA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AAA,2BAAiB,EAAC,mCAAmC,yBAAyB,EAAE,EAAE,GAAG,CAAC,CAAC;QACvF,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,sFAQC;AAED;;;GAGG;AACH,SAAgB,iCAAiC,CAAC,yBAAiC;IACjF,IAAI;QACF,MAAM,YAAY,GAAG,gCAAgC,CAAC,yBAAyB,CAAC,CAAC;QACjF,OAAO,IAAA,iDAAuB,EAAC,YAAY,CAAC,CAAC;KAC9C;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,oCAAoC,yBAAyB,EAAE,EAAE,GAAG,CAAC,CAAC;QACxF,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,8EAQC;AAED;;;GAGG;AACI,KAAK,UAAU,sCAAsC,CAAC,yBAAiC;IAC5F,IAAI;QACF,MAAM,YAAY,GAAG,MAAM,qCAAqC,CAAC,yBAAyB,CAAC,CAAC;QAC5F,OAAO,IAAA,sDAA4B,EAAC,YAAY,CAAC,CAAC;KACnD;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,oCAAoC,yBAAyB,EAAE,EAAE,GAAG,CAAC,CAAC;QACxF,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,wFAQC"}
@@ -1,3 +1,11 @@
1
1
  import { WorkspaceInfo } from "../../types/WorkspaceInfo";
2
+ /** @deprecated Use `getWorkspaceRoot` */
2
3
  export declare function getPnpmWorkspaceRoot(cwd: string): string;
4
+ /** Get package paths for a pnpm workspace. */
5
+ export declare function getWorkspacePackagePaths(cwd: string): string[];
6
+ /**
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.)
9
+ */
3
10
  export declare function getPnpmWorkspaces(cwd: string): WorkspaceInfo;
11
+ export { getPnpmWorkspaces as getWorkspaces };
@@ -3,32 +3,51 @@ 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.getPnpmWorkspaces = exports.getPnpmWorkspaceRoot = void 0;
6
+ exports.getWorkspaces = 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
- const paths_1 = require("../../paths");
11
+ const logging_1 = require("../../logging");
12
+ const getWorkspaceManagerAndRoot_1 = require("./getWorkspaceManagerAndRoot");
13
+ /** @deprecated Use `getWorkspaceRoot` */
12
14
  function getPnpmWorkspaceRoot(cwd) {
13
- const pnpmWorkspacesFile = (0, paths_1.searchUp)("pnpm-workspace.yaml", cwd);
14
- if (!pnpmWorkspacesFile) {
15
- throw new Error("Could not find pnpm workspaces root");
15
+ var _a;
16
+ const root = (_a = (0, getWorkspaceManagerAndRoot_1.getWorkspaceManagerAndRoot)(cwd, undefined, "pnpm")) === null || _a === void 0 ? void 0 : _a.root;
17
+ if (!root) {
18
+ throw new Error("Could not find pnpm workspace root from " + cwd);
16
19
  }
17
- return path_1.default.dirname(pnpmWorkspacesFile);
20
+ return root;
18
21
  }
19
22
  exports.getPnpmWorkspaceRoot = getPnpmWorkspaceRoot;
20
- function getPnpmWorkspaces(cwd) {
23
+ /** Get package paths for a pnpm workspace. */
24
+ function getWorkspacePackagePaths(cwd) {
21
25
  try {
22
26
  const pnpmWorkspacesRoot = getPnpmWorkspaceRoot(cwd);
23
27
  const pnpmWorkspacesFile = path_1.default.join(pnpmWorkspacesRoot, "pnpm-workspace.yaml");
24
28
  const pnpmWorkspaces = (0, readYaml_1.readYaml)(pnpmWorkspacesFile);
25
- const packagePaths = (0, getPackagePaths_1.getPackagePaths)(pnpmWorkspacesRoot, pnpmWorkspaces.packages);
26
- const workspaceInfo = (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths);
27
- return workspaceInfo;
29
+ return (0, getPackagePaths_1.getPackagePaths)(pnpmWorkspacesRoot, pnpmWorkspaces.packages);
30
+ }
31
+ catch (err) {
32
+ (0, logging_1.logVerboseWarning)(`Error getting pnpm workspace package paths for ${cwd}`, err);
33
+ return [];
34
+ }
35
+ }
36
+ exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
37
+ /**
38
+ * Get an array with names, paths, and package.json contents for each package in a pnpm workspace.
39
+ * (See `../getWorkspaces` for why it's named this way.)
40
+ */
41
+ function getPnpmWorkspaces(cwd) {
42
+ try {
43
+ const packagePaths = getWorkspacePackagePaths(cwd);
44
+ return (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths);
28
45
  }
29
- catch {
46
+ catch (err) {
47
+ (0, logging_1.logVerboseWarning)(`Error getting pnpm workspaces for ${cwd}`, err);
30
48
  return [];
31
49
  }
32
50
  }
33
51
  exports.getPnpmWorkspaces = getPnpmWorkspaces;
52
+ exports.getWorkspaces = getPnpmWorkspaces;
34
53
  //# 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,wEAAqE;AACrE,sDAAmD;AACnD,uCAAuC;AAMvC,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,MAAM,kBAAkB,GAAG,IAAA,gBAAQ,EAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;IAEhE,IAAI,CAAC,kBAAkB,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAED,OAAO,cAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC1C,CAAC;AARD,oDAQC;AAED,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,IAAI;QACF,MAAM,kBAAkB,GAAG,oB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CAAC,QAAQ,CAAC,CAAC;KACrE;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,kDAAkD,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;QAChF,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAZD,4DAYC;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;AAE6B,0CAAa"}
@@ -1,3 +1,11 @@
1
1
  import { WorkspaceInfo } from "../../types/WorkspaceInfo";
2
+ /** @deprecated Use getWorkspaceRoot */
2
3
  export declare function getRushWorkspaceRoot(cwd: string): string;
4
+ /** Get package paths for a rush workspace. */
5
+ export declare function getWorkspacePackagePaths(cwd: string): string[];
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.)
9
+ */
3
10
  export declare function getRushWorkspaces(cwd: string): WorkspaceInfo;
11
+ export { getRushWorkspaces as getWorkspaces };
@@ -3,31 +3,52 @@ 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.getRushWorkspaces = exports.getRushWorkspaceRoot = void 0;
6
+ exports.getWorkspaces = exports.getRushWorkspaces = exports.getWorkspacePackagePaths = exports.getRushWorkspaceRoot = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const jju_1 = __importDefault(require("jju"));
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const getWorkspacePackageInfo_1 = require("../getWorkspacePackageInfo");
11
- const paths_1 = require("../../paths");
11
+ const logging_1 = require("../../logging");
12
+ const getWorkspaceManagerAndRoot_1 = require("./getWorkspaceManagerAndRoot");
13
+ /** @deprecated Use getWorkspaceRoot */
12
14
  function getRushWorkspaceRoot(cwd) {
13
- const rushJsonPath = (0, paths_1.searchUp)("rush.json", cwd);
14
- if (!rushJsonPath) {
15
- throw new Error("Could not find rush workspaces root");
15
+ var _a;
16
+ const root = (_a = (0, getWorkspaceManagerAndRoot_1.getWorkspaceManagerAndRoot)(cwd, undefined, "rush")) === null || _a === void 0 ? void 0 : _a.root;
17
+ if (!root) {
18
+ throw new Error("Could not find rush workspace root from " + cwd);
16
19
  }
17
- return path_1.default.dirname(rushJsonPath);
20
+ return root;
18
21
  }
19
22
  exports.getRushWorkspaceRoot = getRushWorkspaceRoot;
20
- function getRushWorkspaces(cwd) {
23
+ /** Get package paths for a rush workspace. */
24
+ function getWorkspacePackagePaths(cwd) {
21
25
  try {
22
26
  const rushWorkspaceRoot = getRushWorkspaceRoot(cwd);
23
27
  const rushJsonPath = path_1.default.join(rushWorkspaceRoot, "rush.json");
24
28
  const rushConfig = jju_1.default.parse(fs_1.default.readFileSync(rushJsonPath, "utf-8"));
25
29
  const root = path_1.default.dirname(rushJsonPath);
26
- return (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(rushConfig.projects.map((project) => path_1.default.join(root, project.projectFolder)));
30
+ return rushConfig.projects.map((project) => path_1.default.join(root, project.projectFolder));
31
+ }
32
+ catch (err) {
33
+ (0, logging_1.logVerboseWarning)(`Error getting rush workspace package paths for ${cwd}`, err);
34
+ return [];
35
+ }
36
+ }
37
+ exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
38
+ /**
39
+ * Get an array with names, paths, and package.json contents for each package in a rush workspace.
40
+ * (See `../getWorkspaces` for why it's named this way.)
41
+ */
42
+ function getRushWorkspaces(cwd) {
43
+ try {
44
+ const packagePaths = getWorkspacePackagePaths(cwd);
45
+ return (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths);
27
46
  }
28
- catch {
47
+ catch (err) {
48
+ (0, logging_1.logVerboseWarning)(`Error getting rush workspaces for ${cwd}`, err);
29
49
  return [];
30
50
  }
31
51
  }
32
52
  exports.getRushWorkspaces = getRushWorkspaces;
53
+ exports.getWorkspaces = getRushWorkspaces;
33
54
  //# sourceMappingURL=rush.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rush.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/rush.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,8CAAsB;AACtB,4CAAoB;AAGpB,wEAAqE;AACrE,uCAAuC;AAEvC,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,MAAM,YAAY,GAAG,IAAA,gBAAQ,EAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAEhD,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAED,OAAO,cAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AACpC,CAAC;AARD,oDAQC;AAED,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,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;QAExC,OAAO,IAAA,iDAAuB,EAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC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;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;AAE6B,0CAAa"}
@@ -1,4 +1,19 @@
1
1
  import { WorkspaceInfo } from "../../types/WorkspaceInfo";
2
+ /** @deprecated Use `getWorkspaceRoot` */
2
3
  export declare function getYarnWorkspaceRoot(cwd: string): string;
4
+ /** Get package paths for a yarn workspace. */
5
+ export declare function getWorkspacePackagePaths(cwd: string): string[];
6
+ /** Get package paths for a yarn workspace. */
7
+ export declare function getWorkspacePackagePathsAsync(cwd: string): Promise<string[]>;
8
+ /**
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.)
11
+ */
3
12
  export declare function getYarnWorkspaces(cwd: string): WorkspaceInfo;
13
+ /**
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.)
16
+ */
4
17
  export declare function getYarnWorkspacesAsync(cwd: string): Promise<WorkspaceInfo>;
18
+ export { getYarnWorkspaces as getWorkspaces };
19
+ export { getYarnWorkspacesAsync as getWorkspacesAsync };
@@ -1,23 +1,48 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getYarnWorkspacesAsync = exports.getYarnWorkspaces = exports.getYarnWorkspaceRoot = void 0;
3
+ exports.getWorkspacesAsync = exports.getWorkspaces = exports.getYarnWorkspacesAsync = exports.getYarnWorkspaces = exports.getWorkspacePackagePathsAsync = exports.getWorkspacePackagePaths = exports.getYarnWorkspaceRoot = void 0;
4
+ const _1 = require(".");
4
5
  const packageJsonWorkspaces_1 = require("./packageJsonWorkspaces");
6
+ /** @deprecated Use `getWorkspaceRoot` */
5
7
  function getYarnWorkspaceRoot(cwd) {
6
- const yarnWorkspacesRoot = (0, packageJsonWorkspaces_1.getPackageJsonWorkspaceRoot)(cwd);
7
- if (!yarnWorkspacesRoot) {
8
- throw new Error("Could not find yarn workspaces root");
8
+ var _a;
9
+ const root = (_a = (0, _1.getWorkspaceManagerAndRoot)(cwd, undefined, "yarn")) === null || _a === void 0 ? void 0 : _a.root;
10
+ if (!root) {
11
+ throw new Error("Could not find yarn workspace root from " + cwd);
9
12
  }
10
- return yarnWorkspacesRoot;
13
+ return root;
11
14
  }
12
15
  exports.getYarnWorkspaceRoot = getYarnWorkspaceRoot;
16
+ /** Get package paths for a yarn workspace. */
17
+ function getWorkspacePackagePaths(cwd) {
18
+ const yarnWorkspacesRoot = getYarnWorkspaceRoot(cwd);
19
+ return (0, packageJsonWorkspaces_1.getPackagePathsFromWorkspaceRoot)(yarnWorkspacesRoot);
20
+ }
21
+ exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
22
+ /** Get package paths for a yarn workspace. */
23
+ function getWorkspacePackagePathsAsync(cwd) {
24
+ const yarnWorkspacesRoot = getYarnWorkspaceRoot(cwd);
25
+ return (0, packageJsonWorkspaces_1.getPackagePathsFromWorkspaceRootAsync)(yarnWorkspacesRoot);
26
+ }
27
+ exports.getWorkspacePackagePathsAsync = getWorkspacePackagePathsAsync;
28
+ /**
29
+ * Get an array with names, paths, and package.json contents for each package in a yarn workspace.
30
+ * (See `../getWorkspaces` for why it's named this way.)
31
+ */
13
32
  function getYarnWorkspaces(cwd) {
14
33
  const yarnWorkspacesRoot = getYarnWorkspaceRoot(cwd);
15
34
  return (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRoot)(yarnWorkspacesRoot);
16
35
  }
17
36
  exports.getYarnWorkspaces = getYarnWorkspaces;
18
- async function getYarnWorkspacesAsync(cwd) {
37
+ exports.getWorkspaces = getYarnWorkspaces;
38
+ /**
39
+ * Get an array with names, paths, and package.json contents for each package in a yarn workspace.
40
+ * (See `../getWorkspaces` for why it's named this way.)
41
+ */
42
+ function getYarnWorkspacesAsync(cwd) {
19
43
  const yarnWorkspacesRoot = getYarnWorkspaceRoot(cwd);
20
- return await (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRootAsync)(yarnWorkspacesRoot);
44
+ return (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRootAsync)(yarnWorkspacesRoot);
21
45
  }
22
46
  exports.getYarnWorkspacesAsync = getYarnWorkspacesAsync;
47
+ exports.getWorkspacesAsync = getYarnWorkspacesAsync;
23
48
  //# sourceMappingURL=yarn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"yarn.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/yarn.ts"],"names":[],"mappings":";;;AACA,mEAIiC;AAEjC,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,MAAM,kBAAkB,GAAG,IAAA,mDAA2B,EAAC,GAAG,CAAC,CAAC;IAE5D,IAAI,CAAC,kBAAkB,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AARD,oDAQC;AAED,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;IACrD,OAAO,IAAA,yDAAiC,EAAC,kBAAkB,CAAC,CAAC;AAC/D,CAAC;AAHD,8CAGC;AAEM,KAAK,UAAU,sBAAsB,CAAC,GAAW;IACtD,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;IACrD,OAAO,MAAM,IAAA,8DAAsC,EAAC,kBAAkB,CAAC,CAAC;AAC1E,CAAC;AAHD,wDAGC"}
1
+ {"version":3,"file":"yarn.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/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  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAllPackageJsonFilesAsync = exports._resetCache = exports.getAllPackageJsonFiles = void 0;
4
- const getWorkspaces_1 = require("./getWorkspaces");
5
- const cache = new Map();
6
- /**
7
- * Get paths to every package.json in the workspace, given a cwd
8
- * @param cwd
9
- */
10
- function getAllPackageJsonFiles(cwd) {
11
- if (cache.has(cwd)) {
12
- return cache.get(cwd);
13
- }
14
- const workspaces = (0, getWorkspaces_1.getWorkspaces)(cwd);
15
- const packageJsonFiles = workspaces.map((workspace) => workspace.packageJson.packageJsonPath);
16
- cache.set(cwd, packageJsonFiles);
17
- return packageJsonFiles;
18
- }
19
- exports.getAllPackageJsonFiles = getAllPackageJsonFiles;
20
- function _resetCache() {
21
- cache.clear();
22
- }
23
- exports._resetCache = _resetCache;
24
- async function getAllPackageJsonFilesAsync(cwd) {
25
- if (cache.has(cwd)) {
26
- return cache.get(cwd);
27
- }
28
- const workspaces = await (0, getWorkspaces_1.getWorkspacesAsync)(cwd);
29
- const packageJsonFiles = workspaces.map((workspace) => workspace.packageJson.packageJsonPath);
30
- cache.set(cwd, packageJsonFiles);
31
- return packageJsonFiles;
32
- }
33
- exports.getAllPackageJsonFilesAsync = getAllPackageJsonFilesAsync;
34
- //# sourceMappingURL=workspaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/workspaces/workspaces.ts"],"names":[],"mappings":";;;AAAA,mDAAoE;AAEpE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;AAE1C;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,GAAW;IAChD,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;KACxB;IAED,MAAM,UAAU,GAAG,IAAA,6BAAa,EAAC,GAAG,CAAC,CAAC;IACtC,MAAM,gBAAgB,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAE9F,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAEjC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAXD,wDAWC;AAED,SAAgB,WAAW;IACzB,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC;AAFD,kCAEC;AAEM,KAAK,UAAU,2BAA2B,CAAC,GAAW;IAC3D,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;KACxB;IAED,MAAM,UAAU,GAAG,MAAM,IAAA,kCAAkB,EAAC,GAAG,CAAC,CAAC;IACjD,MAAM,gBAAgB,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAE9F,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAEjC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAXD,kEAWC"}