workspace-tools 0.18.0 → 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 +16 -1
- package/CHANGELOG.md +10 -2
- 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 +12 -12
- package/lib/dependencies.js +1 -0
- package/lib/getPackageInfos.js +10 -4
- package/lib/getPackagePaths.js +1 -0
- package/lib/git.js +30 -23
- package/lib/graph.js +2 -1
- package/lib/helpers/setupFixture.js +6 -5
- package/lib/index.js +28 -19
- package/lib/infoFromPackageJson.js +1 -0
- package/lib/lockfile/index.js +29 -12
- package/lib/lockfile/nameAtVersion.js +1 -0
- package/lib/lockfile/parseNpmLock.js +3 -1
- package/lib/lockfile/parsePnpmLock.js +2 -1
- package/lib/lockfile/queryLockFile.js +2 -1
- 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 +2 -1
- package/lib/workspaces/getWorkspaces.js +2 -1
- package/lib/workspaces/implementations/index.js +1 -0
- package/lib/workspaces/implementations/lerna.js +3 -2
- package/lib/workspaces/implementations/npm.js +3 -2
- package/lib/workspaces/implementations/packageJsonWorkspaces.js +4 -3
- package/lib/workspaces/implementations/pnpm.js +3 -2
- 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 +2 -2
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "workspace-tools",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Fri, 07 Jan 2022
|
|
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",
|
|
6
21
|
"tag": "workspace-tools_v0.18.0",
|
|
7
22
|
"version": "0.18.0",
|
|
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
|
|
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
|
+
|
|
7
15
|
## 0.18.0
|
|
8
16
|
|
|
9
|
-
Fri, 07 Jan 2022 00:04:
|
|
17
|
+
Fri, 07 Jan 2022 00:04:32 GMT
|
|
10
18
|
|
|
11
19
|
### Minor changes
|
|
12
20
|
|
|
@@ -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([
|
|
@@ -9,34 +9,34 @@ const ERROR_MESSAGES = {
|
|
|
9
9
|
describe("parseLockFile()", () => {
|
|
10
10
|
// General
|
|
11
11
|
it("throws if it cannot find lock file", async () => {
|
|
12
|
-
const packageRoot = await setupFixture_1.setupFixture("basic-without-lock-file");
|
|
13
|
-
await expect(lockfile_1.parseLockFile(packageRoot)).rejects.toThrow(ERROR_MESSAGES.NO_LOCK);
|
|
12
|
+
const packageRoot = await (0, setupFixture_1.setupFixture)("basic-without-lock-file");
|
|
13
|
+
await expect((0, lockfile_1.parseLockFile)(packageRoot)).rejects.toThrow(ERROR_MESSAGES.NO_LOCK);
|
|
14
14
|
});
|
|
15
15
|
// NPM
|
|
16
16
|
it("parses package-lock.json file when it is found", async () => {
|
|
17
|
-
const packageRoot = await setupFixture_1.setupFixture("monorepo-npm");
|
|
18
|
-
const parsedLockeFile = await lockfile_1.parseLockFile(packageRoot);
|
|
17
|
+
const packageRoot = await (0, setupFixture_1.setupFixture)("monorepo-npm");
|
|
18
|
+
const parsedLockeFile = await (0, lockfile_1.parseLockFile)(packageRoot);
|
|
19
19
|
expect(parsedLockeFile).toHaveProperty("type", "success");
|
|
20
20
|
});
|
|
21
21
|
it("throws if npm version is unsupported", async () => {
|
|
22
|
-
const packageRoot = await setupFixture_1.setupFixture("monorepo-npm-unsupported");
|
|
23
|
-
await expect(lockfile_1.parseLockFile(packageRoot)).rejects.toThrow(ERROR_MESSAGES.UNSUPPORTED);
|
|
22
|
+
const packageRoot = await (0, setupFixture_1.setupFixture)("monorepo-npm-unsupported");
|
|
23
|
+
await expect((0, lockfile_1.parseLockFile)(packageRoot)).rejects.toThrow(ERROR_MESSAGES.UNSUPPORTED);
|
|
24
24
|
});
|
|
25
25
|
// Yarn
|
|
26
26
|
it("parses yarn.lock file when it is found", async () => {
|
|
27
|
-
const packageRoot = await setupFixture_1.setupFixture("basic");
|
|
28
|
-
const parsedLockeFile = await lockfile_1.parseLockFile(packageRoot);
|
|
27
|
+
const packageRoot = await (0, setupFixture_1.setupFixture)("basic");
|
|
28
|
+
const parsedLockeFile = await (0, lockfile_1.parseLockFile)(packageRoot);
|
|
29
29
|
expect(parsedLockeFile).toHaveProperty("type", "success");
|
|
30
30
|
});
|
|
31
31
|
it("parses combined ranges in yarn.lock", async () => {
|
|
32
|
-
const packageRoot = await setupFixture_1.setupFixture("basic-yarn");
|
|
33
|
-
const parsedLockeFile = await lockfile_1.parseLockFile(packageRoot);
|
|
32
|
+
const packageRoot = await (0, setupFixture_1.setupFixture)("basic-yarn");
|
|
33
|
+
const parsedLockeFile = await (0, lockfile_1.parseLockFile)(packageRoot);
|
|
34
34
|
expect(parsedLockeFile.object["@babel/code-frame@^7.0.0"].version).toBe(parsedLockeFile.object["@babel/code-frame@^7.8.3"].version);
|
|
35
35
|
});
|
|
36
36
|
// PNPM
|
|
37
37
|
it("parses pnpm-lock.yaml file when it is found", async () => {
|
|
38
|
-
const packageRoot = await setupFixture_1.setupFixture("basic-pnpm");
|
|
39
|
-
const parsedLockeFile = await lockfile_1.parseLockFile(packageRoot);
|
|
38
|
+
const packageRoot = await (0, setupFixture_1.setupFixture)("basic-pnpm");
|
|
39
|
+
const parsedLockeFile = await (0, lockfile_1.parseLockFile)(packageRoot);
|
|
40
40
|
expect(Object.keys(parsedLockeFile.object["yargs@16.2.0"].dependencies)).toContain("cliui");
|
|
41
41
|
});
|
|
42
42
|
});
|
package/lib/dependencies.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInternalDeps = exports.getTransitiveDependents = exports.getTransitiveDependencies = exports.getTransitiveProviders = exports.getTransitiveConsumers = exports.getDependentMap = void 0;
|
|
3
4
|
const graphCache = new Map();
|
|
4
5
|
function memoizedKey(packages, scope = []) {
|
|
5
6
|
return JSON.stringify({ packages, scope });
|
package/lib/getPackageInfos.js
CHANGED
|
@@ -3,21 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPackageInfos = void 0;
|
|
6
7
|
const fs_1 = __importDefault(require("fs"));
|
|
7
8
|
const infoFromPackageJson_1 = require("./infoFromPackageJson");
|
|
8
9
|
const workspaces_1 = require("./workspaces/workspaces");
|
|
9
10
|
function getPackageInfos(cwd) {
|
|
10
|
-
const packageJsonFiles = workspaces_1.getAllPackageJsonFiles(cwd);
|
|
11
|
+
const packageJsonFiles = (0, workspaces_1.getAllPackageJsonFiles)(cwd);
|
|
11
12
|
const packageInfos = {};
|
|
12
13
|
if (packageJsonFiles && packageJsonFiles.length > 0) {
|
|
13
14
|
packageJsonFiles.forEach((packageJsonPath) => {
|
|
14
15
|
try {
|
|
15
16
|
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf-8"));
|
|
16
|
-
packageInfos[packageJson.name] = infoFromPackageJson_1.infoFromPackageJson(packageJson, packageJsonPath);
|
|
17
|
+
packageInfos[packageJson.name] = (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath);
|
|
17
18
|
}
|
|
18
19
|
catch (e) {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
if (e instanceof Error) {
|
|
21
|
+
// Pass, the package.json is invalid
|
|
22
|
+
throw new Error(`Invalid package.json file detected ${packageJsonPath}: ${e.message}`);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw e;
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
});
|
|
23
29
|
return packageInfos;
|
package/lib/getPackagePaths.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPackagePaths = void 0;
|
|
6
7
|
const path_1 = __importDefault(require("path"));
|
|
7
8
|
const globby_1 = __importDefault(require("globby"));
|
|
8
9
|
const packagePathsCache = {};
|