From d2376bfb7cf77e9bd83b3b4caf77b9095b4d5069 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Sat, 12 Oct 2019 09:25:24 +0800 Subject: [PATCH] CLI: Marko template CSF refactor --- lib/cli/generators/MARKO/index.js | 7 +++---- .../MARKO/{template => template-csf}/.storybook/addons.js | 0 .../MARKO/{template => template-csf}/.storybook/config.js | 0 .../stories/components/welcome/index.marko | 0 .../{template => template-csf}/stories/index.stories.js | 0 lib/cli/lib/initiate.js | 4 ++-- 6 files changed, 5 insertions(+), 6 deletions(-) rename lib/cli/generators/MARKO/{template => template-csf}/.storybook/addons.js (100%) rename lib/cli/generators/MARKO/{template => template-csf}/.storybook/config.js (100%) rename lib/cli/generators/MARKO/{template => template-csf}/stories/components/welcome/index.marko (100%) rename lib/cli/generators/MARKO/{template => template-csf}/stories/index.stories.js (100%) diff --git a/lib/cli/generators/MARKO/index.js b/lib/cli/generators/MARKO/index.js index 08ec019d813..448d24d76c4 100644 --- a/lib/cli/generators/MARKO/index.js +++ b/lib/cli/generators/MARKO/index.js @@ -1,14 +1,13 @@ -import path from 'path'; -import fse from 'fs-extra'; import { getVersions, getPackageJson, writePackageJson, getBabelDependencies, installDependencies, + copyTemplate, } from '../../lib/helpers'; -export default async npmOptions => { +export default async (npmOptions, { storyFormat = 'csf' }) => { const [storybookVersion, addonActionVersion, addonKnobsVersion] = await getVersions( npmOptions, '@storybook/marko', @@ -16,7 +15,7 @@ export default async npmOptions => { '@storybook/addon-knobs' ); - fse.copySync(path.resolve(__dirname, 'template/'), '.', { overwrite: true }); + copyTemplate(__dirname, storyFormat); const packageJson = getPackageJson(); diff --git a/lib/cli/generators/MARKO/template/.storybook/addons.js b/lib/cli/generators/MARKO/template-csf/.storybook/addons.js similarity index 100% rename from lib/cli/generators/MARKO/template/.storybook/addons.js rename to lib/cli/generators/MARKO/template-csf/.storybook/addons.js diff --git a/lib/cli/generators/MARKO/template/.storybook/config.js b/lib/cli/generators/MARKO/template-csf/.storybook/config.js similarity index 100% rename from lib/cli/generators/MARKO/template/.storybook/config.js rename to lib/cli/generators/MARKO/template-csf/.storybook/config.js diff --git a/lib/cli/generators/MARKO/template/stories/components/welcome/index.marko b/lib/cli/generators/MARKO/template-csf/stories/components/welcome/index.marko similarity index 100% rename from lib/cli/generators/MARKO/template/stories/components/welcome/index.marko rename to lib/cli/generators/MARKO/template-csf/stories/components/welcome/index.marko diff --git a/lib/cli/generators/MARKO/template/stories/index.stories.js b/lib/cli/generators/MARKO/template-csf/stories/index.stories.js similarity index 100% rename from lib/cli/generators/MARKO/template/stories/index.stories.js rename to lib/cli/generators/MARKO/template-csf/stories/index.stories.js diff --git a/lib/cli/lib/initiate.js b/lib/cli/lib/initiate.js index a5fea1ad9ed..d4f73448936 100644 --- a/lib/cli/lib/initiate.js +++ b/lib/cli/lib/initiate.js @@ -163,12 +163,12 @@ const installStorybook = (projectType, options) => { .then(end); case types.MARKO: - return markoGenerator(npmOptions) + return markoGenerator(npmOptions, generatorOptions) .then(commandLog('Adding storybook support to your "Marko" app')) .then(end); case types.HTML: - return htmlGenerator(npmOptions) + return htmlGenerator(npmOptions, generatorOptions) .then(commandLog('Adding storybook support to your "HTML" app')) .then(end);