@@ -14,7 +14,7 @@ import {
1414} from '@void/platform' ;
1515import { confirm , isCancel , log , outro , select } from '@voidzero-dev/vite-plus-prompts' ;
1616import { ensurePlatformAccessToken } from './cf-access.ts' ;
17- import { printSuccess , createSpinner , formatUrl , note , pc } from './output.ts' ;
17+ import { printSuccess , formatUrl , note , pc } from './output.ts' ;
1818import { activatePlatformAccessCredentials } from './platform-access-setup.ts' ;
1919import { turnOffInstalledProjectZeroTrust } from './platform-app-access.ts' ;
2020import type { PlatformArgs } from './platform-args.ts' ;
@@ -72,6 +72,7 @@ import {
7272 resourceMarkerProblem ,
7373 revalidatePlatformInstallAction ,
7474} from './platform-plan.ts' ;
75+ import { createPlatformProgress , withPlatformProgress } from './platform-progress.ts' ;
7576import {
7677 acquirePlatformLifecycleLock ,
7778 listInstallationManifests ,
@@ -280,6 +281,7 @@ export async function runInstalledPlatformCommand(args: PlatformArgs): Promise<v
280281 throw new Error ( `platform: Unsupported lifecycle command ${ args . subcommand } .` ) ;
281282 }
282283 assertNoninteractivePlatformMutationAcknowledged ( args , process . stdin . isTTY === true ) ;
284+ log . step ( `Preparing platform ${ args . subcommand } ` ) ;
283285 const timingStart = performance . now ( ) ;
284286 let timingPrevious = timingStart ;
285287 const markPhase = ( phase : string ) => {
@@ -297,25 +299,27 @@ export async function runInstalledPlatformCommand(args: PlatformArgs): Promise<v
297299 savedManagementToken : readInstallationRecoverySecrets ( manifest ) ?. managementApiToken ,
298300 } ) ;
299301 const operatorClient = new PlatformCloudflareClient ( operatorCredential . token ) ;
300- await verifyPlatformCloudflareCredential ( operatorClient , {
301- account : manifest . account ,
302- source : operatorCredential . source ,
303- r2Buckets :
304- args . subcommand === 'disable' || args . subcommand === 'uninstall'
305- ? [ ]
306- : manifest . resources
307- . filter ( ( resource ) => resource . kind === 'r2-bucket' )
308- . map ( ( resource ) => resource . name ) ,
309- allowMissingR2Buckets : args . subcommand === 'repair' ,
310- } ) ;
302+ await withPlatformProgress ( 'Checking Cloudflare access' , ( ) =>
303+ verifyPlatformCloudflareCredential ( operatorClient , {
304+ account : manifest . account ,
305+ source : operatorCredential . source ,
306+ r2Buckets :
307+ args . subcommand === 'disable' || args . subcommand === 'uninstall'
308+ ? [ ]
309+ : manifest . resources
310+ . filter ( ( resource ) => resource . kind === 'r2-bucket' )
311+ . map ( ( resource ) => resource . name ) ,
312+ allowMissingR2Buckets : args . subcommand === 'repair' ,
313+ } ) ,
314+ ) ;
311315 markPhase ( 'operator credential' ) ;
312316 const runtime =
313317 args . subcommand === 'uninstall' || args . subcommand === 'disable'
314318 ? null
315319 : loadPlatformRuntime ( args . runtime ) ;
316320 const rollbackSourceRuntime =
317321 args . subcommand === 'rollback' ? loadPlatformRuntime ( args . fromRuntime ) : null ;
318- let progress : ReturnType < typeof createSpinner > | undefined ;
322+ let progress : ReturnType < typeof createPlatformProgress > | undefined ;
319323 let reportResult : ( ( ) => void ) | undefined ;
320324
321325 const execute = async (
@@ -447,15 +451,17 @@ export async function runInstalledPlatformCommand(args: PlatformArgs): Promise<v
447451 installationSlug : deployment . installationSlug ,
448452 zoneName : deployment . application . zoneName ,
449453 } ;
450- const plan = await createPlatformInstallPlan ( client , planInput , manifest , {
451- authoritativeProvisionIntents : databaseCheckpointExists ,
452- repairMissing : args . subcommand === 'repair' ,
453- allowUnverifiedAiGateway : args . plan ,
454- includeEmailGateway : runtime ! . manifest . artifacts . emailGateway !== undefined ,
455- enableSandbox : runtime ! . manifest . safetyProtocols . sandboxDrain >= 3 ,
456- deploymentExecution : runtime ! . manifest . deploymentExecution === 1 ,
457- allowRuntimeLogsChange : args . subcommand === 'upgrade' ,
458- } ) ;
454+ const plan = await withPlatformProgress ( `Preparing ${ args . subcommand } plan` , ( ) =>
455+ createPlatformInstallPlan ( client , planInput , manifest , {
456+ authoritativeProvisionIntents : databaseCheckpointExists ,
457+ repairMissing : args . subcommand === 'repair' ,
458+ allowUnverifiedAiGateway : args . plan ,
459+ includeEmailGateway : runtime ! . manifest . artifacts . emailGateway !== undefined ,
460+ enableSandbox : runtime ! . manifest . safetyProtocols . sandboxDrain >= 3 ,
461+ deploymentExecution : runtime ! . manifest . deploymentExecution === 1 ,
462+ allowRuntimeLogsChange : args . subcommand === 'upgrade' ,
463+ } ) ,
464+ ) ;
459465 assertPlatformRuntimeLogsSupported ( plan . deployment , runtime ! . manifest ) ;
460466 markPhase ( 'plan' ) ;
461467 note (
@@ -669,14 +675,7 @@ export async function runInstalledPlatformCommand(args: PlatformArgs): Promise<v
669675 command : platformLifecycleResumeCommand ( { ...args , yes : false } , manifest . id ) ,
670676 } ) ;
671677 markPhase ( 'outside changes' ) ;
672- progress = createSpinner ( {
673- // Preserve the subprocess signal coordinator used by platform installs.
674- onCancel : ( ) => {
675- if ( ! process . emit ( 'SIGINT' ) ) {
676- process . exit ( 130 ) ;
677- }
678- } ,
679- } ) ;
678+ progress = createPlatformProgress ( ) ;
680679 progress . start (
681680 args . subcommand === 'upgrade'
682681 ? 'Upgrading the platform'
@@ -863,10 +862,8 @@ export async function runInstalledPlatformCommand(args: PlatformArgs): Promise<v
863862 'platform: DATABASE_URL is required to safely serialize lifecycle changes across hosts.' ,
864863 ) ;
865864 }
866- const releaseDatabase = await acquirePlatformDatabaseLifecycleLock (
867- databaseUrl ,
868- current . id ,
869- current . ownershipNonce ,
865+ const releaseDatabase = await withPlatformProgress ( 'Reading platform state' , ( ) =>
866+ acquirePlatformDatabaseLifecycleLock ( databaseUrl , current . id , current . ownershipNonce ) ,
870867 ) ;
871868 markPhase ( 'database lock' ) ;
872869 try {
@@ -1077,7 +1074,9 @@ export async function disablePlatform(
10771074 planOnly : boolean ,
10781075 dependencies : PlatformManagementDependencies = { } ,
10791076) : Promise < void > {
1080- const manifest = await recoverDurablyMarkedProvisionIntents ( client , initialManifest ) ;
1077+ const manifest = await withPlatformProgress ( 'Reading platform resources' , ( ) =>
1078+ recoverDurablyMarkedProvisionIntents ( client , initialManifest ) ,
1079+ ) ;
10811080 const saveCheckpoint = ( state : PlatformInstallationManifest ) =>
10821081 writeLifecycleCheckpoint ( client , state , dependencies . checkpoint ) ;
10831082 const saveRemoteManifest = ( state : PlatformInstallationManifest ) =>
@@ -1144,7 +1143,9 @@ export async function uninstallPlatform(
11441143 args : Extract < PlatformArgs , { subcommand : 'uninstall' } > ,
11451144 dependencies : PlatformManagementDependencies = { } ,
11461145) : Promise < void > {
1147- const manifest = await recoverDurablyMarkedProvisionIntents ( client , initialManifest ) ;
1146+ const manifest = await withPlatformProgress ( 'Reading platform resources' , ( ) =>
1147+ recoverDurablyMarkedProvisionIntents ( client , initialManifest ) ,
1148+ ) ;
11481149 const saveCheckpoint = ( state : PlatformInstallationManifest ) =>
11491150 writeLifecycleCheckpoint ( client , state , dependencies . checkpoint ) ;
11501151 const saveRemoteManifest = ( state : PlatformInstallationManifest ) =>
@@ -1161,11 +1162,15 @@ export async function uninstallPlatform(
11611162 const hasRoutingCheckpoint = routingKv ?. state === 'ready' || reopenedRouting ;
11621163 const interactive = dependencies . interactive ?? process . stdin . isTTY ;
11631164 const confirmAction = dependencies . confirm ?? promptForConfirmation ;
1164- const zeroTrust = await assertProjectZeroTrustAllowsUninstall ( dependencies . readProjectZeroTrust , {
1165- canTurnOff : ! ! dependencies . turnOffProjectZeroTrust ,
1166- } ) ;
1165+ const zeroTrust = await withPlatformProgress ( 'Checking project access' , ( ) =>
1166+ assertProjectZeroTrustAllowsUninstall ( dependencies . readProjectZeroTrust , {
1167+ canTurnOff : ! ! dependencies . turnOffProjectZeroTrust ,
1168+ } ) ,
1169+ ) ;
11671170 if ( purgeResources ) {
1168- await assertNoPlatformProjects ( dependencies . readProjects ) ;
1171+ await withPlatformProgress ( 'Checking platform projects' , ( ) =>
1172+ assertNoPlatformProjects ( dependencies . readProjects ) ,
1173+ ) ;
11691174 }
11701175 if ( args . plan || ( interactive && ! args . yes ) ) {
11711176 note (
0 commit comments