baxtian / merak-env
Manager for Merak themes and plugins
Requires
None
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Environment to maintain a Merak component. Static classes that merak-cli (flags) and the
composer.json of each Merak plugin or theme (scripts) call from the project root.
Scripts
Every script that changes files accepts -- --dry-run when it runs from composer
(composer run update_composer -- --dry-run): it reports what it would change and writes nothing.
| Composer script | Class | What it does |
|---|---|---|
version | MerakEnv\Version::update | Propagates the Version: of the main file to README.md, package.json, composer.json and phpunit.xml. |
version (chained) | MerakEnv\Header::copyrightScript | Copyright year range: first commit year to the current year. Runs together with the version bump. |
update_header | MerakEnv\Header::wordpressScript | WordPress compatibility, only when the user asks: Requires at least (added when missing, never changed), Tested up to (installed WordPress version) and the README. Needs wp-cli. |
update_copyright | MerakEnv\Header::copyrightScript | The copyright step alone. Needs git. |
update_composer | MerakEnv\Composer::updateScript | Leaves what the framework owns in composer.json equal to the reference: archive > exclude, the scripts above and the baxtian/merak-env constraint. |
"scripts": {
"version": [
"MerakEnv\\Version::update",
"MerakEnv\\Header::copyrightScript"
],
"update_header": "MerakEnv\\Header::wordpressScript",
"update_copyright": "MerakEnv\\Header::copyrightScript",
"update_composer": "MerakEnv\\Composer::updateScript"
}
Other classes: Libs, Blocks, Src (regenerate lib.json, entry points and Instances.php),
SilenceIsGold, Dist (zip), Svn.
composer.json
MerakEnv\Composer::update() brings three things to the reference and rewrites only those parts, so
the rest of the file keeps its format. It is the way to reach a project that does not have the
scripts yet (merak --update_composer works without them).
archive > exclude(Composer::EXCLUDE): all entries start with/, so they are resolved from the project root and never touch the files of the dependencies invendor/. It replaces the old patterns (composer.*→/composer.*, thewebpack.*ones →/webpack.*and/vendor/baxtian/merak/config/,merak-env→/vendor/baxtian/merak-env/), adds what is missing and keeps the project's own entries at the end.scripts(Composer::SCRIPTS):version,update_header,update_copyrightandupdate_composerare added when missing and replaced when different. The other scripts of the project are not touched.baxtian/merak-env: a^0.7.xconstraint below^0.7.14is raised to it; runcomposer update baxtian/merak-envafterwards.
Header
MerakEnv\Header has three entry points: wordpress(), copyright() and update() (both).
They return ['changes' => [...], 'warnings' => [...]]; a missing wp-cli or git adds a warning and
skips the step that needs it.
Messages and translation
The library writes its messages in English and does not translate them. A caller that wants to translate
(merak-cli does) uses the codes: the fixed entries of warnings are keyed by a code (no_wp_cli,
wp_version, no_git, no_git_history in Header; no_archive, no_scripts, no_merak_env,
run_update, exclude_not_rewritten, invalid_json, invalid_result in Composer), and errors are
MerakEnvException with a code (MerakEnvException::NO_*) and getContext() for the values of the message.