Task: #53687 Support instance-specific cfg write targets and add coverage V2 #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "53687/task-support-instance-specific-cfg-write-target-v2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
cfg behavior (functional summary)
cfg separates two concepts:
•
--pkgPath(-p): where extension/package default files are read from (<prefix>.default.conf.php).•
--appPath(-a): where local/override configuration is written (config/...).So
-pdoes not define the write target; it defines the defaults source.public/extensions/myCEESV/config/myCEESV.default.conf.php/config/myCEESV.conf.php(if -a is not provided, cwd is used)./config/owner_xyz/myCEESV.conf.php--siteDiraccepts both owner_xyz and config/owner_xyz (both normalize to the same target)public/extensions/myCEESV/config/myCEESV.default.conf.phppublic/extensions/myCEESV/config/myCEESV.conf.phpTechnical note
A bug was fixed in Settings::load() so cfg no longer fails when the extension default config does not define mode; it now applies an automatic fallback and does not require -m.
Please test cfg with instance-specific targets:
From an instance root (
cd <path2instance>), run:Expected:
config/owner_xyz/myCEESV.conf.php(directory created if missing)config/myCEESV.conf.phpis untouched when--siteDiris used.bakwhen overwriting existing instance config--siteDir, behavior stays unchanged (writes to local config)53687/task-support-instance-specific-cfg-write-target-v2to Task: #53687 Support instance-specific cfg write targets and add coverage V2@ -238,27 +369,37 @@ case 'show':case 'write':$path = ($settings['key'] !== '') ? explode(':', $settings['key']) : [];var_dump($path);perhaps we could have a verbose mode?
@norb wrote in #4 (comment):
Hi Norber, for this round I kept the verbose implementation minimal on purpose. The current CLI helper library is not fully compatible with PHP 8 in the verbosity path (especially around incrementing flags), so going further right now would either require patching vendor code or introducing larger structural changes. I agree we should improve this longer term; a good replacement would be Symfony Console (https://symfony.com/doc/current/components/console.html), which I know well and that already provides robust argument parsing, verbosity levels, and many related features. For this version, I think it is safer to keep it simple and stable, and handle a full CLI migration in a dedicated follow-up.
@ -23,3 +23,3 @@}$version = '0.3';// Pre-parse site options so they can be passed after positional args.I don't really like this .. seems over complicating the code. It is just for beging able to have different order of arguments?
not that important to me .. and probably better put inside the input helper library or replace it altogether .. IIRC the one used is not maintained anymore
@norb wrote in #4 (comment):
You're right. After reviewing it again with the alias cleanup in place, I realized we can keep this much simpler. The pre-parse block was added as a defensive workaround while multiple option variants were still in play, but with --siteDir now unified and a couple of small follow-up fixes, the standard parser flow is sufficient. I removed that extra layer to keep the code cleaner and easier to maintain.
@ -60,6 +115,16 @@ $collection = (new Input\InputCollection())->description('Path where the config/ directory of the package conf files is located, defaults to the working dir')) // }}}->add( Input\InputTypeFactory::build('LongOption')->name('site')->short('s') // {{{as agreed in chat, again to keep the code simple, use --siteDir without alias
same argument, if we think we will need arguments, implement in used lib or use different lib
@norb wrote in #4 (comment):
👍🏼 Done, agreed. I removed aliases and kept only --siteDir to keep the CLI simple
@ -198,0 +277,4 @@$siteFlag = 0x01;// Only one site selector may be provided to avoid ambiguous targets.$providedSiteOptions = [];foreach ($preparsedSiteOptions as $option) {our coding style would always put the opening curly bracket on a newline. I retain it specially important if the following codeblock is longer than a couple of lines
@ -23,3 +23,3 @@}$version = '0.3';function readJsonInputFile(string $path): arraycan you do this as validators? e.g.
->validator(new Input\Validator(@ -200,0 +275,4 @@$site = null;$siteFlag = 0x01;$siteInput = $argv->find('siteDir');if ($siteInput !== null && $siteInput !== false)probably most of this should be done in the validator as well
@ -240,0 +366,4 @@// Write needs exactly one payload source:// either SETTING (key=value) or --in (JSON file).// This avoids ambiguous input precedence and empty writes.if ($inputFile && $settings['key'] !== '')probably this one too?