2017-08-28 15:11:47 +00:00
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
});
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const plugins = require("./mod.plugins");
|
2017-09-08 12:58:44 +00:00
|
|
|
const npmci_bash_1 = require("../npmci.bash");
|
|
|
|
const npmci_env_1 = require("../npmci.env");
|
2017-08-28 15:11:47 +00:00
|
|
|
/**
|
|
|
|
* handle cli input
|
|
|
|
* @param argvArg
|
|
|
|
*/
|
|
|
|
exports.handleCli = (argvArg) => __awaiter(this, void 0, void 0, function* () {
|
|
|
|
if (argvArg._.length >= 2) {
|
|
|
|
let action = argvArg._[1];
|
|
|
|
switch (action) {
|
|
|
|
case 'mirror':
|
|
|
|
yield exports.mirror();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
plugins.beautylog.error(`>>npmci git ...<< action >>${action}<< not supported`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
plugins.beautylog.log(`>>npmci git ...<< cli arguments invalid... Please read the documentation.`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
exports.mirror = () => __awaiter(this, void 0, void 0, function* () {
|
2017-09-08 12:58:44 +00:00
|
|
|
let githubToken = process.env.NPMCI_GIT_GITHUBTOKEN;
|
|
|
|
let githubUser = process.env.NPMCI_GIT_GITHUBGROUP || npmci_env_1.repo.user;
|
|
|
|
let githubRepo = process.env.NPMCI_GIT_GITHUB || npmci_env_1.repo.repo;
|
|
|
|
if (githubToken) {
|
|
|
|
plugins.beautylog.info('found github token.');
|
|
|
|
plugins.beautylog.log('attempting the mirror the repository to GitHub');
|
|
|
|
// add the mirror
|
2017-09-08 13:00:43 +00:00
|
|
|
yield npmci_bash_1.bash(`git remote add mirror https://${githubToken}@github.com/${githubUser}/${githubRepo}.git`);
|
2017-09-08 15:51:48 +00:00
|
|
|
yield npmci_bash_1.bash(`git push mirror --all`);
|
|
|
|
plugins.beautylog.ok('pushed all branches to mirror!');
|
|
|
|
yield npmci_bash_1.bash(`git push mirror --tags`);
|
|
|
|
plugins.beautylog.ok('pushed all tags to mirror!');
|
2017-09-08 13:00:43 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
plugins.beautylog.error(`cannot find NPMCI_GIT_GITHUBTOKEN env var!`);
|
|
|
|
process.exit(1);
|
2017-09-08 12:58:44 +00:00
|
|
|
}
|
2017-08-28 15:11:47 +00:00
|
|
|
});
|
2017-10-09 16:10:01 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9tb2RfZ2l0L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQSx5Q0FBd0M7QUFDeEMsOENBQW9DO0FBQ3BDLDRDQUFtQztBQUVuQzs7O0dBR0c7QUFDUSxRQUFBLFNBQVMsR0FBRyxDQUFPLE9BQU8sRUFBRSxFQUFFO0lBQ3ZDLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUMsTUFBTSxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDMUIsSUFBSSxNQUFNLEdBQVcsT0FBTyxDQUFDLENBQUMsQ0FBRSxDQUFDLENBQUUsQ0FBQTtRQUNuQyxNQUFNLENBQUMsQ0FBQyxNQUFNLENBQUMsQ0FBQyxD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