mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
Support new CLI command structure
This commit is contained in:
parent
b90d7d1869
commit
c6183140f2
3 changed files with 19 additions and 7 deletions
|
@ -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;
|
||||
|
|
|
@ -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`;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue