semantic-release-lerna 0.4.2 → 0.6.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/README.md CHANGED
@@ -61,7 +61,6 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
61
61
  "lerna.json",
62
62
  "package.json",
63
63
  "package-lock.json",
64
- "lerna.json",
65
64
  "packages/*/package.json",
66
65
  "packages/*/package-lock.json"
67
66
  ]
@@ -75,20 +74,11 @@ To use legacy auth set `NPM_USERNAME`, `NPM_PASSWORD` and `NPM_EMAIL`.
75
74
 
76
75
  ## Options
77
76
 
78
- ### `npmVerifyAuth`
79
-
80
- - Type: `boolean`
81
- - Default: `true`
82
-
83
- Set to `false` to disable verifying NPM registry credentials.
84
-
85
- ### `latch`
86
-
87
- - Type: `"major" | "minor" | "patch" | "none"`
88
- - Default: `"minor"`
89
-
90
- Latches package versions together.
91
- If the version bump is at least the given version all packages will be bumped regardless if the package has been touched or not.
77
+ | Option | Description | Default |
78
+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
79
+ | `npmVerifyAuth` | Set to `false` to disable verifying NPM registry credentials. | `true` |
80
+ | `latch` | Latches package versions together. If the version bump is at least the given version all packages will be bumped regardless if the package has been touched or not. `"major", "minor", "patch", "none"` | `"minor"` |
81
+ | `rootVersion` | Allow to update version on root `package.json`. | `true` |
92
82
 
93
83
  ## Troubleshooting
94
84
 
