Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored and astrobot-houston committed Jan 23, 2023
1 parent f5adbd6 commit 0d09747
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
57 changes: 34 additions & 23 deletions packages/integrations/netlify/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -46,41 +46,45 @@ 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({
dynamic: true,
input: pattern,
target: `/.netlify/${kind}/${entryFile}`,
status: 200,
weight: 1
weight: 1,
});
}
}
Expand All @@ -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;
}

Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/tailwind/src/index.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down

0 comments on commit 0d09747

Please sign in to comment.