Project archetypes using jsonnet
Got tired of doing the same shit over and over again to setup a new project so I created this super simple project templating system for different kinds of JavaScript projects.
I tried Yeoman but it always gave me more than I needed and was more of a hassle than it was worth. Plus I think I can make it super simple to create new project configurations (archetypes) thanks to the power of jsonnet for configuration files.
I want to keep this as simple as possible.
- Git
- Node
- Jsonnet
Some points as they come to mind: no specific organization.
Layered settings are used with specificity driving overriding power. Huhh?
Some values are personal user settings like your author name. You usually use the same author value most of the time. In special cases you can decide to use an override for the specific project. So we can have at least 3 levels:
- Archetype Defaults: Default values used by the archetype when no other values for the configuration parameter are provided.
- User Settings: Settings in the user's
personal-settings.jsonnet
file the~/.archetype
directory. - Project Overrides: Overrides provided when creating a project instance from an archetype.
Specificity increases as numbers increase, and so does overriding power.
Most of the configuration is done by the configuration file itself. Jsonnet handles pretty much everything for us. Add to that inheritence and the power of mixins and we have everything we could ask for.
Use npm link and unlink to setup the test archetype command. The bin attribute sets up the archetype command to be executed.
The git_type parameter might not be necessary if we can autodetect it. I think we can do that from the repository attribute value URL itself and/or from a simple test to the REST service.
- Required archetype identifier
- Required project name
- Optional vararg list of value overrides use JSON Path dot notation
Examples:
archetype node-ts-cli mycli
archetype node-ts mywebsite author=jackblack description="crazy shit"
These are additive union based merges of attributes and other things like link or script tags for an index.html for example. The other files make sense too on their own right. We can merge in packages.