sst 2.0.21 → 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 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)
@@ -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");
@@ -179,20 +179,18 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
179
179
  lastDeployed = nextChecksum;
180
180
  // Update site env
181
181
  const keys = await SiteEnv.keys();
182
- if (keys.length) {
183
- const result = {};
184
- for (const key of keys) {
185
- const stack = results[key.stack];
186
- const value = stack.outputs[key.output];
187
- let existing = result[key.path];
188
- if (!existing) {
189
- result[key.path] = existing;
190
- existing = result[key.path] = {};
191
- }
192
- existing[key.environment] = value;
182
+ const result = {};
183
+ for (const key of keys) {
184
+ const stack = results[key.stack];
185
+ const value = stack.outputs[key.output];
186
+ let existing = result[key.path];
187
+ if (!existing) {
188
+ result[key.path] = existing;
189
+ existing = result[key.path] = {};
193
190
  }
194
- await SiteEnv.writeValues(result);
191
+ existing[key.environment] = value;
195
192
  }
193
+ await SiteEnv.writeValues(result);
196
194
  // Write outputs.json
197
195
  fs.writeFile(path.join(project.paths.out, "outputs.json"), JSON.stringify(pipe(results, omitBy((_, key) => key.includes("SstSiteEnv")), mapValues((val) => val.outputs)), null, 2));
198
196
  isWorking = false;
@@ -219,7 +217,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
219
217
  watcher.subscribe("file.changed", async (evt) => {
220
218
  if (!project.metafile)
221
219
  return;
222
- if (!project.metafile.inputs[evt.properties.relative])
220
+ if (!project.metafile.inputs[evt.properties.relative.split(path.sep).join(path.posix.sep)])
223
221
  return;
224
222
  build();
225
223
  });
@@ -367,7 +367,7 @@ export interface NodeJSProps {
367
367
  * ```js
368
368
  * new Function(stack, "Function", {
369
369
  * nodejs: {
370
- * nodeModules: ["pg"]
370
+ * install: ["pg"]
371
371
  * }
372
372
  * })
373
373
  * ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.21",
3
+ "version": "2.0.23",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
@@ -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 pipe3, map as map2 } from "remeda";
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
- ...pipe3(
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 Colors.hex(exists.color)(Colors.prefix);
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
- Colors.line(
6565
+ Colors2.line(
6566
6566
  prefix(evt.properties.requestID),
6567
- Colors.dim.bold("Invoked"),
6568
- Colors.dim(
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
- Colors.line(
6577
+ Colors2.line(
6578
6578
  prefix(evt.properties.requestID),
6579
- Colors.dim(("+" + (Date.now() - started) + "ms").padEnd(7)),
6580
- Colors.dim(line)
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
- Colors.line(Colors.dim(Colors.prefix, "Built", info.handler));
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
- Colors.gap();
6595
- Colors.line(Colors.danger("\u2716 "), "Build failed", info.handler);
6594
+ Colors2.gap();
6595
+ Colors2.line(Colors2.danger("\u2716 "), "Build failed", info.handler);
6596
6596
  for (const line of evt.properties.errors) {
6597
- Colors.line(" ", line);
6597
+ Colors2.line(" ", line);
6598
6598
  }
6599
- Colors.gap();
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
- Colors.line(
6605
+ Colors2.line(
6606
6606
  p,
6607
- Colors.dim(`Done in ${Date.now() - req.started - 100}ms`)
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
- Colors.line(
6614
+ Colors2.line(
6615
6615
  prefix(evt.properties.requestID),
6616
- Colors.danger.bold("Error:"),
6617
- Colors.danger.bold(evt.properties.errorMessage)
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
- Colors.line(" ", `${dim2(line)}`);
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
- Colors.gap();
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(Colors.dim(" Built with no changes"));
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
- Colors.mode("gap");
6672
+ Colors2.mode("gap");
6673
6673
  } else {
6674
- spinner.succeed(Colors.dim(` Built`));
6675
- Colors.gap();
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
- Colors.line(
6681
+ Colors2.line(
6682
6682
  ex.stack.split("\n").map((line) => " " + line).join("\n")
6683
6683
  );
6684
- Colors.gap();
6684
+ Colors2.gap();
6685
6685
  }
6686
6686
  }
6687
6687
  async function deploy3(assembly) {
@@ -6696,24 +6696,22 @@ var dev = (program2) => program2.command(
6696
6696
  }
6697
6697
  lastDeployed = nextChecksum;
6698
6698
  const keys2 = await SiteEnv.keys();
6699
- if (keys2.length) {
6700
- const result = {};
6701
- for (const key of keys2) {
6702
- const stack = results[key.stack];
6703
- const value = stack.outputs[key.output];
6704
- let existing = result[key.path];
6705
- if (!existing) {
6706
- result[key.path] = existing;
6707
- existing = result[key.path] = {};
6708
- }
6709
- existing[key.environment] = value;
6699
+ const result = {};
6700
+ for (const key of keys2) {
6701
+ const stack = results[key.stack];
6702
+ const value = stack.outputs[key.output];
6703
+ let existing = result[key.path];
6704
+ if (!existing) {
6705
+ result[key.path] = existing;
6706
+ existing = result[key.path] = {};
6710
6707
  }
6711
- await SiteEnv.writeValues(result);
6708
+ existing[key.environment] = value;
6712
6709
  }
6710
+ await SiteEnv.writeValues(result);
6713
6711
  fs19.writeFile(
6714
6712
  path19.join(project.paths.out, "outputs.json"),
6715
6713
  JSON.stringify(
6716
- pipe2(
6714
+ pipe3(
6717
6715
  results,
6718
6716
  omitBy2((_, key) => key.includes("SstSiteEnv")),
6719
6717
  mapValues((val) => val.outputs)
@@ -6747,7 +6745,7 @@ var dev = (program2) => program2.command(
6747
6745
  watcher.subscribe("file.changed", async (evt) => {
6748
6746
  if (!project.metafile)
6749
6747
  return;
6750
- if (!project.metafile.inputs[evt.properties.relative])
6748
+ if (!project.metafile.inputs[evt.properties.relative.split(path19.sep).join(path19.posix.sep)])
6751
6749
  return;
6752
6750
  build2();
6753
6751
  });
@@ -6767,7 +6765,7 @@ var dev = (program2) => program2.command(
6767
6765
  }
6768
6766
  }
6769
6767
  clear2();
6770
- await printHeader({ console: true, hint: "ready!" });
6768
+ await printHeader2({ console: true, hint: "ready!" });
6771
6769
  await Promise.all([
6772
6770
  useRuntimeWorkers2(),
6773
6771
  useIOTBridge2(),
@@ -6887,7 +6885,7 @@ var deploy2 = (program2) => program2.command(
6887
6885
  const { loadAssembly: loadAssembly2, useAppMetadata: useAppMetadata2, saveAppMetadata: saveAppMetadata2, Stacks } = await Promise.resolve().then(() => (init_stacks(), stacks_exports));
6888
6886
  const { render } = await import("ink");
6889
6887
  const { DeploymentUI: DeploymentUI2 } = await Promise.resolve().then(() => (init_deploy2(), deploy_exports));
6890
- const { mapValues: mapValues2 } = await import("remeda");
6888
+ const { mapValues } = await import("remeda");
6891
6889
  const project = useProject2();
6892
6890
  const [identity, appMetadata] = await Promise.all([
6893
6891
  useSTSIdentity(),
@@ -6939,7 +6937,7 @@ var deploy2 = (program2) => program2.command(
6939
6937
  fs18.writeFile(
6940
6938
  path18.join(project.paths.out, "outputs.json"),
6941
6939
  JSON.stringify(
6942
- mapValues2(results, (val) => val.outputs),
6940
+ mapValues(results, (val) => val.outputs),
6943
6941
  null,
6944
6942
  2
6945
6943
  )