Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tareqimbasher committed Oct 2, 2024
1 parent 68b55ce commit 6790048
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 10 deletions.
40 changes: 40 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

if ! command -v npm &> /dev/null
then
echo "npm could not be found. Executing 'nvm use 18'"
nvm use 18
fi

unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) platform=Linux;;
Darwin*) platform=Mac;;
*) platform="${unameOut}"
esac

echo "Detected platform: ${platform}"

if [ "${platform}" == "Linux" ]; then
echo "Building Tauri app for Linux..."
npx tauri build -c src-tauri/tauri.conf.linux-x64.json5 --target x86_64-unknown-linux-gnu
elif [ "${platform}" == "Mac" ]; then
echo "Building Tauri app for Mac..."
npx tauri build -c src-tauri/tauri.conf.macos.json5 --target aarch64-apple-darwin
fi


# CHANGE Port

# Windows:
# npx tauri build -c src-tauri/tauri.conf.win-x64.json5 --target x86_64-pc-windows-msvc

# Linux:
# npx tauri build -c src-tauri/tauri.conf.linux-x64.json5 --target x86_64-unknown-linux-gnu
# Had to zip a standalone: zip -r "standalone.zip" "netpad-vnext" "resources"

# macOS x64:
# npx tauri build -c src-tauri/tauri.conf.mac-x64.json5 --target x86_64-apple-darwin

# macOS arm64:
# npx tauri build -c src-tauri/tauri.conf.mac-arm64.json5 --target aarch64-apple-darwin
20 changes: 10 additions & 10 deletions scripts/package-electron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ fi
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
APP_DIR=$(cd "$SCRIPT_DIR/../src/Apps/NetPad.Apps.App" && pwd)
PACKAGES_SOURCE_DIR="$APP_DIR/bin/Desktop"
PACKAGES_DEST_DIR="$SCRIPT_DIR/../dist"

printf "%b" "${GREEN}# SCRIPT_DIR: $SCRIPT_DIR${ENDCOLOR}\n"
printf "%b" "${GREEN}# APP_DIR: $APP_DIR${ENDCOLOR}\n"
printf "%b" "${GREEN}# PACKAGES_SOURCE_DIR: $PACKAGES_SOURCE_DIR${ENDCOLOR}\n"
printf "%b" "${GREEN}# PACKAGES_DEST_DIR: $PACKAGES_DEST_DIR${ENDCOLOR}\n"
PACKAGES_DEST_DIR="$SCRIPT_DIR/../dist/electron"

if [ -z "$SCRIPT_DIR" ]; then
echo "Could not determine script dir"
Expand All @@ -87,6 +82,11 @@ if [ -z "$PACKAGES_DEST_DIR" ]; then
exit 1
fi

printf "%b" "${GREEN}# SCRIPT_DIR: $SCRIPT_DIR${ENDCOLOR}\n"
printf "%b" "${GREEN}# APP_DIR: $APP_DIR${ENDCOLOR}\n"
printf "%b" "${GREEN}# PACKAGES_SOURCE_DIR: $PACKAGES_SOURCE_DIR${ENDCOLOR}\n"
printf "%b" "${GREEN}# PACKAGES_DEST_DIR: $PACKAGES_DEST_DIR${ENDCOLOR}\n"

# Create the DEST directory
if [[ "$clean" == "true" ]]; then
rm -rf "$PACKAGES_DEST_DIR"
Expand Down Expand Up @@ -134,7 +134,7 @@ if [[ -z $os ]] || [[ $os == "osx" ]]; then
package osx
fi

if [[ -z $os ]] || [[ $os == "osx-arm" ]]; then
printf "%b" "${GREEN}\n# OSX ARM packages\n${ENDCOLOR}"
package "custom osx-arm64;mac /electron-arch arm64"
fi
#if [[ -z $os ]] || [[ $os == "osx-arm" ]]; then
# printf "%b" "${GREEN}\n# OSX ARM packages\n${ENDCOLOR}"
# package "custom osx-arm64;mac /electron-arch arm64"
#fi
112 changes: 112 additions & 0 deletions scripts/package-tauri-linux-x64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env bash

