@greatstore/cli 0.2.6 → 0.2.7
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/CHANGELOG.md +5 -0
- package/dist/cli.js +7 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
All notable changes to `@greatstore/cli` are recorded here. The format
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/).
|
|
5
5
|
|
|
6
|
+
## 0.2.7 — 2026-10-15
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
- `apps push`, `publish`, `pull`, `build` and `release` exit with an error when any app fails, so scripts and CI see the failure.
|
|
10
|
+
|
|
6
11
|
## 0.2.6 — 2026-10-14
|
|
7
12
|
|
|
8
13
|
### Changed
|
package/dist/cli.js
CHANGED
|
@@ -20,7 +20,7 @@ p{color:#2c3a38}`,or=`<!doctype html>
|
|
|
20
20
|
h1{font-size:1.4rem;color:#a40000}code{background:#f4f4f4;padding:.1em .3em;border-radius:.2em}</style></head>
|
|
21
21
|
<body><h1>Sign-in failed.</h1>
|
|
22
22
|
<p>Return to your terminal for details.</p></body></html>`,X=class extends Error{constructor(t){super(t),this.name="LoopbackError"}};async function Se(e){let t=(e.generateState??ir)(),n=e.timeoutMs??300*1e3,r=e.openBrowser??(s=>ar(s,e.browserCmdEnv)),o=ht.createServer();try{await new Promise(c=>o.listen(0,"127.0.0.1",c));let s=o.address(),i=new URL(`${e.dashboardBaseUrl}/cli/authorize`);i.searchParams.set("port",String(s.port)),i.searchParams.set("state",t),e.requestedStore&&i.searchParams.set("store",e.requestedStore);let a=i.toString(),l=sr(o,t,n);return r(a),await l}finally{o.close()}}function sr(e,t,n){return new Promise((r,o)=>{let s=!1,i=l=>{s||(s=!0,l())},a=setTimeout(()=>{i(()=>o(new X("Sign-in timed out. Re-run `npx greatstore login`.")))},n);typeof a.unref=="function"&&a.unref(),e.on("request",(l,c)=>{let p=new URL(l.url??"/","http://127.0.0.1");if(p.pathname!==tr){c.writeHead(404,{"content-type":"text/plain"}),c.end("Not found");return}let u=p.searchParams,d=u.get("error"),j=u.get("error_description"),y=u.get("code");if(u.get("state")!==t){c.writeHead(400,{"content-type":"text/html"}),c.end(mt),clearTimeout(a),i(()=>o(new X("Sign-in didn't complete. Please try again.")));return}if(d||!y){c.writeHead(400,{"content-type":"text/html"}),c.end(mt),clearTimeout(a),i(()=>o(new X(j??"Sign-in failed. Please try again.")));return}c.writeHead(200,{"content-type":"text/html"}),c.end(or),clearTimeout(a);let we=u.get("store")?.trim();i(()=>r(we?{token:y,store:we}:{token:y}))})})}function ir(){return gt.randomBytes(16).toString("hex")}function ar(e,t){let r=t?.trim()??cr();if(r)try{let o;if(r==="start"){let s=`start "" "${e}"`;o=dt("cmd.exe",["/d","/s","/c",s],{stdio:"ignore",detached:!0,windowsVerbatimArguments:!0})}else o=dt(r,[e],{stdio:"ignore",detached:!0});o.on("error",()=>{}),o.unref()}catch{}}function cr(){switch(process.platform){case"darwin":return"open";case"win32":return"start";case"linux":return"xdg-open";default:return null}}import*as A from"fs";import*as ne from"os";import*as Ve from"path";var lr=".greatstore",ur="credentials.json";function be(e=ne.homedir()){return Ve.join(e,lr)}function Je(e=ne.homedir()){return Ve.join(be(e),ur)}function T(e=ne.homedir()){let t=Je(e),n;try{let r=A.statSync(t);if(process.platform!=="win32"){let o=r.mode&511;if(o&63)throw new Error(`Refusing to read ${t}: permissions are ${o.toString(8)} (should be 600). Run \`chmod 600 ${t}\`.`)}n=A.readFileSync(t,"utf8")}catch(r){if(pr(r))return null;throw r}try{let r=JSON.parse(n);return typeof r.access_token!="string"?null:r}catch{return null}}function xe(e,t=ne.homedir()){let n=be(t);if(A.mkdirSync(n,{recursive:!0,mode:448}),process.platform!=="win32")try{A.chmodSync(n,448)}catch{}let r=Je(t);A.writeFileSync(r,`${JSON.stringify(e,null,2)}
|
|
23
|
-
`,{mode:384}),process.platform!=="win32"&&A.chmodSync(r,384)}function yt(e=ne.homedir()){A.rmSync(Je(e),{force:!0})}function wt(e){let t=e.split(".");if(t.length!==3)throw new Error("Invalid JWT: expected three dot-separated segments");let n=t[1];if(!n)throw new Error("Invalid JWT: empty payload segment");let o=(n+"=".repeat((4-n.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),s=Buffer.from(o,"base64").toString("utf8");return JSON.parse(s)}function ve(e,t=Math.floor(Date.now()/1e3)){return e.expires_at<=t}function pr(e){return typeof e=="object"&&e!==null&&e.code==="ENOENT"}var O="0.2.
|
|
23
|
+
`,{mode:384}),process.platform!=="win32"&&A.chmodSync(r,384)}function yt(e=ne.homedir()){A.rmSync(Je(e),{force:!0})}function wt(e){let t=e.split(".");if(t.length!==3)throw new Error("Invalid JWT: expected three dot-separated segments");let n=t[1];if(!n)throw new Error("Invalid JWT: empty payload segment");let o=(n+"=".repeat((4-n.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),s=Buffer.from(o,"base64").toString("utf8");return JSON.parse(s)}function ve(e,t=Math.floor(Date.now()/1e3)){return e.expires_at<=t}function pr(e){return typeof e=="object"&&e!==null&&e.code==="ENOENT"}var O="0.2.7";var L=class extends Error{constructor(n,r,o){super(r);this.status=n;this.code=o;this.name="HttpError"}},N=class extends Error{constructor(t="Sign in first. Run `npx greatstore login`."){super(t),this.name="AuthRequiredError"}};function fr(e){let t;try{t=new URL(e)}catch{return}let n=t.pathname.split("/").filter(Boolean);if(n[1]==="admin"&&n[0])return n[0];let r=t.hostname.split(".")[0],o=new Set(["my","www","app","api","admin","localhost"]);if(t.hostname.includes(".")&&r&&!o.has(r))return r}function dr(e){let t=fr(e)??T()?.store;return t?`npx greatstore login --store ${t}`:"npx greatstore login"}var Ke=null;function vt(e){Ke=e}async function f(e,t={}){if(Ke!==null)return St(e,t,Ke);let n=()=>`Run \`${dr(e)}\`.`,r=T();if(!r)throw new N(`Sign in first. ${n()}`);if(ve(r))throw new N(`Session expired. ${n()}`);try{return await St(e,t,r.access_token)}catch(o){throw o instanceof L&&o.status===401?new N(`Session expired. ${n()}`):o}}async function St(e,t,n){let r={accept:"application/json",authorization:`Bearer ${n}`,"x-gs-cli-version":O,...t.headers??{}},o;if(t.multipart&&t.body!==void 0)throw new Error("request(): pass either `body` or `multipart`, not both");t.multipart?(o=t.multipart,delete r["content-type"]):t.body!==void 0&&(o=JSON.stringify(t.body),r["content-type"]="application/json");let s={method:t.method??"GET",headers:r};o!==void 0&&(s.body=o);let i=await fetch(e,s);if(i.status>=200&&i.status<300)return i.status===204?void 0:(i.headers.get("content-type")??"").includes("application/json")?await i.json():await i.text();let a=await i.text(),l={};try{l=JSON.parse(a)}catch{}let c=l.code??l.error,p=t.validationDetail&&i.status===400&&l.error?l.error:mr(i.status,c,l.detail);throw new L(i.status,p,l.code??l.error)}var kt=`This version of the GreatStore CLI is no longer supported. Run the latest one:
|
|
24
24
|
|
|
25
25
|
npx greatstore@latest <command>
|
|
26
26
|
|
|
@@ -172,6 +172,11 @@ Did you mean: ${i.join(", ")}?`:""))}if(typeof r!="string"){if(s.kind==="boolean
|
|
|
172
172
|
All notable changes to \`@greatstore/cli\` are recorded here. The format
|
|
173
173
|
follows [Keep a Changelog](https://keepachangelog.com/).
|
|
174
174
|
|
|
175
|
+
## 0.2.7 \u2014 2026-10-15
|
|
176
|
+
|
|
177
|
+
### Fixed
|
|
178
|
+
- \`apps push\`, \`publish\`, \`pull\`, \`build\` and \`release\` exit with an error when any app fails, so scripts and CI see the failure.
|
|
179
|
+
|
|
175
180
|
## 0.2.6 \u2014 2026-10-14
|
|
176
181
|
|
|
177
182
|
### Changed
|
|
@@ -807,7 +812,7 @@ Environment:
|
|
|
807
812
|
`);let n=Yn(Co);return n&&process.stdout.write(`${n}
|
|
808
813
|
`),0}if(m(t.flags,"help")||t.command==="help"||t.command===null){let n=t.command==="configure"?Ft(t.positional[0]):void 0;return process.stdout.write(n??Qn),0}if(t.command!==null&&Eo.has(t.command))return ot({...t,positional:[t.command,...t.positional]});switch(t.command){case"login":return await jt(t),0;case"logout":return At(),0;case"whoami":return Rt();case"switch":return _t(t.positional);case"apps":return ot(t);case"configure":return await qn(t),0;case"connectors":return await Xn(t),0;case"skill":return It(),0;default:return process.stderr.write(`Unknown command: ${t.command}
|
|
809
814
|
|
|
810
|
-
${Qn}`),1}}jo().then(e=>process.exit(e)).catch(e=>{e instanceof N?process.stderr.write(`${e.message}
|
|
815
|
+
${Qn}`),1}}jo().then(e=>process.exit(e||Number(process.exitCode??0))).catch(e=>{e instanceof N?process.stderr.write(`${e.message}
|
|
811
816
|
`):e instanceof L?process.stderr.write(`Error: ${e.message}
|
|
812
817
|
`):e instanceof H||e instanceof X?process.stderr.write(`Error: ${e.message}
|
|
813
818
|
`):e instanceof Error?process.stderr.write(`Error: ${e.message}
|