Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: retire outdate scripts

Steven20b8a97a883e
diff --git a/scripts/build.ps1 b/scripts/build.ps1
deleted file mode 100644
index 052b5c52e..000000000
--- a/scripts/build.ps1
+++ /dev/null
@@ -1,139 +0,0 @@
-# This script builds memos for all listed platforms.
-# It's only for local builds.
-
-# Before using, setup a proper development environment as described here:
-# * https://usememos.com/docs/contribution/development
-# * https://github.com/usememos/memos/blob/main/docs/development.md
-
-# Requirements:
-# * go
-# * node.js
-# * npm
-
-# Usage:
-# ./scripts/build.ps1
-#
-# Output: ./build/memos-<os>-<arch>[.exe]
-
-$goBuilds = @(
- # "darwin/amd64"
- # "darwin/arm64"
- # "linux/amd64"
- # "linux/arm64"
- "windows/amd64"
-)
-$ldFlags = @(
- "-s" # Omit symbol table and debug information
- "-w" # Omit DWARF symbol table
-)
-
-##
-
-foreach ($dir in @(".", "../")) {
- if (Test-Path (Join-Path $dir ".gitignore")) {
- $repoRoot = (Resolve-Path $dir).Path
- break
- }
-}
-if ([string]::IsNullOrWhiteSpace($repoRoot)) {
- Write-Host -BackgroundColor red -ForegroundColor white "Could not find repository root."
- Exit 1
-}
-
-Write-Host "Repository root: " -NoNewline
-Write-Host $repoRoot -f Blue
-
-Push-Location
-Set-Location "$repoRoot/web"
-
-if (-not (Get-Command pnpm -ErrorAction SilentlyContinue)) {
- Write-Host "Installing pnpm..." -f DarkYellow
- npm install -g pnpm
- if (!$?) {
- Write-Host -BackgroundColor red -ForegroundColor white "Could not install pnpm. See above."
- Pop-Location
- Exit 1
- }
-}
-
-Write-Host "`nInstalling frontend dependencies..." -f DarkYellow
-pnpm i --frozen-lockfile
-if (!$?) {
- Write-Host -BackgroundColor red -ForegroundColor white "Could not install frontend dependencies. See above."
- Pop-Location
- Exit 1
-}
-Write-Host "Frontend dependencies installed!" -f green
-
-Write-Host "`nRemoving previous frontend build from ./build/dist ..." -f Magenta
-Remove-Item "$repoRoot/build/dist" -Recurse -Force -ErrorAction SilentlyContinue
-if (!$?) {
- Write-Host -BackgroundColor red -ForegroundColor white "Could not remove frontend from ./build/dist. See above."
- Pop-Location
- Exit 1
-}
-
-Write-Host "`nBuilding frontend..." -f DarkYellow
-$frontendTime = Measure-Command {
- &pnpm build | Out-Host
-}
-if (!$?) {
- Write-Host -BackgroundColor red -ForegroundColor white "Could not build frontend. See above."
- Pop-Location
- Exit 1
-}
-else {
- Write-Host "Frontend built!" -f green
-}
-
-Write-Host "Moving frontend build to ./build/dist..." -f Magenta
-Move-Item "$repoRoot/web/dist" "$repoRoot/build/" -Force -ErrorAction Stop
-if (!$?) {
- Write-Host -BackgroundColor red -ForegroundColor white "Could not move frontend build to ./build/dist. See above."
- Pop-Location
- Exit 1
-}
-
-Set-Location $repoRoot
-Write-Host "`nBuilding backend..." -f DarkYellow
-
-$backendTime = Measure-Command {
- foreach ($build in $goBuilds) {
- $os, $arch = $build.Split("/")
- $Env:CGO_ENABLED = 0
- $Env:GOOS = $os
- $Env:GOARCH = $arch
-
- $output = [IO.Path]::Combine($repoRoot, "build", "memos-$os-$arch")
- if ($os -eq "windows") {
- $output += ".exe"
- }
-
- Write-Host "Building $os/$arch to $output..." -f Blue
- &go build -trimpath -o $output -ldflags="$($ldFlags -join " ")" ./bin/memos/main.go | Out-Host
- if (!$?) {
- Write-Host -BackgroundColor red -ForegroundColor white "'go build' failed for $build ($outputBinary)!. See above."
- continue
- }
- }
-}
-Write-Host "Backend built!" -f green
-
-Write-Host "`nFrontend build took $($frontendTime.TotalSeconds) seconds." -f Cyan
-Write-Host "Backend builds took $($backendTime.TotalSeconds) seconds." -f Cyan
-
-Write-Host "`nBuilds:" -f White
-foreach ($build in $goBuilds) {
- $output = [IO.Path]::Combine($repoRoot, "build", "memos-$os-$arch")
- if ($os -eq "windows") {
- $output = "$output.exe"
- }
- Write-Host $output -f White
-}
-
-Write-Host -f Green "`nYou can test the build with" -NoNewline
-Write-Host -f White "` ./build/memos-<os>-<arch>" -NoNewline
-Write-Host -f DarkGray "`.exe" -NoNewline
-Write-Host -f White " --mode demo"
-
-Set-Location -Path $repoRoot
diff --git a/scripts/build.sh b/scripts/build.sh
deleted file mode 100755
index f03089464..000000000
--- a/scripts/build.sh
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/bin/bash
-# This script builds memos for all listed platforms.
-# It's only for local builds.
-
-# Before using, setup a proper development environment as described here:
-# * https://usememos.com/docs/contribution/development
-# * https://github.com/usememos/memos/blob/main/docs/development.md
-
-# Requirements:
-# * go
-# * node.js
-# * npm
-
-# Usage:
-# chmod +x ./scripts/build.sh
-# ./scripts/build.sh
-#
-# Output: ./build/memos-<os>-<arch>[.exe]
-
-goBuilds=(
- # "darwin/amd64"
- # "darwin/arm64"
- "linux/amd64"
- # "linux/arm64"
- # "windows/amd64"
-)
-ldFlags=(
- "-s" # Omit symbol table and debug information
- "-w" # Omit DWARF symbol table
-)
-
-##
-
-find_repo_root() {
- # Usage: find_repo_root <file_at_root> <dir1> <dir2> ...
- local looking_for="${1:-".gitignore"}"
- shift
- local default_dirs=("." "../")
- local dirs=("${@:-${default_dirs[@]}}")
- for dir in "${dirs[@]}"; do
- if [ -f "$dir/$looking_for" ]; then
- echo $(realpath "$dir")
- return
- fi
- done
-}
-
-repo_root=$(find_repo_root)
-if [ -z "$repo_root" ]; then
- echo -e "\033[0;31mRepository root not found! Exiting.\033[0m"
- exit 1
-else
- echo -e "Repository root: \033[0;34m$repo_root\033[0m"
-fi
-
-pushd $repo_root
-cd "$repo_root/web"
-
-if ! command -v pnpm &>/dev/null; then
- echo -e "\n\033[35mInstalling pnpm...\033[0m"
- npm install -g pnpm
- if [ $? -ne 0 ]; then
- echo -e "\033[0;31mFailed to install pnpm! Exiting.\033[0m"
- popd
- exit 1
- fi
-fi
-
-echo -e "\n\033[33mInstalling frontend dependencies...\033[0m"
-pnpm i --frozen-lockfile
-if [ $? -ne 0 ]; then
- echo -e "\033[0;31mFrontend dependencies failed to install! Exiting.\033[0m"
- popd
- exit 1
-fi
-echo -e "\033[32mFrontend dependencies installed!\033[0m"
-
-echo -e "\n\033[35mRemoving previous frontend build from ./build/dist...\033[0m"
-rm -rf $repo_root/build/dist
-if [ $? -ne 0 ]; then
- echo -e "\033[93mCould not remove frontend from ./build/dist.\033[0m"
- popd
- exit 1
-fi
-
-echo -e "\n\033[33mBuilding frontend...\033[0m"
-pnpm build
-if [ $? -ne 0 ]; then
- echo -e "\033[0;31mFrontend build failed! Exiting.\033[0m"
- popd
- exit 1
-fi
-echo -e "\033[32mFrontend built!\033[0m"
-
-cd $repo_root
-
-echo -e "\033[35mMoving frontend build to ./build/dist...\033[0m"
-mv -f "$repo_root/web/dist" "$repo_root/build/"
-if [ $? -ne 0 ]; then
- echo -e "\033[0;31mFailed to move frontend build! Exiting.\033[0m"
- popd
- exit 1
-fi
-
-cd "$repo_root"
-echo -e "\n\033[33mBuilding backend...\033[0m"
-
-for build in "${goBuilds[@]}"; do
- os=$(echo $build | cut -d'/' -f1)
- arch=$(echo $build | cut -d'/' -f2)
-
- output="$repo_root/build/memos-$os-$arch"
- if [ "$os" = "windows" ]; then
- output="$output.exe"
- fi
-
- CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -trimpath -ldflags="${ldFlags[*]}" -o "$output" ./bin/memos/main.go
-
- echo -e "\033[34mBuilding $os/$arch to $output...\033[0m"
- GOOS=$os GOARCH=$arch go build -ldflags="${ldFlags[*]}" -o "./build/memos-$os-$arch" ./bin/memos/main.go
- if [ $? -ne 0 ]; then
- echo -e "\033[0;31mgo build failed for $os/$arch($output)! See above.\033[0m"
- fi
-done
-
-echo -e "\033[32mBackend built!\033[0m"
-
-echo -e "\n\033[37mBuilds:\033[0m"
-for build in "${goBuilds[@]}"; do
- os=$(echo $build | cut -d'/' -f1)
- arch=$(echo $build | cut -d'/' -f2)
- output="$repo_root/build/memos-$os-$arch"
- if [ "$os" = "windows" ]; then
- output="$output.exe"
- fi
- echo -e "\033[37m$output\033[0m"
-done
-echo -e "\n\033[32mYou can test the build with \033[37m./build/memos-<os>-<arch>\033[0m\033[90m.exe\033[0m \033[37m--mode demo\033[0m"
-
-cd $repo_root
diff --git a/scripts/docker-compose.dev.yaml b/scripts/docker-compose.dev.yaml
deleted file mode 100644
index 05abbf9cc..000000000
--- a/scripts/docker-compose.dev.yaml
+++ /dev/null
@@ -1,340 +0,0 @@
-# > Memos development environment <
-#
-# Available profiles: sqlite, mysql, postgres.
-# Use `docker compose --profile PROFILE_NAME up` to launch only services within the profile.
-#
-# Services in the `tools` profile are used for running one-off tasks like linting, generating code, etc.
-#
-# Services started in all database profiles:
-# Front-end: http://localhost:3001
-# API: http://localhost:8081
-# Adminer: http://localhost:8091
-#
-# On Windows, run this before using docker-compose on a new terminal:
-# $Env:HOME=$Env:USERPROFILE
-#
-# > Start Memos in development mode:
-# docker compose -f ./scripts/docker-compose.dev.yaml --profile [sqlite|mysql|postgres] up --detach
-#
-# > Stop all services:
-# docker compose -f ./scripts/docker-compose.dev.yaml --profile sqlite --profile postgres --profile mysql down
-#
-# > Remove related volumes: (all other files are mapped to ./air/docker/ directory)
-# docker volume rm memos-dev_pnpm-store memos-dev_node-modules
-#
-# One-off tasks:
-# > pnpm:
-# docker compose -f ./scripts/docker-compose.dev.yaml run --rm pnpm [add|remove|update] [PACKAGE_NAME] [--save-dev]
-#
-# > buf: (run this after modifying .proto files)
-# docker compose -f ./scripts/docker-compose.dev.yaml run --rm buf generate
-#
-# > go:
-# docker compose -f ./scripts/docker-compose.dev.yaml run --rm go mod tidy -go=1.22
-#
-# > golangci-lint: (run this before submitting Pull Requests affecting Go code)
-# docker compose -f ./scripts/docker-compose.dev.yaml run --rm golangci-lint run
-#
-# > goimports: (run this if golangci-lint shows "File is not `goimports`-ed"
-# docker compose -f ./scripts/docker-compose.dev.yaml run --rm goimports -local https://github.com/usememos/memos -w [FILE|.]
-#
-version: "3.0"
-name: memos-dev
-volumes:
- # pnpm uses hard links and node_modules uses symlinks.
- # Using volumes make things work properly on any host OS.
- node-modules:
- pnpm-store:
-services:
- web:
- profiles: ["sqlite", "mysql", "postgres"]
- image: node:20-alpine
- ports: [3001:3001]
- environment:
- DEV_PROXY_SERVER: http://api:8081/
- NPM_CONFIG_UPDATE_NOTIFIER: false
- working_dir: &web-working-dir /work/web
- entrypoint: ["/bin/sh", "-c"]
- command: ["corepack enable && pnpm i --frozen-lockfile && pnpm dev"]
- tmpfs: &web-tmpfs /work/node_modules/:exec # avoid ERR_PNPM_LINKING_FAILED
- volumes: &web-volumes
- - node-modules:/work/web/node_modules
- - pnpm-store:/work/web/.pnpm-store
- - ../proto:/work/proto
- - ../web:/work/web
- - ../web/node_modules:/work/web/node_modules
- healthcheck:
- test: ["CMD", "wget", "-qO", "-", "http://localhost:3001"]
- interval: 10s
- timeout: 5s
-
- api:
- profiles: ["sqlite"]
- image: &api-image golang:1.22-alpine
- ports: &api-ports [8081:8081]
- environment:
- MEMOS_DRIVER: sqlite
- MEMOS_DATA: /var/opt/memos
- working_dir: &api-working-dir /work
- volumes: &api-volumes
- - $HOME/go/pkg/:/go/pkg/ # Share go mod cache with host
- - ../.air/docker/go-build:/root/.cache/go-build
- - ../.air/docker/go/bin:/go/bin
- - ../.air/docker/memosdata:/var/opt/memos
- - ..:/work/
- configs: &api-configs
- - source: air-entrypoint.sh
- target: /usr/local/bin/entrypoint.sh
- entrypoint: &api-entrypoint ["/bin/sh", "/usr/local/bin/entrypoint.sh"]
- command: &api-command ["-c", "./scripts/.air.toml"]
- healthcheck: &api-healthcheck
- test: ["CMD", "wget", "-qO", "-", "http://localhost:8081/api/v1/ping"]
- interval: 10s
- timeout: 5s
-
- api-mysql:
- profiles: ["mysql"]
- depends_on: { mysql: { condition: service_healthy } }
- hostname: api
- environment:
- { MEMOS_DRIVER: mysql, MEMOS_DSN: memos:memos@tcp(mysql)/memos }
- image: *api-image
- ports: *api-ports
- working_dir: *api-working-dir
- volumes: *api-volumes
- configs: *api-configs
- entrypoint: *api-entrypoint
- command: *api-command
- healthcheck: *api-healthcheck
-
- api-postgres:
- profiles: ["postgres"]
- depends_on: { postgres: { condition: service_healthy } }
- hostname: api
- environment:
- MEMOS_DSN: "postgresql://memos:memos@postgres:5432/memos?sslmode=disable"
- MEMOS_DRIVER: postgres
- image: *api-image
- ports: *api-ports
- working_dir: *api-working-dir
- volumes: *api-volumes
- configs: *api-configs
- entrypoint: *api-entrypoint
- command: *api-command
- healthcheck: *api-healthcheck
-
- mysql:
- profiles: ["mysql"]
- image: mysql
- environment:
- MYSQL_USER: memos
- MYSQL_PASSWORD: memos
- MYSQL_DATABASE: memos
- MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
- volumes: [../.air/docker/mysql:/var/lib/mysql]
- healthcheck:
- test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
- interval: 10s
- timeout: 5s
-
- postgres:
- profiles: ["postgres"]
- image: postgres:alpine
- hostname: postgres
- volumes: [../.air/docker/postgres:/var/lib/postgresql/data]
- environment:
- { POSTGRES_DB: memos, POSTGRES_USER: memos, POSTGRES_PASSWORD: memos }
- healthcheck:
- test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
- interval: 10s
- timeout: 5s
-
- pnpm:
- profiles: ["tools"]
- image: node:20-alpine
- environment: { NPM_CONFIG_UPDATE_NOTIFIER: false }
- working_dir: *web-working-dir
- volumes: *web-volumes
- tmpfs: *web-tmpfs
- configs:
- - source: pnpm-entrypoint.sh
- target: /usr/local/bin/entrypoint.sh
- entrypoint: ["sh", "/usr/local/bin/entrypoint.sh"]
-
- buf:
- profiles: ["tools"]
- image: bufbuild/buf
- working_dir: /work/proto
- command: generate
- volumes:
- - ../proto:/work/proto
- - ../web/src/types/:/work/web/src/types/
-
- go:
- profiles: ["tools"]
- image: *api-image
- working_dir: *api-working-dir
- volumes: *api-volumes
- entrypoint: ["go"]
-
- goimports:
- profiles: ["tools"]
- image: *api-image
- working_dir: *api-working-dir
- volumes: *api-volumes
- configs:
- - source: goimports-entrypoint.sh
- target: /usr/local/bin/entrypoint.sh
- entrypoint: ["/bin/sh", "/usr/local/bin/entrypoint.sh"]
-
- golangci-lint:
- profiles: ["tools"]
- image: *api-image
- working_dir: *api-working-dir
- volumes: *api-volumes
- configs:
- - source: golangci-lint-entrypoint.sh
- target: /usr/local/bin/entrypoint.sh
- entrypoint: ["/bin/sh", "/usr/local/bin/entrypoint.sh"]
-
- adminer-mysql:
- profiles: ["mysql"]
- depends_on: { mysql: { condition: service_healthy } }
- image: adminer
- environment: &adminer-environment
- ADMINER_DEFAULT_DRIVER: server # "server" is mysql
- ADMINER_DEFAULT_SERVER: mysql
- ADMINER_DEFAULT_USERNAME: memos
- ADMINER_DEFAULT_PASSWORD: memos
- ADMINER_DEFAULT_DB: memos
- ADMINER_DESIGN: dracula # light: pepa-linha | https://www.adminer.org/#extras
- ADMINER_PLUGINS: tables-filter table-structure edit-textarea dump-json # https://www.adminer.org/en/plugins/
- ports: &adminer-ports [127.0.0.1:8091:8080]
- healthcheck: &adminer-healthcheck
- test: 'php -r "exit(strpos(file_get_contents(\"http://localhost:8080/\"), \"Adminer\") !== false ? 0 : 1);"'
- interval: 10s
- timeout: 5s
- configs: &adminer-configs
- - source: adminer-index.php
- target: /var/www/html/index.php
-
- adminer-postgres:
- profiles: ["postgres"]
- depends_on: { postgres: { condition: service_healthy } }
- image: adminer
- ports: *adminer-ports
- healthcheck: *adminer-healthcheck
- configs: *adminer-configs
- environment:
- <<: *adminer-environment
- ADMINER_DEFAULT_DRIVER: pgsql
- ADMINER_DEFAULT_SERVER: postgres
-
- adminer-sqlite:
- profiles: ["sqlite"]
- image: adminer
- ports: *adminer-ports
- healthcheck: *adminer-healthcheck
- configs: *adminer-configs
- environment:
- <<: *adminer-environment
- ADMINER_DEFAULT_PASSWORD: ""
- ADMINER_DEFAULT_DRIVER: sqlite
- ADMINER_DEFAULT_DB: /data/memos_dev.db
- volumes: [../.air/docker/memosdata:/data]
-
-configs:
- # Patched version of adminer index.php to fill the login form with default values
- # and allow passwordless login whenever ADMINER_DEFAULT_DRIVER is sqlite.
- adminer-index.php:
- content: |
- <?php
- namespace docker {
- function adminer_object() {
- require_once('plugins/plugin.php');
- class Adminer extends \AdminerPlugin {
- function _callParent($$function, $$args) {
- if ($$function === 'loginForm') {
- ob_start();
- $$return = \Adminer::loginForm();
- $$form = ob_get_clean();
- $$driver = $$_ENV["ADMINER_DEFAULT_DRIVER"] ?: "server";
- $$server = $$_ENV["ADMINER_DEFAULT_SERVER"] ?: "db";
- $$username = $$_ENV["ADMINER_DEFAULT_USERNAME"];
- $$password = $$_ENV["ADMINER_DEFAULT_PASSWORD"];
- $$db = $$_ENV["ADMINER_DEFAULT_DB"];
- $$form = preg_replace('/ name="auth\[server\]" value="(.*)"/', ' name="auth[server]" value="' . $$server . '"', $$form);
- $$form = str_replace(' id="username" value="" ', ' id="username" value="' . $$username . '" ', $$form);
- $$form = str_replace('name="auth[db]" value=""', 'name="auth[db]" value="' . $$db . '" ', $$form);
- $$form = str_replace('type="password"', 'type="password" value="' . $$password . '"', $$form);
- $$form = preg_replace('/<option value="(.*)" selected/', '/<option value="$$1"/', $$form);
- $$form = preg_replace('/<option value="' . $$driver . '"/', '<option value="' . $$driver . '" selected', $$form);
- echo $$form;
- return $$return;
- }
- return parent::_callParent($$function, $$args);
- }
- }
- $$plugins = [];
- foreach (glob('plugins-enabled/*.php') as $$plugin) {
- $$plugins[] = require($$plugin);
- }
- class AdminerSoftware extends Adminer {
- function login($$login, $$password) {
- return substr($$_ENV["ADMINER_DEFAULT_DRIVER"], 0, 6) == 'sqlite' ? true : parent::login($$login, $$password);
- }
- }
- return new AdminerSoftware($$plugins);
- }
- }
- namespace {
- if (basename($$_SERVER['DOCUMENT_URI'] ?? $$_SERVER['REQUEST_URI']) === 'adminer.css' && is_readable('adminer.css')) {
- header('Content-Type: text/css');
- readfile('adminer.css');
- exit;
- }
- function adminer_object() {
- return \docker\adminer_object();
- }
- require('adminer.php');
- }
- # Patched version of node's container entrypoint to run commands with pnpm by default.
- pnpm-entrypoint.sh:
- content: |
- set -eu
- corepack enable pnpm
- pnpm "$$@"
- # Entrypoint for air container. Installs air and run passed commands.
- air-entrypoint.sh:
- content: |
- set -eu
- if [ -z $$(command -v "air") ]; then
- echo "Installing air..."
- wget -O- -nv https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b \
- $$(go env GOPATH)/bin v1.49.0
- fi
- cd /work
- /go/bin/air "$$@"
- # Entrypoint for goimports container.
- goimports-entrypoint.sh:
- content: |
- set -eu
- if [ -z $$(command -v "goimports") ]; then
- echo "Installing goimports..."
- go install golang.org/x/tools/cmd/goimports@latest
- fi
- cd /work
- echo "Running goimports..."
- goimports "$$@"
- # Entrypoint for golangci-lint container.
- golangci-lint-entrypoint.sh:
- content: |
- set -eu
- if [ -z $$(command -v "golangci-lint") ]; then
- echo "Installing golangci-lint..."
- wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b \
- $$(go env GOPATH)/bin v1.55.2
- fi
- cd /work
- golangci-lint --version
- golangci-lint "$$@"
diff --git a/scripts/start.ps1 b/scripts/start.ps1
deleted file mode 100644
index 6b73c8ec3..000000000
--- a/scripts/start.ps1
+++ /dev/null
@@ -1,163 +0,0 @@
-# This script starts the backend and frontend in development mode, with live reload.
-# It also installs frontend dependencies.
-
-# For more details on setting-up a development environment, check the docs:
-# * https://usememos.com/docs/contribution/development
-# * https://github.com/usememos/memos/blob/main/docs/development.md
-
-# Usage: ./scripts/start.ps1
-
-foreach ($dir in @(".", "../")) {
- if (Test-Path (Join-Path $dir ".gitignore")) {
- $repoRoot = (Resolve-Path $dir).Path
- break
- }
-}
-
-##
-$frontendPort = 3001
-# Tasks to run, in order
-$runTasks = @(
- @{
- Desc = "install frontend dependencies";
- Exe = "powershell.exe";
- Args = (
- "-Command",
- "pnpm i"
- );
- Dir = "$repoRoot/web"
- Wait = $true;
- },
- @{
- Desc = "start backend with live reload";
- Exe = "air.exe";
- Args = (
- "-c",
- ".\scripts\.air-windows.toml"
- );
- Dir = "$repoRoot";
- Wait = $false;
- },
- @{
- Desc = "start frontend with live reload";
- Exe = "powershell.exe";
- Args = (
- "-Command",
- "pnpm dev"
- );
- Dir = "$repoRoot/web";
- Wait = $false;
- }
-)
-##
-
-if (!$repoRoot) {
- Write-Host "Could not find repository root!" -f Red
- Write-Host "cd into the repository root and run the script again."
- Exit 1
-}
-
-Write-Host "Repository root is $repoRoot"
-Write-Host "Starting development environment...`n"
-Write-Host @"
-███╗ ███╗███████╗███╗ ███╗ ██████╗ ███████╗
-████╗ ████║██╔════╝████╗ ████║██╔═══██╗██╔════╝
-██╔████╔██║█████╗ ██╔████╔██║██║ ██║███████╗
-██║╚██╔╝██║██╔══╝ ██║╚██╔╝██║██║ ██║╚════██║
-██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║╚██████╔╝███████║
-╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝
-"@
-
-function Stop-ProcessTree {
- Param([int]$ParentProcessId)
- if (!$ParentProcessId) {
- Write-Host "Stop-ProcessTree: unspecified ParentProcessId!" -f Red
- return
- }
- Write-Host "Terminating pid $($ParentProcessId) with all its child processes" -f DarkGray
- Get-CimInstance Win32_Process | Where-Object {
- $_.ParentProcessId -eq $ParentProcessId
- } | ForEach-Object {
- Stop-ProcessTree $_.ProcessId
- }
- Stop-Process -Id $ParentProcessId -ErrorAction SilentlyContinue
-}
-
-$maxDescLength = ( $runTasks | ForEach-Object { $_.Desc.Length } | Measure-Object -Maximum).Maximum
-$spawnedPids = @()
-foreach ($task in $runTasks) {
- Write-Host ("Running task ""$($task.Desc)""...").PadRight($maxDescLength + 20) -f Blue -NoNewline
- $task.Dir = (Resolve-Path $task.Dir).Path
- try {
- $process = Start-Process -PassThru -WorkingDirectory $task.Dir -FilePath $task.Exe -ArgumentList $task.Args -Wait:$task.Wait
-
- if ($process.ExitCode -and $process.ExitCode -ne 0) {
- # ExitCode only works for processes started with -Wait:$true
- throw "Process exited with code $($process.ExitCode)"
- }
-
- Write-Host "[OK]" -f Green
- $spawnedPids += $process.Id
- }
- catch {
- Write-Host "[FAILED]" -f Red
- Write-Host "Error: $_" -f Red
- Write-Host "Unable to execute: $($task.Exe) $($task.Args)" -f Red
- Write-Host "Process working directory: $($task.Dir)" -f Red
-
- foreach ($spawnedPid in $spawnedPids) {
- Stop-ProcessTree -ParentProcessId $spawnedPid
- }
- Exit $process.ExitCode
- }
-}
-
-Write-Host "Front-end should be accessible at:" -f Green
-$ipAddresses = (Get-NetIPAddress -AddressFamily IPv4) | Select-Object -ExpandProperty IPAddress | Sort-Object
-$ipAddresses += "localhost"
-foreach ($ip in $ipAddresses) {
- Write-Host "· http://$($ip):$($frontendPort)" -f Cyan
-}
-
-Write-Host "`nPress" -NoNewline
-Write-Host " Ctrl + C" -f DarkYellow -NoNewline
-Write-Host " or" -NoNewline
-Write-Host " Esc" -f DarkYellow -NoNewline
-Write-Host " to terminate running servers." -f DarkYellow
-[Console]::TreatControlCAsInput = $true
-
-$lastPoll = 0
-$noWaitTasks = $runTasks | Where-Object { $_.Wait -eq $false }
-while ($true) {
- if ([Console]::KeyAvailable) {
- $readkey = [Console]::ReadKey("AllowCtrlC,IncludeKeyUp,NoEcho")
- if ($readkey.Modifiers -eq "Control" -and $readkey.Key -eq "C") {
- break
- }
- if ($readkey.Key -eq "Escape") {
- Break
- }
- }
-
- # Poll for processes that exited unexpectedly
- # Do this every 5 seconds to avoid excessive CPU usage
- if (([DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() - $lastPoll) -ge 5000) {
- $noWaitTasks | ForEach-Object {
- $name = $_.Exe.TrimEnd(".exe")
- if (!(Get-Process -Name $name -ErrorAction SilentlyContinue)) {
- Write-Host "Process " -f Red -NoNewline
- Write-Host $name -NoNewline -f DarkYellow
- Write-Host " is not running anymore!" -f Red
- break
- }
- }
- $lastPoll = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
- }
- Start-Sleep -Milliseconds 500
-}
-
-foreach ($spawnedPid in $spawnedPids) {
- Stop-ProcessTree -ParentProcessId $spawnedPid
-}
-
-Write-Host "Exiting..."
diff --git a/scripts/start.sh b/scripts/start.sh
deleted file mode 100755
index dc154b92b..000000000
--- a/scripts/start.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-
-# Usage: ./scripts/start.sh
-
-set -e
-
-cd "$(dirname "$0")/../"
-
-air -c ./scripts/.air.toml