Skip to content

elfrank/sample-nodejs-project

Repository files navigation

sample-nodejs-project

License: MIT semantic-release Maintainability Test Coverage

sample-nodejs-project gets you started with a walking skeleton for your next node.js library or app.

Forget about the boilerplate stuff and get started on your project.

Highlights

  • Backwards compatible Javascript through Babel. Modify .babelrc to update its configuration.
  • Typescript support. Modify .tsconfig.json, tsconfig.cjs.json and tsconfig.esm.json to update its configuration.
  • Linting through ESlint. Modify .eslintrc to update its configuration.
  • Docs Generation through Typedoc.
  • Unit Testing through Mocha.
  • Unit Testing Coverage through Istanbul. Modify .nycrc.json to update its configuration.
  • Unit Testing Coverage reporting through CodeClimate.
  • Standard Commit Messages through commitizen.
  • Automated releases through semantinc-release. Modify release.config.js to update its configuration.
  • Github Actions for PR commits: linting, testing, coverage, CodeClimate code quality
  • Github Actions for merging PRs: automated releases (Github tagging only).

Setup

Install nvm (node version manager)

# install and use the version specified in .nvmrc
nvm i

# install global packages
npm install -g commitizen

# install node_modules
npm install

Scripts

# run TypeScript compilation process
npm run build

# build docs
npm run docs

# run linter
npm run lint src/

# run unit tests without coverage
npm run test

# run unit tests with coverage
npm run test:coverage

# run example
node examples/hello-world.cjs.js

Forking

Besides the instructions above, do the following:

  1. Delete CHANGELOG.md. It will be regenerated in your first release.
  2. Set the version field in package.json to 1.0.0.
  3. Update attributes in package.json.
  4. Update the README.md accordingly.
  5. Generate the following secrets for your Github Actions (Repo -> Settings -> Secrets)
  • GH_TOKEN: Create a personal token. This is needed for the automated semantic releases.
  • CC_TEST_REPORTER_ID: Once you add your repo to CodeClimate, go to Repo Settings -> Test Coverage. Get the Test Reporter ID from there. This is needed to send the test coverage to CodeClimate.

How-tos

  • Taking advantage of commitizen auto-formatting
# instead of git commit, use
git cz
  • Testing semantic releases locally
GITHUB_TOKEN=your_token npx semantic-release --dry-run