Skip to content
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): transliterate loose mode #2892

Merged
merged 6 commits into from
Jun 30, 2021
Merged

feat(rosetta): transliterate loose mode #2892

merged 6 commits into from
Jun 30, 2021

Conversation

RomainMuller
Copy link
Contributor

When transliterating code samples from a published package tarball,
supporting files such as fixtures and literate source files may be
missing (typically because they are part of the .npmignore file).

The new --loose option to jsii transliterate allows ignoring those
problems by:

  • Ignoring missing fixtures (the behavior is then the same as if no
    fixture was requested)
  • Falling back to the .lit.js file when the .lit.ts file cannot be
    found, or replacing the source with a placeholder if neither file
    could be found

This addresses the issue outlined in cdklabs/construct-hub#127


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

When transliterating code samples from a published package tarball,
supporting files such as fixtures and literate source files may be
missing (typically because they are part of the `.npmignore` file).

The new `--loose` option to `jsii transliterate` allows ignoring those
problems by:

- Ignoring missing fixtures (the behavior is then the same as if no
  fixture was requested)
- Falling back to the `.lit.js` file when the `.lit.ts` file cannot be
  found, or replacing the source with a placeholder if neither file
  could be found
@RomainMuller RomainMuller self-assigned this Jun 29, 2021
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jun 29, 2021
// In loose mode, we'll fall back to the `.js` file if it exists...
const jsFile = fullPath.replace(/\.ts(x?)$/, '.js$1');
if (fs.existsSync(jsFile)) {
return fs.readFileSync(jsFile, { encoding: 'utf-8' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a header here saying we are showing js code because the expected file is missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is unfortunately no way to reliably do this... Leading comments will be ignored if they are not attached to a render-able statement, which may not even exist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh well, we tried

@mergify
Copy link
Contributor

mergify bot commented Jun 30, 2021

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Jun 30, 2021
@mergify mergify bot merged commit 43e6dfd into main Jun 30, 2021
@mergify mergify bot deleted the rmuller/rosetta-loose branch June 30, 2021 09:25
@mergify
Copy link
Contributor

mergify bot commented Jun 30, 2021

Merging (with squash)...

@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants