I have a full Trellis/Bedrock/Sage setup, where I have forked the Sage theme to customize it to our needs.
The theme is so dependent on ACF Pro, that it makes more sense for me to include it in the theme. My first thought was that the theme composer.json might be able to read the .env file in the site directory but so far, I haven’t found a way to load that from a different folder.
Is my only other option to include the ACF code in my fork and manually update it in the fork anytime ?
Ideally id like to work out an env solution that doesn’t require me to bundle the code with the theme. Does anyone have any smart ideas on how I might do this?
For development I store the ACF PRO key in the .env file (WordPress roots.io Bedrock setup),
for production I store the ACF PRO in vault.yml (roots.io Trellis system).
I appreciate the reply, but I think you have missed my point.
I understand (and use often) the env file for the ACF key when bundling ACF pro in the site folder composer.json.
What I want to do, is move ACF from being a dependency of the Bedrock setup, to being a dependency of the theme itself. And the theme composer.json cannot reach back up to read the .env file in the site folder.
Yes, i have explored that, and thats easy to do, but not what im trying to achieve.
Ill try to clarify: I want to avoid bundling the acf plugin code in the repo itself, and would prefer to use composer to install, but inside the theme and not from the site folder.
Looks like i may have to just bundle it, or let bedrock handle it.
This would be a build step then. For trellis deploy, by default a deploy hook runs and invokes composer install for the bedrock site (composer.json with the plugins).
In your case with the theme you would also want to invoke composer installin the theme directory,
so you add an invocation to composer install to the deploy hook, but with the theme directory as cwd.
If your theme is never going to be used outside of the Roots stack, I’m not sure why it matters whether ACF is a dependency of your theme or your site. If your site is going to be used outside of the scope of the Roots stack, you have a different problem to solve in terms of where your key will be stored so you can either distribute or reliably deploy the theme.
AFAIK you should be able to put a .env file in your theme root and then use ffraenz/private-composer-installer in your theme as you would in your site. Obviously you don’t want to commit that .env to your theme, so if you’re deploying w/ Trellis you could use use deploy-hooks/build-before.yml to generate a new .env in your theme folder, ala: