Restructure code layout #114
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
Ahead of adding support for subflow modules to NodeGen, I have gone through the code and done a bit of restructuring that should make it easier to maintain in the future.
Rather than have all of the generators in the one file, I have split them into their own modules - and moved the tests to match.
I have also moved much of the type-specific logic from the top-level
node-red-nodegen.jsfile, down into the individual modules. That will make it easier to reuse as a library.I have also completed some chores:
requestlibrary in favour ofaxioswhenas we can rely on native Promise supportistanbulas it cannot handle ES2015+ code (ieasync/await)swagger.jsontosamplesand removed the task that downloaded it from the internet every time the tests ranMyLampThing.jsonldThere are some further tasks I would like to look at:
Running npm install generates a node_modules that is over 600Mb in size. I know some of that will be devDependencies, but I'd really like to reduce the footprint of the library.
jimpseems to be to blame for40Mbof that - I realise that's used to handle icons, but it does feel like there should be a way to do that with a smaller footprint.I see there are no tests for
MyLampThing.jsonld- as it stands, we have no way of knowing if the WoT output works. I don't know enough about how it is meant to work to write the tests... we need to be very careful about adding support for new things with the tests in place for them from the beginning.