summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/integrations/netlify/CHANGELOG.md2
-rw-r--r--packages/integrations/netlify/package.json9
-rw-r--r--packages/integrations/netlify/src/functions.ts2
-rw-r--r--packages/integrations/netlify/src/image-service.ts4
-rw-r--r--packages/integrations/netlify/src/index.ts28
-rw-r--r--packages/integrations/netlify/src/lib/nft.ts8
-rw-r--r--packages/integrations/netlify/src/static.ts2
-rw-r--r--packages/integrations/netlify/test/functions/cookies.test.js10
-rw-r--r--packages/integrations/netlify/test/functions/edge-middleware.test.js6
-rw-r--r--packages/integrations/netlify/test/functions/image-cdn.test.js22
-rw-r--r--packages/integrations/netlify/test/functions/redirects.test.js6
-rw-r--r--packages/integrations/netlify/test/hosted/hosted.test.js2
-rw-r--r--packages/integrations/node/test/node-middleware.test.js4
-rw-r--r--packages/integrations/node/test/prerender.test.js14
-rw-r--r--packages/integrations/node/test/trailing-slash.test.js12
15 files changed, 68 insertions, 63 deletions
diff --git a/packages/integrations/netlify/CHANGELOG.md b/packages/integrations/netlify/CHANGELOG.md
index e5e84d3e8..443458ef4 100644
--- a/packages/integrations/netlify/CHANGELOG.md
+++ b/packages/integrations/netlify/CHANGELOG.md
@@ -992,7 +992,7 @@
{ darkMode: true },
{
expires: '1 month',
- }
+ },
);
const prefs = Astro.cookies.get<Prefs>('prefs').json();
diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json
index 1eba7a91a..4fdd0fa90 100644
--- a/packages/integrations/netlify/package.json
+++ b/packages/integrations/netlify/package.json
@@ -11,7 +11,10 @@
"url": "https://github.com/withastro/adapters.git",
"directory": "packages/netlify"
},
- "keywords": ["withastro", "astro-adapter"],
+ "keywords": [
+ "withastro",
+ "astro-adapter"
+ ],
"bugs": "https://github.com/withastro/adapters/issues",
"homepage": "https://docs.astro.build/en/guides/integrations-guide/netlify/",
"exports": {
@@ -22,7 +25,9 @@
"./image-service.js": "./dist/image-service.js",
"./package.json": "./package.json"
},
- "files": ["dist"],
+ "files": [
+ "dist"
+ ],
"scripts": {
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
"test": "pnpm run test-fn && pnpm run test-static",
diff --git a/packages/integrations/netlify/src/functions.ts b/packages/integrations/netlify/src/functions.ts
index 58428fec0..1969913a8 100644
--- a/packages/integrations/netlify/src/functions.ts
+++ b/packages/integrations/netlify/src/functions.ts
@@ -3,7 +3,7 @@ import netlifyIntegration, { type NetlifyIntegrationConfig } from './index.js';
export default function functionsIntegration(config: NetlifyIntegrationConfig): AstroIntegration {
console.warn(
- 'The @astrojs/netlify/functions import is deprecated and will be removed in a future release. Please use @astrojs/netlify instead.'
+ 'The @astrojs/netlify/functions import is deprecated and will be removed in a future release. Please use @astrojs/netlify instead.',
);
return netlifyIntegration(config);
}
diff --git a/packages/integrations/netlify/src/image-service.ts b/packages/integrations/netlify/src/image-service.ts
index afdcc3917..1e1f571f8 100644
--- a/packages/integrations/netlify/src/image-service.ts
+++ b/packages/integrations/netlify/src/image-service.ts
@@ -36,7 +36,7 @@ const service: ExternalImageService = {
if (options.format && !SUPPORTED_FORMATS.includes(options.format)) {
throw new AstroError(
`Unsupported image format "${options.format}"`,
- `Use one of ${SUPPORTED_FORMATS.join(', ')} instead.`
+ `Use one of ${SUPPORTED_FORMATS.join(', ')} instead.`,
);
}
@@ -46,7 +46,7 @@ const service: ExternalImageService = {
if (options.quality < 1 || options.quality > 100) {
throw new AstroError(
`Invalid quality for picture "${options.src}"`,
- 'Quality needs to be between 1 and 100.'
+ 'Quality needs to be between 1 and 100.',
);
}
}
diff --git a/packages/integrations/netlify/src/index.ts b/packages/integrations/netlify/src/index.ts
index 2c0fde008..a43325cd1 100644
--- a/packages/integrations/netlify/src/index.ts
+++ b/packages/integrations/netlify/src/index.ts
@@ -17,7 +17,7 @@ import { copyDependenciesToFunction } from './lib/nft.js';
import type { Args } from './ssr-function.js';
const { version: packageVersion } = JSON.parse(
- await readFile(new URL('../package.json', import.meta.url), 'utf8')
+ await readFile(new URL('../package.json', import.meta.url), 'utf8'),
);
export interface NetlifyLocals {
@@ -33,7 +33,7 @@ type RemotePattern = AstroConfig['image']['remotePatterns'][number];
*/
export function remotePatternToRegex(
pattern: RemotePattern,
- logger: AstroIntegrationLogger
+ logger: AstroIntegrationLogger,
): string | undefined {
let { protocol, hostname, port, pathname } = pattern;
@@ -94,8 +94,8 @@ export function remotePatternToRegex(
} catch (e) {
logger.warn(
`Could not generate a valid regex from the remotePattern "${JSON.stringify(
- pattern
- )}". Please check the syntax.`
+ pattern,
+ )}". Please check the syntax.`,
);
return undefined;
}
@@ -106,13 +106,13 @@ async function writeNetlifyFrameworkConfig(config: AstroConfig, logger: AstroInt
const remoteImages: Array<string> = [];
// Domains get a simple regex match
remoteImages.push(
- ...config.image.domains.map((domain) => `https?:\/\/${domain.replaceAll('.', '\\.')}\/.*`)
+ ...config.image.domains.map((domain) => `https?:\/\/${domain.replaceAll('.', '\\.')}\/.*`),
);
// Remote patterns need to be converted to regexes
remoteImages.push(
...config.image.remotePatterns
.map((pattern) => remotePatternToRegex(pattern, logger))
- .filter(Boolean as unknown as (pattern?: string) => pattern is string)
+ .filter(Boolean as unknown as (pattern?: string) => pattern is string),
);
const headers = config.build.assetsPrefix
@@ -134,7 +134,7 @@ async function writeNetlifyFrameworkConfig(config: AstroConfig, logger: AstroInt
JSON.stringify({
images: { remote_images: remoteImages },
headers,
- })
+ }),
);
}
@@ -181,10 +181,10 @@ export interface NetlifyIntegrationConfig {
}
export default function netlifyIntegration(
- integrationConfig?: NetlifyIntegrationConfig
+ integrationConfig?: NetlifyIntegrationConfig,
): AstroIntegration {
const isRunningInNetlify = Boolean(
- process.env.NETLIFY || process.env.NETLIFY_LOCAL || process.env.NETLIFY_DEV
+ process.env.NETLIFY || process.env.NETLIFY_LOCAL || process.env.NETLIFY_DEV,
);
let _config: AstroConfig;
@@ -213,11 +213,11 @@ export default function netlifyIntegration(
routes: IntegrationResolvedRoute[],
dir: URL,
buildOutput: HookParameters<'astro:config:done'>['buildOutput'],
- assets: HookParameters<'astro:build:done'>['assets']
+ assets: HookParameters<'astro:build:done'>['assets'],
) {
// all other routes are handled by SSR
const staticRedirects = routes.filter(
- (route) => route.type === 'redirect' && (route.redirect || route.redirectRoute)
+ (route) => route.type === 'redirect' && (route.redirect || route.redirectRoute),
);
// this is needed to support redirects to dynamic routes
@@ -266,7 +266,7 @@ export default function netlifyIntegration(
logger,
root,
},
- TRACE_CACHE
+ TRACE_CACHE,
);
await writeFile(
@@ -285,7 +285,7 @@ export default function netlifyIntegration(
path: '/*',
preferStatic: true,
};
- `
+ `,
);
}
@@ -337,7 +337,7 @@ export default function netlifyIntegration(
generator: "@astrojs/netlify@${packageVersion}",
path: "/*", excludedPath: ["/_astro/*", "/.netlify/images/*"]
};
- `
+ `,
);
// taking over bundling, because Netlify bundling trips over NPM modules
diff --git a/packages/integrations/netlify/src/lib/nft.ts b/packages/integrations/netlify/src/lib/nft.ts
index c0584fd92..249637e83 100644
--- a/packages/integrations/netlify/src/lib/nft.ts
+++ b/packages/integrations/netlify/src/lib/nft.ts
@@ -23,7 +23,7 @@ export async function copyDependenciesToFunction(
root: URL;
},
// we want to pass the caching by reference, and not by value
- cache: object
+ cache: object,
): Promise<{ handler: string }> {
const entryPath = fileURLToPath(entry);
logger.info(`Bundling function ${relative(fileURLToPath(outDir), entryPath)}`);
@@ -54,11 +54,11 @@ export async function copyDependenciesToFunction(
if (entryPath === file) {
logger.debug(
- `The module "${module}" couldn't be resolved. This may not be a problem, but it's worth checking.`
+ `The module "${module}" couldn't be resolved. This may not be a problem, but it's worth checking.`,
);
} else {
logger.debug(
- `The module "${module}" inside the file "${file}" couldn't be resolved. This may not be a problem, but it's worth checking.`
+ `The module "${module}" inside the file "${file}" couldn't be resolved. This may not be a problem, but it's worth checking.`,
);
}
}
@@ -73,7 +73,7 @@ export async function copyDependenciesToFunction(
const commonAncestor = await copyFilesToFolder(
[...result.fileList].map((file) => new URL(file, base)).concat(includeFiles),
outDir,
- excludeFiles
+ excludeFiles,
);
return {
diff --git a/packages/integrations/netlify/src/static.ts b/packages/integrations/netlify/src/static.ts
index 1c809ef8f..052897de4 100644
--- a/packages/integrations/netlify/src/static.ts
+++ b/packages/integrations/netlify/src/static.ts
@@ -2,7 +2,7 @@ import netlifyIntegration from './index.js';
export default function staticIntegration() {
console.warn(
- 'The @astrojs/netlify/static import is deprecated and will be removed in a future release. Please use @astrojs/netlify instead.'
+ 'The @astrojs/netlify/static import is deprecated and will be removed in a future release. Please use @astrojs/netlify instead.',
);
return netlifyIntegration();
}
diff --git a/packages/integrations/netlify/test/functions/cookies.test.js b/packages/integrations/netlify/test/functions/cookies.test.js
index 9d2565d91..c8f409eec 100644
--- a/packages/integrations/netlify/test/functions/cookies.test.js
+++ b/packages/integrations/netlify/test/functions/cookies.test.js
@@ -15,12 +15,12 @@ describe(
it('Can set multiple', async () => {
const entryURL = new URL(
'./fixtures/cookies/.netlify/v1/functions/ssr/ssr.mjs',
- import.meta.url
+ import.meta.url,
);
const { default: handler } = await import(entryURL);
const resp = await handler(
new Request('http://example.com/login', { method: 'POST', body: '{}' }),
- {}
+ {},
);
assert.equal(resp.status, 301);
assert.equal(resp.headers.get('location'), '/');
@@ -30,7 +30,7 @@ describe(
it('renders dynamic 404 page', async () => {
const entryURL = new URL(
'./fixtures/cookies/.netlify/v1/functions/ssr/ssr.mjs',
- import.meta.url
+ import.meta.url,
);
const { default: handler } = await import(entryURL);
const resp = await handler(
@@ -39,7 +39,7 @@ describe(
'x-test': 'bar',
},
}),
- {}
+ {},
);
assert.equal(resp.status, 404);
const text = await resp.text();
@@ -49,5 +49,5 @@ describe(
},
{
timeout: 120000,
- }
+ },
);
diff --git a/packages/integrations/netlify/test/functions/edge-middleware.test.js b/packages/integrations/netlify/test/functions/edge-middleware.test.js
index 683ec3b01..ae06a9f6f 100644
--- a/packages/integrations/netlify/test/functions/edge-middleware.test.js
+++ b/packages/integrations/netlify/test/functions/edge-middleware.test.js
@@ -18,7 +18,7 @@ describe(
it('emits no edge function', async () => {
assert.equal(
fixture.pathExists('../.netlify/v1/edge-functions/middleware/middleware.mjs'),
- false
+ false,
);
});
@@ -44,7 +44,7 @@ describe(
it('emits an edge function', async () => {
const contents = await fixture.readFile(
- '../.netlify/v1/edge-functions/middleware/middleware.mjs'
+ '../.netlify/v1/edge-functions/middleware/middleware.mjs',
);
assert.equal(contents.includes('"Hello world"'), false);
});
@@ -62,5 +62,5 @@ describe(
},
{
timeout: 120000,
- }
+ },
);
diff --git a/packages/integrations/netlify/test/functions/image-cdn.test.js b/packages/integrations/netlify/test/functions/image-cdn.test.js
index 45b41e4de..0348ea656 100644
--- a/packages/integrations/netlify/test/functions/image-cdn.test.js
+++ b/packages/integrations/netlify/test/functions/image-cdn.test.js
@@ -67,24 +67,24 @@ describe(
assert.equal(
domain.test('https://www.example.net/image.jpg'),
false,
- 'subdomain should not match'
+ 'subdomain should not match',
);
assert.equal(domain.test('http://example.net/image.jpg'), true, 'http should match');
assert.equal(
domain.test('https://example.net/subdomain/image.jpg'),
true,
- 'subpath should match'
+ 'subpath should match',
);
const subdomain = regexes[1];
assert.equal(
subdomain.test('https://secret.example.edu/image.jpg'),
true,
- 'should match subdomains'
+ 'should match subdomains',
);
assert.equal(
subdomain.test('https://secretxexample.edu/image.jpg'),
false,
- 'should not use dots in domains as wildcards'
+ 'should not use dots in domains as wildcards',
);
});
@@ -93,22 +93,22 @@ describe(
assert.equal(
patterns.test('https://example.org/images/1.jpg'),
true,
- 'should match domain'
+ 'should match domain',
);
assert.equal(
patterns.test('https://www.example.org/images/2.jpg'),
true,
- 'www subdomain should match'
+ 'www subdomain should match',
);
assert.equal(
patterns.test('https://www.subdomain.example.org/images/2.jpg'),
false,
- 'second level subdomain should not match'
+ 'second level subdomain should not match',
);
assert.equal(
patterns.test('https://example.org/not-images/2.jpg'),
false,
- 'wrong path should not match'
+ 'wrong path should not match',
);
});
@@ -121,19 +121,19 @@ describe(
hostname: '*.examp[le.org',
pathname: '/images/*',
},
- logger
+ logger,
);
assert.strictEqual(regex, undefined);
const calls = logger.warn.mock.calls;
assert.strictEqual(calls.length, 1);
assert.equal(
calls[0].arguments[0],
- 'Could not generate a valid regex from the remotePattern "{"hostname":"*.examp[le.org","pathname":"/images/*"}". Please check the syntax.'
+ 'Could not generate a valid regex from the remotePattern "{"hostname":"*.examp[le.org","pathname":"/images/*"}". Please check the syntax.',
);
});
});
},
{
timeout: 120000,
- }
+ },
);
diff --git a/packages/integrations/netlify/test/functions/redirects.test.js b/packages/integrations/netlify/test/functions/redirects.test.js
index ac77056c4..612a46abb 100644
--- a/packages/integrations/netlify/test/functions/redirects.test.js
+++ b/packages/integrations/netlify/test/functions/redirects.test.js
@@ -34,7 +34,7 @@ describe(
it('renders static 404 page', async () => {
const entryURL = new URL(
'./fixtures/redirects/.netlify/v1/functions/ssr/ssr.mjs',
- import.meta.url
+ import.meta.url,
);
const { default: handler } = await import(entryURL);
const resp = await handler(new Request('http://example.com/nonexistant-page'), {});
@@ -54,7 +54,7 @@ describe(
testServer.listen(5678);
const entryURL = new URL(
'./fixtures/redirects/.netlify/v1/functions/ssr/ssr.mjs',
- import.meta.url
+ import.meta.url,
);
const { default: handler } = await import(entryURL);
const resp = await handler(new Request('http://localhost:5678/nonexistant-page'), {});
@@ -65,5 +65,5 @@ describe(
},
{
timeout: 120000,
- }
+ },
);
diff --git a/packages/integrations/netlify/test/hosted/hosted.test.js b/packages/integrations/netlify/test/hosted/hosted.test.js
index b8562ce82..3bc9349f9 100644
--- a/packages/integrations/netlify/test/hosted/hosted.test.js
+++ b/packages/integrations/netlify/test/hosted/hosted.test.js
@@ -6,7 +6,7 @@ const NETLIFY_TEST_URL = 'https://curious-boba-495d6d.netlify.app';
describe('Hosted Netlify Tests', () => {
it('Image endpoint works', async () => {
const image = await fetch(
- `${NETLIFY_TEST_URL}/_image?href=%2F_astro%2Fpenguin.e9c64733.png&w=300&f=webp`
+ `${NETLIFY_TEST_URL}/_image?href=%2F_astro%2Fpenguin.e9c64733.png&w=300&f=webp`,
);
assert.equal(image.status, 200);
diff --git a/packages/integrations/node/test/node-middleware.test.js b/packages/integrations/node/test/node-middleware.test.js
index 57d3ba434..2ff98f735 100644
--- a/packages/integrations/node/test/node-middleware.test.js
+++ b/packages/integrations/node/test/node-middleware.test.js
@@ -31,7 +31,7 @@ describe('behavior from middleware, standalone', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
@@ -72,7 +72,7 @@ describe('behavior from middleware, middleware', () => {
after(async () => {
server.close();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
diff --git a/packages/integrations/node/test/prerender.test.js b/packages/integrations/node/test/prerender.test.js
index 4912f2290..949358159 100644
--- a/packages/integrations/node/test/prerender.test.js
+++ b/packages/integrations/node/test/prerender.test.js
@@ -34,7 +34,7 @@ describe('Prerendering', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
@@ -106,7 +106,7 @@ describe('Prerendering', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
@@ -179,7 +179,7 @@ describe('Prerendering', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
@@ -220,7 +220,7 @@ describe('Prerendering', () => {
after(async () => {
await devServer.stop();
-
+
delete process.env.PRERENDER;
});
@@ -271,7 +271,7 @@ describe('Hybrid rendering', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
@@ -341,7 +341,7 @@ describe('Hybrid rendering', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
@@ -403,7 +403,7 @@ describe('Hybrid rendering', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
diff --git a/packages/integrations/node/test/trailing-slash.test.js b/packages/integrations/node/test/trailing-slash.test.js
index b1ef3c970..feed313ce 100644
--- a/packages/integrations/node/test/trailing-slash.test.js
+++ b/packages/integrations/node/test/trailing-slash.test.js
@@ -36,7 +36,7 @@ describe('Trailing slash', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
@@ -104,7 +104,7 @@ describe('Trailing slash', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
@@ -175,7 +175,7 @@ describe('Trailing slash', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
@@ -236,7 +236,7 @@ describe('Trailing slash', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
@@ -300,7 +300,7 @@ describe('Trailing slash', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});
@@ -379,7 +379,7 @@ describe('Trailing slash', () => {
after(async () => {
await server.stop();
await fixture.clean();
-
+
delete process.env.PRERENDER;
});