Skip to content
⛰️ Scaffolding npm projects with build, test, lint and release scripts
JavaScript Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
bin
fixtures/host
lib
scripts
templates
.eslintignore
.eslintrc.js
.gitignore
.huskyrc.js
.lintstagedrc.js
.prettierrc.js
CHANGELOG.md
README.md
babel.config.js
jest.config.js
package.json
yarn.lock

README.md

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: build, 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 build Build JavaScript files through Babel
yarn run build:watch Build JavaScript files through Babel in watch mode
yarn run test Run tests using Jest
yarn run test:watch Run tests using Jest in watch mode
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

Building (with Babel)

aberlaas build will build all files located in ./lib into ./build by default. You can alter the behavior with the following options:

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.

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 YAML yaml-lint 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.

Releasing

aberlaas release will build the package and release it 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 -n to start a dry-run. It will simulate a release but won't actually push anything to GitHub or npm.

Note that by default it will also build and test everything before pushing and stopping if any of those steps fails. You can disable those checks with the --no-build and --no-test flags.

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.

You can’t perform that action at this time.