Skip to content

Don't automatically run core-quantity's generateUnitsJson.ts at build time #9444

Description

@tcobbs-bentley

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:

  1. Do not run this script automatically as part of the build.
  2. Update the script to take an optional destination folder as input. It will then generate files in the given destination.
  3. 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

  1. Leave things like they are now. I don't feel this is a good idea.
  2. 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

  • I am willing to write the code or documentation for this feature.

AI acknowledgment

  • I used AI to generate this feature request.
  • (If the above is checked) I have reviewed the AI-generated content before submitting.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions