-
Notifications
You must be signed in to change notification settings - Fork 4
/
.projenrc.ts
146 lines (132 loc) · 4.66 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { JsiiProject } from "projen/lib/cdk";
import { NpmAccess, UpgradeDependenciesSchedule } from "projen/lib/javascript";
import { AutoApprove } from "./projenrc/auto-approve";
import { Automerge } from "./projenrc/automerge";
import { CustomizedLicense } from "./projenrc/customized-license";
import { UpgradeCDKTF } from "./projenrc/upgrade-cdktf";
const name = "projen-cdktf-hybrid-construct";
const githubActionPinnedVersions = {
"actions/checkout": "692973e3d937129bcbf40652eb9f2f61becf3332", // v4.1.7
"actions/download-artifact": "fa0a91b85d4f404e444e00e005971372dc801d16", // v4.1.8
"actions/github-script": "60a0d83039c74a4aee543508d2ffcb1c3799cdea", // v7.0.1
"actions/setup-node": "1e60f620b9541d16bece96c5465dc8ee9832be0b", // v4.0.3
"actions/upload-artifact": "89ef406dd8d7e03cfd12d9e0a4a378f454709029", // v4.3.5
"amannn/action-semantic-pull-request":
"0723387faaf9b38adef4775cd42cfd5155ed6017", // v5.5.3
"hashicorp/setup-copywrite": "32638da2d4e81d56a0764aa1547882fc4d209636", // v1.1.3
"peter-evans/create-pull-request": "c5a7806660adbe173f04e3e038b0ccdcd758773c", // v6.1.0
};
const project = new JsiiProject({
defaultReleaseBranch: "main",
name,
repositoryUrl: `https://github.com/cdktf/${name}.git`,
author: "HashiCorp",
authorAddress: "https://hashicorp.com",
authorOrganization: true,
packageName: name,
prettier: true,
projenrcTs: true,
description:
"Projen template for CDKTF Constructs that should also be used as Terraform Modules.",
licensed: false,
release: true,
releaseToNpm: true,
npmAccess: NpmAccess.PUBLIC,
mergify: false,
depsUpgradeOptions: {
workflowOptions: {
labels: ["auto-approve", "automerge", "dependencies"],
schedule: UpgradeDependenciesSchedule.WEEKLY,
},
},
gitignore: [".idea/"],
workflowGitIdentity: {
name: "team-tf-cdk",
email: "github-team-tf-cdk@hashicorp.com",
},
jsiiVersion: "~5.4.0",
typescriptVersion: "~5.4.0", // should always be the same major/minor as JSII
pullRequestTemplate: false,
});
project.tsconfig?.exclude?.push("src/exampleCode/**");
project.tsconfig?.exclude?.push("example/**");
project.tsconfig?.exclude?.push("examples/**");
project.addPeerDeps("projen@>= 0.85.0", "constructs@^10.4.2");
project.addBundledDeps("change-case");
project.addDevDeps(
"fs-extra",
"glob",
"projen@^0.85.0",
"@types/fs-extra",
"@types/glob",
"@types/change-case",
"ts-node@10.9.1",
"comment-json"
);
new CustomizedLicense(project);
new AutoApprove(project);
new Automerge(project);
new UpgradeCDKTF(project);
project.addTask("buildExample", {
exec: "yarn buildExample:hybrid && yarn buildExample:terraform",
});
project.addTask("buildExample:hybrid", {
exec: "git clean -dfx . && rm -rf lib modules src terraform construct-examples && yarn && yarn projen && yarn && yarn build",
cwd: "./examples/hybrid-module",
});
project.addTask("buildExample:terraform", {
exec: "git clean -dfx . && rm -rf lib modules src terraform construct-examples && yarn && yarn projen && yarn && yarn build",
cwd: "./examples/terraform-module",
});
project.addTask("upgrade:hybrid", {
exec: "yarn projen upgrade",
cwd: "./examples/hybrid-module",
});
project.addTask("upgrade:terraform", {
exec: "yarn projen upgrade",
cwd: "./examples/terraform-module",
});
project.removeTask("post-upgrade");
const upgradeTask = project.addTask("post-upgrade", {
description: "Runs after upgrading dependencies",
exec: "yarn compile",
});
upgradeTask.exec("yarn projen upgrade:hybrid");
upgradeTask.exec("yarn projen upgrade:terraform");
project.testTask.exec("yarn buildExample");
project.addPackageIgnore("scripts");
project.addPackageIgnore("examples");
project.addPackageIgnore("projenrc");
project.addPackageIgnore("/.projenrc.ts");
project.addPackageIgnore(".copywrite.hcl");
// Run copywrite tool to add copyright headers to all files
project.buildWorkflow?.addPostBuildSteps(
{
name: "Setup Copywrite tool",
uses: "hashicorp/setup-copywrite",
},
{ name: "Add headers using Copywrite tool", run: "copywrite headers" }
);
// Use pinned versions of github actions
Object.entries(githubActionPinnedVersions).forEach(([action, sha]) => {
project.github?.actions.set(action, `${action}@${sha}`);
});
const releaseWorkflow = project.tryFindObjectFile(
".github/workflows/release.yml"
);
releaseWorkflow?.addOverride("on.push", {
branches: ["main"],
"paths-ignore": [
// don't do a release if the change was only to these files/directories
"examples/**",
".github/ISSUE_TEMPLATE/**",
".github/CODEOWNERS",
".github/dependabot.yml",
".github/**/*.md",
],
});
project.synth();