This repository was archived by the owner on Jul 16, 2024. It is now read-only.
generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy path.projenrc.js
More file actions
225 lines (188 loc) · 6.1 KB
/
.projenrc.js
File metadata and controls
225 lines (188 loc) · 6.1 KB
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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
const { basename, join, dirname, relative } = require('path');
const fs = require('fs');
const glob = require('glob');
const { awscdk } = require('projen');
const CDK_VERSION = '2.84.0';
const CDK_CONSTRUCTS_VERSION = '10.2.55';
const project = new awscdk.AwsCdkConstructLibrary({
majorVersion: 2,
authorName: 'Amazon Web Services',
authorUrl: 'https://aws.amazon.com',
authorOrganization: true,
homepage: 'https://aws-samples.github.io/aws-analytics-reference-architecture/',
copyrightPeriod: `2021-${new Date().getFullYear()}`,
copyrightOwner: 'Amazon.com, Inc. or its affiliates. All Rights Reserved.',
keywords: ['aws', 'constructs', 'cdk', 'analytics'],
cdkVersion: CDK_VERSION,
jsiiVersion: '~5.0.0',
constructsVersion: CDK_CONSTRUCTS_VERSION,
defaultReleaseBranch: 'main',
license: 'MIT-0',
name: 'aws-analytics-reference-architecture',
repositoryUrl: 'https://github.com/aws-samples/aws-analytics-reference-architecture.git',
repositoryDirectory: 'core',
workflow: false,
buildWorkflow: false,
release: true,
depsUpgrade: true,
stale: false,
pullRequestTemplate: false,
cdkVersionPinning: true,
githubOptions: {
pullRequestLint: false,
},
//workflowContainerImage: 'jsii/superchain:1-buster-slim',
deps: [
'@exodus/schemasafe',
`@aws-cdk/aws-redshift-alpha@${CDK_VERSION}-alpha.0`,
`@aws-cdk/aws-glue-alpha@${CDK_VERSION}-alpha.0`,
],
devDeps: [
'@types/js-yaml',
'@types/jest',
'esbuild',
'cdk-nag@^2.0.0',
'constructs',
'aws-cdk-lib',
`aws-cdk@${CDK_VERSION}`,
`cdk-assets@${CDK_VERSION}`,
`@aws-cdk/cloudformation-diff@${CDK_VERSION}`,
'jest-runner-groups',
'promptly',
'proxy-agent',
'glob',
'@types/prettier@2.6.0',
`@aws-cdk/aws-redshift-alpha@${CDK_VERSION}-alpha.0`,
`@aws-cdk/aws-glue-alpha@${CDK_VERSION}-alpha.0`,
`@aws-cdk/cli-lib-alpha@${CDK_VERSION}-alpha.0`,
'@aws-cdk/lambda-layer-kubectl-v22',
'@aws-cdk/lambda-layer-kubectl-v25',
],
peerDeps: [
`@aws-cdk/aws-redshift-alpha@${CDK_VERSION}-alpha.0`,
`@aws-cdk/aws-glue-alpha@${CDK_VERSION}-alpha.0`,
],
jestOptions: {
jestConfig: {
runner: 'groups',
},
},
bundledDeps: [
'js-yaml',
'uuid',
'aws-sdk',
'@exodus/schemasafe',
'simple-base',
'@aws-crypto/sha256-browser',
'@aws-sdk/client-secrets-manager',
'@aws-sdk/credential-provider-node',
'@aws-sdk/node-http-handler',
'@aws-sdk/protocol-http',
'@aws-sdk/signature-v4',
],
python: {
distName: 'aws_analytics_reference_architecture',
module: 'aws_analytics_reference_architecture',
},
tsconfig: {
compilerOptions: {
resolveJsonModule: true,
esModuleInterop: true,
},
include: ['src/**/*.json'],
},
stability: 'experimental',
});
project.testTask.reset('jest --group=unit');
project.testTask.spawn('eslint');
project.addTask('test:best-practice', {
exec: 'jest --group=best-practice',
});
project.addTask('test:unit', {
exec: 'jest --group=unit',
});
project.addTask('test:integ', {
exec: 'jest --group=integ',
});
const testDeploy = project.addTask('test:deploy', {
exec: 'cdk --version && cdk deploy --app=./lib/integ.default.js',
});
testDeploy.prependExec('npx projen build');
project.packageTask.spawn(project.tasks.tryFind('package-all'));
project.addTask('test:destroy', {
exec: 'cdk destroy --app=./lib/integ.default.js',
});
project.addDevDeps('glob');
/**
* Task to copy `resources` directories from `src` to `lib`
*/
const copyResourcesToLibTask = project.addTask('copy-resources', {
description: 'Copy all resources directories from src to lib',
});
for (const from of glob.sync('src/**/resources')) {
const to = dirname(from.replace('src', 'lib'));
const cpCommand = `rsync -avr --exclude '*.ts' --exclude '*.js' ${from} ${to}`;
copyResourcesToLibTask.exec(cpCommand);
}
const workaroundCommand = `perl -i -pe 's/flyway-all.jar//g' lib/db-schema-manager/resources/flyway-lambda/.gitignore`;
copyResourcesToLibTask.exec(workaroundCommand);
/**
* Task to pip install all Python Lambda functions in lib folder
*/
const pipInstallTask = project.addTask('pip-install', {
description: 'pip install all folders in lib that has requirements.txt',
});
for (const dirPath of findAllPythonLambdaDir('src')) {
// Assume that all folders with 'requirements.txt' have been copied to lib
// by the task 'copy-resources'
const dirPathInLib = dirPath.replace('src', 'lib');
const target = dirname(dirPathInLib);
const pipCmd = `pip3 install -r ${dirPathInLib} --target ${target} --upgrade`;
pipInstallTask.exec(pipCmd);
}
/**
* Task to build java lambda jar with gradle
*/
const gradleBuildTask = project.addTask('gradle-build', {
description: './gradlew shadowJar all folders in lib that has requirements.txt',
});
for (const gradlePath of findAllGradleLambdaDir('src')) {
console.log('loop over gradle dir');
const dirPath = dirname(gradlePath);
const gradleCmd = `cd ${dirPath} && ./gradlew shadowJar && cp build/libs/*.jar ./ && rm -rf build 2> /dev/null`;
gradleBuildTask.exec(gradleCmd);
}
/**
* Run `copy-resources` and `pip-install` as part of compile
*/
project.compileTask.exec('npx projen gradle-build');
project.compileTask.exec('npx projen copy-resources');
project.compileTask.exec('npx projen pip-install');
/**
* Find all directory that has a Python package.
* Assume that they have requirements.txt
*
* @param rootDir Root directory to begin finding
* @returns Array of directory paths
*/
function findAllPythonLambdaDir(rootDir) {
return glob.sync(`${rootDir}/**/requirements.txt`).map((pathWithReq) => {
return pathWithReq;
});
}
/**
* Find all directory that has a gradle package.
* Assume that they have build.gradle
*
* @param rootDir Root directory to begin finding
* @returns Array of directory paths
*/
function findAllGradleLambdaDir(rootDir) {
console.log('findAllGradleLambdaDir');
return glob.sync(`${rootDir}/**/build.gradle`).map((pathWithGradle) => {
return pathWithGradle;
});
}
project.synth();