-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(rosetta): find fixtures based on submodules #3131
Conversation
The `rosetta` fixtures directory is assembly-scoped. That means that in the monocdk transform, all Rosetta fixtures from the individual assemblies need to be tossed together into one `rosetta` directory for all of them. Inevitably this leads to conflicts, where the various individual `default.ts-fixture` files compete with each other to be the one, global `default.ts-fixture`. What ends up happening is they end up overwriting each other and the last module to get copied in wins. All other modules' examples fail to compile. Ideally the `ubergen` tool that combines these fixtures would ensure it doesn't clobber existing files, and renames the fixtures to unique names (maybe `s3.default.ts-fixture`). But now, *none* of them are called `default.ts-fixture` and so all snippets require explicit fixture references. Unfortunately, we now need to also automatically add in those references and it's nontrivial to do this automatically. `ubergen` would need to parse and generate both Markdown and Typescript, to add these markers in the right places. Instead, this PR adds the concept of scoped fixtures. If a class (or README) is defined in a submodule, say `aws_s3`, then we will first try `rosetta/aws_s3/default.ts-fixture` before trying `rosetta/default.ts-fixture`. That way, `ubergen` and other tools like it will have an easier time combining default fixtures.
} | ||
|
||
function middle(xs: string[]) { | ||
if (xs.length <= 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor] Why is this a special case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it doesn't need to be.
The title of this Pull Request does not conform with [Conventional Commits] guidelines. It will need to be adjusted before the PR can be merged. |
Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it! |
Merging (with squash)... |
Merging (with squash)... |
Currently ubergen bundles all fixtures into the same `rosetta` folder. This means that all fixtures in files called `default.ts-fixture` replace each other as they are found and vie to be the last `default.ts-fixture` standing in the `rosetta` folder. This causes unintended compiliation failures for `yarn rosetta:extract --compile` in projects that rely on ubergen, since they will be copied into the wrong `default.ts-fixture`. The solution here in jsii is to find fixtures based on submodules: aws/jsii#3131. This PR updates ubergen to construct the necessary subfolders in `rosetta` so that the expected submodule fixtures can be found. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Currently ubergen bundles all fixtures into the same `rosetta` folder. This means that all fixtures in files called `default.ts-fixture` replace each other as they are found and vie to be the last `default.ts-fixture` standing in the `rosetta` folder. This causes unintended compiliation failures for `yarn rosetta:extract --compile` in projects that rely on ubergen, since they will be copied into the wrong `default.ts-fixture`. The solution here in jsii is to find fixtures based on submodules: aws/jsii#3131. This PR updates ubergen to construct the necessary subfolders in `rosetta` so that the expected submodule fixtures can be found. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
The
rosetta
fixtures directory is assembly-scoped. That means that inthe monocdk transform, all Rosetta fixtures from the individual
assemblies need to be tossed together into one
rosetta
directory forall of them.
Inevitably this leads to conflicts, where the various individual
default.ts-fixture
files compete with each other to be the one,global
default.ts-fixture
. What ends up happening is they end upoverwriting each other and the last module to get copied in wins.
All other modules' examples fail to compile.
Ideally the
ubergen
tool that combines these fixtures would ensureit doesn't clobber existing files, and renames the fixtures to unique
names (maybe
s3.default.ts-fixture
). But if it does that, none of them arecalled
default.ts-fixture
and so all snippets require explicitfixture references.
Unfortunately, we now need to also automatically add in those references
and it's nontrivial to do this automatically.
ubergen
would need toparse and generate both Markdown and Typescript, to add these markers
in the right places.
Instead, this PR adds the concept of scoped fixtures. If a class
(or README) is defined in a submodule, say
aws_s3
, then we willfirst try
rosetta/aws_s3/default.ts-fixture
before tryingrosetta/default.ts-fixture
.That way,
ubergen
and other tools like it will have an easiertime combining default fixtures.
Also renamed
AssemblyFixture
=>TestJsiiModule
and made a distinctionbetween the two directories exposed by the object for more clarity on
what it's doing.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.