bbeesley / hygen-cook Goto Github PK
View Code? Open in Web Editor NEWA helpful chef to cook hygen recipes
License: MIT License
A helpful chef to cook hygen recipes
License: MIT License
Also allow option to specify ingredients as an array of strings:
ingredients:
- https://github.com/hygen-generators/scaffolder-demo-hygen
- name: github-actions-generators
version: 1.0.0
After namespace support is added (#102), alias support for ingredients can be added, while also allowing array of strings on the ingredients (without alias):
ingredients:
- alias: sdh
repo: https://github.com/hygen-generators/scaffolder-demo-hygen
- alias: gag
name: github-actions-generators
instructions:
- ingredient: sdh
generator: monorepo
action: new
args:
- option: name
value: simple-service
- ingredient: gag
generator: github-actions
action: build-test-publish
args:
- option: admin-github-token
value: SUPER_SECRET_TOKEN
- option: main-branch
value: main
- option: node-version
value: '14.11'
- option: use-commit-lint
- option: use-lerna
The current recipe schema does not contain enough detail. Currently ingredients are defined by a package
property and a generator
property. This is reasonable, but the implementation treats the package
property as the generator
name (ie what hygen docs refer to as the generator name), and the generator
property as the action
name (what the hygen docs refer to as the action name).
This works, but gives us the limitation that if two packages contain generators with the same name, there will be a collision and only one will work.
To resolve this, we'll need a new property on the ingredient object (probably action
) and we'll need to change the way they're used, so that package
refers to the npm package (or git repo) that the generator comes from, generator
refers to what the hygen docs refer to as the generator, and the new action
property refers to what the hygen docs refer to as the action.
Eg: if running the generator via hygen looks like hygen component new --name myComponent
, the action would be new
, the generator would be component
and the package
property would define with npm package or git repo this generator is contained within.
As well as the changes to the ingredients schema, and the way args are passed to hygen, this will also involve changes to the way templates are fetched and stored (see the add.ts
file), so that its possible to determine which package a generator came from, and select the right one with the call to hygen.
This issue should require little explanation, we need unit tests in place to make sure we haven't broken anything as we make changes, add features, and update packages.
Background
The current implementation of "fetching ingredients" is adapted from hygen-add and only copies across the contents of the _templates
directory. Because .hygen.js
files are located by searching up the tree from process.cwd()
at runtime, any .hygen.js
file included in the package will not be used automatically.
Improvement
Extend the instructions processing workflow to override the location from which .hygen.js
is sourced to ensure that if that file is included in the sourced generator, it's used while running the generator from within hygen-cook
.
yarn
with npm
as the primary method of installing dependencies when recursing through ingredient packages - https://github.com/bbeesley/hygen-cook/blob/main/src/main/add.ts#L50Find a way to improve logging on the CLI.
hygen-cook is all based around recipes. The recipes can be shared, but until there are shared recipes to use (and even then when you need to write your own recipe) it would be useful to have a generator available to help people create a valid recipe file.
There is a minimal level of documentation included in this project. In order to make it easy for people without prior knowledge to pick up and use this tool, we need to add thorough documentation as well as a working demo.
The demo should use existing publicly available hygen templates, composed into a recipe, for people to scaffold something out.
When cooking a big recipe, the module sits without displaying any updates for long periods while installing ingredients. This often makes you think that it has stopped responding. Adding more feedback to show exactly what the module is currently doing would help to remove this problem.
In the add
function used to install the ingredients, the spinner is started, then stopped when the package is successfully installed. If an error is thrown though, the spinner is not stopped.
Currently all generators are executed from the current working directory. This means its not possible to, for instance, scaffold a Lerna repo with multiple packages using a basic node module template.
To resolve this, we should add support for specifying the directory that an ingredient template should be executed from.
UseCase:
I have bulk of generators in /home/username/_hygen_templates
on my laptop and want to use cook for bootstrap projects, or project modules.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.