create-questpie-app
Version:
Bootstrap a new QUESTPIE Studio application with your choice of template and packages
4 lines • 2.71 kB
JavaScript
import e from"node-fetch";const t=`https://packages.eu-central-1.questpie.xyz`,n=`https://registry.eu-central-1.questpie.xyz`;async function r(n){if(!n)throw Error(`Registry token is required to fetch available packages`);try{let r=await e(`${t}/api/me`,{headers:{Authorization:`Bearer ${n}`,Accept:`application/json`}});if(!r.ok)throw r.status===401?Error(`Invalid registry token. Please check your token and try again.`):r.status===403?Error(`Access denied. Your token does not have sufficient permissions.`):r.status>=500?Error(`QUESTPIE packages service is currently unavailable. Please try again later.`):Error(`Failed to fetch packages: ${r.status} ${r.statusText}`);let i=await r.json();if(!i.accessiblePackages||i.accessiblePackages.length===0)throw Error(`Your account does not have access to any QUESTPIE packages. Please contact your administrator to grant package access.`);let a=i.accessiblePackages.map(e=>{let t=e.name.replace(`@questpie/`,``),n=t===`core`||t===`auth`;return{name:t,version:e.latestVersion||`latest`,description:e.description,isCore:n,metadata:e.metadata}}),o=a.some(e=>e.name===`core`);if(!o){let e=[];throw o||e.push(`@questpie/core`),Error(`Your account does not have access to required core packages: ${e.join(`, `)}. Please contact your administrator to grant access to these packages.`)}return a}catch(e){throw e instanceof Error&&(e.message.includes(`Registry token is required`)||e.message.includes(`Invalid registry token`)||e.message.includes(`Access denied`)||e.message.includes(`does not have access`))?e:Error(`Failed to fetch available packages. Please check your network connection and try again. If the problem persists, the QUESTPIE packages service may be temporarily unavailable.`)}}function i(e){let t=[`core`,`auth`];return e===`web`?[...t,`web`]:t}function a(e,t){let n={},r=t.filter(e=>e.isCore);for(let e of r)n[`@questpie/${e.name}`]=e.version;for(let r of e){let e=t.find(e=>e.name===r);e&&!e.isCore&&(n[`@questpie/${e.name}`]=e.version)}return n}function o(e){return`@questpie:registry=${n}/
//${n.replace(`https://`,``)}/:_authToken="${e}"
`}async function s(n){try{let r=await e(`${t}/api/me`,{headers:{Authorization:`Bearer ${n}`,Accept:`application/json`}});if(!r.ok)return r.status===401?{isValid:!1,error:`Invalid token`}:r.status===403?{isValid:!1,error:`Access denied`}:{isValid:!1,error:`Service unavailable`};let i=await r.json();return{isValid:!0,clientName:i.entity.name,packageCount:i.totalPackages}}catch{return{isValid:!1,error:`Network error`}}}export{o as generateNpmrcContent,r as getAvailablePackages,i as getDefaultPackagesForTemplate,a as resolveDependencies,s as validateTokenAccess};
//# sourceMappingURL=package-manager.js.map