chore: update version to 0.69.2 and refine CLI help output

- Bumped the version number in the Makefile to 0.69.2.
- Removed deprecated environment commands from the CLI main.go file to streamline user experience.
- Enhanced help output for development and production commands, adding new options and clarifying usage instructions.
- Introduced a `--no-pull` option in production commands to skip repository updates during installation and upgrades, improving flexibility for users.
This commit is contained in:
anonpenguin23 2025-11-11 15:29:23 +02:00
parent ee566d93b7
commit c2298e476e
No known key found for this signature in database
GPG Key ID: 1CBB1FE35AFBEE30
6 changed files with 95 additions and 111 deletions

View File

@ -13,6 +13,21 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
### Deprecated ### Deprecated
### Fixed ### Fixed
## [0.69.2] - 2025-11-11
### Added
- Added `--no-pull` flag to `dbn prod upgrade` to skip git repository updates and use existing source code.
### Changed
- Removed deprecated environment management commands (`env`, `devnet`, `testnet`, `local`).
- Removed deprecated network commands (`health`, `peers`, `status`, `peer-id`, `connect`, `query`, `pubsub`) from the main CLI interface.
### Deprecated
### Removed
### Fixed
\n
## [0.69.1] - 2025-11-11 ## [0.69.1] - 2025-11-11
### Added ### Added

View File

@ -19,7 +19,7 @@ test-e2e:
.PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill .PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill
VERSION := 0.69.1 VERSION := 0.69.2
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)' LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'

View File

