Lines 1-33javascript
2var Wt=Object.defineProperty;var d=(o,e)=>Wt(o,"name",{value:e,configurable:!0});var ce,le,ue,de,pe,fe,oe;import Gt from"events";import Bt from"child_process";import Te from"path";import _,{existsSync as ge,readFileSync as nt,mkdirSync as Jt,writeFileSync as zt}from"fs";import Yt from"process";import a from"chalk";import y,{join as Kt,dirname as Zt}from"pathe";import je from"js-yaml";import Qt from"dotenv";import{defu as Xt}from"defu";import eo from"http";import to from"open";import L from"handlebars";import oo,{astToString as no}from"openapi-typescript";import F from"prompts";import rt from"o ...
3`).replace(/^/gm," ".repeat(i))}d(u,"formatList");let p=[`Usage: ${t.commandUsage(e)}`,""];const c=t.commandDescription(e);c.length>0&&(p=p.concat([t.wrap(c,r,0),""]));const f=t.visibleArguments(e).map(v=>l(t.argumentTerm(v),t.argumentDescription(v)));f.length>0&&(p=p.concat(["Arguments:",u(f),""]));const g=t.visibleOptions(e).map(v=>l(t.optionTerm(v),t.optionDescription(v)));if(g.length>0&&(p=p.concat(["Options:",u(g),""])),this.showGlobalOptions){const v=t.visibleGlobalOptions(e).map(O=>l(t.optionTerm(O),t.optionDescription(O)));v.length>0&&(p=p.concat(["Global Options:",u(v),""]))}const b=t ...
HighChild Process
Package source references child process execution.
dist/frontic.mjsView on unpkg · L1 4`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,n,r=40){const i=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",s=new RegExp(`[\\n][${i}]+`);if(e.
6`),c=" ".repeat(n),g="\\s\u200B",b=new RegExp(`
7|.{1,${l-1}}([${g}]|$)|[^${g}]+?([${g}]|$)`,"g"),v=p.match(b)||[];return u+v.map((O,T)=>O===`
8`?"":(T>0?c:"")+O.trimEnd()).join(`
9`)}},d(de,"Help"),de);Fe.Help=uo;var Ee={};const{InvalidArgumentError:po}=ie;let fo=(pe=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this
10(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
11(Did you mean ${n[0]}?)`:""}d(wo,"suggestSimilar$1"),at.suggestSimilar=wo;const bo=Gt.EventEmitter,Ne=Bt,G=Te,Ie=_,j=Yt,{Argument:$o,humanReadableArgName:_o}=ye,{CommanderError:De}=ie,{Help:vo}=Fe,{Option:lt,DualOptions:Oo}=Ee,{suggestSimilar:ut}=at;let Co=(oe=class extends bo{constructor(e
12- 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 $o(e,t)}argument(e,t,n,r){const i=this.createArgument(e,t);return typeof n=="function"?i.default(r).argParser(n):i.default(n),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){const t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the l ...
13Expecting one of '${n.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,n){this._exitCallback&&this._exitCallback(new De(e,t,n)),j.exit(e)}action(e){const t=d(n=>{const r=this.registeredArguments.length,i=n.slice(0,r);return this._storeOptionsAsProperties?i[r]=this:i[r]=this.opts(),i.push(this),e.apply(this,i)},"listener");return this._actionHandler=t,this}createOption(e,t){return new lt(e,t)}_ ...
14- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){const t=d(r=>[r.name()].concat(r.aliases()),"knownBy"),n=t(e).find(r=>this._findCommand(r));if(n){const r=t(this._findCommand(n)).join("|"),i
15 - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
16 - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
17 - ${f}`;throw new Error(g)}else if(c.code==="EACCES")throw new Error(`'${s}' not executable`);if(!p)j.exit(1);else{const f=new De(1,"commander.executeSubCommandAsync","(error)");f.nestedError=c,p(f)}}),this.runningCommand=u}_dispatchSubcommand(e,t,n){const r=this._findCommand(e);r||this.help({error:!0});let i;return i=this._chainOrCallSubCommandHook(i,r,"preSubcommand"),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();const t=this._findCommand(e);return t&&!t._executableHandler ...
18`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
19`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
20`),this.outputHelp({error:!0}));const n=t||{},r=n.exitCode||1,i=n.code||"commander.error";this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in j.env){const t=e.attributeName();(this.getOptionValue(t)===void
21`),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");const n=this.parent?._findCommand(e);if(n){const r=[n.name()].concat(n.aliases()).join("|");throw new Err ...
22Expecting one of '${n.join("', '")}'`);const r=`${e}Help`;return this.on(r,i=>{let s;typeof t=="function"?s=t({error:i.error,command:i.command}):s=t,s&&i.write(`${s}
23`)}),this}_outputHelpIfRequested(e){const t=this._getHelpOption();t&&e.find(r=>t.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}},d(oe,"Command"),oe);function dt(o){return o.map(e=>
24Run ${a.hex("#7c3bed")("frontic project")} to select a Frontic project`);return process.env.NODE_TLS_REJECT_UNAUTHORIZED=process.env.FRONTIC_CLI_DEV_MODE?"0":"1",await N(Cn,{method:"GET",headers:{"Content-Type":"application/yaml",Authorization:`Bearer ${r()}`,"FS-Project":h},parseResponse:d($=>{try{return je.load($)}catch{throw new Error("Invalid API specification. The API specification must be a valid YAML file.")}},"parseResponse")})}catch(m){throw"data"in m&&"message"in m.data?new Error(`Server error: ${m.data.message}`):m}},"getFetchApiSpec"),r=d(()=>{const h=y.join(B,We);return _.existsSy ...
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
dist/frontic.mjsView on unpkg · L13 25Run ${a.hex("#7c3bed")("frontic project")} to select a Frontic project`);process.env.NODE_TLS_REJECT_UNAUTHORIZED=process.env.FRONTIC_CLI_DEV_MODE?"0":"1";try{return await N(`${se}api/studio/context/skills`,{method:"GET",headers:{"Content-Type":"application/json",Cookie:`access_token=${r()}`,"FS-Project":h}})}catch{return[]}}catch(h){throw"data"in h&&"message"in h.data?new Error(`Server error: ${h.data.message}
26Run ${a.hex("#7c3bed")("frontic project")} to select a Frontic project`);process.env.NODE_TLS_REJECT_UNAUTHORIZED=process.env.FRONTIC_CLI_DEV_MODE?"0":"1";try{return await N(`${se}api/studio/context/${h}`,{method:"GET",headers:{"Content-Type":"application/json",Cookie:`access_token=${r()}`,"FS-Project":m}})}catch{return null}}catch(m){throw"data"in m&&"message"in m.data?new Error(`Server error: ${m.data.message}`):m}},"getDocument"),getSkillFiles:d(async h=>{try{const m=u();if(m==null)throw new Error(`You have no project selected
27Run ${a.hex("#7c3bed")("frontic project")} to select a Frontic project`);process.env.NODE_TLS_REJECT_UNAUTHORIZED=process.env.FRONTIC_CLI_DEV_MODE?"0":"1";try{return await N(`${se}api/studio/context/${h}/files`,{method:"GET",headers:{"Content-Type":"application/json",Cookie:`access_token=${r()}`,"FS-Project":m}})}catch{return[]}}catch(m){throw"data"in m&&"message"in m.data?new Error(`Server error: ${m.data.message}`):m}},"getSkillFiles"),downloadSkillFile:d(async(h,m)=>{try{const $=u();if($==null)throw new Error(`You have no project selected
28Run ${a.hex("#7c3bed")("frontic project")} to select a Frontic project`);process.env.NODE_TLS_REJECT_UNAUTHORIZED=process.env.FRONTIC_CLI_DEV_MODE?"0":"1";try{return await N(`${se}api/studio/context/${h}/files/${m}/download`,{method:"GET",responseType:"arrayBuffer",headers:{Cookie:`access_token=${r()}`,"FS-Project":$}})}catch{return null}}catch($){throw"data"in $&&"message"in $.data?new Error(`Server error: ${$.data.message}`):$}},"downloadSkillFile"),getRules:d(async()=>{try{const h=u();if(h==null)throw new Error(`You have no project selected
29Run ${a.hex("#7c3bed")("frontic project")} to select a Frontic project`);process.env.NODE_TLS_REJECT_UNAUTHORIZED=process.env.FRONTIC_CLI_DEV_MODE?"0":"1";try{return await N(`${se}api/studio/context/rules`,{method:"GET",headers:{"Content-Type":"application/json",Cookie:`access_token=${r()}`,"FS-Project":h}})}catch(m){if(m?.status===404)return[];throw m}}catch(h){throw"data"in h&&"message"in h.data?new Error(`Server error: ${h.data.message}`):h}},"getRules"),getProjectRules:d(async()=>{try{const h=u();if(h==null)throw new Error(`You have no project selected
30Run ${a.hex("#7c3bed")("frontic project")} to select a Frontic project`);process.env.NODE_TLS_REJECT_UNAUTHORIZED=process.env.FRONTIC_CLI_DEV_MODE?"0":"1";try{return await N(`${se}api/studio/context/system/studio-rules`,{method:"GET",headers:{"Content-Type":"application/json",Cookie:`access_token=${r()}`,"FS-Project":h}})}catch(m){if(m?.status===404)return null;throw m}}catch(h){throw"data"in h&&"message"in h.data?new Error(`Server error: ${h.data.message}`):h}},"getProjectRules")}},"auth"),jt=d(()=>{const o=d(t=>{const n=y.join(t,"metadata.json");if(_.existsSync(n)){const r=_.readFileSync(n," ...
31`+f.error);let g="";try{g=no(await oo(f))}catch(O){throw new Error(`Invalid API Specification: ${O.message}`)}const b=i({paths:f.paths,components:f.components}),v=u({components:f.components,paths:f.paths,servers:f.servers,namespace:vn()?"Frontstack":"Frontic"});return{_schemaTypes:g,_types:b,_client:v,_query:c,_specFile:f}},"generate");const tt=class tt extends Error{constructor(e){super(e),this.name="AccessError"}};d(tt,"AccessError");let ee
32See ${e.docs}`:"";throw new ee(`${l}${u}`)}d(_e,"requireFeatureFlag");async function xe(o,e={}){const t=await xt();if(!t)throw new ee("Not logged in. Run `frontic login` first.");const n=t.permissions;if((Array.isArray(n)?n:[]).includes(o))return;const i=e.cta??(e.action?`Your account doesn't have permission for ${e.action}.`:`Your account doesn't have the "${o}" permission.`);throw new ee(`${i}
33Ask an organization admin to grant "${o}".`)}d(xe,"requirePermission");var Rt=Object.freeze({__proto__:null,AccessError:ee,ensureLoggedIn:ae,ensureProjectSelected:At,hasFeatureFlag:kt,requireFeatureFlag:_e,requirePermission:xe,requireStudioAccess:St,setInteractive:U});const{getProjects:Nn,writeProject:Je}=I(),ze=d(async o=>{let e=o.project??void 0;if(!await ae()){console.log(`You are not logged in. Please run ${a.hex("#7c3bed")("frontic login")} to login`);return}let n=[];try{n=await Nn()}catch{console.log(`You are not logged in. Please run ${a.hex("#7c3bed")("frontic login")} to login`);retur ...
Long lines were clipped for display.