diff --git a/lib/cli/src/generators/SERVER/index.ts b/lib/cli/src/generators/SERVER/index.ts new file mode 100755 index 000000000000..493864afd7d8 --- /dev/null +++ b/lib/cli/src/generators/SERVER/index.ts @@ -0,0 +1,14 @@ +import fse from 'fs-extra'; +import { baseGenerator, Generator } from '../baseGenerator'; + +const generator: Generator = async (packageManager, npmOptions, options) => { + const prefix = fse.existsSync('./src') ? '../src' : '../stories'; + const stories = [`${prefix}/**/*.stories.json`]; + + baseGenerator(packageManager, npmOptions, options, 'server', { + addComponents: false, + configureOptions: { stories }, + }); +}; + +export default generator; diff --git a/lib/cli/src/generators/baseGenerator.ts b/lib/cli/src/generators/baseGenerator.ts index afd6283ca3e7..3355bcf15a6b 100644 --- a/lib/cli/src/generators/baseGenerator.ts +++ b/lib/cli/src/generators/baseGenerator.ts @@ -17,6 +17,7 @@ export interface FrameworkOptions { addComponents?: boolean; addBabel?: boolean; addESLint?: boolean; + configureOptions?: any; } export type Generator = ( @@ -33,6 +34,7 @@ const defaultOptions: FrameworkOptions = { addComponents: true, addBabel: true, addESLint: false, + configureOptions: {}, }; export async function baseGenerator( @@ -50,6 +52,7 @@ export async function baseGenerator( addComponents, addBabel, addESLint, + configureOptions, } = { ...defaultOptions, ...options, @@ -81,7 +84,7 @@ export async function baseGenerator( const versionedPackages = await packageManager.getVersionedPackages(...packages); - configure(framework, [...addons, ...extraAddons]); + configure(framework, [...addons, ...extraAddons], configureOptions); if (addComponents) { copyComponents(framework, language); } diff --git a/lib/cli/src/initiate.ts b/lib/cli/src/initiate.ts index d54da71c35ee..8c10fa6900b4 100644 --- a/lib/cli/src/initiate.ts +++ b/lib/cli/src/initiate.ts @@ -30,6 +30,7 @@ import riotGenerator from './generators/RIOT'; import preactGenerator from './generators/PREACT'; import svelteGenerator from './generators/SVELTE'; import raxGenerator from './generators/RAX'; +import serverGenerator from './generators/SERVER'; import { warn } from './warn'; import { JsPackageManagerFactory, readPackageJson } from './js-package-manager'; import { NpmOptions } from './NpmOptions'; @@ -228,6 +229,11 @@ const installStorybook = (projectType: ProjectType, options: CommandOptions): Pr .then(commandLog('Adding Storybook support to your "Aurelia" app')) .then(end); + case ProjectType.SERVER: + return serverGenerator(packageManager, npmOptions, generatorOptions) + .then(commandLog('Adding Storybook support to your "Server" app')) + .then(end); + case ProjectType.UNSUPPORTED: paddedLog(`We detected a project type that we don't support yet.`); paddedLog( diff --git a/lib/cli/src/project_types.ts b/lib/cli/src/project_types.ts index 1ec761a9c315..cb575f9b851d 100644 --- a/lib/cli/src/project_types.ts +++ b/lib/cli/src/project_types.ts @@ -28,7 +28,8 @@ export type SupportedFrameworks = | 'rax' | 'aurelia' | 'html' - | 'web-components'; + | 'web-components' + | 'server'; export enum ProjectType { UNDETECTED = 'UNDETECTED', @@ -56,6 +57,7 @@ export enum ProjectType { SVELTE = 'SVELTE', RAX = 'RAX', AURELIA = 'AURELIA', + SERVER = 'SERVER', } export const SUPPORTED_FRAMEWORKS: SupportedFrameworks[] = [