diff --git a/.projen/deps.json b/.projen/deps.json index 1d928f783..f596c487e 100644 --- a/.projen/deps.json +++ b/.projen/deps.json @@ -23,6 +23,7 @@ }, { "name": "aws-prototyping-sdk", + "version": "0.0.0", "type": "build" }, { diff --git a/.projen/tasks.json b/.projen/tasks.json index f5e6dc45d..9d052c6c7 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -64,6 +64,9 @@ "name": "default", "description": "Synthesize project files", "steps": [ + { + "exec": "cd packages/aws-prototyping-sdk && $(if [ ! -d lib ]; then npx projen compile > /dev/null; fi;)" + }, { "exec": "ts-node --project tsconfig.dev.json .projenrc.ts" } diff --git a/.projenrc.ts b/.projenrc.ts index 647f03df3..c764eae6a 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -1,4 +1,4 @@ -import { pdk_projen } from 'aws-prototyping-sdk'; +import * as pdk_projen from 'aws-prototyping-sdk/src/pdk_projen/index'; import { JsiiProject } from 'projen/lib/cdk'; import { Release } from 'projen/lib/release'; import { DependencyType } from 'projen'; @@ -21,6 +21,9 @@ const resolveDependencies = (project: NodeProject): NodeProject => { } const configureMonorepo = (monorepo: pdk_projen.NxMonorepoProject): pdk_projen.NxMonorepoProject => { + // Compile pdk as we depend on it in order to bootstrap this repo + monorepo.defaultTask?.prependExec("cd packages/aws-prototyping-sdk && $(if [ ! -d lib ]; then npx projen compile > /dev/null; fi;)"); + monorepo.addTask("prepare", { exec: "husky install", }); @@ -105,10 +108,12 @@ const configureAwsPrototypingSdk = (project: JsiiProject): JsiiProject => { }); // jsii requires peer deps not to be hoisted. This is a workaround for: https://github.com/yarnpkg/yarn/issues/7672 + // TODO: make this more robust as this assumes all deps default to the root node_modules project.preCompileTask.exec(`rm -rf node_modules && mkdir node_modules && cd node_modules && ${project.deps.all .filter(d => d.type === DependencyType.PEER) .map(d => `cp -R ../../../node_modules/${d.name} .`) .join(" && ")}`); + project.postCompileTask.exec("rm -rf node_modules"); // Generate docs for each supported language into a micro-site const buildDocsTask = project.addTask("build:docs", { @@ -177,7 +182,7 @@ const monorepo = configureMonorepo(new pdk_projen.NxMonorepoProject({ eslint: false, name: "aws-prototyping-sdk-monorepo", devDeps: [ - "aws-prototyping-sdk", + "aws-prototyping-sdk@0.0.0", "@commitlint/cli", "@commitlint/config-conventional", "cz-conventional-changelog", @@ -222,7 +227,7 @@ const awsPrototypingSdk = configureAwsPrototypingSdk(new JsiiProject({ } })); -const sampleNxMonorepoTs = configureSampleTs(new TypeScriptProject({ +configureSampleTs(new TypeScriptProject({ parent: monorepo, outdir: "samples/sample-nx-monorepo", defaultReleaseBranch: "mainline", @@ -230,11 +235,12 @@ const sampleNxMonorepoTs = configureSampleTs(new TypeScriptProject({ sampleCode: false, deps: [ "aws-cdk-lib", - "constructs" + "constructs", + "aws-prototyping-sdk@0.0.0" ] })); -const samplePdkPipelineTs = configureSampleTs(new TypeScriptProject({ +configureSampleTs(new TypeScriptProject({ parent: monorepo, outdir: "samples/sample-pdk-pipeline-ts", defaultReleaseBranch: "mainline", @@ -242,7 +248,8 @@ const samplePdkPipelineTs = configureSampleTs(new TypeScriptProject({ sampleCode: false, deps: [ "aws-cdk-lib", - "constructs" + "constructs", + "aws-prototyping-sdk@0.0.0" ] })); @@ -262,8 +269,6 @@ const samplePdkPipelinePy = configureSamplePy(new PythonProject({ ] })); -monorepo.addImplicitDependency(sampleNxMonorepoTs, awsPrototypingSdk); -monorepo.addImplicitDependency(samplePdkPipelineTs, awsPrototypingSdk); monorepo.addImplicitDependency(samplePdkPipelinePy, awsPrototypingSdk); monorepo.synth(); diff --git a/nx.json b/nx.json index b75c281db..b8191d7b3 100644 --- a/nx.json +++ b/nx.json @@ -17,12 +17,6 @@ } }, "implicitDependencies": { - "sample-nx-monorepo": [ - "aws-prototyping-sdk" - ], - "sample-pdk-pipeline-ts": [ - "aws-prototyping-sdk" - ], "sample-pdk-pipeline-py": [ "aws-prototyping-sdk" ] diff --git a/package.json b/package.json index 239187ce4..dc3846426 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@nrwl/cli": "^13.8.4", "@nrwl/workspace": "^13.8.4", "@types/node": "^12", - "aws-prototyping-sdk": "^0.0.25", + "aws-prototyping-sdk": "0.0.0", "cz-conventional-changelog": "^3.3.0", "husky": "^7.0.4", "npm-check-updates": "^12", diff --git a/packages/aws-prototyping-sdk/.projen/tasks.json b/packages/aws-prototyping-sdk/.projen/tasks.json index e88f9e4ec..6e67628fb 100644 --- a/packages/aws-prototyping-sdk/.projen/tasks.json +++ b/packages/aws-prototyping-sdk/.projen/tasks.json @@ -235,7 +235,12 @@ }, "post-compile": { "name": "post-compile", - "description": "Runs after successful compilation" + "description": "Runs after successful compilation", + "steps": [ + { + "exec": "rm -rf node_modules" + } + ] }, "post-upgrade": { "name": "post-upgrade", diff --git a/packages/aws-prototyping-sdk/src/pdk_projen/nx_monorepo/nx-monorepo-project.ts b/packages/aws-prototyping-sdk/src/pdk_projen/nx_monorepo/nx-monorepo-project.ts index a28f7d7d8..ef69526d5 100644 --- a/packages/aws-prototyping-sdk/src/pdk_projen/nx_monorepo/nx-monorepo-project.ts +++ b/packages/aws-prototyping-sdk/src/pdk_projen/nx_monorepo/nx-monorepo-project.ts @@ -4,7 +4,6 @@ import * as fs from "fs"; import * as path from "path"; import { IgnoreFile, JsonFile, Project, TextFile } from "projen"; -import { NodeProject } from "projen/lib/javascript"; import { TypeScriptProject, TypeScriptProjectOptions, @@ -117,7 +116,7 @@ export class NxMonorepoProject extends TypeScriptProject { this.compileTask.reset(); this.testTask.reset(); - this.addDevDeps("aws-prototyping-sdk", "@nrwl/cli", "@nrwl/workspace"); + this.addDevDeps("@nrwl/cli", "@nrwl/workspace"); new IgnoreFile(this, ".nxignore").exclude( "test-reports", @@ -240,12 +239,19 @@ export class NxMonorepoProject extends TypeScriptProject { newSubProject && super.synth(); this.subProjects - .filter((subProject) => !(subProject instanceof NodeProject)) + .filter( + (subProject) => + !fs.existsSync(`${subProject.outdir}/package.json`) || + JSON.parse( + fs.readFileSync(`${subProject.outdir}/package.json`).toString() + ).__pdk__ + ) .forEach((subProject) => { // generate a package.json if not found const manifest: any = {}; manifest.name = subProject.name; manifest.private = true; + manifest.__pdk__ = true; manifest.scripts = subProject.tasks.all.reduce( (p, c) => ({ [c.name]: `npx projen ${c.name}`, diff --git a/samples/sample-nx-monorepo/.projen/deps.json b/samples/sample-nx-monorepo/.projen/deps.json index ff6f5bd4b..f43be9d7f 100644 --- a/samples/sample-nx-monorepo/.projen/deps.json +++ b/samples/sample-nx-monorepo/.projen/deps.json @@ -70,6 +70,11 @@ "name": "aws-cdk-lib", "type": "runtime" }, + { + "name": "aws-prototyping-sdk", + "version": "0.0.0", + "type": "runtime" + }, { "name": "constructs", "type": "runtime" diff --git a/samples/sample-nx-monorepo/.projen/tasks.json b/samples/sample-nx-monorepo/.projen/tasks.json index 804ad3ec3..e54c1a571 100644 --- a/samples/sample-nx-monorepo/.projen/tasks.json +++ b/samples/sample-nx-monorepo/.projen/tasks.json @@ -172,7 +172,7 @@ "exec": "yarn install --check-files" }, { - "exec": "yarn upgrade @types/jest @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-import-resolver-node eslint-import-resolver-typescript eslint-plugin-import eslint jest jest-junit json-schema npm-check-updates ts-jest typescript aws-cdk-lib constructs" + "exec": "yarn upgrade @types/jest @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-import-resolver-node eslint-import-resolver-typescript eslint-plugin-import eslint jest jest-junit json-schema npm-check-updates ts-jest typescript aws-cdk-lib aws-prototyping-sdk constructs" }, { "exec": "npx projen" diff --git a/samples/sample-nx-monorepo/package.json b/samples/sample-nx-monorepo/package.json index 405d30217..6d688afd4 100644 --- a/samples/sample-nx-monorepo/package.json +++ b/samples/sample-nx-monorepo/package.json @@ -38,6 +38,7 @@ }, "dependencies": { "aws-cdk-lib": "^2.15.0", + "aws-prototyping-sdk": "0.0.0", "constructs": "^10.0.78" }, "main": "lib/index.js", diff --git a/samples/sample-pdk-pipeline-py/.gitignore b/samples/sample-pdk-pipeline-py/.gitignore index 7dfc7a0f5..cfe70926f 100644 --- a/samples/sample-pdk-pipeline-py/.gitignore +++ b/samples/sample-pdk-pipeline-py/.gitignore @@ -83,4 +83,3 @@ dmypy.json .pytype/ cython_debug/ -!/package.json diff --git a/samples/sample-pdk-pipeline-py/.projen/deps.json b/samples/sample-pdk-pipeline-py/.projen/deps.json index 7da334bd3..355a23d23 100644 --- a/samples/sample-pdk-pipeline-py/.projen/deps.json +++ b/samples/sample-pdk-pipeline-py/.projen/deps.json @@ -2,7 +2,7 @@ "dependencies": [ { "name": "projen", - "version": "0.52.54", + "version": "0.52.56", "type": "devenv" }, { diff --git a/samples/sample-pdk-pipeline-py/.projen/files.json b/samples/sample-pdk-pipeline-py/.projen/files.json index 789033fe8..75ce256bb 100644 --- a/samples/sample-pdk-pipeline-py/.projen/files.json +++ b/samples/sample-pdk-pipeline-py/.projen/files.json @@ -5,7 +5,6 @@ ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", - "package.json", "requirements-dev.txt", "requirements.txt" ], diff --git a/samples/sample-pdk-pipeline-py/package.json b/samples/sample-pdk-pipeline-py/package.json index 099ad020a..7878155a9 100644 --- a/samples/sample-pdk-pipeline-py/package.json +++ b/samples/sample-pdk-pipeline-py/package.json @@ -1,5 +1,7 @@ { "name": "sample-pdk-pipeline-py", + "private": true, + "__pdk__": false, "scripts": { "install": "npx projen install", "clobber": "npx projen clobber", diff --git a/samples/sample-pdk-pipeline-py/requirements-dev.txt b/samples/sample-pdk-pipeline-py/requirements-dev.txt index 051f858d3..5b45b601e 100644 --- a/samples/sample-pdk-pipeline-py/requirements-dev.txt +++ b/samples/sample-pdk-pipeline-py/requirements-dev.txt @@ -1,3 +1,3 @@ # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". -projen==0.52.54 +projen==0.52.56 pytest==6.2.1 diff --git a/samples/sample-pdk-pipeline-ts/.projen/deps.json b/samples/sample-pdk-pipeline-ts/.projen/deps.json index ff6f5bd4b..f43be9d7f 100644 --- a/samples/sample-pdk-pipeline-ts/.projen/deps.json +++ b/samples/sample-pdk-pipeline-ts/.projen/deps.json @@ -70,6 +70,11 @@ "name": "aws-cdk-lib", "type": "runtime" }, + { + "name": "aws-prototyping-sdk", + "version": "0.0.0", + "type": "runtime" + }, { "name": "constructs", "type": "runtime" diff --git a/samples/sample-pdk-pipeline-ts/.projen/tasks.json b/samples/sample-pdk-pipeline-ts/.projen/tasks.json index 804ad3ec3..e54c1a571 100644 --- a/samples/sample-pdk-pipeline-ts/.projen/tasks.json +++ b/samples/sample-pdk-pipeline-ts/.projen/tasks.json @@ -172,7 +172,7 @@ "exec": "yarn install --check-files" }, { - "exec": "yarn upgrade @types/jest @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-import-resolver-node eslint-import-resolver-typescript eslint-plugin-import eslint jest jest-junit json-schema npm-check-updates ts-jest typescript aws-cdk-lib constructs" + "exec": "yarn upgrade @types/jest @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-import-resolver-node eslint-import-resolver-typescript eslint-plugin-import eslint jest jest-junit json-schema npm-check-updates ts-jest typescript aws-cdk-lib aws-prototyping-sdk constructs" }, { "exec": "npx projen" diff --git a/samples/sample-pdk-pipeline-ts/package.json b/samples/sample-pdk-pipeline-ts/package.json index ddf829dc1..f66b49a2e 100644 --- a/samples/sample-pdk-pipeline-ts/package.json +++ b/samples/sample-pdk-pipeline-ts/package.json @@ -38,6 +38,7 @@ }, "dependencies": { "aws-cdk-lib": "^2.15.0", + "aws-prototyping-sdk": "0.0.0", "constructs": "^10.0.78" }, "main": "lib/index.js", diff --git a/yarn.lock b/yarn.lock index ba79ba72c..d7f51cde1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1535,14 +1535,6 @@ aws-cdk-lib@^2.15.0: semver "^7.3.5" yaml "1.10.2" -aws-prototyping-sdk@^0.0.25: - version "0.0.25" - resolved "https://registry.yarnpkg.com/aws-prototyping-sdk/-/aws-prototyping-sdk-0.0.25.tgz#4b06ccdb416b385ec3ff3127f348550aeff680e2" - integrity sha512-koF+1EndJBZ8OcQw91hVUiXta3hThSMdca7RjHZdRz0wuILv+vxtmAhD9AJW8u1p79AF2Ipk5AUzqpkxqHHIPA== - dependencies: - aws-cdk-lib "^2.15.0" - constructs "^10.0.76" - babel-jest@^27.2.2, babel-jest@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-27.5.1.tgz#a1bf8d61928edfefd21da27eb86a695bfd691444" @@ -2139,10 +2131,10 @@ console-control-strings@^1.1.0: resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= -constructs@^10.0.76, constructs@^10.0.77, constructs@^10.0.78: - version "10.0.78" - resolved "https://registry.yarnpkg.com/constructs/-/constructs-10.0.78.tgz#2ae717d0ce86e04e2360d4722cfa097c740b4ab0" - integrity sha512-i1dZaygBiliDs17hzcuU9VW4QQnJV7rjzCl66nZcTIjxmoZ+tVzf2wV4+aQOo0MxPAikL9eY34tZ/w8XOTKakA== +constructs@^10.0.77, constructs@^10.0.78: + version "10.0.79" + resolved "https://registry.yarnpkg.com/constructs/-/constructs-10.0.79.tgz#a389c15b6d6ac06f5a43679d32be80b10272806f" + integrity sha512-7HQzd4m8W7IQBryzuuHgBbYaPK/gKXOeSFYZad/ax1HVtN5hcTQccVtPMdeR04rzSsicnymr2llANYpK70CsHA== conventional-changelog-angular@^5.0.11, conventional-changelog-angular@^5.0.12: version "5.0.13" @@ -2669,9 +2661,9 @@ ejs@^3.1.5: jake "^10.6.1" electron-to-chromium@^1.4.71: - version "1.4.75" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.75.tgz#d1ad9bb46f2f1bf432118c2be21d27ffeae82fdd" - integrity sha512-LxgUNeu3BVU7sXaKjUDD9xivocQLxFtq6wgERrutdY/yIOps3ODOZExK1jg8DTEg4U8TUCb5MLGeWFOYuxjF3Q== + version "1.4.76" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.76.tgz#a0494baedaf51094b1c172999919becd9975a934" + integrity sha512-3Vftv7cenJtQb+k00McEBZ2vVmZ/x+HEF7pcZONZIkOsESqAqVuACmBxMv0JhzX7u0YltU0vSqRqgBSTAhFUjA== emittery@^0.8.1: version "0.8.1" @@ -4793,9 +4785,9 @@ jsii-diff@^1.54.0: yargs "^16.2.0" jsii-docgen@^6.1.20: - version "6.1.21" - resolved "https://registry.yarnpkg.com/jsii-docgen/-/jsii-docgen-6.1.21.tgz#66ae68a64a85788bdd9eaf84179e257b3667cda0" - integrity sha512-UHi3GE6mDh0HJ2fi6gykL5ka84Q6HBPROt+6OtZL+FUf6RRk7t0sLAHHcVNBG+IxlPuoBuTp6Jvd0nD+rsmvNg== + version "6.1.22" + resolved "https://registry.yarnpkg.com/jsii-docgen/-/jsii-docgen-6.1.22.tgz#cd2c05c082aebd365f4f435733fad4cf40fad0dd" + integrity sha512-NFCren8u+c4QjMSma1yPn+z3eFNAiWJ6/qXNeY7N9oi5e827toLLdV9kKVroI+tb1VlUD1i1Cd5LOW3GwLQDyA== dependencies: "@jsii/spec" "^1.54.0" case "^1.6.3" @@ -5176,9 +5168,9 @@ lru-cache@^6.0.0: yallist "^4.0.0" lru-cache@^7.3.1, lru-cache@^7.4.0: - version "7.4.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.4.0.tgz#2830a779b483e9723e20f26fa5278463c50599d8" - integrity sha512-YOfuyWa/Ee+PXbDm40j9WXyJrzQUynVbgn4Km643UYcWNcrSfRkKL0WaiUcxcIbkXcVTgNpDqSnPXntWXT75cw== + version "7.4.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.4.1.tgz#afe07e885ef0cd5bf99f62f4fa7545d48746d779" + integrity sha512-NCD7/WRlFmADccuHjsRUYqdluYBr//n/O0fesCb/n52FoGcgKh8o4Dpm7YIbZwVcDs8rPBQbCZLmWWsp6m+xGQ== make-dir@^3.0.0: version "3.1.0" @@ -6185,9 +6177,9 @@ projen@0.52.53: yargs "^16.2.0" projen@^0.52.53, projen@^0.52.54: - version "0.52.54" - resolved "https://registry.yarnpkg.com/projen/-/projen-0.52.54.tgz#81df7c304fb9c896398d701205c8d8e9ec110e86" - integrity sha512-b88HgIXK1QZSQB7Hfy9V7S6pNEdg5I1cqqnpWJjhn/tPpdGMg7LVLEPr+SSBKjfKux6qqfwsSxw6iSgKgEDDZw== + version "0.52.56" + resolved "https://registry.yarnpkg.com/projen/-/projen-0.52.56.tgz#e24a966ba63fe32e85ab9169af7205dbeab055b5" + integrity sha512-8My7YSUMyona+2iO5QaKXBjYM9JomQB+OV00zlE0CuLDwQE5fuigkNJ3TE15prhVriv4jlNRl5V0tL1a2l3eVw== dependencies: "@iarna/toml" "^2.2.5" case "^1.6.3"