Page 1 of 1

Automatically patch generated files: How to?

Posted: 2018-08-07 11:58
by jsetzer
Hi there,

I am trying to make my changes in hook files only, but there are couple of things which can only be done in overwritable files :? .

Is there a way to automatically apply patches to generated files?

To give an example:
The file inc.Common.php contains the following code which shows the "Jump-To" menu on all pages except the homepage:

Code: Select all

<?php if(!$home_page){ ?>
	<?php echo NavMenus(); ?>
<?php } ?>


I want to remove the condition (first and last line of the code) to see the menu on every page, even on the homepage.

Code: Select all

<?php echo NavMenus(); ?>
or

Code: Select all

<?php if(!$home_page || true){ ?>
    <?php echo NavMenus(); ?>
<?php } ?>
AppGini will overwrite inc.Common.php on next generation :shock: as long as I do not uncheck the code file :roll: .

So I'm wondering if there is any tool out there which will automatically patch the generated files according to some configurable rules (diff/merge?)

How do others handle this?

Thanks, guys!

Kind Regards,
Jan

PS: Maybe BigProf can add a project setting "[x] hide jump-to menu on homepage" in the next release?

Re: Automatically patch generated files: How to?

Posted: 2018-08-13 16:07
by grimblefritz
I used to do this, but have since made all my changes via the files in hooks.

That said, back when I DID make changes in generated files, I never did find a way to patch automatically within the builder app. I posted a suggestion that the AppGini builder needs hooks to execute a command before/after each file is generated, or at the very least before/after generation. Nothing came of that suggestion.

Ultimately, I changed my workflow to use a script to move files from the output folder to the execution folder (which, in my situation, is always on another host so a transfer had to occur anyway.) In that script, I made whatever changes I needed for the generated files. Not as seamless as hooks in the builder, but it worked for me.

Re: Automatically patch generated files: How to?

Posted: 2018-08-15 10:20
by jsetzer
Thank you @grimblefritz for sharing your ideas!