sst 2.0.2 → 2.0.4

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.
@@ -11,5 +11,5 @@ export declare const bind: (program: Program) => import("yargs").Argv<{
11
11
  } & {
12
12
  role: string | undefined;
13
13
  } & {
14
- command: string;
14
+ command: (string | number)[] | undefined;
15
15
  }>;
@@ -1,9 +1,7 @@
1
- export const bind = (program) => program.command("bind <command>", "Bind your app's resources to a command", (yargs) => yargs
2
- .positional("command", {
3
- type: "string",
4
- describe: "The command to bind to",
5
- demandOption: true,
6
- })
1
+ import { VisibleError } from "../../error.js";
2
+ export const bind = (program) => program
3
+ .command("bind <command..>", "Bind your app's resources to a command", (yargs) => yargs
4
+ .array("command")
7
5
  .example(`sst bind "vitest run"`, "Bind your resources to your tests")
8
6
  .example(`sst bind "tsx scripts/myscript.ts"`, "Bind your resources to a script"), async (args) => {
9
7
  const { Config } = await import("../../config.js");
@@ -13,7 +11,10 @@ export const bind = (program) => program.command("bind <command>", "Bind your ap
13
11
  const env = await Config.env();
14
12
  const project = useProject();
15
13
  const credentials = await useAWSCredentials();
16
- const result = spawnSync(args.command, {
14
+ const joined = args.command?.join(" ");
15
+ if (!joined)
16
+ throw new VisibleError("Command is required, e.g. sst bind env");
17
+ const result = spawnSync(joined, {
17
18
  env: {
18
19
  ...process.env,
19
20
  ...env,
@@ -26,4 +27,5 @@ export const bind = (program) => program.command("bind <command>", "Bind your ap
26
27
  shell: process.env.SHELL || true,
27
28
  });
28
29
  process.exitCode = result.status || undefined;
29
- });
30
+ })
31
+ .strict(false);
@@ -11,5 +11,5 @@ export declare const env: (program: Program) => import("yargs").Argv<{
11
11
  } & {
12
12
  role: string | undefined;
13
13
  } & {
14
- command: string;
14
+ command: (string | number)[] | undefined;
15
15
  }>;
@@ -1,9 +1,7 @@
1
- export const env = (program) => program.command("env <command>", "Load environment variables and start your frontend", (yargs) => yargs
2
- .positional("command", {
3
- type: "string",
4
- describe: "The command to start your frontend",
5
- demandOption: true,
6
- })
1
+ import { VisibleError } from "../../error.js";
2
+ export const env = (program) => program
3
+ .command("env <command..>", "Load environment variables and start your frontend", (yargs) => yargs
4
+ .array("command")
7
5
  .example(`sst env "next dev"`, "Start Next.js with your environment variables")
8
6
  .example(`sst env "vite dev"`, "Start Vite with your environment variables"), async (args) => {
9
7
  const { createSpinner } = await import("../spinner.js");
@@ -28,7 +26,10 @@ export const env = (program) => program.command("env <command>", "Load environme
28
26
  const env = sites[process.cwd()] || {};
29
27
  const project = useProject();
30
28
  const credentials = await useAWSCredentials();
31
- const result = spawnSync(args.command, {
29
+ const joined = args.command?.join(" ");
30
+ if (!joined)
31
+ throw new VisibleError("Command is required, e.g. sst env vite dev");
32
+ const result = spawnSync(joined, {
32
33
  env: {
33
34
  ...process.env,
34
35
  ...env,
@@ -43,4 +44,5 @@ export const env = (program) => program.command("env <command>", "Load environme
43
44
  process.exitCode = result.status || undefined;
44
45
  break;
45
46
  }
46
- });
47
+ })
48
+ .strict(false);
@@ -173,6 +173,7 @@ export declare class App extends cdk.App {
173
173
  */
174
174
  addDefaultFunctionLayers(layers: lambda.ILayerVersion[]): void;
175
175
  synth(options?: cdk.StageSynthesisOptions): cxapi.CloudAssembly;
176
+ /** @internal */
176
177
  finish(): Promise<void>;
177
178
  isRunningSSTTest(): boolean;
178
179
  getInputFilesFromEsbuildMetafile(file: string): Array<string>;
package/constructs/App.js CHANGED
@@ -227,6 +227,7 @@ export class App extends cdk.App {
227
227
  const cloudAssembly = super.synth(options);
228
228
  return cloudAssembly;
229
229
  }
230
+ /** @internal */
230
231
  async finish() {
231
232
  await useDeferredTasks().run();
232
233
  this.buildConstructsMetadata();
@@ -491,7 +491,7 @@ export interface JavaProps {
491
491
  * })
492
492
  *```
493
493
  */
494
- interface FunctionCopyFilesProps {
494
+ export interface FunctionCopyFilesProps {
495
495
  /**
496
496
  * Source path relative to sst.json
497
497
  */
@@ -468,6 +468,11 @@ export class SsrSite extends Construct {
468
468
  }
469
469
  else {
470
470
  domainNames.push(customDomain.domainName);
471
+ if (customDomain.alternateNames) {
472
+ if (!customDomain.cdk?.certificate)
473
+ throw new Error("Certificates for alternate domains cannot be automatically created. Please specify certificate to use");
474
+ domainNames.push(...customDomain.alternateNames);
475
+ }
471
476
  }
472
477
  return domainNames;
473
478
  }
package/iot.js CHANGED
@@ -32,6 +32,9 @@ export const useIOT = Context.memo(async () => {
32
32
  const PREFIX = `/sst/${project.config.name}/${project.config.stage}`;
33
33
  device.subscribe(`${PREFIX}/events`);
34
34
  const fragments = new Map();
35
+ device.on("connect", () => {
36
+ Logger.debug("IoT connected");
37
+ });
35
38
  device.on("error", (err) => {
36
39
  Logger.debug("IoT error", err);
37
40
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
@@ -33,10 +33,10 @@ export const usePythonHandler = Context.memo(async () => {
33
33
  },
34
34
  canHandle: (input) => input.startsWith("python"),
35
35
  startWorker: async (input) => {
36
- const src = "services";
36
+ const src = await findAbove(input.handler, "requirements.txt");
37
37
  const parsed = path.parse(path.relative(src, input.handler));
38
38
  const target = [...parsed.dir.split(path.sep), parsed.name].join(".");
39
- const proc = spawn(os.platform() === "win32" ? "python.exe" : "python3.6".split(".")[0], [
39
+ const proc = spawn(os.platform() === "win32" ? "python.exe" : "python3", [
40
40
  "-u",
41
41
  url.fileURLToPath(new URL("../../support/python-runtime/runtime.py", import.meta.url)),
42
42
  target,
@@ -51,7 +51,7 @@ export const usePythonHandler = Context.memo(async () => {
51
51
  AWS_LAMBDA_RUNTIME_API: `localhost:${server.port}/${input.workerID}`,
52
52
  },
53
53
  shell: true,
54
- cwd: path.join(process.cwd(), src),
54
+ cwd: src,
55
55
  });
56
56
  proc.on("exit", () => workers.exited(input.workerID));
57
57
  proc.stdout.on("data", (data) => {
package/sst.mjs CHANGED
@@ -2475,6 +2475,9 @@ var init_iot = __esm({
2475
2475
  const PREFIX2 = `/sst/${project.config.name}/${project.config.stage}`;
2476
2476
  device.subscribe(`${PREFIX2}/events`);
2477
2477
  const fragments = /* @__PURE__ */ new Map();
2478
+ device.on("connect", () => {
2479
+ Logger.debug("IoT connected");
2480
+ });
2478
2481
  device.on("error", (err) => {
2479
2482
  Logger.debug("IoT error", err);
2480
2483
  });
@@ -5010,11 +5013,11 @@ var init_python = __esm({
5010
5013
  },
5011
5014
  canHandle: (input) => input.startsWith("python"),
5012
5015
  startWorker: async (input) => {
5013
- const src = "services";
5016
+ const src = await findAbove(input.handler, "requirements.txt");
5014
5017
  const parsed = path12.parse(path12.relative(src, input.handler));
5015
5018
  const target = [...parsed.dir.split(path12.sep), parsed.name].join(".");
5016
5019
  const proc = spawn4(
5017
- os3.platform() === "win32" ? "python.exe" : "python3.6".split(".")[0],
5020
+ os3.platform() === "win32" ? "python.exe" : "python3",
5018
5021
  [
5019
5022
  "-u",
5020
5023
  url6.fileURLToPath(
@@ -5033,7 +5036,7 @@ var init_python = __esm({
5033
5036
  AWS_LAMBDA_RUNTIME_API: `localhost:${server.port}/${input.workerID}`
5034
5037
  },
5035
5038
  shell: true,
5036
- cwd: path12.join(process.cwd(), src)
5039
+ cwd: src
5037
5040
  }
5038
5041
  );
5039
5042
  proc.on("exit", () => workers.exited(input.workerID));
@@ -6228,14 +6231,11 @@ init_logger();
6228
6231
  import dotenv2 from "dotenv";
6229
6232
 
6230
6233
  // src/cli/commands/env.ts
6234
+ init_error();
6231
6235
  var env = (program2) => program2.command(
6232
- "env <command>",
6236
+ "env <command..>",
6233
6237
  "Load environment variables and start your frontend",
6234
- (yargs2) => yargs2.positional("command", {
6235
- type: "string",
6236
- describe: "The command to start your frontend",
6237
- demandOption: true
6238
- }).example(
6238
+ (yargs2) => yargs2.array("command").example(
6239
6239
  `sst env "next dev"`,
6240
6240
  "Start Next.js with your environment variables"
6241
6241
  ).example(
@@ -6264,7 +6264,12 @@ var env = (program2) => program2.command(
6264
6264
  const env2 = sites[process.cwd()] || {};
6265
6265
  const project = useProject2();
6266
6266
  const credentials = await useAWSCredentials2();
6267
- const result = spawnSync(args.command, {
6267
+ const joined = args.command?.join(" ");
6268
+ if (!joined)
6269
+ throw new VisibleError(
6270
+ "Command is required, e.g. sst env vite dev"
6271
+ );
6272
+ const result = spawnSync(joined, {
6268
6273
  env: {
6269
6274
  ...process.env,
6270
6275
  ...env2,
@@ -6280,7 +6285,7 @@ var env = (program2) => program2.command(
6280
6285
  break;
6281
6286
  }
6282
6287
  }
6283
- );
6288
+ ).strict(false);
6284
6289
 
6285
6290
  // src/cli/commands/dev.tsx
6286
6291
  init_colors();
@@ -6586,14 +6591,11 @@ async function promptChangeMode() {
6586
6591
  }
6587
6592
 
6588
6593
  // src/cli/commands/bind.ts
6594
+ init_error();
6589
6595
  var bind = (program2) => program2.command(
6590
- "bind <command>",
6596
+ "bind <command..>",
6591
6597
  "Bind your app's resources to a command",
6592
- (yargs2) => yargs2.positional("command", {
6593
- type: "string",
6594
- describe: "The command to bind to",
6595
- demandOption: true
6596
- }).example(`sst bind "vitest run"`, "Bind your resources to your tests").example(
6598
+ (yargs2) => yargs2.array("command").example(`sst bind "vitest run"`, "Bind your resources to your tests").example(
6597
6599
  `sst bind "tsx scripts/myscript.ts"`,
6598
6600
  "Bind your resources to a script"
6599
6601
  ),
@@ -6605,7 +6607,10 @@ var bind = (program2) => program2.command(
6605
6607
  const env2 = await Config2.env();
6606
6608
  const project = useProject2();
6607
6609
  const credentials = await useAWSCredentials2();
6608
- const result = spawnSync(args.command, {
6610
+ const joined = args.command?.join(" ");
6611
+ if (!joined)
6612
+ throw new VisibleError("Command is required, e.g. sst bind env");
6613
+ const result = spawnSync(joined, {
6609
6614
  env: {
6610
6615
  ...process.env,
6611
6616
  ...env2,
@@ -6619,7 +6624,7 @@ var bind = (program2) => program2.command(
6619
6624
  });
6620
6625
  process.exitCode = result.status || void 0;
6621
6626
  }
6622
- );
6627
+ ).strict(false);
6623
6628
 
6624
6629
  // src/cli/commands/build.ts
6625
6630
  var build = (program2) => program2.command(