Recursive use of cookiecutter - templates

I've been reading about cookiecutter as a way of instantiating project templates. The projects I'm interested in templating typically contain a bunch of different sub-project types such as C++ software, microcontroller-specific firmware, PCB schematic/layout, FPGA HDL, etc. Describing each sub-project type is easy with Cookiecutter, but is there a way to make a master cookiecutter that calls the appropriate sub-project cookiecutter at a given point? I haven't seen anything in the docs/tutorials that talk about this kind of recursive mode of operation.

I've used the internal Cookiecutter API in Python scripts so I can generate multiple components quickly. The method is described here: http://cookiecutter.readthedocs.org/en/latest/advanced_usage.html#calling-cookiecutter-functions-from-python
I also think this would be an interesting use of a post_gen_project.py hook. I'll try and get that working.

Related

create a project from a template

I have several project setups in very different languages. For example an android project.
Whenever I want to create a new android project I copy that project, rename everything I need to rename and I have a ready to go project with which I start working.
Since this is very time consuming and I am sure this can be automated I thought about creating a tool that does this for me, but then I thought there are probably thousand solutions out there, which solve the exact same problem already, I am just not aware of.
So my question is, do you know of any tools like this? The requirements I see are, that it has to be os, language, IDE independent and it must support a command line interface. Ideally with less setup effort.
You should try Telosys (https://www.telosys.org) a lightweight code generator that is able to generate any kind of langage with any kind of framework.
This tool is quite simple, free and Open Source.
It provides a Command Line Interface (so it can be used with any environment/IDE).
It is usualy used to boostrap a project and to generated all the repetitive code (CRUD, Controllers, unit tests, HTML pages, etc)
See also :
https://modeling-languages.com/telosys-tools-the-concept-of-lightweight-model-for-code-generation/
https://www.slideshare.net/lguerin/telosys-project-booster-paris-open-source-summit-2019

Is there code generator for Django like Gii?

I use Gii code generator with Yii2 framework for more that 3 years ago.
Now I want to change to Django but I need a similar code generator.
No, I don't think so. Django has some great built-in features that makes coding web applications so much easier, but you have to write Python to use it.
But don't be afraid, it's quite easy to learn!
You could try Telosys (https://www.telosys.org) a lightweight code generator that is able to generate any kind of langage (Python among others) with any kind of framework (possibly Django).
This tool is quite simple, free and Open Source.
It provides a CLI (Command Line Interface) and Eclipse plugin, so it can be used with any IDE
It is usualy used to boostrap a project and to generated all the repetitive code (CRUD, Controllers, unit tests, HTML pages, etc)
Some Python application templates are already available (not for Django but it can serve as an example):
https://github.com/telosys-templates-v3/python-web-mvc-bottle
https://github.com/telosys-templates-v3/python-persistence-sqlalchemy
See also this tutorial: https://www.slideshare.net/lguerin/telosys-tutorial-code-generation-for-a-python-web-application-based-on-bottle-and-sqlalchemy

When starting a new django project via django-admin.py is there a way to inject my own variables?

When starting a new Django project via django-admin.py is there a way to inject my own variables?
I'd like to use {{ <my_var_name }} so that the project is automatically setup for me.
Thanks for the help!
Casey
There is no such capability with the django generator.
What you need is called a 'scaffolding' or 'boilerplate' generator. Usually you enter some configuration parameters (using input, conf files etc depending on the generator) and then the generator configures the new project.
A django generator that is written in python is pyscaffold.
A very common and popular web scaffolding generator if you are slightly familiar with node.js is Yeoman which surprisingly offers quite a number of django project generators.
I have personally developed a generator called django-ana but you can search for others here too.
Experimenting with this is easy because it is matter of installing each generator and generating a project to see what parameters it asks and what it generates. Then pick the one closest to your interest and even open some relevant issue to ask for sth different. Or you can even play with yeoman yourself anyway.
For arbitrary variables, nope.
The current wording is deceptively specific:
The template context used is:
Any option passed to the startproject command (among the command’s
supported options)
...
Here is a brief discussion that lead to that doc change and the feature has not been discussed since then as far as I can tell.

Advice for Web-based Remote Build System

I'm interested in setting up a remote build system at work, initially for internal use, potentially for some customers going forward. We need to compile library code on several different machines (PC, Mac) and with multiple compilers, and it can be a real pain trying to get access to a full set. This is not our main build system, which is Jenkins-based and uses an approach that is not easily modified for the purpose envisaged here.
The idea would be that you could post your source to a website with some basic build parameters, it would compile the code and you could then download the generated code. Ideally users could pick which version of the underlying software they compiled their libraries against. I envisage it being supported by a virtual machine.
Reason I'm posting is that I don't really want to roll-my-own as much as possible - longer term it has maintenance implications - and would prefer something as pre-existing as possible. Obviously one would expect some adaptation in terms of scripting.
Any suggestions? It would have to be supported on Mac and PC at absolute minimum.
This sounds like something you could do by creating a parameterized Jenkins job (the build params given as input to your web frontent could be passed on to the job, perhaps via the Jenkins API). Personally, I would see if you could skip the step of creating a new webfrontend, and have users pass their build params directly to Jenkins.
To support downloading the resulting compiled code, you could have the Jenkins job archive the build as an artifact. Users could then download the files from the result page for that individual build.
As for how to make a Jenkins job accept source code to compile as input, perhaps you could use branches in your CM system? Your users could push their code to a branch, and then pass the branch as a build param. Otherwise, you might be able to use the file parameter feature of Jenkins.

manage and compile large emberjs app

Ember don't seems to play well with requirejs or building with r.js without some hackery.
Bit hard to manage a large application, I like to break down my file structure as HMVC, which manages modules bit easier :
app
- blah
- modules
-module1
- controller
- model
- view.
Has anyone come up a build stack to automate the compilation into single file with dependency management?
Update: You should now be starting new projects using ember-cli, which provides all the build/dev tools plus many other useful features.
Original answer:
An example Ember project using grunt.js as a build system:
https://github.com/trek/ember-todos-with-build-tools-tests-and-other-modern-conveniences
I've used this as a starting point for some Ember apps and it works well.
Ember don't seems to play well with requirejs or building with r.js without some hackery.
Why do you want to use require.js in the first place?
As for making this all work you'll need a build tool. I recommend brunch (Node) or iridium (Ruby). Brunch is more simple and supports many different module formats. Iridium is much more powerful. It uses Minispade for modules. Require.js/AMD is not needed because your js is always delivered as a single concatenated file.
For stand-alone ember dev I use ember-skeleton as a starting point, which is itself based primarily on rake-pipeline.
https://github.com/interline/ember-skeleton
This provides the whole kit-and-kaboodle for beginning an app, but the meat of it is the rake-p Assetfile, which describes how rake-pipeline will digest all the files, filter their contents, and ultimately combine them into the final handful of files. Additionally, the combination of loader.js and the minispade filter allows the use of 'require()' statements for managing dependencies amongst your files.