UNPKG

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

163 lines (124 loc) 3.91 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); 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 _padRight() { const data = _interopRequireDefault(require("pad-right")); _padRight = function () { return data; }; return data; } function _chalk() { const data = _interopRequireDefault(require("chalk")); _chalk = function () { return data; }; return data; } function _constants() { const data = require("../../../constants"); _constants = function () { return data; }; return data; } function config() { const data = _interopRequireWildcard(require("../../../api/consumer/lib/global-config")); config = function () { return data; }; return data; } /* eslint max-classes-per-file: 0 */ // import { config } from '../../../api/consumer'; // const config = require('../../../api/consumer/lib/global-config'); class ConfigSet { constructor() { (0, _defineProperty2().default)(this, "name", 'set <key> <val>'); (0, _defineProperty2().default)(this, "description", 'set a global configuration'); (0, _defineProperty2().default)(this, "alias", ''); (0, _defineProperty2().default)(this, "skipWorkspace", true); (0, _defineProperty2().default)(this, "opts", []); } action([key, value]) { return config().set(key, value); } report() { return _chalk().default.green('added configuration successfully'); } } class ConfigGet { constructor() { (0, _defineProperty2().default)(this, "name", 'get <key>'); (0, _defineProperty2().default)(this, "description", 'get a global configuration'); (0, _defineProperty2().default)(this, "alias", ''); (0, _defineProperty2().default)(this, "opts", []); } action([key]) { return config().get(key); } report(value) { return value; } } class ConfigList { constructor() { (0, _defineProperty2().default)(this, "name", 'list'); (0, _defineProperty2().default)(this, "description", 'list all configuration(s)'); (0, _defineProperty2().default)(this, "alias", ''); (0, _defineProperty2().default)(this, "opts", []); } action() { return config().list(); } report(conf) { return Object.entries(conf).map(tuple => { return tuple.join(' '); }).join('\n'); } } class ConfigDel { constructor() { (0, _defineProperty2().default)(this, "name", 'del <key>'); (0, _defineProperty2().default)(this, "description", 'delete given key from global configuration'); (0, _defineProperty2().default)(this, "alias", ''); (0, _defineProperty2().default)(this, "opts", []); } action([key]) { return config().del(key); } report() { return _chalk().default.green('deleted successfully'); } } class Config { constructor() { (0, _defineProperty2().default)(this, "name", 'config'); (0, _defineProperty2().default)(this, "description", `global config management.\n https://${_constants().BASE_DOCS_DOMAIN}/docs/conf-config`); (0, _defineProperty2().default)(this, "alias", ''); (0, _defineProperty2().default)(this, "commands", [new ConfigSet(), new ConfigDel(), new ConfigGet(), new ConfigList()]); (0, _defineProperty2().default)(this, "opts", []); (0, _defineProperty2().default)(this, "migration", false); } action() { return config().list(); } report(conf) { return Object.entries(conf).map(tuple => { tuple[0] = (0, _padRight().default)(tuple[0], 30, ' '); return tuple.join(''); }).join('\n'); } } exports.default = Config;