MagicMirror icon indicating copy to clipboard operation
MagicMirror copied to clipboard

Proposal: Code Scaffolding for New Module Creation

Open tderflinger opened this issue 3 years ago • 4 comments

Dear Magic Mirror Community,

I really like your project and I have created modules myself as a programmer. In order to help other programmers and especially people new to Magic Mirror module development, I would propose a code scaffolding aid.

There exists a library called Hygen (https://www.hygen.io/) that facilitates rapid JavaScript code generation. Using this tool, I have developed starter templates for the rapid creation of new Magic Mirror modules.

You can find my code here: https://github.com/tderflinger/hygen-magicmirror

Basically, when starting Hygen, the tool asks for the name of the Magic Mirror module and if a package.json is needed. Then it creates a set of ready-to-use source files in the modules folder.

We could include the _templates folder of /tderflinger/hygen-magicmirror in the main Magic Mirror distribution and add a script to the package.json, like "create-module": "npx hygen module new". This is all that is needed to help developers create new modules more easily and rapidly.

What do you think about this?

Thanks and best, -Thomas

P.S.: Of course the code that is generated can be changed easily in the EJS template files.

tderflinger avatar Jun 29 '22 15:06 tderflinger

I do like the idea, it would help for new developers to get into it. Although once you have setup your fresh module with hygen, one still has to know enough of JS and MM to get the rest done... So yeah: helps to get into coding stuff, but doesnt take all work away :-)

rejas avatar Jul 01 '22 06:07 rejas

HI @rejas, yes that is true. For making it even easier for beginner coders there would probably need to be some kind of low code environment. So should I create a pull request with my code proposal or would you rather prefer to wait for some bigger improvements in the direction of low code in the future? Another area would be to write more detailed documentation geared for beginners. I might also be able to help there a bit. :)

tderflinger avatar Jul 05 '22 17:07 tderflinger

Hi @tderflinger, thanks for your suggestion. I appreciate the fact you want to make it easier for people to create modules. As you can read in the "manifesto", one of the reasons I open sourced MagicMirror² was to encourage people to take their first steps in software development.

However I do think that extracting things away, and using generators doesn't make it necessarily easier for users to learn how to built stuff. That being said, it can have it's purpose to have tools like hygen. My suggestion would be to make that an 3rd party repo, separate from the core.

Feel free to add information about this (and the repo) in the docs. That way people can still use it without needing to maintain it in the core repo.

MichMich avatar Jul 06 '22 08:07 MichMich

Hi @MichMich! Thanks for your feedback. I will add a section to the Magic Mirror documentation so that developers who are interested in it can find it.

Kind regards, -Thomas

tderflinger avatar Jul 09 '22 11:07 tderflinger

seems to have been discussed, can this be closed @tderflinger @MichMich

khassel avatar Oct 02 '22 21:10 khassel