UNPKG

1.13 kBPlain TextView Raw
1#!/usr/bin/env node
2
3const shell = require('shelljs');
4const publishUtils = require('../src/utils');
5const build = require('../src/build');
6const path = require('path');
7const packageJson = require(path.resolve('./package.json'));
8const parseArgs = require('../src/parse-args');
9const { config, ...args } = parseArgs(packageJson);
10
11if (!args.BUCKET_PATH) {
12 console.log(
13 'This command needs a bucket path: "my-bucket-name/path/to/destination-folder-in-bucket"'
14 );
15 process.exit(-1);
16}
17
18build(
19 args.SKIP_BUILD,
20 args.OUTPUT_DIR,
21 packageJson,
22 args.PACKAGES_DIRECTORY,
23 args.NPM_SCRIPT,
24 args.MONOREPO_INDEX_GENERATOR
25);
26
27if (args.DRY_RUN) {
28 return;
29}
30
31// If a system does not use an AWS profile we have to exclude the flag entirely.
32// This is indicated by AWS_PROFILE='NONE'.
33const awsProfile =
34 args.AWS_PROFILE === 'NONE' ? '' : `--profile ${args.AWS_PROFILE}`;
35
36console.log('=> Deploying storybook');
37publishUtils.exec(
38 `aws ${awsProfile} s3 sync ${args.OUTPUT_DIR} ${args.S3_PATH} ${args.S3_SYNC_OPTIONS || ''}`
39);
40
41shell.rm('-rf', args.OUTPUT_DIR);
42
43console.log(`=> Storybook deployed to: ${args.S3_PATH}`);