Skip to content

Commit ec7b989

Browse files
committed
Merge branch 'release/1.4.0'
2 parents 14db87a + fd5a4d6 commit ec7b989

File tree

7 files changed

+1545
-1244
lines changed

7 files changed

+1545
-1244
lines changed

.eslintrc.js

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,29 @@
11
module.exports = {
2-
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
2+
root: true,
3+
parser: "@typescript-eslint/parser",
34
plugins: ["@typescript-eslint"],
4-
extends: [
5-
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
6-
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
7-
"plugin:prettier/recommended", // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
8-
],
5+
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "prettier/@typescript-eslint"],
96
parserOptions: {
10-
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
11-
sourceType: "module", // Allows for the use of imports
12-
ecmaFeatures: {
13-
modules: true,
14-
},
7+
ecmaVersion: 2020,
8+
sourceType: "module",
159
},
1610
env: {
1711
node: true,
18-
jest: true,
19-
},
20-
settings: {
21-
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
22-
"import/parsers": {
23-
"@typescript-eslint/parser": [".ts", ".tsx"],
24-
},
25-
"import/resolver": {
26-
typescript: {
27-
directory: "./tsconfig.json",
28-
},
29-
node: {
30-
extensions: [".js", ".jsx", ".ts", ".tsx"],
31-
},
32-
},
12+
es6: true,
3313
},
14+
globals: {},
3415
rules: {
35-
"sort-imports": [
36-
"error",
37-
{
38-
ignoreCase: false,
39-
ignoreDeclarationSort: false,
40-
ignoreMemberSort: false,
41-
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
42-
},
43-
],
44-
"max-len": [
16+
semi: ["error", "always"],
17+
quotes: ["error", "double"],
18+
"@typescript-eslint/explicit-function-return-type": "off",
19+
"@typescript-eslint/no-explicit-any": 1,
20+
"@typescript-eslint/no-var-requires": 0,
21+
"@typescript-eslint/no-inferrable-types": [
4522
"warn",
4623
{
47-
code: 125,
48-
ignoreRegExpLiterals: true,
49-
ignoreTemplateLiterals: true,
50-
ignoreStrings: true,
51-
ignoreUrls: true,
52-
},
53-
],
54-
"no-unused-vars": [
55-
"error",
56-
{
57-
vars: "all",
58-
args: "after-used",
59-
ignoreRestSiblings: true,
60-
argsIgnorePattern: "err",
24+
ignoreParameters: true,
6125
},
6226
],
27+
"@typescript-eslint/no-unused-vars": "warn",
6328
},
6429
};