@ -44,26 +44,6 @@ func main() {
fmt.Println() fmt.Println()
return return
// Environment commands
case "env":
cli.HandleEnvCommand(args)
case "devnet", "testnet", "local":
// Shorthand for switching environments
if len(args) > 0 && (args[0] == "enable" || args[0] == "switch") {
if err := cli.SwitchEnvironment(command); err != nil {
fmt.Fprintf(os.Stderr, "❌ Failed to switch environment: %v\n", err)
os.Exit(1)
}
env, _ := cli.GetActiveEnvironment()
fmt.Printf("✅ Switched to %s environment\n", command)
if env != nil {
fmt.Printf(" Gateway URL: %s\n", env.GatewayURL)
}
} else {
fmt.Fprintf(os.Stderr, "Usage: dbn %s enable\n", command)
os.Exit(1)
}
// Development environment commands // Development environment commands
case "dev": case "dev":
cli.HandleDevCommand(args) cli.HandleDevCommand(args)
@ -76,36 +56,6 @@ func main() {
case "auth": case "auth":
cli.HandleAuthCommand(args) cli.HandleAuthCommand(args)
// Basic network commands
case "health":
cli.HandleHealthCommand(format, timeout)
case "peers":
cli.HandlePeersCommand(format, timeout)
case "status":
cli.HandleStatusCommand(format, timeout)
case "peer-id":
cli.HandlePeerIDCommand(format, timeout)
// Query command
case "query":
if len(args) == 0 {
fmt.Fprintf(os.Stderr, "Usage: dbn query <sql>\n")
os.Exit(1)
}
cli.HandleQueryCommand(args[0], format, timeout)
// PubSub commands
case "pubsub":
cli.HandlePubSubCommand(args, format, timeout)
// Connect command
case "connect":
if len(args) == 0 {
fmt.Fprintf(os.Stderr, "Usage: dbn connect <peer_address>\n")
os.Exit(1)
}
cli.HandleConnectCommand(args[0], timeout)
// Help // Help
case "help", "--help", "-h": case "help", "--help", "-h":
showHelp() showHelp()
@ -138,65 +88,47 @@ func showHelp() {
fmt.Printf("Network CLI - Distributed P2P Network Management Tool\n\n") fmt.Printf("Network CLI - Distributed P2P Network Management Tool\n\n")
fmt.Printf("Usage: dbn <command> [args...]\n\n") fmt.Printf("Usage: dbn <command> [args...]\n\n")
fmt.Printf("🌍 Environment Management:\n")
fmt.Printf(" env list - List available environments\n")
fmt.Printf(" env current - Show current environment\n")
fmt.Printf(" env switch <env> - Switch to environment (local, devnet, testnet)\n")
fmt.Printf(" devnet enable - Shorthand for switching to devnet\n")
fmt.Printf(" testnet enable - Shorthand for switching to testnet\n\n")
fmt.Printf("💻 Local Development:\n") fmt.Printf("💻 Local Development:\n")
fmt.Printf(" dev up - Start full local dev environment\n") fmt.Printf(" dev up - Start full local dev environment\n")
fmt.Printf(" dev down - Stop all dev services\n") fmt.Printf(" dev down - Stop all dev services\n")
fmt.Printf(" dev status - Show status of dev services\n") fmt.Printf(" dev status - Show status of dev services\n")
fmt.Printf(" dev logs <component> - View dev component logs\n\n") fmt.Printf(" dev logs <component> - View dev component logs\n")
fmt.Printf(" dev help - Show dev command help\n\n")
fmt.Printf("🚀 Production Deployment:\n") fmt.Printf("🚀 Production Deployment:\n")
fmt.Printf(" prod install [--bootstrap] - Full production bootstrap (requires root)\n") fmt.Printf(" prod install [--bootstrap] - Full production bootstrap (requires root/sudo)\n")
fmt.Printf(" prod upgrade - Upgrade existing installation\n") fmt.Printf(" prod upgrade - Upgrade existing installation\n")
fmt.Printf(" prod status - Show production service status\n") fmt.Printf(" prod status - Show production service status\n")
fmt.Printf(" prod start - Start all production services (requires root/sudo)\n")
fmt.Printf(" prod stop - Stop all production services (requires root/sudo)\n")
fmt.Printf(" prod restart - Restart all production services (requires root/sudo)\n")
fmt.Printf(" prod logs <service> - View production service logs\n") fmt.Printf(" prod logs <service> - View production service logs\n")
fmt.Printf(" prod uninstall - Remove production services (preserves data)\n\n") fmt.Printf(" prod uninstall - Remove production services (requires root/sudo)\n")
fmt.Printf(" prod help - Show prod command help\n\n")
fmt.Printf("🔐 Authentication:\n") fmt.Printf("🔐 Authentication:\n")
fmt.Printf(" auth login - Authenticate with wallet\n") fmt.Printf(" auth login - Authenticate with wallet\n")
fmt.Printf(" auth logout - Clear stored credentials\n") fmt.Printf(" auth logout - Clear stored credentials\n")
fmt.Printf(" auth whoami - Show current authentication\n") fmt.Printf(" auth whoami - Show current authentication\n")
fmt.Printf(" auth status - Show detailed auth info\n\n") fmt.Printf(" auth status - Show detailed auth info\n")
fmt.Printf(" auth help - Show auth command help\n\n")
fmt.Printf("🌐 Network Commands:\n")
fmt.Printf(" health - Check network health\n")
fmt.Printf(" peers - List connected peers\n")
fmt.Printf(" status - Show network status\n")
fmt.Printf(" peer-id - Show this node's peer ID\n")
fmt.Printf(" connect <peer_address> - Connect to peer\n\n")
fmt.Printf("🗄️ Database:\n")
fmt.Printf(" query <sql> 🔐 Execute database query\n\n")
fmt.Printf("📡 PubSub:\n")
fmt.Printf(" pubsub publish <topic> <msg> 🔐 Publish message\n")
fmt.Printf(" pubsub subscribe <topic> 🔐 Subscribe to topic\n")
fmt.Printf(" pubsub topics 🔐 List topics\n\n")
fmt.Printf("Global Flags:\n") fmt.Printf("Global Flags:\n")
fmt.Printf(" -f, --format <format> - Output format: table, json (default: table)\n") fmt.Printf(" -f, --format <format> - Output format: table, json (default: table)\n")
fmt.Printf(" -t, --timeout <duration> - Operation timeout (default: 30s)\n\n") fmt.Printf(" -t, --timeout <duration> - Operation timeout (default: 30s)\n")
fmt.Printf(" --help, -h - Show this help message\n\n")
fmt.Printf("🔐 = Requires authentication (auto-prompts if needed)\n\n")
fmt.Printf("Examples:\n") fmt.Printf("Examples:\n")
fmt.Printf(" # Switch to devnet\n") fmt.Printf(" # Authenticate\n")
fmt.Printf(" dbn devnet enable\n\n") fmt.Printf(" dbn auth login\n\n")
fmt.Printf(" # Authenticate and query\n") fmt.Printf(" # Start local dev environment\n")
fmt.Printf(" dbn auth login\n") fmt.Printf(" dbn dev up\n")
fmt.Printf(" dbn query \"SELECT * FROM users LIMIT 10\"\n\n") fmt.Printf(" dbn dev status\n\n")
fmt.Printf(" # Setup VPS (Linux only)\n") fmt.Printf(" # Production deployment (requires root/sudo)\n")
fmt.Printf(" sudo dbn setup\n\n") fmt.Printf(" sudo dbn prod install --bootstrap\n")
fmt.Printf(" sudo dbn prod upgrade\n")
fmt.Printf(" # Manage services\n") fmt.Printf(" dbn prod status\n")
fmt.Printf(" sudo dbn service status all\n") fmt.Printf(" dbn prod logs node --follow\n")
fmt.Printf(" sudo dbn service logs node --follow\n")
} }

View File

@ -65,6 +65,7 @@ func showProdHelp() {
fmt.Printf(" Options:\n") fmt.Printf(" Options:\n")
fmt.Printf(" --restart - Automatically restart services after upgrade\n") fmt.Printf(" --restart - Automatically restart services after upgrade\n")
fmt.Printf(" --branch BRANCH - Git branch to use (main or nightly, uses saved preference if not specified)\n") fmt.Printf(" --branch BRANCH - Git branch to use (main or nightly, uses saved preference if not specified)\n")
fmt.Printf(" --no-pull - Skip git clone/pull, use existing /home/debros/src\n")
fmt.Printf(" status - Show status of production services\n") fmt.Printf(" status - Show status of production services\n")
fmt.Printf(" start - Start all production services (requires root/sudo)\n") fmt.Printf(" start - Start all production services (requires root/sudo)\n")
fmt.Printf(" stop - Stop all production services (requires root/sudo)\n") fmt.Printf(" stop - Stop all production services (requires root/sudo)\n")
@ -86,6 +87,8 @@ func showProdHelp() {
fmt.Printf(" sudo dbn prod upgrade --restart\n\n") fmt.Printf(" sudo dbn prod upgrade --restart\n\n")
fmt.Printf(" # Upgrade and switch to nightly branch\n") fmt.Printf(" # Upgrade and switch to nightly branch\n")
fmt.Printf(" sudo dbn prod upgrade --restart --branch nightly\n\n") fmt.Printf(" sudo dbn prod upgrade --restart --branch nightly\n\n")
fmt.Printf(" # Upgrade without pulling latest code (use existing /home/debros/src)\n")
fmt.Printf(" sudo dbn prod upgrade --restart --no-pull\n\n")
fmt.Printf(" # Service management\n") fmt.Printf(" # Service management\n")
fmt.Printf(" sudo dbn prod start\n") fmt.Printf(" sudo dbn prod start\n")
fmt.Printf(" sudo dbn prod stop\n") fmt.Printf(" sudo dbn prod stop\n")
@ -161,7 +164,7 @@ func handleProdInstall(args []string) {
debrosHome := "/home/debros" debrosHome := "/home/debros"
debrosDir := debrosHome + "/.debros" debrosDir := debrosHome + "/.debros"
setup := production.NewProductionSetup(debrosHome, os.Stdout, force, branch) setup := production.NewProductionSetup(debrosHome, os.Stdout, force, branch, false)
// Save branch preference for future upgrades // Save branch preference for future upgrades
if err := production.SaveBranchPreference(debrosDir, branch); err != nil { if err := production.SaveBranchPreference(debrosDir, branch); err != nil {
@ -234,6 +237,7 @@ func handleProdUpgrade(args []string) {
// Parse arguments // Parse arguments
force := false force := false
restartServices := false restartServices := false
noPull := false
branch := "" branch := ""
for i, arg := range args { for i, arg := range args {
if arg == "--force" { if arg == "--force" {
@ -242,6 +246,15 @@ func handleProdUpgrade(args []string) {
if arg == "--restart" { if arg == "--restart" {
restartServices = true restartServices = true
} }
if arg == "--no-pull" {
noPull = true
}
if arg == "--nightly" {
branch = "nightly"
}
if arg == "--main" {
branch = "main"
}
if arg == "--branch" { if arg == "--branch" {
if i+1 < len(args) { if i+1 < len(args) {
branch = args[i+1] branch = args[i+1]
@ -266,7 +279,13 @@ func handleProdUpgrade(args []string) {
fmt.Printf(" This will preserve existing configurations and data\n") fmt.Printf(" This will preserve existing configurations and data\n")
fmt.Printf(" Configurations will be updated to latest format\n\n") fmt.Printf(" Configurations will be updated to latest format\n\n")
setup := production.NewProductionSetup(debrosHome, os.Stdout, force, branch) setup := production.NewProductionSetup(debrosHome, os.Stdout, force, branch, noPull)
// Log if --no-pull is enabled
if noPull {
fmt.Printf(" ⚠️ --no-pull flag enabled: Skipping git clone/pull\n")
fmt.Printf(" Using existing repository at %s/src\n", debrosHome)
}
// If branch was explicitly provided, save it for future upgrades // If branch was explicitly provided, save it for future upgrades
if branch != "" { if branch != "" {

View File

@ -275,7 +275,7 @@ func (bi *BinaryInstaller) ResolveBinaryPath(binary string, extraPaths ...string
} }
// InstallDeBrosBinaries clones and builds DeBros binaries // InstallDeBrosBinaries clones and builds DeBros binaries
func (bi *BinaryInstaller) InstallDeBrosBinaries(branch string, debrosHome string) error { func (bi *BinaryInstaller) InstallDeBrosBinaries(branch string, debrosHome string, skipRepoUpdate bool) error {
fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " Building DeBros binaries...\n") fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " Building DeBros binaries...\n")
srcDir := filepath.Join(debrosHome, "src") srcDir := filepath.Join(debrosHome, "src")
@ -291,23 +291,39 @@ func (bi *BinaryInstaller) InstallDeBrosBinaries(branch string, debrosHome strin
repoInitialized = true repoInitialized = true
} }
// Clone repository if not present, otherwise update it // Handle repository update/clone based on skipRepoUpdate flag
if !repoInitialized { if skipRepoUpdate {
fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " Cloning repository...\n") fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " Skipping repo clone/pull (--no-pull flag)\n")
cmd := exec.Command("git", "clone", "--branch", branch, "--depth", "1", "https://github.com/DeBrosOfficial/network.git", srcDir) if !repoInitialized {
if err := cmd.Run(); err != nil { return fmt.Errorf("cannot skip pull: repository not found at %s", srcDir)
return fmt.Errorf("failed to clone repository: %w", err)
} }
// Verify srcDir exists and has content
if entries, err := os.ReadDir(srcDir); err != nil {
return fmt.Errorf("failed to read source directory %s: %w", srcDir, err)
} else if len(entries) == 0 {
return fmt.Errorf("source directory %s is empty", srcDir)
}
fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " Using existing repository at %s (skipping git operations)\n", srcDir)
// Skip to build step - don't execute any git commands
} else { } else {
fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " Updating repository to latest changes...\n") // Clone repository if not present, otherwise update it
if output, err := exec.Command("git", "-C", srcDir, "fetch", "origin", branch).CombinedOutput(); err != nil { if !repoInitialized {
return fmt.Errorf("failed to fetch repository updates: %v\n%s", err, string(output)) fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " Cloning repository...\n")
} cmd := exec.Command("git", "clone", "--branch", branch, "--depth", "1", "https://github.com/DeBrosOfficial/network.git", srcDir)
if output, err := exec.Command("git", "-C", srcDir, "reset", "--hard", "origin/"+branch).CombinedOutput(); err != nil { if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to reset repository: %v\n%s", err, string(output)) return fmt.Errorf("failed to clone repository: %w", err)
} }
if output, err := exec.Command("git", "-C", srcDir, "clean", "-fd").CombinedOutput(); err != nil { } else {
return fmt.Errorf("failed to clean repository: %v\n%s", err, string(output)) fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " Updating repository to latest changes...\n")
if output, err := exec.Command("git", "-C", srcDir, "fetch", "origin", branch).CombinedOutput(); err != nil {
return fmt.Errorf("failed to fetch repository updates: %v\n%s", err, string(output))
}
if output, err := exec.Command("git", "-C", srcDir, "reset", "--hard", "origin/"+branch).CombinedOutput(); err != nil {
return fmt.Errorf("failed to reset repository: %v\n%s", err, string(output))
}
if output, err := exec.Command("git", "-C", srcDir, "clean", "-fd").CombinedOutput(); err != nil {
return fmt.Errorf("failed to clean repository: %v\n%s", err, string(output))
}
} }
} }

View File

@ -31,6 +31,7 @@ type ProductionSetup struct {
serviceController *SystemdController serviceController *SystemdController
binaryInstaller *BinaryInstaller binaryInstaller *BinaryInstaller
branch string branch string
skipRepoUpdate bool
NodePeerID string // Captured during Phase3 for later display NodePeerID string // Captured during Phase3 for later display
} }
@ -62,7 +63,7 @@ func SaveBranchPreference(debrosDir, branch string) error {
} }
// NewProductionSetup creates a new production setup orchestrator // NewProductionSetup creates a new production setup orchestrator
func NewProductionSetup(debrosHome string, logWriter io.Writer, forceReconfigure bool, branch string) *ProductionSetup { func NewProductionSetup(debrosHome string, logWriter io.Writer, forceReconfigure bool, branch string, skipRepoUpdate bool) *ProductionSetup {
debrosDir := debrosHome + "/.debros" debrosDir := debrosHome + "/.debros"
arch, _ := (&ArchitectureDetector{}).Detect() arch, _ := (&ArchitectureDetector{}).Detect()
@ -78,6 +79,7 @@ func NewProductionSetup(debrosHome string, logWriter io.Writer, forceReconfigure
forceReconfigure: forceReconfigure, forceReconfigure: forceReconfigure,
arch: arch, arch: arch,
branch: branch, branch: branch,
skipRepoUpdate: skipRepoUpdate,
privChecker: &PrivilegeChecker{}, privChecker: &PrivilegeChecker{},
osDetector: &OSDetector{}, osDetector: &OSDetector{},
archDetector: &ArchitectureDetector{}, archDetector: &ArchitectureDetector{},
@ -247,7 +249,7 @@ func (ps *ProductionSetup) Phase2bInstallBinaries() error {
} }
// Install DeBros binaries // Install DeBros binaries
if err := ps.binaryInstaller.InstallDeBrosBinaries(ps.branch, ps.debrosHome); err != nil { if err := ps.binaryInstaller.InstallDeBrosBinaries(ps.branch, ps.debrosHome, ps.skipRepoUpdate); err != nil {
return fmt.Errorf("failed to install DeBros binaries: %w", err) return fmt.Errorf("failed to install DeBros binaries: %w", err)
} }