@a2hmarket/a2hmarket 0.3.3 → 0.3.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2hmarket/a2hmarket",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "index.ts",
@@ -162,12 +162,64 @@ async function pollForAuth(code) {
162
162
 
163
163
  // ── Main ─────────────────────────────────────────────────────────────────
164
164
 
165
+ // ── Uninstall ────────────────────────────────────────────────────────────
166
+
167
+ async function runUninstall() {
168
+ log(`\n${BOLD}🏪 A2H Market — Uninstall${RESET}\n`);
169
+
170
+ const prompt = createPrompt();
171
+ const confirm = await prompt.ask("确认卸载 a2hmarket 插件及所有数据? (y/N)", "N");
172
+ prompt.close();
173
+ if (confirm.toLowerCase() !== "y") {
174
+ log(` 取消卸载。`);
175
+ process.exit(0);
176
+ }
177
+
178
+ // 1. Uninstall plugin
179
+ log(` 卸载插件...`);
180
+ try {
181
+ execSync('echo y | openclaw plugins uninstall a2hmarket 2>&1', { encoding: "utf-8", stdio: "pipe" });
182
+ log(` ${CHECK} 插件已卸载`);
183
+ } catch {
184
+ log(` ${WARN} 插件卸载失败(可能已卸载)`);
185
+ }
186
+
187
+ // 2. Remove runtime data
188
+ if (existsSync(DATA_DIR)) {
189
+ try {
190
+ execSync(`rm -rf "${DATA_DIR}"`, { stdio: "pipe" });
191
+ log(` ${CHECK} 数据目录已删除: ${DATA_DIR}`);
192
+ } catch {
193
+ log(` ${WARN} 数据目录删除失败: ${DATA_DIR}`);
194
+ }
195
+ }
196
+
197
+ // 3. Restart gateway
198
+ try {
199
+ execSync("openclaw gateway restart 2>&1", { encoding: "utf-8", stdio: "pipe" });
200
+ log(` ${CHECK} Gateway 已重启`);
201
+ } catch {
202
+ log(` ${WARN} 请手动执行: openclaw gateway restart`);
203
+ }
204
+
205
+ log(`\n${GREEN}${BOLD}卸载完成${RESET}\n`);
206
+ }
207
+
208
+ // ── Main ─────────────────────────────────────────────────────────────────
209
+
165
210
  async function main() {
166
211
  const args = process.argv.slice(2);
167
- if (!args.includes("install")) {
212
+ const cmd = args[0];
213
+
214
+ if (cmd === "uninstall") {
215
+ return await runUninstall();
216
+ }
217
+
218
+ if (cmd !== "install") {
168
219
  log(`\n${BOLD}A2H Market — OpenClaw Plugin${RESET}\n`);
169
- log(` 安装: npx -y ${NPM_SPEC} install`);
170
- log(` 快速: npx -y ${NPM_SPEC} install --agent ag_xxx:key\n`);
220
+ log(` 安装: npx -y ${NPM_SPEC} install`);
221
+ log(` 快速: npx -y ${NPM_SPEC} install --agent ag_xxx:key`);
222
+ log(` 卸载: npx -y ${NPM_SPEC} uninstall\n`);
171
223
  process.exit(0);
172
224
  }
173
225