You should check out
https://tplang.org/ It's Open-Source and part of the
https://camotics.org/ CNC simulator. TPL is JavaScript with built-in extensions that make generating GCode programmatically and visualizing the results much easier. Disclaimer, I am the author.