Skip to content

Contribution Guide

Corey Larson edited this page Feb 6, 2019 · 8 revisions

This project is a Lerna Monorepo. It contains multiple packages which are versioned and published to NPM separately.

The goal is to hopefully make it a seamless process to create, develop, and publish a new package from this repo.

Prerequisites

Install Supported Node Version

  • Node 11.3

Install Dependencies

Install this project's dependencies and all leaf package dependencies from the project root:

npm i && npm run bootstrap

Contribution Workflow

The following workflow should be followed:

Generate and Develop a New Component

Run the generator script, which will prompt you for a component name:

npm run create

The generator will scaffold your package files based on the name you give it.

For example, a component named MySweetButton will be created at packages/@t7/my-sweet-button ready for development.

Add Dependencies

Install a dependency to your new package from the project root:

# Installs module-name to `dependencies` of @t7/my-sweet-button package.
npm run add -- module-name --scope=@t7/my-sweet-button

# Installs module-name to `devDependencies` of @t7/my-sweet-button package.
npm run add -- module-name --scope=@t7/my-sweet-button --dev

# Installs `@t7/accordion` to `dependencies` of `@t7/my-sweet-button` and symlinks from the local repo.
npm run add -- @t7/accordion --scope=@t7/my-sweet-button

Note: Lerna will automatically symlink dependencies that match any packages within this repo. 🎉

Generate Docz File

Fill out the generated index.mdx file and test it from the project root:

npm run docz

Lint and Test

Run eslint, stylelint, and jest from the package root:

npm run lint && npm run test

If you run into any errors, try reinstalling dependencies.

Bump Changed Package Versions

Bump changed package versions from the project root:

npm run bump

Lerna determines changed packages and will prompt you for all. Be sure to follow semver guidelines.

Commit Files and Submit Pull Request

Changes should go through a pull request process:

git checkout -b feature/my-sweet-button
git add --all
git commit -m "Adds new MySweetButton component."
git push -u origin feature/my-sweet-button

Submit a pull request and merge to master.

Publish Changed Packages

Publish changed packages once all component changes and version numbers have been successfully committed, reviewed, and merged:

npm run publish

# If using 2FA on NPM, use key from your MFA device.
NPM_CONFIG_OTP=123456 npm run publish