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,61 @@
1
+ import { stackNameToId } from "../ui/stack.js";
2
+ export const diff = (program) => program.command("diff", "Compare your app with what is deployed on AWS", (yargs) => yargs.option("dev", {
3
+ type: "boolean",
4
+ describe: "Compare in dev mode",
5
+ }), async (args) => {
6
+ const { useProject } = await import("../../project.js");
7
+ const { Stacks } = await import("../../stacks/index.js");
8
+ const { useAWSClient } = await import("../../credentials.js");
9
+ const { CloudFormationClient, GetTemplateCommand } = await import("@aws-sdk/client-cloudformation");
10
+ const { createSpinner } = await import("../spinner.js");
11
+ const { green } = await import("colorette");
12
+ const { Colors } = await import("../colors.js");
13
+ // Build app
14
+ const project = useProject();
15
+ const assembly = await Stacks.synth({
16
+ fn: project.stacks,
17
+ mode: args.dev ? "dev" : "deploy",
18
+ });
19
+ // Diff each stack
20
+ let changesAcc = 0;
21
+ let changedStacks = 0;
22
+ const cfn = useAWSClient(CloudFormationClient);
23
+ for (const stack of assembly.stacks) {
24
+ const spinner = createSpinner(`${stack.stackName}: Checking for changes...`);
25
+ // get old template
26
+ const response = await cfn.send(new GetTemplateCommand({
27
+ StackName: stack.stackName,
28
+ }));
29
+ const oldTemplate = JSON.parse(response.TemplateBody);
30
+ // generate diff
31
+ const { count, diff } = await Stacks.diff(stack, oldTemplate);
32
+ spinner.clear();
33
+ // print diff result
34
+ if (count === 0) {
35
+ Colors.line(`➜ ${Colors.dim.bold(stackNameToId(stack.stackName) + ":")} No changes`);
36
+ Colors.gap();
37
+ }
38
+ else if (count === 1) {
39
+ Colors.line(`➜ ${Colors.dim.bold(stackNameToId(stack.stackName) + ":")} ${count} change`);
40
+ Colors.gap();
41
+ console.log(diff);
42
+ changesAcc += count;
43
+ changedStacks++;
44
+ }
45
+ else {
46
+ Colors.line(`➜ ${Colors.dim.bold(stackNameToId(stack.stackName) + ":")} ${count} changes`);
47
+ Colors.gap();
48
+ console.log(diff);
49
+ changesAcc += count;
50
+ changedStacks++;
51
+ }
52
+ }
53
+ // Handle no changes
54
+ if (changedStacks === 0) {
55
+ Colors.line(Colors.success(`✔`), Colors.bold(" Diff:"), "No changes");
56
+ }
57
+ else {
58
+ Colors.line(Colors.success(`✔`), Colors.bold(" Diff:"), changesAcc === 1 ? "1 change found in" : `${changesAcc} changes in`, changedStacks === 1 ? "1 stack" : `${changedStacks} stacks`);
59
+ }
60
+ process.exit(0);
61
+ });
@@ -1,11 +1,15 @@
1
1
  /// <reference types="yargs" />
2
- import { Program } from "../program.js";
2
+ import type { Program } from "../program.js";
3
3
  export declare const env: (program: Program) => import("yargs").Argv<{
4
4
  stage: string | undefined;
5
5
  } & {
6
6
  profile: string | undefined;
7
7
  } & {
8
8
  region: string | undefined;
9
+ } & {
10
+ verbose: boolean | undefined;
11
+ } & {
12
+ role: string | undefined;
9
13
  } & {
10
14
  command: string;
11
15
  }>;
