In this post I’ll cover my workflow of creating env-inject-file, a command line utility for populating config files with environment variable placeholders and my first published npm package.
My advice is protect your branch, write descriptive commit messages, use branch management.
To enable branch protection, go to repository Settings -> Branches -> Add Rule.
. ├── bin │ └── env-inject-file.js ├── env-inject-file.js ├── LICENSE ├── package.json ├── .travis.yml ├── .npmignore ├── README.md └── test ├── cmdline.spec.js └── program.spec.js
First thing that users see should contain project description, instructions to install and use. Badges in README make it stand out.
Write unit tests. Tests confirm that code is valid and enrich project documentation.
MIT is a good choice for opensource. Choosing an opensource license is easier with https://choosealicense.com/.
npm init, contains project information for npm.
Configuration for excluding files from your package. Check that exclusion works with
Configuration for travis continuous integration:
language: node_js node_js: - v10 - v8 - v6 before_install: - npm i [email protected]^6 -g install: - npm install script: - npm test notifications: email: false
On every build travis will install dependencies, run tests for 3 versions of node, then update Github PR status to pass or fail.
- Create an account with npm, then authenticate in root project console type:
- After PR merge, you can bump your project version.
npm version patch|minor|major
Command will bump version in
package.json, create a git commit with
<version>message, and git tag
- Push version commit and tag, merge to master
git push && git push --tags
- Publish to npm
Often can happen that you accidentally published your library. For packages published less than 72 hours ago, you can use this command:
npm unpublish [email protected] --force
You might be interested into publishing to a private github registry.