Skip to content

Commit

Permalink
Merge pull request #2 from idesigncode/configuration
Browse files Browse the repository at this point in the history
Configuration
  • Loading branch information
idesigncode committed May 3, 2023
2 parents 0bad378 + 9c067ec commit 1fe80ea
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will run tests using node and then publish an NPM package when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm install-test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm install
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
2 changes: 1 addition & 1 deletion .npm-prepare-clean.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function removeBuildFiles(filepath) {

(async function () {
try {
await Promise.all(files.map(removeBuildFiles));
await Promise.all([...files, 'storybook-static'].map(removeBuildFiles));
} catch (error) {
console.error(error);
}
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Remove/replace the example source files in the `src` directory with your own.
When adding source files, remember to add the build output file details to the `files` & `exports` fields of [package.json](package.json) and [.gitignore](.gitignore).

<details>
<summary>Build</summary>
<summary>🛠️ Build</summary>

`npm run prepare` runs all preparation clean & build scripts:

Expand All @@ -27,15 +27,22 @@ _Note: the ["prepare" Life Cycle Script](https://docs.npmjs.com/cli/using-npm/sc
</details>

<details>
<summary>Storybook</summary>
<summary>🚀 Deployments</summary>

The GitHub action [npm-publish.yml](.github/workflows/npm-publish.yml) is used to automatically deploy a release to the NPM package registry. The action requires the `NPM_TOKEN` secrets to be set.

</details>

<details>
<summary>📕 Storybook</summary>

- `npm run storybook` will run Storybook for local use
- `npm run storybook:build` will build Storybook to `./storybook-static` for deployment use

</details>

<details>
<summary>Testing</summary>
<summary>🧪 Testing</summary>

The GitHub action [node.js.yml](.github/workflows/node.js.yml) is used to run the tests on pull requests and commit pushes into the main branch.

Expand All @@ -48,7 +55,7 @@ The GitHub action [node.js.yml](.github/workflows/node.js.yml) is used to run th
</details>

<details>
<summary>Code linting</summary>
<summary>🕵️ Code linting</summary>

[Husky](https://github.com/typicode/husky) & [lint-staged](https://github.com/okonet/lint-staged) are used to automatically run code linting checks on each file of a commit.

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"prepare:js": "babel src --out-dir . --ignore **/*.test.mjs,**/*.stories.mjs --keep-file-extension",
"prepublishOnly": "npm run test",
"prettier": "prettier --write . --ignore-path .gitignore",
"storybook": "npm run prepare:css && storybook dev --ci -p 6006",
"storybook:build": "npm run prepare:css && storybook build --quiet --docs",
"storybook": "storybook dev --ci -p 6006",
"storybook:build": "storybook build --quiet --docs",
"test": "npm run test:prettier && npm run test:eslint && npm run test:jest",
"test:eslint": "eslint . --ext .js,.cjs,.mjs --ignore-path .gitignore",
"test:jest": "NODE_OPTIONS=--experimental-vm-modules jest --config .jest-config.json",
Expand Down

0 comments on commit 1fe80ea

Please sign in to comment.