8.1.29 • Published 7 months ago

carna v8.1.29

Weekly downloads
53
License
MIT
Repository
github
Last release
7 months ago

Carna

npm David Release GitHub

Global management of the config files

Installation

npm install carna -D

Never install carna globally, but always into the local context.

Quick Start

To run carna, execute the following command:

npx carna

Commands

The following commands are available:

CommandsDescription
analyseRun the code quality tools
testRun the tests
licenseChecks for incompatible licenses
buildBuild the application
startRun a script
manageRun general conditions check
ciRun different Tasks as unit
gitHandler for the git hooks

For the help text, execute npx carna --help and the individual commands npx carna <command> --help.

Global options

OptionsshortDescription
--ciRun carna in CI mode
--helpShow help
--verbose-vPrint info messages
--vvvPrint info/debug messages
--versionShow version number

Hook system

Each time a command is executed, different hooks are called. Every hook corresponds to a script in the npm package.json.

The hooks have the structure <pre|post>carna:<task>.

If you add the option --verbose when calling a command, all possible hooks will be displayed.

The analyse task

Run the code quality tools

When the command is executed, only the changed or new files are checked. If all files are to be checked, then the parameter --all must be set. If the .git folder does not exist, all files are always checked.

Options

OptionsshortDescription
--all-aChecks all files
--path-pChecks only files in the specified path
--only-oRun a single code quality tool
Choices: eslint, prettier, typescript

Exit codes

Exit codeDescription
0Success
1task failed

The test task

Runs the unit, integration and other tests with jest.

Each subfolder in the tests folder is a test project, such as unit or integration test. By default, the projects unit, integration and e2e are created. For a new test project, a folder must be created in the tests folder and the jest-config must be adjusted.

The test projects are executed in the following order: unit, integration, e2e and the rest alphabetically.

The Code Coverage Threshold can be configured in .carnarc.json.

For helper functions and/or functions for multiple test projects can be stored in the folder test/shared. This folder is not interpreted as a test project. Likewise, the folder test/type is ignored, since this is for type tests and are checked by Typescript directly.

If there is an pre.[js|ts] or post.[js|ts] file in the test project folder, then it is called before or after from the respective test project.

If there is an setupTests.[js|ts] file in the test project folder, then the file is called before each test file.

Options

OptionsshortDescription
--project-pRun only the tests of the specified projects
--runInBand-iRun all tests serially in the current process
--updateSnapshot-uUse this flag to re-record every snapshot that fails during this test run
--watch-wWatch files for changes and rerun tests related to changed files

Exit codes

Exit codeDescription
0Success
1task failed

The build task

Build the application

Options

