aws / aws-pdk

The AWS PDK provides building blocks for common patterns together with development tools to manage and build your projects.
https://aws.github.io/aws-pdk/
Apache License 2.0
374 stars 74 forks source link

[FEATURE] make affected.defaultBase configurable in nx.json #167

Closed ktfleming closed 2 years ago

ktfleming commented 2 years ago

Describe the feature

Right now affected.defaultBase in the generated nx.json is hardcoded to mainline:

https://github.com/aws/aws-prototyping-sdk/blob/4881808bdccb2f3e53df5fc96acc186612634bed/packages/nx-monorepo/src/nx-monorepo.ts#L300-L302

It would be nice if this could be configured in the projen config file.

Use Case

When not using a mainline branch, some nx commands will fail. For example, npx nx print-affected fails with

Error: Command failed: git merge-base --fork-point "mainline" "HEAD"
fatal: No such ref: 'mainline'

Proposed Solution

The branch could be specified as a new parameter in the projen file, or it could be set to options.defaultReleaseBranch (I'm new to nx and not sure which is more appropriate).

Other Information

No response

Acknowledgements

PDK version used

v0.11.1

What languages will this feature affect?

No response

Environment details (OS name and version, etc.)

Mac OS 12.3.1

cogwirrel commented 2 years ago

Hey, thanks for the feature request!

I can definitely see it being useful to set the affected branch :) defaultReleaseBranch could be a good candidate, though it could also be added to the nxConfig option so it's colocated with other NX options. I'll discuss with dimecha@ when he's back!

As a workaround you can actually customise your nx.json (or other projen managed files) prior to the call to synth(). For example:

const monorepo = new NxMonorepoProject({
  ...
});

monorepo.tryFindObjectFile('nx.json')!.addOverride('affected.defaultBase', 'my-branch');

monorepo.synth();

Hope that helps!

Thanks, Jack