@ahqstore/cli 0.10.1 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Cargo.toml CHANGED
@@ -1,7 +1,7 @@
1
1
  [package]
2
2
  edition = "2021"
3
3
  name = "ahqstore_cli_rs"
4
- version = "0.10.1"
4
+ version = "0.10.2"
5
5
  description = "AHQ Store CLI"
6
6
  repository = "https://github.com/ahqstore/cli"
7
7
  homepage = "https://github.com/ahqstore/cli"
package/go/ahqstore.go ADDED
@@ -0,0 +1,166 @@
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+ "io"
6
+ "net/http"
7
+ "os"
8
+ "path"
9
+ "runtime"
10
+
11
+ "github.com/ebitengine/purego"
12
+ "github.com/schollz/progressbar/v3"
13
+ )
14
+
15
+ const version = "0.10.2"
16
+
17
+ func main() {
18
+ var bin = getBinary()
19
+
20
+ var libahqstore, err = openLibrary(bin)
21
+
22
+ if err != nil {
23
+ Download(bin)
24
+ libahqstore, err = openLibrary(bin)
25
+
26
+ if err != nil {
27
+ os.Exit(1)
28
+ }
29
+ }
30
+
31
+ var get_ver func() string
32
+ purego.RegisterLibFunc(&get_ver, libahqstore, "get_ver")
33
+
34
+ if get_ver() != version {
35
+ unloadLibrary(libahqstore)
36
+
37
+ os.Remove(bin)
38
+
39
+ Download(bin)
40
+ libahqstore, err = openLibrary(bin)
41
+
42
+ if err != nil {
43
+ os.Exit(1)
44
+ }
45
+ }
46
+
47
+ var init_args func()
48
+ purego.RegisterLibFunc(&init_args, libahqstore, "init_args")
49
+
50
+ init_args()
51
+
52
+ var add_arg func(string)
53
+ purego.RegisterLibFunc(&add_arg, libahqstore, "add_arg")
54
+
55
+ for i := 1; i < len(os.Args); i++ {
56
+ add_arg(os.Args[i])
57
+ }
58
+
59
+ var node_entrypoint func(bool)
60
+ purego.RegisterLibFunc(&node_entrypoint, libahqstore, "node_entrypoint")
61
+
62
+ node_entrypoint(
63
+ os.Getenv("CI") == "true",
64
+ )
65
+ }
66
+
67
+ func Download(file string) {
68
+ var prefix, suffix = GetPrefixSuffix()
69
+ var triple, _ = GetRustTargetTriple()
70
+
71
+ var url = fmt.Sprintf("https://github.com/ahqstore/cli/releases/download/%s/%sahqstore_cli_rs-%s%s", version, prefix, triple, suffix)
72
+
73
+ var req, _ = http.NewRequest("GET", url, nil)
74
+ var resp, err = http.DefaultClient.Do(req)
75
+
76
+ if err != nil {
77
+ fmt.Println("Could not connect to download the required dynamic library")
78
+ os.Exit(1)
79
+ }
80
+ defer resp.Body.Close()
81
+
82
+ bar := progressbar.DefaultBytes(
83
+ resp.ContentLength,
84
+ "Downloading...",
85
+ )
86
+
87
+ defer bar.Finish()
88
+
89
+ var f, _ = os.OpenFile(file, os.O_WRONLY|os.O_CREATE, os.ModePerm)
90
+ defer f.Close()
91
+
92
+ io.Copy(io.MultiWriter(f, bar), resp.Body)
93
+ }
94
+
95
+ func GetPrefixSuffix() (string, string) {
96
+ switch runtime.GOOS {
97
+ case "windows":
98
+ return "", ".dll"
99
+ case "darwin":
100
+ return "lib", ".dylib"
101
+ default:
102
+ return "lib", ".so"
103
+ }
104
+ }
105
+
106
+ func GetRustTargetTriple() (string, error) {
107
+ // Use runtime.GOOS for the operating system and runtime.GOARCH for the architecture.
108
+ switch runtime.GOOS {
109
+ case "windows":
110
+ switch runtime.GOARCH {
111
+ case "386":
112
+ return "i686-pc-windows-msvc", nil
113
+ case "amd64":
114
+ return "x86_64-pc-windows-msvc", nil
115
+ case "arm64":
116
+ return "aarch64-pc-windows-msvc", nil
117
+ }
118
+ case "darwin":
119
+ switch runtime.GOARCH {
120
+ case "amd64":
121
+ return "x86_64-apple-darwin", nil
122
+ case "arm64":
123
+ return "aarch64-apple-darwin", nil
124
+ }
125
+ case "linux":
126
+ switch runtime.GOARCH {
127
+ case "386":
128
+ return "i686-unknown-linux-gnu", nil
129
+ case "amd64":
130
+ return "x86_64-unknown-linux-gnu", nil
131
+ case "arm":
132
+ return "armv7-unknown-linux-gnueabihf", nil
133
+ case "arm64":
134
+ return "aarch64-unknown-linux-gnu", nil
135
+ }
136
+ }
137
+
138
+ return "", fmt.Errorf("whoa there, this platform is not on the list: %s %s", runtime.GOOS, runtime.GOARCH)
139
+ }
140
+
141
+ func binName() string {
142
+ var prefix, suffix = GetPrefixSuffix()
143
+
144
+ return fmt.Sprintf("%sahqstore_cli_rs%s", prefix, suffix)
145
+ }
146
+
147
+ func getBinary() string {
148
+ var dir, err = os.UserHomeDir()
149
+
150
+ if err != nil {
151
+ fmt.Println(err)
152
+ os.Exit(1)
153
+ }
154
+
155
+ dir = path.Join(dir, "ahqstore-go")
156
+
157
+ _, err = os.ReadDir(dir)
158
+
159
+ if err != nil {
160
+ os.MkdirAll(dir, os.ModePerm)
161
+ }
162
+
163
+ var file = path.Join(dir, binName())
164
+
165
+ return file
166
+ }
@@ -0,0 +1,17 @@
1
+ //go:build darwin || freebsd || linux || netbsd
2
+
3
+ package main
4
+
5
+ import (
6
+ "syscall"
7
+
8
+ "github.com/ebitengine/purego"
9
+ )
10
+
11
+ func openLibrary(name string) (uintptr, error) {
12
+ return purego.Dlopen(name, purego.RTLD_NOW|purego.RTLD_GLOBAL)
13
+ }
14
+
15
+ func unloadLibrary(library uintptr) {
16
+ purego.Dlclose(syscall.Handle(library))
17
+ }
@@ -0,0 +1,16 @@
1
+ //go:build windows
2
+
3
+ package main
4
+
5
+ import "syscall"
6
+
7
+ func openLibrary(name string) (uintptr, error) {
8
+ // Use [syscall.LoadLibrary] here to avoid external dependencies (#270).
9
+ // For actual use cases, [golang.org/x/sys/windows.NewLazySystemDLL] is recommended.
10
+ handle, err := syscall.LoadLibrary(name)
11
+ return uintptr(handle), err
12
+ }
13
+
14
+ func unloadLibrary(library uintptr) {
15
+ syscall.FreeLibrary(syscall.Handle(library))
16
+ }
package/go/go.mod CHANGED
@@ -1,3 +1,15 @@
1
- module ahqstore/cli/go
1
+ module github.com/ahqstore
2
2
 