OptionsshortDescription
--watch-wWatch files for changes and rebuild the changed files (only for monorepo's).

Exit codes

Exit codeDescription
0Success
1task failed

The start task

Calls the application directly, without build process.

Options

OptionsshortDescription
--script-sScript to be called (default: src/index.[ts\|js])
--watch-wWatch files for changes and rerun script
--build-dependencies-bIn a monorepo, all packages are built beforehand
--clear-console-cClear console on each restart (only in watch mode)
--pino-pretty-pEnables the pino log formatter

Exit codes

Exit codeDescription
0Success
1task failed

The manage task

The task analyzes...

  • ...the structure of package.json. In the carna config file the subtask can be configured under the point packageLint.

  • ...if there are orphaned packages. In the carna config file the subtask can be configured under the point deps.

  • ...the license compatibility of each dependency. In the carna config file the subtask can be configured under the point license. The license is read from the package.json or from another source from the dependency. The compatibility list is used to validate the license for compatibility.

    If you think that an assignment is incorrect or can be added, please submit a pull request with the change in the compatibility list or license list.

    If the project uses an unknown license, the compatibility check will be disabled.

    Note: License compatibility checking is only a suggestion and it is not legal advice. If you would like to have a legally binding assessment, please contact a lawyer.

Options

None

Exit codes

Exit codeDescription
0Success
1task failed

The ci task

Run build, analyse, tests, license and deps tasks. This command is intended for execution in a CI.

Options

OptionsshortDescription
--build-bExecutes additionally the build process

Exit codes

Exit codeDescription
0Success
1task failed

The git task

The tasks will be automatically called by husky (via git hooks).

The following hooks exists:

  • commit: Checks the files in staged with a part of analyse command (git-hook: pre-commit).
  • msg: Checks the git commit message and run the other part of analyse and test, license and deps (git-hook: commit-msg).

Options

OptionsDescription
--hookThe git hook to execute (Choices: commit, msg)
--editPath to the COMMIT_EDITMSG file (only by msg hook)

Exit codes

Exit codeDescription
0Success
1task failed

Carna config file

Carna can be adjusted via the configuration file .carnarc.json. The file is structured as follows

{
  deps: {
    // Disables the verification
    disable: false,

    ignore: {
      // Ignores the packets when checking whether a packet is used or not
      packages: [],
    },
  },

  license: {
    // Disables the verification
    disable: false,

    // Whether to merge or replace the existing list with the list defined here
    replaceAliaseList: false,
    replaceCompatibleList: false,
    replaceHeuristicList: false,

    // If the license cannot be extracted, a license can be defined here
    aliases: {
      // <package-name>: { <version>: <existing license name> }
    },

    // List which license is compatible with the other licenses
    compatibilities: {
      // <license-name>: ['<compatible license>', '<...>'],
    },

    // The license name must be entered at the top of the combalitity list
    // Important: The name should **not** be an existing license
    heuristics: {
      // Searches with the regexp in the corresponding files (z.B. license/readme/markdown files)
      // <license-name>: /<search-regexp>/u
    },

    ignore: {
      // The packages are ignored during the license check
      packages: [],
    },
  },

  packageLint: {
    // Disables the verification
    disable: false,
  }

  log: {
    ignore: {
      // Will be passed 1to1 to --ignore argument from pino-pretty
      keys: [],
    },
  },

  test: {
    coverage: {
      // Overwrites default coverage threshold (value: number or tuple with two numbers)
      threshold: {
        statements: 90,
        branches: 90,
        functions: 90,
        lines: [50, 90],
      },
    },
  },
}

Default config files

It is possible to overwrite the default config files.

The following files can be overwritten and must be created in the root folder of the project. If the existing configuration is only to be extended, the corresponding code block must be copied into the file.

.commitlintrc.json

{
  "extends": "@kettil"
}

.eslintrc.json

{
  "extends": "@kettil"
}

.prettierrc.json

The configuration cannot be extended, but is overwritten.

For VS Code users the entry prettier.configPath in the .vscode/settings.json must be removed.

{
  "printWidth": 120,
  "tabWidth": 2,
  "useTabs": false,
  "semi": true,
  "singleQuote": true,
  "trailingComma": "all",
  "bracketSpacing": true,
  "arrowParens": "always",
  "overrides": [
    { "files": "{*.ts,*.tsx}", "options": { "parser": "typescript" } },
    { "files": "{*.json,.prettierrc}", "options": { "parser": "json" } },
    { "files": "*.md", "options": { "parser": "markdown" } },
    { "files": "*.scss", "options": { "parser": "scss" } },
    { "files": ["*.yml", "*.yaml"], "options": { "parser": "yaml" } },
    { "files": "*.html", "options": { "parser": "html" } }
  ]
}
8.1.28

9 months ago

8.1.29

7 months ago

8.1.26

1 year ago

8.1.25

1 year ago

8.1.27

1 year ago

8.1.22

2 years ago

8.1.21

2 years ago

8.1.24

2 years ago

8.1.23

2 years ago

8.1.19

2 years ago

8.1.18

2 years ago

8.1.20

2 years ago

8.1.11

2 years ago

8.1.10

2 years ago

8.1.13

2 years ago

8.1.12

2 years ago

8.1.15

2 years ago

8.1.14

2 years ago

8.1.17

2 years ago

8.1.16

2 years ago

8.1.8

2 years ago

8.1.7

2 years ago

8.1.9

2 years ago

8.1.0

2 years ago

8.1.2

2 years ago

8.1.1

2 years ago

8.0.4

2 years ago

8.1.4

2 years ago

8.1.3

2 years ago

8.1.6

2 years ago

8.1.5

2 years ago

8.0.0-beta.2

2 years ago

8.0.0-beta.1

2 years ago

8.0.0-beta.3

2 years ago

7.1.6

2 years ago

8.0.2-beta.1

2 years ago

8.0.1

2 years ago

8.0.0

2 years ago

8.0.3

2 years ago

8.0.2

2 years ago

7.1.5

2 years ago

7.1.4

2 years ago

7.1.3

2 years ago

7.1.2

2 years ago

7.1.1

2 years ago

7.0.5

2 years ago

7.0.4

2 years ago

7.1.0

2 years ago

6.2.10

2 years ago

6.2.13

2 years ago

6.2.14

2 years ago

6.2.11

2 years ago

6.2.12

2 years ago

6.2.7

2 years ago

6.2.6

2 years ago

6.2.9

2 years ago

6.2.8

2 years ago

7.0.0

2 years ago

7.0.3

2 years ago

7.0.2

2 years ago

7.0.1

2 years ago

6.1.0

3 years ago

6.1.1

3 years ago

6.2.5

2 years ago

6.2.4

2 years ago

6.2.1

2 years ago

6.2.0

3 years ago

6.2.3

2 years ago

6.2.2

2 years ago

6.0.0

3 years ago

5.3.1

3 years ago

5.3.0

3 years ago

5.4.1

3 years ago

5.4.0

3 years ago

5.1.1

3 years ago

5.2.0

3 years ago

5.2.0-beta.2

3 years ago

5.0.0-beta.8

3 years ago

5.0.0-beta.9

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

5.2.0-beta.1

3 years ago

5.1.0

3 years ago

5.0.0-beta.10

3 years ago

5.0.0-beta.6

3 years ago

5.0.0-beta.7

3 years ago

5.0.0-beta.4

3 years ago

5.0.0-beta.5

3 years ago

5.0.0-beta.2

3 years ago

5.0.0-beta.3

3 years ago

5.0.0-beta.1

3 years ago

4.13.0-beta.1

3 years ago

4.12.1

3 years ago

4.12.0

3 years ago

4.11.0

3 years ago

4.10.10

3 years ago

4.10.9

3 years ago

4.10.8

3 years ago

4.10.7

3 years ago

4.10.6

3 years ago

4.10.5

3 years ago

4.10.4

3 years ago

4.10.3

3 years ago

4.10.2

3 years ago

4.10.1

3 years ago

4.10.0

3 years ago

4.9.2

3 years ago

4.9.1

3 years ago

4.9.0

3 years ago

4.8.0

3 years ago

4.7.1

3 years ago

4.7.0

3 years ago

4.6.1

3 years ago

4.6.0

3 years ago

4.5.0

3 years ago

4.4.0

3 years ago

4.3.0

3 years ago

4.2.0

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.4.22

3 years ago

1.4.21

3 years ago

1.4.20

3 years ago

1.4.19

3 years ago

1.4.18

3 years ago

1.4.17

3 years ago

1.4.16

3 years ago

1.4.15

3 years ago

1.4.14

3 years ago

1.4.13

3 years ago

1.4.11

3 years ago

1.4.12

3 years ago

1.4.10

3 years ago

1.4.9

3 years ago

1.4.6

3 years ago

1.4.8

3 years ago

1.4.7

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago