semantic-release-lerna 0.8.0 → 0.8.2

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.
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable security/detect-unsafe-regex */
2
2
  const latchMajor = /^\d+\.0\.0$/;
3
3
  const latchMinor = /^\d+\.\d+\.0$/;
4
- const latchPatch = /^\d+\.\d\.\d+$/;
4
+ const latchPatch = /^\d+\.\d+\.\d+$/;
5
5
  const latchPrerelease = /^\d+\.\d+\.\d+(-(.*\.)?\d+)?$/;
6
6
 
7
7
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semantic-release-lerna",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "semantic-release plugin to publish lerna monorepo packages to npm",
5
5
  "keywords": [
6
6
  "npm",
@@ -29,7 +29,7 @@
29
29
  "files": [
30
30
  "lib",
31
31
  "index.js",
32
- "!*.test.js"
32
+ "!**/*.test.js"
33
33
  ],
34
34
  "scripts": {
35
35
  "codecov": "codecov -f coverage/coverage-final.json",
@@ -46,7 +46,7 @@
46
46
  "testTimeout": 10000
47
47
  },
48
48
  "dependencies": {
49
- "@lerna/child-process": "^6.0.0",
49
+ "@lerna/child-process": "^7.0.0",
50
50
  "@lerna/collect-updates": "^6.0.0",
51
51
  "@lerna/package": "^6.0.0",
52
52
  "@lerna/package-graph": "^6.0.0",
@@ -68,28 +68,29 @@
68
68
  "write-json-file": "^4.0.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@html-validate/eslint-config": "5.5.22",
71
+ "@html-validate/eslint-config": "5.5.27",
72
72
  "@html-validate/eslint-config-jest": "5.5.18",
73
- "@html-validate/prettier-config": "2.3.4",
73
+ "@html-validate/prettier-config": "2.3.6",
74
74
  "@semantic-release/npm": "9.0.2",
75
- "@types/jest": "29.4.0",
75
+ "@types/jest": "29.4.1",
76
76
  "codecov": "3.8.3",
77
77
  "fs-extra": "11.1.0",
78
78
  "got": "11.8.6",
79
- "jest": "29.4.2",
80
- "lerna": "6.4.1",
81
- "prettier": "2.8.4",
82
- "semantic-release": "20.1.0",
79
+ "jest": "29.5.0",
80
+ "lerna": "7.1.4",
81
+ "npm": "9.8.1",
82
+ "npm-pkg-lint": "1.14.1",
83
+ "semantic-release": "20.1.1",
83
84
  "stream-buffers": "3.0.2",
84
85
  "verdaccio": "5.19.1"
85
86
  },
86
87
  "peerDependencies": {
87
88
  "@semantic-release/npm": ">= 7",
88
- "lerna": "^3.2 || ^4 || ^5 || ^6",
89
+ "lerna": "^3.2 || ^4 || ^5 || ^6 || ^7",
89
90
  "semantic-release": ">=15.0.0 <21.0.0"
90
91
  },
91
92
  "engines": {
92
- "node": ">= 14"
93
+ "node": ">= 14.17"
93
94
  },
94
95
  "publishConfig": {
95
96
  "access": "public"
@@ -1,477 +0,0 @@
1
- /* eslint-env jest */
2
- const path = require("path");
3
- const { outputJson, readJson } = require("fs-extra");
4
- const tempy = require("tempy");
5
- const execa = require("execa");
6
- const { WritableStreamBuffer } = require("stream-buffers");
7
- const prepare = require("./prepare");
8
-
9
- let context;
10
- let mockChangedPackages;
11
-
12
- jest.mock("../lib/get-changed-packages", () => {
13
- function getChangedPackagesMock() {
14
- return mockChangedPackages;
15
- }
16
-
17
- return getChangedPackagesMock;
18
- });
19
-
20
- async function createProject(cwd, version, pkgData) {
21
- const lernaPath = path.resolve(cwd, "lerna.json");
22
- const manifestLocation = path.resolve(cwd, "package.json");
23
- await outputJson(lernaPath, { version, packages: ["packages/*"] });
24
- await outputJson(manifestLocation, { name: "root-pkg", version, ...pkgData });
25
- return {
26
- lernaPath,
27
- manifestLocation,
28
- };
29
- }
30
-
31
- /* eslint-disable-next-line max-params */
32
- async function createPackage(cwd, name, version, options, pkgData) {
33
- const { changed = false } = options;
34
- const pkgRoot = `packages/${name}`;
35
- const location = path.resolve(cwd, pkgRoot);
36
- const manifestLocation = path.resolve(cwd, pkgRoot, "package.json");
37
- const pkg = {
38
- name,
39
- location,
40
- manifestLocation,
41
- shrinkwrapPath: path.resolve(cwd, pkgRoot, "npm-shrinkwrap.json"),
42
- lockfilePath: path.resolve(cwd, pkgRoot, "package-lock.json"),
43
- };
44
- await outputJson(manifestLocation, { name, version, ...pkgData });
45
- if (changed) {
46
- mockChangedPackages.push(pkg);
47
- }
48
-
49
- return pkg;
50
- }
51
-
52
- beforeEach(() => {
53
- const log = jest.fn();
54
- context = {
55
- log,
56
- logger: { log },
57
- stdout: new WritableStreamBuffer(),
58
- stderr: new WritableStreamBuffer(),
59
- };
60
- mockChangedPackages = [];
61
- });
62
-
63
- it("Update lerna.json and root package.json when no package has changed", async () => {
64
- expect.assertions(4);
65
- const cwd = tempy.directory();
66
- const npmrc = tempy.file({ name: ".npmrc" });
67
- const project = await createProject(cwd, "0.0.0");
68
-
69
- await prepare(
70
- npmrc,
71
- {},
72
- {
73
- cwd,
74
- env: {},
75
- stdout: context.stdout,
76
- stderr: context.stderr,
77
- nextRelease: { version: "1.0.0" },
78
- logger: context.logger,
79
- }
80
- );
81
-
82
- // Verify lerna.json has been updated
83
- expect(await readJson(project.lernaPath)).toEqual(
84
- expect.objectContaining({
85
- version: "1.0.0",
86
- })
87
- );
88
-
89
- // Verify root package.json has been updated
90
- expect(await readJson(project.manifestLocation)).toEqual(
91
- expect.objectContaining({
92
- version: "1.0.0",
93
- })
94
- );
95
-
96
- // Verify the logger has been called with the version updated
97
- expect(context.log).toHaveBeenCalledWith(
98
- "No packages changed, applying version bump on root package only"
99
- );
100
- expect(context.log).toHaveBeenCalledWith("Write version %s to lerna.json in %s", "1.0.0", cwd);
101
- });
102
-
103
- it("Update lerna.json and root package.json when one or more package has changed", async () => {
104
- expect.assertions(5);
105
- const cwd = tempy.directory();
106
- const npmrc = tempy.file({ name: ".npmrc" });
107
- const project = await createProject(cwd, "0.0.0");
108
- const pkg = await createPackage(cwd, "foo", "0.0.0", {
109
- changed: true,
110
- });
111
-
112
- await prepare(
113
- npmrc,
114
- {},
115
- {
116
- cwd,
117
- env: {},
118
- stdout: context.stdout,
119
- stderr: context.stderr,
120
- nextRelease: { version: "1.0.0" },
121
- logger: context.logger,
122
- }
123
- );
124
-
125
- // Verify lerna.json has been updated
126
- expect(await readJson(project.lernaPath)).toEqual(
127
- expect.objectContaining({
128
- version: "1.0.0",
129
- })
130
- );
131
-
132
- // Verify package.json has been updated
133
- expect(await readJson(project.manifestLocation)).toEqual(
134
- expect.objectContaining({
135
- version: "1.0.0",
136
- })
137
- );
138
-
139
- // Verify the logger has been called with the version updated
140
- expect(context.log).toHaveBeenCalledWith("1 package need version bump: [ 'foo' ]");
141
- expect(context.log).toHaveBeenCalledWith(
142
- "Write version %s to package.json in %s",
143
- "1.0.0",
144
- pkg.location
145
- );
146
- expect(context.log).toHaveBeenCalledWith("Write version %s to lerna.json in %s", "1.0.0", cwd);
147
- });
148
-
149
- it("Update only lerna.json when one or more package has changed when option `rootVersion` is `false`", async () => {
150
- expect.assertions(4);
151
- const cwd = tempy.directory();
152
- const npmrc = tempy.file({ name: ".npmrc" });
153
- const project = await createProject(cwd, "0.0.0");
154
-
155
- await createPackage(cwd, "foo", "0.0.0", {
156
- changed: true,
157
- });
158
-
159
- await prepare(
160
- npmrc,
161
- {
162
- rootVersion: false,
163
- },
164
- {
165
- cwd,
166
- env: {},
167
- stdout: context.stdout,
168
- stderr: context.stderr,
169
- nextRelease: { version: "1.0.0" },
170
- logger: context.logger,
171
- }
172
- );
173
-
174
- // Verify lerna.json has been updated
175
- expect(await readJson(project.lernaPath)).toEqual(
176
- expect.objectContaining({
177
- version: "1.0.0",
178
- })
179
- );
180
-
181
- // Verify the logger has been called with the version updated
182
- expect(context.log).toHaveBeenCalledWith("1 package need version bump: [ 'foo' ]");
183
- expect(context.log).toHaveBeenCalledWith("Write version %s to lerna.json in %s", "1.0.0", cwd);
184
- expect(context.log).toHaveBeenCalledWith("Don't write version to root package.json");
185
- });
186
-
187
- it("Update package.json in changed packages", async () => {
188
- expect.assertions(2);
189
- const cwd = tempy.directory();
190
- const npmrc = tempy.file({ name: ".npmrc" });
191
- await createProject(cwd, "0.0.0");
192
- const foo = await createPackage(cwd, "foo", "0.0.0", {
193
- changed: true,
194
- });
195
- const bar = await createPackage(cwd, "bar", "0.0.0", {
196
- changed: false,
197
- });
198
-
199
- await prepare(
200
- npmrc,
201
- {},
202
- {
203
- cwd,
204
- env: {},
205
- stdout: context.stdout,
206
- stderr: context.stderr,
207
- nextRelease: { version: "1.0.0" },
208
- logger: context.logger,
209
- }
210
- );
211
-
212
- // Verify foo/package.json has been updated
213
- expect(await readJson(foo.manifestLocation)).toEqual({
214
- name: "foo",
215
- version: "1.0.0",
216
- });
217
-
218
- // Verify bar/package.json has not been updated
219
- expect(await readJson(bar.manifestLocation)).toEqual({
220
- name: "bar",
221
- version: "0.0.0",
222
- });
223
- });
224
-
225
- it("Update npm-shrinkwrap.json if present", async () => {
226
- expect.assertions(2);
227
- const cwd = tempy.directory();
228
- const npmrc = tempy.file({ name: ".npmrc" });
229
- await createProject(cwd, "0.0.0");
230
- const pkg = await createPackage(cwd, "foo", "0.0.0", {
231
- changed: true,
232
- });
233
- // Create a npm-shrinkwrap.json file
234
- await execa("npm", ["shrinkwrap"], { cwd: pkg.location });
235
-
236
- await prepare(
237
- npmrc,
238
- {},
239
- {
240
- cwd,
241
- env: {},
242
- stdout: context.stdout,
243
- stderr: context.stderr,
244
- nextRelease: { version: "1.0.0" },
245
- logger: context.logger,
246
- }
247
- );
248
-
249
- // Verify foo/package.json has been updated
250
- expect(await readJson(pkg.manifestLocation)).toEqual({
251
- name: "foo",
252
- version: "1.0.0",
253
- });
254
-
255
- // Verify foo/npm-shrinkwrap.json has been updated
256
- expect(await readJson(pkg.shrinkwrapPath)).toEqual(
257
- expect.objectContaining({
258
- lockfileVersion: expect.anything(),
259
- name: "foo",
260
- version: "1.0.0",
261
- })
262
- );
263
- });
264
-
265
- it("Update package-lock.json if present", async () => {
266
- expect.assertions(2);
267
- const cwd = tempy.directory();
268
- const npmrc = tempy.file({ name: ".npmrc" });
269
- await createProject(cwd, "0.0.0");
270
- const pkg = await createPackage(cwd, "foo", "0.0.0", {
271
- changed: true,
272
- });
273
- // Create a package-lock.json file
274
- await execa("npm", ["install"], { cwd: pkg.location });
275
-
276
- await prepare(
277
- npmrc,
278
- {},
279
- {
280
- cwd,
281
- env: {},
282
- stdout: context.stdout,
283
- stderr: context.stderr,
284
- nextRelease: { version: "1.0.0" },
285
- logger: context.logger,
286
- }
287
- );
288
-
289
- // Verify foo/package.json has been updated
290
- expect(await readJson(pkg.manifestLocation)).toEqual({
291
- name: "foo",
292
- version: "1.0.0",
293
- });
294
-
295
- // Verify foo/package-lock.json has been updated
296
- expect(await readJson(pkg.lockfilePath)).toEqual(
297
- expect.objectContaining({
298
- lockfileVersion: expect.anything(),
299
- name: "foo",
300
- version: "1.0.0",
301
- })
302
- );
303
- });
304
-
305
- it("Update package.json dependency when using exact version", async () => {
306
- expect.assertions(1);
307
- const cwd = tempy.directory();
308
- const npmrc = tempy.file({ name: ".npmrc" });
309
- await createProject(cwd, "0.0.0");
310
- const foo = await createPackage(
311
- cwd,
312
- "foo",
313
- "0.0.0",
314
- {
315
- changed: true,
316
- },
317
- {
318
- dependencies: {
319
- a: "0.0.0",
320
- },
321
- devDependencies: {
322
- b: "0.0.0",
323
- },
324
- peerDependencies: {
325
- c: "0.0.0",
326
- },
327
- }
328
- );
329
- await createPackage(cwd, "a", "0.0.0", { changed: true });
330
- await createPackage(cwd, "b", "0.0.0", { changed: true });
331
- await createPackage(cwd, "c", "0.0.0", { changed: true });
332
-
333
- await prepare(
334
- npmrc,
335
- {},
336
- {
337
- cwd,
338
- env: {},
339
- stdout: context.stdout,
340
- stderr: context.stderr,
341
- nextRelease: { version: "0.0.1" },
342
- logger: context.logger,
343
- }
344
- );
345
-
346
- // Verify dependency has been updated
347
- expect(await readJson(foo.manifestLocation)).toEqual({
348
- name: "foo",
349
- version: "0.0.1",
350
- dependencies: {
351
- a: "0.0.1",
352
- },
353
- devDependencies: {
354
- b: "0.0.1",
355
- },
356
- peerDependencies: {
357
- c: "0.0.1",
358
- },
359
- });
360
- });
361
-
362
- it("Update package.json dependency when using hat", async () => {
363
- expect.assertions(1);
364
- const cwd = tempy.directory();
365
- const npmrc = tempy.file({ name: ".npmrc" });
366
- await createProject(cwd, "0.1.2");
367
- const foo = await createPackage(
368
- cwd,
369
- "foo",
370
- "0.1.2",
371
- {
372
- changed: true,
373
- },
374
- {
375
- dependencies: {
376
- a: "^0.1.2",
377
- b: "^0.1",
378
- c: "^0",
379
- },
380
- }
381
- );
382
-
383
- await createPackage(cwd, "a", "0.1.2", { changed: true });
384
- await createPackage(cwd, "b", "0.1.2", { changed: true });
385
- await createPackage(cwd, "c", "0.1.2", { changed: true });
386
-
387
- await prepare(
388
- npmrc,
389
- {},
390
- {
391
- cwd,
392
- env: {},
393
- stdout: context.stdout,
394
- stderr: context.stderr,
395
- nextRelease: { version: "1.0.0" },
396
- logger: context.logger,
397
- }
398
- );
399
-
400
- // Verify dependency has been updated
401
- expect(await readJson(foo.manifestLocation)).toEqual({
402
- name: "foo",
403
- version: "1.0.0",
404
- dependencies: {
405
- a: "^1.0.0",
406
- b: "^1.0",
407
- c: "^1",
408
- },
409
- });
410
- });
411
-
412
- it("Should not update other dependencies", async () => {
413
- expect.assertions(1);
414
- const cwd = tempy.directory();
415
- const npmrc = tempy.file({ name: ".npmrc" });
416
- await createProject(cwd, "0.0.0");
417
- const foo = await createPackage(
418
- cwd,
419
- "foo",
420
- "0.0.0",
421
- {
422
- changed: true,
423
- },
424
- {
425
- dependencies: {
426
- a: "0.0.0",
427
- },
428
- }
429
- );
430
-
431
- await prepare(
432
- npmrc,
433
- {},
434
- {
435
- cwd,
436
- env: {},
437
- stdout: context.stdout,
438
- stderr: context.stderr,
439
- nextRelease: { version: "0.0.1" },
440
- logger: context.logger,
441
- }
442
- );
443
-
444
- // Verify dependency has been updated
445
- expect(await readJson(foo.manifestLocation)).toEqual({
446
- name: "foo",
447
- version: "0.0.1",
448
- dependencies: {
449
- a: "0.0.0",
450
- },
451
- });
452
- });
453
-
454
- it("Handle dependencies from root package", async () => {
455
- expect.assertions(1);
456
- const cwd = tempy.directory();
457
- const npmrc = tempy.file({ name: ".npmrc" });
458
- await createProject(cwd, "0.0.1", {
459
- devDependencies: {
460
- "external-dependency": "1.2.3",
461
- },
462
- });
463
- expect(async () => {
464
- await prepare(
465
- npmrc,
466
- {},
467
- {
468
- cwd,
469
- env: {},
470
- stdout: context.stdout,
471
- stderr: context.stderr,
472
- nextRelease: { version: "0.0.2" },
473
- logger: context.logger,
474
- }
475
- );
476
- }).not.toThrow();
477
- });
@@ -1,71 +0,0 @@
1
- /* eslint-env jest */
2
-
3
- const semver = require("semver");
4
- const shouldLatch = require("./should-latch");
5
-
6
- const version = "1.0.0";
7
-
8
- describe("latch none", () => {
9
- it.each`
10
- bump | result | version | next
11
- ${"major"} | ${false} | ${version} | ${semver.inc(version, "major")}
12
- ${"minor"} | ${false} | ${version} | ${semver.inc(version, "minor")}
13
- ${"patch"} | ${false} | ${version} | ${semver.inc(version, "patch")}
14
- ${"prerelease"} | ${false} | ${version} | ${semver.inc(version, "prerelease")}
15
- `("should return $result when version bump is $bump ($version -> $next)", ({ result, next }) => {
16
- expect.assertions(1);
17
- expect(shouldLatch(next, "none")).toBe(result);
18
- });
19
- });
20
-
21
- describe("latch major", () => {
22
- it.each`
23
- bump | result | version | next
24
- ${"major"} | ${true} | ${version} | ${semver.inc(version, "major")}
25
- ${"minor"} | ${false} | ${version} | ${semver.inc(version, "minor")}
26
- ${"patch"} | ${false} | ${version} | ${semver.inc(version, "patch")}
27
- ${"prerelease"} | ${false} | ${version} | ${semver.inc(version, "prerelease")}
28
- `("should return $result when version bump is $bump ($version -> $next)", ({ result, next }) => {
29
- expect.assertions(1);
30
- expect(shouldLatch(next, "major")).toBe(result);
31
- });
32
- });
33
-
34
- describe("latch minor", () => {
35
- it.each`
36
- bump | result | version | next
37
- ${"major"} | ${true} | ${version} | ${semver.inc(version, "major")}
38
- ${"minor"} | ${true} | ${version} | ${semver.inc(version, "minor")}
39
- ${"patch"} | ${false} | ${version} | ${semver.inc(version, "patch")}
40
- ${"prerelease"} | ${false} | ${version} | ${semver.inc(version, "prerelease")}
41
- `("should return $result when version bump is $bump ($version -> $next)", ({ result, next }) => {
42
- expect.assertions(1);
43
- expect(shouldLatch(next, "minor")).toBe(result);
44
- });
45
- });
46
-
47
- describe("latch patch", () => {
48
- it.each`
49
- bump | result | version | next
50
- ${"major"} | ${true} | ${version} | ${semver.inc(version, "major")}
51
- ${"minor"} | ${true} | ${version} | ${semver.inc(version, "minor")}
52
- ${"patch"} | ${true} | ${version} | ${semver.inc(version, "patch")}
53
- ${"prerelease"} | ${false} | ${version} | ${semver.inc(version, "prerelease")}
54
- `("should return $result when version bump is $bump ($version -> $next)", ({ result, next }) => {
55
- expect.assertions(1);
56
- expect(shouldLatch(next, "patch")).toBe(result);
57
- });
58
- });
59
-
60
- describe("latch prerelease", () => {
61
- it.each`
62
- bump | result | version | next
63
- ${"major"} | ${true} | ${version} | ${semver.inc(version, "major")}
64
- ${"minor"} | ${true} | ${version} | ${semver.inc(version, "minor")}
65
- ${"patch"} | ${true} | ${version} | ${semver.inc(version, "patch")}
66
- ${"prerelease"} | ${true} | ${version} | ${semver.inc(version, "prerelease")}
67
- `("should return $result when version bump is $bump ($version -> $next)", ({ result, next }) => {
68
- expect.assertions(1);
69
- expect(shouldLatch(next, "prerelease")).toBe(result);
70
- });
71
- });
@@ -1,49 +0,0 @@
1
- /* eslint-env jest */
2
-
3
- jest.mock("execa");
4
-
5
- const execa = require("execa");
6
- const verifyGit = require("./verify-git");
7
-
8
- it("should return error if working copy is dirty", async () => {
9
- expect.assertions(2);
10
- execa.mockImplementation(() => ({ stdout: " M file.js\n" }));
11
- const errors = await verifyGit({});
12
- expect(errors).toHaveLength(1);
13
- expect(errors[0]).toMatchObject({
14
- code: "EDIRTYWC",
15
- details: `The git working copy must be clean before releasing:
16
-
17
- M file.js
18
- `,
19
- });
20
- });
21
-
22
- it("should return error when working copy has mixed dirty and untracked", async () => {
23
- expect.assertions(2);
24
- execa.mockImplementation(() => ({ stdout: " M file.js\n?? file.c" }));
25
- const errors = await verifyGit({});
26
- expect(errors).toHaveLength(1);
27
- expect(errors[0]).toMatchObject({
28
- code: "EDIRTYWC",
29
- details: `The git working copy must be clean before releasing:
30
-
31
- M file.js
32
- ?? file.c
33
- `,
34
- });
35
- });
36
-
37
- it("should ignore untracked files", async () => {
38
- expect.assertions(1);
39
- execa.mockImplementation(() => ({ stdout: "?? file.js\n" }));
40
- const errors = await verifyGit({});
41
- expect(errors).toHaveLength(0);
42
- });
43
-
44
- it("should not return error if working copy is clean", async () => {
45
- expect.assertions(1);
46
- execa.mockImplementation(() => ({ stdout: "" }));
47
- const errors = await verifyGit({});
48
- expect(errors).toHaveLength(0);
49
- });