You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great if opentofu-repo/version/VERSION could be used to populate those other files.
Basic Example
I've been working on an interpolation Docusaurus plugin that could achieve this by specifying a config object such as:
{TOFU_VERSION: async()=>{constpath=require('path').join('opentofu-repo','version','VERSION');constversion=awaitrequire('fs/promises').readFile(path,{encoding: 'utf8'});returnversion.trim();}// Other variables...}
With that in place, replacing 1.6.0-alpha2 with %TOFU_VERSION% in the lagging files outputs the correct version string.
It also makes it available in the global namespace under the variable name TOFU_VERSION.
Drawbacks
One downside is that those particular files are included as raw files, without webpack/Docusaurus really touching them. Currently, they're included via raw-loader imports, which is a great way of declaring raw files where they're needed instead of specifying a whitelist in some config. However, this approach doesn't allow other plugins to hook into the processing of the imported files.
To add to that, raw-loader is officially deprecated in favor of Asset Modules (asset/source, specifically). Instead of using !!raw-loader!./file, the webpack docs recommend appending a ?raw query string to indicate that a file is to be included in raw form. This opens the door for injecting other logic in the processing of raw files, like injecting a version string. 😉
All in all, it can be done, though the solution is a bit too webpacky. That said, it does allow for site-wide interpolation for any sort of value, not just a computed version string.
Unresolved questions
If there's interest, I will open a PR.
The text was updated successfully, but these errors were encountered:
Hey @xuoe, this is a great suggestion! However, regarding the install script, if we parse variables in them, that will interfere with the script language (bash/powershell) itself and make the scripts untestable in their raw form.
Summary
I imagine these are difficult to keep in sync (note
alpha2
vs.alpha5
):It would be great if
opentofu-repo/version/VERSION
could be used to populate those other files.Basic Example
I've been working on an interpolation Docusaurus plugin that could achieve this by specifying a config object such as:
With that in place, replacing
1.6.0-alpha2
with%TOFU_VERSION%
in the lagging files outputs the correct version string.It also makes it available in the global namespace under the variable name TOFU_VERSION.
Drawbacks
One downside is that those particular files are included as raw files, without webpack/Docusaurus really touching them. Currently, they're included via
raw-loader
imports, which is a great way of declaring raw files where they're needed instead of specifying a whitelist in some config. However, this approach doesn't allow other plugins to hook into the processing of the imported files.To add to that,
raw-loader
is officially deprecated in favor of Asset Modules (asset/source
, specifically). Instead of using!!raw-loader!./file
, the webpack docs recommend appending a?raw
query string to indicate that a file is to be included in raw form. This opens the door for injecting other logic in the processing of raw files, like injecting a version string. 😉All in all, it can be done, though the solution is a bit too webpacky. That said, it does allow for site-wide interpolation for any sort of value, not just a computed version string.
Unresolved questions
If there's interest, I will open a PR.
The text was updated successfully, but these errors were encountered: