This repository has been archived by the owner on Nov 10, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from storybooks/add-getstorybook-repo
Add getstorybook repo
- Loading branch information
Showing
43 changed files
with
1,325 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ node_modules | |
npm-shrinkwrap.json | ||
dist | ||
.tern-port | ||
*.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Changelog | ||
|
||
### v1.7.0 | ||
18-Dec-2016 | ||
|
||
Use a non-hacky way to detect yarn. [PR24](https://github.com/storybooks/getstorybook/pull/24) | ||
|
||
### v1.6.1 | ||
18-Oct-2016 | ||
|
||
Fix some typos. [PR21](https://github.com/kadirahq/getstorybook/pull/21) | ||
|
||
### v1.6.0 | ||
12-Oct-2016 | ||
|
||
Add yarn support. Now users could install storybook with yarn and use yarn to install deps: | ||
|
||
``` | ||
yarn global add getstorybook | ||
getstorybook | ||
``` | ||
|
||
For more info check [docs](https://github.com/kadirahq/getstorybook#yarn-support). | ||
|
||
### v1.5.2 | ||
07-Oct-2016 | ||
|
||
* Update more user friendly welcome screen to REACT_SCRIPTS generator. | ||
|
||
### v1.5.0 | ||
05-Oct-2016 | ||
|
||
* Update to use the latest storybook. Also update REACT_SCRIPTS generator to support public folder. | ||
|
||
### v1.4.6 | ||
30-Sep-2016 | ||
|
||
* Remove index.css import from config.js in CRA. | ||
|
||
### v1.4.5 | ||
06-Aug-2016 | ||
|
||
Fix an issue related to Meteor. | ||
|
||
* Related issue: [kadirahq/react-storybook#423](https://github.com/kadirahq/react-storybook/issues/423) | ||
* The fix: [088eecf](https://github.com/kadirahq/getstorybook/commit/088eecf740bebf522b6608892a3a7e3e34bcfc31) | ||
|
||
### v1.4.4 | ||
30-Aug-2016 | ||
|
||
* Update @kadira/storybook to version 2.5.2. [PR17](https://github.com/kadirahq/getstorybook/pull/17) | ||
* Add Arial font and remove image from Welcome message. [PR16](https://github.com/kadirahq/getstorybook/pull/16) | ||
|
||
### v1.4.3 | ||
30-Aug-2016 | ||
|
||
This is a mistakenly published version. | ||
|
||
### v1.4.2 | ||
28-Aug-2016 | ||
|
||
* React Native: Do not import addons.js on entryfiles.[PR14](https://github.com/kadirahq/getstorybook/pull/14) | ||
* Fix "emojies" typo. [PR15](https://github.com/kadirahq/getstorybook/pull/15) | ||
|
||
### v1.4.1 | ||
26-Aug-2016 | ||
|
||
* [RN] Automate setting app name on entry files [PR12](https://github.com/kadirahq/getstorybook/pull/12) | ||
* [RN] Add entry javascript file for Android [PR13](https://github.com/kadirahq/getstorybook/pull/13) | ||
|
||
### v1.4.0 | ||
25-Aug-2016 | ||
|
||
* Add support for React Native apps. [PR11](https://github.com/kadirahq/getstorybook/pull/11) | ||
|
||
### v1.3.0 | ||
11-Aug-2016 | ||
|
||
* Add support for Webpack React apps. [PR8](https://github.com/kadirahq/getstorybook/pull/8) | ||
* Add support for Meteor. [PR9](https://github.com/kadirahq/getstorybook/pull/9) | ||
|
||
### v1.2.0 | ||
10-Aug-2016 | ||
|
||
* Add better default stories. [PR7](https://github.com/kadirahq/getstorybook/pull/7) | ||
* Fix an issue with the `-f` option. With `-f`, it was detecting every app as a CRA based app. | ||
|
||
### v1.1.0 | ||
3-Aug-2016 | ||
|
||
Show some feedback when installing NPM dependencies. Fixes: [#5](https://github.com/kadirahq/getstorybook/issues/5). | ||
|
||
Now we use `childProcess.spawnSync` to run the `npm install` command. | ||
|
||
### v1.0.0 | ||
2-Aug-2016 | ||
|
||
Add the initial release supporting following project types: | ||
|
||
* Create React App based projects. | ||
* Any other React app. | ||
* Any React component library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Kadira Inc. <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# getstorybook | ||
|
||
Easiest way to add [Storybook](https://github.com/kadirahq/react-storybook) support to your project. | ||
|
||
![](docs/getstorybook.png) | ||
|
||
First install the storybook generator globally. | ||
|
||
``` | ||
npm i -g getstorybook | ||
``` | ||
|
||
Then go to your project and run: | ||
|
||
``` | ||
getstorybook | ||
``` | ||
|
||
That's all you've to do. | ||
|
||
--- | ||
|
||
## [Yarn](https://github.com/yarnpkg/yarn) support | ||
|
||
`getstorybook` also supports yarn. | ||
If you have installed yarn in your system, it'll detect it and use `yarn` instead of `npm`. | ||
|
||
If you don't want to use `npm` always you can use the `--use-npm` option like this: | ||
|
||
``` | ||
getstorybook --use-npm | ||
``` | ||
|
||
|
||
|
||
For more information, refer [React Storybook](https://github.com/kadirahq/react-storybook) documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#!/usr/bin/env node | ||
|
||
/* eslint global-require: 0 */ | ||
|
||
const updateNotifier = require('update-notifier'); | ||
const program = require('commander'); | ||
const chalk = require('chalk'); | ||
const detect = require('../lib/detect'); | ||
const hasYarn = require('../lib/has_yarn'); | ||
const types = require('../lib/project_types'); | ||
const commandLog = require('../lib/helpers').commandLog; | ||
const codeLog = require('../lib/helpers').codeLog; | ||
const paddedLog = require('../lib/helpers').paddedLog; | ||
const installDeps = require('../lib/helpers').installDeps; | ||
const logger = console; | ||
|
||
const pkg = require('../package.json'); | ||
|
||
program | ||
.version(pkg.version) | ||
.option('-f --force', 'Forcely add storybook') | ||
.option('-N --use-npm', 'Use npm to install deps') | ||
.parse(process.argv); | ||
|
||
const welcomeMessage = 'getstorybook - the simplest way to add a storybook to your project.'; | ||
logger.log(chalk.inverse(`\n ${welcomeMessage} \n`)); | ||
|
||
const useYarn = Boolean(program.useNpm !== true) && hasYarn(); | ||
|
||
const npmOptions = { | ||
useYarn | ||
}; | ||
|
||
const runStorybookCommand = useYarn ? 'yarn run storybook' : 'npm run storybook'; | ||
|
||
// Update notify code. | ||
updateNotifier({ | ||
pkg, | ||
updateCheckInterval: 1000 * 60 * 60 // every hour (we could increase this later on.) | ||
}).notify(); | ||
|
||
let projectType; | ||
|
||
let done = commandLog('Detecting project type'); | ||
try { | ||
projectType = detect({ | ||
force: program.force | ||
}); | ||
} catch (ex) { | ||
done(ex.message); | ||
process.exit(1); | ||
} | ||
done(); | ||
|
||
switch (projectType) { | ||
case types.ALREADY_HAS_STORYBOOK: | ||
logger.log(); | ||
paddedLog('There seems to be a storybook already available in this project.'); | ||
paddedLog('Apply following command to force:\n'); | ||
codeLog(['getstorybook -f']); | ||
break; | ||
case types.REACT_SCRIPTS: | ||
done = commandLog('Adding storybook support to your "Create React App" based project'); | ||
require('../generators/REACT_SCRIPTS'); | ||
done(); | ||
|
||
installDeps(npmOptions); | ||
|
||
logger.log('\nTo run your storybook, type:\n'); | ||
codeLog([runStorybookCommand]); | ||
logger.log('\nFor more information visit:', chalk.cyan('http://getstorybook.io')); | ||
break; | ||
|
||
case types.REACT: | ||
done = commandLog('Adding storybook support to your "React" app'); | ||
require('../generators/REACT'); | ||
done(); | ||
|
||
installDeps(npmOptions); | ||
|
||
logger.log('\nTo run your storybook, type:\n'); | ||
codeLog([runStorybookCommand]); | ||
logger.log('\nFor more information visit:', chalk.cyan('http://getstorybook.io')); | ||
break; | ||
|
||
case types.REACT_NATIVE: | ||
done = commandLog('Adding storybook support to your "React Native" app'); | ||
require('../generators/REACT_NATIVE'); | ||
done(); | ||
|
||
installDeps(npmOptions); | ||
|
||
logger.log('\nTo run your storybook, type:\n'); | ||
codeLog([runStorybookCommand]); | ||
logger.log('\nFor more information visit:', chalk.cyan('http://getstorybook.io')); | ||
break; | ||
|
||
case types.METEOR: | ||
done = commandLog('Adding storybook support to your "Meteor" app'); | ||
require('../generators/METEOR'); | ||
done(); | ||
|
||
installDeps(npmOptions); | ||
|
||
logger.log('\nTo run your storybook, type:\n'); | ||
codeLog([runStorybookCommand]); | ||
logger.log('\nFor more information visit:', chalk.cyan('http://getstorybook.io')); | ||
break; | ||
|
||
case types.WEBPACK_REACT: | ||
done = commandLog('Adding storybook support to your "Webpack React" app'); | ||
require('../generators/WEBPACK_REACT'); | ||
done(); | ||
|
||
installDeps(npmOptions); | ||
|
||
logger.log('\nTo run your storybook, type:\n'); | ||
codeLog([runStorybookCommand]); | ||
logger.log('\nFor more information visit:', chalk.cyan('http://getstorybook.io')); | ||
break; | ||
|
||
case types.REACT_PROJECT: | ||
done = commandLog('Adding storybook support to your "React" library'); | ||
require('../generators/REACT'); | ||
done(); | ||
|
||
installDeps(npmOptions); | ||
|
||
logger.log('\nTo run your storybook, type:\n'); | ||
codeLog([runStorybookCommand]); | ||
logger.log('\nFor more information visit:', chalk.cyan('http://getstorybook.io')); | ||
break; | ||
|
||
default: | ||
paddedLog(`Unsupported Project type. (code: ${projectType})`); | ||
paddedLog('Visit http://getstorybook.io for more information.'); | ||
} | ||
|
||
// Add a new line for the clear visibility. | ||
logger.log(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const mergeDirs = require('merge-dirs').default; | ||
const helpers = require('../../lib/helpers'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const sh = require('shelljs'); | ||
const JSON5 = require('json5'); | ||
|
||
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite'); | ||
|
||
const packageJson = helpers.getPackageJson(); | ||
packageJson.devDependencies = packageJson.devDependencies || {}; | ||
packageJson.scripts = packageJson.scripts || {}; | ||
packageJson.dependencies = packageJson.dependencies || {}; | ||
|
||
// create or update .babelrc | ||
let babelrc = null; | ||
if (fs.existsSync('.babelrc')) { | ||
const babelrcContent = fs.readFileSync('.babelrc', 'utf8'); | ||
babelrc = JSON5.parse(babelrcContent); | ||
babelrc.plugins = babelrc.plugins || []; | ||
|
||
if (babelrc.plugins.indexOf('babel-root-slash-import') < 0) { | ||
babelrc.plugins.push('babel-root-slash-import'); | ||
packageJson.devDependencies['babel-root-slash-import'] = '^1.1.0'; | ||
} | ||
} else { | ||
babelrc = { | ||
presets: ['es2015', 'es2016', 'react', 'stage-1'], | ||
plugins: ['babel-root-slash-import'] | ||
}; | ||
|
||
packageJson.devDependencies['babel-preset-es2015'] = '^6.9.0'; | ||
packageJson.devDependencies['babel-preset-es2016'] = '^6.11.3'; | ||
packageJson.devDependencies['babel-preset-react'] = '^6.11.1'; | ||
packageJson.devDependencies['babel-preset-stage-1'] = '^6.13.0'; | ||
packageJson.devDependencies['babel-root-slash-import'] = '^1.1.0'; | ||
} | ||
|
||
fs.writeFileSync('.babelrc', JSON.stringify(babelrc, null, 2), 'utf8'); | ||
|
||
// write the new package.json. | ||
packageJson.devDependencies['@kadira/storybook'] = '^2.21.0'; | ||
packageJson.scripts['storybook'] = 'start-storybook -p 6006'; | ||
packageJson.scripts['build-storybook'] = 'build-storybook'; | ||
|
||
// add react packages. | ||
if (!packageJson.dependencies.react) { | ||
packageJson.dependencies.react = '^15.3.0'; | ||
} | ||
if (!packageJson.dependencies['react-dom']) { | ||
packageJson.dependencies['react-dom'] = '^15.3.0'; | ||
} | ||
|
||
helpers.writePackageJson(packageJson); |
27 changes: 27 additions & 0 deletions
27
packages/getstorybook/generators/METEOR/template/.stories/Button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
|
||
const buttonStyles = { | ||
border: '1px solid #eee', | ||
borderRadius: 3, | ||
backgroundColor: '#FFFFFF', | ||
cursor: 'pointer', | ||
fontSize: 15, | ||
padding: '3px 10px', | ||
margin: 10, | ||
}; | ||
|
||
const Button = ({ children, onClick }) => ( | ||
<button | ||
style={buttonStyles} | ||
onClick={onClick} | ||
> | ||
{children} | ||
</button> | ||
); | ||
|
||
Button.propTypes = { | ||
children: React.PropTypes.string.isRequired, | ||
onClick: React.PropTypes.func, | ||
}; | ||
|
||
export default Button; |
Oops, something went wrong.