.vscode/settings.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"eslint.enable": true,
32
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
43
"editor.codeActionsOnSave": {
54
"source.fixAll.eslint": true
@@ -11,7 +10,13 @@
1110
"editor.defaultFormatter": "esbenp.prettier-vscode"
1211
},
1312
"[typescript]": {
14-
"editor.defaultFormatter": "esbenp.prettier-vscode"
13+
"editor.defaultFormatter": "esbenp.prettier-vscode",
14+
"editor.formatOnSave": true,
15+
"editor.codeActionsOnSave": {
16+
"source.fixAll.eslint": true,
17+
"source.organizeImports": true,
18+
"source.addMissingImports": true
19+
}
1520
},
1621
"[typescriptreact]": {
1722
"editor.defaultFormatter": "esbenp.prettier-vscode"

__tests__/construct.test.ts

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { countResources, expect as expectCDK } from "@aws-cdk/assert";
2+
import { Certificate, DnsValidatedCertificate } from "@aws-cdk/aws-certificatemanager";
3+
import { PublicHostedZone } from "@aws-cdk/aws-route53";
14
import { App, Stack } from "@aws-cdk/core";
25
import { DomainRedirect, REGION_ERROR_MESSAGE } from "../src/redirect";
3-
import { countResources, expect as expectCDK } from "@aws-cdk/assert";
4-
5-
import { Certificate } from "@aws-cdk/aws-certificatemanager";
66

77
class TestApp {
88
public readonly stack: Stack;
@@ -19,7 +19,7 @@ class TestApp {
1919
}
2020

2121
describe("DomainRedirect", (): void => {
22-
let stack: Stack, fromLookup: jest.Mock, fromAlias: jest.Mock, fakeCert: Certificate;
22+
let stack: Stack, fromLookup: jest.Mock, fromAlias: jest.Mock;
2323
beforeEach(() => {
2424
({ stack } = new TestApp());
2525
fromLookup = jest.fn();
@@ -29,16 +29,13 @@ describe("DomainRedirect", (): void => {
2929
fromLookup: fromLookup,
3030
},
3131
AddressRecordTarget: {
32-
fromAlias: function (): object {
32+
fromAlias: function (): Record<string, unknown> {
3333
return {
3434
bind: fromAlias,
3535
};
3636
},
3737
},
3838
}));
39-
fakeCert = new Certificate(stack, "Certificate", {
40-
domainName: "example.com",
41-
});
4239
});
4340
it("looks up an IHostedZone if a valid hostname is passed as a string to DomainOptions.zoneName", function (): void {
4441
fromLookup.mockReturnValue({
@@ -67,6 +64,9 @@ describe("DomainRedirect", (): void => {
6764
fromLookup.mockReturnValue({
6865
zoneName: "example.com.",
6966
});
67+
const fakeCert = new Certificate(stack, "Certificate", {
68+
domainName: "example.com",
69+
});
7070
new DomainRedirect(stack, "redirects", {
7171
zoneName: "example.com",
7272
cert: fakeCert,
@@ -79,19 +79,42 @@ describe("DomainRedirect", (): void => {
7979
fromLookup.mockReturnValue({
8080
zoneName: "example.com.",
8181
});
82+
const fakeCert = new Certificate(stack, "Certificate", {
83+
domainName: "example.com",
84+
});
8285
new DomainRedirect(stack, "redirects", {
8386
zoneName: "example.com",
8487
cert: fakeCert,
8588
target: "https://spencerbeg.gs",
8689
hostnames: "foobar.example.com",
8790
});
91+
expectCDK(stack).to(countResources("AWS::CertificateManager::Certificate", 1));
92+
expectCDK(stack).to(countResources("AWS::S3::Bucket", 1));
93+
expectCDK(stack).to(countResources("AWS::CloudFront::Distribution", 1));
94+
});
95+
it("accepts a DnsValidatedCertificate as a cert type", function (): void {
96+
const exampleDotComZone = new PublicHostedZone(stack, "ExampleDotCom", {
97+
zoneName: "example.com",
98+
});
99+
new DomainRedirect(stack, "redirects", {
100+
zoneName: "example.com",
101+
cert: new DnsValidatedCertificate(stack, "DnsValidatedCertificate", {
102+
domainName: "test.example.com",
103+
hostedZone: exampleDotComZone,
104+
}),
105+
target: "https://spencerbeg.gs",
106+
hostnames: "foobar.example.com",
107+
});
88108
expectCDK(stack).to(countResources("AWS::S3::Bucket", 1));
89109
expectCDK(stack).to(countResources("AWS::CloudFront::Distribution", 1));
90110
});
91111
it("passes through an array of strings for DomainOptions.hostnames", function (): void {
92112
fromLookup.mockReturnValue({
93113
zoneName: "example.com.",
94114
});
115+
const fakeCert = new Certificate(stack, "Certificate", {
116+
domainName: "example.com",
117+
});
95118
new DomainRedirect(stack, "redirects", {
96119
zoneName: "example.com",
97120
cert: fakeCert,
@@ -105,6 +128,9 @@ describe("DomainRedirect", (): void => {
105128
fromLookup.mockReturnValue({
106129
zoneName: "example.com",
107130
});
131+
const fakeCert = new Certificate(stack, "Certificate", {
132+
domainName: "example.com",
133+
});
108134
new DomainRedirect(stack, "redirects", {
109135
zoneName: "example.com",
110136
cert: fakeCert,
@@ -114,6 +140,9 @@ describe("DomainRedirect", (): void => {
114140
expectCDK(stack).to(countResources("AWS::CloudFront::Distribution", 1));
115141
});
116142
it("accepts and array of DomainOptions", () => {
143+
const fakeCert = new Certificate(stack, "Certificate", {
144+
domainName: "example.com",
145+
});
117146
fromLookup
118147
.mockReturnValueOnce({
119148
zoneName: "domain1.com",
@@ -140,7 +169,9 @@ describe("DomainRedirect", (): void => {
140169
fromLookup.mockReturnValueOnce({
141170
zoneName: "example.com",
142171
});
143-
172+
const fakeCert = new Certificate(stack, "Certificate", {
173+
domainName: "example.com",
174+
});
144175
new DomainRedirect(stack, "redirects", {
145176
zoneName: "domain1.com",
146177
cert: fakeCert,
@@ -157,7 +188,9 @@ describe("DomainRedirect", (): void => {
157188
fromLookup.mockReturnValueOnce({
158189
zoneName: "example.com",
159190
});
160-
191+
const fakeCert = new Certificate(stack, "Certificate", {
192+
domainName: "example.com",
193+
});
161194
new DomainRedirect(stack, "redirects", {
162195
zoneName: "domain1.com",
163196
cert: fakeCert,
@@ -169,6 +202,9 @@ describe("DomainRedirect", (): void => {
169202
});
170203
it("it throws if you try to create a stack that is not in us-east-1", () => {
171204
const { stack: stackInWrongRegion } = new TestApp("us-west-1");
205+
const fakeCert = new Certificate(stack, "Certificate", {
206+
domainName: "example.com",
207+
});
172208
const fn = (): void => {
173209
new DomainRedirect(stackInWrongRegion, "redirects", {
174210
zoneName: "domain1.com",

jest.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ module.exports = {
33
testEnvironment: "node",
44
globals: {
55
"ts-jest": {
6-
packageJson: "package.json",
7-
tsConfig: "tsconfig.json",
6+
tsconfig: "tsconfig.json",
87
},
98
},
109
transform: {

package.json

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@spencerbeggs/aws-cdk-domain-redirect",
33
"description": "An AWS CDK construct that makes redirecting HTTP(S) requests to a different domain a breeze.",
4-
"version": "1.3.0",
4+
"version": "1.4.0",
55
"license": "MIT",
66
"author": "C. Spencer Beggs <spencer@beg.gs>",
77
"scripts": {
@@ -41,51 +41,51 @@
4141
"registry": "https://registry.npmjs.org/"
4242
},
4343
"devDependencies": {
44-
"@aws-cdk/assert": "^1.39.0",
45-
"@aws-cdk/assets": "^1.39.0",
46-
"@aws-cdk/aws-apigateway": "^1.39.0",
47-
"@aws-cdk/aws-certificatemanager": "^1.39.0",
48-
"@aws-cdk/aws-cloudformation": "^1.39.0",
49-
"@aws-cdk/aws-cloudfront": "^1.39.0",
50-
"@aws-cdk/aws-cloudwatch": "^1.39.0",
51-
"@aws-cdk/aws-cognito": "^1.39.0",
52-
"@aws-cdk/aws-ec2": "^1.39.0",
53-
"@aws-cdk/aws-elasticloadbalancing": "^1.39.0",
54-
"@aws-cdk/aws-elasticloadbalancingv2": "^1.39.0",
55-
"@aws-cdk/aws-events": "^1.39.0",
56-
"@aws-cdk/aws-iam": "^1.39.0",
57-
"@aws-cdk/aws-kms": "^1.39.0",
58-
"@aws-cdk/aws-lambda": "^1.39.0",
59-
"@aws-cdk/aws-logs": "^1.39.0",
60-
"@aws-cdk/aws-route53": "^1.39.0",
61-
"@aws-cdk/aws-route53-targets": "^1.39.0",
62-
"@aws-cdk/aws-s3": "^1.39.0",
63-
"@aws-cdk/aws-s3-assets": "^1.39.0",
64-
"@aws-cdk/aws-sns": "^1.39.0",
65-
"@aws-cdk/aws-sqs": "^1.39.0",
66-
"@aws-cdk/aws-ssm": "^1.39.0",
67-
"@aws-cdk/cdk-assets-schema": "^1.39.0",
68-
"@aws-cdk/cloud-assembly-schema": "^1.39.0",
69-
"@aws-cdk/core": "^1.39.0",
70-
"@aws-cdk/custom-resources": "^1.39.0",
71-
"@aws-cdk/cx-api": "^1.39.0",
72-
"@aws-cdk/region-info": "^1.39.0",
73-
"@types/fs-extra": "^9.0.0",
74-
"@types/jest": "^25.2.3",
75-
"@types/node": "14.0.1",
76-
"@typescript-eslint/eslint-plugin": "^2.26.0",
77-
"@typescript-eslint/parser": "^2.26.0",
78-
"constructs": "^3.0.3",
44+
"@aws-cdk/assert": "^1.88.0",
45+
"@aws-cdk/assets": "^1.88.0",
46+
"@aws-cdk/aws-apigateway": "^1.88.0",
47+
"@aws-cdk/aws-certificatemanager": "^1.88.0",
48+
"@aws-cdk/aws-cloudformation": "^1.88.0",
49+
"@aws-cdk/aws-cloudfront": "^1.88.0",
50+
"@aws-cdk/aws-cloudwatch": "^1.88.0",
51+
"@aws-cdk/aws-cognito": "^1.88.0",
52+
"@aws-cdk/aws-ec2": "^1.88.0",
53+
"@aws-cdk/aws-elasticloadbalancing": "^1.88.0",
54+
"@aws-cdk/aws-elasticloadbalancingv2": "^1.88.0",
55+
"@aws-cdk/aws-events": "^1.88.0",
56+
"@aws-cdk/aws-iam": "^1.88.0",
57+
"@aws-cdk/aws-kms": "^1.88.0",
58+
"@aws-cdk/aws-lambda": "^1.88.0",
59+
"@aws-cdk/aws-logs": "^1.88.0",
60+
"@aws-cdk/aws-route53": "^1.88.0",
61+
"@aws-cdk/aws-route53-targets": "^1.88.0",
62+
"@aws-cdk/aws-s3": "^1.88.0",
63+
"@aws-cdk/aws-s3-assets": "^1.88.0",
64+
"@aws-cdk/aws-sns": "^1.88.0",
65+
"@aws-cdk/aws-sqs": "^1.88.0",
66+
"@aws-cdk/aws-ssm": "^1.88.0",
67+
"@aws-cdk/cdk-assets-schema": "^1.88.0",
68+
"@aws-cdk/cloud-assembly-schema": "^1.88.0",
69+
"@aws-cdk/core": "^1.88.0",
70+
"@aws-cdk/custom-resources": "^1.88.0",
71+
"@aws-cdk/cx-api": "^1.88.0",
72+
"@aws-cdk/region-info": "^1.88.0",
73+
"@types/fs-extra": "^9.0.6",
74+
"@types/jest": "^26.0.20",
75+
"@types/node": "14.14.25",
76+
"@typescript-eslint/eslint-plugin": "^4.14.2",
77+
"@typescript-eslint/parser": "^4.14.2",
78+
"constructs": "^3.3.14",
7979
"coveralls": "^3.0.9",
80-
"eslint": "^7.0.0",
81-
"eslint-config-prettier": "^6.10.0",
82-
"eslint-plugin-prettier": "^3.1.2",
83-
"fs-extra": "^9.0.0",
84-
"jest": "^26.0.1",
85-
"prettier": "^2.0.2",
86-
"ts-jest": "^26.0.0",
87-
"ts-node": "^8.6.2",
88-
"typescript": "^3.9.2"
80+
"eslint": "^7.19.0",
81+
"eslint-config-prettier": "^7.2.0",
82+
"eslint-plugin-prettier": "^3.3.1",
83+
"fs-extra": "^9.1.0",
84+
"jest": "^26.6.3",
85+
"prettier": "^2.2.1",
86+
"ts-jest": "^26.5.0",
87+
"ts-node": "^9.1.1",
88+
"typescript": "^4.1.3"
8989
},
9090
"peerDependencies": {
9191
"@aws-cdk/assert": "^1.39.0",
@@ -118,5 +118,14 @@
118118
"@aws-cdk/cx-api": "^1.39.0",
119119
"@aws-cdk/region-info": "^1.39.0",
120120
"constructs": "^3.0.3"
121+
},
122+
"dependencies": {
123+
"@aws-cdk/aws-apigatewayv2": "^1.88.0",
124+
"@aws-cdk/aws-applicationautoscaling": "^1.88.0",
125+
"@aws-cdk/aws-autoscaling-common": "^1.88.0",
126+
"@aws-cdk/aws-codeguruprofiler": "^1.88.0",
127+
"@aws-cdk/aws-ecr": "^1.88.0",
128+
"@aws-cdk/aws-ecr-assets": "^1.88.0",
129+
"@aws-cdk/aws-efs": "^1.88.0"
121130
}
122131
}

0 commit comments

Comments
 (0)