Skip to content

Commit b580d1e

Browse files
mrgraingithub-actions
and
github-actions
authored
chore: setup new package to temporarily hold code shared between Toolkit CLI and Library (#170)
Adds the new private package `@aws-cdk/tmp-toolkit-helpers`. Initially only moves `ToolkitError` into the package to demonstrate its usage. More PRs will follow to move code from the CLI to this new package. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license --------- Signed-off-by: github-actions <[email protected]> Co-authored-by: github-actions <[email protected]>
1 parent c9c2e20 commit b580d1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1276
-160
lines changed

.projenrc.ts

+59-5
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ function transitiveFeaturesAndFixes(thisPkg: string, depPkgs: string[]) {
156156
].join(' '));
157157
}
158158

159+
/**
160+
* Returns all packages that are considered part of the toolkit,
161+
* as relative paths from the provided package.
162+
*/
163+
function transitiveToolkitPackages(thisPkg: string) {
164+
const toolkitPackages = [
165+
'aws-cdk',
166+
'@aws-cdk/tmp-toolkit-helpers',
167+
'@aws-cdk/cloud-assembly-schema',
168+
'@aws-cdk/cloudformation-diff',
169+
];
170+
171+
return transitiveFeaturesAndFixes(thisPkg, toolkitPackages.filter(name => name !== thisPkg));
172+
}
173+
159174
const repoProject = new yarn.Monorepo({
160175
projenrcTs: true,
161176
name: 'aws-cdk-cli',
@@ -668,6 +683,38 @@ cdkAssets.eslint?.addRules({ 'jest/no-export': ['off'] });
668683

669684
//////////////////////////////////////////////////////////////////////
670685

686+
const tmpToolkitHelpers = configureProject(
687+
new yarn.TypeScriptWorkspace({
688+
...genericCdkProps({
689+
private: true,
690+
}),
691+
parent: repo,
692+
name: '@aws-cdk/tmp-toolkit-helpers',
693+
description: 'A temporary package to hold code shared between aws-cdk and @aws-cdk/toolkit-lib',
694+
deps: [],
695+
devDeps: [
696+
cdkBuildTools,
697+
],
698+
tsconfig: {
699+
compilerOptions: {
700+
target: 'es2022',
701+
lib: ['es2022', 'esnext.disposable'],
702+
module: 'NodeNext',
703+
esModuleInterop: false,
704+
},
705+
},
706+
}),
707+
);
708+
709+
// Prevent imports of private API surface
710+
tmpToolkitHelpers.package.addField('exports', {
711+
'.': './lib/index.js',
712+
'./package.json': './package.json',
713+
'./api': './lib/api/index.js',
714+
});
715+
716+
//////////////////////////////////////////////////////////////////////
717+
671718
let CLI_SDK_VERSION: '2' | '3' = ('3' as any);
672719

673720
const cli = configureProject(
@@ -683,6 +730,7 @@ const cli = configureProject(
683730
cdkBuildTools,
684731
yargsGen,
685732
cliPluginContract,
733+
tmpToolkitHelpers,
686734
'@octokit/rest',
687735
'@types/archiver',
688736
'@types/fs-extra@^9',
@@ -826,7 +874,7 @@ const cli = configureProject(
826874
// Append a specific version string for testing
827875
nextVersionCommand: 'tsx ../../projenrc/next-version.ts maybeRc',
828876

829-
releasableCommits: transitiveFeaturesAndFixes('aws-cdk', [cloudAssemblySchema.name, cloudFormationDiff.name]),
877+
releasableCommits: transitiveToolkitPackages('aws-cdk'),
830878
}),
831879
);
832880

@@ -962,7 +1010,7 @@ const cliLib = configureProject(
9621010
devDeps: ['aws-cdk-lib', cli, 'constructs'],
9631011
disableTsconfig: true,
9641012
nextVersionCommand: `tsx ../../../projenrc/next-version.ts copyVersion:../../../${cliPackageJson} append:-alpha.0`,
965-
releasableCommits: transitiveFeaturesAndFixes('@aws-cdk/cli-lib-alpha', [cli.name, cloudAssemblySchema.name, cloudFormationDiff.name]),
1013+
releasableCommits: transitiveToolkitPackages('@aws-cdk/cli-lib-alpha'),
9661014
eslintOptions: {
9671015
dirs: ['lib'],
9681016
ignorePatterns: [
@@ -1118,13 +1166,14 @@ const toolkitLib = configureProject(
11181166
'@types/fs-extra',
11191167
'@types/split2',
11201168
cli,
1169+
tmpToolkitHelpers,
11211170
'aws-cdk-lib',
11221171
'aws-sdk-client-mock',
11231172
'esbuild',
11241173
'typedoc',
11251174
],
11261175
// Watch 2 directories at once
1127-
releasableCommits: transitiveFeaturesAndFixes('@aws-cdk/toolkit-lib', [cli.name, cloudAssemblySchema.name, cloudFormationDiff.name]),
1176+
releasableCommits: transitiveToolkitPackages('@aws-cdk/toolkit-lib'),
11281177
eslintOptions: {
11291178
dirs: ['lib'],
11301179
ignorePatterns: [
@@ -1170,6 +1219,11 @@ toolkitLib.eslint?.addRules({
11701219
target: './',
11711220
from: '../../aws-cdk',
11721221
message: 'All `aws-cdk` code must be used via lib/api/aws-cdk.ts',
1222+
},
1223+
{
1224+
target: './',
1225+
from: '../tmp-toolkit-helpers',
1226+
message: 'All `@aws-cdk/tmp-toolkit-helpers` code must be used via lib/api/shared-*.ts',
11731227
}],
11741228
}],
11751229
});
@@ -1265,7 +1319,7 @@ const cdkCliWrapper = configureProject(
12651319
srcdir: 'lib',
12661320
devDeps: ['aws-cdk-lib', cli, 'constructs', '@aws-cdk/integ-runner'],
12671321
nextVersionCommand: `tsx ../../../projenrc/next-version.ts copyVersion:../../../${cliPackageJson}`,
1268-
releasableCommits: transitiveFeaturesAndFixes('@aws-cdk/cdk-cli-wrapper', [cli.name, cloudAssemblySchema.name, cloudFormationDiff.name]),
1322+
releasableCommits: transitiveToolkitPackages('@aws-cdk/cdk-cli-wrapper'),
12691323

12701324
jestOptions: jestOptionsForProject({
12711325
jestConfig: {
@@ -1295,7 +1349,7 @@ const cdkAliasPackage = configureProject(
12951349
srcdir: 'lib',
12961350
deps: [cli],
12971351
nextVersionCommand: `tsx ../../projenrc/next-version.ts copyVersion:../../${cliPackageJson}`,
1298-
releasableCommits: transitiveFeaturesAndFixes('cdk', [cli.name, cloudAssemblySchema.name, cloudFormationDiff.name]),
1352+
releasableCommits: transitiveToolkitPackages('cdk'),
12991353
}),
13001354
);
13011355
void cdkAliasPackage;

aws-cdk-cli.code-workspace

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/cli-lib-alpha/.projen/tasks.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/tmp-toolkit-helpers/.eslintrc.js

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)