tutorialkit
tutorialkit copied to clipboard
A way to validate the typescript of assembled tutorial sections
Is your feature request related to a problem?
Today, the actual lesson is a combination of files from the template and from the lesson itself. When I use vs code - or when I build astro typescript files - the build fails, because the template may refer to files that exist only on the lesson and vice versa.
I wish there was a way to validate that.
Describe the solution you'd like.
One "dummy" thought, is a cli command to "build" all the lessons with their files and template files into a temp folder and run typescript build there - to validate that all is ok
Describe alternatives you've considered.
The other way I can think of is duplicating many files - but that's maintanance hell.
Additional context
Love this project
Could you set up minimal reproduction for this? For example using https://node.new and running npm create tutorial there to get started?
Hi, here it is: https://stackblitz.com/edit/node-e7zju9
- I change
counter.jstocounter.ts- to use typescript - I deleted
counter.tsfrom the template (it's ok its in the lesson) - I imported in
counter.tsa file calledsome-functionthat exists in the template and not in the lesson.
The lesson itself, that is the combination of the template and the lesson is valid but nore the templare nor the lesson are.
You can verify that its valid by using "open in stackblitz"
If I run astro build I get an error - and that's ok - I exclude template and content from the ts file.
I wish there was a way to generate to some temp folder, the "merged" lessons and build them to make sure its all ok.
I'm not sure how this could be implemented. I thought tsconfig.json's paths would do this automatically, but looks like relative imports are not remapped via paths. So something like this does not work:
{
"compilerOptions": {
"paths": {
+ "./src/content/tutorial/1-basics/1-introduction/1-welcome/_files/*": [
+ "./src/templates/default/*"
+ ]
}
}
}
I'm old school - if there was away to reuse the logic you use to build the source folder for the web container, and just output it to a tmp folder - with a folder for each lesson, and run the tsc there - that would be a good start.