diff --git a/build.php b/build.php index 5a5c549..3dfb7a3 100644 --- a/build.php +++ b/build.php @@ -5,6 +5,12 @@ exit(0); } +/* Parameters: + --no-composer Does not install vendors. Just create the autoloader. + --cleanup Remove removeables. + --allow-gulp Allow gulp to be used. +*/ + // Any command needed to run and build plugin assets when newly cheched out of repo. $buildCommands = []; @@ -17,7 +23,7 @@ } $buildCommands[] = 'composer dump-autoload'; } -/* + //Run npm if package.json is found if(file_exists('package.json') && file_exists('package-lock.json')) { $buildCommands[] = 'npm ci --no-progress --no-audit'; @@ -26,16 +32,19 @@ } //Run build if package-lock.json is found -if(file_exists('package-lock.json')) { +if(file_exists('package-lock.json') && !file_exists('gulp.js')) { $buildCommands[] = 'npx --yes browserslist@latest --update-db'; $buildCommands[] = 'npm run build'; -}*/ +} elseif(file_exists('package-lock.json') && file_exists('gulp.js') && is_array($argv) && in_array('--allow-gulp', $argv)) { + $buildCommands[] = 'gulp'; +} // Files and directories not suitable for prod to be removed. $removables = [ '.git', '.gitignore', '.github', + '.gitattributes', 'build.php', '.npmrc', 'composer.json', @@ -45,7 +54,14 @@ 'package-lock.json', 'package.json', 'phpunit.xml.dist', - 'README.md' + 'README.md', + 'gulpfile.js', + './node_modules/', + './source/sass/', + './source/js/', + 'LICENSE', + 'babel.config.js', + 'yarn.lock' ]; $dirName = basename(dirname(__FILE__)); @@ -65,7 +81,7 @@ } // Remove files and directories if '--cleanup' argument is supplied to save local developers from disasters. -if (isset($argv[1]) && $argv[1] === '--cleanup') { +if(is_array($argv) && in_array('--cleanup', $argv)) { foreach ($removables as $removable) { if (file_exists($removable)) { print "Removing $removable from $dirName\n";