Skip to content

Commit

Permalink
Added parameter to ignore NPM (#32)
Browse files Browse the repository at this point in the history
* feat(npm): added parameter

* feat(npm): added parameter

* feat(npm): added parameter

* feat(npm): added parameter

* added else with verbose info

* fix(composer): execute it

* fix(composer): execute it

* missing fi
  • Loading branch information
Mte90 authored Nov 16, 2022
1 parent e87cd47 commit edb0729
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Running this command will convert an svn based checkout to git and will require
| `site_title` | The first host of the site | The title of the site after install |
| `vcs` | `svn` | The type of WP checkout to make when first creating the site, valid values are `svn` and `git` |
| `wp_type` | `single` | Defines what kind of site gets installed, `subdomain` `subdirectory` or `single` are valid values |
| `npm` | `true` | Execute NPM during the provision |

### The Minimum Required Configuration

Expand Down
29 changes: 21 additions & 8 deletions provision/vvv-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ DOMAIN=$(get_primary_host "${VVV_SITE_NAME}".test)
SITE_TITLE=$(get_config_value 'site_title' "${DOMAIN}")
WP_TYPE=$(get_config_value 'wp_type' "single")
DB_NAME=$(get_config_value 'db_name' "${VVV_SITE_NAME}")
NPM=$(get_config_value 'npm' "true")
DB_NAME=${DB_NAME//[\\\/\.\<\>\:\"\'\|\?\!\*-]/}
VCS=$(get_config_value 'vcs' '')

Expand Down Expand Up @@ -130,7 +131,7 @@ function try_npm_install() {
echo " * Clearing npm cache"
npm_config_loglevel=error npm cache clean --force
echo " * Running npm install again"
npm_config_loglevel=error npm install --no-optional
npm_config_loglevel=error noroot npm install --no-optional --force
echo " * Completed npm install command, check output for issues"
fi
echo " * Finished running npm install"
Expand Down Expand Up @@ -185,8 +186,12 @@ else
handle_git_wp
fi

try_npm_install
try_npm_build
if [[ "${NPM}" == "true" ]]; then
try_npm_install
try_grunt_build
else
echo ' * NPM package installation ignored'
fi

if [[ ! -f "${VVV_PATH_TO_SITE}/public_html/wp-config.php" ]]; then
configure_wp
Expand All @@ -196,14 +201,22 @@ maybe_install_wp
check_for_wp_importer

echo " * Checking for WordPress build"
if [[ ! -d "${VVV_PATH_TO_SITE}/public_html/build" ]]; then
echo " * Running NPM build... This may take a few moments."
cd "${VVV_PATH_TO_SITE}/public_html/"
try_npm_build
echo " * NPM Build completed."
if [[ "${NPM}" == "true" ]]; then
if [[ ! -d "${VVV_PATH_TO_SITE}/public_html/build" ]]; then
echo " * Initializing grunt... This may take a few moments."
cd "${VVV_PATH_TO_SITE}/public_html/"
try_grunt_build
echo " * Grunt initialized."
fi
fi

echo " * Checking mu-plugins folder"
noroot mkdir -p "${VVV_PATH_TO_SITE}/public_html/src/wp-content/mu-plugins" "${VVV_PATH_TO_SITE}/public_html/build/wp-content/mu-plugins"

echo " * Copy wp-tests-config.php for phpunit"
cp "/srv/config/wordpress-config/wp-tests-config.php" "${VVV_PATH_TO_SITE}/public_html/wp-tests-config.php"

echo " * Install Composer packages"
noroot composer update --no-ansi --no-progress > /dev/null

echo " * Custom site template develop provisioner completed, WP will be served from the build folder, don't forget to rebuild after changes to src"

1 comment on commit edb0729

@tomjn
Copy link
Member

@tomjn tomjn commented on edb0729 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mte90 I think this commit broke the provisioner by swapped try_npm_build for try_grunt_build without adding the try_grunt_build function

Please sign in to comment.