workspace-tools 0.38.3 → 0.38.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/lib/getPackageInfos.d.ts +14 -0
  2. package/lib/getPackageInfos.js +17 -20
  3. package/lib/getPackageInfos.js.map +1 -1
  4. package/lib/getPackagePaths.d.ts +2 -2
  5. package/lib/getPackagePaths.js +2 -2
  6. package/lib/git/getRepositoryName.js +6 -6
  7. package/lib/git/getRepositoryName.js.map +1 -1
  8. package/lib/git/git.d.ts +10 -2
  9. package/lib/git/git.js +15 -3
  10. package/lib/git/git.js.map +1 -1
  11. package/lib/git/gitUtilities.d.ts +132 -3
  12. package/lib/git/gitUtilities.js +141 -4
  13. package/lib/git/gitUtilities.js.map +1 -1
  14. package/lib/graph/createDependencyMap.d.ts +1 -1
  15. package/lib/graph/createDependencyMap.js.map +1 -1
  16. package/lib/graph/getPackageDependencies.d.ts +10 -1
  17. package/lib/graph/getPackageDependencies.js +17 -5
  18. package/lib/graph/getPackageDependencies.js.map +1 -1
  19. package/lib/index.d.ts +17 -14
  20. package/lib/index.js +40 -15
  21. package/lib/index.js.map +1 -1
  22. package/lib/lockfile/parseBerryLock.d.ts +3 -0
  23. package/lib/lockfile/parseBerryLock.js +3 -0
  24. package/lib/lockfile/parseBerryLock.js.map +1 -1
  25. package/lib/lockfile/types.d.ts +3 -0
  26. package/lib/paths.d.ts +3 -0
  27. package/lib/paths.js +4 -1
  28. package/lib/paths.js.map +1 -1
  29. package/lib/tsdoc-metadata.json +1 -1
  30. package/lib/types/Catalogs.d.ts +30 -0
  31. package/lib/types/Catalogs.js +3 -0
  32. package/lib/types/Catalogs.js.map +1 -0
  33. package/lib/types/PackageInfo.d.ts +19 -1
  34. package/lib/types/WorkspaceInfo.d.ts +15 -6
  35. package/lib/workspaces/catalogs.d.ts +28 -0
  36. package/lib/workspaces/catalogs.js +57 -0
  37. package/lib/workspaces/catalogs.js.map +1 -0
  38. package/lib/workspaces/findWorkspacePath.d.ts +5 -5
  39. package/lib/workspaces/findWorkspacePath.js +3 -3
  40. package/lib/workspaces/findWorkspacePath.js.map +1 -1
  41. package/lib/workspaces/getWorkspacePackageInfo.d.ts +12 -9
  42. package/lib/workspaces/getWorkspacePackageInfo.js +14 -16
  43. package/lib/workspaces/getWorkspacePackageInfo.js.map +1 -1
  44. package/lib/workspaces/getWorkspaceRoot.d.ts +18 -2
  45. package/lib/workspaces/getWorkspaceRoot.js +23 -4
  46. package/lib/workspaces/getWorkspaceRoot.js.map +1 -1
  47. package/lib/workspaces/getWorkspaces.d.ts +11 -14
  48. package/lib/workspaces/getWorkspaces.js +8 -11
  49. package/lib/workspaces/getWorkspaces.js.map +1 -1
  50. package/lib/workspaces/implementations/getWorkspaceUtilities.d.ts +16 -9
  51. package/lib/workspaces/implementations/getWorkspaceUtilities.js.map +1 -1
  52. package/lib/workspaces/implementations/index.d.ts +2 -2
  53. package/lib/workspaces/implementations/index.js.map +1 -1
  54. package/lib/workspaces/implementations/lerna.d.ts +8 -8
  55. package/lib/workspaces/implementations/lerna.js +5 -5
  56. package/lib/workspaces/implementations/lerna.js.map +1 -1
  57. package/lib/workspaces/implementations/npm.d.ts +9 -9
  58. package/lib/workspaces/implementations/npm.js +6 -6
  59. package/lib/workspaces/implementations/npm.js.map +1 -1
  60. package/lib/workspaces/implementations/packageJsonWorkspaces.d.ts +21 -10
  61. package/lib/workspaces/implementations/packageJsonWorkspaces.js +34 -23
  62. package/lib/workspaces/implementations/packageJsonWorkspaces.js.map +1 -1
  63. package/lib/workspaces/implementations/pnpm.d.ts +17 -9
  64. package/lib/workspaces/implementations/pnpm.js +37 -11
  65. package/lib/workspaces/implementations/pnpm.js.map +1 -1
  66. package/lib/workspaces/implementations/rush.d.ts +8 -8
  67. package/lib/workspaces/implementations/rush.js +5 -5
  68. package/lib/workspaces/implementations/rush.js.map +1 -1
  69. package/lib/workspaces/implementations/yarn.d.ts +18 -10
  70. package/lib/workspaces/implementations/yarn.js +51 -10
  71. package/lib/workspaces/implementations/yarn.js.map +1 -1
  72. package/lib/workspaces/listOfWorkspacePackageNames.d.ts +5 -2
  73. package/lib/workspaces/listOfWorkspacePackageNames.js +3 -0
  74. package/lib/workspaces/listOfWorkspacePackageNames.js.map +1 -1
  75. package/lib/workspaces/readPackageInfo.d.ts +13 -0
  76. package/lib/workspaces/readPackageInfo.js +52 -0
  77. package/lib/workspaces/readPackageInfo.js.map +1 -0
  78. package/package.json +3 -4
