bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
168 lines (132 loc) • 3.92 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _defineProperty2() {
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
_defineProperty2 = function () {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
function _ttyTable() {
const data = _interopRequireDefault(require("tty-table"));
_ttyTable = function () {
return data;
};
return data;
}
function _consumer() {
const data = require("../../../api/consumer");
_consumer = function () {
return data;
};
return data;
}
function _utils() {
const data = require("../../../utils");
_utils = function () {
return data;
};
return data;
}
function _remoteUndefined() {
const data = _interopRequireDefault(require("../exceptions/remote-undefined"));
_remoteUndefined = function () {
return data;
};
return data;
}
function _constants() {
const data = require("../../../constants");
_constants = function () {
return data;
};
return data;
}
/* eslint max-classes-per-file: 0 */
class RemoteAdd {
constructor() {
(0, _defineProperty2().default)(this, "name", 'add <url>');
(0, _defineProperty2().default)(this, "description", 'add a tracked bit remote');
(0, _defineProperty2().default)(this, "alias", '');
(0, _defineProperty2().default)(this, "opts", [['g', 'global', 'configure a remote bit scope']]);
}
action([url], {
global
}) {
try {
if (!url) return Promise.reject(new (_remoteUndefined().default)());
return (0, _consumer().remoteAdd)(url, global);
} catch (err) {
return Promise.reject(err);
}
}
report({
name,
host
}) {
return _chalk().default.green(`added remote scope '${_chalk().default.bold(name)}' with host '${_chalk().default.bold(host)}'`);
}
}
class RemoteRm {
constructor() {
(0, _defineProperty2().default)(this, "name", 'del <name>');
(0, _defineProperty2().default)(this, "description", 'remove a tracked bit remote');
(0, _defineProperty2().default)(this, "alias", '');
(0, _defineProperty2().default)(this, "opts", [['g', 'global', 'remove a global configured remote scope']]);
}
action([name], {
global
}) {
return (0, _consumer().remoteRm)(name, global);
}
report(name) {
return _chalk().default.green(`successfully removed remote ${_chalk().default.bold(name)}`);
}
}
class Remote {
constructor() {
(0, _defineProperty2().default)(this, "name", 'remote');
(0, _defineProperty2().default)(this, "description", `manage set of tracked bit scope(s)\n https://${_constants().BASE_DOCS_DOMAIN}/docs/bit-server#working-with-remote-scopes`);
(0, _defineProperty2().default)(this, "alias", '');
(0, _defineProperty2().default)(this, "opts", [['g', 'global', 'see globally configured remotes']]);
(0, _defineProperty2().default)(this, "migration", true);
(0, _defineProperty2().default)(this, "commands", [new RemoteAdd(), new RemoteRm()]);
}
action(args, {
global
}) {
return (0, _consumer().remoteList)(global);
}
report(remotes) {
if ((0, _utils().empty)(remotes)) return _chalk().default.red('no configured remotes found in scope');
const header = [{
value: 'scope name',
width: 30,
headerColor: 'cyan'
}, {
value: 'host',
width: 100,
headerColor: 'cyan'
}];
const opts = {
align: 'left'
};
const table = new (_ttyTable().default)(header, [], opts);
(0, _utils().forEach)(remotes, (host, name) => {
table.push([name, host]);
});
return table.render();
}
}
exports.default = Remote;
;