Detalhes do pacote

env-linter

merkle-open4.5kMIT2.0.0

Ensures that all developers on your project use the same node version, install dependencies in an unambiguous manner and utilize githooks.

cli, env, hooks installed, merkle

readme (leia-me)

env-linter

Ensures that all developers on your project use the same, secure LTS version of node, install dependencies in an unambiguous manner and utilize githooks.

npm Build Status License
env-linter screencast

Usage example

Feel free to use env-linter in any way that makes sense for your project. Here is an example of how env-linter could be applied as part of your package.json:

{
  "postinstall": "env-linter -s -se -d -vs 'node=16.x.x,npm=8.x.x'",
  "prestart": "env-linter -h -vs 'node=16.x.x,npm=8.x.x'",
  "lint-staged": {
    "**/package.json": ["env-linter -s -d"]
  }
}

You can skip all env-linter checks by using the environment variable ENV_LINTER_SKIP=true. This could be useful on certain CI environments which are not automatically detected by env-linter.

API usage

const { api } = require('env-linter');

await api({
  versions: 'node=16.x.x,npm=8.x.x',
  hooksInstalled: true,
  saveExact: true,
  dependenciesExactVersion: true,
  lts: true,
  security: true,
});

Options

-vs, --versions [string]

Checks the installed versions of global packages or programs like node, npm, yo, etc. against a required version. For example calling env-linter --versions 'node=16.x.x' will ensure that version 16 of node is being used. Multiple versions can be checked by separating them with a comma (eg. --versions 'node=16.x.x,npm=8.x.x,yo=4.x.x'). env-linter will stop any further process-execution if a package or program does not satisfy the required version.

Calling env-linter with --versions but without any arguments will compare the installed node-version with the node-version from the .node-version file.

In any case, the used node version is compared to the list of official node-releases and process-execution is stopped if the used npm version is older than the npm version that node comes with.

-h, --hooksInstalled

Checks if git-hooks are installed (i.e. husky installed). env-linter will stop any further process-execution if git-hooks are not installed.

-se, --security

Checks if the used node version is considered secure according to the current list of node releases. If a newer node-version is available which was released due to a security concern, env-linter will stop any further process-execution. Find out more about the security-flag in this github issue.

-s, --saveExact

Checks if the npm option save-exact is enabled, either through a .npmrc file in the project or in the user-directory. env-linter will stop any further process-execution if save-exact is disabled.

-d, --dependenciesExactVersion

Checks if the version definitions of the dependencies and devDependencies in the package.json (or in a monorepository all available packages) are fitting our standards, which means; no approximate versions eg. tilde ~ or caret ^, no star * wildcard and no tarball embeds via https://*.

-l, --lts

Checks if the used node version is a LTS version. Here is some more information why it might be a good idea to use an LTS version.

Contributing

You want to contribute to the env-linter? That's awesome!

License

MIT License

changelog (log de mudanças)

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.0.0 (2024-01-30)

⚠ BREAKING CHANGES

  • chore: drops node 14 & 16 support (8dc8ba8)

1.0.0 (2022-05-19)

⚠ BREAKING CHANGES

  • chore: remove node v10 support (ea757b8)
  • chore: remove node v12 support (72e200c)

0.5.1 (2021-08-30)

0.5.0 (2021-08-14)

Features

  • hooks: add support for husky v6 (32d9ab5)
  • hooks: adjust detection of hooks for husky 7 (e0570df)
  • log-messages: show npm version in wrong npm version log message (a58df21)
  • log-messages: show why is this link next to the warnings (f94fa41)
  • security: add option to check for secure node version (902ba3b)
  • security: Check for higher minor security version inside used major version; adjust error and success messages; adjust security tests; (9504086)
  • security: Create security check based on lts; add test; (86096b7)

Bug Fixes

  • hooks: change detection of husky 6 hooks (f57c732)

0.4.0 (2020-09-17)

Features

0.3.2 (2020-07-09)

Bug Fixes

  • hooks-installed: allow detection of hooks from anywhere in the repository (ecc7805)

0.3.1 (2020-06-22)

Bug Fixes

  • install: remove env-linter post-install since it is causing issues on install (7ea513b)

0.3.0 (2020-06-22)

Features

  • env-var: add environment variable ENV_LINTER_SKIP to skip all env-linter checks (5eb4548)

Bug Fixes

  • ci: prevent version checks on CI environments (a54563f)

0.2.1 (2020-06-10)

Bug Fixes

  • use safer method to detect ci environments (13ef8d6)
  • update dependencies (c4d3ef9)

0.2.0 (2020-05-31)

Features

0.1.1 (2020-02-02)

Bug Fixes

  • allow newer npm versions (f71e340)
  • fix travis-badge url (f58cdf0)
  • update error-log for hooks-installed check (808c20f)

0.1.0 (2020-01-15)

Features