diff --git a/lib/cli/src/GeneratorOptions.ts b/lib/cli/src/GeneratorOptions.ts deleted file mode 100644 index d9f2b3e01ec6..000000000000 --- a/lib/cli/src/GeneratorOptions.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { StoryFormat } from './project_types'; - -export type GeneratorOptions = { - storyFormat: StoryFormat; -}; diff --git a/lib/cli/src/generators/ANGULAR/index.ts b/lib/cli/src/generators/ANGULAR/index.ts index 22de407c3c99..cc9d5921366f 100644 --- a/lib/cli/src/generators/ANGULAR/index.ts +++ b/lib/cli/src/generators/ANGULAR/index.ts @@ -16,7 +16,7 @@ import { } from '../../helpers'; import { StoryFormat } from '../../project_types'; import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator, GeneratorOptions } from '../Generator'; async function addDependencies(npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) { const packages = [ @@ -64,7 +64,7 @@ function editAngularAppTsConfig() { writeFileAsJson(getAngularAppTsConfigPath(), tsConfigJson); } -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { if (!isDefaultProjectSet()) { throw new Error( 'Could not find a default project in your Angular workspace.\nSet a defaultProject in your angular.json and re-run the installation.' @@ -77,3 +77,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) editAngularAppTsConfig(); editStorybookTsConfig(path.resolve('./.storybook/tsconfig.json')); }; + +export default generator; diff --git a/lib/cli/src/generators/AURELIA/index.ts b/lib/cli/src/generators/AURELIA/index.ts index 282232a7dd8b..3f7362f13759 100644 --- a/lib/cli/src/generators/AURELIA/index.ts +++ b/lib/cli/src/generators/AURELIA/index.ts @@ -8,8 +8,7 @@ import { copyTemplate, readFileAsJson, } from '../../helpers'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; import { StoryFormat } from '../../project_types'; function addStorybookExcludeGlobToTsConfig() { @@ -27,11 +26,7 @@ function addStorybookExcludeGlobToTsConfig() { tsConfigJson.exclude = [...exclude, glob]; writeFileAsJson('tsconfig.json', tsConfigJson); } - -export default async ( - npmOptions: NpmOptions, - { storyFormat = StoryFormat.CSF }: GeneratorOptions -) => { +const generator: Generator = async (npmOptions, { storyFormat = StoryFormat.CSF }) => { copyTemplate(__dirname, storyFormat); const packages = [ '@storybook/aurelia', @@ -62,3 +57,5 @@ export default async ( const babelDependencies = await getBabelDependencies(npmOptions, packageJson); installDependencies({ ...npmOptions, packageJson }, [...versionedPackages, ...babelDependencies]); }; + +export default generator; diff --git a/lib/cli/src/generators/EMBER/index.ts b/lib/cli/src/generators/EMBER/index.ts index 79e151ada78a..874e81e6e2e7 100644 --- a/lib/cli/src/generators/EMBER/index.ts +++ b/lib/cli/src/generators/EMBER/index.ts @@ -6,10 +6,9 @@ import { installDependencies, copyTemplate, } from '../../helpers'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const [ storybookVersion, babelPluginEmberModulePolyfillVersion, @@ -58,3 +57,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) ...babelDependencies, ]); }; + +export default generator; diff --git a/lib/cli/src/generators/Generator.ts b/lib/cli/src/generators/Generator.ts new file mode 100644 index 000000000000..b6143c0c92dc --- /dev/null +++ b/lib/cli/src/generators/Generator.ts @@ -0,0 +1,8 @@ +import { NpmOptions } from '../NpmOptions'; +import { StoryFormat } from '../project_types'; + +export type GeneratorOptions = { + storyFormat: StoryFormat; +}; + +export type Generator = (npmOptions: NpmOptions, options: GeneratorOptions) => Promise; diff --git a/lib/cli/src/generators/HTML/index.ts b/lib/cli/src/generators/HTML/index.ts index 4932497a1062..25d850192b6c 100755 --- a/lib/cli/src/generators/HTML/index.ts +++ b/lib/cli/src/generators/HTML/index.ts @@ -7,10 +7,9 @@ import { copyTemplate, } from '../../helpers'; import { StoryFormat } from '../../project_types'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const packages = ['@storybook/html', '@storybook/addon-actions', '@storybook/addon-links']; const versionedPackages = await getVersionedPackages(npmOptions, ...packages); @@ -35,3 +34,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) installDependencies({ ...npmOptions, packageJson }, [...versionedPackages, ...babelDependencies]); }; + +export default generator; diff --git a/lib/cli/src/generators/MARIONETTE/index.ts b/lib/cli/src/generators/MARIONETTE/index.ts index 88dd0e5c8218..e3ce805931a8 100644 --- a/lib/cli/src/generators/MARIONETTE/index.ts +++ b/lib/cli/src/generators/MARIONETTE/index.ts @@ -7,9 +7,9 @@ import { installDependencies, retrievePackageJson, } from '../../helpers'; -import { NpmOptions } from '../../NpmOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions) => { +const generator: Generator = async (npmOptions) => { const storybookVersion = await getVersion(npmOptions, '@storybook/marionette'); fse.copySync(path.resolve(__dirname, 'template/'), '.', { overwrite: true }); @@ -31,3 +31,5 @@ export default async (npmOptions: NpmOptions) => { ...babelDependencies, ]); }; + +export default generator; diff --git a/lib/cli/src/generators/MARKO/index.ts b/lib/cli/src/generators/MARKO/index.ts index 43a8b6a285e4..b8a3bc0e40e1 100644 --- a/lib/cli/src/generators/MARKO/index.ts +++ b/lib/cli/src/generators/MARKO/index.ts @@ -6,10 +6,9 @@ import { installDependencies, copyTemplate, } from '../../helpers'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const [storybookVersion, addonActionVersion, addonKnobsVersion] = await getVersions( npmOptions, '@storybook/marko', @@ -39,3 +38,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) ...babelDependencies, ]); }; + +export default generator; diff --git a/lib/cli/src/generators/METEOR/index.ts b/lib/cli/src/generators/METEOR/index.ts index d9decd69e534..6420a01f0b03 100644 --- a/lib/cli/src/generators/METEOR/index.ts +++ b/lib/cli/src/generators/METEOR/index.ts @@ -8,10 +8,9 @@ import { installDependencies, copyTemplate, } from '../../helpers'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const [ storybookVersion, actionsVersion, @@ -96,3 +95,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) installDependencies({ ...npmOptions, packageJson }, [...devDependencies, ...babelDependencies]); }; + +export default generator; diff --git a/lib/cli/src/generators/MITHRIL/index.ts b/lib/cli/src/generators/MITHRIL/index.ts index aaca46d1c7b7..d6bff9454643 100644 --- a/lib/cli/src/generators/MITHRIL/index.ts +++ b/lib/cli/src/generators/MITHRIL/index.ts @@ -6,10 +6,9 @@ import { installDependencies, copyTemplate, } from '../../helpers'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const [ storybookVersion, actionsVersion, @@ -49,3 +48,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) ...babelDependencies, ]); }; + +export default generator; diff --git a/lib/cli/src/generators/PREACT/index.ts b/lib/cli/src/generators/PREACT/index.ts index 7d732258998a..42c9eb416c9d 100644 --- a/lib/cli/src/generators/PREACT/index.ts +++ b/lib/cli/src/generators/PREACT/index.ts @@ -6,10 +6,9 @@ import { installDependencies, copyTemplate, } from '../../helpers'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions( npmOptions, '@storybook/preact', @@ -41,3 +40,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) ...babelDependencies, ]); }; + +export default generator; diff --git a/lib/cli/src/generators/RAX/index.ts b/lib/cli/src/generators/RAX/index.ts index a7ef43519a4f..4ac18e259ab9 100644 --- a/lib/cli/src/generators/RAX/index.ts +++ b/lib/cli/src/generators/RAX/index.ts @@ -6,10 +6,9 @@ import { installDependencies, copyTemplate, } from '../../helpers'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const [ storybookVersion, actionsVersion, @@ -59,3 +58,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) ...babelDependencies, ]); }; + +export default generator; diff --git a/lib/cli/src/generators/REACT/index.ts b/lib/cli/src/generators/REACT/index.ts index 01e192db510a..586dac39814b 100644 --- a/lib/cli/src/generators/REACT/index.ts +++ b/lib/cli/src/generators/REACT/index.ts @@ -7,10 +7,9 @@ import { copyTemplate, } from '../../helpers'; import { StoryFormat } from '../../project_types'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const packages = [ '@storybook/react', '@storybook/addon-actions', @@ -40,3 +39,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) installDependencies({ ...npmOptions, packageJson }, [...versionedPackages, ...babelDependencies]); }; + +export default generator; diff --git a/lib/cli/src/generators/REACT_NATIVE/index.ts b/lib/cli/src/generators/REACT_NATIVE/index.ts index 8ce6b66124bf..aad02bcb16c6 100644 --- a/lib/cli/src/generators/REACT_NATIVE/index.ts +++ b/lib/cli/src/generators/REACT_NATIVE/index.ts @@ -10,7 +10,7 @@ import { copyTemplate, } from '../../helpers'; import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { GeneratorOptions } from '../Generator'; export default async ( npmOptions: NpmOptions, diff --git a/lib/cli/src/generators/REACT_SCRIPTS/index.ts b/lib/cli/src/generators/REACT_SCRIPTS/index.ts index efebc3350fe3..cc43eafdb98e 100644 --- a/lib/cli/src/generators/REACT_SCRIPTS/index.ts +++ b/lib/cli/src/generators/REACT_SCRIPTS/index.ts @@ -9,10 +9,9 @@ import { copyTemplate, } from '../../helpers'; import { StoryFormat } from '../../project_types'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const packages = [ '@storybook/react', '@storybook/preset-create-react-app', @@ -50,3 +49,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) installDependencies({ ...npmOptions, packageJson }, [...versionedPackages, ...babelDependencies]); }; + +export default generator; diff --git a/lib/cli/src/generators/RIOT/index.ts b/lib/cli/src/generators/RIOT/index.ts index 3bfc24ef2eae..2c624431018a 100644 --- a/lib/cli/src/generators/RIOT/index.ts +++ b/lib/cli/src/generators/RIOT/index.ts @@ -6,10 +6,9 @@ import { installDependencies, copyTemplate, } from '../../helpers'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const [ storybookVersion, actionsVersion, @@ -54,3 +53,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) installDependencies({ ...npmOptions, packageJson }, [...dependencies, ...babelDependencies]); }; + +export default generator; diff --git a/lib/cli/src/generators/SFC_VUE/index.ts b/lib/cli/src/generators/SFC_VUE/index.ts index 6f6ec71e5573..0f85dbce6b12 100644 --- a/lib/cli/src/generators/SFC_VUE/index.ts +++ b/lib/cli/src/generators/SFC_VUE/index.ts @@ -7,10 +7,9 @@ import { copyTemplate, } from '../../helpers'; import { StoryFormat } from '../../project_types'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const packages = [ '@storybook/vue', '@storybook/addon-actions', @@ -39,3 +38,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) installDependencies({ ...npmOptions, packageJson }, [...versionedPackages, ...babelDependencies]); }; + +export default generator; diff --git a/lib/cli/src/generators/SVELTE/index.ts b/lib/cli/src/generators/SVELTE/index.ts index 1ba6778fe3b3..9da7bfa15463 100644 --- a/lib/cli/src/generators/SVELTE/index.ts +++ b/lib/cli/src/generators/SVELTE/index.ts @@ -6,10 +6,9 @@ import { installDependencies, copyTemplate, } from '../../helpers'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const [ storybookVersion, actionsVersion, @@ -52,3 +51,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) ...babelDependencies, ]); }; + +export default generator; diff --git a/lib/cli/src/generators/VUE/index.ts b/lib/cli/src/generators/VUE/index.ts index 6254b35f923b..01e33e1978cb 100644 --- a/lib/cli/src/generators/VUE/index.ts +++ b/lib/cli/src/generators/VUE/index.ts @@ -9,10 +9,9 @@ import { copyTemplate, } from '../../helpers'; import { StoryFormat } from '../../project_types'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const packages = [ '@storybook/vue', '@storybook/addon-actions', @@ -59,3 +58,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) // see: https://github.com/storybookjs/storybook/issues/4475#issuecomment-432141296 installDependencies({ ...npmOptions, packageJson }, [...versionedPackages, ...babelDependencies]); }; + +export default generator; diff --git a/lib/cli/src/generators/WEB-COMPONENTS/index.ts b/lib/cli/src/generators/WEB-COMPONENTS/index.ts index defc5a13d987..373eac327a67 100755 --- a/lib/cli/src/generators/WEB-COMPONENTS/index.ts +++ b/lib/cli/src/generators/WEB-COMPONENTS/index.ts @@ -8,10 +8,9 @@ import { installDependencies, } from '../../helpers'; import { StoryFormat } from '../../project_types'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const packages = [ '@storybook/web-components', '@storybook/addon-actions', @@ -42,3 +41,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) installDependencies({ ...npmOptions, packageJson }, [...versionedPackages, ...babelDependencies]); }; + +export default generator; diff --git a/lib/cli/src/generators/WEBPACK_REACT/index.ts b/lib/cli/src/generators/WEBPACK_REACT/index.ts index 2a4eec9a6390..75bec7324ed2 100644 --- a/lib/cli/src/generators/WEBPACK_REACT/index.ts +++ b/lib/cli/src/generators/WEBPACK_REACT/index.ts @@ -7,10 +7,9 @@ import { copyTemplate, } from '../../helpers'; import { StoryFormat } from '../../project_types'; -import { NpmOptions } from '../../NpmOptions'; -import { GeneratorOptions } from '../../GeneratorOptions'; +import { Generator } from '../Generator'; -export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) => { +const generator: Generator = async (npmOptions, { storyFormat }) => { const packages = [ '@storybook/react', '@storybook/addon-actions', @@ -39,3 +38,5 @@ export default async (npmOptions: NpmOptions, { storyFormat }: GeneratorOptions) installDependencies({ ...npmOptions, packageJson }, [...versionedPackages, ...babelDependencies]); }; + +export default generator; diff --git a/lib/cli/src/initiate.ts b/lib/cli/src/initiate.ts index ee63341f287f..1c080c029a09 100644 --- a/lib/cli/src/initiate.ts +++ b/lib/cli/src/initiate.ts @@ -180,7 +180,7 @@ const installStorybook = (projectType: ProjectType, options: CommandOptions): Pr .then(end); case ProjectType.MARIONETTE: - return marionetteGenerator(npmOptions) + return marionetteGenerator(npmOptions, generatorOptions) .then(commandLog('Adding storybook support to your "Marionette.js" app')) .then(end);