Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): 1.201.0 #25511

Merged
merged 11 commits into from
May 10, 2023
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.201.0](https://github.com/aws/aws-cdk/compare/v1.200.0...v1.201.0) (2023-05-10)

## [1.200.0](https://github.com/aws/aws-cdk/compare/v1.199.0...v1.200.0) (2023-04-26)


Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ while [[ "${1:-}" != "" ]]; do
done

export PATH=$(npm bin):$PATH
export NODE_OPTIONS="--max-old-space-size=4096 --experimental-worker ${NODE_OPTIONS:-}"
export NODE_OPTIONS="--max-old-space-size=8196 --experimental-worker ${NODE_OPTIONS:-}"

if ! [ -x "$(command -v yarn)" ]; then
echo "yarn is not installed. Install it from here- https://yarnpkg.com/en/docs/install."
Expand Down
5 changes: 5 additions & 0 deletions buildspec-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ version: 0.2

# This buildspec is intended to be used by GitHub PR builds.

env:
variables:
PR_BUILD: true

phases:
install:
commands:
Expand All @@ -24,6 +28,7 @@ phases:
- /bin/bash ./scripts/cache-load.sh
build:
commands:
- export NODE_OPTIONS="--max-old-space-size=8196 --experimental-worker ${NODE_OPTIONS:-}"
- /bin/bash ./build.sh
- /bin/bash ./scripts/transform.sh
# After compilation, run Rosetta (using the cache if available).
Expand Down
1,787 changes: 1,787 additions & 0 deletions packages/@aws-cdk/cfnspec/CHANGELOG.md

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions packages/@aws-cdk/cfnspec/build-tools/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,28 @@
*/

import * as path from 'path';
import * as fs from 'fs-extra';
import * as md5 from 'md5';
import { schema } from '../lib';
import { massageSpec, normalize } from './massage-spec';;
import { writeSorted, applyPatchSet, applyAndWrite } from './patch-set';
import { validateSpecificationEvolution } from './validate-evolution';
import { schema } from '../lib';

async function main() {
const inputDir = path.join(process.cwd(), 'spec-source');
const outDir = path.join(process.cwd(), 'spec');

await generateResourceSpecification(inputDir, path.join(outDir, 'specification.json'));
// If this is a PR build check the spec for evolution (this is set in buildspec-pr.yaml)
const outputFile = path.join(outDir, 'specification.json');
if (process.env.CODEBUILD_WEBHOOK_TRIGGER?.startsWith('pr/')) {
await validateSpecificationEvolution(async () => {
await generateResourceSpecification(inputDir, outputFile);
return fs.readJson(outputFile);
});
} else {
await generateResourceSpecification(inputDir, outputFile);
}

await applyAndWrite(path.join(outDir, 'cfn-lint.json'), path.join(inputDir, 'cfn-lint'));
await applyAndWrite(path.join(outDir, 'cfn-docs.json'), path.join(inputDir, 'cfn-docs'));
}
Expand Down
326 changes: 0 additions & 326 deletions packages/@aws-cdk/cfnspec/build-tools/create-missing-libraries.ts
Original file line number Diff line number Diff line change
@@ -1,326 +0,0 @@
#!/usr/bin/env node

/**
* automatically creates a module for any CloudFormation namespaces that do not
* have an AWS construct library.
*/

import * as path from 'path';
import * as pkglint from '@aws-cdk/pkglint';
import * as fs from 'fs-extra';
import * as cfnspec from '../lib';

// don't be a prude:
/* eslint-disable no-console */
/* eslint-disable quote-props */

async function main() {
const root = path.join(__dirname, '..', '..');
if (path.basename(root) !== '@aws-cdk') {
throw new Error(`Something went wrong. We expected ${root} to be the "packages/@aws-cdk" directory. Did you move me?`);
}

// eslint-disable-next-line @typescript-eslint/no-require-imports
const cfnSpecPkgJson = require('../package.json');
const version = cfnSpecPkgJson.version;
const jestTypesVersion = cfnSpecPkgJson.devDependencies['@types/jest'];

// iterate over all cloudformation namespaces
for (const namespace of cfnspec.namespaces()) {
const module = pkglint.createModuleDefinitionFromCfnNamespace(namespace);
const lowcaseModuleName = module.moduleBaseName.toLocaleLowerCase();
const packagePath = path.join(root, module.moduleName);

// we already have a module for this namesapce, move on.
if (await fs.pathExists(packagePath)) {
const packageJsonPath = path.join(packagePath, 'package.json');
// eslint-disable-next-line @typescript-eslint/no-require-imports
const packageJson = require(packageJsonPath);
let scopes: string | string[] = packageJson['cdk-build'].cloudformation;
if (typeof scopes === 'string') { scopes = [scopes]; }
if (scopes.indexOf(namespace) !== -1) {
// V2-style module is already modeled in the root package, nothing to be done!
continue;
} else if (await fs.pathExists(path.join(root, `${module.moduleFamily}-${module.moduleBaseName}`.toLocaleLowerCase()))) {
// V2-style package already has it's own package (legacy behavior), nothing to be done!
continue;
} else {
// V2-style package needs to be added to it's "V1" package... Get down to business!
console.error(`Adding ${namespace} to ${module.packageName}`);
scopes.push(namespace);
packageJson['cdk-build'].cloudformation = scopes;
await fs.writeJson(packageJsonPath, packageJson, { encoding: 'utf-8', spaces: 2 });
const indexTsPath = path.join(packagePath, 'lib', 'index.ts');
const indexTs = [
(await fs.readFile(indexTsPath, { encoding: 'utf8' })).trimRight(),
`// ${namespace} CloudFormation Resources:`,
`export * from './${lowcaseModuleName}.generated';`,
].join('\n');
await fs.writeFile(indexTsPath, indexTs, { encoding: 'utf8' });
continue;
}
}

async function write(relativePath: string, contents: string[] | string | object) {
const fullPath = path.join(packagePath, relativePath);
const dir = path.dirname(fullPath);
await fs.mkdirp(dir);

let data;
if (typeof contents === 'string') {
data = contents.trimLeft(); // trim first newline
} else if (Array.isArray(contents)) {
data = contents.join('\n');
} else if (typeof contents === 'object') {
data = JSON.stringify(contents, undefined, 2);
} else {
throw new Error('Invalid type of contents: ' + contents);
}

await fs.writeFile(fullPath, data + '\n');
}

console.log(`generating module for ${module.packageName}...`);

const description = `${namespace} Construct Library`;

await write('package.json', {
name: module.packageName,
version,
description,
main: 'lib/index.js',
types: 'lib/index.d.ts',
jsii: {
outdir: 'dist',
projectReferences: true,
targets: {
dotnet: {
namespace: module.dotnetPackage,
packageId: module.dotnetPackage,
signAssembly: true,
assemblyOriginatorKeyFile: '../../key.snk',
iconUrl: 'https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png',
},
java: {
package: `${module.javaGroupId}.${module.javaPackage}`,
maven: {
groupId: module.javaGroupId,
artifactId: module.javaArtifactId,
},
},
python: {
classifiers: [
'Framework :: AWS CDK',
'Framework :: AWS CDK :: 1',
],
distName: module.pythonDistName,
module: module.pythonModuleName,
},
},
metadata: {
jsii: {
rosetta: {
strict: true,
},
},
},
},
repository: {
type: 'git',
url: 'https://github.com/aws/aws-cdk.git',
directory: `packages/${module.packageName}`,
},
homepage: 'https://github.com/aws/aws-cdk',
scripts: {
build: 'cdk-build',
watch: 'cdk-watch',
lint: 'cdk-lint',
test: 'cdk-test',
integ: 'cdk-integ',
pkglint: 'pkglint -f',
package: 'cdk-package',
awslint: 'cdk-awslint',
cfn2ts: 'cfn2ts',
'build+test': 'yarn build && yarn test',
'build+test+package': 'yarn build+test && yarn package',
compat: 'cdk-compat',
gen: 'cfn2ts',
'rosetta:extract': 'yarn --silent jsii-rosetta extract',
'build+extract': 'yarn build && yarn rosetta:extract',
'build+test+extract': 'yarn build+test && yarn rosetta:extract',
},
'cdk-build': {
cloudformation: namespace,
jest: true,
env: {
AWSLINT_BASE_CONSTRUCT: 'true',
},
},
keywords: [
'aws',
'cdk',
'constructs',
namespace,
module.moduleName,
],
author: {
name: 'Amazon Web Services',
url: 'https://aws.amazon.com',
organization: true,
},
license: 'Apache-2.0',
devDependencies: {
'@aws-cdk/assertions': version,
'@aws-cdk/cdk-build-tools': version,
'@aws-cdk/cfn2ts': version,
'@aws-cdk/pkglint': version,
'@types/jest': jestTypesVersion,
},
dependencies: {
'@aws-cdk/core': version,
'constructs': '^3.3.69',
},
peerDependencies: {
'@aws-cdk/core': version,
'constructs': '^3.3.69',
},
engines: {
node: '>= 14.15.0',
},
stability: 'experimental',
maturity: 'cfn-only',
awscdkio: {
announce: false,
},
publishConfig: {
tag: 'latest',
},
});

await write('.gitignore', [
'*.js',
'*.js.map',
'*.d.ts',
'tsconfig.json',
'node_modules',
'*.generated.ts',
'dist',
'.jsii',
'',
'.LAST_BUILD',
'.nyc_output',
'coverage',
'.nycrc',
'.LAST_PACKAGE',
'*.snk',
'nyc.config.js',
'!.eslintrc.js',
'!jest.config.js',
'junit.xml',
]);

await write('.npmignore', [
'# Don\'t include original .ts files when doing `npm pack`',
'*.ts',
'!*.d.ts',
'coverage',
'.nyc_output',
'*.tgz',
'',
'dist',
'.LAST_PACKAGE',
'.LAST_BUILD',
'!*.js',
'',
'# Include .jsii',
'!.jsii',
'',
'*.snk',
'',
'*.tsbuildinfo',
'',
'tsconfig.json',
'',
'.eslintrc.js',
'jest.config.js',
'',
'# exclude cdk artifacts',
'**/cdk.out',
'junit.xml',
'test/',
'!*.lit.ts',
]);

await write('lib/index.ts', [
`// ${namespace} CloudFormation Resources:`,
`export * from './${lowcaseModuleName}.generated';`,
]);

await write(`test/${lowcaseModuleName}.test.ts`, [
"import '@aws-cdk/assertions';",
"import {} from '../lib';",
'',
"test('No tests are specified for this package', () => {",
' expect(true).toBe(true);',
'});',
]);

await pkglint.createLibraryReadme(namespace, path.join(packagePath, 'README.md'));

await write('.eslintrc.js', [
"const baseConfig = require('@aws-cdk/cdk-build-tools/config/eslintrc');",
"baseConfig.parserOptions.project = __dirname + '/tsconfig.json';",
'module.exports = baseConfig;',
]);

await write('jest.config.js', [
"const baseConfig = require('@aws-cdk/cdk-build-tools/config/jest.config');",
'module.exports = baseConfig;',
]);

await write('rosetta/default.ts-fixture', [
"import { Construct } from 'constructs';",
"import { Stack } from '@aws-cdk/core';",
'',
'class MyStack extends Stack {',
' constructor(scope: Construct, id: string) {',
' /// here',
' }',
'}',
]);

const templateDir = path.join(__dirname, 'template');
for (const file of await fs.readdir(templateDir)) {
await fs.copy(path.join(templateDir, file), path.join(packagePath, file));
}

await addDependencyToMegaPackage(path.join('@aws-cdk', 'cloudformation-include'), module.packageName, version, ['dependencies', 'peerDependencies']);
await addDependencyToMegaPackage('aws-cdk-lib', module.packageName, version, ['devDependencies']);
await addDependencyToMegaPackage('monocdk', module.packageName, version, ['devDependencies']);
}
}

/**
* A few of our packages (e.g., aws-cdk-lib) require a dependency on every service package.
* This automates adding the dependency (and peer dependency) to the package.json.
*/
async function addDependencyToMegaPackage(megaPackageName: string, packageName: string, version: string, dependencyTypes: string[]) {
const packageJsonPath = path.join(__dirname, '..', '..', '..', megaPackageName, 'package.json');
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
dependencyTypes.forEach(dependencyType => {
const unorderedDeps = {
...packageJson[dependencyType],
[packageName]: version,
};
packageJson[dependencyType] = {};
Object.keys(unorderedDeps).sort().forEach(k => {
packageJson[dependencyType][k] = unorderedDeps[k];
});
});
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
}

main().catch(e => {
console.error(e);
process.exit(1);
});
Loading