diff --git a/cmd/sst/main.go b/cmd/sst/main.go index 4b5c194cd..5c596e548 100644 --- a/cmd/sst/main.go +++ b/cmd/sst/main.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "io" "log/slog" "os" "os/signal" @@ -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, })), ) diff --git a/internal/components/package-lock.json b/internal/components/package-lock.json index bfab4090e..44f25f24b 100644 --- a/internal/components/package-lock.json +++ b/internal/components/package-lock.json @@ -26,6 +26,7 @@ "devDependencies": { "@tsconfig/node18": "^18.2.2", "@types/archiver": "^6.0.2", + "prettier": "^3.1.1", "typescript": "^5.3.2" } }, @@ -5245,6 +5246,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/prettier": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", + "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", diff --git a/internal/components/package.json b/internal/components/package.json index 75f73b19d..2fb6dbb8c 100644 --- a/internal/components/package.json +++ b/internal/components/package.json @@ -26,6 +26,7 @@ "devDependencies": { "@tsconfig/node18": "^18.2.2", "@types/archiver": "^6.0.2", + "prettier": "^3.1.1", "typescript": "^5.3.2" } } diff --git a/internal/components/src/components/bucket.ts b/internal/components/src/components/bucket.ts index fed18f63b..14bd400a9 100644 --- a/internal/components/src/components/bucket.ts +++ b/internal/components/src/components/bucket.ts @@ -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); @@ -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) => { @@ -58,7 +58,7 @@ export class Bucket extends Component { ignorePublicAcls: true, restrictPublicBuckets: true, }, - { parent } + { parent }, ); }); diff --git a/internal/components/src/components/component.ts b/internal/components/src/components/component.ts index 3576410d6..efda06fc7 100644 --- a/internal/components/src/components/component.ts +++ b/internal/components/src/components/component.ts @@ -16,7 +16,7 @@ export class Component extends ComponentResource { type: string, name: string, args?: Inputs, - opts?: ComponentResourceOptions + opts?: ComponentResourceOptions, ) { super(type, name, args, { transformations: [ @@ -24,7 +24,7 @@ export class Component extends ComponentResource { // 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`, ); } @@ -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`, ); } @@ -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}`, @@ -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 { diff --git a/internal/components/src/components/distribution.ts b/internal/components/src/components/distribution.ts index 691830226..67e4cae61 100644 --- a/internal/components/src/components/distribution.ts +++ b/internal/components/src/components/distribution.ts @@ -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; @@ -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.`, ); } } @@ -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") }, ); } @@ -210,7 +210,7 @@ export class Distribution extends Component { }, ...args.nodes.distribution, }, - { parent } + { parent }, ); } @@ -240,7 +240,7 @@ export class Distribution extends Component { }, ], }, - { parent } + { parent }, ); } } @@ -262,7 +262,7 @@ export class Distribution extends Component { sourceDomains: customDomain.redirects, targetDomain: customDomain.domainName, }, - { parent } + { parent }, ); }); } diff --git a/internal/components/src/components/dns-validated-certificate.ts b/internal/components/src/components/dns-validated-certificate.ts index eaa3745d5..de092f8c1 100644 --- a/internal/components/src/components/dns-validated-certificate.ts +++ b/internal/components/src/components/dns-validated-certificate.ts @@ -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); @@ -43,7 +43,7 @@ export class DnsValidatedCertificate extends Component { validationMethod: "DNS", subjectAlternativeNames: alternativeNames ?? [], }, - { parent } + { parent }, ); const records: aws.route53.Record[] = []; @@ -59,8 +59,8 @@ export class DnsValidatedCertificate extends Component { records: [option.resourceRecordValue], ttl: 60, }, - { parent } - ) + { parent }, + ), ); }); }); @@ -71,7 +71,7 @@ export class DnsValidatedCertificate extends Component { certificateArn: certificate.arn, validationRecordFqdns: records.map((record) => record.fqdn), }, - { parent } + { parent }, ); this.certificateValidation = certificateValidation; diff --git a/internal/components/src/components/function.ts b/internal/components/src/components/function.ts index a87408089..dc580865e 100644 --- a/internal/components/src/components/function.ts +++ b/internal/components/src/components/function.ts @@ -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); @@ -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 }; }); @@ -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); @@ -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}`, ); - } + }, ); } @@ -464,7 +464,7 @@ export class Function extends Component { "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", ], }, - { parent } + { parent }, ); } @@ -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, @@ -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; }); @@ -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 }, ); } @@ -537,7 +536,7 @@ export class Function extends Component { }, ...args.nodes?.function, }, - { parent } + { parent }, ); } @@ -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 }, ); } @@ -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 }, ); }); } @@ -584,7 +583,7 @@ export class Function extends Component { s3Key: file.key, region, }, - { parent } + { parent }, ); return fnRaw; }); diff --git a/internal/components/src/components/handler-function.ts b/internal/components/src/components/handler-function.ts index 44d0e9efa..785994617 100644 --- a/internal/components/src/components/handler-function.ts +++ b/internal/components/src/components/handler-function.ts @@ -12,7 +12,7 @@ export class HandlerFunction extends Function { constructor( name: string, args: HandlerFunctionArgs, - opts?: ComponentResourceOptions + opts?: ComponentResourceOptions, ) { const buildResult = output(args).apply((args) => build(name, args)); const successful = buildResult.apply((result) => { @@ -22,7 +22,7 @@ export class HandlerFunction extends Function { const hash = successful.apply(async (result) => { const content = await fs.readFile( path.join(result.out, result.handler), - "utf8" + "utf8", ); const hash = crypto.createHash("sha256"); hash.update(content); @@ -38,7 +38,7 @@ export class HandlerFunction extends Function { bundle: successful.out, bundleHash: hash, }, - opts + opts, ); } } diff --git a/internal/components/src/components/helpers/aws.ts b/internal/components/src/components/helpers/aws.ts index 20373e9dc..381d2055e 100644 --- a/internal/components/src/components/helpers/aws.ts +++ b/internal/components/src/components/helpers/aws.ts @@ -34,7 +34,7 @@ export const AWS = { .send( new GetParameterCommand({ Name: `/sst/bootstrap`, - }) + }), ) .catch((err) => { if (err instanceof ParameterNotFound) return; @@ -47,14 +47,14 @@ export const AWS = { await s3.send( new CreateBucketCommand({ Bucket: name, - }) + }), ); await ssm.send( new PutParameterCommand({ Name: `/sst/bootstrap`, Value: name, Type: "String", - }) + }), ); return name; })(); @@ -82,7 +82,7 @@ export const AWS = { }, useClient: ( client: new (config: any) => C, - region?: string + region?: string, ) => { const cache = useClientCache(); const existing = cache.get(client.name); diff --git a/internal/components/src/components/helpers/naming.ts b/internal/components/src/components/helpers/naming.ts index d4c442586..a1a6a88c4 100644 --- a/internal/components/src/components/helpers/naming.ts +++ b/internal/components/src/components/helpers/naming.ts @@ -20,7 +20,7 @@ export function prefixName(name: string, suffix?: string) { const stageTruncated = $app.stage.substring( 0, - Math.max(8, L - nameLen - 1) + Math.max(8, L - nameLen - 1), ); const nameTruncated = name.substring(0, L - stageTruncated.length - 1); return `${nameTruncated}-${stageTruncated}`; diff --git a/internal/components/src/components/https-redirect.ts b/internal/components/src/components/https-redirect.ts index 36c5c4772..6d2dbf1c0 100644 --- a/internal/components/src/components/https-redirect.ts +++ b/internal/components/src/components/https-redirect.ts @@ -44,7 +44,7 @@ export class HttpsRedirect extends Component { constructor( name: string, args: HttpsRedirectArgs, - opts?: ComponentResourceOptions + opts?: ComponentResourceOptions, ) { super("sst:sst:HttpsRedirect", name, args, opts); @@ -55,11 +55,11 @@ export class HttpsRedirect extends Component { { domainName: output(args.sourceDomains).apply((domains) => domains[0]), alternativeNames: output(args.sourceDomains).apply((domains) => - domains.slice(1) + domains.slice(1), ), zoneId: args.zoneId, }, - { parent } + { parent }, ); const bucket = new Bucket( @@ -67,7 +67,7 @@ export class HttpsRedirect extends Component { { blockPublicAccess: true, }, - { parent } + { parent }, ); const bucketWebsite = new aws.s3.BucketWebsiteConfigurationV2( @@ -79,7 +79,7 @@ export class HttpsRedirect extends Component { protocol: "https", }, }, - { parent } + { parent }, ); const distribution = new aws.cloudfront.Distribution( @@ -95,7 +95,7 @@ export class HttpsRedirect extends Component { }, comment: all([args.targetDomain, args.sourceDomains]).apply( ([targetDomain, sourceDomains]) => - `Redirect to ${targetDomain} from ${sourceDomains.join(", ")}` + `Redirect to ${targetDomain} from ${sourceDomains.join(", ")}`, ), priceClass: "PriceClass_All", viewerCertificate: { @@ -115,7 +115,7 @@ export class HttpsRedirect extends Component { }, ], }, - { parent } + { parent }, ); output(args.sourceDomains).apply((sourceDomains) => { @@ -135,7 +135,7 @@ export class HttpsRedirect extends Component { }, ], }, - { parent } + { parent }, ); } } diff --git a/internal/components/src/components/nextjs.ts b/internal/components/src/components/nextjs.ts index 0eb1b12c6..5fe86e8d3 100644 --- a/internal/components/src/components/nextjs.ts +++ b/internal/components/src/components/nextjs.ts @@ -139,7 +139,7 @@ export class Nextjs extends Component { constructor( name: string, args?: NextjsArgs, - opts?: ComponentResourceOptions + opts?: ComponentResourceOptions, ) { super("sst:sst:Nextjs", name, args, opts); @@ -199,7 +199,7 @@ export class Nextjs extends Component { outputPath, access, bucket, - plan + plan, ); const serverFunction = ssrFunctions[0] ?? Object.values(edgeFunctions)[0]; @@ -247,7 +247,7 @@ export class Nextjs extends Component { ...(experimental.disableIncrementalCache ? ["--dangerously-disable-incremental-cache"] : []), - ].join(" ") + ].join(" "), ); } @@ -349,7 +349,7 @@ export class Nextjs extends Component { bundle: path.join( outputPath, ".open-next", - "image-optimization-function" + "image-optimization-function", ), runtime: "nodejs18.x", architectures: ["arm64"], @@ -436,13 +436,13 @@ export class Nextjs extends Component { cacheType: "static", pattern: fs .statSync( - path.join(outputPath, ".open-next/assets", item) + path.join(outputPath, ".open-next/assets", item), ) .isDirectory() ? `${item}/*` : item, origin: "s3", - } as const) + }) as const, ), ], cachePolicyAllowedHeaders: DEFAULT_CACHE_POLICY_ALLOWED_HEADERS, @@ -453,7 +453,7 @@ export class Nextjs extends Component { function: path.join( outputPath, ".open-next", - "warmer-function" + "warmer-function", ), }, }); @@ -465,7 +465,7 @@ if (event.rawPath) { routes.map(({ regex, logGroupPath }) => ({ regex, logGroupPath, - })) + })), )}.find(({ regex }) => event.rawPath.match(new RegExp(regex))); if (routeData) { console.log("::sst::" + JSON.stringify({ @@ -477,8 +477,8 @@ if (event.rawPath) { } }`; } - } - ) + }, + ), ); } @@ -493,7 +493,7 @@ if (event.rawPath) { fifoQueue: true, receiveWaitTimeSeconds: 20, }, - { parent } + { parent }, ); const consumer = new Function( `${name}RevalidationConsumer`, @@ -501,7 +501,7 @@ if (event.rawPath) { description: "Next.js revalidator", handler: "index.handler", bundle: outputPath.apply((outputPath) => - path.join(outputPath, ".open-next", "revalidation-function") + path.join(outputPath, ".open-next", "revalidation-function"), ), runtime: "nodejs18.x", timeout: "30 seconds", @@ -524,12 +524,12 @@ if (event.rawPath) { }, ], }) - .then((doc) => doc.json) + .then((doc) => doc.json), ), }, ], }, - { parent } + { parent }, ); new aws.lambda.EventSourceMapping( `${name}RevalidationEventSource`, @@ -538,7 +538,7 @@ if (event.rawPath) { eventSourceArn: queue.arn, batchSize: 5, }, - { parent } + { parent }, ); return queue; }); @@ -636,7 +636,7 @@ if (event.rawPath) { }); for (const file of files) { fs.rmSync( - path.join(outputPath, ".open-next", "server-function", file) + path.join(outputPath, ".open-next", "server-function", file), ); } }); @@ -701,7 +701,7 @@ if (event.rawPath) { // "/favicon.ico/route": "/favicon.ico" // } const appPathRoute = Object.keys(appPathRoutesManifest).find( - (key) => appPathRoutesManifest[key] === page + (key) => appPathRoutesManifest[key] === page, ); if (!appPathRoute) return; @@ -722,7 +722,7 @@ if (event.rawPath) { outputPath, ".next", "server", - `${filePath}.map` + `${filePath}.map`, ); if (!fs.existsSync(sourcemapPath)) return; @@ -751,13 +751,13 @@ if (event.rawPath) { outputPath, ".next", "server", - `${filePath}.map` + `${filePath}.map`, ); if (!fs.existsSync(sourcemapPath)) return; return sourcemapPath; } - } + }, ); return _routes; @@ -776,7 +776,7 @@ if (event.rawPath) { } catch (e) { console.error(e); throw new Error( - `Failed to read routes data from ".next/routes-manifest.json" for the "${name}" site.` + `Failed to read routes data from ".next/routes-manifest.json" for the "${name}" site.`, ); } }); @@ -789,7 +789,7 @@ if (event.rawPath) { try { const content = fs .readFileSync( - path.join(outputPath, ".next/app-path-routes-manifest.json") + path.join(outputPath, ".next/app-path-routes-manifest.json"), ) .toString(); return JSON.parse(content) as Record; @@ -807,7 +807,7 @@ if (event.rawPath) { try { const content = fs .readFileSync( - path.join(outputPath, ".next/server/app-paths-manifest.json") + path.join(outputPath, ".next/server/app-paths-manifest.json"), ) .toString(); return JSON.parse(content) as Record; @@ -825,7 +825,7 @@ if (event.rawPath) { try { const content = fs .readFileSync( - path.join(outputPath, ".next/server/pages-manifest.json") + path.join(outputPath, ".next/server/pages-manifest.json"), ) .toString(); return JSON.parse(content) as Record; @@ -843,7 +843,7 @@ if (event.rawPath) { try { const content = fs .readFileSync( - path.join(outputPath, ".next/prerender-manifest.json") + path.join(outputPath, ".next/prerender-manifest.json"), ) .toString(); prerenderManifest = JSON.parse(content); @@ -887,19 +887,17 @@ if (event.rawPath) { "Effect": "Deny", "Resources": [ "arn:aws:logs:${$app.providers?.aws - ?.region!}:*:log-group:/aws/lambda/${ - serverFunction?.nodes.function.name - }", + ?.region!}:*:log-group:/aws/lambda/${serverFunction?.nodes + .function.name}", "arn:aws:logs:${$app.providers?.aws - ?.region!}:*:log-group:/aws/lambda/${ - serverFunction?.nodes.function.name - }:*", + ?.region!}:*:log-group:/aws/lambda/${serverFunction?.nodes + .function.name}:*", ], } ] }`, }, - { parent } + { parent }, ); new aws.iam.RolePolicyAttachment( `${name}DisableLoggingPolicyAttachment`, @@ -907,7 +905,7 @@ if (event.rawPath) { policyArn: policy.arn, role: serverFunction.nodes.function.role, }, - { parent } + { parent }, ); } @@ -922,14 +920,14 @@ if (event.rawPath) { `${name}Sourcemap${toPascalCase(sourcemapKey)}`, { bucket: output($app.providers?.aws?.region!).apply((region) => - AWS.bootstrap.forRegion(region) + AWS.bootstrap.forRegion(region), ), source: new asset.FileAsset(sourcemapPath), key: serverFunction!.nodes.function.arn.apply((arn) => - path.posix.join("sourcemaps", arn, sourcemapKey) + path.posix.join("sourcemaps", arn, sourcemapKey), ), }, - { parent } + { parent }, ); }); }); diff --git a/internal/components/src/components/providers/distribution-invalidation.ts b/internal/components/src/components/providers/distribution-invalidation.ts index 673d2976c..f89a134ff 100644 --- a/internal/components/src/components/providers/distribution-invalidation.ts +++ b/internal/components/src/components/providers/distribution-invalidation.ts @@ -34,7 +34,7 @@ class Provider implements dynamic.ResourceProvider { async update( id: string, olds: Inputs, - news: Inputs + news: Inputs, ): Promise { await this.handle(news); return { outs: {} }; @@ -64,7 +64,7 @@ class Provider implements dynamic.ResourceProvider { const stepsCount: number = Math.max( Math.ceil(pathsFile.length / FILE_LIMIT), - Math.ceil(pathsWildcard.length / WILDCARD_LIMIT) + Math.ceil(pathsWildcard.length / WILDCARD_LIMIT), ); const invalidationIds: string[] = []; @@ -74,7 +74,7 @@ class Provider implements dynamic.ResourceProvider { ...pathsWildcard.slice(i * WILDCARD_LIMIT, (i + 1) * WILDCARD_LIMIT), ]; invalidationIds.push( - await this.invalidateChunk(client, distributionId, stepPaths) + await this.invalidateChunk(client, distributionId, stepPaths), ); } return invalidationIds; @@ -83,7 +83,7 @@ class Provider implements dynamic.ResourceProvider { async invalidateChunk( client: CloudFrontClient, distributionId: string, - paths: string[] + paths: string[], ) { console.log("invalidating chunk", paths); @@ -97,7 +97,7 @@ class Provider implements dynamic.ResourceProvider { Items: paths, }, }, - }) + }), ); const invalidationId = result.Invalidation?.Id; @@ -112,7 +112,7 @@ class Provider implements dynamic.ResourceProvider { async waitForInvalidation( client: CloudFrontClient, inputs: Inputs, - invalidationIds: string[] + invalidationIds: string[], ) { const { distributionId } = inputs; for (const invalidationId of invalidationIds) { @@ -126,7 +126,7 @@ class Provider implements dynamic.ResourceProvider { { DistributionId: distributionId, Id: invalidationId, - } + }, ); } catch (e) { // supress errors @@ -140,7 +140,7 @@ export class DistributionInvalidation extends dynamic.Resource { constructor( name: string, args: DistributionInvalidationInputs, - opts?: CustomResourceOptions + opts?: CustomResourceOptions, ) { super( new Provider(), @@ -155,7 +155,7 @@ export class DistributionInvalidation extends dynamic.Resource { args.version || Date.now().toString(16) + Math.random().toString(16).slice(2), }, - opts + opts, ); } } diff --git a/internal/components/src/components/providers/function-code-updater.ts b/internal/components/src/components/providers/function-code-updater.ts index 41887709b..969a823d7 100644 --- a/internal/components/src/components/providers/function-code-updater.ts +++ b/internal/components/src/components/providers/function-code-updater.ts @@ -27,7 +27,7 @@ class Provider implements dynamic.ResourceProvider { FunctionName: inputs.functionName, S3Bucket: inputs.s3Bucket, S3Key: inputs.s3Key, - }) + }), ); return { id: inputs.functionName, outs: inputs }; } @@ -35,7 +35,7 @@ class Provider implements dynamic.ResourceProvider { async update( id: string, olds: Inputs, - news: Inputs + news: Inputs, ): Promise { const client = AWS.useClient(LambdaClient, news.region); await client.send( @@ -43,7 +43,7 @@ class Provider implements dynamic.ResourceProvider { FunctionName: news.functionName, S3Bucket: news.s3Bucket, S3Key: news.s3Key, - }) + }), ); return { outs: news }; } @@ -53,7 +53,7 @@ export class FunctionCodeUpdater extends dynamic.Resource { constructor( name: string, args: FunctionCodeUpdaterInputs, - opts?: CustomResourceOptions + opts?: CustomResourceOptions, ) { super(new Provider(), `${name}.sst.FunctionCodeUpdater`, args, opts); } diff --git a/internal/components/src/components/providers/log-group.ts b/internal/components/src/components/providers/log-group.ts index 49b7e820d..0770db5f1 100644 --- a/internal/components/src/components/providers/log-group.ts +++ b/internal/components/src/components/providers/log-group.ts @@ -30,7 +30,7 @@ class Provider implements dynamic.ResourceProvider { async update( id: string, olds: Inputs, - news: Inputs + news: Inputs, ): Promise { await this.createLogGroup(news); await this.setRetentionPolicy(news); @@ -45,7 +45,7 @@ class Provider implements dynamic.ResourceProvider { const client = AWS.useClient(CloudWatchLogsClient, inputs.region); try { await client.send( - new CreateLogGroupCommand({ logGroupName: inputs.logGroupName }) + new CreateLogGroupCommand({ logGroupName: inputs.logGroupName }), ); } catch (error: any) { if (error.name === "ResourceAlreadyExistsException") return; @@ -57,7 +57,7 @@ class Provider implements dynamic.ResourceProvider { const client = AWS.useClient(CloudWatchLogsClient, inputs.region); try { await client.send( - new DeleteLogGroupCommand({ logGroupName: inputs.logGroupName }) + new DeleteLogGroupCommand({ logGroupName: inputs.logGroupName }), ); } catch (error: any) { if (error.name === "ResourceNotFoundException") return; @@ -73,7 +73,7 @@ class Provider implements dynamic.ResourceProvider { await client.send(new DeleteRetentionPolicyCommand({ logGroupName })); } else { await client.send( - new PutRetentionPolicyCommand({ logGroupName, retentionInDays }) + new PutRetentionPolicyCommand({ logGroupName, retentionInDays }), ); } } @@ -83,7 +83,7 @@ export class LogGroup extends dynamic.Resource { constructor( name: string, args: LogGroupInputs, - opts?: CustomResourceOptions + opts?: CustomResourceOptions, ) { super(new Provider(), `${name}.sst.LogGroup`, args, opts); } diff --git a/internal/components/src/runtime/node.ts b/internal/components/src/runtime/node.ts index f891f01c3..4c656aae8 100644 --- a/internal/components/src/runtime/node.ts +++ b/internal/components/src/runtime/node.ts @@ -8,7 +8,7 @@ import { HandlerFunctionArgs } from "../components/handler-function.js"; export async function build( name: string, - input: pulumi.Unwrap + input: pulumi.Unwrap, ) { const out = path.join($cli.paths.work, "artifacts", name); await fs.rm(out, { recursive: true, force: true }); @@ -38,7 +38,7 @@ export async function build( ? relative : "", // Lambda handler can only contain 1 dot separating the file name and function name - parsed.name.replace(".", "-") + extension + parsed.name.replace(".", "-") + extension, ); const handler = path .relative(out, target.replace(extension, parsed.ext)) @@ -108,8 +108,8 @@ export async function build( .filter((pkg) => !external?.includes(pkg)) .filter((pkg) => Object.values(result.metafile?.inputs || {}).some(({ imports }) => - imports.some(({ path }) => path === pkg) - ) + imports.some(({ path }) => path === pkg), + ), ), ]; @@ -121,9 +121,9 @@ export async function build( .filter(({ path }) => path.includes("sst/constructs")) .forEach(({ path }) => { warnings.push( - `You are importing from "${path}" in "${inputPath}". Did you mean to import from "sst/node"?` + `You are importing from "${path}" in "${inputPath}". Did you mean to import from "sst/node"?`, ); - }) + }), ); if (installPackages) { @@ -139,15 +139,15 @@ export async function build( const json = JSON.parse( await fs .readFile(path.join(src, "package.json")) - .then((x) => x.toString()) + .then((x) => x.toString()), ); await fs.writeFile( path.join(out, "package.json"), JSON.stringify({ dependencies: Object.fromEntries( - installPackages.map((x) => [x, json.dependencies?.[x] || "*"]) + installPackages.map((x) => [x, json.dependencies?.[x] || "*"]), ), - }) + }), ); const cmd = ["npm install"]; if (installPackages.includes("sharp")) { @@ -155,7 +155,7 @@ export async function build( "--platform=linux", input.nodes?.function?.architectures?.includes("arm_64") ? "--arch=arm64" - : "--arch=x64" + : "--arch=x64", ); } await new Promise((resolve, reject) => { @@ -176,7 +176,7 @@ export async function build( handler, sourcemap: !nodejs.sourcemap ? Object.keys(result.metafile?.outputs || {}).find((item) => - item.endsWith(".map") + item.endsWith(".map"), ) : undefined, }; diff --git a/internal/components/src/util/fs.ts b/internal/components/src/util/fs.ts index c0b8f7b7a..f3d856c25 100644 --- a/internal/components/src/util/fs.ts +++ b/internal/components/src/util/fs.ts @@ -3,7 +3,7 @@ import path from "path"; export async function findAbove( dir: string, - target: string + target: string, ): Promise { if (dir === "/") return undefined; if (await existsAsync(path.join(dir, target))) return dir; @@ -37,7 +37,7 @@ export async function findBelow(dir: string, target: string) { export function isChild(parent: string, child: string) { const relative = path.relative(parent, child); return Boolean( - relative && !relative.startsWith("..") && !path.isAbsolute(relative) + relative && !relative.startsWith("..") && !path.isAbsolute(relative), ); }