Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Extend guidelines for managing packages and publishing them to npm #8768

Merged
merged 12 commits into from
Aug 22, 2018

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Aug 9, 2018

Description

As discussed during the JavaScript weekly chat earlier this week, I opened pull request to extend our guidelines for managing and publishing npm packages with Lerna.

TODO

  • creating new packages
  • Babel dependencies
  • maintaining changelogs

@gziolo gziolo added [Type] Developer Documentation Documentation for developers npm Packages Related to npm packages labels Aug 9, 2018
@gziolo gziolo self-assigned this Aug 9, 2018
@gziolo gziolo added the [Status] In Progress Tracking issues with work in progress label Aug 9, 2018
@gziolo
Copy link
Member Author

gziolo commented Aug 9, 2018

Problem: Publishing modules to npm can be difficult because it is not always clear at the time of publishing to what version the package should be updated. The individual performing the publish is not always the same as the contributors who had proposed changes to the package.

Options:

  • Adopt conventional commits to enable automatic versioning (pull request)
    • Issue: This is hard to enforce
  • Encourage developers to introduce relevant changelog entries as part of proposed changes. The type of change should indicate versioning requirements.
    • Issue: Not every version bump is caused by directly by new changes, sometimes indirectly by updated dependencies.
    • Issue: Prone to frequent merge conflicts with many developers adding entries to the same text file.

Decision: Encourage developers to introduce changelog entries and evaluate success in a future meeting.

@gziolo gziolo requested a review from hypest August 13, 2018 11:17
@gziolo
Copy link
Member Author

gziolo commented Aug 13, 2018

@hypest feel free to include react-native in the package.json example. We probably should add a note that it should be added only for packages which are meant to be sent to the user. It doesn't make sense in the context of build tools.

@aduth
Copy link
Member

aduth commented Aug 14, 2018

It occurred to me: Maybe it shouldn't be the releaser who touches the version, but instead the developer who proposes a change. If, for example, a current changelog appears as:

## v1.2.2 (Unreleased)

- Fix: ...
- Fix: ...
  • If I need to add something considered a bugfix, I add the "Fix:" item and change version to 1.2.3 leave the version as 1.2.2 (see correction notes)
  • If it's a new feature I'm adding, I add the "New:" item and change version to 1.3.0
  • If it's a breaking change I'm introducing, I add the "Breaking:" item and change version to 2.0.0
    • And at this point it becomes extremely obvious to me whether I should consider pushing 1.2.2 before introducing the breaking change so as to ensure the fixes are shipped separate to a major version bump.

Thoughts? In retrospect, this is my workflow for how I manage my own personal projects.

@gziolo
Copy link
Member Author

gziolo commented Aug 14, 2018

That’s a really good idea. We can almost copy and paste what you described. I would also encourage grouping by:

  • Breaking
  • New
  • Fix

And skip everything else from the changelog. This is what popular repositories do usually.

@aduth
Copy link
Member

aduth commented Aug 15, 2018

A correction to my previous comment, which is worth clarifying as it's a potential point of confusion:

If I need to add something considered a bugfix, I add the "Fix:" item and change version to 1.2.3

In my above example, since the existing "1.2.2" version is marked unreleased, I shouldn't change the version at all.

Similarly, if the version was "1.3.0 (Unreleased)" and I was adding a new feature, I wouldn't change the version.

The version bump is only necessary if (a) there are no other unreleased changes or (b) the type of change I'm introducing is incompatible (more severe) than the other unreleased changes.

@gziolo gziolo force-pushed the update/publishing-docs branch from a9889dd to 3f52844 Compare August 21, 2018 09:43
@gziolo gziolo removed the [Status] In Progress Tracking issues with work in progress label Aug 21, 2018
@gziolo
Copy link
Member Author

gziolo commented Aug 21, 2018

This is ready for a final check. I included all suggestions shared by @aduth. Thanks for help 💯

@gziolo gziolo added this to the 3.7 milestone Aug 21, 2018
Copy link
Member

@ntwb ntwb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gziolo
Copy link
Member Author

gziolo commented Aug 21, 2018

@ntwb, thanks for your verbiage tweaks 🙇

@tofumatt tofumatt self-assigned this Aug 21, 2018
@gziolo gziolo requested review from ntwb and tofumatt August 21, 2018 11:28
CONTRIBUTING.md Outdated
}
}
```
It assumes that code is goind to be located in `src` folder and will be transpiled with `Babel`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "goind" -> "going"

CONTRIBUTING.md Outdated
```
3. `README.md` file containing at least:
- Package name.
- Package description.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in package.json ? (Should we mention this?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't always the case. Not sure to be honest.

CONTRIBUTING.md Outdated
- Package description.
- Installation details.
- Usage example.
- `Code is Poetry` logo.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does one find this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should include the snippet. It's copy and paste anyways.

CONTRIBUTING.md Outdated

### Maintaining changelogs

It isn't easy task to maintain dozens of npm packages. That's why we decided to introduce `CHANGELOG.md` files for all packages to simplify the release process.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar: "It isn't an easy"

CONTRIBUTING.md Outdated
```md
## v1.2.2 (Unreleased)

#### Bug Fix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on document structure, why would this be an H4 following an H2 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I blame Babel, will update :)

CONTRIBUTING.md Outdated

- If you need to add something considered a bug fix, you add the item to `Bug Fix`section and leave the version as 1.2.2.
- If it's a new feature you add the item to `New Feature` section and change version to 1.3.0.
- If it's a breaking change you want to introduce, you add the item to `Breaking Change` section and bump the version to 2.0.0.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any other changes which wouldn't fall neatly under one of these classifications? I've personally observed some "Internal" / "Housekeeping" type changes which don't necessarily contribute to public-facing consumer, though I suppose could have some place in the SemVer hierarchy. These are also items it's not entirely clear we'd need to include at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are also items it's not entirely clear we'd need to include at all.

It might get tricky because Lerna will bump version anyways. We probably should skip them as they aren't that important but we still will have a new version released. It might sometimes happen only because one of the packages maintained by Lerna listed in dependencies has version bump.

Copy link
Member

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this took me ages to get to, I got distracted with some other PRs! 😓

I made a few tweaks and tidied up some of the docs based on @aduth's comments. The rest looks good to me. 👍

CONTRIBUTING.md Outdated

### Maintaining changelogs

Maintaining dozens of npm packages is difficult–it can be tough to keep track of changes. That's why we use `CHANGELOG.md` files for each package to simplify the release process. All packages should follow the [Semantic Versioning (`semver`) specification](https://semver.org/).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ultimate nitpick! If we're going to be fancy with dashes, we should use the correct one: here an en dash should be the em dash 😄

Before:
After:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omg you’re totally right and I’m often the one to comment on that. I have no excuse!

@tofumatt
Copy link
Member

Sorry about my rubbish commit message, I made it from my iPad and fat-fingered the return key.

@gziolo
Copy link
Member Author

gziolo commented Aug 22, 2018

Thanks @tofumatt and @aduth for your help 🙇 Let's see how those guidelines influence daily workflow and iterate later.

@gziolo gziolo merged commit abac58c into master Aug 22, 2018
@gziolo gziolo deleted the update/publishing-docs branch August 22, 2018 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm Packages Related to npm packages [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants