1 | #!/usr/bin/env node
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const once = require("once");
|
4 | const yargs = require("yargs");
|
5 | const logger_1 = require("./logger");
|
6 | const env_1 = require("./utils/env");
|
7 | const helpers_1 = require("./utils/helpers");
|
8 | const noInput_1 = require("./utils/noInput");
|
9 | const sentry_1 = require("./utils/sentry");
|
10 | const version_1 = require("./utils/version");
|
11 |
|
12 |
|
13 |
|
14 | function processDryRun(arg) {
|
15 |
|
16 |
|
17 | if (process.argv.indexOf('--dry-run') > -1) {
|
18 | process.env.DRY_RUN = String(arg);
|
19 | }
|
20 | if (helpers_1.isDryRun()) {
|
21 | logger_1.logger.info('[dry-run] Dry-run mode is on!');
|
22 | }
|
23 | return arg;
|
24 | }
|
25 |
|
26 |
|
27 |
|
28 | function processNoInput(arg) {
|
29 | if (arg) {
|
30 | noInput_1.setNoInput(true);
|
31 | }
|
32 | if (noInput_1.hasNoInput()) {
|
33 | logger_1.logger.info('[no-input] The script will not accept any input!');
|
34 | }
|
35 | return arg;
|
36 | }
|
37 |
|
38 |
|
39 |
|
40 | function printVersion() {
|
41 | if (process.argv.indexOf('-v') === -1 &&
|
42 | process.argv.indexOf('--version') === -1) {
|
43 |
|
44 | logger_1.logger.info(`craft ${version_1.getPackageVersion()}`);
|
45 | }
|
46 | }
|
47 |
|
48 |
|
49 |
|
50 | function main() {
|
51 | version_1.checkForUpdates();
|
52 | printVersion();
|
53 | env_1.readEnvironmentConfig();
|
54 | logger_1.init();
|
55 | sentry_1.initSentrySdk();
|
56 | yargs
|
57 | .parserConfiguration({
|
58 | 'boolean-negation': false,
|
59 | })
|
60 | .commandDir('commands')
|
61 | .demandCommand()
|
62 | .version()
|
63 | .alias('v', 'version')
|
64 | .help()
|
65 | .alias('h', 'help')
|
66 | .option('no-input', {
|
67 | boolean: true,
|
68 | coerce: once(processNoInput),
|
69 | default: false,
|
70 | describe: 'Suppresses all user prompts',
|
71 | })
|
72 | .global('no-input')
|
73 | .option('dry-run', {
|
74 | boolean: true,
|
75 | coerce: once(processDryRun),
|
76 | default: false,
|
77 | describe: 'Dry run mode: do not perform any real actions',
|
78 | })
|
79 | .global('dry-run')
|
80 | .strict()
|
81 | .showHelpOnFail(true)
|
82 | .parse();
|
83 | }
|
84 | main();
|
85 |
|
\ | No newline at end of file |