1 | #!/usr/bin/env node
|
2 |
|
3 | const shell = require('shelljs');
|
4 | const publishUtils = require('../src/utils');
|
5 | const build = require('../src/build');
|
6 | const path = require('path');
|
7 | const packageJson = require(path.resolve('./package.json'));
|
8 | const parseArgs = require('../src/parse-args');
|
9 | const { config, ...args } = parseArgs(packageJson);
|
10 |
|
11 | if (!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 |
|
18 | build(
|
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 |
|
27 | if (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'.
|
33 | const awsProfile =
|
34 | args.AWS_PROFILE === 'NONE' ? '' : `--profile ${args.AWS_PROFILE}`;
|
35 |
|
36 | console.log('=> Deploying storybook');
|
37 | publishUtils.exec(
|
38 | `aws ${awsProfile} s3 sync ${args.OUTPUT_DIR} ${args.S3_PATH} ${args.S3_SYNC_OPTIONS || ''}`
|
39 | );
|
40 |
|
41 | shell.rm('-rf', args.OUTPUT_DIR);
|
42 |
|
43 | console.log(`=> Storybook deployed to: ${args.S3_PATH}`);
|