-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy path.projenrc.ts
More file actions
1789 lines (1633 loc) · 52.7 KB
/
.projenrc.ts
File metadata and controls
1789 lines (1633 loc) · 52.7 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import * as path from 'path';
import { yarn } from 'cdklabs-projen-project-types';
import { TypeScriptWorkspace, type TypeScriptWorkspaceOptions } from 'cdklabs-projen-project-types/lib/yarn';
import * as pj from 'projen';
import { AdcPublishing } from './projenrc/adc-publishing';
import { BootstrapTemplateProtection } from './projenrc/bootstrap-template-protection';
import { BundleCli } from './projenrc/bundle';
import { CdkCliIntegTestsWorkflow, fixupTestTask } from './projenrc/cdk-cli-integ-tests';
import { CodeCovWorkflow } from './projenrc/codecov';
import { configureEslint } from './projenrc/eslint';
import { IssueLabeler } from './projenrc/issue-labeler';
import { IssueRegressionLabeler } from './projenrc/issue-regression-labeler';
import { JsiiBuild } from './projenrc/jsii';
import { LargePrChecker } from './projenrc/large-pr-checker';
import { PrLabeler } from './projenrc/pr-labeler';
import { RecordPublishingTimestamp } from './projenrc/record-publishing-timestamp';
import { DocType, S3DocsPublishing } from './projenrc/s3-docs-publishing';
import { SelfMutationOnForks } from './projenrc/SelfMutationOnForks';
import { TypecheckTests } from './projenrc/TypecheckTests';
// #region shared config
const TYPESCRIPT_VERSION = '5.9';
/**
* Global note on customizeReference
* ---------------------------------
*
* All packages references using `customizeReference()` should have an `^0.0.0`
* dependency in `package.json` regardless of what the argument to
* `customizeReference()` is. This because unbump will always set the range
* specified to that value, and if it used to be something else then we will
* introduce a git diff that stops the release. Do not worry, the bumped version
* will have the correct range character.
*
* When adding a fresh package, projen sometimes inserts `"0.0.0"` there, if
* that happens you need to edit `package.json` once by hand.
*/
/**
* When adding an SDK dependency, use this function
*
* It forces the package.json to contain `@^3`. This has 2 benefits:
*
* - If we don't force that, projen will make it contain something like
* `^3.282.74` and update that version every couple of days.
* By forcing a large range, we provide ample opportunity for our library user's
* package manager to deduplicate whatever version of SDKv3 the consumer is
* using with the version that our library expects.
* - The above is only necessary for libraries, but we use this for CLIs as well,
* so that all SDK packages have the same specifier. This increases the chances of
* `yarn up` updating all packages at the same time to the same version; otherwise,
* if one SDK library is at `3.1028.0` and the other at `3.1033.0` (or whatever),
* they sometimes bring different versions of Smithy packages which then take up
* unnecessary space and also conflict with each other.
*/
function sdkDep(name: string) {
if (!name.startsWith('@aws-sdk/')) {
throw new Error('Must be an SDK package');
}
return `${name}@^3`;
}
/**
* Same as `sdkDepForLib`, but for smithy
*/
function smithyDep(name: string) {
if (!name.startsWith('@smithy/')) {
throw new Error('Must be a Smithy package');
}
return `${name}@^4`;
}
const BUNDLED_LICENSES = [
'Apache-2.0',
'MIT',
'BSD-3-Clause',
'ISC',
'BSD-2-Clause',
'0BSD',
'MIT OR Apache-2.0',
];
/**
* Configures a Eslint, which is a complex setup.
*
* We also need to override the built-in prettier dependency to prettier@2, because
* Jest < 30 can only work with prettier 2 (https://github.com/jestjs/jest/issues/14305)
* and 30 is not stable yet.
*/
function configureProject<A extends pj.typescript.TypeScriptProject>(x: A): A {
// currently supported min node version
x.package.addEngine('node', '>= 18.0.0');
x.addDevDeps(
'jest-junit@^16',
'prettier@^2.8',
);
configureEslint(x);
x.npmignore?.addPatterns(
// don't inlcude config files
'.eslintrc.js',
// As a rule we don't include .ts sources in the NPM package
'*.ts',
'!*.d.ts',
// Never include the build-tools directory
'build-tools',
);
return x;
}
const POWERFUL_RUNNER = 'aws-cdk_ubuntu-latest_16-core';
// Ignore patterns that apply both to the Toolkit CLI and Library
const ADDITIONAL_CLI_IGNORE_PATTERNS = [
'db.json.gz',
'.init-version.json',
'index_bg.wasm',
'build-info.json',
'.recommended-feature-flags.json',
'synth.lock',
];
const defaultTsOptions: NonNullable<TypeScriptWorkspaceOptions['tsconfig']>['compilerOptions'] = {
target: 'ES2020',
module: 'commonjs',
lib: ['es2020'],
incremental: true,
esModuleInterop: false,
skipLibCheck: true,
isolatedModules: true,
};
/**
* Shared jest config
*
* Must be a function because these structures will be mutated in-place inside projen
*/
function sharedJestConfig(): pj.javascript.JestConfigOptions {
return {
moduleFileExtensions: [
// .ts first to prefer a ts over a js if present
'ts',
'js',
],
maxWorkers: '80%',
testEnvironment: 'node',
coverageThreshold: {
statements: 80,
branches: 80,
functions: 80,
lines: 80,
},
collectCoverage: true,
coverageReporters: [
'text-summary', // for console summary
'cobertura', // for codecov. see https://docs.codecov.com/docs/code-coverage-with-javascript
['html', { subdir: 'html-report' }] as any, // for local deep dive
],
testMatch: ['<rootDir>/test/**/?(*.)+(test).ts'],
coveragePathIgnorePatterns: ['\\.generated\\.[jt]s$', '<rootDir>/test/', '.warnings.jsii.js$', '/node_modules/'],
reporters: ['default', ['jest-junit', { suiteName: 'jest tests', outputDirectory: 'coverage' }]] as any,
// Randomize test order: this will catch tests that accidentally pass or
// fail because they rely on shared mutable state left by other tests
// (files on disk, global mocks, etc).
randomize: true,
};
}
/**
* Extend default jest options for a project
*/
function jestOptionsForProject(options: pj.javascript.JestOptions): pj.javascript.JestOptions {
const generic = genericCdkProps().jestOptions;
return {
...generic,
...options,
jestConfig: {
...generic.jestConfig,
...(options.jestConfig ?? {}),
coveragePathIgnorePatterns: [
...(generic.jestConfig?.coveragePathIgnorePatterns ?? []),
...(options.jestConfig?.coveragePathIgnorePatterns ?? []),
],
coverageThreshold: {
...(generic.jestConfig?.coverageThreshold ?? {}),
...(options.jestConfig?.coverageThreshold ?? {}),
},
},
};
}
function transitiveFeaturesAndFixes(thisPkg: string, depPkgs: string[]) {
return pj.ReleasableCommits.featuresAndFixes([
'.',
...depPkgs.map(p => path.relative(`packages/${thisPkg}`, `packages/${p}`)),
].join(' '));
}
/**
* Returns all packages that are considered part of the toolkit,
* as relative paths from the provided package.
*/
function transitiveToolkitPackages(thisPkg: string) {
const toolkitPackages = [
'aws-cdk',
'@aws-cdk/cloud-assembly-schema',
'@aws-cdk/cloud-assembly-api',
'@aws-cdk/cloudformation-diff',
'@aws-cdk/toolkit-lib',
];
return transitiveFeaturesAndFixes(thisPkg, toolkitPackages.filter(name => name !== thisPkg));
}
// #endregion
//////////////////////////////////////////////////////////////////////
// #region Monorepo
const repoProject = new yarn.Monorepo({
projenrcTs: true,
name: 'aws-cdk-cli',
description: "Monorepo for the AWS CDK's CLI",
repository: 'https://github.com/aws/aws-cdk-cli',
defaultReleaseBranch: 'main',
typescriptVersion: TYPESCRIPT_VERSION,
devDeps: [
'cdklabs-projen-project-types',
'fast-glob',
'semver',
sdkDep('@aws-sdk/client-s3'),
sdkDep('@aws-sdk/credential-providers'),
sdkDep('@aws-sdk/lib-storage'),
'tsx',
'jest',
'@types/jest',
'eslint-config-prettier',
'eslint-plugin-prettier',
],
vscodeWorkspace: true,
vscodeWorkspaceOptions: {
includeRootWorkspace: true,
},
nx: true,
buildWithNx: true,
yarnBerry: true,
consistentVersions: [
'typescript',
'eslint',
'eslint-import-resolver-typescript',
'eslint-plugin-import',
'eslint-plugin-jest',
'eslint-plugin-jsdoc',
'@cdklabs/eslint-plugin',
'@stylistic/eslint-plugin',
'@typescript-eslint/eslint-plugin',
'@typescript-eslint/parser',
'prettier',
'eslint-config-prettier',
'eslint-plugin-prettier',
'jest',
'jest-junit',
'@types/jest',
'projen',
],
eslintOptions: {
dirs: ['lib'],
devdirs: ['test'],
},
workflowNodeVersion: 'lts/*',
workflowRunsOn: [POWERFUL_RUNNER],
gitignore: ['.DS_Store', '.tools'],
autoApproveUpgrades: true,
autoApproveOptions: {
allowedUsernames: ['aws-cdk-automation', 'dependabot[bot]'],
},
release: true,
releaseOptions: {
publishToNpm: true,
releaseTrigger: pj.release.ReleaseTrigger.workflowDispatch(),
},
depsUpgradeOptions: {
cooldown: 3,
workflowOptions: {
schedule: pj.javascript.UpgradeDependenciesSchedule.WEEKLY,
},
},
githubOptions: {
projenCredentials: pj.github.GithubCredentials.fromPersonalAccessToken({
secret: 'PROJEN_GITHUB_TOKEN',
environment: 'automation',
}),
mergify: false,
mergeQueue: true,
mergeQueueOptions: {
autoQueueOptions: {
// Only autoqueue for PRs targeting the 'main' branch
targetBranches: ['main'],
},
},
pullRequestLint: true,
pullRequestLintOptions: {
contributorStatement: 'By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license',
contributorStatementOptions: {
exemptUsers: ['aws-cdk-automation', 'dependabot[bot]'],
},
semanticTitleOptions: {
types: ['feat', 'fix', 'chore', 'refactor', 'test', 'docs', 'revert'],
scopes: [], // actually set at the bottom of the file to be based on monorepo packages
},
},
},
pullRequestTemplateContents: [
'Fixes #',
'',
'### Checklist',
'- [ ] This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed',
' - Release notes for the new version:',
],
buildWorkflowOptions: {
preBuildSteps: [
// Need this for the init tests
{
name: 'Set git identity',
run: [
'git config --global user.name "aws-cdk-cli"',
'git config --global user.email "noreply@example.com"',
].join('\n'),
},
],
},
});
repoProject.tryFindObjectFile(`${repoProject.name}.code-workspace`)?.patch(
pj.JsonPatch.add('/settings/jest.jestCommandLine', 'npx jest'),
pj.JsonPatch.add('/settings/js~1ts.tsdk.path', '<root>/node_modules/typescript/lib'),
);
new AdcPublishing(repoProject);
new RecordPublishingTimestamp(repoProject);
new BootstrapTemplateProtection(repoProject);
new SelfMutationOnForks(repoProject, { environment: 'automation' });
repoProject.gitignore.addPatterns('.vscode/settings.json');
// Eslint for projen config
// @ts-ignore
repoProject.eslint = new pj.javascript.Eslint(repoProject, {
tsconfigPath: `./${repoProject.tsconfigDev.fileName}`,
dirs: [],
devdirs: ['projenrc', '.projenrc.ts'],
fileExtensions: ['.ts', '.tsx'],
lintProjenRc: false,
});
// always lint projen files as part of the build
if (repoProject.eslint?.eslintTask) {
repoProject.tasks.tryFind('build')?.spawn(repoProject.eslint?.eslintTask);
}
// always scan for git secrets before building
const gitSecretsScan = repoProject.addTask('git-secrets-scan', {
steps: [
{
exec: '/bin/bash ./projenrc/git-secrets-scan.sh',
},
],
});
repoProject.tasks.tryFind('build')!.spawn(gitSecretsScan);
const repo = configureProject(repoProject);
interface GenericProps {
private?: boolean;
}
/**
* Generic CDK props
*
* Must be a function because the structures of jestConfig will be mutated
* in-place inside projen
*/
function genericCdkProps(props: GenericProps = {}) {
return {
keywords: ['aws', 'cdk'],
homepage: 'https://github.com/aws/aws-cdk',
authorName: 'Amazon Web Services',
authorUrl: 'https://aws.amazon.com',
authorOrganization: true,
releasableCommits: pj.ReleasableCommits.featuresAndFixes('.'),
releaseEnvironment: 'releasing',
npmTrustedPublishing: true,
jestOptions: {
configFilePath: 'jest.config.json',
junitReporting: false,
coverageText: false,
jestConfig: sharedJestConfig(),
preserveDefaultReporters: false,
},
minNodeVersion: '20',
prettierOptions: {
settings: {
printWidth: 120,
singleQuote: true,
trailingComma: pj.javascript.TrailingComma.ALL,
},
},
tsconfig: {
compilerOptions: {
...defaultTsOptions,
},
},
typescriptVersion: TYPESCRIPT_VERSION,
checkLicenses: props.private ? undefined : {
allow: ['Apache-2.0', 'MIT', 'ISC', 'BSD-3-Clause', '0BSD'],
},
...props,
} satisfies Partial<yarn.TypeScriptWorkspaceOptions>;
}
// #endregion
//////////////////////////////////////////////////////////////////////
// #region @aws-cdk/cloud-assembly-schema
const cloudAssemblySchema = configureProject(
new yarn.TypeScriptWorkspace({
...genericCdkProps(),
parent: repo,
name: '@aws-cdk/cloud-assembly-schema',
description: 'Schema for the protocol between CDK framework and CDK CLI',
srcdir: 'lib',
bundledDeps: ['jsonschema@~1.4.1', 'semver'],
devDeps: ['@types/semver', 'mock-fs', 'typescript-json-schema', 'tsx'],
disableTsconfig: true,
jestOptions: jestOptionsForProject({
jestConfig: {
coverageThreshold: {
functions: 75,
},
},
}),
// Append a specific version string for testing
nextVersionCommand: 'tsx ../../../projenrc/next-version.ts majorFromRevision:schema/version.json maybeRc',
}),
);
fixupTestTask(cloudAssemblySchema);
new JsiiBuild(cloudAssemblySchema, {
docgen: false,
jsiiVersion: TYPESCRIPT_VERSION,
excludeTypescript: ['**/test/**/*.ts'],
publishToMaven: {
javaPackage: 'software.amazon.awscdk.cloudassembly.schema',
mavenArtifactId: 'cdk-cloud-assembly-schema',
mavenGroupId: 'software.amazon.awscdk',
mavenServerId: 'central-ossrh',
},
publishToNuget: {
dotNetNamespace: 'Amazon.CDK.CloudAssembly.Schema',
packageId: 'Amazon.CDK.CloudAssembly.Schema',
iconUrl: 'https://raw.githubusercontent.com/aws/aws-cdk/main/logo/default-256-dark.png',
},
publishToPypi: {
distName: 'aws-cdk.cloud-assembly-schema',
module: 'aws_cdk.cloud_assembly_schema',
trustedPublishing: true,
},
pypiClassifiers: [
'Framework :: AWS CDK',
'Framework :: AWS CDK :: 2',
],
publishToGo: {
moduleName: 'github.com/cdklabs/cloud-assembly-schema-go',
},
composite: true,
});
(() => {
cloudAssemblySchema.preCompileTask.exec('tsx projenrc/update.ts');
// This file will be generated at release time. It needs to be gitignored or it will
// fail projen's "no tamper" check, which means it must also be generated every build time.
//
// Crucially, this must also run during release after bumping, but that is satisfied already
// by making it part of preCompile, because that makes it run as part of projen build.
cloudAssemblySchema.preCompileTask.exec('tsx ../../../projenrc/copy-cli-version-to-assembly.task.ts');
cloudAssemblySchema.gitignore.addPatterns('cli-version.json');
cloudAssemblySchema.addPackageIgnore('*.ts');
cloudAssemblySchema.addPackageIgnore('!*.d.ts');
cloudAssemblySchema.addPackageIgnore('**/scripts');
})();
// #endregion
//////////////////////////////////////////////////////////////////////
// #region @aws-cdk/cloudformation-diff
const cloudFormationDiff = configureProject(
new yarn.TypeScriptWorkspace({
...genericCdkProps(),
parent: repo,
name: '@aws-cdk/cloudformation-diff',
description: 'Utilities to diff CDK stacks against CloudFormation templates',
majorVersion: 2,
srcdir: 'lib',
devDeps: [
'fast-check',
],
peerDependencyOptions: {
pinnedDevDependency: false,
},
peerDeps: [
sdkDep('@aws-sdk/client-cloudformation'),
],
deps: [
'@aws-cdk/aws-service-spec',
'@aws-cdk/service-spec-types',
'chalk@^4',
'diff',
'fast-deep-equal',
'string-width@^4',
'table@^6',
],
// FIXME: this should be a jsii project
// (EDIT: or should it? We're going to bundle it into aws-cdk-lib)
tsconfig: {
compilerOptions: {
...defaultTsOptions,
},
},
jestOptions: jestOptionsForProject({
jestConfig: {
coverageThreshold: {
functions: 75,
},
},
}),
// Append a specific version string for testing
nextVersionCommand: 'tsx ../../../projenrc/next-version.ts maybeRc',
}),
);
fixupTestTask(cloudFormationDiff);
// #endregion
//////////////////////////////////////////////////////////////////////
// #region @aws-cdk/cloud-assembly-api
const cloudAssemblyApi = configureProject(
new yarn.TypeScriptWorkspace({
...genericCdkProps(),
parent: repo,
name: '@aws-cdk/cloud-assembly-api',
description: 'API for working with Cloud Assemblies',
srcdir: 'lib',
bundledDeps: ['jsonschema@~1.4.1', 'semver'],
devDeps: [
cloudAssemblySchema.customizeReference({ versionType: 'exact' }),
],
peerDeps: [
cloudAssemblySchema.customizeReference({ versionType: 'any-future' }),
],
jestOptions: jestOptionsForProject({
jestConfig: {
coverageThreshold: {
functions: 75,
},
},
}),
// Append a specific version string for testing
nextVersionCommand: 'tsx ../../../projenrc/next-version.ts atLeast:2.0.0 maybeRc',
}),
);
fixupTestTask(cloudAssemblyApi);
// #endregion
//////////////////////////////////////////////////////////////////////
// #region @aws-cdk/cx-api
// cx-api represents the flags that the Cloud Executable expects. It is
// generated from `aws-cdk-lib` at build time. Stay within the same MV,
// otherwise any should work
const cxApi = '@aws-cdk/cx-api@^2';
// #endregion
//////////////////////////////////////////////////////////////////////
// #region @aws-cdk/yarn-cling
const yarnCling = configureProject(
new yarn.TypeScriptWorkspace({
...genericCdkProps({
private: true,
}),
parent: repo,
name: '@aws-cdk/yarn-cling',
description: 'Tool for generating npm-shrinkwrap from yarn.lock',
srcdir: 'lib',
deps: ['@yarnpkg/parsers', 'semver'],
devDeps: ['@types/semver', 'fast-check'],
minNodeVersion: '20',
tsconfig: {
compilerOptions: {
...defaultTsOptions,
},
},
jestOptions: jestOptionsForProject({
jestConfig: {
coverageThreshold: {
branches: 78,
},
},
}),
}),
);
yarnCling.testTask.prependExec('ln -sf ../../cdk test/test-fixture/jsii/node_modules/');
yarnCling.testTask.prependExec('ln -sf ../../cdk test/test-fixture-berry/jsii/node_modules/');
// #endregion
//////////////////////////////////////////////////////////////////////
// #region @aws-cdk/user-input-gen
const yargsGen = configureProject(
new yarn.TypeScriptWorkspace({
...genericCdkProps({
private: true,
}),
parent: repo,
name: '@aws-cdk/user-input-gen',
description: 'Generate CLI arguments',
srcdir: 'lib',
deps: ['@cdklabs/typewriter', 'prettier@^2.8', 'lodash.clonedeep'],
devDeps: ['@types/semver', '@types/yarnpkg__lockfile', '@types/lodash.clonedeep', '@types/prettier@^2'],
minNodeVersion: '20', // Necessary for 'structuredClone'
tsconfig: {
compilerOptions: {
...defaultTsOptions,
},
},
}),
);
// #endregion
//////////////////////////////////////////////////////////////////////
// #region @aws-cdk/cli-plugin-contract
// This should be deprecated, but only after the move
const cliPluginContract = configureProject(
new yarn.TypeScriptWorkspace({
...genericCdkProps(),
parent: repo,
name: '@aws-cdk/cli-plugin-contract',
description: 'Contract between the CLI and authentication plugins, for the exchange of AWS credentials',
majorVersion: 2,
srcdir: 'lib',
deps: [
],
devDeps: [
],
tsconfig: {
compilerOptions: {
...defaultTsOptions,
},
},
}),
);
// #endregion
//////////////////////////////////////////////////////////////////////
// #region @aws-cdk/cdk-assets-lib
const cdkAssetsLib = configureProject(
new yarn.TypeScriptWorkspace({
...genericCdkProps(),
parent: repo,
name: '@aws-cdk/cdk-assets-lib',
majorVersion: 1,
description: 'CDK Asset Publishing Library',
srcdir: 'lib',
deps: [
cloudAssemblySchema.customizeReference({ versionType: 'any-future' }),
cloudAssemblyApi.customizeReference({ versionType: 'exact' }),
'archiver',
'fast-glob',
'mime@^2',
sdkDep('@aws-sdk/client-ecr'),
sdkDep('@aws-sdk/client-s3'),
sdkDep('@aws-sdk/client-secrets-manager'),
sdkDep('@aws-sdk/client-sts'),
sdkDep('@aws-sdk/credential-providers'),
sdkDep('@aws-sdk/lib-storage'),
smithyDep('@smithy/config-resolver'),
smithyDep('@smithy/node-config-provider'),
'picomatch',
],
devDeps: [
'@types/archiver',
'@types/mime@^2',
'@types/picomatch',
'fs-extra@^11',
'graceful-fs',
'jszip',
'@types/mock-fs@^4',
'mock-fs@^5',
'aws-sdk-client-mock',
'aws-sdk-client-mock-jest',
],
tsconfigDev: {
compilerOptions: {
...defaultTsOptions,
},
include: ['bin/**/*.ts'],
},
tsconfig: {
compilerOptions: {
...defaultTsOptions,
rootDir: undefined,
outDir: undefined,
},
include: ['bin/**/*.ts'],
},
jestOptions: jestOptionsForProject({
jestConfig: {
// We have many tests here that commonly time out
testTimeout: 10_000,
},
}),
// Append a specific version string for testing
nextVersionCommand: 'tsx ../../../projenrc/next-version.ts neverMajor maybeRc',
releasableCommits: transitiveFeaturesAndFixes('@aws-cdk/cdk-assets-lib', [
'@aws-cdk/cloud-assembly-schema',
]),
}),
);
fixupTestTask(cdkAssetsLib);
// Prevent imports of private API surface
cdkAssetsLib.package.addField('exports', {
'.': {
types: './lib/index.d.ts',
default: './lib/index.js',
},
'./package.json': './package.json',
});
new TypecheckTests(cdkAssetsLib);
cdkAssetsLib.gitignore.addPatterns(
'*.js',
'*.d.ts',
);
// This package happens do something only slightly naughty
cdkAssetsLib.eslint?.addRules({ 'jest/no-export': ['off'] });
// #endregion
//////////////////////////////////////////////////////////////////////
// #region cdk-assets
const cdkAssetsCli = configureProject(
new yarn.TypeScriptWorkspace({
...genericCdkProps(),
parent: repo,
name: 'cdk-assets',
description: 'CDK Asset Publishing Tool',
majorVersion: 4,
srcdir: 'lib',
deps: [
cdkAssetsLib,
'yargs',
],
devDeps: [
'@types/yargs',
// These are for tests
cloudAssemblySchema,
sdkDep('@aws-sdk/client-s3'),
'aws-sdk-client-mock',
],
tsconfigDev: {
compilerOptions: {
...defaultTsOptions,
},
include: ['bin/**/*.ts'],
},
tsconfig: {
compilerOptions: {
...defaultTsOptions,
rootDir: undefined,
outDir: undefined,
},
include: ['bin/**/*.ts'],
},
jestOptions: jestOptionsForProject({
jestConfig: {
// We have many tests here that commonly time out
testTimeout: 10_000,
coverageThreshold: {
branches: 74,
},
},
}),
// Append a specific version string for testing
nextVersionCommand: 'tsx ../../projenrc/next-version.ts maybeRc',
releasableCommits: transitiveFeaturesAndFixes('cdk-assets', [
'@aws-cdk/cdk-assets-lib',
'@aws-cdk/cloud-assembly-schema',
]),
}),
);
fixupTestTask(cdkAssetsCli);
cdkAssetsCli.gitignore.addPatterns(
'*.js',
'*.d.ts',
);
new BundleCli(cdkAssetsCli, {
allowedLicenses: BUNDLED_LICENSES,
dontAttribute: '^@aws-cdk/|^@cdklabs/$',
test: 'bin/cdk-assets --version',
entryPoints: [
'bin/cdk-assets.js',
'bin/docker-credential-cdk-assets.js',
],
minifyWhitespace: true,
});
// #endregion
//////////////////////////////////////////////////////////////////////
// #region @aws-cdk/toolkit-lib
const TOOLKIT_LIB_EXCLUDE_PATTERNS = [
'lib/init-templates/*/typescript/*/*.template.ts',
];
const toolkitLibTsCompilerOptions = {
...defaultTsOptions,
target: 'es2022',
lib: ['es2022', 'esnext.disposable'],
module: 'NodeNext',
declarationMap: true,
};
const toolkitLib = configureProject(
new yarn.TypeScriptWorkspace({
...genericCdkProps(),
homepage: 'https://docs.aws.amazon.com/cdk/api/toolkit-lib',
parent: repo,
name: '@aws-cdk/toolkit-lib',
description: 'AWS CDK Programmatic Toolkit Library',
majorVersion: 1,
srcdir: 'lib',
peerDeps: [
cliPluginContract.customizeReference({ versionType: 'any-minor' }), // allow consumers to easily de-depulicate this
],
deps: [
cloudAssemblySchema.customizeReference({ versionType: 'any-future' }), // needs to be newer than what this was build with
cloudFormationDiff.customizeReference({ versionType: 'any-minor' }), // stay within the same MV, otherwise any should work
cdkAssetsLib.customizeReference({ versionType: 'any-minor' }), // stay within the same MV, otherwise any should work
cxApi,
cloudAssemblyApi.customizeReference({ versionType: 'exact' }),
sdkDep('@aws-sdk/client-appsync'),
sdkDep('@aws-sdk/client-bedrock-agentcore-control'),
sdkDep('@aws-sdk/client-cloudformation'),
sdkDep('@aws-sdk/client-cloudwatch-logs'),
sdkDep('@aws-sdk/client-cloudcontrol'),
sdkDep('@aws-sdk/client-codebuild'),
sdkDep('@aws-sdk/client-ec2'),
sdkDep('@aws-sdk/client-ecr'),
sdkDep('@aws-sdk/client-ecs'),
sdkDep('@aws-sdk/client-elastic-load-balancing-v2'),
sdkDep('@aws-sdk/client-iam'),
sdkDep('@aws-sdk/client-kms'),
sdkDep('@aws-sdk/client-lambda'),
sdkDep('@aws-sdk/client-route-53'),
sdkDep('@aws-sdk/client-s3'),
sdkDep('@aws-sdk/client-secrets-manager'),
sdkDep('@aws-sdk/client-sfn'),
sdkDep('@aws-sdk/client-ssm'),
sdkDep('@aws-sdk/client-sts'),
sdkDep('@aws-sdk/credential-providers'),
sdkDep('@aws-sdk/ec2-metadata-service'),
sdkDep('@aws-sdk/lib-storage'),
smithyDep('@smithy/middleware-endpoint'),
smithyDep('@smithy/property-provider'),
smithyDep('@smithy/shared-ini-file-loader'),
smithyDep('@smithy/util-retry'),
smithyDep('@smithy/util-waiter'),
'archiver',
'cdk-from-cfn',
'chalk@^4',
'chokidar@^4',
'fast-deep-equal',
'fs-extra@^11',
'picomatch',
'p-limit@^3',
'semver',
'split2',
'fast-glob',
'uuid',
'wrap-ansi@^7', // Last non-ESM version
'yaml@^1',
],
devDeps: [
'@aws-cdk/aws-service-spec',
'@jest/environment',
'@jest/globals',
'@jest/types',
'@microsoft/api-extractor',
'@smithy/util-stream',
'@types/fs-extra@^11',
'@types/picomatch',
'@types/split2',
'aws-cdk-lib',
'aws-sdk-client-mock',
'aws-sdk-client-mock-jest',
'fast-check',
'jest-environment-node',
'@types/jest-when',
'jest-when',
'nock@13',
'tsx',
],
// Watch 2 directories at once
releasableCommits: transitiveToolkitPackages('@aws-cdk/toolkit-lib'),
eslintOptions: {
dirs: ['lib'],
ignorePatterns: [
...TOOLKIT_LIB_EXCLUDE_PATTERNS,
'*.d.ts',
],
},
jestOptions: jestOptionsForProject({
jestConfig: {
// Tests that synth an assembly usually need a bit longer
testTimeout: 10_000,
coverageThreshold: {
statements: 87,
branches: 83,
functions: 82,
lines: 87,
},
testEnvironment: './test/_helpers/jest-bufferedconsole.ts',
setupFilesAfterEnv: [
'<rootDir>/test/_helpers/jest-setup-after-env.ts',
'<rootDir>/test/_helpers/jest-custom-matchers.ts',
],
},
}),
tsconfig: {
compilerOptions: {
...toolkitLibTsCompilerOptions,
},
},
tsconfigDev: {
compilerOptions: {
...toolkitLibTsCompilerOptions,
rootDir: '.', // shouldn't be required but something broke... check again once we have gotten rid of the tmpToolkitHelpers package
},
},
nextVersionCommand: 'tsx ../../../projenrc/next-version.ts maybeRc',
}),
);
fixupTestTask(toolkitLib);
toolkitLib.tasks.tryFind('test')?.updateStep(0, {
// https://github.com/aws/aws-sdk-js-v3/issues/7420
exec: 'NODE_OPTIONS="$NODE_OPTIONS --experimental-vm-modules" jest --passWithNoTests --updateSnapshot',
});
new TypecheckTests(toolkitLib);
// API Extractor documentation publishing
new S3DocsPublishing(toolkitLib, {