aberlaas
Shared default config for npm packages.
Last updated 23 days ago by pixelastic .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install aberlaas 
SYNC missed versions from official npm registry.

Aberlaas

Start a new npm package with all the right tooling in place.

This package exposes the aberlaas script that can be used to perform the most common tasks on a package: lint, test and release. It also exposes the inner configuration of the tools it uses.

Installing aberlaas

Run yarn add --dev aberlaas && yarn run aberlaas init to bootstrap your project with Aberlaas scripts and configuration.

This will update your package.json to add custom scripts (located in ./scripts), and also add default configuration files for all the tool used at the root of your project.

The following table lists all the scripts added:

Script Description
yarn run husky:precommit Run before any commit (through Husky)
yarn run test Run tests using Jest
yarn run test:watch Run tests using Jest in watch mode
yarn run ci Run testing and linting in CI
yarn run lint Lint all supported file types
yarn run lint:fix Attempt to fix linting issues on all supported file types
yarn run release Release the module on npm

Linting

aberlaas lint will lint all supported files. Each file type can be linted independently with the corresponding argument (aberlaas lint --json will lint JSON files for example).

You can have Aberlaas trying to autofix linting issues by adding the --fix argument to your command.

The following table show the file types supported and the corresponding command and linter used.

Command File type Linter used Fixer used Config files
aberlaas lint All supported N/A N/A See individual file type
aberlaas lint --js JavaScript ESLint Prettier (through ESLint) .eslintrc.js or --config.js
aberlaas lint --css CSS Stylelint Prettier .stylelintrc.js or --config.css
aberlaas lint --json JSON jsonlint Prettier
aberlaas lint --yml (or --yaml) YAML yaml-lint Prettier
aberlaas lint --circleci .circleci/config.yml yaml-lint, circleci (if available in $PATH) Prettier

Testing (with Jest)

aberlaas test to run all the Jest tests in ./lib. You can alter the behavior with the following options:

CLI Argument Default value Description
[...] ./lib Files and directories to test.
--config jest.config.js Jest config file to use
--watch false If enabled, will listen for changes on files and rerun tests
--failFast false If enabled, will stop as soon as one test fails

Note that you can also pass any other command-line flag and they will be passed directly to Jest under the hood.

Jest is loaded with jest-extended allowing you to use new matchers like .toBeString(), .toStartWith(), etc.

New global variables

testName is available in all tests and contains the name of the current it/test block.

captureOutput allows to swallow any stdout/stderr output for later inspection. Output is stripped of any trailing newlines and ANSI characters.

const actual = await captureOutput(async () => {
  console.log('foo');
});
// actual.stdout = ['foo']

Precommit hooks

aberlaas uses husky and lint-staged to make sure all committed code follows your coding standard.

All css, js, json and yml files will be checked for parsing errors (using aberlaas lint internally), and if errors are found it will attempt to automatically fix them. If errors persist, it will prevent the commit and let you know which file contains errors so you can fix them before committing again.

Whenever you commit a .js file that has a test attached (or a test file directly), aberlaas test will be run on those files. If the tests don't pass, your commit will be rejected.

Those two measures ensure that you'll never "break the build", by committing invalid files or code that does not pass the test. If you want to ignore this behavior, you can always add the -n option to your git commit command to skip the hooks.

Releasing

aberlaas release will release the package to npm. It will update the version in package.json as well as creating the related git tag.

When called without arguments, it will prompt you for the next version to package. If called with an argument, this will be used as the next version number (for example, yarn run release 1.1.3). You can also use SemVer increments (for example, yarn run release minor).

Use --dry-run to start a dry-run. It will simulate a release but won't actually push anything to GitHub or npm.

Continuous Integration

aberlaas ci is triggered by CI Servers (currently only CircleCI is supported), and won't do anything when run locally.

When on a CI server it will first display the current node and yarn version, and then test and lint scripts in that order. It will fail whenever one of them fails, or succeed if they all succeed.

The node and yarn version used both locally and on the CI server will be the same. A .nvmrc file is created when running yarn run aberlaas init that will force local users to use the specified version. The same version is also specified in the Docker image pulled by CircleCI. As for Yarn, a local copy of the whole yarn program is added to the repository when first initializing it, so both locals and CI servers will use it.

Building (with Babel)

This command is still available but deprecated. aberlaas expect code to use node >= v12, and require in place of import

aberlaas build can build all files located in ./lib into ./build using Babel.

CLI Argument Default value Description
[...] ./lib Files or directory to build
--config ./babel.config.js Babel config file to use
--out-dir ./build Build directory
--ignore {pattern} empty Define patterns of files to ignore. Accepts globs, and can be passed more than once
--watch false If enabled, will listen for changes on files and rebuild

You can extend the internal Babel by editing the babel.config.js created at the root of your project.

File structure

./lib/configs contain the default configuration for all the tools. They are exported by the package and thus can be imported in userland.

./templates contains default configurations files copied to userland. Each extends the configuration exported in the previous files. Copying files to userland allows user to change the files if they want to change the behavior.

babel.config.js, .eslintrc.js, .stylelintrc.js, jest.config.js and .huskyrc.js are local configuration files for aberlaas itself. They eat their own dog food by referencing the same configs as above.

Related packages

Check renovate-config-aberlaas for the Renovate bot config used.

Where does the name Aberlaas come from?

Aberlaas is the base camp from which all great expedition start in the La Horde du Contrevent book. I felt it's a great name for a bootstrapping kit for modules.

For your convenience, aberlass and aberlas are added as aliases by default.

