diff --git a/qqq-dev-tools/CURRENT-SNAPSHOT-VERSION b/qqq-dev-tools/CURRENT-SNAPSHOT-VERSION new file mode 100644 index 00000000..a918a2aa --- /dev/null +++ b/qqq-dev-tools/CURRENT-SNAPSHOT-VERSION @@ -0,0 +1 @@ +0.6.0 diff --git a/qqq-dev-tools/MODULE_LIST b/qqq-dev-tools/MODULE_LIST new file mode 100644 index 00000000..a3b11017 --- /dev/null +++ b/qqq-dev-tools/MODULE_LIST @@ -0,0 +1,5 @@ +qqq-backend-core +qqq-backend-module-rdbms +qqq-backend-module-filesystem +qqq-middleware-javalin +qqq-middleware-picocli diff --git a/qqq-dev-tools/bin/end-of-sprint-release.sh b/qqq-dev-tools/bin/end-of-sprint-release.sh new file mode 100755 index 00000000..851a4d2d --- /dev/null +++ b/qqq-dev-tools/bin/end-of-sprint-release.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +############################################################################ +## Script to run the release process on qqq at the end of a sprint. +## It's a good idea to run it from a fresh clone, but that's not strictly needed. +## Uses gum for CLI UI. +############################################################################ + +function gumBanner +{ + gum style --foreground "#60A0FF" --border thick --width 80 --align=center "${@}" +} + +function gumConfirmProceed +{ + prompt=$1 + affirmative=$2 + negative=$3 + gum confirm "$prompt" --prompt.border thick --prompt.width 80 --prompt.align center --affirmative="$affirmative" --negative="$negative" + + if [ "$?" == "1" ]; then + echo "OK, exiting." + exit; + fi +} + +gumBanner "Making sure you have a clean git checkout" +git status +gumConfirmProceed "Can we Proceed, or do you need to clean up your checkout (git stash -u)?" "Proceed" "I need to clean up my checkout" + +gumBanner "Checking for open PR's..." +gh pr list +gumConfirmProceed "Can we Proceed, or are there open PR's that need merged?" "Proceed" "There are open PR's that need merged" + +gumBanner "Getting dev & main branches up to date and ready" +git checkout main && git pull && git checkout dev && git pull + +if [ ! -e "qqq-sample-project/.env" ]; then + dir=$(realpath qqq-sample-project) + gumBanner "Installing .env file -- for qqq-sample-project" "Tell it your qqq is at:" "$dir" + setup-environments.sh --qqq --quiet +fi + +MVN_VERIFY_LOG=/tmp/mvn-verify.log +gumBanner "Doing clean build (logging to $MVN_VERIFY_LOG)" +cp ~/git/kingsrook/qqq/qqq-sample-project/.env qqq-sample-project +mvn clean verify > $MVN_VERIFY_LOG 2>&1 +tail -30 $MVN_VERIFY_LOG +gumConfirmProceed "Can we Proceed, or are there build errors to fix?" "Proceed" "There are build errors to fix" + +gumBanner "Running mvn gitflow:release-start" +mvn gitflow:release-start +gumConfirmProceed "Can we Proceed, or were there errors from the gitflow:release-start?" "Proceed" "There were errors..." + +gumBanner "Pushining release branch to origin" +git push --set-upstream origin "$(git rev-parse --abbrev-ref HEAD)" + +gumBanner "Please wait for a green run in CI on the release branch..." +gumConfirmProceed "Can we Proceed, or did CI not pass on the release branch?" "Proceed" "CI did not pass..." + +gumBanner "Running mvn gitflow:release-finish" +mvn gitflow:release-finish + +gumBanner "Updating qqq-dev-tools/CURRENT-SNAPSHOT-VERSION" +CURRENT_SNAPSHOT_VERSION=$(grep '' pom.xml | sed 's/<.\?revision>//g;s/-SNAPSHOT//;s/ //g;') +echo $CURRENT_SNAPSHOT_VERSION > $QQQ_DEV_TOOLS_DIR/CURRENT-SNAPSHOT-VERSION +cd $QQQ_DEV_TOOLS_DIR +git commit -m "Updating to $CURRENT_SNAPSHOT_VERSION" CURRENT-SNAPSHOT-VERSION +git push + +gumBanner "Done!" +echo "(My notes say to delete branches and snapshot tags now... and to update dependent projects)" diff --git a/qqq-dev-tools/bin/get-latest-snapshot.sh b/qqq-dev-tools/bin/get-latest-snapshot.sh new file mode 100755 index 00000000..11025009 --- /dev/null +++ b/qqq-dev-tools/bin/get-latest-snapshot.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +############################################################################ +## get-latest-snapshot.sh +## Queries the qqq maven registry for the current snapshot version of qqq modules. +############################################################################ + +CURRENT_VERSION="$(cat $QQQ_DEV_TOOLS_DIR/CURRENT-SNAPSHOT-VERSION)" +MODULE_LIST_FILE=$QQQ_DEV_TOOLS_DIR/MODULE_LIST +. $QQQ_DEV_TOOLS_DIR/.env + +function getLatestVersion +{ + artifact=$1 + version=$2 + + curl -s --user ${GITHUB_USER}:${GITHUB_TOKEN} https://maven.pkg.github.com/Kingsrook/qqq-maven-registry/com/kingsrook/qqq/${artifact}/${version}-SNAPSHOT/maven-metadata.xml > /tmp/metadata.xml + ## xmllint -format - < /tmp/metadata.xml + + grep 'does not exist' /tmp/metadata.xml > /dev/null + if [ "$?" == "0" ]; then + echo "not found" + return + fi + + timetsamp=$(xpath -q -e '/metadata/versioning/snapshot/timestamp/text()' /tmp/metadata.xml) + buildNumber=$(xpath -q -e '/metadata/versioning/snapshot/buildNumber/text()' /tmp/metadata.xml) + + echo "$version-$timetsamp-$buildNumber" +} + +function promptForVersion +{ + echo "What version?" + version=$(gum input --value $CURRENT_VERSION) + if [ -z "$version" ]; then + exit 1; + fi + echo " $version" +} + +if [ "$1" == "-i" ]; then + + echo "What artifact?" + artifact=$(cat $MODULE_LIST_FILE | gum filter) + if [ -z "$artifact" ]; then + exit 1; + fi + echo " $artifact" + + promptForVersion + + getLatestVersion $artifact $version + +elif [ "$1" == "-a" ]; then + + version=$2 + if [ "$version" == "-l" ]; then + version=$CURRENT_VERSION + elif [ -z "$version" ]; then + promptForVersion + fi + + for artifact in $(cat $MODULE_LIST_FILE); do + echo "$artifact $(getLatestVersion $artifact $version)" + done + +else + + artifact=$1 + version=$2 + if [ "$version" == "-l" ]; then + version=$CURRENT_VERSION + fi + + if [ -z "$artifact" -o -z "$version" ]; then + echo "Usage: $0 artifact snapshot-version-prefix" + echo " or: $0 -i (interactive mode)" + echo " or: $0 -a [snapshot-version-prefix] (all mode)" + echo "Ex: $0 qqq-backend-core $CURRENT_VERSION" + echo "Ex: $0 -i" + echo "Ex: $0 -a" + echo "Ex: $0 -a $CURRENT_VERSION" + exit 1 + fi + + if [ -z "$version" ]; then + promptForVersion + fi + + getLatestVersion $artifact $version +fi + + diff --git a/qqq-dev-tools/bin/git-tag b/qqq-dev-tools/bin/git-tag new file mode 100755 index 00000000..923f9f63 --- /dev/null +++ b/qqq-dev-tools/bin/git-tag @@ -0,0 +1,34 @@ +#!/bin/bash + +############################################################################ +## git-tag +## Add (deleting, if it already exists) a git tag to a repo (both local & remote) +############################################################################ + +TAG=$1 +if [ -z "$TAG" ]; then + echo "Usage: $0 tagname" + exit 1; +fi + +if [ "$TAG" == "-l" ]; then + git tag -l; + exit 0; +fi + +echo +echo "== Deleting $TAG on local" +git tag -d $TAG + +echo +echo "== Deleting $TAG on remote" +git push origin :refs/tags/$TAG + +echo +echo "== Creating $TAG on local" +git tag $TAG + +echo +echo "== Pushing $TAG on remote" +git push origin $TAG + diff --git a/qqq-dev-tools/bin/install-packages.sh b/qqq-dev-tools/bin/install-packages.sh new file mode 100755 index 00000000..afe7245d --- /dev/null +++ b/qqq-dev-tools/bin/install-packages.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +############################################################################ +## install-packages.sh +## Used by the root-level install.sh - to ensure required packages are installed. +############################################################################ + +brew list coreutils > /dev/null || brew install coreutils; +brew list gnu-sed > /dev/null || brew install gnu-sed; +brew list jq > /dev/null || brew install jq; +brew list gum > /dev/null || (brew tap charmbracelet/tap && brew install charmbracelet/tap/gum); +brew list 1password-cli > /dev/null || brew install --cask 1password/tap/1password-cli diff --git a/qqq-dev-tools/bin/liquibaseColumnsToEntityFields.groovy b/qqq-dev-tools/bin/liquibaseColumnsToEntityFields.groovy new file mode 100755 index 00000000..446ca086 --- /dev/null +++ b/qqq-dev-tools/bin/liquibaseColumnsToEntityFields.groovy @@ -0,0 +1,90 @@ +#!/usr/bin/env groovy + +/******************************************************************************* + ** Script to convert a list of columnNames from liquibase XML (on stdin) + ** to fields for a QRecordEntity (on stdout) + *******************************************************************************/ + +def reader = new BufferedReader(new InputStreamReader(System.in)) +String line +String allFieldNames = "" +while ((line = reader.readLine()) != null) +{ + line = line.trim(); + if (!line.matches(".* name=\".*") || !line.matches(".* type=\".*") ) + { + continue; + } + + String columnName = line.replaceFirst(".* name=\"", "").replaceFirst("\".*", ""); + String columnType = line.replaceFirst(".* type=\"", "").replaceFirst("\".*", ""); + + String fieldName = columNameToFieldName(columnName) + String fieldType = columTypeToFieldType(columnType) + + printf(""" + @QField() + private %s %s; + """, fieldType, fieldName) + + allFieldNames += '"' + fieldName + '",' +} + +println() +println("All field names:") +println(allFieldNames); + +private static String columNameToFieldName(String columnName) +{ + String fieldName = ""; + char lastChar = 0; + for (int i = 0; i < columnName.length(); i++) + { + char c = columnName.charAt(i); + if (c == '_') + { + // noop + } + else if (lastChar == '_') + { + fieldName += new String(c).toUpperCase(); + } + else + { + fieldName += c; + } + + lastChar = c; + } + fieldName +} + + +private static String columTypeToFieldType(String columnType) +{ + if (columnType.toUpperCase().startsWith("INT")) + { + return ("Integer"); + } + if (columnType.toUpperCase().startsWith("VARCHAR")) + { + return ("String"); + } + if (columnType.toUpperCase().startsWith("TIMESTAMP")) + { + return ("Instant"); + } + if (columnType.toUpperCase().startsWith("DATE")) + { + return ("LocalDate"); + } + if (columnType.toUpperCase().startsWith("DECIMAL")) + { + return ("BigDecimal"); + } + if (columnType.toUpperCase().startsWith("BOOL")) + { + return ("Boolean"); + } + return ("FixMeUnknownType"); +} \ No newline at end of file diff --git a/qqq-dev-tools/bin/quick-deps.sh b/qqq-dev-tools/bin/quick-deps.sh new file mode 100755 index 00000000..c3f50d13 --- /dev/null +++ b/qqq-dev-tools/bin/quick-deps.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +DIR=$(dirname $0) +. ${DIR}/../lib/quickLoop.sh + + +defineOption 1 "ls" "Short listing" +defineOption 2 "ls -l" "Long listing" +defineOption 3 "tree" "Tree listing" + +quickLoop; diff --git a/qqq-dev-tools/bin/reset-snapshot-deps.sh b/qqq-dev-tools/bin/reset-snapshot-deps.sh new file mode 100755 index 00000000..77240dee --- /dev/null +++ b/qqq-dev-tools/bin/reset-snapshot-deps.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +############################################################################ +## reset-snapshot-deps.sh +## Reset the version of all qqq deps in a given pom to the current snapshot. +############################################################################ + +CURRENT_VERSION="$(cat $QQQ_DEV_TOOLS_DIR/CURRENT-SNAPSHOT-VERSION)" +MODULE_LIST_FILE=$QQQ_DEV_TOOLS_DIR/MODULE_LIST + +for artifact in $(cat $MODULE_LIST_FILE); do + update-dep.sh $artifact ${CURRENT_VERSION}-SNAPSHOT +done diff --git a/qqq-dev-tools/bin/setup-environments.sh b/qqq-dev-tools/bin/setup-environments.sh new file mode 100755 index 00000000..e6204cee --- /dev/null +++ b/qqq-dev-tools/bin/setup-environments.sh @@ -0,0 +1,234 @@ +#!/bin/bash + +############################################################################ +## setup-environments.sh +## Write .env files, pulling secrets from 1password +############################################################################ + +. $QQQ_DEV_TOOLS_DIR/lib/qqq-shell-functions.sh || (echo "QQQ Dev Tools not properly installed?"; read; exit) + +function usage() +{ + echo "Usage: $0 [--nf-one|--qqq] [-q|--quiet]" + echo "By default, all environments are set up. Give an option to just do nf-one or qqq." + exit 1; +} + +DO_NF_ONE=0 +DO_QQQ=0 +QUIET=0 + +if [ -z "$1" ]; then + DO_NF_ONE=1 + DO_QQQ=1 +else + for arg in ${@}; do + if [ "$arg" == "--nf-one" ]; then + DO_NF_ONE=1 + elif [ "$arg" == "--qqq" ]; then + DO_QQQ=1 + elif [ "$arg" == "-q" -o "$arg" == "--quiet" ]; then + QUIET=1 + else + usage + fi + done +fi + +TAB=" " + +################ +## silly logo ## +################ +if [ "$QUIET" == "0" ]; then + qqqLogo +fi + + +######################################### +## locations of env files in 1password ## +######################################### +QQQ_OP_LOCATION="op://Development Environments/" +NUTRIFRESH_OP_LOCATION="op://NF-One-Development/" + + +################################################## +## repos which need environments setup for them ## +################################################## +QQQ_FRONTEND_MATERIAL_DASHBOARD_REPO_NAME="qqq-frontend-material-dashboard" +QQQ_PROJECT_NAME="qqq" +NF_ONE_REPO_NAME="Nutrifresh-One" + +######################################################## +## qqq modules which need environments setup for them ## +######################################################## +QQQ_SAMPLE_PROJECT_MODULE_NAME="qqq-sample-project" +QQQ_BACKEND_CORE_MODULE_NAME="qqq-backend-core" +QQQ_BACKEND_MODULE_RDBMS_MODULE_NAME="qqq-backend-module-rdbms" +QQQ_DEV_TOOLS_MODULE_NAME="qqq-dev-tools" + + +############################## +## make a list of QQQ repos ## +############################## +QQQ_REPO_LIST=( + $QQQ_FRONTEND_MATERIAL_DASHBOARD_REPO_NAME + $QQQ_PROJECT_NAME +) + +######################### +## list of qqq modules ## +######################### +QQQ_MODULE_LIST=( + $QQQ_SAMPLE_PROJECT_MODULE_NAME + $QQQ_BACKEND_MODULE_RDBMS_MODULE_NAME + $QQQ_BACKEND_CORE_MODULE_NAME + $QQQ_DEV_TOOLS_MODULE_NAME +) + + + +function createDotEnv +{ + repoName=$1 + repoLocation=$2 + isNutrifreshOneRepo=$3 + + echo "${TAB}Changing directory to repository [$repoName] at [$repoLocation]..." + cd "${repoLocation}" || exit + + if [ "$isNutrifreshOneRepo" != "1" ]; then + + if [ "${repoName}" = "${QQQ_PROJECT_NAME}" ]; then + + for moduleName in "${QQQ_MODULE_LIST[@]}" + do + echo "${TAB}Creating QQQ .env for module [$moduleName]..." + cd ${repoLocation} + cd ${moduleName} + rm -rf .env + op read "${QQQ_OP_LOCATION}${moduleName}/environment" > .env + done + + else + + echo "${TAB}Creating QQQ .env..." + rm -rf .env + op read "${QQQ_OP_LOCATION}${repoName}/environment" > .env + + fi + + else + + echo "${TAB}Creating NF .env..." + rm -rf .env + op read "${NUTRIFRESH_OP_LOCATION}${repoName}/environment" > .env + + ##################################################################### + ## assume this is Nutrifresh One and copy down to the ui directory ## + ##################################################################### + echo "${TAB}Copying .env to src/main/ui..." + cd src/main/ui || exit + rm -rf .env + cp ../../../.env . + + fi +} + + + +function setupRepoEnvironment +{ + repoName=$1 + isNutrifreshOneRepo=$2 + + ############################################################# + ## try to automatically find the proper git repo directory ## + ############################################################# + repoLocation=$(find ${HOME}/git -maxdepth 5 -type d -path "*${repoName}/.git" | sed 's/\/\.git//') + + if [ "$repoLocation" != "" ]; then + + ######################################### + ## if found confirm that it is correct ## + ######################################### + echo + echo "Found repository [$repoName] under directory [$repoLocation]. " + echo "If correct, press enter to continue, otherwise enter a different repository location: " + read inputLocation + if [ "$inputLocation" != "" ]; then + repoLocation="$inputLocation" + fi + + else + + echo + echo "Could not find a directory containing repository [$repoName]." + echo "Enter the directory containing this repo: " + read inputLocation + repoLocation="$inputLocation" + + fi + + ############################# + ## remove trailing slashes ## + ############################# + repoLocation=$(echo $repoLocation | sed 's/\/*$//') + + ######################################################## + ## confirm the directory exists and is a git checkout ## + ######################################################## + if [ ! -d "${repoLocation}/.git" ]; then + echo + echo "Invalid git directory was given, quitting..." && exit 1 + fi + + createDotEnv ${repoName} ${repoLocation} $isNutrifreshOneRepo +} + + + +########### +### QQQ ### +########### +if [ "$DO_QQQ" == "1" ]; then + + ################################################## + ## make sure signed into right 1passord account ## + ################################################## + echo + echo "Signing in to Kingsrook's 1password account..." + op signin --account kingsrook.1password.com + + ###################################### + ## build list of all qqq repo names ## + ###################################### + for repoName in "${QQQ_REPO_LIST[@]}" + do + setupRepoEnvironment $repoName + done + +fi + + + +################## +### NUTRIFRESH ### +################## +if [ "$DO_NF_ONE" == "1" ]; then + + ################################################## + ## make sure signed into right 1passord account ## + ################################################## + echo + echo "Signing in to Nutrifresh's 1password account..." + op signin --account team-nutrifreshservices.1password.com + setupRepoEnvironment ${NF_ONE_REPO_NAME} 1 + +fi + + +if [ "$QUIET" == "0" ]; then + echo + echo "All done!" +fi diff --git a/qqq-dev-tools/bin/update-all-qqq-deps.sh b/qqq-dev-tools/bin/update-all-qqq-deps.sh new file mode 100755 index 00000000..09cad332 --- /dev/null +++ b/qqq-dev-tools/bin/update-all-qqq-deps.sh @@ -0,0 +1,14 @@ +#!/bin/zsh + +############################################################################ +## update-all-qqq-deps.sh +## Set the version of all qqq deps in a given pom to the latest snapshot. +############################################################################ + +CURRENT_VERSION="$(cat $QQQ_DEV_TOOLS_DIR/CURRENT-SNAPSHOT-VERSION)" +MODULE_LIST_FILE=$QQQ_DEV_TOOLS_DIR/MODULE_LIST + +for module in $(cat $MODULE_LIST_FILE); do + version=$(get-latest-snapshot.sh $module $CURRENT_VERSION) + update-dep.sh $module $version +done diff --git a/qqq-dev-tools/bin/update-dep.sh b/qqq-dev-tools/bin/update-dep.sh new file mode 100755 index 00000000..22b6ae7d --- /dev/null +++ b/qqq-dev-tools/bin/update-dep.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +############################################################################ +## update-dep.sh +## Update one qqq dependency in a pom with a specific snapshot version +############################################################################ + +dep=$1 +version=$2 + +if [ -z "$dep" -o -z "$version" ]; then + + echo "What dependency?" + dep=$(cat $QQQ_DEV_TOOLS_DIR/MODULE_LIST | gum filter) + if [ -z "$dep" ]; then + exit 1; + fi + echo " $dep" + + echo "What version?" + version=$(gum input --placeholder 0.0.0-20220202.202022-1) + if [ -z "$version" ]; then + exit 1; + fi + echo " $version" +fi + +lines=$(grep -n ".*$dep" pom.xml) +if [ $? != 0 -o $(echo "$lines" | wc -l) -ne 1 ]; then + echo "Error: couldn't really tell where $dep was in the pom.xml" + exit 1; +fi +lineNo=$(( $(echo $lines | cut -d: -f1) + 1 )) + +dependenciesTagLineNo=$(grep -n "" pom.xml | head -1 | cut -d: -f1) +if [ $lineNo -lt $dependenciesTagLineNo ]; then + echo "Not updating $dep in what appears to be the pom for $dep." + exit 0; +fi + +echo "Going to update version of $dep at line $lineNo" +gsed -i "${lineNo}s/.*$version $FILE +NOW=$(date +%s) + +checkBuild() +{ + index=$1 + + repo=$($JQ ".[$i].reponame" < $FILE | sed 's/"//g') + buildStatus=$($JQ ".[$i].status" < $FILE | sed 's/"//g') + url=$($JQ ".[$i].build_url" < $FILE | sed 's/"//g') + jobName=$($JQ ".[$i].workflows.job_name" < $FILE | sed 's/"//g') + avatarUrl=$($JQ ".[$i].user.avatar_url" < $FILE | sed 's/"//g') + date=$($JQ ".[$i].queued_at" < $FILE | sed 's/"//g') + if [ "$date" == "null" ]; then + date=$($JQ ".[$i].committer_date" < $FILE | sed 's/"//g') + fi + + curl $avatarUrl > /tmp/avatar.jpg + sips -s dpiHeight 96 -s dpiWidth 96 /tmp/avatar.jpg -o /tmp/avatar-96dpi.jpg > /dev/null + sips -z 20 20 /tmp/avatar-96dpi.jpg -o /tmp/avatar-20.jpg > /dev/null + base64 /tmp/avatar-20.jpg > /tmp/avatar.b64 + avatarB64=$(cat /tmp/avatar.b64) + + shortRepo="$repo" + case $repo in + qqq-backend-core) shortRepo="core";; + qqq-backend-module-filesystem) shortRepo="fs";; + qqq-backend-module-rdbms) shortRepo="db";; + qqq-middleware-javalin) shortRepo="j'lin";; + qqq-middleware-picocli) shortRepo="p'cli";; + qqq-sample-project) shortRepo="samp";; + qqq-frontend-core) shortRepo="f'core";; + qqq-frontend-material-dashboard) shortRepo="m-db";; + Nutrifresh-One) shortRepo="nf1";; + esac + + timestamp=$(date -j -f "%Y-%m-%dT%H:%M:%S%z" $(echo "$date" | sed 's/\....Z/+0000/') +%s) + seconds=$(( $NOW - $timestamp )) + if [ $seconds -lt 120 ]; then + age="$seconds seconds" + shortAge="${seconds}s" + elif [ $seconds -lt 7200 ]; then + minutes=$(( $seconds / 60 )) + age="$minutes minutes" + shortAge="${minutes}m" + elif [ $seconds -lt 172800 ]; then + hours=$(( $seconds / 3600 )) + age="$hours hours" + shortAge="${hours}h" + else + days=$(( $seconds / 86400 )) + age="$days days" + shortAge="old" + fi + + ## "status" : "failed", // :retried, :canceled, :infrastructure_fail, :timedout, :not_run, :running, :failed, :queued, :not_running, :no_tests, :fixed, :success + if [ "$buildStatus" == "success" ]; then + icon="āœ…" + color="green" + elif [ "$buildStatus" == "failed" ]; then + icon="āŒ" + color="red" + elif [ "$buildStatus" == "running" ]; then + ## icon="šŸƒ" + icon="ā±ļø" + color="blue" + else + icon="ā”" + color="gray" + fi + + if [ $index -lt 1 -o $seconds -lt 300 ]; then + echo -n "${shortRepo}(${shortAge})${icon} " + fi + details="$details\n$repo: $jobName: $buildStatus @ $age ago | color=$color | href=$url | image=$avatarB64" +} + +details="---" +details="$details\nšŸ”„ Refresh | refresh=true" + +for i in $(seq 0 9); do + checkBuild $i +done + +echo "@$(date +%M:%S)" +echo -e "$details" + +cp $FILE /tmp/cci-latest.json +rm $FILE diff --git a/qqq-dev-tools/bin/xbar-latest-snapshots.sh b/qqq-dev-tools/bin/xbar-latest-snapshots.sh new file mode 100755 index 00000000..990ad917 --- /dev/null +++ b/qqq-dev-tools/bin/xbar-latest-snapshots.sh @@ -0,0 +1,35 @@ +#!/bin/zsh + +############################################################################ +## xbar-latest-snapshots.sh +## XBar script to give quick access to current qqq module snapshot build versions +## To use with xbar: +## - Install xbar from https://xbarapp.com/ +## - create a symlink under $HOME/Library/Application Support/xbar/plugins/ +## pointed at this script - with a filename that indicates how frequently +## you want it to run. e.g., every-60-seconds (60s) as: +## ln -s $QQQ_DEV_TOOLS_DIR/bin/xbar-latest-snapshots.sh "$HOME/Library/Application Support/xbar/plugins/xbar-latest-snapshots.60s.sh +## Then, in xbar, go to Plugin Browser, refresh, and :fingerscrossed: +############################################################################ + +echo "Versions@$(date +%M:%S)" +echo "---" +echo "šŸ”„ Refresh | refresh=true" +DIR=$(realpath $(dirname $0)) + +. ~/.zshrc + +function doOne +{ + name=$1 + version=$($QQQ_DEV_TOOLS_DIR/bin/get-latest-snapshot.sh $name -l) + + rest="| font=Menlo" + echo "$name $version" | sed 's/ \(.*\)/ \1 | shell="bash" param1="-c" param2="echo \1 | pbcopy"/' | sed "s/\$/ $rest/" +} + +doOne "qqq-backend-core " +doOne "qqq-backend-module-rdbms " +doOne "qqq-backend-module-filesystem " +doOne "qqq-middleware-picocli " +doOne "qqq-middleware-javalin " diff --git a/qqq-dev-tools/install.sh b/qqq-dev-tools/install.sh new file mode 100755 index 00000000..d6ddb26d --- /dev/null +++ b/qqq-dev-tools/install.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +############################################################################ +## install.sh +## This script installs the qqq-dev-tools onto a user's mac. +## e.g., by adding required brew packages, and settings in ~/zshrc +############################################################################ + +function introBanner() +{ + gum style --border double --margin 1 --padding 1 --align center --width 80 --foreground "#FFFF00" --border-foreground "#0000B0" \ + "Installing qqq-dev-tools at:" \ + $QQQ_DEV_TOOLS_DIR +} + +################################################## +## check if gum and realpath are both available ## +################################################## +which gum && which realpath > /dev/null 2>&1 +if [ "$?" == "0" ]; then + ################################################################################### + ## if so, use realpath to get the QQQ_DEV_TOOLS_DIR ## + ## print our gum banner, and use a gum spinner while checking for other packages ## + ################################################################################### + QQQ_DEV_TOOLS_DIR=$(dirname $(realpath $0)) + introBanner + gum spin --title "Checking for / Installing required homebrew packages..." -- $QQQ_DEV_TOOLS_DIR/bin/install-packages.sh +else + ################################################################################################## + ## if not, run the install-packages script just based dirname of $0, and don't give gum spinner ## + ## after packages are installed, we can use realpath to get the actual QQQ_DEV_TOOLS_DIR ## + ## then print our gum introBanner and resume ## + ################################################################################################## + DIR=$(dirname $0) + echo "Checking for / Installing required homebrew packages..." + $DIR/bin/install-packages.sh + QQQ_DEV_TOOLS_DIR=$(dirname $(realpath $0)) + introBanner +fi + +function addVarsToRc() +{ + file=$1 + grep '##QQQ_DEV_TOOLS:start' $file > /dev/null + if [ "$?" == "0" ]; then + echo + echo "Found existing QQQ_DEV_TOOLS section in $file:" + echo + gsed '/##QQQ_DEV_TOOLS:start/,/##QQQ_DEV_TOOLS:end/p;d' $file | gum format -t code + echo + gum confirm "Please confirm removal (for replacement) of these lines of $file" + if [ "$?" == "1" ]; then + echo "OK, exiting." + exit; + fi + gsed -i '/##QQQ_DEV_TOOLS:start/,/##QQQ_DEV_TOOLS:end/d' $file + fi + + echo "Adding QQQ_DEV_TOOLS section to $file" + cat <> $file +##QQQ_DEV_TOOLS:start +## This section of this file was written automatically by: +## $(realpath $0). +## It may be re-written in the future by re-running that script. +## Unless, that is, you edit things here. Then, you're on your own :) +export QQQ_DEV_TOOLS_DIR=$QQQ_DEV_TOOLS_DIR +export PATH="$QQQ_DEV_TOOLS_DIR/bin:\$PATH" +. $QQQ_DEV_TOOLS_DIR/lib/qqq-shell-functions.sh +##QQQ_DEV_TOOLS:end +EOF +} + +addVarsToRc ~/.zshrc +addVarsToRc ~/.bashrc + +tada=$(echo ':tada:' | gum format --type emoji) +gum style --border double --margin 1 --padding 1 --align center --width 80 --foreground "#00FF00" --border-foreground "#0000B0" \ + "QQQ Dev Tools installation is complete $tada" \ + "" \ + "You'll want to either re-source ~/.zshrc, or make a new terminal session, to start using it." diff --git a/qqq-dev-tools/lib/qqq-shell-functions.sh b/qqq-dev-tools/lib/qqq-shell-functions.sh new file mode 100644 index 00000000..7e55cb12 --- /dev/null +++ b/qqq-dev-tools/lib/qqq-shell-functions.sh @@ -0,0 +1,5 @@ + +function qqqLogo() +{ + base64 -d <<<"H4sIAD/I4WIAA72XQY4sIQiG932KTowbiByAhGTuf6pB0SpRy67ufvOYxSRqfyL+gPV8/pU9/oz8f9EsCCFmC4DC9I/QJOFntAjpe7ScuBAAwrkNfuL7ieaKCdJxUsPDF2isCB5XSLQd33a8oWHz+xqod0P+6MmTx9XIHH/Tb0NbNORyld1D/ARtJ94sC9tTbdD00in5INo30RYxTU+UdDdBbwSE5xR12t+j52usMkeusp4spFd0Jz4XyzQyLWDEAvFWhvqUiU4DyaO7OYYbWXQkurRznnPQgwcX2eKPd9At5RRSoyg9eWLQS7/7opo6JWgn8OGY2WVBuIfOdJgEEaS6PxZt8/taJ4veyKItDGyPmkYCxYZELyuuC89128UOvbaCBr7Kzmu0Sa8fITObxdCHLsKcn5vHwnR7rRER4XghBT+oZYPGiU0w8bQ9wyGs6G5698Sxn/imJp7cNj5KTefJ9vW0aMU+FH0IavLHw5P9w6ymc74l04Ejj+lSa05z5NWb77KoFvYgdCqeNMHeeE7Or7V8iLCEl0G5jS7Op/zGNHBVcCpPTi8KK5bhLbSZRXrXXWzFDs1p2VzFXdPK4AqtT2sB1TGCtilVEesDu2+BJoG+KSQpduwWO203NCXWCpwHETC3GlJsFjTpPuR+6dntAgpkoRBGIUSEVYXUjRK24hMm9pH90nTd8sjQqVM/5Xqt2+ifLaLcUdp6Y/v2zE76R4bWgLANaLDL86j6qJtInkinwpqP/iukU/453mKtPL0Su7OjKNtMQodpyZ8TJ7FaEjzJ3XEOhTBbNFR26nX+L2UrkvkCFh9Ti+Tfp0w+ycXE1GX4OST/V5+kxMVoHODv0Xt7PH4BE2iQ6AAQAAA=" | gunzip +}