From 65f2ae1d14d89303071423c515911f617639e7d0 Mon Sep 17 00:00:00 2001 From: PRASSamin Date: Fri, 12 Sep 2025 15:22:31 +0600 Subject: [PATCH 1/2] chore: synced update script with new cli structure --- README.md | 1 - cmd/upgrade/vars.go | 2 +- cmd/version/version.go | 33 --------------------------------- cmd/version/version_test.go | 28 ---------------------------- update | 2 +- 5 files changed, 2 insertions(+), 64 deletions(-) delete mode 100644 cmd/version/version.go delete mode 100644 cmd/version/version_test.go diff --git a/README.md b/README.md index 89bee7a..62e7b7a 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,6 @@ Prasmoid provides a comprehensive set of commands to manage your plasmoid projec | `regen types` | Regenerates `prasmoid.d.ts`. | `prasmoid regen types` | | `regen config` | Regenerates `prasmoid.config.js`. | `prasmoid regen config` | | `upgrade` | Updates Prasmoid itself to the latest version. | `prasmoid upgrade` | -| `version` | Shows the current version of Prasmoid. | `prasmoid version` | ## Extending Prasmoid with Custom Commands diff --git a/cmd/upgrade/vars.go b/cmd/upgrade/vars.go index 7f24911..0db379a 100644 --- a/cmd/upgrade/vars.go +++ b/cmd/upgrade/vars.go @@ -22,5 +22,5 @@ var ( rootGetCacheFilePath = root.GetCacheFilePath confirmInstallation bool - scriptURL = "https://raw.githubusercontent.com/PRASSamin/prasmoid/main/update" + scriptURL = "https://raw.githubusercontent.com/PRASSamin/prasmoid/refs/heads/pras/update" ) diff --git a/cmd/version/version.go b/cmd/version/version.go deleted file mode 100644 index 4374b85..0000000 --- a/cmd/version/version.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2025 PRAS -*/ -package cmd - -import ( - "fmt" - - "github.com/PRASSamin/prasmoid/cmd" - "github.com/PRASSamin/prasmoid/internal" - "github.com/spf13/cobra" -) - -var CliConfig struct { - Version string `yaml:"version"` - Name string `yaml:"name"` - Author string `yaml:"author"` - License string `yaml:"license"` - Github string `yaml:"github"` -} - -func init() { - cmd.RootCmd.AddCommand(VersionCmd) -} - -var VersionCmd = &cobra.Command{ - Use: "version", - Short: "Show Prasmoid version", - Long: "Show Prasmoid version.", - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(internal.AppMetaData.Version) - }, -} diff --git a/cmd/version/version_test.go b/cmd/version/version_test.go deleted file mode 100644 index 7b28d5c..0000000 --- a/cmd/version/version_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package cmd - -import ( - "bytes" - "io" - "os" - "testing" - - "github.com/PRASSamin/prasmoid/internal" - "github.com/stretchr/testify/assert" -) - -func TestVersionCmd(t *testing.T) { - // Capture stdout - oldStdout := os.Stdout - r, w, _ := os.Pipe() - os.Stdout = w - - // Act - VersionCmd.Run(VersionCmd, []string{}) - _ = w.Close() - - // Assert - var buf bytes.Buffer - _, _ = io.Copy(&buf, r) - os.Stdout = oldStdout - assert.Contains(t, buf.String(), internal.AppMetaData.Version) -} diff --git a/update b/update index 1d6c6bf..b4b3f14 100755 --- a/update +++ b/update @@ -22,7 +22,7 @@ if [ -z "$LATEST_RELEASE_INFO" ]; then log_fail "Failed to fetch release info from GitHub." fi -CURRENT_VERSION=$("$CURRENT_EXE" version) +CURRENT_VERSION=$("$CURRENT_EXE" --version) RAW_CURRENT_VERSION=$(echo "$CURRENT_VERSION" | sed "s/-portable//") IS_PORTABLE=false if [[ "$CURRENT_VERSION" == *"-portable"* ]]; then From 36985d79c13c39ddf7f4cc18365a68d9cc821206 Mon Sep 17 00:00:00 2001 From: PRASSamin Date: Fri, 12 Sep 2025 16:10:14 +0600 Subject: [PATCH 2/2] chore: improved update script --- cmd/upgrade/vars.go | 2 +- update | 4 ++-- utils/main.go | 9 --------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/cmd/upgrade/vars.go b/cmd/upgrade/vars.go index 0db379a..7f24911 100644 --- a/cmd/upgrade/vars.go +++ b/cmd/upgrade/vars.go @@ -22,5 +22,5 @@ var ( rootGetCacheFilePath = root.GetCacheFilePath confirmInstallation bool - scriptURL = "https://raw.githubusercontent.com/PRASSamin/prasmoid/refs/heads/pras/update" + scriptURL = "https://raw.githubusercontent.com/PRASSamin/prasmoid/main/update" ) diff --git a/update b/update index b4b3f14..299c634 100755 --- a/update +++ b/update @@ -89,7 +89,7 @@ mv "$TEMP_FILE" "$CURRENT_EXE" log_done "Update complete $LATEST_VERSION ($LATEST_HASH)" -log_step "Relaunching CLI..." -exec "$CURRENT_EXE" +# log_step "Relaunching CLI..." +# exec "$CURRENT_EXE" exit 0 diff --git a/utils/main.go b/utils/main.go index 6c6b880..ce54e03 100644 --- a/utils/main.go +++ b/utils/main.go @@ -364,36 +364,27 @@ func LoadConfigRC() types.Config { data, err := os.ReadFile(configFileName) if err != nil { - color.Yellow("Configuration file (prasmoid.config.js) not found.\n" + - "Run 'prasmoid regen config'\n") return defaultConfig } vm := runtime.NewRuntime() _, err = vm.RunString(string(data)) if err != nil { - color.Yellow("Failed to load configuration file (prasmoid.config.js).\n" + - "Run 'prasmoid regen config'\n") return defaultConfig } config := vm.Get("config") if config == nil { - color.Yellow("Failed to load configuration file (prasmoid.config.js).\n" + - "Run 'prasmoid regen config'\n") return defaultConfig } // Convert to JSON bytes configBytes, err := json.Marshal(config.Export()) if err != nil { - color.Yellow("Failed to load configuration file (prasmoid.config.js).\n" + "Run 'prasmoid regen config'\n") return defaultConfig } // Unmarshal into Config struct var result types.Config if err := json.Unmarshal(configBytes, &result); err != nil { - color.Yellow("Failed to load configuration file (prasmoid.config.js).\n" + - "Run 'prasmoid regen config'\n") return defaultConfig }