fix(release): add groupPreVersionCommand to schema, improve logging (#28087)
This commit is contained in:
parent
4fa50ad238
commit
619dbe7316
@ -106,7 +106,9 @@ describe('nx release pre-version command', () => {
|
||||
// command should succeed because the pre-version command will build the package
|
||||
const result4 = runCLI(`release patch -d -g ${groupName} --first-release`);
|
||||
|
||||
expect(result4).toContain('NX Executing pre-version command');
|
||||
expect(result4).toContain(
|
||||
`NX Executing release group pre-version command for "${groupName}"`
|
||||
);
|
||||
|
||||
updateJson(`nx.json`, (json) => {
|
||||
json.release = {
|
||||
|
||||
@ -152,25 +152,7 @@
|
||||
]
|
||||
},
|
||||
"version": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/NxReleaseVersionConfiguration"
|
||||
},
|
||||
{
|
||||
"allOf": [
|
||||
{
|
||||
"not": {
|
||||
"required": ["git"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"not": {
|
||||
"required": ["preVersionCommand"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"$ref": "#/definitions/NxReleaseGroupVersionConfiguration"
|
||||
},
|
||||
"changelog": {
|
||||
"oneOf": [
|
||||
@ -675,10 +657,33 @@
|
||||
},
|
||||
"preVersionCommand": {
|
||||
"type": "string",
|
||||
"description": "A command to run after validation of nx release configuration, but before versioning begins. Used for preparing build artifacts. If --dry-run is passed, the command is still executed, but with the NX_DRY_RUN environment variable set to 'true'."
|
||||
"description": "A command to run after validation of nx release configuration, but before versioning begins. Useful for preparing build artifacts. If --dry-run is passed, the command is still executed, but with the NX_DRY_RUN environment variable set to 'true'."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"NxReleaseGroupVersionConfiguration": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"conventionalCommits": {
|
||||
"type": "boolean",
|
||||
"description": "Shorthand for enabling the current version of projects to be resolved from git tags, and the next version to be determined by analyzing commit messages according to the Conventional Commits specification.",
|
||||
"default": false
|
||||
},
|
||||
"generator": {
|
||||
"type": "string"
|
||||
},
|
||||
"generatorOptions": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
},
|
||||
"groupPreVersionCommand": {
|
||||
"type": "string",
|
||||
"description": "A command to run after validation of nx release configuration AND after the release.version.preVersionCommand (if any), but before versioning begins for this specific group. Useful for preparing build artifacts for the group. If --dry-run is passed, the command is still executed, but with the NX_DRY_RUN environment variable set to 'true'."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"NxReleaseChangelogConfiguration": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@ -383,10 +383,14 @@ export function createAPI(overrideReleaseConfig: NxReleaseConfiguration) {
|
||||
for (const releaseGroup of releaseGroups) {
|
||||
const releaseGroupName = releaseGroup.name;
|
||||
|
||||
runPreVersionCommand(releaseGroup.version.groupPreVersionCommand, {
|
||||
runPreVersionCommand(
|
||||
releaseGroup.version.groupPreVersionCommand,
|
||||
{
|
||||
dryRun: args.dryRun,
|
||||
verbose: args.verbose,
|
||||
});
|
||||
},
|
||||
releaseGroup
|
||||
);
|
||||
|
||||
const projectBatches = batchProjectsByGeneratorConfig(
|
||||
projectGraph,
|
||||
@ -727,13 +731,18 @@ function resolveGeneratorData({
|
||||
}
|
||||
function runPreVersionCommand(
|
||||
preVersionCommand: string,
|
||||
{ dryRun, verbose }: { dryRun: boolean; verbose: boolean }
|
||||
{ dryRun, verbose }: { dryRun: boolean; verbose: boolean },
|
||||
releaseGroup?: ReleaseGroupWithName
|
||||
) {
|
||||
if (!preVersionCommand) {
|
||||
return;
|
||||
}
|
||||
|
||||
output.logSingleLine(`Executing pre-version command`);
|
||||
output.logSingleLine(
|
||||
releaseGroup
|
||||
? `Executing release group pre-version command for "${releaseGroup.name}"`
|
||||
: `Executing pre-version command`
|
||||
);
|
||||
if (verbose) {
|
||||
console.log(`Executing the following pre-version command:`);
|
||||
console.log(preVersionCommand);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user