-
Notifications
You must be signed in to change notification settings - Fork 294
/
.projenrc.ts
150 lines (134 loc) · 3.75 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
147
148
149
150
import * as fs from 'fs';
import { Cdk8sTeamTypeScriptProject } from '@cdk8s/projen-common';
import { JobPermission } from 'projen/lib/github/workflows-model';
const SPEC_VERSION = fs.readFileSync('src/latest-k8s-version.txt', 'utf-8');
// the latest version of k8s we support
const LATEST_SUPPORTED_K8S_VERSION = Number(SPEC_VERSION);
const mainBranch = 'master';
const project = new Cdk8sTeamTypeScriptProject({
name: 'root',
repoName: 'cdk8s',
sampleCode: false,
defaultReleaseBranch: mainBranch,
pullRequestTemplate: false,
release: false,
devDeps: [
'@cdk8s/projen-common',
'@types/jest',
'@types/node',
'cdk8s',
'cdk8s-cli',
'constructs',
'lerna',
'semver',
'ts-jest',
'typescript',
'projen',
],
projenrcTs: true,
githubOptions: {
mergify: false,
},
});
for (let i = 0; i < 3; i++) {
project.addDevDeps(`cdk8s-plus-${LATEST_SUPPORTED_K8S_VERSION - i}`);
}
project.gitignore.exclude('.vscode/');
project.gitignore.addPatterns('*.js');
project.gitignore.addPatterns('*.d.ts');
project.gitignore.addPatterns('dist/');
// enable mono-repo
project.package.addField('private', true);
project.package.addField('workspaces', {
packages: [],
});
// override the default test task to run test across the repo
project.testTask.reset('lerna run test -- -u');
project.tasks.removeTask('test:watch');
project.tasks.removeTask('test:update');
project.tasks.removeTask('test:compile');
// no package task is needed
project.packageTask.reset();
project.package.addPackageResolutions(
// Pin version of @types/responselike and got, see: https://github.com/sindresorhus/got/issues/2129
'@types/[email protected]',
);
// construct the build task
project.compileTask.exec('lerna run build');
// deploy website
const workflow = project.github!.addWorkflow('website');
workflow.on({ push: { branches: [mainBranch] } });
workflow.addJobs({
deploy: {
permissions: {
contents: JobPermission.WRITE,
},
runsOn: ['ubuntu-latest'],
steps: [
{
name: 'Checkout sources',
uses: 'actions/checkout@v2',
},
{
name: 'Setup Node.js',
uses: 'actions/setup-node@v2',
},
{
name: 'Setup Hugo',
uses: 'peaceiris/actions-hugo@v2',
with: {
'hugo-version': '0.68.3',
'extended': true,
},
},
{
name: 'Setup Python',
uses: 'actions/setup-python@v2',
with: {
'python-version': '3.x',
'architecture': 'x64',
},
},
{
name: 'Install dependencies',
run: 'yarn install --frozen-lockfile',
},
{
name: 'Build Website',
run: [
'cd website',
'./build.sh',
].join('\n'),
},
{
name: 'Build Docs Site',
run: './docs/build.sh website/public/docs',
},
{
name: 'Deploy',
uses: 'peaceiris/actions-gh-pages@v3',
with: {
github_token: '${{ secrets.GITHUB_TOKEN }}',
publish_dir: './website/public',
},
},
],
},
});
// The API reference is generated when the website is built and released
// on the main branch, so the files should not be committed to the repo.
// See docs/build.sh.
let packages = ['cdk8s'];
for (let i = 0; i < 3; i++) {
packages.push(`cdk8s-plus-${LATEST_SUPPORTED_K8S_VERSION - i}`);
}
for (const pkg of packages) {
for (const language of ['java', 'typescript', 'python']) {
project.gitignore.exclude(`/docs/reference/${pkg}/${language}.md`);
}
}
// Projen task to update references to old versions of cdk8s-plus
const versionTaskObject = project.addTask('rotate-cdk8s-plus');
versionTaskObject.exec('ts-node src/rotate-cdk8s-plus.ts ' + SPEC_VERSION);
project.synth();