sst 2.0.0-rc.44 → 2.0.0-rc.45

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.
@@ -44,7 +44,7 @@ export const deploy = (program) => program.command("deploy [filter]", "Deploy yo
44
44
  Colors.line(`No stacks found matching ${blue(args.filter)}`);
45
45
  process.exit(1);
46
46
  }
47
- const component = render(React.createElement(DeploymentUI, { stacks: assembly.stacks.map((s) => s.stackName) }));
47
+ const component = render(React.createElement(DeploymentUI, { assembly: assembly }));
48
48
  const results = await Stacks.deployMany(assembly.stacks);
49
49
  component.clear();
50
50
  component.unmount();
@@ -160,7 +160,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
160
160
  pending = undefined;
161
161
  if (lastDeployed)
162
162
  console.log();
163
- const component = render(React.createElement(DeploymentUI, { stacks: assembly.stacks.map((s) => s.stackName) }));
163
+ const component = render(React.createElement(DeploymentUI, { assembly: assembly }));
164
164
  const results = await Stacks.deployMany(assembly.stacks);
165
165
  component.clear();
166
166
  component.unmount();
@@ -32,7 +32,7 @@ export const remove = (program) => program.command("remove [filter]", "Remove yo
32
32
  console.log(`No stacks found matching ${blue(args.filter)}`);
33
33
  process.exit(1);
34
34
  }
35
- const component = render(React.createElement(DeploymentUI, { stacks: assembly.stacks.map((s) => s.stackName) }));
35
+ const component = render(React.createElement(DeploymentUI, { assembly: assembly }));
36
36
  const results = await Stacks.removeMany(target);
37
37
  component.clear();
38
38
  component.unmount();
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" resolution-mode="require"/>
2
2
  import { Stacks } from "../../stacks/index.js";
3
- import { CloudAssembly } from "aws-cdk-lib/cx-api";
3
+ import type { CloudAssembly } from "aws-cdk-lib/cx-api";
4
4
  interface Props {
5
- stacks: string[];
5
+ assembly: CloudAssembly;
6
6
  }
7
7
  export declare const DeploymentUI: (props: Props) => JSX.Element;
8
8
  export declare function printDeploymentResults(assembly: CloudAssembly, results: Awaited<ReturnType<typeof Stacks.deployMany>>): void;
