github-up 0.1.3 → 0.1.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.
Files changed (2) hide show
  1. package/dist/bin/cli.mjs +14 -14
  2. package/package.json +5 -5
package/dist/bin/cli.mjs CHANGED
@@ -1,26 +1,26 @@
1
1
  #!/usr/bin/env node
2
- import{argv as e,platform as t}from"node:process";import{ParseError as n,cli as r,command as i,flag as a,osc8 as o,packageRepositoryUrl as s}from"@kjanat/dreamcli";import{cyan as c}from"ansispeck/safe";import{createColors as l}from"ansispeck";import{spawn as u,spawnSync as d}from"node:child_process";import{existsSync as f,mkdtempSync as ee,readFileSync as te,rmSync as ne}from"node:fs";import{tmpdir as re}from"node:os";import{join as p,win32 as ie}from"node:path";import{setTimeout as m}from"node:timers/promises";import{createAdapter as ae}from"@kjanat/dreamcli/runtime";const h=[`github`,`downdetector`],g={github:`GitHub`,downdetector:`Downdetector`},_=[`actions`,`api`,`codespaces`,`copilot`,`git`,`issues`,`packages`,`pages`,`pr`,`webhooks`],oe={actions:/\bactions\b/i,api:/\bapi\b/i,codespaces:/\bcodespaces\b/i,copilot:/\bcopilot\b/i,git:/\bgit\b/i,issues:/\bissues\b/i,packages:/\bpackages\b/i,pages:/\bpages\b/i,pr:/\bpull requests?\b/i,webhooks:/\bwebhooks?\b/i},se=/\b(?:all|many|most|multiple|several|some|various)\s+(?:github\s+)?(?:components|services|systems)\b/i;function ce(e){return se.test(e)}function v(e,t){let n=[];for(let r of t)oe[r].test(e)&&n.push(r);return n}function y(e,t){return t.size>0&&(v(e,t).length>0||ce(e))}const b={none:0,minor:1,major:2,critical:2,unavailable:21},x=`https://www.githubstatus.com`,S=`https://downdetector.com/status/github/`,C=[`google-chrome-stable`,`google-chrome`,`chromium`,`brave`,`microsoft-edge-stable`,`microsoft-edge`],le=[`chrome.exe`,`msedge.exe`,`brave.exe`],ue=[[`Google`,`Chrome`,`Application`,`chrome.exe`],[`Microsoft`,`Edge`,`Application`,`msedge.exe`],[`BraveSoftware`,`Brave-Browser`,`Application`,`brave.exe`],[`Chromium`,`Application`,`chrome.exe`]],de=[`ProgramFiles`,`ProgramFiles(x86)`,`LOCALAPPDATA`],fe=[`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,`/Applications/Brave Browser.app/Contents/MacOS/Brave Browser`,`/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge`,`/Applications/Chromium.app/Contents/MacOS/Chromium`];function w(e,t){return r=>{let i=[];for(let a of String(r).split(`,`)){let r=a.trim();if(r.length===0)continue;let o=e.find(e=>e===r);if(o===void 0)throw new n(`Invalid value '${r}' for flag --${t}. Allowed: ${e.join(`, `)}`,{code:`INVALID_VALUE`,details:{flag:t,input:`--${t}`,value:r,allowed:e}});i.push(o)}return i}}const pe=w(h,`source`),me=w(_,`component`),T=a.boolean().alias(`q`).describe(`Silent; exit code only`),E=a.custom(e=>new URL(String(e))).alias(`github-status-base`,{hidden:!0}).alias(`base`).alias(`b`).default(new URL(x)).env(`GITHUB_UP_GITHUB_STATUS_BASE`).describe(`Override GitHub status page base URL`),he=a.array(a.custom(pe)).alias(`s`).default([[...h]]).env(`GITHUB_UP_SOURCE`).env(`GITHUB_UP_SOURCES`).describe(`Data source(s) to check`),D=a.string().env(`GITHUB_UP_CHROME`).describe(`Path to a Chrome/Chromium binary`),ge=a.array(a.custom(me)).alias(`c`).describe(`Only report incidents/components mentioning these component(s)`),O=e=>`Shortcut for ${c`--component ${e}`}`,k={actions:a.boolean().describe(O(`actions`)),api:a.boolean().describe(O(`api`)),codespaces:a.boolean().describe(O(`codespaces`)),copilot:a.boolean().describe(O(`copilot`)),git:a.boolean().describe(O(`git`)),issues:a.boolean().alias(`issue`).describe(O(`issues`)),packages:a.boolean().describe(O(`packages`)),pages:a.boolean().describe(O(`pages`)),pr:a.boolean().alias(`prs`).describe(O(`pr`)),webhooks:a.boolean().describe(O(`webhooks`))};function A(e){let t=new Set(e.component.flat());for(let n of _)e[n]&&t.add(n);return t}function _e(e){return[...new Set(e.flat())]}var j=`https://github-up.kjanat.dev`,M={name:`github-up`,version:`0.1.3`,description:`Is GitHub down? Probably...`,homepage:j,bugs:{url:`https://github.com/kjanat/github-up/issues`},repository:{type:`git`,url:`git+https://github.com/kjanat/github-up.git`},license:`MIT`,author:`Kaj Kowalski <info@kajkowalski.nl> (https://github.com/kjanat)`,keywords:[`github`,`cli`,`downdetector`,`dreamcli`,`statuspage`,`ansispeck`],type:`module`,jsdelivr:`./dist/browser/browser.js`,imports:{"#github-up":`./src/index.ts`,"#github-up/cli":`./src/cli/index.ts`,"#github-up/browser":`./src/browser.ts`,"#github-up/types":`./src/lib/types.ts`,"#github-up/*":`./src/*.ts`,"#demo/*":`./demo/*.ts`,"#pkg":`./package.json`,"#test/*":`./test/*`},exports:{".":{types:`./dist/index.d.mts`,default:`./dist/index.mjs`},"./browser":{types:`./dist/browser/browser.d.ts`,default:`./dist/browser/browser.js`},"./package.json":`./package.json`},bin:{"github-up":`dist/bin/cli.mjs`},files:[`dist`,`README.md`,`LICENSE`,`package.json`],scripts:{bd:`runner build`,build:`bun --bun build.ts`,"build:watch":`runner build --watch`,check:`biome check`,fmt:`bunx dprint fmt`,lint:`biome lint`,local:`bun run build -l warn && bun link`,prepublishOnly:`bun run build -l warn`,publishChecks:`e18e-cli analyze; attw; bunx publint --pack bun --strict`,test:`bun test`,typecheck:`tsc --noEmit`,dev:`runner build:watch`,preview:`bun start`,"site:build":`runner build`,prestart:`runner build`,start:`bunx serve dist/site`,"publish:npm":`npm view "$(jq -r '"\\(.name)@\\(.version)"' package.json)" version >/dev/null 2>&1 && echo already published, skipping || bunx npm@11 publish`,"publish:pkg-pr-new":`bunx pkg-pr-new publish --bun --bin --packageManager=npm,bun,pnpm`},dependencies:{"@kjanat/dreamcli":`^3.0.0-rc.8`,ansispeck:`^0.1.2`},devDependencies:{"@biomejs/biome":`>=2.5,<2.5.3`,"@types/bun":`^1.3`,"@types/node":`^26`,"runner-run":`^0.19.1`,"statuspage.io":`^3.5`,tsdown:`^0.22`,typescript:`^7`},packageManager:`bun@1.3.14`,engines:{bun:`>=1.3`,node:`>=22.18`},devEngines:{packageManager:[{name:`bun`,onFail:`warn`}],runtime:[{name:`bun`,onFail:`ignore`}]},volta:{node:`26.5.0`,npm:`11.18.0`},publishConfig:{access:`public`,tag:`latest`}};function ve(e){return{none:e.green,minor:e.yellow,major:e.red,critical:e.red}}function ye(e,t){return e.indicator===`unavailable`?t.dim:ve(t)[e.indicator]}function be(e){return e.source===`github`?x:S}function N(e,t,n){if(n.length!==0){e.push(` ${t}:`);for(let t of n)e.push(` - ${t}`)}}function P(e,t){let n=l(t),r=ye(e,n),i=[n.link(be(e),n.underline(n.bold(r(g[e.source]))))];if(e.indicator===`unavailable`){let t=e.summaryText??`unknown error`;return i.push(` ${r(`Unavailable: ${t}`)}`),i.join(`
3
- `)}if(e.source===`downdetector`){let t=e.summaryText??`No user-reported issues`;return i.push(` ${r(t)}`),i.join(`
4
- `)}let a=e.summaryText??`All systems operational`;i.push(` ${r(a)}`);let o=e.incidents?.map(e=>`${e.name} (${e.status})`)??[];return N(i,o.length===1?`Active incident`:`Active incidents`,o),N(i,`Affected components`,e.affectedComponents?.map(e=>e.name)??[]),i.join(`
5
- `)}function xe(e){return e.source===`downdetector`?{source:`downdetector`,status:e.indicator===`unavailable`?`unavailable`:e.reportsOutage?`down`:`up`,details:e.summaryText}:{source:`github`,status:e.indicator===`none`?`up`:e.indicator,details:e.summaryText,incidents:e.incidents,affected:e.affectedComponents}}function Se(e){return e.map(e=>xe(e))}function Ce(e,t){if(t.jsonMode||!t.isTTY){t.json(Se(e));return}t.log(e.map(e=>P(e,t.isTTY)).join(`
2
+ import{cli as e,command as t,flag as n,includesBeforeSeparator as r,osc8 as i,packageRepositoryUrl as a,resolveRenderContext as o}from"@kjanat/dreamcli";import{cyan as s}from"ansispeck/safe";import{spawn as c,spawnSync as l}from"node:child_process";import{existsSync as u,mkdtempSync as ee,readFileSync as te,rmSync as ne}from"node:fs";import{tmpdir as re}from"node:os";import{join as d,win32 as ie}from"node:path";import{setTimeout as f}from"node:timers/promises";import{platform as ae}from"node:process";import{createAdapter as oe}from"@kjanat/dreamcli/runtime";const p=[`github`,`downdetector`],m={github:`GitHub`,downdetector:`Downdetector`},h=[`actions`,`api`,`codespaces`,`copilot`,`git`,`issues`,`packages`,`pages`,`pr`,`webhooks`],se={actions:/\bactions\b/i,api:/\bapi\b/i,codespaces:/\bcodespaces\b/i,copilot:/\bcopilot\b/i,git:/\bgit\b/i,issues:/\bissues\b/i,packages:/\bpackages\b/i,pages:/\bpages\b/i,pr:/\bpull requests?\b/i,webhooks:/\bwebhooks?\b/i},ce=/\b(?:all|many|most|multiple|several|some|various)\s+(?:github\s+)?(?:components|services|systems)\b/i;function g(e){return ce.test(e)}function _(e,t){let n=[];for(let r of t)se[r].test(e)&&n.push(r);return n}function v(e,t){return t.size>0&&(_(e,t).length>0||g(e))}const y={none:0,minor:1,major:2,critical:2,unavailable:21},b=`https://www.githubstatus.com`,x=`https://downdetector.com/status/github/`,S=[`google-chrome-stable`,`google-chrome`,`chromium`,`brave`,`microsoft-edge-stable`,`microsoft-edge`],le=[`chrome.exe`,`msedge.exe`,`brave.exe`],ue=[[`Google`,`Chrome`,`Application`,`chrome.exe`],[`Microsoft`,`Edge`,`Application`,`msedge.exe`],[`BraveSoftware`,`Brave-Browser`,`Application`,`brave.exe`],[`Chromium`,`Application`,`chrome.exe`]],de=[`ProgramFiles`,`ProgramFiles(x86)`,`LOCALAPPDATA`],fe=[`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,`/Applications/Brave Browser.app/Contents/MacOS/Brave Browser`,`/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge`,`/Applications/Chromium.app/Contents/MacOS/Chromium`],C=n.url().alias(`github-status-base`,{hidden:!0}).alias(`base`).alias(`b`).default(new URL(b)).env(`GITHUB_UP_GITHUB_STATUS_BASE`).describe(`Override GitHub status page base URL`),pe=n.array(n.enum(p)).separator(`,`).unique().alias(`s`).default([...p]).env(`GITHUB_UP_SOURCE`).env(`GITHUB_UP_SOURCES`).describe(`Data source(s) to check`),w=n.string().env(`GITHUB_UP_CHROME`).describe(`Path to a Chrome/Chromium binary`),me=n.array(n.enum(h)).separator(`,`).unique().alias(`c`).describe(`Only report incidents/components mentioning these component(s)`),T=e=>`Shortcut for ${s`--component ${e}`}`,E={actions:n.boolean().describe(T(`actions`)),api:n.boolean().describe(T(`api`)),codespaces:n.boolean().describe(T(`codespaces`)),copilot:n.boolean().describe(T(`copilot`)),git:n.boolean().describe(T(`git`)),issues:n.boolean().alias(`issue`).describe(T(`issues`)),packages:n.boolean().describe(T(`packages`)),pages:n.boolean().describe(T(`pages`)),pr:n.boolean().alias(`prs`).describe(T(`pr`)),webhooks:n.boolean().describe(T(`webhooks`))};function D(e){let t=new Set(e.component);for(let n of h)e[n]&&t.add(n);return t}var O=`https://github-up.kjanat.dev`,k={name:`github-up`,version:`0.1.4`,description:`Is GitHub down? Probably...`,homepage:O,bugs:{url:`https://github.com/kjanat/github-up/issues`},repository:{type:`git`,url:`git+https://github.com/kjanat/github-up.git`},license:`MIT`,author:`Kaj Kowalski <info@kajkowalski.nl> (https://github.com/kjanat)`,keywords:[`github`,`cli`,`downdetector`,`dreamcli`,`statuspage`,`ansispeck`],type:`module`,jsdelivr:`./dist/browser/browser.js`,imports:{"#github-up":`./src/index.ts`,"#github-up/cli":`./src/cli/index.ts`,"#github-up/browser":`./src/browser.ts`,"#github-up/types":`./src/lib/types.ts`,"#github-up/*":`./src/*.ts`,"#demo/*":`./demo/*.ts`,"#pkg":`./package.json`,"#test/*":`./test/*`},exports:{".":{types:`./dist/index.d.mts`,default:`./dist/index.mjs`},"./browser":{types:`./dist/browser/browser.d.ts`,default:`./dist/browser/browser.js`},"./package.json":`./package.json`},bin:{"github-up":`dist/bin/cli.mjs`},files:[`dist`,`README.md`,`LICENSE`,`package.json`],scripts:{bd:`runner build`,build:`bun --bun build.ts`,"build:watch":`runner build --watch`,check:`biome check`,fmt:`bunx dprint fmt`,lint:`biome lint`,local:`bun run build -l warn && bun link`,prepublishOnly:`bun run build -l warn`,publishChecks:`e18e-cli analyze; attw; bunx publint --pack bun --strict`,test:`bun test`,typecheck:`tsc --noEmit`,dev:`runner build:watch`,preview:`bun start`,"site:build":`runner build`,prestart:`runner build`,start:`bunx serve dist/site`,"publish:npm":`npm view "$(jq -r '"\\(.name)@\\(.version)"' package.json)" version >/dev/null 2>&1 && echo already published, skipping || bunx npm@11 publish`,"publish:pkg-pr-new":`bunx pkg-pr-new publish --bun --bin --packageManager=npm,bun,pnpm`},dependencies:{"@kjanat/dreamcli":`^3.0.1`,ansispeck:`^0.4.1`},devDependencies:{"@biomejs/biome":`>=2.5.5`,"@types/bun":`^1.3`,"@types/node":`^26`,"runner-run":`^0.21`,"statuspage.io":`^3.5`,tsdown:`^0.22`,typescript:`^7`},packageManager:`bun@1.3.14`,engines:{bun:`>=1.3`,node:`>=22.18`},devEngines:{packageManager:[{name:`bun`,onFail:`warn`}],runtime:[{name:`bun`,onFail:`ignore`}]},volta:{node:`26.5.0`,npm:`11.18.0`},publishConfig:{access:`public`,tag:`latest`}};function he(e){return{none:e.green,minor:e.yellow,major:e.red,critical:e.red}}function ge(e,t){return e.indicator===`unavailable`?t.dim:he(t)[e.indicator]}function _e(e){return e.source===`github`?b:x}function A(e,t,n){if(n.length!==0){e.push(` ${t}:`);for(let t of n)e.push(` - ${t}`)}}function j(e,t,n){let r=ge(e,t),i=t.underline(t.bold(r(m[e.source]))),a=[n?t.link(_e(e),i):i];if(e.indicator===`unavailable`){let t=e.summaryText??`unknown error`;return a.push(` ${r(`Unavailable: ${t}`)}`),a.join(`
3
+ `)}if(e.source===`downdetector`){let t=e.summaryText??`No user-reported issues`;return a.push(` ${r(t)}`),a.join(`
4
+ `)}let o=e.summaryText??`All systems operational`;a.push(` ${r(o)}`);let s=e.incidents?.map(e=>`${e.name} (${e.status})`)??[];return A(a,s.length===1?`Active incident`:`Active incidents`,s),A(a,`Affected components`,e.affectedComponents?.map(e=>e.name)??[]),a.join(`
5
+ `)}function ve(e){return e.source===`downdetector`?{source:`downdetector`,status:e.indicator===`unavailable`?`unavailable`:e.reportsOutage?`down`:`up`,details:e.summaryText}:{source:`github`,status:e.indicator===`none`?`up`:e.indicator,details:e.summaryText,incidents:e.incidents,affected:e.affectedComponents}}function M(e){return e.map(e=>ve(e))}function ye(e,t){if(t.jsonMode){t.json(M(e));return}if(!t.isTTY){t.info(JSON.stringify(M(e)));return}t.info(e.map(e=>j(e,t.color,t.isHyperlinkSupported)).join(`
6
6
 
7
- `))}function we(e,t,n={}){let r=n.leadingBlank===!0?`
8
- `:``;t.log(`${r}${P(e,t.isTTY)}`)}function Te(e){if(e.jsonMode||!e.isTTY)return;let t=l(!0),n=t.link(M.homepage,t.underline(M.homepage));e.log(`\n${t.dim(`Watch the live status page: ${n}`)}`)}function Ee(e){return typeof e==`object`&&!!e&&`webSocketDebuggerUrl`in e&&typeof e.webSocketDebuggerUrl==`string`}function De(e){return typeof e==`object`&&!!e&&`id`in e&&typeof e.id==`number`}function Oe(e){let t=new Map,n=0;return e.onmessage=e=>{let n=typeof e.data==`string`?e.data:e.data instanceof ArrayBuffer?new TextDecoder().decode(e.data):null;if(n===null)return;let r;try{r=JSON.parse(n)}catch{return}if(!De(r))return;let i=t.get(r.id);typeof i==`function`&&(t.delete(r.id),i(r))},(r,i={})=>new Promise((a,o)=>{let s=++n,c=setTimeout(()=>{t.delete(s),o(Error(`CDP command '${r}' timed out`))},5e3);t.set(s,e=>{clearTimeout(c),a(e)}),e.send(JSON.stringify({id:s,method:r,params:i}))})}async function ke(e,t){let n=await(await fetch(`${e}/json/new?about%3Ablank`,{method:`PUT`})).json();if(!Ee(n))return{ok:!1,error:`unexpected CDP target shape`};let r=new WebSocket(n.webSocketDebuggerUrl);await new Promise((e,t)=>{r.onopen=()=>e(),r.onerror=()=>t(Error(`WebSocket connection failed`)),r.onclose=()=>t(Error(`WebSocket closed before opening`))});let i=Oe(r);return await i(`Page.enable`),await i(`Page.navigate`,{url:t}),{ok:!0,send:i,close:()=>r.close()}}function F(e,t){for(let n of t){let t=d(e,[n]);if(t.status===0&&t.stdout){let e=t.stdout.toString().split(/\r?\n/)[0]?.trim();if(e)return e}}return null}function I(e){for(let t of e)if(t&&f(t))return t;return null}function Ae(){let e=[];for(let t of de){let n=process.env[t];if(n)for(let t of ue)e.push(ie.join(n,...t))}return e}function je(e){let t=e??process.env.GITHUB_UP_CHROME;return t?f(t)?t:null:process.platform===`win32`?F(`where.exe`,le)??I(Ae()):process.platform===`darwin`?F(`which`,C)??I(fe):F(`which`,C)}async function Me(e,t){let n=Date.now()+t;for(;Date.now()<n;){try{if((await fetch(`${e}/json/version`)).ok)return!0}catch{}await m(100)}return!1}async function Ne(e,t){let n=p(e,`DevToolsActivePort`),r=Date.now()+t;for(;Date.now()<r;){try{let e=te(n,`utf8`).split(`
9
- `)[0]?.trim(),t=Number(e);if(Number.isInteger(t)&&t>0)return t}catch{}await m(100)}return null}async function Pe(e){let t;try{t=ee(p(re(),`github-up-`))}catch(e){return{ok:!1,error:`mkdtemp failed: ${e instanceof Error?e.message:String(e)}`}}let n=u(e,[`--headless=new`,`--disable-gpu`,`--no-sandbox`,`--disable-blink-features=AutomationControlled`,`--window-size=1920,1080`,`--user-data-dir=${t}`,`--remote-debugging-port=0`,`--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36`,`about:blank`],{stdio:`ignore`}),r=new Promise(e=>{n.once(`error`,t=>e({failed:t.message})),n.once(`exit`,(t,n)=>e({failed:`Chrome exited before CDP came up (${n??t??`unknown`})`}))}),i=await Promise.race([Ne(t,5e3),r]);if(typeof i!=`number`)return L(n,t),{ok:!1,error:i===null?`CDP endpoint never came up`:`Chrome launch failed: ${i.failed}`};let a=`http://localhost:${i}`;return await Me(a,5e3)?{ok:!0,browser:{proc:n,userDataDir:t,base:a}}:(L(n,t),{ok:!1,error:`CDP endpoint never came up`})}function L(e,t){process.platform===`win32`&&e.pid!==void 0?d(`taskkill`,[`/pid`,String(e.pid),`/t`,`/f`]):e.kill();try{ne(t,{recursive:!0,force:!0,maxRetries:5,retryDelay:100})}catch{}}const R=`({
7
+ `))}function be(e,t,n={}){let r=n.leadingBlank===!0?`
8
+ `:``;t.info(`${r}${j(e,t.color,t.isHyperlinkSupported)}`)}function xe(e){if(e.jsonMode||!e.isTTY)return;let t=e.color.underline(k.homepage),n=e.isHyperlinkSupported?e.color.link(k.homepage,t):t;e.info(`\n${e.color.dim(`Watch the live status page: ${n}`)}`)}function Se(e){return typeof e==`object`&&!!e&&`webSocketDebuggerUrl`in e&&typeof e.webSocketDebuggerUrl==`string`}function Ce(e){return typeof e==`object`&&!!e&&`id`in e&&typeof e.id==`number`}function we(e){let t=new Map,n=0;return e.onmessage=e=>{let n=typeof e.data==`string`?e.data:e.data instanceof ArrayBuffer?new TextDecoder().decode(e.data):null;if(n===null)return;let r;try{r=JSON.parse(n)}catch{return}if(!Ce(r))return;let i=t.get(r.id);typeof i==`function`&&(t.delete(r.id),i(r))},(r,i={})=>new Promise((a,o)=>{let s=++n,c=setTimeout(()=>{t.delete(s),o(Error(`CDP command '${r}' timed out`))},5e3);t.set(s,e=>{clearTimeout(c),a(e)}),e.send(JSON.stringify({id:s,method:r,params:i}))})}async function Te(e,t){let n=await(await fetch(`${e}/json/new?about%3Ablank`,{method:`PUT`})).json();if(!Se(n))return{ok:!1,error:`unexpected CDP target shape`};let r=new WebSocket(n.webSocketDebuggerUrl);await new Promise((e,t)=>{r.onopen=()=>e(),r.onerror=()=>t(Error(`WebSocket connection failed`)),r.onclose=()=>t(Error(`WebSocket closed before opening`))});let i=we(r);return await i(`Page.enable`),await i(`Page.navigate`,{url:t}),{ok:!0,send:i,close:()=>r.close()}}function N(e,t){for(let n of t){let t=l(e,[n]);if(t.status===0&&t.stdout){let e=t.stdout.toString().split(/\r?\n/)[0]?.trim();if(e)return e}}return null}function P(e){for(let t of e)if(t&&u(t))return t;return null}function Ee(){let e=[];for(let t of de){let n=process.env[t];if(n)for(let t of ue)e.push(ie.join(n,...t))}return e}function De(e){let t=e??process.env.GITHUB_UP_CHROME;return t?u(t)?t:null:process.platform===`win32`?N(`where.exe`,le)??P(Ee()):process.platform===`darwin`?N(`which`,S)??P(fe):N(`which`,S)}async function Oe(e,t){let n=Date.now()+t;for(;Date.now()<n;){try{if((await fetch(`${e}/json/version`)).ok)return!0}catch{}await f(100)}return!1}async function ke(e,t){let n=d(e,`DevToolsActivePort`),r=Date.now()+t;for(;Date.now()<r;){try{let e=te(n,`utf8`).split(`
9
+ `)[0]?.trim(),t=Number(e);if(Number.isInteger(t)&&t>0)return t}catch{}await f(100)}return null}async function Ae(e){let t;try{t=ee(d(re(),`github-up-`))}catch(e){return{ok:!1,error:`mkdtemp failed: ${e instanceof Error?e.message:String(e)}`}}let n=c(e,[`--headless=new`,`--disable-gpu`,`--no-sandbox`,`--disable-blink-features=AutomationControlled`,`--window-size=1920,1080`,`--user-data-dir=${t}`,`--remote-debugging-port=0`,`--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36`,`about:blank`],{stdio:`ignore`}),r=new Promise(e=>{n.once(`error`,t=>e({failed:t.message})),n.once(`exit`,(t,n)=>e({failed:`Chrome exited before CDP came up (${n??t??`unknown`})`}))}),i=await Promise.race([ke(t,5e3),r]);if(typeof i!=`number`)return F(n,t),{ok:!1,error:i===null?`CDP endpoint never came up`:`Chrome launch failed: ${i.failed}`};let a=`http://localhost:${i}`;return await Oe(a,5e3)?{ok:!0,browser:{proc:n,userDataDir:t,base:a}}:(F(n,t),{ok:!1,error:`CDP endpoint never came up`})}function F(e,t){process.platform===`win32`&&e.pid!==void 0?l(`taskkill`,[`/pid`,String(e.pid),`/t`,`/f`]):e.kill();try{ne(t,{recursive:!0,force:!0,maxRetries:5,retryDelay:100})}catch{}}const I=`({
10
10
  title: document.title,
11
11
  pogo: window.PogoConfig ?? null,
12
12
  h1: document.querySelector('h1')?.innerText ?? null,
13
13
  cfChallenge: document.title === 'Just a moment...'
14
14
  || document.querySelector('script[src*="/cdn-cgi/challenge-platform/"]') !== null
15
15
  || document.body?.innerText?.includes('Enable JavaScript and cookies to continue') === true,
16
- })`;function Fe(e){return typeof e==`object`&&!!e&&`result`in e&&typeof e.result==`object`&&e.result!==null&&`result`in e.result&&typeof e.result.result==`object`&&e.result.result!==null&&`value`in e.result.result&&typeof e.result.result.value==`string`}function Ie(e){if(typeof e!=`object`||!e||!(`title`in e)||typeof e.title!=`string`||`h1`in e&&e.h1!==null&&typeof e.h1!=`string`||`cfChallenge`in e&&e.cfChallenge!==void 0&&typeof e.cfChallenge!=`boolean`||!(`pogo`in e))return!1;let{pogo:t}=e;return t===null||!(typeof t!=`object`||`outage`in t&&t.outage!==void 0&&typeof t.outage!=`boolean`)}async function Le(e,t){return await e(`Runtime.enable`),Re(async t=>{let n=await e(`Runtime.evaluate`,{expression:`JSON.stringify(${t})`,returnByValue:!0});if(!Fe(n))return null;try{return JSON.parse(n.result.result.value)}catch{return null}},t)}async function Re(e,t){let n=Date.now()+t;for(;Date.now()<n;){let t=await e(R);if(Ie(t)&&t.cfChallenge===!0)return{kind:`cloudflare-challenge`};if(Ie(t)&&t.pogo!==null)return{kind:`status`,pogo:t.pogo,heading:t.h1};await m(700)}return null}const z=/possible problems/i;function B(e){return e!==null&&z.test(e)?e:void 0}const ze=`
16
+ })`;function je(e){return typeof e==`object`&&!!e&&`result`in e&&typeof e.result==`object`&&e.result!==null&&`result`in e.result&&typeof e.result.result==`object`&&e.result.result!==null&&`value`in e.result.result&&typeof e.result.result.value==`string`}function L(e){if(typeof e!=`object`||!e||!(`title`in e)||typeof e.title!=`string`||`h1`in e&&e.h1!==null&&typeof e.h1!=`string`||`cfChallenge`in e&&e.cfChallenge!==void 0&&typeof e.cfChallenge!=`boolean`||!(`pogo`in e))return!1;let{pogo:t}=e;return t===null||!(typeof t!=`object`||`outage`in t&&t.outage!==void 0&&typeof t.outage!=`boolean`)}async function Me(e,t){return await e(`Runtime.enable`),Ne(async t=>{let n=await e(`Runtime.evaluate`,{expression:`JSON.stringify(${t})`,returnByValue:!0});if(!je(n))return null;try{return JSON.parse(n.result.result.value)}catch{return null}},t)}async function Ne(e,t){let n=Date.now()+t;for(;Date.now()<n;){let t=await e(I);if(L(t)&&t.cfChallenge===!0)return{kind:`cloudflare-challenge`};if(L(t)&&t.pogo!==null)return{kind:`status`,pogo:t.pogo,heading:t.h1};await f(700)}return null}const R=/possible problems/i;function z(e){return e!==null&&R.test(e)?e:void 0}const Pe=`
17
17
  const WEBVIEW_WIDTH = 1920;
