@guardian/cdk 49.0.0 → 49.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/constructs/s3/index.d.ts +90 -0
- package/lib/constructs/s3/index.d.ts.map +1 -1
- package/lib/constructs/s3/index.js +33 -1
- package/lib/constructs/s3/index.js.map +1 -1
- package/lib/experimental/riff-raff-yaml-file/deployments/s3.d.ts +4 -0
- package/lib/experimental/riff-raff-yaml-file/deployments/s3.d.ts.map +1 -0
- package/lib/experimental/riff-raff-yaml-file/deployments/s3.js +48 -0
- package/lib/experimental/riff-raff-yaml-file/deployments/s3.js.map +1 -0
- package/lib/experimental/riff-raff-yaml-file/index.d.ts +13 -3
- package/lib/experimental/riff-raff-yaml-file/index.d.ts.map +1 -1
- package/lib/experimental/riff-raff-yaml-file/index.js +23 -3
- package/lib/experimental/riff-raff-yaml-file/index.js.map +1 -1
- package/lib/experimental/riff-raff-yaml-file/types.d.ts +1 -1
- package/lib/experimental/riff-raff-yaml-file/types.d.ts.map +1 -1
- package/lib/experimental/riff-raff-yaml-file/types.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { Duration } from "aws-cdk-lib";
|
|
1
2
|
import type { BucketProps } from "aws-cdk-lib/aws-s3";
|
|
2
3
|
import { Bucket } from "aws-cdk-lib/aws-s3";
|
|
4
|
+
import type { IConstruct } from "constructs";
|
|
3
5
|
import type { AppIdentity, GuStack } from "../core";
|
|
4
6
|
export interface GuS3BucketProps extends Omit<BucketProps, "removalPolicy">, AppIdentity {
|
|
5
7
|
}
|
|
@@ -14,5 +16,93 @@ declare const GuS3Bucket_base: {
|
|
|
14
16
|
export declare class GuS3Bucket extends GuS3Bucket_base {
|
|
15
17
|
constructor(scope: GuStack, id: string, props: GuS3BucketProps);
|
|
16
18
|
}
|
|
19
|
+
interface GuS3OriginBucketDeploymentProps {
|
|
20
|
+
/**
|
|
21
|
+
* Customises the SSM Parameter path, making it stage agnostic.
|
|
22
|
+
* Useful when a single bucket is used across multiple stages.
|
|
23
|
+
*
|
|
24
|
+
* When `false` the path will be `/<STAGE>/<STACK>/<APP>/<APP>-origin-bucket`.
|
|
25
|
+
* When `true` the path will be `/<STACK>/<APP>/<APP>-origin-bucket`.
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
withoutStageAwareness: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Used to configure `bucketSsmKeyStageParam` in a generated `riff-raff.yaml` file.
|
|
32
|
+
*
|
|
33
|
+
* The SSM Parameter path, without a stage prefix.
|
|
34
|
+
*
|
|
35
|
+
* Not settable by user.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
baseParameterName: string;
|
|
40
|
+
/**
|
|
41
|
+
* Used to configure `cacheControl` in a generated `riff-raff.yaml` file.
|
|
42
|
+
* Only needed if you're also using {@link GuRootExperimental}.
|
|
43
|
+
*
|
|
44
|
+
* Set the cache control header for the uploaded files.
|
|
45
|
+
*
|
|
46
|
+
* The key is a regular expression to match uploaded files.
|
|
47
|
+
* The value is the max-age to set in the `Cache-Control` header.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* To cache all files for one hour:
|
|
51
|
+
* ```ts
|
|
52
|
+
* { ".*", Duration.hours(1) }
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @default cache nothing
|
|
56
|
+
* @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3
|
|
57
|
+
*/
|
|
58
|
+
cacheControl: Record<string, Duration>;
|
|
59
|
+
/**
|
|
60
|
+
* Used to configure `surrogateControl` in a generated `riff-raff.yaml` file.
|
|
61
|
+
* Only needed if you're also using {@link GuRootExperimental}.
|
|
62
|
+
*
|
|
63
|
+
* Same as [[cacheControl]], but for setting the surrogate-control cache header, which is used by Fastly.
|
|
64
|
+
*
|
|
65
|
+
* @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3
|
|
66
|
+
*/
|
|
67
|
+
surrogateControl: Record<string, Duration>;
|
|
68
|
+
/**
|
|
69
|
+
* Used to configure `mimeTypes` in a generated `riff-raff.yaml` file.
|
|
70
|
+
* Only needed if you're also using {@link GuRootExperimental}.
|
|
71
|
+
*
|
|
72
|
+
* A map of file extension to MIME type.
|
|
73
|
+
*
|
|
74
|
+
* When a file is uploaded with a file extension that is in this map, the Content-Type header will be set to the MIME type provided.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* { "xpi", "application/x-xpinstall" }
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3
|
|
82
|
+
*/
|
|
83
|
+
mimeTypes: Record<string, string>;
|
|
84
|
+
}
|
|
85
|
+
export interface GuS3OriginBucketProps extends GuS3BucketProps, Partial<Omit<GuS3OriginBucketDeploymentProps, "baseParameterName">> {
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* An S3 bucket for use as an origin for a static site.
|
|
89
|
+
* The bucket name will be stored in an SSM Parameter.
|
|
90
|
+
* Other infrastructure, or applications, that use this bucket should discover its name by the Parameter.
|
|
91
|
+
*/
|
|
92
|
+
export declare class GuS3OriginBucket extends GuS3Bucket implements IConstruct {
|
|
93
|
+
/**
|
|
94
|
+
* The name of the created SSM Parameter.
|
|
95
|
+
*/
|
|
96
|
+
readonly parameterName: string;
|
|
97
|
+
readonly app: string;
|
|
98
|
+
/**
|
|
99
|
+
* For internal use only, used to generate a `riff-raff.yaml` file.
|
|
100
|
+
*
|
|
101
|
+
* @see [[RiffRaffYamlFileExperimental]]
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
readonly _deploymentProps: Required<GuS3OriginBucketDeploymentProps>;
|
|
105
|
+
constructor(scope: GuStack, id: string, props: GuS3OriginBucketProps);
|
|
106
|
+
}
|
|
17
107
|
export {};
|
|
18
108
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constructs/s3/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constructs/s3/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAqB,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEpD,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,EAAE,WAAW;CAAG;;;;;;AAE3F;;GAEG;AACH,qBAAa,UAAW,SAAQ,eAA2B;gBAC7C,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe;CAQ/D;AAED,UAAU,+BAA+B;IACvC;;;;;;;;OAQG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAE/B;;;;;;;;OAQG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEvC;;;;;;;OAOG;IACH,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE3C;;;;;;;;;;;;;;OAcG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,qBACf,SAAQ,eAAe,EACrB,OAAO,CAAC,IAAI,CAAC,+BAA+B,EAAE,mBAAmB,CAAC,CAAC;CAAG;AAE1E;;;;GAIG;AAEH,qBAAa,gBAAiB,SAAQ,UAAW,YAAW,UAAU;IACpE;;OAEG;IACH,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,SAAgB,GAAG,EAAE,MAAM,CAAC;IAE5B;;;;;OAKG;IACH,SAAgB,gBAAgB,EAAE,QAAQ,CAAC,+BAA+B,CAAC,CAAC;gBAEhE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB;CA4BrE"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GuS3Bucket = void 0;
|
|
3
|
+
exports.GuS3OriginBucket = exports.GuS3Bucket = void 0;
|
|
4
4
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
5
|
const aws_s3_1 = require("aws-cdk-lib/aws-s3");
|
|
6
|
+
const aws_ssm_1 = require("aws-cdk-lib/aws-ssm");
|
|
6
7
|
const app_aware_construct_1 = require("../../utils/mixin/app-aware-construct");
|
|
7
8
|
/**
|
|
8
9
|
* A construct to create a bucket with a "retain" policy to prevent it from being deleted. It will be orphaned instead.
|
|
@@ -18,4 +19,35 @@ class GuS3Bucket extends (0, app_aware_construct_1.GuAppAwareConstruct)(aws_s3_1
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
exports.GuS3Bucket = GuS3Bucket;
|
|
22
|
+
/**
|
|
23
|
+
* An S3 bucket for use as an origin for a static site.
|
|
24
|
+
* The bucket name will be stored in an SSM Parameter.
|
|
25
|
+
* Other infrastructure, or applications, that use this bucket should discover its name by the Parameter.
|
|
26
|
+
*/
|
|
27
|
+
// implementing `IConstruct` is a no-op here as `Bucket` ultimately does so already. We explicitly do so to avoid a `SuspiciousTypeOfGuard` warning in `riff-raff-yaml-file/index.ts`.
|
|
28
|
+
class GuS3OriginBucket extends GuS3Bucket {
|
|
29
|
+
constructor(scope, id, props) {
|
|
30
|
+
const { stage, stack } = scope;
|
|
31
|
+
const { app, withoutStageAwareness = false, cacheControl = {}, surrogateControl = {}, mimeTypes = {} } = props;
|
|
32
|
+
super(scope, id, props);
|
|
33
|
+
this.app = app;
|
|
34
|
+
const stageAgnosticParameterParts = [stack, app, `${app}-origin-bucket`];
|
|
35
|
+
const parameterParts = withoutStageAwareness
|
|
36
|
+
? stageAgnosticParameterParts
|
|
37
|
+
: [stage, ...stageAgnosticParameterParts];
|
|
38
|
+
this.parameterName = `/${parameterParts.join("/")}`;
|
|
39
|
+
new aws_ssm_1.StringParameter(scope, `${id}-ssm-param`, {
|
|
40
|
+
parameterName: this.parameterName,
|
|
41
|
+
stringValue: this.bucketName,
|
|
42
|
+
});
|
|
43
|
+
this._deploymentProps = {
|
|
44
|
+
withoutStageAwareness,
|
|
45
|
+
cacheControl,
|
|
46
|
+
surrogateControl,
|
|
47
|
+
mimeTypes,
|
|
48
|
+
baseParameterName: `/${stageAgnosticParameterParts.join("/")}`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.GuS3OriginBucket = GuS3OriginBucket;
|
|
21
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constructs/s3/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constructs/s3/index.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAE5C,+CAA+D;AAC/D,iDAAsD;AAEtD,+EAA4E;AAK5E;;GAEG;AACH,MAAa,UAAW,SAAQ,IAAA,yCAAmB,EAAC,eAAM,CAAC;IACzD,YAAY,KAAc,EAAE,EAAU,EAAE,KAAsB;QAC5D,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE;YACf,aAAa,EAAE,2BAAa,CAAC,MAAM;YACnC,gBAAgB,EAAE,KAAK;YACvB,iBA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dk-lib\";\nimport type { BucketProps } from \"aws-cdk-lib/aws-s3\";\nimport { BlockPublicAccess, Bucket } from \"aws-cdk-lib/aws-s3\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport type { IConstruct } from \"constructs\";\nimport { GuAppAwareConstruct } from \"../../utils/mixin/app-aware-construct\";\nimport type { AppIdentity, GuStack } from \"../core\";\n\nexport interface GuS3BucketProps extends Omit<BucketProps, \"removalPolicy\">, AppIdentity {}\n\n/**\n * A construct to create a bucket with a \"retain\" policy to prevent it from being deleted. It will be orphaned instead.\n */\nexport class GuS3Bucket extends GuAppAwareConstruct(Bucket) {\n constructor(scope: GuStack, id: string, props: GuS3BucketProps) {\n super(scope, id, {\n removalPolicy: RemovalPolicy.RETAIN,\n publicReadAccess: false,\n blockPublicAccess: BlockPublicAccess.BLOCK_ALL,\n ...props,\n });\n }\n}\n\ninterface GuS3OriginBucketDeploymentProps {\n /**\n * Customises the SSM Parameter path, making it stage agnostic.\n * Useful when a single bucket is used across multiple stages.\n *\n * When `false` the path will be `/<STAGE>/<STACK>/<APP>/<APP>-origin-bucket`.\n * When `true` the path will be `/<STACK>/<APP>/<APP>-origin-bucket`.\n *\n * @default false\n */\n withoutStageAwareness: boolean;\n\n /**\n * Used to configure `bucketSsmKeyStageParam` in a generated `riff-raff.yaml` file.\n *\n * The SSM Parameter path, without a stage prefix.\n *\n * Not settable by user.\n *\n * @internal\n */\n baseParameterName: string;\n\n /**\n * Used to configure `cacheControl` in a generated `riff-raff.yaml` file.\n * Only needed if you're also using {@link GuRootExperimental}.\n *\n * Set the cache control header for the uploaded files.\n *\n * The key is a regular expression to match uploaded files.\n * The value is the max-age to set in the `Cache-Control` header.\n *\n * @example\n * To cache all files for one hour:\n * ```ts\n * { \".*\", Duration.hours(1) }\n * ```\n *\n * @default cache nothing\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3\n */\n cacheControl: Record<string, Duration>;\n\n /**\n * Used to configure `surrogateControl` in a generated `riff-raff.yaml` file.\n * Only needed if you're also using {@link GuRootExperimental}.\n *\n * Same as [[cacheControl]], but for setting the surrogate-control cache header, which is used by Fastly.\n *\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3\n */\n surrogateControl: Record<string, Duration>;\n\n /**\n * Used to configure `mimeTypes` in a generated `riff-raff.yaml` file.\n * Only needed if you're also using {@link GuRootExperimental}.\n *\n * A map of file extension to MIME type.\n *\n * When a file is uploaded with a file extension that is in this map, the Content-Type header will be set to the MIME type provided.\n *\n * @example\n * ```ts\n * { \"xpi\", \"application/x-xpinstall\" }\n * ```\n *\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types#awss3\n */\n mimeTypes: Record<string, string>;\n}\n\nexport interface GuS3OriginBucketProps\n extends GuS3BucketProps,\n Partial<Omit<GuS3OriginBucketDeploymentProps, \"baseParameterName\">> {}\n\n/**\n * An S3 bucket for use as an origin for a static site.\n * The bucket name will be stored in an SSM Parameter.\n * Other infrastructure, or applications, that use this bucket should discover its name by the Parameter.\n */\n// implementing `IConstruct` is a no-op here as `Bucket` ultimately does so already. We explicitly do so to avoid a `SuspiciousTypeOfGuard` warning in `riff-raff-yaml-file/index.ts`.\nexport class GuS3OriginBucket extends GuS3Bucket implements IConstruct {\n /**\n * The name of the created SSM Parameter.\n */\n public readonly parameterName: string;\n\n public readonly app: string;\n\n /**\n * For internal use only, used to generate a `riff-raff.yaml` file.\n *\n * @see [[RiffRaffYamlFileExperimental]]\n * @internal\n */\n public readonly _deploymentProps: Required<GuS3OriginBucketDeploymentProps>;\n\n constructor(scope: GuStack, id: string, props: GuS3OriginBucketProps) {\n const { stage, stack } = scope;\n const { app, withoutStageAwareness = false, cacheControl = {}, surrogateControl = {}, mimeTypes = {} } = props;\n\n super(scope, id, props);\n\n this.app = app;\n\n const stageAgnosticParameterParts = [stack, app, `${app}-origin-bucket`];\n const parameterParts = withoutStageAwareness\n ? stageAgnosticParameterParts\n : [stage, ...stageAgnosticParameterParts];\n\n this.parameterName = `/${parameterParts.join(\"/\")}`;\n\n new StringParameter(scope, `${id}-ssm-param`, {\n parameterName: this.parameterName,\n stringValue: this.bucketName,\n });\n\n this._deploymentProps = {\n withoutStageAwareness,\n cacheControl,\n surrogateControl,\n mimeTypes,\n baseParameterName: `/${stageAgnosticParameterParts.join(\"/\")}`,\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GuS3OriginBucket } from "../../../constructs/s3";
|
|
2
|
+
import type { RiffRaffDeployment } from "../types";
|
|
3
|
+
export declare function uploadStaticFilesDeployment(stages: string[], originBucket: GuS3OriginBucket, { name: cfnDeployName }: RiffRaffDeployment): RiffRaffDeployment;
|
|
4
|
+
//# sourceMappingURL=s3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../../src/experimental/riff-raff-yaml-file/deployments/s3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EAAE,EAChB,YAAY,EAAE,gBAAgB,EAC9B,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,kBAAkB,GAC1C,kBAAkB,CAoDpB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadStaticFilesDeployment = void 0;
|
|
4
|
+
function uploadStaticFilesDeployment(stages, originBucket, { name: cfnDeployName }) {
|
|
5
|
+
const { app, _deploymentProps } = originBucket;
|
|
6
|
+
const { withoutStageAwareness, baseParameterName, cacheControl, surrogateControl, mimeTypes } = _deploymentProps;
|
|
7
|
+
const { stack, region } = originBucket.stack;
|
|
8
|
+
const cacheControlValue = Object.entries(cacheControl).map(([pattern, duration]) => {
|
|
9
|
+
return {
|
|
10
|
+
pattern,
|
|
11
|
+
value: `public, max-age=${duration.toSeconds()}`,
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
const surrogateControlValue = Object.entries(surrogateControl).map(([pattern, duration]) => {
|
|
15
|
+
return {
|
|
16
|
+
pattern,
|
|
17
|
+
value: `public, max-age=${duration.toSeconds()}`,
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
name: ["upload-static-files", region, stack, app].join("-"),
|
|
22
|
+
props: {
|
|
23
|
+
type: "aws-s3",
|
|
24
|
+
actions: ["uploadStaticFiles"],
|
|
25
|
+
dependencies: [cfnDeployName],
|
|
26
|
+
stacks: new Set([stack]),
|
|
27
|
+
regions: new Set([region]),
|
|
28
|
+
app,
|
|
29
|
+
contentDirectory: app,
|
|
30
|
+
parameters: {
|
|
31
|
+
bucketSsmKeyStageParam: stages.reduce((acc, stage) => ({
|
|
32
|
+
...acc,
|
|
33
|
+
[stage]: withoutStageAwareness ? baseParameterName : `/${stage}${baseParameterName}`,
|
|
34
|
+
}), {}),
|
|
35
|
+
// Never create per object ACLs.
|
|
36
|
+
// If the bucket content needs to be public, it’s better to control this via the bucket policy.
|
|
37
|
+
publicReadAcl: false,
|
|
38
|
+
cacheControl: cacheControlValue.length > 0 ? cacheControlValue : "private",
|
|
39
|
+
// only add the `surrogateControl` property if there are some
|
|
40
|
+
...(surrogateControlValue.length > 0 && { surrogateControl: surrogateControlValue }),
|
|
41
|
+
// only add the `mimeTypes` property if there are some
|
|
42
|
+
...(Object.keys(mimeTypes).length > 0 && { mimeTypes }),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.uploadStaticFilesDeployment = uploadStaticFilesDeployment;
|
|
48
|
+
//# sourceMappingURL=s3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.js","sourceRoot":"","sources":["../../../../src/exper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,GAAG;YACH,gBAAgB,EAAE,GAAG;YACrB,UAAU,EAAE;gBACV,sBAAsB,EAAE,MAAM,CAAC,MAAM,CACnC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;oBACf,GAAG,GAAG;oBACN,CAAC,KAAK,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,iBAAiB,EAAE;iBACrF,CAAC,EACF,EAAE,CACH;gBAED,gCAAgC;gBAChC,+FAA+F;gBAC/F,aAAa,EAAE,KAAK;gBAEpB,YAAY,EAAE,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS;gBAE1E,6DAA6D;gBAC7D,GAAG,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,CAAC;gBAEpF,sDAAsD;gBACtD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;aACxD;SACF;KACF,CAAC;AACJ,CAAC;AAxDD,kEAwDC","sourcesContent":["import type { GuStack } from \"../../../constructs/core\";\nimport type { GuS3OriginBucket } from \"../../../constructs/s3\";\nimport type { RiffRaffDeployment } from \"../types\";\n\nexport function uploadStaticFilesDeployment(\n stages: string[],\n originBucket: GuS3OriginBucket,\n { name: cfnDeployName }: RiffRaffDeployment\n): RiffRaffDeployment {\n const { app, _deploymentProps } = originBucket;\n const { withoutStageAwareness, baseParameterName, cacheControl, surrogateControl, mimeTypes } = _deploymentProps;\n const { stack, region } = originBucket.stack as GuStack;\n\n const cacheControlValue = Object.entries(cacheControl).map(([pattern, duration]) => {\n return {\n pattern,\n value: `public, max-age=${duration.toSeconds()}`,\n };\n });\n\n const surrogateControlValue = Object.entries(surrogateControl).map(([pattern, duration]) => {\n return {\n pattern,\n value: `public, max-age=${duration.toSeconds()}`,\n };\n });\n\n return {\n name: [\"upload-static-files\", region, stack, app].join(\"-\"),\n props: {\n type: \"aws-s3\",\n actions: [\"uploadStaticFiles\"],\n dependencies: [cfnDeployName],\n stacks: new Set([stack]),\n regions: new Set([region]),\n app,\n contentDirectory: app,\n parameters: {\n bucketSsmKeyStageParam: stages.reduce(\n (acc, stage) => ({\n ...acc,\n [stage]: withoutStageAwareness ? baseParameterName : `/${stage}${baseParameterName}`,\n }),\n {}\n ),\n\n // Never create per object ACLs.\n // If the bucket content needs to be public, it’s better to control this via the bucket policy.\n publicReadAcl: false,\n\n cacheControl: cacheControlValue.length > 0 ? cacheControlValue : \"private\",\n\n // only add the `surrogateControl` property if there are some\n ...(surrogateControlValue.length > 0 && { surrogateControl: surrogateControlValue }),\n\n // only add the `mimeTypes` property if there are some\n ...(Object.keys(mimeTypes).length > 0 && { mimeTypes }),\n },\n },\n };\n}\n"]}
|
|
@@ -9,6 +9,7 @@ import type { App } from "aws-cdk-lib";
|
|
|
9
9
|
* - Multiple regions
|
|
10
10
|
* - Lambda applications
|
|
11
11
|
* - EC2 (autoscaling) applications
|
|
12
|
+
* - Upload of static files to S3
|
|
12
13
|
*
|
|
13
14
|
* For lambda applications, 3 deployments will be defined:
|
|
14
15
|
* 1. Lambda upload (`aws-lambda`, `action: [uploadLambda]`)
|
|
@@ -17,9 +18,13 @@ import type { App } from "aws-cdk-lib";
|
|
|
17
18
|
*
|
|
18
19
|
* For EC2 applications, 3 deployments will be defined:
|
|
19
20
|
* 1. Artifact upload (`autoscaling`, `action: [uploadArtifacts]`)
|
|
20
|
-
*
|
|
21
|
+
* 2. CloudFormation deploy (`cloud-formation`)
|
|
21
22
|
* 3. Autoscaling deploy (`autoscaling`, `action: [deploy]`)
|
|
22
23
|
*
|
|
24
|
+
* For S3 uploads, 2 deployments will be defined:
|
|
25
|
+
* 1. Artifact upload (`aws-s3`, `action: [uploadStaticFiles]`)
|
|
26
|
+
* 2. CloudFormation deploy (`cloud-formation`)
|
|
27
|
+
*
|
|
23
28
|
* It assumes a Riff-Raff bundle structure as follows:
|
|
24
29
|
*
|
|
25
30
|
* ```
|
|
@@ -28,8 +33,12 @@ import type { App } from "aws-cdk-lib";
|
|
|
28
33
|
* │ └── MyApplication.template.json
|
|
29
34
|
* ├── my-application
|
|
30
35
|
* │ └── my-application.deb
|
|
31
|
-
*
|
|
32
|
-
*
|
|
36
|
+
* ├── my-lambda
|
|
37
|
+
* │ └── my-lambda.zip
|
|
38
|
+
* └── my-static-site
|
|
39
|
+
* ├── index.html
|
|
40
|
+
* ├── main.js
|
|
41
|
+
* └── index.css
|
|
33
42
|
* ```
|
|
34
43
|
*
|
|
35
44
|
* That is, all CloudFormation templates are in a `cdk.out` directory, and there is a directory per app.
|
|
@@ -110,6 +119,7 @@ export declare class RiffRaffYamlFileExperimental {
|
|
|
110
119
|
private validateAllRegionsAreResolved;
|
|
111
120
|
private getLambdas;
|
|
112
121
|
private getAutoScalingGroups;
|
|
122
|
+
private getOriginBuckets;
|
|
113
123
|
constructor(app: App);
|
|
114
124
|
/**
|
|
115
125
|
* The `riff-raff.yaml` file as a string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/experimental/riff-raff-yaml-file/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/experimental/riff-raff-yaml-file/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAyBvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,qBAAa,4BAA4B;IACvC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAY;IACzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;IAEtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO,CAAC,iBAAiB;IAqBzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuDG;IACH,OAAO,CAAC,mBAAmB;IAkD3B,OAAO,CAAC,6BAA6B;IAQrC,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,gBAAgB;gBAMZ,GAAG,EAAE,GAAG;IAoEpB;;;OAGG;IACH,MAAM,IAAI,MAAM;IAiBhB;;;OAGG;IACH,KAAK,IAAI,IAAI;CAId"}
|
|
@@ -12,9 +12,11 @@ const js_yaml_1 = require("js-yaml");
|
|
|
12
12
|
const autoscaling_1 = require("../../constructs/autoscaling");
|
|
13
13
|
const core_1 = require("../../constructs/core");
|
|
14
14
|
const lambda_1 = require("../../constructs/lambda");
|
|
15
|
+
const s3_1 = require("../../constructs/s3");
|
|
15
16
|
const autoscaling_2 = require("./deployments/autoscaling");
|
|
16
17
|
const cloudformation_1 = require("./deployments/cloudformation");
|
|
17
18
|
const lambda_2 = require("./deployments/lambda");
|
|
19
|
+
const s3_2 = require("./deployments/s3");
|
|
18
20
|
const group_by_1 = require("./group-by");
|
|
19
21
|
/**
|
|
20
22
|
* A class that creates a `riff-raff.yaml` file.
|
|
@@ -26,6 +28,7 @@ const group_by_1 = require("./group-by");
|
|
|
26
28
|
* - Multiple regions
|
|
27
29
|
* - Lambda applications
|
|
28
30
|
* - EC2 (autoscaling) applications
|
|
31
|
+
* - Upload of static files to S3
|
|
29
32
|
*
|
|
30
33
|
* For lambda applications, 3 deployments will be defined:
|
|
31
34
|
* 1. Lambda upload (`aws-lambda`, `action: [uploadLambda]`)
|
|
@@ -34,9 +37,13 @@ const group_by_1 = require("./group-by");
|
|
|
34
37
|
*
|
|
35
38
|
* For EC2 applications, 3 deployments will be defined:
|
|
36
39
|
* 1. Artifact upload (`autoscaling`, `action: [uploadArtifacts]`)
|
|
37
|
-
*
|
|
40
|
+
* 2. CloudFormation deploy (`cloud-formation`)
|
|
38
41
|
* 3. Autoscaling deploy (`autoscaling`, `action: [deploy]`)
|
|
39
42
|
*
|
|
43
|
+
* For S3 uploads, 2 deployments will be defined:
|
|
44
|
+
* 1. Artifact upload (`aws-s3`, `action: [uploadStaticFiles]`)
|
|
45
|
+
* 2. CloudFormation deploy (`cloud-formation`)
|
|
46
|
+
*
|
|
40
47
|
* It assumes a Riff-Raff bundle structure as follows:
|
|
41
48
|
*
|
|
42
49
|
* ```
|
|
@@ -45,8 +52,12 @@ const group_by_1 = require("./group-by");
|
|
|
45
52
|
* │ └── MyApplication.template.json
|
|
46
53
|
* ├── my-application
|
|
47
54
|
* │ └── my-application.deb
|
|
48
|
-
*
|
|
49
|
-
*
|
|
55
|
+
* ├── my-lambda
|
|
56
|
+
* │ └── my-lambda.zip
|
|
57
|
+
* └── my-static-site
|
|
58
|
+
* ├── index.html
|
|
59
|
+
* ├── main.js
|
|
60
|
+
* └── index.css
|
|
50
61
|
* ```
|
|
51
62
|
*
|
|
52
63
|
* That is, all CloudFormation templates are in a `cdk.out` directory, and there is a directory per app.
|
|
@@ -175,6 +186,10 @@ class RiffRaffYamlFileExperimental {
|
|
|
175
186
|
getAutoScalingGroups(cdkStack) {
|
|
176
187
|
return cdkStack.node.findAll().filter((_) => _ instanceof autoscaling_1.GuAutoScalingGroup);
|
|
177
188
|
}
|
|
189
|
+
getOriginBuckets(cdkStack) {
|
|
190
|
+
// `GuS3OriginBucket` implements `IConstruct` to remove a `SuspiciousTypeOfGuard` warning here
|
|
191
|
+
return cdkStack.node.findAll().filter((_) => _ instanceof s3_1.GuS3OriginBucket);
|
|
192
|
+
}
|
|
178
193
|
// eslint-disable-next-line custom-rules/valid-constructors -- this needs to sit above GuStack on the cdk tree
|
|
179
194
|
constructor(app) {
|
|
180
195
|
this.allCdkStacks = app.node.findAll().filter((_) => _ instanceof core_1.GuStack);
|
|
@@ -199,6 +214,7 @@ class RiffRaffYamlFileExperimental {
|
|
|
199
214
|
const stack = stacks[0];
|
|
200
215
|
const lambdas = this.getLambdas(stack);
|
|
201
216
|
const autoscalingGroups = this.getAutoScalingGroups(stack);
|
|
217
|
+
const originBuckets = this.getOriginBuckets(stack);
|
|
202
218
|
const artifactUploads = [
|
|
203
219
|
lambdas.map(lambda_2.uploadLambdaArtifact),
|
|
204
220
|
autoscalingGroups.map(autoscaling_2.uploadAutoscalingArtifact),
|
|
@@ -215,6 +231,10 @@ class RiffRaffYamlFileExperimental {
|
|
|
215
231
|
deployments.set(asgDeployment.name, asgDeployment.props);
|
|
216
232
|
deployments.set(cfnDeployment.name, (0, cloudformation_1.addAmiParametersToCloudFormationDeployment)(cfnDeployment, asg));
|
|
217
233
|
});
|
|
234
|
+
originBuckets.forEach((bucket) => {
|
|
235
|
+
const staticFilesDeployment = (0, s3_2.uploadStaticFilesDeployment)(this.allStageTags, bucket, cfnDeployment);
|
|
236
|
+
deployments.set(staticFilesDeployment.name, staticFilesDeployment.props);
|
|
237
|
+
});
|
|
218
238
|
});
|
|
219
239
|
});
|
|
220
240
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/experimental/riff-raff-yaml-file/index.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAmC;AACnC,gDAAwB;AAExB,6CAAoC;AACpC,kDAA0B;AAC1B,qCAA+B;AAC/B,8DAAkE;AAClE,gDAAgD;AAChD,oDAA2D;AAC3D,2DAA6F;AAC7F,iEAAoH;AACpH,iDAAoF;AACpF,yCAA8D;AAa9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAa,4BAA4B;IAS/B,iBAAiB,CACvB,iBAA4B,EAC5B,aA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AiG;gBACjG,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC1B;YACD,IAAI,KAAK,YAAY,GAAG,EAAE;gBACxB,iGAAiG;gBACjG,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;aAClC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;QAEF,OAAO,IAAA,cAAI,EAAC,IAAI,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACzD,IAAA,kBAAa,EAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,CAAC;CACF;AApPD,oEAoPC","sourcesContent":["import { writeFileSync } from \"fs\";\nimport path from \"path\";\nimport type { App } from \"aws-cdk-lib\";\nimport { Token } from \"aws-cdk-lib\";\nimport chalk from \"chalk\";\nimport { dump } from \"js-yaml\";\nimport { GuAutoScalingGroup } from \"../../constructs/autoscaling\";\nimport { GuStack } from \"../../constructs/core\";\nimport { GuLambdaFunction } from \"../../constructs/lambda\";\nimport { autoscalingDeployment, uploadAutoscalingArtifact } from \"./deployments/autoscaling\";\nimport { addAmiParametersToCloudFormationDeployment, cloudFormationDeployment } from \"./deployments/cloudformation\";\nimport { updateLambdaDeployment, uploadLambdaArtifact } from \"./deployments/lambda\";\nimport { groupByClassNameStackRegionStage } from \"./group-by\";\nimport type {\n ClassName,\n GroupedCdkStacks,\n Region,\n RiffRaffDeployment,\n RiffRaffDeploymentName,\n RiffRaffDeploymentProps,\n RiffRaffYaml,\n StackTag,\n StageTag,\n} from \"./types\";\n\n/**\n * A class that creates a `riff-raff.yaml` file.\n *\n * Rather than using this directly, prefer to use [[`GuRoot`]] instead.\n *\n * Supports:\n * - Multiple CloudFormation stacks\n * - Multiple regions\n * - Lambda applications\n * - EC2 (autoscaling) applications\n *\n * For lambda applications, 3 deployments will be defined:\n * 1. Lambda upload (`aws-lambda`, `action: [uploadLambda]`)\n * 2. CloudFormation deploy (`cloud-formation`)\n * 3. Lambda update (`aws-lambda`, `action: [updateLambda]`)\n *\n * For EC2 applications, 3 deployments will be defined:\n * 1. Artifact upload (`autoscaling`, `action: [uploadArtifacts]`)\n * 2. CloudFormation deploy (`cloud-formation`)\n * 3. Autoscaling deploy (`autoscaling`, `action: [deploy]`)\n *\n * It assumes a Riff-Raff bundle structure as follows:\n *\n * ```\n * .\n * ├── cdk.out\n * │ └── MyApplication.template.json\n * ├── my-application\n * │ └── my-application.deb\n * └── my-lambda\n * └── my-lambda.zip\n * ```\n *\n * That is, all CloudFormation templates are in a `cdk.out` directory, and there is a directory per app.\n * Application artifact(s) are in the app directory.\n *\n * NOTE: The file extension is decided by you, the above file tree is used for illustration purposes.\n *\n * NOTE: Resources will be looked up by tags (Stack, Stage, App). Ensure your CFN stack is tagged appropriately!\n *\n * @see https://riffraff.gutools.co.uk/docs/reference/riff-raff.yaml.md\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types\n */\nexport class RiffRaffYamlFileExperimental {\n private readonly allCdkStacks: GuStack[];\n private readonly allStackTags: StackTag[];\n private readonly allStageTags: StageTag[];\n private readonly allRegions: Region[];\n\n private readonly riffRaffYaml: RiffRaffYaml;\n private readonly outdir: string;\n\n private isCdkStackPresent(\n expectedClassName: ClassName,\n expectedStack: StackTag,\n expectedRegion: Region,\n expectedStage: StageTag\n ): boolean {\n const matches = this.allCdkStacks.find((cdkStack) => {\n const {\n constructor: { name },\n stack,\n stage,\n region,\n } = cdkStack;\n return (\n name === expectedClassName && stack === expectedStack && stage === expectedStage && region === expectedRegion\n );\n });\n\n return !!matches;\n }\n\n /**\n * Check there are the appropriate number of `GuStack`s.\n * Expect to find an instance for each combination of `GuStack`, `stack`, `region`, and `stage`.\n *\n * If not valid, a message is logged describing what is missing to aid debugging.\n *\n * Given the following:\n *\n * ```ts\n * const app = new App();\n *\n * class MyApplicationStack extends GuStack { }\n *\n * new MyApplicationStack(app, \"App-CODE-deploy\", {\n * env: {\n * region: \"eu-west-1\",\n * },\n * stack: \"deploy\",\n * stage: \"CODE\"\n * });\n *\n * new MyApplicationStack(app, \"App-PROD-media-service\", {\n * env: {\n * region: \"eu-west-1\",\n * },\n * stack: \"media-service\",\n * stage: \"PROD\",\n * });\n *\n * new MyApplicationStack(app, \"App-PROD-deploy\", {\n * env: {\n * region: \"eu-west-1\",\n * },\n * stack: \"deploy\",\n * stage: \"PROD\"\n * });\n * ```\n *\n * This will log a message like this, where ❌ denotes something missing,\n * specifically there is no `CODE` template for `media-service`.\n *\n * ```log\n * Unable to produce a working riff-raff.yaml file; missing 1 definitions (details below)\n *\n * For the class: MyApplicationStack\n *\n * ┌───────────────┬────────────────────────────┐\n * │ (index) │ eu-west-1 │\n * ├───────────────┼────────────────────────────┤\n * │ deploy │ { CODE: '✅', PROD: '✅' } │\n * │ media-service │ { CODE: '❌', PROD: '✅' } │\n * └───────────────┴────────────────────────────┘\n * ```\n *\n * @private\n */\n private validateStacksInApp(): void {\n type Found = \"✅\";\n type NotFound = \"❌\";\n type AppValidation = Record<ClassName, Record<StackTag, Record<Region, Record<StageTag, Found | NotFound>>>>;\n\n const { allCdkStacks, allStackTags, allStageTags, allRegions } = this;\n\n const checks: AppValidation = allCdkStacks.reduce((accClassName, { constructor: { name } }) => {\n return {\n ...accClassName,\n [name]: allStackTags.reduce((accStackTag, stackTag) => {\n return {\n ...accStackTag,\n [stackTag]: allRegions.reduce((accRegion, region) => {\n return {\n ...accRegion,\n [region]: allStageTags.reduce((accStageTag, stageTag) => {\n return {\n ...accStageTag,\n [stageTag]: this.isCdkStackPresent(name, stackTag, region, stageTag) ? \"✅\" : \"❌\",\n };\n }, {}),\n };\n }, {}),\n };\n }, {}),\n };\n }, {});\n\n const missingDefinitions = Object.values(checks).flatMap((groupedByStackTag) => {\n return Object.values(groupedByStackTag).flatMap((groupedByRegion) => {\n return Object.values(groupedByRegion).flatMap((groupedByStage) => {\n return Object.values(groupedByStage).filter((_) => _ === \"❌\");\n });\n });\n });\n\n if (missingDefinitions.length > 0) {\n const message = `Unable to produce a working riff-raff.yaml file; missing ${missingDefinitions.length} definitions`;\n\n console.log(`${message} (details below)`);\n Object.entries(checks).forEach(([className, detail]) => {\n console.log(`For the class: ${chalk.yellow(className)}`);\n console.table(detail);\n });\n\n throw new Error(message);\n }\n }\n\n private validateAllRegionsAreResolved(): void {\n const unresolved = this.allRegions.filter((region) => Token.isUnresolved(region));\n\n if (unresolved.length !== 0) {\n throw new Error(`Unable to produce a working riff-raff.yaml file; all stacks must have an explicit region set`);\n }\n }\n\n private getLambdas(cdkStack: GuStack): GuLambdaFunction[] {\n return cdkStack.node.findAll().filter((_) => _ instanceof GuLambdaFunction) as GuLambdaFunction[];\n }\n\n private getAutoScalingGroups(cdkStack: GuStack): GuAutoScalingGroup[] {\n return cdkStack.node.findAll().filter((_) => _ instanceof GuAutoScalingGroup) as GuAutoScalingGroup[];\n }\n\n // eslint-disable-next-line custom-rules/valid-constructors -- this needs to sit above GuStack on the cdk tree\n constructor(app: App) {\n this.allCdkStacks = app.node.findAll().filter((_) => _ instanceof GuStack) as GuStack[];\n const allowedStages = new Set(this.allCdkStacks.map(({ stage }) => stage));\n this.allStageTags = Array.from(allowedStages);\n this.allStackTags = Array.from(new Set(this.allCdkStacks.map(({ stack }) => stack)));\n this.allRegions = Array.from(new Set(this.allCdkStacks.map(({ region }) => region)));\n\n this.validateStacksInApp();\n this.validateAllRegionsAreResolved();\n\n this.outdir = app.outdir;\n\n const deployments = new Map<RiffRaffDeploymentName, RiffRaffDeploymentProps>();\n\n const groupedStacks: GroupedCdkStacks = groupByClassNameStackRegionStage(this.allCdkStacks);\n\n Object.values(groupedStacks).forEach((stackTagGroup) => {\n Object.values(stackTagGroup).forEach((regionGroup) => {\n Object.values(regionGroup).forEach((stageGroup) => {\n const stacks: GuStack[] = Object.values(stageGroup).flat();\n\n if (stacks.length === 0) {\n throw new Error(\"Unable to produce a working riff-raff.yaml file; there are no stacks!\");\n }\n\n // The items in `stacks` only differ by stage, so we can just use the first item in the list.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- length of `stacks` is checked above\n const stack = stacks[0]!;\n\n const lambdas = this.getLambdas(stack);\n const autoscalingGroups = this.getAutoScalingGroups(stack);\n\n const artifactUploads: RiffRaffDeployment[] = [\n lambdas.map(uploadLambdaArtifact),\n autoscalingGroups.map(uploadAutoscalingArtifact),\n ].flat();\n artifactUploads.forEach(({ name, props }) => deployments.set(name, props));\n\n const cfnDeployment = cloudFormationDeployment(stacks, artifactUploads, this.outdir);\n deployments.set(cfnDeployment.name, cfnDeployment.props);\n\n lambdas.forEach((lambda) => {\n const lambdaDeployment = updateLambdaDeployment(lambda, cfnDeployment);\n deployments.set(lambdaDeployment.name, lambdaDeployment.props);\n });\n\n autoscalingGroups.forEach((asg) => {\n const asgDeployment = autoscalingDeployment(asg, cfnDeployment);\n deployments.set(asgDeployment.name, asgDeployment.props);\n\n deployments.set(cfnDeployment.name, addAmiParametersToCloudFormationDeployment(cfnDeployment, asg));\n });\n });\n });\n });\n\n this.riffRaffYaml = {\n allowedStages,\n deployments,\n };\n }\n\n /**\n * The `riff-raff.yaml` file as a string.\n * Useful for testing.\n */\n toYAML(): string {\n // Add support for ES6 Set and Map. See https://github.com/nodeca/js-yaml/issues/436.\n const replacer = (_key: string, value: unknown) => {\n if (value instanceof Set) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- this is how `js-yaml` is typed\n return Array.from(value);\n }\n if (value instanceof Map) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- this is how `js-yaml` is typed\n return Object.fromEntries(value);\n }\n return value;\n };\n\n return dump(this.riffRaffYaml, { replacer });\n }\n\n /**\n * Write the `riff-raff.yaml` file to disk.\n * It'll be located with the CFN JSON templates generated by `cdk synth`.\n */\n synth(): void {\n const outPath = path.join(this.outdir, \"riff-raff.yaml\");\n writeFileSync(outPath, this.toYAML());\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/experimental/riff-raff-yaml-file/index.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAmC;AACnC,gDAAwB;AAExB,6CAAoC;AACpC,kDAA0B;AAC1B,qCAA+B;AAC/B,8DAAkE;AAClE,gDAAgD;AAChD,oDAA2D;AAC3D,4CAAuD;AACvD,2DAA6F;AAC7F,iEAAoH;AACpH,iDAAoF;AACpF,yCAA+D;AAC/D,yCAA8D;AAa9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAa,4BAA4B;IAS/B,iBAAiB,CACvB,iBAA4B,EAC5B,aAAuB,EACvB,cAAsB,EACtB,aAAuB;QAEvB,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YAClD,MAAM,EACJ,WAAW,EAAE,EAAE,IAAI,EAAE,EACrB,KAAK,EACL,KAAK,EACL,MAAM,GACP,GAAG,QAAQ,CAAC;YACb,OAAO,CACL,IAAI,KAAK,iBAAiB,IAAI,KAAK,KAAK,aAAa,IAAI,KAAK,KAAK,aAAa,IAAI,MAAM,KAAK,cAAc,CAC9G,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,CAAC,OAAO,CAAC;IACnB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuDG;IACK,mBAAmB;QAKzB,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAEtE,MAAM,MAAM,GAAkB,YAAY,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;YAC5F,OAAO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,CAAC;QACf,CAAC,CAAC;QAEF,OAAO,IAAA,cAAI,EAAC,IAAI,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACzD,IAAA,kBAAa,EAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,CAAC;CACF;AA/PD,oEA+PC","sourcesContent":["import { writeFileSync } from \"fs\";\nimport path from \"path\";\nimport type { App } from \"aws-cdk-lib\";\nimport { Token } from \"aws-cdk-lib\";\nimport chalk from \"chalk\";\nimport { dump } from \"js-yaml\";\nimport { GuAutoScalingGroup } from \"../../constructs/autoscaling\";\nimport { GuStack } from \"../../constructs/core\";\nimport { GuLambdaFunction } from \"../../constructs/lambda\";\nimport { GuS3OriginBucket } from \"../../constructs/s3\";\nimport { autoscalingDeployment, uploadAutoscalingArtifact } from \"./deployments/autoscaling\";\nimport { addAmiParametersToCloudFormationDeployment, cloudFormationDeployment } from \"./deployments/cloudformation\";\nimport { updateLambdaDeployment, uploadLambdaArtifact } from \"./deployments/lambda\";\nimport { uploadStaticFilesDeployment } from \"./deployments/s3\";\nimport { groupByClassNameStackRegionStage } from \"./group-by\";\nimport type {\n ClassName,\n GroupedCdkStacks,\n Region,\n RiffRaffDeployment,\n RiffRaffDeploymentName,\n RiffRaffDeploymentProps,\n RiffRaffYaml,\n StackTag,\n StageTag,\n} from \"./types\";\n\n/**\n * A class that creates a `riff-raff.yaml` file.\n *\n * Rather than using this directly, prefer to use [[`GuRoot`]] instead.\n *\n * Supports:\n * - Multiple CloudFormation stacks\n * - Multiple regions\n * - Lambda applications\n * - EC2 (autoscaling) applications\n * - Upload of static files to S3\n *\n * For lambda applications, 3 deployments will be defined:\n * 1. Lambda upload (`aws-lambda`, `action: [uploadLambda]`)\n * 2. CloudFormation deploy (`cloud-formation`)\n * 3. Lambda update (`aws-lambda`, `action: [updateLambda]`)\n *\n * For EC2 applications, 3 deployments will be defined:\n * 1. Artifact upload (`autoscaling`, `action: [uploadArtifacts]`)\n * 2. CloudFormation deploy (`cloud-formation`)\n * 3. Autoscaling deploy (`autoscaling`, `action: [deploy]`)\n *\n * For S3 uploads, 2 deployments will be defined:\n * 1. Artifact upload (`aws-s3`, `action: [uploadStaticFiles]`)\n * 2. CloudFormation deploy (`cloud-formation`)\n *\n * It assumes a Riff-Raff bundle structure as follows:\n *\n * ```\n * .\n * ├── cdk.out\n * │ └── MyApplication.template.json\n * ├── my-application\n * │ └── my-application.deb\n * ├── my-lambda\n * │ └── my-lambda.zip\n * └── my-static-site\n * ├── index.html\n * ├── main.js\n * └── index.css\n * ```\n *\n * That is, all CloudFormation templates are in a `cdk.out` directory, and there is a directory per app.\n * Application artifact(s) are in the app directory.\n *\n * NOTE: The file extension is decided by you, the above file tree is used for illustration purposes.\n *\n * NOTE: Resources will be looked up by tags (Stack, Stage, App). Ensure your CFN stack is tagged appropriately!\n *\n * @see https://riffraff.gutools.co.uk/docs/reference/riff-raff.yaml.md\n * @see https://riffraff.gutools.co.uk/docs/magenta-lib/types\n */\nexport class RiffRaffYamlFileExperimental {\n private readonly allCdkStacks: GuStack[];\n private readonly allStackTags: StackTag[];\n private readonly allStageTags: StageTag[];\n private readonly allRegions: Region[];\n\n private readonly riffRaffYaml: RiffRaffYaml;\n private readonly outdir: string;\n\n private isCdkStackPresent(\n expectedClassName: ClassName,\n expectedStack: StackTag,\n expectedRegion: Region,\n expectedStage: StageTag\n ): boolean {\n const matches = this.allCdkStacks.find((cdkStack) => {\n const {\n constructor: { name },\n stack,\n stage,\n region,\n } = cdkStack;\n return (\n name === expectedClassName && stack === expectedStack && stage === expectedStage && region === expectedRegion\n );\n });\n\n return !!matches;\n }\n\n /**\n * Check there are the appropriate number of `GuStack`s.\n * Expect to find an instance for each combination of `GuStack`, `stack`, `region`, and `stage`.\n *\n * If not valid, a message is logged describing what is missing to aid debugging.\n *\n * Given the following:\n *\n * ```ts\n * const app = new App();\n *\n * class MyApplicationStack extends GuStack { }\n *\n * new MyApplicationStack(app, \"App-CODE-deploy\", {\n * env: {\n * region: \"eu-west-1\",\n * },\n * stack: \"deploy\",\n * stage: \"CODE\"\n * });\n *\n * new MyApplicationStack(app, \"App-PROD-media-service\", {\n * env: {\n * region: \"eu-west-1\",\n * },\n * stack: \"media-service\",\n * stage: \"PROD\",\n * });\n *\n * new MyApplicationStack(app, \"App-PROD-deploy\", {\n * env: {\n * region: \"eu-west-1\",\n * },\n * stack: \"deploy\",\n * stage: \"PROD\"\n * });\n * ```\n *\n * This will log a message like this, where ❌ denotes something missing,\n * specifically there is no `CODE` template for `media-service`.\n *\n * ```log\n * Unable to produce a working riff-raff.yaml file; missing 1 definitions (details below)\n *\n * For the class: MyApplicationStack\n *\n * ┌───────────────┬────────────────────────────┐\n * │ (index) │ eu-west-1 │\n * ├───────────────┼────────────────────────────┤\n * │ deploy │ { CODE: '✅', PROD: '✅' } │\n * │ media-service │ { CODE: '❌', PROD: '✅' } │\n * └───────────────┴────────────────────────────┘\n * ```\n *\n * @private\n */\n private validateStacksInApp(): void {\n type Found = \"✅\";\n type NotFound = \"❌\";\n type AppValidation = Record<ClassName, Record<StackTag, Record<Region, Record<StageTag, Found | NotFound>>>>;\n\n const { allCdkStacks, allStackTags, allStageTags, allRegions } = this;\n\n const checks: AppValidation = allCdkStacks.reduce((accClassName, { constructor: { name } }) => {\n return {\n ...accClassName,\n [name]: allStackTags.reduce((accStackTag, stackTag) => {\n return {\n ...accStackTag,\n [stackTag]: allRegions.reduce((accRegion, region) => {\n return {\n ...accRegion,\n [region]: allStageTags.reduce((accStageTag, stageTag) => {\n return {\n ...accStageTag,\n [stageTag]: this.isCdkStackPresent(name, stackTag, region, stageTag) ? \"✅\" : \"❌\",\n };\n }, {}),\n };\n }, {}),\n };\n }, {}),\n };\n }, {});\n\n const missingDefinitions = Object.values(checks).flatMap((groupedByStackTag) => {\n return Object.values(groupedByStackTag).flatMap((groupedByRegion) => {\n return Object.values(groupedByRegion).flatMap((groupedByStage) => {\n return Object.values(groupedByStage).filter((_) => _ === \"❌\");\n });\n });\n });\n\n if (missingDefinitions.length > 0) {\n const message = `Unable to produce a working riff-raff.yaml file; missing ${missingDefinitions.length} definitions`;\n\n console.log(`${message} (details below)`);\n Object.entries(checks).forEach(([className, detail]) => {\n console.log(`For the class: ${chalk.yellow(className)}`);\n console.table(detail);\n });\n\n throw new Error(message);\n }\n }\n\n private validateAllRegionsAreResolved(): void {\n const unresolved = this.allRegions.filter((region) => Token.isUnresolved(region));\n\n if (unresolved.length !== 0) {\n throw new Error(`Unable to produce a working riff-raff.yaml file; all stacks must have an explicit region set`);\n }\n }\n\n private getLambdas(cdkStack: GuStack): GuLambdaFunction[] {\n return cdkStack.node.findAll().filter((_) => _ instanceof GuLambdaFunction) as GuLambdaFunction[];\n }\n\n private getAutoScalingGroups(cdkStack: GuStack): GuAutoScalingGroup[] {\n return cdkStack.node.findAll().filter((_) => _ instanceof GuAutoScalingGroup) as GuAutoScalingGroup[];\n }\n\n private getOriginBuckets(cdkStack: GuStack): GuS3OriginBucket[] {\n // `GuS3OriginBucket` implements `IConstruct` to remove a `SuspiciousTypeOfGuard` warning here\n return cdkStack.node.findAll().filter((_) => _ instanceof GuS3OriginBucket) as GuS3OriginBucket[];\n }\n\n // eslint-disable-next-line custom-rules/valid-constructors -- this needs to sit above GuStack on the cdk tree\n constructor(app: App) {\n this.allCdkStacks = app.node.findAll().filter((_) => _ instanceof GuStack) as GuStack[];\n const allowedStages = new Set(this.allCdkStacks.map(({ stage }) => stage));\n this.allStageTags = Array.from(allowedStages);\n this.allStackTags = Array.from(new Set(this.allCdkStacks.map(({ stack }) => stack)));\n this.allRegions = Array.from(new Set(this.allCdkStacks.map(({ region }) => region)));\n\n this.validateStacksInApp();\n this.validateAllRegionsAreResolved();\n\n this.outdir = app.outdir;\n\n const deployments = new Map<RiffRaffDeploymentName, RiffRaffDeploymentProps>();\n\n const groupedStacks: GroupedCdkStacks = groupByClassNameStackRegionStage(this.allCdkStacks);\n\n Object.values(groupedStacks).forEach((stackTagGroup) => {\n Object.values(stackTagGroup).forEach((regionGroup) => {\n Object.values(regionGroup).forEach((stageGroup) => {\n const stacks: GuStack[] = Object.values(stageGroup).flat();\n\n if (stacks.length === 0) {\n throw new Error(\"Unable to produce a working riff-raff.yaml file; there are no stacks!\");\n }\n\n // The items in `stacks` only differ by stage, so we can just use the first item in the list.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- length of `stacks` is checked above\n const stack = stacks[0]!;\n\n const lambdas = this.getLambdas(stack);\n const autoscalingGroups = this.getAutoScalingGroups(stack);\n const originBuckets = this.getOriginBuckets(stack);\n\n const artifactUploads: RiffRaffDeployment[] = [\n lambdas.map(uploadLambdaArtifact),\n autoscalingGroups.map(uploadAutoscalingArtifact),\n ].flat();\n artifactUploads.forEach(({ name, props }) => deployments.set(name, props));\n\n const cfnDeployment = cloudFormationDeployment(stacks, artifactUploads, this.outdir);\n deployments.set(cfnDeployment.name, cfnDeployment.props);\n\n lambdas.forEach((lambda) => {\n const lambdaDeployment = updateLambdaDeployment(lambda, cfnDeployment);\n deployments.set(lambdaDeployment.name, lambdaDeployment.props);\n });\n\n autoscalingGroups.forEach((asg) => {\n const asgDeployment = autoscalingDeployment(asg, cfnDeployment);\n deployments.set(asgDeployment.name, asgDeployment.props);\n\n deployments.set(cfnDeployment.name, addAmiParametersToCloudFormationDeployment(cfnDeployment, asg));\n });\n\n originBuckets.forEach((bucket) => {\n const staticFilesDeployment = uploadStaticFilesDeployment(this.allStageTags, bucket, cfnDeployment);\n deployments.set(staticFilesDeployment.name, staticFilesDeployment.props);\n });\n });\n });\n });\n\n this.riffRaffYaml = {\n allowedStages,\n deployments,\n };\n }\n\n /**\n * The `riff-raff.yaml` file as a string.\n * Useful for testing.\n */\n toYAML(): string {\n // Add support for ES6 Set and Map. See https://github.com/nodeca/js-yaml/issues/436.\n const replacer = (_key: string, value: unknown) => {\n if (value instanceof Set) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- this is how `js-yaml` is typed\n return Array.from(value);\n }\n if (value instanceof Map) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- this is how `js-yaml` is typed\n return Object.fromEntries(value);\n }\n return value;\n };\n\n return dump(this.riffRaffYaml, { replacer });\n }\n\n /**\n * Write the `riff-raff.yaml` file to disk.\n * It'll be located with the CFN JSON templates generated by `cdk synth`.\n */\n synth(): void {\n const outPath = path.join(this.outdir, \"riff-raff.yaml\");\n writeFileSync(outPath, this.toYAML());\n }\n}\n"]}
|
|
@@ -15,7 +15,7 @@ export interface RiffRaffDeploymentProps {
|
|
|
15
15
|
stacks: Set<StackTag>;
|
|
16
16
|
app: string;
|
|
17
17
|
contentDirectory: string;
|
|
18
|
-
parameters: Record<string, string | boolean | Record<string, string
|
|
18
|
+
parameters: Record<string, string | boolean | Record<string, string> | Array<Record<string, string>>>;
|
|
19
19
|
dependencies?: RiffRaffDeploymentName[];
|
|
20
20
|
actions?: string[];
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/experimental/riff-raff-yaml-file/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,6BAA6B,GAAG,OAAO,EAAE,CAAC;AAEtD,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7B,WAAW,EAAE,GAAG,CAAC,sBAAsB,EA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AAM,GAAG,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IACtG,YAAY,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,KAAK,EAAE,uBAAuB,CAAC;CAChC;AASD,MAAM,MAAM,gBAAgB,GAAG,MAAM,CACnC,SAAS,EACT,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,6BAA6B,CAAC,CAAC,CAAC,CAClF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/experimental/riff-raff-yaml-file/types.ts"],"names":[],"mappings":"","sourcesContent":["// type aliases to, hopefully, improve readability\nimport type { GuStack } from \"../../constructs/core\";\n\nexport type ClassName = string;\nexport type StackTag = string;\nexport type StageTag = string;\nexport type Region = string;\nexport type CdkStacksDifferingOnlyByStage = GuStack[];\n\nexport interface RiffRaffYaml {\n allowedStages: Set<StageTag>;\n deployments: Map<RiffRaffDeploymentName, RiffRaffDeploymentProps>;\n}\n\nexport type RiffRaffDeploymentName = string;\n\nexport interface RiffRaffDeploymentProps {\n type: string;\n regions: Set<Region>;\n stacks: Set<StackTag>;\n app: string;\n contentDirectory: string;\n parameters: Record<string, string | boolean | Record<string, string
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/experimental/riff-raff-yaml-file/types.ts"],"names":[],"mappings":"","sourcesContent":["// type aliases to, hopefully, improve readability\nimport type { GuStack } from \"../../constructs/core\";\n\nexport type ClassName = string;\nexport type StackTag = string;\nexport type StageTag = string;\nexport type Region = string;\nexport type CdkStacksDifferingOnlyByStage = GuStack[];\n\nexport interface RiffRaffYaml {\n allowedStages: Set<StageTag>;\n deployments: Map<RiffRaffDeploymentName, RiffRaffDeploymentProps>;\n}\n\nexport type RiffRaffDeploymentName = string;\n\nexport interface RiffRaffDeploymentProps {\n type: string;\n regions: Set<Region>;\n stacks: Set<StackTag>;\n app: string;\n contentDirectory: string;\n parameters: Record<string, string | boolean | Record<string, string> | Array<Record<string, string>>>;\n dependencies?: RiffRaffDeploymentName[];\n actions?: string[];\n}\n\nexport interface RiffRaffDeployment {\n name: RiffRaffDeploymentName;\n props: RiffRaffDeploymentProps;\n}\n\n/*\n The aim here is to produce an identity of a `GuStack` as a composite of:\n - Class name\n - Stack tag\n - Region\n Finally, group by stage to help form the `templateStagePaths` property for the `cloud-formation` deployment type in `riff-raff.yaml`.\n */\nexport type GroupedCdkStacks = Record<\n ClassName,\n Record<StackTag, Record<Region, Record<StageTag, CdkStacksDifferingOnlyByStage>>>\n>;\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guardian/cdk",
|
|
3
3
|
"description": "Generic Guardian flavoured AWS CDK components",
|
|
4
|
-
"version": "49.0.
|
|
4
|
+
"version": "49.1.0-beta.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/yargs": "^17.0.17",
|
|
40
40
|
"aws-cdk": "2.54.0",
|
|
41
41
|
"cz-conventional-changelog": "^3.3.0",
|
|
42
|
-
"eslint": "^8.
|
|
42
|
+
"eslint": "^8.29.0",
|
|
43
43
|
"eslint-plugin-custom-rules": "file:tools/eslint",
|
|
44
44
|
"gh-pages": "^4.0.0",
|
|
45
45
|
"jest": "^29.3.1",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"serve": "^14.1.2",
|
|
49
49
|
"ts-jest": "^29.0.3",
|
|
50
50
|
"ts-node": "^10.9.1",
|
|
51
|
-
"typedoc": "^0.23.
|
|
51
|
+
"typedoc": "^0.23.22",
|
|
52
52
|
"typescript": "~4.9.3"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|