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

95 lines (68 loc) 2.31 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 path() { const data = _interopRequireWildcard(require("path")); path = function () { return data; }; return data; } function _os() { const data = _interopRequireDefault(require("os")); _os = function () { return data; }; return data; } function _chalk() { const data = _interopRequireDefault(require("chalk")); _chalk = 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; } class Graph { constructor() { (0, _defineProperty2().default)(this, "name", 'graph [id]'); (0, _defineProperty2().default)(this, "description", 'EXPERIMENTAL. generate an image file with the dependencies graph'); (0, _defineProperty2().default)(this, "alias", ''); (0, _defineProperty2().default)(this, "opts", [['i', 'image <image>', 'image path. use one of the following extensions: [gif, png, svg, pdf]'], ['r', 'remote [remoteName]', 'remote name (name is optional, leave empty when id is specified)'], ['', 'all-versions', 'enter all components versions into the graph, not only latest'], ['', 'layout <name>', 'GraphVis layout. default to "dot". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]']]); (0, _defineProperty2().default)(this, "remoteOp", true); } action([id], options) { if (!options.image) { options.image = path().join(_os().default.tmpdir(), `${(0, _utils().generateRandomStr)()}.png`); } return (0, _consumer().paintGraph)(id, options); } report(result) { return _chalk().default.green(`image created at ${result}`); } } exports.default = Graph;