mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 12:47:48 +00:00
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
const yargs = require('yargs');
|
|
const { execSync } = require('child_process');
|
|
const package = require('../package.json');
|
|
|
|
const version = package.version;
|
|
const fileName = `openapi-cli.${version}.tar.gz`;
|
|
const fileNameLatest = `openapi-cli.latest.tar.gz`;
|
|
|
|
execSync(`tar -zcvf ${fileName} dist`);
|
|
execSync(`tar -zcvf ${fileNameLatest} dist`);
|
|
|
|
const argv = yargs.option('aws-profile', {
|
|
alias: 'p',
|
|
type: 'string',
|
|
}).argv;
|
|
|
|
let profile = !!argv.awsProfile ? `--profile ${argv.awsProfile}` : '';
|
|
|
|
if (process.env.ENV === 'local') {
|
|
execSync(`mkdir -p /tmp/redocly/openapi-cli/latest/`);
|
|
execSync(`mkdir -p /tmp/redocly/openapi-cli/${version}/`);
|
|
execSync(`cp -R dist /tmp/redocly/openapi-cli/latest/`);
|
|
execSync(`cp -R dist /tmp/redocly/openapi-cli/${version}/`);
|
|
} else {
|
|
try {
|
|
execSync(`aws s3 cp ${fileName} s3://${process.env.AWS_S3_PATH} ${profile}`);
|
|
execSync(`aws s3 cp ${fileNameLatest} s3://${process.env.AWS_S3_PATH} ${profile}`);
|
|
} catch (e) {
|
|
process.stderr.write(e.output);
|
|
}
|
|
}
|