-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
lerna-list-filter-options.spec.ts
254 lines (213 loc) · 8.07 KB
/
lerna-list-filter-options.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
import { Fixture } from "../../utils/fixture";
import { normalizeEnvironment } from "../../utils/snapshot-serializer-utils";
expect.addSnapshotSerializer({
serialize(str: string) {
return normalizeEnvironment(str);
},
test(val: string) {
return val != null && typeof val === "string";
},
});
describe("lerna-list-filter-options", () => {
let fixture: Fixture;
beforeAll(async () => {
fixture = await Fixture.create({
name: "lerna-list-filter-options",
packageManager: "npm",
initializeGit: true,
runLernaInit: true,
installDependencies: true,
});
await fixture.lerna("create package-c -y");
await fixture.lerna("create package-b --private -y");
await fixture.addPackagesDirectory("modules");
await fixture.lerna("create package-a modules -y");
await fixture.lerna("create package-e modules -y");
await fixture.lerna("create package-d modules --private -y");
await fixture.addDependencyToPackage({
packagePath: "modules/package-a",
dependencyName: "package-c",
version: "0.0.0",
});
await fixture.addDependencyToPackage({
packagePath: "packages/package-b",
dependencyName: "package-c",
version: "0.0.0",
});
await fixture.addDependencyToPackage({
packagePath: "modules/package-a",
dependencyName: "package-d",
version: "0.0.0",
});
});
afterAll(() => fixture.destroy());
describe("--scope", () => {
it("should list public packages, narrowed to only those that match the scope glob", async () => {
const output = await fixture.lerna("list --scope package-[ae]");
expect(output.combinedOutput).toMatchInlineSnapshot(`
package-a
package-e
lerna notice cli v999.9.9-e2e.0
lerna notice filter including "package-[ae]"
lerna info filter [ 'package-[ae]' ]
lerna success found 2 packages
`);
});
});
describe("--ignore", () => {
it("should list public packages, narrowed to only those that do not match the ignore glob", async () => {
const output = await fixture.lerna("list --ignore package-[ae]");
expect(output.combinedOutput).toMatchInlineSnapshot(`
package-c
lerna notice cli v999.9.9-e2e.0
lerna notice filter excluding "package-[ae]"
lerna info filter [ '!package-[ae]' ]
lerna success found 1 package
`);
});
});
describe("--no-private", () => {
it("should list all packages, hiding private ones, even with --all argument", async () => {
const output = await fixture.lerna("list --all --no-private");
expect(output.combinedOutput).toMatchInlineSnapshot(`
package-a
package-e
package-c
lerna notice cli v999.9.9-e2e.0
lerna success found 3 packages
`);
});
});
describe("--include-dependencies", () => {
it("should list public packages, narrowed to only those that match the scope glob, but with all of their public dependencies", async () => {
const output = await fixture.lerna("list --scope package-a --include-dependencies");
expect(output.combinedOutput).toMatchInlineSnapshot(`
package-a
package-c
lerna notice cli v999.9.9-e2e.0
lerna notice filter including "package-a"
lerna notice filter including dependencies
lerna info filter [ 'package-a' ]
lerna success found 2 packages
`);
});
});
});
describe("lerna list --since", () => {
let fixture: Fixture;
beforeEach(async () => {
fixture = await Fixture.create({
name: "lerna-list-filter-options",
packageManager: "npm",
initializeGit: true,
runLernaInit: true,
installDependencies: true,
});
await fixture.lerna("create package-c -y");
await fixture.lerna("create package-b --private -y");
await fixture.addPackagesDirectory("modules");
await fixture.lerna("create package-a modules -y");
await fixture.lerna("create package-e modules -y");
await fixture.lerna("create package-d modules --private -y");
await fixture.addDependencyToPackage({
packagePath: "modules/package-a",
dependencyName: "package-c",
version: "0.0.0",
});
await fixture.addDependencyToPackage({
packagePath: "packages/package-b",
dependencyName: "package-c",
version: "0.0.0",
});
await fixture.addDependencyToPackage({
packagePath: "modules/package-a",
dependencyName: "package-d",
version: "0.0.0",
});
await fixture.createInitialGitCommit();
});
afterEach(() => fixture.destroy());
it("should list public packages, narrowed to only those that have changed since the given tag", async () => {
await fixture.addDependencyToPackage({
packagePath: "modules/package-a",
dependencyName: "package-b",
version: "0.0.0",
});
await fixture.exec("git add .");
await fixture.exec('git commit -m "add package b as dependency of package a"');
await fixture.exec("git tag 1.0.0");
await fixture.addDependencyToPackage({
packagePath: "modules/package-e",
dependencyName: "package-c",
version: "0.0.0",
});
await fixture.exec("git add .");
await fixture.exec('git commit -m "add package c as dependency of package e"');
const output = await fixture.lerna("list --since 1.0.0");
expect(output.combinedOutput).toMatchInlineSnapshot(`
package-e
lerna notice cli v999.9.9-e2e.0
lerna notice filter changed since "1.0.0"
lerna info Looking for changed packages since 1.0.0
lerna success found 1 package
`);
});
it("should list public packages, narrowed to only those that have changed since the given ref", async () => {
await fixture.exec("git checkout -b modify-package-a");
await fixture.addDependencyToPackage({
packagePath: "modules/package-a",
dependencyName: "package-b",
version: "0.0.0",
});
await fixture.exec("git add .");
await fixture.exec('git commit -m "add package b as dependency of package a"');
const output = await fixture.lerna("list --since test-main");
expect(output.combinedOutput).toMatchInlineSnapshot(`
package-a
lerna notice cli v999.9.9-e2e.0
lerna notice filter changed since "test-main"
lerna info Looking for changed packages since test-main
lerna success found 1 package
`);
});
it("should list public packages, narrowed to only those that have changed since the given ref and their dependencies", async () => {
await fixture.exec("git checkout -b modify-package-c");
await fixture.addDependencyToPackage({
packagePath: "packages/package-c",
dependencyName: "package-e",
version: "0.0.0",
});
await fixture.exec("git add .");
await fixture.exec('git commit -m "add package e as dependency of package c"');
const output = await fixture.lerna("list --since test-main");
expect(output.combinedOutput).toMatchInlineSnapshot(`
package-a
package-c
lerna notice cli v999.9.9-e2e.0
lerna notice filter changed since "test-main"
lerna info Looking for changed packages since test-main
lerna success found 2 packages
`);
});
describe("--exclude-dependents", () => {
it("should list public packages, narrowed to only those that have changed, but without their dependents", async () => {
await fixture.exec("git checkout -b modify-package-c");
await fixture.addDependencyToPackage({
packagePath: "packages/package-c",
dependencyName: "package-e",
version: "0.0.0",
});
await fixture.exec("git add .");
await fixture.exec('git commit -m "add package e as dependency of package c"');
const output = await fixture.lerna("list --since test-main --exclude-dependents");
expect(output.combinedOutput).toMatchInlineSnapshot(`
package-c
lerna notice cli v999.9.9-e2e.0
lerna notice filter changed since "test-main"
lerna notice filter excluding dependents
lerna info Looking for changed packages since test-main
lerna success found 1 package
`);
});
});
});