Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapter related changes for IntegrationData #377

Merged
merged 10 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/olive-jobs-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vercel': major
---

Updates the adapter to use new `IntegrationRouteData` type
6 changes: 3 additions & 3 deletions packages/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@astrojs/internal-helpers": "0.4.1",
"@astrojs/underscore-redirects": "^0.3.4",
"@astrojs/underscore-redirects": "^0.4.0-alpha.0",
"@cloudflare/workers-types": "^4.20240821.1",
"esbuild": "^0.23.1",
"estree-walker": "^3.0.3",
Expand All @@ -40,11 +40,11 @@
"@inox-tools/astro-when": "^0.2.2"
},
"peerDependencies": {
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
},
"devDependencies": {
"@astrojs/test-utils": "workspace:*",
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"astro-scripts": "workspace:*",
"cheerio": "1.0.0",
"execa": "^8.0.1",
Expand Down
1 change: 0 additions & 1 deletion packages/cloudflare/src/entrypoints/image-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const service: ExternalImageService = {
}

const imageEndpoint = joinPaths(
// @ts-expect-error - Property 'env' does not exist on type 'ImportMeta'.ts(2339)
import.meta.env.BASE_URL,
'/cdn-cgi/image',
resizingParams.join(','),
Expand Down
6 changes: 3 additions & 3 deletions packages/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AstroConfig, AstroIntegration, RouteData } from 'astro';
import type { AstroConfig, AstroIntegration, IntegrationRouteData } from 'astro';
import type { PluginOption } from 'vite';

import { createReadStream } from 'node:fs';
Expand Down Expand Up @@ -295,7 +295,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
redirectsExists = false;
}

const redirects: RouteData['segments'][] = [];
const redirects: IntegrationRouteData['segments'][] = [];
if (redirectsExists) {
const rl = createInterface({
input: createReadStream(new URL('./_redirects', _config.outDir)),
Expand Down Expand Up @@ -342,7 +342,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
);
}

const redirectRoutes: [RouteData, string][] = [];
const redirectRoutes: [IntegrationRouteData, string][] = [];
for (const route of routes) {
if (route.type === 'redirect') redirectRoutes.push([route, '']);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/cloudflare/src/utils/generate-routes-json.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AstroConfig, AstroIntegrationLogger, RouteData, RoutePart } from 'astro';
import type { AstroConfig, AstroIntegrationLogger, IntegrationRouteData, RoutePart } from 'astro';

import { existsSync } from 'node:fs';
import { writeFile } from 'node:fs/promises';
Expand Down Expand Up @@ -63,7 +63,7 @@ async function writeRoutesFileToOutDir(
}
}

