Add comment to the top of every generated file
dabbott opened this issue · comments
Summary
Add a comment containing the compiler's version number to the top of every file. This is useful to prevent people from unknowingly modifying generated code and having their changes wiped away. It's also helpful to see the compiler's version for debugging purposes.
We should add the comment:
// Generated by Lona Compiler 0.1.1
where the version number comes from the package.json. If it ends up looking nicer, we should add an extra newline after the comment.
We should do this for every Swift and JS file: components, colors, text styles, shadows, custom types, and static files copied from the /static
dir. No need to handle Android XML files for now.
Proposed Implementation
All file writing happens from main.re
, so most or all of the changes will be in that file. We should prepend the comment string to the top of every relevant file before writing it. We shouldn't go through the AST printer for this, since that will complicate things and isn't necessary.
Future Improvements
We should add a CLI parameter for modifying the comment, e.g. using a text file and prepending a project's LICENSE to every generated file.