forked from kriskbx/gitlab-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgtt-sync.js
More file actions
executable file
·37 lines (32 loc) · 1.26 KB
/
gtt-sync.js
File metadata and controls
executable file
·37 lines (32 loc) · 1.26 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
const moment = require('moment');
const program = require('commander');
const Config = require('./include/file-config');
const Cli = require('./include/cli');
const Tasks = require('./include/tasks');
const Owner = require('./models/owner');
program
.option('-p --proxy <proxy>', 'use a proxy server with the given url')
.option('--verbose', 'show verbose output')
.parse(process.argv);
Cli.verbose = program.verbose;
let config = new Config(process.cwd())
.set('proxy', program.proxy);
tasks = new Tasks(config),
owner = new Owner(config);
tasks.syncInit()
.then(() => tasks.sync.frames.length === 0 ? process.exit(0) : null)
.then(() => owner.authorized())
.catch(e => Cli.x(`Invalid access token!`, e))
.then(() => {
Cli.bar(`${Cli.fetch} Fetching or creating issues & merge requests...`, tasks.sync.frames.length);
return tasks.syncResolve(Cli.advance);
})
.then(() => {
Cli.bar(`${Cli.process} Processing issues & merge requests...`, tasks.sync.frames.length);
return tasks.syncNotes(Cli.advance);
})
.then(() => {
Cli.bar(`${Cli.update} Syncing time records...`, tasks.sync.frames.length);
return tasks.syncUpdate(Cli.advance)
})
.catch(error => Cli.x(error));