package/lib/paths.d.ts CHANGED
@@ -18,4 +18,7 @@ export declare function findPackageRoot(cwd: string): string | undefined;
18
18
  * falling back to the git root if no workspace is detected.
19
19
  */
20
20
  export declare function findProjectRoot(cwd: string): string;
21
+ /**
22
+ * Determines if `child` path is a subdirectory of `parent` path.
23
+ */
21
24
  export declare function isChildOf(child: string, parent: string): boolean;
package/lib/paths.js CHANGED
@@ -57,7 +57,7 @@ exports.findPackageRoot = findPackageRoot;
57
57
  function findProjectRoot(cwd) {
58
58
  let workspaceRoot;
59
59
  try {
60
- workspaceRoot = (0, getWorkspaceRoot_1.getWorkspaceRoot)(cwd);
60
+ workspaceRoot = (0, getWorkspaceRoot_1.getWorkspaceManagerRoot)(cwd);
61
61
  }
62
62
  catch (err) {
63
63
  (0, logging_1.logVerboseWarning)(`Error getting workspace root for ${cwd}`, err);
@@ -68,6 +68,9 @@ function findProjectRoot(cwd) {
68
68
  return workspaceRoot || findGitRoot(cwd);
69
69
  }
70
70
  exports.findProjectRoot = findProjectRoot;
71
+ /**
72
+ * Determines if `child` path is a subdirectory of `parent` path.
73
+ */
71
74
  function isChildOf(child, parent) {
72
75
  const relativePath = path_1.default.relative(child, parent);
73
76
  return /^[.\/\\]+$/.test(relativePath);
package/lib/paths.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,oEAAiE;AACjE,+BAA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C9C;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,2BAAiB,EAAC,oCAAoC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;KACnE;IAED,IAAI,CAAC,aAAa,EAAE;QAClB,IAAA,2BAAiB,EAAC,qCAAqC,GAAG,6BAA6B,CAAC,CAAC;KAC1F;IACD,OAAO,aAAa,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC;AAC3C,CAAC;AAZD,0CAYC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,KAAa,EAAE,MAAc;IACrD,MAAM,YAAY,GAAG,cAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAClD,OAAO,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC;AAHD,8BAGC"}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.1"
8
+ "packageVersion": "7.52.9"
9
9
  }
10
10
  ]
11
11
  }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Mapping from package name to package version.
