diff --git a/examples/with-tailwindcss/tailwind.config.cjs b/examples/with-tailwindcss/tailwind.config.cjs index 81cb91aee..2282e757d 100644 --- a/examples/with-tailwindcss/tailwind.config.cjs +++ b/examples/with-tailwindcss/tailwind.config.cjs @@ -4,4 +4,4 @@ module.exports = { extend: {}, }, plugins: [], -} +}; diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts index fa6fc7547..4108d4984 100644 --- a/packages/astro/src/cli/index.ts +++ b/packages/astro/src/cli/index.ts @@ -108,14 +108,14 @@ export async function cli(args: string[]) { switch (cmd) { case 'add': { - try { - const packages = flags._.slice(3) as string[]; - await add(packages, { cwd: projectRoot, flags, logging }); - process.exit(0); - } catch (err) { - throwAndExit(err); - } - return; + try { + const packages = flags._.slice(3) as string[]; + await add(packages, { cwd: projectRoot, flags, logging }); + process.exit(0); + } catch (err) { + throwAndExit(err); + } + return; } case 'dev': { try { diff --git a/packages/astro/src/core/add/index.ts b/packages/astro/src/core/add/index.ts index 4175cbf2f..042695071 100644 --- a/packages/astro/src/core/add/index.ts +++ b/packages/astro/src/core/add/index.ts @@ -126,7 +126,7 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO configResult = await updateAstroConfig({ configURL, ast, flags, logging }); } catch (err) { debug('add', 'Error updating astro config', err); - throw createPrettyError(err as Error); + throw createPrettyError(err as Error); } } @@ -138,9 +138,9 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO case UpdateResult.none: { const pkgURL = new URL('./package.json', configURL); if (existsSync(fileURLToPath(pkgURL))) { - const { dependencies = {}, devDependencies = {} } = await fs.readFile(fileURLToPath(pkgURL)).then(res => JSON.parse(res.toString())); + const { dependencies = {}, devDependencies = {} } = await fs.readFile(fileURLToPath(pkgURL)).then((res) => JSON.parse(res.toString())); const deps = Object.keys(Object.assign(dependencies, devDependencies)); - const missingDeps = integrations.filter(integration => !deps.includes(integration.packageName)); + const missingDeps = integrations.filter((integration) => !deps.includes(integration.packageName)); if (missingDeps.length === 0) { info(logging, null, msg.success(`Configuration up-to-date.`)); return; @@ -158,7 +158,7 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO case UpdateResult.updated: { const len = integrations.length; if (integrations.find((integration) => integration.id === 'tailwind')) { - const possibleConfigFiles = ['./tailwind.config.cjs', './tailwind.config.mjs', './tailwind.config.js'].map(p => fileURLToPath(new URL(p, configURL))); + const possibleConfigFiles = ['./tailwind.config.cjs', './tailwind.config.mjs', './tailwind.config.js'].map((p) => fileURLToPath(new URL(p, configURL))); let alreadyConfigured = false; for (const possibleConfigPath of possibleConfigFiles) { if (existsSync(possibleConfigPath)) { @@ -176,7 +176,7 @@ export default async function add(names: string[], { cwd, flags, logging }: AddO debug('add', `Using existing Tailwind configuration`); } } - const list = integrations.map(integration => ` - ${integration.packageName}`).join('\n') + const list = integrations.map((integration) => ` - ${integration.packageName}`).join('\n'); info(logging, null, msg.success(`Added the following integration${len === 1 ? '' : 's'} to your project:\n${list}`)); return; } @@ -208,12 +208,12 @@ const toIdent = (name: string) => { }; function createPrettyError(err: Error) { - err.message = `Astro could not update your astro.config.js file safely. + err.message = `Astro could not update your astro.config.js file safely. Reason: ${err.message} You will need to add these integration(s) manually. -Documentation: https://next--astro-docs-2.netlify.app/en/guides/integrations-guide/` - return err; +Documentation: https://next--astro-docs-2.netlify.app/en/guides/integrations-guide/`; + return err; } async function addIntegration(ast: t.File, integration: IntegrationInfo) { @@ -281,10 +281,7 @@ async function updateAstroConfig({ configURL, ast, flags, logging }: { configURL let changes = []; for (const change of diffWords(input, output)) { - let lines = change.value - .trim() - .split('\n') - .slice(0, change.count) + let lines = change.value.trim().split('\n').slice(0, change.count); if (lines.length === 0) continue; if (change.added) { if (!change.value.trim()) continue; @@ -366,11 +363,7 @@ async function tryToInstallIntegrations({ } else { const coloredOutput = `${bold(installCommand.pm)} ${installCommand.command} ${installCommand.flags.join(' ')} ${cyan(installCommand.dependencies.join(' '))}`; const message = `\n${boxen(coloredOutput, { margin: 0.5, padding: 0.5, borderStyle: 'round' })}\n`; - info( - logging, - null, - `\n ${magenta('Astro will run the following command:')}\n ${dim('If you skip this step, you can always run it yourself later')}\n${message}` - ); + info(logging, null, `\n ${magenta('Astro will run the following command:')}\n ${dim('If you skip this step, you can always run it yourself later')}\n${message}`); if (await askToContinue({ flags })) { const spinner = ora('Installing dependencies...').start(); diff --git a/packages/astro/src/core/config.ts b/packages/astro/src/core/config.ts index 7bc121963..85f082274 100644 --- a/packages/astro/src/core/config.ts +++ b/packages/astro/src/core/config.ts @@ -265,11 +265,11 @@ interface LoadConfigOptions { flags?: Flags; } -/** - * Resolve the file URL of the user's `astro.config.js|cjs|mjs|ts` file - * Note: currently the same as loadConfig but only returns the `filePath` - * instead of the resolved config - */ +/** + * Resolve the file URL of the user's `astro.config.js|cjs|mjs|ts` file + * Note: currently the same as loadConfig but only returns the `filePath` + * instead of the resolved config + */ export async function resolveConfigURL(configOptions: LoadConfigOptions): Promise { const root = configOptions.cwd ? path.resolve(configOptions.cwd) : process.cwd(); const flags = resolveFlags(configOptions.flags || {});