Open XedinUnknown opened 7 years ago
There may be other things to install in the future. For this reason, and for the sake of future stability, it's probably best to back-up and restore the files in the project folder. However, there are several challenges to overcome here.
The file attributes, such as modification and creations times, must be preserved - these files should remain exactly as they were before provisioning.
One way to do this could be by archiving them, instead of simply moving. This is time-consuming.
Another way could be by copying the contents with -a
(preserve everything, no de-reference, recursive) and -l
(hard links instead of copying contents). This would save time and preserve attributes. Then, could copy back, and delete backup.
This approach involves installing files in a temporary directory (like is happening now with Bedrock), and then moving them where they belong (usually into the project folder). The -n
flag of mv
can be used to prevent overwriting existing files in the project folder. At this point, it is unclear whether it's possible to install WP using WP CLI in this way.
If running composer install
for Bedrock directly in the project folder, it's important to remember that Bedrock's composer.json
will not overwrite the project's composer.json
. If the latter does not contain required Bedrock configuration, Bedrock installation will fail. For this reason, the documentation must mention that the project's composer.json
must be based on that of Bedrock, or at least contain the required config.
I tried the solution with mv -n
. Here's what I did
git clone https://github.com/Dhii/scotch-bedrock.git my-project && cd my-project
- This gave me the boilerplate. I also had to git checkout task/use-wp-provisioner_12
, since it's currently the most up-to-date branch.nano Vagrantfile
- Changed the hostname, the IP, and the VB memory to avoid having Composer running out of memory; the latter is necessary until a better solution is found, such as enabling swap in the guest.vagrant up
- This installed everything, most importantly giving me the composer.json
and provision.php
. You could also move the .composer-cache
to the project folder at this stage, if you have it backed up.rm -rf .git
- Removing the repo files of scotch-bedrock
. I want to start the history from scratch, and avoid having extra files in the repo.git init
- Initialized my own repo.nano .gitignore
- Excluded all files except the following: Vagrantfile
, provision.php
, composer.json
, composer.lock
, .gitignore
, wp-cli.yml
, README.md
. These are all the files I need in my project at this stage.nano composer.json
- Updated the project details, such as name and author, and removed unnecessary info, e.g. tags, multiple authors, etc. Added project dependencies, such as plugins.nano provision.php
- Added the plugins to the activation list. Optionally, other adjustments, such as title or admin detail customizaton, theme activation, etc.git add .
- To add all files. Remember: files should be explicitly allowed in .gitignore
.git commit
- Now I have all I need.
The Problem
The various tools installed into the project directory during provisioning may overwrite existing project files.
Suggested Solution
Keep the actual project files. Possible approaches:
-n
flag withmv
when moving Bedrock or other files into the project directory. This will prevent existing files from being overwritten.