4444// ⛔ Additive change passes: a row HEAD's boot ADDS (an activity shard, a
4545// seeder's row) is not a failure, so counts are compared as "at least", and
4646// every fixture row is looked up by id.
47- import { spawnSync } from 'node:child_process' ;
4847import { copyFileSync , mkdtempSync , readFileSync , rmSync } from 'node:fs' ;
49- import { createRequire } from 'node:module' ;
5048import { tmpdir } from 'node:os' ;
51- import { dirname , join } from 'node:path' ;
52- import { fileURLToPath } from 'node:url' ;
49+ import { join } from 'node:path' ;
5350import { DatabaseSync } from 'node:sqlite' ;
5451import { afterAll , beforeAll , describe , expect , it } from 'vitest' ;
5552import { isOrganizationOwnershipBootRefusal } from '@objectstack/runtime' ;
@@ -58,12 +55,10 @@ import type { VerifyStack } from '@objectstack/verify';
5855import { columnsOf , type FixtureManifest } from './upgrade-harness/fixture-manifest.js' ;
5956import { FIXTURE_NAMES , FIXTURE_PEOPLE , bootFixture } from './upgrade-harness/populate-fixture.js' ;
6057import { loadSqlIntoSqlite } from './upgrade-harness/sqlite-text-dump.js' ;
58+ import { OWNERSHIP_MARKER , runOwnershipCeremony } from './upgrade-harness/ceremony.js' ;
6159
6260const FIXTURE = new URL ( './upgrade-harness/fixture-18.0/' , import . meta. url ) ;
63- const SHOWCASE_DIR = fileURLToPath ( new URL ( '../../../../examples/app-showcase/' , import . meta. url ) ) ;
64- const CLI_ROOT = dirname ( createRequire ( import . meta. url ) . resolve ( '@objectstack/cli/package.json' ) ) ;
65- const CLI_BIN = join ( CLI_ROOT , 'bin' , 'run.js' ) ;
66- const MARKER = 'adr-0131-organization-ownership' ;
61+ const MARKER = OWNERSHIP_MARKER ;
6762const manifest = JSON . parse ( readFileSync ( new URL ( 'manifest.json' , FIXTURE ) , 'utf8' ) ) as FixtureManifest ;
6863const fixtureSql = readFileSync ( new URL ( 'database.sql' , FIXTURE ) , 'utf8' ) ;
6964
@@ -84,22 +79,9 @@ async function tryBoot(file: string): Promise<{ stack?: VerifyStack; error?: unk
8479 }
8580}
8681
87- /**
88- * The ceremony on `file`, as an operator runs it: the plan, then the apply of
89- * that reviewed plan file — the real binary, in the showcase's directory, so it
90- * composes what the deployment serves. The apply report.
91- */
82+ /** The ceremony on `file`, as an operator runs it (`runOwnershipCeremony`). */
9283function ceremony ( dir : string , file : string , tag : string ) : Record < string , unknown > {
93- const run = ( args : string [ ] ) => spawnSync ( process . execPath , [
94- CLI_BIN , 'migrate' , 'organization-ownership' , '--database-url' , `file:${ file } ` , ...args ,
95- ] , { cwd : SHOWCASE_DIR , encoding : 'utf8' , timeout : 300_000 , env : { ...process . env , NO_COLOR : '1' } } ) ;
96- const planFile = join ( dir , `${ tag } -plan.json` ) ;
97- const plan = run ( [ '--out' , planFile ] ) ;
98- expect ( plan . status , `the plan: ${ plan . stdout } \n${ plan . stderr } ` ) . toBe ( 0 ) ;
99- const reportFile = join ( dir , `${ tag } -apply.json` ) ;
100- const apply = run ( [ '--apply' , '--plan-file' , planFile , '--backup-taken' , '--out' , reportFile , '--json' ] ) ;
101- expect ( apply . status , `the apply: ${ apply . stdout } \n${ apply . stderr } ` ) . toBe ( 0 ) ;
102- return JSON . parse ( readFileSync ( reportFile , 'utf8' ) ) as Record < string , unknown > ;
84+ return runOwnershipCeremony ( dir , file , tag ) ;
10385}
10486
10587/** The ceremony's marker on `file`: verified, blocking 0, at this release's generation. */
0 commit comments