sst 2.0.0-rc.9 → 2.0.0

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.
Files changed (242) hide show
  1. package/bootstrap.d.ts +2 -4
  2. package/bootstrap.js +208 -61
  3. package/bus.d.ts +3 -3
  4. package/bus.js +1 -1
  5. package/cache.js +1 -1
  6. package/cdk/cloudformation-deployments-wrapper.d.ts +3 -0
  7. package/cdk/cloudformation-deployments-wrapper.js +117 -0
  8. package/cdk/cloudformation-deployments.d.ts +19 -4
  9. package/cdk/deploy-stack.d.ts +17 -2
  10. package/cdk/deploy-stack.js +6 -1
  11. package/cli/colors.d.ts +28 -0
  12. package/cli/colors.js +27 -0
  13. package/cli/commands/bind.d.ts +4 -0
  14. package/cli/commands/bind.js +10 -7
  15. package/cli/commands/bootstrap.d.ts +13 -0
  16. package/cli/commands/bootstrap.js +11 -0
  17. package/cli/commands/build.d.ts +6 -2
  18. package/cli/commands/build.js +13 -8
  19. package/cli/commands/console.d.ts +5 -1
  20. package/cli/commands/console.js +8 -6
  21. package/cli/commands/deploy.d.ts +4 -2
  22. package/cli/commands/deploy.js +69 -29
  23. package/cli/commands/dev.d.ts +5 -1
  24. package/cli/commands/dev.js +157 -79
  25. package/cli/commands/diff.d.ts +15 -0
  26. package/cli/commands/diff.js +61 -0
  27. package/cli/commands/env.d.ts +5 -1
  28. package/cli/commands/env.js +14 -15
  29. package/cli/commands/plugins/kysely.js +13 -5
  30. package/cli/commands/plugins/pothos.js +9 -4
  31. package/cli/commands/remove.d.ts +4 -0
  32. package/cli/commands/remove.js +26 -18
  33. package/cli/commands/secrets/get.d.ts +7 -3
  34. package/cli/commands/secrets/get.js +11 -24
  35. package/cli/commands/secrets/list.d.ts +6 -2
  36. package/cli/commands/secrets/list.js +15 -7
  37. package/cli/commands/secrets/remove.d.ts +8 -4
  38. package/cli/commands/secrets/remove.js +18 -16
  39. package/cli/commands/secrets/secrets.js +3 -3
  40. package/cli/commands/secrets/set.d.ts +8 -6
  41. package/cli/commands/secrets/set.js +16 -33
  42. package/cli/commands/telemetry.d.ts +15 -0
  43. package/cli/commands/telemetry.js +17 -0
  44. package/cli/commands/transform.d.ts +15 -0
  45. package/cli/commands/transform.js +55 -0
  46. package/cli/commands/update.d.ts +6 -2
  47. package/cli/commands/update.js +41 -33
  48. package/cli/commands/version.d.ts +13 -0
  49. package/cli/commands/version.js +7 -0
  50. package/cli/local/router.d.ts +6 -6
  51. package/cli/local/router.js +3 -3
  52. package/cli/local/server.d.ts +5 -3
  53. package/cli/local/server.js +21 -14
  54. package/cli/program.d.ts +5 -1
  55. package/cli/program.js +29 -5
  56. package/cli/spinner.js +2 -0
  57. package/cli/sst.js +35 -23
  58. package/cli/telemetry/environment.d.ts +1 -1
  59. package/cli/telemetry/environment.js +1 -1
  60. package/cli/terminal.d.ts +1 -0
  61. package/cli/terminal.js +8 -0
  62. package/cli/ui/deploy.d.ts +3 -2
  63. package/cli/ui/deploy.js +106 -106
  64. package/cli/ui/functions.d.ts +2 -0
  65. package/cli/ui/functions.js +132 -0
  66. package/cli/ui/header.d.ts +5 -0
  67. package/cli/ui/header.js +16 -0
  68. package/cli/ui/stack.d.ts +1 -0
  69. package/cli/ui/stack.js +6 -0
  70. package/config.d.ts +1 -1
  71. package/config.js +8 -8
  72. package/constructs/Api.d.ts +3 -71
  73. package/constructs/Api.js +3 -42
  74. package/constructs/ApiGatewayV1Api.d.ts +3 -3
  75. package/constructs/ApiGatewayV1Api.js +4 -3
  76. package/constructs/App.d.ts +2 -22
  77. package/constructs/App.js +12 -25
  78. package/constructs/AppSyncApi.d.ts +4 -5
  79. package/constructs/AppSyncApi.js +8 -5
  80. package/constructs/AstroSite.d.ts +2 -3
  81. package/constructs/AstroSite.js +43 -53
  82. package/constructs/Auth.js +27 -16
  83. package/constructs/BaseSite.d.ts +10 -10
  84. package/constructs/BaseSite.js +2 -2
  85. package/constructs/Cognito.js +28 -28
  86. package/constructs/EdgeFunction.d.ts +6 -4
  87. package/constructs/EdgeFunction.js +56 -59
  88. package/constructs/EventBus.js +1 -1
  89. package/constructs/Function.d.ts +4 -44
  90. package/constructs/Function.js +14 -50
  91. package/constructs/FunctionalStack.d.ts +2 -2
  92. package/constructs/Job.d.ts +23 -63
  93. package/constructs/Job.js +11 -32
  94. package/constructs/Metadata.d.ts +18 -20
  95. package/constructs/NextjsSite.d.ts +21 -5
  96. package/constructs/NextjsSite.js +67 -101
  97. package/constructs/Queue.js +10 -10
  98. package/constructs/RDS.d.ts +1 -1
  99. package/constructs/RDS.js +1 -1
  100. package/constructs/RemixSite.d.ts +0 -2
  101. package/constructs/RemixSite.js +20 -20
  102. package/constructs/Script.js +1 -1
  103. package/constructs/Secret.js +5 -3
  104. package/constructs/SolidStartSite.d.ts +2 -3
  105. package/constructs/SolidStartSite.js +42 -52
  106. package/constructs/SsrFunction.d.ts +22 -0
  107. package/constructs/SsrFunction.js +113 -0
  108. package/constructs/SsrSite.d.ts +104 -104
  109. package/constructs/SsrSite.js +196 -217
  110. package/constructs/Stack.d.ts +1 -20
  111. package/constructs/Stack.js +3 -65
  112. package/constructs/StaticSite.d.ts +33 -53
  113. package/constructs/StaticSite.js +92 -118
  114. package/constructs/Table.d.ts +1 -1
  115. package/constructs/Table.js +4 -4
  116. package/constructs/Topic.js +1 -1
  117. package/constructs/cdk/certificate-base.d.ts +18 -0
  118. package/constructs/cdk/certificate-base.js +26 -0
  119. package/constructs/cdk/dns-validated-certificate.d.ts +77 -0
  120. package/constructs/cdk/dns-validated-certificate.js +125 -0
  121. package/constructs/cdk/website-redirect.d.ts +53 -0
  122. package/constructs/cdk/website-redirect.js +77 -0
  123. package/constructs/deferred_task.d.ts +1 -1
  124. package/constructs/deprecated/NextjsSite.js +8 -6
  125. package/constructs/index.d.ts +0 -6
  126. package/constructs/index.js +0 -6
  127. package/constructs/util/apiGatewayV1AccessLog.d.ts +1 -1
  128. package/constructs/util/apiGatewayV2AccessLog.js +4 -4
  129. package/constructs/util/apiGatewayV2Domain.js +9 -2
  130. package/constructs/util/appSyncApiDomain.d.ts +1 -1
  131. package/constructs/util/appSyncApiDomain.js +9 -15
  132. package/constructs/util/duration.d.ts +1 -1
  133. package/constructs/util/functionBinding.js +1 -1
  134. package/constructs/util/permission.d.ts +3 -3
  135. package/constructs/util/permission.js +16 -18
  136. package/constructs/util/size.d.ts +1 -1
  137. package/constructs/util/warning.js +2 -2
  138. package/context/context.d.ts +2 -2
  139. package/context/context.js +4 -4
  140. package/context/handler.d.ts +1 -1
  141. package/credentials.d.ts +1 -1
  142. package/credentials.js +42 -6
  143. package/index.d.ts +1 -0
  144. package/index.js +1 -0
  145. package/iot.js +6 -2
  146. package/logger.js +3 -1
  147. package/node/api/index.d.ts +2 -3
  148. package/node/api/index.js +8 -2
  149. package/node/auth/adapter/adapter.d.ts +1 -1
  150. package/node/auth/adapter/facebook.js +1 -1
  151. package/node/auth/adapter/github.js +4 -4
  152. package/node/auth/adapter/google.d.ts +1 -1
  153. package/node/auth/adapter/google.js +2 -2
  154. package/node/auth/adapter/twitch.js +1 -1
  155. package/node/auth/session.d.ts +1 -1
  156. package/node/config/index.d.ts +2 -2
  157. package/node/config/index.js +3 -8
  158. package/node/job/index.d.ts +2 -2
  159. package/node/site/index.js +3 -5
  160. package/package.json +26 -21
  161. package/pothos.js +1 -0
  162. package/project.d.ts +47 -0
  163. package/{app.js → project.js} +60 -53
  164. package/runtime/handlers/dotnet.d.ts +1 -1
  165. package/runtime/handlers/dotnet.js +4 -4
  166. package/runtime/handlers/go.d.ts +1 -1
  167. package/runtime/handlers/go.js +3 -3
  168. package/runtime/handlers/java.d.ts +1 -1
  169. package/runtime/handlers/java.js +4 -4
  170. package/runtime/handlers/node.d.ts +1 -1
  171. package/runtime/handlers/node.js +60 -39
  172. package/runtime/handlers/python.d.ts +1 -1
  173. package/runtime/handlers/python.js +3 -3
  174. package/runtime/handlers.js +15 -12
  175. package/runtime/iot.js +3 -0
  176. package/runtime/runtime.d.ts +4 -0
  177. package/runtime/server.d.ts +3 -3
  178. package/runtime/server.js +11 -5
  179. package/runtime/workers.d.ts +4 -2
  180. package/runtime/workers.js +13 -3
  181. package/site-env.js +2 -1
  182. package/sst.mjs +6357 -20848
  183. package/stacks/app-metadata.d.ts +7 -0
  184. package/stacks/app-metadata.js +78 -0
  185. package/stacks/assembly.d.ts +1 -0
  186. package/stacks/assembly.js +4 -0
  187. package/stacks/build.d.ts +1 -1
  188. package/stacks/build.js +41 -48
  189. package/stacks/deploy.d.ts +1 -0
  190. package/stacks/deploy.js +128 -7
  191. package/stacks/diff.d.ts +8 -0
  192. package/stacks/diff.js +62 -0
  193. package/stacks/index.d.ts +3 -0
  194. package/stacks/index.js +3 -0
  195. package/stacks/metadata.d.ts +2 -0
  196. package/stacks/metadata.js +14 -12
  197. package/stacks/monitor.d.ts +8 -3
  198. package/stacks/monitor.js +38 -4
  199. package/stacks/remove.js +0 -4
  200. package/stacks/synth.d.ts +1 -0
  201. package/stacks/synth.js +27 -13
  202. package/support/base-site-archiver.mjs +1 -1
  203. package/support/bootstrap-metadata-function/index.mjs +68740 -0
  204. package/support/bridge/bridge.mjs +28 -28
  205. package/support/certificate-requestor/index.js +549 -0
  206. package/support/custom-resources/index.mjs +3824 -26567
  207. package/support/dotnet6-bootstrap/release/dotnet-bootstrap.deps.json +1 -1
  208. package/support/dotnet6-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +1 -1
  209. package/support/edge-function/edge-lambda.mjs +2 -2
  210. package/support/job-invoker/index.mjs +26 -0
  211. package/support/nodejs-runtime/index.mjs +75 -72
  212. package/support/rds-migrator/index.mjs +22 -23
  213. package/support/remix-site-function/edge-server.js +1 -1
  214. package/support/script-function/index.mjs +30485 -0
  215. package/support/{edge-function-code-replacer → sls-nextjs-site-function-code-replacer}/lambda-code-updater.py +0 -0
  216. package/support/ssr-site-function-archiver.mjs +96 -0
  217. package/watcher.js +1 -1
  218. package/app.d.ts +0 -36
  219. package/constructs/DebugApp.d.ts +0 -49
  220. package/constructs/DebugApp.js +0 -63
  221. package/constructs/DebugStack.d.ts +0 -34
  222. package/constructs/DebugStack.js +0 -132
  223. package/constructs/GraphQLApi.d.ts +0 -98
  224. package/constructs/GraphQLApi.js +0 -80
  225. package/constructs/ReactStaticSite.d.ts +0 -20
  226. package/constructs/ReactStaticSite.js +0 -54
  227. package/constructs/Script/cfn-response.d.ts +0 -19
  228. package/constructs/Script/cfn-response.js +0 -77
  229. package/constructs/Script/index.d.ts +0 -1
  230. package/constructs/Script/index.js +0 -78
  231. package/constructs/Script/outbound.d.ts +0 -10
  232. package/constructs/Script/outbound.js +0 -42
  233. package/constructs/Script/util.d.ts +0 -2
  234. package/constructs/Script/util.js +0 -11
  235. package/constructs/ViteStaticSite.d.ts +0 -32
  236. package/constructs/ViteStaticSite.js +0 -66
  237. package/support/astro-site-html-stub/index.html +0 -99
  238. package/support/base-site-archiver.cjs +0 -116
  239. package/support/nextjs-site-html-stub/index.html +0 -99
  240. package/support/remix-site-html-stub/index.html +0 -99
  241. package/support/solid-start-site-html-stub/index.html +0 -99
  242. package/support/static-site-stub/index.html +0 -90
