diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts index 77169f3806..3978d9feac 100644 --- a/packages/astro/src/cli/index.ts +++ b/packages/astro/src/cli/index.ts @@ -76,6 +76,10 @@ function resolveCommand(flags: yargs.Arguments): CLICommand { 'docs', 'db', 'info', + 'login', + 'loutout', + 'link', + 'init', ]); if (supportedCommands.has(cmd)) { return cmd as CLICommand; @@ -146,7 +150,11 @@ async function runCommand(cmd: string, flags: yargs.Arguments) { await add(packages, { flags }); return; } - case 'db': { + case 'db': + case 'login': + case 'logout': + case 'link': + case 'init': { const { db } = await import('./db/index.js'); await db({ flags }); return; diff --git a/packages/db/src/core/cli/commands/sync/index.ts b/packages/db/src/core/cli/commands/gen/index.ts similarity index 100% rename from packages/db/src/core/cli/commands/sync/index.ts rename to packages/db/src/core/cli/commands/gen/index.ts diff --git a/packages/db/src/core/cli/index.ts b/packages/db/src/core/cli/index.ts index 77eb364c2d..56a5667a67 100644 --- a/packages/db/src/core/cli/index.ts +++ b/packages/db/src/core/cli/index.ts @@ -3,7 +3,10 @@ import type { Arguments } from 'yargs-parser'; import { STUDIO_CONFIG_MISSING_CLI_ERROR } from '../errors.js'; export async function cli({ flags, config }: { flags: Arguments; config: AstroConfig }) { - const command = flags._[3] as string; + const args = flags._ as string[]; + // Most commands are `astro db foo`, but for now login/logout + // are also handled by this package, so first check if this is a db command. + const command = args[2] === 'db' ? args[3] : args[2]; if (!config.db?.studio) { console.log(STUDIO_CONFIG_MISSING_CLI_ERROR); @@ -15,8 +18,9 @@ export async function cli({ flags, config }: { flags: Arguments; config: AstroCo const { cmd } = await import('./commands/shell/index.js'); return await cmd({ config, flags }); } + case 'gen': case 'sync': { - const { cmd } = await import('./commands/sync/index.js'); + const { cmd } = await import('./commands/gen/index.js'); return await cmd({ config, flags }); } case 'push': { @@ -58,11 +62,11 @@ ${showHelp()}`); Usage: -astro db login Authenticate your machine with Astro Studio -astro db logout End your authenticated session with Astro Studio -astro db link Link this directory to an Astro Studio project +astro login Authenticate your machine with Astro Studio +astro logout End your authenticated session with Astro Studio +astro link Link this directory to an Astro Studio project -astro db sync Creates snapshot based on your schema +astro db gen Creates snapshot based on your schema astro db push Pushes migrations to Astro Studio astro db verify Verifies migrations have been pushed and errors if not`; }