diff --git a/app-stop.sh b/app-stop.sh new file mode 100644 index 00000000..280c48a6 --- /dev/null +++ b/app-stop.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Function to check the last command for errors +check_last_command() { + if [ $? -ne 0 ]; then + echo "An error occurred. Exiting." + exit 1 + fi +} + +# Step 0: Run the sh-stop-projects.sh script to stop all running ports +echo "Ensuring templates/app/sh-stop-projects.sh is executable..." +chmod +x templates/app/sh-stop-projects.sh +check_last_command + +echo "Running templates/app/sh-stop-projects.sh to clean up..." +(cd templates/app && sh sh-stop-projects.sh) +check_last_command \ No newline at end of file diff --git a/app-upgrade.sh b/app-upgrade.sh new file mode 100644 index 00000000..102c6319 --- /dev/null +++ b/app-upgrade.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Function to check the last command for errors +check_last_command() { + if [ $? -ne 0 ]; then + echo "An error occurred. Exiting." + exit 1 + fi +} + +# Step 0: Run the sh-cleanup-projects.sh script to clean up before creating the zip file +echo "Ensuring templates/app/sh-cleanup-projects.sh is executable..." +chmod +x templates/app/sh-cleanup-projects.sh +check_last_command + +echo "Running templates/app/sh-cleanup-projects.sh to clean up..." +(cd templates/app && sh sh-cleanup-projects.sh) +check_last_command + +# Step 1: Run the sh-upgrade-projects.sh script to upgrade dependencies +echo "Ensuring templates/app/sh-upgrade-projects.sh is executable..." +chmod +x templates/app/sh-upgrade-projects.sh +check_last_command + +echo "Running templates/app/sh-upgrade-projects.sh to upgrade dependencies..." +(cd templates/app && sh sh-upgrade-projects.sh) +check_last_command + +# Step 2: Run the sh-install-projects.sh script to install dependencies +echo "Ensuring templates/app/sh-install-projects.sh is executable..." +chmod +x templates/app/sh-install-projects.sh +check_last_command + +echo "Running templates/app/sh-install-projects.sh to install dependencies..." +(cd templates/app && sh sh-install-projects.sh) +check_last_command + +# Step 3: Run the sh-start-projects.sh script to start the project +echo "Ensuring templates/app/sh-start-projects.sh is executable..." +chmod +x templates/app/sh-start-projects.sh +check_last_command + +echo "Running templates/app/sh-start-projects.sh to start the project..." +(cd templates/app && sh sh-start-projects.sh) +check_last_command + +echo "All done!" diff --git a/library-stop.sh b/library-stop.sh new file mode 100644 index 00000000..5eee109b --- /dev/null +++ b/library-stop.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Function to check the last command for errors +check_last_command() { + if [ $? -ne 0 ]; then + echo "An error occurred. Exiting." + exit 1 + fi +} + +# Step 0: Run the sh-stop-projects.sh script to stop all running ports +echo "Ensuring templates/library/sh-stop-projects.sh is executable..." +chmod +x templates/library/sh-stop-projects.sh +check_last_command + +echo "Running templates/library/sh-stop-projects.sh to clean up..." +(cd templates/library && sh sh-stop-projects.sh) +check_last_command \ No newline at end of file diff --git a/library-upgrade.sh b/library-upgrade.sh new file mode 100644 index 00000000..6ef43ef8 --- /dev/null +++ b/library-upgrade.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Function to check the last command for errors +check_last_command() { + if [ $? -ne 0 ]; then + echo "An error occurred. Exiting." + exit 1 + fi +} + +# Step 0: Run the sh-cleanup-projects.sh script to clean up before creating the zip file +echo "Ensuring templates/library/sh-cleanup-projects.sh is executable..." +chmod +x templates/library/sh-cleanup-projects.sh +check_last_command + +echo "Running templates/library/sh-cleanup-projects.sh to clean up..." +(cd templates/library && sh sh-cleanup-projects.sh) +check_last_command + +# Step 1: Run the sh-upgrade-projects.sh script to upgrade dependencies +echo "Ensuring templates/library/sh-upgrade-projects.sh is executable..." +chmod +x templates/library/sh-upgrade-projects.sh +check_last_command + +echo "Running templates/library/sh-upgrade-projects.sh to upgrade dependencies..." +(cd templates/library && sh sh-upgrade-projects.sh) +check_last_command + +# Step 2: Run the sh-install-projects.sh script to install dependencies +echo "Ensuring templates/library/sh-install-projects.sh is executable..." +chmod +x templates/library/sh-install-projects.sh +check_last_command + +echo "Running templates/library/sh-install-projects.sh to install dependencies..." +(cd templates/library && sh sh-install-projects.sh) +check_last_command + +# Step 3: Run the sh-start-projects.sh script to start the project +echo "Ensuring templates/library/sh-start-projects.sh is executable..." +chmod +x templates/library/sh-start-projects.sh +check_last_command + +echo "Running templates/library/sh-start-projects.sh to start the project..." +(cd templates/library && sh sh-start-projects.sh) +check_last_command + +echo "All done!" diff --git a/templates/library/expressjs-library-boilerplate.zip b/templates/library/expressjs-library-boilerplate.zip new file mode 100644 index 00000000..16e10acd Binary files /dev/null and b/templates/library/expressjs-library-boilerplate.zip differ diff --git a/templates/library/javascript-library-boilerplate.zip b/templates/library/javascript-library-boilerplate.zip new file mode 100644 index 00000000..5ad1640b Binary files /dev/null and b/templates/library/javascript-library-boilerplate.zip differ diff --git a/templates/library/nextjs-library-boilerplate.zip b/templates/library/nextjs-library-boilerplate.zip new file mode 100644 index 00000000..beabcacb Binary files /dev/null and b/templates/library/nextjs-library-boilerplate.zip differ diff --git a/templates/library/nodejs-library-boilerplate.zip b/templates/library/nodejs-library-boilerplate.zip new file mode 100644 index 00000000..d9ee3835 Binary files /dev/null and b/templates/library/nodejs-library-boilerplate.zip differ diff --git a/templates/library/react-native-library-boilerplate.zip b/templates/library/react-native-library-boilerplate.zip new file mode 100644 index 00000000..8ad25289 Binary files /dev/null and b/templates/library/react-native-library-boilerplate.zip differ diff --git a/templates/library/reactjs-library-boilerplate.zip b/templates/library/reactjs-library-boilerplate.zip new file mode 100644 index 00000000..4814c14c Binary files /dev/null and b/templates/library/reactjs-library-boilerplate.zip differ diff --git a/templates/library/sh-cleanup-projects.sh b/templates/library/sh-cleanup-projects.sh new file mode 100755 index 00000000..86b0f282 --- /dev/null +++ b/templates/library/sh-cleanup-projects.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +# List of project directories +projects=( + "expressjs-library-boilerplate" + "javascript-library-boilerplate" + "nextjs-library-boilerplate" + "nodejs-library-boilerplate" + "react-native-library-boilerplate" + "reactjs-library-boilerplate" +) + +rm -rf react-native-library-boilerplate/example/node_modules + +# Loop through each project directory and remove specified files/folders +for project in "${projects[@]}"; do + echo "Cleaning up $project" + + # Define the zip file name + zip_file="${project}.zip" + + # Check if the zip file exists and remove it + if [ -f "$zip_file" ]; then + echo "Removing existing zip file $zip_file" + rm "$zip_file" + else + echo "No zip file found for $project" + fi + + + cd "$project" + + + # Remove node_modules directory if it exists + if [ -d node_modules ]; then + echo "Removing node_modules from $project" + rm -rf node_modules + fi + + # Remove .next directory if it exists + if [ -d .next ]; then + echo "Removing .next from $project" + rm -rf .next + fi + + # Remove .next directory if it exists + if [ -d .cache ]; then + echo "Removing .cache from $project" + rm -rf .cache + fi + + # Remove .expo-shared directory if it exists + if [ -d .expo-shared ]; then + echo "Removing .expo-shared from $project" + rm -rf .expo-shared + fi + + # Remove .expo directory if it exists + if [ -d .expo ]; then + echo "Removing .expo from $project" + rm -rf .expo + fi + + # Remove yarn.lock file if it exists + if [ -f yarn.lock ]; then + echo "Removing yarn.lock from $project" + rm yarn.lock + fi + + # Go back to the parent directory + cd .. +done + +# Remove logs and pids directories if they exist +if [ -d logs ]; then + echo "Removing logs directory" + rm -rf logs +fi + +if [ -d pids ]; then + echo "Removing pids directory" + rm -rf pids +fi + +echo "Cleanup completed for all projects." diff --git a/templates/library/sh-install-projects.sh b/templates/library/sh-install-projects.sh new file mode 100755 index 00000000..316e58ef --- /dev/null +++ b/templates/library/sh-install-projects.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# List of project directories +projects=( + "expressjs-library-boilerplate" + "javascript-library-boilerplate" + "nextjs-library-boilerplate" + "nodejs-library-boilerplate" + "react-native-library-boilerplate" + "reactjs-library-boilerplate" +) + +# Loop through each project directory and run yarn install +for project in "${projects[@]}"; do + echo "Installing dependencies in $project" + cd "$project" + + # Check if package.json exists + if [ -f package.json ]; then + # Run yarn install + yarn install + else + echo "package.json not found in $project" + fi + + # Go back to the parent directory + cd .. +done + +echo "Dependencies have been installed for all projects." diff --git a/templates/library/sh-start-projects.sh b/templates/library/sh-start-projects.sh new file mode 100755 index 00000000..552069ba --- /dev/null +++ b/templates/library/sh-start-projects.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# List of project directories +projects=( + "expressjs-library-boilerplate" + "javascript-library-boilerplate" + "nextjs-library-boilerplate" + "nodejs-library-boilerplate" + "react-native-library-boilerplate" + "reactjs-library-boilerplate" +) + +# Create logs and pids directories if they don't exist +mkdir -p logs +mkdir -p pids + +# Loop through each project directory and run yarn install +for project in "${projects[@]}"; do + echo "Starting project in $project" + + # Navigate to the project directory + cd "$project" + + # Check if package.json exists + if [ -f package.json ]; then + # Run yarn dev and log output to a file + (yarn dev > "../logs/$project.log" 2>&1 & echo $! > "../pids/$project.pid") + echo "$project started, logging to ../logs/$project.log, PID saved to ../pids/$project.pid" + else + echo "package.json not found in $project" + fi + + # Go back to the parent directory + cd .. +done + +# Wait for all background processes to finish +wait + +echo "Dev servers have been started for all projects." diff --git a/templates/library/sh-stop-projects.sh b/templates/library/sh-stop-projects.sh new file mode 100755 index 00000000..24952a31 --- /dev/null +++ b/templates/library/sh-stop-projects.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# List of project directories +projects=( + "expressjs-library-boilerplate" + "javascript-library-boilerplate" + "nextjs-library-boilerplate" + "nodejs-library-boilerplate" + "react-native-library-boilerplate" + "reactjs-library-boilerplate" +) + +# Loop through each project directory and stop the servers +for project in "${projects[@]}"; do + echo "Stopping project in $project" + + # Check if PID file exists + if [ -f "pids/$project.pid" ]; then + # Read the PID from the file and kill the process + PID=$(cat "pids/$project.pid") + kill $PID + echo "$project stopped, PID $PID killed" + + # Remove the PID file + rm "pids/$project.pid" + else + echo "PID file not found for $project" + fi +done + +echo "All dev servers have been stopped." diff --git a/templates/library/sh-upgrade-projects.sh b/templates/library/sh-upgrade-projects.sh new file mode 100755 index 00000000..d196520b --- /dev/null +++ b/templates/library/sh-upgrade-projects.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# List of project directories +projects=( + "expressjs-library-boilerplate" + "javascript-library-boilerplate" + "nextjs-library-boilerplate" + "nodejs-library-boilerplate" + "react-native-library-boilerplate" + "reactjs-library-boilerplate" +) + +# Loop through each project directory and run the upgrade command +for project in "${projects[@]}"; do + echo "Upgrading packages in $project" + cd "$project" + + # Check if package.json exists + if [ -f package.json ]; then + # Run the upgrade command + npm run upgrade + else + echo "package.json not found in $project" + fi + + # Go back to the parent directory + cd .. +done + +echo "All projects have been upgraded." diff --git a/templates/library/sh-zip-projects.sh b/templates/library/sh-zip-projects.sh new file mode 100755 index 00000000..b4ec2ab8 --- /dev/null +++ b/templates/library/sh-zip-projects.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# List of project directories +projects=( + "expressjs-library-boilerplate" + "javascript-library-boilerplate" + "nextjs-library-boilerplate" + "nodejs-library-boilerplate" + "react-native-library-boilerplate" + "reactjs-library-boilerplate" +) + +# Loop through each project directory to remove existing zip files and create new ones +for project in "${projects[@]}"; do + zip_file="${project}.zip" + + # Check if the zip file exists and remove it + if [ -f "$zip_file" ]; then + echo "Removing existing zip file $zip_file" + rm "$zip_file" + fi + + # Create a new zip file for the project directory + echo "Creating zip file for $project" + zip -r "$zip_file" "$project" +done + +echo "Zip files have been created for all projects."