Use case
Currently, the generateUnitsJson.ts script in core/quantity is run during every build, regenerating a number of git-tracked files:
core/quantity/src/assets/Units.json
core/quantity/src/generated/Units.generated.ts
core/quantity/src/internal/BasicUnitConversions.generated.ts
core/quantity/src/internal/DefaultPersistenceUnits.generated.ts
If changes are made by a developer that affect that generation, it will result in one or more of those files being changed in the developer's source tree, with no obvious reason as to why they were changed, leading to likely confusion. Furthermore, the developer may not know if the changes are expected and correct or due to an error in their tree.
Proposed solution
In my opinion, the following changes should be made:
- Do not run this script automatically as part of the build.
- Update the script to take an optional destination folder as input. It will then generate files in the given destination.
- Add a unit test that runs the script with a temporary destination and then compares the results to the original git-tracked files. If they differ, the unit test will fail with an error message instructing the developer to determine if their changes were expected to cause such changes. If so, they can run the script without the destination folder argument to updated the git-tracked files. If not, they can fix whatever caused the undesired changes.
Alternatives considered
- Leave things like they are now. I don't feel this is a good idea.
- Update the generation script to add a comment to the top of each generated file instructing developers what to do if the file contents change in their branch. (This is an easier solution, but I feel inferior to the proposed solution. It also won't work for the JSON file since JSON doesn't support comments.)
Willingness to contribute
AI acknowledgment
Use case
Currently, the
generateUnitsJson.tsscript in core/quantity is run during every build, regenerating a number of git-tracked files:core/quantity/src/assets/Units.jsoncore/quantity/src/generated/Units.generated.tscore/quantity/src/internal/BasicUnitConversions.generated.tscore/quantity/src/internal/DefaultPersistenceUnits.generated.tsIf changes are made by a developer that affect that generation, it will result in one or more of those files being changed in the developer's source tree, with no obvious reason as to why they were changed, leading to likely confusion. Furthermore, the developer may not know if the changes are expected and correct or due to an error in their tree.
Proposed solution
In my opinion, the following changes should be made:
Alternatives considered
Willingness to contribute
AI acknowledgment