0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/create-astro/src/config.ts
Juan Martín Seery 1fdb63b5d0
feat(create-astro): add peer dependencies to package.json (#2843)
* Install dependencies automatically

* Added spinners

* Updated lockfile

* changeset

* Sort dependencies

* Reverted autoinstall

* Updated changeset
2022-03-21 12:33:31 -05:00

23 lines
700 B
TypeScript

import type { Integration } from './frameworks';
export const createConfig = ({ integrations }: { integrations: Integration[] }) => {
if (integrations.length === 0) {
return `import { defineConfig } from 'astro/config';
// https://astro.build/config
export default defineConfig({});
`;
}
const rendererImports = integrations.map((r) => ` import ${r.id} from '${r.packageName}';`);
const rendererIntegrations = integrations.map((r) => ` ${r.id}(),`);
return [
`import { defineConfig } from 'astro/config';`,
...rendererImports,
`// https://astro.build/config`,
`export default defineConfig({`,
` integrations: [`,
...rendererIntegrations,
` ]`,
`});`,
].join('\n');
};