Skip to content

Commit

Permalink
fix(monorepo): fix issues with monorepo-ts peer deps
Browse files Browse the repository at this point in the history
fix #601, #586
  • Loading branch information
agdimech committed Oct 16, 2023
1 parent 25607d0 commit 2ee0136
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
13 changes: 9 additions & 4 deletions packages/monorepo/src/projects/typescript/monorepo-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ export class MonorepoTsProject
},
include: ["**/*.ts", ".projenrc.ts"],
},
peerDeps: ["nx@^16", ...(options.peerDeps || [])],
devDeps: ["nx@^16", "@aws/pdk@^0", ...(options.devDeps || [])],
deps: ["aws-cdk-lib", "constructs", "cdk-nag", ...(options.deps || [])],
});

this.nxConfigurator = new NxConfigurator(this, {
Expand Down Expand Up @@ -201,6 +204,12 @@ export class MonorepoTsProject
);
break;
}
case NodePackageManager.NPM: {
// Allow older versions of peer deps to resolv compatibility issues
this.tasks.tryFind("install")?.reset("npm install --legacy-peer-deps");
this.tasks.tryFind("install:ci")?.reset("npm ci --legacy-peer-deps");
break;
}
}

this.workspaceConfig = options.workspaceConfig;
Expand Down Expand Up @@ -272,10 +281,6 @@ export class MonorepoTsProject
});
}

// Add dependency on nx 16
this.addPeerDeps("nx@^16");
this.addDevDeps("nx@^16", "@aws/pdk@^0");
this.addDeps("aws-cdk-lib", "constructs", "cdk-nag"); // Needed as this can be bundled in @aws/pdk
this.package.addPackageResolutions(
"@types/[email protected]",
"wrap-ansi@^7.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/pdk/_scripts/exec-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const engines = JSON.parse(
).engines;

if (engines) {
const pkgMgr = engines.pnpm ? "pnpm" : engines.yarn ? "yarn" : "npm";
execa.commandSync(`${pkgMgr}${isSynth ? " projen" : ""} ${process.argv.join(" ")}`, { stdio: "inherit" });
const pkgMgrCmd = engines.pnpm ? "pnpm" : engines.yarn ? "yarn" : "npm run";
execa.commandSync(`${pkgMgrCmd}${isSynth ? " default" : ""} ${process.argv.join(" ")}`, { stdio: "inherit" });
} else {
execa.commandSync(`npx projen ${process.argv.join(" ")}`, { stdio: "inherit"});
}

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

0 comments on commit 2ee0136

Please sign in to comment.