Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Add explicit dependencies on used plugins #1652

Merged
merged 5 commits into from
Aug 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/cli/generators/METEOR/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const latestVersion = require('latest-version');

module.exports = Promise.all([
latestVersion('@storybook/react'),
latestVersion('@storybook/addon-actions'),
latestVersion('@storybook/addon-links'),
latestVersion('react'),
latestVersion('react-dom'),
latestVersion('babel-preset-env'),
Expand All @@ -17,6 +19,8 @@ module.exports = Promise.all([
(
[
storybookVersion,
actionsVersion,
linksVersion,
reactVersion,
reactDomVersion,
presetEnvVersion,
Expand Down Expand Up @@ -59,6 +63,8 @@ module.exports = Promise.all([

// write the new package.json.
packageJson.devDependencies['@storybook/react'] = `^${storybookVersion}`;
packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;
packageJson.scripts.storybook = 'start-storybook -p 6006';
packageJson.scripts['build-storybook'] = 'build-storybook';

Expand Down
2 changes: 1 addition & 1 deletion lib/cli/generators/METEOR/template/.stories/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import React from 'react';

Expand Down
2 changes: 1 addition & 1 deletion lib/cli/generators/METEOR/template/.storybook/addons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
2 changes: 1 addition & 1 deletion lib/cli/generators/METEOR/template/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import { configure } from '@storybook/react';

Expand Down
10 changes: 8 additions & 2 deletions lib/cli/generators/REACT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ const helpers = require('../../lib/helpers');
const path = require('path');
const latestVersion = require('latest-version');

module.exports = latestVersion('@storybook/react').then(version => {
module.exports = Promise.all([
latestVersion('@storybook/react'),
latestVersion('@storybook/addon-actions'),
latestVersion('@storybook/addon-links'),
]).then(([storybookVersion, actionsVersion, linksVersion]) => {
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');

const packageJson = helpers.getPackageJson();

packageJson.devDependencies = packageJson.devDependencies || {};
packageJson.devDependencies['@storybook/react'] = `^${version}`;
packageJson.devDependencies['@storybook/react'] = `^${storybookVersion}`;
packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;

packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/generators/REACT/template/.storybook/addons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
2 changes: 1 addition & 1 deletion lib/cli/generators/REACT/template/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import { configure } from '@storybook/react';

Expand Down
10 changes: 8 additions & 2 deletions lib/cli/generators/REACT_NATIVE/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ const latestVersion = require('latest-version');
const chalk = require('chalk');
const helpers = require('../../lib/helpers');

module.exports = latestVersion('@storybook/react-native').then(version => {
module.exports = Promise.all([
latestVersion('@storybook/react'),
latestVersion('@storybook/addon-actions'),
latestVersion('@storybook/addon-links'),
]).then(([storybookVersion, actionsVersion, linksVersion]) => {
// copy all files from the template directory to project directory
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');

Expand All @@ -28,7 +32,9 @@ module.exports = latestVersion('@storybook/react-native').then(version => {
packageJson.dependencies = packageJson.dependencies || {};
packageJson.devDependencies = packageJson.devDependencies || {};

packageJson.devDependencies['@storybook/react-native'] = `^${version}`;
packageJson.devDependencies['@storybook/react'] = `^${storybookVersion}`;
packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;

if (!packageJson.dependencies['react-dom'] && !packageJson.devDependencies['react-dom']) {
const reactVersion = packageJson.dependencies.react;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import React, { PropTypes } from 'react';
import { TouchableNativeFeedback } from 'react-native';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import React, { PropTypes } from 'react';
import { TouchableHighlight } from 'react-native';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import React, { PropTypes } from 'react';
import { View } from 'react-native';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import React, { PropTypes } from 'react';
import { View, Text } from 'react-native';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import React from 'react';
import { Text } from 'react-native';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions, global-require */
/* eslint-disable import/extensions, global-require */

import { AppRegistry } from 'react-native';
import { getStorybookUI, configure } from '@storybook/react-native';
Expand Down
10 changes: 8 additions & 2 deletions lib/cli/generators/REACT_NATIVE_SCRIPTS/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ const helpers = require('../../lib/helpers');
const path = require('path');
const latestVersion = require('latest-version');

module.exports = latestVersion('@storybook/react-native').then(version => {
module.exports = Promise.all([
latestVersion('@storybook/react'),
latestVersion('@storybook/addon-actions'),
latestVersion('@storybook/addon-links'),
]).then(([storybookVersion, actionsVersion, linksVersion]) => {
// copy all files from the template directory to project directory
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');

Expand All @@ -12,7 +16,9 @@ module.exports = latestVersion('@storybook/react-native').then(version => {
packageJson.dependencies = packageJson.dependencies || {};
packageJson.devDependencies = packageJson.devDependencies || {};

packageJson.devDependencies['@storybook/react-native'] = `^${version}`;
packageJson.devDependencies['@storybook/react'] = `^${storybookVersion}`;
packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;

if (!packageJson.dependencies['react-dom'] && !packageJson.devDependencies['react-dom']) {
const reactVersion = packageJson.dependencies.react;
Expand Down
10 changes: 8 additions & 2 deletions lib/cli/generators/REACT_SCRIPTS/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ const path = require('path');
const fs = require('fs');
const latestVersion = require('latest-version');

module.exports = latestVersion('@storybook/react').then(version => {
module.exports = Promise.all([
latestVersion('@storybook/react'),
latestVersion('@storybook/addon-actions'),
latestVersion('@storybook/addon-links'),
]).then(([storybookVersion, actionsVersion, linksVersion]) => {
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');

const packageJson = helpers.getPackageJson();

packageJson.devDependencies['@storybook/react'] = `^${version}`;
packageJson.devDependencies['@storybook/react'] = `^${storybookVersion}`;
packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;
packageJson.scripts.storybook = 'start-storybook -p 9009';
packageJson.scripts['build-storybook'] = 'build-storybook';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import { configure } from '@storybook/react';

Expand Down
10 changes: 8 additions & 2 deletions lib/cli/generators/SFC_VUE/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ const helpers = require('../../lib/helpers');
const path = require('path');
const latestVersion = require('latest-version');

module.exports = latestVersion('@storybook/vue').then(version => {
module.exports = Promise.all([
latestVersion('@storybook/vue'),
latestVersion('@storybook/addon-actions'),
latestVersion('@storybook/addon-links'),
]).then(([storybookVersion, actionsVersion, linksVersion]) => {
mergeDirs(path.resolve(__dirname, 'template'), '.', 'overwrite');

const packageJson = helpers.getPackageJson();

packageJson.devDependencies = packageJson.devDependencies || {};
packageJson.devDependencies['@storybook/vue'] = `^${version}`;
packageJson.devDependencies['@storybook/vue'] = `^${storybookVersion}`;
packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;

packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/generators/SFC_VUE/template/.storybook/addons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import '@storybook/addon-actions/register'
import '@storybook/addon-links/register'
2 changes: 1 addition & 1 deletion lib/cli/generators/SFC_VUE/template/src/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import { storiesOf } from '@storybook/vue';
import { action } from '@storybook/addon-actions';
Expand Down
10 changes: 8 additions & 2 deletions lib/cli/generators/VUE/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ const helpers = require('../../lib/helpers');
const path = require('path');
const latestVersion = require('latest-version');

module.exports = latestVersion('@storybook/vue').then(version => {
Promise.all([
latestVersion('@storybook/vue'),
latestVersion('@storybook/addon-actions'),
latestVersion('@storybook/addon-links'),
]).then(([storybookVersion, actionsVersion, linksVersion]) => {
mergeDirs(path.resolve(__dirname, 'template'), '.', 'overwrite');

const packageJson = helpers.getPackageJson();

packageJson.devDependencies = packageJson.devDependencies || {};
packageJson.devDependencies['@storybook/vue'] = `^${version}`;
packageJson.devDependencies['@storybook/vue'] = `^${storybookVersion}`;
packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;

packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/generators/VUE/template/.storybook/addons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import '@storybook/addon-actions/register'
import '@storybook/addon-links/register'
2 changes: 1 addition & 1 deletion lib/cli/generators/VUE/template/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
/* eslint-disable import/extensions */

import { configure } from '@storybook/vue'

Expand Down
2 changes: 0 additions & 2 deletions lib/cli/generators/VUE/template/stories/MyButton.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */

export default {
name: 'my-button',

Expand Down
2 changes: 0 additions & 2 deletions lib/cli/generators/VUE/template/stories/Welcome.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */

const log = () => console.log('Welcome to storybook!')

export default {
Expand Down
10 changes: 8 additions & 2 deletions lib/cli/generators/WEBPACK_REACT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ const helpers = require('../../lib/helpers');
const path = require('path');
const latestVersion = require('latest-version');

module.exports = latestVersion('@storybook/react').then(version => {
Promise.all([
latestVersion('@storybook/react'),
latestVersion('@storybook/addon-actions'),
latestVersion('@storybook/addon-links'),
]).then(([storybookVersion, actionsVersion, linksVersion]) => {
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');

const packageJson = helpers.getPackageJson();

packageJson.devDependencies = packageJson.devDependencies || {};
packageJson.devDependencies['@storybook/react'] = `^${version}`;
packageJson.devDependencies['@storybook/react'] = `^${storybookVersion}`;
packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;

packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';
Expand Down