@vibeapi/api-helper 0.0.137 → 0.0.138
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 +1 -1
- package/dist/lib/auto-update.d.ts +0 -1
- package/dist/lib/auto-update.js +1 -1
- package/dist/locales/en_US.json +1 -1
- package/dist/locales/zh_CN.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ npmjs.com 无法访问时,从高速下载站启动:
|
|
|
29
29
|
npx --yes --registry https://npm.cnb.cool/vibeapi/npm/-/packages/ @vibeapi/cli@latest
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
全局安装的 `vibecli`
|
|
32
|
+
全局安装的 `vibecli` 每次启动先检查更新(检查失败时 10 分钟内不再检查),按 **高速下载站 → npmjs → npmmirror → Yarn registry** 的顺序查询和安装;有新版时自动升级,再重新执行当前命令。网络或权限出错时照常执行原命令:每个安装源最多等 45 秒,安装失败后 1 小时内不再重试。设置 `VIBECLI_DISABLE_AUTO_UPDATE=1` 可关闭启动时的更新。`npx @vibeapi/cli@latest` 由 npm 在 VibeCLI 启动前下载,所以第一次就下载失败时,请改用上面的高速下载站命令。
|
|
33
33
|
|
|
34
34
|
### 还没有安装编码工具
|
|
35
35
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type LocalPackageInfo, type UpdateCheckResult } from '../commands/update.js';
|
|
2
|
-
export declare const UPDATE_CHECK_INTERVAL_MS: number;
|
|
3
2
|
export declare const INSTALL_RETRY_INTERVAL_MS: number;
|
|
4
3
|
export declare const INSTALL_TIMEOUT_MS = 45000;
|
|
5
4
|
interface RunnerResult {
|
package/dist/lib/auto-update.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{chmodSync as e,existsSync as t,mkdirSync as r,readFileSync as n,renameSync as o,writeFileSync as s}from"fs";import{homedir as a}from"os";import{dirname as l,join as i,sep as u}from"path";import{spawnSync as c}from"child_process";import p from"chalk";import{checkForUpdate as d,
|
|
1
|
+
import{chmodSync as e,existsSync as t,mkdirSync as r,readFileSync as n,renameSync as o,writeFileSync as s}from"fs";import{homedir as a}from"os";import{dirname as l,join as i,sep as u}from"path";import{spawnSync as c}from"child_process";import p from"chalk";import{checkForUpdate as d,readLocalPackage as m,UPDATE_SOURCES as f}from"../commands/update.js";import{i18n as _}from"./i18n.js";import{isColorEnabled as h}from"./runtime-options.js";import{logger as g}from"../utils/logger.js";import{isHelpRequest as x}from"./cli-help.js";import{brand as v,brandEnvName as y}from"./brand.js";export const INSTALL_RETRY_INTERVAL_MS=36e5;export const INSTALL_TIMEOUT_MS=45e3;function k(e,t){return h()?e(t):t}export function resolveUpdateCachePath(e=process.env){const t=e[y("CONFIG_DIR")]?.trim();if(t)return i(t,"update-state.json");const r=e[y("TEST_HOME")]?.trim();return i(r||a(),v().configDirName,"update-state.json")}export function isGlobalPackageInstall(e){return e.split(u).includes("node_modules")}export function isNpxExecution(e=process.env){return"exec"===e.npm_command||"npx"===e.npm_lifecycle_event}export function isPnpmGlobalInstall(e){return e.includes(`${u}.pnpm${u}`)||e.includes(`${u}pnpm${u}global${u}`)}export function resolveNpmGlobalPrefix(e){const t=`${u}node_modules${u}`,r=e.indexOf(t);if(r<0)return null;const n=e.slice(0,r);return n.endsWith(`${u}lib`)?l(n):n}export function shouldSkipStartupUpdate(e,t=process.env){return"1"===t[y("SKIP_AUTO_UPDATE")]||"1"===t[y("DISABLE_AUTO_UPDATE")]||(!(!["--json","--non-interactive","--dry-run","--help","-h","--version","-v"].some(t=>e.includes(t))&&!x(e))||e.includes("update")||e.includes("completion"))}function S(t,n,a,i,u){try{r(l(t),{recursive:!0,mode:448});const c=`${t}.tmp-${process.pid}`,p={package_name:n,checked_at:a,latest:i.latest,source:i.source,registry:i.registry,errors:i.errors,...void 0===u?{}:{install_attempted_at:u,install_attempted_version:i.latest||void 0}};s(c,JSON.stringify(p),{encoding:"utf-8",mode:384}),o(c,t),e(t,384)}catch(e){g.warn("Failed to persist update check cache:",e)}}export function windowsShellCommand(e,t){return[e,...t.map(e=>`"${e}"`)].join(" ")}const $=(e,t)=>{const r={stdio:"inherit",timeout:45e3,killSignal:"SIGTERM"};return"win32"===process.platform?c(windowsShellCommand(e,t),{...r,shell:!0}):c(e,t,r)},P=(e,t)=>c(process.execPath,[process.argv[1],...e],{stdio:"inherit",env:t});export async function runStartupUpdate(e,r={}){const o=r.env||process.env,s=r.localPackage||m(),a=r.globalInstall??isGlobalPackageInstall(s.root),l=r.npx??isNpxExecution(o);if(!a||l||shouldSkipStartupUpdate(e,o))return{status:"skipped",handled:!1,source:null};const i=r.now??Date.now(),u=r.cachePath||resolveUpdateCachePath(o),c=function(e,r){try{if(!t(e))return null;const o=JSON.parse(n(e,"utf-8"));return o.package_name===r.name&&Number.isFinite(o.checked_at)?o:null}catch{return null}}(u,s);let h=function(e,t,r){if(!e||e.latest||r-e.checked_at>=6e5)return null;const n=Array.isArray(e.errors)?e.errors:[];return{current:t.version,latest:null,up_to_date:null,source:e.source,registry:e.registry,errors:n,error:n.map(e=>`${e.source}: ${e.error}`).join("; ")||"unknown"}}(c,s,i),g=null;if(h||(h=await d({localPackage:s,fetchFn:r.fetchFn}),h.latest&&c?.install_attempted_version===h.latest&&Number.isFinite(c.install_attempted_at)&&(g=c.install_attempted_at),S(u,s.name,i,h,g??void 0)),!h.latest)return{status:"unavailable",handled:!1,source:null};if(h.up_to_date)return{status:"current",handled:!1,source:h.source};if(null!==g&&i-g<36e5)return{status:"update_failed",handled:!1,source:h.source};const x=r.output||console.log,v=r.errorOutput||console.error,b=r.installRunner||$,w=isPnpmGlobalInstall(s.root),I=w?"win32"===process.platform?"pnpm.cmd":"pnpm":"win32"===process.platform?"npm.cmd":"npm",T=w?null:resolveNpmGlobalPrefix(s.root);x(k(p.cyan,_.t("update.auto_installing",{version:h.latest})));let N=null,A="unknown";for(const e of f.map(e=>e.registry)){const t=b(I,w?["add","--global",`${s.name}@${h.latest}`,"--registry",e]:["install","--global",...T?["--prefix",T]:[],`${s.name}@${h.latest}`,"--registry",e,"--no-audit","--no-fund","--fetch-timeout=15000","--fetch-retries=1","--fetch-retry-mintimeout=1000","--fetch-retry-maxtimeout=3000"]);if(0===t.status){N=e;break}A=t.error?.message||`exit ${t.status??"unknown"}`}if(!N)return S(u,s.name,i,h,i),v(k(p.yellow,_.t("update.auto_failed",{error:A}))),{status:"update_failed",handled:!1,source:h.source};x(k(p.green,_.t("update.auto_installed",{version:h.latest})));const E=(r.reexecRunner||P)(e,{...o,[y("SKIP_AUTO_UPDATE")]:"1"});return E.error?(v(k(p.yellow,_.t("update.reexec_failed",{error:E.error.message}))),{status:"update_failed",handled:!1,source:h.source}):(process.exitCode=E.status??1,{status:"reexecuted",handled:!0,source:h.source})}
|
package/dist/locales/en_US.json
CHANGED
|
@@ -874,7 +874,7 @@
|
|
|
874
874
|
},
|
|
875
875
|
"update": {
|
|
876
876
|
"summary": "Check for a newer {{product}}",
|
|
877
|
-
"description": "Checks {{updateSources}} in turn and prints the install command when a newer version exists.\nA global install also checks at
|
|
877
|
+
"description": "Checks {{updateSources}} in turn and prints the install command when a newer version exists.\nA global install also checks at every start and, when there is a newer version, installs it and reruns the command.",
|
|
878
878
|
"ex": {
|
|
879
879
|
"check": "Check for a new version",
|
|
880
880
|
"json": "Print JSON"
|
package/dist/locales/zh_CN.json
CHANGED
|
@@ -874,7 +874,7 @@
|
|
|
874
874
|
},
|
|
875
875
|
"update": {
|
|
876
876
|
"summary": "检查 {{product}} 是否有新版本",
|
|
877
|
-
"description": "依次查询这些来源:{{updateSources}}。有新版本时给出安装命令。\n全局安装的 {{product}}
|
|
877
|
+
"description": "依次查询这些来源:{{updateSources}}。有新版本时给出安装命令。\n全局安装的 {{product}} 每次启动时也会检查,有新版本时自动安装并重新运行当前命令。",
|
|
878
878
|
"ex": {
|
|
879
879
|
"check": "检查新版本",
|
|
880
880
|
"json": "输出 JSON"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeapi/api-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.138",
|
|
4
4
|
"description": "CLI tool for managing AI coding assistants (Claude Code, Codex, OpenClaw, Hermes, AtomCode, Grok Build) with one unified config",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|