From 87265403c591e393dca909ebe5152b617269bd0d Mon Sep 17 00:00:00 2001 From: Mohamadhosein Moazennia Date: Wed, 18 Feb 2026 20:11:36 +0330 Subject: [PATCH] chore: add dev tooling (air config and justfile) --- .air.toml | 35 ++++++++++++++++++++++++++++++++++ justfile | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 .air.toml create mode 100644 justfile diff --git a/.air.toml b/.air.toml new file mode 100644 index 00000000..4f47689a --- /dev/null +++ b/.air.toml @@ -0,0 +1,35 @@ +root = "." +tmp_dir = "tmp/bin" + +[build] +cmd = "go build -o ./tmp/bin/3x-ui-dev ." +entrypoint = "./tmp/bin/3x-ui-dev" +full_bin = "XUI_DB_FOLDER=$PWD/tmp/db XUI_LOG_FOLDER=$PWD/tmp/logs XUI_DEBUG=true ./tmp/bin/3x-ui-dev run" +include_ext = ["go", "html", "toml", "js", "css"] +exclude_dir = ["tmp", ".git", ".vscode", "node_modules", "output", ".playwright-cli"] +exclude_file = [] +delay = 1000 +stop_on_error = true +send_interrupt = true +kill_delay = 500 + +[log] +time = true + +[misc] +clean_on_exit = false + +[screen] +clear_on_rebuild = false +keep_scroll = true + +[proxy] +enabled = false +proxy_port = 0 +app_port = 0 + +[pre_cmd] +commands = [ + "mkdir -p tmp/db tmp/logs tmp/bin", + "[ -f tmp/db/x-ui.db ] || XUI_DB_FOLDER=$PWD/tmp/db XUI_LOG_FOLDER=$PWD/tmp/logs XUI_DEBUG=true go run . setting -port 2099 -username admin -password admin" +] diff --git a/justfile b/justfile new file mode 100644 index 00000000..a88f2d6a --- /dev/null +++ b/justfile @@ -0,0 +1,56 @@ +set shell := ["bash", "-cu"] + +port := "2099" +user := "admin" +pass := "admin" +db_dir := "tmp/db" +log_dir := "tmp/logs" +bin_dir := "tmp/bin" +app_bin := "tmp/bin/3x-ui-dev" +cookie := "tmp/cookies/dev.cookie" + +# Show available commands +help: + just --list + +# Create local temp folders used by dev commands +ensure-tmp: + mkdir -p {{db_dir}} {{log_dir}} {{bin_dir}} tmp/cookies + +# Initialize local DB and default dev credentials/port (safe to re-run) +init-dev: ensure-tmp + XUI_DB_FOLDER="$PWD/{{db_dir}}" XUI_LOG_FOLDER="$PWD/{{log_dir}}" XUI_DEBUG=true \ + go run . setting -port {{port}} -username {{user}} -password {{pass}} + +# Build local dev binary +build: ensure-tmp + GOPROXY=direct go build -o {{app_bin}} . + +# Run app in dev mode (tmp DB/logs) +run: ensure-tmp + XUI_DB_FOLDER="$PWD/{{db_dir}}" XUI_LOG_FOLDER="$PWD/{{log_dir}}" XUI_DEBUG=true \ + go run . run + +# Run with live reload using Air (reads .air.toml) +air: ensure-tmp + air -c .air.toml + +# Quick compile check for all packages +check: + GOPROXY=direct go build ./... + +# Login to local dev panel and save cookie for API testing +api-login: ensure-tmp + curl -s -c {{cookie}} -d 'username={{user}}&password={{pass}}' "http://127.0.0.1:{{port}}/login" + +# Example: fetch client-center inbounds via API +api-clients-inbounds: api-login + curl -s -b {{cookie}} "http://127.0.0.1:{{port}}/panel/api/clients/inbounds" + +# Example: fetch client-center master clients via API +api-clients-list: api-login + curl -s -b {{cookie}} "http://127.0.0.1:{{port}}/panel/api/clients/list" + +# Remove local temp artifacts +clean-tmp: + rm -rf tmp