-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfdplg
65 lines (55 loc) · 1.97 KB
/
fdplg
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
#!/usr/bin/env node --no-warnings
const watch = require('./commands/watch');
const bundle = require('./commands/bundle');
const args = require('./args');
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const { showHelp } = require('yargs');
const commonArgs = {
'upload-dir': {
alias: 'd',
description: 'The auto uploads directory for your local FlexDeploy Server. Also reads from FDPLG_UPLOAD_DIR env variable.'
},
upload: {
alias: 'u',
description: 'Whether the command should auto upload to the upload directory. Used in conjunction with --upload-dir.'
},
prefix: {
alias: 'p',
description: 'The prefix to apply to the plugin version. Defaults to FDPLG_',
default: 'FDPLG_'
}
}
const argv = yargs(hideBin(process.argv))
.usage('$0 <command> [options]', 'A utility to build FlexDeploy development plugins', (yargs) => {
yargs.command('watch', 'Watches a plugin deploy directory for changes and uploads to local server.', {
...commonArgs,
'init-bundle': {
alias: 'i',
description: 'Initialize the watch by bundling and then watching. Use this if there is already a change you want to bundle.'
}
}),
yargs.command('bundle', 'Bundles a development plugin.', {
...commonArgs,
'plugin-version': {
alias: 'r',
description: 'Specify the exact plugin version you want to use. When set, this will ignore the prefix.'
}
})
})
.argv;
args.setArgs(argv);
if (args.isUpload() && !args.getUploadDir()) {
console.log('Upload Directory must be set if using --upload. Either pass --upload-dir or set FDPLG_UPLOAD_DIR env variable');
return;
}
switch (args.getCommand()) {
case 'watch':
watch.watch();
break;
case 'bundle':
bundle.bundle();
break;
default:
showHelp();
}