fix(release): allow specifier override for version command when version plans are enabled (#27436)
This commit is contained in:
parent
c17969665c
commit
4d2793987c
@ -139,7 +139,7 @@ Here is another line in the message.
|
|||||||
`git commit -m "chore: add version plans for fixed and independent groups"`
|
`git commit -m "chore: add version plans for fixed and independent groups"`
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = runCLI('release --verbose', {
|
const result = runCLI('release --verbose --skip-publish', {
|
||||||
silenceError: true,
|
silenceError: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -597,7 +597,7 @@ Update packages in both groups with a mix #2
|
|||||||
// dry-run should not remove the version plan
|
// dry-run should not remove the version plan
|
||||||
expect(exists(join(versionPlansDir, 'bump-mixed1.md'))).toBeTruthy();
|
expect(exists(join(versionPlansDir, 'bump-mixed1.md'))).toBeTruthy();
|
||||||
|
|
||||||
const result2 = runCLI('release --verbose', {
|
const result2 = runCLI('release --verbose --skip-publish', {
|
||||||
silenceError: true,
|
silenceError: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -767,4 +767,92 @@ Update packages in both groups with a mix #2
|
|||||||
|
|
||||||
expect(readdirSync(versionPlansDir)).toEqual([]);
|
expect(readdirSync(versionPlansDir)).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('version command should bypass version plans when a specifier is passed', async () => {
|
||||||
|
updateJson<NxJsonConfiguration>('nx.json', (nxJson) => {
|
||||||
|
nxJson.release = {
|
||||||
|
groups: {
|
||||||
|
'fixed-group': {
|
||||||
|
projects: [pkg1, pkg2],
|
||||||
|
releaseTagPattern: 'v{version}',
|
||||||
|
},
|
||||||
|
'independent-group': {
|
||||||
|
projects: [pkg3, pkg4, pkg5],
|
||||||
|
projectsRelationship: 'independent',
|
||||||
|
releaseTagPattern: '{projectName}@{version}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
version: {
|
||||||
|
generatorOptions: {
|
||||||
|
specifierSource: 'version-plans',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
changelog: {
|
||||||
|
projectChangelogs: true,
|
||||||
|
},
|
||||||
|
versionPlans: true,
|
||||||
|
};
|
||||||
|
return nxJson;
|
||||||
|
});
|
||||||
|
|
||||||
|
runCLI(
|
||||||
|
'release plan minor -g fixed-group -m "Update the fixed packages with another minor release." --verbose',
|
||||||
|
{
|
||||||
|
silenceError: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
runCLI(
|
||||||
|
'release plan minor -g independent-group -m "Update the independent packages with another minor release." --verbose',
|
||||||
|
{
|
||||||
|
silenceError: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const versionPlansDir = tmpProjPath('.nx/version-plans');
|
||||||
|
await runCommandAsync(`git add ${versionPlansDir}`);
|
||||||
|
await runCommandAsync(
|
||||||
|
`git commit -m "chore: add version plans for fixed and independent groups again"`
|
||||||
|
);
|
||||||
|
|
||||||
|
const releaseResult = runCLI('release major --verbose --skip-publish', {
|
||||||
|
silenceError: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(releaseResult).toContain(
|
||||||
|
`NX A specifier option cannot be provided when using version plans.`
|
||||||
|
);
|
||||||
|
expect(releaseResult).toContain(
|
||||||
|
`To override this behavior, use the Nx Release programmatic API directly (https://nx.dev/features/manage-releases#using-the-programmatic-api-for-nx-release).`
|
||||||
|
);
|
||||||
|
|
||||||
|
const versionResult = runCLI('release version major --verbose', {
|
||||||
|
silenceError: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(versionResult).toContain(
|
||||||
|
'Skipping version plan discovery as a specifier was provided'
|
||||||
|
);
|
||||||
|
expect(versionResult).toContain(
|
||||||
|
`${pkg1} 📄 Using the provided version specifier "major".`
|
||||||
|
);
|
||||||
|
expect(versionResult).toContain(
|
||||||
|
`${pkg2} 📄 Using the provided version specifier "major".`
|
||||||
|
);
|
||||||
|
expect(versionResult).toContain(
|
||||||
|
`${pkg3} 📄 Using the provided version specifier "major".`
|
||||||
|
);
|
||||||
|
expect(versionResult).toContain(
|
||||||
|
`${pkg4} 📄 Using the provided version specifier "major".`
|
||||||
|
);
|
||||||
|
expect(versionResult).toContain(
|
||||||
|
`${pkg5} 📄 Using the provided version specifier "major".`
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(versionResult).toContain(
|
||||||
|
`git add ${pkg1}/package.json ${pkg2}/package.json ${pkg3}/package.json ${pkg4}/package.json ${pkg5}/package.json`
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(readdirSync(versionPlansDir).length).toEqual(2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -81,6 +81,7 @@ export type PlanCheckOptions = BaseNxReleaseArgs & {
|
|||||||
|
|
||||||
export type ReleaseOptions = NxReleaseArgs &
|
export type ReleaseOptions = NxReleaseArgs &
|
||||||
FirstReleaseArgs & {
|
FirstReleaseArgs & {
|
||||||
|
specifier?: string;
|
||||||
yes?: boolean;
|
yes?: boolean;
|
||||||
skipPublish?: boolean;
|
skipPublish?: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -94,6 +94,18 @@ export function createAPI(overrideReleaseConfig: NxReleaseConfiguration) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rawVersionPlans = await readRawVersionPlans();
|
||||||
|
|
||||||
|
if (args.specifier && rawVersionPlans.length > 0) {
|
||||||
|
output.error({
|
||||||
|
title: `A specifier option cannot be provided when using version plans.`,
|
||||||
|
bodyLines: [
|
||||||
|
`To override this behavior, use the Nx Release programmatic API directly (https://nx.dev/features/manage-releases#using-the-programmatic-api-for-nx-release).`,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// These properties must never be undefined as this command should
|
// These properties must never be undefined as this command should
|
||||||
// always explicitly override the git operations of the subcommands.
|
// always explicitly override the git operations of the subcommands.
|
||||||
const shouldCommit = userProvidedReleaseConfig.git?.commit ?? true;
|
const shouldCommit = userProvidedReleaseConfig.git?.commit ?? true;
|
||||||
@ -134,7 +146,7 @@ export function createAPI(overrideReleaseConfig: NxReleaseConfiguration) {
|
|||||||
output.error(filterError);
|
output.error(filterError);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const rawVersionPlans = await readRawVersionPlans();
|
|
||||||
setResolvedVersionPlansOnGroups(
|
setResolvedVersionPlansOnGroups(
|
||||||
rawVersionPlans,
|
rawVersionPlans,
|
||||||
releaseGroups,
|
releaseGroups,
|
||||||
|
|||||||
@ -189,12 +189,20 @@ export function createAPI(overrideReleaseConfig: NxReleaseConfiguration) {
|
|||||||
output.error(filterError);
|
output.error(filterError);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
if (!args.specifier) {
|
||||||
const rawVersionPlans = await readRawVersionPlans();
|
const rawVersionPlans = await readRawVersionPlans();
|
||||||
setResolvedVersionPlansOnGroups(
|
setResolvedVersionPlansOnGroups(
|
||||||
rawVersionPlans,
|
rawVersionPlans,
|
||||||
releaseGroups,
|
releaseGroups,
|
||||||
Object.keys(projectGraph.nodes)
|
Object.keys(projectGraph.nodes)
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
if (args.verbose && releaseGroups.some((g) => !!g.versionPlans)) {
|
||||||
|
console.log(
|
||||||
|
`Skipping version plan discovery as a specifier was provided`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (args.deleteVersionPlans === undefined) {
|
if (args.deleteVersionPlans === undefined) {
|
||||||
// default to not delete version plans after versioning as they may be needed for changelog generation
|
// default to not delete version plans after versioning as they may be needed for changelog generation
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user