chore: add dev tooling (air config and justfile)

This commit is contained in:
Mohamadhosein Moazennia 2026-02-18 20:11:36 +03:30
parent 37f0880f8f
commit 87265403c5
2 changed files with 91 additions and 0 deletions

35
.air.toml Normal file
View file

@ -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"
]

56
justfile Normal file
View file

@ -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