Skip to content

Commit

Permalink
chore: pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
HamishBuckmaster committed Nov 9, 2022
1 parent c51f031 commit 4a088e1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
11 changes: 7 additions & 4 deletions commands/publish/README.md
Expand Up @@ -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 <dir/filename>`](#--summary-file)
- [`--summary-file <dir>`](#--summary-file)

### `--canary`

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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).
Expand Down
7 changes: 5 additions & 2 deletions commands/publish/__tests__/publish-command.test.js
Expand Up @@ -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" },
Expand All @@ -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", () => {
Expand Down
3 changes: 1 addition & 2 deletions commands/publish/command.js
Expand Up @@ -111,8 +111,7 @@ exports.builder = (yargs) => {
type: "boolean",
},
"summary-file": {
// Json output.
hidden: true,
// generate lerna publish json output.
type: "string",
},
// y: {
Expand Down
4 changes: 3 additions & 1 deletion commands/publish/index.js
Expand Up @@ -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,
Expand Down

0 comments on commit 4a088e1

Please sign in to comment.