Skip to content

Commit

Permalink
chore: setup new package to temporarily hold code shared between Tool…
Browse files Browse the repository at this point in the history
…kit 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 <github-actions@github.com>
Co-authored-by: github-actions <github-actions@github.com>
  • Loading branch information
mrgrain and github-actions authored Feb 28, 2025
1 parent c9c2e20 commit b580d1e
Show file tree
Hide file tree
Showing 51 changed files with 1,276 additions and 160 deletions.
64 changes: 59 additions & 5 deletions .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,21 @@ function transitiveFeaturesAndFixes(thisPkg: string, depPkgs: string[]) {
].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/tmp-toolkit-helpers',
'@aws-cdk/cloud-assembly-schema',
'@aws-cdk/cloudformation-diff',
];

return transitiveFeaturesAndFixes(thisPkg, toolkitPackages.filter(name => name !== thisPkg));
}

const repoProject = new yarn.Monorepo({
projenrcTs: true,
name: 'aws-cdk-cli',
Expand Down Expand Up @@ -668,6 +683,38 @@ cdkAssets.eslint?.addRules({ 'jest/no-export': ['off'] });

//////////////////////////////////////////////////////////////////////

const tmpToolkitHelpers = configureProject(
new yarn.TypeScriptWorkspace({
...genericCdkProps({
private: true,
}),
parent: repo,
name: '@aws-cdk/tmp-toolkit-helpers',
description: 'A temporary package to hold code shared between aws-cdk and @aws-cdk/toolkit-lib',
deps: [],
devDeps: [
cdkBuildTools,
],
tsconfig: {
compilerOptions: {
target: 'es2022',
lib: ['es2022', 'esnext.disposable'],
module: 'NodeNext',
esModuleInterop: false,
},
},
}),
);

// Prevent imports of private API surface
tmpToolkitHelpers.package.addField('exports', {
'.': './lib/index.js',
'./package.json': './package.json',
'./api': './lib/api/index.js',
});

//////////////////////////////////////////////////////////////////////

let CLI_SDK_VERSION: '2' | '3' = ('3' as any);

const cli = configureProject(
Expand All @@ -683,6 +730,7 @@ const cli = configureProject(
cdkBuildTools,
yargsGen,
cliPluginContract,
tmpToolkitHelpers,
'@octokit/rest',
'@types/archiver',
'@types/fs-extra@^9',
Expand Down Expand Up @@ -826,7 +874,7 @@ const cli = configureProject(
// Append a specific version string for testing
nextVersionCommand: 'tsx ../../projenrc/next-version.ts maybeRc',

releasableCommits: transitiveFeaturesAndFixes('aws-cdk', [cloudAssemblySchema.name, cloudFormationDiff.name]),
releasableCommits: transitiveToolkitPackages('aws-cdk'),
}),
);

Expand Down Expand Up @@ -962,7 +1010,7 @@ const cliLib = configureProject(
devDeps: ['aws-cdk-lib', cli, 'constructs'],
disableTsconfig: true,
nextVersionCommand: `tsx ../../../projenrc/next-version.ts copyVersion:../../../${cliPackageJson} append:-alpha.0`,
releasableCommits: transitiveFeaturesAndFixes('@aws-cdk/cli-lib-alpha', [cli.name, cloudAssemblySchema.name, cloudFormationDiff.name]),
releasableCommits: transitiveToolkitPackages('@aws-cdk/cli-lib-alpha'),
eslintOptions: {
dirs: ['lib'],
ignorePatterns: [
Expand Down Expand Up @@ -1118,13 +1166,14 @@ const toolkitLib = configureProject(
'@types/fs-extra',
'@types/split2',
cli,
tmpToolkitHelpers,
'aws-cdk-lib',
'aws-sdk-client-mock',
'esbuild',
'typedoc',
],
// Watch 2 directories at once
releasableCommits: transitiveFeaturesAndFixes('@aws-cdk/toolkit-lib', [cli.name, cloudAssemblySchema.name, cloudFormationDiff.name]),
releasableCommits: transitiveToolkitPackages('@aws-cdk/toolkit-lib'),
eslintOptions: {
dirs: ['lib'],
ignorePatterns: [
Expand Down Expand Up @@ -1170,6 +1219,11 @@ toolkitLib.eslint?.addRules({
target: './',
from: '../../aws-cdk',
message: 'All `aws-cdk` code must be used via lib/api/aws-cdk.ts',
},
{
target: './',
from: '../tmp-toolkit-helpers',
message: 'All `@aws-cdk/tmp-toolkit-helpers` code must be used via lib/api/shared-*.ts',
}],
}],
});
Expand Down Expand Up @@ -1265,7 +1319,7 @@ const cdkCliWrapper = configureProject(
srcdir: 'lib',
devDeps: ['aws-cdk-lib', cli, 'constructs', '@aws-cdk/integ-runner'],
nextVersionCommand: `tsx ../../../projenrc/next-version.ts copyVersion:../../../${cliPackageJson}`,
releasableCommits: transitiveFeaturesAndFixes('@aws-cdk/cdk-cli-wrapper', [cli.name, cloudAssemblySchema.name, cloudFormationDiff.name]),
releasableCommits: transitiveToolkitPackages('@aws-cdk/cdk-cli-wrapper'),

jestOptions: jestOptionsForProject({
jestConfig: {
Expand Down Expand Up @@ -1295,7 +1349,7 @@ const cdkAliasPackage = configureProject(
srcdir: 'lib',
deps: [cli],
nextVersionCommand: `tsx ../../projenrc/next-version.ts copyVersion:../../${cliPackageJson}`,
releasableCommits: transitiveFeaturesAndFixes('cdk', [cli.name, cloudAssemblySchema.name, cloudFormationDiff.name]),
releasableCommits: transitiveToolkitPackages('cdk'),
}),
);
void cdkAliasPackage;
Expand Down
3 changes: 3 additions & 0 deletions aws-cdk-cli.code-workspace

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/@aws-cdk/cli-lib-alpha/.projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/@aws-cdk/tmp-toolkit-helpers/.eslintrc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b580d1e

Please sign in to comment.