@redocly/cli 2.43.3 → 2.44.1

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.
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{c as p}from"./P26PQ2RU.js";import{a as O}from"./RS5PUOTT.js";import{a as R}from"./A7L35TO3.js";import{a as I}from"./O6MCQRCP.js";import{G as T,I as w,O as a}from"./DLYUMFFQ.js";import{e as C}from"./RFWIIJFG.js";import{Buffer as P}from"node:buffer";import y from"node:crypto";import{mkdirSync as j,existsSync as F,writeFileSync as q,readFileSync as z,rmSync as M}from"node:fs";import{homedir as H}from"node:os";import B from"node:path";var l={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function G(){return process.env.REDOCLY_DOMAIN||l.us}var U=D((o,e)=>{try{let t=e||o?.resolvedConfig.residency;return W(t)?l[t]:t?new URL(t).origin:o?.resolvedConfig.scorecard?.fromProjectUrl?new URL(o.resolvedConfig.scorecard.fromProjectUrl).origin:l.us}catch{throw new f}});function x(o){try{U(void 0,o)}catch{return!1}return!0}function D(o){return(...e)=>{let t=o(...e);if(!t.startsWith("https://"))throw new f;return t}}var f=class extends Error{constructor(){super("Invalid Reunite URL")}};function W(o){return typeof o=="string"&&o in l}import*as k from"node:child_process";var g=C(I(),1);var N=C(O(),1);function b(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function S(o){let e=process.env.NO_PROXY||process.env.no_proxy;if(!e)return!1;let t=e.split(",").map(s=>s.trim().toLowerCase()).filter(Boolean);if(t.length===0)return!1;let r;try{r=new URL(o).hostname.toLowerCase()}catch{return!1}return t.some(s=>!!(s==="*"||r===s||s.startsWith(".")&&r.endsWith(s)||!s.startsWith(".")&&r.endsWith("."+s)))}var _=async(o,{timeout:e,...t}={})=>{let r=b(),s=r&&!S(o),n,i=e?{connect:{timeout:e}}:{};return s?n=new g.ProxyAgent({uri:r,...i}):e&&(n=new g.Agent(i)),await fetch(o,{signal:e?AbortSignal.timeout(e):void 0,...t,dispatcher:n})};var c=class extends Error{constructor(t,r){super(t);this.status=r}status},h=class{constructor(e){this.command=e}command;sunsetWarnings=[];async request(e,t){let r={...t.headers,"user-agent":`redocly-cli/${R} ${this.command}`};try{let s=await _(e,{...t,headers:r});return this.collectSunsetWarning(s),s}catch(s){let n="Failed to fetch.";throw s.cause&&(n+=` Caused by ${s.cause.message||s.cause.name}.`),(s.code||s.cause?.code)&&(n+=` Code: ${s.code||s.cause?.code}`),new Error(n)}}collectSunsetWarning(e){let t=this.getSunsetDate(e);if(!t)return;let r=new Date(t);t>Date.now()?this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!1}):this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!0})}getSunsetDate(e){let{headers:t}=e;if(!t)return;let r=t.get("sunset")||t.get("Sunset");if(r)return Date.parse(r)}},v=class{constructor(e,t,r){this.client=e;this.domain=t;this.apiKey=r}client;domain;apiKey;async getParsedResponse(e){let t=await e.json();if(e.ok)return t;throw new c(`${t.title||e.statusText||"Unknown error"}.`,e.status)}async getDefaultBranch(e,t){try{let r=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/source`,{timeout:p,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return(await this.getParsedResponse(r)).branchName}catch(r){let s=`Failed to fetch default branch. ${r.message}`;throw r instanceof c?new c(s,r.status):new Error(s)}}async upsert(e,t,r){try{let s=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/remotes`,{timeout:p,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({mountPath:r.mountPath,mountBranchName:r.mountBranchName,type:"CICD",autoMerge:!0})});return await this.getParsedResponse(s)}catch(s){let n=`Failed to upsert remote. ${s.message}`;throw s instanceof c?new c(n,s.status):new Error(n)}}async push(e,t,r,s){let n=new globalThis.FormData;n.append("remoteId",r.remoteId),n.append("commit[message]",r.commit.message),n.append("commit[author][name]",r.commit.author.name),n.append("commit[author][email]",r.commit.author.email),n.append("commit[branchName]",r.commit.branchName),r.commit.url&&n.append("commit[url]",r.commit.url),r.commit.namespace&&n.append("commit[namespaceId]",r.commit.namespace),r.commit.sha&&n.append("commit[sha]",r.commit.sha),r.commit.repository&&n.append("commit[repositoryId]",r.commit.repository),r.commit.createdAt&&n.append("commit[createdAt]",r.commit.createdAt);for(let i of s){let u=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await L(i.stream)]);n.append(`files[${i.path}]`,u,i.path)}r.isMainBranch&&n.append("isMainBranch","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/pushes`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:n});return await this.getParsedResponse(i)}catch(i){let u=`Failed to push. ${i.message}`;throw i instanceof c?new c(u,i.status):new Error(u)}}async getRemotesList({organizationId:e,projectId:t,mountPath:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/remotes?filter=mountPath:/${r}/`,{timeout:p,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return await this.getParsedResponse(s)}catch(s){let n=`Failed to get remote list. ${s.message}`;throw s instanceof c?new c(n,s.status):new Error(n)}}async getPush({organizationId:e,projectId:t,pushId:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/pushes/${r}`,{timeout:p,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return await this.getParsedResponse(s)}catch(s){let n=`Failed to get push status. ${s.message}`;throw s instanceof c?new c(n,s.status):new Error(n)}}},$=class{apiClient;command;remotes;constructor({domain:e,apiKey:t,command:r}){this.command=r,this.apiClient=new h(this.command),this.remotes=new v(this.apiClient,e,t)}reportSunsetWarnings(){let e=this.apiClient.sunsetWarnings;if(e.length){let[{isSunsetExpired:t,sunsetDate:r}]=e.sort((n,i)=>n.isSunsetExpired!==i.isSunsetExpired?n.isSunsetExpired?-1:1:n.sunsetDate>i.sunsetDate?1:-1),s='Update to the latest version by running "npm install @redocly/cli@latest".';t?a.error(`The "${this.command}" command is not compatible with your version of Redocly CLI. ${s}
7
+ import{c as p}from"./P26PQ2RU.js";import{a as O}from"./RS5PUOTT.js";import{a as R}from"./KWC7BG2V.js";import{a as I}from"./BXI4SF2U.js";import{G as T,I as w,O as a}from"./XJCGCKLR.js";import{e as C}from"./RFWIIJFG.js";import{Buffer as P}from"node:buffer";import y from"node:crypto";import{mkdirSync as j,existsSync as F,writeFileSync as q,readFileSync as z,rmSync as M}from"node:fs";import{homedir as H}from"node:os";import B from"node:path";var l={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function G(){return process.env.REDOCLY_DOMAIN||l.us}var U=D((o,e)=>{try{let t=e||o?.resolvedConfig.residency;return W(t)?l[t]:t?new URL(t).origin:o?.resolvedConfig.scorecard?.fromProjectUrl?new URL(o.resolvedConfig.scorecard.fromProjectUrl).origin:l.us}catch{throw new f}});function x(o){try{U(void 0,o)}catch{return!1}return!0}function D(o){return(...e)=>{let t=o(...e);if(!t.startsWith("https://"))throw new f;return t}}var f=class extends Error{constructor(){super("Invalid Reunite URL")}};function W(o){return typeof o=="string"&&o in l}import*as k from"node:child_process";var g=C(I(),1);var N=C(O(),1);function b(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function S(o){let e=process.env.NO_PROXY||process.env.no_proxy;if(!e)return!1;let t=e.split(",").map(s=>s.trim().toLowerCase()).filter(Boolean);if(t.length===0)return!1;let r;try{r=new URL(o).hostname.toLowerCase()}catch{return!1}return t.some(s=>!!(s==="*"||r===s||s.startsWith(".")&&r.endsWith(s)||!s.startsWith(".")&&r.endsWith("."+s)))}var _=async(o,{timeout:e,...t}={})=>{let r=b(),s=r&&!S(o),n,i=e?{connect:{timeout:e}}:{};return s?n=new g.ProxyAgent({uri:r,...i}):e&&(n=new g.Agent(i)),await fetch(o,{signal:e?AbortSignal.timeout(e):void 0,...t,dispatcher:n})};var c=class extends Error{constructor(t,r){super(t);this.status=r}status},h=class{constructor(e){this.command=e}command;sunsetWarnings=[];async request(e,t){let r={...t.headers,"user-agent":`redocly-cli/${R} ${this.command}`};try{let s=await _(e,{...t,headers:r});return this.collectSunsetWarning(s),s}catch(s){let n="Failed to fetch.";throw s.cause&&(n+=` Caused by ${s.cause.message||s.cause.name}.`),(s.code||s.cause?.code)&&(n+=` Code: ${s.code||s.cause?.code}`),new Error(n)}}collectSunsetWarning(e){let t=this.getSunsetDate(e);if(!t)return;let r=new Date(t);t>Date.now()?this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!1}):this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!0})}getSunsetDate(e){let{headers:t}=e;if(!t)return;let r=t.get("sunset")||t.get("Sunset");if(r)return Date.parse(r)}},v=class{constructor(e,t,r){this.client=e;this.domain=t;this.apiKey=r}client;domain;apiKey;async getParsedResponse(e){let t=await e.json();if(e.ok)return t;throw new c(`${t.title||e.statusText||"Unknown error"}.`,e.status)}async getDefaultBranch(e,t){try{let r=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/source`,{timeout:p,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return(await this.getParsedResponse(r)).branchName}catch(r){let s=`Failed to fetch default branch. ${r.message}`;throw r instanceof c?new c(s,r.status):new Error(s)}}async upsert(e,t,r){try{let s=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/remotes`,{timeout:p,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({mountPath:r.mountPath,mountBranchName:r.mountBranchName,type:"CICD",autoMerge:!0})});return await this.getParsedResponse(s)}catch(s){let n=`Failed to upsert remote. ${s.message}`;throw s instanceof c?new c(n,s.status):new Error(n)}}async push(e,t,r,s){let n=new globalThis.FormData;n.append("remoteId",r.remoteId),n.append("commit[message]",r.commit.message),n.append("commit[author][name]",r.commit.author.name),n.append("commit[author][email]",r.commit.author.email),n.append("commit[branchName]",r.commit.branchName),r.commit.url&&n.append("commit[url]",r.commit.url),r.commit.namespace&&n.append("commit[namespaceId]",r.commit.namespace),r.commit.sha&&n.append("commit[sha]",r.commit.sha),r.commit.repository&&n.append("commit[repositoryId]",r.commit.repository),r.commit.createdAt&&n.append("commit[createdAt]",r.commit.createdAt);for(let i of s){let u=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await L(i.stream)]);n.append(`files[${i.path}]`,u,i.path)}r.isMainBranch&&n.append("isMainBranch","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/pushes`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:n});return await this.getParsedResponse(i)}catch(i){let u=`Failed to push. ${i.message}`;throw i instanceof c?new c(u,i.status):new Error(u)}}async getRemotesList({organizationId:e,projectId:t,mountPath:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/remotes?filter=mountPath:/${r}/`,{timeout:p,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return await this.getParsedResponse(s)}catch(s){let n=`Failed to get remote list. ${s.message}`;throw s instanceof c?new c(n,s.status):new Error(n)}}async getPush({organizationId:e,projectId:t,pushId:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/pushes/${r}`,{timeout:p,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return await this.getParsedResponse(s)}catch(s){let n=`Failed to get push status. ${s.message}`;throw s instanceof c?new c(n,s.status):new Error(n)}}},$=class{apiClient;command;remotes;constructor({domain:e,apiKey:t,command:r}){this.command=r,this.apiClient=new h(this.command),this.remotes=new v(this.apiClient,e,t)}reportSunsetWarnings(){let e=this.apiClient.sunsetWarnings;if(e.length){let[{isSunsetExpired:t,sunsetDate:r}]=e.sort((n,i)=>n.isSunsetExpired!==i.isSunsetExpired?n.isSunsetExpired?-1:1:n.sunsetDate>i.sunsetDate?1:-1),s='Update to the latest version by running "npm install @redocly/cli@latest".';t?a.error(`The "${this.command}" command is not compatible with your version of Redocly CLI. ${s}
8
8
 
9
9
  `):a.warn(`The "${this.command}" command will be incompatible with your version of Redocly CLI after ${r.toLocaleString()}. ${s}
10
10