npm-upgrade
Version:
Interactive CLI utility to easily update outdated NPM dependencies
35 lines (34 loc) • 1.45 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.handler = exports.describe = exports.command = void 0;
var _open = _interopRequireDefault(require("open"));
var _catchAsyncError = _interopRequireDefault(require("../catchAsyncError"));
var _changelogUtils = require("../changelogUtils");
var _cliStyles = require("../cliStyles");
const pkg = require('../../package.json');
const command = exports.command = 'changelog <moduleName>';
const describe = exports.describe = 'Show changelog for a module';
const handler = exports.handler = (0, _catchAsyncError.default)(async opts => {
const {
moduleName
} = opts;
console.log(`Trying to find changelog URL for ${(0, _cliStyles.strong)(moduleName)}...`);
let changelogUrl;
try {
changelogUrl = await (0, _changelogUtils.findModuleChangelogUrl)(moduleName);
} catch (err) {
if (err.code === 'E404') {
console.log("Couldn't find info about this module in npm registry");
return;
}
}
if (changelogUrl) {
console.log(`Opening ${(0, _cliStyles.strong)(changelogUrl)}...`);
(0, _open.default)(changelogUrl);
} else {
console.log("Sorry, we haven't found any changelog URL for this module.\n" + `It would be great if you could fill an issue about this here: ${(0, _cliStyles.strong)(pkg.bugs.url)}\n` + 'Thanks a lot!');
}
});