mirror of
https://github.com/withastro/astro.git
synced 2025-03-31 23:31:30 -05:00
Change way args are passed to cli packages (#9774)
This commit is contained in:
parent
eed0e8757c
commit
6c5f42d308
1 changed files with 12 additions and 4 deletions
|
@ -1,11 +1,17 @@
|
|||
import type { Arguments } from 'yargs-parser';
|
||||
import { createLoggerFromFlags } from '../flags.js';
|
||||
import { createLoggerFromFlags, flagsToAstroInlineConfig } from '../flags.js';
|
||||
import { getPackage } from '../install-package.js';
|
||||
import { resolveConfig } from '../../core/config/config.js';
|
||||
import type { AstroConfig } from '../../@types/astro.js';
|
||||
|
||||
type DBPackage = {
|
||||
cli: (args: { flags: Arguments, config: AstroConfig }) => unknown;
|
||||
};
|
||||
|
||||
export async function db({ flags }: { flags: Arguments }) {
|
||||
const logger = createLoggerFromFlags(flags);
|
||||
const getPackageOpts = { skipAsk: flags.yes || flags.y, cwd: flags.root };
|
||||
const dbPackage = await getPackage<any>('@astrojs/db', logger, getPackageOpts, []);
|
||||
const dbPackage = await getPackage<DBPackage>('@astrojs/db', logger, getPackageOpts, []);
|
||||
|
||||
if (!dbPackage) {
|
||||
logger.error(
|
||||
|
@ -17,6 +23,8 @@ export async function db({ flags }: { flags: Arguments }) {
|
|||
|
||||
const { cli } = dbPackage;
|
||||
|
||||
const [command, ...args] = flags._.slice(3).map((v) => v.toString());
|
||||
await cli(command, args);
|
||||
const inlineConfig = flagsToAstroInlineConfig(flags);
|
||||
const { astroConfig } = await resolveConfig(inlineConfig, 'build');
|
||||
|
||||
await cli({flags, config: astroConfig});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue