workspace-tools 0.21.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.json +54 -1
  2. package/CHANGELOG.md +30 -2
  3. package/lib/dependencies/index.d.ts +12 -0
  4. package/lib/dependencies/index.js +14 -0
  5. package/lib/{dependencies.d.ts → dependencies/transitiveDeps.d.ts} +1 -7
  6. package/lib/{dependencies.js → dependencies/transitiveDeps.js} +3 -12
  7. package/lib/{createDependencyMap.d.ts → graph/createDependencyMap.d.ts} +3 -5
  8. package/lib/{createDependencyMap.js → graph/createDependencyMap.js} +3 -2
  9. package/lib/graph/createPackageGraph.d.ts +10 -0
  10. package/lib/graph/createPackageGraph.js +122 -0
  11. package/lib/graph/getPackageDependencies.d.ts +6 -0
  12. package/lib/graph/getPackageDependencies.js +20 -0
  13. package/lib/graph/index.d.ts +3 -0
  14. package/lib/graph/index.js +16 -0
  15. package/lib/index.d.ts +2 -2
  16. package/lib/index.js +2 -2
  17. package/lib/lockfile/index.js +2 -2
  18. package/package.json +5 -3
  19. package/.github/workflows/pr.yml +0 -29
  20. package/.github/workflows/release.yml +0 -36
  21. package/.prettierrc +0 -6
  22. package/CODE_OF_CONDUCT.md +0 -9
  23. package/SECURITY.md +0 -41
  24. package/beachball.config.js +0 -12
  25. package/docs/.nojekyll +0 -1
  26. package/docs/assets/highlight.css +0 -22
  27. package/docs/assets/icons.css +0 -1043
  28. package/docs/assets/icons.png +0 -0
  29. package/docs/assets/icons@2x.png +0 -0
  30. package/docs/assets/main.js +0 -52
  31. package/docs/assets/search.js +0 -1
  32. package/docs/assets/style.css +0 -1414
  33. package/docs/assets/widgets.png +0 -0
  34. package/docs/assets/widgets@2x.png +0 -0
  35. package/docs/index.html +0 -42
  36. package/docs/interfaces/NpmLockFile.html +0 -1
  37. package/docs/interfaces/NpmSymlinkInfo.html +0 -1
  38. package/docs/interfaces/NpmWorkspacesInfo.html +0 -1
  39. package/docs/interfaces/PackageInfo.html +0 -1
  40. package/docs/interfaces/PackageInfos.html +0 -1
  41. package/docs/interfaces/PnpmLockFile.html +0 -1
  42. package/docs/modules.html +0 -70
  43. package/jest.config.js +0 -11
  44. package/lib/__tests__/dependencies.test.d.ts +0 -1
  45. package/lib/__tests__/dependencies.test.js +0 -141
  46. package/lib/__tests__/getChangedPackages.test.d.ts +0 -1
  47. package/lib/__tests__/getChangedPackages.test.js +0 -142
  48. package/lib/__tests__/getDefaultRemote.test.d.ts +0 -1
  49. package/lib/__tests__/getDefaultRemote.test.js +0 -26
  50. package/lib/__tests__/getInitDefaultBranch.test.d.ts +0 -1
  51. package/lib/__tests__/getInitDefaultBranch.test.js +0 -26
  52. package/lib/__tests__/getPackagesByFiles.test.d.ts +0 -1
  53. package/lib/__tests__/getPackagesByFiles.test.js +0 -54
  54. package/lib/__tests__/getScopedPackages.test.d.ts +0 -1
  55. package/lib/__tests__/getScopedPackages.test.js +0 -74
  56. package/lib/__tests__/getWorkspaceRoot.test.d.ts +0 -1
  57. package/lib/__tests__/getWorkspaceRoot.test.js +0 -40
  58. package/lib/__tests__/getWorkspaces.test.d.ts +0 -1
  59. package/lib/__tests__/getWorkspaces.test.js +0 -122
  60. package/lib/__tests__/graph.test.d.ts +0 -1
  61. package/lib/__tests__/graph.test.js +0 -117
  62. package/lib/__tests__/lockfile.test.d.ts +0 -1
  63. package/lib/__tests__/lockfile.test.js +0 -42
  64. package/lib/__tests__/queryLockFile.test.d.ts +0 -1
  65. package/lib/__tests__/queryLockFile.test.js +0 -43
  66. package/lib/graph.d.ts +0 -8
  67. package/lib/graph.js +0 -61
package/jest.config.js DELETED
@@ -1,11 +0,0 @@
1
- module.exports = {
2
- roots: ["<rootDir>/src"],
3
- transform: {
4
- "^.+\\.tsx?$": "ts-jest",
5
- },
6
- testRegex: "(/__tests__/.*(\\.|/)(test|spec))\\.tsx?$",
7
- moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
8
- modulePathIgnorePatterns: ["<rootDir>/src/__fixtures__"],
9
- preset: "ts-jest",
10
- setupFilesAfterEnv: [require.resolve("./src/helpers/setupTests.ts")],
11
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,141 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const dependencies_1 = require("../dependencies");
4
- describe("getTransitiveConsumers", () => {
5
- it("can get linear transitive consumers", () => {
6
- const allPackages = {
7
- a: stubPackage("a", ["b"]),
8
- b: stubPackage("b", ["c"]),
9
- c: stubPackage("c"),
10
- };
11
- const actual = (0, dependencies_1.getTransitiveConsumers)(["c"], allPackages);
12
- expect(actual).toContain("a");
13
- expect(actual).toContain("b");
14
- });
15
- it("can get linear transitive consumers with scope", () => {
16
- const allPackages = {
17
- grid: stubPackage("grid", ["foo"]),
18
- word: stubPackage("word", ["bar"]),
19
- foo: stubPackage("foo", ["core"]),
20
- bar: stubPackage("bar", ["core"]),
21
- core: stubPackage("core"),
22
- demo: stubPackage("demo", ["grid", "word"]),
23
- };
24
- const actual = (0, dependencies_1.getTransitiveConsumers)(["core"], allPackages, [
25
- "grid",
26
- "word",
27
- ]);
28
- expect(actual).toContain("foo");
29
- expect(actual).toContain("bar");
30
- expect(actual).toContain("grid");
31
- expect(actual).toContain("word");
32
- expect(actual).not.toContain("demo");
33
- });
34
- it("can get transitive consumer with deps", () => {
35
- /*
36
- [b, a]
37
- [d, a]
38
- [c, b]
39
- [e, b]
40
- [f, d]
41
- [c, g]
42
-
43
- expected: a, b, g (orignates from c)
44
- */
45
- const allPackages = {
46
- a: stubPackage("a", ["b", "d"]),
47
- b: stubPackage("b", ["c", "e"]),
48
- c: stubPackage("c"),
49
- d: stubPackage("d", ["f"]),
50
- e: stubPackage("e"),
51
- f: stubPackage("f"),
52
- g: stubPackage("g", ["c"]),
53
- };
54
- const actual = (0, dependencies_1.getTransitiveConsumers)(["c"], allPackages);
55
- expect(actual).toContain("a");
56
- expect(actual).toContain("b");
57
- expect(actual).toContain("g");
58
- expect(actual).not.toContain("d");
59
- expect(actual).not.toContain("e");
60
- expect(actual).not.toContain("f");
61
- expect(actual).not.toContain("c");
62
- });
63
- });
64
- describe("getTransitiveProviders", () => {
65
- it("can get linear transitive providers", () => {
66
- const allPackages = {
67
- a: stubPackage("a", ["b"]),
68
- b: stubPackage("b", ["c"]),
69
- c: stubPackage("c"),
70
- };
71
- const actual = (0, dependencies_1.getTransitiveProviders)(["a"], allPackages);
72
- expect(actual).toContain("b");
73
- expect(actual).toContain("c");
74
- });
75
- it("can get transitive providers with deps", () => {
76
- /*
77
- [b, a]
78
- [c, b]
79
- [e, c]
80
- [f, c]
81
- [f, e]
82
- [g, f]
83
-
84
- expected: e, f, g
85
- */
86
- const allPackages = {
87
- a: stubPackage("a", ["b"]),
88
- b: stubPackage("b", ["c"]),
89
- c: stubPackage("c", ["e", "f"]),
90
- d: stubPackage("d"),
91
- e: stubPackage("e", ["f"]),
92
- f: stubPackage("f", ["g"]),
93
- g: stubPackage("g"),
94
- };
95
- const actual = (0, dependencies_1.getTransitiveProviders)(["c"], allPackages);
96
- expect(actual).toContain("e");
97
- expect(actual).toContain("f");
98
- expect(actual).toContain("g");
99
- expect(actual).not.toContain("a");
100
- expect(actual).not.toContain("b");
101
- expect(actual).not.toContain("d");
102
- expect(actual).not.toContain("c");
103
- });
104
- it("can get transitive consumers with deps and scope", () => {
105
- /*
106
- [b, a]
107
- [c, b]
108
- [e, c]
109
- [f, c]
110
- [f, e]
111
- [g, f]
112
-
113
- expected: e, f, g
114
- */
115
- const allPackages = {
116
- a: stubPackage("a", ["b", "h"]),
117
- b: stubPackage("b", ["c"]),
118
- c: stubPackage("c", ["e", "f"]),
119
- d: stubPackage("d"),
120
- e: stubPackage("e", ["f"]),
121
- f: stubPackage("f", ["g"]),
122
- g: stubPackage("g"),
123
- h: stubPackage("h", ["i"]),
124
- i: stubPackage("i", ["f"]),
125
- };
126
- const actual = (0, dependencies_1.getTransitiveConsumers)(["f"], allPackages, ["b"]);
127
- expect(actual).toContain("e");
128
- expect(actual).toContain("c");
129
- expect(actual).toContain("b");
130
- expect(actual).not.toContain("h");
131
- });
132
- });
133
- function stubPackage(name, deps = []) {
134
- return {
135
- name,
136
- packageJsonPath: `packages/${name}`,
137
- version: "1.0",
138
- dependencies: deps.reduce((depMap, dep) => (Object.assign(Object.assign({}, depMap), { [dep]: "*" })), {}),
139
- devDependencies: {},
140
- };
141
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,142 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = __importDefault(require("path"));
7
- const fs_1 = __importDefault(require("fs"));
8
- const setupFixture_1 = require("../helpers/setupFixture");
9
- const git_1 = require("../git");
10
- const getChangedPackages_1 = require("../workspaces/getChangedPackages");
11
- describe("getChangedPackages()", () => {
12
- afterAll(() => {
13
- (0, setupFixture_1.cleanupFixtures)();
14
- });
15
- it("can detect changes inside an untracked file", () => {
16
- // arrange
17
- const root = (0, setupFixture_1.setupFixture)("monorepo");
18
- const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
19
- fs_1.default.writeFileSync(newFile, "hello foo test");
20
- // act
21
- const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
22
- // assert
23
- expect(changedPkgs).toContain("package-a");
24
- });
25
- it("can detect changes inside an untracked file in a nested monorepo", () => {
26
- // arrange
27
- const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo");
28
- const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
29
- fs_1.default.writeFileSync(newFile, "hello foo test");
30
- // act
31
- const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
32
- // assert
33
- expect(changedPkgs).toEqual(["package-a"]);
34
- });
35
- it("can detect changes inside an unstaged file", () => {
36
- // arrange
37
- const root = (0, setupFixture_1.setupFixture)("monorepo");
38
- const newFile = path_1.default.join(root, "packages/package-a/src/index.ts");
39
- fs_1.default.writeFileSync(newFile, "hello foo test");
40
- // act
41
- const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
42
- // assert
43
- expect(changedPkgs).toContain("package-a");
44
- });
45
- it("can detect changes inside an unstaged file in a nested monorepo", () => {
46
- // arrange
47
- const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo");
48
- const newFile = path_1.default.join(root, "packages/package-a/src/index.ts");
49
- fs_1.default.writeFileSync(newFile, "hello foo test");
50
- // act
51
- const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
52
- // assert
53
- expect(changedPkgs).toEqual(["package-a"]);
54
- });
55
- it("can detect changes inside a staged file", () => {
56
- // arrange
57
- const root = (0, setupFixture_1.setupFixture)("monorepo");
58
- const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
59
- fs_1.default.writeFileSync(newFile, "hello foo test");
60
- (0, git_1.git)(["add", newFile], { cwd: root });
61
- // act
62
- const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
63
- // assert
64
- expect(changedPkgs).toContain("package-a");
65
- });
66
- it("can detect changes inside a staged file in a nested monorepo", () => {
67
- // arrange
68
- const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo");
69
- const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
70
- fs_1.default.writeFileSync(newFile, "hello foo test");
71
- (0, git_1.git)(["add", newFile], { cwd: root });
72
- // act
73
- const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
74
- // assert
75
- expect(changedPkgs).toEqual(["package-a"]);
76
- });
77
- it("can detect changes inside a file that has been committed in a different branch", () => {
78
- // arrange
79
- const root = (0, setupFixture_1.setupFixture)("monorepo");
80
- const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
81
- fs_1.default.writeFileSync(newFile, "hello foo test");
82
- (0, git_1.git)(["checkout", "-b", "newbranch"], { cwd: root });
83
- (0, git_1.stageAndCommit)(["add", newFile], "test commit", root);
84
- // act
85
- const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
86
- // assert
87
- expect(changedPkgs).toContain("package-a");
88
- });
89
- it("can detect changes inside a file that has been committed in a different branch in a nested monorepo", () => {
90
- // arrange
91
- const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo");
92
- const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
93
- fs_1.default.writeFileSync(newFile, "hello foo test");
94
- (0, git_1.git)(["checkout", "-b", "newbranch"], { cwd: root });
95
- (0, git_1.stageAndCommit)(["add", newFile], "test commit", root);
96
- // act
97
- const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main");
98
- // assert
99
- expect(changedPkgs).toEqual(["package-a"]);
100
- });
101
- it("can detect changes inside a file that has been committed in a different branch using default remote", () => {
102
- // arrange
103
- const root = (0, setupFixture_1.setupFixture)("monorepo");
104
- (0, setupFixture_1.setupLocalRemote)(root, "origin", "basic");
105
- const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
106
- fs_1.default.writeFileSync(newFile, "hello foo test");
107
- (0, git_1.git)(["checkout", "-b", "newbranch"], { cwd: root });
108
- (0, git_1.stageAndCommit)(["add", newFile], "test commit", root);
109
- // act
110
- const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, undefined);
111
- // assert
112
- expect(changedPkgs).toContain("package-a");
113
- });
114
- it("can ignore glob patterns in detecting changes", () => {
115
- // arrange
116
- const root = (0, setupFixture_1.setupFixture)("monorepo");
117
- const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
118
- fs_1.default.writeFileSync(newFile, "hello foo test");
119
- (0, git_1.git)(["add", newFile], { cwd: root });
120
- // act
121
- const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main", ["packages/package-a/*"]);
122
- // assert
123
- expect(changedPkgs).toEqual([]);
124
- });
125
- it("can detect changed packages between two refs", () => {
126
- // arrange
127
- const root = (0, setupFixture_1.setupFixture)("monorepo");
128
- const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
129
- fs_1.default.writeFileSync(newFile, "hello foo test");
130
- (0, git_1.git)(["add", newFile], { cwd: root });
131
- (0, git_1.stageAndCommit)(["packages/package-a/footest.txt"], "test commit in a", root);
132
- const newFile2 = path_1.default.join(root, "packages/package-b/footest2.txt");
133
- fs_1.default.writeFileSync(newFile2, "hello foo test");
134
- (0, git_1.git)(["add", newFile2], { cwd: root });
135
- (0, git_1.stageAndCommit)(["packages/package-b/footest2.txt"], "test commit in b", root);
136
- // act
137
- const changedPkgs = (0, getChangedPackages_1.getChangedPackagesBetweenRefs)(root, "HEAD^1", "HEAD");
138
- // assert
139
- expect(changedPkgs).toContain("package-b");
140
- expect(changedPkgs).not.toContain("package-a");
141
- });
142
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const setupFixture_1 = require("../helpers/setupFixture");
4
- const git_1 = require("../git");
5
- describe("getDefaultRemote()", () => {
6
- afterAll(() => {
7
- (0, setupFixture_1.cleanupFixtures)();
8
- });
9
- it("is origin in the default test repo", () => {
10
- // arrange
11
- const cwd = (0, setupFixture_1.setupFixture)("basic");
12
- // act
13
- const remote = (0, git_1.getDefaultRemote)(cwd);
14
- // assert
15
- expect(remote).toBe("origin");
16
- });
17
- it("is myMain when default branch is different", () => {
18
- // arrange
19
- const cwd = (0, setupFixture_1.setupFixture)("basic");
20
- (0, setupFixture_1.setupLocalRemote)(cwd, "myRemote", "basic");
21
- // act
22
- const remote = (0, git_1.getDefaultRemote)(cwd);
23
- // assert
24
- expect(remote).toBe("myRemote");
25
- });
26
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const setupFixture_1 = require("../helpers/setupFixture");
4
- const git_1 = require("../git");
5
- describe("getDefaultBranch()", () => {
6
- afterAll(() => {
7
- (0, setupFixture_1.cleanupFixtures)();
8
- });
9
- it("is main in the default test repo", () => {
10
- // arrange
11
- const cwd = (0, setupFixture_1.setupFixture)("basic");
12
- // act
13
- const branch = (0, git_1.getDefaultBranch)(cwd);
14
- // assert
15
- expect(branch).toBe("main");
16
- });
17
- it("is myMain when default branch is different", () => {
18
- // arrange
19
- const cwd = (0, setupFixture_1.setupFixture)("basic");
20
- (0, git_1.git)(['config', 'init.defaultBranch', 'myMain'], { cwd });
21
- // act
22
- const branch = (0, git_1.getDefaultBranch)(cwd);
23
- // assert
24
- expect(branch).toBe("myMain");
25
- });
26
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = __importDefault(require("path"));
7
- const fs_1 = __importDefault(require("fs"));
8
- const setupFixture_1 = require("../helpers/setupFixture");
9
- const getPackagesByFiles_1 = require("../workspaces/getPackagesByFiles");
10
- describe("getPackagesByFiles()", () => {
11
- afterAll(() => {
12
- (0, setupFixture_1.cleanupFixtures)();
13
- });
14
- it("can find all packages that contain the files in a monorepo", () => {
15
- // arrange
16
- const root = (0, setupFixture_1.setupFixture)("monorepo");
17
- const newFile = path_1.default.join(root, "packages/package-a/footest.txt");
18
- fs_1.default.writeFileSync(newFile, "hello foo test");
19
- // act
20
- const packages = (0, getPackagesByFiles_1.getPackagesByFiles)(root, ["packages/package-a/footest.txt"]);
21
- // assert
22
- expect(packages).toContain("package-a");
23
- expect(packages).not.toContain("package-b");
24
- });
25
- it("can find can ignore changes in a glob pattern", () => {
26
- // arrange
27
- const root = (0, setupFixture_1.setupFixture)("monorepo");
28
- const newFileA = path_1.default.join(root, "packages/package-a/footest.txt");
29
- fs_1.default.writeFileSync(newFileA, "hello foo test");
30
- const newFileB = path_1.default.join(root, "packages/package-b/footest.txt");
31
- fs_1.default.writeFileSync(newFileB, "hello foo test");
32
- // act
33
- const packages = (0, getPackagesByFiles_1.getPackagesByFiles)(root, ["packages/package-a/footest.txt", "packages/package-b/footest.txt"], ["packages/package-b/**"]);
34
- // assert
35
- expect(packages).toContain("package-a");
36
- expect(packages).not.toContain("package-b");
37
- });
38
- it("can find can handle empty files", () => {
39
- // arrange
40
- const root = (0, setupFixture_1.setupFixture)("monorepo");
41
- // act
42
- const packages = (0, getPackagesByFiles_1.getPackagesByFiles)(root, []);
43
- // assert
44
- expect(packages.length).toBe(0);
45
- });
46
- it("can find can handle unrelated files", () => {
47
- // arrange
48
- const root = (0, setupFixture_1.setupFixture)("monorepo");
49
- // act
50
- const packages = (0, getPackagesByFiles_1.getPackagesByFiles)(root, ["package.json"]);
51
- // assert
52
- expect(packages.length).toBe(0);
53
- });
54
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const scope_1 = require("../scope");
4
- describe("getScopedPackages", () => {
5
- it("can match scopes for full matches for an array", () => {
6
- const results = (0, scope_1.getScopedPackages)(["foo", "bar"], ["foo", "bar", "baz"]);
7
- expect(results).toContain("foo");
8
- expect(results).toContain("bar");
9
- expect(results).not.toContain("baz");
10
- });
11
- it("can match scopes for full matches for a map", () => {
12
- const results = (0, scope_1.getScopedPackages)(["foo", "bar"], {
13
- foo: {},
14
- bar: {},
15
- baz: {},
16
- });
17
- expect(results).toContain("foo");
18
- expect(results).toContain("bar");
19
- expect(results).not.toContain("baz");
20
- });
21
- it("can match scopes for full matches for a map of PackageInfos", () => {
22
- const results = (0, scope_1.getScopedPackages)(["foo", "bar"], {
23
- foo: { name: "foo", packageJsonPath: "nowhere", version: "1.0.0" },
24
- bar: { name: "bar", packageJsonPath: "nowhere", version: "1.0.0" },
25
- baz: { name: "baz", packageJsonPath: "nowhere", version: "1.0.0" },
26
- });
27
- expect(results).toContain("foo");
28
- expect(results).toContain("bar");
29
- expect(results).not.toContain("baz");
30
- });
31
- it("can match with wildcards", () => {
32
- const results = (0, scope_1.getScopedPackages)(["foo*"], ["foo1", "foo2", "baz"]);
33
- expect(results).toContain("foo1");
34
- expect(results).toContain("foo2");
35
- expect(results).not.toContain("baz");
36
- });
37
- it("can match with npm package scopes", () => {
38
- const results = (0, scope_1.getScopedPackages)(["foo"], ["@yay/foo", "@yay1/foo", "foo", "baz"]);
39
- expect(results).toContain("@yay/foo");
40
- expect(results).toContain("@yay1/foo");
41
- expect(results).toContain("foo");
42
- expect(results).not.toContain("baz");
43
- });
44
- it("can match with npm package scopes with wildcards", () => {
45
- const results = (0, scope_1.getScopedPackages)(["foo*"], ["@yay/foo1", "@yay1/foo2", "foo", "baz"]);
46
- expect(results).toContain("@yay/foo1");
47
- expect(results).toContain("@yay1/foo2");
48
- expect(results).toContain("foo");
49
- expect(results).not.toContain("baz");
50
- });
51
- it("uses the correct package scope when the search pattern starts a @ character", () => {
52
- const results = (0, scope_1.getScopedPackages)(["@yay/foo*"], ["@yay/foo1", "@yay1/foo2", "foo", "baz"]);
53
- expect(results).toContain("@yay/foo1");
54
- expect(results).not.toContain("@yay1/foo2");
55
- expect(results).not.toContain("foo");
56
- expect(results).not.toContain("baz");
57
- });
58
- it("can deal with brace expansion with scopes", () => {
59
- const results = (0, scope_1.getScopedPackages)(["@yay/foo{1,2}"], ["@yay/foo1", "@yay/foo2", "@yay/foo3", "foo", "baz"]);
60
- expect(results).toContain("@yay/foo1");
61
- expect(results).toContain("@yay/foo2");
62
- expect(results).not.toContain("@yay/foo3");
63
- expect(results).not.toContain("foo");
64
- expect(results).not.toContain("baz");
65
- });
66
- it("can deal with negated search", () => {
67
- const results = (0, scope_1.getScopedPackages)(["@yay/foo*", "!@yay/foo3"], ["@yay/foo1", "@yay/foo2", "@yay/foo3", "foo", "baz"]);
68
- expect(results).toContain("@yay/foo1");
69
- expect(results).toContain("@yay/foo2");
70
- expect(results).not.toContain("@yay/foo3");
71
- expect(results).not.toContain("foo");
72
- expect(results).not.toContain("baz");
73
- });
74
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const setupFixture_1 = require("../helpers/setupFixture");
4
- const yarn_1 = require("../workspaces/implementations/yarn");
5
- const pnpm_1 = require("../workspaces/implementations/pnpm");
6
- const rush_1 = require("../workspaces/implementations/rush");
7
- const npm_1 = require("../workspaces/implementations/npm");
8
- const lerna_1 = require("../workspaces/implementations/lerna");
9
- describe("getWorkspaceRoot", () => {
10
- afterAll(() => {
11
- (0, setupFixture_1.cleanupFixtures)();
12
- });
13
- it("handles yarn workspace", () => {
14
- const repoRoot = (0, setupFixture_1.setupFixture)("monorepo");
15
- const workspaceRoot = (0, yarn_1.getYarnWorkspaceRoot)(repoRoot);
16
- expect(workspaceRoot).toBe(repoRoot);
17
- });
18
- it("handles pnpm workspace", () => {
19
- const repoRoot = (0, setupFixture_1.setupFixture)("monorepo-pnpm");
20
- const workspaceRoot = (0, pnpm_1.getPnpmWorkspaceRoot)(repoRoot);
21
- expect(workspaceRoot).toBe(repoRoot);
22
- });
23
- it("handles rush workspace", () => {
24
- const repoRoot = (0, setupFixture_1.setupFixture)("monorepo-rush-pnpm");
25
- const workspaceRoot = (0, rush_1.getRushWorkspaceRoot)(repoRoot);
26
- expect(workspaceRoot).toBe(repoRoot);
27
- });
28
- it("handles npm workspace", () => {
29
- const repoRoot = (0, setupFixture_1.setupFixture)("monorepo-npm");
30
- const workspaceRoot = (0, npm_1.getNpmWorkspaceRoot)(repoRoot);
31
- expect(workspaceRoot).toBe(repoRoot);
32
- });
33
- });
34
- describe("getLernaWorkspaceRoot()", () => {
35
- it("gets the root of the workspace", async () => {
36
- const repoRoot = await (0, setupFixture_1.setupFixture)("monorepo-lerna-npm");
37
- const workspaceRoot = (0, lerna_1.getLernaWorkspaceRoot)(repoRoot);
38
- expect(workspaceRoot).toBe(repoRoot);
39
- });
40
- });
@@ -1 +0,0 @@
1
- export {};