Current Tags

  • 1.4.3                                ...           latest (23 days ago)

120 Versions

  • 1.4.3                                ...           23 days ago
  • 1.4.2                                ...           2 months ago
  • 1.4.1                                ...           2 months ago
  • 1.4.0                                ...           2 months ago
  • 1.3.1                                ...           2 months ago
  • 1.3.0                                ...           2 months ago
  • 1.2.4                                ...           3 months ago
  • 1.2.3                                ...           3 months ago
  • 1.2.2                                ...           3 months ago
  • 1.2.1                                ...           3 months ago
  • 1.2.0                                ...           3 months ago
  • 1.1.1                                ...           4 months ago
  • 1.1.0                                ...           4 months ago
  • 1.0.3                                ...           4 months ago
  • 1.0.2                                ...           4 months ago
  • 1.0.1                                ...           4 months ago
  • 1.0.0                                ...           4 months ago
  • 0.11.4                                ...           5 months ago
  • 0.11.3                                ...           5 months ago
  • 0.11.2                                ...           5 months ago
  • 0.11.1                                ...           5 months ago
  • 0.11.0                                ...           5 months ago
  • 0.10.9                                ...           5 months ago
  • 0.10.8                                ...           5 months ago
  • 0.10.7                                ...           5 months ago
  • 0.10.6                                ...           5 months ago
  • 0.10.5                                ...           6 months ago
  • 0.10.4                                ...           6 months ago
  • 0.10.3                                ...           6 months ago
  • 0.10.2                                ...           6 months ago
  • 0.10.1                                ...           6 months ago
  • 0.10.0                                ...           6 months ago
  • 0.9.3                                ...           6 months ago
  • 0.9.2                                ...           6 months ago
  • 0.9.1                                ...           6 months ago
  • 0.9.0                                ...           6 months ago
  • 0.8.1                                ...           6 months ago
  • 0.8.0                                ...           6 months ago
  • 0.7.3                                ...           7 months ago
  • 0.7.2                                ...           7 months ago
  • 0.7.1                                ...           7 months ago
  • 0.7.0                                ...           7 months ago
  • 0.6.10                                ...           7 months ago
  • 0.6.9                                ...           8 months ago
  • 0.6.8                                ...           8 months ago
  • 0.6.7                                ...           8 months ago
  • 0.6.6                                ...           8 months ago
  • 0.6.5                                ...           8 months ago
  • 0.6.4                                ...           8 months ago
  • 0.6.3                                ...           8 months ago
  • 0.6.2                                ...           8 months ago
  • 0.6.0                                ...           8 months ago
  • 0.5.1                                ...           8 months ago
  • 0.5.0                                ...           8 months ago
  • 0.4.11                                ...           8 months ago
  • 0.4.10                                ...           8 months ago
  • 0.4.9                                ...           8 months ago
  • 0.4.8                                ...           8 months ago
  • 0.4.7                                ...           8 months ago
  • 0.4.6                                ...           8 months ago
  • 0.4.5                                ...           8 months ago
  • 0.4.4                                ...           8 months ago
  • 0.4.3                                ...           9 months ago
  • 0.4.2                                ...           9 months ago
  • 0.4.1                                ...           9 months ago
  • 0.4.0                                ...           9 months ago
  • 0.3.1                                ...           9 months ago
  • 0.3.0                                ...           9 months ago
  • 0.2.2                                ...           10 months ago
  • 0.2.1                                ...           10 months ago
  • 0.2.0                                ...           10 months ago
  • 0.1.10                                ...           10 months ago
  • 0.1.9                                ...           10 months ago
  • 0.1.8                                ...           10 months ago
  • 0.1.7                                ...           10 months ago
  • 0.1.6                                ...           a year ago
  • 0.1.5                                ...           a year ago
  • 0.1.4                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
  • 0.0.41                                ...           a year ago
  • 0.0.40                                ...           a year ago
  • 0.0.39                                ...           a year ago
  • 0.0.38                                ...           a year ago
  • 0.0.37                                ...           a year ago
  • 0.0.36                                ...           a year ago
  • 0.0.35                                ...           a year ago
  • 0.0.34                                ...           a year ago
  • 0.0.33                                ...           a year ago
  • 0.0.32                                ...           a year ago
  • 0.0.31                                ...           a year ago
  • 0.0.30                                ...           a year ago
  • 0.0.29                                ...           a year ago
  • 0.0.28                                ...           a year ago
  • 0.0.27                                ...           a year ago
  • 0.0.26                                ...           a year ago
  • 0.0.25                                ...           a year ago
  • 0.0.23                                ...           a year ago
  • 0.0.22                                ...           a year ago
  • 0.0.21                                ...           a year ago
  • 0.0.20                                ...           a year ago
  • 0.0.18                                ...           a year ago
  • 0.0.17                                ...           a year ago
  • 0.0.16                                ...           2 years ago
  • 0.0.15                                ...           2 years ago
  • 0.0.14                                ...           2 years ago
  • 0.0.13                                ...           2 years ago
  • 0.0.12                                ...           2 years ago
  • 0.0.11                                ...           2 years ago
  • 0.0.10                                ...           2 years ago
  • 0.0.9                                ...           2 years ago
  • 0.0.8                                ...           2 years ago
  • 0.0.7                                ...           2 years ago
  • 0.0.6                                ...           2 years ago
  • 0.0.5                                ...           2 years ago
  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 2
Last Day 0
Last Week 1
Last Month 24
Dependencies (35)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |