From 898d9250cef90dbfca9a81a523459c1b28f26f2e Mon Sep 17 00:00:00 2001 From: tooppaaa Date: Thu, 11 Jun 2020 23:32:19 +0200 Subject: [PATCH] CLI: riot --- .../riot}/0-Welcome.stories.js | 0 .../riot}/1-Button.stories.js | 0 .../stories => frameworks/riot}/MyButton.tag | 0 .../stories => frameworks/riot}/Welcome.tag | 0 lib/cli/src/generators/RIOT/index.ts | 53 ++----------------- .../RIOT/template-csf/.storybook/main.js | 4 -- 6 files changed, 5 insertions(+), 52 deletions(-) rename lib/cli/src/{generators/RIOT/template-csf/stories => frameworks/riot}/0-Welcome.stories.js (100%) rename lib/cli/src/{generators/RIOT/template-csf/stories => frameworks/riot}/1-Button.stories.js (100%) rename lib/cli/src/{generators/RIOT/template-csf/stories => frameworks/riot}/MyButton.tag (100%) rename lib/cli/src/{generators/RIOT/template-csf/stories => frameworks/riot}/Welcome.tag (100%) delete mode 100644 lib/cli/src/generators/RIOT/template-csf/.storybook/main.js diff --git a/lib/cli/src/generators/RIOT/template-csf/stories/0-Welcome.stories.js b/lib/cli/src/frameworks/riot/0-Welcome.stories.js similarity index 100% rename from lib/cli/src/generators/RIOT/template-csf/stories/0-Welcome.stories.js rename to lib/cli/src/frameworks/riot/0-Welcome.stories.js diff --git a/lib/cli/src/generators/RIOT/template-csf/stories/1-Button.stories.js b/lib/cli/src/frameworks/riot/1-Button.stories.js similarity index 100% rename from lib/cli/src/generators/RIOT/template-csf/stories/1-Button.stories.js rename to lib/cli/src/frameworks/riot/1-Button.stories.js diff --git a/lib/cli/src/generators/RIOT/template-csf/stories/MyButton.tag b/lib/cli/src/frameworks/riot/MyButton.tag similarity index 100% rename from lib/cli/src/generators/RIOT/template-csf/stories/MyButton.tag rename to lib/cli/src/frameworks/riot/MyButton.tag diff --git a/lib/cli/src/generators/RIOT/template-csf/stories/Welcome.tag b/lib/cli/src/frameworks/riot/Welcome.tag similarity index 100% rename from lib/cli/src/generators/RIOT/template-csf/stories/Welcome.tag rename to lib/cli/src/frameworks/riot/Welcome.tag diff --git a/lib/cli/src/generators/RIOT/index.ts b/lib/cli/src/generators/RIOT/index.ts index 404eb4aeacf..21601dfe3b3 100644 --- a/lib/cli/src/generators/RIOT/index.ts +++ b/lib/cli/src/generators/RIOT/index.ts @@ -1,52 +1,9 @@ -import { getBabelDependencies, copyTemplate } from '../../helpers'; -import { Generator } from '../Generator'; -import { writePackageJson } from '../../js-package-manager'; +import { baseGenerator, Generator } from '../generator'; -const generator: Generator = async (packageManager, npmOptions, { storyFormat }) => { - const [ - storybookVersion, - actionsVersion, - linksVersion, - addonsVersion, - tagLoaderVersion, - ] = await packageManager.getVersions( - '@storybook/riot', - '@storybook/addon-actions', - '@storybook/addon-links', - '@storybook/addons', - 'riot-tag-loader' - ); - - copyTemplate(__dirname, storyFormat); - - const packageJson = packageManager.retrievePackageJson(); - - packageJson.dependencies = packageJson.dependencies || {}; - packageJson.devDependencies = packageJson.devDependencies || {}; - - const dependencies = [ - `@storybook/riot@${storybookVersion}`, - `@storybook/addon-actions@${actionsVersion}`, - `@storybook/addon-links@${linksVersion}`, - `@storybook/addons@${addonsVersion}`, - ]; - if ( - !packageJson.devDependencies['riot-tag-loader'] && - !packageJson.dependencies['riot-tag-loader'] - ) { - dependencies.push(`riot-tag-loader@${tagLoaderVersion}`); - } - - writePackageJson(packageJson); - - const babelDependencies = await getBabelDependencies(packageManager, packageJson); - - packageManager.addDependencies({ ...npmOptions, packageJson }, [ - ...dependencies, - ...babelDependencies, - ]); - - packageManager.addStorybookCommandInScripts(); +const generator: Generator = async (packageManager, npmOptions, options) => { + baseGenerator(packageManager, npmOptions, options, 'riot', { + extraPackages: ['riot-tag-loader'], + }); }; export default generator; diff --git a/lib/cli/src/generators/RIOT/template-csf/.storybook/main.js b/lib/cli/src/generators/RIOT/template-csf/.storybook/main.js deleted file mode 100644 index 3036098563c..00000000000 --- a/lib/cli/src/generators/RIOT/template-csf/.storybook/main.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - stories: ['../stories/**/*.stories.js'], - addons: ['@storybook/addon-actions', '@storybook/addon-links'], -};