Skip to content

Commit

Permalink
Y2024
Browse files Browse the repository at this point in the history
  • Loading branch information
vprtsingh committed Jun 22, 2024
1 parent a37ee60 commit 4c5dea2
Show file tree
Hide file tree
Showing 16 changed files with 374 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app-stop.sh
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions app-upgrade.sh
Original file line number Diff line number Diff line change
@@ -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!"
18 changes: 18 additions & 0 deletions library-stop.sh
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions library-upgrade.sh
Original file line number Diff line number Diff line change
@@ -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!"
Binary file not shown.
Binary file not shown.
Binary file added templates/library/nextjs-library-boilerplate.zip
Binary file not shown.
Binary file added templates/library/nodejs-library-boilerplate.zip
Binary file not shown.
Binary file not shown.
Binary file added templates/library/reactjs-library-boilerplate.zip
Binary file not shown.
85 changes: 85 additions & 0 deletions templates/library/sh-cleanup-projects.sh
Original file line number Diff line number Diff line change
@@ -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."
30 changes: 30 additions & 0 deletions templates/library/sh-install-projects.sh
Original file line number Diff line number Diff line change
@@ -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."
40 changes: 40 additions & 0 deletions templates/library/sh-start-projects.sh
Original file line number Diff line number Diff line change
@@ -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."
31 changes: 31 additions & 0 deletions templates/library/sh-stop-projects.sh
Original file line number Diff line number Diff line change
@@ -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."
30 changes: 30 additions & 0 deletions templates/library/sh-upgrade-projects.sh
Original file line number Diff line number Diff line change
@@ -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."
28 changes: 28 additions & 0 deletions templates/library/sh-zip-projects.sh
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit 4c5dea2

Please sign in to comment.