requirements
    TypeScript icon, indicating that this package has built-in type declarations

    1.4.1 • Public • Published

    requirements

    npm coveralls dependency Status snyk code style: prettier

    Validate your project's software requirements.

    requirements-screenshot

    install

    $ npm install -D requirements
    $ yarn add --dev requirements

    setup

    Scaffold a new requirements.config.js configuration file

    $ npx requirements --init

    config

    Configure the requirements.config.js file in your project root.

    module.exports = {
      software: {
        node: '*',
        yarn: '~1.17.3',
        nginx: {
          semver: '>= 1.16.x',
          optional: true, // optional (won't fail)
          installMessage: '<install instruction>', // custom message when binary is not found
          updateMessage: '<update instruction>', // custom message when binary has wrong version
        },
        httpd: {
          semver: '^1.x',
          flag: '-v', // custom version flag
        },
      },
    };

    check requirements

    Run requirements command in the project root. By default it will try to find the requirements.config.js file.

    $ npx requirements

    Or use a custom path:

    $ npx requirements --config <filepath>

    CLI options

    $ npx requirements --help
    Options:
      --help, -h     Show help                                             [boolean]
      --version, -v  Show version number                                   [boolean]
      --init, -i     Create a requirements.config.js file
      --config, -c   Path to the configuration file
                                                 [default: "requirements.config.js"]
      --force, -f    Succeeds even if not all requirements are satisfied
                                                          [boolean] [default: false]
      --quiet, -q    Only output when errors are present                   [boolean]
      --debug        Print raw data                                        [boolean]
    

    require('requirements')

    const { checkSoftware, renderTable } = require('requirements');
    
    (async () => {
      const result = await checkSoftware({ node: '*' });
      console.log(renderTable(result));
    })();

    checkSoftware() returns an Array with results

    [
      {
        bin: 'node',
        semver: '*',
        installed: true,
        version: '12.8.1',
        satisfies: true,
      },
    ];

    testing

    # test functionality
    yarn build
    node bin/requirements.js --config tests/requirements.config.js
    
    # unit tests
    yarn test

    license

    The MIT License (MIT)

    Copyright (c) 2017-2020 Steven Chim

    Install

    npm i requirements

    DownloadsWeekly Downloads

    52

    Version

    1.4.1

    License

    MIT

    Unpacked Size

    27.6 kB

    Total Files

    24

    Last publish

    Collaborators

    • avatar