-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
54 lines (48 loc) · 1.59 KB
/
app.js
File metadata and controls
54 lines (48 loc) · 1.59 KB
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
const argv = require('boring')();
const cp = require('child_process');
const linter = require('./lib/linter');
const upgrader = require('./lib/upgrader');
const { stripIndent } = require('common-tags');
const prompts = require('prompts');
if (argv._[0] === 'reset') {
cp.execSync('git reset --hard && git clean -df');
} else if (argv._[0] === 'lint') {
linter({ argv });
} else if (argv._[0] === 'upgrade') {
upgrade({ argv });
} else if (argv._[0] === 'help' || argv.help) {
console.log(stripIndent`
Commands:
lint List changes you need to make (always recommended)
Example: apos-code-upgrader lint
upgrade [options] Make some changes automatically
Example: apos-code-upgrader upgrade
Options:
- --upgrade-required-files: Experimental support for inlining module
code included with \`require\` statements. Most successful when the
inlined file is limited to an exported function that the module
invokes with \`(self, options)\`
`);
} else {
console.log(stripIndent`
Run \`apos-code-upgrader help\` or \`apos-code-upgrader --help\` for commands.
`);
}
async function upgrade({ argv }) {
const { proceed } = await confirm();
if (proceed) {
upgrader({ argv });
} else {
process.exit(1);
}
}
async function confirm() {
return prompts({
type: 'confirm',
name: 'proceed',
message: stripIndent`
Running the upgrade command will make MAJOR changes to your code. It will not (git) commit those changes, however.
Are you sure you want to continue?`,
initial: false
});
}