Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Reorg dev command
Browse files Browse the repository at this point in the history
  • Loading branch information
jayair committed Oct 17, 2024
1 parent 2be5837 commit cf20c65
Show file tree
Hide file tree
Showing 15 changed files with 389 additions and 328 deletions.
3 changes: 1 addition & 2 deletions platform/src/components/aws/analog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Cdn } from "./cdn.js";
import { Bucket } from "./bucket.js";
import { Component } from "../component.js";
import { Link } from "../link.js";
import { DevArgs } from "../dev.js";
import { buildApp } from "../base/base-ssr-site.js";
import { URL_UNAVAILABLE } from "./linkable.js";
import { VisibleError } from "../error.js";
Expand All @@ -34,7 +33,7 @@ export interface AnalogArgs extends SsrSiteArgs {
*
* To disable dev mode, pass in `false`.
*/
dev?: false | DevArgs["dev"];
dev?: SsrSiteArgs["dev"];
/**
* Permissions and the resources that the [server function](#nodes-server) in your Analog app needs to access. These permissions are used to create the function's IAM role.
*
Expand Down
12 changes: 5 additions & 7 deletions platform/src/components/aws/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Cdn } from "./cdn.js";
import { Bucket } from "./bucket.js";
import { Component } from "./../component.js";
import { Link } from "../link.js";
import { DevArgs } from "../dev.js";
import { buildApp } from "../base/base-ssr-site.js";
import { URL_UNAVAILABLE } from "./linkable.js";

Expand All @@ -35,7 +34,7 @@ export interface AstroArgs extends SsrSiteArgs {
*
* To disable dev mode, pass in `false`.
*/
dev?: false | DevArgs["dev"];
dev?: SsrSiteArgs["dev"];
/**
* Permissions and the resources that the [server function](#nodes-server) in your Astro site needs to access. These permissions are used to create the function's IAM role.
*
Expand Down Expand Up @@ -675,11 +674,10 @@ function useCloudFrontRoutingInjection(buildMetadata: BuildMetaConfig) {
var matchedRoute = findFirstMatch(findMatches(event.request.uri, routeData));
if (matchedRoute[0]) {
if (!matchedRoute[1] && !/^.*\\.[^\\/]+$/.test(event.request.uri)) {
${
buildMetadata.pageResolution === "file"
? `event.request.uri = event.request.uri === "/" ? "/index.html" : event.request.uri.replace(/\\/?$/, ".html");`
: `event.request.uri = event.request.uri.replace(/\\/?$/, "/index.html");`
}
${buildMetadata.pageResolution === "file"
? `event.request.uri = event.request.uri === "/" ? "/index.html" : event.request.uri.replace(/\\/?$/, ".html");`
: `event.request.uri = event.request.uri.replace(/\\/?$/, "/index.html");`
}
} else if (matchedRoute[1] === 2) {
var redirectPath = matchedRoute[2];
matchedRoute[0].exec(event.request.uri).forEach((match, index) => {
Expand Down
63 changes: 31 additions & 32 deletions platform/src/components/aws/nextjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { Cdn } from "./cdn.js";
import { Bucket } from "./bucket.js";
import { Component } from "../component.js";
import { Link } from "../link.js";
import { DevArgs } from "../dev.js";
import { VisibleError } from "../error.js";
import type { Input } from "../input.js";
import { Queue } from "./queue.js";
Expand Down Expand Up @@ -105,7 +104,7 @@ export interface NextjsArgs extends SsrSiteArgs {
*
* To disable dev mode, pass in `false`.
*/
dev?: false | DevArgs["dev"];
dev?: SsrSiteArgs["dev"];
/**
* Permissions and the resources that the [server function](#nodes-server) in your Next.js app needs to access. These permissions are used to create the function's IAM role.
*
Expand Down Expand Up @@ -788,39 +787,39 @@ export class Nextjs extends Component implements Link.Linkable {
},
...(revalidationQueueArn
? [
{
actions: [
"sqs:SendMessage",
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl",
],
resources: [revalidationQueueArn],
},
]
{
actions: [
"sqs:SendMessage",
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl",
],
resources: [revalidationQueueArn],
},
]
: []),
...(revalidationTableArn
? [
{
actions: [
"dynamodb:BatchGetItem",
"dynamodb:GetRecords",
"dynamodb:GetShardIterator",
"dynamodb:Query",
"dynamodb:GetItem",
"dynamodb:Scan",
"dynamodb:ConditionCheckItem",
"dynamodb:BatchWriteItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
"dynamodb:DescribeTable",
],
resources: [
revalidationTableArn,
`${revalidationTableArn}/*`,
],
},
]
{
actions: [
"dynamodb:BatchGetItem",
"dynamodb:GetRecords",
"dynamodb:GetShardIterator",
"dynamodb:Query",
"dynamodb:GetItem",
"dynamodb:Scan",
"dynamodb:ConditionCheckItem",
"dynamodb:BatchWriteItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
"dynamodb:DescribeTable",
],
resources: [
revalidationTableArn,
`${revalidationTableArn}/*`,
],
},
]
: []),
],
injections: [
Expand Down
3 changes: 1 addition & 2 deletions platform/src/components/aws/nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Cdn } from "./cdn.js";
import { Bucket } from "./bucket.js";
import { Component } from "../component.js";
import { Link } from "../link.js";
import { DevArgs } from "../dev.js";
import { buildApp } from "../base/base-ssr-site.js";
import { URL_UNAVAILABLE } from "./linkable.js";

Expand All @@ -33,7 +32,7 @@ export interface NuxtArgs extends SsrSiteArgs {
*
* To disable dev mode, pass in `false`.
*/
dev?: false | DevArgs["dev"];
dev?: SsrSiteArgs["dev"];
/**
* Permissions and the resources that the [server function](#nodes-server) in your Nuxt app needs to access. These permissions are used to create the function's IAM role.
*
Expand Down
95 changes: 47 additions & 48 deletions platform/src/components/aws/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { Cdn } from "./cdn.js";
import { Bucket } from "./bucket.js";
import { Component } from "../component.js";
import { Link } from "../link.js";
import { DevArgs } from "../dev.js";
import type { Input } from "../input.js";
import { buildApp } from "../base/base-ssr-site.js";
import { URL_UNAVAILABLE } from "./linkable.js";
Expand All @@ -40,7 +39,7 @@ export interface ReactArgs extends SsrSiteArgs {
*
* To disable dev mode, pass in `false`.
*/
dev?: false | DevArgs["dev"];
dev?: SsrSiteArgs["dev"];
/**
* Permissions and the resources that the [server function](#nodes-server) in your React app needs to access. These permissions are used to create the function's IAM role.
*
Expand Down Expand Up @@ -485,36 +484,36 @@ export class React extends Component implements Link.Linkable {
defaultRootObject: indexPage,
errorResponses: !serverConfig
? [
{
errorCode: 403,
responsePagePath: interpolate`/${indexPage}`,
responseCode: 200,
},
{
errorCode: 404,
responsePagePath: interpolate`/${indexPage}`,
responseCode: 200,
},
]
{
errorCode: 403,
responsePagePath: interpolate`/${indexPage}`,
responseCode: 200,
},
{
errorCode: 404,
responsePagePath: interpolate`/${indexPage}`,
responseCode: 200,
},
]
: [],
edgeFunctions:
edge && serverConfig
? {
server: {
function: serverConfig,
},
}
server: {
function: serverConfig,
},
}
: undefined,
origins: {
...(edge || !serverConfig
? {}
: {
server: {
server: {
server: {
function: serverConfig,
},
function: serverConfig,
},
}),
},
}),
s3: {
s3: {
copy: [
Expand All @@ -530,35 +529,35 @@ export class React extends Component implements Link.Linkable {
behaviors: [
...(!serverConfig
? [
{
cacheType: "static",
{
cacheType: "static",
cfFunction: "serverCfFunction",
origin: "s3",
} as const,
]
: [
edge
? ({
cacheType: "server",
cfFunction: "serverCfFunction",
edgeFunction: "server",
origin: "s3",
} as const,
]
: [
edge
? ({
cacheType: "server",
cfFunction: "serverCfFunction",
edgeFunction: "server",
origin: "s3",
} as const)
: ({
cacheType: "server",
cfFunction: "serverCfFunction",
origin: "server",
} as const),
...buildMeta.staticRoutes.map(
(route) =>
({
cacheType: "static",
pattern: route,
cfFunction: "staticCfFunction",
origin: "s3",
}) as const,
),
]),
} as const)
: ({
cacheType: "server",
cfFunction: "serverCfFunction",
origin: "server",
} as const),
...buildMeta.staticRoutes.map(
(route) =>
({
cacheType: "static",
pattern: route,
cfFunction: "staticCfFunction",
origin: "s3",
}) as const,
),
]),
],
});
},
Expand Down
37 changes: 18 additions & 19 deletions platform/src/components/aws/remix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Cdn } from "./cdn.js";
import { Bucket } from "./bucket.js";
import { Component } from "../component.js";
import { Link } from "../link.js";
import { DevArgs } from "../dev.js";
import type { Input } from "../input.js";
import { buildApp } from "../base/base-ssr-site.js";
import { URL_UNAVAILABLE } from "./linkable.js";
Expand All @@ -35,7 +34,7 @@ export interface RemixArgs extends SsrSiteArgs {
*
* To disable dev mode, pass in `false`.
*/
dev?: false | DevArgs["dev"];
dev?: SsrSiteArgs["dev"];
/**
* Permissions and the resources that the [server function](#nodes-server) in your Remix app needs to access. These permissions are used to create the function's IAM role.
*
Expand Down Expand Up @@ -554,21 +553,21 @@ export class Remix extends Component implements Link.Linkable {
},
edgeFunctions: edge
? {
server: {
function: serverConfig,
},
}
server: {
function: serverConfig,
},
}
: undefined,
origins: {
...(edge
? {}
: {
server: {
server: {
server: {
function: serverConfig,
},
function: serverConfig,
},
}),
},
}),
s3: {
s3: {
copy: [
Expand All @@ -585,16 +584,16 @@ export class Remix extends Component implements Link.Linkable {
behaviors: [
edge
? {
cacheType: "server",
cfFunction: "serverCfFunction",
edgeFunction: "server",
origin: "s3",
}
cacheType: "server",
cfFunction: "serverCfFunction",
edgeFunction: "server",
origin: "s3",
}
: {
cacheType: "server",
cfFunction: "serverCfFunction",
origin: "server",
},
cacheType: "server",
cfFunction: "serverCfFunction",
origin: "server",
},
...buildMeta.staticRoutes.map(
(route) =>
({
Expand Down
3 changes: 1 addition & 2 deletions platform/src/components/aws/solid-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Cdn } from "./cdn.js";
import { Bucket } from "./bucket.js";
import { Component } from "../component.js";
import { Link } from "../link.js";
import { DevArgs } from "../dev.js";
import { buildApp } from "../base/base-ssr-site.js";
import { URL_UNAVAILABLE } from "./linkable.js";
import { VisibleError } from "../error.js";
Expand All @@ -34,7 +33,7 @@ export interface SolidStartArgs extends SsrSiteArgs {
*
* To disable dev mode, pass in `false`.
*/
dev?: false | DevArgs["dev"];
dev?: SsrSiteArgs["dev"];
/**
* Permissions and the resources that the [server function](#nodes-server) in your SolidStart app needs to access. These permissions are used to create the function's IAM role.
*
Expand Down
Loading

0 comments on commit cf20c65

Please sign in to comment.