Skip to content

Instantly share code, notes, and snippets.

@db
Last active January 20, 2017 03:15
Show Gist options
  • Save db/065107eea4633d63dd88 to your computer and use it in GitHub Desktop.
Save db/065107eea4633d63dd88 to your computer and use it in GitHub Desktop.
Bulletproof NPM Workflow

Bulletproof NPM Workflow

Use the Bulletproof Git Workflow, and before code review:

pre-release package

Publish a pre-release version of the package:

npm publish my-package@1.0.0-my-work

prepare for integration testing

Create a branch in sites that use the package to test integration with the pre-release package:

git checkout -b feature/use-my-work
npm install my-package@1.0.0-my-work --save
git add package.json
git commit -m 'use package/@1.0.0-my-work for testing'

local testing

Test each of the sites locally; observe passed unit tests and expected functional changes manually:

npm install
npm run build
npm test
npm start

Fix any issues, follow the Bulletproof Git Workflow and re-release the pre-release package to retest changes:

npm unpublish my-package@1.0.0-my-work
npm publish my-package@1.0.0-my-work

Then in site:

rm -rf ./node_modules/my-package
npm install my-package@1.0.0-my-work

automation testing

If new functional automation tests are needed, add them to the site branch using the Bulletproof Git Workflow.

Run functional automation tests on the branch.

review

Proceed with "code review" and "review feedback" using the Bulletproof Git Workflow and when done, manage the release:

release preparation

  • Create the package Release Notes (use Github Release Notes).
  • Update the UPGRADE.md file with detailed upgrade instructions.
  • Check that artifacts and dot files are npmignored or gitignored as appropriate. .babelrc and .eslintrc can be particularly problematic.

Always gitignore dependencies, build output and logs. Always npmignore gitignored files and dev configs that may intefere with parent folder dev configs such as .babelrc, .eslintrc, .nvmrc.

release package

Release the package where <release-type> is major, minor or patch. When starting a new package, start from v1.0.0 to simplify and standardise the semver behaviour in NPM.

npm run release <release-type>
# eg. npm run release minor

Post notes to relevant slack channels.

use package

Use the Bulletproof Git Workflow to update each site that uses the package.

@felixSchl
Copy link

Thank you for this! Question, is

npm unpublish my-package@1.0.0-my-work
npm publish my-package@1.0.0-my-work

not the same as

npm publish -f my-package@1.0.0-my-work

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment