2017-08-27 13:24:17 +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");
|
|
|
|
const npmci_bash_1 = require("../npmci.bash");
|
|
|
|
/**
|
|
|
|
* 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 'install':
|
|
|
|
yield install();
|
|
|
|
break;
|
|
|
|
case 'prepare':
|
|
|
|
yield prepare();
|
|
|
|
break;
|
|
|
|
case 'test':
|
|
|
|
yield exports.test();
|
|
|
|
break;
|
2017-08-28 11:08:21 +00:00
|
|
|
case 'publish':
|
|
|
|
yield publish();
|
|
|
|
break;
|
2017-08-27 13:24:17 +00:00
|
|
|
default:
|
2017-08-28 00:24:06 +00:00
|
|
|
plugins.beautylog.error(`>>npmci npm ...<< action >>${action}<< not supported`);
|
2017-08-28 11:25:22 +00:00
|
|
|
process.exit(1);
|
2017-08-27 13:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2017-08-28 00:24:06 +00:00
|
|
|
plugins.beautylog.log(`>>npmci npm ...<< cli arguments invalid... Please read the documentation.`);
|
2017-08-28 11:25:22 +00:00
|
|
|
process.exit(1);
|
2017-08-27 13:24:17 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
/**
|
|
|
|
* authenticates npm with token from env var
|
|
|
|
*/
|
|
|
|
let prepare = () => __awaiter(this, void 0, void 0, function* () {
|
|
|
|
let npmrcPrefix = '//registry.npmjs.org/:_authToken=';
|
|
|
|
let npmToken = process.env.NPMCI_TOKEN_NPM;
|
|
|
|
let npmrcFileString = npmrcPrefix + npmToken;
|
|
|
|
if (npmToken) {
|
|
|
|
plugins.beautylog.info('found access token');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
plugins.beautylog.error('no access token found! Exiting!');
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
plugins.smartfile.memory.toFsSync(npmrcFileString, '/root/.npmrc');
|
|
|
|
return;
|
|
|
|
});
|
2017-08-28 11:08:21 +00:00
|
|
|
let publish = () => __awaiter(this, void 0, void 0, function* () {
|
|
|
|
yield npmci_bash_1.bash('npm publish');
|
|
|
|
});
|
2017-08-27 13:24:17 +00:00
|
|
|
let install = () => __awaiter(this, void 0, void 0, function* () {
|
|
|
|
plugins.beautylog.info('now installing dependencies:');
|
|
|
|
if (yield npmci_bash_1.yarnAvailable.promise) {
|
|
|
|
yield npmci_bash_1.bash('yarn install');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
yield npmci_bash_1.bash('npm install');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
exports.test = () => __awaiter(this, void 0, void 0, function* () {
|
|
|
|
plugins.beautylog.info('now starting tests:');
|
|
|
|
yield npmci_bash_1.bash('yarn test');
|
|
|
|
});
|
2017-08-28 11:25:22 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9tb2RfbnBtL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQSx5Q0FBd0M7QUFFeEM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