@@ -0,0 +1,55 @@
1
+ export const transform = (program) => program.command("transform <mod>", "Apply a transform to your SST app", (yargs) => yargs.positional("mod", {
2
+ type: "string",
3
+ describe: "Name of the transform",
4
+ demandOption: true,
5
+ }), async (args) => {
6
+ const { Colors } = await import("../colors.js");
7
+ if (args.mod === "resource-binding-secrets") {
8
+ await handleSecretsMigration();
9
+ Colors.line(Colors.success(`✔ `), `Transform "${args.mod}" applied successfully!`);
10
+ return;
11
+ }
12
+ Colors.line(Colors.danger(`✖ `), `Transform "${args.mod}" not found`);
13
+ });
14
+ async function handleSecretsMigration() {
15
+ const { useProject } = await import("../../project.js");
16
+ const { useAWSClient } = await import("../../credentials.js");
17
+ const { SSMClient, GetParametersByPathCommand, PutParameterCommand } = await import("@aws-sdk/client-ssm");
18
+ const project = useProject();
19
+ const { name: app, stage } = project.config;
20
+ const ssm = useAWSClient(SSMClient);
21
+ async function* getAllPrametersByPath(prefix) {
22
+ let token;
23
+ while (true) {
24
+ const results = await ssm.send(new GetParametersByPathCommand({
25
+ Path: prefix,
26
+ WithDecryption: true,
27
+ Recursive: true,
28
+ NextToken: token,
29
+ }));
30
+ yield* results.Parameters || [];
31
+ if (!results.NextToken)
32
+ break;
33
+ token = results.NextToken;
34
+ }
35
+ }
36
+ async function migrateSecretsSSMPath(stage) {
37
+ const oldPrefix = `/sst/${app}/${stage}/secrets/`;
38
+ const newPrefix = `/sst/${app}/${stage}/Secret/`;
39
+ for await (const secret of getAllPrametersByPath(oldPrefix)) {
40
+ const name = secret.Name.split("/")[5];
41
+ // Do not migrate SST Auth secrets b/c they are no longer secrets in v1.16.
42
+ if (name === "SST_AUTH_PRIVATE" || name === "SST_AUTH_PUBLIC") {
43
+ continue;
44
+ }
45
+ await ssm.send(new PutParameterCommand({
46
+ Name: `${newPrefix}${name}/value`,
47
+ Value: secret.Value,
48
+ Type: secret.Type,
49
+ Overwrite: true,
50
+ }));
51
+ }
52
+ }
53
+ await migrateSecretsSSMPath(stage);
54
+ await migrateSecretsSSMPath(".fallback");
55
+ }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="yargs" />
2
- import { Program } from "../program.js";
2
+ import type { Program } from "../program.js";
3
3
  export declare const update: (program: Program) => import("yargs").Argv<{
4
4
  stage: string | undefined;
5
5
  } & {
@@ -7,5 +7,9 @@ export declare const update: (program: Program) => import("yargs").Argv<{
7
7
  } & {
8
8
  region: string | undefined;
9
9
  } & {
10
- ver: string | undefined;
10
+ verbose: boolean | undefined;
11
+ } & {
12
+ role: string | undefined;
13
+ } & {
14
+ version: string | undefined;
11
15
  }>;
@@ -1,17 +1,36 @@
1
- import { green, yellow } from "colorette";
2
- import fs from "fs/promises";
3
- import path from "path";
4
- const PACKAGE_MATCH = ["sst", "aws-cdk", "@aws-cdk"];
1
+ const PACKAGE_MATCH = ["sst", "aws-cdk", "@aws-cdk", "constructs"];
5
2
  const FIELDS = ["dependencies", "devDependencies"];
6
- export const update = (program) => program.command("update [ver]", "Update SST and CDK packages to another version", (yargs) => yargs.positional("ver", {
3
+ export const update = (program) => program.command("update [version]", "Update your SST and CDK packages", (yargs) => yargs.positional("version", {
7
4
  type: "string",
8
- describe: "Optional SST version to update to",
5
+ describe: "Optionally specify a version to update to",
9
6
  }), async (args) => {
7
+ const { green, yellow } = await import("colorette");
8
+ const fs = await import("fs/promises");
9
+ const path = await import("path");
10
10
  const { fetch } = await import("undici");
11
- const { useProject } = await import("../../app.js");
11
+ const { useProject } = await import("../../project.js");
12
+ const { Colors } = await import("../colors.js");
13
+ async function find(dir) {
14
+ const children = await fs.readdir(dir);
15
+ const tasks = children.map(async (item) => {
16
+ if (item === "node_modules")
17
+ return [];
18
+ // Ignore hidden paths
19
+ if (/(^|\/)\.[^\/\.]/g.test(item))
20
+ return [];
21
+ const full = path.join(dir, item);
22
+ if (item === "package.json")
23
+ return [full];
24
+ const stat = await fs.stat(full);
25
+ if (stat.isDirectory())
26
+ return find(full);
27
+ return [];
28
+ });
29
+ return (await Promise.all(tasks)).flat();
30
+ }
12
31
  const project = useProject();
13
32
  const files = await find(project.paths.root);
14
- const metadata = await fetch(`https://registry.npmjs.org/sst/${args.ver || "latest"}`).then((resp) => resp.json());
33
+ const metadata = await fetch(`https://registry.npmjs.org/sst/${args.version || "latest"}`).then((resp) => resp.json());
15
34
  const results = new Map();
16
35
  const tasks = files.map(async (file) => {
17
36
  const data = await fs
@@ -25,9 +44,15 @@ export const update = (program) => program.command("update [ver]", "Update SST a
25
44
  for (const [pkg, existing] of Object.entries(deps)) {
26
45
  if (!PACKAGE_MATCH.some((x) => pkg.startsWith(x)))
27
46
  continue;
28
- const desired = pkg === "sst"
29
- ? metadata.version
30
- : metadata.dependencies["aws-cdk-lib"];
47
+ const desired = (() => {
48
+ if (pkg === "sst")
49
+ return metadata.version;
50
+ if (pkg === "constructs")
51
+ return metadata.dependencies.constructs;
52
+ if (pkg.endsWith("alpha"))
53
+ return metadata.dependencies["@aws-cdk/aws-apigatewayv2-alpha"];
54
+ return metadata.dependencies["aws-cdk-lib"];
55
+ })();
31
56
  if (existing === desired)
32
57
  continue;
33
58
  let arr = results.get(file);
@@ -43,32 +68,15 @@ export const update = (program) => program.command("update [ver]", "Update SST a
43
68
  });
44
69
  await Promise.all(tasks);
45
70
  if (results.size === 0) {
46
- console.log(green(`All packages already match version ${metadata.version}`));
71
+ Colors.line(Colors.success(`✔ `), `Already using v${metadata.version}`);
47
72
  return;
48
73
  }
49
74
  for (const [file, pkgs] of results.entries()) {
50
- console.log(green(`✅ ${path.relative(project.paths.root, file)}`));
75
+ Colors.line(Colors.success(`✔ `), Colors.bold.dim(path.relative(project.paths.root, file)));
51
76
  for (const [pkg, version] of pkgs) {
52
- console.log(green(` ${pkg}@${version}`));
77
+ Colors.line(Colors.dim(` ${pkg}@${version}`));
53
78
  }
54
79
  }
55
- console.log(yellow("Don't forget to run your package manager to install the packages"));
80
+ Colors.gap();
81
+ Colors.line(`${Colors.primary(`➜`)} ${Colors.warning("Make sure to run: npm install (or pnpm install, or yarn)")}`);
56
82
  });
57
- async function find(dir) {
58
- const children = await fs.readdir(dir);
59
- const tasks = children.map(async (item) => {
60
- if (item === "node_modules")
61
- return [];
62
- // Ignore hidden paths
63
- if (/(^|\/)\.[^\/\.]/g.test(item))
64
- return [];
65
- const full = path.join(dir, item);
66
- if (item === "package.json")
67
- return [full];
68
- const stat = await fs.stat(full);
69
- if (stat.isDirectory())
70
- return find(full);
71
- return [];
72
- });
73
- return (await Promise.all(tasks)).flat();
74
- }
@@ -0,0 +1,13 @@
1
+ /// <reference types="yargs" />
2
+ import type { Program } from "../program.js";
3
+ export declare const version: (program: Program) => import("yargs").Argv<{
4
+ stage: string | undefined;
5
+ } & {
6
+ profile: string | undefined;
7
+ } & {
8
+ region: string | undefined;
9
+ } & {
10
+ verbose: boolean | undefined;
11
+ } & {
12
+ role: string | undefined;
13
+ }>;
@@ -0,0 +1,7 @@
1
+ export const version = (program) => program.command("version", "Print SST and CDK version", (yargs) => yargs, async (args) => {
2
+ const { Colors } = await import("../colors.js");
3
+ const { useProject } = await import("../../project.js");
4
+ const project = useProject();
5
+ Colors.line(Colors.bold(`SST:`), `v${project.version}`);
6
+ Colors.line(Colors.bold(`CDK:`), `v${project.cdkVersion}`);
7
+ });
@@ -1,6 +1,6 @@
1
1
  import * as trpc from "@trpc/server";
2
2
  import { DendriformPatch } from "dendriform-immer-patch-optimiser";
3
- export declare type State = {
3
+ export type State = {
4
4
  app: string;
5
5
  stage: string;
6
6
  functions: Record<string, FunctionState>;
@@ -9,13 +9,13 @@ export declare type State = {
9
9
  status: any;
10
10
  };
11
11
  };
12
- export declare type FunctionState = {
12
+ export type FunctionState = {
13
13
  state: "idle" | "building" | "checking";
14
14
  invocations: Invocation[];
15
15
  issues: Record<string, any[]>;
16
16
  warm: boolean;
17
17
  };
18
- export declare type Invocation = {
18
+ export type Invocation = {
19
19
  id: string;
20
20
  request: any;
21
21
  response?: any;
@@ -28,15 +28,15 @@ export declare type Invocation = {
28
28
  timestamp: number;
29
29
  }[];
30
30
  };
31
- export declare type Context = {
31
+ export type Context = {
32
32
  state: State;
33
33
  };
34
34
  export declare const router: import("@trpc/server/dist/declarations/src/router.js").Router<Context, Context, Record<"getCredentials", import("@trpc/server/dist/declarations/src/internals/procedure.js").Procedure<Context, Context, undefined, undefined, {
35
- region: string;
35
+ region: string | undefined;
36
36
  credentials: {
37
37
  accessKeyId: string;
38
38
  secretAccessKey: string;
39
39
  sessionToken: string | undefined;
40
40
  };
41
41
  }>> & Record<"getState", import("@trpc/server/dist/declarations/src/internals/procedure.js").Procedure<Context, Context, undefined, undefined, State>>, Record<"deploy", import("@trpc/server/dist/declarations/src/internals/procedure.js").Procedure<Context, Context, undefined, undefined, void>>, Record<"onStateChange", import("@trpc/server/dist/declarations/src/internals/procedure.js").Procedure<Context, Context, undefined, undefined, trpc.Subscription<DendriformPatch[]>>>, trpc.DefaultErrorShape>;
42
- export declare type Router = typeof router;
42
+ export type Router = typeof router;
@@ -1,5 +1,5 @@
1
1
  import * as trpc from "@trpc/server";
2
- import { useProject } from "../../app.js";
2
+ import { useProject } from "../../project.js";
3
3
  import { useBus } from "../../bus.js";
4
4
  import { useAWSCredentials } from "../../credentials.js";
5
5
  export const router = trpc
@@ -9,7 +9,7 @@ export const router = trpc
9
9
  const project = useProject();
10
10
  const credentials = await useAWSCredentials();
11
11
  return {
12
- region: project.region,
12
+ region: project.config.region,
13
13
  credentials: {
14
14
  accessKeyId: credentials.accessKeyId,
15
15
  secretAccessKey: credentials.secretAccessKey,
@@ -24,7 +24,7 @@ export const router = trpc
24
24
  },
25
25
  })
26
26
  .mutation("deploy", {
27
- async resolve({ ctx }) {
27
+ async resolve() {
28
28
  return;
29
29
  },
30
30
  })
@@ -1,8 +1,7 @@
1
1
  import { FunctionState, State } from "./router.js";
2
2
  import { WritableDraft } from "immer/dist/internal.js";
3
3
  import { DendriformPatch } from "dendriform-immer-patch-optimiser";
4
- declare type Opts = {
5
- port: number;
4
+ type Opts = {
6
5
  key: any;
7
6
  cert: any;
8
7
  live: boolean;
@@ -12,8 +11,11 @@ declare module "../../bus.js" {
12
11
  "local.patches": DendriformPatch[];
13
12
  }
14
13
  }
15
- export declare function useLocalServer(opts: Opts): Promise<{
14
+ export declare const useLocalServerConfig: () => Promise<{
16
15
  port: number;
16
+ url: string;
17
+ }>;
18
+ export declare function useLocalServer(opts: Opts): Promise<{
17
19
  updateState: (cb: (draft: WritableDraft<State>) => void) => void;
18
20
  updateFunction: (id: string, cb: (draft: WritableDraft<FunctionState>) => void) => void;
19
21
  }>;
@@ -9,13 +9,26 @@ import { applyWSSHandler } from "@trpc/server/adapters/ws/dist/trpc-server-adapt
9
9
  import { router } from "./router.js";
10
10
  import { optimise } from "dendriform-immer-patch-optimiser";
11
11
  import { sync } from "cross-spawn";
12
- import { useProject } from "../../app.js";
12
+ import { useProject } from "../../project.js";
13
13
  import { useBus } from "../../bus.js";
14
+ import getPort from "get-port";
15
+ import { Context } from "../../context/context.js";
16
+ export const useLocalServerConfig = Context.memo(async () => {
17
+ const project = useProject();
18
+ const port = await getPort({
19
+ port: 13557,
20
+ });
21
+ return {
22
+ port,
23
+ url: `https://console.sst.dev/${project.config.name}/${project.config.stage}${port !== 13557 ? `?_port=${port}` : ""}`,
24
+ };
25
+ });
14
26
  export async function useLocalServer(opts) {
27
+ const cfg = await useLocalServerConfig();
15
28
  const project = useProject();
16
29
  let state = {
17
- app: project.name,
18
- stage: project.stage,
30
+ app: project.config.name,
31
+ stage: project.config.stage,
19
32
  live: opts.live,
20
33
  stacks: {
21
34
  status: "idle",
@@ -23,17 +36,12 @@ export async function useLocalServer(opts) {
23
36
  functions: {},
24
37
  };
25
38
  const rest = express();
26
- /*
27
39
  rest.all(`/ping`, (req, res) => {
28
- res.header("Access-Control-Allow-Origin", "*");
29
- res.header("Access-Control-Allow-Methods", "GET, PUT, PATCH, POST, DELETE");
30
- res.header(
31
- "Access-Control-Allow-Headers",
32
- req.header("access-control-request-headers")
33
- );
34
- res.sendStatus(200);
40
+ res.header("Access-Control-Allow-Origin", "*");
41
+ res.header("Access-Control-Allow-Methods", "GET, PUT, PATCH, POST, DELETE");
42
+ res.header("Access-Control-Allow-Headers", req.header("access-control-request-headers"));
43
+ res.sendStatus(200);
35
44
  });
36
- */
37
45
  rest.all(`/proxy*`, express.raw({
38
46
  type: "*/*",
39
47
  limit: "1024mb",
@@ -107,7 +115,7 @@ export async function useLocalServer(opts) {
107
115
  console.log("Rejecting unauthorized connection from " + req.headers.origin);
108
116
  socket.terminate();
109
117
  });
110
- server.listen(opts.port);
118
+ server.listen(cfg.port);
111
119
  const handler = applyWSSHandler({
112
120
  wss,
113
121
  router,
@@ -204,7 +212,6 @@ export async function useLocalServer(opts) {
204
212
  });
205
213
  });
206
214
  const result = {
207
- port: opts.port,
208
215
  updateState,
209
216
  updateFunction,
210
217
  };
package/cli/program.d.ts CHANGED
@@ -5,5 +5,9 @@ export declare const program: import("yargs").Argv<{
5
5
  profile: string | undefined;
6
6
  } & {
7
7
  region: string | undefined;
8
+ } & {
9
+ verbose: boolean | undefined;
10
+ } & {
11
+ role: string | undefined;
8
12
  }>;
9
- export declare type Program = typeof program;
13
+ export type Program = typeof program;
package/cli/program.js CHANGED
@@ -1,7 +1,5 @@
1
1
  import yargs from "yargs";
2
2
  import { hideBin } from "yargs/helpers";
3
- import { initProject } from "../app.js";
4
- import { trackCli } from "./telemetry/telemetry.js";
5
3
  export const program = yargs(hideBin(process.argv))
6
4
  .scriptName("sst")
7
5
  .option("stage", {
@@ -16,9 +14,35 @@ export const program = yargs(hideBin(process.argv))
16
14
  type: "string",
17
15
  describe: "The AWS region to use",
18
16
  })
17
+ .option("verbose", {
18
+ type: "boolean",
19
+ describe: "Print verbose logs",
20
+ })
21
+ .option("role", {
22
+ type: "string",
23
+ describe: "ARN of the IAM role to use when invoking AWS",
24
+ })
25
+ .group(["stage", "profile", "region", "role", "verbose", "help"], "Global:")
19
26
  .middleware(async (argv) => {
20
- await initProject(argv);
21
- trackCli(argv._[0]);
27
+ if (argv.verbose) {
28
+ process.env.SST_VERBOSE = "1";
29
+ }
30
+ if (argv._.length > 0) {
31
+ const { initProject } = await import("../project.js");
32
+ await initProject(argv);
33
+ const { trackCli } = await import("./telemetry/telemetry.js");
34
+ trackCli(argv._[0]);
35
+ }
22
36
  })
37
+ .version(false)
38
+ .epilogue(`Join the SST community on Discord https://sst.dev/discord`)
39
+ .recommendCommands()
40
+ .demandCommand()
23
41
  .strict()
24
- .demandCommand(1);
42
+ .fail((_, error, yargs) => {
43
+ if (!error) {
44
+ yargs.showHelp();
45
+ process.exit(1);
46
+ }
47
+ throw error;
48
+ });
package/cli/spinner.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Context } from "../context/context.js";
2
2
  import ora from "ora";
3
+ import { Colors } from "./colors.js";
3
4
  export const useSpinners = Context.memo(() => {
4
5
  const spinners = [];
5
6
  return spinners;
@@ -8,5 +9,6 @@ export function createSpinner(options) {
8
9
  const spinners = useSpinners();
9
10
  const next = ora(options);
10
11
  spinners.push(next);
12
+ Colors.mode("line");
11
13
  return next;
12
14
  }
package/cli/sst.js CHANGED
@@ -1,29 +1,49 @@
1
1
  #!/usr/bin/env node
2
2
  import { blue, red } from "colorette";
3
3
  import { program } from "./program.js";
4
- import { secrets } from "./commands/secrets/secrets.js";
5
- import { update } from "./commands/update.js";
4
+ import { VisibleError } from "../error.js";
5
+ import { useSpinners } from "./spinner.js";
6
+ import { Logger } from "../logger.js";
7
+ import dotenv from "dotenv";
8
+ dotenv.config({
9
+ override: true,
10
+ });
11
+ dotenv.config({
12
+ path: ".env.local",
13
+ override: true,
14
+ });
15
+ import { env } from "./commands/env.js";
6
16
  import { dev } from "./commands/dev.js";
7
17
  import { bind } from "./commands/bind.js";
8
18
  import { build } from "./commands/build.js";
9
- import { VisibleError } from "../error.js";
10
- import { useSpinners } from "./spinner.js";
11
19
  import { deploy } from "./commands/deploy.js";
12
20
  import { remove } from "./commands/remove.js";
13
- import dotenv from "dotenv";
14
- import { env } from "./commands/env.js";
15
- import { Logger } from "../logger.js";
16
21
  import { consoleCommand } from "./commands/console.js";
17
- dotenv.config();
18
- secrets(program);
19
- update(program);
22
+ import { secrets } from "./commands/secrets/secrets.js";
23
+ import { update } from "./commands/update.js";
24
+ import { transform } from "./commands/transform.js";
25
+ import { diff } from "./commands/diff.js";
26
+ import { version } from "./commands/version.js";
27
+ import { telemetry } from "./commands/telemetry.js";
28
+ import { bootstrap } from "./commands/bootstrap.js";
20
29
  dev(program);
21
- bind(program);
22
- build(program);
23
30
  deploy(program);
24
- remove(program);
31
+ build(program);
32
+ bind(program);
25
33
  env(program);
34
+ secrets(program);
35
+ remove(program);
36
+ update(program);
37
+ transform(program);
26
38
  consoleCommand(program);
39
+ diff(program);
40
+ version(program);
41
+ telemetry(program);
42
+ bootstrap(program);
43
+ if ("setSourceMapsEnabled" in process) {
44
+ // @ts-expect-error
45
+ process.setSourceMapsEnabled(true);
46
+ }
27
47
  process.removeAllListeners("uncaughtException");
28
48
  process.on("uncaughtException", (err) => {
29
49
  Logger.debug(err);
@@ -38,16 +58,8 @@ process.on("uncaughtException", (err) => {
38
58
  console.trace(err.stack);
39
59
  }
40
60
  console.log();
41
- console.log(`Need help with this error? Join our discord ${blue(`https://discord.gg/sst`)} and talk to the team`);
61
+ console.log(`Need help with this error? Join the SST community on Discord ${blue(`https://sst.dev/discord`)}`);
42
62
  process.exit(1);
43
63
  });
44
64
  process.on("beforeExit", () => { });
45
- program
46
- .fail((msg, error) => {
47
- if (!error) {
48
- console.log(msg);
49
- return;
50
- }
51
- throw error;
52
- })
53
- .parse();
65
+ program.parse();
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
- declare type EnvironmentData = {
2
+ type EnvironmentData = {
3
3
  systemPlatform: NodeJS.Platform;
4
4
  systemRelease: string;
5
5
  systemArchitecture: string;
@@ -1,6 +1,6 @@
1
1
  import os from "os";
2
2
  import ciInfo from "ci-info";
3
- import { useProject } from "../../app.js";
3
+ import { useProject } from "../../project.js";
4
4
  let data;
5
5
  export function getEnvironmentData() {
6
6
  if (data) {
@@ -0,0 +1 @@
1
+ export declare function clear(): void;
@@ -0,0 +1,8 @@
1
+ export function clear() {
2
+ // console.clear() removes the content in the viewport in VSCode
3
+ // and on Windows. This is a workaround to preserve the viewport.
4
+ for (let i = 0, l = process.stdout.rows; i < l - 1; i++) {
5
+ console.log("");
6
+ }
7
+ console.clear();
8
+ }
@@ -1,8 +1,9 @@
1
1
  /// <reference types="react" resolution-mode="require"/>
2
2
  import { Stacks } from "../../stacks/index.js";
3
+ import type { CloudAssembly } from "aws-cdk-lib/cx-api";
3
4
  interface Props {
4
- stacks: string[];
5
+ assembly: CloudAssembly;
5
6
  }
6
7
  export declare const DeploymentUI: (props: Props) => JSX.Element;
7
- export declare function printDeploymentResults(results: Awaited<ReturnType<typeof Stacks.deployMany>>): void;
8
+ export declare function printDeploymentResults(assembly: CloudAssembly, results: Awaited<ReturnType<typeof Stacks.deployMany>>, remove?: boolean): void;
8
9
  export {};