GitlabSync.ts 1.65 KB
Newer Older
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
// set up yargs command line parsing

import { GitlabSyncRunner } from './GitlabSyncRunner';
import yargs from 'yargs';
let args = yargs(process.argv)
  .usage('Usage: $0 [options]')
  .example('$0', '')
  .option('d', {
    alias: 'dryrun',
    description: 'Runs script as dry run, not writing any changes to API',
    boolean: true,
    default: false,
  })
  .option('D', {
    alias: 'devMode',
    description: 'Runs script in dev mode, which returns API data that does not impact production organizations/teams.',
    boolean: true,
    default: false,
  })
  .option('V', {
    alias: 'verbose',
    description: 'Sets the script to run in verbose mode',
    boolean: true,
    default: false,
  })
  .option('H', {
    alias: 'host',
    description: 'GitLab host base URL',
    default: 'http://gitlab.eclipse.org/',
    string: true,
  })
  .option('p', {
    alias: 'provider',
    description: 'The OAuth provider name set in GitLab',
    default: 'oauth2_generic',
    string: true,
  })
  .option('P', {
    alias: 'project',
    description: 'The short project ID of the target for the current sync run',
    string: true,
  })
  .option('s', {
    alias: 'secretLocation',
    description: 'The location of the access-token file containing an API access token',
    string: true,
  })
  .help('h')
  .alias('h', 'help')
  .version('0.1')
  .alias('v', 'version')
  .epilog('Copyright 2019 Eclipse Foundation inc.').argv;
run();

async function run() {
  const argv = await args;
  await new GitlabSyncRunner({
    devMode: argv.D,
    host: argv.H,
    dryRun: argv.d,
    provider: argv.p,
    verbose: argv.V,
    project: argv.P,
    secretLocation: argv.s,
  }).run();
}