auth0-toolkit
v0.0.1-alpha.61
Published
A toolkit for common scripts used at Auth0
Downloads
15
Readme
Inspired by "Tools without config", "The Melting Pot of JavaScript", and kcd-scripts.
Usage
- Create a project:
npm init new-auth0-project
- If it's a TypeScript project: add
types
intopackage.json
. For example:{ "types": "lib/index" }
- Install auth-toolkit:
npm install --save-dev auth0-toolkit
- Run the initialization script:
npx auth0-toolkit init
- Use included scripts:
npm run build -- --watch
npm run build:doc
npm run validate
npm run format
npm run lint
- ... etc.
Configuration
This toolkit exposes a bin called auth0-toolkit
. All scripts are stored in lib/scripts
and all configuration files are stored in lib/config
.
The toolkit determines whether a project is a TypeScript project or JavaScript project depending on whether the types
property exists in package.json
.
All included tools can have their configuration overwritten by adding flags to the command or by including configuration files in the root of your project. For example: running auth0-toolkit format
will run Prettier with the included configuration, but having a .prettierrc
in your project will cause the toolkit to use that configuration instead.
Overriding Configuration
During the toolkit setup process, configuration files for the libraries used by the toolkit are created in the project root. Libraries natively supporting an "extend" feature will use those by default to allow for toolkit configuration to be used as a starting point.
All configuration can be overridden with configuration files, package.json
properties, or arguments passed to the toolkit binary.
API
Modules
build
Properties
| Name | Default | Description | | ------------ | ---------------- | --------------------------------------------------------------------------------------- | | [--out-dir] | lib | Output destination for built files. (Babel) | | [--outDir] | lib | Output destination for built files. (Typescript) | | [--no-clean] | | If present, does not clean target directory. | | [OTHERS] | | All CLI options used by related binary. (tsc or babel) |
Example
$ npm run build -- --watch --preserveWatchOutput
$ npx auth0-toolkit build
$ npx auth0-toolkit build --watch --preserveWatchOutput
doc
Properties
| Name | Description | | -------- | ---------------------------------------------------------------------- | | [OTHERS] | All CLI options used by related binary. (jsdoc2md) |
Example
$ npm run build:doc
$ npx auth0-toolkit doc
format
Properties
| Name | Description | | ------------ | ------------------------------------------------------------------------------------ | | [--no-write] | If provided, files will not be written to disk. (Defaults to writing to disk) | | [OTHERS] | All CLI options used by the related binary. (prettier) |
Example
$ npm run format
$ npx auth0-scripts format
init
Properties
| Name | Description | | ------------ | ----------------------------------------------------------------------------------------------- | | [...files] | Files to lint | | [--no-cache] | Disables ESLint --cache arg which is added by this script. | | [OTHERS] | All CLI options used by the related binary. (eslint or tslint) |
Example
$ npx auth0-toolkit init
lint
Properties
| Name | Description | | ------------ | ----------------------------------------------------------------- | | [...files] | A list of files to lint. | | [--no-cache] | Disables ESLint's --cache arg. | | [OTHERS] | All CLI options used by related binary. (TSLint or ESLint) |
Example
$ npm run lint
$ npm run lint my-file.ts -- --config my-config.json
$ npx auth0-toolkit lint
$ npx auth0-toolkit lint --no-cache
$ npx auth0-toolkit lint my-file.ts
precommit
Properties
| Name | Description | | -------- | ----------------------------------------------------------------------------- | | [OTHERS] | All CLI options used by the related binary. (lint-staged) |
test
Properties
| Name | Description | | ------------ | ---------------------------------------------------------------------- | | [--no-watch] | If provided, tests run once. (Default is watch mode) | | [OTHERS] | All CLI options used by the related binary. (jest) |
Example
$ npm run test
$ npx auth0-toolkit test
validate
Properties
| Name | Description | | ------------ | --------------------------------------------- | | [...scripts] | A list of scripts to specifically run. |
Example
$ npm run validate custom-validator
$ npx auth0-toolkit validate
$ npx auth0-toolkit validate custom-validator,another-validator
Author
License
This project is licensed under the MIT license. See the LICENSE file for more info.