grix-connector 1.1.4 → 1.1.6
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.
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import{execFile as p}from"node:child_process";import{existsSync as l,readFileSync as f}from"node:fs";import{join as i}from"node:path";import{promisify as h}from"node:util";import{detectPlatformOS as c}from"./registry.js";const r=h(p),o=5e3;async function V(){const t=c(),n=process.arch,e=process.env.SHELL??process.env.ComSpec??null,s=!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.JENKINS_URL),u=w(),[a,m,d]=await Promise.all([y(t),g(),v()]);return{platform:t,osVersion:a,arch:n,shell:e,nodeVersion:m,npmVersion:d,isDocker:u,isCI:s}}function C(t){const n=[`Platform: ${t.platform} (${t.osVersion})`,`Arch: ${t.arch}`,`Shell: ${t.shell??"unknown"}`,`Node.js: ${t.nodeVersion??"not installed"}`,`npm: ${t.npmVersion??"not installed"}`];return t.isDocker&&n.push("Running in: Docker container"),t.isCI&&n.push("CI environment: yes"),n.join(`
|
|
2
2
|
`)}function I(t){return t.platform==="windows"?{supported:!0}:t.platform==="macos"?t.shell?{supported:!0}:{supported:!1,reason:"No SHELL environment variable detected"}:t.platform==="linux"?t.shell?{supported:!0}:{supported:!1,reason:"No SHELL environment variable detected"}:{supported:!0}}function w(){if(l("/.dockerenv"))return!0;try{const t=f("/proc/1/cgroup","utf-8");if(t.includes("/docker/")||t.includes("/kubepods")||t.includes("containerd"))return!0}catch{}return!1}async function y(t){try{if(t==="macos"){const{stdout:n}=await r("sw_vers",["-productVersion"],{timeout:o,encoding:"utf-8"});return`macOS ${n.trim()}`}if(t==="linux"){try{const{stdout:n}=await r("sh",["-c",`cat /etc/os-release 2>/dev/null | grep PRETTY_NAME | cut -d= -f2 | tr -d '"'`],{timeout:o,encoding:"utf-8"}),e=n.trim();if(e)return e}catch{}try{const{stdout:n}=await r("uname",["-sr"],{timeout:o,encoding:"utf-8"});return n.trim()}catch{}return"Linux (unknown distro)"}if(t==="windows"){const{stdout:n}=await r("cmd.exe",["/c","ver"],{timeout:o,encoding:"utf-8"});return n.trim()}}catch{}return`${t} (version unknown)`}async function g(){try{const{stdout:t}=await r("node",["--version"],{timeout:o,encoding:"utf-8"});return t.trim().replace(/^v/,"")}catch{return null}}async function v(){if(c()==="windows"){const n=["npm",i(process.env.ProgramFiles||"C:\\Program Files","nodejs","npm.cmd"),i(process.env.APPDATA||"","npm","npm.cmd")];try{const{stdout:e}=await r("where.exe",["node"],{timeout:o,encoding:"utf-8"}),s=i(e.trim().split(`
|
|
3
|
-
`)[0],"..");n.push(i(s,"npm.cmd"))}catch{}for(const e of n)try{const{stdout:s}=await r(
|
|
3
|
+
`)[0],"..");n.push(i(s,"npm.cmd"))}catch{}for(const e of n)try{const{stdout:s}=await r("cmd.exe",["/c",e,"--version"],{timeout:o,encoding:"utf-8"});return s.trim()}catch{}return null}try{const{stdout:n}=await r("npm",["--version"],{timeout:o,encoding:"utf-8"});return n.trim()}catch{return null}}export{V as detectEnvironment,C as formatEnvironmentInfo,I as isEnvironmentSupported};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{execFile as
|
|
2
|
-
${
|
|
1
|
+
import{execFile as f}from"node:child_process";import{promisify as y}from"node:util";import{log as p}from"../log/logger.js";import{probeUrls as h}from"./speed-test.js";const b=y(f),w=1e4,c=[{id:"official",label:"npm \u5B98\u65B9",url:"https://registry.npmjs.org"},{id:"npmmirror",label:"npmmirror (\u6DD8\u5B9D\u955C\u50CF)",url:"https://registry.npmmirror.com"}];async function R(){const n=await h(c.map(r=>({url:r.url,label:r.label})),5e3),e=[];for(const r of n)if(r.reachable){const i=c.find(o=>o.url===r.url);i&&e.push(i)}for(const r of n)if(!r.reachable){const i=c.find(o=>o.url===r.url);i&&!e.includes(i)&&e.push(i)}for(const r of c)e.includes(r)||e.push(r);return e}async function N(){try{const{stdout:n}=await b("npm",["config","get","registry"],{timeout:w,encoding:"utf-8"});return n.trim()}catch{return"https://registry.npmjs.org"}}async function O(n,e,r){const i=await R();if(i.length===0)throw new Error("All npm registries are unreachable. Check your network connection.");let o="";for(const l of i)try{return p.info("installer",`npm install ${n} using ${l.label} (${l.url})`),{output:await T(n,l.url,e,r),registry:l.label}}catch(s){const t=s instanceof Error?s.message:String(s);if(o=t,p.info("installer",`${l.label} failed: ${t.slice(0,200)}`),!(t.includes("ECONNRESET")||t.includes("ETIMEDOUT")||t.includes("ECONNREFUSED")||t.includes("ENOTFOUND")||t.includes("network")||t.includes("fetch failed")||t.includes("404")||t.includes("ERR_SOCKET_TIMEOUT")||t.includes("getaddrinfo")))throw s}throw new Error(`npm install failed on all registries. Last error: ${o}`)}function T(n,e,r,i){return new Promise((o,l)=>{const s=["install","-g",n,"--registry",e,"--prefer-online","--no-audit","--no-fund"],t=process.platform==="win32",a=t?"cmd.exe":"npm",g=t?["/c","npm",...s]:s;f(a,g,{timeout:r,maxBuffer:i},(u,d,m)=>{if(u){const E=m?.trim()||u.message;l(new Error(E));return}o(`${d??""}
|
|
2
|
+
${m??""}`.trim())})})}function M(n){return c.map(e=>({label:e.label,command:`npm install -g ${n} --registry ${e.url}`}))}export{c as NPM_REGISTRIES,N as getCurrentRegistry,M as getMirrorInstallCommands,O as npmInstallWithMirror,R as probeRegistries};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import{execFile as h}from"node:child_process";import{join as l}from"node:path";import{promisify as v}from"node:util";import{log as o}from"../log/logger.js";const u=v(h),m=5e3;function f(e){const t=e.replace(/^[^0-9]*/,"").split(".");return[parseInt(t[0]??"0",10)||0,parseInt(t[1]??"0",10)||0]}function g(e,n){const[t,r]=f(e),[c,i]=f(n);return t>c||t===c&&r>=i}async function s(e,n=["--version"]){try{const{stdout:t}=await u(e,n,{timeout:m,encoding:"utf-8"});return{found:!0,version:(t||"").trim().split(`
|
|
2
2
|
`)[0]?.trim()||null}}catch{return{found:!1,version:null}}}async function w(){const e=await s("node",["--version"]);return e.version?{found:!0,version:e.version.replace(/^v/,"")}:e}async function b(){if(process.platform==="win32"){o.info("preflight","[npm-detect] Starting Windows npm detection");const e=["npm",l(process.env.ProgramFiles||"C:\\Program Files","nodejs","npm.cmd"),l(process.env.APPDATA||"","npm","npm.cmd")];try{o.info("preflight","[npm-detect] Trying to locate node.exe via where.exe");const{stdout:n}=await u("where.exe",["node"],{timeout:m,encoding:"utf-8"}),t=l(n.trim().split(`
|
|
3
|
-
`)[0],".."),r=l(t,"npm.cmd");e.push(r),o.info("preflight",`[npm-detect] Inferred npm path from node: ${r}`)}catch(n){o.warn("preflight",`[npm-detect] Failed to locate node.exe: ${n instanceof Error?n.message:String(n)}`)}o.info("preflight",`[npm-detect] Will try ${e.length} paths: ${e.join(", ")}`);for(const n of e)try{o.info("preflight",`[npm-detect] Trying: ${n}`);const{stdout:t}=await u(
|
|
3
|
+
`)[0],".."),r=l(t,"npm.cmd");e.push(r),o.info("preflight",`[npm-detect] Inferred npm path from node: ${r}`)}catch(n){o.warn("preflight",`[npm-detect] Failed to locate node.exe: ${n instanceof Error?n.message:String(n)}`)}o.info("preflight",`[npm-detect] Will try ${e.length} paths: ${e.join(", ")}`);for(const n of e)try{o.info("preflight",`[npm-detect] Trying: ${n}`);const{stdout:t}=await u("cmd.exe",["/c",n,"--version"],{timeout:m,encoding:"utf-8"}),r=t.trim();return o.info("preflight",`[npm-detect] SUCCESS at ${n}, version: ${r}`),{found:!0,version:r}}catch(t){o.warn("preflight",`[npm-detect] Failed at ${n}: ${t instanceof Error?t.message:String(t)}`)}return o.error("preflight","[npm-detect] All paths failed, npm not found"),{found:!1,version:null}}return s("npm",["--version"])}async function y(){const e=await s("curl",["--version"]);return e.version?{found:!0,version:e.version.split(" ")[0]?.trim()??null}:e}async function P(){const e=await s("gh",["--version"]);return e.version?{found:!0,version:e.version.match(/(\d+\.\d+\.\d+)/)?.[1]??e.version}:e}async function x(){const e=await s("brew",["--version"]);return e.version?{found:!0,version:e.version.match(/(\d+\.\d+\.\d+)/)?.[1]??e.version}:e}function V(e){return[{id:"node",label:"Node.js",minVersion:"18.0",detect:w},{id:"npm",label:"npm",minVersion:"9.0",detect:b},{id:"curl",label:"curl",minVersion:null,detect:y},{id:"gh",label:"GitHub CLI (gh)",minVersion:null,detect:P},...e!=="windows"?[{id:"brew",label:"Homebrew",minVersion:null,detect:x}]:[]]}async function k(e,n){const r=V(n).find(p=>p.id===e);if(!r)return{id:e,label:e,met:!1,version:null,minVersion:null,autoInstallable:!1};const{found:c,version:i}=await r.detect();let a=c;a&&r.minVersion&&i&&(a=g(i,r.minVersion));const d=C(e,n);return{id:e,label:r.label,met:a,version:i,minVersion:r.minVersion,autoInstallable:a?!1:d}}async function A(e,n){return await Promise.all(e.map(r=>k(r,n)))}function F(e){return e.every(n=>n.met)}function M(e){return e.filter(n=>!n.met)}function C(e,n){switch(e){case"node":case"npm":return!0;case"curl":return!0;case"gh":return!0;case"brew":return n==="macos";default:return!1}}export{F as allPrerequisitesMet,k as checkPrerequisite,A as checkPrerequisites,M as getMissingPrerequisites};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grix-connector",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "Connect local AI coding agents (Claude, Codex, Gemini, Qwen, DeepSeek, Cursor, OpenCode, Pi, OpenHuman, Reasonix) to the Grix scheduling platform. Also serves as an OpenClaw plugin for Grix channel transport.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|