diff --git a/src/Builder.php b/src/Builder.php
index 8b110cc4..03bda0ec 100644
--- a/src/Builder.php
+++ b/src/Builder.php
@@ -51,6 +51,11 @@ class Builder
*/
private $salter;
+ /**
+ * @var bool|int
+ */
+ private $gitignoreDone = false;
+
/**
* Construct. Just for DI.
*
@@ -80,20 +85,24 @@ public function build(ArrayAccess $paths)
} else {
return $this->error('error');
}
+ if ($this->moveContent($paths) === true) {
+ $this->progress('move_done');
+ }
foreach (self::$files as $file) {
if ($file === '.gitignore' && is_file($paths['root'].DIRECTORY_SEPARATOR.$file)) {
+ $this->gitignoreDone = 0;
continue;
}
if ($this->saveFile($this->buildFile($paths, $file), $paths['root'], $file)) {
+ if ($file === '.gitignore') {
+ $this->gitignoreDone = true;
+ }
$this->progress('file_done', $file);
}
}
if ($this->copy($paths, '.env.example')) {
$this->progress('env_done');
}
- if ($this->moveContent($paths) === true) {
- $this->progress('move_done');
- }
return $this->errors > 0
? $this->error($this->errors === 1 ? 'error' : 'errors')
@@ -139,10 +148,23 @@ private function buildFile(ArrayAccess $paths, $fileName)
static $vars;
if (is_null($vars)) {
$vars = array(
- 'VENDOR_PATH' => $paths['vendor'],
- 'WP_INSTALL_PATH' => $paths['wp'],
- 'WP_CONTENT_PATH' => $paths['content'],
+ 'VENDOR_PATH' => $paths['vendor'],
+ 'WP_INSTALL_PATH' => $paths['wp'],
+ 'WP_CONTENT_PATH' => $paths['content'],
+ 'VENDOR_PATH_IGNORE' => str_replace(array('\\', '/'), '/', $paths['vendor']).'/',
);
+ if ($paths['content']) {
+ $content = str_replace(array('\\', '/'), '/', $paths['content']).'/';
+ $vars['THEMES_PATH_IGNORE'] = is_dir($paths['root'].'/'.$content.'/themes')
+ ? $content.'themes/'
+ : '';
+ $vars['PLUGINS_PATH_IGNORE'] = is_dir($paths['root'].'/'.$content.'/plugins')
+ ? $content.'plugins/'
+ : '';
+ $vars['MUPLUGINS_PATH_IGNORE'] = is_dir($paths['root'].'/'.$content.'/mu-plugins')
+ ? $content.'mu-plugins/'
+ : '';
+ }
}
$template = implode(
DIRECTORY_SEPARATOR,
@@ -334,8 +356,15 @@ private function progress()
'same_content_folder' => ' - Your content folder is WP content folder.',
'done' => ' WP Starter finished successfully!'.str_repeat(' ', 20),
'end' => ' Remember you need an .env file with -at least- DB settings'
- .PHP_EOL.' to make your site fully functional.',
+ .PHP_EOL.' to make your site fully functional.'.PHP_EOL,
);
+ if ($this->gitignoreDone === true) {
+ $messages['end'] .= PHP_EOL.' A .gitignore file has been created with common to-be-ignored'.
+ PHP_EOL.' files and files generated by WP Starter.';
+ } elseif ($this->gitignoreDone === 0) {
+ $messages['end'] .= PHP_EOL.' A .gitignore was found in your project folder, please'.
+ PHP_EOL.' be sure it contains .env and wp-config.php files.';
+ }
$args = func_get_args();
$msg = array_shift($args);
$txt = $messages[$msg];
diff --git a/templates/.gitignore b/templates/.gitignore
index e319f1ca..53045699 100644
--- a/templates/.gitignore
+++ b/templates/.gitignore
@@ -117,12 +117,10 @@ sftp-config.json
### Vagrant
.vagrant/
-### Composer
-{{{VENDOR_PATH_SUBDIR}}}/
-
-### DO NOT REMOVE FOLLOWING LINES
+### GENERATED FILES
.env
-.env.development
-.env.production
-.env.staging
-/wp-config.php
\ No newline at end of file
+/wp-config.php
+{{{VENDOR_PATH_IGNORE}}}
+{{{THEMES_PATH_IGNORE}}}
+{{{PLUGINS_PATH_IGNORE}}}
+{{{MUPLUGINS_PATH_IGNORE}}}
\ No newline at end of file