forked from projen/projen
/
.projenrc.js
226 lines (198 loc) · 5.68 KB
/
.projenrc.js
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
const { cdk, github, JsonFile, TextFile } = require('./lib');
const { workflows } = require('./lib/github');
const project = new cdk.JsiiProject({
name: 'projen',
description: 'CDK for software projects',
repository: 'https://github.com/projen/projen.git',
authorName: 'Elad Ben-Israel',
authorEmail: 'benisrae@amazon.com',
stability: 'experimental',
keywords: [
'scaffolding',
'cicd',
'project',
'management',
'generator',
'cdk',
],
pullRequestTemplateContents: [
'---',
'By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.',
],
bundledDeps: [
'conventional-changelog-config-spec',
'yaml',
'fs-extra',
'yargs',
'case',
'glob@^7',
'semver',
'chalk',
'@iarna/toml',
'xmlbuilder2',
'ini',
'shx',
],
devDeps: [
'@types/conventional-changelog-config-spec',
'@types/fs-extra@^8',
'@types/yargs',
'@types/glob',
'@types/semver',
'@types/ini',
'markmac',
'all-contributors-cli',
],
projenDevDependency: false, // because I am projen
releaseToNpm: true,
minNodeVersion: '12.7.0',
workflowNodeVersion: '12.22.0', // required by @typescript-eslint/eslint-plugin@5.5.0
codeCov: true,
defaultReleaseBranch: 'main',
gitpod: true,
devContainer: true,
// since this is projen, we need to always compile before we run
projenCommand: '/bin/bash ./projen.bash',
// cli tests need projen to be compiled
compileBeforeTest: true,
// makes it very hard to iterate with jest --watch
jestOptions: {
coverageText: false,
},
publishToMaven: {
javaPackage: 'io.github.cdklabs.projen',
mavenGroupId: 'io.github.cdklabs',
mavenArtifactId: 'projen',
mavenEndpoint: 'https://s01.oss.sonatype.org',
},
publishToPypi: {
distName: 'projen',
module: 'projen',
},
releaseFailureIssue: true,
// Disabled due to cycles between main module and submodules
// publishToGo: {
// moduleName: 'github.com/projen/projen-go',
// },
autoApproveUpgrades: true,
autoApproveOptions: { allowedUsernames: ['cdklabs-automation'], secret: 'GITHUB_TOKEN' },
depsUpgradeOptions: {
workflowOptions: {
secret: 'PROJEN_GITHUB_TOKEN',
},
},
});
// this script is what we use as the projen command in this project
// it will compile the project if needed and then run the cli.
new TextFile(project, 'projen.bash', {
lines: [
'#!/bin/bash',
`# ${TextFile.PROJEN_MARKER}`,
'set -euo pipefail',
'if [ ! -f lib/cli/index.js ]; then',
' echo "bootstrapping..."',
' npx jsii --silence-warnings=reserved-word --no-fix-peer-dependencies',
'fi',
'exec bin/projen $@',
],
});
project.npmignore.exclude('/projen.bash');
project.addExcludeFromCleanup('test/**'); // because snapshots include the projen marker...
project.gitignore.include('templates/**');
// expand markdown macros in readme
const macros = project.addTask('readme-macros');
macros.exec('mv README.md README.md.bak');
macros.exec('cat README.md.bak | markmac > README.md');
macros.exec('rm README.md.bak');
project.postCompileTask.spawn(macros);
new JsonFile(project, '.markdownlint.json', {
obj: {
'default': true,
'commands-show-output': false,
'line-length': {
line_length: 200,
},
},
});
project.npmignore.exclude('/.markdownlint.json');
project.vscode.launchConfiguration.addConfiguration({
type: 'pwa-node',
request: 'launch',
name: 'projen CLI',
skipFiles: [
'<node_internals>/**',
],
program: '${workspaceFolder}/lib/cli/index.js',
outFiles: [
'${workspaceFolder}/lib/**/*.js',
],
});
project.github.mergify.addRule({
name: 'Label core contributions',
actions: {
label: {
add: ['contribution/core'],
},
},
conditions: [
'author~=^(eladb|Chriscbr)$',
'label!=contribution/core',
],
});
project.gitpod.addCustomTask({
name: 'Setup',
init: 'yarn install',
prebuild: 'bash ./projen.bash',
command: 'npx projen build',
});
const setup = project.addTask('devenv:setup');
setup.exec('yarn install');
setup.spawn(project.buildTask);
project.devContainer.addTasks(setup);
project.npmignore.exclude('/.devcontainer.json');
project.addTask('contributors:update', {
exec: 'all-contributors check | grep "Missing contributors" -A 1 | tail -n1 | sed -e "s/,//g" | xargs -n1 | grep -v "\[bot\]" | xargs -n1 -I{} all-contributors add {} code',
});
project.npmignore.exclude('/.all-contributorsrc');
project.npmignore.exclude('/scripts/');
project.npmignore.exclude('/ARCHITECTURE.md');
project.npmignore.exclude('/CODE_OF_CONDUCT.md');
project.npmignore.exclude('/CONTRIBUTING.md');
project.npmignore.exclude('/VISION.md');
project.npmignore.exclude('/SECURITY.md');
project.npmignore.exclude('/.gitattributes');
project.npmignore.exclude('/.gitpod.yml');
// integ test
const pythonCompatTask = project.addTask('integ:python-compat', {
exec: 'scripts/python-compat.sh',
description: 'Checks that projen\'s submodule structure does not cause import failures for python. Expects python to be installed and projen to be fully built.',
});
const integTask = project.addTask('integ');
integTask.spawn(project.buildTask);
integTask.spawn(pythonCompatTask);
new github.TaskWorkflow(project.github, {
name: 'integ',
jobId: 'integ',
triggers: {
pullRequest: {},
workflowDispatch: {},
},
env: {
CI: 'true',
},
permissions: {
contents: workflows.JobPermission.READ,
},
preBuildSteps: [
...project.installWorkflowSteps, // install dependencies for projen
{
name: 'Set up Python 3.x',
uses: 'actions/setup-python@v2',
with: {
'python-version': '3.x',
},
},
],
task: integTask,
});
project.synth();