From c1560d9d1c35feb5139ac714034fb5991c5d2886 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 22 Sep 2024 00:10:42 +0800 Subject: [PATCH 1/2] feat: provide storybook and essential addons as transitive dependency --- docs/content/1.getting-started/1.setup.md | 2 + examples/showcase/package.json | 6 +-- examples/starter/package.json | 6 +-- examples/tailwind/package.json | 6 +-- packages/nuxt-module/bin/storybook.mjs | 3 ++ packages/nuxt-module/package.json | 9 +++- playground/package.json | 2 - pnpm-lock.yaml | 51 ++++------------------- 8 files changed, 25 insertions(+), 60 deletions(-) create mode 100644 packages/nuxt-module/bin/storybook.mjs diff --git a/docs/content/1.getting-started/1.setup.md b/docs/content/1.getting-started/1.setup.md index 738b7b91..b77386a8 100644 --- a/docs/content/1.getting-started/1.setup.md +++ b/docs/content/1.getting-started/1.setup.md @@ -11,6 +11,8 @@ description: Using Storybook in your Nuxt project is only one command away ✨ npx nuxi@latest module add storybook ``` +By default, the module comes with the latest version of Storybook preinstalled. So you don't need to add it manually in your project. Similarly, all [essential addons](https://storybook.js.org/docs/essentials) as well as the packages [`@storybook/test`](https://storybook.js.org/docs/writing-tests/component-testing) and [`@storybook/blocks`](https://storybook.js.org/docs/writing-docs/doc-blocks) are included. You can always install additional addons as needed. + 2. Add it to your `modules` section in your `nuxt.config`: ::code-group diff --git a/examples/showcase/package.json b/examples/showcase/package.json index b067d213..26e9a083 100644 --- a/examples/showcase/package.json +++ b/examples/showcase/package.json @@ -20,10 +20,6 @@ "devDependencies": { "@chromatic-com/storybook": "2.0.2", "@nuxtjs/storybook": "latest", - "@storybook/addon-essentials": "8.3.0", - "@storybook/addon-links": "8.3.0", - "@storybook/blocks": "8.3.0", - "@storybook/test": "8.3.0", - "storybook": "8.3.0" + "@storybook/addon-links": "8.3.0" } } diff --git a/examples/starter/package.json b/examples/starter/package.json index 838ce53c..c0f4a009 100644 --- a/examples/starter/package.json +++ b/examples/starter/package.json @@ -18,10 +18,6 @@ "devDependencies": { "@chromatic-com/storybook": "2.0.2", "@nuxtjs/storybook": "latest", - "@storybook/addon-essentials": "8.3.0", - "@storybook/addon-links": "8.3.0", - "@storybook/blocks": "8.3.0", - "@storybook/test": "8.3.0", - "storybook": "8.3.0" + "@storybook/addon-links": "8.3.0" } } diff --git a/examples/tailwind/package.json b/examples/tailwind/package.json index 0e75edcb..83a6a28c 100644 --- a/examples/tailwind/package.json +++ b/examples/tailwind/package.json @@ -19,10 +19,6 @@ "devDependencies": { "@chromatic-com/storybook": "2.0.2", "@nuxtjs/storybook": "latest", - "@storybook/addon-essentials": "8.3.0", - "@storybook/addon-links": "8.3.0", - "@storybook/blocks": "8.3.0", - "@storybook/test": "8.3.0", - "storybook": "8.3.0" + "@storybook/addon-links": "8.3.0" } } diff --git a/packages/nuxt-module/bin/storybook.mjs b/packages/nuxt-module/bin/storybook.mjs new file mode 100644 index 00000000..6ad58e39 --- /dev/null +++ b/packages/nuxt-module/bin/storybook.mjs @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +import 'storybook/internal/cli/bin' diff --git a/packages/nuxt-module/package.json b/packages/nuxt-module/package.json index 2aae55f6..119f8b8d 100644 --- a/packages/nuxt-module/package.json +++ b/packages/nuxt-module/package.json @@ -30,10 +30,14 @@ "require": "./dist/module.cjs" } }, + "bin":{ + "storybook": "./bin/storybook.mjs" + }, "main": "./dist/module.cjs", "types": "./dist/types.d.ts", "files": [ - "dist" + "dist", + "bin" ], "engines": { "node": ">=18.0.0" @@ -47,8 +51,11 @@ "@nuxt/devtools-kit": "^1.0.8", "@nuxt/kit": "^3.12.0", "@storybook-vue/nuxt": "workspace:*", + "@storybook/addon-essentials": "^8.3.0", + "@storybook/blocks": "^8.3.0", "@storybook/core-common": "^8.3.0", "@storybook/core-server": "^8.3.0", + "@storybook/test": "^8.3.0", "chalk": "^5.0.0", "consola": "^3.2.3", "defu": "^6.1.4", diff --git a/playground/package.json b/playground/package.json index 9434d413..d0a7237e 100644 --- a/playground/package.json +++ b/playground/package.json @@ -13,11 +13,9 @@ }, "devDependencies": { "@nuxtjs/storybook": "workspace:*", - "@storybook/addon-essentials": "^8.3.0", "@storybook/addon-interactions": "^8.3.0", "@storybook/addon-links": "^8.3.0", "nuxt": "3.13.1", - "storybook": "^8.3.0", "vite-plugin-inspect": "0.8.7" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e5c2fae5..86bd1456 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -109,21 +109,9 @@ importers: '@nuxtjs/storybook': specifier: latest version: link:../../packages/nuxt-module - '@storybook/addon-essentials': - specifier: 8.3.0 - version: 8.3.0(storybook@8.3.0)(webpack-sources@3.2.3) '@storybook/addon-links': specifier: 8.3.0 version: 8.3.0(react@18.3.1)(storybook@8.3.0) - '@storybook/blocks': - specifier: 8.3.0 - version: 8.3.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.3.0) - '@storybook/test': - specifier: 8.3.0 - version: 8.3.0(storybook@8.3.0) - storybook: - specifier: 8.3.0 - version: 8.3.0 examples/starter: dependencies: @@ -143,21 +131,9 @@ importers: '@nuxtjs/storybook': specifier: latest version: link:../../packages/nuxt-module - '@storybook/addon-essentials': - specifier: 8.3.0 - version: 8.3.0(storybook@8.3.0)(webpack-sources@3.2.3) '@storybook/addon-links': specifier: 8.3.0 version: 8.3.0(react@18.3.1)(storybook@8.3.0) - '@storybook/blocks': - specifier: 8.3.0 - version: 8.3.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.3.0) - '@storybook/test': - specifier: 8.3.0 - version: 8.3.0(storybook@8.3.0) - storybook: - specifier: 8.3.0 - version: 8.3.0 examples/tailwind: dependencies: @@ -180,21 +156,9 @@ importers: '@nuxtjs/storybook': specifier: latest version: link:../../packages/nuxt-module - '@storybook/addon-essentials': - specifier: 8.3.0 - version: 8.3.0(storybook@8.3.0)(webpack-sources@3.2.3) '@storybook/addon-links': specifier: 8.3.0 version: 8.3.0(react@18.3.1)(storybook@8.3.0) - '@storybook/blocks': - specifier: 8.3.0 - version: 8.3.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.3.0) - '@storybook/test': - specifier: 8.3.0 - version: 8.3.0(storybook@8.3.0) - storybook: - specifier: 8.3.0 - version: 8.3.0 packages/nuxt-module: dependencies: @@ -207,12 +171,21 @@ importers: '@storybook-vue/nuxt': specifier: workspace:* version: link:../storybook-addon + '@storybook/addon-essentials': + specifier: ^8.3.0 + version: 8.3.0(storybook@8.3.0)(webpack-sources@3.2.3) + '@storybook/blocks': + specifier: ^8.3.0 + version: 8.3.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.3.0) '@storybook/core-common': specifier: ^8.3.0 version: 8.3.0(storybook@8.3.0) '@storybook/core-server': specifier: ^8.3.0 version: 8.3.0(storybook@8.3.0) + '@storybook/test': + specifier: ^8.3.0 + version: 8.3.0(storybook@8.3.0) chalk: specifier: ^5.0.0 version: 5.3.0 @@ -320,9 +293,6 @@ importers: '@nuxtjs/storybook': specifier: workspace:* version: link:../packages/nuxt-module - '@storybook/addon-essentials': - specifier: ^8.3.0 - version: 8.3.0(storybook@8.3.0)(webpack-sources@3.2.3) '@storybook/addon-interactions': specifier: ^8.3.0 version: 8.3.0(storybook@8.3.0) @@ -332,9 +302,6 @@ importers: nuxt: specifier: 3.13.1 version: 3.13.1(@parcel/watcher@2.4.1)(@types/node@22.5.0)(encoding@0.1.13)(eslint@9.10.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.21.0)(sass@1.77.7)(terser@5.31.6)(typescript@5.6.2)(vite@5.4.5(@types/node@22.5.0)(sass@1.77.7)(terser@5.31.6))(vue-tsc@2.1.6(typescript@5.6.2))(webpack-sources@3.2.3) - storybook: - specifier: ^8.3.0 - version: 8.3.0 vite-plugin-inspect: specifier: 0.8.7 version: 0.8.7(@nuxt/kit@3.13.1(magicast@0.3.5)(rollup@4.21.0)(webpack-sources@3.2.3))(rollup@4.21.0)(vite@5.4.5(@types/node@22.5.0)(sass@1.77.7)(terser@5.31.6)) From 5b1ced5ceabb2cd9b4c91344b0e5bba7a2125940 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 22 Sep 2024 22:16:53 +0800 Subject: [PATCH 2/2] move dependencies to storybook-addon --- packages/nuxt-module/package.json | 5 +---- packages/storybook-addon/package.json | 2 ++ pnpm-lock.yaml | 15 ++++++--------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/nuxt-module/package.json b/packages/nuxt-module/package.json index 119f8b8d..bd7dae00 100644 --- a/packages/nuxt-module/package.json +++ b/packages/nuxt-module/package.json @@ -30,7 +30,7 @@ "require": "./dist/module.cjs" } }, - "bin":{ + "bin": { "storybook": "./bin/storybook.mjs" }, "main": "./dist/module.cjs", @@ -51,11 +51,8 @@ "@nuxt/devtools-kit": "^1.0.8", "@nuxt/kit": "^3.12.0", "@storybook-vue/nuxt": "workspace:*", - "@storybook/addon-essentials": "^8.3.0", - "@storybook/blocks": "^8.3.0", "@storybook/core-common": "^8.3.0", "@storybook/core-server": "^8.3.0", - "@storybook/test": "^8.3.0", "chalk": "^5.0.0", "consola": "^3.2.3", "defu": "^6.1.4", diff --git a/packages/storybook-addon/package.json b/packages/storybook-addon/package.json index 2ba2df07..769557bc 100644 --- a/packages/storybook-addon/package.json +++ b/packages/storybook-addon/package.json @@ -70,7 +70,9 @@ "@nuxt/schema": "^3.13.0", "@nuxt/vite-builder": "^3.13.0", "@rollup/plugin-replace": "^5.0.7", + "@storybook/addon-essentials": "^8.3.0", "@storybook/builder-vite": "^8.3.0", + "@storybook/test": "^8.3.0", "@storybook/vue3": "^8.3.0", "@storybook/vue3-vite": "^8.3.0", "json-stable-stringify": "^1.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 86bd1456..373e6207 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -171,21 +171,12 @@ importers: '@storybook-vue/nuxt': specifier: workspace:* version: link:../storybook-addon - '@storybook/addon-essentials': - specifier: ^8.3.0 - version: 8.3.0(storybook@8.3.0)(webpack-sources@3.2.3) - '@storybook/blocks': - specifier: ^8.3.0 - version: 8.3.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.3.0) '@storybook/core-common': specifier: ^8.3.0 version: 8.3.0(storybook@8.3.0) '@storybook/core-server': specifier: ^8.3.0 version: 8.3.0(storybook@8.3.0) - '@storybook/test': - specifier: ^8.3.0 - version: 8.3.0(storybook@8.3.0) chalk: specifier: ^5.0.0 version: 5.3.0 @@ -229,9 +220,15 @@ importers: '@rollup/plugin-replace': specifier: ^5.0.7 version: 5.0.7(rollup@4.21.0) + '@storybook/addon-essentials': + specifier: ^8.3.0 + version: 8.3.0(storybook@8.3.0)(webpack-sources@3.2.3) '@storybook/builder-vite': specifier: ^8.3.0 version: 8.3.0(storybook@8.3.0)(typescript@5.6.2)(vite@5.4.5(@types/node@22.5.0)(sass@1.77.7)(terser@5.31.6))(webpack-sources@3.2.3) + '@storybook/test': + specifier: ^8.3.0 + version: 8.3.0(storybook@8.3.0) '@storybook/vue3': specifier: ^8.3.0 version: 8.3.0(storybook@8.3.0)(vue@3.5.5(typescript@5.6.2))