sst 2.0.22 → 2.0.23
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 +5 -5
- package/constructs/Function.d.ts +1 -1
- package/package.json +1 -1
- package/runtime/handlers/node.js +1 -1
- package/sst.mjs +37 -37
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");
|
|
@@ -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
|
});
|
package/constructs/Function.d.ts
CHANGED
package/package.json
CHANGED
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";
|
package/sst.mjs
CHANGED
|
@@ -4812,7 +4812,7 @@ var init_node = __esm({
|
|
|
4812
4812
|
if (!file)
|
|
4813
4813
|
return {
|
|
4814
4814
|
type: "error",
|
|
4815
|
-
errors: [`Could not find file for handler ${input.props.handler}`]
|
|
4815
|
+
errors: [`Could not find file for handler "${input.props.handler}"`]
|
|
4816
4816
|
};
|
|
4817
4817
|
const nodejs = input.props.nodejs || {};
|
|
4818
4818
|
const isESM = (nodejs.format || "esm") === "esm";
|
|
@@ -6200,7 +6200,7 @@ import {
|
|
|
6200
6200
|
LambdaClient,
|
|
6201
6201
|
UpdateFunctionConfigurationCommand
|
|
6202
6202
|
} from "@aws-sdk/client-lambda";
|
|
6203
|
-
import { pipe as
|
|
6203
|
+
import { pipe as pipe2, map as map2 } from "remeda";
|
|
6204
6204
|
async function* scan(prefix) {
|
|
6205
6205
|
const ssm = useAWSClient(SSMClient);
|
|
6206
6206
|
let token;
|
|
@@ -6293,7 +6293,7 @@ var init_config = __esm({
|
|
|
6293
6293
|
const env3 = {
|
|
6294
6294
|
SST_APP: project.config.name,
|
|
6295
6295
|
SST_STAGE: project.config.stage,
|
|
6296
|
-
...
|
|
6296
|
+
...pipe2(
|
|
6297
6297
|
parameters2,
|
|
6298
6298
|
map2((p) => [envFor(p), p.value]),
|
|
6299
6299
|
Object.fromEntries
|
|
@@ -6495,9 +6495,6 @@ var env = (program2) => program2.command(
|
|
|
6495
6495
|
).strict(false);
|
|
6496
6496
|
|
|
6497
6497
|
// src/cli/commands/dev.tsx
|
|
6498
|
-
init_colors();
|
|
6499
|
-
init_header();
|
|
6500
|
-
import { mapValues, omitBy as omitBy2, pipe as pipe2 } from "remeda";
|
|
6501
6498
|
var dev = (program2) => program2.command(
|
|
6502
6499
|
["dev", "start"],
|
|
6503
6500
|
"Work on your app locally",
|
|
@@ -6506,6 +6503,10 @@ var dev = (program2) => program2.command(
|
|
|
6506
6503
|
description: "Increase function timeout"
|
|
6507
6504
|
}),
|
|
6508
6505
|
async (args) => {
|
|
6506
|
+
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
6507
|
+
const { printHeader: printHeader2 } = await Promise.resolve().then(() => (init_header(), header_exports));
|
|
6508
|
+
const { mapValues, omitBy: omitBy2, pipe: pipe3 } = await import("remeda");
|
|
6509
|
+
const path19 = await import("path");
|
|
6509
6510
|
const { useRuntimeWorkers: useRuntimeWorkers2 } = await Promise.resolve().then(() => (init_workers(), workers_exports));
|
|
6510
6511
|
const { useIOTBridge: useIOTBridge2 } = await Promise.resolve().then(() => (init_iot2(), iot_exports));
|
|
6511
6512
|
const { useRuntimeServer: useRuntimeServer2 } = await Promise.resolve().then(() => (init_server2(), server_exports2));
|
|
@@ -6520,7 +6521,6 @@ var dev = (program2) => program2.command(
|
|
|
6520
6521
|
const { Context: Context2 } = await Promise.resolve().then(() => (init_context(), context_exports));
|
|
6521
6522
|
const { printDeploymentResults: printDeploymentResults2, DeploymentUI: DeploymentUI2 } = await Promise.resolve().then(() => (init_deploy2(), deploy_exports));
|
|
6522
6523
|
const { useLocalServer: useLocalServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
6523
|
-
const path19 = await import("path");
|
|
6524
6524
|
const fs19 = await import("fs/promises");
|
|
6525
6525
|
const crypto2 = await import("crypto");
|
|
6526
6526
|
const { useFunctions: useFunctions3 } = await import("../src/constructs/Function.js");
|
|
@@ -6548,7 +6548,7 @@ var dev = (program2) => program2.command(
|
|
|
6548
6548
|
function prefix(requestID) {
|
|
6549
6549
|
const exists = pending.get(requestID);
|
|
6550
6550
|
if (exists) {
|
|
6551
|
-
return
|
|
6551
|
+
return Colors2.hex(exists.color)(Colors2.prefix);
|
|
6552
6552
|
}
|
|
6553
6553
|
pending.set(requestID, {
|
|
6554
6554
|
requestID,
|
|
@@ -6562,10 +6562,10 @@ var dev = (program2) => program2.command(
|
|
|
6562
6562
|
pending.delete(requestID);
|
|
6563
6563
|
}
|
|
6564
6564
|
bus.subscribe("function.invoked", async (evt) => {
|
|
6565
|
-
|
|
6565
|
+
Colors2.line(
|
|
6566
6566
|
prefix(evt.properties.requestID),
|
|
6567
|
-
|
|
6568
|
-
|
|
6567
|
+
Colors2.dim.bold("Invoked"),
|
|
6568
|
+
Colors2.dim(
|
|
6569
6569
|
useFunctions3().fromID(evt.properties.functionID).handler
|
|
6570
6570
|
)
|
|
6571
6571
|
);
|
|
@@ -6574,10 +6574,10 @@ var dev = (program2) => program2.command(
|
|
|
6574
6574
|
prefix(evt.properties.requestID);
|
|
6575
6575
|
const { started } = pending.get(evt.properties.requestID);
|
|
6576
6576
|
for (let line of evt.properties.message.split("\n")) {
|
|
6577
|
-
|
|
6577
|
+
Colors2.line(
|
|
6578
6578
|
prefix(evt.properties.requestID),
|
|
6579
|
-
|
|
6580
|
-
|
|
6579
|
+
Colors2.dim(("+" + (Date.now() - started) + "ms").padEnd(7)),
|
|
6580
|
+
Colors2.dim(line)
|
|
6581
6581
|
);
|
|
6582
6582
|
}
|
|
6583
6583
|
});
|
|
@@ -6585,41 +6585,41 @@ var dev = (program2) => program2.command(
|
|
|
6585
6585
|
const info = useFunctions3().fromID(evt.properties.functionID);
|
|
6586
6586
|
if (!info.enableLiveDev)
|
|
6587
6587
|
return;
|
|
6588
|
-
|
|
6588
|
+
Colors2.line(Colors2.dim(Colors2.prefix, "Built", info.handler));
|
|
6589
6589
|
});
|
|
6590
6590
|
bus.subscribe("function.build.failed", async (evt) => {
|
|
6591
6591
|
const info = useFunctions3().fromID(evt.properties.functionID);
|
|
6592
6592
|
if (info.enableLiveDev === false)
|
|
6593
6593
|
return;
|
|
6594
|
-
|
|
6595
|
-
|
|
6594
|
+
Colors2.gap();
|
|
6595
|
+
Colors2.line(Colors2.danger("\u2716 "), "Build failed", info.handler);
|
|
6596
6596
|
for (const line of evt.properties.errors) {
|
|
6597
|
-
|
|
6597
|
+
Colors2.line(" ", line);
|
|
6598
6598
|
}
|
|
6599
|
-
|
|
6599
|
+
Colors2.gap();
|
|
6600
6600
|
});
|
|
6601
6601
|
bus.subscribe("function.success", async (evt) => {
|
|
6602
6602
|
const p = prefix(evt.properties.requestID);
|
|
6603
6603
|
const req = pending.get(evt.properties.requestID);
|
|
6604
6604
|
setTimeout(() => {
|
|
6605
|
-
|
|
6605
|
+
Colors2.line(
|
|
6606
6606
|
p,
|
|
6607
|
-
|
|
6607
|
+
Colors2.dim(`Done in ${Date.now() - req.started - 100}ms`)
|
|
6608
6608
|
);
|
|
6609
6609
|
end(evt.properties.requestID);
|
|
6610
6610
|
}, 100);
|
|
6611
6611
|
});
|
|
6612
6612
|
bus.subscribe("function.error", async (evt) => {
|
|
6613
6613
|
setTimeout(() => {
|
|
6614
|
-
|
|
6614
|
+
Colors2.line(
|
|
6615
6615
|
prefix(evt.properties.requestID),
|
|
6616
|
-
|
|
6617
|
-
|
|
6616
|
+
Colors2.danger.bold("Error:"),
|
|
6617
|
+
Colors2.danger.bold(evt.properties.errorMessage)
|
|
6618
6618
|
);
|
|
6619
6619
|
for (const line of evt.properties.trace || []) {
|
|
6620
6620
|
if (line.includes(evt.properties.errorMessage))
|
|
6621
6621
|
continue;
|
|
6622
|
-
|
|
6622
|
+
Colors2.line(" ", `${dim2(line)}`);
|
|
6623
6623
|
}
|
|
6624
6624
|
end(evt.properties.requestID);
|
|
6625
6625
|
}, 100);
|
|
@@ -6639,7 +6639,7 @@ var dev = (program2) => program2.command(
|
|
|
6639
6639
|
}
|
|
6640
6640
|
isDirty = false;
|
|
6641
6641
|
isWorking = true;
|
|
6642
|
-
|
|
6642
|
+
Colors2.gap();
|
|
6643
6643
|
const spinner = createSpinner2({
|
|
6644
6644
|
color: "gray",
|
|
6645
6645
|
text: lastDeployed ? ` Building...` : dim2(` Checking for changes`)
|
|
@@ -6660,7 +6660,7 @@ var dev = (program2) => program2.command(
|
|
|
6660
6660
|
const next = await checksum(assembly.directory);
|
|
6661
6661
|
Logger2.debug("Checksum", "next", next, "old", lastDeployed);
|
|
6662
6662
|
if (next === lastDeployed) {
|
|
6663
|
-
spinner.succeed(
|
|
6663
|
+
spinner.succeed(Colors2.dim(" Built with no changes"));
|
|
6664
6664
|
isWorking = false;
|
|
6665
6665
|
if (isDirty)
|
|
6666
6666
|
build2();
|
|
@@ -6669,19 +6669,19 @@ var dev = (program2) => program2.command(
|
|
|
6669
6669
|
if (!lastDeployed) {
|
|
6670
6670
|
spinner.stop();
|
|
6671
6671
|
spinner.clear();
|
|
6672
|
-
|
|
6672
|
+
Colors2.mode("gap");
|
|
6673
6673
|
} else {
|
|
6674
|
-
spinner.succeed(
|
|
6675
|
-
|
|
6674
|
+
spinner.succeed(Colors2.dim(` Built`));
|
|
6675
|
+
Colors2.gap();
|
|
6676
6676
|
}
|
|
6677
6677
|
deploy3(assembly);
|
|
6678
6678
|
} catch (ex) {
|
|
6679
6679
|
isWorking = false;
|
|
6680
6680
|
spinner.fail();
|
|
6681
|
-
|
|
6681
|
+
Colors2.line(
|
|
6682
6682
|
ex.stack.split("\n").map((line) => " " + line).join("\n")
|
|
6683
6683
|
);
|
|
6684
|
-
|
|
6684
|
+
Colors2.gap();
|
|
6685
6685
|
}
|
|
6686
6686
|
}
|
|
6687
6687
|
async function deploy3(assembly) {
|
|
@@ -6711,7 +6711,7 @@ var dev = (program2) => program2.command(
|
|
|
6711
6711
|
fs19.writeFile(
|
|
6712
6712
|
path19.join(project.paths.out, "outputs.json"),
|
|
6713
6713
|
JSON.stringify(
|
|
6714
|
-
|
|
6714
|
+
pipe3(
|
|
6715
6715
|
results,
|
|
6716
6716
|
omitBy2((_, key) => key.includes("SstSiteEnv")),
|
|
6717
6717
|
mapValues((val) => val.outputs)
|
|
@@ -6745,7 +6745,7 @@ var dev = (program2) => program2.command(
|
|
|
6745
6745
|
watcher.subscribe("file.changed", async (evt) => {
|
|
6746
6746
|
if (!project.metafile)
|
|
6747
6747
|
return;
|
|
6748
|
-
if (!project.metafile.inputs[evt.properties.relative])
|
|
6748
|
+
if (!project.metafile.inputs[evt.properties.relative.split(path19.sep).join(path19.posix.sep)])
|
|
6749
6749
|
return;
|
|
6750
6750
|
build2();
|
|
6751
6751
|
});
|
|
@@ -6765,7 +6765,7 @@ var dev = (program2) => program2.command(
|
|
|
6765
6765
|
}
|
|
6766
6766
|
}
|
|
6767
6767
|
clear2();
|
|
6768
|
-
await
|
|
6768
|
+
await printHeader2({ console: true, hint: "ready!" });
|
|
6769
6769
|
await Promise.all([
|
|
6770
6770
|
useRuntimeWorkers2(),
|
|
6771
6771
|
useIOTBridge2(),
|
|
@@ -6885,7 +6885,7 @@ var deploy2 = (program2) => program2.command(
|
|
|
6885
6885
|
const { loadAssembly: loadAssembly2, useAppMetadata: useAppMetadata2, saveAppMetadata: saveAppMetadata2, Stacks } = await Promise.resolve().then(() => (init_stacks(), stacks_exports));
|
|
6886
6886
|
const { render } = await import("ink");
|
|
6887
6887
|
const { DeploymentUI: DeploymentUI2 } = await Promise.resolve().then(() => (init_deploy2(), deploy_exports));
|
|
6888
|
-
const { mapValues
|
|
6888
|
+
const { mapValues } = await import("remeda");
|
|
6889
6889
|
const project = useProject2();
|
|
6890
6890
|
const [identity, appMetadata] = await Promise.all([
|
|
6891
6891
|
useSTSIdentity(),
|
|
@@ -6937,7 +6937,7 @@ var deploy2 = (program2) => program2.command(
|
|
|
6937
6937
|
fs18.writeFile(
|
|
6938
6938
|
path18.join(project.paths.out, "outputs.json"),
|
|
6939
6939
|
JSON.stringify(
|
|
6940
|
-
|
|
6940
|
+
mapValues(results, (val) => val.outputs),
|
|
6941
6941
|
null,
|
|
6942
6942
|
2
|
|
6943
6943
|
)
|