workspace-tools 0.16.1 → 0.18.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.
- package/CHANGELOG.json +76 -1
- package/CHANGELOG.md +34 -2
- package/README.md +4 -3
- package/beachball.config.js +9 -0
- package/lib/__tests__/dependencies.test.js +6 -6
- package/lib/__tests__/getChangedPackages.test.js +31 -31
- package/lib/__tests__/getDefaultRemote.test.js +6 -6
- package/lib/__tests__/getInitDefaultBranch.test.js +6 -6
- package/lib/__tests__/getScopedPackages.test.js +9 -9
- package/lib/__tests__/getWorkspaceRoot.test.js +11 -11
- package/lib/__tests__/getWorkspaces.test.js +15 -15
- package/lib/__tests__/lockfile.test.js +28 -11
- package/lib/dependencies.js +1 -0
- package/lib/getPackageInfos.js +10 -4
- package/lib/getPackagePaths.js +19 -18
- package/lib/git.js +44 -22
- package/lib/graph.js +2 -1
- package/lib/helpers/setupFixture.js +10 -10
- package/lib/index.js +28 -19
- package/lib/infoFromPackageJson.js +1 -0
- package/lib/lockfile/index.d.ts +1 -1
- package/lib/lockfile/index.js +54 -15
- package/lib/lockfile/nameAtVersion.js +1 -0
- package/lib/lockfile/parseNpmLock.d.ts +2 -0
- package/lib/lockfile/parseNpmLock.js +11 -0
- package/lib/lockfile/parsePnpmLock.js +2 -1
- package/lib/lockfile/queryLockFile.js +2 -1
- package/lib/lockfile/types.d.ts +31 -0
- package/lib/paths.js +1 -0
- package/lib/scope.js +3 -2
- package/lib/workspaces/findWorkspacePath.js +1 -0
- package/lib/workspaces/getChangedPackages.js +8 -7
- package/lib/workspaces/getWorkspacePackageInfo.js +1 -0
- package/lib/workspaces/getWorkspaceRoot.js +16 -17
- package/lib/workspaces/getWorkspaces.js +16 -17
- package/lib/workspaces/implementations/index.d.ts +9 -1
- package/lib/workspaces/implementations/index.js +48 -20
- package/lib/workspaces/implementations/lerna.js +3 -2
- package/lib/workspaces/implementations/npm.js +4 -3
- package/lib/workspaces/implementations/packageJsonWorkspaces.js +7 -4
- package/lib/workspaces/implementations/pnpm.js +5 -4
- package/lib/workspaces/implementations/rush.js +2 -1
- package/lib/workspaces/implementations/yarn.js +3 -2
- package/lib/workspaces/listOfWorkspacePackageNames.js +1 -0
- package/lib/workspaces/workspaces.js +2 -1
- package/package.json +3 -6
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,82 @@
|
|
|
2
2
|
"name": "workspace-tools",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Fri, 07 Jan 2022 17:07:14 GMT",
|
|
6
|
+
"tag": "workspace-tools_v0.18.1",
|
|
7
|
+
"version": "0.18.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "kchau@microsoft.com",
|
|
12
|
+
"package": "workspace-tools",
|
|
13
|
+
"comment": "bump ts to 4.5 and fixed typing issues with caught errors as unknown",
|
|
14
|
+
"commit": "253384a2c94b5bf41189c6a2b4e5d4478daeaa5e"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Fri, 07 Jan 2022 00:04:32 GMT",
|
|
21
|
+
"tag": "workspace-tools_v0.18.0",
|
|
22
|
+
"version": "0.18.0",
|
|
23
|
+
"comments": {
|
|
24
|
+
"minor": [
|
|
25
|
+
{
|
|
26
|
+
"author": "kchau@microsoft.com",
|
|
27
|
+
"package": "workspace-tools",
|
|
28
|
+
"comment": "speed up workspace-tools - reducing weight and adding caches - lazy load pkg mgr helpers",
|
|
29
|
+
"commit": "6105a8eb81e4972b9ffbdd18669a137f0f5d9400"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"date": "Thu, 02 Dec 2021 17:11:12 GMT",
|
|
36
|
+
"tag": "workspace-tools_v0.17.0",
|
|
37
|
+
"version": "0.17.0",
|
|
38
|
+
"comments": {
|
|
39
|
+
"minor": [
|
|
40
|
+
{
|
|
41
|
+
"author": "riacarmin@microsoft.com",
|
|
42
|
+
"package": "workspace-tools",
|
|
43
|
+
"comment": "Implements NPM workspaces support to parseLockFile utility.",
|
|
44
|
+
"commit": "0d9b3bd5c091e238d302f4a6912692e2eda95385"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"date": "Thu, 21 Oct 2021 20:01:33 GMT",
|
|
51
|
+
"tag": "workspace-tools_v0.16.2",
|
|
52
|
+
"version": "0.16.2",
|
|
53
|
+
"comments": {
|
|
54
|
+
"none": [
|
|
55
|
+
{
|
|
56
|
+
"author": "elcraig@microsoft.com",
|
|
57
|
+
"package": "workspace-tools",
|
|
58
|
+
"comment": "Update beachball and add ignorePatterns",
|
|
59
|
+
"commit": "1aca866df2443581ce221c08b8e783a7054fcd7d"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"date": "Thu, 03 Jun 2021 20:23:22 GMT",
|
|
66
|
+
"tag": "workspace-tools_v0.16.2",
|
|
67
|
+
"version": "0.16.2",
|
|
68
|
+
"comments": {
|
|
69
|
+
"patch": [
|
|
70
|
+
{
|
|
71
|
+
"comment": "get the right default remote branch",
|
|
72
|
+
"author": "kchau@microsoft.com",
|
|
73
|
+
"commit": "cb3c26d432f838805190f9afb65181f682c0145a",
|
|
74
|
+
"package": "workspace-tools"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"date": "Thu, 27 May 2021 20:04:05 GMT",
|
|
6
81
|
"tag": "workspace-tools_v0.16.1",
|
|
7
82
|
"version": "0.16.1",
|
|
8
83
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
# Change Log - workspace-tools
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 07 Jan 2022 17:07:14 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.18.1
|
|
8
|
+
|
|
9
|
+
Fri, 07 Jan 2022 17:07:14 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- bump ts to 4.5 and fixed typing issues with caught errors as unknown (kchau@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 0.18.0
|
|
16
|
+
|
|
17
|
+
Fri, 07 Jan 2022 00:04:32 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- speed up workspace-tools - reducing weight and adding caches - lazy load pkg mgr helpers (kchau@microsoft.com)
|
|
22
|
+
|
|
23
|
+
## 0.17.0
|
|
24
|
+
|
|
25
|
+
Thu, 02 Dec 2021 17:11:12 GMT
|
|
26
|
+
|
|
27
|
+
### Minor changes
|
|
28
|
+
|
|
29
|
+
- Implements NPM workspaces support to parseLockFile utility. (riacarmin@microsoft.com)
|
|
30
|
+
|
|
31
|
+
## 0.16.2
|
|
32
|
+
|
|
33
|
+
Thu, 03 Jun 2021 20:23:22 GMT
|
|
34
|
+
|
|
35
|
+
### Patches
|
|
36
|
+
|
|
37
|
+
- get the right default remote branch (kchau@microsoft.com)
|
|
38
|
+
|
|
7
39
|
## 0.16.1
|
|
8
40
|
|
|
9
|
-
Thu, 27 May 2021 20:04:
|
|
41
|
+
Thu, 27 May 2021 20:04:05 GMT
|
|
10
42
|
|
|
11
43
|
### Patches
|
|
12
44
|
|
package/README.md
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
A collection of tools that are useful in a git-controlled monorepo that is managed by one of these software:
|
|
4
4
|
|
|
5
|
+
- lerna
|
|
6
|
+
- npm workspaces
|
|
7
|
+
- pnpm workspaces
|
|
5
8
|
- rush
|
|
6
9
|
- yarn workspaces
|
|
7
|
-
- pnpm workspaces
|
|
8
|
-
- lerna
|
|
9
10
|
|
|
10
11
|
# Environment Variables
|
|
11
12
|
|
|
@@ -17,7 +18,7 @@ default node.js maxBuffer of 1MB)
|
|
|
17
18
|
## PREFERRED_WORKSPACE_MANAGER
|
|
18
19
|
|
|
19
20
|
Sometimes multiple package manager files are checked in. It is necessary to hint to `workspace-tools` which manager
|
|
20
|
-
is used: `yarn`, `pnpm`, `rush`, or `lerna`
|
|
21
|
+
is used: `npm`, `yarn`, `pnpm`, `rush`, or `lerna`
|
|
21
22
|
|
|
22
23
|
# Contributing
|
|
23
24
|
|
package/beachball.config.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
scope: ["!src/__fixtures__/**/*"],
|
|
3
|
+
ignorePatterns: [
|
|
4
|
+
".github/**",
|
|
5
|
+
".prettierrc",
|
|
6
|
+
"jest.config.js",
|
|
7
|
+
"src/__fixtures__/**",
|
|
8
|
+
"src/__tests__/**",
|
|
9
|
+
// This prevents dependabot from being blocked by change file requirements for lock file-only changes
|
|
10
|
+
"yarn.lock",
|
|
11
|
+
],
|
|
3
12
|
};
|
|
@@ -8,7 +8,7 @@ describe("getTransitiveConsumers", () => {
|
|
|
8
8
|
b: stubPackage("b", ["c"]),
|
|
9
9
|
c: stubPackage("c"),
|
|
10
10
|
};
|
|
11
|
-
const actual = dependencies_1.getTransitiveConsumers(["c"], allPackages);
|
|
11
|
+
const actual = (0, dependencies_1.getTransitiveConsumers)(["c"], allPackages);
|
|
12
12
|
expect(actual).toContain("a");
|
|
13
13
|
expect(actual).toContain("b");
|
|
14
14
|
});
|
|
@@ -21,7 +21,7 @@ describe("getTransitiveConsumers", () => {
|
|
|
21
21
|
core: stubPackage("core"),
|
|
22
22
|
demo: stubPackage("demo", ["grid", "word"]),
|
|
23
23
|
};
|
|
24
|
-
const actual = dependencies_1.getTransitiveConsumers(["core"], allPackages, [
|
|
24
|
+
const actual = (0, dependencies_1.getTransitiveConsumers)(["core"], allPackages, [
|
|
25
25
|
"grid",
|
|
26
26
|
"word",
|
|
27
27
|
]);
|
|
@@ -51,7 +51,7 @@ describe("getTransitiveConsumers", () => {
|
|
|
51
51
|
f: stubPackage("f"),
|
|
52
52
|
g: stubPackage("g", ["c"]),
|
|
53
53
|
};
|
|
54
|
-
const actual = dependencies_1.getTransitiveConsumers(["c"], allPackages);
|
|
54
|
+
const actual = (0, dependencies_1.getTransitiveConsumers)(["c"], allPackages);
|
|
55
55
|
expect(actual).toContain("a");
|
|
56
56
|
expect(actual).toContain("b");
|
|
57
57
|
expect(actual).toContain("g");
|
|
@@ -68,7 +68,7 @@ describe("getTransitiveProviders", () => {
|
|
|
68
68
|
b: stubPackage("b", ["c"]),
|
|
69
69
|
c: stubPackage("c"),
|
|
70
70
|
};
|
|
71
|
-
const actual = dependencies_1.getTransitiveProviders(["a"], allPackages);
|
|
71
|
+
const actual = (0, dependencies_1.getTransitiveProviders)(["a"], allPackages);
|
|
72
72
|
expect(actual).toContain("b");
|
|
73
73
|
expect(actual).toContain("c");
|
|
74
74
|
});
|
|
@@ -92,7 +92,7 @@ describe("getTransitiveProviders", () => {
|
|
|
92
92
|
f: stubPackage("f", ["g"]),
|
|
93
93
|
g: stubPackage("g"),
|
|
94
94
|
};
|
|
95
|
-
const actual = dependencies_1.getTransitiveProviders(["c"], allPackages);
|
|
95
|
+
const actual = (0, dependencies_1.getTransitiveProviders)(["c"], allPackages);
|
|
96
96
|
expect(actual).toContain("e");
|
|
97
97
|
expect(actual).toContain("f");
|
|
98
98
|
expect(actual).toContain("g");
|
|
@@ -123,7 +123,7 @@ describe("getTransitiveProviders", () => {
|
|
|
123
123
|
h: stubPackage("h", ["i"]),
|
|
124
124
|
i: stubPackage("i", ["f"]),
|
|
125
125
|
};
|
|
126
|
-
const actual = dependencies_1.getTransitiveConsumers(["f"], allPackages, ["b"]);
|
|
126
|
+
const actual = (0, dependencies_1.getTransitiveConsumers)(["f"], allPackages, ["b"]);
|
|
127
127
|
expect(actual).toContain("e");
|
|
128
128
|
expect(actual).toContain("c");
|
|
129
129
|
expect(actual).toContain("b");
|
|
@@ -10,115 +10,115 @@ const git_1 = require("../git");
|
|
|
10
10
|
const getChangedPackages_1 = require("../workspaces/getChangedPackages");
|
|
11
11
|
describe("getChangedPackages()", () => {
|
|
12
12
|
afterAll(() => {
|
|
13
|
-
setupFixture_1.cleanupFixtures();
|
|
13
|
+
(0, setupFixture_1.cleanupFixtures)();
|
|
14
14
|
});
|
|
15
15
|
it("can detect changes inside an untracked file", () => {
|
|
16
16
|
// arrange
|
|
17
|
-
const root = setupFixture_1.setupFixture("monorepo");
|
|
17
|
+
const root = (0, setupFixture_1.setupFixture)("monorepo");
|
|
18
18
|
const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
|
|
19
19
|
fs_1.default.writeFileSync(newFile, "hello foo test");
|
|
20
20
|
// act
|
|
21
|
-
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
|
|
21
|
+
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
|
|
22
22
|
// assert
|
|
23
23
|
expect(changedPkgs).toContain("package-a");
|
|
24
24
|
});
|
|
25
25
|
it("can detect changes inside an untracked file in a nested monorepo", () => {
|
|
26
26
|
// arrange
|
|
27
|
-
const root = path_1.default.join(setupFixture_1.setupFixture("monorepo-nested"), "monorepo");
|
|
27
|
+
const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo");
|
|
28
28
|
const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
|
|
29
29
|
fs_1.default.writeFileSync(newFile, "hello foo test");
|
|
30
30
|
// act
|
|
31
|
-
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
|
|
31
|
+
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
|
|
32
32
|
// assert
|
|
33
33
|
expect(changedPkgs).toEqual(["package-a"]);
|
|
34
34
|
});
|
|
35
35
|
it("can detect changes inside an unstaged file", () => {
|
|
36
36
|
// arrange
|
|
37
|
-
const root = setupFixture_1.setupFixture("monorepo");
|
|
37
|
+
const root = (0, setupFixture_1.setupFixture)("monorepo");
|
|
38
38
|
const newFile = path_1.default.join(root, "packages/package-a/src/index.ts");
|
|
39
39
|
fs_1.default.writeFileSync(newFile, "hello foo test");
|
|
40
40
|
// act
|
|
41
|
-
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
|
|
41
|
+
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
|
|
42
42
|
// assert
|
|
43
43
|
expect(changedPkgs).toContain("package-a");
|
|
44
44
|
});
|
|
45
45
|
it("can detect changes inside an unstaged file in a nested monorepo", () => {
|
|
46
46
|
// arrange
|
|
47
|
-
const root = path_1.default.join(setupFixture_1.setupFixture("monorepo-nested"), "monorepo");
|
|
47
|
+
const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo");
|
|
48
48
|
const newFile = path_1.default.join(root, "packages/package-a/src/index.ts");
|
|
49
49
|
fs_1.default.writeFileSync(newFile, "hello foo test");
|
|
50
50
|
// act
|
|
51
|
-
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
|
|
51
|
+
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
|
|
52
52
|
// assert
|
|
53
53
|
expect(changedPkgs).toEqual(["package-a"]);
|
|
54
54
|
});
|
|
55
55
|
it("can detect changes inside a staged file", () => {
|
|
56
56
|
// arrange
|
|
57
|
-
const root = setupFixture_1.setupFixture("monorepo");
|
|
57
|
+
const root = (0, setupFixture_1.setupFixture)("monorepo");
|
|
58
58
|
const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
|
|
59
59
|
fs_1.default.writeFileSync(newFile, "hello foo test");
|
|
60
|
-
git_1.git(["add", newFile], { cwd: root });
|
|
60
|
+
(0, git_1.git)(["add", newFile], { cwd: root });
|
|
61
61
|
// act
|
|
62
|
-
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
|
|
62
|
+
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
|
|
63
63
|
// assert
|
|
64
64
|
expect(changedPkgs).toContain("package-a");
|
|
65
65
|
});
|
|
66
66
|
it("can detect changes inside a staged file in a nested monorepo", () => {
|
|
67
67
|
// arrange
|
|
68
|
-
const root = path_1.default.join(setupFixture_1.setupFixture("monorepo-nested"), "monorepo");
|
|
68
|
+
const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo");
|
|
69
69
|
const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
|
|
70
70
|
fs_1.default.writeFileSync(newFile, "hello foo test");
|
|
71
|
-
git_1.git(["add", newFile], { cwd: root });
|
|
71
|
+
(0, git_1.git)(["add", newFile], { cwd: root });
|
|
72
72
|
// act
|
|
73
|
-
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
|
|
73
|
+
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
|
|
74
74
|
// assert
|
|
75
75
|
expect(changedPkgs).toEqual(["package-a"]);
|
|
76
76
|
});
|
|
77
77
|
it("can detect changes inside a file that has been committed in a different branch", () => {
|
|
78
78
|
// arrange
|
|
79
|
-
const root = setupFixture_1.setupFixture("monorepo");
|
|
79
|
+
const root = (0, setupFixture_1.setupFixture)("monorepo");
|
|
80
80
|
const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
|
|
81
81
|
fs_1.default.writeFileSync(newFile, "hello foo test");
|
|
82
|
-
git_1.git(["checkout", "-b", "newbranch"], { cwd: root });
|
|
83
|
-
git_1.stageAndCommit(["add", newFile], "test commit", root);
|
|
82
|
+
(0, git_1.git)(["checkout", "-b", "newbranch"], { cwd: root });
|
|
83
|
+
(0, git_1.stageAndCommit)(["add", newFile], "test commit", root);
|
|
84
84
|
// act
|
|
85
|
-
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
|
|
85
|
+
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
|
|
86
86
|
// assert
|
|
87
87
|
expect(changedPkgs).toContain("package-a");
|
|
88
88
|
});
|
|
89
89
|
it("can detect changes inside a file that has been committed in a different branch in a nested monorepo", () => {
|
|
90
90
|
// arrange
|
|
91
|
-
const root = path_1.default.join(setupFixture_1.setupFixture("monorepo-nested"), "monorepo");
|
|
91
|
+
const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo");
|
|
92
92
|
const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
|
|
93
93
|
fs_1.default.writeFileSync(newFile, "hello foo test");
|
|
94
|
-
git_1.git(["checkout", "-b", "newbranch"], { cwd: root });
|
|
95
|
-
git_1.stageAndCommit(["add", newFile], "test commit", root);
|
|
94
|
+
(0, git_1.git)(["checkout", "-b", "newbranch"], { cwd: root });
|
|
95
|
+
(0, git_1.stageAndCommit)(["add", newFile], "test commit", root);
|
|
96
96
|
// act
|
|
97
|
-
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main");
|
|
97
|
+
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
|
|
98
98
|
// assert
|
|
99
99
|
expect(changedPkgs).toEqual(["package-a"]);
|
|
100
100
|
});
|
|
101
101
|
it("can detect changes inside a file that has been committed in a different branch using default remote", () => {
|
|
102
102
|
// arrange
|
|
103
|
-
const root = setupFixture_1.setupFixture("monorepo");
|
|
104
|
-
setupFixture_1.setupLocalRemote(root, "origin", "basic");
|
|
103
|
+
const root = (0, setupFixture_1.setupFixture)("monorepo");
|
|
104
|
+
(0, setupFixture_1.setupLocalRemote)(root, "origin", "basic");
|
|
105
105
|
const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
|
|
106
106
|
fs_1.default.writeFileSync(newFile, "hello foo test");
|
|
107
|
-
git_1.git(["checkout", "-b", "newbranch"], { cwd: root });
|
|
108
|
-
git_1.stageAndCommit(["add", newFile], "test commit", root);
|
|
107
|
+
(0, git_1.git)(["checkout", "-b", "newbranch"], { cwd: root });
|
|
108
|
+
(0, git_1.stageAndCommit)(["add", newFile], "test commit", root);
|
|
109
109
|
// act
|
|
110
|
-
const changedPkgs = getChangedPackages_1.getChangedPackages(root, undefined);
|
|
110
|
+
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, undefined);
|
|
111
111
|
// assert
|
|
112
112
|
expect(changedPkgs).toContain("package-a");
|
|
113
113
|
});
|
|
114
114
|
it("can ignore glob patterns in detecting changes", () => {
|
|
115
115
|
// arrange
|
|
116
|
-
const root = setupFixture_1.setupFixture("monorepo");
|
|
116
|
+
const root = (0, setupFixture_1.setupFixture)("monorepo");
|
|
117
117
|
const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
|
|
118
118
|
fs_1.default.writeFileSync(newFile, "hello foo test");
|
|
119
|
-
git_1.git(["add", newFile], { cwd: root });
|
|
119
|
+
(0, git_1.git)(["add", newFile], { cwd: root });
|
|
120
120
|
// act
|
|
121
|
-
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main", ["packages/package-a/*"]);
|
|
121
|
+
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main", ["packages/package-a/*"]);
|
|
122
122
|
// assert
|
|
123
123
|
expect(changedPkgs).toEqual([]);
|
|
124
124
|
});
|
|
@@ -4,22 +4,22 @@ const setupFixture_1 = require("../helpers/setupFixture");
|
|
|
4
4
|
const git_1 = require("../git");
|
|
5
5
|
describe("getDefaultRemote()", () => {
|
|
6
6
|
afterAll(() => {
|
|
7
|
-
setupFixture_1.cleanupFixtures();
|
|
7
|
+
(0, setupFixture_1.cleanupFixtures)();
|
|
8
8
|
});
|
|
9
9
|
it("is origin in the default test repo", () => {
|
|
10
10
|
// arrange
|
|
11
|
-
const cwd = setupFixture_1.setupFixture("basic");
|
|
11
|
+
const cwd = (0, setupFixture_1.setupFixture)("basic");
|
|
12
12
|
// act
|
|
13
|
-
const remote = git_1.getDefaultRemote(cwd);
|
|
13
|
+
const remote = (0, git_1.getDefaultRemote)(cwd);
|
|
14
14
|
// assert
|
|
15
15
|
expect(remote).toBe("origin");
|
|
16
16
|
});
|
|
17
17
|
it("is myMain when default branch is different", () => {
|
|
18
18
|
// arrange
|
|
19
|
-
const cwd = setupFixture_1.setupFixture("basic");
|
|
20
|
-
setupFixture_1.setupLocalRemote(cwd, "myRemote", "basic");
|
|
19
|
+
const cwd = (0, setupFixture_1.setupFixture)("basic");
|
|
20
|
+
(0, setupFixture_1.setupLocalRemote)(cwd, "myRemote", "basic");
|
|
21
21
|
// act
|
|
22
|
-
const remote = git_1.getDefaultRemote(cwd);
|
|
22
|
+
const remote = (0, git_1.getDefaultRemote)(cwd);
|
|
23
23
|
// assert
|
|
24
24
|
expect(remote).toBe("myRemote");
|
|
25
25
|
});
|
|
@@ -4,22 +4,22 @@ const setupFixture_1 = require("../helpers/setupFixture");
|
|
|
4
4
|
const git_1 = require("../git");
|
|
5
5
|
describe("getDefaultBranch()", () => {
|
|
6
6
|
afterAll(() => {
|
|
7
|
-
setupFixture_1.cleanupFixtures();
|
|
7
|
+
(0, setupFixture_1.cleanupFixtures)();
|
|
8
8
|
});
|
|
9
9
|
it("is main in the default test repo", () => {
|
|
10
10
|
// arrange
|
|
11
|
-
const cwd = setupFixture_1.setupFixture("basic");
|
|
11
|
+
const cwd = (0, setupFixture_1.setupFixture)("basic");
|
|
12
12
|
// act
|
|
13
|
-
const branch = git_1.getDefaultBranch(cwd);
|
|
13
|
+
const branch = (0, git_1.getDefaultBranch)(cwd);
|
|
14
14
|
// assert
|
|
15
15
|
expect(branch).toBe("main");
|
|
16
16
|
});
|
|
17
17
|
it("is myMain when default branch is different", () => {
|
|
18
18
|
// arrange
|
|
19
|
-
const cwd = setupFixture_1.setupFixture("basic");
|
|
20
|
-
git_1.git(['config', 'init.defaultBranch', 'myMain'], { cwd });
|
|
19
|
+
const cwd = (0, setupFixture_1.setupFixture)("basic");
|
|
20
|
+
(0, git_1.git)(['config', 'init.defaultBranch', 'myMain'], { cwd });
|
|
21
21
|
// act
|
|
22
|
-
const branch = git_1.getDefaultBranch(cwd);
|
|
22
|
+
const branch = (0, git_1.getDefaultBranch)(cwd);
|
|
23
23
|
// assert
|
|
24
24
|
expect(branch).toBe("myMain");
|
|
25
25
|
});
|
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const scope_1 = require("../scope");
|
|
4
4
|
describe("getScopedPackages", () => {
|
|
5
5
|
it("can match scopes for full matches for an array", () => {
|
|
6
|
-
const results = scope_1.getScopedPackages(["foo", "bar"], ["foo", "bar", "baz"]);
|
|
6
|
+
const results = (0, scope_1.getScopedPackages)(["foo", "bar"], ["foo", "bar", "baz"]);
|
|
7
7
|
expect(results).toContain("foo");
|
|
8
8
|
expect(results).toContain("bar");
|
|
9
9
|
expect(results).not.toContain("baz");
|
|
10
10
|
});
|
|
11
11
|
it("can match scopes for full matches for a map", () => {
|
|
12
|
-
const results = scope_1.getScopedPackages(["foo", "bar"], {
|
|
12
|
+
const results = (0, scope_1.getScopedPackages)(["foo", "bar"], {
|
|
13
13
|
foo: {},
|
|
14
14
|
bar: {},
|
|
15
15
|
baz: {},
|
|
@@ -19,7 +19,7 @@ describe("getScopedPackages", () => {
|
|
|
19
19
|
expect(results).not.toContain("baz");
|
|
20
20
|
});
|
|
21
21
|
it("can match scopes for full matches for a map of PackageInfos", () => {
|
|
22
|
-
const results = scope_1.getScopedPackages(["foo", "bar"], {
|
|
22
|
+
const results = (0, scope_1.getScopedPackages)(["foo", "bar"], {
|
|
23
23
|
foo: { name: "foo", packageJsonPath: "nowhere", version: "1.0.0" },
|
|
24
24
|
bar: { name: "bar", packageJsonPath: "nowhere", version: "1.0.0" },
|
|
25
25
|
baz: { name: "baz", packageJsonPath: "nowhere", version: "1.0.0" },
|
|
@@ -29,34 +29,34 @@ describe("getScopedPackages", () => {
|
|
|
29
29
|
expect(results).not.toContain("baz");
|
|
30
30
|
});
|
|
31
31
|
it("can match with wildcards", () => {
|
|
32
|
-
const results = scope_1.getScopedPackages(["foo*"], ["foo1", "foo2", "baz"]);
|
|
32
|
+
const results = (0, scope_1.getScopedPackages)(["foo*"], ["foo1", "foo2", "baz"]);
|
|
33
33
|
expect(results).toContain("foo1");
|
|
34
34
|
expect(results).toContain("foo2");
|
|
35
35
|
expect(results).not.toContain("baz");
|
|
36
36
|
});
|
|
37
37
|
it("can match with npm package scopes", () => {
|
|
38
|
-
const results = scope_1.getScopedPackages(["foo"], ["@yay/foo", "@yay1/foo", "foo", "baz"]);
|
|
38
|
+
const results = (0, scope_1.getScopedPackages)(["foo"], ["@yay/foo", "@yay1/foo", "foo", "baz"]);
|
|
39
39
|
expect(results).toContain("@yay/foo");
|
|
40
40
|
expect(results).toContain("@yay1/foo");
|
|
41
41
|
expect(results).toContain("foo");
|
|
42
42
|
expect(results).not.toContain("baz");
|
|
43
43
|
});
|
|
44
44
|
it("can match with npm package scopes with wildcards", () => {
|
|
45
|
-
const results = scope_1.getScopedPackages(["foo*"], ["@yay/foo1", "@yay1/foo2", "foo", "baz"]);
|
|
45
|
+
const results = (0, scope_1.getScopedPackages)(["foo*"], ["@yay/foo1", "@yay1/foo2", "foo", "baz"]);
|
|
46
46
|
expect(results).toContain("@yay/foo1");
|
|
47
47
|
expect(results).toContain("@yay1/foo2");
|
|
48
48
|
expect(results).toContain("foo");
|
|
49
49
|
expect(results).not.toContain("baz");
|
|
50
50
|
});
|
|
51
51
|
it("uses the correct package scope when the search pattern starts a @ character", () => {
|
|
52
|
-
const results = scope_1.getScopedPackages(["@yay/foo*"], ["@yay/foo1", "@yay1/foo2", "foo", "baz"]);
|
|
52
|
+
const results = (0, scope_1.getScopedPackages)(["@yay/foo*"], ["@yay/foo1", "@yay1/foo2", "foo", "baz"]);
|
|
53
53
|
expect(results).toContain("@yay/foo1");
|
|
54
54
|
expect(results).not.toContain("@yay1/foo2");
|
|
55
55
|
expect(results).not.toContain("foo");
|
|
56
56
|
expect(results).not.toContain("baz");
|
|
57
57
|
});
|
|
58
58
|
it("can deal with brace expansion with scopes", () => {
|
|
59
|
-
const results = scope_1.getScopedPackages(["@yay/foo{1,2}"], ["@yay/foo1", "@yay/foo2", "@yay/foo3", "foo", "baz"]);
|
|
59
|
+
const results = (0, scope_1.getScopedPackages)(["@yay/foo{1,2}"], ["@yay/foo1", "@yay/foo2", "@yay/foo3", "foo", "baz"]);
|
|
60
60
|
expect(results).toContain("@yay/foo1");
|
|
61
61
|
expect(results).toContain("@yay/foo2");
|
|
62
62
|
expect(results).not.toContain("@yay/foo3");
|
|
@@ -64,7 +64,7 @@ describe("getScopedPackages", () => {
|
|
|
64
64
|
expect(results).not.toContain("baz");
|
|
65
65
|
});
|
|
66
66
|
it("can deal with negated search", () => {
|
|
67
|
-
const results = scope_1.getScopedPackages(["@yay/foo*", "!@yay/foo3"], ["@yay/foo1", "@yay/foo2", "@yay/foo3", "foo", "baz"]);
|
|
67
|
+
const results = (0, scope_1.getScopedPackages)(["@yay/foo*", "!@yay/foo3"], ["@yay/foo1", "@yay/foo2", "@yay/foo3", "foo", "baz"]);
|
|
68
68
|
expect(results).toContain("@yay/foo1");
|
|
69
69
|
expect(results).toContain("@yay/foo2");
|
|
70
70
|
expect(results).not.toContain("@yay/foo3");
|
|
@@ -8,33 +8,33 @@ const npm_1 = require("../workspaces/implementations/npm");
|
|
|
8
8
|
const lerna_1 = require("../workspaces/implementations/lerna");
|
|
9
9
|
describe("getWorkspaceRoot", () => {
|
|
10
10
|
afterAll(() => {
|
|
11
|
-
setupFixture_1.cleanupFixtures();
|
|
11
|
+
(0, setupFixture_1.cleanupFixtures)();
|
|
12
12
|
});
|
|
13
13
|
it("handles yarn workspace", () => {
|
|
14
|
-
const repoRoot = setupFixture_1.setupFixture("monorepo");
|
|
15
|
-
const workspaceRoot = yarn_1.getYarnWorkspaceRoot(repoRoot);
|
|
14
|
+
const repoRoot = (0, setupFixture_1.setupFixture)("monorepo");
|
|
15
|
+
const workspaceRoot = (0, yarn_1.getYarnWorkspaceRoot)(repoRoot);
|
|
16
16
|
expect(workspaceRoot).toBe(repoRoot);
|
|
17
17
|
});
|
|
18
18
|
it("handles pnpm workspace", () => {
|
|
19
|
-
const repoRoot = setupFixture_1.setupFixture("monorepo-pnpm");
|
|
20
|
-
const workspaceRoot = pnpm_1.getPnpmWorkspaceRoot(repoRoot);
|
|
19
|
+
const repoRoot = (0, setupFixture_1.setupFixture)("monorepo-pnpm");
|
|
20
|
+
const workspaceRoot = (0, pnpm_1.getPnpmWorkspaceRoot)(repoRoot);
|
|
21
21
|
expect(workspaceRoot).toBe(repoRoot);
|
|
22
22
|
});
|
|
23
23
|
it("handles rush workspace", () => {
|
|
24
|
-
const repoRoot = setupFixture_1.setupFixture("monorepo-rush-pnpm");
|
|
25
|
-
const workspaceRoot = rush_1.getRushWorkspaceRoot(repoRoot);
|
|
24
|
+
const repoRoot = (0, setupFixture_1.setupFixture)("monorepo-rush-pnpm");
|
|
25
|
+
const workspaceRoot = (0, rush_1.getRushWorkspaceRoot)(repoRoot);
|
|
26
26
|
expect(workspaceRoot).toBe(repoRoot);
|
|
27
27
|
});
|
|
28
28
|
it("handles npm workspace", () => {
|
|
29
|
-
const repoRoot = setupFixture_1.setupFixture("monorepo-npm");
|
|
30
|
-
const workspaceRoot = npm_1.getNpmWorkspaceRoot(repoRoot);
|
|
29
|
+
const repoRoot = (0, setupFixture_1.setupFixture)("monorepo-npm");
|
|
30
|
+
const workspaceRoot = (0, npm_1.getNpmWorkspaceRoot)(repoRoot);
|
|
31
31
|
expect(workspaceRoot).toBe(repoRoot);
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
describe("getLernaWorkspaceRoot()", () => {
|
|
35
35
|
it("gets the root of the workspace", async () => {
|
|
36
|
-
const repoRoot = await setupFixture_1.setupFixture("monorepo-lerna-npm");
|
|
37
|
-
const workspaceRoot = lerna_1.getLernaWorkspaceRoot(repoRoot);
|
|
36
|
+
const repoRoot = await (0, setupFixture_1.setupFixture)("monorepo-lerna-npm");
|
|
37
|
+
const workspaceRoot = (0, lerna_1.getLernaWorkspaceRoot)(repoRoot);
|
|
38
38
|
expect(workspaceRoot).toBe(repoRoot);
|
|
39
39
|
});
|
|
40
40
|
});
|
|
@@ -12,12 +12,12 @@ const npm_1 = require("../workspaces/implementations/npm");
|
|
|
12
12
|
const lerna_1 = require("../workspaces/implementations/lerna");
|
|
13
13
|
describe("getWorkspaces", () => {
|
|
14
14
|
afterAll(() => {
|
|
15
|
-
setupFixture_1.cleanupFixtures();
|
|
15
|
+
(0, setupFixture_1.cleanupFixtures)();
|
|
16
16
|
});
|
|
17
17
|
describe("yarn", () => {
|
|
18
18
|
it("gets the name and path of the workspaces", () => {
|
|
19
|
-
const packageRoot = setupFixture_1.setupFixture("monorepo");
|
|
20
|
-
const workspacesPackageInfo = yarn_1.getYarnWorkspaces(packageRoot);
|
|
19
|
+
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo");
|
|
20
|
+
const workspacesPackageInfo = (0, yarn_1.getYarnWorkspaces)(packageRoot);
|
|
21
21
|
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
|
|
22
22
|
const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
|
|
23
23
|
expect(workspacesPackageInfo).toMatchObject([
|
|
@@ -26,8 +26,8 @@ describe("getWorkspaces", () => {
|
|
|
26
26
|
]);
|
|
27
27
|
});
|
|
28
28
|
it("gets the name and path of the workspaces against a packages spec of an individual package", () => {
|
|
29
|
-
const packageRoot = setupFixture_1.setupFixture("monorepo-globby");
|
|
30
|
-
const workspacesPackageInfo = yarn_1.getYarnWorkspaces(packageRoot);
|
|
29
|
+
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-globby");
|
|
30
|
+
const workspacesPackageInfo = (0, yarn_1.getYarnWorkspaces)(packageRoot);
|
|
31
31
|
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
|
|
32
32
|
const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
|
|
33
33
|
const individualPath = path_1.default.join(packageRoot, "packages", "individual");
|
|
@@ -40,8 +40,8 @@ describe("getWorkspaces", () => {
|
|
|
40
40
|
});
|
|
41
41
|
describe("pnpm", () => {
|
|
42
42
|
it("gets the name and path of the workspaces", () => {
|
|
43
|
-
const packageRoot = setupFixture_1.setupFixture("monorepo-pnpm");
|
|
44
|
-
const workspacesPackageInfo = pnpm_1.getPnpmWorkspaces(packageRoot);
|
|
43
|
+
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-pnpm");
|
|
44
|
+
const workspacesPackageInfo = (0, pnpm_1.getPnpmWorkspaces)(packageRoot);
|
|
45
45
|
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
|
|
46
46
|
const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
|
|
47
47
|
expect(workspacesPackageInfo).toMatchObject([
|
|
@@ -52,8 +52,8 @@ describe("getWorkspaces", () => {
|
|
|
52
52
|
});
|
|
53
53
|
describe("rush", () => {
|
|
54
54
|
it("gets the name and path of the workspaces", () => {
|
|
55
|
-
const packageRoot = setupFixture_1.setupFixture("monorepo-rush-pnpm");
|
|
56
|
-
const workspacesPackageInfo = rush_1.getRushWorkspaces(packageRoot);
|
|
55
|
+
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-rush-pnpm");
|
|
56
|
+
const workspacesPackageInfo = (0, rush_1.getRushWorkspaces)(packageRoot);
|
|
57
57
|
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
|
|
58
58
|
const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
|
|
59
59
|
expect(workspacesPackageInfo).toMatchObject([
|
|
@@ -64,8 +64,8 @@ describe("getWorkspaces", () => {
|
|
|
64
64
|
});
|
|
65
65
|
describe("npm", () => {
|
|
66
66
|
it("gets the name and path of the workspaces", () => {
|
|
67
|
-
const packageRoot = setupFixture_1.setupFixture("monorepo-npm");
|
|
68
|
-
const workspacesPackageInfo = npm_1.getNpmWorkspaces(packageRoot);
|
|
67
|
+
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-npm");
|
|
68
|
+
const workspacesPackageInfo = (0, npm_1.getNpmWorkspaces)(packageRoot);
|
|
69
69
|
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
|
|
70
70
|
const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
|
|
71
71
|
expect(workspacesPackageInfo).toMatchObject([
|
|
@@ -74,8 +74,8 @@ describe("getWorkspaces", () => {
|
|
|
74
74
|
]);
|
|
75
75
|
});
|
|
76
76
|
it("gets the name and path of the workspaces using the shorthand configuration", () => {
|
|
77
|
-
const packageRoot = setupFixture_1.setupFixture("monorepo-shorthand");
|
|
78
|
-
const workspacesPackageInfo = npm_1.getNpmWorkspaces(packageRoot);
|
|
77
|
+
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-shorthand");
|
|
78
|
+
const workspacesPackageInfo = (0, npm_1.getNpmWorkspaces)(packageRoot);
|
|
79
79
|
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
|
|
80
80
|
const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
|
|
81
81
|
const individualPath = path_1.default.join(packageRoot, "individual");
|
|
@@ -88,8 +88,8 @@ describe("getWorkspaces", () => {
|
|
|
88
88
|
});
|
|
89
89
|
describe("lerna", () => {
|
|
90
90
|
it("gets the name and path of the workspaces", async () => {
|
|
91
|
-
const packageRoot = await setupFixture_1.setupFixture("monorepo-lerna-npm");
|
|
92
|
-
const workspacesPackageInfo = lerna_1.getLernaWorkspaces(packageRoot);
|
|
91
|
+
const packageRoot = await (0, setupFixture_1.setupFixture)("monorepo-lerna-npm");
|
|
92
|
+
const workspacesPackageInfo = (0, lerna_1.getLernaWorkspaces)(packageRoot);
|
|
93
93
|
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a");
|
|
94
94
|
const packageBPath = path_1.default.join(packageRoot, "packages", "package-b");
|
|
95
95
|
expect(workspacesPackageInfo).toMatchObject([
|