@@ -33,7 +33,7 @@ async function generateNotes(pluginConfig, context) {
33
33
  const { generateNotes = false } = pluginConfig;
34
34
 
35
35
  if (!generateNotes) {
36
- logger.log(`release notes scope disabled, skipping`);
36
+ logger.log(`Release notes scope disabled, skipping`);
37
37
  return "";
38
38
  }
39
39
 
package/lib/prepare.js CHANGED
@@ -3,6 +3,7 @@ const fs = require("fs").promises;
3
3
  const { existsSync } = require("fs");
4
4
  const { format } = require("util");
5
5
  const execa = require("execa");
6
+ const npmVersion = require("libnpmversion");
6
7
  const { Project } = require("@lerna/project");
7
8
  const { Package } = require("@lerna/package");
8
9
  const writeJsonFile = require("write-json-file");
@@ -47,28 +48,22 @@ async function updateLernaJson(basePath, context) {
47
48
  */
48
49
  async function updatePackage(npmrc, pkg, context, currentVersions) {
49
50
  const {
50
- env,
51
51
  nextRelease: { version },
52
- stdout,
53
- stderr,
54
52
  logger,
55
53
  } = context;
56
54
  logger.log("Write version %s to package.json in %s", version, pkg.location);
57
55
 
58
- /* Use "npm version" to bump version for all changed packages: "lerna version"
59
- * would handle this better but lerna disagrees with the tags produced by
60
- * semantic-release and bumps all packages. */
61
- const versionResult = execa(
62
- "npm",
63
- ["version", version, "--userconfig", npmrc, "--no-git-tag-version", "--allow-same-version"],
64
- {
65
- cwd: pkg.location,
66
- env,
67
- }
68
- );
69
- versionResult.stdout.pipe(stdout, { end: false });
70
- versionResult.stderr.pipe(stderr, { end: false });
71
- await versionResult;
56
+ await npmVersion(version, {
57
+ path: pkg.location,
58
+ allowSameVersion: true,
59
+ commitHooks: false,
60
+ gitTagVersion: false,
61
+ signGitCommit: false,
62
+ signGitTag: false,
63
+ force: false,
64
+ ignoreScripts: false,
65
+ silent: false,
66
+ });
72
67
 
73
68
  /* Bump dependencies */
74
69
  if (currentVersions) {
@@ -193,6 +188,7 @@ module.exports = async (npmrc, pluginConfig, context) => {
193
188
  } = context;
194
189
  const basePath = pluginConfig.pkgRoot ? path.resolve(cwd, pluginConfig.pkgRoot) : cwd;
195
190
  const rootPkg = new Package(readJson(path.join(basePath, "package.json")), basePath);
191
+ const { rootVersion = true } = pluginConfig;
196
192
 
197
193
  const changed = await getChangedPackages(pluginConfig.latch, { cwd, logger, version });
198
194
  if (changed.length === 0) {
@@ -220,8 +216,11 @@ module.exports = async (npmrc, pluginConfig, context) => {
220
216
 
221
217
  /* Bump version in "lerna.json" */
222
218
  await updateLernaJson(basePath, context);
223
- await updatePackage(npmrc, rootPkg, context);
224
219
 
225
- /* Bump version in "package-lock.json" */
226
- await updateLockfile(npmrc, rootPkg, context);
220
+ if (rootVersion) {
221
+ await updatePackage(npmrc, rootPkg, context);
222
+ await updateLockfile(npmrc, rootPkg, context);
223
+ } else {
224
+ logger.log("Don't write version to root package.json");
225
+ }
227
226
  };
@@ -146,6 +146,44 @@ it("Update lerna.json and root package.json when one or more package has changed
146
146
  expect(context.log).toHaveBeenCalledWith("Write version %s to lerna.json in %s", "1.0.0", cwd);
147
147
  });
148
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
+
149
187
  it("Update package.json in changed packages", async () => {
150
188
  expect.assertions(2);
151
189
  const cwd = tempy.directory();
package/lib/publish.js CHANGED
@@ -42,6 +42,7 @@ module.exports = async (npmrc, config, pkg, context) => {
42
42
  lerna, 'publish', 'from-package',
43
43
  '--loglevel', 'verbose',
44
44
  '--yes',
45
+ '--concurrency', "1",
45
46
  '--no-verify-access', // prepare step has already verify access and lerna doesn't properly pass authentication
46
47
  '--dist-tag', distTag,
47
48
  '--registry', registry,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semantic-release-lerna",
3
- "version": "0.4.2",
3
+ "version": "0.6.1",
4
4
  "description": "semantic-release plugin to publish lerna monorepo packages to npm",
5
5
  "keywords": [
6
6
  "npm",
@@ -46,11 +46,11 @@
46
46
  "testTimeout": 10000
47
47
  },
48
48
  "dependencies": {
49
- "@lerna/child-process": "^4.0.0",
50
- "@lerna/collect-updates": "^4.0.0",
51
- "@lerna/package": "^4.0.0",
52
- "@lerna/package-graph": "^4.0.0",
53
- "@lerna/project": "^4.0.0",
49
+ "@lerna/child-process": "^5.0.0",
50
+ "@lerna/collect-updates": "^5.0.0",
51
+ "@lerna/package": "^5.0.0",
52
+ "@lerna/package-graph": "^5.0.0",
53
+ "@lerna/project": "^5.0.0",
54
54
  "@semantic-release/error": "^3.0.0",
55
55
  "@semantic-release/release-notes-generator": "^10.0.0",
56
56
  "aggregate-error": "^3.1.0",
@@ -61,30 +61,31 @@
61
61
  "execa": "^5.0.0",
62
62
  "get-stream": "^6.0.0",
63
63
  "into-stream": "^6.0.0",
64
+ "libnpmversion": "^3.0.0",
64
65
  "read-pkg-up": "^7.0.0",
65
66
  "semver": "^7.0.0",
66
67
  "tempy": "^1.0.0",
67
68
  "write-json-file": "^4.0.0"
68
69
  },
69
70
  "devDependencies": {
70
- "@html-validate/eslint-config": "5.3.1",
71
- "@html-validate/eslint-config-jest": "5.3.1",
72
- "@html-validate/prettier-config": "2.0.0",
73
- "@semantic-release/npm": "9.0.0",
74
- "@types/jest": "27.4.0",
71
+ "@html-validate/eslint-config": "5.4.12",
72
+ "@html-validate/eslint-config-jest": "5.4.11",
73
+ "@html-validate/prettier-config": "2.2.1",
74
+ "@semantic-release/npm": "9.0.1",
75
+ "@types/jest": "28.1.2",
75
76
  "codecov": "3.8.3",
76
- "fs-extra": "10.0.0",
77
- "got": "11.8.3",
78
- "jest": "27.4.7",
79
- "lerna": "4.0.0",
80
- "prettier": "2.5.1",
81
- "semantic-release": "19.0.2",
77
+ "fs-extra": "10.1.0",
78
+ "got": "11.8.5",
79
+ "jest": "28.1.1",
80
+ "lerna": "5.1.4",
81
+ "prettier": "2.7.1",
82
+ "semantic-release": "19.0.3",
82
83
  "stream-buffers": "3.0.2",
83
- "verdaccio": "5.4.0"
84
+ "verdaccio": "5.13.0"
84
85
  },
85
86
  "peerDependencies": {
86
87
  "@semantic-release/npm": ">= 7",
87
- "lerna": "^3.2 || ^4",
88
+ "lerna": "^3.2 || ^4 || ^5",
88
89
  "semantic-release": ">=15.0.0 <20.0.0"
89
90
  },
90
91
  "engines": {