Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
format errors
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Dec 22, 2023
1 parent 361d867 commit f918698
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ changelog:
exclude:
- '^docs:'
- '^test:'

16 changes: 8 additions & 8 deletions cmd/sst/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ func (u *UI) Trigger(evt *project.StackEvent) {
lines := strings.Split(evt.DiagnosticEvent.Message, "\n")
if len(lines) > 2 {
lines = strings.Split(lines[1], ":")
msg = strings.TrimRight(lines[len(lines)-1], "\n")
msg = strings.TrimSpace(lines[len(lines)-1])
}
u.errors = append(u.errors, errorStatus{
Error: msg,
Error: " " + msg,
URN: evt.DiagnosticEvent.URN,
})
u.printProgress(Progress{
Expand All @@ -269,9 +269,10 @@ func (u *UI) Trigger(evt *project.StackEvent) {
if trimmed == "" {
continue
}
if strings.HasPrefix(trimmed, "at") {
trimmed = " " + trimmed
if strings.HasPrefix(trimmed, "Running program") {
continue
}
trimmed = " " + trimmed
out = append(out, trimmed)
}
if len(out) > 1 {
Expand Down Expand Up @@ -328,14 +329,13 @@ func (u *UI) Finish() {
}

color.New(color.FgRed, color.Bold).Print("\n❌")
color.New(color.FgWhite, color.Bold).Println(" Failed:")
color.New(color.FgWhite, color.Bold).Println(" Failed")

for _, status := range u.errors {
color.New(color.FgHiBlack).Print(" ")
if status.URN != "" {
color.New(color.FgRed, color.Bold).Print(formatURN(status.URN) + ": ")
color.New(color.FgRed, color.Bold).Println(" " + formatURN(status.URN))
}
color.New(color.FgWhite).Println(strings.TrimSpace(status.Error))
color.New(color.FgWhite).Println(status.Error)
}
}

Expand Down
9 changes: 8 additions & 1 deletion examples/test/sst.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ export default $config({
};
},
async run() {
const item = new sst.Bucket("Item", {});
const item = new sst.Bucket("Item2", {
nodes: {
bucket: {
bucket: "foo",
},
},
});
// throw new Error("lol");

return {
bucket: item.nodes.bucket.bucket,
Expand Down
18 changes: 3 additions & 15 deletions internal/components/src/auto/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,11 @@ export async function run(program: PulumiFn) {
};
}
return undefined;
}
},
);
runtime.registerStackTransformation(
(args: util.ResourceTransformationArgs) => {
let normalizedName = args.name;

if (args.type === "pulumi:providers:aws") {
const parts = args.name.split(".");
if (
parts.length === 3 &&
parts[0] === "AwsProvider" &&
parts[1] === "sst"
) {
normalizedName = parts[0];
}
}

if (args.type === "pulumi-nodejs:dynamic:Resource") {
const parts = args.name.split(".");
if (parts.length === 3 && parts[1] === "sst") {
Expand All @@ -46,12 +34,12 @@ export async function run(program: PulumiFn) {

if (!normalizedName.match(/^[A-Z][a-zA-Z0-9]*$/)) {
throw new Error(
`Invalid component name "${normalizedName}". Component names must start with an uppercase letter and contain only alphanumeric characters.`
`Invalid component name "${normalizedName}". Component names must start with an uppercase letter and contain only alphanumeric characters.`,
);
}

return undefined;
}
},
);

const results = await program();
Expand Down

0 comments on commit f918698

Please sign in to comment.