tutorialkit icon indicating copy to clipboard operation
tutorialkit copied to clipboard

A way to validate the typescript of assembled tutorial sections

Open noam-honig opened this issue 1 year ago • 4 comments

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

noam-honig avatar Oct 26 '24 07:10 noam-honig

Could you set up minimal reproduction for this? For example using https://node.new and running npm create tutorial there to get started?

AriPerkkio avatar Oct 27 '24 08:10 AriPerkkio

Hi, here it is: https://stackblitz.com/edit/node-e7zju9

  • I change counter.js to counter.ts - to use typescript
  • I deleted counter.ts from the template (it's ok its in the lesson)
  • I imported in counter.ts a file called some-function that 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.

noam-honig avatar Oct 28 '24 11:10 noam-honig

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/*"
+     ]
    }
  }
}

AriPerkkio avatar Oct 28 '24 11:10 AriPerkkio

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.

noam-honig avatar Oct 28 '24 12:10 noam-honig