1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const lodash_1 = require("lodash");
|
4 | const os_1 = require("os");
|
5 | const identity_1 = require("../../commons/identity");
|
6 | const travisRelease_1 = require("../../commons/travisRelease");
|
7 | const Log_1 = require("../Log");
|
8 | const PromptableConfig_1 = require("../PromptableConfig");
|
9 | const travis_1 = require("../sync-request/travis/travis");
|
10 | exports.options = travisRelease_1.addTravisRelease();
|
11 | identity_1.addGhRepo(exports.options);
|
12 | identity_1.addGhUser(exports.options);
|
13 | function handle(c) {
|
14 | if (c.get('skipTravisRelease')) {
|
15 | Log_1.Log.info('Skipping Travis release');
|
16 | return;
|
17 | }
|
18 | Log_1.Log.info('Setting up Travis release');
|
19 | try {
|
20 | const endpoint = c.get('travisEndpoint');
|
21 | const ort = {
|
22 | owner: c.promptedGhUser(),
|
23 | pro: endpoint === travisRelease_1.TravisEndpoint.PRO,
|
24 | repo: c.promptedGhRepo(),
|
25 | token: endpoint === travisRelease_1.TravisEndpoint.PRO ? c.promptedTravisTokenPro() : c.promptedTravisTokenOrg()
|
26 | };
|
27 | travis_1.setStdSettings(ort);
|
28 | const envVarsToSet = {
|
29 | GH_TOKEN: () => c.promptedReleaseGhToken(),
|
30 | GIT_COMMITTER_EMAIL: () => c.promptedGhEmail(),
|
31 | GIT_COMMITTER_NAME: () => c.promptedName(),
|
32 | GIT_EMAIL: () => c.promptedGhEmail(),
|
33 | GIT_USERNAME: () => c.promptedName(),
|
34 | NPM_TOKEN: () => c.promptedReleaseNpmToken()
|
35 | };
|
36 | lodash_1.forEach(envVarsToSet, (getVarFn, varName) => {
|
37 | if (!travis_1.envVarExists(Object.assign({}, ort, { name: varName }))) {
|
38 | travis_1.setEnvVar(Object.assign({}, ort, {
|
39 | name: varName,
|
40 | public: false,
|
41 | value: getVarFn()
|
42 | }));
|
43 | }
|
44 | });
|
45 | Log_1.Log.success('Set up Travis release');
|
46 | }
|
47 | catch (e) {
|
48 | process.stderr.write((e.stack || e.message || e.toString()) + os_1.EOL + os_1.EOL);
|
49 | const msg = 'travis-ci environment setup failed with the error above. Do you want to still want to continue?';
|
50 | if (PromptableConfig_1.PromptableConfig.readline.keyInYNStrict(msg)) {
|
51 | Log_1.Log.warn('Travis release failed; user chose to continue.');
|
52 | }
|
53 | else {
|
54 | Log_1.Log.err('Travis release failed. Terminating setup.');
|
55 | process.exit(1);
|
56 | }
|
57 | }
|
58 | }
|
59 | exports.handle = handle;
|