diff --git a/packages/nx/src/command-line/release/config/config.spec.ts b/packages/nx/src/command-line/release/config/config.spec.ts index 8190d1bf37fe54..37c9c4c0facae1 100644 --- a/packages/nx/src/command-line/release/config/config.spec.ts +++ b/packages/nx/src/command-line/release/config/config.spec.ts @@ -274,6 +274,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -449,6 +450,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -627,6 +629,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -836,6 +839,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -1029,6 +1033,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -1230,6 +1235,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -1432,6 +1438,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -1614,6 +1621,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -1795,6 +1803,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -1978,6 +1987,7 @@ describe('createNxReleaseConfig()', () => { "generatorOptions": { "optionsOverride": "something", }, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -1992,6 +2002,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@custom/generator-alternative", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -2184,6 +2195,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -2370,6 +2382,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -2395,6 +2408,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -2579,6 +2593,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -2766,6 +2781,7 @@ describe('createNxReleaseConfig()', () => { "generatorOptions": { "foo": "bar", }, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -2949,6 +2965,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -3133,6 +3150,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -3313,6 +3331,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "nx run-many -t build", }, "versionPlans": false, }, @@ -3511,6 +3530,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -3691,6 +3711,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -3893,6 +3914,7 @@ describe('createNxReleaseConfig()', () => { "currentVersionResolver": "git-tag", "specifierSource": "conventional-commits", }, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -4065,6 +4087,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -4278,6 +4301,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -4481,6 +4505,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -4662,6 +4687,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -4843,6 +4869,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -5022,6 +5049,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -5237,6 +5265,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -5428,6 +5457,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -5622,6 +5652,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -5817,6 +5848,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -6015,6 +6047,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -6234,6 +6267,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -6248,6 +6282,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -6273,6 +6308,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -6486,6 +6522,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -6859,6 +6896,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -7219,6 +7257,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -7234,6 +7273,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -7402,6 +7442,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -7590,6 +7631,7 @@ describe('createNxReleaseConfig()', () => { "currentVersionResolver": "git-tag", "specifierSource": "conventional-commits", }, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -7777,6 +7819,7 @@ describe('createNxReleaseConfig()', () => { "currentVersionResolver": "registry", "specifierSource": "prompt", }, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -7963,6 +8006,7 @@ describe('createNxReleaseConfig()', () => { "currentVersionResolver": "git-tag", "specifierSource": "conventional-commits", }, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -8152,6 +8196,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -8342,6 +8387,7 @@ describe('createNxReleaseConfig()', () => { "someUnrelatedOption": "foobar", "specifierSource": "conventional-commits", }, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -8571,6 +8617,7 @@ describe('createNxReleaseConfig()', () => { "generatorOptions": { "specifierSource": "version-plans", }, + "preVersionCommand": "", }, "versionPlans": true, }, @@ -8758,6 +8805,7 @@ describe('createNxReleaseConfig()', () => { "generatorOptions": { "specifierSource": "version-plans", }, + "preVersionCommand": "", }, "versionPlans": { "ignorePatternsForPlanCheck": [ @@ -8949,6 +8997,7 @@ describe('createNxReleaseConfig()', () => { "generatorOptions": { "specifierSource": "version-plans", }, + "preVersionCommand": "", }, "versionPlans": true, }, @@ -8963,6 +9012,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -9144,6 +9194,7 @@ describe('createNxReleaseConfig()', () => { "generatorOptions": { "specifierSource": "version-plans", }, + "preVersionCommand": "", }, "versionPlans": { "ignorePatternsForPlanCheck": [ @@ -9162,6 +9213,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -9341,6 +9393,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -9357,6 +9410,7 @@ describe('createNxReleaseConfig()', () => { "generatorOptions": { "specifierSource": "version-plans", }, + "preVersionCommand": "", }, "versionPlans": true, }, @@ -9540,6 +9594,7 @@ describe('createNxReleaseConfig()', () => { "conventionalCommits": false, "generator": "@nx/js:release-version", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -9556,6 +9611,7 @@ describe('createNxReleaseConfig()', () => { "generatorOptions": { "specifierSource": "version-plans", }, + "preVersionCommand": "", }, "versionPlans": { "ignorePatternsForPlanCheck": [ diff --git a/packages/nx/src/command-line/release/config/config.ts b/packages/nx/src/command-line/release/config/config.ts index 7c2918067c1fc4..939c20ffaf4538 100644 --- a/packages/nx/src/command-line/release/config/config.ts +++ b/packages/nx/src/command-line/release/config/config.ts @@ -273,6 +273,7 @@ export async function createNxReleaseConfig( conventionalCommits: false, generator: '@nx/js:release-version', generatorOptions: {}, + preVersionCommand: '', }, changelog: { createRelease: false, @@ -357,7 +358,6 @@ export async function createNxReleaseConfig( // these options are not supported at the group level, only the root/command level const rootVersionWithoutGlobalOptions = { ...rootVersionConfig }; delete rootVersionWithoutGlobalOptions.git; - delete rootVersionWithoutGlobalOptions.preVersionCommand; // Apply conventionalCommits shorthand to the final group defaults if explicitly configured in the original user config if (userConfig.version?.conventionalCommits === true) { diff --git a/packages/nx/src/command-line/release/config/filter-release-groups.spec.ts b/packages/nx/src/command-line/release/config/filter-release-groups.spec.ts index 5a44c384e0ca34..bf87d62394aa19 100644 --- a/packages/nx/src/command-line/release/config/filter-release-groups.spec.ts +++ b/packages/nx/src/command-line/release/config/filter-release-groups.spec.ts @@ -102,6 +102,7 @@ describe('filterReleaseGroups()', () => { conventionalCommits: false, generator: '', generatorOptions: {}, + preVersionCommand: '', }, releaseTagPattern: '', versionPlans: false, @@ -130,6 +131,7 @@ describe('filterReleaseGroups()', () => { conventionalCommits: false, generator: '', generatorOptions: {}, + preVersionCommand: '', }, releaseTagPattern: '', versionPlans: false, @@ -142,6 +144,7 @@ describe('filterReleaseGroups()', () => { conventionalCommits: false, generator: '', generatorOptions: {}, + preVersionCommand: '', }, releaseTagPattern: '', versionPlans: false, @@ -165,6 +168,7 @@ describe('filterReleaseGroups()', () => { "conventionalCommits": false, "generator": "", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -181,6 +185,7 @@ describe('filterReleaseGroups()', () => { "conventionalCommits": false, "generator": "", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -201,6 +206,7 @@ describe('filterReleaseGroups()', () => { "conventionalCommits": false, "generator": "", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, } => Set { @@ -219,6 +225,7 @@ describe('filterReleaseGroups()', () => { "conventionalCommits": false, "generator": "", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, } => Set { @@ -238,6 +245,7 @@ describe('filterReleaseGroups()', () => { conventionalCommits: false, generator: '', generatorOptions: {}, + preVersionCommand: '', }, releaseTagPattern: '', versionPlans: false, @@ -265,6 +273,7 @@ describe('filterReleaseGroups()', () => { conventionalCommits: false, generator: '', generatorOptions: {}, + preVersionCommand: '', }, releaseTagPattern: '', versionPlans: false, @@ -277,6 +286,7 @@ describe('filterReleaseGroups()', () => { conventionalCommits: false, generator: '', generatorOptions: {}, + preVersionCommand: '', }, releaseTagPattern: '', versionPlans: false, @@ -305,6 +315,7 @@ describe('filterReleaseGroups()', () => { conventionalCommits: false, generator: '', generatorOptions: {}, + preVersionCommand: '', }, releaseTagPattern: '', versionPlans: false, @@ -317,6 +328,7 @@ describe('filterReleaseGroups()', () => { conventionalCommits: false, generator: '', generatorOptions: {}, + preVersionCommand: '', }, releaseTagPattern: '', versionPlans: false, @@ -340,6 +352,7 @@ describe('filterReleaseGroups()', () => { "conventionalCommits": false, "generator": "", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -360,6 +373,7 @@ describe('filterReleaseGroups()', () => { "conventionalCommits": false, "generator": "", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, } => Set { @@ -395,6 +409,7 @@ describe('filterReleaseGroups()', () => { conventionalCommits: false, generator: '', generatorOptions: {}, + preVersionCommand: '', }, releaseTagPattern: '', versionPlans: false, @@ -407,6 +422,7 @@ describe('filterReleaseGroups()', () => { conventionalCommits: false, generator: '', generatorOptions: {}, + preVersionCommand: '', }, releaseTagPattern: '', versionPlans: false, @@ -430,6 +446,7 @@ describe('filterReleaseGroups()', () => { "conventionalCommits": false, "generator": "", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, }, @@ -450,6 +467,7 @@ describe('filterReleaseGroups()', () => { "conventionalCommits": false, "generator": "", "generatorOptions": {}, + "preVersionCommand": "", }, "versionPlans": false, } => Set { diff --git a/packages/nx/src/command-line/release/utils/shared.spec.ts b/packages/nx/src/command-line/release/utils/shared.spec.ts index b1852c2ad824bb..86ef0ab15c7112 100644 --- a/packages/nx/src/command-line/release/utils/shared.spec.ts +++ b/packages/nx/src/command-line/release/utils/shared.spec.ts @@ -14,6 +14,7 @@ describe('shared', () => { conventionalCommits: false, generator: '@nx/js:version', generatorOptions: {}, + preVersionCommand: '', }, changelog: false, releaseTagPattern: '{projectName}-{version}', @@ -28,6 +29,7 @@ describe('shared', () => { conventionalCommits: false, generator: '@nx/js:version', generatorOptions: {}, + preVersionCommand: '', }, changelog: false, releaseTagPattern: '{projectName}-{version}', @@ -82,6 +84,7 @@ describe('shared', () => { conventionalCommits: false, generator: '@nx/js:version', generatorOptions: {}, + preVersionCommand: '', }, changelog: false, releaseTagPattern: '{projectName}-{version}', @@ -96,6 +99,7 @@ describe('shared', () => { conventionalCommits: false, generator: '@nx/js:version', generatorOptions: {}, + preVersionCommand: '', }, changelog: false, releaseTagPattern: '{projectName}-{version}', @@ -161,6 +165,7 @@ describe('shared', () => { specifierSource: 'conventional-commits', currentVersionResolver: 'git-tag', }, + preVersionCommand: '', }, changelog: { createRelease: 'github', diff --git a/packages/nx/src/config/nx-json.ts b/packages/nx/src/config/nx-json.ts index fa97fffb6168c2..3ff913dd70642a 100644 --- a/packages/nx/src/config/nx-json.ts +++ b/packages/nx/src/config/nx-json.ts @@ -69,6 +69,12 @@ export interface NxReleaseVersionConfiguration { * If the user attempts to mix and match these options with the shorthand, we will provide a helpful error. */ conventionalCommits?: boolean; + /** + * 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'. + */ + preVersionCommand?: string; } export interface NxReleaseChangelogConfiguration { @@ -276,12 +282,6 @@ export interface NxReleaseConfiguration { * Enable or override configuration for git operations as part of the version subcommand */ git?: NxReleaseGitConfiguration; - /** - * 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'. - */ - preVersionCommand?: string; }; /** * Optionally override the git/release tag pattern to use. This field is the source of truth