-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
74 lines (61 loc) · 1.53 KB
/
Copy pathcli.js
File metadata and controls
74 lines (61 loc) · 1.53 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env node
const meow = require('meow');
const logSymbols = require('log-symbols');
const updateNotifier = require('update-notifier');
const getLogger = require('./lib/get-logger');
const ui = require('./lib/ui');
const gitlabRelease = require('.');
const cli = meow(`
Usage
$ gitlab-release <input>
Options
--built-type, -bt Build Type
--git-host, -gh 'gitlab.domain.com/{group-name}/{project-name}.git';
--allow-push
Examples
$ gitlab-release --git-host 'gitlab.domain.com/project.git'
`, {
flags: {
allowPush: {
type: 'boolean',
default: true
},
gitHost: {
type: 'string',
alias: 'gh'
},
buildType: {
type: 'string',
alias: 'bt'
}
}
});
updateNotifier({pkg: cli.pkg}).notify();
const context = {
cwd: process.cwd(),
env: process.env,
stdout: process.stdout,
stderr: process.stderr
};
const logger = getLogger(context);
process.on('SIGINT', () => {
logger.log('\nAborted!');
process.exit(1);
});
Promise
.resolve()
.then(() => {
return ui(cli.flags);
})
.then(options => {
if (!options.gitHost) {
logger.error(`Must set "--git-host" option`);
process.exit(0);
}
return options;
})
.then(options => gitlabRelease(options, { logger } ))
.catch(err => {
logger.error(`\n${logSymbols.error} ${err.message}`);
process.exit(1);
});