()
| 348 | } |
| 349 | |
| 350 | async function main() { |
| 351 | try { |
| 352 | const whoamiOutput = executeCommand("wrangler whoami"); |
| 353 | if (whoamiOutput === undefined || typeof whoamiOutput !== "string") { |
| 354 | console.error( |
| 355 | "\x1b[31mError running wrangler whoami. Please run `wrangler login`.\x1b[0m", |
| 356 | ); |
| 357 | cancel("Operation cancelled."); |
| 358 | process.exit(1); |
| 359 | } |
| 360 | |
| 361 | try { |
| 362 | await createDatabaseAndConfigure(); |
| 363 | } catch (error) { |
| 364 | console.error("\x1b[31mError:", error, "\x1b[0m"); |
| 365 | const accountIds = extractAccountDetails(whoamiOutput); |
| 366 | const accountId = await promptForAccountId(accountIds); |
| 367 | setEnvironmentVariable("CLOUDFLARE_ACCOUNT_ID", accountId); |
| 368 | cancel("Operation cancelled."); |
| 369 | process.exit(1); |
| 370 | } |
| 371 | |
| 372 | try { |
| 373 | await createPagesProject(); |
| 374 | } catch (error) { |
| 375 | console.error("\x1b[31mError:", error, "\x1b[0m"); |
| 376 | cancel("Operation cancelled."); |
| 377 | process.exit(1); |
| 378 | } |
| 379 | |
| 380 | // try { |
| 381 | // await createBucketR2(); |
| 382 | // } catch (error) { |
| 383 | // console.error("\x1b[31mError:", error, "\x1b[0m"); |
| 384 | // cancel("Operation cancelled."); |
| 385 | // process.exit(1); |
| 386 | // } |
| 387 | |
| 388 | await promptForGoogleClientCredentials(); |
| 389 | console.log("\x1b[33mReady... Set... Launch\x1b[0m"); |
| 390 | await updateDevVarsWithSecret(); |
| 391 | await runDatabaseMigrations(dbName); |
| 392 | |
| 393 | console.log("\x1b[33mRunning bun run dev command...\x1b[0m"); |
| 394 | spawnSync("bun", ["run", "dev"], { stdio: "inherit" }); |
| 395 | } catch (error) { |
| 396 | console.error("\x1b[31mError:", error, "\x1b[0m"); |
| 397 | cancel("Operation cancelled."); |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | main(); |
no test coverage detected