From d271756e89bfdaed027fca67048dd94232fdace0 Mon Sep 17 00:00:00 2001 From: matthewp Date: Mon, 23 Jan 2023 14:49:20 +0000 Subject: [PATCH] [ci] format --- packages/integrations/netlify/src/shared.ts | 57 ++++++++++++--------- packages/integrations/tailwind/src/index.ts | 2 +- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/packages/integrations/netlify/src/shared.ts b/packages/integrations/netlify/src/shared.ts index c87d946f5..59354b156 100644 --- a/packages/integrations/netlify/src/shared.ts +++ b/packages/integrations/netlify/src/shared.ts @@ -29,7 +29,7 @@ export async function createRedirects( input: route.pathname, target: prependForwardSlash(route.distURL.toString().replace(dir.toString(), '')), status: 200, - weight: 1 + weight: 1, }); } else { definitions.push({ @@ -46,33 +46,37 @@ export async function createRedirects( input: '/*', target: `/.netlify/${kind}/${entryFile}`, status: 404, - weight: 0 + weight: 0, }); } } } else { const pattern = - '/' + route.segments.map(([part]) => { - //(part.dynamic ? '*' : part.content) - if(part.dynamic) { - if(part.spread) { - return '*'; + '/' + + route.segments + .map(([part]) => { + //(part.dynamic ? '*' : part.content) + if (part.dynamic) { + if (part.spread) { + return '*'; + } else { + return ':' + part.content; + } } else { - return ':' + part.content; + return part.content; } - } else { - return part.content; - } - }).join('/'); + }) + .join('/'); if (route.distURL) { - const target = `${pattern}` + (config.build.format === 'directory' ? '/index.html' : '.html'); + const target = + `${pattern}` + (config.build.format === 'directory' ? '/index.html' : '.html'); definitions.push({ dynamic: true, input: pattern, target, status: 200, - weight: 1 + weight: 1, }); } else { definitions.push({ @@ -80,7 +84,7 @@ export async function createRedirects( input: pattern, target: `/.netlify/${kind}/${entryFile}`, status: 200, - weight: 1 + weight: 1, }); } } @@ -95,21 +99,22 @@ export async function createRedirects( } function prettify(definitions: RedirectDefinition[]) { - let minInputLength = 0, minTargetLength = 0; + let minInputLength = 0, + minTargetLength = 0; definitions.sort((a, b) => { // Find the longest input, so we can format things nicely - if(a.input.length > minInputLength) { + if (a.input.length > minInputLength) { minInputLength = a.input.length; } - if(b.input.length > minInputLength) { + if (b.input.length > minInputLength) { minInputLength = b.input.length; } // Same for the target - if(a.target.length > minTargetLength) { + if (a.target.length > minTargetLength) { minTargetLength = a.target.length; } - if(b.target.length > minTargetLength) { + if (b.target.length > minTargetLength) { minTargetLength = b.target.length; } @@ -122,9 +127,15 @@ function prettify(definitions: RedirectDefinition[]) { definitions.forEach((defn, i) => { // Figure out the number of spaces to add. We want at least 4 spaces // after the input. This ensure that all targets line up together. - let inputSpaces = (minInputLength - defn.input.length) + 4; - let targetSpaces = (minTargetLength - defn.target.length) + 4; - _redirects += (i === 0 ? '' : '\n') + defn.input + ' '.repeat(inputSpaces) + defn.target + ' '.repeat(Math.abs(targetSpaces)) + defn.status; + let inputSpaces = minInputLength - defn.input.length + 4; + let targetSpaces = minTargetLength - defn.target.length + 4; + _redirects += + (i === 0 ? '' : '\n') + + defn.input + + ' '.repeat(inputSpaces) + + defn.target + + ' '.repeat(Math.abs(targetSpaces)) + + defn.status; }); return _redirects; } diff --git a/packages/integrations/tailwind/src/index.ts b/packages/integrations/tailwind/src/index.ts index 8783d8606..9106b672b 100644 --- a/packages/integrations/tailwind/src/index.ts +++ b/packages/integrations/tailwind/src/index.ts @@ -1,12 +1,12 @@ import load, { resolve } from '@proload/core'; import type { AstroIntegration } from 'astro'; -import type { CSSOptions, UserConfig } from 'vite'; import autoprefixerPlugin from 'autoprefixer'; import fs from 'fs/promises'; import path from 'path'; import tailwindPlugin, { Config as TailwindConfig } from 'tailwindcss'; import resolveConfig from 'tailwindcss/resolveConfig.js'; import { fileURLToPath } from 'url'; +import type { CSSOptions, UserConfig } from 'vite'; function getDefaultTailwindConfig(srcUrl: URL): TailwindConfig { return resolveConfig({