Skip to content

Commit

Permalink
v 0.98.0
Browse files Browse the repository at this point in the history
- Clean vars when launching some high level tasks.
- Sandbox : handle current repository & create a basic admin.
  • Loading branch information
Darklg committed Jul 31, 2024
1 parent 6abcb27 commit e8825f5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 11 deletions.
56 changes: 46 additions & 10 deletions bin/sandbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ function wputools__sandbox(){
_REPOSITORY="${1}";
fi;

# Detect a git repository
if [[ -d .git ]]; then
_INSTALL_TYPE="local"
# Asks the user wants to continue
local continue_git_detected=$(bashutilities_get_yn "- A git repository has been detected in this folder, do you want to continue and use it ?" 'n')
if [[ "${continue_git_detected}" == 'n' ]]; then
return 0;
fi;
# Stop if a wp-config file is detected
if [[ -f wp-config.php || -f ../wp-config.php ]]; then
bashutilities_message "A wp-config.php file has been detected in this folder or the parent, please remove it before continuing" 'error';
return 0;
fi;
fi;

echo "# Chosen mode : ${_MODE}";

# Temp dir
Expand All @@ -27,26 +42,23 @@ function wputools__sandbox(){
git clone "${_REPOSITORY}" "${_DIR}";
cd "${_DIR}";
git submodule update --init --recursive;
else
fi;
if [[ "${_INSTALL_TYPE}" == 'blank' ]];then
mkdir "${_DIR}";
cd "${_DIR}";
fi;
local _CURRENT_DIR_SANDBOX=$(pwd);

# Download WordPress
if [[ "${_MODE}" == 'sqlite' ]];then

# Download WordPress
if [[ "${_INSTALL_TYPE}" == 'blank' ]];then
_WPCLICOMMAND core download ;
fi;
if [[ "${_INSTALL_TYPE}" == 'blank' ]];then
_WPCLICOMMAND core download ;
fi;

# Download and Install SQLite integration
# Download and Install SQLite integration
if [[ "${_MODE}" == 'sqlite' ]];then
git clone https://github.com/aaemnnosttv/wp-sqlite-db.git;
mv wp-sqlite-db/src/db.php wp-content/db.php;
rm -rf wp-sqlite-db;
else
_WPCLICOMMAND core download;
fi;

# Install site
Expand Down Expand Up @@ -85,8 +97,15 @@ PHP
# Activate theme
if [[ "${_INSTALL_TYPE}" == 'blank' ]];then
_WPCLICOMMAND theme activate "${_DIR}";
else
# Install first available theme excluding twenty* and wputhemes
local _THEME=$(wp theme list --status=inactive --field=name | grep -v 'twenty' | grep -v 'WPUT' | head -n 1);
_WPCLICOMMAND theme activate "${_THEME}";
fi;

# Create an admin user
_WPCLICOMMAND user create admin2 admin2@example.com --user_pass=admin2 --role=administrator;

# Create init file
cat <<EOT >> "init-server.sh";
#!/bin/bash
Expand All @@ -101,6 +120,23 @@ init_server_sandbox;
EOT
chmod +x "init-server.sh";

if [[ "${_INSTALL_TYPE}" == 'local' ]];then
cat <<EOT >> "clean-server.sh";
#!/bin/bash
function clean_server_sandbox(){
rm -r "${_CURRENT_DIR_SANDBOX}/wp-content/database";
rm -r "${_CURRENT_DIR_SANDBOX}/wp-config.php";
rm -r "${_CURRENT_DIR_SANDBOX}/clean-server.sh";
rm -r "${_CURRENT_DIR_SANDBOX}/init-server.sh";
rm -r "${_CURRENT_DIR_SANDBOX}/wp-content/db.php";
}
clean_server_sandbox;
EOT
chmod +x "clean-server.sh";
fi;

# Init server
. "init-server.sh";
}
Expand Down
3 changes: 2 additions & 1 deletion wputools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

WPUTools(){

local _WPUTOOLS_VERSION='0.97.0';
local _WPUTOOLS_VERSION='0.98.0';
local _PHP_VERSIONS=(7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5 9.0)
local _PHP_VERSIONS_OBSOLETES=(7.0 7.1 7.2 7.3 7.4)
local _PHP_VERSIONS_ADVANCED=(8.2 8.3 8.4 8.5 9.0)
Expand Down Expand Up @@ -130,6 +130,7 @@ fi;
case "${1}" in
"sandbox" | "src" | "self-update" | "importsite" | "help")
. "${_SOURCEDIR}bin/${1}.sh";
. "${_SOURCEDIR}inc/stop.sh";
return 0;
;;
esac
Expand Down

0 comments on commit e8825f5

Please sign in to comment.