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
@@ -1,3 +1,23 @@
1
1
  import { WorkspaceInfo } from "../types/WorkspaceInfo";
2
- export declare function getWorkspacePackageInfo(workspacePaths: string[]): WorkspaceInfo;
3
- export declare function getWorkspacePackageInfoAsync(workspacePaths: string[]): Promise<WorkspaceInfo>;
2
+ /**
3
+ * Get an array with names, paths, and package.json contents for each of the given package paths
4
+ * within a workspace.
5
+ *
6
+ * This is an internal helper used by `getWorkspaces` implementations for different managers.
7
+ * (See `../getWorkspaces` for why it's named this way.)
8
+ * @param packagePaths Paths to packages within a workspace
9
+ * @returns Array of workspace package infos
10
+ * @internal
11
+ */
12
+ export declare function getWorkspacePackageInfo(packagePaths: string[]): WorkspaceInfo;
13
+ /**
14
+ * Get an array with names, paths, and package.json contents for each of the given package paths
15
+ * within a workspace.
16
+ *
17
+ * This is an internal helper used by `getWorkspaces` implementations for different managers.
18
+ * (See `../getWorkspaces` for why it's named this way.)
19
+ * @param packagePaths Paths to packages within a workspace
20
+ * @returns Array of workspace package infos
21
+ * @internal
22
+ */
23
+ export declare function getWorkspacePackageInfoAsync(packagePaths: string[]): Promise<WorkspaceInfo>;
@@ -6,56 +6,73 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getWorkspacePackageInfoAsync = exports.getWorkspacePackageInfo = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
- function getWorkspacePackageInfo(workspacePaths) {
10
- if (!workspacePaths) {
9
+ const promises_1 = __importDefault(require("fs/promises"));
10
+ const logging_1 = require("../logging");
11
+ const infoFromPackageJson_1 = require("../infoFromPackageJson");
12
+ /**
13
+ * Get an array with names, paths, and package.json contents for each of the given package paths
14
+ * within a workspace.
15
+ *
16
+ * This is an internal helper used by `getWorkspaces` implementations for different managers.
17
+ * (See `../getWorkspaces` for why it's named this way.)
18
+ * @param packagePaths Paths to packages within a workspace
19
+ * @returns Array of workspace package infos
20
+ * @internal
21
+ */
22
+ function getWorkspacePackageInfo(packagePaths) {
23
+ if (!packagePaths) {
11
24
  return [];
12
25
  }
13
- return workspacePaths.reduce((returnValue, workspacePath) => {
26
+ return packagePaths
27
+ .map((workspacePath) => {
14
28
  let packageJson;
15
29
  const packageJsonPath = path_1.default.join(workspacePath, "package.json");
16
30
  try {
17
31
  packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf-8"));
18
32
  }
19
- catch {
20
- return returnValue;
33
+ catch (err) {
34
+ (0, logging_1.logVerboseWarning)(`Error reading or parsing ${packageJsonPath} while getting workspace package info`, err);
35
+ return null;
21
36
  }
22
- return [
23
- ...returnValue,
24
- {
25
- name: packageJson.name,
26
- path: workspacePath,
27
- packageJson: {
28
- ...packageJson,
29
- packageJsonPath,
30
- },
31
- },
32
- ];
33
- }, []);
37
+ return {
38
+ name: packageJson.name,
39
+ path: workspacePath,
40
+ packageJson: (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath),
41
+ };
42
+ })
43
+ .filter(Boolean);
34
44
  }
35
45
  exports.getWorkspacePackageInfo = getWorkspacePackageInfo;
36
- async function getWorkspacePackageInfoAsync(workspacePaths) {
37
- if (!workspacePaths) {
46
+ /**
47
+ * Get an array with names, paths, and package.json contents for each of the given package paths
48
+ * within a workspace.
49
+ *
50
+ * This is an internal helper used by `getWorkspaces` implementations for different managers.
51
+ * (See `../getWorkspaces` for why it's named this way.)
52
+ * @param packagePaths Paths to packages within a workspace
53
+ * @returns Array of workspace package infos
54
+ * @internal
55
+ */
56
+ async function getWorkspacePackageInfoAsync(packagePaths) {
57
+ if (!packagePaths) {
38
58
  return [];
39
59
  }
40
- const packageInfoPromises = workspacePaths.map(async (workspacePath) => {
41
- let packageJson;
60
+ const workspacePkgPromises = packagePaths.map(async (workspacePath) => {
42
61
  const packageJsonPath = path_1.default.join(workspacePath, "package.json");
43
62
  try {
44
- packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf-8"));
63
+ const packageJson = JSON.parse(await promises_1.default.readFile(packageJsonPath, "utf-8"));
45
64
  return {
46
65
  name: packageJson.name,
47
66
  path: workspacePath,
48
- packageJson: {
49
- ...packageJson,
50
- packageJsonPath,
51
- },
67
+ packageJson: (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath),
52
68
  };
53
69
  }
54
- catch {
70
+ catch (err) {
71
+ (0, logging_1.logVerboseWarning)(`Error reading or parsing ${packageJsonPath} while getting workspace package info`, err);
55
72
  return null;
56
73
  }
57
74
  });
58
- return (await Promise.all(packageInfoPromises)).flat().filter(Boolean);
75
+ return (await Promise.all(workspacePkgPromises)).filter(Boolean);
59
76
  }
60
77
  exports.getWorkspacePackageInfoAsync = getWorkspacePackageInfoAsync;
61
78
  //# sourceMappingURL=getWorkspacePackageInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getWorkspacePackageInfo.js","sourceRoot":"","sources":["../../src/workspaces/getWorkspacePackageInfo.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAIpB,SAAgB,uBAAuB,CAAC,cAAwB;IAC9D,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,EAAE,CAAC;KACX;IAED,OAAO,cAAc,CAAC,MAAM,CAAgB,CAAC,WAAW,EAAE,aAAa,EAAE,EAAE;QACzE,IAAI,WAAwB,CAAC;QAC7B,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QAEjE,IAAI;YACF,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAgB,CAAC;SACpF;QAAC,MAAM;YACN,OAAO,WAAW,CAAC;SACpB;QAED,OAAO;YACL,GAAG,WAAW;YACd;gBACE,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE;oBACX,GAAG,WAAW;oBACd,eAAe;iBAChB;aACF;SACF,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AA3BD,0DA2BC;AAEM,KAAK,UAAU,4BAA4B,CAAC,cAAwB;IACzE,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,mBAAmB,GACvB,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;QACzC,IAAI,WAAwB,CAAC;QAC7B,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QAEjE,IAAI;YACF,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAgB,CAAC;YACnF,OAAO;gBACL,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE;oBACX,GAAG,WAAW;oBACd,eAAe;iBAChB;aACF,CAAC;SACH;QAAC,MAAM;YACN,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAkB,CAAC;AAC1F,CAAC;AA1BD,oEA0BC"}
1
+ {"version":3,"file":"getWorkspacePackageInfo.js","sourceRoot":"","sources":["../../src/workspaces/getWorkspacePackageInfo.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,2DAAqC;AAGrC,wCAA+C;AAC/C,gEAA6D;AAE7D;;;;;;;;;GASG;AACH,SAAgB,uBAAuB,CAAC,YAAsB;IAC5D,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,EAAE,CAAC;KACX;IAED,OAAO,YAAY;SAChB,GAAG,CAA+B,CAAC,aAAa,EAAE,EAAE;QACnD,IAAI,WAAwB,CAAC;QAC7B,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QAEjE,IAAI;YACF,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAgB,CAAC;SACpF;QAAC,OAAO,GAAG,EAAE;YACZ,IAAA,2BAAiB,EAAC,4BAA4B,eAAe,uCAAuC,EAAE,GAAG,CAAC,CAAC;YAC3G,OAAO,IAAI,CAAC;SACb;QAED,OAAO;YACL,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,IAAA,yCAAmB,EAAC,WAAW,EAAE,eAAe,CAAC;SAC/D,CAAC;IACJ,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAkB,CAAC;AACtC,CAAC;AAxBD,0DAwBC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,4BAA4B,CAAC,YAAsB;IACvE,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,oBAAoB,GAAG,YAAY,CAAC,GAAG,CAAwC,KAAK,EAAE,aAAa,EAAE,EAAE;QAC3G,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QAEjE,IAAI;YACF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,kBAAU,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAgB,CAAC;YACnG,OAAO;gBACL,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,IAAA,yCAAmB,EAAC,WAAW,EAAE,eAAe,CAAC;aAC/D,CAAC;SACH;QAAC,OAAO,GAAG,EAAE;YACZ,IAAA,2BAAiB,EAAC,4BAA4B,eAAe,uCAAuC,EAAE,GAAG,CAAC,CAAC;YAC3G,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAkB,CAAC;AACpF,CAAC;AAtBD,oEAsBC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Get a list of package folder paths in the workspace. The list of included packages is based on
3
+ * the manager's config file and matching package folders (which must contain package.json) on disk.
4
+ */
5
+ export declare function getWorkspacePackagePaths(cwd: string): string[];
6
+ /**
7
+ * Get a list of package folder paths in the workspace. The list of included packages is based on
8
+ * the manager's config file and matching package folders (which must contain package.json) on disk.
9
+ */
10
+ export declare function getWorkspacePackagePathsAsync(cwd: string): Promise<string[]>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWorkspacePackagePathsAsync = exports.getWorkspacePackagePaths = void 0;
4
+ const implementations_1 = require("./implementations");
5
+ /**
6
+ * Get a list of package folder paths in the workspace. The list of included packages is based on
7
+ * the manager's config file and matching package folders (which must contain package.json) on disk.
8
+ */
9
+ function getWorkspacePackagePaths(cwd) {
10
+ const utils = (0, implementations_1.getWorkspaceUtilities)(cwd);
11
+ return (utils === null || utils === void 0 ? void 0 : utils.getWorkspacePackagePaths(cwd)) || [];
12
+ }
13
+ exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
14
+ /**
15
+ * Get a list of package folder paths in the workspace. The list of included packages is based on
16
+ * the manager's config file and matching package folders (which must contain package.json) on disk.
17
+ */
18
+ async function getWorkspacePackagePathsAsync(cwd) {
19
+ var _a;
20
+ const utils = (0, implementations_1.getWorkspaceUtilities)(cwd);
21
+ if (!utils) {
22
+ return [];
23
+ }
24
+ if (!utils.getWorkspacePackagePathsAsync) {
25
+ const managerName = (_a = (0, implementations_1.getWorkspaceManagerAndRoot)(cwd)) === null || _a === void 0 ? void 0 : _a.manager;
26
+ throw new Error(`${cwd} is using ${managerName} which has not been converted to async yet`);
27
+ }
28
+ return utils.getWorkspacePackagePathsAsync(cwd);
29
+ }
30
+ exports.getWorkspacePackagePathsAsync = getWorkspacePackagePathsAsync;
31
+ //# sourceMappingURL=getWorkspacePackagePaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWorkspacePackagePaths.js","sourceRoot":"","sources":["../../src/workspaces/getWorkspacePackagePaths.ts"],"names":[],"mappings":";;;AAAA,uDAAsF;AAEtF;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,GAAW;IAClD,MAAM,KAAK,GAAG,IAAA,uCAAqB,EAAC,GAAG,CAAC,CAAC;IACzC,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,wBAAwB,CAAC,GAAG,CAAC,KAAI,EAAE,CAAC;AACpD,CAAC;AAHD,4DAGC;AAED;;;GAGG;AACI,KAAK,UAAU,6BAA6B,CAAC,GAAW;;IAC7D,MAAM,KAAK,GAAG,IAAA,uCAAqB,EAAC,GAAG,CAAC,CAAC;IAEzC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAC;KACX;IAED,IAAI,CAAC,KAAK,CAAC,6BAA6B,EAAE;QACxC,MAAM,WAAW,GAAG,MAAA,IAAA,4CAA0B,EAAC,GAAG,CAAC,0CAAE,OAAO,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,aAAa,WAAW,4CAA4C,CAAC,CAAC;KAC7F;IAED,OAAO,KAAK,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC;AAClD,CAAC;AAbD,sEAaC"}
@@ -1 +1,8 @@
1
- export declare function getWorkspaceRoot(cwd: string): string | undefined;
1
+ import { WorkspaceManager } from "./WorkspaceManager";
2
+ /**
3
+ * Get the root directory of a workspace/monorepo, defined as the directory where the workspace
4
+ * manager config file is located.
5
+ * @param cwd Start searching from here
6
+ * @param preferredManager Search for only this manager's config file
7
+ */
8
+ export declare function getWorkspaceRoot(cwd: string, preferredManager?: WorkspaceManager): string | undefined;
@@ -2,24 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWorkspaceRoot = void 0;
4
4
  const implementations_1 = require("./implementations");
5
- const preferred = process.env.PREFERRED_WORKSPACE_MANAGER;
6
- function getWorkspaceRoot(cwd) {
7
- const workspaceImplementation = preferred || (0, implementations_1.getWorkspaceImplementation)(cwd);
8
- if (!workspaceImplementation) {
9
- return;
10
- }
11
- switch (workspaceImplementation) {
12
- case "yarn":
13
- return require(`./implementations/yarn`).getYarnWorkspaceRoot(cwd);
14
- case "pnpm":
15
- return require(`./implementations/pnpm`).getPnpmWorkspaceRoot(cwd);
16
- case "rush":
17
- return require(`./implementations/rush`).getRushWorkspaceRoot(cwd);
18
- case "npm":
19
- return require(`./implementations/npm`).getNpmWorkspaceRoot(cwd);
20
- case "lerna":
21
- return require(`./implementations/lerna`).getLernaWorkspaceRoot(cwd);
22
- }
5
+ /**
6
+ * Get the root directory of a workspace/monorepo, defined as the directory where the workspace
7
+ * manager config file is located.
8
+ * @param cwd Start searching from here
9
+ * @param preferredManager Search for only this manager's config file
10
+ */
11
+ function getWorkspaceRoot(cwd, preferredManager) {
12
+ var _a;
13
+ return (_a = (0, implementations_1.getWorkspaceManagerAndRoot)(cwd, undefined, preferredManager)) === null || _a === void 0 ? void 0 : _a.root;
23
14
  }
24
15
  exports.getWorkspaceRoot = getWorkspaceRoot;
25
16
  //# sourceMappingURL=getWorkspaceRoot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getWorkspaceRoot.js","sourceRoot":"","sources":["../../src/workspaces/getWorkspaceRoot.ts"],"names":[],"mappings":";;;AAAA,uDAA+D;AAI/D,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,2BAAsD,CAAC;AAErF,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,MAAM,uBAAuB,GAAG,SAAS,IAAI,IAAA,4CAA0B,EAAC,GAAG,CAAC,CAAC;IAE7E,IAAI,CAAC,uBAAuB,EAAE;QAC5B,OAAO;KACR;IAED,QAAQ,uBAAuB,EAAE;QAC/B,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,wBAAwB,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAErE,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,wBAAwB,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAErE,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,wBAAwB,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAErE,KAAK,KAAK;YACR,OAAO,OAAO,CAAC,uBAAuB,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;QAEnE,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,yBAAyB,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;KACxE;AACH,CAAC;AAvBD,4CAuBC"}
1
+ {"version":3,"file":"getWorkspaceRoot.js","sourceRoot":"","sources":["../../src/workspaces/getWorkspaceRoot.ts"],"names":[],"mappings":";;;AACA,uDAA+D;AAE/D;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,GAAW,EAAE,gBAAmC;;IAC/E,OAAO,MAAA,IAAA,4CAA0B,EAAC,GAAG,EAAE,SAAS,EAAE,gBAAgB,CAAC,0CAAE,IAAI,CAAC;AAC5E,CAAC;AAFD,4CAEC"}
@@ -1,3 +1,19 @@
1
1
  import { WorkspaceInfo } from "../types/WorkspaceInfo";
2
+ /**
3
+ * Get an array with names, paths, and package.json contents for each package in a workspace.
4
+ * The list of included packages is based on the workspace manager's config file.
5
+ *
6
+ * The method name is somewhat misleading due to the double meaning of "workspace", but it's retained
7
+ * for compatibility. "Workspace" here refers to an individual package, in the sense of the `workspaces`
8
+ * package.json config used by npm/yarn (instead of referring to the entire monorepo).
9
+ */
2
10
  export declare function getWorkspaces(cwd: string): WorkspaceInfo;
11
+ /**
12
+ * Get an array with names, paths, and package.json contents for each package in a workspace.
13
+ * The list of included packages is based on the workspace manager's config file.
14
+ *
15
+ * The method name is somewhat misleading due to the double meaning of "workspace", but it's retained
16
+ * for compatibility. "Workspace" here refers to an individual package, in the sense of the `workspaces`
17
+ * package.json config used by npm/yarn (instead of referring to the entire monorepo).
18
+ */
3
19
  export declare function getWorkspacesAsync(cwd: string): Promise<WorkspaceInfo>;
@@ -2,41 +2,38 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWorkspacesAsync = exports.getWorkspaces = void 0;
4
4
  const implementations_1 = require("./implementations");
5
- const preferred = process.env.PREFERRED_WORKSPACE_MANAGER;
5
+ /**
6
+ * Get an array with names, paths, and package.json contents for each package in a workspace.
7
+ * The list of included packages is based on the workspace manager's config file.
8
+ *
9
+ * The method name is somewhat misleading due to the double meaning of "workspace", but it's retained
10
+ * for compatibility. "Workspace" here refers to an individual package, in the sense of the `workspaces`
11
+ * package.json config used by npm/yarn (instead of referring to the entire monorepo).
12
+ */
6
13
  function getWorkspaces(cwd) {
7
- const workspaceImplementation = preferred || (0, implementations_1.getWorkspaceImplementation)(cwd);
8
- if (!workspaceImplementation) {
9
- return [];
10
- }
11
- switch (workspaceImplementation) {
12
- case "yarn":
13
- return require(`./implementations/yarn`).getYarnWorkspaces(cwd);
14
- case "pnpm":
15
- return require(`./implementations/pnpm`).getPnpmWorkspaces(cwd);
16
- case "rush":
17
- return require(`./implementations/rush`).getRushWorkspaces(cwd);
18
- case "npm":
19
- return require(`./implementations/npm`).getNpmWorkspaces(cwd);
20
- case "lerna":
21
- return require(`./implementations/lerna`).getLernaWorkspaces(cwd);
22
- }
14
+ const utils = (0, implementations_1.getWorkspaceUtilities)(cwd);
15
+ return (utils === null || utils === void 0 ? void 0 : utils.getWorkspaces(cwd)) || [];
23
16
  }
24
17
  exports.getWorkspaces = getWorkspaces;
18
+ /**
19
+ * Get an array with names, paths, and package.json contents for each package in a workspace.
20
+ * The list of included packages is based on the workspace manager's config file.
21
+ *
22
+ * The method name is somewhat misleading due to the double meaning of "workspace", but it's retained
23
+ * for compatibility. "Workspace" here refers to an individual package, in the sense of the `workspaces`
24
+ * package.json config used by npm/yarn (instead of referring to the entire monorepo).
25
+ */
25
26
  async function getWorkspacesAsync(cwd) {
26
- const workspaceImplementation = preferred || (0, implementations_1.getWorkspaceImplementation)(cwd);
27
- if (!workspaceImplementation) {
27
+ var _a;
28
+ const utils = (0, implementations_1.getWorkspaceUtilities)(cwd);
29
+ if (!utils) {
28
30
  return [];
29
31
  }
30
- switch (workspaceImplementation) {
31
- case "yarn":
32
- return await require(`./implementations/yarn`).getYarnWorkspacesAsync(cwd);
33
- case "npm":
34
- return require(`./implementations/npm`).getNpmWorkspacesAsync(cwd);
35
- case "pnpm":
36
- case "rush":
37
- case "lerna":
38
- throw new Error(`${cwd} is using ${workspaceImplementation} which has not been converted to async yet`);
32
+ if (!utils.getWorkspacesAsync) {
33
+ const managerName = (_a = (0, implementations_1.getWorkspaceManagerAndRoot)(cwd)) === null || _a === void 0 ? void 0 : _a.manager;
34
+ throw new Error(`${cwd} is using ${managerName} which has not been converted to async yet`);
39
35
  }
36
+ return utils.getWorkspacesAsync(cwd);
40
37
  }
41
38
  exports.getWorkspacesAsync = getWorkspacesAsync;
42
39
  //# sourceMappingURL=getWorkspaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getWorkspaces.js","sourceRoot":"","sources":["../../src/workspaces/getWorkspaces.ts"],"names":[],"mappings":";;;AAAA,uDAA+D;AAK/D,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,2BAAsD,CAAC;AAErF,SAAgB,aAAa,CAAC,GAAW;IACvC,MAAM,uBAAuB,GAAG,SAAS,IAAI,IAAA,4CAA0B,EAAC,GAAG,CAAC,CAAC;IAE7E,IAAI,CAAC,uBAAuB,EAAE;QAC5B,OAAO,EAAE,CAAC;KACX;IAED,QAAQ,uBAAuB,EAAE;QAC/B,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,wBAAwB,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAElE,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,wBAAwB,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAElE,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,wBAAwB,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAElE,KAAK,KAAK;YACR,OAAO,OAAO,CAAC,uBAAuB,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAEhE,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,yBAAyB,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;KACrE;AACH,CAAC;AAvBD,sCAuBC;AAEM,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAClD,MAAM,uBAAuB,GAAG,SAAS,IAAI,IAAA,4CAA0B,EAAC,GAAG,CAAC,CAAC;IAE7E,IAAI,CAAC,uBAAuB,EAAE;QAC5B,OAAO,EAAE,CAAC;KACX;IAED,QAAQ,uBAAuB,EAAE;QAC/B,KAAK,MAAM;YACT,OAAO,MAAM,OAAO,CAAC,wBAAwB,CAAC,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;QAE7E,KAAK,KAAK;YACR,OAAO,OAAO,CAAC,uBAAuB,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAErE,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO;YACV,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,aAAa,uBAAuB,4CAA4C,CAAC,CAAC;KAC3G;AACH,CAAC;AAnBD,gDAmBC"}
1
+ {"version":3,"file":"getWorkspaces.js","sourceRoot":"","sources":["../../src/workspaces/getWorkspaces.ts"],"names":[],"mappings":";;;AAAA,uDAAsF;AAGtF;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAC,GAAW;IACvC,MAAM,KAAK,GAAG,IAAA,uCAAqB,EAAC,GAAG,CAAC,CAAC;IACzC,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,aAAa,CAAC,GAAG,CAAC,KAAI,EAAE,CAAC;AACzC,CAAC;AAHD,sCAGC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,kBAAkB,CAAC,GAAW;;IAClD,MAAM,KAAK,GAAG,IAAA,uCAAqB,EAAC,GAAG,CAAC,CAAC;IAEzC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAC;KACX;IAED,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE;QAC7B,MAAM,WAAW,GAAG,MAAA,IAAA,4CAA0B,EAAC,GAAG,CAAC,0CAAE,OAAO,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,aAAa,WAAW,4CAA4C,CAAC,CAAC;KAC7F;IAED,OAAO,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC;AAbD,gDAaC"}
@@ -0,0 +1,22 @@
1
+ import { WorkspaceManager } from "../WorkspaceManager";
2
+ export interface WorkspaceManagerAndRoot {
3
+ /** Workspace manager name */
4
+ manager: WorkspaceManager;
5
+ /** Workspace root, where the manager configuration file is located */
6
+ root: string;
7
+ }
8
+ /**
9
+ * Get the preferred workspace manager based on `process.env.PREFERRED_WORKSPACE_MANAGER`
10
+ * (if valid).
11
+ */
12
+ export declare function getPreferredWorkspaceManager(): WorkspaceManager | undefined;
13
+ /**
14
+ * Get the workspace manager name and workspace root directory for `cwd`, with caching.
15
+ * Also respects the `process.env.PREFERRED_WORKSPACE_MANAGER` override, provided the relevant
16
+ * manager file exists.
17
+ * @param cwd Directory to search up from
18
+ * @param cache Optional override cache for testing
19
+ * @param preferredManager Optional override manager (if provided, only searches for this manager's file)
20
+ * @returns Workspace manager and root, or undefined if it can't be determined
21
+ */
22
+ export declare function getWorkspaceManagerAndRoot(cwd: string, cache?: Map<string, WorkspaceManagerAndRoot | undefined>, preferredManager?: WorkspaceManager): WorkspaceManagerAndRoot | undefined;
@@ -0,0 +1,63 @@
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.getWorkspaceManagerAndRoot = exports.getPreferredWorkspaceManager = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const paths_1 = require("../../paths");
9
+ const workspaceCache = new Map();
10
+ /**
11
+ * Files indicating the workspace root for each manager.
12
+ *
13
+ * DO NOT REORDER! The order of keys determines the precedence of the files, which is
14
+ * important for cases like lerna where lerna.json and e.g. yarn.lock may both exist.
15
+ */
16
+ const managerFiles = {
17
+ // DO NOT REORDER! (see above)
18
+ lerna: "lerna.json",
19
+ rush: "rush.json",
20
+ yarn: "yarn.lock",
21
+ pnpm: "pnpm-workspace.yaml",
22
+ npm: "package-lock.json",
23
+ };
24
+ /**
25
+ * Get the preferred workspace manager based on `process.env.PREFERRED_WORKSPACE_MANAGER`
26
+ * (if valid).
27
+ */
28
+ function getPreferredWorkspaceManager() {
29
+ const preferred = process.env.PREFERRED_WORKSPACE_MANAGER;
30
+ return preferred && managerFiles[preferred] ? preferred : undefined;
31
+ }
32
+ exports.getPreferredWorkspaceManager = getPreferredWorkspaceManager;
33
+ /**
34
+ * Get the workspace manager name and workspace root directory for `cwd`, with caching.
35
+ * Also respects the `process.env.PREFERRED_WORKSPACE_MANAGER` override, provided the relevant
36
+ * manager file exists.
37
+ * @param cwd Directory to search up from
38
+ * @param cache Optional override cache for testing
39
+ * @param preferredManager Optional override manager (if provided, only searches for this manager's file)
40
+ * @returns Workspace manager and root, or undefined if it can't be determined
41
+ */
42
+ function getWorkspaceManagerAndRoot(cwd, cache, preferredManager) {
43
+ cache = cache || workspaceCache;
44
+ if (cache.has(cwd)) {
45
+ return cache.get(cwd);
46
+ }
47
+ preferredManager = preferredManager || getPreferredWorkspaceManager();
48
+ const managerFile = (0, paths_1.searchUp)((preferredManager && managerFiles[preferredManager]) || Object.values(managerFiles), cwd);
49
+ if (managerFile) {
50
+ const managerFileName = path_1.default.basename(managerFile);
51
+ cache.set(cwd, {
52
+ manager: Object.keys(managerFiles).find((name) => managerFiles[name] === managerFileName),
53
+ root: path_1.default.dirname(managerFile),
54
+ });
55
+ }
56
+ else {
57
+ // Avoid searching again if no file was found
58
+ cache.set(cwd, undefined);
59
+ }
60
+ return cache.get(cwd);
61
+ }
62
+ exports.getWorkspaceManagerAndRoot = getWorkspaceManagerAndRoot;
63
+ //# sourceMappingURL=getWorkspaceManagerAndRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWorkspaceManagerAndRoot.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/getWorkspaceManagerAndRoot.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,uCAAuC;AASvC,MAAM,cAAc,GAAG,IAAI,GAAG,EAA+C,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,YAAY,GAAG;IACnB,8BAA8B;IAC9B,KAAK,EAAE,YAAY;IACnB,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,qBAAqB;IAC3B,GAAG,EAAE,mBAAmB;CACzB,CAAC;AAEF;;;GAGG;AACH,SAAgB,4BAA4B;IAC1C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,2BAA2D,CAAC;IAC1F,OAAO,SAAS,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AACtE,CAAC;AAHD,oEAGC;AAED;;;;;;;;GAQG;AACH,SAAgB,0BAA0B,CACxC,GAAW,EACX,KAAwD,EACxD,gBAAmC;IAEnC,KAAK,GAAG,KAAK,IAAI,cAAc,CAAC;IAChC,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACvB;IAED,gBAAgB,GAAG,gBAAgB,IAAI,4BAA4B,EAAE,CAAC;IACtE,MAAM,WAAW,GAAG,IAAA,gBAAQ,EAC1B,CAAC,gBAAgB,IAAI,YAAY,CAAC,gBAAgB,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EACnF,GAAG,CACJ,CAAC;IAEF,IAAI,WAAW,EAAE;QACf,MAAM,eAAe,GAAG,cAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACnD,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YACb,OAAO,EAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAwB,CAAC,IAAI,CAC7D,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,eAAe,CAChD;YACF,IAAI,EAAE,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC;SAChC,CAAC,CAAC;KACJ;SAAM;QACL,6CAA6C;QAC7C,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;KAC3B;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AA9BD,gEA8BC"}
@@ -0,0 +1,26 @@
1
+ import { WorkspaceInfo } from "../../types/WorkspaceInfo";
2
+ export interface WorkspaceUtilities {
3
+ /**
4
+ * Get an array of paths to packages in the workspace, based on the manager's config file.
5
+ */
6
+ getWorkspacePackagePaths: (cwd: string) => string[];
7
+ /**
8
+ * Get an array of paths to packages in the workspace, based on the manager's config file.
9
+ */
10
+ getWorkspacePackagePathsAsync?: (cwd: string) => Promise<string[]>;
11
+ /**
12
+ * Get an array with names, paths, and package.json contents for each package in a workspace.
13
+ * (See `../getWorkspaces` for why it's named this way.)
14
+ */
15
+ getWorkspaces: (cwd: string) => WorkspaceInfo;
16
+ /**
17
+ * Get an array with names, paths, and package.json contents for each package in a workspace.
18
+ * (See `../getWorkspaces` for why it's named this way.)
19
+ */
20
+ getWorkspacesAsync?: (cwd: string) => Promise<WorkspaceInfo>;
21
+ }
22
+ /**
23
+ * Get utility implementations for the workspace manager of `cwd`.
24
+ * Returns undefined if the manager can't be determined.
25
+ */
26
+ export declare function getWorkspaceUtilities(cwd: string): WorkspaceUtilities | undefined;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWorkspaceUtilities = void 0;
4
+ const getWorkspaceManagerAndRoot_1 = require("./getWorkspaceManagerAndRoot");
5
+ /**
6
+ * Get utility implementations for the workspace manager of `cwd`.
7
+ * Returns undefined if the manager can't be determined.
8
+ */
9
+ function getWorkspaceUtilities(cwd) {
10
+ var _a;
11
+ const manager = (_a = (0, getWorkspaceManagerAndRoot_1.getWorkspaceManagerAndRoot)(cwd)) === null || _a === void 0 ? void 0 : _a.manager;
12
+ switch (manager) {
13
+ case "yarn":
14
+ return require("./yarn");
15
+ case "pnpm":
16
+ return require("./pnpm");
17
+ case "rush":
18
+ return require("./rush");
19
+ case "npm":
20
+ return require("./npm");
21
+ case "lerna":
22
+ return require("./lerna");
23
+ }
24
+ }
25
+ exports.getWorkspaceUtilities = getWorkspaceUtilities;
26
+ //# sourceMappingURL=getWorkspaceUtilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWorkspaceUtilities.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/getWorkspaceUtilities.ts"],"names":[],"mappings":";;;AACA,6EAA0E;AA6B1E;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,GAAW;;IAC/C,MAAM,OAAO,GAAG,MAAA,IAAA,uDAA0B,EAAC,GAAG,CAAC,0CAAE,OAAO,CAAC;IAEzD,QAAQ,OAAO,EAAE;QACf,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,QAAQ,CAAyB,CAAC;QAEnD,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,QAAQ,CAAyB,CAAC;QAEnD,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,QAAQ,CAAyB,CAAC;QAEnD,KAAK,KAAK;YACR,OAAO,OAAO,CAAC,OAAO,CAAwB,CAAC;QAEjD,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,SAAS,CAA0B,CAAC;KACtD;AACH,CAAC;AAnBD,sDAmBC"}
@@ -1,14 +1,2 @@
1
- export declare type WorkspaceImplementations = "yarn" | "pnpm" | "rush" | "npm" | "lerna";
2
- export interface ImplementationAndLockFile {
3
- implementation: WorkspaceImplementations | undefined;
4
- lockFile: string;
5
- }
6
- export declare function getWorkspaceImplementationAndLockFile(cwd: string, cache?: {
7
- [cwd: string]: ImplementationAndLockFile;
8
- }): {
9
- implementation: WorkspaceImplementations | undefined;
10
- lockFile: string;
11
- } | undefined;
12
- export declare function getWorkspaceImplementation(cwd: string, cache?: {
13
- [cwd: string]: ImplementationAndLockFile;
14
- }): WorkspaceImplementations | undefined;
1
+ export { getWorkspaceManagerAndRoot, WorkspaceManagerAndRoot } from "./getWorkspaceManagerAndRoot";
2
+ export { getWorkspaceUtilities, WorkspaceUtilities } from "./getWorkspaceUtilities";
@@ -1,58 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getWorkspaceImplementation = exports.getWorkspaceImplementationAndLockFile = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const paths_1 = require("../../paths");
9
- const workspaceCache = {};
10
- function getWorkspaceImplementationAndLockFile(cwd, cache = workspaceCache) {
11
- if (cache[cwd]) {
12
- return cache[cwd];
13
- }
14
- const lockFile = (0, paths_1.searchUp)(["lerna.json", "rush.json", "yarn.lock", "pnpm-workspace.yaml", "package-lock.json"], cwd);
15
- if (!lockFile) {
16
- return;
17
- }
18
- switch (path_1.default.basename(lockFile)) {
19
- case "lerna.json":
20
- cache[cwd] = {
21
- implementation: "lerna",
22
- lockFile,
23
- };
24
- break;
25
- case "yarn.lock":
26
- cache[cwd] = {
27
- implementation: "yarn",
28
- lockFile,
29
- };
30
- break;
31
- case "pnpm-workspace.yaml":
32
- cache[cwd] = {
33
- implementation: "pnpm",
34
- lockFile,
35
- };
36
- break;
37
- case "rush.json":
38
- cache[cwd] = {
39
- implementation: "rush",
40
- lockFile,
41
- };
42
- break;
43
- case "package-lock.json":
44
- cache[cwd] = {
45
- implementation: "npm",
46
- lockFile,
47
- };
48
- break;
49
- }
50
- return cache[cwd];
51
- }
52
- exports.getWorkspaceImplementationAndLockFile = getWorkspaceImplementationAndLockFile;
53
- function getWorkspaceImplementation(cwd, cache = workspaceCache) {
54
- var _a;
55
- return (_a = getWorkspaceImplementationAndLockFile(cwd, cache)) === null || _a === void 0 ? void 0 : _a.implementation;
56
- }
57
- exports.getWorkspaceImplementation = getWorkspaceImplementation;
3
+ exports.getWorkspaceUtilities = exports.getWorkspaceManagerAndRoot = void 0;
4
+ var getWorkspaceManagerAndRoot_1 = require("./getWorkspaceManagerAndRoot");
5
+ Object.defineProperty(exports, "getWorkspaceManagerAndRoot", { enumerable: true, get: function () { return getWorkspaceManagerAndRoot_1.getWorkspaceManagerAndRoot; } });
6
+ var getWorkspaceUtilities_1 = require("./getWorkspaceUtilities");
7
+ Object.defineProperty(exports, "getWorkspaceUtilities", { enumerable: true, get: function () { return getWorkspaceUtilities_1.getWorkspaceUtilities; } });
58
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,uCAAuC;AAOvC,MAAM,cAAc,GAAiD,EAAE,CAAC;AAExE,SAAgB,qCAAqC,CACnD,GAAW,EACX,KAAK,GAAG,cAAc;IAEtB,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE;QACd,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;IAED,MAAM,QAAQ,GAAG,IAAA,gBAAQ,EAAC,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,qBAAqB,EAAE,mBAAmB,CAAC,EAAE,GAAG,CAAC,CAAC;IAErH,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO;KACR;IAED,QAAQ,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAC/B,KAAK,YAAY;YACf,KAAK,CAAC,GAAG,CAAC,GAAG;gBACX,cAAc,EAAE,OAAO;gBACvB,QAAQ;aACT,CAAC;YACF,MAAM;QAER,KAAK,WAAW;YACd,KAAK,CAAC,GAAG,CAAC,GAAG;gBACX,cAAc,EAAE,MAAM;gBACtB,QAAQ;aACT,CAAC;YACF,MAAM;QAER,KAAK,qBAAqB;YACxB,KAAK,CAAC,GAAG,CAAC,GAAG;gBACX,cAAc,EAAE,MAAM;gBACtB,QAAQ;aACT,CAAC;YACF,MAAM;QAER,KAAK,WAAW;YACd,KAAK,CAAC,GAAG,CAAC,GAAG;gBACX,cAAc,EAAE,MAAM;gBACtB,QAAQ;aACT,CAAC;YACF,MAAM;QAER,KAAK,mBAAmB;YACtB,KAAK,CAAC,GAAG,CAAC,GAAG;gBACX,cAAc,EAAE,KAAK;gBACrB,QAAQ;aACT,CAAC;YACF,MAAM;KACT;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC;AApDD,sFAoDC;AAED,SAAgB,0BAA0B,CAAC,GAAW,EAAE,KAAK,GAAG,cAAc;;IAC5E,OAAO,MAAA,qCAAqC,CAAC,GAAG,EAAE,KAAK,CAAC,0CAAE,cAAc,CAAC;AAC3E,CAAC;AAFD,gEAEC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/index.ts"],"names":[],"mappings":";;;AAAA,2EAAmG;AAA1F,wIAAA,0BAA0B,OAAA;AACnC,iEAAoF;AAA3E,8HAAA,qBAAqB,OAAA"}
@@ -1,3 +1,9 @@
1
1
  import { WorkspaceInfo } from "../../types/WorkspaceInfo";
2
- export declare function getLernaWorkspaceRoot(cwd: string): string;
3
- export declare function getLernaWorkspaces(cwd: string, ignorePatterns?: string[]): WorkspaceInfo;
2
+ /** Get package paths for a lerna workspace. */
3
+ export declare function getWorkspacePackagePaths(cwd: string): string[];
4
+ /**
5
+ * Get an array with names, paths, and package.json contents for each package in a lerna workspace.
6
+ * (See `../getWorkspaces` for why it's named this way.)
7
+ */
8
+ export declare function getLernaWorkspaces(cwd: string): WorkspaceInfo;
9
+ export { getLernaWorkspaces as getWorkspaces };