Skip to content

Commit

Permalink
build: fix linking so that all projects reference the local aws-proto…
Browse files Browse the repository at this point in the history
…typing-sdk
  • Loading branch information
agdimech committed Mar 5, 2022
1 parent 233b61f commit e53a462
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 49 deletions.
1 change: 1 addition & 0 deletions .projen/deps.json

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

3 changes: 3 additions & 0 deletions .projen/tasks.json

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

21 changes: 13 additions & 8 deletions .projenrc.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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",
});
Expand Down Expand Up @@ -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", {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -222,27 +227,29 @@ const awsPrototypingSdk = configureAwsPrototypingSdk(new JsiiProject({
}
}));

const sampleNxMonorepoTs = configureSampleTs(new TypeScriptProject({
configureSampleTs(new TypeScriptProject({
parent: monorepo,
outdir: "samples/sample-nx-monorepo",
defaultReleaseBranch: "mainline",
name: "sample-nx-monorepo",
sampleCode: false,
deps: [
"aws-cdk-lib",
"constructs"
"constructs",
"[email protected]"
]
}));

const samplePdkPipelineTs = configureSampleTs(new TypeScriptProject({
configureSampleTs(new TypeScriptProject({
parent: monorepo,
outdir: "samples/sample-pdk-pipeline-ts",
defaultReleaseBranch: "mainline",
name: "sample-pdk-pipeline-ts",
sampleCode: false,
deps: [
"aws-cdk-lib",
"constructs"
"constructs",
"[email protected]"
]
}));

Expand All @@ -262,8 +269,6 @@ const samplePdkPipelinePy = configureSamplePy(new PythonProject({
]
}));

monorepo.addImplicitDependency(sampleNxMonorepoTs, awsPrototypingSdk);
monorepo.addImplicitDependency(samplePdkPipelineTs, awsPrototypingSdk);
monorepo.addImplicitDependency(samplePdkPipelinePy, awsPrototypingSdk);

monorepo.synth();
6 changes: 0 additions & 6 deletions nx.json

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

2 changes: 1 addition & 1 deletion package.json

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

7 changes: 6 additions & 1 deletion packages/aws-prototyping-sdk/.projen/tasks.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}`,
Expand Down
5 changes: 5 additions & 0 deletions samples/sample-nx-monorepo/.projen/deps.json

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

2 changes: 1 addition & 1 deletion samples/sample-nx-monorepo/.projen/tasks.json

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

1 change: 1 addition & 0 deletions samples/sample-nx-monorepo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion samples/sample-pdk-pipeline-py/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,3 @@ dmypy.json
.pytype/

cython_debug/
!/package.json
2 changes: 1 addition & 1 deletion samples/sample-pdk-pipeline-py/.projen/deps.json

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

1 change: 0 additions & 1 deletion samples/sample-pdk-pipeline-py/.projen/files.json

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

2 changes: 2 additions & 0 deletions samples/sample-pdk-pipeline-py/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "sample-pdk-pipeline-py",
"private": true,
"__pdk__": false,
"scripts": {
"install": "npx projen install",
"clobber": "npx projen clobber",
Expand Down
2 changes: 1 addition & 1 deletion samples/sample-pdk-pipeline-py/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions samples/sample-pdk-pipeline-ts/.projen/deps.json

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

2 changes: 1 addition & 1 deletion samples/sample-pdk-pipeline-ts/.projen/tasks.json

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

1 change: 1 addition & 0 deletions samples/sample-pdk-pipeline-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
40 changes: 16 additions & 24 deletions yarn.lock

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

0 comments on commit e53a462

Please sign in to comment.