workspace-tools 0.18.2 → 0.18.3

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.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "workspace-tools",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 07 Jan 2022 18:15:30 GMT",
5
+ "date": "Sat, 09 Apr 2022 15:51:11 GMT",
6
+ "tag": "workspace-tools_v0.18.3",
7
+ "version": "0.18.3",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "4123478+tido64@users.noreply.github.com",
12
+ "package": "workspace-tools",
13
+ "comment": "Fix Rush not being detected correctly. When Rush is set up to use Yarn or pnpm, the lock file for the latter are found first.",
14
+ "commit": "b99f6f82a6f22da37b67d74b519a204abd631c87"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Fri, 07 Jan 2022 18:15:36 GMT",
6
21
  "tag": "workspace-tools_v0.18.2",
7
22
  "version": "0.18.2",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - workspace-tools
2
2
 
3
- This log was last generated on Fri, 07 Jan 2022 18:15:30 GMT and should not be manually modified.
3
+ This log was last generated on Sat, 09 Apr 2022 15:51:11 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.18.3
8
+
9
+ Sat, 09 Apr 2022 15:51:11 GMT
10
+
11
+ ### Patches
12
+
13
+ - Fix Rush not being detected correctly. When Rush is set up to use Yarn or pnpm, the lock file for the latter are found first. (4123478+tido64@users.noreply.github.com)
14
+
7
15
  ## 0.18.2
8
16
 
9
- Fri, 07 Jan 2022 18:15:30 GMT
17
+ Fri, 07 Jan 2022 18:15:36 GMT
10
18
 
11
19
  ### Patches
12
20
 
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const path_1 = __importDefault(require("path"));
7
7
  const setupFixture_1 = require("../helpers/setupFixture");
8
+ const implementations_1 = require("../workspaces/implementations");
8
9
  const yarn_1 = require("../workspaces/implementations/yarn");
9
10
  const pnpm_1 = require("../workspaces/implementations/pnpm");
10
11
  const rush_1 = require("../workspaces/implementations/rush");
