diff --git a/commands/publish/README.md b/commands/publish/README.md index 52fbde62ff..dd8105b833 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 8293c8a0a3..f94a0baacb 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 9bb5eb39bb..6739066124 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 f9fe53a50d..6fac149990 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, diff --git a/core/lerna/schemas/lerna-schema.json b/core/lerna/schemas/lerna-schema.json index f052890fe1..15f6e91535 100644 --- a/core/lerna/schemas/lerna-schema.json +++ b/core/lerna/schemas/lerna-schema.json @@ -874,6 +874,9 @@ }, "continueIfNoMatch": { "$ref": "#/$defs/filters/continueIfNoMatch" + }, + "summaryFile": { + "$ref": "#/$defs/filters/summaryFile" } } }, @@ -1487,6 +1490,10 @@ "continueIfNoMatch": { "type": "boolean", "description": "Don't fail if no package is matched." + }, + "summaryFile": { + "type": "string", + "description": "A json summary report will be generated after all packages have been successfully published" } }, "commandOptions": {