Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions cmd/gox/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ if [ "$1" = "--web" ]; then
go env -w GOFLAGS="-buildvcs=false"
( cd ../ispx && ./build.sh )
cp ../ispx/ispx.wasm "$GOPATH/bin/"

# Install ispx web runtime
echo "Installing ispx web runtime..."
rm -rf "$GOPATH/bin/ispx"
mkdir -p "$GOPATH/bin/ispx"
cp ../ispx/web/* "$GOPATH/bin/ispx/"
echo "ispx web runtime installed to $GOPATH/bin/ispx/"
fi

( cd ../ispxnative && ./build.sh )
Expand Down
3 changes: 2 additions & 1 deletion cmd/gox/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"embed"
"fmt"
"strings"

"github.com/goplus/spx/v2/cmd/gox/pkg/command"
Expand Down Expand Up @@ -50,7 +51,7 @@ func main() {
// Initialize the Args field if not already initialized
err := cmd.RunCmd(appName, appName, cmd.Version, projectFS, "template/project", "project")
if err != nil {
println("failed to run cmd:", err)
fmt.Println("failed to run cmd:", err)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change redirects the error message from stderr (with println) to stdout (with fmt.Println). It's a best practice for command-line tools to write error messages to stderr. This allows users to separate normal output from error output, for example when using pipes. I suggest using fmt.Fprintf to write to os.Stderr. Note that this will require importing the os package.

Suggested change
fmt.Println("failed to run cmd:", err)
fmt.Fprintf(os.Stderr, "failed to run cmd: %v\n", err)

return
}
}
5 changes: 3 additions & 2 deletions cmd/gox/pkg/command/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (pself *CmdTool) CheckCmd(ext ...string) bool {
"build", "buildtinygo", "rune", "export",
"runweb", "buildweb", "exportweb", "stopweb", "runwebworker",
"runm", "exportbot", "exportapk", "exportios",
"run", "runi", "exporttemplateweb", "exportminigame", "exportminiprogram", "exportwebworker",
"run", "runi", "exportwebruntime", "exportminigame", "exportminiprogram", "exportwebworker",
}
cmds = append(cmds, ext...)

Expand Down Expand Up @@ -192,8 +192,8 @@ Available commands:
- runweb # Launch the web server
- runwebworker # Run web worker
- exportweb # Export the web package
- exportwebruntime # Export the reusable web runtime bundle
- exportwebworker # Export web worker package
- exporttemplateweb # Export template web package
- stopweb # Stop the web server

Export & Distribution:
Expand All @@ -216,6 +216,7 @@ Examples:
#CMDNAME run --ixgogen --goenv=./cmd/portable-go # Run with xgobuild and portable Go
#CMDNAME build --servermode # Build in server mode
#CMDNAME runweb --debugweb # Run web server with debug service
#CMDNAME exportwebruntime -mode=normal # Export the reusable web runtime bundle
#CMDNAME buildtinygo # Build TinyGo static library for ESP32
#CMDNAME exportminigame -build=fast # Export minigame without compression (faster)
#CMDNAME run -tags=pure_engine # Run in pure engine mode
Expand Down
5 changes: 3 additions & 2 deletions cmd/gox/pkg/command/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ func (cmd *CmdTool) RunCmd(projectName, fileSuffix, version string, fs embed.FS,
if cmd.Args.CmdName == "init" {
return cmd.Init()
}
if cmd.Args.CmdName == "exportwebruntime" {
return cmd.ExportWebRuntime()
}

// Setup paths
err = cmd.setupPaths(dstRelDir)
Expand Down Expand Up @@ -241,8 +244,6 @@ func (cmd *CmdTool) handleExecutionPhase() error {
return cmd.RunWebWorker()
case "export":
return cmd.Export()
case "exporttemplateweb":
return cmd.ExportTemplateWeb()
case "exportweb":
return cmd.ExportWeb()
case "exportwebworker":
Expand Down
10 changes: 0 additions & 10 deletions cmd/gox/pkg/command/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,6 @@ func (pself *CmdTool) getWasmPath() string {
return filePath
}

// getIspxWebDir returns the path to the ispx web runtime directory.
func (pself *CmdTool) getIspxWebDir() (string, error) {
ispxWebDir := path.Join(pself.GoBinPath, "ispx")
if _, err := os.Stat(ispxWebDir); os.IsNotExist(err) {
return "", fmt.Errorf("ispx web runtime not found at %s; "+
"run 'cd cmd/gox && ./install.sh --web' to install", ispxWebDir)
}
return ispxWebDir, nil
}

// SetupPC sets up the PC environment by running the initialization script
func (pself *CmdTool) SetupPC() error {
// Get current working directory
Expand Down
Loading