@@ -1,30 +1,29 @@
1
- import { useProject } from "../../app.js";
2
- import { createSpinner } from "../spinner.js";
3
- import fs from "fs/promises";
4
- import path from "path";
5
- import { SiteEnv } from "../../site-env.js";
6
- import { spawnSync } from "child_process";
7
- export const env = (program) => program.command("env <command>", "description", (yargs) => yargs.positional("command", {
1
+ export const env = (program) => program.command("env <command>", "Load environment variables and start your frontend", (yargs) => yargs
2
+ .positional("command", {
8
3
  type: "string",
9
- describe: "Command to run with environment variabels loaded",
4
+ describe: "The command to start your frontend",
10
5
  demandOption: true,
11
- }), async (args) => {
12
- const project = useProject();
13
- const spinner = createSpinner("Waiting for SST to start").start();
6
+ })
7
+ .example(`sst env "next dev"`, "Start Next.js with your environment variables")
8
+ .example(`sst env "vite dev"`, "Start Vite with your environment variables"), async (args) => {
9
+ const { createSpinner } = await import("../spinner.js");
10
+ const fs = await import("fs/promises");
11
+ const { SiteEnv } = await import("../../site-env.js");
12
+ const { spawnSync } = await import("child_process");
13
+ let spinner;
14
14
  while (true) {
15
15
  const exists = await fs
16
16
  .access(SiteEnv.valuesFile())
17
17
  .then(() => true)
18
18
  .catch(() => false);
19
19
  if (!exists) {
20
+ spinner = createSpinner("Cannot find SST environment variables. Waiting for SST to start...").start();
20
21
  await new Promise((resolve) => setTimeout(resolve, 1000));
21
22
  continue;
22
23
  }
23
- spinner.succeed();
24
+ spinner?.succeed();
24
25
  const sites = await SiteEnv.values();
25
- const current = path.relative(project.paths.root, process.cwd());
26
- const env = sites[current] || {};
27
- console.log(args.command);
26
+ const env = sites[process.cwd()] || {};
28
27
  const result = spawnSync(args.command, {
29
28
  env: {
30
29
  ...process.env,
@@ -5,7 +5,9 @@ import * as fs from "fs/promises";
5
5
  import { DatabaseMetadata, EnumCollection, PostgresDialect, Serializer, Transformer, } from "kysely-codegen";
6
6
  import { Context } from "../../../context/context.js";
7
7
  import { useBus } from "../../../bus.js";
8
- import { useProject } from "../../../app.js";
8
+ import { useProject } from "../../../project.js";
9
+ import { Logger } from "../../../logger.js";
10
+ import { useAWSCredentials, } from "../../../credentials.js";
9
11
  export const useKyselyTypeGenerator = Context.memo(async () => {
10
12
  let databases = [];
11
13
  const bus = useBus();
@@ -13,6 +15,8 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
13
15
  async function generate(db) {
14
16
  if (!db.types)
15
17
  return;
18
+ Logger.debug("Generating types for", db.migratorID);
19
+ const credentials = await useAWSCredentials();
16
20
  const k = new Kysely({
17
21
  dialect: new DataApiDialect({
18
22
  mode: db.engine.includes("postgres") ? "postgres" : "mysql",
@@ -21,7 +25,8 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
21
25
  resourceArn: db.clusterArn,
22
26
  database: db.defaultDatabaseName,
23
27
  client: new RDSDataService({
24
- region: project.region,
28
+ region: project.config.region,
29
+ credentials,
25
30
  }),
26
31
  },
27
32
  }),
@@ -67,13 +72,13 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
67
72
  await fs.writeFile(db.types.path, data);
68
73
  }
69
74
  bus.subscribe("stacks.metadata", (evt) => {
70
- databases = Object.values(evt.properties)
71
- .flat()
75
+ const constructs = Object.values(evt.properties).flat();
76
+ databases = constructs
72
77
  .filter((c) => c.type === "RDS")
73
78
  .filter((c) => c.data.migrator)
74
79
  .filter((c) => c.data.types)
75
80
  .map((c) => ({
76
- migratorID: evt.properties.metadata.find((fn) => fn.addr == c.data.migrator?.node).addr,
81
+ migratorID: constructs.find((fn) => fn.addr == c.data.migrator?.node).addr,
77
82
  clusterArn: c.data.clusterArn,
78
83
  types: c.data.types,
79
84
  engine: c.data.engine,
@@ -83,9 +88,12 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
83
88
  databases.map((db) => generate(db));
84
89
  });
85
90
  bus.subscribe("function.success", async (evt) => {
91
+ if (!evt.properties.body?.results)
92
+ return;
86
93
  const db = databases.find((db) => db.migratorID === evt.properties.functionID);
87
94
  if (!db)
88
95
  return;
89
96
  generate(db);
90
97
  });
98
+ Logger.debug("Loaded kyseley type generator");
91
99
  });
@@ -6,6 +6,7 @@ import { exec } from "child_process";
6
6
  import { promisify } from "util";
7
7
  const execAsync = promisify(exec);
8
8
  import path from "path";
9
+ import { Colors } from "../../colors.js";
9
10
  export const usePothosBuilder = Context.memo(() => {
10
11
  let routes = [];
11
12
  const bus = useBus();
@@ -16,12 +17,16 @@ export const usePothosBuilder = Context.memo(() => {
16
17
  });
17
18
  await fs.writeFile(route.output, schema);
18
19
  // bus.publish("pothos.extracted", { file: route.output });
19
- await Promise.all(route.commands.map((cmd) => execAsync(cmd)));
20
- console.log("Done building pothos schema");
20
+ if (Array.isArray(route.commands) && route.commands.length > 0) {
21
+ await Promise.all(route.commands.map((cmd) => execAsync(cmd)));
22
+ }
23
+ Colors.line(Colors.success(`✔`), " Pothos: Extracted pothos schema");
21
24
  }
22
25
  catch (ex) {
23
- console.error("Failed to extract schema from pothos");
24
- console.error(ex);
26
+ Colors.line(Colors.danger(`✖`), " Pothos: Failed to extract schema:");
27
+ for (let line of ex.message.split("\n")) {
28
+ console.log(` `, line);
29
+ }
25
30
  }
26
31
  }
27
32
  bus.subscribe("file.changed", async (evt) => {
@@ -6,6 +6,10 @@ export declare const remove: (program: Program) => import("yargs").Argv<{
6
6
  profile: string | undefined;
7
7
  } & {
8
8
  region: string | undefined;
9
+ } & {
10
+ verbose: boolean | undefined;
11
+ } & {
12
+ role: string | undefined;
9
13
  } & {
10
14
  from: string | undefined;
11
15
  } & {
@@ -1,39 +1,47 @@
1
- import { printDeploymentResults } from "../ui/deploy.js";
2
- export const remove = (program) => program.command("remove [filter]", "Remove all stacks for this app", (yargs) => yargs
3
- .option("from", { type: "string" })
4
- .positional("filter", { type: "string" }), async (args) => {
1
+ export const remove = (program) => program.command("remove [filter]", "Remove your app from AWS", (yargs) => yargs.option("from", { type: "string" }).positional("filter", {
2
+ type: "string",
3
+ describe: "Optionally filter stacks to remove",
4
+ }), async (args) => {
5
5
  const React = await import("react");
6
- const { CloudAssembly } = await import("aws-cdk-lib/cx-api");
7
- const { blue, bold } = await import("colorette");
8
- const { useProject } = await import("../../app.js");
9
- const { Stacks } = await import("../../stacks/index.js");
6
+ const { dim, blue, bold } = await import("colorette");
7
+ const { useProject } = await import("../../project.js");
8
+ const { loadAssembly, clearAppMetadata, Stacks } = await import("../../stacks/index.js");
10
9
  const { render } = await import("ink");
11
10
  const { DeploymentUI } = await import("../ui/deploy.js");
11
+ const { printDeploymentResults } = await import("../ui/deploy.js");
12
+ const { Colors } = await import("../colors.js");
13
+ const { useSTSIdentity } = await import("../../credentials.js");
14
+ const project = useProject();
15
+ const identity = await useSTSIdentity();
16
+ Colors.line(`${Colors.primary.bold(`SST v${project.version}`)}`);
17
+ Colors.gap();
18
+ Colors.line(`${Colors.primary(`➜`)} ${Colors.bold("App:")} ${project.config.name}`);
19
+ Colors.line(` ${Colors.bold("Stage:")} ${project.config.stage}`);
20
+ Colors.line(` ${Colors.bold("Region:")} ${project.config.region}`);
21
+ Colors.line(` ${Colors.bold("Account:")} ${identity.Account}`);
12
22
  const assembly = await (async function () {
13
23
  if (args.from) {
14
- const result = new CloudAssembly(args.from);
24
+ const result = await loadAssembly(args.from);
15
25
  return result;
16
26
  }
17
- const fn = await Stacks.build();
18
27
  return await Stacks.synth({
19
- fn,
28
+ fn: project.stacks,
20
29
  mode: "remove",
21
30
  });
22
31
  })();
23
- const project = useProject();
24
32
  const target = assembly.stacks.filter((s) => !args.filter ||
25
33
  s.stackName.toLowerCase().includes(args.filter.toLowerCase()));
26
34
  if (!target.length) {
27
35
  console.log(`No stacks found matching ${blue(args.filter)}`);
28
36
  process.exit(1);
29
- return;
30
37
  }
31
- console.log(`Removing ${bold(target.length + " stacks")} for stage ${blue(project.stage)}...`);
32
- process.stdout.write("\x1b[?1049h");
33
- const component = render(React.createElement(DeploymentUI, { stacks: target.map((s) => s.stackName) }));
38
+ const component = render(React.createElement(DeploymentUI, { assembly: assembly }));
34
39
  const results = await Stacks.removeMany(target);
40
+ component.clear();
35
41
  component.unmount();
36
- process.stdout.write("\x1b[?1049l");
37
- printDeploymentResults(results);
42
+ printDeploymentResults(assembly, results, true);
43
+ if (Object.values(results).some((stack) => Stacks.isFailed(stack.status)))
44
+ process.exit(1);
45
+ await clearAppMetadata();
38
46
  process.exit(0);
39
47
  });
@@ -1,13 +1,17 @@
1
1
  /// <reference types="yargs" />
2
2
  import { Program } from "../../program.js";
3
- export declare const get: (program: Program) => import("yargs").Argv<import("yargs").Omit<{
3
+ export declare const get: (program: Program) => import("yargs").Argv<{
4
4
  stage: string | undefined;
5
5
  } & {
6
6
  profile: string | undefined;
7
7
  } & {
8
8
  region: string | undefined;
9
+ } & {
10
+ verbose: boolean | undefined;
11
+ } & {
12
+ role: string | undefined;
9
13
  } & {
10
14
  name: string;
11
- }, "name"> & {
12
- name: string;
15
+ } & {
16
+ fallback: boolean | undefined;
13
17
  }>;
@@ -1,37 +1,24 @@
1
- import { red } from "colorette";
2
- export const get = (program) => program
3
- .command("get <name>", "Get secret value", (yargs) => yargs.positional("name", {
1
+ export const get = (program) => program.command("get <name>", "Get the value of a secret", (yargs) => yargs
2
+ .positional("name", {
4
3
  type: "string",
5
- describe: "Name of secret",
4
+ describe: "Name of the secret",
6
5
  demandOption: true,
7
- }), async (args) => {
8
- const { Config } = await import("../../../config.js");
9
- const { bold } = await import("colorette");
10
- try {
11
- const result = await Config.getSecret({
12
- key: args.name,
13
- });
14
- console.log(bold(result));
15
- }
16
- catch {
17
- console.log(red(`${bold(args.name)} is not set`));
18
- }
19
6
  })
20
- .command("get-fallback <name>", "Get secret value", (yargs) => yargs.positional("name", {
21
- type: "string",
22
- describe: "Name of secret",
23
- demandOption: true,
7
+ .option("fallback", {
8
+ type: "boolean",
9
+ describe: "Get the fallback value",
24
10
  }), async (args) => {
11
+ const { red } = await import("colorette");
25
12
  const { Config } = await import("../../../config.js");
26
- const { bold } = await import("colorette");
13
+ const { Colors } = await import("../../colors.js");
27
14
  try {
28
15
  const result = await Config.getSecret({
29
16
  key: args.name,
30
- fallback: true,
17
+ fallback: args.fallback === true,
31
18
  });
32
- console.log(bold(result));
19
+ console.log(result);
33
20
  }
34
21
  catch {
35
- console.log(red(`${bold(args.name)} is not set`));
22
+ Colors.line(Colors.danger(`✖ `), `"${args.name}" is not set`);
36
23
  }
37
24
  });
@@ -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 list: (program: Program) => import("yargs").Argv<{
4
4
  stage: string | undefined;
5
5
  } & {
@@ -7,5 +7,9 @@ export declare const list: (program: Program) => import("yargs").Argv<{
7
7
  } & {
8
8
  region: string | undefined;
9
9
  } & {
10
- format: string;
10
+ verbose: boolean | undefined;
11
+ } & {
12
+ role: string | undefined;
13
+ } & {
14
+ format: string | undefined;
11
15
  }>;
@@ -1,8 +1,16 @@
1
- import { Config } from "../../../config.js";
2
- import { gray } from "colorette";
3
- export const list = (program) => program.command("list [format]", "Fetch and decrypt all secrets", yargs => yargs.positional("format", { type: "string", default: "table" }), async (args) => {
1
+ export const list = (program) => program.command("list [format]", "Fetch all the secrets", (yargs) => yargs.positional("format", {
2
+ type: "string",
3
+ choices: ["table", "env"],
4
+ }), async (args) => {
5
+ const { Config } = await import("../../../config.js");
6
+ const { gray } = await import("colorette");
7
+ const { Colors } = await import("../../colors.js");
4
8
  const secrets = await Config.secrets();
5
- switch (args.format) {
9
+ if (Object.entries(secrets).length === 0) {
10
+ Colors.line("No secrets set");
11
+ return;
12
+ }
13
+ switch (args.format || "table") {
6
14
  case "env":
7
15
  for (const [key, value] of Object.entries(secrets)) {
8
16
  console.log(`${key}=${value.value || value.fallback}`);
@@ -10,8 +18,8 @@ export const list = (program) => program.command("list [format]", "Fetch and dec
10
18
  break;
11
19
  case "table":
12
20
  const keys = Object.keys(secrets);
13
- const keyLen = Math.max("Secrets".length, ...keys.map(key => key.length));
14
- const valueLen = Math.max("Values".length, ...keys.map(key => secrets[key].value
21
+ const keyLen = Math.max("Secrets".length, ...keys.map((key) => key.length));
22
+ const valueLen = Math.max("Values".length, ...keys.map((key) => secrets[key].value
15
23
  ? secrets[key].value.length
16
24
  : `${secrets[key].fallback} (fallback)`.length));
17
25
  console.log("┌".padEnd(keyLen + 3, "─") +
@@ -23,7 +31,7 @@ export const list = (program) => program.command("list [format]", "Fetch and dec
23
31
  "┼" +
24
32
  "".padEnd(valueLen + 2, "─") +
25
33
  "┤");
26
- keys.sort().forEach(key => {
34
+ keys.sort().forEach((key) => {
27
35
  const value = secrets[key].value
28
36
  ? secrets[key].value
29
37
  : `${secrets[key].fallback} ${gray("(fallback)")}`;
@@ -1,13 +1,17 @@
1
1
  /// <reference types="yargs" />
2
- import { Program } from "../../program.js";
3
- export declare const remove: (program: Program) => import("yargs").Argv<import("yargs").Omit<{
2
+ import type { Program } from "../../program.js";
3
+ export declare const remove: (program: Program) => import("yargs").Argv<{
4
4
  stage: string | undefined;
5
5
  } & {
6
6
  profile: string | undefined;
7
7
  } & {
8
8
  region: string | undefined;
9
+ } & {
10
+ verbose: boolean | undefined;
11
+ } & {
12
+ role: string | undefined;
9
13
  } & {
10
14
  name: string;
11
- }, "name"> & {
12
- name: string;
15
+ } & {
16
+ fallback: boolean | undefined;
13
17
  }>;
@@ -1,21 +1,23 @@
1
- import { Config } from "../../../config.js";
2
- export const remove = (program) => program
3
- .command("remove <name>", "Remove secret", (yargs) => yargs.positional("name", {
4
- describe: "Name of secret to remove",
1
+ export const remove = (program) => program.command("remove <name>", "Remove a secret", (yargs) => yargs
2
+ .positional("name", {
3
+ describe: "Name of the secret",
5
4
  type: "string",
6
5
  demandOption: true,
7
- }), async (args) => {
8
- await Config.removeSecret({
9
- key: args.name,
10
- });
11
6
  })
12
- .command("remove-fallback <name>", "Remove secret", (yargs) => yargs.positional("name", {
13
- describe: "Name of secret to remove",
14
- type: "string",
15
- demandOption: true,
7
+ .option("fallback", {
8
+ type: "boolean",
9
+ describe: "Remove the fallback value",
16
10
  }), async (args) => {
17
- await Config.removeSecret({
18
- key: args.name,
19
- fallback: true,
20
- });
11
+ const { Config } = await import("../../../config.js");
12
+ const { Colors } = await import("../../colors.js");
13
+ try {
14
+ await Config.removeSecret({
15
+ key: args.name,
16
+ fallback: args.fallback === true,
17
+ });
18
+ Colors.line(Colors.success(`✔ `), `Removed "${args.name}"`);
19
+ }
20
+ catch {
21
+ Colors.line(Colors.danger(`✖ `), `"${args.name}" is not set`);
22
+ }
21
23
  });
@@ -3,12 +3,12 @@ import { list } from "./list.js";
3
3
  import { remove } from "./remove.js";
4
4
  import { set } from "./set.js";
5
5
  export function secrets(program) {
6
- program.command("secrets", "Manage secrets", (yargs) => {
6
+ program.command("secrets", "Manage the secrets in your app", (yargs) => {
7
7
  yargs.demandCommand(1);
8
- remove(yargs);
8
+ set(yargs);
9
9
  get(yargs);
10
10
  list(yargs);
11
- set(yargs);
11
+ remove(yargs);
12
12
  return yargs;
13
13
  });
14
14
  }
@@ -1,17 +1,19 @@
1
1
  /// <reference types="yargs" />
2
- import { Program } from "../../program.js";
3
- export declare const set: (program: Program) => import("yargs").Argv<import("yargs").Omit<import("yargs").Omit<{
2
+ import type { Program } from "../../program.js";
3
+ export declare const set: (program: Program) => import("yargs").Argv<{
4
4
  stage: string | undefined;
5
5
  } & {
6
6
  profile: string | undefined;
7
7
  } & {
8
8
  region: string | undefined;
9
9
  } & {
10
- name: string;
10
+ verbose: boolean | undefined;
11
+ } & {
12
+ role: string | undefined;
11
13
  } & {
12
- value: string;
13
- }, "name"> & {
14
14
  name: string;
15
- }, "value"> & {
15
+ } & {
16
16
  value: string;
17
+ } & {
18
+ fallback: boolean | undefined;
17
19
  }>;
@@ -1,46 +1,29 @@
1
- import { Config } from "../../../config.js";
2
- import { blue } from "colorette";
3
- import { createSpinner } from "../../spinner.js";
4
- export const set = (program) => program
5
- .command("set <name> <value>", "Set secret value", yargs => yargs
1
+ export const set = (program) => program.command("set <name> <value>", "Set the value of a secret", (yargs) => yargs
6
2
  .positional("name", {
7
3
  type: "string",
8
- describe: "Name of secret",
9
- demandOption: true
4
+ describe: "Name of the secret",
5
+ demandOption: true,
10
6
  })
11
7
  .positional("value", {
12
8
  type: "string",
13
- describe: "Value to set",
14
- demandOption: true
15
- }), async (args) => {
16
- const setting = createSpinner(`Setting secret ${blue(args.name)}`).start();
17
- await Config.setSecret({
18
- key: args.name,
19
- value: args.value
20
- });
21
- setting.succeed();
22
- const restarting = createSpinner(`Restarting all functions using ${blue(args.name)}...`).start();
23
- const count = await Config.restart(args.name);
24
- restarting.succeed(`Restarted ${blue(count)} functions`);
9
+ describe: "Value of the secret",
10
+ demandOption: true,
25
11
  })
26
- .command("set-fallback <name> <value>", "Set a fallback value for secret", yargs => yargs
27
- .positional("name", {
28
- type: "string",
29
- describe: "Name of secret",
30
- demandOption: true
31
- })
32
- .positional("value", {
33
- type: "string",
34
- describe: "Value to set",
35
- demandOption: true
12
+ .option("fallback", {
13
+ type: "boolean",
14
+ describe: "Set the fallback value",
36
15
  }), async (args) => {
37
- console.log("Setting", `${blue(args.name)}...`);
16
+ const { Config } = await import("../../../config.js");
17
+ const { blue } = await import("colorette");
18
+ const { createSpinner } = await import("../../spinner.js");
19
+ const setting = createSpinner(` Setting "${args.name}"`).start();
38
20
  await Config.setSecret({
39
21
  key: args.name,
40
22
  value: args.value,
41
- fallback: true
23
+ fallback: args.fallback === true,
42
24
  });
43
- console.log("Restarting all functions using", `${blue(args.name)}...`);
25
+ setting.succeed();
26
+ const restarting = createSpinner(` Restarting all functions using ${blue(args.name)}...`).start();
44
27
  const count = await Config.restart(args.name);
45
- console.log("✅ Restarted", `${blue(count)}`, "functions");
28
+ restarting.succeed(` Restarted ${count} functions`);
46
29
  });
@@ -0,0 +1,15 @@
1
+ /// <reference types="yargs" />
2
+ import type { Program } from "../program.js";
3
+ export declare const telemetry: (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
+ } & {
14
+ action: string;
15
+ }>;
@@ -0,0 +1,17 @@
1
+ import { Colors } from "../colors.js";
2
+ export const telemetry = (program) => program.command("telemetry <action>", "Load environment variables and start your frontend", (yargs) => yargs.positional("action", {
3
+ type: "string",
4
+ describe: "Whether to enable or disable",
5
+ choices: ["enable", "disable"],
6
+ demandOption: true,
7
+ }), async (args) => {
8
+ const { enable, disable } = await import("../telemetry/telemetry.js");
9
+ if (args.action === "enable") {
10
+ enable();
11
+ Colors.line(Colors.success(`✔ `), `Telemetry enabled`);
12
+ }
13
+ if (args.action === "disable") {
14
+ disable();
15
+ Colors.line(Colors.success(`✔ `), `Telemetry disabled`);
16
+ }
17
+ });
@@ -0,0 +1,15 @@
1
+ /// <reference types="yargs" />
2
+ import type { Program } from "../program.js";
3
+ export declare const transform: (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
+ } & {
14
+ mod: string;
15
+ }>;