Dhii / scotch-bedrock

2 stars 2 forks source link

Preserve Project Files #11

Open XedinUnknown opened 7 years ago

XedinUnknown commented 7 years ago

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:

  1. Use the -n flag with mv when moving Bedrock or other files into the project directory. This will prevent existing files from being overwritten.
  2. Back up all existing files before installation of Bedrock or other things into project directory, and move them back after, overwriting existing files.
XedinUnknown commented 7 years ago

Backup and restore

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.

  1. 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.

Install separately and move

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.

XedinUnknown commented 7 years ago

I tried the solution with mv -n. Here's what I did