Skip to content

Commit

Permalink
chore(monocdk): upgrade jsii and generate bindings for monocdk (aws#7520
Browse files Browse the repository at this point in the history
)

Those bindings are experimental in that the name of types within those is subject to change
in the future as jsii adds features to enable name customization. The names are eventually
expected to converge to those in the individual modules
  • Loading branch information
RomainMuller authored Apr 23, 2020
1 parent 3eeb21e commit 607b84b
Show file tree
Hide file tree
Showing 14 changed files with 219 additions and 137 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"devDependencies": {
"conventional-changelog-cli": "^2.0.31",
"fs-extra": "^8.1.0",
"jsii-diff": "^1.3.2",
"jsii-pacmak": "^1.3.2",
"jsii-rosetta": "^1.3.2",
"jsii-diff": "^1.4.1",
"jsii-pacmak": "^1.4.1",
"jsii-rosetta": "^1.4.1",
"lerna": "^3.20.2",
"standard-version": "^7.1.0",
"typescript": "~3.8.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk-dasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"codemaker": "^1.3.2",
"codemaker": "^1.4.1",
"yaml": "1.9.2"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/decdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
"@aws-cdk/region-info": "0.0.0",
"constructs": "^3.0.2",
"fs-extra": "^8.1.0",
"jsii-reflect": "^1.3.2",
"jsii-reflect": "^1.4.1",
"jsonschema": "^1.2.6",
"yaml": "1.9.2",
"yargs": "^15.3.1"
Expand All @@ -184,7 +184,7 @@
"@types/yaml": "1.2.0",
"@types/yargs": "^15.0.4",
"jest": "^25.4.0",
"jsii": "^1.3.2"
"jsii": "^1.4.1"
},
"keywords": [
"aws",
Expand Down
1 change: 1 addition & 0 deletions packages/monocdk-experiment/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
!deps.js
!gen.js
staging/
tsconfig.json
1 change: 1 addition & 0 deletions packages/monocdk-experiment/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ dist
.LAST_PACKAGE
.jsii

tsconfig.json
*.tsbuildinfo
18 changes: 9 additions & 9 deletions packages/monocdk-experiment/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ echo "installing dependencies for bundling..."
npm install

echo "compiling..."
tsc
${CDK_BUILD_JSII:-jsii}

echo "packaging..."
npm pack
tarball=$PWD/monocdk-experiment-*.tgz
${CDK_PACKAGE_JSII_PACMAK:-jsii-pacmak}
tarball=$PWD/dist/js/monocdk-experiment@*.tgz

echo "verifying package..."
cd $(mktemp -d)
Expand All @@ -28,11 +28,11 @@ npm install ${tarball} constructs@${constructs_version}
node -e "require('monocdk-experiment')"
unpacked=$(node -p 'path.dirname(require.resolve("monocdk-experiment/package.json"))')

# saving tarball
cd ${scriptdir}
mkdir -p dist/js
cp ${tarball} dist/js
# saving publishable artifact
rm -fr ${scriptdir}/dist
mv ${outdir}/dist ${scriptdir}/dist

# so this module will also work as a local dependency (e.g. for modules under @monocdk-experiment/*).
rm -fr staging
mv ${unpacked} staging
rm -fr ${scriptdir}/staging
mv ${unpacked} ${scriptdir}/staging
mv ${scriptdir}/staging/.jsii ${scriptdir}
36 changes: 20 additions & 16 deletions packages/monocdk-experiment/gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const path = require('path');
const glob = require('glob');
const os = require('os');

const exclude_modules = [
const exclude_modules = [
// 'aws-lambda-nodejs' // bundles "parcel" which is unacceptable for now
];

const include_non_jsii = [
const include_non_jsii = [
// 'assert',
// 'cloudformation-diff',
];
Expand All @@ -22,14 +22,14 @@ const include_dev_deps = [
const exclude_files = [
'test',
'scripts',
'node_modules',
'package.json',
'tsconfig.json',
'tsconfig.tsbuildinfo',
'.gitignore',
'.jsii',
'LICENSE',
'NOTICE'
'node_modules',
'package.json',
'tsconfig.json',
'tsconfig.tsbuildinfo',
'.gitignore',
'.jsii',
'LICENSE',
'NOTICE'
];

async function main() {
Expand All @@ -46,6 +46,10 @@ async function main() {
const modules = await fs.readdir(root);
const manifest = await fs.readJson(path.join(monocdkroot, 'package.json'));

// Adjust index location for initial compilation
manifest.main = manifest.main.replace(/^staging\//, '');
manifest.types = manifest.types.replace(/^staging\//, '');

const nodeTypes = manifest.devDependencies['@types/node'];
if (!nodeTypes) {
throw new Error(`@types/node must be defined in devDependencies`);
Expand Down Expand Up @@ -134,12 +138,12 @@ async function main() {
const bundled = [ ...meta.bundleDependencies || [], ...meta.bundledDependencies || [] ];
for (const d of bundled) {
const ver = meta.dependencies[d];

console.error(`adding bundled dep ${d} with version ${ver}`);
if (!pkgBundled.includes(d)) {
pkgBundled.push(d);
}

if (!ver) {
throw new Error(`cannot determine version for bundled dep ${d} of module ${meta.name}`);
}
Expand All @@ -151,7 +155,7 @@ async function main() {
throw new Error(`version mismatch for bundled dep ${d}: ${meta.name} requires version ${ver} but we already have version ${existingVer}`);
}
}
}
}
}

await fs.writeFile(path.join(outdir, 'index.ts'), reexports.join('\n'));
Expand All @@ -162,12 +166,12 @@ async function main() {
await rewriteImports(outdir, source);
}

// copy tsconfig.json and .npmignore
const files = [ 'tsconfig.json', '.npmignore', 'README.md', 'LICENSE', 'NOTICE' ];
// copy .npmignore, license stuff, readme, ...
const files = [ '.npmignore', 'README.md', 'LICENSE', 'NOTICE' ];
for (const file of files) {
await fs.copy(path.join(monocdkroot, file), path.join(outdir, file));
}

console.error('writing package.json');
await fs.writeJson(path.join(outdir, 'package.json'), manifest, { spaces: 2 });

Expand Down
25 changes: 23 additions & 2 deletions packages/monocdk-experiment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "monocdk-experiment",
"version": "0.0.0",
"description": "An experiment to bundle the entire CDK into a single module",
"main": "index.js",
"types": "index.d.ts",
"main": "staging/index.js",
"types": "staging/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/aws/aws-cdk.git"
Expand All @@ -17,6 +17,27 @@
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test && npm run package"
},
"jsii": {
"outdir": "dist",
"targets": {
"java": {
"package": "software.amazon.awscdk.monocdkexperiment",
"maven": {
"groupId": "software.amazon.awscdk",
"artifactId": "monocdk-experiment",
"versionSuffix": ".DEVPREVIEW"
}
},
"dotnet": {
"namespace": "Amazon.CDK.MonoCDK.Experiment",
"packageId": "Amazon.CDK.MonoCDK.Experiment",
"iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png",
"versionSuffix": "-devpreview",
"signAssembly": true,
"assemblyOriginatorKeyFile": "../../key.snk"
}
}
},
"author": {
"name": "Amazon Web Services",
"url": "https://aws.amazon.com",
Expand Down
18 changes: 0 additions & 18 deletions packages/monocdk-experiment/tsconfig.json

This file was deleted.

1 change: 1 addition & 0 deletions scripts/check-api-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ success=true
for dir in $jsii_package_dirs; do
name=$(package_name "$dir")
if [[ ! -d $tmpdir/node_modules/$name ]]; then continue; fi
if [[ ! -f $tmpdir/node_modules/$name/.jsii ]]; then continue; fi
echo -n "$name... "
if npx jsii-diff \
--keys \
Expand Down
4 changes: 2 additions & 2 deletions tools/awslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"awslint": "bin/awslint"
},
"dependencies": {
"@jsii/spec": "^1.3.2",
"@jsii/spec": "^1.4.1",
"camelcase": "^6.0.0",
"colors": "^1.4.0",
"fs-extra": "^8.1.0",
"jsii-reflect": "^1.3.2",
"jsii-reflect": "^1.4.1",
"yargs": "^15.3.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions tools/cdk-build-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"eslint-plugin-import": "^2.20.2",
"fs-extra": "^8.1.0",
"jest": "^25.4.0",
"jsii": "^1.3.2",
"jsii-pacmak": "^1.3.2",
"jsii": "^1.4.1",
"jsii-pacmak": "^1.4.1",
"nodeunit": "^0.11.3",
"nyc": "^15.0.1",
"ts-jest": "^25.4.0",
Expand Down
2 changes: 1 addition & 1 deletion tools/cfn2ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"license": "Apache-2.0",
"dependencies": {
"@aws-cdk/cfnspec": "0.0.0",
"codemaker": "^1.3.2",
"codemaker": "^1.4.1",
"fast-json-patch": "^3.0.0-1",
"fs-extra": "^8.1.0",
"yargs": "^15.3.1"
Expand Down
Loading

0 comments on commit 607b84b

Please sign in to comment.