workspace-tools 0.40.4 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/README.md +39 -1
  2. package/lib/dependencies/index.d.ts +2 -2
  3. package/lib/dependencies/index.js +31 -12
  4. package/lib/dependencies/index.js.map +1 -1
  5. package/lib/dependencies/transitiveDeps.d.ts +1 -1
  6. package/lib/dependencies/transitiveDeps.js +59 -38
  7. package/lib/dependencies/transitiveDeps.js.map +1 -1
  8. package/lib/getPackageInfo.d.ts +7 -5
  9. package/lib/getPackageInfo.js +46 -39
  10. package/lib/getPackageInfo.js.map +1 -1
  11. package/lib/getPackageInfos.d.ts +31 -8
  12. package/lib/getPackageInfos.js +41 -41
  13. package/lib/getPackageInfos.js.map +1 -1
  14. package/lib/git/config.d.ts +1 -1
  15. package/lib/git/config.js +15 -12
  16. package/lib/git/config.js.map +1 -1
  17. package/lib/git/getDefaultRemote.js +45 -30
  18. package/lib/git/getDefaultRemote.js.map +1 -1
  19. package/lib/git/getDefaultRemoteBranch.d.ts +1 -1
  20. package/lib/git/getDefaultRemoteBranch.js +35 -24
  21. package/lib/git/getDefaultRemoteBranch.js.map +1 -1
  22. package/lib/git/getRepositoryName.d.ts +1 -1
  23. package/lib/git/getRepositoryName.js +17 -19
  24. package/lib/git/getRepositoryName.js.map +1 -1
  25. package/lib/git/git.d.ts +2 -5
  26. package/lib/git/git.js +62 -64
  27. package/lib/git/git.js.map +1 -1
  28. package/lib/git/gitUtilities.d.ts +3 -3
  29. package/lib/git/gitUtilities.js +377 -147
  30. package/lib/git/gitUtilities.js.map +1 -1
  31. package/lib/git/index.d.ts +5 -5
  32. package/lib/git/index.js +50 -28
  33. package/lib/git/index.js.map +1 -1
  34. package/lib/git/types.js +4 -3
  35. package/lib/git/types.js.map +1 -1
  36. package/lib/graph/createDependencyMap.d.ts +12 -2
  37. package/lib/graph/createDependencyMap.js +18 -10
  38. package/lib/graph/createDependencyMap.js.map +1 -1
  39. package/lib/graph/createPackageGraph.d.ts +10 -6
  40. package/lib/graph/createPackageGraph.js +58 -42
  41. package/lib/graph/createPackageGraph.js.map +1 -1
  42. package/lib/graph/getPackageDependencies.d.ts +2 -2
  43. package/lib/graph/getPackageDependencies.js +24 -53
  44. package/lib/graph/getPackageDependencies.js.map +1 -1
  45. package/lib/graph/index.d.ts +4 -4
  46. package/lib/graph/index.js +25 -27
  47. package/lib/graph/index.js.map +1 -1
  48. package/lib/index.d.ts +29 -27
  49. package/lib/index.js +154 -75
  50. package/lib/index.js.map +1 -1
  51. package/lib/isCachingEnabled.js +17 -6
  52. package/lib/isCachingEnabled.js.map +1 -1
  53. package/lib/lockfile/nameAtVersion.js +9 -4
  54. package/lib/lockfile/nameAtVersion.js.map +1 -1
  55. package/lib/lockfile/parseBerryLock.d.ts +1 -1
  56. package/lib/lockfile/parseBerryLock.js +13 -11
  57. package/lib/lockfile/parseBerryLock.js.map +1 -1
  58. package/lib/lockfile/parseLockFile.d.ts +2 -0
  59. package/lib/lockfile/parseLockFile.js +87 -0
  60. package/lib/lockfile/parseLockFile.js.map +1 -0
  61. package/lib/lockfile/parseNpmLock.d.ts +1 -1
  62. package/lib/lockfile/parseNpmLock.js +15 -7
  63. package/lib/lockfile/parseNpmLock.js.map +1 -1
  64. package/lib/lockfile/parsePnpmLock.d.ts +1 -1
  65. package/lib/lockfile/parsePnpmLock.js +14 -9
  66. package/lib/lockfile/parsePnpmLock.js.map +1 -1
  67. package/lib/lockfile/queryLockFile.d.ts +1 -1
  68. package/lib/lockfile/queryLockFile.js +11 -6
  69. package/lib/lockfile/queryLockFile.js.map +1 -1
  70. package/lib/lockfile/readYaml.js +17 -9
  71. package/lib/lockfile/readYaml.js.map +1 -1
  72. package/lib/lockfile/types.js +3 -2
  73. package/lib/lockfile/types.js.map +1 -1
  74. package/lib/logging.js +10 -6
  75. package/lib/logging.js.map +1 -1
  76. package/lib/paths.d.ts +4 -1
  77. package/lib/paths.js +60 -58
  78. package/lib/paths.js.map +1 -1
  79. package/lib/scope.js +30 -21
  80. package/lib/scope.js.map +1 -1
  81. package/lib/types/Catalogs.js +8 -3
  82. package/lib/types/Catalogs.js.map +1 -1
  83. package/lib/types/PackageGraph.d.ts +5 -1
  84. package/lib/types/PackageGraph.js +4 -3
  85. package/lib/types/PackageGraph.js.map +1 -1
  86. package/lib/types/PackageInfo.d.ts +1 -1
  87. package/lib/types/PackageInfo.js +3 -2
  88. package/lib/types/PackageInfo.js.map +1 -1
  89. package/lib/types/WorkspaceInfo.d.ts +3 -5
  90. package/lib/types/WorkspaceInfo.js +3 -2
  91. package/lib/types/WorkspaceInfo.js.map +1 -1
  92. package/lib/types/WorkspaceManager.js +4 -0
  93. package/lib/types/WorkspaceManager.js.map +1 -0
  94. package/lib/workspaces/catalogsToYaml.d.ts +1 -1
  95. package/lib/workspaces/catalogsToYaml.js +12 -10
  96. package/lib/workspaces/catalogsToYaml.js.map +1 -1
  97. package/lib/workspaces/findWorkspacePath.d.ts +2 -1
  98. package/lib/workspaces/findWorkspacePath.js +10 -12
  99. package/lib/workspaces/findWorkspacePath.js.map +1 -1
  100. package/lib/workspaces/getAllPackageJsonFiles.d.ts +10 -4
  101. package/lib/workspaces/getAllPackageJsonFiles.js +32 -22
  102. package/lib/workspaces/getAllPackageJsonFiles.js.map +1 -1
  103. package/lib/workspaces/getCatalogVersion.d.ts +1 -1
  104. package/lib/workspaces/getCatalogVersion.js +19 -32
  105. package/lib/workspaces/getCatalogVersion.js.map +1 -1
  106. package/lib/workspaces/getCatalogs.d.ts +8 -2
  107. package/lib/workspaces/getCatalogs.js +23 -15
  108. package/lib/workspaces/getCatalogs.js.map +1 -1
  109. package/lib/workspaces/getChangedPackages.d.ts +1 -1
  110. package/lib/workspaces/getChangedPackages.js +47 -30
  111. package/lib/workspaces/getChangedPackages.js.map +1 -1
  112. package/lib/workspaces/getPackagesByFiles.js +29 -24
  113. package/lib/workspaces/getPackagesByFiles.js.map +1 -1
  114. package/lib/workspaces/getWorkspaceInfos.d.ts +36 -0
  115. package/lib/workspaces/getWorkspaceInfos.js +60 -0
  116. package/lib/workspaces/getWorkspaceInfos.js.map +1 -0
  117. package/lib/workspaces/getWorkspaceManagerRoot.d.ts +16 -0
  118. package/lib/workspaces/getWorkspaceManagerRoot.js +32 -0
  119. package/lib/workspaces/getWorkspaceManagerRoot.js.map +1 -0
  120. package/lib/workspaces/getWorkspacePackagePaths.d.ts +17 -2
  121. package/lib/workspaces/getWorkspacePackagePaths.js +138 -24
  122. package/lib/workspaces/getWorkspacePackagePaths.js.map +1 -1
  123. package/lib/workspaces/getWorkspacePatterns.d.ts +11 -0
  124. package/lib/workspaces/getWorkspacePatterns.js +25 -0
  125. package/lib/workspaces/getWorkspacePatterns.js.map +1 -0
  126. package/lib/workspaces/implementations/WorkspaceUtilities.d.ts +27 -0
  127. package/lib/workspaces/implementations/WorkspaceUtilities.js +4 -0
  128. package/lib/workspaces/implementations/WorkspaceUtilities.js.map +1 -0
  129. package/lib/workspaces/implementations/getPackageJsonWorkspacePatterns.d.ts +9 -0
  130. package/lib/workspaces/implementations/getPackageJsonWorkspacePatterns.js +38 -0
  131. package/lib/workspaces/implementations/getPackageJsonWorkspacePatterns.js.map +1 -0
  132. package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.d.ts +19 -5
  133. package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.js +38 -40
  134. package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.js.map +1 -1
  135. package/lib/workspaces/implementations/getWorkspaceUtilities.d.ts +4 -36
  136. package/lib/workspaces/implementations/getWorkspaceUtilities.js +35 -20
  137. package/lib/workspaces/implementations/getWorkspaceUtilities.js.map +1 -1
  138. package/lib/workspaces/implementations/index.d.ts +2 -2
  139. package/lib/workspaces/implementations/index.js +19 -7
  140. package/lib/workspaces/implementations/index.js.map +1 -1
  141. package/lib/workspaces/implementations/lerna.d.ts +2 -20
  142. package/lib/workspaces/implementations/lerna.js +77 -62
  143. package/lib/workspaces/implementations/lerna.js.map +1 -1
  144. package/lib/workspaces/implementations/npm.d.ts +3 -17
  145. package/lib/workspaces/implementations/npm.js +12 -43
  146. package/lib/workspaces/implementations/npm.js.map +1 -1
  147. package/lib/workspaces/implementations/pnpm.d.ts +2 -30
  148. package/lib/workspaces/implementations/pnpm.js +32 -89
  149. package/lib/workspaces/implementations/pnpm.js.map +1 -1
  150. package/lib/workspaces/implementations/rush.d.ts +2 -22
  151. package/lib/workspaces/implementations/rush.js +26 -69
  152. package/lib/workspaces/implementations/rush.js.map +1 -1
  153. package/lib/workspaces/implementations/yarn.d.ts +2 -35
  154. package/lib/workspaces/implementations/yarn.js +33 -85
  155. package/lib/workspaces/implementations/yarn.js.map +1 -1
  156. package/lib/workspaces/wrapWorkspaceUtility.d.ts +31 -0
  157. package/lib/workspaces/wrapWorkspaceUtility.js +47 -0
  158. package/lib/workspaces/wrapWorkspaceUtility.js.map +1 -0
  159. package/package.json +21 -12
  160. package/lib/getPackagePaths.d.ts +0 -10
  161. package/lib/getPackagePaths.js +0 -49
  162. package/lib/getPackagePaths.js.map +0 -1
  163. package/lib/infoFromPackageJson.d.ts +0 -17
  164. package/lib/infoFromPackageJson.js +0 -11
  165. package/lib/infoFromPackageJson.js.map +0 -1
  166. package/lib/lockfile/index.d.ts +0 -6
  167. package/lib/lockfile/index.js +0 -105
  168. package/lib/lockfile/index.js.map +0 -1
  169. package/lib/workspaces/WorkspaceManager.js +0 -3
  170. package/lib/workspaces/WorkspaceManager.js.map +0 -1
  171. package/lib/workspaces/getWorkspacePackageInfo.d.ts +0 -26
  172. package/lib/workspaces/getWorkspacePackageInfo.js +0 -76
  173. package/lib/workspaces/getWorkspacePackageInfo.js.map +0 -1
  174. package/lib/workspaces/getWorkspaceRoot.d.ts +0 -25
  175. package/lib/workspaces/getWorkspaceRoot.js +0 -35
  176. package/lib/workspaces/getWorkspaceRoot.js.map +0 -1
  177. package/lib/workspaces/getWorkspaces.d.ts +0 -20
  178. package/lib/workspaces/getWorkspaces.js +0 -39
  179. package/lib/workspaces/getWorkspaces.js.map +0 -1
  180. package/lib/workspaces/implementations/packageJsonWorkspaces.d.ts +0 -31
  181. package/lib/workspaces/implementations/packageJsonWorkspaces.js +0 -104
  182. package/lib/workspaces/implementations/packageJsonWorkspaces.js.map +0 -1
  183. package/lib/workspaces/listOfWorkspacePackageNames.d.ts +0 -5
  184. package/lib/workspaces/listOfWorkspacePackageNames.js +0 -11
  185. package/lib/workspaces/listOfWorkspacePackageNames.js.map +0 -1
  186. /package/lib/{workspaces → types}/WorkspaceManager.d.ts +0 -0
