MCPcopy
hub / github.com/vercel/next.js / resolveSemanticRevision

Function resolveSemanticRevision

packages/next-codemod/bin/upgrade.ts:91–110  ·  view source on GitHub ↗

* Resolves semantic version keywords (patch, minor, major) to npm version queries. * - patch: latest patch within current minor (e.g., 15.0.x -> 15.0.y) * - minor: latest minor within current major (e.g., 15.0.x -> 15.1.x) * - major: latest stable version (equivalent to "latest")

(
  revision: string,
  installedVersion: string
)

Source from the content-addressed store, hash-verified

89 * - major: latest stable version (equivalent to "latest")
90 */
91function resolveSemanticRevision(
92 revision: string,
93 installedVersion: string
94): string {
95 const installedMajor = major(installedVersion)
96 const installedMinor = minor(installedVersion)
97
98 switch (revision) {
99 case 'patch':
100 // ~15.0.0 matches >=15.0.0 <15.1.0
101 return `~${installedMajor}.${installedMinor}.0`
102 case 'minor':
103 // ^15.0.0 matches >=15.0.0 <16.0.0
104 return `^${installedMajor}.0.0`
105 case 'major':
106 return 'latest'
107 default:
108 return revision
109 }
110}
111
112export async function runUpgrade(
113 revision: string | undefined,

Callers 1

runUpgradeFunction · 0.85

Calls 2

majorFunction · 0.90
minorFunction · 0.90

Tested by

no test coverage detected