-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.projenrc.ts
97 lines (86 loc) · 2.77 KB
/
.projenrc.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import * as path from "path";
import { javascript, JsonPatch } from "projen";
import { AwsCdkConstructLibrary } from "projen/lib/awscdk";
import {
DataDogMonitorSchemaGenerator,
DataDogDashboardSchemaGenerator,
DataDogSLOSchemaGenerator,
PATCHERS,
} from "./projenrc";
const project = new AwsCdkConstructLibrary({
author: "Gabriel Fürstenheim",
cdkVersion: "2.92.0",
defaultReleaseBranch: "master",
name: "@goodnotes-oss/cdk-datadog-resources",
repositoryUrl: "https://github.com/GoodNotes/cdk-datadog-resources.git",
projenrcTs: true,
/* AwsCdkConstructLibraryOptions */
constructsVersion: "10.2.69",
jsiiVersion: "~5.0.0",
bundledDeps: ["camelcase-keys", "decamelize"],
devDeps: [
"json-schema-to-typescript",
],
npmAccess: javascript.NpmAccess.PUBLIC,
gitignore: ["cdk.out/"],
prettier: true,
autoApproveOptions: {
allowedUsernames: ["gn-devops-ci"],
// must be different Token from PROJEN_GITHUB_TOKEN to approve PR
secret: "GITHUB_TOKEN",
},
autoApproveUpgrades: true,
});
// JSII sets this to `false` so we need to be compatible
const tsConfigDev = project.tryFindObjectFile("tsconfig.dev.json");
tsConfigDev?.patch(
JsonPatch.replace("/compilerOptions/esModuleInterop", false),
);
// docgen is currently the only task of post-compile and it fails for aws-cdk-lib in jsii
// https://github.com/cdklabs/jsii-docgen/issues/1122
const docgen = project.tasks.tryFind("docgen");
if (docgen) docgen.reset();
const schemaDir = "cf-schema";
const monitorProps = new DataDogMonitorSchemaGenerator(
project,
path.join(project.srcdir, "monitors", "datadog-monitor-schema.generated.ts"),
{
filePath: path.join(schemaDir, "datadog-monitor-4.6.0.json"),
},
);
const dashboardProps = new DataDogDashboardSchemaGenerator(
project,
path.join(
project.srcdir,
"dashboards",
"datadog-dashboard-schema.generated.ts",
),
{
filePath: path.join(schemaDir, "datadog-dashboard-2.1.0.json"),
},
);
const sloProps = new DataDogSLOSchemaGenerator(
project,
path.join(project.srcdir, "slos", "datadog-slo-schema.generated.ts"),
{
filePath: path.join(schemaDir, "datadog-slo-1.1.0.json"),
},
);
project.addTask("parse-json", {
exec: "ts-node projenrc/parse-json.ts",
description:
"Parse a DataDog json file into DataDog Typescript compatible json",
receiveArgs: true,
});
// call all Json Schema generators async, then synth
void Promise.all([
monitorProps.generate("DatadogMonitorProps", PATCHERS.readonlyFields),
dashboardProps.generate("DatadogDashboardProps", PATCHERS.readonlyFields),
sloProps.generate("DatadogSLOProps", PATCHERS.readonlyFields),
]).then(() => {
project.synth();
});