@@ -1,25 +0,0 @@
1
- import { WorkspaceManager } from "./WorkspaceManager";
2
- /**
3
- * Get the root directory of a monorepo, defined as the directory where the workspace/monorepo manager
4
- * config file is located. (Does not rely in any way on git, and the result is cached by `cwd`.)
5
- *
6
- * NOTE: "Workspace" here refers to the entire project/monorepo, not an individual package the way it does
7
- * in e.g. npm/yarn/pnpm "workspaces."
8
- *
9
- * @param cwd Start searching from here
10
- * @param preferredManager Search for only this manager's config file
11
- *
12
- * @deprecated Renamed to `getWorkspaceManagerRoot` to align "workspace" terminology with npm/yarn/pnpm.
13
- * In most cases, you should use `findProjectRoot` instead since it falls back to the git root if no
14
- * workspace manager is found (single-package projects).
15
- */
16
- export declare function getWorkspaceRoot(cwd: string, preferredManager?: WorkspaceManager): string | undefined;
17
- /**
18
- * Get the root directory of a monorepo, defined as the directory where the workspace/monorepo manager
19
- * config file is located. (Does not rely in any way on git, and the result is cached by `cwd`.)
20
- *
21
- * @param cwd Start searching from here
22
- * @param preferredManager Search for only this manager's config file
23
- * @returns Workspace manager root directory, or undefined if not found
24
- */
25
- export declare function getWorkspaceManagerRoot(cwd: string, preferredManager?: WorkspaceManager): string | undefined;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWorkspaceManagerRoot = exports.getWorkspaceRoot = void 0;
4
- const implementations_1 = require("./implementations");
5
- /**
6
- * Get the root directory of a monorepo, defined as the directory where the workspace/monorepo manager
7
- * config file is located. (Does not rely in any way on git, and the result is cached by `cwd`.)
8
- *
9
- * NOTE: "Workspace" here refers to the entire project/monorepo, not an individual package the way it does
10
- * in e.g. npm/yarn/pnpm "workspaces."
11
- *
12
- * @param cwd Start searching from here
13
- * @param preferredManager Search for only this manager's config file
14
- *
15
- * @deprecated Renamed to `getWorkspaceManagerRoot` to align "workspace" terminology with npm/yarn/pnpm.
16
- * In most cases, you should use `findProjectRoot` instead since it falls back to the git root if no
17
- * workspace manager is found (single-package projects).
18
- */
19
- function getWorkspaceRoot(cwd, preferredManager) {
20
- return getWorkspaceManagerRoot(cwd, preferredManager);
21
- }
22
- exports.getWorkspaceRoot = getWorkspaceRoot;
23
- /**
24
- * Get the root directory of a monorepo, defined as the directory where the workspace/monorepo manager
25
- * config file is located. (Does not rely in any way on git, and the result is cached by `cwd`.)
26
- *
27
- * @param cwd Start searching from here
28
- * @param preferredManager Search for only this manager's config file
29
- * @returns Workspace manager root directory, or undefined if not found
30
- */
31
- function getWorkspaceManagerRoot(cwd, preferredManager) {
32
- return (0, implementations_1.getWorkspaceManagerAndRoot)(cwd, undefined, preferredManager)?.root;
33
- }
34
- exports.getWorkspaceManagerRoot = getWorkspaceManagerRoot;
35
- //# sourceMappingURL=getWorkspaceRoot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getWorkspaceRoot.js","sourceRoot":"","sources":["../../src/workspaces/getWorkspaceRoot.ts"],"names":[],"mappings":";;;AACA,uDAA+D;AAE/D;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB,CAAC,GAAW,EAAE,gBAAmC;IAC/E,OAAO,uBAAuB,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;AACxD,CAAC;AAFD,4CAEC;AAED;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,GAAW,EAAE,gBAAmC;IACtF,OAAO,IAAA,4CAA0B,EAAC,GAAG,EAAE,SAAS,EAAE,gBAAgB,CAAC,EAAE,IAAI,CAAC;AAC5E,CAAC;AAFD,0DAEC"}
@@ -1,20 +0,0 @@
1
- import type { WorkspaceInfos } from "../types/WorkspaceInfo";
2
- /**
3
- * Get an array with names, paths, and package.json contents for each package ("workspace" in
4
- * npm/yarn/pnpm terms) within a monorepo. The list of included packages is based on the
5
- * workspace/monorepo manager's config file.
6
- */
7
- export declare function getWorkspaceInfos(cwd: string): WorkspaceInfos;
8
- /** @deprecated Use `getWorkspaceInfos` */
9
- export declare const getWorkspaces: typeof getWorkspaceInfos;
10
- /**
11
- * Get an array with names, paths, and package.json contents for each package ("workspace" in
12
- * npm/yarn/pnpm terms) within a monorepo. The list of included packages is based on the
13
- * workspace/monorepo manager's config file.
14
- *
15
- * NOTE: As of writing, this will start promises to read all package.json files in parallel,
16
- * without direct concurrency control.
17
- */
18
- export declare function getWorkspaceInfosAsync(cwd: string): Promise<WorkspaceInfos>;
19
- /** @deprecated Use `getWorkspaceInfosAsync` */
20
- export declare const getWorkspacesAsync: typeof getWorkspaceInfosAsync;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWorkspacesAsync = exports.getWorkspaceInfosAsync = exports.getWorkspaces = exports.getWorkspaceInfos = void 0;
4
- const implementations_1 = require("./implementations");
5
- /**
6
- * Get an array with names, paths, and package.json contents for each package ("workspace" in
7
- * npm/yarn/pnpm terms) within a monorepo. The list of included packages is based on the
8
- * workspace/monorepo manager's config file.
9
- */
10
- function getWorkspaceInfos(cwd) {
11
- const utils = (0, implementations_1.getWorkspaceUtilities)(cwd);
12
- return utils?.getWorkspaces(cwd) || [];
13
- }
14
- exports.getWorkspaceInfos = getWorkspaceInfos;
15
- /** @deprecated Use `getWorkspaceInfos` */
16
- exports.getWorkspaces = getWorkspaceInfos;
17
- /**
18
- * Get an array with names, paths, and package.json contents for each package ("workspace" in
19
- * npm/yarn/pnpm terms) within a monorepo. The list of included packages is based on the
20
- * workspace/monorepo manager's config file.
21
- *
22
- * NOTE: As of writing, this will start promises to read all package.json files in parallel,
23
- * without direct concurrency control.
24
- */
25
- async function getWorkspaceInfosAsync(cwd) {
26
- const utils = (0, implementations_1.getWorkspaceUtilities)(cwd);
27
- if (!utils) {
28
- return [];
29
- }
30
- if (!utils.getWorkspacesAsync) {
31
- const managerName = (0, implementations_1.getWorkspaceManagerAndRoot)(cwd)?.manager;
32
- throw new Error(`${cwd} is using ${managerName} which has not been converted to async yet`);
33
- }
34
- return utils.getWorkspacesAsync(cwd);
35
- }
36
- exports.getWorkspaceInfosAsync = getWorkspaceInfosAsync;
37
- /** @deprecated Use `getWorkspaceInfosAsync` */
38
- exports.getWorkspacesAsync = getWorkspaceInfosAsync;
39
- //# sourceMappingURL=getWorkspaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getWorkspaces.js","sourceRoot":"","sources":["../../src/workspaces/getWorkspaces.ts"],"names":[],"mappings":";;;AAAA,uDAAsF;AAGtF;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,MAAM,KAAK,GAAG,IAAA,uCAAqB,EAAC,GAAG,CAAC,CAAC;IACzC,OAAO,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AACzC,CAAC;AAHD,8CAGC;AAED,0CAA0C;AAC7B,QAAA,aAAa,GAAG,iBAAiB,CAAC;AAE/C;;;;;;;GAOG;AACI,KAAK,UAAU,sBAAsB,CAAC,GAAW;IACtD,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,IAAA,4CAA0B,EAAC,GAAG,CAAC,EAAE,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,wDAaC;AAED,+CAA+C;AAClC,QAAA,kBAAkB,GAAG,sBAAsB,CAAC"}
@@ -1,31 +0,0 @@
1
- /**
2
- * Read the `workspaces` property the monorepo root package.json, then process the workspace globs
3
- * into absolute package paths. Returns an empty array if the `workspaces` property is not found or
4
- * there's some other issue.
5
- */
6
- export declare function getPackagePathsFromWorkspaceRoot(root: string): string[];
7
- /**
8
- * Read the `workspaces` property the monorepo root package.json, then process the workspace globs
9
- * into absolute package paths. Returns an empty array if the `workspaces` property is not found or
10
- * there's some other issue.
11
- */
12
- export declare function getPackagePathsFromWorkspaceRootAsync(root: string): Promise<string[]>;
13
- /**
14
- * Read the `workspaces` property the monorepo root package.json, then process the workspace globs
15
- * into an array with names, paths, and package.json contents for each package (each "workspace"
16
- * in npm/yarn/pnpm terms).
17
- *
18
- * @returns Array of monorepo package infos, or an empty array on error
19
- */
20
- export declare function getWorkspaceInfoFromWorkspaceRoot(root: string): import("../..").WorkspaceInfos;
21
- /**
22
- * Read the `workspaces` property the monorepo root package.json, then process the workspace globs
23
- * into an array with names, paths, and package.json contents for each package (each "workspace"
24
- * in npm/yarn/pnpm terms).
25
- *
26
- * NOTE: As of writing, this will start promises to read all package.json files in parallel,
27
- * without direct concurrency control.
28
- *
29
- * @returns Array of monorepo package infos, or an empty array on error
30
- */
31
- export declare function getWorkspaceInfoFromWorkspaceRootAsync(root: string): Promise<import("../..").WorkspaceInfos>;
@@ -1,104 +0,0 @@
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.getWorkspaceInfoFromWorkspaceRootAsync = exports.getWorkspaceInfoFromWorkspaceRoot = exports.getPackagePathsFromWorkspaceRootAsync = exports.getPackagePathsFromWorkspaceRoot = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const getPackagePaths_1 = require("../../getPackagePaths");
10
- const getWorkspacePackageInfo_1 = require("../getWorkspacePackageInfo");
11
- const logging_1 = require("../../logging");
12
- /**
13
- * Read the monorepo root package.json and get the list of package globs from its `workspaces` property.
14
- */
15
- function getPackages(root) {
16
- const packageJsonFile = path_1.default.join(root, "package.json");
17
- let packageJson;
18
- try {
19
- packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonFile, "utf-8"));
20
- }
21
- catch (e) {
22
- throw new Error("Could not load package.json from monorepo root");
23
- }
24
- const { workspaces } = packageJson;
25
- if (Array.isArray(workspaces)) {
26
- return workspaces;
27
- }
28
- if (!workspaces?.packages) {
29
- throw new Error("Could not find a workspaces object in package.json (expected if this is not a monorepo)");
30
- }
31
- return workspaces.packages;
32
- }
33
- /**
34
- * Read the `workspaces` property the monorepo root package.json, then process the workspace globs
35
- * into absolute package paths. Returns an empty array if the `workspaces` property is not found or
36
- * there's some other issue.
37
- */
38
- function getPackagePathsFromWorkspaceRoot(root) {
39
- try {
40
- const packageGlobs = getPackages(root);
41
- return packageGlobs ? (0, getPackagePaths_1.getPackagePaths)(root, packageGlobs) : [];
42
- }
43
- catch (err) {
44
- (0, logging_1.logVerboseWarning)(`Error getting package paths for ${root}`, err);
45
- return [];
46
- }
47
- }
48
- exports.getPackagePathsFromWorkspaceRoot = getPackagePathsFromWorkspaceRoot;
49
- /**
50
- * Read the `workspaces` property the monorepo root package.json, then process the workspace globs
51
- * into absolute package paths. Returns an empty array if the `workspaces` property is not found or
52
- * there's some other issue.
53
- */
54
- async function getPackagePathsFromWorkspaceRootAsync(root) {
55
- try {
56
- const packageGlobs = getPackages(root);
57
- return packageGlobs ? (0, getPackagePaths_1.getPackagePathsAsync)(root, packageGlobs) : [];
58
- }
59
- catch (err) {
60
- (0, logging_1.logVerboseWarning)(`Error getting package paths for ${root}`, err);
61
- return [];
62
- }
63
- }
64
- exports.getPackagePathsFromWorkspaceRootAsync = getPackagePathsFromWorkspaceRootAsync;
65
- /**
66
- * Read the `workspaces` property the monorepo root package.json, then process the workspace globs
67
- * into an array with names, paths, and package.json contents for each package (each "workspace"
68
- * in npm/yarn/pnpm terms).
69
- *
70
- * @returns Array of monorepo package infos, or an empty array on error
71
- */
72
- function getWorkspaceInfoFromWorkspaceRoot(root) {
73
- try {
74
- const packagePaths = getPackagePathsFromWorkspaceRoot(root);
75
- return (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths);
76
- }
77
- catch (err) {
78
- (0, logging_1.logVerboseWarning)(`Error getting workspace package infos for ${root}`, err);
79
- return [];
80
- }
81
- }
82
- exports.getWorkspaceInfoFromWorkspaceRoot = getWorkspaceInfoFromWorkspaceRoot;
83
- /**
84
- * Read the `workspaces` property the monorepo root package.json, then process the workspace globs
85
- * into an array with names, paths, and package.json contents for each package (each "workspace"
86
- * in npm/yarn/pnpm terms).
87
- *
88
- * NOTE: As of writing, this will start promises to read all package.json files in parallel,
89
- * without direct concurrency control.
90
- *
91
- * @returns Array of monorepo package infos, or an empty array on error
92
- */
93
- async function getWorkspaceInfoFromWorkspaceRootAsync(root) {
94
- try {
95
- const packagePaths = await getPackagePathsFromWorkspaceRootAsync(root);
96
- return (0, getWorkspacePackageInfo_1.getWorkspacePackageInfoAsync)(packagePaths);
97
- }
98
- catch (err) {
99
- (0, logging_1.logVerboseWarning)(`Error getting workspace package infos for ${root}`, err);
100
- return [];
101
- }
102
- }
103
- exports.getWorkspaceInfoFromWorkspaceRootAsync = getWorkspaceInfoFromWorkspaceRootAsync;
104
- //# sourceMappingURL=packageJsonWorkspaces.js.map
@@ -1 +0,0 @@
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;AAKlD;;GAEG;AACH,SAAS,WAAW,CAAC,IAAY;IAC/B,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAExD,IAAI,WAAsC,CAAC;IAC3C,IAAI;QACF,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAA8B,CAAC;KAClG;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;KACnE;IAED,MAAM,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;IAEnC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC7B,OAAO,UAAU,CAAC;KACnB;IAED,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC,CAAC;KAC5G;IAED,OAAO,UAAU,CAAC,QAAQ,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,SAAgB,gCAAgC,CAAC,IAAY;IAC3D,IAAI;QACF,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QACvC,OAAO,YAAY,CAAC,CAAC,CAAC,IAAA,iCAAe,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAChE;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,mCAAmC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;QAClE,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,4EAQC;AAED;;;;GAIG;AACI,KAAK,UAAU,qCAAqC,CAAC,IAAY;IACtE,IAAI;QACF,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QACvC,OAAO,YAAY,CAAC,CAAC,CAAC,IAAA,sCAAoB,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACrE;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,mCAAmC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;QAClE,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,sFAQC;AAED;;;;;;GAMG;AACH,SAAgB,iCAAiC,CAAC,IAAY;IAC5D,IAAI;QACF,MAAM,YAAY,GAAG,gCAAgC,CAAC,IAAI,CAAC,CAAC;QAC5D,OAAO,IAAA,iDAAuB,EAAC,YAAY,CAAC,CAAC;KAC9C;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,6CAA6C,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;QAC5E,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,8EAQC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,sCAAsC,CAAC,IAAY;IACvE,IAAI;QACF,MAAM,YAAY,GAAG,MAAM,qCAAqC,CAAC,IAAI,CAAC,CAAC;QACvE,OAAO,IAAA,sDAA4B,EAAC,YAAY,CAAC,CAAC;KACnD;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,6CAA6C,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;QAC5E,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AARD,wFAQC"}
@@ -1,5 +0,0 @@
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,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listOfWorkspacePackageNames = void 0;
4
- /**
5
- * @deprecated Just write `workspaces.map(w => w.name)` directly
6
- */
7
- function listOfWorkspacePackageNames(workspaces) {
8
- return workspaces.map(({ name }) => name);
9
- }
10
- exports.listOfWorkspacePackageNames = listOfWorkspacePackageNames;
11
- //# sourceMappingURL=listOfWorkspacePackageNames.js.map
@@ -1 +0,0 @@
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"}
File without changes