GitlabSync.ts 2.35 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
/** ***************************************************************
 Copyright (C) 2022 Eclipse Foundation, Inc.

 This program and the accompanying materials are made
 available under the terms of the Eclipse Public License 2.0
 which is available at https://www.eclipse.org/legal/epl-2.0/

  Contributors:
    Martin Lowe <martin.lowe@eclipse-foundation.org>

 SPDX-License-Identifier: EPL-2.0
******************************************************************/
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

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,
  })
54
55
56
57
58
59
  .option('r', {
    alias: 'rootGroup',
    description: 'The root group to be used when syncing groups over (e.g. eclipse, openhwgroup)',
    string: true,
    default: 'eclipse',
  })
60
61
62
63
64
65
66
67
68
69
70
71
  .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();

72
73
74
/**
 * runs the sync process using the CLI args as configuration items to pass to the sync runner.
 */
75
76
77
78
79
80
81
82
83
84
85
86
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();
}