This repository has been archived by the owner on Jan 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·67 lines (59 loc) · 1.81 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env node
import util from 'util';
import { exec as baseExec } from 'child_process';
import { execaSync } from 'execa';
import consola from 'consola';
import { program } from 'commander';
import './src/utils/load-env.cjs';
import version from './src/utils/get-version.cjs';
import scriptsDir from './src/utils/get-scripts-dir.cjs';
import makeMobileCommand from './src/commands/mobile/index.js';
import makeConfigCommand from './src/commands/config.js';
const exec = util.promisify(baseExec);
program.name('apollos');
program.version(version);
// check version
if (process.env.NODE_ENV !== 'test') {
const { stdout: latest } = execaSync(`${scriptsDir}/get-latest-version.sh`);
if (latest !== version) {
consola.warn(
`Apollos CLI current version: ${version}. Newer version is available: ${latest}`,
);
}
}
program.addCommand(makeMobileCommand());
program.addCommand(makeConfigCommand());
program
.command('secrets')
.description("Decrypt or encrypt your app's secrets")
.argument('<password>')
.option('-d', 'decrypt shared files')
.option('-e', 'encrypt shared files')
.action((password, options) => {
if ((options.d && options.e) || (!options.d && !options.e)) console.error('Must use either -e or -d, not both');
if (options.d) {
exec(`${scriptsDir}/secrets.sh -d ${password}`).then(
({ stdout, stderr }) => {
if (stdout) {
console.log(stdout);
}
if (stderr) {
console.log(stderr);
}
},
);
}
if (options.e) {
exec(`${scriptsDir}/secrets.sh -e ${password}`).then(
({ stdout, stderr }) => {
if (stdout) {
console.log(stdout);
}
if (stderr) {
console.log(stderr);
}
},
);
}
});
program.parse();