Skip to content

Commit

Permalink
fix: exclude tailwind package when installing integration (#13106)
Browse files Browse the repository at this point in the history
* fix: exclude tailwind package when installing integration

* Update .changeset/green-sloths-switch.md

---------

Co-authored-by: Florian Lefebvre <[email protected]>
  • Loading branch information
ascorbic and florian-lefebvre authored Jan 31, 2025
1 parent 3b10b97 commit 187c4d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-sloths-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes a bug that caused peer dependency errors when running `astro add tailwind`
22 changes: 15 additions & 7 deletions packages/astro/src/cli/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface AddOptions {
interface IntegrationInfo {
id: string;
packageName: string;
integrationName: string;
dependencies: [name: string, version: string][];
type: 'integration' | 'adapter';
}
Expand Down Expand Up @@ -283,7 +284,7 @@ export async function add(names: string[], { flags }: AddOptions) {
'SKIP_FORMAT',
`\n ${magenta(
`Check our deployment docs for ${bold(
integration.packageName,
integration.integrationName,
)} to update your "adapter" config.`,
)}`,
);
Expand Down Expand Up @@ -349,7 +350,9 @@ export async function add(names: string[], { flags }: AddOptions) {
case UpdateResult.failure:
case UpdateResult.updated:
case undefined: {
const list = integrations.map((integration) => ` - ${integration.packageName}`).join('\n');
const list = integrations
.map((integration) => ` - ${integration.integrationName}`)
.join('\n');
logger.info(
'SKIP_FORMAT',
msg.success(
Expand Down Expand Up @@ -618,8 +621,7 @@ async function convertIntegrationsToInstallSpecifiers(
integrations: IntegrationInfo[],
): Promise<string[]> {
const ranges: Record<string, string> = {};
for (let { packageName, dependencies } of integrations) {
ranges[packageName] = '*';
for (let { dependencies } of integrations) {
for (const [name, range] of dependencies) {
ranges[name] = range;
}
Expand Down Expand Up @@ -790,7 +792,7 @@ async function validateIntegrations(integrations: string[]): Promise<Integration

const resolvedScope = pkgType === 'first-party' ? '@astrojs' : scope;
const packageName = `${resolvedScope ? `${resolvedScope}/` : ''}${name}`;

let integrationName = packageName;
let dependencies: IntegrationInfo['dependencies'] = [
[pkgJson['name'], `^${pkgJson['version']}`],
];
Expand Down Expand Up @@ -823,13 +825,19 @@ async function validateIntegrations(integrations: string[]): Promise<Integration
}

if (integration === 'tailwind') {
integrationName = 'tailwind';
dependencies = [
['@tailwindcss/vite', '^4.0.0'],
['tailwindcss', '^4.0.0'],
];
}

return { id: integration, packageName, dependencies, type: integrationType };
return {
id: integration,
packageName,
dependencies,
type: integrationType,
integrationName,
};
}),
);
spinner.success();
Expand Down

0 comments on commit 187c4d3

Please sign in to comment.