sst 2.38.3 → 2.38.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/bind.js +4 -2
- package/cli/commands/dev.js +6 -1
- package/constructs/AstroSite.js +19 -28
- package/constructs/Function.js +3 -1
- package/constructs/SsrSite.js +9 -3
- package/constructs/util/astroRouteCompressor.d.ts +10 -0
- package/constructs/util/astroRouteCompressor.js +75 -0
- package/credentials.js +15 -3
- package/iot.d.ts +1 -0
- package/iot.js +26 -1
- package/package.json +2 -2
- package/runtime/handlers/container.js +13 -1
- package/runtime/handlers/node.js +21 -3
- package/support/bridge/Dockerfile +2 -2
- package/util/wsl.d.ts +2 -0
- package/util/wsl.js +10 -0
- /package/support/bridge/{bridge.mjs → live-lambda.mjs} +0 -0
package/cli/commands/bind.js
CHANGED
|
@@ -21,7 +21,7 @@ export const bind = (program) => program
|
|
|
21
21
|
const { useProject } = await import("../../project.js");
|
|
22
22
|
const { Stacks } = await import("../../stacks/index.js");
|
|
23
23
|
const { useBus } = await import("../../bus.js");
|
|
24
|
-
const { useIOT } = await import("../../iot.js");
|
|
24
|
+
const { useIOT, isSupported } = await import("../../iot.js");
|
|
25
25
|
const { Colors } = await import("../colors.js");
|
|
26
26
|
const { Logger } = await import("../../logger.js");
|
|
27
27
|
const [{ useServices }, { useSites: useSsrSites }, { useSites: useStaticSites }, { useSites: useSlsNextjsSites }, { Parameter }, { getEnvironmentKey },] = await Promise.all([
|
|
@@ -42,7 +42,9 @@ export const bind = (program) => program
|
|
|
42
42
|
if (!command) {
|
|
43
43
|
throw new VisibleError("Command is required, e.g. sst bind npm run script");
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
if (isSupported()) {
|
|
46
|
+
useIOT();
|
|
47
|
+
}
|
|
46
48
|
const bus = useBus();
|
|
47
49
|
const project = useProject();
|
|
48
50
|
let p;
|
package/cli/commands/dev.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { VisibleError } from "../../error.js";
|
|
1
2
|
export const dev = (program) => program.command(["dev", "start"], "Work on your app locally", (yargs) => yargs.option("increase-timeout", {
|
|
2
3
|
type: "boolean",
|
|
3
4
|
description: "Increase function timeout",
|
|
@@ -20,11 +21,15 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
20
21
|
const { getCiInfo } = await import("../ci-info.js");
|
|
21
22
|
const { useMetadataCache } = await import("../../stacks/metadata.js");
|
|
22
23
|
const { lazy } = await import("../../util/lazy.js");
|
|
24
|
+
const { useIOT, isSupported } = await import("../../iot.js");
|
|
23
25
|
try {
|
|
24
26
|
if (args._[0] === "start") {
|
|
25
27
|
console.log(yellow(`Warning: ${bold(`sst start`)} has been renamed to ${bold(`sst dev`)}`));
|
|
26
28
|
}
|
|
27
29
|
const project = useProject();
|
|
30
|
+
if (!isSupported()) {
|
|
31
|
+
throw new VisibleError(`Live Lambda is not currently supported in the "${project.config.region}" region. To fix this, you can pick an alternative region just for your local environment - https://docs.sst.dev/live-lambda-development#supported-regions`);
|
|
32
|
+
}
|
|
28
33
|
const useFunctionLogger = lazy(async () => {
|
|
29
34
|
const { useFunctions } = await import("../../constructs/Function.js");
|
|
30
35
|
const bus = useBus();
|
|
@@ -296,7 +301,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
296
301
|
});
|
|
297
302
|
const useDisconnector = lazy(async () => {
|
|
298
303
|
const bus = useBus();
|
|
299
|
-
const iot = await
|
|
304
|
+
const iot = await useIOT();
|
|
300
305
|
bus.subscribe("cli.dev", async (evt) => {
|
|
301
306
|
const topic = `${iot.prefix}/events`;
|
|
302
307
|
iot.publish(topic, "cli.dev", evt.properties);
|
package/constructs/AstroSite.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readFileSync, existsSync, readdirSync, statSync } from "fs";
|
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { SsrSite, } from "./SsrSite.js";
|
|
4
4
|
import { AllowedMethods } from "aws-cdk-lib/aws-cloudfront";
|
|
5
|
+
import { getStringifiedRouteTree } from "./util/astroRouteCompressor.js";
|
|
5
6
|
const BUILD_META_FILE_NAME = "sst.buildMeta.json";
|
|
6
7
|
/**
|
|
7
8
|
* The `AstroSite` construct is a higher level CDK construct that makes it easy to create a Astro app.
|
|
@@ -28,40 +29,30 @@ export class AstroSite extends SsrSite {
|
|
|
28
29
|
return JSON.parse(readFileSync(filePath, "utf-8"));
|
|
29
30
|
}
|
|
30
31
|
static getCFRoutingFunction({ routes, pageResolution, }) {
|
|
31
|
-
const serializedRoutes = routes.map((route) => ({
|
|
32
|
-
rt: route.route,
|
|
33
|
-
pt: new RegExp(route.pattern),
|
|
34
|
-
t: route.type[1],
|
|
35
|
-
pr: route.prerender === true ? true : undefined,
|
|
36
|
-
rp: route.redirectPath,
|
|
37
|
-
rs: route.redirectStatus,
|
|
38
|
-
}));
|
|
39
|
-
function objectToString(obj) {
|
|
40
|
-
return `{ ${Object.entries(obj)
|
|
41
|
-
.filter(([_, value]) => value !== undefined)
|
|
42
|
-
.map(([key, value]) => `${key}: ${typeof value === "string" ? `'${value}'` : value}`)
|
|
43
|
-
.join(", ")} }`;
|
|
44
|
-
}
|
|
45
32
|
return `
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
var routeData = ${getStringifiedRouteTree(routes)};
|
|
34
|
+
var findMatch = (path, routeData) => {
|
|
35
|
+
var match = routeData.find((route) => route[0].test(path));
|
|
36
|
+
return match && Array.isArray(match[1]) ? findMatch(path, match[1]) : match;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var matchedRoute = findMatch(request.uri, routeData);
|
|
40
|
+
if (matchedRoute) {
|
|
41
|
+
if (!matchedRoute[1]) {
|
|
42
|
+
${pageResolution === "file"
|
|
43
|
+
? `request.uri = request.uri === "/" ? "/index.html" : request.uri.replace(/\\/?$/, ".html");`
|
|
44
|
+
: `request.uri = request.uri.replace(/\\/?$/, "/index.html");`}
|
|
45
|
+
} else if (matchedRoute[1] === 2) {
|
|
46
|
+
var redirectPath = matchedRoute[2];
|
|
47
|
+
matchedRoute[0].exec(request.uri).forEach((match, index) => {
|
|
48
|
+
redirectPath = redirectPath.replace(\`\\\${\${index}}\`, match);
|
|
53
49
|
});
|
|
54
50
|
return {
|
|
55
|
-
statusCode:
|
|
51
|
+
statusCode: matchedRoute[3] || 308,
|
|
56
52
|
headers: { location: { value: redirectPath } },
|
|
57
53
|
};
|
|
58
|
-
} else if (match.t === "p" && match.pr) {
|
|
59
|
-
${pageResolution === "file"
|
|
60
|
-
? `request.uri = request.uri === "/" ? "/index.html" : request.uri.replace(/\\/?$/, ".html");`
|
|
61
|
-
: `request.uri = request.uri.replace(/\\/?$/, "/index.html");`}
|
|
62
54
|
}
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
55
|
+
}`;
|
|
65
56
|
}
|
|
66
57
|
plan() {
|
|
67
58
|
const { path: sitePath } = this.props;
|
package/constructs/Function.js
CHANGED
|
@@ -151,6 +151,7 @@ export class Function extends CDKFunction {
|
|
|
151
151
|
...props,
|
|
152
152
|
...(props.runtime === "container"
|
|
153
153
|
? {
|
|
154
|
+
description: "SST Live Lambda handler",
|
|
154
155
|
code: Code.fromAssetImage(path.resolve(__dirname, "../support/bridge"), {
|
|
155
156
|
...(architecture?.dockerPlatform
|
|
156
157
|
? { platform: Platform.custom(architecture.dockerPlatform) }
|
|
@@ -161,9 +162,10 @@ export class Function extends CDKFunction {
|
|
|
161
162
|
layers: undefined,
|
|
162
163
|
}
|
|
163
164
|
: {
|
|
165
|
+
description: "SST Live Lambda handler",
|
|
164
166
|
runtime: CDKRuntime.NODEJS_18_X,
|
|
165
167
|
code: Code.fromAsset(path.resolve(__dirname, "../support/bridge")),
|
|
166
|
-
handler: "
|
|
168
|
+
handler: "live-lambda.handler",
|
|
167
169
|
layers: [],
|
|
168
170
|
}),
|
|
169
171
|
architecture,
|
package/constructs/SsrSite.js
CHANGED
|
@@ -30,6 +30,7 @@ import { getParameterPath, } from "./util/functionBinding.js";
|
|
|
30
30
|
import { useProject } from "../project.js";
|
|
31
31
|
import { VisibleError } from "../error.js";
|
|
32
32
|
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
33
|
+
import { transformSync } from "esbuild";
|
|
33
34
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
34
35
|
/**
|
|
35
36
|
* The `SsrSite` construct is a higher level CDK construct that makes it easy to create modern web apps with Server Side Rendering capabilities.
|
|
@@ -371,13 +372,18 @@ export class SsrSite extends Construct {
|
|
|
371
372
|
function createCloudFrontFunctions() {
|
|
372
373
|
const functions = {};
|
|
373
374
|
Object.entries(plan.cloudFrontFunctions ?? {}).forEach(([name, { constructId, injections }]) => {
|
|
374
|
-
|
|
375
|
-
code: CfFunctionCode.fromInline(`
|
|
375
|
+
const rawCode = `
|
|
376
376
|
function handler(event) {
|
|
377
377
|
var request = event.request;
|
|
378
378
|
${injections.join("\n")}
|
|
379
379
|
return request;
|
|
380
|
-
}
|
|
380
|
+
}`;
|
|
381
|
+
const minifiedCode = transformSync(rawCode, {
|
|
382
|
+
minify: true,
|
|
383
|
+
target: "es5",
|
|
384
|
+
});
|
|
385
|
+
functions[name] = new CfFunction(self, constructId, {
|
|
386
|
+
code: CfFunctionCode.fromInline(minifiedCode.code),
|
|
381
387
|
});
|
|
382
388
|
});
|
|
383
389
|
return functions;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BuildMetaConfig } from "astro-sst/build-meta";
|
|
2
|
+
type TreeNode = {
|
|
3
|
+
branches: Record<string, TreeNode>;
|
|
4
|
+
nodes: BuildMetaConfig["routes"][number][];
|
|
5
|
+
};
|
|
6
|
+
type FlattenedRoute = [string] | [string, 1] | [string, 2, string | undefined, number | undefined];
|
|
7
|
+
type FlattenedRouteTree = Array<FlattenedRoute | [string, FlattenedRouteTree]>;
|
|
8
|
+
export declare function flattenRouteTree(tree: TreeNode, parentKey?: string): FlattenedRouteTree;
|
|
9
|
+
export declare function getStringifiedRouteTree(routes: BuildMetaConfig["routes"]): string;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
function buildRouteTree(routes, level = 0) {
|
|
2
|
+
const routeTree = routes.reduce((tree, route) => {
|
|
3
|
+
const routePatternWithoutCaptureGroups = route.pattern
|
|
4
|
+
.replace(/\((?:\?:)?(.*?[^\\])\)/g, (_, content) => content.trim())
|
|
5
|
+
.replace(/\/\^/g, "")
|
|
6
|
+
.replace(/\$\//g, "");
|
|
7
|
+
const routeParts = routePatternWithoutCaptureGroups
|
|
8
|
+
.split(/(?=\\\/)/g)
|
|
9
|
+
.filter((part) => part !== "/^" && part !== "/$/");
|
|
10
|
+
tree.branches[routeParts[level]] = tree.branches[routeParts[level]] || {
|
|
11
|
+
branches: {},
|
|
12
|
+
nodes: [],
|
|
13
|
+
};
|
|
14
|
+
tree.branches[routeParts[level]].nodes.push(route);
|
|
15
|
+
return tree;
|
|
16
|
+
}, { branches: {}, nodes: [] });
|
|
17
|
+
for (const [key, branch] of Object.entries(routeTree.branches)) {
|
|
18
|
+
if (!branch.nodes.some((node) => node.prerender || node.type === "redirect")) {
|
|
19
|
+
delete routeTree.branches[key];
|
|
20
|
+
}
|
|
21
|
+
else if (branch.nodes.length > 1) {
|
|
22
|
+
routeTree.branches[key] = buildRouteTree(branch.nodes, level + 1);
|
|
23
|
+
branch.nodes = [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return routeTree;
|
|
27
|
+
}
|
|
28
|
+
export function flattenRouteTree(tree, parentKey = "") {
|
|
29
|
+
const flatTree = [];
|
|
30
|
+
for (const [key, branch] of Object.entries(tree.branches)) {
|
|
31
|
+
if (branch.nodes.length === 1) {
|
|
32
|
+
const node = branch.nodes[0];
|
|
33
|
+
if (node.type === "page") {
|
|
34
|
+
flatTree.push([node.pattern]);
|
|
35
|
+
}
|
|
36
|
+
if (node.type === "endpoint") {
|
|
37
|
+
flatTree.push([node.pattern, 1]);
|
|
38
|
+
}
|
|
39
|
+
else if (node.type === "redirect") {
|
|
40
|
+
flatTree.push([
|
|
41
|
+
node.pattern,
|
|
42
|
+
2,
|
|
43
|
+
node.redirectPath,
|
|
44
|
+
node.redirectStatus,
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const flatKey = parentKey + key;
|
|
50
|
+
flatTree.push([flatKey, flattenRouteTree(branch, flatKey)]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return flatTree;
|
|
54
|
+
}
|
|
55
|
+
function stringifyFlattenedRouteTree(tree) {
|
|
56
|
+
return `[${tree
|
|
57
|
+
.map((tuple) => {
|
|
58
|
+
if (Array.isArray(tuple[1])) {
|
|
59
|
+
return `[/^${tuple[0]}/,${stringifyFlattenedRouteTree(tuple[1])}]`;
|
|
60
|
+
}
|
|
61
|
+
if (typeof tuple[1] === "undefined") {
|
|
62
|
+
return `[${tuple[0]}]`;
|
|
63
|
+
}
|
|
64
|
+
else if (tuple[1] === 1) {
|
|
65
|
+
return `[${tuple[0]},1]`;
|
|
66
|
+
}
|
|
67
|
+
return `[${tuple[0]},2,"${tuple[2]}"${tuple[3] ? `,${tuple[3]}` : ""}]`;
|
|
68
|
+
})
|
|
69
|
+
.join(",")}]`;
|
|
70
|
+
}
|
|
71
|
+
export function getStringifiedRouteTree(routes) {
|
|
72
|
+
const tree = buildRouteTree(routes);
|
|
73
|
+
const flatTree = flattenRouteTree(tree);
|
|
74
|
+
return stringifyFlattenedRouteTree(flatTree);
|
|
75
|
+
}
|
package/credentials.js
CHANGED
|
@@ -53,10 +53,22 @@ export function useAWSClient(client, force = false) {
|
|
|
53
53
|
const [project, credentials] = [useProject(), useAWSCredentialsProvider()];
|
|
54
54
|
const printNoInternet = (() => {
|
|
55
55
|
let lastPrinted = 0;
|
|
56
|
-
return () => {
|
|
56
|
+
return (message) => {
|
|
57
|
+
const isIotUnreachable = message.includes(`iot.${project.config.region}.amazonaws.com`);
|
|
57
58
|
const now = Date.now();
|
|
58
59
|
if (now - lastPrinted > 5000) {
|
|
59
|
-
|
|
60
|
+
if (isIotUnreachable) {
|
|
61
|
+
console.log("\nConnecting to Live Lambda...");
|
|
62
|
+
if (lastPrinted === 0) {
|
|
63
|
+
console.log("");
|
|
64
|
+
console.log("Connecting to Live Lambda is taking long:");
|
|
65
|
+
console.log(" - Check if your machine is able to connect to AWS.");
|
|
66
|
+
console.log(" - Or, if you're connecting to a new AWS account for the first time, give it 10 minutes.");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
console.log("\nWaiting for internet connection...");
|
|
71
|
+
}
|
|
60
72
|
lastPrinted = now;
|
|
61
73
|
}
|
|
62
74
|
};
|
|
@@ -68,7 +80,7 @@ export function useAWSClient(client, force = false) {
|
|
|
68
80
|
retryDecider: (e) => {
|
|
69
81
|
// Handle no internet connection => retry
|
|
70
82
|
if (e.code === "ENOTFOUND") {
|
|
71
|
-
printNoInternet();
|
|
83
|
+
printNoInternet(e.message);
|
|
72
84
|
return true;
|
|
73
85
|
}
|
|
74
86
|
// Handle throttling errors => retry
|
package/iot.d.ts
CHANGED
package/iot.js
CHANGED
|
@@ -114,7 +114,7 @@ export const useIOT = lazy(async () => {
|
|
|
114
114
|
Logger.debug("IoT closed");
|
|
115
115
|
});
|
|
116
116
|
device.on("reconnect", () => {
|
|
117
|
-
Logger.debug("IoT
|
|
117
|
+
Logger.debug("IoT reconnecting...");
|
|
118
118
|
});
|
|
119
119
|
device.on("message", (_topic, buffer) => {
|
|
120
120
|
const fragment = JSON.parse(buffer.toString());
|
|
@@ -161,3 +161,28 @@ export const useIOT = lazy(async () => {
|
|
|
161
161
|
},
|
|
162
162
|
};
|
|
163
163
|
});
|
|
164
|
+
export const isSupported = () => [
|
|
165
|
+
"eu-central-1",
|
|
166
|
+
"eu-west-1",
|
|
167
|
+
"eu-west-2",
|
|
168
|
+
"eu-west-3",
|
|
169
|
+
"eu-north-1",
|
|
170
|
+
"ap-south-1",
|
|
171
|
+
"ap-northeast-2",
|
|
172
|
+
"ap-northeast-1",
|
|
173
|
+
"me-south-1",
|
|
174
|
+
"me-central-1",
|
|
175
|
+
"sa-east-1",
|
|
176
|
+
"ca-central-1",
|
|
177
|
+
"ap-east-1",
|
|
178
|
+
"ap-southeast-1",
|
|
179
|
+
"ap-southeast-2",
|
|
180
|
+
"us-east-1",
|
|
181
|
+
"us-east-2",
|
|
182
|
+
"us-west-1",
|
|
183
|
+
"us-west-2",
|
|
184
|
+
"us-gov-east-1",
|
|
185
|
+
"us-gov-west-1",
|
|
186
|
+
"cn-north-1",
|
|
187
|
+
"cn-northwest-1",
|
|
188
|
+
].includes(useProject().config.region);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "sst",
|
|
4
|
-
"version": "2.38.
|
|
4
|
+
"version": "2.38.5",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sst": "cli/sst.js"
|
|
7
7
|
},
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"@types/ws": "^8.5.3",
|
|
121
121
|
"@types/yargs": "^17.0.13",
|
|
122
122
|
"archiver": "^5.3.1",
|
|
123
|
-
"astro-sst": "2.38.
|
|
123
|
+
"astro-sst": "2.38.5",
|
|
124
124
|
"async": "^3.2.4",
|
|
125
125
|
"tsx": "^3.12.1",
|
|
126
126
|
"typescript": "^5.2.2",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import process from "process";
|
|
2
|
+
import { release, networkInterfaces } from "os";
|
|
1
3
|
import http from "http";
|
|
2
4
|
import { spawn } from "child_process";
|
|
3
5
|
import { useRuntimeWorkers } from "../workers.js";
|
|
@@ -50,10 +52,11 @@ export const useContainerHandler = () => {
|
|
|
50
52
|
const server = await useRuntimeServerConfig();
|
|
51
53
|
const workers = await useRuntimeWorkers();
|
|
52
54
|
const fn = useFunctions().fromID(input.functionID);
|
|
55
|
+
const host = isWSL() ? getInternalHost() : "host.docker.internal";
|
|
53
56
|
dockerRun(input, {
|
|
54
57
|
cmd: fn?.container?.cmd,
|
|
55
58
|
envs: {
|
|
56
|
-
AWS_LAMBDA_RUNTIME_API:
|
|
59
|
+
AWS_LAMBDA_RUNTIME_API: `${host}:${server.port}/${input.workerID}`,
|
|
57
60
|
},
|
|
58
61
|
}, () => {
|
|
59
62
|
workers.exited(input.workerID);
|
|
@@ -261,3 +264,12 @@ export const useContainerHandler = () => {
|
|
|
261
264
|
},
|
|
262
265
|
};
|
|
263
266
|
};
|
|
267
|
+
function isWSL() {
|
|
268
|
+
return (process.platform == "linux" && release().toLowerCase().includes("microsoft"));
|
|
269
|
+
}
|
|
270
|
+
function getInternalHost() {
|
|
271
|
+
const host = []
|
|
272
|
+
.concat(...Object.values(networkInterfaces()))
|
|
273
|
+
.find((x) => !x?.internal && x?.family === "IPv4")?.address;
|
|
274
|
+
return host ?? "host.docker.internal";
|
|
275
|
+
}
|
package/runtime/handlers/node.js
CHANGED
|
@@ -87,7 +87,9 @@ export const useNodeHandler = () => {
|
|
|
87
87
|
const extension = isESM ? ".mjs" : ".cjs";
|
|
88
88
|
const target = path.join(input.out, !relative.startsWith("..") && !path.isAbsolute(input.props.handler)
|
|
89
89
|
? relative
|
|
90
|
-
: "",
|
|
90
|
+
: "",
|
|
91
|
+
// Lambda handler can only contain 1 dot separating the file name and function name
|
|
92
|
+
parsed.name.replace(".", "-") + extension);
|
|
91
93
|
const handler = path
|
|
92
94
|
.relative(input.out, target.replace(extension, parsed.ext))
|
|
93
95
|
.split(path.sep)
|
|
@@ -206,9 +208,25 @@ export const useNodeHandler = () => {
|
|
|
206
208
|
}));
|
|
207
209
|
const cmd = ["npm install"];
|
|
208
210
|
if (installPackages.includes("sharp")) {
|
|
209
|
-
|
|
211
|
+
/**
|
|
212
|
+
* TODO: This is a workaround for issues that sharp v0.33.0 has
|
|
213
|
+
* with cross platform builds. This can be removed once sharp
|
|
214
|
+
* releases a new version with the fix.
|
|
215
|
+
*/
|
|
216
|
+
cmd.push("--platform=linux", "--omit=dev", "--no-optional", input.props.architecture === "arm_64"
|
|
210
217
|
? "--arch=arm64"
|
|
211
|
-
: "--arch=x64");
|
|
218
|
+
: "--arch=x64", "--force sharp@0.32.6");
|
|
219
|
+
/**
|
|
220
|
+
* Once the above issue is resolved, the code below can be used.
|
|
221
|
+
*/
|
|
222
|
+
// cmd.push(
|
|
223
|
+
// "--platform=linux",
|
|
224
|
+
// "--omit=dev",
|
|
225
|
+
// "--no-optional",
|
|
226
|
+
// ...input.props.architecture === "arm_64"
|
|
227
|
+
// ? ["--arch=arm64", "--force @img/sharp-linux-arm64"]
|
|
228
|
+
// : ["--arch=x64", "--force @img/sharp-linux-x64"],
|
|
229
|
+
// );
|
|
212
230
|
}
|
|
213
231
|
await new Promise((resolve, reject) => {
|
|
214
232
|
exec(cmd.join(" "), { cwd: input.out }, (error) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
FROM public.ecr.aws/lambda/nodejs:18
|
|
2
|
-
COPY
|
|
3
|
-
CMD ["
|
|
2
|
+
COPY live-lambda.mjs ${LAMBDA_TASK_ROOT}
|
|
3
|
+
CMD ["live-lambda.handler"]
|
package/util/wsl.d.ts
ADDED
package/util/wsl.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import process from "process";
|
|
2
|
+
import { release, networkInterfaces } from "os";
|
|
3
|
+
export const isWSL = () => {
|
|
4
|
+
return (process.platform == "linux" && release().toLowerCase().includes("microsoft"));
|
|
5
|
+
};
|
|
6
|
+
export const getInternalHost = () => {
|
|
7
|
+
return []
|
|
8
|
+
.concat(...Object.values(networkInterfaces()))
|
|
9
|
+
.find((x) => !x?.internal && x?.family === "IPv4")?.address;
|
|
10
|
+
};
|
|
File without changes
|