Skip to content

Commit 565583b

Browse files
authoredMar 14, 2025··
fix: respect --yes flag for third-party integrations (#13426)
1 parent 51d2a1a commit 565583b

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed
 

‎.changeset/ten-tips-share.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes a bug that caused the `astro add` command to ignore the `--yes` flag for third-party integrations

‎packages/astro/src/cli/add/index.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { eventCliSession, telemetry } from '../../events/index.js';
3232
import { exec } from '../exec.js';
3333
import { type Flags, createLoggerFromFlags, flagsToAstroInlineConfig } from '../flags.js';
3434
import { fetchPackageJson, fetchPackageVersions } from '../install-package.js';
35+
import type yargsParser from 'yargs-parser';
3536

3637
interface AddOptions {
3738
flags: Flags;
@@ -138,7 +139,7 @@ export async function add(names: string[], { flags }: AddOptions) {
138139
const cwd = inlineConfig.root;
139140
const logger = createLoggerFromFlags(flags);
140141
const integrationNames = names.map((name) => (ALIASES.has(name) ? ALIASES.get(name)! : name));
141-
const integrations = await validateIntegrations(integrationNames);
142+
const integrations = await validateIntegrations(integrationNames, flags);
142143
let installResult = await tryToInstallIntegrations({ integrations, cwd, flags, logger });
143144
const rootPath = resolveRoot(cwd);
144145
const root = pathToFileURL(rootPath);
@@ -713,7 +714,10 @@ async function tryToInstallIntegrations({
713714
}
714715
}
715716

716-
async function validateIntegrations(integrations: string[]): Promise<IntegrationInfo[]> {
717+
async function validateIntegrations(
718+
integrations: string[],
719+
flags: yargsParser.Arguments,
720+
): Promise<IntegrationInfo[]> {
717721
const spinner = yoctoSpinner({ text: 'Resolving packages...' }).start();
718722
try {
719723
const integrationEntries = await Promise.all(
@@ -735,13 +739,7 @@ async function validateIntegrations(integrations: string[]): Promise<Integration
735739
spinner.warning(yellow(firstPartyPkgCheck.message));
736740
}
737741
spinner.warning(yellow(`${bold(integration)} is not an official Astro package.`));
738-
const response = await prompts({
739-
type: 'confirm',
740-
name: 'askToContinue',
741-
message: 'Continue?',
742-
initial: true,
743-
});
744-
if (!response.askToContinue) {
742+
if (!(await askToContinue({ flags }))) {
745743
throw new Error(
746744
`No problem! Find our official integrations at ${cyan(
747745
'https://astro.build/integrations',

0 commit comments

Comments
 (0)
Please sign in to comment.