diff --git a/package/pingpong.tengo b/package/pingpong.tengo new file mode 100644 index 0000000..da20165 --- /dev/null +++ b/package/pingpong.tengo @@ -0,0 +1,66 @@ +os := import("os") +fmt := import("fmt") +text := import("text") +nami := import("nami") +json := import("json") + +b := nami.sh1(`curl`, `-L`, `https://api.github.com/repos/txthinking/pingpong/releases/latest`) +if is_error(b) { + fmt.println(b) + os.exit(1) +} +v := json.decode(b).tag_name +err := nami.write_file(text.join([nami.cache_dir, "version"], os.path_separator), v) +if is_error(err) { + fmt.println(err) + os.exit(1) +} + +if nami.os == "darwin" && nami.arch == "arm64" { + err := nami.sh(`curl`, `-L`, `--progress-bar`, `https://github.com/txthinking/pingpong/releases/latest/download/pps_darwin_arm64`, `-o`, text.join([nami.cache_dir, "pps"], os.path_separator)) + if is_error(err) { + fmt.println(err) + os.exit(1) + } + err = nami.sh(`curl`, `-L`, `--progress-bar`, `https://github.com/txthinking/pingpong/releases/latest/download/ppc_darwin_arm64`, `-o`, text.join([nami.cache_dir, "ppc"], os.path_separator)) + if is_error(err) { + fmt.println(err) + os.exit(1) + } +} +if nami.os == "darwin" && nami.arch == "amd64" { + err := nami.sh(`curl`, `-L`, `--progress-bar`, `https://github.com/txthinking/pingpong/releases/latest/download/pps_darwin_amd64`, `-o`, text.join([nami.cache_dir, "pps"], os.path_separator)) + if is_error(err) { + fmt.println(err) + os.exit(1) + } + err = nami.sh(`curl`, `-L`, `--progress-bar`, `https://github.com/txthinking/pingpong/releases/latest/download/ppc_darwin_amd64`, `-o`, text.join([nami.cache_dir, "ppc"], os.path_separator)) + if is_error(err) { + fmt.println(err) + os.exit(1) + } +} +if nami.os == "linux" && nami.arch == "amd64" { + err := nami.sh(`curl`, `-L`, `--progress-bar`, `https://github.com/txthinking/pingpong/releases/latest/download/pps_linux_amd64`, `-o`, text.join([nami.cache_dir, "pps"], os.path_separator)) + if is_error(err) { + fmt.println(err) + os.exit(1) + } + err = nami.sh(`curl`, `-L`, `--progress-bar`, `https://github.com/txthinking/pingpong/releases/latest/download/ppc_linux_amd64`, `-o`, text.join([nami.cache_dir, "ppc"], os.path_separator)) + if is_error(err) { + fmt.println(err) + os.exit(1) + } +} +if nami.os == "windows" && nami.arch == "amd64" { + err := nami.sh(`curl`, `-L`, `--progress-bar`, `https://github.com/txthinking/pingpong/releases/latest/download/pps_windows_amd64.exe`, `-o`, text.join([nami.cache_dir, "pps.exe"], os.path_separator)) + if is_error(err) { + fmt.println(err) + os.exit(1) + } + err = nami.sh(`curl`, `-L`, `--progress-bar`, `https://github.com/txthinking/pingpong/releases/latest/download/ppc_windows_amd64.exe`, `-o`, text.join([nami.cache_dir, "ppc.exe"], os.path_separator)) + if is_error(err) { + fmt.println(err) + os.exit(1) + } +}