Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #27 from travisbloom/ISSUE-26-existing-directory
Browse files Browse the repository at this point in the history
Add a new CLI config "existing-output-dir" that
  • Loading branch information
ndelangen authored Dec 12, 2017
2 parents 424f437 + 77b259e commit 59c97f7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ If you customize the build configuration with some additional params (like stati

> Make sure to set the output directory as **`.out`**.
### Skip Build Step

If you have previously built your storybook output (through a different CI step, etc) and just need to publish it, specify the directory with like this:

```js
npm run deploy-storybook -- --existing-output-dir=.out
```

### Custom deploy configuration

If you want to customize Git username, email or commit message, add this to `package.json`:
Expand Down
26 changes: 14 additions & 12 deletions bin/storybook_to_ghpages
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var path = require('path');
var packageJson = require(path.resolve('./package.json'));
var argv = require('yargs').argv;

var OUTPUT_DIR = 'out' + Math.ceil(Math.random() * 9999);
var SKIP_BUILD = Boolean(argv['existing-output-dir'])
var OUTPUT_DIR = argv['existing-output-dir'] || 'out' + Math.ceil(Math.random() * 9999);

var defaultConfig = {
gitUsername: 'GH Pages Bot',
Expand All @@ -29,16 +30,18 @@ if (!GIT_URL) {
process.exit(-1);
}

// clear and re-create the out directory
shell.rm('-rf', OUTPUT_DIR);
shell.mkdir(OUTPUT_DIR);
if (!SKIP_BUILD) {
// clear and re-create the out directory
shell.rm('-rf', OUTPUT_DIR);
shell.mkdir(OUTPUT_DIR);

// run our compile script
console.log('=> Building storybook');
if (packageJson.scripts[NPM_SCRIPT]) {
publishUtils.exec('npm run ' + NPM_SCRIPT + ' -- -o ' + OUTPUT_DIR);
} else {
publishUtils.exec('node ./node_modules/.bin/build-storybook -o ' + OUTPUT_DIR);
// run our compile script
console.log('=> Building storybook');
if (packageJson.scripts[NPM_SCRIPT]) {
publishUtils.exec('npm run ' + NPM_SCRIPT + ' -- -o ' + OUTPUT_DIR);
} else {
publishUtils.exec('node ./node_modules/.bin/build-storybook -o ' + OUTPUT_DIR);
}
}

// go to the out directory and create a *new* Git repo
Expand Down Expand Up @@ -66,8 +69,7 @@ publishUtils.exec('git push --force --quiet ' + GIT_URL + ' ' + SOURCE_BRANCH +
shell.cd('..');
shell.rm('-rf', OUTPUT_DIR);

console.log();
if(TARGET_BRANCH !== 'gh-pages') {
if (TARGET_BRANCH !== 'gh-pages') {
var rawgit_url = GIT_URL.replace('github.com', 'rawgit.com').replace('.git', '/') +
TARGET_BRANCH + '/index.html';
console.log('=> Storybook deployed to: ' + rawgit_url);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
"shelljs": "^0.7.0",
"yargs": "^8.0.1"
}
}
}

0 comments on commit 59c97f7

Please sign in to comment.