From 8c6f782071c5f75acbb6352bbb976d101c7c85ff Mon Sep 17 00:00:00 2001 From: Aaron Sterren Date: Tue, 9 Sep 2025 10:49:39 -0500 Subject: [PATCH] fix: Add yes flag --- structures-js/structures-cli/src/commands/synchronize.ts | 3 ++- structures-js/structures-cli/src/internal/Utils.ts | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/structures-js/structures-cli/src/commands/synchronize.ts b/structures-js/structures-cli/src/commands/synchronize.ts index caa5b8aa2..27ce118cb 100644 --- a/structures-js/structures-cli/src/commands/synchronize.ts +++ b/structures-js/structures-cli/src/commands/synchronize.ts @@ -28,6 +28,7 @@ export class Synchronize extends Command { server: Flags.string({char: 's', description: 'The structures server to connect to'}), publish: Flags.boolean({char: 'p', description: 'Publish each Entity after save/update'}), verbose: Flags.boolean({char: 'v', description: 'Enable verbose logging'}), + yes: Flags.boolean({description: 'Automatically confirm opening the browser'}), dryRun: Flags.boolean({description: 'Dry run enables verbose logging and does not save any changes to the server'}) } @@ -54,7 +55,7 @@ export class Synchronize extends Command { serverUrl = serverConfig.url } - if (flags.dryRun || await connectAndUpgradeSession(serverUrl, this)) { + if (flags.dryRun || await connectAndUpgradeSession(serverUrl, this, flags.yes)) { try { if(!flags.dryRun) { diff --git a/structures-js/structures-cli/src/internal/Utils.ts b/structures-js/structures-cli/src/internal/Utils.ts index dafe975bf..443f3cd86 100644 --- a/structures-js/structures-cli/src/internal/Utils.ts +++ b/structures-js/structures-cli/src/internal/Utils.ts @@ -57,9 +57,10 @@ export function jsonStringifyReplacer(key: any, value: any) { * This will be replaced when the server supports a session upgrade command * @param server the server to connect to * @param logger the logger to use + * @param autoConfirm allow the user to skip the browser confirmation * @return true if the session was upgraded successfully */ -export async function connectAndUpgradeSession(server: string, logger: Logger): Promise{ +export async function connectAndUpgradeSession(server: string, logger: Logger, autoConfirm?: boolean): Promise{ try { const serverURL: URL = new URL(server) @@ -100,7 +101,7 @@ export async function connectAndUpgradeSession(server: string, logger: Logger): logger.log('Authenticate your account at:') logger.log(url) - const answer = await confirm({ + const answer = autoConfirm ?? await confirm({ message: 'Open in browser?', default: true, })