Skip to content

Commit

Permalink
Merge pull request #39 from IgnacioNMiranda/docs/README.md
Browse files Browse the repository at this point in the history
docs: README.md
  • Loading branch information
IgnacioNMiranda authored Jan 21, 2023
2 parents dc34aba + 893a060 commit f1260bc
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ dist-ssr
*.sw?

# Storybook
storybook-static
storybook-static

# Testing
coverage
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# vite-component-library-template

Starter project to build a component library using Vite as the build tool. It also setup some handy features like:

- Components preview using [Storybook](https://storybook.js.org/blog/storybook-for-vite/)
- UI Testing with [Vitest](https://vitest.dev/), the vite-native unit test framework.
- Library bundling and publish to npm registry using Github Actions.

The bundling was possible thanks to the Google [Release Please](https://github.com/googleapis/release-please) package using the Github Action approach.

## Getting Started

1. Install dependencies with `yarn`
2. Run `yarn prepare` command to install [Husky](https://typicode.github.io/husky).
3. That's pretty much it.

## Main Scripts

Always prepending yarn:

- `dev`: Bootstrap the Storybook preview with Hot Reload.
- `build`: Builds the static storybook project.
- `build:lib`: Builds the component library into the **dist** folder.
- `lint:fix`: Applies linting to the project based on the rules defined in **.eslintrc.js**.
- `format:prettier`: Formats files using the prettier rules defined in **.prettierrc**.
- `test`: Runs testing using watch mode.
- `test:cov`: Runs testing displaying a coverage report.

## Publishing the Library to NPM

- Instructions using Github as the hosting service.

1. Check the `Allow GitHub Actions to create and approve pull requests` box under the Settings>Code and automation>Actions>General repository configuration.
2. Create a repository secret called `NPM_TOKEN` under Settings>Security>Secrets and variables>Actions, this will allow the github actions to publish the library to npm.

With these 2 requirements, Pull Requests raised by release-please will have enough permissions. For more details, please check the [official documentation](https://github.com/google-github-actions/release-please-action).

## Author

[Ignacio Miranda Figueroa](https://www.linkedin.com/in/ignacio-miranda-figueroa/)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint:fix": "eslint --ext .js,.jsx,.ts,.tsx --fix",
"format:prettier": "prettier --write \"src/**/*.{ts,tsx,js,mdx}\"",
"test": "vitest",
"test:coverage": "vitest run --coverage",
"test:cov": "vitest run --coverage",
"prepare": "husky install",
"prepack": "json -f package.json -I -e \"delete this.devDependencies; delete this.dependencies\""
},
Expand All @@ -43,6 +43,7 @@
"@types/react-dom": "^18.0.9",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@vitejs/plugin-react": "^3.0.0",
"@vitest/coverage-c8": "^0.27.3",
"autoprefixer": "^10.4.13",
"babel-loader": "^8.3.0",
"eslint": "^8.0.1",
Expand Down
54 changes: 53 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3009,6 +3009,14 @@
magic-string "^0.27.0"
react-refresh "^0.14.0"

"@vitest/coverage-c8@^0.27.3":
version "0.27.3"
resolved "https://registry.yarnpkg.com/@vitest/coverage-c8/-/coverage-c8-0.27.3.tgz#fef29bd092f06a5a51ec30ce10b26f4ca1fbd41f"
integrity sha512-xIN4FXXwJqeP6z0gfQ06gbyBMRN2mYvZ4/mn4F96mKXzch0Y93fBeS81eo7D/2YtjbeJBUcU9/amPVb2T+h83Q==
dependencies:
c8 "^7.12.0"
vitest "0.27.3"

"@webassemblyjs/[email protected]":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7"
Expand Down Expand Up @@ -4131,7 +4139,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5"
integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==

c8@^7.6.0:
c8@^7.12.0, c8@^7.6.0:
version "7.12.0"
resolved "https://registry.yarnpkg.com/c8/-/c8-7.12.0.tgz#402db1c1af4af5249153535d1c84ad70c5c96b14"
integrity sha512-CtgQrHOkyxr5koX1wEUmN/5cfDa2ckbHRA4Gy5LAL0zaCFtVWJS5++n+w4/sr2GWGerBxgTjpKeDclk/Qk6W/A==
Expand Down Expand Up @@ -10552,6 +10560,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63"
integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==

std-env@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.3.1.tgz#93a81835815e618c8aa75e7c8a4dc04f7c314e29"
integrity sha512-3H20QlwQsSm2OvAxWIYhs+j01MzzqwMwGiiO1NQaJYZgJZFPuAbf95/DiKRBSTYIJ2FeGUc+B/6mPGcWP9dO3Q==

stop-iteration-iterator@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz#6a60be0b4ee757d1ed5254858ec66b10c49285e4"
Expand Down Expand Up @@ -11579,6 +11592,20 @@ [email protected]:
source-map-support "^0.5.21"
vite "^3.0.0 || ^4.0.0"

[email protected]:
version "0.27.3"
resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-0.27.3.tgz#56b823b7f45b17f6ee45cd37468e869a7915ff5a"
integrity sha512-eyJYOO64o5HIp8poc4bJX+ZNBwMZeI3f6/JdiUmJgW02Mt7LnoCtDMRVmLaY9S05SIsjGe339ZK4uo2wQ+bF9g==
dependencies:
cac "^6.7.14"
debug "^4.3.4"
mlly "^1.1.0"
pathe "^0.2.0"
picocolors "^1.0.0"
source-map "^0.6.1"
source-map-support "^0.5.21"
vite "^3.0.0 || ^4.0.0"

vite-plugin-dts@^1.7.1:
version "1.7.1"
resolved "https://registry.npmjs.org/vite-plugin-dts/-/vite-plugin-dts-1.7.1.tgz"
Expand All @@ -11605,6 +11632,31 @@ vite-plugin-dts@^1.7.1:
optionalDependencies:
fsevents "~2.3.2"

[email protected]:
version "0.27.3"
resolved "https://registry.yarnpkg.com/vitest/-/vitest-0.27.3.tgz#207529ca35943956e3141b270ac01dcc635a89c3"
integrity sha512-Ld3UVgRVhJUtqvQ3dW89GxiApFAgBsWJZBCWzK+gA3w2yG68csXlGZZ4WDJURf+8ecNfgrScga6xY+8YSOpiMg==
dependencies:
"@types/chai" "^4.3.4"
"@types/chai-subset" "^1.3.3"
"@types/node" "*"
acorn "^8.8.1"
acorn-walk "^8.2.0"
cac "^6.7.14"
chai "^4.3.7"
debug "^4.3.4"
local-pkg "^0.4.2"
picocolors "^1.0.0"
source-map "^0.6.1"
std-env "^3.3.1"
strip-literal "^1.0.0"
tinybench "^2.3.1"
tinypool "^0.3.0"
tinyspy "^1.0.2"
vite "^3.0.0 || ^4.0.0"
vite-node "0.27.3"
why-is-node-running "^2.2.2"

vitest@^0.27.2:
version "0.27.2"
resolved "https://registry.yarnpkg.com/vitest/-/vitest-0.27.2.tgz#af10dad4d2e94b816b2e7c4d947a0976626b345a"
Expand Down

0 comments on commit f1260bc

Please sign in to comment.