From 4a088e11a16a97821406eb00a9b8e51abf8ac117 Mon Sep 17 00:00:00 2001 From: Hamish Buckmaster Date: Wed, 9 Nov 2022 19:43:58 +1100 Subject: [PATCH] chore: pr feedback --- commands/publish/README.md | 11 +++++++---- commands/publish/__tests__/publish-command.test.js | 7 +++++-- commands/publish/command.js | 3 +-- commands/publish/index.js | 4 +++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/commands/publish/README.md b/commands/publish/README.md index 52fbde62ff4..dd8105b8333 100644 --- a/commands/publish/README.md +++ b/commands/publish/README.md @@ -65,7 +65,7 @@ This is useful when a previous `lerna publish` failed to publish all packages to - [`--tag-version-prefix`](#--tag-version-prefix) - [`--temp-tag`](#--temp-tag) - [`--yes`](#--yes) -- [`--summary-file `](#--summary-file) +- [`--summary-file `](#--summary-file) ### `--canary` @@ -119,11 +119,10 @@ This option can be used to publish a [`prerelease`](http://carrot.is/coding/npm_ > Note: the `latest` tag is the one that is used when a user runs `npm install my-package`. > To install a different tag, a user can run `npm install my-package@prerelease`. -> ### `--force-publish` -To be used with [`--canary`](#--canary) to publish a canary version of all packages in your monorepo. This flag can be helpful when you need to make canary releases of packages beyond what was changed in the most recent commit. +To be used with [`--canary`](#--canary) to publish a canary version of all packages in your monorepo. This flag can be helpful when you need to make canary releases of packages beyond what was changed in the most recent commit. ``` lerna publish --canary --force-publish @@ -307,7 +306,11 @@ Useful in [Continuous integration (CI)](https://en.wikipedia.org/wiki/Continuous ### `--summary-file` ```sh -lerna publish --canary --yes --summary-file ./output.json +# Will create a summary file in the root directory ./lerna-publish-summary.json +lerna publish --canary --yes --summary-file +# Will create a summary file in the root directory ./some/other/dir/lerna-publish-summary.json +lerna publish --canary --yes --summary-file ./some/other/dir + ``` When run with this flag, a json summary report will be generated after all packages have been successfully published (see below for an example). diff --git a/commands/publish/__tests__/publish-command.test.js b/commands/publish/__tests__/publish-command.test.js index 8293c8a0a32..f94a0baacb5 100644 --- a/commands/publish/__tests__/publish-command.test.js +++ b/commands/publish/__tests__/publish-command.test.js @@ -374,7 +374,7 @@ Map { it("creates the summary file", async () => { const cwd = await initFixture("normal"); const fsSpy = jest.spyOn(fsmain, "writeFileSync"); - await lernaPublish(cwd)("--summary-file", "./output.json"); + await lernaPublish(cwd)("--summary-file", "./outputs"); const expectedJsonResponse = [ { packageName: "package-1", version: "1.0.1" }, @@ -383,7 +383,10 @@ Map { { packageName: "package-4", version: "1.0.1" }, ]; expect(fsSpy).toHaveBeenCalled(); - expect(fsSpy).toHaveBeenCalledWith("./output.json", JSON.stringify(expectedJsonResponse)); + expect(fsSpy).toHaveBeenCalledWith( + "./outputs/lerna-publish-summary.json", + JSON.stringify(expectedJsonResponse) + ); }); }); describe("--verify-access", () => { diff --git a/commands/publish/command.js b/commands/publish/command.js index 9bb5eb39bb6..67390661240 100644 --- a/commands/publish/command.js +++ b/commands/publish/command.js @@ -111,8 +111,7 @@ exports.builder = (yargs) => { type: "boolean", }, "summary-file": { - // Json output. - hidden: true, + // generate lerna publish json output. type: "string", }, // y: { diff --git a/commands/publish/index.js b/commands/publish/index.js index f9fe53a50d5..6fac1499909 100644 --- a/commands/publish/index.js +++ b/commands/publish/index.js @@ -262,7 +262,9 @@ class PublishCommand extends Command { if (this.options.summaryFile) { // create a json object and output it to a file location. - const filePath = this.options.summaryFile || "./output.json"; + const filePath = this.options.summaryFile + ? `${this.options.summaryFile}/lerna-publish-summary.json` + : "./lerna-publish-summary.json"; const jsonObject = this.packagesToPublish.map((pkg) => { return { packageName: pkg.name,