From 54503208a654ab395b8b906b69c26ece4e340e4e Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 2 Sep 2022 15:35:27 +0800 Subject: [PATCH] CLI: Fix sb init to use renderer assets instead of frameworks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 6.5 the `framework` config option was one of `react`, `angular`, etc. and included Webpack settings. In the 7.0, we’ve updated it so that these are now called `renderers`, and are builder-independent. Now, frameworks contain specific builder information, such as `cra` or `nextjs` (for specific app environments) or `react-webpack5` / `react-vite` (for custom apps). This fixes the `sb init` CLI command to use renderer-specific templates. I also call out some follow-up work to fix automigrations & telemetry --- code/lib/cli/.babelrc.json | 2 +- .../.eslintrc.json | 0 .../angular/Button.stories.ts | 0 .../angular/Header.stories.ts | 0 .../angular/Page.stories.ts | 0 .../angular/User.ts | 0 .../angular/button.component.ts | 0 .../angular/header.component.ts | 0 .../angular/page.component.ts | 0 .../aurelia/1-Button.stories.ts | 0 .../aurelia/button.ts | 0 .../common/Introduction.stories.mdx | 0 .../common/assets/code-brackets.svg | 0 .../common/assets/colors.svg | 0 .../common/assets/comments.svg | 0 .../common/assets/direction.svg | 0 .../common/assets/flow.svg | 0 .../common/assets/plugin.svg | 0 .../common/assets/repo.svg | 0 .../common/assets/stackalt.svg | 0 .../common/button.css | 0 .../common/header.css | 0 .../common/page.css | 0 .../ember/1-Button.stories.js | 0 .../html/js/Button.js | 0 .../html/js/Button.stories.js | 0 .../html/js/Header.js | 0 .../html/js/Header.stories.js | 0 .../html/js/Page.js | 0 .../html/js/Page.stories.js | 0 .../html/ts/Button.stories.ts | 0 .../html/ts/Button.ts | 0 .../html/ts/Header.stories.ts | 0 .../html/ts/Header.ts | 0 .../html/ts/Page.stories.ts | 0 .../html/ts/Page.ts | 0 .../marionette/index.stories.js | 0 .../marko/1-Button.stories.js | 0 .../marko/Button.marko | 0 .../mithril/Button.js | 0 .../mithril/Button.stories.js | 0 .../mithril/Header.js | 0 .../mithril/Header.stories.js | 0 .../mithril/Page.js | 0 .../mithril/Page.stories.js | 0 .../preact/Button.jsx | 0 .../preact/Button.stories.jsx | 0 .../preact/Header.jsx | 0 .../preact/Header.stories.jsx | 0 .../preact/Page.jsx | 0 .../preact/Page.stories.jsx | 0 .../rax/Button.js | 0 .../rax/Button.stories.js | 0 .../rax/Header.js | 0 .../rax/Header.stories.js | 0 .../rax/Page.js | 0 .../rax/Page.stories.js | 0 .../react/js/Button.jsx | 0 .../react/js/Button.stories.jsx | 0 .../react/js/Header.jsx | 0 .../react/js/Header.stories.jsx | 0 .../react/js/Page.jsx | 0 .../react/js/Page.stories.jsx | 0 .../react/ts/Button.stories.tsx | 0 .../react/ts/Button.tsx | 0 .../react/ts/Header.stories.tsx | 0 .../react/ts/Header.tsx | 0 .../react/ts/Page.stories.tsx | 0 .../react/ts/Page.tsx | 0 .../riot/1-Button.stories.js | 0 .../riot/MyButton.tag | 0 .../server/button.stories.json | 0 .../server/header.stories.json | 0 .../server/page.stories.json | 0 .../svelte/Button.stories.js | 0 .../svelte/Button.svelte | 0 .../svelte/Header.stories.js | 0 .../svelte/Header.svelte | 0 .../svelte/Page.stories.js | 0 .../svelte/Page.svelte | 0 .../vue/Button.stories.js | 0 .../vue/Button.vue | 0 .../vue/Header.stories.js | 0 .../vue/Header.vue | 0 .../vue/Page.stories.js | 0 .../vue/Page.vue | 0 .../vue3/Button.stories.js | 0 .../vue3/Button.vue | 0 .../vue3/Header.stories.js | 0 .../vue3/Header.vue | 0 .../vue3/Page.stories.js | 0 .../vue3/Page.vue | 0 .../web-components/js/Button.js | 0 .../web-components/js/Button.stories.js | 0 .../web-components/js/Header.js | 0 .../web-components/js/Header.stories.js | 0 .../web-components/js/Page.js | 0 .../web-components/js/Page.stories.js | 0 .../web-components/ts/Button.stories.ts | 0 .../web-components/ts/Button.ts | 0 .../web-components/ts/Header.stories.ts | 0 .../web-components/ts/Header.ts | 0 .../web-components/ts/Page.stories.ts | 0 .../web-components/ts/Page.ts | 0 code/lib/cli/src/.eslintrc.js | 2 +- .../src/automigrate/fixes/eslint-plugin.ts | 3 +- .../src/automigrate/fixes/mainjsFramework.ts | 2 ++ .../src/automigrate/fixes/new-frameworks.ts | 4 +-- code/lib/cli/src/generators/baseGenerator.ts | 1 + code/lib/cli/src/helpers.test.ts | 20 ++++++------ code/lib/cli/src/helpers.ts | 32 ++++++++----------- .../src/utils/get-storybook-info.ts | 27 +++++++++++----- code/lib/telemetry/src/storybook-metadata.ts | 2 ++ 113 files changed, 52 insertions(+), 43 deletions(-) rename code/lib/cli/{frameworks => rendererAssets}/.eslintrc.json (100%) rename code/lib/cli/{frameworks => rendererAssets}/angular/Button.stories.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/angular/Header.stories.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/angular/Page.stories.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/angular/User.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/angular/button.component.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/angular/header.component.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/angular/page.component.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/aurelia/1-Button.stories.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/aurelia/button.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/Introduction.stories.mdx (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/assets/code-brackets.svg (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/assets/colors.svg (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/assets/comments.svg (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/assets/direction.svg (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/assets/flow.svg (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/assets/plugin.svg (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/assets/repo.svg (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/assets/stackalt.svg (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/button.css (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/header.css (100%) rename code/lib/cli/{frameworks => rendererAssets}/common/page.css (100%) rename code/lib/cli/{frameworks => rendererAssets}/ember/1-Button.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/js/Button.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/js/Button.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/js/Header.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/js/Header.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/js/Page.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/js/Page.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/ts/Button.stories.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/ts/Button.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/ts/Header.stories.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/ts/Header.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/ts/Page.stories.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/html/ts/Page.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/marionette/index.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/marko/1-Button.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/marko/Button.marko (100%) rename code/lib/cli/{frameworks => rendererAssets}/mithril/Button.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/mithril/Button.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/mithril/Header.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/mithril/Header.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/mithril/Page.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/mithril/Page.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/preact/Button.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/preact/Button.stories.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/preact/Header.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/preact/Header.stories.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/preact/Page.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/preact/Page.stories.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/rax/Button.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/rax/Button.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/rax/Header.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/rax/Header.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/rax/Page.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/rax/Page.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/js/Button.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/js/Button.stories.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/js/Header.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/js/Header.stories.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/js/Page.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/js/Page.stories.jsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/ts/Button.stories.tsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/ts/Button.tsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/ts/Header.stories.tsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/ts/Header.tsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/ts/Page.stories.tsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/react/ts/Page.tsx (100%) rename code/lib/cli/{frameworks => rendererAssets}/riot/1-Button.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/riot/MyButton.tag (100%) rename code/lib/cli/{frameworks => rendererAssets}/server/button.stories.json (100%) rename code/lib/cli/{frameworks => rendererAssets}/server/header.stories.json (100%) rename code/lib/cli/{frameworks => rendererAssets}/server/page.stories.json (100%) rename code/lib/cli/{frameworks => rendererAssets}/svelte/Button.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/svelte/Button.svelte (100%) rename code/lib/cli/{frameworks => rendererAssets}/svelte/Header.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/svelte/Header.svelte (100%) rename code/lib/cli/{frameworks => rendererAssets}/svelte/Page.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/svelte/Page.svelte (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue/Button.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue/Button.vue (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue/Header.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue/Header.vue (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue/Page.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue/Page.vue (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue3/Button.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue3/Button.vue (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue3/Header.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue3/Header.vue (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue3/Page.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/vue3/Page.vue (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/js/Button.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/js/Button.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/js/Header.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/js/Header.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/js/Page.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/js/Page.stories.js (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/ts/Button.stories.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/ts/Button.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/ts/Header.stories.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/ts/Header.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/ts/Page.stories.ts (100%) rename code/lib/cli/{frameworks => rendererAssets}/web-components/ts/Page.ts (100%) diff --git a/code/lib/cli/.babelrc.json b/code/lib/cli/.babelrc.json index ffec5b09f395..89a2815442ec 100644 --- a/code/lib/cli/.babelrc.json +++ b/code/lib/cli/.babelrc.json @@ -12,7 +12,7 @@ ] ], "ignore": [ - "./src/frameworks", + "./src/rendererAssets", "./src/generators/**/template", "./src/generators/**/template-csf", "./src/generators/**/template-csf-ts", diff --git a/code/lib/cli/frameworks/.eslintrc.json b/code/lib/cli/rendererAssets/.eslintrc.json similarity index 100% rename from code/lib/cli/frameworks/.eslintrc.json rename to code/lib/cli/rendererAssets/.eslintrc.json diff --git a/code/lib/cli/frameworks/angular/Button.stories.ts b/code/lib/cli/rendererAssets/angular/Button.stories.ts similarity index 100% rename from code/lib/cli/frameworks/angular/Button.stories.ts rename to code/lib/cli/rendererAssets/angular/Button.stories.ts diff --git a/code/lib/cli/frameworks/angular/Header.stories.ts b/code/lib/cli/rendererAssets/angular/Header.stories.ts similarity index 100% rename from code/lib/cli/frameworks/angular/Header.stories.ts rename to code/lib/cli/rendererAssets/angular/Header.stories.ts diff --git a/code/lib/cli/frameworks/angular/Page.stories.ts b/code/lib/cli/rendererAssets/angular/Page.stories.ts similarity index 100% rename from code/lib/cli/frameworks/angular/Page.stories.ts rename to code/lib/cli/rendererAssets/angular/Page.stories.ts diff --git a/code/lib/cli/frameworks/angular/User.ts b/code/lib/cli/rendererAssets/angular/User.ts similarity index 100% rename from code/lib/cli/frameworks/angular/User.ts rename to code/lib/cli/rendererAssets/angular/User.ts diff --git a/code/lib/cli/frameworks/angular/button.component.ts b/code/lib/cli/rendererAssets/angular/button.component.ts similarity index 100% rename from code/lib/cli/frameworks/angular/button.component.ts rename to code/lib/cli/rendererAssets/angular/button.component.ts diff --git a/code/lib/cli/frameworks/angular/header.component.ts b/code/lib/cli/rendererAssets/angular/header.component.ts similarity index 100% rename from code/lib/cli/frameworks/angular/header.component.ts rename to code/lib/cli/rendererAssets/angular/header.component.ts diff --git a/code/lib/cli/frameworks/angular/page.component.ts b/code/lib/cli/rendererAssets/angular/page.component.ts similarity index 100% rename from code/lib/cli/frameworks/angular/page.component.ts rename to code/lib/cli/rendererAssets/angular/page.component.ts diff --git a/code/lib/cli/frameworks/aurelia/1-Button.stories.ts b/code/lib/cli/rendererAssets/aurelia/1-Button.stories.ts similarity index 100% rename from code/lib/cli/frameworks/aurelia/1-Button.stories.ts rename to code/lib/cli/rendererAssets/aurelia/1-Button.stories.ts diff --git a/code/lib/cli/frameworks/aurelia/button.ts b/code/lib/cli/rendererAssets/aurelia/button.ts similarity index 100% rename from code/lib/cli/frameworks/aurelia/button.ts rename to code/lib/cli/rendererAssets/aurelia/button.ts diff --git a/code/lib/cli/frameworks/common/Introduction.stories.mdx b/code/lib/cli/rendererAssets/common/Introduction.stories.mdx similarity index 100% rename from code/lib/cli/frameworks/common/Introduction.stories.mdx rename to code/lib/cli/rendererAssets/common/Introduction.stories.mdx diff --git a/code/lib/cli/frameworks/common/assets/code-brackets.svg b/code/lib/cli/rendererAssets/common/assets/code-brackets.svg similarity index 100% rename from code/lib/cli/frameworks/common/assets/code-brackets.svg rename to code/lib/cli/rendererAssets/common/assets/code-brackets.svg diff --git a/code/lib/cli/frameworks/common/assets/colors.svg b/code/lib/cli/rendererAssets/common/assets/colors.svg similarity index 100% rename from code/lib/cli/frameworks/common/assets/colors.svg rename to code/lib/cli/rendererAssets/common/assets/colors.svg diff --git a/code/lib/cli/frameworks/common/assets/comments.svg b/code/lib/cli/rendererAssets/common/assets/comments.svg similarity index 100% rename from code/lib/cli/frameworks/common/assets/comments.svg rename to code/lib/cli/rendererAssets/common/assets/comments.svg diff --git a/code/lib/cli/frameworks/common/assets/direction.svg b/code/lib/cli/rendererAssets/common/assets/direction.svg similarity index 100% rename from code/lib/cli/frameworks/common/assets/direction.svg rename to code/lib/cli/rendererAssets/common/assets/direction.svg diff --git a/code/lib/cli/frameworks/common/assets/flow.svg b/code/lib/cli/rendererAssets/common/assets/flow.svg similarity index 100% rename from code/lib/cli/frameworks/common/assets/flow.svg rename to code/lib/cli/rendererAssets/common/assets/flow.svg diff --git a/code/lib/cli/frameworks/common/assets/plugin.svg b/code/lib/cli/rendererAssets/common/assets/plugin.svg similarity index 100% rename from code/lib/cli/frameworks/common/assets/plugin.svg rename to code/lib/cli/rendererAssets/common/assets/plugin.svg diff --git a/code/lib/cli/frameworks/common/assets/repo.svg b/code/lib/cli/rendererAssets/common/assets/repo.svg similarity index 100% rename from code/lib/cli/frameworks/common/assets/repo.svg rename to code/lib/cli/rendererAssets/common/assets/repo.svg diff --git a/code/lib/cli/frameworks/common/assets/stackalt.svg b/code/lib/cli/rendererAssets/common/assets/stackalt.svg similarity index 100% rename from code/lib/cli/frameworks/common/assets/stackalt.svg rename to code/lib/cli/rendererAssets/common/assets/stackalt.svg diff --git a/code/lib/cli/frameworks/common/button.css b/code/lib/cli/rendererAssets/common/button.css similarity index 100% rename from code/lib/cli/frameworks/common/button.css rename to code/lib/cli/rendererAssets/common/button.css diff --git a/code/lib/cli/frameworks/common/header.css b/code/lib/cli/rendererAssets/common/header.css similarity index 100% rename from code/lib/cli/frameworks/common/header.css rename to code/lib/cli/rendererAssets/common/header.css diff --git a/code/lib/cli/frameworks/common/page.css b/code/lib/cli/rendererAssets/common/page.css similarity index 100% rename from code/lib/cli/frameworks/common/page.css rename to code/lib/cli/rendererAssets/common/page.css diff --git a/code/lib/cli/frameworks/ember/1-Button.stories.js b/code/lib/cli/rendererAssets/ember/1-Button.stories.js similarity index 100% rename from code/lib/cli/frameworks/ember/1-Button.stories.js rename to code/lib/cli/rendererAssets/ember/1-Button.stories.js diff --git a/code/lib/cli/frameworks/html/js/Button.js b/code/lib/cli/rendererAssets/html/js/Button.js similarity index 100% rename from code/lib/cli/frameworks/html/js/Button.js rename to code/lib/cli/rendererAssets/html/js/Button.js diff --git a/code/lib/cli/frameworks/html/js/Button.stories.js b/code/lib/cli/rendererAssets/html/js/Button.stories.js similarity index 100% rename from code/lib/cli/frameworks/html/js/Button.stories.js rename to code/lib/cli/rendererAssets/html/js/Button.stories.js diff --git a/code/lib/cli/frameworks/html/js/Header.js b/code/lib/cli/rendererAssets/html/js/Header.js similarity index 100% rename from code/lib/cli/frameworks/html/js/Header.js rename to code/lib/cli/rendererAssets/html/js/Header.js diff --git a/code/lib/cli/frameworks/html/js/Header.stories.js b/code/lib/cli/rendererAssets/html/js/Header.stories.js similarity index 100% rename from code/lib/cli/frameworks/html/js/Header.stories.js rename to code/lib/cli/rendererAssets/html/js/Header.stories.js diff --git a/code/lib/cli/frameworks/html/js/Page.js b/code/lib/cli/rendererAssets/html/js/Page.js similarity index 100% rename from code/lib/cli/frameworks/html/js/Page.js rename to code/lib/cli/rendererAssets/html/js/Page.js diff --git a/code/lib/cli/frameworks/html/js/Page.stories.js b/code/lib/cli/rendererAssets/html/js/Page.stories.js similarity index 100% rename from code/lib/cli/frameworks/html/js/Page.stories.js rename to code/lib/cli/rendererAssets/html/js/Page.stories.js diff --git a/code/lib/cli/frameworks/html/ts/Button.stories.ts b/code/lib/cli/rendererAssets/html/ts/Button.stories.ts similarity index 100% rename from code/lib/cli/frameworks/html/ts/Button.stories.ts rename to code/lib/cli/rendererAssets/html/ts/Button.stories.ts diff --git a/code/lib/cli/frameworks/html/ts/Button.ts b/code/lib/cli/rendererAssets/html/ts/Button.ts similarity index 100% rename from code/lib/cli/frameworks/html/ts/Button.ts rename to code/lib/cli/rendererAssets/html/ts/Button.ts diff --git a/code/lib/cli/frameworks/html/ts/Header.stories.ts b/code/lib/cli/rendererAssets/html/ts/Header.stories.ts similarity index 100% rename from code/lib/cli/frameworks/html/ts/Header.stories.ts rename to code/lib/cli/rendererAssets/html/ts/Header.stories.ts diff --git a/code/lib/cli/frameworks/html/ts/Header.ts b/code/lib/cli/rendererAssets/html/ts/Header.ts similarity index 100% rename from code/lib/cli/frameworks/html/ts/Header.ts rename to code/lib/cli/rendererAssets/html/ts/Header.ts diff --git a/code/lib/cli/frameworks/html/ts/Page.stories.ts b/code/lib/cli/rendererAssets/html/ts/Page.stories.ts similarity index 100% rename from code/lib/cli/frameworks/html/ts/Page.stories.ts rename to code/lib/cli/rendererAssets/html/ts/Page.stories.ts diff --git a/code/lib/cli/frameworks/html/ts/Page.ts b/code/lib/cli/rendererAssets/html/ts/Page.ts similarity index 100% rename from code/lib/cli/frameworks/html/ts/Page.ts rename to code/lib/cli/rendererAssets/html/ts/Page.ts diff --git a/code/lib/cli/frameworks/marionette/index.stories.js b/code/lib/cli/rendererAssets/marionette/index.stories.js similarity index 100% rename from code/lib/cli/frameworks/marionette/index.stories.js rename to code/lib/cli/rendererAssets/marionette/index.stories.js diff --git a/code/lib/cli/frameworks/marko/1-Button.stories.js b/code/lib/cli/rendererAssets/marko/1-Button.stories.js similarity index 100% rename from code/lib/cli/frameworks/marko/1-Button.stories.js rename to code/lib/cli/rendererAssets/marko/1-Button.stories.js diff --git a/code/lib/cli/frameworks/marko/Button.marko b/code/lib/cli/rendererAssets/marko/Button.marko similarity index 100% rename from code/lib/cli/frameworks/marko/Button.marko rename to code/lib/cli/rendererAssets/marko/Button.marko diff --git a/code/lib/cli/frameworks/mithril/Button.js b/code/lib/cli/rendererAssets/mithril/Button.js similarity index 100% rename from code/lib/cli/frameworks/mithril/Button.js rename to code/lib/cli/rendererAssets/mithril/Button.js diff --git a/code/lib/cli/frameworks/mithril/Button.stories.js b/code/lib/cli/rendererAssets/mithril/Button.stories.js similarity index 100% rename from code/lib/cli/frameworks/mithril/Button.stories.js rename to code/lib/cli/rendererAssets/mithril/Button.stories.js diff --git a/code/lib/cli/frameworks/mithril/Header.js b/code/lib/cli/rendererAssets/mithril/Header.js similarity index 100% rename from code/lib/cli/frameworks/mithril/Header.js rename to code/lib/cli/rendererAssets/mithril/Header.js diff --git a/code/lib/cli/frameworks/mithril/Header.stories.js b/code/lib/cli/rendererAssets/mithril/Header.stories.js similarity index 100% rename from code/lib/cli/frameworks/mithril/Header.stories.js rename to code/lib/cli/rendererAssets/mithril/Header.stories.js diff --git a/code/lib/cli/frameworks/mithril/Page.js b/code/lib/cli/rendererAssets/mithril/Page.js similarity index 100% rename from code/lib/cli/frameworks/mithril/Page.js rename to code/lib/cli/rendererAssets/mithril/Page.js diff --git a/code/lib/cli/frameworks/mithril/Page.stories.js b/code/lib/cli/rendererAssets/mithril/Page.stories.js similarity index 100% rename from code/lib/cli/frameworks/mithril/Page.stories.js rename to code/lib/cli/rendererAssets/mithril/Page.stories.js diff --git a/code/lib/cli/frameworks/preact/Button.jsx b/code/lib/cli/rendererAssets/preact/Button.jsx similarity index 100% rename from code/lib/cli/frameworks/preact/Button.jsx rename to code/lib/cli/rendererAssets/preact/Button.jsx diff --git a/code/lib/cli/frameworks/preact/Button.stories.jsx b/code/lib/cli/rendererAssets/preact/Button.stories.jsx similarity index 100% rename from code/lib/cli/frameworks/preact/Button.stories.jsx rename to code/lib/cli/rendererAssets/preact/Button.stories.jsx diff --git a/code/lib/cli/frameworks/preact/Header.jsx b/code/lib/cli/rendererAssets/preact/Header.jsx similarity index 100% rename from code/lib/cli/frameworks/preact/Header.jsx rename to code/lib/cli/rendererAssets/preact/Header.jsx diff --git a/code/lib/cli/frameworks/preact/Header.stories.jsx b/code/lib/cli/rendererAssets/preact/Header.stories.jsx similarity index 100% rename from code/lib/cli/frameworks/preact/Header.stories.jsx rename to code/lib/cli/rendererAssets/preact/Header.stories.jsx diff --git a/code/lib/cli/frameworks/preact/Page.jsx b/code/lib/cli/rendererAssets/preact/Page.jsx similarity index 100% rename from code/lib/cli/frameworks/preact/Page.jsx rename to code/lib/cli/rendererAssets/preact/Page.jsx diff --git a/code/lib/cli/frameworks/preact/Page.stories.jsx b/code/lib/cli/rendererAssets/preact/Page.stories.jsx similarity index 100% rename from code/lib/cli/frameworks/preact/Page.stories.jsx rename to code/lib/cli/rendererAssets/preact/Page.stories.jsx diff --git a/code/lib/cli/frameworks/rax/Button.js b/code/lib/cli/rendererAssets/rax/Button.js similarity index 100% rename from code/lib/cli/frameworks/rax/Button.js rename to code/lib/cli/rendererAssets/rax/Button.js diff --git a/code/lib/cli/frameworks/rax/Button.stories.js b/code/lib/cli/rendererAssets/rax/Button.stories.js similarity index 100% rename from code/lib/cli/frameworks/rax/Button.stories.js rename to code/lib/cli/rendererAssets/rax/Button.stories.js diff --git a/code/lib/cli/frameworks/rax/Header.js b/code/lib/cli/rendererAssets/rax/Header.js similarity index 100% rename from code/lib/cli/frameworks/rax/Header.js rename to code/lib/cli/rendererAssets/rax/Header.js diff --git a/code/lib/cli/frameworks/rax/Header.stories.js b/code/lib/cli/rendererAssets/rax/Header.stories.js similarity index 100% rename from code/lib/cli/frameworks/rax/Header.stories.js rename to code/lib/cli/rendererAssets/rax/Header.stories.js diff --git a/code/lib/cli/frameworks/rax/Page.js b/code/lib/cli/rendererAssets/rax/Page.js similarity index 100% rename from code/lib/cli/frameworks/rax/Page.js rename to code/lib/cli/rendererAssets/rax/Page.js diff --git a/code/lib/cli/frameworks/rax/Page.stories.js b/code/lib/cli/rendererAssets/rax/Page.stories.js similarity index 100% rename from code/lib/cli/frameworks/rax/Page.stories.js rename to code/lib/cli/rendererAssets/rax/Page.stories.js diff --git a/code/lib/cli/frameworks/react/js/Button.jsx b/code/lib/cli/rendererAssets/react/js/Button.jsx similarity index 100% rename from code/lib/cli/frameworks/react/js/Button.jsx rename to code/lib/cli/rendererAssets/react/js/Button.jsx diff --git a/code/lib/cli/frameworks/react/js/Button.stories.jsx b/code/lib/cli/rendererAssets/react/js/Button.stories.jsx similarity index 100% rename from code/lib/cli/frameworks/react/js/Button.stories.jsx rename to code/lib/cli/rendererAssets/react/js/Button.stories.jsx diff --git a/code/lib/cli/frameworks/react/js/Header.jsx b/code/lib/cli/rendererAssets/react/js/Header.jsx similarity index 100% rename from code/lib/cli/frameworks/react/js/Header.jsx rename to code/lib/cli/rendererAssets/react/js/Header.jsx diff --git a/code/lib/cli/frameworks/react/js/Header.stories.jsx b/code/lib/cli/rendererAssets/react/js/Header.stories.jsx similarity index 100% rename from code/lib/cli/frameworks/react/js/Header.stories.jsx rename to code/lib/cli/rendererAssets/react/js/Header.stories.jsx diff --git a/code/lib/cli/frameworks/react/js/Page.jsx b/code/lib/cli/rendererAssets/react/js/Page.jsx similarity index 100% rename from code/lib/cli/frameworks/react/js/Page.jsx rename to code/lib/cli/rendererAssets/react/js/Page.jsx diff --git a/code/lib/cli/frameworks/react/js/Page.stories.jsx b/code/lib/cli/rendererAssets/react/js/Page.stories.jsx similarity index 100% rename from code/lib/cli/frameworks/react/js/Page.stories.jsx rename to code/lib/cli/rendererAssets/react/js/Page.stories.jsx diff --git a/code/lib/cli/frameworks/react/ts/Button.stories.tsx b/code/lib/cli/rendererAssets/react/ts/Button.stories.tsx similarity index 100% rename from code/lib/cli/frameworks/react/ts/Button.stories.tsx rename to code/lib/cli/rendererAssets/react/ts/Button.stories.tsx diff --git a/code/lib/cli/frameworks/react/ts/Button.tsx b/code/lib/cli/rendererAssets/react/ts/Button.tsx similarity index 100% rename from code/lib/cli/frameworks/react/ts/Button.tsx rename to code/lib/cli/rendererAssets/react/ts/Button.tsx diff --git a/code/lib/cli/frameworks/react/ts/Header.stories.tsx b/code/lib/cli/rendererAssets/react/ts/Header.stories.tsx similarity index 100% rename from code/lib/cli/frameworks/react/ts/Header.stories.tsx rename to code/lib/cli/rendererAssets/react/ts/Header.stories.tsx diff --git a/code/lib/cli/frameworks/react/ts/Header.tsx b/code/lib/cli/rendererAssets/react/ts/Header.tsx similarity index 100% rename from code/lib/cli/frameworks/react/ts/Header.tsx rename to code/lib/cli/rendererAssets/react/ts/Header.tsx diff --git a/code/lib/cli/frameworks/react/ts/Page.stories.tsx b/code/lib/cli/rendererAssets/react/ts/Page.stories.tsx similarity index 100% rename from code/lib/cli/frameworks/react/ts/Page.stories.tsx rename to code/lib/cli/rendererAssets/react/ts/Page.stories.tsx diff --git a/code/lib/cli/frameworks/react/ts/Page.tsx b/code/lib/cli/rendererAssets/react/ts/Page.tsx similarity index 100% rename from code/lib/cli/frameworks/react/ts/Page.tsx rename to code/lib/cli/rendererAssets/react/ts/Page.tsx diff --git a/code/lib/cli/frameworks/riot/1-Button.stories.js b/code/lib/cli/rendererAssets/riot/1-Button.stories.js similarity index 100% rename from code/lib/cli/frameworks/riot/1-Button.stories.js rename to code/lib/cli/rendererAssets/riot/1-Button.stories.js diff --git a/code/lib/cli/frameworks/riot/MyButton.tag b/code/lib/cli/rendererAssets/riot/MyButton.tag similarity index 100% rename from code/lib/cli/frameworks/riot/MyButton.tag rename to code/lib/cli/rendererAssets/riot/MyButton.tag diff --git a/code/lib/cli/frameworks/server/button.stories.json b/code/lib/cli/rendererAssets/server/button.stories.json similarity index 100% rename from code/lib/cli/frameworks/server/button.stories.json rename to code/lib/cli/rendererAssets/server/button.stories.json diff --git a/code/lib/cli/frameworks/server/header.stories.json b/code/lib/cli/rendererAssets/server/header.stories.json similarity index 100% rename from code/lib/cli/frameworks/server/header.stories.json rename to code/lib/cli/rendererAssets/server/header.stories.json diff --git a/code/lib/cli/frameworks/server/page.stories.json b/code/lib/cli/rendererAssets/server/page.stories.json similarity index 100% rename from code/lib/cli/frameworks/server/page.stories.json rename to code/lib/cli/rendererAssets/server/page.stories.json diff --git a/code/lib/cli/frameworks/svelte/Button.stories.js b/code/lib/cli/rendererAssets/svelte/Button.stories.js similarity index 100% rename from code/lib/cli/frameworks/svelte/Button.stories.js rename to code/lib/cli/rendererAssets/svelte/Button.stories.js diff --git a/code/lib/cli/frameworks/svelte/Button.svelte b/code/lib/cli/rendererAssets/svelte/Button.svelte similarity index 100% rename from code/lib/cli/frameworks/svelte/Button.svelte rename to code/lib/cli/rendererAssets/svelte/Button.svelte diff --git a/code/lib/cli/frameworks/svelte/Header.stories.js b/code/lib/cli/rendererAssets/svelte/Header.stories.js similarity index 100% rename from code/lib/cli/frameworks/svelte/Header.stories.js rename to code/lib/cli/rendererAssets/svelte/Header.stories.js diff --git a/code/lib/cli/frameworks/svelte/Header.svelte b/code/lib/cli/rendererAssets/svelte/Header.svelte similarity index 100% rename from code/lib/cli/frameworks/svelte/Header.svelte rename to code/lib/cli/rendererAssets/svelte/Header.svelte diff --git a/code/lib/cli/frameworks/svelte/Page.stories.js b/code/lib/cli/rendererAssets/svelte/Page.stories.js similarity index 100% rename from code/lib/cli/frameworks/svelte/Page.stories.js rename to code/lib/cli/rendererAssets/svelte/Page.stories.js diff --git a/code/lib/cli/frameworks/svelte/Page.svelte b/code/lib/cli/rendererAssets/svelte/Page.svelte similarity index 100% rename from code/lib/cli/frameworks/svelte/Page.svelte rename to code/lib/cli/rendererAssets/svelte/Page.svelte diff --git a/code/lib/cli/frameworks/vue/Button.stories.js b/code/lib/cli/rendererAssets/vue/Button.stories.js similarity index 100% rename from code/lib/cli/frameworks/vue/Button.stories.js rename to code/lib/cli/rendererAssets/vue/Button.stories.js diff --git a/code/lib/cli/frameworks/vue/Button.vue b/code/lib/cli/rendererAssets/vue/Button.vue similarity index 100% rename from code/lib/cli/frameworks/vue/Button.vue rename to code/lib/cli/rendererAssets/vue/Button.vue diff --git a/code/lib/cli/frameworks/vue/Header.stories.js b/code/lib/cli/rendererAssets/vue/Header.stories.js similarity index 100% rename from code/lib/cli/frameworks/vue/Header.stories.js rename to code/lib/cli/rendererAssets/vue/Header.stories.js diff --git a/code/lib/cli/frameworks/vue/Header.vue b/code/lib/cli/rendererAssets/vue/Header.vue similarity index 100% rename from code/lib/cli/frameworks/vue/Header.vue rename to code/lib/cli/rendererAssets/vue/Header.vue diff --git a/code/lib/cli/frameworks/vue/Page.stories.js b/code/lib/cli/rendererAssets/vue/Page.stories.js similarity index 100% rename from code/lib/cli/frameworks/vue/Page.stories.js rename to code/lib/cli/rendererAssets/vue/Page.stories.js diff --git a/code/lib/cli/frameworks/vue/Page.vue b/code/lib/cli/rendererAssets/vue/Page.vue similarity index 100% rename from code/lib/cli/frameworks/vue/Page.vue rename to code/lib/cli/rendererAssets/vue/Page.vue diff --git a/code/lib/cli/frameworks/vue3/Button.stories.js b/code/lib/cli/rendererAssets/vue3/Button.stories.js similarity index 100% rename from code/lib/cli/frameworks/vue3/Button.stories.js rename to code/lib/cli/rendererAssets/vue3/Button.stories.js diff --git a/code/lib/cli/frameworks/vue3/Button.vue b/code/lib/cli/rendererAssets/vue3/Button.vue similarity index 100% rename from code/lib/cli/frameworks/vue3/Button.vue rename to code/lib/cli/rendererAssets/vue3/Button.vue diff --git a/code/lib/cli/frameworks/vue3/Header.stories.js b/code/lib/cli/rendererAssets/vue3/Header.stories.js similarity index 100% rename from code/lib/cli/frameworks/vue3/Header.stories.js rename to code/lib/cli/rendererAssets/vue3/Header.stories.js diff --git a/code/lib/cli/frameworks/vue3/Header.vue b/code/lib/cli/rendererAssets/vue3/Header.vue similarity index 100% rename from code/lib/cli/frameworks/vue3/Header.vue rename to code/lib/cli/rendererAssets/vue3/Header.vue diff --git a/code/lib/cli/frameworks/vue3/Page.stories.js b/code/lib/cli/rendererAssets/vue3/Page.stories.js similarity index 100% rename from code/lib/cli/frameworks/vue3/Page.stories.js rename to code/lib/cli/rendererAssets/vue3/Page.stories.js diff --git a/code/lib/cli/frameworks/vue3/Page.vue b/code/lib/cli/rendererAssets/vue3/Page.vue similarity index 100% rename from code/lib/cli/frameworks/vue3/Page.vue rename to code/lib/cli/rendererAssets/vue3/Page.vue diff --git a/code/lib/cli/frameworks/web-components/js/Button.js b/code/lib/cli/rendererAssets/web-components/js/Button.js similarity index 100% rename from code/lib/cli/frameworks/web-components/js/Button.js rename to code/lib/cli/rendererAssets/web-components/js/Button.js diff --git a/code/lib/cli/frameworks/web-components/js/Button.stories.js b/code/lib/cli/rendererAssets/web-components/js/Button.stories.js similarity index 100% rename from code/lib/cli/frameworks/web-components/js/Button.stories.js rename to code/lib/cli/rendererAssets/web-components/js/Button.stories.js diff --git a/code/lib/cli/frameworks/web-components/js/Header.js b/code/lib/cli/rendererAssets/web-components/js/Header.js similarity index 100% rename from code/lib/cli/frameworks/web-components/js/Header.js rename to code/lib/cli/rendererAssets/web-components/js/Header.js diff --git a/code/lib/cli/frameworks/web-components/js/Header.stories.js b/code/lib/cli/rendererAssets/web-components/js/Header.stories.js similarity index 100% rename from code/lib/cli/frameworks/web-components/js/Header.stories.js rename to code/lib/cli/rendererAssets/web-components/js/Header.stories.js diff --git a/code/lib/cli/frameworks/web-components/js/Page.js b/code/lib/cli/rendererAssets/web-components/js/Page.js similarity index 100% rename from code/lib/cli/frameworks/web-components/js/Page.js rename to code/lib/cli/rendererAssets/web-components/js/Page.js diff --git a/code/lib/cli/frameworks/web-components/js/Page.stories.js b/code/lib/cli/rendererAssets/web-components/js/Page.stories.js similarity index 100% rename from code/lib/cli/frameworks/web-components/js/Page.stories.js rename to code/lib/cli/rendererAssets/web-components/js/Page.stories.js diff --git a/code/lib/cli/frameworks/web-components/ts/Button.stories.ts b/code/lib/cli/rendererAssets/web-components/ts/Button.stories.ts similarity index 100% rename from code/lib/cli/frameworks/web-components/ts/Button.stories.ts rename to code/lib/cli/rendererAssets/web-components/ts/Button.stories.ts diff --git a/code/lib/cli/frameworks/web-components/ts/Button.ts b/code/lib/cli/rendererAssets/web-components/ts/Button.ts similarity index 100% rename from code/lib/cli/frameworks/web-components/ts/Button.ts rename to code/lib/cli/rendererAssets/web-components/ts/Button.ts diff --git a/code/lib/cli/frameworks/web-components/ts/Header.stories.ts b/code/lib/cli/rendererAssets/web-components/ts/Header.stories.ts similarity index 100% rename from code/lib/cli/frameworks/web-components/ts/Header.stories.ts rename to code/lib/cli/rendererAssets/web-components/ts/Header.stories.ts diff --git a/code/lib/cli/frameworks/web-components/ts/Header.ts b/code/lib/cli/rendererAssets/web-components/ts/Header.ts similarity index 100% rename from code/lib/cli/frameworks/web-components/ts/Header.ts rename to code/lib/cli/rendererAssets/web-components/ts/Header.ts diff --git a/code/lib/cli/frameworks/web-components/ts/Page.stories.ts b/code/lib/cli/rendererAssets/web-components/ts/Page.stories.ts similarity index 100% rename from code/lib/cli/frameworks/web-components/ts/Page.stories.ts rename to code/lib/cli/rendererAssets/web-components/ts/Page.stories.ts diff --git a/code/lib/cli/frameworks/web-components/ts/Page.ts b/code/lib/cli/rendererAssets/web-components/ts/Page.ts similarity index 100% rename from code/lib/cli/frameworks/web-components/ts/Page.ts rename to code/lib/cli/rendererAssets/web-components/ts/Page.ts diff --git a/code/lib/cli/src/.eslintrc.js b/code/lib/cli/src/.eslintrc.js index 5eff5c56025e..e52ac7f901d5 100644 --- a/code/lib/cli/src/.eslintrc.js +++ b/code/lib/cli/src/.eslintrc.js @@ -23,7 +23,7 @@ module.exports = { }, }, { - files: 'frameworks/**/*', + files: 'rendererAssets/**/*', env: { browser: true, }, diff --git a/code/lib/cli/src/automigrate/fixes/eslint-plugin.ts b/code/lib/cli/src/automigrate/fixes/eslint-plugin.ts index 668349594cc1..1a83c18c91b7 100644 --- a/code/lib/cli/src/automigrate/fixes/eslint-plugin.ts +++ b/code/lib/cli/src/automigrate/fixes/eslint-plugin.ts @@ -36,9 +36,8 @@ export const eslintPlugin: Fix = { return null; } - const config = getStorybookInfo(packageJson); + const { mainConfig } = getStorybookInfo(packageJson); - const { mainConfig } = config; if (!mainConfig) { logger.warn('Unable to find storybook main.js config, skipping'); return null; diff --git a/code/lib/cli/src/automigrate/fixes/mainjsFramework.ts b/code/lib/cli/src/automigrate/fixes/mainjsFramework.ts index 935f134367fd..9c48c9b58227 100644 --- a/code/lib/cli/src/automigrate/fixes/mainjsFramework.ts +++ b/code/lib/cli/src/automigrate/fixes/mainjsFramework.ts @@ -19,6 +19,8 @@ export const mainjsFramework: Fix = { async check({ packageManager }) { const packageJson = packageManager.retrievePackageJson(); + + // FIXME: use renderer in SB7? const { mainConfig, framework, version: storybookVersion } = getStorybookInfo(packageJson); if (!mainConfig) { diff --git a/code/lib/cli/src/automigrate/fixes/new-frameworks.ts b/code/lib/cli/src/automigrate/fixes/new-frameworks.ts index ca5b2ecbce38..fae11338f7b4 100644 --- a/code/lib/cli/src/automigrate/fixes/new-frameworks.ts +++ b/code/lib/cli/src/automigrate/fixes/new-frameworks.ts @@ -89,8 +89,8 @@ export const newFrameworks: Fix = { const packageJson = packageManager.retrievePackageJson(); const allDeps = { ...packageJson.dependencies, ...packageJson.devDependencies }; - const config = getStorybookInfo(packageJson); - const { mainConfig, version: storybookVersion, framework } = config; + // FIXME: update to use renderer instead of framework + const { mainConfig, version: storybookVersion, framework } = getStorybookInfo(packageJson); if (!mainConfig) { logger.warn('Unable to find storybook main.js config, skipping'); return null; diff --git a/code/lib/cli/src/generators/baseGenerator.ts b/code/lib/cli/src/generators/baseGenerator.ts index 86b63d4fb334..62be508ec73e 100644 --- a/code/lib/cli/src/generators/baseGenerator.ts +++ b/code/lib/cli/src/generators/baseGenerator.ts @@ -176,6 +176,7 @@ export async function baseGenerator( const packages = [ 'storybook', + `@storybook/${renderer}`, ...frameworkPackages, ...addonPackages, ...extraPackages, diff --git a/code/lib/cli/src/helpers.test.ts b/code/lib/cli/src/helpers.test.ts index 9c78e7873516..78cd7cbbf1c4 100644 --- a/code/lib/cli/src/helpers.test.ts +++ b/code/lib/cli/src/helpers.test.ts @@ -67,10 +67,10 @@ describe('Helpers', () => { `( `should copy $expected when folder $exists exists for language $language`, async ({ language, exists, expected }) => { - const componentsDirectory = exists.map((folder: string) => `frameworks/react/${folder}`); - const expectedDirectory = `frameworks/react${expected}`; + const componentsDirectory = exists.map((folder: string) => `rendererAssets/react/${folder}`); + const expectedDirectory = `rendererAssets/react${expected}`; (fse.pathExists as jest.Mock).mockImplementation((filePath) => { - return componentsDirectory.includes(filePath) || filePath === 'frameworks/react'; + return componentsDirectory.includes(filePath) || filePath === 'rendererAssets/react'; }); await helpers.copyComponents('react', language); @@ -78,7 +78,7 @@ describe('Helpers', () => { expect(copySpy).toHaveBeenNthCalledWith(1, expectedDirectory, './stories', expect.anything()); expect(copySpy).toHaveBeenNthCalledWith( 2, - 'frameworks/common', + 'rendererAssets/common', './stories', expect.anything() ); @@ -87,7 +87,7 @@ describe('Helpers', () => { it(`should copy to src folder when exists`, async () => { (fse.pathExists as jest.Mock).mockImplementation((filePath) => { - return filePath === 'frameworks/react' || filePath === './src'; + return filePath === 'rendererAssets/react' || filePath === './src'; }); await helpers.copyComponents('react', SupportedLanguage.JAVASCRIPT); expect(fse.copy).toHaveBeenCalledWith(expect.anything(), './src/stories', expect.anything()); @@ -95,17 +95,17 @@ describe('Helpers', () => { it(`should copy to root folder when src doesn't exist`, async () => { (fse.pathExists as jest.Mock).mockImplementation((filePath) => { - return filePath === 'frameworks/react'; + return filePath === 'rendererAssets/react'; }); await helpers.copyComponents('react', SupportedLanguage.JAVASCRIPT); expect(fse.copy).toHaveBeenCalledWith(expect.anything(), './stories', expect.anything()); }); - it(`should throw an error for unsupported framework`, async () => { - const framework = 'unknown framework' as SupportedRenderers; - const expectedMessage = `Unsupported framework: ${framework}`; + it(`should throw an error for unsupported renderer`, async () => { + const renderer = 'unknown renderer' as SupportedRenderers; + const expectedMessage = `Unsupported renderer: ${renderer}`; await expect( - helpers.copyComponents(framework, SupportedLanguage.JAVASCRIPT) + helpers.copyComponents(renderer, SupportedLanguage.JAVASCRIPT) ).rejects.toThrowError(expectedMessage); }); diff --git a/code/lib/cli/src/helpers.ts b/code/lib/cli/src/helpers.ts index 1db460148191..2d1626748b24 100644 --- a/code/lib/cli/src/helpers.ts +++ b/code/lib/cli/src/helpers.ts @@ -181,33 +181,27 @@ export function copyTemplate(templateRoot: string) { fse.copySync(templateDir, '.', { overwrite: true }); } -export async function copyComponents(framework: SupportedRenderers, language: SupportedLanguage) { +export async function copyComponents(renderer: SupportedRenderers, language: SupportedLanguage) { const languageFolderMapping: Record = { javascript: 'js', typescript: 'ts', }; const componentsPath = async () => { const baseDir = getBaseDir(); - const frameworkPath = join(baseDir, 'frameworks', framework); - const languageSpecific = path.resolve( - __dirname, - `${frameworkPath}/${languageFolderMapping[language]}` - ); - if (await fse.pathExists(languageSpecific)) { - return languageSpecific; + const assetsRoot = join(baseDir, 'rendererAssets'); + const assetsRenderer = join(assetsRoot, renderer); + const assetsLanguage = join(assetsRenderer, languageFolderMapping[language]); + if (await fse.pathExists(assetsLanguage)) { + return assetsLanguage; } - const jsFallback = path.resolve( - __dirname, - `${frameworkPath}/${languageFolderMapping.javascript}` - ); - if (await fse.pathExists(jsFallback)) { - return jsFallback; + const assetsJS = join(assetsRenderer, languageFolderMapping.javascript); + if (await fse.pathExists(assetsJS)) { + return assetsJS; } - const frameworkRootPath = path.resolve(__dirname, frameworkPath); - if (await fse.pathExists(frameworkRootPath)) { - return frameworkRootPath; + if (await fse.pathExists(assetsRenderer)) { + return assetsRenderer; } - throw new Error(`Unsupported framework: ${framework}`); + throw new Error(`Unsupported renderer: ${renderer}`); }; const targetPath = async () => { @@ -219,7 +213,7 @@ export async function copyComponents(framework: SupportedRenderers, language: Su const destinationPath = await targetPath(); await fse.copy(await componentsPath(), destinationPath, { overwrite: true }); - await fse.copy(join(getBaseDir(), 'frameworks/common'), destinationPath, { + await fse.copy(join(getBaseDir(), 'rendererAssets/common'), destinationPath, { overwrite: true, }); } diff --git a/code/lib/core-common/src/utils/get-storybook-info.ts b/code/lib/core-common/src/utils/get-storybook-info.ts index c9e8369542bb..ea44ad5760df 100644 --- a/code/lib/core-common/src/utils/get-storybook-info.ts +++ b/code/lib/core-common/src/utils/get-storybook-info.ts @@ -4,16 +4,21 @@ import { getStorybookConfiguration } from './get-storybook-configuration'; import { PackageJson } from '../types'; interface StorybookInfo { - framework: string; version: string; + // FIXME: these are renderers for now, + // need to update with framework OR fix + // the calling code + framework: string; frameworkPackage: string; + renderer: string; + rendererPackage: string; configDir?: string; mainConfig?: string; previewConfig?: string; managerConfig?: string; } -const viewLayers: Record = { +const rendererPackages: Record = { '@storybook/react': 'react', '@storybook/vue': 'vue', '@storybook/vue3': 'vue3', @@ -42,11 +47,11 @@ const findDependency = ( Object.entries(peerDependencies || {}).find(predicate), ]; -const getFrameworkInfo = (packageJson: PackageJson) => { +const getRendererInfo = (packageJson: PackageJson) => { // Pull the viewlayer from dependencies in package.json - const [dep, devDep, peerDep] = findDependency(packageJson, ([key]) => viewLayers[key]); + const [dep, devDep, peerDep] = findDependency(packageJson, ([key]) => rendererPackages[key]); const [pkg, version] = dep || devDep || peerDep || []; - const framework = pkg ? viewLayers[pkg] : undefined; + const renderer = pkg ? rendererPackages[pkg] : undefined; if (dep && devDep && dep[0] === devDep[0]) { logger.warn( @@ -59,7 +64,13 @@ const getFrameworkInfo = (packageJson: PackageJson) => { ); } - return { framework, version, frameworkPackage: pkg }; + return { + version, + framework: renderer, + frameworkPackage: pkg, + renderer, + rendererPackage: pkg, + }; }; const validConfigExtensions = ['ts', 'js', 'tsx', 'jsx', 'mjs', 'cjs']; @@ -89,11 +100,11 @@ const getConfigInfo = (packageJson: PackageJson) => { }; export const getStorybookInfo = (packageJson: PackageJson) => { - const frameworkInfo = getFrameworkInfo(packageJson); + const rendererInfo = getRendererInfo(packageJson); const configInfo = getConfigInfo(packageJson); return { - ...frameworkInfo, + ...rendererInfo, ...configInfo, } as StorybookInfo; }; diff --git a/code/lib/telemetry/src/storybook-metadata.ts b/code/lib/telemetry/src/storybook-metadata.ts index a9449de8637c..da3727d261f3 100644 --- a/code/lib/telemetry/src/storybook-metadata.ts +++ b/code/lib/telemetry/src/storybook-metadata.ts @@ -181,6 +181,8 @@ export const computeStorybookMetadata = async ({ const hasStorybookEslint = !!allDependencies['eslint-plugin-storybook']; + // FIXME: resolve framework/renderer split in 7.0 + // OR should be getting this from mainConfig instead? const storybookInfo = getStorybookInfo(packageJson); const storybookVersion =