shoplazza-cli 2.0.0 → 2.0.1

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/README.md CHANGED
@@ -38,7 +38,7 @@ The official [Shoplazza Open Platform](https://www.shoplazza.dev/) CLI tool —
38
38
  |--------|---------|-------|
39
39
  | **Homebrew** (macOS / Linux) | `brew install Shoplazza/tap/shoplazza-cli` | Recommended. Auto-updates via `brew upgrade`. |
40
40
  | **Shell script** (macOS / Linux) | `curl -fsSL https://raw.githubusercontent.com/Shoplazza/shoplazza-cli/main/install.sh \| bash` | Auto-detects OS and architecture. |
41
- | **npm** | `npm install -g @shoplazza/cli` | Requires Node.js `>=14.18.0`. |
41
+ | **npm** | `npm install -g shoplazza-cli` | Requires Node.js `>=14.18.0`. |
42
42
  | **Download binary** | See [GitHub Releases](https://github.com/Shoplazza/shoplazza-cli/releases) | Manual download for any platform. |
43
43
  | **Build from source** | `git clone ... && cd shoplazza-cli && make install` | Requires Go `v1.24`+. Installs to `~/.local/bin`. |
44
44
 
package/README.zh.md CHANGED
@@ -38,7 +38,7 @@ Shoplazza 开放平台官方 CLI 工具 — 让人类和 AI Agent 都能在终
38
38
  |------|------|------|
39
39
  | **Homebrew**(macOS / Linux) | `brew install Shoplazza/tap/shoplazza-cli` | 推荐。通过 `brew upgrade` 自动更新。 |
40
40
  | **一键脚本**(macOS / Linux) | `curl -fsSL https://raw.githubusercontent.com/Shoplazza/shoplazza-cli/main/install.sh \| bash` | 自动检测系统和架构。 |
41
- | **npm** | `npm install -g @shoplazza/cli` | 需要 Node.js `>=14.18.0`。 |
41
+ | **npm** | `npm install -g shoplazza-cli` | 需要 Node.js `>=14.18.0`。 |
42
42
  | **下载二进制** | 见 [GitHub Releases](https://github.com/Shoplazza/shoplazza-cli/releases) | 手动下载,支持所有平台。 |
43
43
  | **源码构建** | `git clone ... && cd shoplazza-cli && make install` | 需要 Go `v1.24`+。安装到 `~/.local/bin`。 |
44
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shoplazza-cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "The official CLI for Shoplazza Open Platform",
5
5
  "bin": {
6
6
  "shoplazza": "scripts/run.js"
@@ -8,8 +8,15 @@
8
8
  "scripts": {
9
9
  "postinstall": "node scripts/install.js"
10
10
  },
11
- "os": ["darwin", "linux", "win32"],
12
- "cpu": ["x64", "arm64"],
11
+ "os": [
12
+ "darwin",
13
+ "linux",
14
+ "win32"
15
+ ],
16
+ "cpu": [
17
+ "x64",
18
+ "arm64"
19
+ ],
13
20
  "engines": {
14
21
  "node": ">=14.18.0"
15
22
  },
@@ -70,27 +70,28 @@ const downloadURL = `${RELEASE_BASE}/${fileName}`;
70
70
 
71
71
  function download(url, dest) {
72
72
  return new Promise((resolve, reject) => {
73
- const proto = url.startsWith('https') ? https : http;
74
- const file = fs.createWriteStream(dest);
75
-
76
73
  function get(u) {
74
+ const proto = u.startsWith('https') ? https : http;
77
75
  proto.get(u, (res) => {
78
76
  if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
79
- // Follow redirects.
80
- file.close();
77
+ res.resume(); // Drain response before following redirect.
81
78
  get(res.headers.location);
82
79
  return;
83
80
  }
84
81
  if (res.statusCode !== 200) {
85
- file.close();
86
- fs.unlinkSync(dest);
82
+ res.resume();
87
83
  reject(new Error(`HTTP ${res.statusCode} for ${u}`));
88
84
  return;
89
85
  }
86
+ const file = fs.createWriteStream(dest);
90
87
  res.pipe(file);
91
88
  file.on('finish', () => file.close(resolve));
89
+ file.on('error', (err) => {
90
+ fs.unlink(dest, () => {});
91
+ reject(err);
92
+ });
92
93
  }).on('error', (err) => {
93
- fs.unlinkSync(dest);
94
+ fs.unlink(dest, () => {});
94
95
  reject(err);
95
96
  });
96
97
  }