package/cli/ui/deploy.js CHANGED
@@ -19,7 +19,8 @@ export const DeploymentUI = (props) => {
19
19
  return;
20
20
  setResources((previous) => {
21
21
  if (Stacks.isFinal(event.ResourceStatus)) {
22
- Colors.line(Colors.warning(Colors.prefix), Colors.dim(`${event.StackName} ${event.ResourceType} ${event.LogicalResourceId}`), Stacks.isFailed(event.ResourceStatus)
22
+ const readable = Stacks.logicalIdToCdkPath(props.assembly, event.StackName, event.LogicalResourceId);
23
+ Colors.line(Colors.warning(Colors.prefix), Colors.dim(`${event.StackName} ${readable} ${event.ResourceType}`), Stacks.isFailed(event.ResourceStatus)
23
24
  ? Colors.danger(event.ResourceStatus)
24
25
  : Colors.dim(event.ResourceStatus));
25
26
  const { [event.LogicalResourceId]: _, ...next } = previous;
@@ -44,15 +45,16 @@ export const DeploymentUI = (props) => {
44
45
  }
45
46
  return (React.createElement(Box, { flexDirection: "column" },
46
47
  Object.entries(resources).map(([_, evt]) => {
48
+ const readable = Stacks.logicalIdToCdkPath(props.assembly, evt.StackName, evt.LogicalResourceId);
47
49
  return (React.createElement(Box, { key: evt.LogicalResourceId },
48
50
  React.createElement(Text, null,
49
51
  React.createElement(Spinner, null),
50
52
  " ",
51
53
  evt.StackName,
52
54
  " ",
53
- evt.ResourceType,
55
+ readable,
54
56
  " ",
55
- evt.LogicalResourceId,
57
+ evt.ResourceType,
56
58
  " "),
57
59
  React.createElement(Text, { color: color(evt.ResourceStatus || "") }, evt.ResourceStatus)));
58
60
  }),
@@ -62,44 +64,42 @@ export const DeploymentUI = (props) => {
62
64
  " ")))));
63
65
  };
64
66
  export function printDeploymentResults(assembly, results) {
65
- Colors.gap();
66
- Colors.line(Colors.success(`✔`), Colors.bold(` Deployed`));
67
- for (const [stack, result] of Object.entries(results)) {
68
- if (Object.values(result.errors).length)
69
- continue;
70
- const outputs = Object.entries(result.outputs).filter(([key, _]) => {
71
- if (key.startsWith("Export"))
72
- return false;
73
- if (key.includes("SstSiteEnv"))
74
- return false;
75
- if (key === "SSTMetadata")
76
- return false;
77
- return true;
78
- });
79
- Colors.line(` ${Colors.dim(stack)}`);
80
- if (outputs.length > 0) {
81
- for (const key of Object.keys(Object.fromEntries(outputs)).sort()) {
82
- const value = result.outputs[key];
83
- Colors.line(` ${Colors.bold.dim(key)}: ${value}`);
67
+ // Print success stacks
68
+ const success = Object.entries(results)
69
+ .filter(([_stack, result]) => Object.keys(result.errors).length === 0);
70
+ if (success.length) {
71
+ Colors.gap();
72
+ Colors.line(Colors.success(`✔`), Colors.bold(` Deployed`));
73
+ for (const [stack, result] of success) {
74
+ const outputs = Object.entries(result.outputs).filter(([key, _]) => {
75
+ if (key.startsWith("Export"))
76
+ return false;
77
+ if (key.includes("SstSiteEnv"))
78
+ return false;
79
+ if (key === "SSTMetadata")
80
+ return false;
81
+ return true;
82
+ });
83
+ Colors.line(` ${Colors.dim(stack)}`);
84
+ if (outputs.length > 0) {
85
+ for (const key of Object.keys(Object.fromEntries(outputs)).sort()) {
86
+ const value = result.outputs[key];
87
+ Colors.line(` ${Colors.bold.dim(key + ":")} ${value}`);
88
+ }
84
89
  }
85
90
  }
86
91
  }
87
- Colors.gap();
88
- if (Object.values(results).flatMap((s) => Object.keys(s.errors)).length) {
92
+ // Print failed stacks
93
+ const failed = Object.entries(results)
94
+ .filter(([_stack, result]) => Object.keys(result.errors).length > 0);
95
+ if (failed.length) {
96
+ Colors.gap();
89
97
  Colors.line(`${Colors.danger(`✖`)} ${Colors.bold.dim(`Errors`)}`);
90
- for (const [stack, result] of Object.entries(results)) {
91
- const hasErrors = Object.entries(result.errors).length > 0;
92
- if (!hasErrors)
93
- continue;
98
+ for (const [stack, result] of failed) {
94
99
  Colors.line(` ${Colors.dim(stack)}`);
95
100
  for (const [id, error] of Object.entries(result.errors)) {
96
- const found = Object.entries(assembly.manifest.artifacts?.[stack].metadata || {}).find(([_key, value]) => value[0]?.type === "aws:cdk:logicalId" && value[0]?.data === id)?.[0] || "";
97
- const readable = found
98
- .split("/")
99
- .filter(Boolean)
100
- .slice(1, -1)
101
- .join("/");
102
- Colors.line(` ${Colors.danger.bold(readable)}: ${error}`);
101
+ const readable = Stacks.logicalIdToCdkPath(assembly, stack, id);
102
+ Colors.line(` ${Colors.danger.bold(readable + ":")} ${error}`);
103
103
  }
104
104
  }
105
105
  Colors.gap();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.0-rc.44",
3
+ "version": "2.0.0-rc.45",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
package/sst.mjs CHANGED
@@ -1101,6 +1101,17 @@ async function loadAssembly(from) {
1101
1101
  const { CloudAssembly } = await import("aws-cdk-lib/cx-api");
1102
1102
  return new CloudAssembly(from);
1103
1103
  }
1104
+ function logicalIdToCdkPath(assembly, stack, logicalId) {
1105
+ const found = Object.entries(
1106
+ assembly.manifest.artifacts?.[stack].metadata || {}
1107
+ ).find(
1108
+ ([_key, value]) => value[0]?.type === "aws:cdk:logicalId" && value[0]?.data === logicalId
1109
+ )?.[0];
1110
+ if (!found) {
1111
+ return logicalId;
1112
+ }
1113
+ return found.split("/").filter(Boolean).slice(1, -1).join("/");
1114
+ }
1104
1115
  var init_assembly = __esm({
1105
1116
  "src/stacks/assembly.ts"() {
1106
1117
  "use strict";
@@ -3993,6 +4004,7 @@ __export(stacks_exports, {
3993
4004
  isSuccess: () => isSuccess,
3994
4005
  load: () => load,
3995
4006
  loadAssembly: () => loadAssembly,
4007
+ logicalIdToCdkPath: () => logicalIdToCdkPath,
3996
4008
  metadata: () => metadata,
3997
4009
  metadataForStack: () => metadataForStack,
3998
4010
  monitor: () => monitor,
@@ -5122,44 +5134,38 @@ import React, { useState, useEffect } from "react";
5122
5134
  import { Box, Text } from "ink";
5123
5135
  import inkSpinner from "ink-spinner";
5124
5136
  function printDeploymentResults(assembly, results) {
5125
- Colors.gap();
5126
- Colors.line(Colors.success(`\u2714`), Colors.bold(` Deployed`));
5127
- for (const [stack, result] of Object.entries(results)) {
5128
- if (Object.values(result.errors).length)
5129
- continue;
5130
- const outputs = Object.entries(result.outputs).filter(([key, _]) => {
5131
- if (key.startsWith("Export"))
5132
- return false;
5133
- if (key.includes("SstSiteEnv"))
5134
- return false;
5135
- if (key === "SSTMetadata")
5136
- return false;
5137
- return true;
5138
- });
5139
- Colors.line(` ${Colors.dim(stack)}`);
5140
- if (outputs.length > 0) {
5141
- for (const key of Object.keys(Object.fromEntries(outputs)).sort()) {
5142
- const value = result.outputs[key];
5143
- Colors.line(` ${Colors.bold.dim(key)}: ${value}`);
5137
+ const success = Object.entries(results).filter(([_stack, result]) => Object.keys(result.errors).length === 0);
5138
+ if (success.length) {
5139
+ Colors.gap();
5140
+ Colors.line(Colors.success(`\u2714`), Colors.bold(` Deployed`));
5141
+ for (const [stack, result] of success) {
5142
+ const outputs = Object.entries(result.outputs).filter(([key, _]) => {
5143
+ if (key.startsWith("Export"))
5144
+ return false;
5145
+ if (key.includes("SstSiteEnv"))
5146
+ return false;
5147
+ if (key === "SSTMetadata")
5148
+ return false;
5149
+ return true;
5150
+ });
5151
+ Colors.line(` ${Colors.dim(stack)}`);
5152
+ if (outputs.length > 0) {
5153
+ for (const key of Object.keys(Object.fromEntries(outputs)).sort()) {
5154
+ const value = result.outputs[key];
5155
+ Colors.line(` ${Colors.bold.dim(key + ":")} ${value}`);
5156
+ }
5144
5157
  }
5145
5158
  }
5146
5159
  }
5147
- Colors.gap();
5148
- if (Object.values(results).flatMap((s) => Object.keys(s.errors)).length) {
5160
+ const failed = Object.entries(results).filter(([_stack, result]) => Object.keys(result.errors).length > 0);
5161
+ if (failed.length) {
5162
+ Colors.gap();
5149
5163
  Colors.line(`${Colors.danger(`\u2716`)} ${Colors.bold.dim(`Errors`)}`);
5150
- for (const [stack, result] of Object.entries(results)) {
5151
- const hasErrors = Object.entries(result.errors).length > 0;
5152
- if (!hasErrors)
5153
- continue;
5164
+ for (const [stack, result] of failed) {
5154
5165
  Colors.line(` ${Colors.dim(stack)}`);
5155
5166
  for (const [id, error2] of Object.entries(result.errors)) {
5156
- const found = Object.entries(
5157
- assembly.manifest.artifacts?.[stack].metadata || {}
5158
- ).find(
5159
- ([_key, value]) => value[0]?.type === "aws:cdk:logicalId" && value[0]?.data === id
5160
- )?.[0] || "";
5161
- const readable = found.split("/").filter(Boolean).slice(1, -1).join("/");
5162
- Colors.line(` ${Colors.danger.bold(readable)}: ${error2}`);
5167
+ const readable = stacks_exports.logicalIdToCdkPath(assembly, stack, id);
5168
+ Colors.line(` ${Colors.danger.bold(readable + ":")} ${error2}`);
5163
5169
  }
5164
5170
  }
5165
5171
  Colors.gap();
@@ -5186,11 +5192,10 @@ var init_deploy2 = __esm({
5186
5192
  return;
5187
5193
  setResources((previous2) => {
5188
5194
  if (stacks_exports.isFinal(event2.ResourceStatus)) {
5195
+ const readable = stacks_exports.logicalIdToCdkPath(props.assembly, event2.StackName, event2.LogicalResourceId);
5189
5196
  Colors.line(
5190
5197
  Colors.warning(Colors.prefix),
5191
- Colors.dim(
5192
- `${event2.StackName} ${event2.ResourceType} ${event2.LogicalResourceId}`
5193
- ),
5198
+ Colors.dim(`${event2.StackName} ${readable} ${event2.ResourceType}`),
5194
5199
  stacks_exports.isFailed(event2.ResourceStatus) ? Colors.danger(event2.ResourceStatus) : Colors.dim(event2.ResourceStatus)
5195
5200
  );
5196
5201
  const { [event2.LogicalResourceId]: _, ...next } = previous2;
@@ -5214,7 +5219,8 @@ var init_deploy2 = __esm({
5214
5219
  return "yellow";
5215
5220
  }
5216
5221
  return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, Object.entries(resources).map(([_, evt]) => {
5217
- return /* @__PURE__ */ React.createElement(Box, { key: evt.LogicalResourceId }, /* @__PURE__ */ React.createElement(Text, null, /* @__PURE__ */ React.createElement(Spinner, null), " ", evt.StackName, " ", evt.ResourceType, " ", evt.LogicalResourceId, " "), /* @__PURE__ */ React.createElement(Text, { color: color(evt.ResourceStatus || "") }, evt.ResourceStatus));
5222
+ const readable = stacks_exports.logicalIdToCdkPath(props.assembly, evt.StackName, evt.LogicalResourceId);
5223
+ return /* @__PURE__ */ React.createElement(Box, { key: evt.LogicalResourceId }, /* @__PURE__ */ React.createElement(Text, null, /* @__PURE__ */ React.createElement(Spinner, null), " ", evt.StackName, " ", readable, " ", evt.ResourceType, " "), /* @__PURE__ */ React.createElement(Text, { color: color(evt.ResourceStatus || "") }, evt.ResourceStatus));
5218
5224
  }), Object.entries(resources).length === 0 && /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Text, null, /* @__PURE__ */ React.createElement(Spinner, null), " ")));
5219
5225
  };
5220
5226
  }
@@ -6118,7 +6124,7 @@ var dev = (program2) => program2.command(
6118
6124
  if (lastDeployed)
6119
6125
  console.log();
6120
6126
  const component = render(
6121
- /* @__PURE__ */ React2.createElement(DeploymentUI2, { stacks: assembly.stacks.map((s) => s.stackName) })
6127
+ /* @__PURE__ */ React2.createElement(DeploymentUI2, { assembly })
6122
6128
  );
6123
6129
  const results = await Stacks.deployMany(assembly.stacks);
6124
6130
  component.clear();
@@ -6301,7 +6307,7 @@ var deploy2 = (program2) => program2.command(
6301
6307
  process.exit(1);
6302
6308
  }
6303
6309
  const component = render(
6304
- /* @__PURE__ */ React2.createElement(DeploymentUI2, { stacks: assembly.stacks.map((s) => s.stackName) })
6310
+ /* @__PURE__ */ React2.createElement(DeploymentUI2, { assembly })
6305
6311
  );
6306
6312
  const results = await Stacks.deployMany(assembly.stacks);
6307
6313
  component.clear();
@@ -6358,7 +6364,7 @@ var remove2 = (program2) => program2.command(
6358
6364
  process.exit(1);
6359
6365
  }
6360
6366
  const component = render(
6361
- /* @__PURE__ */ React2.createElement(DeploymentUI2, { stacks: assembly.stacks.map((s) => s.stackName) })
6367
+ /* @__PURE__ */ React2.createElement(DeploymentUI2, { assembly })
6362
6368
  );
6363
6369
  const results = await Stacks.removeMany(target);
6364
6370
  component.clear();
@@ -1 +1,3 @@
1
- export declare function loadAssembly(from: string): Promise<import("aws-cdk-lib/cx-api").CloudAssembly>;
1
+ import type { CloudAssembly } from "aws-cdk-lib/cx-api";
2
+ export declare function loadAssembly(from: string): Promise<CloudAssembly>;
3
+ export declare function logicalIdToCdkPath(assembly: CloudAssembly, stack: string, logicalId: string): string;
@@ -2,3 +2,14 @@ export async function loadAssembly(from) {
2
2
  const { CloudAssembly } = await import("aws-cdk-lib/cx-api");
3
3
  return new CloudAssembly(from);
4
4
  }
5
+ export function logicalIdToCdkPath(assembly, stack, logicalId) {
6
+ const found = Object.entries(assembly.manifest.artifacts?.[stack].metadata || {}).find(([_key, value]) => value[0]?.type === "aws:cdk:logicalId" && value[0]?.data === logicalId)?.[0];
7
+ if (!found) {
8
+ return logicalId;
9
+ }
10
+ return found
11
+ .split("/")
12
+ .filter(Boolean)
13
+ .slice(1, -1)
14
+ .join("/");
15
+ }