Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Dec 19, 2023
1 parent c7c9e92 commit 8e22674
Show file tree
Hide file tree
Showing 18 changed files with 149 additions and 129 deletions.
14 changes: 10 additions & 4 deletions cmd/sst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"io"
"log/slog"
"os"
"os/signal"
Expand Down Expand Up @@ -31,13 +32,18 @@ func main() {
},
},
Before: func(c *cli.Context) error {
level := slog.LevelWarn
logFile, err := os.CreateTemp("", "sst-*.log")
if err != nil {
return err
}
writers := []io.Writer{logFile}
writer := io.MultiWriter(writers...)
if c.Bool("verbose") {
level = slog.LevelInfo
writers = append(writers, os.Stderr)
}
slog.SetDefault(
slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
Level: level,
slog.New(slog.NewTextHandler(writer, &slog.HandlerOptions{
Level: slog.LevelInfo,
})),
)

Expand Down
16 changes: 16 additions & 0 deletions internal/components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"devDependencies": {
"@tsconfig/node18": "^18.2.2",
"@types/archiver": "^6.0.2",
"prettier": "^3.1.1",
"typescript": "^5.3.2"
}
}
8 changes: 4 additions & 4 deletions internal/components/src/components/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Bucket extends Component {
constructor(
name: string,
args?: BucketArgs,
opts?: ComponentResourceOptions
opts?: ComponentResourceOptions,
) {
super("sst:sst:Bucket", name, args, opts);

Expand All @@ -36,14 +36,14 @@ export class Bucket extends Component {
`${name}Bucket`,
{
bucket: randomId.dec.apply((dec) =>
prefixName(name.toLowerCase(), `-${randomDecToSuffix(dec)}`)
prefixName(name.toLowerCase(), `-${randomDecToSuffix(dec)}`),
),
forceDestroy: true,
...args?.nodes?.bucket,
},
{
parent,
}
},
);

output(args?.blockPublicAccess).apply((blockPublicAccess) => {
Expand All @@ -58,7 +58,7 @@ export class Bucket extends Component {
ignorePublicAcls: true,
restrictPublicBuckets: true,
},
{ parent }
{ parent },
);
});

Expand Down
10 changes: 5 additions & 5 deletions internal/components/src/components/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export class Component extends ComponentResource {
type: string,
name: string,
args?: Inputs,
opts?: ComponentResourceOptions
opts?: ComponentResourceOptions,
) {
super(type, name, args, {
transformations: [
(args) => {
// Ensure "parent" is set
if (args.type !== type && !args.opts.parent) {
throw new Error(
`In "${name}" component, parent of "${args.name}" (${args.type}) is not set`
`In "${name}" component, parent of "${args.name}" (${args.type}) is not set`,
);
}

Expand All @@ -35,7 +35,7 @@ export class Component extends ComponentResource {
!args.name.startsWith(args.opts.parent!.__name)
) {
throw new Error(
`In "${name}" component, the name of "${args.name}" (${args.type}) is not prefixed with parent's name`
`In "${name}" component, the name of "${args.name}" (${args.type}) is not prefixed with parent's name`,
);
}

Expand All @@ -54,7 +54,7 @@ export class Component extends ComponentResource {
break;
case "aws:sqs/queue:Queue":
const suffix = output(args.props.fifoQueue).apply((fifo) =>
fifo ? ".fifo" : ""
fifo ? ".fifo" : "",
);
overrides = {
name: interpolate`${prefixName(args.name)}${suffix}`,
Expand All @@ -79,7 +79,7 @@ export class Component extends ComponentResource {
break;
default:
throw new Error(
`In "${name}" component, the physical name of "${args.name}" (${args.type}) is not prefixed`
`In "${name}" component, the physical name of "${args.name}" (${args.type}) is not prefixed`,
);
}
return {
Expand Down
14 changes: 7 additions & 7 deletions internal/components/src/components/distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class Distribution extends Component {
constructor(
name: string,
args: DistributionArgs,
opts?: ComponentResourceOptions
opts?: ComponentResourceOptions,
) {
super("sst:sst:Distribution", name, args, opts);
const parent = this;
Expand Down Expand Up @@ -149,14 +149,14 @@ export class Distribution extends Component {
.viewerCertificate
) {
throw new Error(
`Do not configure the "distribution.certificate". Use the "customDomain" to configure the domain certificate.`
`Do not configure the "distribution.certificate". Use the "customDomain" to configure the domain certificate.`,
);
}
if (
(args.nodes.distribution as aws.cloudfront.DistributionArgs).aliases
) {
throw new Error(
`Do not configure the "distribution.aliases". Use the "customDomain" to configure the domain name.`
`Do not configure the "distribution.aliases". Use the "customDomain" to configure the domain name.`,
);
}
}
Expand Down Expand Up @@ -185,7 +185,7 @@ export class Distribution extends Component {
alternativeNames: customDomain.aliases,
zoneId,
},
{ parent, provider: AWS.useProvider("us-east-1") }
{ parent, provider: AWS.useProvider("us-east-1") },
);
}

Expand All @@ -210,7 +210,7 @@ export class Distribution extends Component {
},
...args.nodes.distribution,
},
{ parent }
{ parent },
);
}

Expand Down Expand Up @@ -240,7 +240,7 @@ export class Distribution extends Component {
},
],
},
{ parent }
{ parent },
);
}
}
Expand All @@ -262,7 +262,7 @@ export class Distribution extends Component {
sourceDomains: customDomain.redirects,
targetDomain: customDomain.domainName,
},
{ parent }
{ parent },
);
});
}
Expand Down
10 changes: 5 additions & 5 deletions internal/components/src/components/dns-validated-certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class DnsValidatedCertificate extends Component {
constructor(
name: string,
args: DnsValidatedCertificateArgs,
opts?: ComponentResourceOptions
opts?: ComponentResourceOptions,
) {
super("sst:sst:Certificate", name, args, opts);

Expand All @@ -43,7 +43,7 @@ export class DnsValidatedCertificate extends Component {
validationMethod: "DNS",
subjectAlternativeNames: alternativeNames ?? [],
},
{ parent }
{ parent },
);

const records: aws.route53.Record[] = [];
Expand All @@ -59,8 +59,8 @@ export class DnsValidatedCertificate extends Component {
records: [option.resourceRecordValue],
ttl: 60,
},
{ parent }
)
{ parent },
),
);
});
});
Expand All @@ -71,7 +71,7 @@ export class DnsValidatedCertificate extends Component {
certificateArn: certificate.arn,
validationRecordFqdns: records.map((record) => record.fqdn),
},
{ parent }
{ parent },
);

