@@ -32,6 +32,7 @@ import {
3232 writeReleaseNote ,
3333} from '../release.ts' ;
3434import {
35+ advancePublishedReleaseStateText ,
3536 buildVersionAnchorReplacements ,
3637 bumpProjectConstantsText ,
3738 nextPrereleaseTag ,
@@ -248,6 +249,29 @@ Deno.test('bumpProjectConstantsText: re-running a bump is a no-op and keeps the
248249 assert ( once . includes ( "PREVIOUS_PACKAGE_VERSION = '0.41.0-alpha.16'" ) ) ;
249250} ) ;
250251
252+ Deno . test ( 'advancePublishedReleaseStateText: finalize converges source and registry truth' , ( ) => {
253+ const input = JSON . stringify ( {
254+ schemaVersion : 1 ,
255+ sourceVersion : '0.43.1' ,
256+ publishedVersion : '0.43.0' ,
257+ latestLandedTrain : 'v0.43.0' ,
258+ activeTarget : 'v0.43.1' ,
259+ nextPlannedTrain : 'not scheduled (maintenance mode)' ,
260+ maturity : 'stable' ,
261+ } ) ;
262+ const stable = JSON . parse ( advancePublishedReleaseStateText ( input , '0.43.1' ) ) ;
263+ assertEquals ( stable . sourceVersion , '0.43.1' ) ;
264+ assertEquals ( stable . publishedVersion , '0.43.1' ) ;
265+ assertEquals ( stable . latestLandedTrain , 'v0.43.1' ) ;
266+ assertEquals ( stable . activeTarget , 'v0.43.1' ) ;
267+ assertEquals ( stable . nextPlannedTrain , 'not scheduled (maintenance mode)' ) ;
268+ assertEquals ( stable . maturity , 'stable' ) ;
269+
270+ const alpha = JSON . parse ( advancePublishedReleaseStateText ( input , '0.44.0-alpha.1' ) ) ;
271+ assertEquals ( alpha . publishedVersion , '0.44.0-alpha.1' ) ;
272+ assertEquals ( alpha . maturity , 'alpha' ) ;
273+ } ) ;
274+
251275Deno . test ( 'two-phase release: prepare never publishes, tags, or pushes main' , ( ) => {
252276 const steps = createPreparePlan ( '0.41.0-alpha.11' , 'docs/current/VERSION_PLAN.md' ) ;
253277 const names = steps . map ( ( step ) => step . name ) ;
@@ -260,6 +284,7 @@ Deno.test('two-phase release: prepare never publishes, tags, or pushes main', ()
260284 assertFalse ( commands . some ( ( command ) => command . includes ( 'git push' ) ) ) ;
261285 const stage = steps . find ( ( step ) => step . name === 'stage release bump' ) ;
262286 assert ( stage ?. command ?. includes ( 'packages/create/src/version.ts' ) ) ;
287+ assert ( stage ?. command ?. includes ( 'examples/supabase-cloudflare-starter/deno.json' ) ) ;
263288} ) ;
264289
265290Deno . test ( 'two-phase release: publish-existing never bumps and verifies main CI first' , ( ) => {
@@ -811,7 +836,26 @@ async function initReleaseRepo(): Promise<{ root: string; work: string }> {
811836 await git ( work , [ 'config' , 'user.name' , 'Release Test' ] ) ;
812837 await git ( work , [ 'checkout' , '-b' , 'main' ] ) ;
813838 await Deno . writeTextFile ( `${ work } /seed.txt` , 'seed\n' ) ;
814- await git ( work , [ 'add' , 'seed.txt' ] ) ;
839+ await Deno . mkdir ( `${ work } /docs/release` , { recursive : true } ) ;
840+ await Deno . writeTextFile (
841+ `${ work } /docs/release/release-state.json` ,
842+ `${
843+ JSON . stringify (
844+ {
845+ schemaVersion : 1 ,
846+ sourceVersion : '9.9.9' ,
847+ publishedVersion : '9.9.8' ,
848+ latestLandedTrain : 'v9.9.8' ,
849+ activeTarget : 'v9.9.9' ,
850+ nextPlannedTrain : 'not scheduled' ,
851+ maturity : 'stable' ,
852+ } ,
853+ null ,
854+ 2 ,
855+ )
856+ } \n`,
857+ ) ;
858+ await git ( work , [ 'add' , 'seed.txt' , 'docs/release/release-state.json' ] ) ;
815859 await git ( work , [ 'commit' , '-m' , 'seed' ] ) ;
816860 await git ( work , [ 'checkout' , '-b' , 'dev' ] ) ;
817861 await git ( work , [ 'remote' , 'add' , 'origin' , origin ] ) ;
@@ -896,6 +940,12 @@ Deno.test('local release finalize: evidence and closure land on main, dev is syn
896940 await git ( work , [ 'show' , 'main:docs/release/autoflow3/v9.9.9.json' ] ) ,
897941 ) as { status : string } ;
898942 assertEquals ( mainEvidence . status , 'completed' ) ;
943+ const releaseState = JSON . parse (
944+ await git ( work , [ 'show' , 'main:docs/release/release-state.json' ] ) ,
945+ ) as { sourceVersion : string ; publishedVersion : string ; latestLandedTrain : string } ;
946+ assertEquals ( releaseState . sourceVersion , '9.9.9' ) ;
947+ assertEquals ( releaseState . publishedVersion , '9.9.9' ) ;
948+ assertEquals ( releaseState . latestLandedTrain , 'v9.9.9' ) ;
899949 // The release note on main carries the Durable closure section.
900950 const note = await git ( work , [ 'show' , 'main:docs/release/v9.9.9.md' ] ) ;
901951 assert ( note . includes ( '## Durable closure' ) ) ;
0 commit comments