Quickly setup ESM React repositories with preconfigured functionality.
- Run
npm initand answer the required prompts - Run
npm install
Remove/replace the sample source files in src & stories with your own.
When adding source files, remember to add the build output file details to the files & exports fields of package.json and .gitignore.
🛠️ Build
npm run prepare runs all preparation clean & build scripts:
npm run prepare:cleanremoves any files as specified in thefilesfields of package.jsonnpm run prepare:csscompiles SCSS files fromsrcinto CSS files in the root directory with PostCSS & Sassnpm run prepare:jscompiles JavaScript source files into the root directory files with Babel
Note: the "prepare" Life Cycle Script runs automatically during publish, pack and on local install.
🚀 Deployments
The GitHub action release.yml is used to automatically deploy a release to the NPM package registry. The action requires the NPM_TOKEN secrets to be set.
📕 Storybook
npm run storybookwill run Storybook for local usenpm run storybook:buildwill build Storybook to./storybook-staticfor deployment use
🧪 Testing
The GitHub action node-tests.yml is used to run the code linting tests on pull requests and commit pushes into the main branch. The action requires the NPM_TOKEN secrets to be set.
npm run test runs the code linting tests:
npm run test:eslintruns the ESLint JavaScript linting checksnpm run test:prettierruns the Prettier code formatting checks
The GitHub action storybook-tests.yml is used to run the Storybook CI tests on pull requests and commit pushes into the main branch. The action requires the following secrets to be set:
NETLIFY_SITE_IDNETLIFY_TOKENNPM_TOKEN
These Storybook CI tests can also be run while running Storybook locally:
npm run test:storybookuses Storybook Test Runner to run Test Coverage, User Interaction, DOM & Image Snapshot tests.npm run test:storybook:updatewill update the Test Coverage results and any failing DOM & Image Snapshot snapshots
🕵️ Code linting
Husky & lint-staged are used to automatically run code linting checks on each file of a commit.
You can manually run linting error fixes with:
npm init
- Automatically resets
namewith--scopearg (if given) and directory name (lowercased) - Automatically resets
versionto0.0.0 - Automatically sets
repository,bugs&homepagefrom.git/config - Prompts user for
description(required) - Prompts user for
keywords,license&author(optional)
postprepare
npm run postprepare runs the following formatting:
- Updates package.json:
- Formats
repository&bugsto shorthand urls - Sorts the order of keys - see KEYS_ORDER
- Sorts the order of sub-keys alphabetically
- Sorts the order of
dependencies,devDependencies&peerDependenciesfields to the end
- Formats
- Updates the README.md:
- Uses the package
namefor the main title - Uses the package
descriptionfor the first paragraph after the main title - Keeps anything from the second title and below
- Uses the package
Note: the "postprepare" Life Cycle Script runs automatically on install.