From b9bf7d39ff58df17365fe309cd629e5b4669ea78 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Mon, 15 Jul 2024 15:05:45 +0200 Subject: [PATCH 1/5] Revert "Revert: Nuxt support" --- code/core/scripts/helpers/sourcefiles.ts | 2 +- .../src/common/utils/framework-to-renderer.ts | 1 + code/core/src/types/modules/frameworks.ts | 3 +- code/core/src/types/modules/renderers.ts | 3 +- code/lib/cli/package.json | 3 +- code/lib/cli/src/detect.test.ts | 32 +++++++++++++------ code/lib/cli/src/detect.ts | 15 ++++++++- code/lib/cli/src/generators/NUXT/index.ts | 31 ++++++++++++++++++ code/lib/cli/src/generators/baseGenerator.ts | 24 +++++++++----- code/lib/cli/src/generators/types.ts | 2 ++ code/lib/cli/src/helpers.ts | 1 + code/lib/cli/src/initiate.ts | 6 ++++ code/lib/cli/src/project_types.ts | 14 +++++--- 13 files changed, 110 insertions(+), 27 deletions(-) create mode 100644 code/lib/cli/src/generators/NUXT/index.ts diff --git a/code/core/scripts/helpers/sourcefiles.ts b/code/core/scripts/helpers/sourcefiles.ts index 867f401ad15b..df232a7a9ee7 100644 --- a/code/core/scripts/helpers/sourcefiles.ts +++ b/code/core/scripts/helpers/sourcefiles.ts @@ -54,7 +54,7 @@ async function generateVersionsFile(prettierConfig: prettier.Options | null): Pr } async function generateFrameworksFile(prettierConfig: prettier.Options | null): Promise { - const thirdPartyFrameworks = ['qwik', 'solid']; + const thirdPartyFrameworks = ['qwik', 'solid', 'nuxt']; const location = join( import.meta.dirname, '..', diff --git a/code/core/src/common/utils/framework-to-renderer.ts b/code/core/src/common/utils/framework-to-renderer.ts index a34ac765c2c7..8efc821a8e43 100644 --- a/code/core/src/common/utils/framework-to-renderer.ts +++ b/code/core/src/common/utils/framework-to-renderer.ts @@ -23,6 +23,7 @@ export const frameworkToRenderer: Record< sveltekit: 'svelte', 'vue3-vite': 'vue3', 'vue3-webpack5': 'vue3', + nuxt: 'vue3', 'web-components-vite': 'web-components', 'web-components-webpack5': 'web-components', // renderers diff --git a/code/core/src/types/modules/frameworks.ts b/code/core/src/types/modules/frameworks.ts index 9ae2cc538b51..9feef71ffdb8 100644 --- a/code/core/src/types/modules/frameworks.ts +++ b/code/core/src/types/modules/frameworks.ts @@ -18,4 +18,5 @@ export type SupportedFrameworks = | 'web-components-vite' | 'web-components-webpack5' | 'qwik' - | 'solid'; + | 'solid' + | 'nuxt'; diff --git a/code/core/src/types/modules/renderers.ts b/code/core/src/types/modules/renderers.ts index 4fcf0be99d87..e6fd0f650bf3 100644 --- a/code/core/src/types/modules/renderers.ts +++ b/code/core/src/types/modules/renderers.ts @@ -11,4 +11,5 @@ export type SupportedRenderers = | 'html' | 'web-components' | 'server' - | 'solid'; + | 'solid' + | 'nuxt'; diff --git a/code/lib/cli/package.json b/code/lib/cli/package.json index 3b7f10bf0838..3299261d8e7a 100644 --- a/code/lib/cli/package.json +++ b/code/lib/cli/package.json @@ -282,7 +282,8 @@ ], "scripts": { "check": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/check.ts", - "prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts" + "prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts", + "sb": "node ./bin/index.js" }, "dependencies": { "@babel/core": "^7.24.4", diff --git a/code/lib/cli/src/detect.test.ts b/code/lib/cli/src/detect.test.ts index cf21f8bc423c..4ea3d075babe 100644 --- a/code/lib/cli/src/detect.test.ts +++ b/code/lib/cli/src/detect.test.ts @@ -42,6 +42,28 @@ const MOCK_FRAMEWORK_FILES: { }, }, }, + { + name: ProjectType.NUXT, + files: { + 'package.json': { + dependencies: { + nuxt: '^3.11.2', + }, + }, + }, + }, + { + name: ProjectType.NUXT, + files: { + 'package.json': { + dependencies: { + // Nuxt projects may have Vue 3 as an explicit dependency + nuxt: '^3.11.2', + vue: '^3.0.0', + }, + }, + }, + }, { name: ProjectType.VUE3, files: { @@ -434,16 +456,6 @@ describe('Detect', () => { expect(result).toBe(ProjectType.UNDETECTED); }); - // TODO(blaine): Remove once Nuxt3 is supported - it(`UNSUPPORTED for Nuxt framework above version 3.0.0`, () => { - const result = detectFrameworkPreset({ - dependencies: { - nuxt: '3.0.0', - }, - }); - expect(result).toBe(ProjectType.UNSUPPORTED); - }); - // TODO: The mocking in this test causes tests after it to fail it('REACT_SCRIPTS for custom react scripts config', () => { const forkedReactScriptsConfig = { diff --git a/code/lib/cli/src/detect.ts b/code/lib/cli/src/detect.ts index 440336f74bb8..084890783427 100644 --- a/code/lib/cli/src/detect.ts +++ b/code/lib/cli/src/detect.ts @@ -120,7 +120,11 @@ export async function detectBuilder(packageManager: JsPackageManager, projectTyp } // REWORK - if (webpackConfig || (dependencies.webpack && dependencies.vite !== undefined)) { + if ( + webpackConfig || + ((dependencies.webpack || dependencies['@nuxt/webpack-builder']) && + dependencies.vite !== undefined) + ) { commandLog('Detected webpack project. Setting builder to webpack')(); return CoreBuilder.Webpack5; } @@ -133,6 +137,8 @@ export async function detectBuilder(packageManager: JsPackageManager, projectTyp case ProjectType.NEXTJS: case ProjectType.EMBER: return CoreBuilder.Webpack5; + case ProjectType.NUXT: + return CoreBuilder.Vite; default: const { builder } = await prompts( { @@ -202,6 +208,13 @@ export async function detectLanguage(packageManager: JsPackageManager) { } else if (semver.lt(typescriptVersion, '3.8.0')) { logger.warn('Detected TypeScript < 3.8, populating with JavaScript examples'); } + } else { + // No direct dependency on TypeScript, but could be a transitive dependency + // This is eg the case for Nuxt projects, which support a recent version of TypeScript + // Check for tsconfig.json (https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) + if (fs.existsSync('tsconfig.json')) { + language = SupportedLanguage.TYPESCRIPT_4_9; + } } return language; diff --git a/code/lib/cli/src/generators/NUXT/index.ts b/code/lib/cli/src/generators/NUXT/index.ts new file mode 100644 index 000000000000..3832f2d6551d --- /dev/null +++ b/code/lib/cli/src/generators/NUXT/index.ts @@ -0,0 +1,31 @@ +import { baseGenerator } from '../baseGenerator'; +import type { Generator } from '../types'; + +const generator: Generator = async (packageManager, npmOptions, options) => { + await baseGenerator( + packageManager, + npmOptions, + options, + 'nuxt', + { + extraPackages: async ({ builder }) => { + return ['@nuxtjs/storybook']; + }, + installFrameworkPackages: false, + componentsDestinationPath: './components', + extraMain: { + stories: ['../components/**/*.mdx', '../components/**/*.stories.@(js|jsx|ts|tsx|mdx)'], + }, + }, + 'nuxt' + ); + // Add nuxtjs/storybook to nuxt.config.js + await packageManager.runPackageCommand('nuxi', [ + 'module', + 'add', + '@nuxtjs/storybook', + '--skipInstall', + ]); +}; + +export default generator; diff --git a/code/lib/cli/src/generators/baseGenerator.ts b/code/lib/cli/src/generators/baseGenerator.ts index 26af38afdbf4..2cd67d52d52e 100644 --- a/code/lib/cli/src/generators/baseGenerator.ts +++ b/code/lib/cli/src/generators/baseGenerator.ts @@ -23,6 +23,7 @@ const defaultOptions: FrameworkOptions = { staticDir: undefined, addScripts: true, addMainFile: true, + addPreviewFile: true, addComponents: true, webpackCompiler: () => undefined, extraMain: undefined, @@ -30,6 +31,7 @@ const defaultOptions: FrameworkOptions = { extensions: undefined, componentsDestinationPath: undefined, storybookConfigFolder: '.storybook', + installFrameworkPackages: true, }; const getBuilderDetails = (builder: string) => { @@ -202,12 +204,14 @@ export async function baseGenerator( staticDir, addScripts, addMainFile, + addPreviewFile, addComponents, extraMain, extensions, storybookConfigFolder, componentsDestinationPath, webpackCompiler, + installFrameworkPackages, } = { ...defaultOptions, ...options, @@ -281,7 +285,7 @@ export async function baseGenerator( const allPackages = [ 'storybook', getExternalFramework(rendererId) ? undefined : `@storybook/${rendererId}`, - ...frameworkPackages, + ...(installFrameworkPackages ? frameworkPackages : []), ...addonPackages, ...(extraPackagesToInstall || []), ].filter(Boolean); @@ -323,7 +327,9 @@ export async function baseGenerator( addDependenciesSpinner.succeed(); } - await fse.ensureDir(`./${storybookConfigFolder}`); + if (addMainFile || addPreviewFile) { + await fse.ensureDir(`./${storybookConfigFolder}`); + } if (addMainFile) { const prefixes = shouldApplyRequireWrapperOnPackageNames @@ -371,12 +377,14 @@ export async function baseGenerator( }); } - await configurePreview({ - frameworkPreviewParts, - storybookConfigFolder: storybookConfigFolder as string, - language, - rendererId, - }); + if (addPreviewFile) { + await configurePreview({ + frameworkPreviewParts, + storybookConfigFolder: storybookConfigFolder as string, + language, + rendererId, + }); + } if (addScripts) { await packageManager.addStorybookCommandInScripts({ diff --git a/code/lib/cli/src/generators/types.ts b/code/lib/cli/src/generators/types.ts index d1478019be0a..6040840a3956 100644 --- a/code/lib/cli/src/generators/types.ts +++ b/code/lib/cli/src/generators/types.ts @@ -22,6 +22,7 @@ export interface FrameworkOptions { staticDir?: string; addScripts?: boolean; addMainFile?: boolean; + addPreviewFile?: boolean; addComponents?: boolean; webpackCompiler?: ({ builder }: { builder: Builder }) => 'babel' | 'swc' | undefined; extraMain?: any; @@ -29,6 +30,7 @@ export interface FrameworkOptions { framework?: Record; storybookConfigFolder?: string; componentsDestinationPath?: string; + installFrameworkPackages?: boolean; } export type Generator = ( diff --git a/code/lib/cli/src/helpers.ts b/code/lib/cli/src/helpers.ts index f2256e11c2b8..2c467b27bc8b 100644 --- a/code/lib/cli/src/helpers.ts +++ b/code/lib/cli/src/helpers.ts @@ -143,6 +143,7 @@ export const frameworkToDefaultBuilder: Record 'html-vite': CoreBuilder.Vite, 'html-webpack5': CoreBuilder.Webpack5, nextjs: CoreBuilder.Webpack5, + nuxt: CoreBuilder.Vite, 'preact-vite': CoreBuilder.Vite, 'preact-webpack5': CoreBuilder.Webpack5, qwik: CoreBuilder.Vite, diff --git a/code/lib/cli/src/initiate.ts b/code/lib/cli/src/initiate.ts index 747e2c6f6ea7..abf5ef0f404b 100644 --- a/code/lib/cli/src/initiate.ts +++ b/code/lib/cli/src/initiate.ts @@ -28,6 +28,7 @@ import reactNativeGenerator from './generators/REACT_NATIVE'; import reactScriptsGenerator from './generators/REACT_SCRIPTS'; import nextjsGenerator from './generators/NEXTJS'; import vue3Generator from './generators/VUE3'; +import nuxtGenerator from './generators/NUXT'; import webpackReactGenerator from './generators/WEBPACK_REACT'; import htmlGenerator from './generators/HTML'; import webComponentsGenerator from './generators/WEB-COMPONENTS'; @@ -109,6 +110,11 @@ const installStorybook = async ( commandLog('Adding Storybook support to your "Vue 3" app') ); + case ProjectType.NUXT: + return nuxtGenerator(packageManager, npmOptions, generatorOptions).then( + commandLog('Adding Storybook support to your "Nuxt" app') + ); + case ProjectType.ANGULAR: commandLog('Adding Storybook support to your "Angular" app'); return angularGenerator(packageManager, npmOptions, generatorOptions, options); diff --git a/code/lib/cli/src/project_types.ts b/code/lib/cli/src/project_types.ts index b0f6c889c7c5..404c8f01d9b3 100644 --- a/code/lib/cli/src/project_types.ts +++ b/code/lib/cli/src/project_types.ts @@ -23,6 +23,7 @@ export type ExternalFramework = { export const externalFrameworks: ExternalFramework[] = [ { name: 'qwik', packageName: 'storybook-framework-qwik' }, { name: 'solid', frameworks: ['storybook-solidjs-vite'], renderer: 'storybook-solidjs' }, + { name: 'nuxt', packageName: '@storybook-vue/nuxt' }, ]; /** @@ -52,6 +53,7 @@ export enum ProjectType { WEBPACK_REACT = 'WEBPACK_REACT', NEXTJS = 'NEXTJS', VUE3 = 'VUE3', + NUXT = 'NUXT', ANGULAR = 'ANGULAR', EMBER = 'EMBER', WEB_COMPONENTS = 'WEB_COMPONENTS', @@ -117,6 +119,13 @@ export type TemplateConfiguration = { * therefore WEBPACK_REACT has to come first, as it's more specific. */ export const supportedTemplates: TemplateConfiguration[] = [ + { + preset: ProjectType.NUXT, + dependencies: ['nuxt'], + matcherFunction: ({ dependencies }) => { + return dependencies?.every(Boolean) ?? true; + }, + }, { preset: ProjectType.VUE3, dependencies: { @@ -238,10 +247,7 @@ export const supportedTemplates: TemplateConfiguration[] = [ // users an "Unsupported framework" message export const unsupportedTemplate: TemplateConfiguration = { preset: ProjectType.UNSUPPORTED, - dependencies: { - // TODO(blaine): Remove when we support Nuxt 3 - nuxt: (versionRange) => eqMajor(versionRange, 3), - }, + dependencies: {}, matcherFunction: ({ dependencies }) => { return dependencies?.some(Boolean) ?? false; }, From a729e4f7582ad357cee8357d381e35e0a59f6c4c Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 14 Aug 2024 14:39:20 +0200 Subject: [PATCH 2/5] dedupe --- code/yarn.lock | 348 +------------------------------------------------ 1 file changed, 3 insertions(+), 345 deletions(-) diff --git a/code/yarn.lock b/code/yarn.lock index 2aa5193261ef..e0bdf07ca5ca 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -2459,15 +2459,6 @@ __metadata: languageName: node linkType: hard -"@emnapi/runtime@npm:^1.1.0": - version: 1.1.1 - resolution: "@emnapi/runtime@npm:1.1.1" - dependencies: - tslib: "npm:^2.4.0" - checksum: 10c0/c11ee57abf0ec643e64ccdace4b4fcc0b0c7b1117a191f969e84ae3669841aa90d2c17fa35b73f5a66fc0c843c8caca7bf11187faaeaa526bcfb7dbfb9b85de9 - languageName: node - linkType: hard - "@emnapi/runtime@npm:^1.1.1": version: 1.2.0 resolution: "@emnapi/runtime@npm:1.2.0" @@ -3390,18 +3381,6 @@ __metadata: languageName: node linkType: hard -"@img/sharp-darwin-arm64@npm:0.33.3": - version: 0.33.3 - resolution: "@img/sharp-darwin-arm64@npm:0.33.3" - dependencies: - "@img/sharp-libvips-darwin-arm64": "npm:1.0.2" - dependenciesMeta: - "@img/sharp-libvips-darwin-arm64": - optional: true - conditions: os=darwin & cpu=arm64 - languageName: node - linkType: hard - "@img/sharp-darwin-arm64@npm:0.33.4": version: 0.33.4 resolution: "@img/sharp-darwin-arm64@npm:0.33.4" @@ -3414,18 +3393,6 @@ __metadata: languageName: node linkType: hard -"@img/sharp-darwin-x64@npm:0.33.3": - version: 0.33.3 - resolution: "@img/sharp-darwin-x64@npm:0.33.3" - dependencies: - "@img/sharp-libvips-darwin-x64": "npm:1.0.2" - dependenciesMeta: - "@img/sharp-libvips-darwin-x64": - optional: true - conditions: os=darwin & cpu=x64 - languageName: node - linkType: hard - "@img/sharp-darwin-x64@npm:0.33.4": version: 0.33.4 resolution: "@img/sharp-darwin-x64@npm:0.33.4" @@ -3494,18 +3461,6 @@ __metadata: languageName: node linkType: hard -"@img/sharp-linux-arm64@npm:0.33.3": - version: 0.33.3 - resolution: "@img/sharp-linux-arm64@npm:0.33.3" - dependencies: - "@img/sharp-libvips-linux-arm64": "npm:1.0.2" - dependenciesMeta: - "@img/sharp-libvips-linux-arm64": - optional: true - conditions: os=linux & cpu=arm64 & libc=glibc - languageName: node - linkType: hard - "@img/sharp-linux-arm64@npm:0.33.4": version: 0.33.4 resolution: "@img/sharp-linux-arm64@npm:0.33.4" @@ -3518,18 +3473,6 @@ __metadata: languageName: node linkType: hard -"@img/sharp-linux-arm@npm:0.33.3": - version: 0.33.3 - resolution: "@img/sharp-linux-arm@npm:0.33.3" - dependencies: - "@img/sharp-libvips-linux-arm": "npm:1.0.2" - dependenciesMeta: - "@img/sharp-libvips-linux-arm": - optional: true - conditions: os=linux & cpu=arm & libc=glibc - languageName: node - linkType: hard - "@img/sharp-linux-arm@npm:0.33.4": version: 0.33.4 resolution: "@img/sharp-linux-arm@npm:0.33.4" @@ -3542,18 +3485,6 @@ __metadata: languageName: node linkType: hard -"@img/sharp-linux-s390x@npm:0.33.3": - version: 0.33.3 - resolution: "@img/sharp-linux-s390x@npm:0.33.3" - dependencies: - "@img/sharp-libvips-linux-s390x": "npm:1.0.2" - dependenciesMeta: - "@img/sharp-libvips-linux-s390x": - optional: true - conditions: os=linux & cpu=s390x & libc=glibc - languageName: node - linkType: hard - "@img/sharp-linux-s390x@npm:0.33.4": version: 0.33.4 resolution: "@img/sharp-linux-s390x@npm:0.33.4" @@ -3566,18 +3497,6 @@ __metadata: languageName: node linkType: hard -"@img/sharp-linux-x64@npm:0.33.3": - version: 0.33.3 - resolution: "@img/sharp-linux-x64@npm:0.33.3" - dependencies: - "@img/sharp-libvips-linux-x64": "npm:1.0.2" - dependenciesMeta: - "@img/sharp-libvips-linux-x64": - optional: true - conditions: os=linux & cpu=x64 & libc=glibc - languageName: node - linkType: hard - "@img/sharp-linux-x64@npm:0.33.4": version: 0.33.4 resolution: "@img/sharp-linux-x64@npm:0.33.4" @@ -3590,18 +3509,6 @@ __metadata: languageName: node linkType: hard -"@img/sharp-linuxmusl-arm64@npm:0.33.3": - version: 0.33.3 - resolution: "@img/sharp-linuxmusl-arm64@npm:0.33.3" - dependencies: - "@img/sharp-libvips-linuxmusl-arm64": "npm:1.0.2" - dependenciesMeta: - "@img/sharp-libvips-linuxmusl-arm64": - optional: true - conditions: os=linux & cpu=arm64 & libc=musl - languageName: node - linkType: hard - "@img/sharp-linuxmusl-arm64@npm:0.33.4": version: 0.33.4 resolution: "@img/sharp-linuxmusl-arm64@npm:0.33.4" @@ -3614,18 +3521,6 @@ __metadata: languageName: node linkType: hard -"@img/sharp-linuxmusl-x64@npm:0.33.3": - version: 0.33.3 - resolution: "@img/sharp-linuxmusl-x64@npm:0.33.3" - dependencies: - "@img/sharp-libvips-linuxmusl-x64": "npm:1.0.2" - dependenciesMeta: - "@img/sharp-libvips-linuxmusl-x64": - optional: true - conditions: os=linux & cpu=x64 & libc=musl - languageName: node - linkType: hard - "@img/sharp-linuxmusl-x64@npm:0.33.4": version: 0.33.4 resolution: "@img/sharp-linuxmusl-x64@npm:0.33.4" @@ -3638,15 +3533,6 @@ __metadata: languageName: node linkType: hard -"@img/sharp-wasm32@npm:0.33.3": - version: 0.33.3 - resolution: "@img/sharp-wasm32@npm:0.33.3" - dependencies: - "@emnapi/runtime": "npm:^1.1.0" - conditions: cpu=wasm32 - languageName: node - linkType: hard - "@img/sharp-wasm32@npm:0.33.4": version: 0.33.4 resolution: "@img/sharp-wasm32@npm:0.33.4" @@ -3656,13 +3542,6 @@ __metadata: languageName: node linkType: hard -"@img/sharp-win32-ia32@npm:0.33.3": - version: 0.33.3 - resolution: "@img/sharp-win32-ia32@npm:0.33.3" - conditions: os=win32 & cpu=ia32 - languageName: node - linkType: hard - "@img/sharp-win32-ia32@npm:0.33.4": version: 0.33.4 resolution: "@img/sharp-win32-ia32@npm:0.33.4" @@ -3670,13 +3549,6 @@ __metadata: languageName: node linkType: hard -"@img/sharp-win32-x64@npm:0.33.3": - version: 0.33.3 - resolution: "@img/sharp-win32-x64@npm:0.33.3" - conditions: os=win32 & cpu=x64 - languageName: node - linkType: hard - "@img/sharp-win32-x64@npm:0.33.4": version: 0.33.4 resolution: "@img/sharp-win32-x64@npm:0.33.4" @@ -3939,13 +3811,6 @@ __metadata: languageName: node linkType: hard -"@next/env@npm:14.1.0": - version: 14.1.0 - resolution: "@next/env@npm:14.1.0" - checksum: 10c0/f45ce1e3dad87cdbddc58b06bd411f44a6d21dfc2c344d02a5e1b07f56fbc9a39e192c0b0917df9f2e9e4e2156306a8c78f173ca4b53932c2793e67797462a23 - languageName: node - linkType: hard - "@next/env@npm:14.2.5, @next/env@npm:^14.2.5": version: 14.2.5 resolution: "@next/env@npm:14.2.5" @@ -3953,13 +3818,6 @@ __metadata: languageName: node linkType: hard -"@next/swc-darwin-arm64@npm:14.1.0": - version: 14.1.0 - resolution: "@next/swc-darwin-arm64@npm:14.1.0" - conditions: os=darwin & cpu=arm64 - languageName: node - linkType: hard - "@next/swc-darwin-arm64@npm:14.2.5": version: 14.2.5 resolution: "@next/swc-darwin-arm64@npm:14.2.5" @@ -3967,13 +3825,6 @@ __metadata: languageName: node linkType: hard -"@next/swc-darwin-x64@npm:14.1.0": - version: 14.1.0 - resolution: "@next/swc-darwin-x64@npm:14.1.0" - conditions: os=darwin & cpu=x64 - languageName: node - linkType: hard - "@next/swc-darwin-x64@npm:14.2.5": version: 14.2.5 resolution: "@next/swc-darwin-x64@npm:14.2.5" @@ -3981,13 +3832,6 @@ __metadata: languageName: node linkType: hard -"@next/swc-linux-arm64-gnu@npm:14.1.0": - version: 14.1.0 - resolution: "@next/swc-linux-arm64-gnu@npm:14.1.0" - conditions: os=linux & cpu=arm64 & libc=glibc - languageName: node - linkType: hard - "@next/swc-linux-arm64-gnu@npm:14.2.5": version: 14.2.5 resolution: "@next/swc-linux-arm64-gnu@npm:14.2.5" @@ -3995,13 +3839,6 @@ __metadata: languageName: node linkType: hard -"@next/swc-linux-arm64-musl@npm:14.1.0": - version: 14.1.0 - resolution: "@next/swc-linux-arm64-musl@npm:14.1.0" - conditions: os=linux & cpu=arm64 & libc=musl - languageName: node - linkType: hard - "@next/swc-linux-arm64-musl@npm:14.2.5": version: 14.2.5 resolution: "@next/swc-linux-arm64-musl@npm:14.2.5" @@ -4009,13 +3846,6 @@ __metadata: languageName: node linkType: hard -"@next/swc-linux-x64-gnu@npm:14.1.0": - version: 14.1.0 - resolution: "@next/swc-linux-x64-gnu@npm:14.1.0" - conditions: os=linux & cpu=x64 & libc=glibc - languageName: node - linkType: hard - "@next/swc-linux-x64-gnu@npm:14.2.5": version: 14.2.5 resolution: "@next/swc-linux-x64-gnu@npm:14.2.5" @@ -4023,13 +3853,6 @@ __metadata: languageName: node linkType: hard -"@next/swc-linux-x64-musl@npm:14.1.0": - version: 14.1.0 - resolution: "@next/swc-linux-x64-musl@npm:14.1.0" - conditions: os=linux & cpu=x64 & libc=musl - languageName: node - linkType: hard - "@next/swc-linux-x64-musl@npm:14.2.5": version: 14.2.5 resolution: "@next/swc-linux-x64-musl@npm:14.2.5" @@ -4037,13 +3860,6 @@ __metadata: languageName: node linkType: hard -"@next/swc-win32-arm64-msvc@npm:14.1.0": - version: 14.1.0 - resolution: "@next/swc-win32-arm64-msvc@npm:14.1.0" - conditions: os=win32 & cpu=arm64 - languageName: node - linkType: hard - "@next/swc-win32-arm64-msvc@npm:14.2.5": version: 14.2.5 resolution: "@next/swc-win32-arm64-msvc@npm:14.2.5" @@ -4051,13 +3867,6 @@ __metadata: languageName: node linkType: hard -"@next/swc-win32-ia32-msvc@npm:14.1.0": - version: 14.1.0 - resolution: "@next/swc-win32-ia32-msvc@npm:14.1.0" - conditions: os=win32 & cpu=ia32 - languageName: node - linkType: hard - "@next/swc-win32-ia32-msvc@npm:14.2.5": version: 14.2.5 resolution: "@next/swc-win32-ia32-msvc@npm:14.2.5" @@ -4065,13 +3874,6 @@ __metadata: languageName: node linkType: hard -"@next/swc-win32-x64-msvc@npm:14.1.0": - version: 14.1.0 - resolution: "@next/swc-win32-x64-msvc@npm:14.1.0" - conditions: os=win32 & cpu=x64 - languageName: node - linkType: hard - "@next/swc-win32-x64-msvc@npm:14.2.5": version: 14.2.5 resolution: "@next/swc-win32-x64-msvc@npm:14.2.5" @@ -7233,15 +7035,6 @@ __metadata: languageName: node linkType: hard -"@swc/helpers@npm:0.5.2": - version: 0.5.2 - resolution: "@swc/helpers@npm:0.5.2" - dependencies: - tslib: "npm:^2.4.0" - checksum: 10c0/b6fa49bcf6c00571d0eb7837b163f8609960d4d77538160585e27ed167361e9776bd6e5eb9646ffac2fb4d43c58df9ca50dab9d96ab097e6591bc82a75fd1164 - languageName: node - linkType: hard - "@swc/helpers@npm:0.5.5": version: 0.5.5 resolution: "@swc/helpers@npm:0.5.5" @@ -17015,18 +16808,7 @@ __metadata: languageName: node linkType: hard -"image-size@npm:^1.0.0": - version: 1.0.2 - resolution: "image-size@npm:1.0.2" - dependencies: - queue: "npm:6.0.2" - bin: - image-size: bin/image-size.js - checksum: 10c0/df518606c75d0ee12a6d7e822a64ef50d9eabbb303dcee8c9df06bad94e49b4d4680b9003968203f239ff39a9cc51d4ff1781cd331cc0a4b3b858d9fc9836c68 - languageName: node - linkType: hard - -"image-size@npm:^1.1.1": +"image-size@npm:^1.0.0, image-size@npm:^1.1.1": version: 1.1.1 resolution: "image-size@npm:1.1.1" dependencies: @@ -20902,62 +20684,7 @@ __metadata: languageName: node linkType: hard -"next@npm:^14.1.0": - version: 14.1.0 - resolution: "next@npm:14.1.0" - dependencies: - "@next/env": "npm:14.1.0" - "@next/swc-darwin-arm64": "npm:14.1.0" - "@next/swc-darwin-x64": "npm:14.1.0" - "@next/swc-linux-arm64-gnu": "npm:14.1.0" - "@next/swc-linux-arm64-musl": "npm:14.1.0" - "@next/swc-linux-x64-gnu": "npm:14.1.0" - "@next/swc-linux-x64-musl": "npm:14.1.0" - "@next/swc-win32-arm64-msvc": "npm:14.1.0" - "@next/swc-win32-ia32-msvc": "npm:14.1.0" - "@next/swc-win32-x64-msvc": "npm:14.1.0" - "@swc/helpers": "npm:0.5.2" - busboy: "npm:1.6.0" - caniuse-lite: "npm:^1.0.30001579" - graceful-fs: "npm:^4.2.11" - postcss: "npm:8.4.31" - styled-jsx: "npm:5.1.1" - peerDependencies: - "@opentelemetry/api": ^1.1.0 - react: ^18.2.0 - react-dom: ^18.2.0 - sass: ^1.3.0 - dependenciesMeta: - "@next/swc-darwin-arm64": - optional: true - "@next/swc-darwin-x64": - optional: true - "@next/swc-linux-arm64-gnu": - optional: true - "@next/swc-linux-arm64-musl": - optional: true - "@next/swc-linux-x64-gnu": - optional: true - "@next/swc-linux-x64-musl": - optional: true - "@next/swc-win32-arm64-msvc": - optional: true - "@next/swc-win32-ia32-msvc": - optional: true - "@next/swc-win32-x64-msvc": - optional: true - peerDependenciesMeta: - "@opentelemetry/api": - optional: true - sass: - optional: true - bin: - next: dist/bin/next - checksum: 10c0/dbb1ef8d22eec29a9127d28ed46eb34f14e3f7f7b4e4b91dc96027feb4d9ead554a804275484d9a54026e6e55d632d3997561e598c1fb8e8956e77614f39765f - languageName: node - linkType: hard - -"next@npm:^14.2.5": +"next@npm:^14.1.0, next@npm:^14.2.5": version: 14.2.5 resolution: "next@npm:14.2.5" dependencies: @@ -25190,76 +24917,7 @@ __metadata: languageName: node linkType: hard -"sharp@npm:^0.33.3": - version: 0.33.3 - resolution: "sharp@npm:0.33.3" - dependencies: - "@img/sharp-darwin-arm64": "npm:0.33.3" - "@img/sharp-darwin-x64": "npm:0.33.3" - "@img/sharp-libvips-darwin-arm64": "npm:1.0.2" - "@img/sharp-libvips-darwin-x64": "npm:1.0.2" - "@img/sharp-libvips-linux-arm": "npm:1.0.2" - "@img/sharp-libvips-linux-arm64": "npm:1.0.2" - "@img/sharp-libvips-linux-s390x": "npm:1.0.2" - "@img/sharp-libvips-linux-x64": "npm:1.0.2" - "@img/sharp-libvips-linuxmusl-arm64": "npm:1.0.2" - "@img/sharp-libvips-linuxmusl-x64": "npm:1.0.2" - "@img/sharp-linux-arm": "npm:0.33.3" - "@img/sharp-linux-arm64": "npm:0.33.3" - "@img/sharp-linux-s390x": "npm:0.33.3" - "@img/sharp-linux-x64": "npm:0.33.3" - "@img/sharp-linuxmusl-arm64": "npm:0.33.3" - "@img/sharp-linuxmusl-x64": "npm:0.33.3" - "@img/sharp-wasm32": "npm:0.33.3" - "@img/sharp-win32-ia32": "npm:0.33.3" - "@img/sharp-win32-x64": "npm:0.33.3" - color: "npm:^4.2.3" - detect-libc: "npm:^2.0.3" - semver: "npm:^7.6.0" - dependenciesMeta: - "@img/sharp-darwin-arm64": - optional: true - "@img/sharp-darwin-x64": - optional: true - "@img/sharp-libvips-darwin-arm64": - optional: true - "@img/sharp-libvips-darwin-x64": - optional: true - "@img/sharp-libvips-linux-arm": - optional: true - "@img/sharp-libvips-linux-arm64": - optional: true - "@img/sharp-libvips-linux-s390x": - optional: true - "@img/sharp-libvips-linux-x64": - optional: true - "@img/sharp-libvips-linuxmusl-arm64": - optional: true - "@img/sharp-libvips-linuxmusl-x64": - optional: true - "@img/sharp-linux-arm": - optional: true - "@img/sharp-linux-arm64": - optional: true - "@img/sharp-linux-s390x": - optional: true - "@img/sharp-linux-x64": - optional: true - "@img/sharp-linuxmusl-arm64": - optional: true - "@img/sharp-linuxmusl-x64": - optional: true - "@img/sharp-wasm32": - optional: true - "@img/sharp-win32-ia32": - optional: true - "@img/sharp-win32-x64": - optional: true - checksum: 10c0/12f5203426595b4e64c807162a6d52358b591d25fbb414a51fe38861584759fba38485be951ed98d15be3dfe21f2def5336f78ca35bf8bbd22d88cc78ca03f2a - languageName: node - linkType: hard - -"sharp@npm:^0.33.4": +"sharp@npm:^0.33.3, sharp@npm:^0.33.4": version: 0.33.4 resolution: "sharp@npm:0.33.4" dependencies: From 0356e4468e9aefd9f49ee9a0761670746a9c1b0a Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 14 Aug 2024 14:50:54 +0200 Subject: [PATCH 3/5] fixes --- code/core/src/cli/detect.ts | 2 +- code/frameworks/nextjs/src/routing/app-router-provider.tsx | 1 + code/lib/{cli => create-storybook}/src/generators/NUXT/index.ts | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename code/lib/{cli => create-storybook}/src/generators/NUXT/index.ts (100%) diff --git a/code/core/src/cli/detect.ts b/code/core/src/cli/detect.ts index 92e884a6dd7b..8a51241374ae 100644 --- a/code/core/src/cli/detect.ts +++ b/code/core/src/cli/detect.ts @@ -215,7 +215,7 @@ export async function detectLanguage(packageManager: JsPackageManager) { // No direct dependency on TypeScript, but could be a transitive dependency // This is eg the case for Nuxt projects, which support a recent version of TypeScript // Check for tsconfig.json (https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) - if (fs.existsSync('tsconfig.json')) { + if (existsSync('tsconfig.json')) { language = SupportedLanguage.TYPESCRIPT_4_9; } } diff --git a/code/frameworks/nextjs/src/routing/app-router-provider.tsx b/code/frameworks/nextjs/src/routing/app-router-provider.tsx index 5685ec8bbf85..9f37f5768e15 100644 --- a/code/frameworks/nextjs/src/routing/app-router-provider.tsx +++ b/code/frameworks/nextjs/src/routing/app-router-provider.tsx @@ -101,6 +101,7 @@ export const AppRouterProvider: React.FC {children} diff --git a/code/lib/cli/src/generators/NUXT/index.ts b/code/lib/create-storybook/src/generators/NUXT/index.ts similarity index 100% rename from code/lib/cli/src/generators/NUXT/index.ts rename to code/lib/create-storybook/src/generators/NUXT/index.ts From 846bf4bf4ba83135bbf2d66b9cfebff64dd87f5a Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 23 Aug 2024 13:04:26 +0200 Subject: [PATCH 4/5] add nuxt sandbox --- code/lib/cli-storybook/src/sandbox-templates.ts | 12 ++++++++++++ scripts/utils/yarn.ts | 2 ++ 2 files changed, 14 insertions(+) diff --git a/code/lib/cli-storybook/src/sandbox-templates.ts b/code/lib/cli-storybook/src/sandbox-templates.ts index ffdbccdd5e4d..e388d24d6737 100644 --- a/code/lib/cli-storybook/src/sandbox-templates.ts +++ b/code/lib/cli-storybook/src/sandbox-templates.ts @@ -354,6 +354,17 @@ const baseTemplates = { }, skipTasks: ['e2e-tests-dev', 'bench'], }, + 'nuxt/v3-vite': { + name: 'Nuxt v3 (Vite | TypeScript)', + script: 'npx nuxi init --packageManager yarn --gitInit false {{beforeDir}}', + inDevelopment: true, + expected: { + framework: '@storybook-vue/nuxt', + renderer: '@storybook/vue3', + builder: '@storybook/builder-vite', + }, + skipTasks: ['e2e-tests-dev', 'bench'], + }, 'html-webpack/default': { name: 'HTML Latest (Webpack | JavaScript)', script: 'yarn create webpack5-html {{beforeDir}}', @@ -722,6 +733,7 @@ export const normal: TemplateKey[] = [ 'react-vite/default-ts', 'angular-cli/default-ts', 'vue3-vite/default-ts', + 'nuxt/v3-vite', 'lit-vite/default-ts', 'svelte-vite/default-ts', 'svelte-kit/skeleton-ts', diff --git a/scripts/utils/yarn.ts b/scripts/utils/yarn.ts index 95f686a382a4..9e29b91aeedf 100644 --- a/scripts/utils/yarn.ts +++ b/scripts/utils/yarn.ts @@ -123,6 +123,8 @@ export const configureYarn2ForVerdaccio = async ({ command.push( `yarn config set logFilters --json '[ { "code": "YN0013", "level": "discard" } ]'` ); + } else if (key.includes('nuxt')) { + // Nothing to do for Nuxt } else { // Discard all YN0013 - FETCH_NOT_CACHED messages // Error on YN0060 - INCOMPATIBLE_PEER_DEPENDENCY From 00ffb6bdc81977f0196d9d63861ee92f1a620ad8 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Tue, 10 Sep 2024 14:48:55 +0200 Subject: [PATCH 5/5] Update sandbox template for Nuxt v3 (Vite | TypeScript) --- code/lib/cli-storybook/src/sandbox-templates.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/lib/cli-storybook/src/sandbox-templates.ts b/code/lib/cli-storybook/src/sandbox-templates.ts index c30d740a245e..873804df841a 100644 --- a/code/lib/cli-storybook/src/sandbox-templates.ts +++ b/code/lib/cli-storybook/src/sandbox-templates.ts @@ -349,7 +349,7 @@ const baseTemplates = { }, skipTasks: ['e2e-tests-dev', 'bench'], }, - 'nuxt/v3-vite': { + 'nuxt-vite/default-ts': { name: 'Nuxt v3 (Vite | TypeScript)', script: 'npx nuxi init --packageManager yarn --gitInit false {{beforeDir}}', inDevelopment: true,