Lines 1-61javascript
2var ii=Object.create;var We=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var oi=Object.getOwnPropertyNames;var ai=Object.getPrototypeOf,ci=Object.prototype.hasOwnProperty;var ae=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},li=(r,e)=>{for(var t in e)We(r,t,{get:e[t],enumerable:!0})},sn=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of oi(e))!ci.call(r,s)&&s!==t&&We(r,s,{get:()=>e[s],enumerable:!(i=ri(e,s))||i.enumerable});return r};var K=(r,e,t)=>(t=r!=null?ii(ai(r)):{},sn(e||!r||!r.__esModule?We(t,"default",{valu ...
3`)}displayWidth(e){return rn(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOpti ...
4`+" ".repeat(t+c)),o+a+" ".repeat(c)+u.replace(/\n/g,`
5${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let i=e.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,n=[];return i.forEach(o=>{let a=o.match(s);if(a===null){n.push("");return}let c=[a.shift()],l=this.displayWidth(c[0]);a.forEach(d=>{let u=this.displayWidth(d);if(l+u<=t){c.push(d),l+=u;return}n.push(c.join(""));let h=d.trimStart();c=[h],l=this.displayWidth(h)}),n.push(c.join(""))}),n.join(`
6`)}};function rn(r){let e=/\x1b\[\d*(;\d*)*m/g;return r.replace(e,"")}$t.Help=wt;$t.stripColor=rn});var xt=ae(Ct=>{var{InvalidArgumentError:mi}=De(),vt=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>
7- a short flag is a single dash and a single character
8 - either use a single dash and a single character (for a short flag)
9 - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(o)?new Error(`${a}
10- too many short flags`):s.test(o)?new Error(`${a}
11- too many long flags`):new Error(`${a}
12- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${r}'.`);return{shortFlag:e,longFlag:t}}Ct.Option=vt;Ct.DualOptions=St});var cn=ae(an=>{function gi(r,e){if(Math.abs(r.length-e.length)>3)return Math.max(r.length,e.length);let t=[];for(let i=0;i<=r.length;i++)t[i]=[i];for(let i=0;i<=e.length;i++)t[0][i]=i;for(let i=1;i<=e.length;i++)for(let s=1;s<=r.length;s++){let n=1;r[s-1]===e[i-1]?n=0:n=1,t[s][i]=Math.min(t[s-1][i]+1,t[s][i-1]+1,t[s-1][i-1]+n),s>1&&i>1&&r[s-1]===e[i-2]&&r[s-2]===e[i-1]&&(t[s][i]=Math.min(t[s][i],t[s-2][ ...
13(Did you mean one of ${i.join(", ")}?)`:i.length===1?`
14(Did you mean ${i[0]}?)`:""}an.suggestSimilar=yi});var hn=ae(It=>{var bi=require("node:events").EventEmitter,At=require("node:child_process"),ue=require("node:path"),Ge=require("node:fs"),D=require("node:process"),{Argument:wi,humanReadableArgName:$i}
15- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new wi(e,t)}argument(e,t,i,s){let n=this.createArgument(e,t);return typeof i=="function"?n.default(s).argParser(i):n.default(i),this.addArgument(n),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last ...
HighChild Process
Package source references child process execution.
bin/chainabit.cjsView on unpkg · L13 16Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new _t(e,t,i)),D.exit(e)}action(e){let t=i=>{let s=this.registeredArguments.length,n=i.slice(0,s);return this._storeOptionsAsProperties?n[s]=this:n[s]=this.opts(),n.push(this),e.apply(this,n)};return this._actionHandler=t,this}createOption(e,t){return new ln(e,t)}_callParseArg(e,t,i ...
17- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=s=>[s.name()].concat(s.aliases()),i=t(e).find(s=>this._findCommand(s));if(i){let s=t(this._findCommand(i)).join("|"),n=t(e).
18- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,i){if(Ge.existsSync(e))return;let s=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",n=`'${e}' does not exist
19 - if '${i}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
20 - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
21 - ${s}`;throw new Error(n)}_executeSubCommand(e,t){t=t.slice();let i=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function n(d,u){let h=ue.resolve(d,u);if(Ge.existsSync(h))return h;if(s.includes(ue.extname(u)))return;let m=s.find(f=>Ge.existsSync(`${h}${f}`));if(m)return`${h}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let d;try{d=Ge.realpathSync(this._scriptPath)}catch{d=this._scriptPath}a=ue.resolve(ue.dirname(d),a)}if(a){let d=n(a,o);if(!d&&!e._executableFile&&t ...
22`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
23`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
24`),this.outputHelp({error:!0}));let i=t||{},s=i.exitCode||1,n=i.code||"commander.error";this._exit(s,n,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in D.env){let t=e.attributeName();(this.getOptionValue(t)
25`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(e);if(i){let s=[i.name()].concat(i.aliases()).join("|");throw new Error(` ...
26Expecting one of '${i.join("', '")}'`);let s=`${e}Help`;return this.on(s,n=>{let o;typeof t=="function"?o=t({error:n.error,command:n.command}):o=t,o&&n.write(`${o}
27`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function un(r){return r.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",s="9229",n;return(n=e.match(/^(--inspect(-brk)?)$/))!==null?t=n[1]:(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=n[1],/^\d+$/.test(n[3])?s=n[3]:i=n[3]):(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=n[1],i=n[3],s=n[4]),t&&s!=="0"?`${t}=${i}:${parseInt(s)+1}`:e})}function Rt(){if(D.env.NO_COLOR||D.env.FORCE_COL ...
28`);let i;for(;(i=Ui.exec(t))!=null;){let s=i[1],n=i[2]||"";n=n.trim();let o=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),o==='"'&&
29`),n=n.replace(/\\r/g,"\r")),e[s]=n}return e}function Vi(r){r=r||{};let e=Tn(r);r.path=e;let t=G.configDotenv(r);if(!t.parsed){let o=new Error(`MISSING_DATA: Cannot parse ${e} for an unknown reason`);throw o.code="MISSING_DATA",o}let i=In(r).split(","),s=i.length,n;for(let o=0;o<s;o++)try{let a=i[o].trim(),c=Wi(t,a);n=G.decrypt(c.ciphertext,c.key);break}catch(a){if(o+1>=s)throw a}return G.parse(n)}function Fi(r){console.log(`[dotenv@${jt}][WARN] ${r}`)}function Ne(r){console.log(`[dotenv@${jt}][DEBUG] ${r}`)}function Rn(r){console.log(`[dotenv@${jt}] ${r}`)}function In(r){return r&&r.DOTENV_KE ...
30`,{encoding:"utf-8",mode:384}),Mt(ye,384)}function we(r){if(r)return r;if(process.env.CHAINABIT_BASE_URL)return process.env.CHAINABIT_BASE_URL;if(process.env.CHAINABIT__API_BASE_URL){let e=process.env.CHAINABIT__API_BASE_URL.replace(/\/+$/,
31`,{encoding:"utf-8",mode:384})}function Ae(){return ye}var Ai=3,_i=1e3,W=class{baseUrl;token;constructor(e,t){this.baseUrl=we(e).replace(/\/+$/,""),this.token=
32${I("\u2717",`${q}${Le}`)} ${I(r,q)}`),t&&t.length>0){console.error(""),console.error(I(" Suggestions:",`${q}`));for(let i of t)console.error(` ${I("\xB7",U)} ${i.message}`),i.command&&console.error(` ${I("$",U)} ${I(i.command,`${U}${q}`)}`);console.error("")}process.exit(1)}function ee(r){if(!_e()){console.log(` \u2192 ${r}`);return}console.log(` ${I
33 [ ${r} ]`);for(let a of e)console.log(` | ${a}`);console.log("");return}let i=Math.max(r.length,...e.map(a=>a.length),36)+2,s=`\u256D${"\u2500".repeat(i)}\u256E`,n=`\u251C${"\u2500".repeat(i)}\u2524`,o=`\u2570${"\u2500".repeat(i)}\u256F`;if(console.log(""),console.log(I(s,U)),console.log(`${I("\u2502",U)} ${I(r,`${q}${Y
34`)),this}succeed(e){return this.stop("\u2713",zi,e)}fail(e){return this.stop("\u2717",Xi,e)}warn(e){return this.stop("\u26A0",Qi,e)}info(e){return this.stop("\xB7",Zi,e)}render(){let e=Pn[this.frameIndex%Pn.length];this.frameIndex++,process.stdout.write(`\r${er}${e}${jn} ${this.label}`)}};async function V(r,e,t){let i=new Ee(r);t?.jsonMode||i.start();try{let s=await e();return t?.jsonMode||i.succeed(t?.successLabel),s}catch(s){throw t?.jsonMode||i.fail(),s}}function Bn(r){let e=r.split(/\r?\n/).map(n=>n.trimEnd()).filter(n=>n.length>0);if(e.length===0)return null;let t,i="message",s=[];for(let ...
35`)}}async function*Pe(r){if(!r.body)return;let e=r.body.getReader(),t=new TextDecoder("utf-8"),i="";for(;;){let{done:n,value:o}=await e.read();if(n)break;for(i+=t.decode(o,{stream:!0});;){let a=i.indexOf(`
37`);if(a===-1)break;let c=i.slice(0,a);i=i.slice(a+2);let l=Bn(c);l&&(yield l)}}let s=Bn(i);s&&(yield s)}var nr={isLocal:!1,isDebug:!1,commandStartMs:Date.now()};function Un(r){Object.assign(nr,r)}var Rs=K(require("os"));var Ut=K(require("readline")),Gn=require("child_process");var Xe=K(require("fs")),Hn=K(require("path"));async function Re(r){let e=Bt(r.directValue),t=Bt(r.envVar),i=Bt(r.filePath);if(+!!e+ +!!r.stdin+ +!!t+ +!!i>1&&w(`Use only one ${r.label} source at a time: direct value, --${r.label}-stdin, --${r.label}-env, or --${r.label}-file.`,r.jsonMode),e)return{value:e,source:"direct" ...
38`):process.stdout.write(s+`
39`)})}function hr(r,e){e.command("device").description("Start browser device-approval flow explicitly.").option("--no-open","Do not auto-open the browser").action(async t=>{let i=r.opts().json??!1,s=r.opts().apiUrl,n=new W(s);await
40`):($e("API key created \u2014 save this now, it will not be shown again",[`Token ${I(u.token,q)}`,`Preview ${u.tokenPreview}`,`Scopes ${Array.isArray(u.scopes)&&u.scopes.length>0?u.scopes.join(", "):"execution:run"}`,`Kind ${u.tokenKind??"account_bearer"}`,`Expires ${u.expiresAt}`]),ee(`export CHAINABIT_TOKEN=${u.tokenPreview.replace(/\*+/,"\u2026")}`),ee("chainabit workspace use <workspace-id>"))}catch(l){throw l instanceof N&&w(l.message,n),l}}),t.command("list").description("List all API keys for the current account.").action(async i=>{let s=r.opts().json??!1,n=r.opts().apiUrl,o ...
41`):($e("API key created \u2014 save this now, it will not be shown again",[`Token ${I(u.token,q)}`,`Preview ${u.tokenPreview}`,`Scopes ${Array.isArray(u.scopes)&&u.scopes.length>0?u.scopes.join(", "
42USAGE chainabit auth login|logout|whoami|refresh|token|device|developer-token|keys|register
45 login Authenticate with your Chainabit account. Omit flags for browser login.
46 logout Clear stored credentials and invalidate the server session.
47 whoami Show the currently authenticated user.
48 refresh Force-refresh the stored access token.
49 token Print the raw access token (for piping).
50 device Start browser device-approval flow explicitly.
51developer-token Manage API keys for CI/CD and project automation (create, list, revoke).
52 keys Alias for developer-token.
53 register Create a new Chainabit account.
56 chainabit auth login # browser login (default in TTY)
57 chainabit auth login --no-open # print URL + code, no auto-browser
58 chainabit auth login --token-env CHAINABIT_TOKEN # non-interactive
60 chainabit auth token | pbcopy # copy token to clipboard (macOS)
61 chainabit auth keys create "ci-deploy" --ttl 90 --scope execution:run
Long lines were clipped for display.