@zhuan-ai/zhuanspec 2.11.13 → 2.11.15
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/dist/core/hooks/init.js +13 -3
- package/package.json +1 -1
package/dist/core/hooks/init.js
CHANGED
|
@@ -18,9 +18,19 @@ import { resolveZhuanSpecRoot } from '../../utils/resolve-root.js';
|
|
|
18
18
|
const execAsync = promisify(exec);
|
|
19
19
|
async function checkVersionUpdate() {
|
|
20
20
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
// 当前版本:以用户实际使用的全局 CLI 为准(`zhuanspec --version`),避免受 hook 执行路径
|
|
22
|
+
// (本地开发目录 / npm link / 多份安装)干扰。
|
|
23
|
+
// 兜底:当全局 CLI 不可达时,降级读取 hook 自身 package.json。
|
|
24
|
+
let current = '';
|
|
25
|
+
try {
|
|
26
|
+
const { stdout: verOut } = await execAsync('zhuanspec --version', { timeout: 3000 });
|
|
27
|
+
current = verOut.trim().replace(/^v/, '');
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
const pkgPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..', 'package.json');
|
|
31
|
+
const pkgContent = JSON.parse(await fs.promises.readFile(pkgPath, 'utf-8'));
|
|
32
|
+
current = pkgContent.version;
|
|
33
|
+
}
|
|
24
34
|
// 显式指定公共 npm registry,避免受用户本地 registry 或私有源同步延迟影响
|
|
25
35
|
// --cache-min=0 强制绕过本地 metadata 缓存,确保拿到真正的 latest
|
|
26
36
|
const { stdout } = await execAsync('npm view @zhuan-ai/zhuanspec version --registry https://registry.npmjs.org/ --cache-min=0', { timeout: 5000 });
|