Add CLI template

This commit is contained in:
Hypnosphi 2018-05-05 22:55:31 +03:00
parent 067caf8498
commit f00a369d9e
17 changed files with 204 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import vueGenerator from '../generators/VUE';
import polymerGenerator from '../generators/POLYMER';
import webpackReactGenerator from '../generators/WEBPACK_REACT';
import mithrilGenerator from '../generators/MITHRIL';
import markoGenerator from '../generators/MARKO';
const logger = console;
@ -163,6 +164,11 @@ const runGenerator = () => {
.then(commandLog('Adding storybook support to your "Mithril" app'))
.then(end);
case types.MARKO:
return markoGenerator()
.then(commandLog('Adding storybook support to your "Marko" app'))
.then(end);
default:
paddedLog(`We couldn't detect your project type. (code: ${projectType})`);
paddedLog(

View File

@ -0,0 +1,45 @@
import path from 'path';
import mergeDirs from 'merge-dirs';
import { getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
export default async () => {
const [
storybookVersion,
actionsVersion,
linksVersion,
addonsVersion,
babelCoreVersion,
babelRuntimeVersion,
] = await getVersions(
'@storybook/marko',
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addons',
'babel-core',
'babel-runtime'
);
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
const packageJson = getPackageJson();
packageJson.dependencies = packageJson.dependencies || {};
packageJson.devDependencies = packageJson.devDependencies || {};
packageJson.devDependencies['@storybook/addon-actions'] = actionsVersion;
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
packageJson.devDependencies['@storybook/marko'] = storybookVersion;
if (!packageJson.dependencies['babel-core'] && !packageJson.devDependencies['babel-core']) {
packageJson.devDependencies['babel-core'] = babelCoreVersion;
}
if (!packageJson.dependencies['babel-runtime'] && !packageJson.devDependencies['babel-runtime']) {
packageJson.devDependencies['babel-runtime'] = babelRuntimeVersion;
}
packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';
packageJson.scripts['build-storybook'] = 'build-storybook';
writePackageJson(packageJson);
};

View File

@ -0,0 +1,2 @@
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';

View File

@ -0,0 +1,9 @@
import { configure } from '@storybook/mithril';
// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /.stories.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}
configure(loadStories, module);

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -0,0 +1,5 @@
import { storiesOf } from '@storybook/marko';
import Welcome from '../components/welcome/index.marko';
storiesOf('Welcome', module).add('welcome', () => Welcome.renderSync({}));

View File

@ -84,6 +84,13 @@ function detectFramework(dependencies) {
return types.MITHRIL;
}
if (
(dependencies.dependencies && dependencies.dependencies.marko) ||
(dependencies.devDependencies && dependencies.devDependencies.marko)
) {
return types.MARKO;
}
return false;
}

View File

@ -14,4 +14,5 @@ export default {
UPDATE_PACKAGE_ORGANIZATIONS: 'UPDATE_PACKAGE_ORGANIZATIONS',
POLYMER: 'POLYMER',
MITHRIL: 'MITHRIL',
MARKO: 'MARKO',
};

View File

@ -56,6 +56,7 @@
"@storybook/channel-postmessage": "4.0.0-alpha.4",
"@storybook/channel-websocket": "4.0.0-alpha.4",
"@storybook/channels": "4.0.0-alpha.4",
"@storybook/marko": "4.0.0-alpha.4",
"@storybook/mithril": "4.0.0-alpha.4",
"@storybook/polymer": "4.0.0-alpha.4",
"@storybook/react": "4.0.0-alpha.4",

View File

@ -0,0 +1,9 @@
{
"name": "marko-fixture",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"marko": "^4.9.7"
}
}

View File

@ -0,0 +1,2 @@
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';

View File

@ -0,0 +1,9 @@
import { configure } from '@storybook/mithril';
// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /.stories.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}
configure(loadStories, module);

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -0,0 +1,21 @@
{
"name": "marko-fixture",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"marko": "^4.9.7"
},
"devDependencies": {
"@storybook/addon-actions": "^4.0.0-alpha.4",
"@storybook/addon-links": "^4.0.0-alpha.4",
"@storybook/addons": "^4.0.0-alpha.4",
"@storybook/marko": "4.0.0-alpha.4",
"babel-core": "^6.26.3",
"babel-runtime": "^6.26.0"
},
"scripts": {
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
}
}

View File

@ -0,0 +1,5 @@
import { storiesOf } from '@storybook/marko';
import Welcome from '../components/welcome/index.marko';
storiesOf('Welcome', module).add('welcome', () => Welcome.renderSync({}));