From d08094a98277c52035b3ae709c84434bdfe7482a Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 14 Dec 2023 08:36:57 +0100 Subject: [PATCH] fix: cli uses await for every push call --- cli/sync.ts | 28 +++++++++++++++++++++------- cli/types.ts | 25 ++++++++++++++++--------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/cli/sync.ts b/cli/sync.ts index db06cbb58f..0ce6df44de 100644 --- a/cli/sync.ts +++ b/cli/sync.ts @@ -671,6 +671,7 @@ async function push( log.info( `remote (${workspace.name}) <- local: ${changes.length} changes to apply` ); + if (changes.length > 0) { prettyChanges(changes); if ( @@ -706,7 +707,12 @@ async function push( } continue; } else if ( - await handleFile(change.path, workspace.workspaceId, alreadySynced, opts.message) + await handleFile( + change.path, + workspace.workspaceId, + alreadySynced, + opts.message + ) ) { if (!opts.raw && stateExists) { await Deno.writeTextFile(stateTarget, change.after); @@ -720,14 +726,14 @@ async function push( const oldObj = parseFromPath(change.path, change.before); const newObj = parseFromPath(change.path, change.after); - pushObj( + await pushObj( workspace.workspaceId, change.path, oldObj, newObj, opts.plainSecrets ?? false, opts.raw, - opts.message, + opts.message ); if (!opts.raw && stateExists) { @@ -740,7 +746,12 @@ async function push( ) { continue; } else if ( - await handleFile(change.path, workspace.workspaceId, alreadySynced, opts.message) + await handleFile( + change.path, + workspace.workspaceId, + alreadySynced, + opts.message + ) ) { continue; } @@ -749,14 +760,14 @@ async function push( log.info(`Adding ${getTypeStrFromPath(change.path)} ${change.path}`); } const obj = parseFromPath(change.path, change.content); - pushObj( + await pushObj( workspace.workspaceId, change.path, undefined, obj, opts.plainSecrets ?? false, opts.raw, - opts.message, + opts.message ); if (!opts.raw && stateExists) { @@ -884,7 +895,10 @@ const command = new Command() .option("--skip-secrets", "Skip syncing only secrets variables") .option("--skip-resources", "Skip syncing resources") .option("--include-schedules", "Include syncing schedules") - .option("--message ", "Include a message that will be added to all scripts/flows/apps updated during this push") + .option( + "--message ", + "Include a message that will be added to all scripts/flows/apps updated during this push" + ) // deno-lint-ignore no-explicit-any .action(push as any); diff --git a/cli/types.ts b/cli/types.ts index 1d07f235d9..0d2d2ee324 100644 --- a/cli/types.ts +++ b/cli/types.ts @@ -93,32 +93,39 @@ export function showConflict(path: string, local: string, remote: string) { log.info("\n"); } -export function pushObj( +export async function pushObj( workspace: string, p: string, befObj: any, newObj: any, plainSecrets: boolean, checkForCreate: boolean, - message?: string, + message?: string ) { const typeEnding = getTypeStrFromPath(p); if (typeEnding === "app") { - pushApp(workspace, p, befObj, newObj, checkForCreate, message); + await pushApp(workspace, p, befObj, newObj, checkForCreate, message); } else if (typeEnding === "folder") { - pushFolder(workspace, p, befObj, newObj, checkForCreate); + await pushFolder(workspace, p, befObj, newObj, checkForCreate); } else if (typeEnding === "variable") { - pushVariable(workspace, p, befObj, newObj, plainSecrets, checkForCreate); + await pushVariable( + workspace, + p, + befObj, + newObj, + plainSecrets, + checkForCreate + ); } else if (typeEnding === "flow") { const flowName = p.split(".flow/")[0]; - pushFlow(workspace, flowName, flowName + ".flow", message); + await pushFlow(workspace, flowName, flowName + ".flow", message); } else if (typeEnding === "resource") { - pushResource(workspace, p, befObj, newObj, checkForCreate); + await pushResource(workspace, p, befObj, newObj, checkForCreate); } else if (typeEnding === "resource-type") { - pushResourceType(workspace, p, befObj, newObj, checkForCreate); + await pushResourceType(workspace, p, befObj, newObj, checkForCreate); } else if (typeEnding === "schedule") { - pushSchedule(workspace, p, befObj, newObj, checkForCreate); + await pushSchedule(workspace, p, befObj, newObj, checkForCreate); } else { throw new Error("infer type unreachable"); }