quick-publish
Version:
Shipped a standard `npm publish` workflow with one click.
61 lines • 2.15 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.publish = void 0;
/**
* Module dependencies
*/
const inquirer_1 = __importDefault(require("inquirer"));
const select_version_1 = require("./select-version");
const shared_1 = require("./shared");
const commands_1 = require("./commands");
/**
* Release a npm package.
*
* Built for standard publish of **single** repository.
*/
async function publish(opts = {}) {
opts = {
depcost: false,
push: true,
...opts,
};
/**
* 1. Select version and tag.
*/
const { version, tag } = await (0, select_version_1.selectVersionAndTag)(require(`${process.cwd()}/package.json`).version);
/**
* 2. Double check.
*/
const { continueTo } = await inquirer_1.default.prompt({
type: 'confirm',
name: 'continueTo',
message: `Continue to publish \`${version}\` with tag \`${tag}\`?`,
});
/**
* 3. Publish workflow.
*/
if (continueTo) {
await (0, shared_1.exec)(commands_1.COMMANDS.bumpVersion(version));
await (0, shared_1.exec)(commands_1.COMMANDS.changelog());
await (0, shared_1.exec)(commands_1.COMMANDS.npmPublish(tag));
await (0, shared_1.exec)(commands_1.COMMANDS.gitAdd('CHANGELOG.md'));
await (0, shared_1.exec)(commands_1.COMMANDS.gitCommit(`chore: changelog ${version}`));
if (opts.depcost) {
await (0, shared_1.exec)(commands_1.COMMANDS.depcost());
await (0, shared_1.exec)(commands_1.COMMANDS.gitAdd('DEPCOST.md'));
await (0, shared_1.exec)(commands_1.COMMANDS.gitCommit(`chore: DEPCOST.md ${version}`));
}
if (opts.push) {
await (0, shared_1.exec)(commands_1.COMMANDS.gitPush());
await (0, shared_1.exec)(commands_1.COMMANDS.gitPushTag(`v${version}`));
}
}
else {
console.log('Publish cancelled');
}
}
exports.publish = publish;
//# sourceMappingURL=index.js.map