-
Notifications
You must be signed in to change notification settings - Fork 26
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: env-replace workspace #2251
Conversation
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.
Really nice, and good to have as a standalone package.
From the proposed next steps:
Add workflows to run selective template replacements as required. E.g.
yarn workflow android setup
could be used to update all android config files and replace variables such as the appId and versionCode from templates. It could also trigger related workflows such as processing assets.
I like this idea, I think it would make a lot of sense to include multiple workflows such as generating the native icon/splash assets in a command like that, I will keep in mind when working on #2241.
I suppose it might be more user friendly to use a syntax like yarn workflow setup_native --android --ios
, where the flags are optional (and default is both). But as we already have the android
workflow namespace it's probably not worth refactoring, we can add an equivalent ios
one.
const outputPath = resolve(cwd, outputName); | ||
writeFileSync(outputPath, replaceContent); | ||
} | ||
return this.summary; |
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.
It could be nice to log the paths of the output files here (the keys of this.summary
) to see what's been generated? Although these files won't necessarily have changed, so perhaps git diffs are a better place to view changes
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.
I had previously included a table log, although was concerned whether github actions would still be able to correctly mask any variables populated from secrets if logging after the various manipulations. No harm including as an optional config param to test later however, I'll include the update with next pr (screenshot below for reference)
PR Checklist
Description
env-replace
workspace used to manage utility methods for future template file replacementreplaceFiles
method used to rewrite.template
files using global environment variablesDev Notes
Whilst drafting a PR to populate android and ios template files I realised the code was quickly becoming unmanageable as there are various combinations of files to convert at different times with variables read from multiple places (e.g. Android config has about 5 file replacements but some need to leave templated strings in whilst others need to replace).
To reduce complexity I've moved the core replacement utility into its own workspace, and will make a follow-up pr to call specific methods from it as required.
The utility is designed to support various folder and filename search and exclusion patterns, as well as variable names to include/exclude. See full list of configuration variables included and test cases for more details.
Rough next steps would be
yarn workflow android setup
could be used to update all android config files and replace variables such as the appId and versionCode from templates. It could also trigger related workflows such as processing assets.Review Notes
Test suite can be run via
yarn workspace @idemsInternational/env-replace test
Git Issues
Closes #
Screenshots/Videos
If useful, provide screenshot or capture to highlight main changes