mirror of
https://github.com/strapi/strapi.git
synced 2025-09-21 14:31:16 +00:00
Merge branch 'features/upgrade-tool' of github.com:strapi/strapi into upgrade-tool/chores
This commit is contained in:
commit
c56802ae6f
@ -32,17 +32,15 @@ addReleaseUpgradeCommand(
|
|||||||
'Upgrade to the next available major version of Strapi'
|
'Upgrade to the next available major version of Strapi'
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: Add back the command when adding the support for minor upgrades
|
addReleaseUpgradeCommand(
|
||||||
// addReleaseUpgradeCommand(
|
Version.ReleaseType.Minor,
|
||||||
// Version.ReleaseType.Minor,
|
'Upgrade to the latest minor and patch version of Strapi for the current major'
|
||||||
// 'Upgrade to the latest minor/patch version of Strapi for the current major'
|
);
|
||||||
// );
|
|
||||||
|
|
||||||
// TODO: Add back the command when adding the support for patch upgrades
|
addReleaseUpgradeCommand(
|
||||||
// addReleaseUpgradeCommand(
|
Version.ReleaseType.Patch,
|
||||||
// Version.ReleaseType.Patch,
|
'Upgrade to latest patch version of Strapi for the current major and minor'
|
||||||
// 'Upgrade to latest patch version of Strapi for the current major and minor'
|
);
|
||||||
// );
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.usage('<command> [options]')
|
.usage('<command> [options]')
|
||||||
|
@ -8,16 +8,24 @@ export const rangeFactory = (range: string): Version.Range => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const rangeFromReleaseType = (current: Version.SemVer, identifier: Version.ReleaseType) => {
|
export const rangeFromReleaseType = (current: Version.SemVer, identifier: Version.ReleaseType) => {
|
||||||
const fromCurrentTo = (version: Version.LiteralVersion) => {
|
|
||||||
return rangeFactory(`>${current.raw} <=${version}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
switch (identifier) {
|
switch (identifier) {
|
||||||
case Version.ReleaseType.Major: {
|
case Version.ReleaseType.Major: {
|
||||||
// semver.inc(_, 'major') will target <major + 1>.0.0 which is what we want
|
// semver.inc(_, 'major') will target <major + 1>.0.0 which is what we want
|
||||||
// e.g. for 4.15.4, it'll return 5.0.0
|
// e.g. for 4.15.4, it'll return 5.0.0
|
||||||
const nextMajor = semver.inc(current, 'major') as Version.LiteralSemVer;
|
const nextMajor = semver.inc(current, 'major') as Version.LiteralSemVer;
|
||||||
return fromCurrentTo(nextMajor);
|
return rangeFactory(`>${current.raw} <=${nextMajor}`);
|
||||||
|
}
|
||||||
|
case Version.ReleaseType.Patch: {
|
||||||
|
// This will return the minor for the next minor
|
||||||
|
// e.g. for 4.15.4, it'll return 4.16.0
|
||||||
|
const minor = semver.inc(current, 'minor') as Version.LiteralSemVer;
|
||||||
|
return rangeFactory(`>${current.raw} <${minor}`);
|
||||||
|
}
|
||||||
|
case Version.ReleaseType.Minor: {
|
||||||
|
// This will return the major for the next major
|
||||||
|
// e.g. for 4.15.4, it'll return 5.0.0
|
||||||
|
const major = semver.inc(current, 'major') as Version.LiteralSemVer;
|
||||||
|
return rangeFactory(`>${current.raw} <${major}`);
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new Error('Not implemented');
|
throw new Error('Not implemented');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user