@gruum/cli 0.1.13 → 0.1.14
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/gruum.mjs +3 -3
- package/package.json +1 -1
package/gruum.mjs
CHANGED
|
@@ -57,7 +57,7 @@ Live URL for this repo.
|
|
|
57
57
|
For example: ${Ec} or ${e}.
|
|
58
58
|
You may not use wildcards.
|
|
59
59
|
|
|
60
|
-
URL: `}function so(e){let t=/https:\/\/[^\s"'<>)\]]+/gi;for(let n of e.matchAll(t)){let s;try{s=new URL(n[0])}catch{continue}let r=s.hostname.toLowerCase();if(!(!r.includes(".")||r.includes("*"))&&!(r==="localhost"||r==="127.0.0.1")&&!Ic.test(r))return`https://${r}`}return null}function jc(e){let t=e.toLowerCase().replace(/:\d+$/,"");return t==="localhost"||t==="127.0.0.1"}function ro(e){if(typeof e!="string")return{error:"Enter a live URL."};let t=e.trim();if(!t)return{error:"Enter a live URL."};if(t.includes("*"))return{error:"You may not use wildcards."};let n=Pc(t);return n
|
|
60
|
+
URL: `}function so(e){let t=/https:\/\/[^\s"'<>)\]]+/gi;for(let n of e.matchAll(t)){let s;try{s=new URL(n[0])}catch{continue}let r=s.hostname.toLowerCase();if(!(!r.includes(".")||r.includes("*"))&&!(r==="localhost"||r==="127.0.0.1")&&!Ic.test(r))return`https://${r}`}return null}function jc(e){let t=e.toLowerCase().replace(/:\d+$/,"");return t==="localhost"||t==="127.0.0.1"}function ro(e){if(typeof e!="string")return{error:"Enter a live URL."};let t=e.trim();if(!t)return{error:"Enter a live URL."};if(t.includes("*"))return{error:"You may not use wildcards."};let n=Pc(t);if(n)return n;let s=/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:`https://${t}`;return eo(s)}function Pc(e){let t=/^https?:\/\//i.test(e)?e:`http://${e}`,n;try{n=new URL(t)}catch{return null}let s=n.hostname.toLowerCase();if(s!=="localhost"&&s!=="127.0.0.1")return null;if(n.username||n.password)return{error:"That doesn\u2019t look like a URL."};let r=n.port;return{value:r&&r!=="80"&&r!=="443"?`${s}:${r}`:s}}function oo(e){return jc(e)?`http://${e}`:`https://${e}`}function io(e,t){let n=e.filter(r=>r.workspaces.length>0);if(n.length===0)return{step:"none"};if(t){let r=n.find(o=>o.id===t);if(!r)return{step:"none"};if(r.workspaces.length===1){let o=r.workspaces[0];return{step:"use",workspaceId:o.id,orgName:r.name,workspaceName:o.name}}return{step:"workspace",orgId:r.id,orgName:r.name,workspaces:r.workspaces}}if(n.reduce((r,o)=>r+o.workspaces.length,0)===1){let r=n[0],o=r.workspaces[0];return{step:"use",workspaceId:o.id,orgName:r.name,workspaceName:o.name}}if(n.length===1){let r=n[0];return{step:"workspace",orgId:r.id,orgName:r.name,workspaces:r.workspaces}}return{step:"org",orgs:n.map(r=>({id:r.id,name:r.name}))}}var ao="No project for this repo found. Creating\u2026";function lo(e,t){let n=t.workspaceId;if(n)for(let s of e){let r=s.workspaces.find(o=>o.id===n);if(r)return`${s.name} / ${r.name} / ${t.name}`}return t.name}function co(e){let t=e.length===1?`Use ${e[0]}, or create a new one.`:"This repo is already in more than one project. Use one, or create a new one.",s=[...e,"Create a new one"].map((r,o)=>` ${o+1} ${r}`);return`
|
|
61
61
|
${t}
|
|
62
62
|
${s.join(`
|
|
63
63
|
`)}
|
|
@@ -82,7 +82,7 @@ ${i}`)}function Uc(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(
|
|
|
82
82
|
`),null;let n=await t.json();return Uc(n.orgs)}async function zc(e,t,n,s){let r=s??await Ao(e);if(!r)return null;let o=null;for(;;){let i=io(r,o);if(i.step==="none")return{workspaceId:"",label:""};if(i.step==="use")return{workspaceId:i.workspaceId,label:`${i.orgName} / ${i.workspaceName}`};if(!t)return process.stderr.write("gruum: this account has more than one workspace. Run `npx @gruum/cli check` in a terminal and choose where the project should live.\n"),null;if(i.step==="org"){let h=await Ro(go("This account has more than one organization.",i.orgs,"organization"),i.orgs);o=i.orgs[h].id;continue}let a=uo(n),l=await So(po(i.orgName,i.workspaces,a),h=>fo(h,i.workspaces),`gruum: enter C, or one of the numbers.
|
|
83
83
|
`);if(l!=="create"){let h=i.workspaces[l];return{workspaceId:h.id,label:`${i.orgName} / ${h.name}`}}let c=await Z(e,"/api/v2/cli/workspaces",{method:"POST",body:JSON.stringify({orgId:i.orgId,name:a})}),u=await c.json().catch(()=>({})),f=u.workspace?.id,m=typeof u.workspace?.name=="string"?u.workspace.name:a;if(!c.ok||typeof f!="string"){process.stderr.write(`gruum: ${u.error||`couldn't create that workspace (${c.status})`}
|
|
84
84
|
`);continue}return{workspaceId:f,label:`${i.orgName} / ${m}`}}}function Wc(e,t){let n=vt(e);for(let s of n.files.values()){let r=so(s);if(r)return r}return to(t)}async function Gc(e,t){let n=no(Wc(e,t)),s=xo({input:process.stdin,output:process.stderr});try{for(;;){let r=(await s.question(n)).trim(),o=ro(r);if("error"in o){process.stderr.write(`gruum: ${o.error}
|
|
85
|
-
`);continue}return
|
|
85
|
+
`);continue}return r}}finally{s.close()}}async function _o(){let e=`Cursor on ${Nc()}`,t=await Z(null,"/api/cli/pair/start",{method:"POST",body:JSON.stringify({label:e})});if(!t.ok)return process.stderr.write(`gruum: couldn't start sign-in (${t.status}). Is Gruum running at ${Le}?
|
|
86
86
|
`),1;let n=await t.json(),s=`${Le}/extension/connect?code=${encodeURIComponent(n.userCode)}`;process.stdout.write(`Sign in to Gruum to connect this CLI.
|
|
87
87
|
|
|
88
88
|
Code: ${n.userCode}
|
|
@@ -107,7 +107,7 @@ ${w}
|
|
|
107
107
|
`)}catch{process.stderr.write(`gruum: couldn't reach Gruum to report this check. The local result still stands.
|
|
108
108
|
`)}}async function jo(e,t,n){let s=await On(e);if(!s)return{ok:!1,text:"Sign in with gruum login before requesting an exception."};let r=_t(e.repoDir);if(!r)return{ok:!1,text:"This folder is not on a named git branch."};try{let o=await Z(s.credentials,`/api/v2/cli/projects/${encodeURIComponent(s.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"request",concept:"button",branch:r,commit:vo(e.repoDir),reason:n,item:t})}),i=await o.json().catch(()=>({}));if(!o.ok)return{ok:!1,text:i.error||`Request failed (${o.status}).`};let a=i.reviewUrl?`${Pn(s.credentials)}${i.reviewUrl}`:"",l=i.created?`Exception request ${i.id} is pending review.`:`An exception for this change is already pending (${i.id}).`;return{ok:!0,text:a?`${l}
|
|
109
109
|
${a}`:l}}catch{return{ok:!1,text:"Couldn't reach Gruum to request an exception."}}}async function Po(e,t){let n=await On(e);if(!n)return{ok:!1,text:"Sign in with gruum login to see exception status."};let s=_t(e.repoDir);try{let r=await Z(n.credentials,`/api/v2/cli/projects/${encodeURIComponent(n.project.id)}/drift?concept=button&branch=${encodeURIComponent(s)}`);if(!r.ok)return{ok:!1,text:`Couldn't load exceptions (${r.status}).`};let o=await r.json(),i=Array.isArray(o.requests)?o.requests:[],a=t?i.filter(l=>l.id===t):i;return a.length===0?{ok:!0,text:t?`No exception request ${t} on ${s||"this branch"}.`:`No exception requests on ${s||"this branch"}.`}:{ok:!0,text:a.map(l=>`${l.id} ${l.status} ${l.title} (${l.branch})`).join(`
|
|
110
|
-
`)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var Pt="0.1.
|
|
110
|
+
`)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var Pt="0.1.14",Lo=`gruum ${Pt}: keep buttons on the Gruum spec
|
|
111
111
|
|
|
112
112
|
Run it as \`npx @gruum/cli <command>\`.
|
|
113
113
|
|