@raycast/api 1.88.3 → 1.88.4

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.
@@ -824,7 +824,7 @@ To automate this process, you have to authenticate with GitHub.
824
824
  First copy your one-time code: ${s.user_code}
825
825
  Press Enter to open github.com in your browser...`),process.stdin.setRawMode(!0),process.stdin.resume(),await new Promise(p=>process.stdin.once("data",y=>{let x=[...y];x.length>0&&x[0]===3&&(console.log("^C"),process.exit(1)),process.stdin.setRawMode(!1),p(void 0)})),NFe(s.verification_uri);let c=s.interval*1e3;for(;;){await new Promise(p=>setTimeout(p,c));try{let p=await Hg("https://github.com/login/oauth/access_token",{method:"POST",body:JSON.stringify({client_id:i,device_code:s.device_code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})});if(!p.error){oY("githubAccessToken",p.access_token);return}if(p.error!=="authorization_pending")throw new Error(p.error_description)}catch(p){throw new Error(`failed to get the access token (${p.message})`)}}}async function rPt(i,s){let c=$_("githubAccessToken"),p=await Hg(`https://api.github.com/repos/${i.owner.login}/${i.name}/forks`,{method:"POST",token:c,body:JSON.stringify({name:s,default_branch_only:!0})});for(let y=0;y<=30;y++){try{await Hg(`https://api.github.com/repos/${p.owner.login}/${p.name}/commits?per_page=1`,{token:c});break}catch(x){if(y===30)throw new Error(`fork not ready after 1min (${x.message})`)}await new Promise(x=>setTimeout(x,2e3))}return p}async function nPt(i){let s=$_("githubAccessToken");try{await Hg(`https://api.github.com/repos/${i.owner.login}/${i.name}/merge-upstream`,{method:"POST",token:s,body:JSON.stringify({branch:"main"})})}catch(c){throw new Error(`could not get the latest changes. Head to https://github.com/${i.owner.login}/${i.name}, select the Sync fork dropdown menu above the list of files, and then click Update branch. Once you've done that, try running this command again
826
826
 
