0
Fork 0
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:
Matthew Phillips 2024-01-22 18:32:50 -05:00 committed by GitHub
parent eed0e8757c
commit 6c5f42d308
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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});
}