sst 2.0.28 → 2.0.30
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/constructs/NextjsSite.js +7 -0
- package/constructs/RDS.js +1 -1
- package/package.json +1 -1
- package/runtime/handlers/python.js +16 -8
- package/runtime/handlers/rust.js +5 -0
- package/sst.mjs +25 -9
- package/stacks/build.js +2 -0
- package/util/fs.d.ts +1 -1
- package/util/fs.js +1 -1
package/constructs/NextjsSite.js
CHANGED
|
@@ -10,6 +10,7 @@ import { SsrFunction } from "./SsrFunction.js";
|
|
|
10
10
|
import { EdgeFunction } from "./EdgeFunction.js";
|
|
11
11
|
import { SsrSite } from "./SsrSite.js";
|
|
12
12
|
import { toCdkSize } from "./util/size.js";
|
|
13
|
+
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
13
14
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
14
15
|
/**
|
|
15
16
|
* The `NextjsSite` construct is a higher level CDK construct that makes it easy to create a Next.js app.
|
|
@@ -72,6 +73,12 @@ export class NextjsSite extends SsrSite {
|
|
|
72
73
|
environment: {
|
|
73
74
|
BUCKET_NAME: this.cdk.bucket.bucketName,
|
|
74
75
|
},
|
|
76
|
+
initialPolicy: [
|
|
77
|
+
new PolicyStatement({
|
|
78
|
+
actions: ["s3:GetObject"],
|
|
79
|
+
resources: [this.cdk.bucket.arnForObjects("*")],
|
|
80
|
+
}),
|
|
81
|
+
],
|
|
75
82
|
});
|
|
76
83
|
}
|
|
77
84
|
createMiddlewareEdgeFunctionForRegional() {
|
package/constructs/RDS.js
CHANGED
|
@@ -263,7 +263,7 @@ export class RDS extends Construct {
|
|
|
263
263
|
// - when running resources tests, __dirname is `resources/src`
|
|
264
264
|
// For now we will do `__dirname/../dist` to make both cases work.
|
|
265
265
|
const fn = new Fn(this, "MigrationFunction", {
|
|
266
|
-
handler: path.resolve(path.join(__dirname, "
|
|
266
|
+
handler: path.resolve(path.join(__dirname, "../../support/rds-migrator/index.handler")),
|
|
267
267
|
runtime: "nodejs16.x",
|
|
268
268
|
timeout: 900,
|
|
269
269
|
memorySize: 1024,
|
package/package.json
CHANGED
|
@@ -91,22 +91,30 @@ export const usePythonHandler = Context.memo(async () => {
|
|
|
91
91
|
type: "error",
|
|
92
92
|
errors: [`Could not find src for ${input.props.handler}`],
|
|
93
93
|
};
|
|
94
|
+
await fs.cp(src, input.out, {
|
|
95
|
+
recursive: true,
|
|
96
|
+
filter: (src) => !src.includes(".sst"),
|
|
97
|
+
});
|
|
94
98
|
if (await existsAsync(path.join(src, "Pipfile"))) {
|
|
95
|
-
await execAsync("pipenv requirements > requirements.txt"
|
|
99
|
+
await execAsync("pipenv requirements > requirements.txt", {
|
|
100
|
+
cwd: input.out,
|
|
101
|
+
});
|
|
96
102
|
}
|
|
97
103
|
if (await existsAsync(path.join(src, "poetry.lock"))) {
|
|
98
|
-
await execAsync("poetry export --with-credentials --format requirements.txt --output requirements.txt"
|
|
104
|
+
await execAsync("poetry export --with-credentials --format requirements.txt --output requirements.txt", {
|
|
105
|
+
cwd: input.out,
|
|
106
|
+
});
|
|
99
107
|
}
|
|
100
108
|
if (await existsAsync(path.join(src, "requirements.txt"))) {
|
|
101
|
-
await execAsync("pip install -r requirements.txt"
|
|
109
|
+
await execAsync("pip install -r requirements.txt", {
|
|
110
|
+
cwd: input.out,
|
|
111
|
+
});
|
|
102
112
|
}
|
|
103
|
-
await fs.cp(src, input.out, {
|
|
104
|
-
recursive: true,
|
|
105
|
-
filter: (src) => !src.includes(".sst"),
|
|
106
|
-
});
|
|
107
113
|
if (input.props.python?.installCommands) {
|
|
108
114
|
for (const cmd of input.props.python.installCommands) {
|
|
109
|
-
await execAsync(cmd
|
|
115
|
+
await execAsync(cmd, {
|
|
116
|
+
cwd: input.out,
|
|
117
|
+
});
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
120
|
const result = {
|
package/runtime/handlers/rust.js
CHANGED
|
@@ -58,6 +58,11 @@ export const useRustHandler = Context.memo(async () => {
|
|
|
58
58
|
build: async (input) => {
|
|
59
59
|
const parsed = path.parse(input.props.handler);
|
|
60
60
|
const project = await findAbove(parsed.dir, "Cargo.toml");
|
|
61
|
+
if (!project)
|
|
62
|
+
return {
|
|
63
|
+
type: "error",
|
|
64
|
+
errors: ["Could not find a Cargo.toml file"],
|
|
65
|
+
};
|
|
61
66
|
sources.set(input.functionID, project);
|
|
62
67
|
if (input.mode === "start") {
|
|
63
68
|
try {
|
package/sst.mjs
CHANGED
|
@@ -181,7 +181,7 @@ import fs2 from "fs/promises";
|
|
|
181
181
|
import path2 from "path";
|
|
182
182
|
async function findAbove(dir, target) {
|
|
183
183
|
if (dir === "/")
|
|
184
|
-
|
|
184
|
+
return void 0;
|
|
185
185
|
if (await existsAsync(path2.join(dir, target)))
|
|
186
186
|
return dir;
|
|
187
187
|
return findAbove(path2.resolve(path2.join(dir, "..")), target);
|
|
@@ -235,6 +235,8 @@ import path3 from "path";
|
|
|
235
235
|
async function load(input) {
|
|
236
236
|
const parsed = path3.parse(input);
|
|
237
237
|
const root = await findAbove(input, "package.json");
|
|
238
|
+
if (!root)
|
|
239
|
+
throw new VisibleError("Could not find a package.json file");
|
|
238
240
|
const outfile = path3.join(parsed.dir, `.${parsed.name}.${Date.now()}.mjs`);
|
|
239
241
|
const pkg = JSON.parse(
|
|
240
242
|
await fs3.readFile(path3.join(root, "package.json")).then((x) => x.toString())
|
|
@@ -5132,6 +5134,11 @@ var init_rust = __esm({
|
|
|
5132
5134
|
build: async (input) => {
|
|
5133
5135
|
const parsed = path12.parse(input.props.handler);
|
|
5134
5136
|
const project = await findAbove(parsed.dir, "Cargo.toml");
|
|
5137
|
+
if (!project)
|
|
5138
|
+
return {
|
|
5139
|
+
type: "error",
|
|
5140
|
+
errors: ["Could not find a Cargo.toml file"]
|
|
5141
|
+
};
|
|
5135
5142
|
sources.set(input.functionID, project);
|
|
5136
5143
|
if (input.mode === "start") {
|
|
5137
5144
|
try {
|
|
@@ -5283,24 +5290,33 @@ var init_python = __esm({
|
|
|
5283
5290
|
type: "error",
|
|
5284
5291
|
errors: [`Could not find src for ${input.props.handler}`]
|
|
5285
5292
|
};
|
|
5293
|
+
await fs13.cp(src, input.out, {
|
|
5294
|
+
recursive: true,
|
|
5295
|
+
filter: (src2) => !src2.includes(".sst")
|
|
5296
|
+
});
|
|
5286
5297
|
if (await existsAsync(path13.join(src, "Pipfile"))) {
|
|
5287
|
-
await execAsync4("pipenv requirements > requirements.txt"
|
|
5298
|
+
await execAsync4("pipenv requirements > requirements.txt", {
|
|
5299
|
+
cwd: input.out
|
|
5300
|
+
});
|
|
5288
5301
|
}
|
|
5289
5302
|
if (await existsAsync(path13.join(src, "poetry.lock"))) {
|
|
5290
5303
|
await execAsync4(
|
|
5291
|
-
"poetry export --with-credentials --format requirements.txt --output requirements.txt"
|
|
5304
|
+
"poetry export --with-credentials --format requirements.txt --output requirements.txt",
|
|
5305
|
+
{
|
|
5306
|
+
cwd: input.out
|
|
5307
|
+
}
|
|
5292
5308
|
);
|
|
5293
5309
|
}
|
|
5294
5310
|
if (await existsAsync(path13.join(src, "requirements.txt"))) {
|
|
5295
|
-
await execAsync4("pip install -r requirements.txt"
|
|
5311
|
+
await execAsync4("pip install -r requirements.txt", {
|
|
5312
|
+
cwd: input.out
|
|
5313
|
+
});
|
|
5296
5314
|
}
|
|
5297
|
-
await fs13.cp(src, input.out, {
|
|
5298
|
-
recursive: true,
|
|
5299
|
-
filter: (src2) => !src2.includes(".sst")
|
|
5300
|
-
});
|
|
5301
5315
|
if (input.props.python?.installCommands) {
|
|
5302
5316
|
for (const cmd of input.props.python.installCommands) {
|
|
5303
|
-
await execAsync4(cmd
|
|
5317
|
+
await execAsync4(cmd, {
|
|
5318
|
+
cwd: input.out
|
|
5319
|
+
});
|
|
5304
5320
|
}
|
|
5305
5321
|
}
|
|
5306
5322
|
const result = {
|
package/stacks/build.js
CHANGED
|
@@ -7,6 +7,8 @@ import { VisibleError } from "../error.js";
|
|
|
7
7
|
export async function load(input) {
|
|
8
8
|
const parsed = path.parse(input);
|
|
9
9
|
const root = await findAbove(input, "package.json");
|
|
10
|
+
if (!root)
|
|
11
|
+
throw new VisibleError("Could not find a package.json file");
|
|
10
12
|
const outfile = path.join(parsed.dir, `.${parsed.name}.${Date.now()}.mjs`);
|
|
11
13
|
const pkg = JSON.parse(await fs.readFile(path.join(root, "package.json")).then((x) => x.toString()));
|
|
12
14
|
try {
|
package/util/fs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function findAbove(dir: string, target: string): Promise<string>;
|
|
1
|
+
export declare function findAbove(dir: string, target: string): Promise<string | undefined>;
|
|
2
2
|
export declare function findBelow(dir: string, target: string): Promise<string>;
|
|
3
3
|
export declare function isChild(parent: string, child: string): boolean;
|
|
4
4
|
export declare function existsAsync(input: string): Promise<boolean>;
|
package/util/fs.js
CHANGED
|
@@ -3,7 +3,7 @@ import fs from "fs/promises";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
export async function findAbove(dir, target) {
|
|
5
5
|
if (dir === "/")
|
|
6
|
-
|
|
6
|
+
return undefined;
|
|
7
7
|
if (await existsAsync(path.join(dir, target)))
|
|
8
8
|
return dir;
|
|
9
9
|
return findAbove(path.resolve(path.join(dir, "..")), target);
|