827
- Error: ${c.message}`)}}async function iPt(i){let s=$_("githubAccessToken");await Hg(`https://api.github.com/repos/${i.owner.login}/${i.name}`,{method:"POST",token:s,body:JSON.stringify({delete_branch_on_merge:"true"})})}function sPt(i,s){return q6t(`https://oauth2:${$_("githubAccessToken")}@github.com/${i.owner.login}/${i.name}`,s)}function R9e(i,s){return J6t(i,`https://oauth2:${$_("githubAccessToken")}@github.com/${s.owner.login}/${s.name}`)}async function aPt(i,s,c){let p=`"\\"name\\": \\"${s}\\"" "\\"author\\": \\"${c}\\"" repo:raycast/extensions in:file path:extensions extension:json`,y=$_("githubAccessToken"),w=(await Hg(`https://api.github.com/search/code?q=${encodeURIComponent(p)}&per_page=3`,{token:y})).items.filter(L=>L.name==="package.json");if(w.length===0)return O9e.default.join("extensions",s);if(w.length>1)throw new Error(`found more than one extension with name ${s}`);return O9e.default.dirname(w[0].path)}async function oPt(i){let s=`type:pr repo:raycast/extensions ${i} is:merged`,c=$_("githubAccessToken");return(await Hg(`https://api.github.com/search/issues?q=${encodeURIComponent(s)}&per_page=1`,{token:c})).items.length>0}async function cPt(i,s,c){return(await Hg(`https://api.github.com/repos/${i.owner.login}/${i.name}/pulls?base=main&head=${s.owner.login}:${encodeURIComponent(c)}`,{token:$_("githubAccessToken")})).find(y=>y.head.ref===c&&y.head.user.login===s.owner.login)}function lPt(i,s,c,p,y){return Hg(`https://api.github.com/repos/${i.owner.login}/${i.name}/pulls`,{method:"POST",token:$_("githubAccessToken"),body:JSON.stringify({title:p,head:`${s.owner.login}:${c}`,base:"main",body:y,maintainer_can_modify:!0})})}var L9e=Da(require("path")),iJ=Da(require("fs"));function ahe(i,s,c=[".git",".github","node_modules","raycast-env.d.ts",".raycast-swift-build",".swiftpm","compiled_raycast_swift"]){let p=iJ.default.readdirSync(i);try{iJ.default.mkdirSync(s,{recursive:!0})}catch{}for(let y of p){let x=L9e.default.join(i,y),w=L9e.default.join(s,y);if(iJ.default.lstatSync(x).isDirectory()){if(!c.includes(y)){try{iJ.default.mkdirSync(w,{recursive:!0})}catch{}ahe(x,w,c)}}else c.includes(y)||iJ.default.copyFileSync(x,w)}}var M9e=Da(require("path")),fPt=Da(require("fs"));var uPt=!1;async function j9e(i){if(!await ehe())throw new Error("please create a git repository first (git init)");if(await mX())throw new Error("please commit or discard your uncommited changes first (git commit -a -m 'your changes')");await tPt();let s={owner:{login:"raycast"},name:"extensions"},c=M9e.default.join(cY(),"public-extensions-fork"),p=`ext/${i.name}`,y="",x,w=await Vg("getting fork",async()=>{try{x=await rPt(s,"raycast-extensions"),await nPt(x),await iPt(x)}catch(L){throw new Error(`fork extensions repo: ${L.message}`)}},{printError:!1});if(w){if(w.message.includes("not authorized \u2013 please log in first using `npx ray login`")){if(uPt)throw new Error("fork extensions repo: not authorized");return uPt=!0,oY("githubAccessToken",void 0),j9e(i)}throw w}else x=x;if(!fPt.default.existsSync(c)){let L=await Vg("cloning repo",async()=>{await sPt(x,c)},{printError:!1});if(L)throw L}if(Z2(c),await R9e("origin",x),await R9e("upstream",s),w=await Vg("preparing clone",async()=>{let L=await aPt(s,i.name,i.author);y=M9e.default.join(c,L),Z2(void 0);let $=await D9e("user.name"),ne=await D9e("user.email");if(Z2(c),await C9e("user.name",$),await C9e("user.email",ne),await W6t(L),await _I("main"),await w9e("upstream","main"),await z6t("upstream/main"),await nhe(p)){await rhe(p),await w9e("origin",p);let pe=await the();await oPt(pe)&&(await U6t(p),await rhe(p))}else await E9e(p),await rhe(p)},{printError:!1}),w)throw w;return{upstream:s,fork:x,clonePath:c,extensionPathInClone:y,branch:p}}async function dPt(i){let{upstream:s,fork:c,clonePath:p,extensionPathInClone:y,branch:x}=await j9e(i),w=pPt.default.existsSync(_Pt.default.join(y,"package.json")),{latestPublishTag:L,latestPullTag:$}=Y6t(x);Z2(p);let ne=await Vg("checking for new contributions",async()=>{if(w){if(await nhe(x)){if(!await $6t(x))throw new Error("some contributions are available. Pull them using `npx @raycast/api@latest pull-contributions`");return}if(_I("main"),!(await ihe($)&&!await V6t(y,$))){Z2(void 0),await ihe(L)?await _I(L):await _I(M6t);try{if(ahe(y,process.cwd()),await mX())throw await G6t(),await _I(R6t),new Error("some contributions are available. Pull them using `npx @raycast/api@latest pull-contributions`")}finally{await _I(L6t)}}}});ne&&process.exit(1),Z2(p),_I(x),ne=await Vg("preparing extension",async()=>{if(ahe(process.cwd(),y),!await mX())throw Z2(p),k9e(x),Z2(void 0),A9e(L,"Used by the Ray CLI to track the latest commit that was published"),new Error("seems like there is nothing new to publish")}),ne&&process.exit(1),ne=await Vg("pushing extension",async()=>{await H6t(y,await B7r(i,w,p,L)),await k9e(x)}),ne&&process.exit(1),Z2(""),A9e(L,"Used by the Ray CLI to track the latest commit that was published"),ne=await Vg("opening PR",async()=>{let pe=await cPt(s,c,x);if(pe)return`
827
+ Error: ${c.message}`)}}async function iPt(i){let s=$_("githubAccessToken");await Hg(`https://api.github.com/repos/${i.owner.login}/${i.name}`,{method:"POST",token:s,body:JSON.stringify({delete_branch_on_merge:"true"})})}function sPt(i,s){return q6t(`https://oauth2:${$_("githubAccessToken")}@github.com/${i.owner.login}/${i.name}`,s)}function R9e(i,s){return J6t(i,`https://oauth2:${$_("githubAccessToken")}@github.com/${s.owner.login}/${s.name}`)}async function aPt(i,s,c){let p=`"\\"name\\": \\"${s}\\"" "\\"author\\": \\"${c}\\"" repo:raycast/extensions in:file path:extensions extension:json`,y=$_("githubAccessToken"),w=(await Hg(`https://api.github.com/search/code?q=${encodeURIComponent(p)}&per_page=3`,{token:y})).items.filter(L=>L.name==="package.json");if(w.length===0)return O9e.default.join("extensions",s);if(w.length>1)throw new Error(`found more than one extension with name ${s}`);return O9e.default.dirname(w[0].path)}async function oPt(i){let s=`type:pr repo:raycast/extensions ${i} is:merged`,c=$_("githubAccessToken");return(await Hg(`https://api.github.com/search/issues?q=${encodeURIComponent(s)}&per_page=1`,{token:c})).items.length>0}async function cPt(i,s,c){return(await Hg(`https://api.github.com/repos/${i.owner.login}/${i.name}/pulls?base=main&head=${s.owner.login}:${encodeURIComponent(c)}`,{token:$_("githubAccessToken")})).find(y=>y.head.ref===c&&y.head.user.login===s.owner.login)}function lPt(i,s,c,p,y){return Hg(`https://api.github.com/repos/${i.owner.login}/${i.name}/pulls`,{method:"POST",token:$_("githubAccessToken"),body:JSON.stringify({title:p,head:`${s.owner.login}:${c}`,base:"main",body:y,maintainer_can_modify:!0})})}var L9e=Da(require("path")),iJ=Da(require("fs"));function ahe(i,s,c=[".git",".github","node_modules","raycast-env.d.ts",".raycast-swift-build",".swiftpm","compiled_raycast_swift"]){let p=iJ.default.readdirSync(i);try{iJ.default.mkdirSync(s,{recursive:!0})}catch{}for(let y of p){let x=L9e.default.join(i,y),w=L9e.default.join(s,y);if(iJ.default.lstatSync(x).isDirectory()){if(!c.includes(y)){try{iJ.default.mkdirSync(w,{recursive:!0})}catch{}ahe(x,w,c)}}else c.includes(y)||iJ.default.copyFileSync(x,w)}}var M9e=Da(require("path")),fPt=Da(require("fs"));var uPt=!1;async function j9e(i){if(!await ehe())throw new Error("please create a git repository first (git init)");if(await mX())throw new Error("please commit or discard your uncommited changes first (git commit -a -m 'your changes')");await tPt();let s={owner:{login:"raycast"},name:"extensions"},c=M9e.default.join(cY(),"public-extensions-fork"),p=`ext/${i.name}`,y="",x,w=await Vg("getting fork",async()=>{try{x=await rPt(s,"raycast-extensions"),await nPt(x),await iPt(x)}catch(L){throw new Error(`fork extensions repo: ${L.message}`)}},{printError:!1});if(w){if(w.message.includes("not authorized \u2013 please log in first using `npx ray login`")){if(uPt)throw new Error("fork extensions repo: not authorized");return uPt=!0,oY("githubAccessToken",void 0),j9e(i)}throw w}else x=x;if(!fPt.default.existsSync(c)){let L=await Vg("cloning repo",async()=>{await sPt(x,c)},{printError:!1});if(L)throw L}if(Z2(c),await R9e("origin",x),await R9e("upstream",s),w=await Vg("preparing clone",async()=>{let L=await aPt(s,i.name,i.author);y=M9e.default.join(c,L),Z2(void 0);let $=await D9e("user.name"),ne=await D9e("user.email");if(Z2(c),await C9e("user.name",$),await C9e("user.email",ne),await W6t(L),await _I("main"),await w9e("upstream","main"),await z6t("upstream/main"),await nhe(p)){await rhe(p),await w9e("origin",p);let pe=await the();await oPt(pe)&&(await U6t(p),await rhe(p))}else await E9e(p),await rhe(p)},{printError:!1}),w)throw w;return{upstream:s,fork:x,clonePath:c,extensionPathInClone:y,branch:p}}async function dPt(i){let{upstream:s,fork:c,clonePath:p,extensionPathInClone:y,branch:x}=await j9e(i),w=pPt.default.existsSync(_Pt.default.join(y,"package.json")),{latestPublishTag:L,latestPullTag:$}=Y6t(x);Z2(p);let ne=await Vg("checking for new contributions",async()=>{if(w){if(await nhe(x)){if(!await $6t(x))throw new Error("some contributions are available. Pull them using `npx @raycast/api@latest pull-contributions`");return}if(await _I("main"),!(await ihe($)&&!await V6t(y,$))){Z2(void 0),await ihe(L)?await _I(L):await _I(M6t);try{if(ahe(y,process.cwd()),await mX())throw await G6t(),await _I(R6t),new Error("some contributions are available. Pull them using `npx @raycast/api@latest pull-contributions`")}finally{await _I(L6t)}}}});ne&&process.exit(1),Z2(p),await _I(x),ne=await Vg("preparing extension",async()=>{if(ahe(process.cwd(),y),!await mX())throw Z2(p),await k9e(x),Z2(void 0),await A9e(L,"Used by the Ray CLI to track the latest commit that was published"),new Error("seems like there is nothing new to publish")}),ne&&process.exit(1),ne=await Vg("pushing extension",async()=>{await H6t(y,await B7r(i,w,p,L)),await k9e(x)}),ne&&process.exit(1),Z2(void 0),await A9e(L,"Used by the Ray CLI to track the latest commit that was published"),ne=await Vg("opening PR",async()=>{let pe=await cPt(s,c,x);if(pe)return`
828
828
 
829
829
  \u{1F680} Your submission has been updated!
830
830