-
Couldn't load subscription status.
- Fork 3
Description
Big questions:
- Should it be Yaml (cleaner) or PHP (easier to do custom stuff, easier to parse and write)?
- Does "recipes" of "steps" make sense?
- How best to distribute steps and recipes that aren't "official"? How do we let people distribute their own?
- Does namespacing steps make the most sense? e.g.
step('duster/install')runsSteps/Duster/InstallPHP class? - Should it allow for user input?
- Is there a better way, other than this being a Laravel app, to build this so it can be as useful as possible for other tools (e.g. a modified Laravel installer or something) to use them?
Copied from current README for context (so that future people looking at this can understand the state of thinking at the time of creation):
Vision
I imagine it'll look like this. Once Mise is installed globally with Composer, you'll install a new Laravel app:
Usage
laravel new money-maker
cd money-makerThen you can use Mise to apply presets:
mise apply preset1 preset2 preset3Or you can use it interactively, where Prompts will let you choose which you want to apply:
mise applyHow it would work
I can imagine Mise comes with predefined "steps"; for example, a step named "duster" could do the following:
composer rqeuire-dev tightenco/duster- Run
./vendor/bin/duster github-actions - Run
git add . && git commit -m "Install Duster" - Run
./vendor/bin/duster fix - Run
git add . && git commit -m "Run Duster"
The definition for this step would be built into code in Mise, using some combination of convenience helpers that make common tasks (e.g. "git commit with message", "composer require dev") easy; then presets would include this step.
How presets/recipes would be defined/loaded
Presets would be defined... that's the hard part. I know some can be defined in Mise. And I know some can be defined locally. But what is a safe way to define presets to be shared?
- Composer is too heavy, I think, unless one person/group wanted to release a whole pack of steps/recipes
- Pulling from gists makes it too easy for someone just to update it to something nefarious and then you're running untested bash scripts on your machine
- Clumsiest but safest is to just have a central site where you can share presets but you have to manually copy to them to your local machine
Also maybe some useful thing where you can set a configuration item so if you run mise default or something, it'll run a predefined set of presets, so you can say "all my new Laravel apps should have these three presets run" as your default.
Building a step
OK, so I'm imagining a step is single file (?), either a PHP class or a procedural PHP file. It could be yaml, which would be cleaner, but wouldn't allow for arbitrary PHP. Maybe allow both?
Let's imagine duster is a step. Maybe this? Will keep working on the API...
namespace Steps/Duster;
class Install extends Step
{
public function __invoke()
{
$this->composer->requireDev('tightenco/duster');
$this->git->add('.')->commit('Install Duster');
// or $this->git->addAndCommit('Install Duster'), not sure
$this->exec('./vendor/bin/duster fix');
$this->git->add('.')->commit('Run Duster');
}
}I can imagine we'll want tooling to create files, replace content in files, rename or move files. More Git tooling, more Composer tooling, NPM tooling.
Some of this will come from having a filesystem component directly available, and, of course, access to the entire Laravel world through the container. Some it'd be nice to have one-off commands or even little suites of tools (e.g this git helper described above) to simplify some of the steps. I'll be looking to Lambo and Valet for at least some inspiration on those.
Building a recipe/preset
Let's imagine we have a preset for creating a new Tighten SaaS. What steps do we want to take after laravel new?
We could have it be a simple YML/JSON file... just with a list of steps... or it can be a PHP file so it can have standalone work outside of steps, or pass configuration items to steps?
class Tighten extends Recipe
{
public function __invoke()
{
$this->step('duster/install');
$this->step('duster/ci', someParameterHereOrWhatever: true);
}
}I don't know if I want any steps to take user input, but if they can, doing it as a class would help that:
class Tighten extends Recipe
{
public function __invoke()
{
$this->step('duster/install');
$this->step('duster/ci', someParameterHereOrWhatever: true);
if (confirm(label: 'Do you want to install our frontend tooling?')) {
$this->step('tighten/prettier');
}
}
}Reference
- Valet
- Lambo, especially this PR: WIP Presets work lambo#185
- Josh Manders announced a tool Skeletor while I was plotting this; his tool is primarily hooking around
Composerso I'll consider it a cousin :)