function segmentsToCfSyntax(segments: RouteData['segments'], _config: AstroConfig) {
function segmentsToCfSyntax(segments: IntegrationRouteData['segments'], _config: AstroConfig) {
const pathSegments = [];
if (removeLeadingForwardSlash(removeTrailingForwardSlash(_config.base)).length > 0) {
pathSegments.push(removeLeadingForwardSlash(removeTrailingForwardSlash(_config.base)));
Expand Down Expand Up @@ -138,11 +138,11 @@ class PathTrie {
export async function createRoutesFile(
_config: AstroConfig,
logger: AstroIntegrationLogger,
routes: RouteData[],
routes: IntegrationRouteData[],
pages: {
pathname: string;
}[],
redirects: RouteData['segments'][],
redirects: IntegrationRouteData['segments'][],
includeExtends:
| {
pattern: string;
Expand Down
9 changes: 4 additions & 5 deletions packages/cloudflare/src/utils/image-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ export function setImageConfig(
return {
...config,
service: sharpImageService(),
endpoint: command === 'dev' ? undefined : '@astrojs/cloudflare/image-endpoint',
endpoint: {
entrypoint: command === 'dev' ? undefined : '@astrojs/cloudflare/image-endpoint',
},
};

case 'custom':
return { ...config };

default:
if (
config.service.entrypoint === 'astro/assets/services/sharp' ||
config.service.entrypoint === 'astro/assets/services/squoosh'
) {
if (config.service.entrypoint === 'astro/assets/services/sharp') {
logger.warn(
`The current configuration does not support image optimization. To allow your project to build with the original, unoptimized images, the image service has been automatically switched to the 'noop' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@astrojs/cloudflare": "workspace:*",
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
},
"devDependencies": {
"wrangler": "^3.72.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/cloudflare/test/fixtures/astro-env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@astrojs/cloudflare": "workspace:*",
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
},
"devDependencies": {
"wrangler": "^3.72.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"@astrojs/cloudflare": "workspace:*",
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"@astrojs/cloudflare": "workspace:*",
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"@astrojs/cloudflare": "workspace:*",
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
}
}
2 changes: 1 addition & 1 deletion packages/cloudflare/test/fixtures/no-output/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"@astrojs/cloudflare": "workspace:*",
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
}
}
2 changes: 1 addition & 1 deletion packages/cloudflare/test/fixtures/routes-json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"@astrojs/cloudflare": "workspace:*",
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@astrojs/cloudflare": "workspace:*",
"@astrojs/solid-js": "^4.4.1",
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"solid-js": "^1.8.21"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"dependencies": {
"@astrojs/cloudflare": "workspace:*",
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
}
}
6 changes: 3 additions & 3 deletions packages/netlify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@
},
"dependencies": {
"@astrojs/internal-helpers": "0.4.1",
"@astrojs/underscore-redirects": "^0.3.4",
"@astrojs/underscore-redirects": "^0.4.0-alpha.0",
"@netlify/functions": "^2.8.0",
"@vercel/nft": "^0.27.3",
"esbuild": "^0.23.1"
},
"peerDependencies": {
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
},
"devDependencies": {
"@astrojs/test-utils": "workspace:*",
"@netlify/edge-functions": "^2.10.0",
"@netlify/edge-handler-types": "^0.34.1",
"@types/node": "^20.16.1",
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"astro-scripts": "workspace:*",
"cheerio": "1.0.0",
"execa": "^8.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/netlify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
AstroIntegration,
AstroIntegrationLogger,
HookParameters,
RouteData,
IntegrationRouteData,
} from 'astro';
import { build } from 'esbuild';
import { copyDependenciesToFunction } from './lib/nft.js';
Expand All @@ -26,7 +26,7 @@ export interface NetlifyLocals {
};
}

const isStaticRedirect = (route: RouteData) =>
const isStaticRedirect = (route: IntegrationRouteData) =>
route.type === 'redirect' && (route.redirect || route.redirectRoute);

type RemotePattern = AstroConfig['image']['remotePatterns'][number];
Expand Down Expand Up @@ -212,7 +212,7 @@ export default function netlifyIntegration(
emptyDir(ssrBuildDir()),
]);

async function writeRedirects(routes: RouteData[], dir: URL) {
async function writeRedirects(routes: IntegrationRouteData[], dir: URL) {
const fallback = finalBuildOutput === 'static' ? '/.netlify/static' : '/.netlify/functions/ssr';
const redirects = createRedirectsFromAstroRoutes({
config: _config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
},
"dependencies": {
"@astrojs/netlify": "workspace:*",
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
}
}
4 changes: 2 additions & 2 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"server-destroy": "^1.0.1"
},
"peerDependencies": {
"astro": "^5.0.0-alpha.6"
"astro": "^5.0.0-alpha.8"
},
"devDependencies": {
"@astrojs/test-utils": "workspace:*",
"@types/node": "^18.17.8",
"@types/send": "^0.17.4",
"@types/server-destroy": "^1.0.4",
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"astro-scripts": "workspace:*",
"cheerio": "1.0.0",
"express": "^4.19.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/api-route/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/bad-urls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/encoded/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/headers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/locals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/node-middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/prerender-404-500/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"type": "module",
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/prerender/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
4 changes: 1 addition & 3 deletions packages/node/test/fixtures/prerender/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { shared } from './shared';
export const onRequest = (ctx, next) => {
ctx.locals = {
name: shared,
};
ctx.locals.name = shared;
return next();
};
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/preview-headers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/trailing-slash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/node/test/fixtures/url/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "^5.0.0-alpha.6",
"astro": "^5.0.0-alpha.8",
"@astrojs/node": "workspace:*"
}
}
Loading