3
+ * @see https://pnpm.io/catalogs#default-catalog
4
+ * @see https://yarnpkg.com/features/catalogs#basic-usage
5
+ */
6
+ export interface Catalog {
7
+ [packageName: string]: string;
8
+ }
9
+ /**
10
+ * Mapping from catalog name (non-default) to catalog definition
11
+ * @see https://pnpm.io/catalogs#named-catalogs
12
+ * @see https://yarnpkg.com/features/catalogs#named-catalogs
13
+ */
14
+ export interface NamedCatalogs {
15
+ [catalogName: string]: Catalog;
16
+ }
17
+ /**
18
+ * Package version catalogs
19
+ * @see https://pnpm.io/catalogs
20
+ * @see https://yarnpkg.com/features/catalogs
21
+ */
22
+ export interface Catalogs {
23
+ /**
24
+ * The default catalog if present.
25
+ * (This can't be combined with the named catalogs because "default" could be a catalog name.)
26
+ */
27
+ default?: Catalog;
28
+ /** Mapping from catalog name to catalog definition, if present */
29
+ named?: NamedCatalogs;
30
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Catalogs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Catalogs.js","sourceRoot":"","sources":["../../src/types/Catalogs.ts"],"names":[],"mappings":""}
@@ -1,6 +1,9 @@
1
+ import type { Catalog, NamedCatalogs } from "./Catalogs";
2
+ /** Contents of `package.json`, plus the `packageJsonPath` */
1
3
  export interface PackageInfo {
2
- name: string;
4
+ /** Absolute path to this package.json file */
3
5
  packageJsonPath: string;
6
+ name: string;
4
7
  version: string;
5
8
  dependencies?: {
6
9
  [dep: string]: string;
@@ -25,7 +28,22 @@ export interface PackageInfo {
25
28
  directory?: string;
26
29
  };
27
30
  [key: string]: any;
31
+ /**
32
+ * Workspace info, only in the root package.json for certain managers.
33
+ * If an array of strings, it's a list of workspace package patterns.
34
+ */
35
+ workspaces?: string[] | {
36
+ /** List of workspace package patterns */
37
+ packages: string[];
38
+ nohoist?: string[];
39
+ /** `midgard-yarn-strict` catalog definition (yarn4/pnpm use yaml config) */
40
+ catalog?: Catalog;
41
+ /** `midgard-yarn-strict` named catalog definition (yarn4/pnpm use yaml config) */
42
+ catalogs?: NamedCatalogs;
43
+ [key: string]: any;
44
+ };
28
45
  }
46
+ /** Mapping from package name to info (`package.json`) for packages within a monorepo. */
29
47
  export interface PackageInfos {
30
48
  [pkgName: string]: PackageInfo;
31
49
  }
@@ -1,13 +1,22 @@
1
1
  import { PackageInfo } from "./PackageInfo";
2
2
  /**
3
- * Array with names, paths, and package.json contents for each package in a workspace.
3
+ * Info about a single package ("workspace" in npm/yarn/pnpm terms) within a monorepo.
4
4
  *
5
- * The method name is somewhat misleading due to the double meaning of "workspace", but it's retained
6
- * for compatibility. "Workspace" here refers to an individual package, in the sense of the `workspaces`
7
- * package.json config used by npm/yarn (instead of referring to the entire monorepo).
5
+ * Ideally this should be called just `WorkspaceInfo`, but that name was previously used for the
6
+ * aggregate type.
8
7
  */
9
- export type WorkspaceInfo = {
8
+ export interface WorkspacePackageInfo {
9
+ /** Package name */
10
10
  name: string;
11
+ /** Absolute path to the package root */
11
12
  path: string;
13
+ /** `package.json` contents + path */
12
14
  packageJson: PackageInfo;
13
- }[];
15
+ }
16
+ /**
17
+ * Array with names, paths, and package.json contents for each package ("workspace" in
18
+ * npm/yarn/pnpm terms) within a monorepo.
19
+ */
20
+ export type WorkspaceInfos = WorkspacePackageInfo[];
21
+ /** @deprecated Use `WorkspaceInfos` */
22
+ export type WorkspaceInfo = WorkspaceInfos;
@@ -0,0 +1,28 @@
1
+ import type { Catalogs } from "../types/Catalogs";
2
+ /**
3
+ * Get version catalogs, if supported by the manager (only pnpm and yarn v4 as of writing).
4
+ * Returns undefined if no catalogs are present or the manager doesn't support them.
5
+ * @see https://pnpm.io/catalogs
6
+ * @see https://yarnpkg.com/features/catalogs
7
+ */
8
+ export declare function getCatalogs(cwd: string): Catalogs | undefined;
9
+ /**
10
+ * Returns true if the version starts with `catalog:`.
11
+ */
12
+ export declare function isCatalogVersion(version: string): boolean;
13
+ /**
14
+ * Given a dependency package name and a version string, if the version starts with `catalog:`,
15
+ * look up the actual version spec from the given catalogs.
16
+ *
17
+ * Throws an error if the version uses `catalog:` but no catalogs are defined, or the version
18
+ * isn't found in the given catalog.
19
+ *
20
+ * Returns undefined if the version doesn't start with `catalog:`.
21
+ * @see https://pnpm.io/catalogs
22
+ * @see https://yarnpkg.com/features/catalogs
23
+ */
24
+ export declare function getCatalogVersion(params: {
25
+ name: string;
26
+ version: string;
27
+ catalogs: Catalogs | undefined;
28
+ }): string | undefined;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCatalogVersion = exports.isCatalogVersion = exports.getCatalogs = void 0;
4
+ const implementations_1 = require("./implementations");
5
+ /**
6
+ * Get version catalogs, if supported by the manager (only pnpm and yarn v4 as of writing).
7
+ * Returns undefined if no catalogs are present or the manager doesn't support them.
8
+ * @see https://pnpm.io/catalogs
9
+ * @see https://yarnpkg.com/features/catalogs
10
+ */
11
+ function getCatalogs(cwd) {
12
+ const utils = (0, implementations_1.getWorkspaceUtilities)(cwd);
13
+ return utils?.getCatalogs?.(cwd);
14
+ }
15
+ exports.getCatalogs = getCatalogs;
16
+ const catalogRegex = /^catalog:(.*)$/;
17
+ /**
18
+ * Returns true if the version starts with `catalog:`.
19
+ */
20
+ function isCatalogVersion(version) {
21
+ return catalogRegex.test(version);
22
+ }
23
+ exports.isCatalogVersion = isCatalogVersion;
24
+ /**
25
+ * Given a dependency package name and a version string, if the version starts with `catalog:`,
26
+ * look up the actual version spec from the given catalogs.
27
+ *
28
+ * Throws an error if the version uses `catalog:` but no catalogs are defined, or the version
29
+ * isn't found in the given catalog.
30
+ *
31
+ * Returns undefined if the version doesn't start with `catalog:`.
32
+ * @see https://pnpm.io/catalogs
33
+ * @see https://yarnpkg.com/features/catalogs
34
+ */
35
+ function getCatalogVersion(params) {
36
+ const { name, version, catalogs } = params;
37
+ const catalogMatch = version.match(/^catalog:(.*)$/);
38
+ if (!catalogMatch) {
39
+ return undefined;
40
+ }
41
+ if (!catalogs) {
42
+ throw new Error(`Dependency "${name}" uses a catalog version "${version}" but no catalogs are defined.`);
43
+ }
44
+ const catalogName = catalogMatch[1];
45
+ const checkCatalog = catalogName ? catalogs.named?.[catalogName] : catalogs.default;
46
+ const catalogNameStr = catalogName ? `catalogs.${catalogName}` : "the default catalog";
47
+ if (!checkCatalog) {
48
+ throw new Error(`Dependency "${name}" uses a catalog version "${version}" but ${catalogNameStr} is not defined.`);
49
+ }
50
+ const actualVersion = checkCatalog[name];
51
+ if (!actualVersion) {
52
+ throw new Error(`Dependency "${name}" uses a catalog version "${version}", but ${catalogNameStr} doesn't define a version for "${name}".`);
53
+ }
54
+ return actualVersion;
55
+ }
56
+ exports.getCatalogVersion = getCatalogVersion;
57
+ //# sourceMappingURL=catalogs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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Aa,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,KAAK,CACb,eAAe,IAAI,6BAA6B,OAAO,UAAU,cAAc,kCAAkC,IAAI,IAAI,CAC1H,CAAC;KACH;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AA/BD,8CA+BC"}
@@ -1,9 +1,9 @@
1
- import { WorkspaceInfo } from "../types/WorkspaceInfo";
1
+ import type { WorkspaceInfos } from "../types/WorkspaceInfo";
2
2
  /**
3
- * Find the path for a particular package name from an array of info about packages within a workspace.
4
- * (See `../getWorkspaces` for why it's named this way.)
5
- * @param workspaces Array of info about packages within a workspace
3
+ * Find the path for a particular package name from an array of info about packages ("workspaces"
4
+ * in npm/yarn/pnpm terms) within a monorepo.
5
+ * @param workspaces Array of info about packages within a monorepo
6
6
  * @param packageName Package name to find
7
7
  * @returns Package path if found, or undefined
8
8
  */
9
- export declare function findWorkspacePath(workspaces: WorkspaceInfo, packageName: string): string | undefined;
9
+ export declare function findWorkspacePath(workspaces: WorkspaceInfos, packageName: string): string | undefined;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findWorkspacePath = void 0;
4
4
  /**
5
- * Find the path for a particular package name from an array of info about packages within a workspace.
6
- * (See `../getWorkspaces` for why it's named this way.)
7
- * @param workspaces Array of info about packages within a workspace
5
+ * Find the path for a particular package name from an array of info about packages ("workspaces"
6
+ * in npm/yarn/pnpm terms) within a monorepo.
7
+ * @param workspaces Array of info about packages within a monorepo
8
8
  * @param packageName Package name to find
9
9
  * @returns Package path if found, or undefined
10
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"findWorkspacePath.js","sourceRoot":"","sources":["../../src/workspaces/findWorkspacePath.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,UAAyB,EAAE,WAAmB;IAC9E,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,WAAW,CAAC,EAAE,IAAI,CAAC;AACnE,CAAC;AAFD,8CAEC"}
1
+ {"version":3,"file":"findWorkspacePath.js","sourceRoot":"","sources":["../../src/workspaces/findWorkspacePath.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,UAA0B,EAAE,WAAmB;IAC/E,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,WAAW,CAAC,EAAE,IAAI,CAAC;AACnE,CAAC;AAFD,8CAEC"}
@@ -1,23 +1,26 @@
1
- import { WorkspaceInfo } from "../types/WorkspaceInfo";
1
+ import type { WorkspaceInfos } from "../types/WorkspaceInfo";
2
2
  /**
3
3
  * Get an array with names, paths, and package.json contents for each of the given package paths
4
- * within a workspace.
4
+ * ("workspace" paths in npm/yarn/pnpm terms) within a monorepo.
5
5
  *
6
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
7
+ *
8
+ * @param packagePaths Paths to packages within a monorepo
9
9
  * @returns Array of workspace package infos
10
10
  * @internal
11
11
  */
12
- export declare function getWorkspacePackageInfo(packagePaths: string[]): WorkspaceInfo;
12
+ export declare function getWorkspacePackageInfo(packagePaths: string[]): WorkspaceInfos;
13
13
  /**
14
14
  * Get an array with names, paths, and package.json contents for each of the given package paths
15
- * within a workspace.
15
+ * ("workspace" paths in npm/yarn/pnpm terms) within a monorepo.
16
+ *
17
+ * NOTE: As of writing, this will start promises to read all package.json files in parallel,
18
+ * without direct concurrency control.
16
19
  *
17
20
  * 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
21
+ *
22
+ * @param packagePaths Paths to packages within a monorepo
20
23
  * @returns Array of workspace package infos
21
24
  * @internal
22
25
  */
23
- export declare function getWorkspacePackageInfoAsync(packagePaths: string[]): Promise<WorkspaceInfo>;
26
+ export declare function getWorkspacePackageInfoAsync(packagePaths: string[]): Promise<WorkspaceInfos>;
@@ -5,17 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getWorkspacePackageInfoAsync = exports.getWorkspacePackageInfo = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const fs_1 = __importDefault(require("fs"));
9
8
  const promises_1 = __importDefault(require("fs/promises"));
10
9
  const logging_1 = require("../logging");
11
10
  const infoFromPackageJson_1 = require("../infoFromPackageJson");
11
+ const readPackageInfo_1 = require("./readPackageInfo");
12
12
  /**
13
13
  * Get an array with names, paths, and package.json contents for each of the given package paths
14
- * within a workspace.
14
+ * ("workspace" paths in npm/yarn/pnpm terms) within a monorepo.
15
15
  *
16
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
17
+ *
18
+ * @param packagePaths Paths to packages within a monorepo
19
19
  * @returns Array of workspace package infos
20
20
  * @internal
21
21
  */
@@ -25,19 +25,14 @@ function getWorkspacePackageInfo(packagePaths) {
25
25
  }
26
26
  return packagePaths
27
27
  .map((workspacePath) => {
28
- let packageJson;
29
- const packageJsonPath = path_1.default.join(workspacePath, "package.json");
30
- try {
31
- packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf-8"));
32
- }
33
- catch (err) {
34
- (0, logging_1.logVerboseWarning)(`Error reading or parsing ${packageJsonPath} while getting workspace package info`, err);
35
- return null;
28
+ const packageJson = (0, readPackageInfo_1.readPackageInfo)(workspacePath);
29
+ if (!packageJson) {
30
+ return null; // readPackageInfo already logged a warning
36
31
  }
37
32
  return {
38
33
  name: packageJson.name,
39
34
  path: workspacePath,
40
- packageJson: (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath),
35
+ packageJson,
41
36
  };
42
37
  })
43
38
  .filter(Boolean);
@@ -45,11 +40,14 @@ function getWorkspacePackageInfo(packagePaths) {
45
40
  exports.getWorkspacePackageInfo = getWorkspacePackageInfo;
46
41
  /**
47
42
  * Get an array with names, paths, and package.json contents for each of the given package paths
48
- * within a workspace.
43
+ * ("workspace" paths in npm/yarn/pnpm terms) within a monorepo.
44
+ *
45
+ * NOTE: As of writing, this will start promises to read all package.json files in parallel,
46
+ * without direct concurrency control.
49
47
  *
50
48
  * 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
49
+ *
50
+ * @param packagePaths Paths to packages within a monorepo
53
51
  * @returns Array of workspace package infos
54
52
  * @internal
55
53
  */
@@ -1 +1 @@
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,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CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAmB,CAAC;AACrF,CAAC;AAtBD,oEAsBC"}
@@ -1,8 +1,24 @@
1
1
  import { WorkspaceManager } from "./WorkspaceManager";
2
2
  /**
3
- * Get the root directory of a workspace/monorepo, defined as the directory where the workspace
4
- * manager config file is located.
3
+ * Get the root directory of a monorepo, defined as the directory where the workspace manager
4
+ * config file is located.
5
+ *
6
+ * NOTE: "Workspace" here refers to the entire project, not an individual package the way it does
7
+ * in e.g. npm/yarn/pnpm "workspaces."
8
+ *
5
9
  * @param cwd Start searching from here
6
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).
7
15
  */
8
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 manager
19
+ * config file is located.
20
+ *
21
+ * @param cwd Start searching from here
22
+ * @param preferredManager Search for only this manager's config file
23
+ */
24
+ export declare function getWorkspaceManagerRoot(cwd: string, preferredManager?: WorkspaceManager): string | undefined;
@@ -1,15 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWorkspaceRoot = void 0;
3
+ exports.getWorkspaceManagerRoot = exports.getWorkspaceRoot = void 0;
4
4
  const implementations_1 = require("./implementations");
5
5
  /**
6
- * Get the root directory of a workspace/monorepo, defined as the directory where the workspace
7
- * manager config file is located.
6
+ * Get the root directory of a monorepo, defined as the directory where the workspace manager
7
+ * config file is located.
8
+ *
9
+ * NOTE: "Workspace" here refers to the entire project, not an individual package the way it does
10
+ * in e.g. npm/yarn/pnpm "workspaces."
11
+ *
8
12
  * @param cwd Start searching from here
9
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).
10
18
  */
11
19
  function getWorkspaceRoot(cwd, preferredManager) {
12
- return (0, implementations_1.getWorkspaceManagerAndRoot)(cwd, undefined, preferredManager)?.root;
20
+ return getWorkspaceManagerRoot(cwd, preferredManager);
13
21
  }
14
22
  exports.getWorkspaceRoot = getWorkspaceRoot;
23
+ /**
24
+ * Get the root directory of a monorepo, defined as the directory where the workspace manager
25
+ * config file is located.
26
+ *
27
+ * @param cwd Start searching from here
28
+ * @param preferredManager Search for only this manager's config file
29
+ */
30
+ function getWorkspaceManagerRoot(cwd, preferredManager) {
31
+ return (0, implementations_1.getWorkspaceManagerAndRoot)(cwd, undefined, preferredManager)?.root;
32
+ }
33
+ exports.getWorkspaceManagerRoot = getWorkspaceManagerRoot;
15
34
  //# sourceMappingURL=getWorkspaceRoot.js.map
@@ -1 +1 @@
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,IAAA,4CAA0B,EAAC,GAAG,EAAE,SAAS,EAAE,gBAAgB,CAAC,EAAE,IAAI,CAAC;AAC5E,CAAC;AAFD,4CAEC"}
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;;;;;;GAMG;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,19 +1,16 @@
1
- import { WorkspaceInfo } from "../types/WorkspaceInfo";
1
+ import type { WorkspaceInfos } from "../types/WorkspaceInfo";
2
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).
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 workspace
5
+ * manager's config file.
9
6
  */
10
- export declare function getWorkspaces(cwd: string): WorkspaceInfo;
7
+ export declare function getWorkspaces(cwd: string): WorkspaceInfos;
11
8
  /**
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.
9
+ * Get an array with names, paths, and package.json contents for each package ("workspace" in
10
+ * npm/yarn/pnpm terms) within a monorepo. The list of included packages is based on the workspace
11
+ * manager's config file.
14
12
  *
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).
13
+ * NOTE: As of writing, this will start promises to read all package.json files in parallel,
14
+ * without direct concurrency control.
18
15
  */
19
- export declare function getWorkspacesAsync(cwd: string): Promise<WorkspaceInfo>;
16
+ export declare function getWorkspacesAsync(cwd: string): Promise<WorkspaceInfos>;
@@ -3,12 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWorkspacesAsync = exports.getWorkspaces = void 0;
4
4
  const implementations_1 = require("./implementations");
5
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).
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 workspace
8
+ * manager's config file.
12
9
  */
13
10
  function getWorkspaces(cwd) {
14
11
  const utils = (0, implementations_1.getWorkspaceUtilities)(cwd);
@@ -16,12 +13,12 @@ function getWorkspaces(cwd) {
16
13
  }
17
14
  exports.getWorkspaces = getWorkspaces;
18
15
  /**
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.
16
+ * Get an array with names, paths, and package.json contents for each package ("workspace" in
17
+ * npm/yarn/pnpm terms) within a monorepo. The list of included packages is based on the workspace
18
+ * manager's config file.
21
19
  *
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).
20
+ * NOTE: As of writing, this will start promises to read all package.json files in parallel,
21
+ * without direct concurrency control.
25
22
  */
26
23
  async function getWorkspacesAsync(cwd) {
27
24
  const utils = (0, implementations_1.getWorkspaceUtilities)(cwd);
@@ -1 +1 @@
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,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AACzC,CAAC;AAHD,sC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 -1,23 +1,30 @@
1
- import { WorkspaceInfo } from "../../types/WorkspaceInfo";
1
+ import type { Catalogs } from "../../types/Catalogs";
2
+ import type { WorkspaceInfos } from "../../types/WorkspaceInfo";
2
3
  export interface WorkspaceUtilities {
3
4
  /**
4
- * Get an array of paths to packages in the workspace, based on the manager's config file.
5
+ * Get an array of paths to packages ("workspaces") in the monorepo, based on the
6
+ * manager's config file.
5
7
  */
6
8
  getWorkspacePackagePaths: (cwd: string) => string[];
7
9
  /**
8
- * Get an array of paths to packages in the workspace, based on the manager's config file.
10
+ * Get an array of paths to packages ("workspaces") in the monorepo, based on the
11
+ * manager's config file.
9
12
  */
10
13
  getWorkspacePackagePathsAsync?: (cwd: string) => Promise<string[]>;
11
14
  /**
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.)
15
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
16
+ * in a monorepo.
14
17
  */
15
- getWorkspaces: (cwd: string) => WorkspaceInfo;
18
+ getWorkspaces: (cwd: string) => WorkspaceInfos;
16
19
  /**
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.)
20
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
21
+ * in a monorepo.
19
22
  */
20
- getWorkspacesAsync?: (cwd: string) => Promise<WorkspaceInfo>;
23
+ getWorkspacesAsync: (cwd: string) => Promise<WorkspaceInfos>;
24
+ /**
25
+ * Get version catalogs, if supported by the manager (only pnpm and yarn v4 as of writing).
26
+ */
27
+ getCatalogs?: (cwd: string) => Catalogs | undefined;
21
28
  }
22
29
  /**
23
30
  * Get utility implementations for the workspace manager of `cwd`.
@@ -1 +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,IAAA,uDAA0B,EAAC,GAAG,CAAC,EAAE,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
+ {"version":3,"file":"getWorkspaceUtilities.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/getWorkspaceUtilities.ts"],"names":[],"mappings":";;;AAEA,6EAA0E;AAmC1E;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,GAAW;IAC/C,MAAM,OAAO,GAAG,IAAA,uDAA0B,EAAC,GAAG,CAAC,EAAE,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,2 +1,2 @@
1
- export { getWorkspaceManagerAndRoot, WorkspaceManagerAndRoot } from "./getWorkspaceManagerAndRoot";
2
- export { getWorkspaceUtilities, WorkspaceUtilities } from "./getWorkspaceUtilities";
1
+ export { getWorkspaceManagerAndRoot, type WorkspaceManagerAndRoot } from "./getWorkspaceManagerAndRoot";
2
+ export { getWorkspaceUtilities, type WorkspaceUtilities } from "./getWorkspaceUtilities";
@@ -1 +1 @@
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
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/workspaces/implementations/index.ts"],"names":[],"mappings":";;;AAAA,2EAAwG;AAA/F,wIAAA,0BAA0B,OAAA;AACnC,iEAAyF;AAAhF,8HAAA,qBAAqB,OAAA"}
@@ -1,15 +1,15 @@
1
- import { WorkspaceInfo } from "../../types/WorkspaceInfo";
2
- /** Get package paths for a lerna workspace. */
1
+ import type { WorkspaceInfos } from "../../types/WorkspaceInfo";
2
+ /** Get paths for each package ("workspace") in a lerna monorepo. */
3
3
  export declare function getWorkspacePackagePaths(cwd: string): string[];
4
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.)
5
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
6
+ * in a lerna monorepo.
7
7
  */
8
- export declare function getLernaWorkspaces(cwd: string): WorkspaceInfo;
8
+ export declare function getLernaWorkspaces(cwd: string): WorkspaceInfos;
9
9
  /**
10
- * Get an array with names, paths, and package.json contents for each package in a lerna workspace.
11
- * (See `../getWorkspaces` for why it's named this way.)
10
+ * Get an array with names, paths, and package.json contents for each package ("workspace")
11
+ * in a lerna monorepo.
12
12
  */
13
- export declare function getLernaWorkspacesAsync(cwd: string): Promise<WorkspaceInfo>;
13
+ export declare function getLernaWorkspacesAsync(cwd: string): Promise<WorkspaceInfos>;
14
14
  export { getLernaWorkspaces as getWorkspaces };
15
15
  export { getLernaWorkspacesAsync as getWorkspacesAsync };