diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fbd9d7fc..a8a6b5bc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -36,7 +36,7 @@ jobs: env: REF_NAME: ${{ github.ref_name }} run: | - zip -r "${REF_NAME}.zip" * .eslintrc.js .prettierignore .prettierrc.json .shellcheckrc + zip -r "release.zip" * .eslintrc.js .prettierignore .prettierrc.json .shellcheckrc - name: Create changelog env: @@ -48,7 +48,7 @@ jobs: env: REF_NAME: ${{ github.ref_name }} run: | - SUM=`sha256sum "${REF_NAME}.zip"` + SUM=`sha256sum "release.zip"` echo -e "\n#### SHA256 Checksum\n\n\`\`\`\n$SUM\n\`\`\`\n" >> ./RELEASE_CHANGELOG echo "$SUM" > checksum.txt @@ -62,5 +62,5 @@ jobs: prerelease: ${{ contains(github.ref, 'rc') }} body_path: ./RELEASE_CHANGELOG files: | - ${{ github.ref_name }}.zip + release.zip checksum.txt diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 3eca9ed3..8bf86d9f 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,32 +1,3 @@ ![Code of conduct](https://github.com/user-attachments/assets/c65201ac-400b-41c4-9fdf-a0abeb82048e) - -## Community Code of Conduct -Blueprint's Code of Conduct is designed to create a welcoming and inclusive environment for all members of our community. By adhering to these guidelines, we can ensure a positive experience for everyone. - -1. **Respect and Inclusivity**\ -• Treat all members with respect, kindness, and consideration.\ -• Embrace diversity and be inclusive of different backgrounds, perspectives, and experiences. - -2. **Communication**\ -• Communicate openly and honestly, but also thoughtfully.\ -• Listen actively and be open to feedback and differing opinions.\ -• Avoid using offensive language, personal attacks, or harassment. - -3. **Collaboration**\ -• Foster a spirit of collaboration and teamwork.\ -• Support one another in achieving community goals. - -4. **Conflict Resolution**\ -• Address conflicts constructively and privately when possible.\ -• Seek mediation from a community leader or moderator if needed. - -5. **Privacy and Safety**\ -• Respect the privacy of others and do not share personal information without consent.\ -• Create a safe space for all members, free from bullying, discrimination, or intimidation. - -6. **Accountability**\ -• Take responsibility for your actions and their impact on the community.\ -• Report any violations of this Code of Conduct to a community leader or moderator. - -By following this Code of Conduct, we can create a positive and supportive community for everyone. +## Blueprint's [code of conduct](https://blueprint.zip/legal/conduct) applies to this project. diff --git a/blueprint.sh b/blueprint.sh index 47bda8ef..e5ee28bc 100644 --- a/blueprint.sh +++ b/blueprint.sh @@ -10,7 +10,8 @@ BLUEPRINT_ENGINE="solstice" REPOSITORY="BlueprintFramework/framework" -VERSION="rolling" #; +REPOSITORY_BRANCH="main" +VERSION="beta-2025-12" #; FOLDER=$(realpath "$(dirname "$0" 2> /dev/null)" 2> /dev/null) || FOLDER="$BLUEPRINT__FOLDER" OWNERSHIP="www-data:www-data" #; @@ -232,7 +233,7 @@ if [[ $1 != "-bash" ]]; then exit 2 else # Only run if Blueprint is not in the process of upgrading. - if [[ ( $BLUEPRINT_ENVIRONMENT != "upgrade" ) && ( $1 != "--post-upgrade" ) ]]; then + if [[ $BLUEPRINT_ENVIRONMENT != "upgrade2" ]]; then # Print Blueprint icon with ascii characters. C0="\x1b[0m" C1="\x1b[31;43;1m" @@ -246,9 +247,22 @@ if [[ $1 != "-bash" ]]; then export PROGRESS_TOTAL=15 export PROGRESS_NOW=0 + else + PROGRESS_TOTAL="$(("$PROGRESS_TOTAL" + 15))" fi if [[ $BLUEPRINT_ENVIRONMENT == "upgrade" ]]; then + echo -e "\x1b[37;41;1m MANUAL ACTION REQUIRED \x1b[0m" + echo -e "\n\x1b[31;49;1mThis is NOT a bug. Please follow the following instructions:\x1b[0m" + + echo -e "\n\x1b[31;49m1. Use the CTRL+C (^C) keyboard shortcut to terminate this process.\x1b[0m" + echo -e "\x1b[31;49m2. Then, run 'blueprint -upgrade' AGAIN.\x1b[0m" + + read -r + exit 1 + fi + + if [[ $BLUEPRINT_ENVIRONMENT == "upgrade2" ]]; then # Get rid of beta-2025-11 leftovers rm -rf resources/scripts/blueprint/utility resources/scripts/blueprint/css/BlueprintStylesheet.css resources/scripts/blueprint/index.ts fi @@ -257,7 +271,7 @@ if [[ $1 != "-bash" ]]; then PRINT INFO "Installing node modules.." # Check for yarn before installing node modules.. if ! [ -x "$(command -v yarn)" ]; then - PRINT FATAL "Missing dependency \"yarn\"." + PRINT FATAL "Missing dependency \"yarn\"." fi hide_progress fi @@ -417,7 +431,7 @@ if [[ $1 != "-bash" ]]; then sed -i "s~NOTINSTALLED~INSTALLED~g" "$FOLDER/app/BlueprintFramework/Services/PlaceholderService/BlueprintPlaceholderService.php" # Finish installation - if [[ ( $BLUEPRINT_ENVIRONMENT != "upgrade" ) && ( $1 != "--post-upgrade" ) ]]; then + if [[ $BLUEPRINT_ENVIRONMENT != "upgrade2" ]]; then PRINT SUCCESS "Blueprint has completed its installation process." hide_progress fi diff --git a/scripts/commands/advanced/upgrade.sh b/scripts/commands/advanced/upgrade.sh index 35c2499d..19ad0c9c 100644 --- a/scripts/commands/advanced/upgrade.sh +++ b/scripts/commands/advanced/upgrade.sh @@ -1,121 +1,147 @@ #!/bin/bash Command() { - PRINT WARNING "This is an advanced feature, only proceed if you know what you are doing." - - # Confirmation question for developer upgrade. - if [[ $1 == "remote" ]]; then - PRINT INPUT "Upgrading to the latest development build will update Blueprint to a remote version which might differ from the latest release. Continue? (y/N)" - read -r YN - if [[ ( ${YN} != "y"* ) && ( ${YN} != "Y"* ) ]]; then PRINT INFO "Upgrade cancelled.";exit 1;fi - YN="" + # Confirmation question before updating Blueprint + PRINT INPUT "You are about to update your Blueprint installation. Continue? (y/N)" + read -r update_choice + if [[ ( ${update_choice} != "y"* ) && ( ${update_choice} != "Y"* ) ]]; then + # Exit when cancelled by user + PRINT INFO "Upgrade cancelled by user." + exit 1 fi + update_choice="" - # Confirmation question for both developer and stable upgrade. - PRINT INPUT "Upgrading will wipe your .blueprint folder and will deactivate all active extensions. Continue? (y/N)" - read -r YN - if [[ ( ${YN} != "y"* ) && ( ${YN} != "Y"* ) ]]; then PRINT INFO "Upgrade cancelled.";exit 1;fi - YN="" + # Initial steps count for progress bar + export PROGRESS_TOTAL=7 + export PROGRESS_NOW=0 - # Last confirmation question for both developer and stable upgrade. - PRINT INPUT "This is the last warning before upgrading/wiping Blueprint. Type 'continue' to continue, all other input will be taken as 'no'." - read -r YN - if [[ ${YN} != "continue" ]]; then PRINT INFO "Upgrade cancelled.";exit 1;fi - YN="" + # Make sure the script is in $FOLDER + cd "$FOLDER" || exit 1 - INSTALL_STEPS=15 - export PROGRESS_TOTAL="$((10 + "$INSTALL_STEPS"))" - export PROGRESS_NOW=0 + # Export the repository variables + export remote_repo + export remote_branch + export fetched_version - if [[ $1 == "remote" ]]; then PRINT INFO "Fetching and pulling latest commit.." - else PRINT INFO "Fetching and pulling latest release.."; fi + if [[ -d '.update' ]]; then + PRINT WARNING ".update already exists! Replacing it." + rm -rf .update + fi - ((PROGRESS_NOW++)) + # Create temporary directory for upgrade files + PRINT INFO "Creating .update directory.." + mkdir -p .update - mkdir "$FOLDER/.tmp" - cp blueprint.sh .blueprint.sh.bak + # Define cleanup + cleanup() { + PRINT INFO "Cleaning up.." + cd "$FOLDER" || exit 1 - ((PROGRESS_NOW++)) + if [[ $development_files == true ]]; then + PRINT INFO "Restoring extension development files.." + rm -rf .blueprint/dev + mv .update/backup/dev .blueprint/dev + fi + rm -rf .update - HAS_DEV=false - if [[ -n $(find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ]]; then - PRINT INFO "Backing up extension development files.." - mkdir -p "$FOLDER/.tmp" - cp .blueprint/dev "$FOLDER/.tmp/dev" -Rf - HAS_DEV=true - fi + if [[ $1 != "" ]]; then + hide_progress + exit "$1" + fi + } ((PROGRESS_NOW++)) - mkdir -p "$FOLDER/.tmp/files" - cd "$FOLDER/.tmp/files" || cdhalt + # Prepare repository URL if [[ $1 == "remote" ]]; then - if [[ $2 == "" ]]; then - REMOTE_REPOSITORY="https://github.com/$REPOSITORY.git" - else - if [[ $2 != "http://"* ]] && [[ $2 != "https://"* ]]; then - REMOTE_REPOSITORY="https://github.com/$2.git" - else - REMOTE_REPOSITORY="$2" - fi - fi - # download release - hide_progress - if [[ $3 == "" ]]; then - git clone "$REMOTE_REPOSITORY" main - else - git clone "$REMOTE_REPOSITORY" main --branch "$3" - fi + PRINT DEBUG "\$1 was 'remote'" + case $2 in + # Custom git repository + *.git|http://*|https://*) + PRINT DEBUG "setting remote_repo to '$2', remote_branch to '$3'" + remote_repo="$2" + remote_branch="$3" + + if [[ $remote_branch == "" ]]; then + PRINT FATAL "Expected a git branch at argument 3, was empty. Exiting.." + cleanup 1 + fi + if [[ $remote_branch != *.git ]]; then + PRINT FATAL "Expected a git repository at argument 2, was invalid. (Did you forget to prepend your argument with .git?) Exiting.." + cleanup 1 + fi + ;; + + # Custom GitHub repository + */*) + PRINT DEBUG "setting remote_repo to 'https://github.com/$2.git', remote_branch to '$3'" + remote_repo="https://github.com/$2.git" + remote_branch="$3" + + if [[ $remote_branch == "" ]]; then + PRINT WARNING "Expected a git branch at argument 3, was empty. Defaulting to $REPOSITORY_BRANCH.." + remote_branch="$REPOSITORY_BRANCH" + fi + ;; + + # Blueprint default repository + "") + PRINT INFO "No git repository provided, defaulting to '$REPOSITORY' (repo) and '$REPOSITORY_BRANCH' (branch)!" + PRINT DEBUG "setting remote_repo to 'https://github.com/$REPOSITORY.git'" + remote_repo="https://github.com/$REPOSITORY.git" + remote_branch="$REPOSITORY_BRANCH" + ;; + + # Invalid repository provided + *) + PRINT DEBUG "Invalid repository provided" + PRINT FATAL "Expected a GitHub repository name or git repo url at argument 2, but was invalid. Exiting.." + cleanup 1 + ;; + esac else - # download latest release - hide_progress - LOCATION=$(curl -s https://api.github.com/repos/"$REPOSITORY"/releases/latest \ - | grep "zipball_url" \ - | awk '{ print $2 }' \ - | sed 's/,$//' \ - | sed 's/"//g' ) \ - ; curl -L -o main.zip "$LOCATION" - - unzip main.zip - rm main.zip - mv ./* main - fi + PRINT DEBUG "\$1 was NOT 'remote' (it was '$1')" + PRINT INFO "Fetching version info" - ((PROGRESS_NOW++)) + php artisan bp:version:cache 2> "$BLUEPRINT__DEBUG" + tag_latest=$(php artisan bp:version:latest) + PRINT DEBUG "tag_latest is $tag_latest" - if [[ ! -d "main" ]]; then - cd "$FOLDER" || cdhalt - rm -r "$FOLDER/.tmp" &>> "$BLUEPRINT__DEBUG" - rm "$FOLDER/.blueprint.sh.bak" &>> "$BLUEPRINT__DEBUG" - PRINT FATAL "Remote does not exist or encountered an error, try again later." - hide_progress - exit 1 + fetched_version="$tag_latest" + remote_repo="https://github.com/$REPOSITORY.git" + remote_branch="release/$tag_latest" + PRINT DEBUG "set remote_repo to '$remote_repo', remote_branch to '$remote_branch'" fi ((PROGRESS_NOW++)) - # Remove some files/directories that don't have to be moved to the Pterodactyl folder. - PRINT INFO "Cleaning up fetched release.." - rm -r \ - "main/.github" \ - "main/.git" \ - "main/.gitignore" \ - "main/README.md" \ - &>> "$BLUEPRINT__DEBUG" + # Fetching repository with git + PRINT INFO "Downloading repository.." + hide_progress + git clone "$remote_repo" .update/repo --branch "$remote_branch" + + if [[ ! -d ".update/repo" ]]; then + PRINT FATAL "Could not download repository! Exiting.." + cleanup 1 + fi ((PROGRESS_NOW++)) - # Copy fetched release files to the Pterodactyl directory and remove temp files. - PRINT INFO "Moving release files to Pterodactyl directory.." - cp -r main/* "$FOLDER"/ - rm -r \ - "main" \ - "$FOLDER"/.blueprint \ - "$FOLDER"/.tmp/files - cd "$FOLDER" || cdhalt + # Determine and backup development files + development_files=false + if [[ -n $(find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ]]; then + development_files=true + PRINT INFO "Backing up extension development files.." + mkdir -p .update/backup + cp -Rf .blueprint/dev .update/backup/dev + fi ((PROGRESS_NOW++)) + # Delete files + PRINT INFO "Deleting files.." + rm -rf .blueprint + # Clean up folders with potentially broken symlinks. rm \ "resources/views/blueprint/admin/wrappers/"* \ @@ -127,54 +153,34 @@ Command() { ((PROGRESS_NOW++)) + # Run update script + PRINT INFO "Running update script.." + source .update/repo/scripts/updater/update.sh + hide_progress + UpdaterInstall + + ((PROGRESS_NOW++)) + # Deprecated, kept in for backwards compatibility sed -i -E \ -e "s|OWNERSHIP=\"www-data:www-data\" #;|OWNERSHIP=\"$OWNERSHIP\" #;|g" \ -e "s|WEBUSER=\"www-data\" #;|WEBUSER=\"$WEBUSER\" #;|g" \ -e "s|USERSHELL=\"/bin/bash\" #;|USERSHELL=\"$USERSHELL\" #;|g" \ - "$FOLDER/blueprint.sh" + blueprint.sh + # Run install script + PRINT INFO "Running final install script.." chmod +x blueprint.sh - mv "$FOLDER/blueprint" "$FOLDER/.blueprint" + mv blueprint .blueprint hide_progress - BLUEPRINT_ENVIRONMENT="upgrade" PROGRESS_NOW="$PROGRESS_NOW" PROGRESS_TOTAL="$PROGRESS_TOTAL" bash blueprint.sh + BLUEPRINT_ENVIRONMENT="upgrade2" PROGRESS_NOW="$PROGRESS_NOW" PROGRESS_TOTAL="$PROGRESS_TOTAL" bash blueprint.sh ((PROGRESS_NOW++)) - if [[ ${HAS_DEV} == true ]]; then - PRINT INFO "Restoring extension development files.." - rm -rf .blueprint/dev - mv "$FOLDER/.tmp/dev" .blueprint/dev - fi + cleanup - rm -r "$FOLDER/.tmp" - - ((PROGRESS_NOW++)) - - # Post-upgrade checks. - PRINT INFO "Validating update.." - score=0 - - if dbValidate "blueprint.setupFinished"; then score=$((score+1)) - else PRINT WARNING "'blueprint.setupFinished' could not be detected or found."; fi - - # Finalize upgrade. - if [[ ${score} == 1 ]]; then - PRINT SUCCESS "Upgrade finished." - hide_progress - rm .blueprint.sh.bak - exit 0 # success - elif [[ ${score} == 0 ]]; then - PRINT FATAL "All checks have failed. The 'blueprint.sh' file has been reverted." - hide_progress - rm blueprint.sh - mv .blueprint.sh.bak blueprint.sh - exit 1 # error - else - PRINT FATAL "Some checks have failed. The 'blueprint.sh' file has been reverted." - hide_progress - rm blueprint.sh - mv .blueprint.sh.bak blueprint.sh - exit 1 # error - fi + # Tell user that update has finished + PRINT SUCCESS "Update finished!" + hide_progress + exit 0 } diff --git a/scripts/libraries/logFormat.sh b/scripts/libraries/logFormat.sh index e98f2710..40fa578b 100644 --- a/scripts/libraries/logFormat.sh +++ b/scripts/libraries/logFormat.sh @@ -1,5 +1,5 @@ #!/bin/bash -# +# # This script has been created as part of the Blueprint source code # and uses the same license as the rest of the codebase. @@ -97,10 +97,12 @@ PRINT() { echo -e "${SECONDARY}${DATE}${RESET} ${PRIMARY}${TYPE}:${RESET} $MESSAGE${RESET}" fi - echo -e "${BOLD}${SECONDARY}$DATEDEBUG${RESET} ${PRIMARY}${TYPE}:${RESET} $MESSAGE" >> "$FOLDER"/.blueprint/extensions/blueprint/private/debug/logs.txt + if [[ -d "$FOLDER"/.blueprint/extensions/blueprint/private/debug/logs.txt ]]; then + echo -e "${BOLD}${SECONDARY}$DATEDEBUG${RESET} ${PRIMARY}${TYPE}:${RESET} $MESSAGE" >> "$FOLDER"/.blueprint/extensions/blueprint/private/debug/logs.txt + fi # If progress variables exist, draw progress bar if [[ -n "${PROGRESS_TOTAL}" && -n "${PROGRESS_NOW}" ]]; then draw_progress "${PROGRESS_NOW}" "${PROGRESS_TOTAL}" fi -} \ No newline at end of file +} diff --git a/scripts/updater/update.sh b/scripts/updater/update.sh new file mode 100644 index 00000000..d2e19508 --- /dev/null +++ b/scripts/updater/update.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +UpdaterInstall() { + # Copy release files to Pterodactyl directory + PRINT INFO "Copying release files to Pterodactyl directory.." + cp -r .update/repo/* . + cp .update/repo/.eslintrc.js . + cp .update/repo/.prettierignore . + cp .update/repo/.prettierrc.json . + cp .update/repo/.shellcheckrc . +}