sst 2.0.22 → 2.0.24
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/README.md +43 -0
- package/cli/commands/dev.js +6 -6
- package/cli/telemetry/post-payload.js +17 -12
- package/constructs/Function.d.ts +2 -1
- package/constructs/Function.js +5 -1
- package/constructs/util/warning.d.ts +1 -0
- package/constructs/util/warning.js +1 -0
- package/package.json +1 -1
- package/runtime/handlers/go.js +5 -5
- package/runtime/handlers/node.js +1 -1
- package/runtime/handlers/python.js +27 -3
- package/sst.mjs +97 -70
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# sst
|
|
2
|
+
|
|
3
|
+
[SST](https://sst.dev) makes it easy to build modern full-stack applications on AWS.
|
|
4
|
+
|
|
5
|
+
The `sst` package is made up of the following.
|
|
6
|
+
|
|
7
|
+
- [`sst`](https://docs.sst.dev/packages/sst) CLI
|
|
8
|
+
- [`sst/node`](https://docs.sst.dev/clients) Node.js client
|
|
9
|
+
- [`sst/constructs`](https://docs.sst.dev/constructs) CDK constructs
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Install the `sst` package in your project root.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install sst --save-exact
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Once installed, you can run the CLI commands using.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx sst <command>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Import the Node.js client in your functions. For example, you can import the `Bucket` client.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { Bucket } from "sst/node/bucket";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
And import the constructs you need in your stacks code. For example, you can add an API.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { Api } from "sst/constructs";
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For more details, [head over to our docs](https://docs.sst.dev).
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
**Join our community** [Discord](https://sst.dev/discord) | [YouTube](https://www.youtube.com/c/sst-dev) | [Twitter](https://twitter.com/SST_dev)
|
package/cli/commands/dev.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Colors } from "../colors.js";
|
|
2
|
-
import { printHeader } from "../ui/header.js";
|
|
3
|
-
import { mapValues, omitBy, pipe } from "remeda";
|
|
4
1
|
export const dev = (program) => program.command(["dev", "start"], "Work on your app locally", (yargs) => yargs.option("increase-timeout", {
|
|
5
2
|
type: "boolean",
|
|
6
3
|
description: "Increase function timeout",
|
|
7
4
|
}), async (args) => {
|
|
5
|
+
const { Colors } = await import("../colors.js");
|
|
6
|
+
const { printHeader } = await import("../ui/header.js");
|
|
7
|
+
const { mapValues, omitBy, pipe } = await import("remeda");
|
|
8
|
+
const path = await import("path");
|
|
8
9
|
const { useRuntimeWorkers } = await import("../../runtime/workers.js");
|
|
9
10
|
const { useIOTBridge } = await import("../../runtime/iot.js");
|
|
10
11
|
const { useRuntimeServer } = await import("../../runtime/server.js");
|
|
@@ -19,7 +20,6 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
19
20
|
const { Context } = await import("../../context/context.js");
|
|
20
21
|
const { printDeploymentResults, DeploymentUI } = await import("../ui/deploy.js");
|
|
21
22
|
const { useLocalServer } = await import("../local/server.js");
|
|
22
|
-
const path = await import("path");
|
|
23
23
|
const fs = await import("fs/promises");
|
|
24
24
|
const crypto = await import("crypto");
|
|
25
25
|
const { useFunctions } = await import("../../constructs/Function.js");
|
|
@@ -57,7 +57,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
57
57
|
pending.delete(requestID);
|
|
58
58
|
}
|
|
59
59
|
bus.subscribe("function.invoked", async (evt) => {
|
|
60
|
-
Colors.line(prefix(evt.properties.requestID), Colors.dim.bold("Invoked"), Colors.dim(useFunctions().fromID(evt.properties.functionID)
|
|
60
|
+
Colors.line(prefix(evt.properties.requestID), Colors.dim.bold("Invoked"), Colors.dim(useFunctions().fromID(evt.properties.functionID)?.handler));
|
|
61
61
|
});
|
|
62
62
|
bus.subscribe("worker.stdout", async (evt) => {
|
|
63
63
|
prefix(evt.properties.requestID);
|
|
@@ -217,7 +217,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
217
217
|
watcher.subscribe("file.changed", async (evt) => {
|
|
218
218
|
if (!project.metafile)
|
|
219
219
|
return;
|
|
220
|
-
if (!project.metafile.inputs[evt.properties.relative])
|
|
220
|
+
if (!project.metafile.inputs[evt.properties.relative.split(path.sep).join(path.posix.sep)])
|
|
221
221
|
return;
|
|
222
222
|
build();
|
|
223
223
|
});
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import https from "https";
|
|
2
2
|
export function postPayload(endpoint, body) {
|
|
3
3
|
return new Promise((resolve, reject) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
try {
|
|
5
|
+
const req = https.request(endpoint, {
|
|
6
|
+
method: "POST",
|
|
7
|
+
headers: { "content-type": "application/json" },
|
|
8
|
+
timeout: 5000,
|
|
9
|
+
}, (resp) => {
|
|
10
|
+
if (resp.statusCode !== 200) {
|
|
11
|
+
reject(new Error(`Unexpected status code: ${resp.statusCode}`));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
resolve();
|
|
15
|
+
});
|
|
16
|
+
req.write(JSON.stringify(body));
|
|
17
|
+
req.end();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
13
20
|
resolve();
|
|
14
|
-
}
|
|
15
|
-
req.write(JSON.stringify(body));
|
|
16
|
-
req.end();
|
|
21
|
+
}
|
|
17
22
|
});
|
|
18
23
|
}
|
package/constructs/Function.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ declare const supportedRuntimes: {
|
|
|
33
33
|
java8: cdk.aws_lambda.Runtime;
|
|
34
34
|
java11: cdk.aws_lambda.Runtime;
|
|
35
35
|
"go1.x": cdk.aws_lambda.Runtime;
|
|
36
|
+
go: cdk.aws_lambda.Runtime;
|
|
36
37
|
};
|
|
37
38
|
export type Runtime = keyof typeof supportedRuntimes;
|
|
38
39
|
export type FunctionInlineDefinition = string | Function;
|
|
@@ -367,7 +368,7 @@ export interface NodeJSProps {
|
|
|
367
368
|
* ```js
|
|
368
369
|
* new Function(stack, "Function", {
|
|
369
370
|
* nodejs: {
|
|
370
|
-
*
|
|
371
|
+
* install: ["pg"]
|
|
371
372
|
* }
|
|
372
373
|
* })
|
|
373
374
|
* ```
|
package/constructs/Function.js
CHANGED
|
@@ -19,6 +19,7 @@ import { useDeferredTasks } from "./deferred_task.js";
|
|
|
19
19
|
import { useProject } from "../project.js";
|
|
20
20
|
import { useRuntimeHandlers } from "../runtime/handlers.js";
|
|
21
21
|
import { createAppContext } from "./context.js";
|
|
22
|
+
import { useWarning } from "./util/warning.js";
|
|
22
23
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
23
24
|
const supportedRuntimes = {
|
|
24
25
|
rust: lambda.Runtime.PROVIDED_AL2,
|
|
@@ -43,7 +44,8 @@ const supportedRuntimes = {
|
|
|
43
44
|
dotnet6: lambda.Runtime.DOTNET_6,
|
|
44
45
|
java8: lambda.Runtime.JAVA_8,
|
|
45
46
|
java11: lambda.Runtime.JAVA_11,
|
|
46
|
-
"go1.x": lambda.Runtime.
|
|
47
|
+
"go1.x": lambda.Runtime.PROVIDED_AL2,
|
|
48
|
+
go: lambda.Runtime.PROVIDED_AL2,
|
|
47
49
|
};
|
|
48
50
|
/**
|
|
49
51
|
* The `Function` construct is a higher level CDK construct that makes it easy to create a Lambda Function with support for Live Lambda Development.
|
|
@@ -77,6 +79,8 @@ export class Function extends lambda.Function {
|
|
|
77
79
|
props = Function.mergeProps(per, props);
|
|
78
80
|
});
|
|
79
81
|
props.runtime = props.runtime || "nodejs16.x";
|
|
82
|
+
if (props.runtime === "go1.x")
|
|
83
|
+
useWarning().add("go.deprecated");
|
|
80
84
|
// Set defaults
|
|
81
85
|
const functionName = props.functionName &&
|
|
82
86
|
(typeof props.functionName === "string"
|
|
@@ -2,6 +2,7 @@ import { createAppContext } from "../context.js";
|
|
|
2
2
|
const WARNINGS = {
|
|
3
3
|
"config.deprecated": `WARNING: The "config" prop is deprecated, and will be removed in SST v2. Pass Parameters and Secrets in through the "bind" prop. Read more about how to upgrade here — https://docs.serverless-stack.com/upgrade-guide#upgrade-to-v116`,
|
|
4
4
|
"permissions.noConstructs": `WARNING: Passing SST constructs into "permissions" is deprecated, and will be removed in SST v2. Pass them into the "bind" prop. Read more about how to upgrade here — https://docs.serverless-stack.com/upgrade-guide#upgrade-to-v116`,
|
|
5
|
+
"go.deprecated": `WARNING: The "go1.x" runtime is deprecated and replaced by the "go" runtime`,
|
|
5
6
|
};
|
|
6
7
|
export const useWarning = createAppContext(() => {
|
|
7
8
|
const set = new Set();
|
package/package.json
CHANGED
package/runtime/handlers/go.js
CHANGED
|
@@ -15,7 +15,7 @@ export const useGoHandler = Context.memo(async () => {
|
|
|
15
15
|
const handlers = useRuntimeHandlers();
|
|
16
16
|
const processes = new Map();
|
|
17
17
|
const sources = new Map();
|
|
18
|
-
const handlerName = process.platform === "win32" ? `
|
|
18
|
+
const handlerName = process.platform === "win32" ? `bootstrap.exe` : `bootstrap`;
|
|
19
19
|
handlers.register({
|
|
20
20
|
shouldBuild: (input) => {
|
|
21
21
|
const parent = sources.get(input.functionID);
|
|
@@ -71,13 +71,13 @@ export const useGoHandler = Context.memo(async () => {
|
|
|
71
71
|
}
|
|
72
72
|
if (input.mode === "deploy") {
|
|
73
73
|
try {
|
|
74
|
-
const target = path.join(input.out, "
|
|
75
|
-
|
|
74
|
+
const target = path.join(input.out, "bootstrap");
|
|
75
|
+
await execAsync(`go build -ldflags '-s -w' -o ${target} ./${src}`, {
|
|
76
76
|
cwd: project,
|
|
77
77
|
env: {
|
|
78
78
|
...process.env,
|
|
79
79
|
CGO_ENABLED: "0",
|
|
80
|
-
GOARCH: "amd64",
|
|
80
|
+
GOARCH: input.props.architecture === "arm_64" ? "arm64" : "amd64",
|
|
81
81
|
GOOS: "linux",
|
|
82
82
|
},
|
|
83
83
|
});
|
|
@@ -88,7 +88,7 @@ export const useGoHandler = Context.memo(async () => {
|
|
|
88
88
|
}
|
|
89
89
|
return {
|
|
90
90
|
type: "success",
|
|
91
|
-
handler: "
|
|
91
|
+
handler: "bootstrap",
|
|
92
92
|
};
|
|
93
93
|
},
|
|
94
94
|
});
|
package/runtime/handlers/node.js
CHANGED
|
@@ -74,7 +74,7 @@ export const useNodeHandler = Context.memo(async () => {
|
|
|
74
74
|
if (!file)
|
|
75
75
|
return {
|
|
76
76
|
type: "error",
|
|
77
|
-
errors: [`Could not find file for handler ${input.props.handler}`],
|
|
77
|
+
errors: [`Could not find file for handler "${input.props.handler}"`],
|
|
78
78
|
};
|
|
79
79
|
const nodejs = input.props.nodejs || {};
|
|
80
80
|
const isESM = (nodejs.format || "esm") === "esm";
|
|
@@ -5,7 +5,7 @@ import { Context } from "../../context/context.js";
|
|
|
5
5
|
import { exec, spawn } from "child_process";
|
|
6
6
|
import { promisify } from "util";
|
|
7
7
|
import { useRuntimeServerConfig } from "../server.js";
|
|
8
|
-
import { findAbove, isChild } from "../../util/fs.js";
|
|
8
|
+
import { existsAsync, findAbove, isChild } from "../../util/fs.js";
|
|
9
9
|
import { Runtime } from "aws-cdk-lib/aws-lambda";
|
|
10
10
|
import fs from "fs/promises";
|
|
11
11
|
const execAsync = promisify(exec);
|
|
@@ -24,6 +24,14 @@ export const usePythonHandler = Context.memo(async () => {
|
|
|
24
24
|
const handlers = useRuntimeHandlers();
|
|
25
25
|
const processes = new Map();
|
|
26
26
|
const sources = new Map();
|
|
27
|
+
async function findSrc(input) {
|
|
28
|
+
const hints = ["requirements.txt", "Pipfile", "poetry.lock"];
|
|
29
|
+
for (const hint of hints) {
|
|
30
|
+
const result = await findAbove(input, hint);
|
|
31
|
+
if (result)
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
27
35
|
handlers.register({
|
|
28
36
|
shouldBuild: (input) => {
|
|
29
37
|
const parent = sources.get(input.functionID);
|
|
@@ -33,7 +41,9 @@ export const usePythonHandler = Context.memo(async () => {
|
|
|
33
41
|
},
|
|
34
42
|
canHandle: (input) => input.startsWith("python"),
|
|
35
43
|
startWorker: async (input) => {
|
|
36
|
-
const src = await
|
|
44
|
+
const src = await findSrc(input.handler);
|
|
45
|
+
if (!src)
|
|
46
|
+
throw new Error(`Could not find src for ${input.handler}`);
|
|
37
47
|
const parsed = path.parse(path.relative(src, input.handler));
|
|
38
48
|
const target = [...parsed.dir.split(path.sep), parsed.name].join(".");
|
|
39
49
|
const proc = spawn(os.platform() === "win32" ? "python.exe" : "python3", [
|
|
@@ -75,7 +85,21 @@ export const usePythonHandler = Context.memo(async () => {
|
|
|
75
85
|
type: "success",
|
|
76
86
|
handler: input.props.handler,
|
|
77
87
|
};
|
|
78
|
-
const src = await
|
|
88
|
+
const src = await findSrc(input.props.handler);
|
|
89
|
+
if (!src)
|
|
90
|
+
return {
|
|
91
|
+
type: "error",
|
|
92
|
+
errors: [`Could not find src for ${input.props.handler}`],
|
|
93
|
+
};
|
|
94
|
+
if (await existsAsync(path.join(src, "Pipfile"))) {
|
|
95
|
+
await execAsync("pipenv requirements > requirements.txt");
|
|
96
|
+
}
|
|
97
|
+
if (await existsAsync(path.join(src, "poetry.lock"))) {
|
|
98
|
+
await execAsync("poetry export --with-credentials --format requirements.txt --output requirements.txt");
|
|
99
|
+
}
|
|
100
|
+
if (await existsAsync(path.join(src, "requirements.txt"))) {
|
|
101
|
+
await execAsync("pip install -r requirements.txt");
|
|
102
|
+
}
|
|
79
103
|
await fs.cp(src, input.out, {
|
|
80
104
|
recursive: true,
|
|
81
105
|
filter: (src) => !src.includes(".sst"),
|
package/sst.mjs
CHANGED
|
@@ -455,23 +455,27 @@ var init_project = __esm({
|
|
|
455
455
|
import https from "https";
|
|
456
456
|
function postPayload(endpoint, body) {
|
|
457
457
|
return new Promise((resolve, reject) => {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
458
|
+
try {
|
|
459
|
+
const req = https.request(
|
|
460
|
+
endpoint,
|
|
461
|
+
{
|
|
462
|
+
method: "POST",
|
|
463
|
+
headers: { "content-type": "application/json" },
|
|
464
|
+
timeout: 5e3
|
|
465
|
+
},
|
|
466
|
+
(resp) => {
|
|
467
|
+
if (resp.statusCode !== 200) {
|
|
468
|
+
reject(new Error(`Unexpected status code: ${resp.statusCode}`));
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
resolve();
|
|
469
472
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
473
|
+
);
|
|
474
|
+
req.write(JSON.stringify(body));
|
|
475
|
+
req.end();
|
|
476
|
+
} catch {
|
|
477
|
+
resolve();
|
|
478
|
+
}
|
|
475
479
|
});
|
|
476
480
|
}
|
|
477
481
|
var init_post_payload = __esm({
|
|
@@ -4812,7 +4816,7 @@ var init_node = __esm({
|
|
|
4812
4816
|
if (!file)
|
|
4813
4817
|
return {
|
|
4814
4818
|
type: "error",
|
|
4815
|
-
errors: [`Could not find file for handler ${input.props.handler}`]
|
|
4819
|
+
errors: [`Could not find file for handler "${input.props.handler}"`]
|
|
4816
4820
|
};
|
|
4817
4821
|
const nodejs = input.props.nodejs || {};
|
|
4818
4822
|
const isESM = (nodejs.format || "esm") === "esm";
|
|
@@ -4971,7 +4975,7 @@ var init_go = __esm({
|
|
|
4971
4975
|
const handlers = useRuntimeHandlers();
|
|
4972
4976
|
const processes = /* @__PURE__ */ new Map();
|
|
4973
4977
|
const sources = /* @__PURE__ */ new Map();
|
|
4974
|
-
const handlerName = process.platform === "win32" ? `
|
|
4978
|
+
const handlerName = process.platform === "win32" ? `bootstrap.exe` : `bootstrap`;
|
|
4975
4979
|
handlers.register({
|
|
4976
4980
|
shouldBuild: (input) => {
|
|
4977
4981
|
const parent = sources.get(input.functionID);
|
|
@@ -5029,26 +5033,23 @@ var init_go = __esm({
|
|
|
5029
5033
|
}
|
|
5030
5034
|
if (input.mode === "deploy") {
|
|
5031
5035
|
try {
|
|
5032
|
-
const target = path11.join(input.out, "
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
{
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
GOARCH: "amd64",
|
|
5041
|
-
GOOS: "linux"
|
|
5042
|
-
}
|
|
5036
|
+
const target = path11.join(input.out, "bootstrap");
|
|
5037
|
+
await execAsync2(`go build -ldflags '-s -w' -o ${target} ./${src}`, {
|
|
5038
|
+
cwd: project,
|
|
5039
|
+
env: {
|
|
5040
|
+
...process.env,
|
|
5041
|
+
CGO_ENABLED: "0",
|
|
5042
|
+
GOARCH: input.props.architecture === "arm_64" ? "arm64" : "amd64",
|
|
5043
|
+
GOOS: "linux"
|
|
5043
5044
|
}
|
|
5044
|
-
);
|
|
5045
|
+
});
|
|
5045
5046
|
} catch {
|
|
5046
5047
|
throw new VisibleError("Failed to build");
|
|
5047
5048
|
}
|
|
5048
5049
|
}
|
|
5049
5050
|
return {
|
|
5050
5051
|
type: "success",
|
|
5051
|
-
handler: "
|
|
5052
|
+
handler: "bootstrap"
|
|
5052
5053
|
};
|
|
5053
5054
|
}
|
|
5054
5055
|
});
|
|
@@ -5203,6 +5204,14 @@ var init_python = __esm({
|
|
|
5203
5204
|
const handlers = useRuntimeHandlers();
|
|
5204
5205
|
const processes = /* @__PURE__ */ new Map();
|
|
5205
5206
|
const sources = /* @__PURE__ */ new Map();
|
|
5207
|
+
async function findSrc(input) {
|
|
5208
|
+
const hints = ["requirements.txt", "Pipfile", "poetry.lock"];
|
|
5209
|
+
for (const hint of hints) {
|
|
5210
|
+
const result = await findAbove(input, hint);
|
|
5211
|
+
if (result)
|
|
5212
|
+
return result;
|
|
5213
|
+
}
|
|
5214
|
+
}
|
|
5206
5215
|
handlers.register({
|
|
5207
5216
|
shouldBuild: (input) => {
|
|
5208
5217
|
const parent = sources.get(input.functionID);
|
|
@@ -5212,7 +5221,9 @@ var init_python = __esm({
|
|
|
5212
5221
|
},
|
|
5213
5222
|
canHandle: (input) => input.startsWith("python"),
|
|
5214
5223
|
startWorker: async (input) => {
|
|
5215
|
-
const src = await
|
|
5224
|
+
const src = await findSrc(input.handler);
|
|
5225
|
+
if (!src)
|
|
5226
|
+
throw new Error(`Could not find src for ${input.handler}`);
|
|
5216
5227
|
const parsed = path13.parse(path13.relative(src, input.handler));
|
|
5217
5228
|
const target = [...parsed.dir.split(path13.sep), parsed.name].join(".");
|
|
5218
5229
|
const proc = spawn5(
|
|
@@ -5260,7 +5271,23 @@ var init_python = __esm({
|
|
|
5260
5271
|
type: "success",
|
|
5261
5272
|
handler: input.props.handler
|
|
5262
5273
|
};
|
|
5263
|
-
const src = await
|
|
5274
|
+
const src = await findSrc(input.props.handler);
|
|
5275
|
+
if (!src)
|
|
5276
|
+
return {
|
|
5277
|
+
type: "error",
|
|
5278
|
+
errors: [`Could not find src for ${input.props.handler}`]
|
|
5279
|
+
};
|
|
5280
|
+
if (await existsAsync(path13.join(src, "Pipfile"))) {
|
|
5281
|
+
await execAsync4("pipenv requirements > requirements.txt");
|
|
5282
|
+
}
|
|
5283
|
+
if (await existsAsync(path13.join(src, "poetry.lock"))) {
|
|
5284
|
+
await execAsync4(
|
|
5285
|
+
"poetry export --with-credentials --format requirements.txt --output requirements.txt"
|
|
5286
|
+
);
|
|
5287
|
+
}
|
|
5288
|
+
if (await existsAsync(path13.join(src, "requirements.txt"))) {
|
|
5289
|
+
await execAsync4("pip install -r requirements.txt");
|
|
5290
|
+
}
|
|
5264
5291
|
await fs13.cp(src, input.out, {
|
|
5265
5292
|
recursive: true,
|
|
5266
5293
|
filter: (src2) => !src2.includes(".sst")
|
|
@@ -6200,7 +6227,7 @@ import {
|
|
|
6200
6227
|
LambdaClient,
|
|
6201
6228
|
UpdateFunctionConfigurationCommand
|
|
6202
6229
|
} from "@aws-sdk/client-lambda";
|
|
6203
|
-
import { pipe as
|
|
6230
|
+
import { pipe as pipe2, map as map2 } from "remeda";
|
|
6204
6231
|
async function* scan(prefix) {
|
|
6205
6232
|
const ssm = useAWSClient(SSMClient);
|
|
6206
6233
|
let token;
|
|
@@ -6293,7 +6320,7 @@ var init_config = __esm({
|
|
|
6293
6320
|
const env3 = {
|
|
6294
6321
|
SST_APP: project.config.name,
|
|
6295
6322
|
SST_STAGE: project.config.stage,
|
|
6296
|
-
...
|
|
6323
|
+
...pipe2(
|
|
6297
6324
|
parameters2,
|
|
6298
6325
|
map2((p) => [envFor(p), p.value]),
|
|
6299
6326
|
Object.fromEntries
|
|
@@ -6495,9 +6522,6 @@ var env = (program2) => program2.command(
|
|
|
6495
6522
|
).strict(false);
|
|
6496
6523
|
|
|
6497
6524
|
// src/cli/commands/dev.tsx
|
|
6498
|
-
init_colors();
|
|
6499
|
-
init_header();
|
|
6500
|
-
import { mapValues, omitBy as omitBy2, pipe as pipe2 } from "remeda";
|
|
6501
6525
|
var dev = (program2) => program2.command(
|
|
6502
6526
|
["dev", "start"],
|
|
6503
6527
|
"Work on your app locally",
|
|
@@ -6506,6 +6530,10 @@ var dev = (program2) => program2.command(
|
|
|
6506
6530
|
description: "Increase function timeout"
|
|
6507
6531
|
}),
|
|
6508
6532
|
async (args) => {
|
|
6533
|
+
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
6534
|
+
const { printHeader: printHeader2 } = await Promise.resolve().then(() => (init_header(), header_exports));
|
|
6535
|
+
const { mapValues, omitBy: omitBy2, pipe: pipe3 } = await import("remeda");
|
|
6536
|
+
const path19 = await import("path");
|
|
6509
6537
|
const { useRuntimeWorkers: useRuntimeWorkers2 } = await Promise.resolve().then(() => (init_workers(), workers_exports));
|
|
6510
6538
|
const { useIOTBridge: useIOTBridge2 } = await Promise.resolve().then(() => (init_iot2(), iot_exports));
|
|
6511
6539
|
const { useRuntimeServer: useRuntimeServer2 } = await Promise.resolve().then(() => (init_server2(), server_exports2));
|
|
@@ -6520,7 +6548,6 @@ var dev = (program2) => program2.command(
|
|
|
6520
6548
|
const { Context: Context2 } = await Promise.resolve().then(() => (init_context(), context_exports));
|
|
6521
6549
|
const { printDeploymentResults: printDeploymentResults2, DeploymentUI: DeploymentUI2 } = await Promise.resolve().then(() => (init_deploy2(), deploy_exports));
|
|
6522
6550
|
const { useLocalServer: useLocalServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
6523
|
-
const path19 = await import("path");
|
|
6524
6551
|
const fs19 = await import("fs/promises");
|
|
6525
6552
|
const crypto2 = await import("crypto");
|
|
6526
6553
|
const { useFunctions: useFunctions3 } = await import("../src/constructs/Function.js");
|
|
@@ -6548,7 +6575,7 @@ var dev = (program2) => program2.command(
|
|
|
6548
6575
|
function prefix(requestID) {
|
|
6549
6576
|
const exists = pending.get(requestID);
|
|
6550
6577
|
if (exists) {
|
|
6551
|
-
return
|
|
6578
|
+
return Colors2.hex(exists.color)(Colors2.prefix);
|
|
6552
6579
|
}
|
|
6553
6580
|
pending.set(requestID, {
|
|
6554
6581
|
requestID,
|
|
@@ -6562,11 +6589,11 @@ var dev = (program2) => program2.command(
|
|
|
6562
6589
|
pending.delete(requestID);
|
|
6563
6590
|
}
|
|
6564
6591
|
bus.subscribe("function.invoked", async (evt) => {
|
|
6565
|
-
|
|
6592
|
+
Colors2.line(
|
|
6566
6593
|
prefix(evt.properties.requestID),
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
useFunctions3().fromID(evt.properties.functionID)
|
|
6594
|
+
Colors2.dim.bold("Invoked"),
|
|
6595
|
+
Colors2.dim(
|
|
6596
|
+
useFunctions3().fromID(evt.properties.functionID)?.handler
|
|
6570
6597
|
)
|
|
6571
6598
|
);
|
|
6572
6599
|
});
|
|
@@ -6574,10 +6601,10 @@ var dev = (program2) => program2.command(
|
|
|
6574
6601
|
prefix(evt.properties.requestID);
|
|
6575
6602
|
const { started } = pending.get(evt.properties.requestID);
|
|
6576
6603
|
for (let line of evt.properties.message.split("\n")) {
|
|
6577
|
-
|
|
6604
|
+
Colors2.line(
|
|
6578
6605
|
prefix(evt.properties.requestID),
|
|
6579
|
-
|
|
6580
|
-
|
|
6606
|
+
Colors2.dim(("+" + (Date.now() - started) + "ms").padEnd(7)),
|
|
6607
|
+
Colors2.dim(line)
|
|
6581
6608
|
);
|
|
6582
6609
|
}
|
|
6583
6610
|
});
|
|
@@ -6585,41 +6612,41 @@ var dev = (program2) => program2.command(
|
|
|
6585
6612
|
const info = useFunctions3().fromID(evt.properties.functionID);
|
|
6586
6613
|
if (!info.enableLiveDev)
|
|
6587
6614
|
return;
|
|
6588
|
-
|
|
6615
|
+
Colors2.line(Colors2.dim(Colors2.prefix, "Built", info.handler));
|
|
6589
6616
|
});
|
|
6590
6617
|
bus.subscribe("function.build.failed", async (evt) => {
|
|
6591
6618
|
const info = useFunctions3().fromID(evt.properties.functionID);
|
|
6592
6619
|
if (info.enableLiveDev === false)
|
|
6593
6620
|
return;
|
|
6594
|
-
|
|
6595
|
-
|
|
6621
|
+
Colors2.gap();
|
|
6622
|
+
Colors2.line(Colors2.danger("\u2716 "), "Build failed", info.handler);
|
|
6596
6623
|
for (const line of evt.properties.errors) {
|
|
6597
|
-
|
|
6624
|
+
Colors2.line(" ", line);
|
|
6598
6625
|
}
|
|
6599
|
-
|
|
6626
|
+
Colors2.gap();
|
|
6600
6627
|
});
|
|
6601
6628
|
bus.subscribe("function.success", async (evt) => {
|
|
6602
6629
|
const p = prefix(evt.properties.requestID);
|
|
6603
6630
|
const req = pending.get(evt.properties.requestID);
|
|
6604
6631
|
setTimeout(() => {
|
|
6605
|
-
|
|
6632
|
+
Colors2.line(
|
|
6606
6633
|
p,
|
|
6607
|
-
|
|
6634
|
+
Colors2.dim(`Done in ${Date.now() - req.started - 100}ms`)
|
|
6608
6635
|
);
|
|
6609
6636
|
end(evt.properties.requestID);
|
|
6610
6637
|
}, 100);
|
|
6611
6638
|
});
|
|
6612
6639
|
bus.subscribe("function.error", async (evt) => {
|
|
6613
6640
|
setTimeout(() => {
|
|
6614
|
-
|
|
6641
|
+
Colors2.line(
|
|
6615
6642
|
prefix(evt.properties.requestID),
|
|
6616
|
-
|
|
6617
|
-
|
|
6643
|
+
Colors2.danger.bold("Error:"),
|
|
6644
|
+
Colors2.danger.bold(evt.properties.errorMessage)
|
|
6618
6645
|
);
|
|
6619
6646
|
for (const line of evt.properties.trace || []) {
|
|
6620
6647
|
if (line.includes(evt.properties.errorMessage))
|
|
6621
6648
|
continue;
|
|
6622
|
-
|
|
6649
|
+
Colors2.line(" ", `${dim2(line)}`);
|
|
6623
6650
|
}
|
|
6624
6651
|
end(evt.properties.requestID);
|
|
6625
6652
|
}, 100);
|
|
@@ -6639,7 +6666,7 @@ var dev = (program2) => program2.command(
|
|
|
6639
6666
|
}
|
|
6640
6667
|
isDirty = false;
|
|
6641
6668
|
isWorking = true;
|
|
6642
|
-
|
|
6669
|
+
Colors2.gap();
|
|
6643
6670
|
const spinner = createSpinner2({
|
|
6644
6671
|
color: "gray",
|
|
6645
6672
|
text: lastDeployed ? ` Building...` : dim2(` Checking for changes`)
|
|
@@ -6660,7 +6687,7 @@ var dev = (program2) => program2.command(
|
|
|
6660
6687
|
const next = await checksum(assembly.directory);
|
|
6661
6688
|
Logger2.debug("Checksum", "next", next, "old", lastDeployed);
|
|
6662
6689
|
if (next === lastDeployed) {
|
|
6663
|
-
spinner.succeed(
|
|
6690
|
+
spinner.succeed(Colors2.dim(" Built with no changes"));
|
|
6664
6691
|
isWorking = false;
|
|
6665
6692
|
if (isDirty)
|
|
6666
6693
|
build2();
|
|
@@ -6669,19 +6696,19 @@ var dev = (program2) => program2.command(
|
|
|
6669
6696
|
if (!lastDeployed) {
|
|
6670
6697
|
spinner.stop();
|
|
6671
6698
|
spinner.clear();
|
|
6672
|
-
|
|
6699
|
+
Colors2.mode("gap");
|
|
6673
6700
|
} else {
|
|
6674
|
-
spinner.succeed(
|
|
6675
|
-
|
|
6701
|
+
spinner.succeed(Colors2.dim(` Built`));
|
|
6702
|
+
Colors2.gap();
|
|
6676
6703
|
}
|
|
6677
6704
|
deploy3(assembly);
|
|
6678
6705
|
} catch (ex) {
|
|
6679
6706
|
isWorking = false;
|
|
6680
6707
|
spinner.fail();
|
|
6681
|
-
|
|
6708
|
+
Colors2.line(
|
|
6682
6709
|
ex.stack.split("\n").map((line) => " " + line).join("\n")
|
|
6683
6710
|
);
|
|
6684
|
-
|
|
6711
|
+
Colors2.gap();
|
|
6685
6712
|
}
|
|
6686
6713
|
}
|
|
6687
6714
|
async function deploy3(assembly) {
|
|
@@ -6711,7 +6738,7 @@ var dev = (program2) => program2.command(
|
|
|
6711
6738
|
fs19.writeFile(
|
|
6712
6739
|
path19.join(project.paths.out, "outputs.json"),
|
|
6713
6740
|
JSON.stringify(
|
|
6714
|
-
|
|
6741
|
+
pipe3(
|
|
6715
6742
|
results,
|
|
6716
6743
|
omitBy2((_, key) => key.includes("SstSiteEnv")),
|
|
6717
6744
|
mapValues((val) => val.outputs)
|
|
@@ -6745,7 +6772,7 @@ var dev = (program2) => program2.command(
|
|
|
6745
6772
|
watcher.subscribe("file.changed", async (evt) => {
|
|
6746
6773
|
if (!project.metafile)
|
|
6747
6774
|
return;
|
|
6748
|
-
if (!project.metafile.inputs[evt.properties.relative])
|
|
6775
|
+
if (!project.metafile.inputs[evt.properties.relative.split(path19.sep).join(path19.posix.sep)])
|
|
6749
6776
|
return;
|
|
6750
6777
|
build2();
|
|
6751
6778
|
});
|
|
@@ -6765,7 +6792,7 @@ var dev = (program2) => program2.command(
|
|
|
6765
6792
|
}
|
|
6766
6793
|
}
|
|
6767
6794
|
clear2();
|
|
6768
|
-
await
|
|
6795
|
+
await printHeader2({ console: true, hint: "ready!" });
|
|
6769
6796
|
await Promise.all([
|
|
6770
6797
|
useRuntimeWorkers2(),
|
|
6771
6798
|
useIOTBridge2(),
|
|
@@ -6885,7 +6912,7 @@ var deploy2 = (program2) => program2.command(
|
|
|
6885
6912
|
const { loadAssembly: loadAssembly2, useAppMetadata: useAppMetadata2, saveAppMetadata: saveAppMetadata2, Stacks } = await Promise.resolve().then(() => (init_stacks(), stacks_exports));
|
|
6886
6913
|
const { render } = await import("ink");
|
|
6887
6914
|
const { DeploymentUI: DeploymentUI2 } = await Promise.resolve().then(() => (init_deploy2(), deploy_exports));
|
|
6888
|
-
const { mapValues
|
|
6915
|
+
const { mapValues } = await import("remeda");
|
|
6889
6916
|
const project = useProject2();
|
|
6890
6917
|
const [identity, appMetadata] = await Promise.all([
|
|
6891
6918
|
useSTSIdentity(),
|
|
@@ -6937,7 +6964,7 @@ var deploy2 = (program2) => program2.command(
|
|
|
6937
6964
|
fs18.writeFile(
|
|
6938
6965
|
path18.join(project.paths.out, "outputs.json"),
|
|
6939
6966
|
JSON.stringify(
|
|
6940
|
-
|
|
6967
|
+
mapValues(results, (val) => val.outputs),
|
|
6941
6968
|
null,
|
|
6942
6969
|
2
|
|
6943
6970
|
)
|