File: /var/www/web.enelar.com.co/node_modules/nx/src/command-line/release/release.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.release = exports.releaseCLIHandler = void 0;
const enquirer_1 = require("enquirer");
const nx_json_1 = require("../../config/nx-json");
const devkit_exports_1 = require("../../devkit-exports");
const project_graph_1 = require("../../project-graph/project-graph");
const params_1 = require("../../utils/params");
const changelog_1 = require("./changelog");
const config_1 = require("./config/config");
const publish_1 = require("./publish");
const resolve_nx_json_error_message_1 = require("./utils/resolve-nx-json-error-message");
const version_1 = require("./version");
const releaseCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => release(args));
exports.releaseCLIHandler = releaseCLIHandler;
async function release(args) {
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
const nxJson = (0, nx_json_1.readNxJson)();
if (args.verbose) {
process.env.NX_VERBOSE_LOGGING = 'true';
}
const hasVersionGitConfig = Object.keys(nxJson.release?.version?.git ?? {}).length > 0;
const hasChangelogGitConfig = Object.keys(nxJson.release?.changelog?.git ?? {}).length > 0;
if (hasVersionGitConfig || hasChangelogGitConfig) {
const jsonConfigErrorPath = hasVersionGitConfig
? ['release', 'version', 'git']
: ['release', 'changelog', 'git'];
const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)(jsonConfigErrorPath);
devkit_exports_1.output.error({
title: `The 'release' top level command cannot be used with granular git configuration. Instead, configure git options in the 'release.git' property in nx.json.`,
bodyLines: [nxJsonMessage],
});
process.exit(1);
}
// Apply default configuration to any optional user configuration
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, nxJson.release, 'nx-release-publish');
if (configError) {
return await (0, config_1.handleNxReleaseConfigError)(configError);
}
const versionResult = await (0, version_1.releaseVersion)({
...args,
// if enabled, committing and tagging will be handled by the changelog
// command, so we should only stage the changes in the version command
stageChanges: nxReleaseConfig.git?.commit,
gitCommit: false,
gitTag: false,
});
await (0, changelog_1.releaseChangelog)({
...args,
versionData: versionResult.projectsVersionData,
version: versionResult.workspaceVersion,
workspaceChangelog: versionResult.workspaceVersion !== undefined,
});
let shouldPublish = !!args.yes && !args.skipPublish;
const shouldPromptPublishing = !args.yes && !args.skipPublish && !args.dryRun;
if (shouldPromptPublishing) {
shouldPublish = await promptForPublish();
}
if (shouldPublish) {
await (0, publish_1.releasePublish)(args);
}
else {
console.log('Skipped publishing packages.');
}
return versionResult;
}
exports.release = release;
async function promptForPublish() {
console.log('\n');
const reply = await (0, enquirer_1.prompt)([
{
name: 'confirmation',
message: 'Do you want to publish these versions?',
type: 'confirm',
},
]);
console.log('\n');
return reply.confirmation;
}