@@ -17,6 +18,7 @@ describe("getWorkspaces", () => {
17
18
  describe("yarn", () => {
18
19
  it("gets the name and path of the workspaces", () => {
19
20
  const packageRoot = (0, setupFixture_1.setupFixture)("monorepo");
21
+ expect((0, implementations_1.getWorkspaceImplementation)(packageRoot, {})).toBe("yarn");
20
22
  const workspacesPackageInfo = (0, yarn_1.getYarnWorkspaces)(packageRoot);
21
23
  const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
22
24
  const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
@@ -27,6 +29,7 @@ describe("getWorkspaces", () => {
27
29
  });
28
30
  it("gets the name and path of the workspaces against a packages spec of an individual package", () => {
29
31
  const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-globby");
32
+ expect((0, implementations_1.getWorkspaceImplementation)(packageRoot, {})).toBe("yarn");
30
33
  const workspacesPackageInfo = (0, yarn_1.getYarnWorkspaces)(packageRoot);
31
34
  const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
32
35
  const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
@@ -41,6 +44,7 @@ describe("getWorkspaces", () => {
41
44
  describe("pnpm", () => {
42
45
  it("gets the name and path of the workspaces", () => {
43
46
  const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-pnpm");
47
+ expect((0, implementations_1.getWorkspaceImplementation)(packageRoot, {})).toBe("pnpm");
44
48
  const workspacesPackageInfo = (0, pnpm_1.getPnpmWorkspaces)(packageRoot);
45
49
  const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
46
50
  const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
@@ -50,9 +54,23 @@ describe("getWorkspaces", () => {
50
54
  ]);
51
55
  });
52
56
  });
53
- describe("rush", () => {
57
+ describe("rush + pnpm", () => {
54
58
  it("gets the name and path of the workspaces", () => {
55
59
  const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-rush-pnpm");
60
+ expect((0, implementations_1.getWorkspaceImplementation)(packageRoot, {})).toBe("rush");
61
+ const workspacesPackageInfo = (0, rush_1.getRushWorkspaces)(packageRoot);
62
+ const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
63
+ const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
64
+ expect(workspacesPackageInfo).toMatchObject([
65
+ { name: "package-a", path: packageAPath },
66
+ { name: "package-b", path: packageBPath },
67
+ ]);
68
+ });
69
+ });
70
+ describe("rush + yarn", () => {
71
+ it("gets the name and path of the workspaces", () => {
72
+ const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-rush-yarn");
73
+ expect((0, implementations_1.getWorkspaceImplementation)(packageRoot, {})).toBe("rush");
56
74
  const workspacesPackageInfo = (0, rush_1.getRushWorkspaces)(packageRoot);
57
75
  const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
58
76
  const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
@@ -65,6 +83,7 @@ describe("getWorkspaces", () => {
65
83
  describe("npm", () => {
66
84
  it("gets the name and path of the workspaces", () => {
67
85
  const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-npm");
86
+ expect((0, implementations_1.getWorkspaceImplementation)(packageRoot, {})).toBe("npm");
68
87
  const workspacesPackageInfo = (0, npm_1.getNpmWorkspaces)(packageRoot);
69
88
  const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
70
89
  const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
@@ -75,6 +94,7 @@ describe("getWorkspaces", () => {
75
94
  });
76
95
  it("gets the name and path of the workspaces using the shorthand configuration", () => {
77
96
  const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-shorthand");
97
+ expect((0, implementations_1.getWorkspaceImplementation)(packageRoot, {})).toBe("npm");
78
98
  const workspacesPackageInfo = (0, npm_1.getNpmWorkspaces)(packageRoot);
79
99
  const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
80
100
  const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
@@ -88,7 +108,8 @@ describe("getWorkspaces", () => {
88
108
  });
89
109
  describe("lerna", () => {
90
110
  it("gets the name and path of the workspaces", async () => {
91
- const packageRoot = await (0, setupFixture_1.setupFixture)("monorepo-lerna-npm");
111
+ const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-lerna-npm");
112
+ expect((0, implementations_1.getWorkspaceImplementation)(packageRoot, {})).toBe("lerna");
92
113
  const workspacesPackageInfo = (0, lerna_1.getLernaWorkspaces)(packageRoot);
93
114
  const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
94
115
  const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
@@ -35,6 +35,8 @@ function setupFixture(fixtureName) {
35
35
  fs_extra_1.default.mkdirpSync(cwd);
36
36
  fs_extra_1.default.copySync(fixturePath, cwd);
37
37
  (0, git_1.init)(cwd, "test@test.email", "test user");
38
+ // Ensure GPG signing doesn't interfere with tests
39
+ (0, git_1.gitFailFast)(["config", "commit.gpgsign", "false"], { cwd });
38
40
  // Make the 'main' branch the default in the test repo
39
41
  // ensure that the configuration for this repo does not collide
40
42
  // with any global configuration the user had made, so we have
@@ -3,8 +3,12 @@ export interface ImplementationAndLockFile {
3
3
  implementation: WorkspaceImplementations | undefined;
4
4
  lockFile: string;
5
5
  }
6
- export declare function getWorkspaceImplementationAndLockFile(cwd: string): {
6
+ export declare function getWorkspaceImplementationAndLockFile(cwd: string, cache?: {
7
+ [cwd: string]: ImplementationAndLockFile;
8
+ }): {
7
9
  implementation: WorkspaceImplementations | undefined;
8
10
  lockFile: string;
9
11
  } | undefined;
10
- export declare function getWorkspaceImplementation(cwd: string): WorkspaceImplementations | undefined;
12
+ export declare function getWorkspaceImplementation(cwd: string, cache?: {
13
+ [cwd: string]: ImplementationAndLockFile;
14
+ }): WorkspaceImplementations | undefined;
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getWorkspaceImplementation = exports.getWorkspaceImplementationAndLockFile = void 0;
7
7
  const find_up_1 = __importDefault(require("find-up"));
8
8
  const path_1 = __importDefault(require("path"));
9
- const cache = {};
10
- function getWorkspaceImplementationAndLockFile(cwd) {
9
+ const workspaceCache = {};
10
+ function getWorkspaceImplementationAndLockFile(cwd, cache = workspaceCache) {
11
11
  if (cache[cwd]) {
12
12
  return cache[cwd];
13
13
  }
14
- const lockFile = find_up_1.default.sync(["lerna.json", "yarn.lock", "pnpm-workspace.yaml", "rush.json", "package-lock.json"], {
14
+ const lockFile = find_up_1.default.sync(["lerna.json", "rush.json", "yarn.lock", "pnpm-workspace.yaml", "package-lock.json"], {
15
15
  cwd,
16
16
  });
17
17
  if (!lockFile) {
@@ -52,8 +52,8 @@ function getWorkspaceImplementationAndLockFile(cwd) {
52
52
  return cache[cwd];
53
53
  }
54
54
  exports.getWorkspaceImplementationAndLockFile = getWorkspaceImplementationAndLockFile;
55
- function getWorkspaceImplementation(cwd) {
55
+ function getWorkspaceImplementation(cwd, cache = workspaceCache) {
56
56
  var _a;
57
- return (_a = getWorkspaceImplementationAndLockFile(cwd)) === null || _a === void 0 ? void 0 : _a.implementation;
57
+ return (_a = getWorkspaceImplementationAndLockFile(cwd, cache)) === null || _a === void 0 ? void 0 : _a.implementation;
58
58
  }
59
59
  exports.getWorkspaceImplementation = getWorkspaceImplementation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workspace-tools",
3
- "version": "0.18.2",
3
+ "version": "0.18.3",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",