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
91 lines (68 loc) • 2.65 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 _consumer() {
const data = require("../../../api/consumer");
_consumer = function () {
return data;
};
return data;
}
function _constants() {
const data = require("../../../constants");
_constants = function () {
return data;
};
return data;
}
class Diff {
constructor() {
(0, _defineProperty2().default)(this, "name", 'diff [values...]');
(0, _defineProperty2().default)(this, "description", `show diff between components files
bit diff => compare all modified components to their model version
bit diff [ids...] => compare the specified components against their modified states
bit diff [id] [version] => compare the specified version to used or modified files
bit diff [id] [version] [to_version] => compare the specified version files to to_version files
${(0, _constants().WILDCARD_HELP)('diff')}`);
(0, _defineProperty2().default)(this, "alias", '');
(0, _defineProperty2().default)(this, "opts", [['v', 'verbose', 'show a more verbose output when possible']]);
(0, _defineProperty2().default)(this, "loader", true);
}
action([values], {
verbose = false
}) {
return (0, _consumer().diff)(values, verbose);
}
report(diffResults) {
return diffResults.map(diffResult => {
if (diffResult.hasDiff) {
const titleStr = `showing diff for ${_chalk().default.bold(diffResult.id.toStringWithoutVersion())}`;
const titleSeparator = new Array(titleStr.length).fill('-').join('');
const title = _chalk().default.cyan(`${titleSeparator}\n${titleStr}\n${titleSeparator}`); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
const filesWithDiff = diffResult.filesDiff.filter(file => file.diffOutput);
const files = filesWithDiff.map(fileDiff => fileDiff.diffOutput).join('\n');
const fields = diffResult.fieldsDiff ? diffResult.fieldsDiff.map(field => field.diffOutput).join('\n') : '';
return `${title}\n${files}\n${fields}`;
}
return `no diff for ${_chalk().default.bold(diffResult.id.toString())}`;
}).join('\n\n');
}
}
exports.default = Diff;
;