Skip to content

Commit 187c4d3

Browse files
fix: exclude tailwind package when installing integration (#13106)
* fix: exclude tailwind package when installing integration * Update .changeset/green-sloths-switch.md --------- Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
1 parent 3b10b97 commit 187c4d3

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

.changeset/green-sloths-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes a bug that caused peer dependency errors when running `astro add tailwind`

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface AddOptions {
4040
interface IntegrationInfo {
4141
id: string;
4242
packageName: string;
43+
integrationName: string;
4344
dependencies: [name: string, version: string][];
4445
type: 'integration' | 'adapter';
4546
}
@@ -283,7 +284,7 @@ export async function add(names: string[], { flags }: AddOptions) {
283284
'SKIP_FORMAT',
284285
`\n ${magenta(
285286
`Check our deployment docs for ${bold(
286-
integration.packageName,
287+
integration.integrationName,
287288
)} to update your "adapter" config.`,
288289
)}`,
289290
);
@@ -349,7 +350,9 @@ export async function add(names: string[], { flags }: AddOptions) {
349350
case UpdateResult.failure:
350351
case UpdateResult.updated:
351352
case undefined: {
352-
const list = integrations.map((integration) => ` - ${integration.packageName}`).join('\n');
353+
const list = integrations
354+
.map((integration) => ` - ${integration.integrationName}`)
355+
.join('\n');
353356
logger.info(
354357
'SKIP_FORMAT',
355358
msg.success(
@@ -618,8 +621,7 @@ async function convertIntegrationsToInstallSpecifiers(
618621
integrations: IntegrationInfo[],
619622
): Promise<string[]> {
620623
const ranges: Record<string, string> = {};
621-
for (let { packageName, dependencies } of integrations) {
622-
ranges[packageName] = '*';
624+
for (let { dependencies } of integrations) {
623625
for (const [name, range] of dependencies) {
624626
ranges[name] = range;
625627
}
@@ -790,7 +792,7 @@ async function validateIntegrations(integrations: string[]): Promise<Integration
790792

791793
const resolvedScope = pkgType === 'first-party' ? '@astrojs' : scope;
792794
const packageName = `${resolvedScope ? `${resolvedScope}/` : ''}${name}`;
793-
795+
let integrationName = packageName;
794796
let dependencies: IntegrationInfo['dependencies'] = [
795797
[pkgJson['name'], `^${pkgJson['version']}`],
796798
];
@@ -823,13 +825,19 @@ async function validateIntegrations(integrations: string[]): Promise<Integration
823825
}
824826

825827
if (integration === 'tailwind') {
828+
integrationName = 'tailwind';
826829
dependencies = [
827830
['@tailwindcss/vite', '^4.0.0'],
828831
['tailwindcss', '^4.0.0'],
829832
];
830833
}
831-
832-
return { id: integration, packageName, dependencies, type: integrationType };
834+
return {
835+
id: integration,
836+
packageName,
837+
dependencies,
838+
type: integrationType,
839+
integrationName,
840+
};
833841
}),
834842
);
835843
spinner.success();

0 commit comments

Comments
 (0)