@ziniao-open/cli 0.1.0-beta.173 → 0.1.0-beta.175

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": "@ziniao-open/cli",
3
- "version": "0.1.0-beta.173",
3
+ "version": "0.1.0-beta.175",
4
4
  "description": "紫鸟开放平台命令行工具,为开发者和 AI Agent 提供统一的接口调用入口。",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
@@ -37,7 +37,7 @@ const https = require("node:https");
37
37
  const http = require("node:http");
38
38
  const { URL } = require("node:url");
39
39
 
40
- const { installOpenEcoBins, resolveNpmBinDir } = require("./open-eco-bin");
40
+ const { installOpenEcoBins, recordCompatBin, resolveNpmBinDir } = require("./open-eco-bin");
41
41
 
42
42
  const PKG = require("../package.json");
43
43
  const REPO_ROOT = join(__dirname, "..");
@@ -327,6 +327,10 @@ function installCompatCommand() {
327
327
  log(`replaced existing zn-open-eco shim: ${replaced.join(", ")}`);
328
328
  }
329
329
  log(`installed zn-open-eco -> ${binDir}`);
330
+ // npm 11 does not run preuninstall. Recording the command in the installed
331
+ // package.json makes npm delete the shim itself. The published manifest
332
+ // stays without this bin, so an older zn-open-eco file does not block install.
333
+ recordCompatBin(REPO_ROOT);
330
334
  } catch (err) {
331
335
  warn(`zn-open-eco shim was not replaced: ${err.message}`);
332
336
  }
@@ -1,4 +1,4 @@
1
- const { existsSync, lstatSync, readFileSync, readlinkSync, rmSync, symlinkSync, writeFileSync } = require("node:fs");
1
+ const { chmodSync, existsSync, lstatSync, readFileSync, readlinkSync, rmSync, symlinkSync, writeFileSync } = require("node:fs");
2
2
  const { basename, dirname, join, relative } = require("node:path");
3
3
 
4
4
  const COMMAND = "zn-open-eco";
@@ -124,11 +124,32 @@ function installOpenEcoBins({ binDir, packageRoot, platform }) {
124
124
  }
125
125
  const dest = join(binDir, COMMAND);
126
126
  if (existsSync(dest)) replaced.push(dest);
127
+ makeLauncherExecutable(packageRoot);
127
128
  rmSync(dest, { force: true });
128
129
  symlinkSync(relPosix, dest);
129
130
  return replaced;
130
131
  }
131
132
 
133
+ function makeLauncherExecutable(packageRoot) {
134
+ chmodSync(join(packageRoot, LAUNCHER), 0o777 & ~process.umask());
135
+ }
136
+
137
+ const COMPAT_BIN = "scripts/run-open-eco.js";
138
+
139
+ function recordCompatBin(packageRoot) {
140
+ const pkgPath = join(packageRoot, "package.json");
141
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
142
+ if (!pkg.bin || typeof pkg.bin !== "object" || Array.isArray(pkg.bin)) {
143
+ pkg.bin = {};
144
+ }
145
+ if (pkg.bin[COMMAND] === COMPAT_BIN) {
146
+ return false;
147
+ }
148
+ pkg.bin[COMMAND] = COMPAT_BIN;
149
+ writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
150
+ return true;
151
+ }
152
+
132
153
  function removeOpenEcoBins({ binDir, packageRoot, platform }) {
133
154
  const relPosix = launcherRelative(binDir, packageRoot).split("\\").join("/");
134
155
  const removed = [];
@@ -144,6 +165,7 @@ function removeOpenEcoBins({ binDir, packageRoot, platform }) {
144
165
  module.exports = {
145
166
  installOpenEcoBins,
146
167
  isOurLauncher,
168
+ recordCompatBin,
147
169
  removeOpenEcoBins,
148
170
  renderWindowsShims,
149
171
  resolveNpmBinDir,