Skip to content

Commit 03d80f8

Browse files
committed
chore: enable prettier
1 parent cac1b0b commit 03d80f8

File tree

14 files changed

+247
-251
lines changed

14 files changed

+247
-251
lines changed

.eslintrc.json

Lines changed: 6 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitattributes

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.prettierignore

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.prettierrc.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/deps.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/files.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
const { awscdk } = require('projen');
1+
const { awscdk } = require("projen");
22

3-
const cdkVersion = '2.51.0';
3+
const cdkVersion = "2.51.0";
44

55
const project = new awscdk.AwsCdkConstructLibrary({
6-
author: 'Lorenz Nimmervoll',
7-
authorAddress: 'admin@nimmervoll.work',
6+
author: "Lorenz Nimmervoll",
7+
authorAddress: "admin@nimmervoll.work",
88
cdkVersion,
9-
defaultReleaseBranch: 'main',
10-
name: 'cdk-self-destruct',
11-
repositoryUrl: 'https://github.com/NimmLor/cdk-self-destruct.git',
12-
stability: 'experimental',
13-
description: 'A construct that allows you to self-destruct your AWS resources in a given stack',
14-
keywords: ['cdk', 'awscdk', 'aws-cdk'],
9+
defaultReleaseBranch: "main",
10+
name: "cdk-self-destruct",
11+
repositoryUrl: "https://github.com/NimmLor/cdk-self-destruct.git",
12+
stability: "experimental",
13+
description:
14+
"A construct that allows you to self-destruct your AWS resources in a given stack",
15+
keywords: ["cdk", "awscdk", "aws-cdk"],
1516

1617
deps: [],
17-
devDeps: ['aws-sdk', 'esbuild'],
18-
packageName: 'cdk-self-destruct',
18+
devDeps: ["aws-sdk", "esbuild"],
19+
packageName: "cdk-self-destruct",
1920
jest: true,
2021
jestOptions: {
21-
extraCliOptions: ['--testMatch "**/(test|src)/**/*(*.)@(spec|test).ts?(x)"'],
22+
extraCliOptions: [
23+
'--testMatch "**/(test|src)/**/*(*.)@(spec|test).ts?(x)"',
24+
],
2225
},
23-
gitignore: ['cdk.out'],
26+
gitignore: ["cdk.out"],
27+
eslintOptions: {
28+
prettier: true,
29+
},
30+
prettier: true,
2431
});
25-
project.synth();
32+
project.synth();

package.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.handler.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// eslint-disable-next-line import/no-extraneous-dependencies
2-
import { CloudFormation, S3, StepFunctions } from 'aws-sdk';
2+
import { CloudFormation, S3, StepFunctions } from "aws-sdk";
33

4-
const cf = new CloudFormation({ apiVersion: '2010-05-15' });
5-
const s3 = new S3({ apiVersion: '2006-03-01' });
6-
const stepFunctions = new StepFunctions({ apiVersion: '2016-11-23' });
4+
const cf = new CloudFormation({ apiVersion: "2010-05-15" });
5+
const s3 = new S3({ apiVersion: "2006-03-01" });
6+
const stepFunctions = new StepFunctions({ apiVersion: "2016-11-23" });
77

88
/**
99
* Purge all objects from an S3 bucket
@@ -25,7 +25,7 @@ const purgeS3Bucket = async (bucketName: string) => {
2525
const deleteObjectsParameters: S3.Types.DeleteObjectsRequest = {
2626
Bucket: bucketName,
2727
Delete: {
28-
Objects: response.Contents.map(object => ({
28+
Objects: response.Contents.map((object) => ({
2929
Key: object.Key as string,
3030
})),
3131
},
@@ -44,7 +44,7 @@ const stopAllExecutions = async (stateMachineArn: string) => {
4444
maxResults: 100,
4545
nextToken: response?.nextToken,
4646
stateMachineArn,
47-
statusFilter: 'RUNNING',
47+
statusFilter: "RUNNING",
4848
})
4949
.promise();
5050
response = listExecutionsResponse;
@@ -62,36 +62,40 @@ const stopAllExecutions = async (stateMachineArn: string) => {
6262
} while (response?.nextToken);
6363
};
6464

65-
export const handler = async (_event: unknown, _context: unknown, callback: (error: unknown, response: Record<string, unknown>) => void) => {
65+
export const handler = async (
66+
_event: unknown,
67+
_context: unknown,
68+
callback: (error: unknown, response: Record<string, unknown>) => void
69+
) => {
6670
const { STACK_NAME, S3_BUCKETS, STATE_MACHINES } = process.env;
6771

68-
const s3Buckets = S3_BUCKETS?.split(';') || [];
69-
const stateMachines = STATE_MACHINES?.split(';') || [];
72+
const s3Buckets = S3_BUCKETS?.split(";") || [];
73+
const stateMachines = STATE_MACHINES?.split(";") || [];
7074

7175
const promises: Array<Promise<unknown>> = [];
7276

7377
for (const bucketName of s3Buckets) {
7478
if (bucketName) {
75-
console.log('Purging S3 bucket: ' + bucketName);
79+
console.log("Purging S3 bucket: " + bucketName);
7680
promises.push(purgeS3Bucket(bucketName));
7781
}
7882
}
7983

8084
for (const stateMachineArn of stateMachines) {
8185
if (stateMachineArn) {
82-
console.log('Stopping Statemachine executions of: ' + stateMachineArn);
86+
console.log("Stopping Statemachine executions of: " + stateMachineArn);
8387
promises.push(stopAllExecutions(stateMachineArn));
8488
}
8589
}
8690

8791
if (STACK_NAME === undefined) {
88-
throw new Error('STACK_NAME is not defined');
92+
throw new Error("STACK_NAME is not defined");
8993
}
9094

9195
if (promises.length) {
92-
console.log('Waiting for all promises to resolve...');
96+
console.log("Waiting for all promises to resolve...");
9397
await Promise.all(promises);
94-
console.log('All promises resolved');
98+
console.log("All promises resolved");
9599
}
96100

97101
const timestamp = new Date().toISOString();
@@ -100,13 +104,12 @@ export const handler = async (_event: unknown, _context: unknown, callback: (err
100104

101105
const message = `Started self destruct at ${timestamp}`;
102106

103-
104107
console.log(message);
105108

106109
callback(null, {
107110
statusCode: 201,
108111
headers: {
109-
'Content-Type': 'application/json',
112+
"Content-Type": "application/json",
110113
},
111114
body: JSON.stringify({ message, stack: STACK_NAME, timestamp }, null, 2),
112115
isBase64Encoded: false,

0 commit comments

Comments
 (0)