18
18
  const WEBVIEW_HEIGHT = 1080;
19
19
  const SNAPSHOT_TIMEOUT_MS = 20000;
20
20
  const POLL_INTERVAL_MS = 700;
21
21
  const CHROME_ARGV = ${JSON.stringify([`--headless=new`,`--disable-gpu`,`--no-sandbox`,`--disable-blink-features=AutomationControlled`,`--window-size=1920,1080`,`--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36`])};
22
- const POSSIBLE_PROBLEMS_PATTERN = ${z};
23
- ${B.toString()}
22
+ const POSSIBLE_PROBLEMS_PATTERN = ${R};
23
+ ${z.toString()}
24
24
 
25
25
  function webViewOptions(chromePath) {
26
26
  if (chromePath || process.platform !== 'darwin') {
@@ -54,7 +54,7 @@ function isPogoSnapshot(value) {
54
54
  async function pollPogoSnapshot(view) {
55
55
  const deadline = Date.now() + SNAPSHOT_TIMEOUT_MS;
56
56
  while (Date.now() < deadline) {
57
- const snapshot = await view.evaluate(${JSON.stringify(R)}).catch(() => null);
57
+ const snapshot = await view.evaluate(${JSON.stringify(I)}).catch(() => null);
58
58
  if (isPogoSnapshot(snapshot) && snapshot.cfChallenge === true) {
59
59
  return { kind: 'cloudflare-challenge' };
60
60
  }
@@ -116,6 +116,6 @@ self.onmessage = async (event) => {
116
116
  });
117
117
  }
118
118
  };
119
- `;function Be(){let e=globalThis.Bun;return e===void 0?null:e}function V(){let e=Be()?.WebView;return typeof e==`function`?e:null}function Ve(){return V()!==null}function He(){let e=URL.createObjectURL(new Blob([ze],{type:`text/javascript`}));return new Worker(e,{type:`module`})}async function Ue(e,t,n=45e3){let r;try{r=He()}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}try{return await new Promise(i=>{let a=setTimeout(()=>{r.terminate(),i({ok:!1,error:`Bun.WebView timed out`})},n);r.onmessage=e=>{clearTimeout(a),r.terminate();let t=e.data;if(t.type===`result`){i(t.result);return}i({ok:!1,error:t.error})},r.onerror=e=>{clearTimeout(a),r.terminate(),i({ok:!1,error:e.message})},r.postMessage({url:e,chromePath:t})})}finally{await m(0)}}async function We(e,t){return V()===null?{ok:!1,error:`Bun.WebView is unavailable; upgrade Bun or run with Node`}:Ue(e,t??process.env.GITHUB_UP_CHROME)}async function Ge(e){if(Ve())return We(S,e);let t=je(e);if(t===null)return{ok:!1,error:`no Chrome/Chromium found; set GITHUB_UP_CHROME or pass --chrome <path>`};let n=await Pe(t);if(!n.ok)return n;let{browser:{proc:r,userDataDir:i,base:a}}=n;try{let e=await ke(a,S);if(!e.ok)return e;let t=await Le(e.send,2e4);if(e.close(),t===null)return{ok:!1,error:`CF challenge not cleared in time`};if(t.kind===`cloudflare-challenge`)return{ok:!1,error:`Cloudflare challenge page`};if(t.pogo.outage===!0)return{ok:!0,down:!0,reason:t.heading??`outage reported`};let n=B(t.heading);return n===void 0?{ok:!0,down:!1}:{ok:!0,down:!1,note:n}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}finally{L(r,i)}}const Ke={components(){return H(`/components.json`)},Incidents:{all(){return H(`/incidents.json`)},unresolved(){return H(`/incidents/unresolved.json`)}},ScheduledMaintenances:{active(){return H(`/scheduled-maintenances/active.json`)},all(){return H(`/scheduled-maintenances.json`)},upcoming(){return H(`/scheduled-maintenances/upcoming.json`)}},status(){return H(`/status.json`)},subscriber(e){return H(`/subscribers/${encodeURIComponent(e)}.json`)},subscribers(){return H(`/subscribers.json`)},summary(){return H(`/summary.json`)}},H=(e,t=`/api/v2/`)=>`${t.replace(/\/+$/,``)}/${e.replace(/^\/+/,``)}`;function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W(e){return U(e)&&typeof e.name==`string`&&typeof e.status==`string`}function qe(e){return U(e)&&typeof e.indicator==`string`&&typeof e.description==`string`}function Je(e){return W(e)&&U(e)&&typeof e.impact==`string`}function Ye(e){return U(e)&&qe(e.status)&&Array.isArray(e.components)&&e.components.every(W)&&Array.isArray(e.incidents)&&e.incidents.every(Je)}async function Xe(e){try{let t=await e.text(),n=t.length>0?`: ${t}`:``;return`Request failed with status code ${e.status}${n}`}catch{let{status:t,statusText:n}=e;return`Request failed with status code ${t}: ${n}`}}async function Ze(e=x){try{let t=await fetch(new URL(Ke.summary(),e));if(!t.ok){let{headers:e}=t;return{headers:e,kind:`unknown`,reason:await Xe(t)}}let n=await t.json();return Ye(n)?{headers:t.headers,kind:`ok`,summary:n}:{headers:t.headers,kind:`unknown`,reason:`unexpected response shape from status API`}}catch(e){return{kind:`unknown`,reason:e instanceof Error?e.message:String(e)}}}const G={none:0,minor:1,major:2,critical:3},Qe={none:`All Systems Operational`,minor:`Minor Service Outage`,major:`Major Service Outage`,critical:`Critical Service Outage`};function $e(e){return typeof e==`string`&&e in G}function et(e){return $e(e)?e:`critical`}function K(e,t){return G[t]>G[e]?t:e}function tt(e){switch(e){case`operational`:return`none`;case`degraded_performance`:case`under_maintenance`:return`minor`;case`partial_outage`:case`major_outage`:return`major`;default:return`major`}}function nt(e){switch(e){case`degraded_performance`:case`partial_outage`:case`major_outage`:return!0;default:return!1}}function q(e){let t=`none`,n=0;for(let r of e)nt(r.status)&&(n+=1),t=K(t,tt(r.status));return n>=3?K(t,`major`):t}function rt(e,t=[]){return K(et(e),q(t))}function it(e){return Qe[e]}function at(e){return e===`operational`||e===`degraded_performance`||e===`partial_outage`||e===`major_outage`||e===`under_maintenance`?e:`major_outage`}async function J(e){let t=await Ze(e);if(t.kind===`unknown`)return{source:`github`,indicator:`unavailable`,summaryText:t.reason,incidents:null,affectedComponents:null};let n=t.summary.status.indicator,r=rt(n,t.summary.components),i=r===n?t.summary.status.description:`${it(r)} (reported ${String(n)})`,a=t.summary.components.filter(e=>e.status!==`operational`);return{source:`github`,indicator:r,summaryText:i,incidents:t.summary.incidents.length>0?t.summary.incidents.map(e=>({name:e.name,status:e.status})):null,affectedComponents:a.length>0?a.map(e=>({name:e.name,status:at(e.status)})):null}}async function Y(e){let t=await Ge(e);return t.ok?t.down?{source:`downdetector`,indicator:`major`,summaryText:t.reason,reportsOutage:!0}:{source:`downdetector`,indicator:t.note===void 0?`none`:`minor`,summaryText:t.note??null,reportsOutage:!1}:{source:`downdetector`,indicator:`unavailable`,summaryText:t.error,reportsOutage:!1}}async function ot(e,t,n){switch(e){case`github`:return J(t);case`downdetector`:return Y(n)}}function X(e,t,n){let r=!1;for(let i of t){ce(i.name)&&(r=!0);for(let t of v(i.name,n))e.add(t)}return r}function st(e,t,n){let r=new Set,i=X(r,e,n),a=X(r,t,n);if(i||a)for(let e of n)r.add(e);return[...n].filter(e=>r.has(e))}function Z(e,t){if(e.source!==`github`||t.size===0||e.indicator===`unavailable`)return e;let n=e.incidents?.filter(e=>y(e.name,t))??[],r=e.affectedComponents?.filter(e=>y(e.name,t))??[],i=n.length+r.length,a=st(n,r,t),o=q(r);return{source:`github`,indicator:n.length>0?K(o,`minor`):o,summaryText:i>0?`${i} report${i===1?``:`s`} affecting ${a.join(`, `)}`:`No incidents reported for ${[...t].join(`, `)}`,incidents:n.length>0?n:null,affectedComponents:r.length>0?r:null}}function ct(e){let t=b[e.indicator];return e.source===`github`&&e.incidents&&e.incidents.length>0?Math.max(t,b.minor):t}function Q(e){let t=e.filter(e=>e.indicator!==`unavailable`);return t.length===0?e.length===0?b.none:b.unavailable:t.reduce((e,t)=>Math.max(e,ct(t)),b.none)}function lt(e){return[...e].sort((e,t)=>e.source.localeCompare(t.source))}function ut(e,n=t){switch(n){case`darwin`:return{command:`open`,args:[e]};case`win32`:return{command:`cmd`,args:[`/c`,`start`,``,e]};default:return{command:`xdg-open`,args:[e]}}}function dt(e){let{args:t,command:n}=ut(e);return new Promise((e,r)=>{let i=u(n,[...t],{detached:!0,stdio:`ignore`});i.once(`error`,r),i.once(`spawn`,()=>{i.unref(),e()})})}function ft(e){return e.flag(`component`,ge).flag(`actions`,k.actions).flag(`api`,k.api).flag(`codespaces`,k.codespaces).flag(`copilot`,k.copilot).flag(`git`,k.git).flag(`issues`,k.issues).flag(`packages`,k.packages).flag(`pages`,k.pages).flag(`pr`,k.pr).flag(`webhooks`,k.webhooks)}async function $(e,t,n,r){if(r.isTTY&&!r.jsonMode&&!n){let n=await mt(e,t,r);r.setExitCode(Q(n));return}ht(gt(await Promise.all(e.map(e=>e.run())),t),n,r)}function pt(e){return`Checking ${[...e].map(e=>g[e]).join(`, `)}…`}async function mt(e,t,n){let r=new Set(e.map(e=>e.source)),i=[],a=new Map(e.map((e,t)=>[t,e.run().then(t=>({source:e.source,row:t}))])),o=n.spinner(pt(r)),s=0;try{for(;a.size>0;){let e=await Promise.race([...a].map(([e,t])=>t.then(t=>({index:e,...t}))));a.delete(e.index),r.delete(e.source);let c=Z(e.row,t);i.push(c),o.stop(),we(c,n,{leadingBlank:s>0}),s+=1,r.size>0&&(o=n.spinner(pt(r)))}}catch(e){throw o.stop(),e}return Te(n),i}function ht(e,t,n){t||Ce(lt(e),n),n.setExitCode(Q(e))}function gt(e,t){return t.size===0?e:e.map(e=>Z(e,t))}const _t=ft(i(`status`).description(`Check GitHub status across GitHub and Downdetector`).example(`status`,`Check all sources`).example(`status --source github`,`Check only GitHub`).example(`status --actions`,`Only report trouble mentioning Actions`).example(`status --json`,`Emit machine-readable source rows`)).flag(`githubStatusBase`,E).flag(`chrome`,D).flag(`quiet`,T).flag(`source`,he).action(async({flags:e,out:t})=>{let{source:n,githubStatusBase:r,chrome:i,quiet:a}=e;await $(_e(n).map(e=>({source:e,run:()=>ot(e,r,i)})),A(e),a,t)}),vt=ft(i(`github`).description(`Check only ${g.github}`).example(`github`,`Check only ${g.github}`).example(`github --component actions`,`Only report trouble mentioning Actions`)).flag(`githubStatusBase`,E).flag(`quiet`,T).action(async({flags:e,out:t})=>{await $([{source:`github`,run:()=>J(e.githubStatusBase)}],A(e),e.quiet,t)}),yt=i(`downdetector`).description(`Check only ${g.downdetector}`).example(`downdetector`,`Check only ${g.downdetector}`).flag(`chrome`,D).flag(`quiet`,T).action(async({flags:e,out:t})=>{await $([{source:`downdetector`,run:()=>Y(e.chrome)}],new Set,e.quiet,t)});function bt(e=dt){return i(`web`).alias(`site`).description(`Open the live status page`).example(`web`,`Open the live status page in your browser`).action(async({out:t})=>{await e(M.homepage),t.log(`Opening ${M.homepage}`)})}const xt=bt(),St=s({repository:M.repository}),Ct=r(M.name).manifest(M).links({name:St,version:`${St}/releases/tag/v${M.version}`}).default(_t,{route:!0}).command(vt).command(yt).command(xt).completions(),wt=new Set([`--help`,`-h`]);function Tt(e){return e.some(e=>wt.has(e))}function Et(e,t=!1){return`
120
- No terminal? Watch the live status page: ${t?o(e,e):e}
121
- `}if(import.meta.main){let t=ae(),n=Tt(e.slice(2));Ct.run({adapter:{...t,exit:e=>(n&&t.stdout(Et(j,t.isTTY)),t.exit(e))}})}export{};
119
+ `;function Fe(){let e=globalThis.Bun;return e===void 0?null:e}function B(){let e=Fe()?.WebView;return typeof e==`function`?e:null}function Ie(){return B()!==null}function Le(){let e=URL.createObjectURL(new Blob([Pe],{type:`text/javascript`}));return new Worker(e,{type:`module`})}async function Re(e,t,n=45e3){let r;try{r=Le()}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}try{return await new Promise(i=>{let a=setTimeout(()=>{r.terminate(),i({ok:!1,error:`Bun.WebView timed out`})},n);r.onmessage=e=>{clearTimeout(a),r.terminate();let t=e.data;if(t.type===`result`){i(t.result);return}i({ok:!1,error:t.error})},r.onerror=e=>{clearTimeout(a),r.terminate(),i({ok:!1,error:e.message})},r.postMessage({url:e,chromePath:t})})}finally{await f(0)}}async function ze(e,t){return B()===null?{ok:!1,error:`Bun.WebView is unavailable; upgrade Bun or run with Node`}:Re(e,t??process.env.GITHUB_UP_CHROME)}async function Be(e){if(Ie())return ze(x,e);let t=De(e);if(t===null)return{ok:!1,error:`no Chrome/Chromium found; set GITHUB_UP_CHROME or pass --chrome <path>`};let n=await Ae(t);if(!n.ok)return n;let{browser:{proc:r,userDataDir:i,base:a}}=n;try{let e=await Te(a,x);if(!e.ok)return e;let t=await Me(e.send,2e4);if(e.close(),t===null)return{ok:!1,error:`CF challenge not cleared in time`};if(t.kind===`cloudflare-challenge`)return{ok:!1,error:`Cloudflare challenge page`};if(t.pogo.outage===!0)return{ok:!0,down:!0,reason:t.heading??`outage reported`};let n=z(t.heading);return n===void 0?{ok:!0,down:!1}:{ok:!0,down:!1,note:n}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}finally{F(r,i)}}const Ve={components(){return V(`/components.json`)},Incidents:{all(){return V(`/incidents.json`)},unresolved(){return V(`/incidents/unresolved.json`)}},ScheduledMaintenances:{active(){return V(`/scheduled-maintenances/active.json`)},all(){return V(`/scheduled-maintenances.json`)},upcoming(){return V(`/scheduled-maintenances/upcoming.json`)}},status(){return V(`/status.json`)},subscriber(e){return V(`/subscribers/${encodeURIComponent(e)}.json`)},subscribers(){return V(`/subscribers.json`)},summary(){return V(`/summary.json`)}},V=(e,t=`/api/v2/`)=>`${t.replace(/\/+$/,``)}/${e.replace(/^\/+/,``)}`;function H(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function U(e){return H(e)&&typeof e.name==`string`&&typeof e.status==`string`}function He(e){return H(e)&&typeof e.indicator==`string`&&typeof e.description==`string`}function Ue(e){return U(e)&&H(e)&&typeof e.impact==`string`}function We(e){return H(e)&&He(e.status)&&Array.isArray(e.components)&&e.components.every(U)&&Array.isArray(e.incidents)&&e.incidents.every(Ue)}async function Ge(e){try{let t=await e.text(),n=t.length>0?`: ${t}`:``;return`Request failed with status code ${e.status}${n}`}catch{let{status:t,statusText:n}=e;return`Request failed with status code ${t}: ${n}`}}async function Ke(e=b){try{let t=await fetch(new URL(Ve.summary(),e));if(!t.ok){let{headers:e}=t;return{headers:e,kind:`unknown`,reason:await Ge(t)}}let n=await t.json();return We(n)?{headers:t.headers,kind:`ok`,summary:n}:{headers:t.headers,kind:`unknown`,reason:`unexpected response shape from status API`}}catch(e){return{kind:`unknown`,reason:e instanceof Error?e.message:String(e)}}}const W={none:0,minor:1,major:2,critical:3},qe={none:`All Systems Operational`,minor:`Minor Service Outage`,major:`Major Service Outage`,critical:`Critical Service Outage`};function Je(e){return typeof e==`string`&&e in W}function Ye(e){return Je(e)?e:`critical`}function G(e,t){return W[t]>W[e]?t:e}function Xe(e){switch(e){case`operational`:return`none`;case`degraded_performance`:case`under_maintenance`:return`minor`;case`partial_outage`:case`major_outage`:return`major`;default:return`major`}}function Ze(e){switch(e){case`degraded_performance`:case`partial_outage`:case`major_outage`:return!0;default:return!1}}function K(e){let t=`none`,n=0;for(let r of e)Ze(r.status)&&(n+=1),t=G(t,Xe(r.status));return n>=3?G(t,`major`):t}function Qe(e,t=[]){return G(Ye(e),K(t))}function $e(e){return qe[e]}function et(e){return e===`operational`||e===`degraded_performance`||e===`partial_outage`||e===`major_outage`||e===`under_maintenance`?e:`major_outage`}async function q(e){let t=await Ke(e);if(t.kind===`unknown`)return{source:`github`,indicator:`unavailable`,summaryText:t.reason,incidents:null,affectedComponents:null};let n=t.summary.status.indicator,r=Qe(n,t.summary.components),i=r===n?t.summary.status.description:`${$e(r)} (reported ${String(n)})`,a=t.summary.components.filter(e=>e.status!==`operational`);return{source:`github`,indicator:r,summaryText:i,incidents:t.summary.incidents.length>0?t.summary.incidents.map(e=>({name:e.name,status:e.status})):null,affectedComponents:a.length>0?a.map(e=>({name:e.name,status:et(e.status)})):null}}async function J(e){let t=await Be(e);return t.ok?t.down?{source:`downdetector`,indicator:`major`,summaryText:t.reason,reportsOutage:!0}:{source:`downdetector`,indicator:t.note===void 0?`none`:`minor`,summaryText:t.note??null,reportsOutage:!1}:{source:`downdetector`,indicator:`unavailable`,summaryText:t.error,reportsOutage:!1}}async function tt(e,t,n){switch(e){case`github`:return q(t);case`downdetector`:return J(n)}}function Y(e,t,n){let r=!1;for(let i of t){g(i.name)&&(r=!0);for(let t of _(i.name,n))e.add(t)}return r}function nt(e,t,n){let r=new Set,i=Y(r,e,n),a=Y(r,t,n);if(i||a)for(let e of n)r.add(e);return[...n].filter(e=>r.has(e))}function X(e,t){if(e.source!==`github`||t.size===0||e.indicator===`unavailable`)return e;let n=e.incidents?.filter(e=>v(e.name,t))??[],r=e.affectedComponents?.filter(e=>v(e.name,t))??[],i=n.length+r.length,a=nt(n,r,t),o=K(r);return{source:`github`,indicator:n.length>0?G(o,`minor`):o,summaryText:i>0?`${i} report${i===1?``:`s`} affecting ${a.join(`, `)}`:`No incidents reported for ${[...t].join(`, `)}`,incidents:n.length>0?n:null,affectedComponents:r.length>0?r:null}}function rt(e){let t=y[e.indicator];return e.source===`github`&&e.incidents&&e.incidents.length>0?Math.max(t,y.minor):t}function Z(e){let t=e.filter(e=>e.indicator!==`unavailable`);return t.length===0?e.length===0?y.none:y.unavailable:t.reduce((e,t)=>Math.max(e,rt(t)),y.none)}function it(e){return[...e].sort((e,t)=>e.source.localeCompare(t.source))}function at(e,t=ae){switch(t){case`darwin`:return{command:`open`,args:[e]};case`win32`:return{command:`cmd`,args:[`/c`,`start`,``,e]};default:return{command:`xdg-open`,args:[e]}}}function ot(e){let{args:t,command:n}=at(e);return new Promise((e,r)=>{let i=c(n,[...t],{detached:!0,stdio:`ignore`});i.once(`error`,r),i.once(`spawn`,()=>{i.unref(),e()})})}function Q(e){return e.flag(`component`,me).flag(`actions`,E.actions).flag(`api`,E.api).flag(`codespaces`,E.codespaces).flag(`copilot`,E.copilot).flag(`git`,E.git).flag(`issues`,E.issues).flag(`packages`,E.packages).flag(`pages`,E.pages).flag(`pr`,E.pr).flag(`webhooks`,E.webhooks)}async function $(e,t,n){if(n.isTTY&&!n.jsonMode){let r=await ct(e,t,n);n.setExitCode(Z(r));return}lt(ut(await Promise.all(e.map(e=>e.run())),t),n)}function st(e){return`Checking ${[...e].map(e=>m[e]).join(`, `)}…`}async function ct(e,t,n){let r=new Set(e.map(e=>e.source)),i=[],a=new Map(e.map((e,t)=>[t,e.run().then(t=>({source:e.source,row:t}))]));n.status(st(r));let o=0;for(;a.size>0;){let e=await Promise.race([...a].map(([e,t])=>t.then(t=>({index:e,...t}))));a.delete(e.index),r.delete(e.source);let s=X(e.row,t);i.push(s),be(s,n,{leadingBlank:o>0}),o+=1}return xe(n),i}function lt(e,t){ye(it(e),t),t.setExitCode(Z(e))}function ut(e,t){return t.size===0?e:e.map(e=>X(e,t))}const dt=Q(t(`status`).description(`Check GitHub status across GitHub and Downdetector`).example(({name:e})=>`${e} status`,`Check all sources`).example(({name:e})=>`${e} status --source github`,`Check only GitHub`).example(({name:e})=>`${e} status --actions`,`Only report trouble mentioning Actions`).example(({name:e})=>`${e} status --json`,`Emit machine-readable source rows`)).flag(`githubStatusBase`,C).flag(`chrome`,w).flag(`source`,pe).action(async({flags:e,out:t})=>{let{source:n,githubStatusBase:r,chrome:i}=e;await $(n.map(e=>({source:e,run:()=>tt(e,r,i)})),D(e),t)}),ft=Q(t(`github`).description(`Check only ${m.github}`).example(({name:e})=>`${e} github`,`Check only ${m.github}`).example(({name:e})=>`${e} github --component actions`,`Only report trouble mentioning Actions`)).flag(`githubStatusBase`,C).action(async({flags:e,out:t})=>{await $([{source:`github`,run:()=>q(e.githubStatusBase)}],D(e),t)}),pt=t(`downdetector`).description(`Check only ${m.downdetector}`).example(({name:e})=>`${e} downdetector`,`Check only ${m.downdetector}`).flag(`chrome`,w).action(async({flags:e,out:t})=>{await $([{source:`downdetector`,run:()=>J(e.chrome)}],new Set,t)});function mt(e=ot){return t(`web`).alias(`site`).description(`Open the live status page`).example(({name:e})=>`${e} web`,`Open the live status page in your browser`).action(async({out:t})=>{await e(k.homepage),t.status(`Opening ${k.homepage}`)})}const ht=mt(),gt=a(k,{require:!0}),_t=e(k.name).manifest(k).links({name:gt,version:`${gt}/releases/tag/v${k.version}`}).default(dt,{route:!0}).command(ft).command(pt).command(ht).completions(),vt=new Set([`--help`,`-h`]);function yt(e){return[...vt].some(t=>r(e,t))}function bt(e,t=!1){return`
120
+ No terminal? Watch the live status page: ${t?i(e):e}
121
+ `}if(import.meta.main){let e=oe(),t=e.argv.slice(2),n=yt(t),r=o(t,{env:e.env,isTTY:e.isTTY});_t.run({adapter:{...e,exit:t=>(n&&e.stdout(bt(O,r.isHyperlinkSupported)),e.exit(t))}})}export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-up",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Is GitHub down? Probably...",
5
5
  "homepage": "https://github-up.kjanat.dev",
6
6
  "bugs": {
@@ -73,14 +73,14 @@
73
73
  "publish:pkg-pr-new": "bunx pkg-pr-new publish --bun --bin --packageManager=npm,bun,pnpm"
74
74
  },
75
75
  "dependencies": {
76
- "@kjanat/dreamcli": "^3.0.0-rc.8",
77
- "ansispeck": "^0.1.2"
76
+ "@kjanat/dreamcli": "^3.0.1",
77
+ "ansispeck": "^0.4.1"
78
78
  },
79
79
  "devDependencies": {
80
- "@biomejs/biome": ">=2.5,<2.5.3",
80
+ "@biomejs/biome": ">=2.5.5",
81
81
  "@types/bun": "^1.3",
82
82
  "@types/node": "^26",
83
- "runner-run": "^0.19.1",
83
+ "runner-run": "^0.21",
84
84
  "statuspage.io": "^3.5",
85
85
  "tsdown": "^0.22",
86
86
  "typescript": "^7"