3
3
  go 1.25.1
4
+
5
+ require (
6
+ github.com/ebitengine/purego v0.8.4
7
+ github.com/schollz/progressbar/v3 v3.18.0
8
+ )
9
+
10
+ require (
11
+ github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
12
+ github.com/rivo/uniseg v0.4.7 // indirect
13
+ golang.org/x/sys v0.36.0 // indirect
14
+ golang.org/x/term v0.35.0 // indirect
15
+ )
package/go/go.sum ADDED
@@ -0,0 +1,28 @@
1
+ github.com/chengxilo/virtualterm v1.0.4 h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7mk9/PwM=
2
+ github.com/chengxilo/virtualterm v1.0.4/go.mod h1:DyxxBZz/x1iqJjFxTFcr6/x+jSpqN0iwWCOK1q10rlY=
3
+ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4
+ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5
+ github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw=
6
+ github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
7
+ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
8
+ github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
9
+ github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
10
+ github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
11
+ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
12
+ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
13
+ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
14
+ github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
15
+ github.com/schollz/progressbar/v3 v3.18.0 h1:uXdoHABRFmNIjUfte/Ex7WtuyVslrw2wVPQmCN62HpA=
16
+ github.com/schollz/progressbar/v3 v3.18.0/go.mod h1:IsO3lpbaGuzh8zIMzgY3+J8l4C8GjO0Y9S69eFvNsec=
17
+ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
18
+ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
19
+ golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
20
+ golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
21
+ golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
22
+ golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
23
+ golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
24
+ golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
25
+ golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ=
26
+ golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA=
27
+ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
28
+ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahqstore/cli",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "AHQ Store Official CLI, A port of the rust version to NodeJS",
5
5
  "keywords": [
6
6
  "cli",
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "ahqstore-cli"
7
- version = "0.10.1"
7
+ version = "0.10.2"
8
8
  authors = [{ name = "AHQ Softwares", email = "ahqsecret@gmail.com" }]
9
9
  description = "A modern Python wrapper for the ahqstore CLI"
10
10
  readme = "../README.md"
package/go/go.exe DELETED
Binary file
package/go/main.go DELETED
@@ -1,7 +0,0 @@
1
- package main
2
-
3
- import "fmt"
4
-
5
- func main() {
6
- fmt.Println("Welcome from Go")
7
- }