this.certificateValidation = certificateValidation;
Expand Down
41 changes: 20 additions & 21 deletions internal/components/src/components/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class Function extends Component {
constructor(
name: string,
args: FunctionArgs,
opts?: ComponentResourceOptions
opts?: ComponentResourceOptions,
) {
super("sst:sst:Function", name, args, opts);

Expand Down Expand Up @@ -366,12 +366,12 @@ export class Function extends Component {
url.cors === false
? {}
: url.cors === true || url.cors === undefined
? defaultCors
: {
...defaultCors,
...url.cors,
maxAge: url.cors.maxAge && toSeconds(url.cors.maxAge),
};
? defaultCors
: {
...defaultCors,
...url.cors,
maxAge: url.cors.maxAge && toSeconds(url.cors.maxAge),
};

return { authorization, cors };
});
Expand All @@ -390,7 +390,7 @@ export class Function extends Component {

return output(args.bind).apply(async (component) => {
const outputs = Object.entries(component).filter(
([key]) => !key.startsWith("__")
([key]) => !key.startsWith("__"),
);
const keys = outputs.map(([key]) => key);
const values = outputs.map(([_, value]) => value);
Expand Down Expand Up @@ -442,13 +442,13 @@ export class Function extends Component {
` const { ${oldHandlerFunction}: rawHandler} = await import("./${oldHandlerName}.mjs");`,
` return rawHandler(event, context);`,
`};`,
].join("\n")
].join("\n"),
);
return path.posix.join(
handlerDir,
`${newHandlerName}.${newHandlerFunction}`
`${newHandlerName}.${newHandlerFunction}`,
);
}
},
);
}

Expand All @@ -464,7 +464,7 @@ export class Function extends Component {
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
],
},
{ parent }
{ parent },
);
}

Expand All @@ -478,7 +478,7 @@ export class Function extends Component {
$cli.paths.work,
"artifacts",
name,
"code.zip"
"code.zip",
);
await fs.promises.mkdir(path.dirname(zipPath), {
recursive: true,
Expand All @@ -501,7 +501,6 @@ export class Function extends Component {
archive.glob("**", { cwd: bundle, dot: true }, { date: new Date(0) });
await archive.finalize();
});
throw "stop";

return zipPath;
});
Expand All @@ -515,7 +514,7 @@ export class Function extends Component {
bucket: region.apply((region) => AWS.bootstrap.forRegion(region)),
source: zipPath.apply((zipPath) => new asset.FileArchive(zipPath)),
},
{ parent }
{ parent },
);
}

Expand All @@ -537,7 +536,7 @@ export class Function extends Component {
},
...args.nodes?.function,
},
{ parent }
{ parent },
);
}

Expand All @@ -547,11 +546,11 @@ export class Function extends Component {
{
logGroupName: interpolate`/aws/lambda/${fn.name}`,
retentionInDays: logging.apply(
(logging) => RETENTION[logging.retention]
(logging) => RETENTION[logging.retention],
),
region,
},
{ parent }
{ parent },
);
}

Expand All @@ -565,11 +564,11 @@ export class Function extends Component {
functionName: fn.name,
authorizationType: url.authorization.toUpperCase(),
invokeMode: streaming.apply((streaming) =>
streaming ? "RESPONSE_STREAM" : "BUFFERED"
streaming ? "RESPONSE_STREAM" : "BUFFERED",
),
cors: url.cors,
},
{ parent }
{ parent },
);
});
}
Expand All @@ -584,7 +583,7 @@ export class Function extends Component {
s3Key: file.key,
region,
},
{ parent }
{ parent },
);
return fnRaw;
});
Expand Down
Loading

0 comments on commit 8e22674

Please sign in to comment.