set -o nounset
set -o errexit

RED="\033[0;31m"
GREEN="\033[0;32m"
LCYAN="\033[1;36m"
NC="\033[0m"

if ! command -v dotnet &> /dev/null; then
echo "Could not find 'dotnet'."
exit 1
fi

if ! command -v npm &> /dev/null; then
echo "Could not find 'npm'."
exit 1
fi

if ! command -v cargo &> /dev/null; then
echo "Could not find 'cargo'."
exit 1
fi

SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
APP_DIR=$(cd "$SCRIPT_DIR/../src/Apps/NetPad.Apps.Shells.Tauri/TauriApp" && pwd)
SPA_APP_DIR=$(cd "$SCRIPT_DIR/../src/Apps/NetPad.Apps.App/App" && pwd)
PACKAGES_SOURCE_DIR="$APP_DIR/src-tauri/target/x86_64-unknown-linux-gnu/release"
PACKAGES_DEST_DIR="$SCRIPT_DIR/../dist/tauri"

if [ -z "$SCRIPT_DIR" ]; then
echo "Could not determine script dir"
exit 1
fi

if [ -z "$APP_DIR" ]; then
echo "Could not determine app dir"
exit 1
fi

if [ -z "$SPA_APP_DIR" ]; then
echo "Could not determine SPA app dir"
exit 1
fi

if [ -z "$PACKAGES_DEST_DIR" ]; then
echo "Could not determine destination package dir"
exit 1
fi

printf "%b" "${GREEN}# SCRIPT_DIR:${NC} $SCRIPT_DIR\n"
printf "%b" "${GREEN}# APP_DIR:${NC} $APP_DIR\n"
printf "%b" "${GREEN}# SPA_APP_DIR:${NC} $SPA_APP_DIR\n"
printf "%b" "${GREEN}# PACKAGES_SOURCE_DIR:${NC} $PACKAGES_DEST_DIR\n"
printf "%b" "${GREEN}# PACKAGES_DEST_DIR:${NC} $PACKAGES_DEST_DIR\n"

# Create the DEST directory
# if [[ "$clean" == "true" ]]; then
# rm -rf "$PACKAGES_DEST_DIR"
# fi

mkdir -p "$PACKAGES_DEST_DIR"

print_section_div() {
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
}

copy() {
local dir="$1"

for filename in "$dir"/*; do
if [[ -d $filename ]]; then
continue
fi

if [[ $filename != *.zip ]] && [[ $filename != *.pacman ]] && [[ $filename != *.AppImage ]] && [[ $filename != *.deb ]] && [[ $filename != *.rpm ]] && [[ $filename != *.flatpak ]] && [[ $filename != *.snap ]]; then
continue
fi

echo " - Copying: $filename"
mv "$filename" "$PACKAGES_DEST_DIR/"
done
}

# Ensure npm packages are installed
printf "\n1. ${LCYAN}Installing npm packages in: $APP_DIR${NC}\n"
npm install --prefix "$APP_DIR"
print_section_div

printf "\n2. ${LCYAN}Installing npm packages in: $SPA_APP_DIR${NC}\n"
npm install --prefix "$SPA_APP_DIR"
print_section_div

cd "$APP_DIR"

printf "\n3. ${LCYAN}Packaging Tauri app${NC}\n"
#npx tauri build -c src-tauri/tauri.conf.linux-x64.json5 --target x86_64-unknown-linux-gnu
print_section_div

printf "\n4. ${LCYAN}Copying generated bundles${NC}\n"
copy "$PACKAGES_SOURCE_DIR/bundle/deb"
copy "$PACKAGES_SOURCE_DIR/bundle/rpm"
print_section_div

printf "\n5. ${LCYAN}Zipping standalone app${NC}\n"
cd "$PACKAGES_SOURCE_DIR"
zip -q -r "$PACKAGES_DEST_DIR/NetPad-vNext-0.8.0-linux-x86_64.zip" "NetPad vNext" "resources"
cd "$APP_DIR"
print_section_div

cd "$SCRIPT_DIR"

0 comments on commit 6790048

Please sign in to comment.