Skip to content

Commit

Permalink
Merge pull request #13 from qupaya/me/feature/storybook
Browse files Browse the repository at this point in the history
add & deploy storybook
  • Loading branch information
Markus-Ende authored Apr 15, 2024
2 parents 2aa6710 + 2cefc27 commit 19b5028
Show file tree
Hide file tree
Showing 17 changed files with 5,859 additions and 343 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ jobs:
run: npx playwright install --with-deps
- uses: nrwl/nx-set-shas@v4

- run: npx nx-cloud record -- nx format:check
# - run: npx nx-cloud record -- nx format:check
- run: npx nx affected -t lint test build e2e-ci
47 changes: 47 additions & 0 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Storybook Publish'

on:
push:
branches:
- 'main'

jobs:
storybook-deployment:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'npm'

- uses: nrwl/nx-set-shas@v4

- name: Install dependencies
run: |
npm ci
- name: Restore nx cache
id: nxcache
uses: actions/cache@v4
with:
path: node_modules/.cache/nx
key: ${{ runner.os }}-nxcache-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-nxcache-
- name: build storybook
run: nx run sketch:build-storybook

- name: Publish to Chromatic
# see https://github.com/chromaui/action/tags for versions
uses: chromaui/[email protected]
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
storybookBuildDir: ./dist/storybook/sketch
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ Thumbs.db

.nx/cache
.angular
.eslintcache
2 changes: 1 addition & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"*.ts": ["npx nx lint --fix --files"],
"*.ts": ["eslint --cache --fix"],
"*": ["npx nx format:write --files"],
"*.css": ["npx stylelint --fix"]
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

**This workspace has been generated by [Nx, Smart Monorepos · Fast CI.](https://nx.dev)**

## Storybook

Deployed from main: https://661d194a3f6d14d86c328554-yfvvdffiwi.chromatic.com/

Chromatic app: https://www.chromatic.com/builds?appId=661d194a3f6d14d86c328554

## Integrate with editors

Enhance your Nx experience by installing [Nx Console](https://nx.dev/nx-console) for your favorite editor. Nx Console
Expand Down
8 changes: 8 additions & 0 deletions chromatic.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"projectId": "Project:661d194a3f6d14d86c328554",
"autoAcceptChanges": "main",
"exitOnceUploaded": true,
"externals": ["public/**"],
"onlyChanged": true,
"storybookBuildDir": "dist/storybook/sketch"
}
2 changes: 1 addition & 1 deletion libs/sketch/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"ignorePatterns": ["!**/*", "storybook-static"],
"overrides": [
{
"files": ["*.ts"],
Expand Down
16 changes: 16 additions & 0 deletions libs/sketch/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { StorybookConfig } from '@storybook/angular';

const config: StorybookConfig = {
stories: ['../**/*.stories.@(js|jsx|ts|tsx|mdx)'],
addons: ['@storybook/addon-essentials'],
framework: {
name: '@storybook/angular',
options: {},
},
};

export default config;

// To customize your webpack configuration you can use the webpackFinal field.
// Check https://storybook.js.org/docs/react/builders/webpack#extending-storybooks-webpack-config
// and https://nx.dev/recipes/storybook/custom-builder-configs
Empty file.
16 changes: 16 additions & 0 deletions libs/sketch/.storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"emitDecoratorMetadata": true
},
"exclude": ["../**/*.spec.ts"],
"include": [
"../src/**/*.stories.ts",
"../src/**/*.stories.js",
"../src/**/*.stories.jsx",
"../src/**/*.stories.tsx",
"../src/**/*.stories.mdx",
"*.js",
"*.ts"
]
}
42 changes: 42 additions & 0 deletions libs/sketch/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,48 @@
},
"lint": {
"executor": "@nx/eslint:lint"
},
"storybook": {
"executor": "@storybook/angular:start-storybook",
"options": {
"port": 4400,
"configDir": "libs/sketch/.storybook",
"browserTarget": "sketch:build-storybook",
"compodoc": false
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"build-storybook": {
"executor": "@storybook/angular:build-storybook",
"outputs": ["{options.outputDir}"],
"options": {
"outputDir": "dist/storybook/sketch",
"configDir": "libs/sketch/.storybook",
"browserTarget": "sketch:build-storybook",
"compodoc": false
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"static-storybook": {
"executor": "@nx/web:file-server",
"options": {
"buildTarget": "sketch:build-storybook",
"staticFilePath": "dist/storybook/sketch",
"spa": true
},
"configurations": {
"ci": {
"buildTarget": "sketch:build-storybook:ci"
}
}
}
}
}
13 changes: 13 additions & 0 deletions libs/sketch/src/lib/sketch/sketch.component.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Meta, StoryObj } from '@storybook/angular';
import { SketchComponent } from './sketch.component';

const meta: Meta<SketchComponent> = {
component: SketchComponent,
title: 'SketchComponent',
};
export default meta;
type Story = StoryObj<SketchComponent>;

export const Primary: Story = {
args: {},
};
3 changes: 3 additions & 0 deletions libs/sketch/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./.storybook/tsconfig.json"
}
],
"extends": "../../tsconfig.base.json",
Expand Down
4 changes: 3 additions & 1 deletion libs/sketch/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"src/**/*.spec.ts",
"src/test-setup.ts",
"jest.config.ts",
"src/**/*.test.ts"
"src/**/*.test.ts",
"**/*.stories.ts",
"**/*.stories.js"
],
"include": ["src/**/*.ts"]
}
17 changes: 14 additions & 3 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/src/test-setup.[jt]s",
"!{projectRoot}/test-setup.[jt]s"
"!{projectRoot}/test-setup.[jt]s",
"!{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)",
"!{projectRoot}/.storybook/**/*",
"!{projectRoot}/tsconfig.storybook.json"
],
"sharedGlobals": []
},
Expand Down Expand Up @@ -46,6 +49,15 @@
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"build-storybook": {
"cache": true,
"inputs": [
"default",
"^production",
"{projectRoot}/.storybook/**/*",
"{projectRoot}/tsconfig.storybook.json"
]
}
},
"plugins": [
Expand Down Expand Up @@ -77,6 +89,5 @@
"style": "css"
}
},
"defaultProject": "demo-app",
"nxCloudAccessToken": "ZDI5MjU3NmYtYWU2OS00OGJkLWI0ODEtY2I1NDM2MGM1MDJifHJlYWQtd3JpdGU="
"defaultProject": "demo-app"
}
Loading

0 comments on commit 19b5028

Please sign in to comment.