File tree Expand file tree Collapse file tree 4 files changed +44
-4
lines changed
packages/core/src/project Expand file tree Collapse file tree 4 files changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,8 @@ export abstract class MonorepoProject extends Project {
197197
198198 private async getBumpOptions (
199199 project : Project ,
200- options : MonorepoProjectBumpOptions
200+ options : MonorepoProjectBumpOptions ,
201+ baseVersion ?: string
201202 ) {
202203 const {
203204 preset = bumpDefaultOptions . preset ,
@@ -218,7 +219,8 @@ export abstract class MonorepoProject extends Project {
218219 ...bumpOptions ,
219220 ...byProject ?. [ name ] ,
220221 preset : projectPreset ,
221- tagPrefix
222+ tagPrefix,
223+ baseVersion
222224 }
223225
224226 return projectBumpOptions
@@ -268,13 +270,15 @@ export abstract class MonorepoProject extends Project {
268270 project : Project
269271 options : MonorepoProjectBumpOptions
270272 } [ ] = [ ]
273+ const baseVersion = await this . manifest . getVersion ( )
271274 let hasBump = false
272275 let fixedVersion : string | undefined
273276
274277 for await ( const project of this . getProjects ( ) ) {
275278 const projectBumpOptions = await this . getBumpOptions (
276279 project ,
277- options
280+ options ,
281+ baseVersion
278282 )
279283 const version = await project . getNextVersion ( projectBumpOptions )
280284
Original file line number Diff line number Diff line change @@ -330,6 +330,36 @@ describe('core', () => {
330330
331331 expect ( message ) . toBe ( 'chore(release): 2.1.0' )
332332 } )
333+
334+ it ( 'should bump using base version' , async ( ) => {
335+ const path = await forkProject ( 'bump' , packageJsonFixedMonorepoProject ( {
336+ 0 : {
337+ version : '4.0.0'
338+ }
339+ } ) )
340+ const project = new PackageJsonMonorepoProject ( {
341+ mode : 'fixed' ,
342+ root : path ,
343+ getProjects
344+ } )
345+ const result = await project . bump ( )
346+
347+ expect ( result ) . toBe ( true )
348+ expect ( project . versionUpdates ) . toMatchObject ( [
349+ {
350+ name : 'package-json-monorepo-project' ,
351+ to : '4.1.0'
352+ } ,
353+ {
354+ name : 'subproject-2' ,
355+ to : '4.1.0'
356+ } ,
357+ {
358+ name : 'subproject-3' ,
359+ to : '4.1.0'
360+ }
361+ ] )
362+ } )
333363 } )
334364 } )
335365 } )
Original file line number Diff line number Diff line change @@ -187,6 +187,7 @@ export abstract class Project {
187187 const { projectPath } = manifest
188188 const {
189189 version : forcedVersion ,
190+ baseVersion,
190191 as,
191192 prerelease,
192193 firstRelease : firstReleaseOption ,
@@ -205,7 +206,7 @@ export abstract class Project {
205206 } )
206207 }
207208
208- const version = await manifest . getVersion ( )
209+ const version = baseVersion || await manifest . getVersion ( )
209210
210211 if ( firstRelease ) {
211212 return version
Original file line number Diff line number Diff line change @@ -38,6 +38,11 @@ export interface ProjectBumpOptions {
3838 * If not provided, the version will be determined based on the commits.
3939 */
4040 version ?: string
41+ /**
42+ * The base version to use for bumping.
43+ * If not provided, the version will be getted from the manifest.
44+ */
45+ baseVersion ?: string
4146 /**
4247 * The type of release to bump to.
4348 * If not provided, the version will be determined based on the commits.
You can’t perform that action at this time.
0 commit comments