prismic 1.27.0 → 1.28.0
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.
- package/dist/adapters-_6OwtgCL.mjs +197 -0
- package/dist/index.mjs +96 -96
- package/dist/{nextjs-C5Tecr6K.mjs → nextjs-CiU-wONg.mjs} +52 -52
- package/dist/{nuxt-Dv-vPR1I.mjs → nuxt-BNM57THK.mjs} +7 -7
- package/dist/package-DPO7tnYd.mjs +1 -0
- package/dist/packageJson-Du_fIYqH.mjs +32 -0
- package/dist/{segment-B4vS06Kb.mjs → segment-BW5d22g2.mjs} +1 -1
- package/dist/subprocesses/sendSegmentEvents.mjs +1 -1
- package/dist/subprocesses/updateVersionState.mjs +1 -1
- package/dist/{sveltekit-CuRs_Ytj.mjs → sveltekit-BvwbM55F.mjs} +26 -26
- package/dist/sveltekit-C5og1T-S.mjs +1 -0
- package/dist/{sveltekit2-C_afy31M.mjs → sveltekit2-CVfxQ2tH.mjs} +7 -7
- package/dist/update-notifier-CaPWDsNo.mjs +1 -0
- package/package.json +9 -6
- package/dist/adapters-CH12Bn8O.mjs +0 -189
- package/dist/auth-dqtuCJNc.mjs +0 -2
- package/dist/package-DruwThDN.mjs +0 -1
- package/dist/packageJson-uZy38HFJ.mjs +0 -2
- package/dist/request-BlAQgJGK.mjs +0 -31
- package/dist/subprocesses/refreshToken.mjs +0 -1
- package/dist/sveltekit-DJ5rpjcZ.mjs +0 -1
- package/dist/update-notifier-DUA88jNO.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{n as e,t}from"./package-
|
|
2
|
+
import{n as e,t}from"./package-DPO7tnYd.mjs";import{$ as n,$t as r,A as i,At as a,B as o,Bt as s,C as c,Ct as l,D as u,Dt as d,E as f,Et as p,F as m,Ft as h,G as g,Gt as _,H as v,Ht as y,I as b,It as x,J as ee,Jt as S,K as te,Kt as C,L as w,Lt as ne,M as T,Mt as re,N as ie,Nt as ae,O as oe,Ot as se,P as ce,Pt as le,Q as ue,R as de,Rt as fe,S as E,St as pe,T as me,Tt as he,U as ge,Ut as _e,V as ve,Vt as ye,W as D,Wt as be,X as xe,Xt as O,Y as Se,Yt as Ce,Z as we,Zt as Te,_t as Ee,a as De,an as Oe,at as k,b as ke,bt as Ae,c as A,cn as je,ct as Me,dt as Ne,en as Pe,et as Fe,f as Ie,fn as j,ft as Le,g as Re,gn as ze,gt as Be,h as Ve,hn as He,ht as Ue,i as We,in as Ge,it as Ke,j as qe,jt as Je,k as Ye,kt as Xe,l as M,ln as Ze,lt as Qe,m as $e,mn as N,mt as et,n as tt,nn as nt,nt as rt,o as it,on as at,ot,p as st,pn as ct,pt as lt,q as P,qt as F,r as I,rn as ut,rt as dt,sn as ft,st as pt,tn as mt,tt as ht,un as gt,ut as _t,v as vt,vt as yt,w as bt,wt as xt,x as L,xt as St,y as Ct,yt as wt,z as Tt,zt as Et}from"./adapters-_6OwtgCL.mjs";import{C as Dt,D as Ot,E as kt,H as At,K as jt,M as R,N as z,O as B,R as Mt,S as Nt,T as Pt,X as V,Y as Ft,_ as It,c as Lt,d as Rt,f as zt,i as Bt,it as Vt,j as Ht,k as Ut,l as H,o as Wt,p as U,q as W,t as Gt,u as Kt,v as qt,w as G,x as Jt}from"./packageJson-Du_fIYqH.mjs";import{t as Yt}from"./update-notifier-CaPWDsNo.mjs";import{isDeepStrictEqual as Xt,parseArgs as Zt}from"node:util";import{realpath as Qt,rm as $t}from"node:fs/promises";import{fileURLToPath as en,pathToFileURL as tn}from"node:url";import{createHash as nn,randomBytes as rn}from"node:crypto";import{setTimeout as an}from"node:timers/promises";const on=W({error:At(`invalid_auth_context`)});function sn(e){return e instanceof B&&Vt(on,e.body).success}const cn={expired:`The login code expired. Run the command again.`,declined:`The login was declined in the browser.`,"email-unverified":`Prismic sent you an email to verify your address. Verify it, then run the command again.`,"invalid-grant":`The login code was already used or isn't valid. Run the command again.`,unavailable:`Can't reach the Prismic login service. Check your connection, then run the command again.`};async function ln(e){if(e instanceof ft)return e.reason===`misconfigured`?`Login isn't set up correctly for ${await D()} (${e.detail}). Report this: https://github.com/prismicio/cli/issues`:cn[e.reason];if(e instanceof B||e instanceof G)return await g().catch(()=>void 0)?j.PRISMIC_TOKEN?sn(e)?"This token cannot run administrative commands. Unset PRISMIC_TOKEN and run `prismic login`.":`PRISMIC_TOKEN is invalid or expired, or doesn't have access to this repository. Unset it to log in with a browser, or replace it with a valid token.`:e instanceof B?"Your session is invalid or expired. Run `prismic login` to sign in again.":`You do not have access to this repository. Check the repository name or log in with an account that has access.`:"Not logged in. Run `prismic login` first.";if(e instanceof Pt)return`Can't reach Prismic. Check your connection, then run the command again.`;if(e instanceof Dt||e instanceof Ut){let t=new URL(e.response.url);t.search=``;let n=e.message?`${e.message}\n\n`:``;return Te`
|
|
3
3
|
${n}Prismic responded with an unexpected error. Try again, and report it if it keeps happening.
|
|
4
4
|
|
|
5
5
|
Status: ${e.status} ${e.statusText}
|
|
6
6
|
URL: ${t}
|
|
7
7
|
Report: https://github.com/prismicio/cli/issues
|
|
8
|
-
`}if(e instanceof Error)return
|
|
8
|
+
`}if(e instanceof Error)return Te(e.message)}const un=j.PRISMIC_SYNC_POLL_MS??5e3;var dn=F({name:`prismic dev`,description:`
|
|
9
9
|
Edit local content types and slices visually in the Type Builder.
|
|
10
10
|
|
|
11
11
|
Type Builder changes are saved to local files, and local file changes
|
|
@@ -15,40 +15,40 @@ import{n as e,t}from"./package-DruwThDN.mjs";import{$ as n,A as r,B as i,C as a,
|
|
|
15
15
|
background and give the user the URL from its "Type Builder:" line.
|
|
16
16
|
|
|
17
17
|
@experimental - This command may change or be removed in any release and does not follow semver.
|
|
18
|
-
`,options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},continue:{type:`boolean`,description:`Continue the previous session`},new:{type:`boolean`,description:`Start a new session, even if the previous one has unpulled changes`},"no-browser":{type:`boolean`,description:`Skip opening the Type Builder in the browser`}}},async({values:e})=>{
|
|
19
|
-
`);let h,g=e=>{e!==h&&
|
|
20
|
-
Ending the session...`),await
|
|
18
|
+
`,options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},continue:{type:`boolean`,description:`Continue the previous session`},new:{type:`boolean`,description:`Start a new session, even if the previous one has unpulled changes`},"no-browser":{type:`boolean`,description:`Skip opening the Type Builder in the browser`}}},async({values:e})=>{O(e,[`continue`,`new`]);let t=await M(),{repo:n=await t.getEnvironment()??await E(),continue:r,new:i,"no-browser":a}=e,o=await D(),s=await fn(),c=await _n(t,s,{host:o,continueSession:r,newSession:i}),l;c?(l={...c,pid:process.pid},console.info(`Continuing your session for ${n}...`)):(console.info(`Preparing your session for ${n}...`),l=await hn({repo:n,getToken:g,host:o}));let u={repo:n,getToken:g,host:o,onUnauthorized:P,releaseId:l.releaseId},d=(e=!0)=>xn(t,u,l,s,{push:e,onPull:e=>q(`↓ Pulled ${En(e)}`),onPush:e=>q(`↑ Pushed ${En(e)}`),onDelete:e=>q(`− Deleted ${En(e)}`)}),f=async()=>{try{return await d(!1),await gn(u,s),!0}catch(e){return console.error(`Could not end the session: ${await ln(e)}\nRun \`prismic dev --continue\` to continue it.`),!1}},p=yn();try{let e=Jt([...await t.getCustomTypeLibraries(),...await t.getSliceLibraries()],p.signal),i=r?await d():await bn(t,u,l,s),c=i.customTypes.length,f=i.slices.length;console.info(`Ready. Loaded ${c} ${c===1?`type`:`types`} and ${f} ${f===1?`slice`:`slices`} from your project.\n`);let m=new URL(`builder/types`,`https://${n}.${o}/`);m.searchParams.set(`r`,u.releaseId),console.info(`Type Builder: ${m}`),a?console.info(`Open the URL above to start editing. Changes sync both ways while this runs.`):(Pe(m),console.info(`Opened in your browser. Changes sync both ways while this runs.`)),console.info(`Press Ctrl+C to end the session.
|
|
19
|
+
`);let h,g=e=>{e!==h&&q(`! ${e}`,console.error),h=e};await Sn(d,e,p.signal,{onSync:()=>{h=void 0},onRecover:()=>q(`Back in sync.`),onUnreachable:()=>g(`Cannot reach Prismic. Retrying...`),onError:async e=>g(await ln(On(e))??`Unknown error`)})}catch(e){throw p.abort(),await Cn(e,f)}console.info(`
|
|
20
|
+
Ending the session...`),await f()&&console.info(`Session ended.`)});async function fn(){let e=nn(`sha256`).update(en(await L())).digest(`hex`);return new URL(`dev/${e}.json`,Ze)}async function pn(e){return It(e,{schema:jn}).catch(()=>void 0)}async function mn(e,t){await Nt(e,U(t))}async function hn({repo:e,getToken:t,host:n}){return{repo:e,releaseId:(await _t({label:`prismic dev`,hidden:!0},{repo:e,getToken:t,host:n,onUnauthorized:P}).catch(e=>{throw On(e)})).id,pid:process.pid,synced:{}}}async function gn({releaseId:e,...t},n){await Ee(e,t),await $t(n,{force:!0})}async function _n(e,t,n){let{host:r,continueSession:i,newSession:a}=n,o=await pn(t);if(o&&Dn(o.pid))throw new C(`A session is already running for this project. Press Ctrl+C in its terminal to end it, or run \`kill ${o.pid}\`.`);if(i){if(!o)throw new C("There is no session to continue. Run `prismic dev` to start a new one.");return o}if(o){if(!a&&await vn(e,{repo:o.repo,getToken:g,host:r,onUnauthorized:P,releaseId:o.releaseId},o.synced))throw new C("Your last session has Type Builder changes that were not pulled.\nRun `prismic dev --continue` to continue the session, or `prismic dev --new` to start a new one without them.");await Ee(o.releaseId,{repo:o.repo,getToken:g,host:r,onUnauthorized:P}).catch(()=>{})}}async function vn(e,t,n){let r=await w(t).catch(e=>{if(!(e instanceof kt))throw On(e)}),i=K(await e.getModels());if(!r)return!1;let a=K(r);return Object.keys({...a,...n}).some(e=>a[e]!==n[e]&&a[e]!==i[e])}function yn(){let e=new AbortController;for(let t of[`SIGINT`,`SIGTERM`,`SIGHUP`,`SIGBREAK`])process.on(t,()=>{process.stdout.on(`error`,()=>{}),process.stderr.on(`error`,()=>{}),e.abort()});return e}async function bn(e,t,n,r){let i=await e.getModels(),a=await w(t);return await ve(m(i,a),t),n.synced=K(i),await mn(r,n),i}async function xn(e,t,n,r,i){let{push:a,onPull:o,onPush:s,onDelete:c}=i,[l,u]=await Promise.all([e.getModels(),w(t)]),d=K(l),f=K(u),p=wn(d,f,n.synced),h=l;if(p.pull.length>0){await e.writeModels(m(Tn(u,p.pull),Tn(l,p.pull))),await e.generateTypes(),h=await e.getModels();let t=K(h);for(let e of p.pull)e in t?n.synced[e]=t[e]:delete n.synced[e];await mn(r,n)}let g=p.pull.filter(e=>e in f);g.length>0&&o(g);let _=a?p.push:[];await ve(m(Tn(l,_),Tn(u,_)),t);let v=_.filter(e=>e in d);v.length>0&&s(v);let y=[...p.pull.filter(e=>!(e in f)),..._.filter(e=>!(e in d))];return y.length>0&&c(y),n.synced=K(h),await mn(r,n),h}async function Sn(e,t,n,r){let{onSync:i,onRecover:a,onUnreachable:o,onError:s}=r,c=0;for(;;){if(await t(un),n.aborted)return;try{await e(),c>=6&&a(),c=0,i()}catch(e){if(e instanceof B||e instanceof G||e instanceof kt)throw e;let t=e instanceof Ot?e.status>=500||e.status===429:e instanceof Pt;if(t&&++c<6)continue;t?o():await s(e)}}}async function Cn(e,t){return e instanceof B?new C("Your login expired. Run `prismic login`, then `prismic dev --continue` to continue the session."):e instanceof kt?new C("The session ended. Run `prismic dev` to start a new one."):(e instanceof G||await t(),On(e))}function wn(e,t,n){let r=[],i=[];for(let a of/* @__PURE__ */ new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)])){if(e[a]===t[a])continue;let o=e[a]!==n[a],s=t[a]!==n[a];!o||s&&!(a in e)?r.push(a):i.push(a)}return{pull:r,push:i}}function K(e){let t=e=>nn(`sha256`).update(JSON.stringify(e)).digest(`hex`);return Object.fromEntries([...e.customTypes.map(e=>[`type:${e.id}`,t(ie(e))]),...e.slices.map(e=>[`slice:${e.id}`,t(ce(e))])])}function Tn(e,t){return{customTypes:e.customTypes.filter(e=>t.includes(`type:${e.id}`)),slices:e.slices.filter(e=>t.includes(`slice:${e.id}`))}}function En(e){return e.map(e=>e.slice(e.indexOf(`:`)+1)).join(`, `)}function q(e,t=console.info){t(`${(/* @__PURE__ */ new Date()).toTimeString().slice(0,8)} ${e.replaceAll(`
|
|
21
21
|
`,`
|
|
22
|
-
`)}`)}function
|
|
23
|
-
`)):e}const
|
|
22
|
+
`)}`)}function Dn(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function On(e){if(!(e instanceof Ot))return e;switch(Vt(W({error:V()}),e.body).data?.error){case`missing_right`:return new C(`To edit models in the Type Builder, you need an Administrator, Owner, or Super User role on this repository.`);case`LEGACY_REPOSITORY`:return new C(`Local mode does not support this repository yet.`)}let t=Vt(An,e.body).data?.details;return t?new C([...t.customTypes,...t.slices].map(({id:e,error:t})=>`Could not push ${e}: ${t}`).join(`
|
|
23
|
+
`)):e}const kn=Mt(W({id:V(),error:V()})),An=W({details:W({customTypes:kn,slices:kn})}),jn=W({repo:V(),releaseId:V(),pid:jt(),synced:Ft(V(),V())});var Mn=F({name:`prismic docs list`,description:`
|
|
24
24
|
List available documentation pages.
|
|
25
25
|
|
|
26
26
|
With a path argument, list the anchors within that page.
|
|
27
|
-
`,positionals:{path:{description:`Documentation path to list anchors for`,required:!1}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:
|
|
27
|
+
`,positionals:{path:{description:`Documentation path to list anchors for`,required:!1}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:i}=t;if(n){let e=await xt(n,{host:j.PRISMIC_DOCS_HOST});if(i){console.info(U(e));return}if(e.anchors.length===0){console.info(`(no anchors)`);return}let t=e.anchors.map(e=>[`${n}#${e.slug}`,e.excerpt]);console.info(r(t,{headers:[`PATH`,`EXCERPT`]}))}else{let e=await pe({host:j.PRISMIC_DOCS_HOST});if(e.sort((e,t)=>e.path.localeCompare(t.path)),i){console.info(U(e));return}if(e.length===0){console.info(`No documentation pages found.`);return}let t=e.map(e=>[e.path,e.title,e.description??``]);console.info(r(t,{headers:[`PATH`,`TITLE`,`DESCRIPTION`]}))}});const Nn=/[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g,Pn=Object.hasOwnProperty;var Fn=class{constructor(){this.occurrences,this.reset()}slug(e,t){let n=this,r=In(e,t===!0),i=r;for(;Pn.call(n.occurrences,r);)n.occurrences[i]++,r=i+`-`+n.occurrences[i];return n.occurrences[r]=0,r}reset(){this.occurrences=Object.create(null)}};function In(e,t){return typeof e==`string`?(t||(e=e.toLowerCase()),e.replace(Nn,``).replace(/ /g,`-`)):``}var Ln=F({name:`prismic docs view`,description:`
|
|
28
28
|
View a documentation page as Markdown.
|
|
29
29
|
|
|
30
30
|
Append #anchor to the path to view only the section under that heading.
|
|
31
|
-
`,positionals:{path:{description:`Documentation path, optionally with #anchor (e.g., setup#install)`,required:!0}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t,i=n.indexOf(`#`),a=i>=0?n.slice(0,i):n,o=i>=0?n.slice(i+1):void 0,s=await
|
|
32
|
-
`),r=new
|
|
33
|
-
`).trim()}var
|
|
34
|
-
`);super(
|
|
31
|
+
`,positionals:{path:{description:`Documentation path, optionally with #anchor (e.g., setup#install)`,required:!0}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t,i=n.indexOf(`#`),a=i>=0?n.slice(0,i):n,o=i>=0?n.slice(i+1):void 0,s=await l(a,{host:j.PRISMIC_DOCS_HOST,headers:xe()});if(o){let e=Rn(s,o);if(!e)throw new C(`Anchor not found: #${o}`);s=e}console.info(r?U({path:a,anchor:o,content:s}):s)});function Rn(e,t){let n=e.split(`
|
|
32
|
+
`),r=new Fn,i,a,o,s;for(let e=0;e<n.length;e++){let c=n[e],l=c.match(/^(?<fence>`{3,}|~{3,})/)?.groups?.fence;if(i){l?.startsWith(i)&&(i=void 0);continue}if(l){i=l;continue}let u=c.match(/^(?<level>#{1,6})\s+(?<text>.*)/);if(u?.groups?.level&&u?.groups?.text){if(a!==void 0&&s!==void 0&&u.groups.level.length<=s){o=e;break}r.slug(u.groups.text)===t&&(a=e,s=u.groups.level.length)}}if(a!==void 0)return n.slice(a,o).join(`
|
|
33
|
+
`).trim()}var zn=S({name:`prismic docs`,description:`Browse Prismic documentation.`,commands:{list:{handler:Mn,description:`List available documentation pages`},view:{handler:Ln,description:`View a documentation page`}}}),Bn=F({name:`prismic env active`,description:`Print the active environment.`},async()=>{let e=await E(),t=await(await M()).getEnvironment();console.info(t??e)});async function Vn(e){let{results:t}=await p(e),n=await _(await e.getToken(),e);return n.type===`Machine2Machine`?t.filter(e=>e.domain===n.domain):t.filter(e=>(e.kind===`prod`||e.kind===`stage`)&&e.users.some(e=>e.id===n.shortId))}var Hn=class extends Error{name=`InvalidEnvironmentError`;constructor(e,t,n){if(t.length===1&&n===t[0].domain)super(`No environments available on repository "${n}".`);else{let r=t.map(e=>e.domain).join(`
|
|
34
|
+
`);super(Te`
|
|
35
35
|
Environment "${e}" not found on repository "${n}".
|
|
36
36
|
|
|
37
37
|
Available environments:
|
|
38
38
|
${r}
|
|
39
|
-
`)}}},
|
|
39
|
+
`)}}},Un=F({name:`prismic env list`,description:`List the environments available for the project.`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({values:e})=>{let t=await E(),{json:n,repo:i=t}=e,a=await D(),o=await Vn({repo:i,getToken:g,host:a,onUnauthorized:P}),s;if(i===t&&(s=await(await M()).getEnvironment()??t),n){let e=o.map(e=>({domain:e.domain,kind:e.kind,active:e.domain===s}));console.info(U(e));return}let c=o.map(e=>[e.domain,e.kind,e.domain===s?`*`:``]);console.info(r(c,{headers:[`DOMAIN`,`KIND`,`ACTIVE`]}))}),Wn=F({name:`prismic env set`,description:`Set the active environment.`,positionals:{environment:{description:`Environment domain`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await E(),r=await D(),i=await Vn({repo:n,getToken:g,host:r,onUnauthorized:P});if(!i.some(e=>e.domain===t))throw new Hn(t,i,n);let a=await M();t===n?(await a.unsetEnvironment(),console.info(`Reset to the production environment "${n}".`)):(await a.setEnvironment(t),console.info(`Set the active environment to "${t}".`));let o=await a.getSetupInstructions();o&&console.info(`\n${o}`)}),Gn=F({name:`prismic env unset`,description:`Reset the active environment to the production environment.`},async()=>{let e=await E();await(await M()).unsetEnvironment(),console.info(`Reset to the production environment "${e}".`)}),Kn=S({name:`prismic env`,description:`
|
|
40
40
|
Manage the active environment for a Prismic project.
|
|
41
41
|
|
|
42
42
|
Run \`prismic docs view environments\` for details.
|
|
43
|
-
`,commands:{set:{handler:
|
|
43
|
+
`,commands:{set:{handler:Wn,description:`Set the active environment`},unset:{handler:Gn,description:`Reset to the production environment`},active:{handler:Bn,description:`Print the active environment`},list:{handler:Un,description:`List environments`}}});const J={"to-slice":{type:`string`,description:`ID of the target slice`},"to-type":{type:`string`,description:`ID of the target content type`},variation:{type:`string`,description:`Slice variation ID (default: "default")`,dependsOn:`to-slice`},tab:{type:`string`,description:`Content type tab name (default: "Main")`,dependsOn:`to-type`}},qn={"from-slice":{type:`string`,description:`ID of the source slice`},"from-type":{type:`string`,description:`ID of the source content type`},variation:{type:`string`,description:`Slice variation ID (default: "default")`,dependsOn:`from-slice`}};async function Jn(e,t,n){let{variation:r=`default`}=n,{key:i,value:a}=Ce(n,[`from-slice`,`from-type`]),s=await M(),c,l,d;if(i===`from-slice`){let{model:n}=await s.getSlice(a);c=o(e,n,r),l=o(t,n,r),d=async()=>{await s.updateSlice(n),await s.generateTypes()}}else{let{model:n}=await s.getCustomType(a);c=Tt(e,n),l=Tt(t,n),d=async()=>{await s.updateCustomType(n),await s.generateTypes()}}if(!(c.fieldId in c.fields))throw new u(e);if(!(l.fieldId in l.fields))throw new u(t);return{source:c,anchor:l,save:d}}async function Y(e,t){let{tab:n=`Main`,variation:r=`default`}=t,{key:i,value:a}=Ce(t,[`to-slice`,`to-type`]),o=i===`to-slice`?await Zn(e,a,r):await Qn(e,a,n);if(o.fieldId in o.fields)throw new f(e);return o}async function Yn(e,t){let{variation:n=`default`}=t,{key:r,value:i}=Ce(t,[`from-slice`,`from-type`]),a=r===`from-slice`?await Zn(e,i,n):await Qn(e,i),o=a.fields[a.fieldId];if(!o)throw new u(e);return{...a,field:o}}async function Xn(e,t){let n=await(await M()).getCustomTypes();return de(e,t,n.map(({model:e})=>e))}async function Zn(e,t,n){let r=await M(),{model:i}=await r.getSlice(t);return{...o(e,i,n),save:async()=>{await r.updateSlice(i),await r.generateTypes()}}}async function Qn(e,t,n){let r=await M(),{model:i}=await r.getCustomType(t);return{...Tt(e,i,n),save:async()=>{await r.updateCustomType(i),await r.generateTypes()}}}function X(e,t){if(e===void 0)return;let n=Number(e);if(Number.isNaN(n))throw new C(`--${t} must be a valid number, got "${e}"`);return n}function $n(e){let t=Object.entries(e);if(t.length===0)return` (no fields)`;let n=t.map(([e,t])=>{let n=t.config,r=n?.label||``,i=n?.placeholder?`"${n.placeholder}"`:``;return[` ${e}`,t.type,r,i]});return r(n)}const er={name:`prismic field add boolean`,description:`
|
|
44
44
|
Add a boolean field to a slice or custom type.
|
|
45
45
|
|
|
46
46
|
Run \`prismic docs view fields/boolean\` for details.
|
|
47
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
47
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},"default-true":{type:`boolean`,description:`Default the field to true`},"default-false":{type:`boolean`,description:`Default the field to false`},"true-label":{type:`string`,description:`Label for true value`},"false-label":{type:`string`,description:`Label for false value`}}};var tr=F(er,async({positionals:e,values:t})=>{let[n]=e;O(t,[`default-true`,`default-false`]);let{label:r,"true-label":i,"false-label":a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`Boolean`,config:{label:r??N(s),default_value:!t[`default-false`]&&t[`default-true`],placeholder_true:i,placeholder_false:a}};T(o,s,l),await c(),console.info(`Field added: ${n}`)});const nr={name:`prismic field add color`,description:`
|
|
48
48
|
Add a color field to a slice or custom type.
|
|
49
49
|
|
|
50
50
|
Run \`prismic docs view fields/color\` for details.
|
|
51
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
51
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var rr=F(nr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Color`,config:{label:r??N(o),placeholder:i}};T(a,o,c),await s(),console.info(`Field added: ${n}`)});const ir={name:`prismic field add content-relationship`,description:`
|
|
52
52
|
Add a content relationship field to a slice or custom type.
|
|
53
53
|
|
|
54
54
|
Content relationships fetch and display data from related documents
|
|
@@ -79,31 +79,31 @@ Ending the session...`),await p()&&console.info(`Session ended.`)});async functi
|
|
|
79
79
|
|
|
80
80
|
Fetch fields from the related document:
|
|
81
81
|
prismic field add content-relationship author --to-type blog_post --custom-type author --field name --field bio
|
|
82
|
-
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
82
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},tag:{type:`string`,multiple:!0,description:`Restrict to documents with this tag (can be repeated)`},"custom-type":{type:`string`,multiple:!0,description:`Restrict to documents of this type (can be repeated)`},field:{type:`string`,multiple:!0,description:`Fetch this field from the related document (can be repeated, requires one --custom-type)`}}};var ar=F(ir,async({positionals:e,values:t})=>{let[n]=e,{label:r,tag:i,"custom-type":a,field:o}=t;if(o&&(!a||a.length!==1))throw new C(`--field requires exactly one --custom-type.`);let{fields:s,fieldId:c,save:l}=await Y(n,t),u=a;if(o&&a){let e=await Xn(o,a[0]);u=[{id:a[0],fields:e}]}let d={type:`Link`,config:{label:r??N(c),select:`document`,tags:i,customtypes:u}};T(s,c,d),await l(),console.info(`Field added: ${n}`)});const or={name:`prismic field add date`,description:`
|
|
83
83
|
Add a date field to a slice or custom type.
|
|
84
84
|
|
|
85
85
|
Run \`prismic docs view fields/date\` for details.
|
|
86
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
86
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var sr=F(or,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,default:a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`Date`,config:{label:r??N(s),placeholder:i,default:a}};T(o,s,l),await c(),console.info(`Field added: ${n}`)});const cr={name:`prismic field add embed`,description:`
|
|
87
87
|
Add an embed field to a slice or custom type.
|
|
88
88
|
|
|
89
89
|
Run \`prismic docs view fields/embed\` for details.
|
|
90
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
90
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var lr=F(cr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Embed`,config:{label:r??N(o),placeholder:i}};T(a,o,c),await s(),console.info(`Field added: ${n}`)});const ur={name:`prismic field add geopoint`,description:`
|
|
91
91
|
Add a geopoint field to a slice or custom type.
|
|
92
92
|
|
|
93
93
|
Run \`prismic docs view fields/geopoint\` for details.
|
|
94
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
94
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`}}};var dr=F(ur,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await Y(n,t),s={type:`GeoPoint`,config:{label:r??N(a)}};T(i,a,s),await o(),console.info(`Field added: ${n}`)});const fr={name:`prismic field add group`,description:`
|
|
95
95
|
Add a group field to a slice or custom type.
|
|
96
96
|
|
|
97
97
|
Run \`prismic docs view fields/repeatable-group\` for details.
|
|
98
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
98
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`}}};var pr=F(fr,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await Y(n,t),s={type:`Group`,config:{label:r??N(a)}};T(i,a,s),await o(),console.info(`Field added: ${n}`)});const mr={name:`prismic field add image`,description:`
|
|
99
99
|
Add an image field to a slice or custom type.
|
|
100
100
|
|
|
101
101
|
Run \`prismic docs view fields/image\` for details.
|
|
102
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
102
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var hr=F(mr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Image`,config:{label:r??N(o),placeholder:i}};T(a,o,c),await s(),console.info(`Field added: ${n}`)});const gr={name:`prismic field add integration`,description:`
|
|
103
103
|
Add an integration field to a slice or custom type.
|
|
104
104
|
|
|
105
105
|
Run \`prismic docs view fields/integration\` for details.
|
|
106
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
106
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},catalog:{type:`string`,description:`Integration catalog ID`}}};var _r=F(gr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,catalog:a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`IntegrationFields`,config:{label:r??N(s),placeholder:i,catalog:a}};T(o,s,l),await c(),console.info(`Field added: ${n}`)});const vr={name:`prismic field add link`,description:`
|
|
107
107
|
Add a link field to a slice or custom type. Use for navigational links to URLs, documents, or media. For data-level relations between documents, use content-relationship instead.
|
|
108
108
|
|
|
109
109
|
Run \`prismic docs view fields/link\` for details.
|
|
@@ -119,11 +119,11 @@ Ending the session...`),await p()&&console.info(`Session ended.`)});async functi
|
|
|
119
119
|
|
|
120
120
|
Allow any link type, but restrict document links to a type:
|
|
121
121
|
prismic field add link cta --to-type landing_page --custom-type page
|
|
122
|
-
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
122
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},allow:{type:`string`,description:`Restrict to a link type: document, media, or web`},"allow-target-blank":{type:`boolean`,description:`Allow opening in new tab`},"allow-text":{type:`boolean`,description:`Allow custom link text`},repeatable:{type:`boolean`,description:`Allow multiple links`},variant:{type:`string`,multiple:!0,description:`Allowed variant (can be repeated)`},"custom-type":{type:`string`,multiple:!0,description:`Restrict document links to this custom type (can be repeated)`}}};var yr=F(vr,async({positionals:e,values:t})=>{let[n]=e,r=[`document`,`media`,`web`],{label:i,allow:a,"allow-target-blank":o,"allow-text":s,repeatable:c,variant:l,"custom-type":u}=t;if(a?.includes(`,`))throw new C(`--allow accepts a single link type. Prismic links allow either one type or all types.`);if(a&&!r.includes(a))throw new C(`--allow must be one of: ${r.join(`, `)}`);let d=a;if(u&&(d===`media`||d===`web`))throw new C(`--custom-type cannot be used with --allow ${d}`);let{fields:f,fieldId:p,save:m}=await Y(n,t),h={type:`Link`,config:{label:i??N(p),select:d,allowTargetBlank:o,allowText:s,repeat:c,variants:l,customtypes:u}};T(f,p,h),await m(),console.info(`Field added: ${n}`)});const br={name:`prismic field add number`,description:`
|
|
123
123
|
Add a number field to a slice or custom type.
|
|
124
124
|
|
|
125
125
|
Run \`prismic docs view fields/number\` for details.
|
|
126
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
126
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},min:{type:`string`,description:`Minimum value`},max:{type:`string`,description:`Maximum value`},step:{type:`string`,description:`Step increment`}}};var xr=F(br,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,a=X(t.min,`min`),o=X(t.max,`max`),s=X(t.step,`step`),{fields:c,fieldId:l,save:u}=await Y(n,t),d={type:`Number`,config:{label:r??N(l),placeholder:i,min:a,max:o,step:s}};T(c,l,d),await u(),console.info(`Field added: ${n}`)});const Sr={name:`prismic field add rich-text`,description:`
|
|
127
127
|
Add a rich text field to a slice or custom type.
|
|
128
128
|
|
|
129
129
|
Run \`prismic docs view fields/rich-text\` for details.
|
|
@@ -137,7 +137,7 @@ Ending the session...`),await p()&&console.info(`Session ended.`)});async functi
|
|
|
137
137
|
|
|
138
138
|
Add a body field with only headings and paragraphs:
|
|
139
139
|
prismic field add rich-text body --to-type blog_post --allow heading1,heading2,paragraph,strong,em,hyperlink
|
|
140
|
-
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
140
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},allow:{type:`string`,description:`Comma-separated allowed block types (e.g. heading1,heading2,paragraph)`},single:{type:`boolean`,description:`Restrict to a single block`},labels:{type:`string`,description:`Comma-separated custom labels for styling text spans (e.g. highlight,quote)`},"allow-target-blank":{type:`boolean`,description:`Allow opening links in new tab`}}};var Cr=F(Sr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,allow:a=`paragraph,preformatted,heading1,heading2,heading3,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl`,single:o,labels:s,"allow-target-blank":c}=t,{fields:l,fieldId:u,save:d}=await Y(n,t),f={type:`StructuredText`,config:{label:r??N(u),placeholder:i,...o?{single:a}:{multi:a},labels:s?.split(`,`).map(e=>e.trim()).filter(Boolean),allowTargetBlank:c}};T(l,u,f),await d(),console.info(`Field added: ${n}`)});const wr={name:`prismic field add select`,description:`
|
|
141
141
|
Add a select field to a slice or custom type.
|
|
142
142
|
|
|
143
143
|
Run \`prismic docs view fields/select\` for details.
|
|
@@ -147,11 +147,11 @@ Ending the session...`),await p()&&console.info(`Session ended.`)});async functi
|
|
|
147
147
|
|
|
148
148
|
With a default value:
|
|
149
149
|
prismic field add select layout --to-type landing_page --option full --option centered --option sidebar --default-value full
|
|
150
|
-
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
150
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},"default-value":{type:`string`,description:`Default selected value`},option:{type:`string`,multiple:!0,description:`Select option value (can be repeated)`}}};var Tr=F(wr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,"default-value":a,option:o}=t,{fields:s,fieldId:c,save:l}=await Y(n,t),u={type:`Select`,config:{label:r??N(c),placeholder:i,default_value:a,options:o}};T(s,c,u),await l(),console.info(`Field added: ${n}`)});const Er={name:`prismic field add table`,description:`
|
|
151
151
|
Add a table field to a slice or custom type.
|
|
152
152
|
|
|
153
153
|
Run \`prismic docs view fields/table\` for details.
|
|
154
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
154
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`}}};var Dr=F(Er,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await Y(n,t),s={type:`Table`,config:{label:r??N(a)}};T(i,a,s),await o(),console.info(`Field added: ${n}`)});const Or={name:`prismic field add text`,description:`
|
|
155
155
|
Add a text field to a slice or custom type.
|
|
156
156
|
|
|
157
157
|
A text field holds a short plain string with no formatting.
|
|
@@ -162,15 +162,15 @@ Ending the session...`),await p()&&console.info(`Session ended.`)});async functi
|
|
|
162
162
|
prismic field add rich-text title --to-type blog_post --allow heading1 --single
|
|
163
163
|
|
|
164
164
|
Run \`prismic docs view fields/text\` for details.
|
|
165
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
165
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var kr=F(Or,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await Y(n,t),c={type:`Text`,config:{label:r??N(o),placeholder:i}};T(a,o,c),await s(),console.info(`Field added: ${n}`)});const Ar={name:`prismic field add timestamp`,description:`
|
|
166
166
|
Add a timestamp field to a slice or custom type.
|
|
167
167
|
|
|
168
168
|
Run \`prismic docs view fields/timestamp\` for details.
|
|
169
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
169
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...J,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var jr=F(Ar,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,default:a}=t,{fields:o,fieldId:s,save:c}=await Y(n,t),l={type:`Timestamp`,config:{label:r??N(s),placeholder:i,default:a}};T(o,s,l),await c(),console.info(`Field added: ${n}`)});const Mr={name:`prismic field add uid`,description:`
|
|
170
170
|
Add a UID field to a content type.
|
|
171
171
|
|
|
172
172
|
Run \`prismic docs view fields/uid\` for details.
|
|
173
|
-
`,options:{"to-type":
|
|
173
|
+
`,options:{"to-type":J[`to-type`],tab:J.tab,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Nr=F(Mr,async({values:e})=>{let{label:t=`UID`,placeholder:n}=e,{fields:r,fieldId:i,save:a}=await Y(`uid`,e);T(r,i,{type:`UID`,config:{label:t,placeholder:n}}),await a(),console.info(`Field added: uid`)}),Pr=S({name:`prismic field add`,description:`
|
|
174
174
|
Add a field to a slice or custom type.
|
|
175
175
|
|
|
176
176
|
Run \`prismic docs view fields\` for details.
|
|
@@ -180,7 +180,7 @@ Ending the session...`),await p()&&console.info(`Session ended.`)});async functi
|
|
|
180
180
|
prismic field add text my_group.description --to-type blog_post
|
|
181
181
|
|
|
182
182
|
The group must already exist. Only one level of nesting is supported.
|
|
183
|
-
`},commands:{boolean:{handler:
|
|
183
|
+
`},commands:{boolean:{handler:tr,description:`Add a boolean field`},color:{handler:rr,description:`Add a color field`},"content-relationship":{handler:ar,description:`Add a content relationship field for fetching data from related documents (not for navigation -- use link)`},date:{handler:sr,description:`Add a date field`},embed:{handler:lr,description:`Add an embed field`},geopoint:{handler:dr,description:`Add a geopoint field`},group:{handler:pr,description:`Add a group field`},image:{handler:hr,description:`Add an image field`},integration:{handler:_r,description:`Add an integration field`},link:{handler:yr,description:`Add a link field for URLs, documents, or media (navigational)`},number:{handler:xr,description:`Add a number field`},"rich-text":{handler:Cr,description:`Add a rich text field`},select:{handler:Tr,description:`Add a select field`},table:{handler:Dr,description:`Add a table field`},text:{handler:kr,description:`Add a text field for short plain strings (not for titles or headings -- use rich-text --allow heading1 --single)`},timestamp:{handler:jr,description:`Add a timestamp field`},uid:{handler:Nr,description:`Add a UID field`}}});const Fr={name:`prismic field edit`,description:`Edit an existing field in a slice or custom type.`,sections:{"FIELD TYPE OPTIONS":`
|
|
184
184
|
Options vary by field type. Only options matching the field's
|
|
185
185
|
type will be applied. See \`prismic field add <type> --help\`
|
|
186
186
|
for type-specific option details.
|
|
@@ -193,38 +193,38 @@ Ending the session...`),await p()&&console.info(`Session ended.`)});async functi
|
|
|
193
193
|
|
|
194
194
|
Restrict a rich text field to a single block:
|
|
195
195
|
prismic field edit subtitle --from-type blog_post --single
|
|
196
|
-
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
196
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...qn,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},"default-true":{type:`boolean`,description:`Default the field to true (boolean)`},"default-false":{type:`boolean`,description:`Default the field to false (boolean)`},"true-label":{type:`string`,description:`Label for true value (boolean)`},"false-label":{type:`string`,description:`Label for false value (boolean)`},default:{type:`string`,description:`Default value (date/timestamp)`},min:{type:`string`,description:`Minimum value (number)`},max:{type:`string`,description:`Maximum value (number)`},step:{type:`string`,description:`Step increment (number)`},"default-value":{type:`string`,description:`Default selected value (select)`},option:{type:`string`,multiple:!0,description:`Select option value (can be repeated)`},"allow-target-blank":{type:`boolean`,description:`Allow opening in new tab (link/rich-text)`},"allow-text":{type:`boolean`,description:`Allow custom link text (link)`},repeatable:{type:`boolean`,description:`Allow multiple links (link)`},variant:{type:`string`,multiple:!0,description:`Allowed variant (link/link-to-media, can be repeated)`},tag:{type:`string`,multiple:!0,description:`Allowed tag (content-relationship, can be repeated)`},"custom-type":{type:`string`,multiple:!0,description:`Allowed custom type (content-relationship, can be repeated)`},field:{type:`string`,multiple:!0,description:`Fetch this field from the related document (content-relationship, can be repeated)`},allow:{type:`string`,description:`Comma-separated allowed block types (rich-text), or allowed link type: document, media, web, any (link)`},single:{type:`boolean`,description:`Restrict to a single block (rich-text)`},labels:{type:`string`,description:`Comma-separated custom labels for styling text spans; "" clears (rich-text)`},catalog:{type:`string`,description:`Integration catalog ID (integration)`}}};var Ir=F(Fr,async({positionals:e,values:t})=>{let[n]=e,{field:r,save:i}=await Yn(n,t);switch(r.config??={},`label`in t&&(r.config.label=t.label),`placeholder`in t&&(r.config.placeholder=t.placeholder),r.type){case`Boolean`:O(t,[`default-true`,`default-false`]),`default-true`in t&&(r.config.default_value=!0),`default-false`in t&&(r.config.default_value=!1),`true-label`in t&&(r.config.placeholder_true=t[`true-label`]),`false-label`in t&&(r.config.placeholder_false=t[`false-label`]);break;case`Number`:`min`in t&&(r.config.min=X(t.min,`min`)),`max`in t&&(r.config.max=X(t.max,`max`)),`step`in t&&(r.config.step=X(t.step,`step`));break;case`Select`:`default-value`in t&&(r.config.default_value=t[`default-value`]),`option`in t&&(r.config.options=t.option);break;case`Date`:case`Timestamp`:`default`in t&&(r.config.default=t.default);break;case`IntegrationFields`:`catalog`in t&&(r.config.catalog=t.catalog);break;case`StructuredText`:if(`allow-target-blank`in t&&(r.config.allowTargetBlank=t[`allow-target-blank`]),`labels`in t&&(t.labels?r.config.labels=t.labels.split(`,`):delete r.config.labels),`single`in t){let e=`allow`in t?t.allow:r.config.multi??r.config.single;delete r.config.multi,r.config.single=e}else`allow`in t&&(`single`in r.config?r.config.single=t.allow:r.config.multi=t.allow);break;case`Link`:if(`allow-target-blank`in t&&(r.config.allowTargetBlank=t[`allow-target-blank`]),`allow-text`in t&&(r.config.allowText=t[`allow-text`]),`repeatable`in t&&(r.config.repeat=t.repeatable),`variant`in t&&(r.config.variants=t.variant),`tag`in t&&(r.config.tags=t.tag),`allow`in t){let e=t.allow;if(e===`any`)delete r.config.select;else if(e===`document`||e===`media`||e===`web`)r.config.select=e;else if(e?.includes(`,`))throw new C(`--allow accepts a single link type. Prismic links allow either one type or all types.`);else throw new C(`--allow for link fields must be one of: document, media, web, any`)}if(`field`in t){let e=`custom-type`in t?t[`custom-type`]:r.config.customtypes;if(!e||e.length===0)throw new C(`--field requires the field to be restricted to a custom type. Use --custom-type to specify one.`);if(e.length>1)throw new C(`--field requires the field to be restricted to a single custom type.`);let[n]=e,i=typeof n==`string`?n:n.id,a=await Xn(t.field,i);r.config.customtypes=[{id:i,fields:a}]}else if(`custom-type`in t){let e=t[`custom-type`].filter(Boolean);e.length===0?delete r.config.customtypes:r.config.customtypes=e}if((r.config.select===`media`||r.config.select===`web`)&&r.config.customtypes&&r.config.customtypes.length>0)throw new C(`Custom type restrictions require document links, but this field is restricted to ${r.config.select} links. Change --allow or clear the restriction with --custom-type "".`)}await i(),console.info(`Field updated: ${n}`)}),Lr=F({name:`prismic field remove`,description:`Remove a field from a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:qn},async({positionals:e,values:t})=>{let[n]=e,{fields:r,fieldId:i,save:a}=await Yn(n,t);delete r[i],await a(),console.info(`Field removed: ${n}`)});const Rr={name:`prismic field reorder`,description:`Reorder a field in a slice or custom type.`,positionals:{id:{description:`Field ID to move`,required:!0}},options:{before:{type:`string`,description:`Place field before this field ID`},after:{type:`string`,description:`Place field after this field ID`},...qn}};var zr=F(Rr,async({positionals:e,values:t})=>{let[n]=e,{key:r,value:i}=Ce(t,[`before`,`after`]);if(n===i)throw new C(`Cannot reorder "${n}" relative to itself.`);if(n.split(`.`).slice(0,-1).join(`.`)!==i.split(`.`).slice(0,-1).join(`.`))throw new C(`Cannot reorder "${n}" relative to "${i}": fields must be in the same container.`);let{source:a,anchor:o,save:s}=await Jn(n,i,t);if(a.fields!==o.fields&&a.fieldId in o.fields)throw new f(a.fieldId);let c=a.fields[a.fieldId];delete a.fields[a.fieldId];let l=Object.entries(o.fields);for(let[e]of l)delete o.fields[e];for(let[e,t]of l)r===`before`&&e===o.fieldId&&(o.fields[a.fieldId]=c),o.fields[e]=t,r===`after`&&e===o.fieldId&&(o.fields[a.fieldId]=c);await s(),console.info(`Field reordered: ${n}`)});const Br={name:`prismic field view`,description:`View details of a field in a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:{...qn,json:{type:`boolean`,description:`Output as JSON`}}};var Vr=F(Br,async({positionals:e,values:t})=>{let[n]=e,{field:r,fieldId:i}=await Yn(n,t);if(t.json)console.info(U({id:i,...r}));else if(console.info(`Type: ${r.type}`),r.config){for(let[e,t]of Object.entries(r.config))if(t!==void 0){if(e===`fields`&&typeof t==`object`&&t){let e=Object.keys(t).join(`, `)||`(none)`;console.info(`Fields: ${e}`)}else console.info(Array.isArray(t)?`${N(e)}: ${t.join(`, `)}`:`${N(e)}: ${t}`)}}}),Hr=S({name:`prismic field`,description:`
|
|
197
197
|
Manage fields in slices and content types.
|
|
198
198
|
|
|
199
199
|
Run \`prismic docs view fields\` for details.
|
|
200
|
-
`,commands:{add:{handler:
|
|
200
|
+
`,commands:{add:{handler:Pr,description:`Add a field`},edit:{handler:Ir,description:`Edit a field`},remove:{handler:Lr,description:`Remove a field`},reorder:{handler:zr,description:`Reorder a field`},view:{handler:Vr,description:`View details of a field`}}}),Ur=F({name:`prismic gen page`,description:`
|
|
201
201
|
Generate the page files for a page type.
|
|
202
202
|
|
|
203
203
|
Uses the type's route in prismic.config.json. Existing files are not
|
|
204
204
|
changed: their generated code is printed instead.
|
|
205
|
-
`,positionals:{"type-id":{description:`ID of the page type`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await
|
|
205
|
+
`,positionals:{"type-id":{description:`ID of the page type`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await M(),{model:r}=await n.getCustomType(t);if(r.format!==`page`)throw new C(`"${t}" is not a page type.`);let{routes:i=[]}=await c(),a=!ke(i,t)&&i.find(e=>e.type===t&&!e.uid);a&&console.info(`The route ${a.path} has optional or repeated params, so the page uses the default path ${Re(r)}. Move it to match the route.\n`);let o=await n.writePageFiles(r);if(o.length===0){console.info(`Generated the page for "${t}".`);return}let s=await L();for(let e of o){let t=z(s,e.path);console.info(`${t} already exists. Generated code:\n\n${e.contents}`),console.info(`Merge this into ${t}.\n`)}}),Wr=F({name:`prismic gen setup`,description:`
|
|
206
206
|
Generate framework-specific setup files for a Prismic project.
|
|
207
207
|
|
|
208
208
|
Installs dependencies, creates the Prismic client file, slice simulator
|
|
209
209
|
page, preview routes, and other files required by the detected framework.
|
|
210
210
|
Skips files that already exist.
|
|
211
|
-
`,options:{"no-install":{type:`boolean`,description:`Skip installing dependencies`}}},async({values:e})=>{let t=await
|
|
212
|
-
`);await fetch(
|
|
213
|
-
`).slice(1)){let e=n.match(/^\s*at (?:(.+?) \()?(.+?):(\d+):(\d+)\)?$/);e&&t.push({function:e[1]||`?`,filename:e[2],lineno:Number(e[3]),colno:Number(e[4]),in_app:!0})}return t.length>0?{frames:t.reverse()}:void 0}const
|
|
211
|
+
`,options:{"no-install":{type:`boolean`,description:`Skip installing dependencies`}}},async({values:e})=>{let t=await M(),n=await H();await t.setupProject();for(let{name:e,from:t,to:r}of Wt(n,await H()))console.info(`Updated ${e} from ${t} to ${r}. Check your code for breaking changes in the new version.`);if(!e[`no-install`])try{console.info(`Installing dependencies...`),await Lt()}catch{console.warn(`Could not install dependencies. Run \`${await Bt()}\` to finish.\nThe rest of the setup is done.`)}console.info(`Generated setup files.`);let r=await t.getSetupInstructions();r&&console.info(`\n${r}`)}),Gr=F({name:`prismic gen slice-index`,description:`Generate the slice index file of each slice library.`},async()=>{let e=await M(),t=await e.getSliceLibraries();for(let n of t)await e.createSliceIndexFile(n);console.info(t.length===1?`Generated the slice index file.`:`Generated ${t.length} slice index files.`)}),Kr=F({name:`prismic gen types`,description:`Generate TypeScript types for slices and content types.`},async()=>{let e=await(await M()).generateTypes(),t=await L(),n=z(t,e);console.info(`Generated types at ${n}`)}),qr=S({name:`prismic gen`,description:`Generate files from local Prismic models.`,commands:{page:{handler:Ur,description:`Generate the page files for a page type`},setup:{handler:Wr,description:`Generate framework-specific Prismic setup`},"slice-index":{handler:Gr,description:`Generate the slice index file of each slice library`},types:{handler:Kr,description:`Generate TypeScript types from local models`}}});async function Z(e,t){let{completedSteps:n}=await Xe(t),r=e.filter(e=>!n.includes(e));for(let e of r)await ye(e,t)}let Q;const $={tags:{},contexts:{}};function Jr(e){Q=e,$.contexts.Process={command:process.argv.join(` `),cwd:process.cwd()}}function Yr(e,t){$.tags[e]=t}function Xr(e,t){$.contexts[e]=t}function Zr(e){$.user=e}async function Qr(e){if(Q)try{let t=new URL(Q.dsn),n=e instanceof Error?e:Error(String(e)),r=crypto.randomUUID().replace(/-/g,``),i={event_id:r,timestamp:Date.now()/1e3,platform:`node`,level:`error`,release:Q.appVersion,environment:Q.environment||$r(Q.appVersion),tags:$.tags,user:$.user,contexts:{...$.contexts,runtime:{name:`node`,version:process.versions.node}},exception:{values:[{type:n.name,value:n.message.slice(0,2500),stacktrace:ti(n)}]},extra:{cause:n.cause,fullCommand:process.argv.join(` `)}},a=[JSON.stringify({event_id:r,sent_at:(/* @__PURE__ */ new Date()).toISOString()}),JSON.stringify({type:`event`}),JSON.stringify(i)].join(`
|
|
212
|
+
`);await fetch(ei(t),{method:`POST`,headers:{"Content-Type":`application/x-sentry-envelope`,"X-Sentry-Auth":`Sentry sentry_version=7, sentry_client=${Q.appName}/${Q.appVersion}, sentry_key=${t.username}`},body:a,signal:AbortSignal.timeout(2e3)})}catch{}}function $r(e){let t=e.match(/-(.+?)\./);return t?t[1]:`production`}function ei(e){return`${e.protocol}//${e.host}/api${e.pathname}/envelope/`}function ti(e){let t=[];for(let n of(e.stack??``).split(`
|
|
213
|
+
`).slice(1)){let e=n.match(/^\s*at (?:(.+?) \()?(.+?):(\d+):(\d+)\)?$/);e&&t.push({function:e[1]||`?`,filename:e[2],lineno:Number(e[3]),colno:Number(e[4]),in_app:!0})}return t.length>0?{frames:t.reverse()}:void 0}const ni={name:`prismic repo create`,description:`
|
|
214
214
|
Create a new Prismic repository.
|
|
215
215
|
|
|
216
216
|
The CLI generates a random domain, shown in the output. The domain cannot
|
|
217
217
|
be chosen or changed. --name sets only the display name, which
|
|
218
218
|
\`prismic repo set-name\` can change later.
|
|
219
|
-
`,options:{name:{type:`string`,short:`n`,description:`Display name for the repository`},lang:{type:`string`,short:`l`,description:`Master locale for the new repository (default: en-us)`},framework:{type:`string`,short:`f`,description:`Framework the repository is for: ${
|
|
219
|
+
`,options:{name:{type:`string`,short:`n`,description:`Display name for the repository`},lang:{type:`string`,short:`l`,description:`Master locale for the new repository (default: en-us)`},framework:{type:`string`,short:`f`,description:`Framework the repository is for: ${I.join(`, `)} (default: detected from the project)`}}};var ri=F(ni,async({values:e})=>{let t=await M().catch(()=>void 0),{name:n,lang:r,framework:i=t?.id}=e;if(!i)throw new C(`
|
|
220
220
|
No supported framework found. The CLI needs a Next.js, Nuxt, or SvelteKit project to work with a repository.
|
|
221
221
|
|
|
222
222
|
Do one of the following:
|
|
223
223
|
- Run this command inside an existing Next.js, Nuxt, or SvelteKit project.
|
|
224
224
|
- Create the project first, then run \`prismic init\` to create and connect a repository.
|
|
225
|
-
- Pass --framework <${
|
|
225
|
+
- Pass --framework <${I.join(`|`)}> to create the repository now.
|
|
226
226
|
You still need a compatible project to use it. Connect one later with \`prismic init --repo <domain>\`.
|
|
227
|
-
`);if(!
|
|
227
|
+
`);if(!I.includes(i))throw new C(`Unsupported framework "${i}". Use one of: ${I.join(`, `)}.`);let a=await D(),o=await ii({name:n,lang:r,framework:i,host:a});console.info(`Repository created: ${o}`),console.info(`URL: https://${o}.${a}/`)});async function ii(e){let{name:t,lang:n=`en-us`,framework:r,host:i}=e,a=await ai(i);if(!a)throw new C(`Failed to create a repository. Please try again.`);let o=mt();return await Ne({domain:a,name:t??a,framework:r,agent:o,getToken:g,host:i,onUnauthorized:P}),await be({id:n,isMaster:!0},{repo:a,getToken:g,host:i,onUnauthorized:P}),await Z([`createPrismicProject`],{repo:a,getToken:g,host:i,onUnauthorized:P}).catch(()=>{}),a}async function ai(e){let t;for(let n=0;n<5;n++){let n=crypto.randomUUID().replace(/-/g,``).slice(0,8);if(await pt({domain:n,getToken:g,host:e,onUnauthorized:P})){t=n;break}}return t}var oi=F({name:`prismic init`,description:`
|
|
228
228
|
Initialize a new Prismic project by creating a repository and
|
|
229
229
|
prismic.config.json file. Detects the project framework, installs
|
|
230
230
|
dependencies, and pulls models from Prismic. The CLI generates a random
|
|
@@ -235,70 +235,70 @@ Ending the session...`),await p()&&console.info(`Session ended.`)});async functi
|
|
|
235
235
|
migrated.
|
|
236
236
|
|
|
237
237
|
Run \`prismic docs view cli#set-up-a-type-builder-project\` for details.
|
|
238
|
-
`,options:{repo:{type:`string`,short:`r`,description:`Domain of an existing repository to connect to`},"repo-name":{type:`string`,description:`Display name for the new repository (its domain is generated)`},lang:{type:`string`,short:`l`,description:`Master locale for a new repository (default: en-us)`},"no-browser":{type:`boolean`,description:`Skip opening the browser automatically during login`},"no-setup":{type:`boolean`,description:`Skip framework scaffolding (dependencies and framework files)`}}},async({values:e})=>{
|
|
239
|
-
This project is already set up for Prismic (repository: ${
|
|
238
|
+
`,options:{repo:{type:`string`,short:`r`,description:`Domain of an existing repository to connect to`},"repo-name":{type:`string`,description:`Display name for the new repository (its domain is generated)`},lang:{type:`string`,short:`l`,description:`Master locale for a new repository (default: en-us)`},"no-browser":{type:`boolean`,description:`Skip opening the browser automatically during login`},"no-setup":{type:`boolean`,description:`Skip framework scaffolding (dependencies and framework files)`}}},async({values:e})=>{O(e,[`repo`,`repo-name`]);let{repo:t,lang:n,"no-browser":r,"no-setup":i}=e,a;try{a=await c()}catch(e){if(!(e instanceof $e))throw e}if(a&&!t)throw new C(`
|
|
239
|
+
This project is already set up for Prismic (repository: ${a.repositoryName}).
|
|
240
240
|
|
|
241
241
|
Do one of the following:
|
|
242
242
|
- Run \`prismic gen setup\` to add missing framework files and install dependencies.
|
|
243
243
|
- Run \`prismic init --repo <domain>\` to connect the project to a different repository.
|
|
244
|
-
`);let
|
|
244
|
+
`);let o=a!==void 0&&t!==void 0,s;if(!a)try{s=await bt()}catch(e){e instanceof Ie&&console.warn(`Could not read slicemachine.config.json, ignoring.`)}let l=await D();try{await le({getToken:g,host:l})}catch(e){if(e instanceof B||e instanceof G){if(j.PRISMIC_TOKEN)throw e;await ee({browser:!r})}else throw e}let u=(t??s?.repositoryName)?.toLowerCase(),d;u&&(d=await Je({repo:u,getToken:g,host:l}).catch(e=>{throw e instanceof G?new C(`Repository "${u}" not found in your account. Check the name or request access to the repository.`):e}));let f;try{f=await M()}catch(e){throw e instanceof De||e instanceof Gt?new C(`
|
|
245
245
|
No supported framework found. \`prismic init\` needs a Next.js, Nuxt, or SvelteKit project.
|
|
246
246
|
|
|
247
247
|
Do one of the following:
|
|
248
248
|
- Run this command inside an existing Next.js, Nuxt, or SvelteKit project.
|
|
249
249
|
- Create the project first, then run \`prismic init\` again.
|
|
250
|
-
- To create the repository now, run \`prismic repo create --framework <${
|
|
250
|
+
- To create the repository now, run \`prismic repo create --framework <${I.join(`|`)}>\`.
|
|
251
251
|
Connect the project later with \`prismic init --repo <domain>\`.
|
|
252
|
-
`):e}let
|
|
252
|
+
`):e}let p=j.PRISMIC_TYPE_BUILDER_ENABLED??d?.quotas?.sliceMachineEnabled;if(u&&d&&(!p||d.framework!==f.id))try{await St(f.id,{repo:u,getToken:g,host:l}),p||console.info(`Turned on the Type Builder for repository "${u}".`)}catch(e){if(!(e instanceof G))throw e;if(!p)throw new C(`Repository "${u}" uses the Legacy Builder. Only a repository administrator can turn on the Type Builder. Ask an administrator to run \`prismic init\`.`);console.warn(`Could not set the repository's framework to ${f.id}. Ask a repository administrator to run \`prismic init\`.`)}u||(u=await ii({name:e[`repo-name`],lang:n,framework:f.id,host:l}),console.info(`Created repository: ${u}`));try{let e=l===`prismic.io`?void 0:`https://${u}.cdn.${l}/api/v2/`;a?await me({repositoryName:u,documentAPIEndpoint:e}):await vt({repositoryName:u,documentAPIEndpoint:e,libraries:s?.libraries,routes:[]})}catch(e){throw e instanceof Ve?new C(`Could not find a package.json file. Run this command from a project directory.`):new C(`Failed to create prismic.config.json.`)}if(s){try{await Ct()}catch{}let{dependencies:e,devDependencies:t,peerDependencies:n}=await H(),r=Object.keys({...e,...t,...n}).filter(e=>e===`slice-machine-ui`||e.startsWith(`@slicemachine/adapter-`));r.length>0&&await Kt(r),console.info(`Migrated slicemachine.config.json to prismic.config.json`)}let h=await H();await f.initProject({setup:!i&&!a});for(let{name:e,from:t,to:n}of Wt(h,await H()))console.info(`Updated ${e} from ${t} to ${n}. Check your code for breaking changes in the new version.`);if(!i)try{console.info(`Installing dependencies...`),await Lt()}catch{console.warn(`Could not install dependencies. Run \`${await Bt()}\` to finish.\nThe rest of the setup is done, so you don't need to run \`prismic init\` again.`)}let[_,v]=await Promise.all([w({repo:u,getToken:g,host:l}),f.getModels()]),y=m(_,v);if(o&&d?.starter){if(_.customTypes.length===0&&_.slices.length===0)throw new C(`Repository "${u}" has no starter models. Use a repository created from the starter in the Prismic dashboard.`);await li(d.starter)}let x=o&&[y.customTypes,y.slices].some(e=>e.update.length>0||e.delete.length>0);if(!x)for(let e of await f.writeModels(y))console.info(e);await f.generateTypes(),await Z([`connectPrismic`],{repo:u,getToken:g,host:l}).catch(()=>{}),b(_.customTypes).length>0&&console.info("\nRun `prismic slice list --legacy` to find legacy slices to upgrade."),x&&console.warn(Te`
|
|
253
253
|
Local and remote models differ, so no model files were changed. The project is connected.
|
|
254
254
|
|
|
255
255
|
Choose the source of truth:
|
|
256
256
|
prismic pull --force Adopt remote models
|
|
257
257
|
prismic push --force Keep local models
|
|
258
|
-
`),
|
|
258
|
+
`),o&&d?.starter?(await ci(f,d.starter,{repo:u,getToken:g,host:l}),x||(console.info(`
|
|
259
259
|
---`),console.info(`
|
|
260
|
-
Your project is ready! Here's what you can do next:`),console.info("- Run `npm run dev` to start the development server"),console.info(`- Open https://${
|
|
260
|
+
Your project is ready! Here's what you can do next:`),console.info("- Run `npm run dev` to start the development server"),console.info(`- Open https://${u}.${l}/builder to preview pages live`),console.info(`
|
|
261
261
|
Start building 🚀`))):(console.info(`
|
|
262
|
-
---`),console.info(`\nInitialized Prismic for repository "${
|
|
262
|
+
---`),console.info(`\nInitialized Prismic for repository "${u}".`),console.info("Run `prismic type create <name>` to create a content type."),console.info("Run `prismic pull` to pull models from Prismic."));let S=await f.getSetupInstructions();S&&console.info(`\n${S}`)});async function si(e){let t=await H(),n=e.id.split(`/`).at(-1);return!!(n&&t.name===n)}async function ci(e,t,n){try{let{results:t}=await a(n);await Promise.all(t.filter(e=>e.label===`Starter Preview`).map(e=>Be(e.id,n))),t.some(t=>t.url===e.localPreviewUrl)||await ot(e.localPreviewConfig,n)}catch(t){await Qr(t),console.error(`Could not configure the local preview. Run \`prismic preview add ${e.localPreviewUrl} --name ${e.localPreviewConfig.name}\` manually. Continuing.`)}try{await s(e.localSimulatorUrl,n)}catch(t){await Qr(t),console.error(`Could not configure the local slice simulator. Run \`prismic preview set-simulator ${e.localSimulatorUrl}\` manually. Continuing.`)}await Z([`instantStart_continueBuildingLocally`],n).catch(()=>{}),await si(t)&&await Rt(n.repo)}async function li(e){if(!await si(e))return;let t=await L();await Promise.all([$t(new URL(`.deployment`,t),{recursive:!0,force:!0}),$t(new URL(`documents`,t),{recursive:!0,force:!0})])}var ui=F({name:`prismic locale add`,description:`
|
|
263
263
|
Add a locale to a Prismic repository.
|
|
264
264
|
|
|
265
265
|
By default, this command reads the repository from prismic.config.json at the
|
|
266
266
|
project root.
|
|
267
|
-
`,positionals:{code:{description:`Locale code (e.g. fr-fr, es-es)`,required:!0}},options:{master:{type:`boolean`,description:`Set as the master locale`},name:{type:`string`,short:`n`,description:`Custom display name (for custom locales)`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
267
|
+
`,positionals:{code:{description:`Locale code (e.g. fr-fr, es-es)`,required:!0}},options:{master:{type:`boolean`,description:`Set as the master locale`},name:{type:`string`,short:`n`,description:`Custom display name (for custom locales)`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A(),master:a=!1,name:o}=t,s=await D();await be({id:n,isMaster:a,customName:o},{repo:i,getToken:g,host:s,onUnauthorized:P}),console.info(`Locale added: ${n}`)}),di=F({name:`prismic locale list`,description:`
|
|
268
268
|
List all locales in a Prismic repository.
|
|
269
269
|
|
|
270
270
|
By default, this command reads the repository from prismic.config.json at the
|
|
271
271
|
project root.
|
|
272
|
-
`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await
|
|
272
|
+
`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await A(),json:i}=e,a=await D(),{results:o}=await d({repo:n,getToken:g,host:a,onUnauthorized:P});if(i){console.info(U(o));return}if(o.length===0){console.info(`No locales found.`);return}let s=o.map(e=>{let t=e.isMaster?` (master)`:``;return[e.id,`${e.label}${t}`]});console.info(r(s,{headers:[`ID`,`LABEL`]}))}),fi=F({name:`prismic locale remove`,description:`
|
|
273
273
|
Remove a locale from a Prismic repository.
|
|
274
274
|
|
|
275
275
|
By default, this command reads the repository from prismic.config.json at the
|
|
276
276
|
project root.
|
|
277
|
-
`,positionals:{code:{description:`Locale code (e.g. en-us, fr-fr)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
277
|
+
`,positionals:{code:{description:`Locale code (e.g. en-us, fr-fr)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A()}=t,a=await D();await et(n,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Locale removed: ${n}`)}),pi=F({name:`prismic locale set-master`,description:`
|
|
278
278
|
Set the master locale for a Prismic repository.
|
|
279
279
|
|
|
280
280
|
By default, this command reads the repository from prismic.config.json at the
|
|
281
281
|
project root.
|
|
282
|
-
`,positionals:{code:{description:`Locale code (e.g. en-us, fr-fr)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
282
|
+
`,positionals:{code:{description:`Locale code (e.g. en-us, fr-fr)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A()}=t,a=await D(),{results:o}=await d({repo:i,getToken:g,host:a,onUnauthorized:P}),s=o.find(e=>e.id===n);if(!s)throw new C(`Locale "${n}" not found. Available locales: ${o.map(e=>e.id).join(`, `)}`);if(s.isMaster)throw new C(`Locale "${n}" is already the master.`);await be({id:s.id,isMaster:!0,customName:s.customName??void 0},{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Master locale set: ${n}`)}),mi=S({name:`prismic locale`,description:`
|
|
283
283
|
Manage locales in a Prismic repository.
|
|
284
284
|
|
|
285
285
|
Run \`prismic docs view locales\` for details.
|
|
286
|
-
`,commands:{add:{handler:
|
|
286
|
+
`,commands:{add:{handler:ui,description:`Add a locale`},list:{handler:di,description:`List locales`},remove:{handler:fi,description:`Remove a locale`},"set-master":{handler:pi,description:`Set the master locale`}}}),hi=F({name:`prismic login`,description:`Log in to Prismic. Prints a URL and a code to approve in a browser.`,options:{"no-browser":{type:`boolean`,description:`Skip opening the browser automatically`}}},async({values:e})=>{await te({browser:!e[`no-browser`]})}),gi=F({name:`prismic logout`,description:`Log out of Prismic.`},async()=>{let e=!1;await at(async t=>{try{let t=(await Ge()).login?.session;t?.refreshToken&&(await je(t.refreshToken,t),e=!0)}catch(e){if(!(e instanceof nt||e instanceof ft))throw e;console.warn(`Couldn't revoke your session because ${_i(e)}. It stays valid until it expires.`)}await ut(t),await Se()}),Fe({revoked:e}),j.PRISMIC_TOKEN&&console.warn(`PRISMIC_TOKEN is still set, so commands still use it.`),console.info(`Logged out of Prismic`)});function _i(e){return e instanceof nt?`the saved login can't be read`:e.reason===`unavailable`?`the Prismic login service can't be reached`:`the Prismic login service answered ${e.detail}`}var vi=F({name:`prismic preview add`,description:`
|
|
287
287
|
Add a preview configuration to a Prismic repository.
|
|
288
288
|
|
|
289
289
|
By default, this command reads the repository from prismic.config.json at the
|
|
290
290
|
project root.
|
|
291
|
-
`,positionals:{url:{description:`Preview URL (e.g. https://example.com/api/preview)`,required:!0}},options:{name:{type:`string`,short:`n`,description:`Display name (defaults to hostname)`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
291
|
+
`,positionals:{url:{description:`Preview URL (e.g. https://example.com/api/preview)`,required:!0}},options:{name:{type:`string`,short:`n`,description:`Display name (defaults to hostname)`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A(),name:a}=t,o;try{o=new URL(n)}catch{throw new C(`Invalid URL: ${n}`)}let s=a||o.hostname,c=`${o.protocol}//${o.host}`,l=o.pathname===`/`?void 0:o.pathname,u=await D();await ot({name:s,websiteURL:c,resolverPath:l},{repo:i,getToken:g,host:u,onUnauthorized:P}),console.info(`Preview added: ${n}`),console.info("Run `prismic preview set-simulator <url>` to set the slice simulator URL.");try{let e=await(await M()).getSetupInstructions();e&&console.info(`\n${e}`)}catch(e){if(!(e instanceof De||e instanceof Gt))throw e}}),yi=F({name:`prismic preview list`,description:`
|
|
292
292
|
List all preview configurations in a Prismic repository.
|
|
293
293
|
|
|
294
294
|
By default, this command reads the repository from prismic.config.json at the
|
|
295
295
|
project root.
|
|
296
|
-
`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await
|
|
296
|
+
`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await A(),json:i}=e,o=await D(),[{results:s},{simulator_url:c}]=await Promise.all([a({repo:n,getToken:g,host:o,onUnauthorized:P}),ae({repo:n,getToken:g,host:o,onUnauthorized:P})]);if(i)console.info(U({previews:s,simulatorUrl:c??null}));else if(s.length===0&&!c)console.info(`No preview configurations found.`);else{if(s.length>0){let e=s.map(e=>[e.url,e.label]);console.info(r(e,{headers:[`URL`,`NAME`]}))}c&&(s.length>0&&console.info(``),console.info(`Simulator: ${c}`))}}),bi=F({name:`prismic preview remove`,description:`
|
|
297
297
|
Remove a preview configuration from a Prismic repository.
|
|
298
298
|
|
|
299
299
|
By default, this command reads the repository from prismic.config.json at the
|
|
300
300
|
project root.
|
|
301
|
-
`,positionals:{url:{description:`Preview URL to remove`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[
|
|
301
|
+
`,positionals:{url:{description:`Preview URL to remove`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A()}=t,o=await D(),{results:s}=await a({repo:i,getToken:g,host:o,onUnauthorized:P}),c=s.find(e=>e.url===n);if(!c)throw new C(`Preview not found: ${n}`);await Be(c.id,{repo:i,getToken:g,host:o,onUnauthorized:P}),console.info(`Preview removed: ${n}`)}),xi=F({name:`prismic preview set-simulator`,description:`
|
|
302
302
|
Set the slice simulator URL for a Prismic repository.
|
|
303
303
|
|
|
304
304
|
If the URL pathname does not end with /slice-simulator, it is appended
|
|
@@ -306,7 +306,7 @@ Start building 🚀`))):(console.info(`
|
|
|
306
306
|
|
|
307
307
|
By default, this command reads the repository from prismic.config.json at the
|
|
308
308
|
project root.
|
|
309
|
-
`,positionals:{url:{description:`Simulator URL (e.g. https://example.com/slice-simulator)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
309
|
+
`,positionals:{url:{description:`Simulator URL (e.g. https://example.com/slice-simulator)`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A()}=t,a;try{a=new URL(n)}catch{throw new C(`Invalid URL: ${n}`)}a.pathname.endsWith(`/slice-simulator`)||(a.pathname=a.pathname.replace(/\/+$/,``)+`/slice-simulator`);let o=a.toString(),c=await D();await s(o,{repo:i,getToken:g,host:c,onUnauthorized:P}),console.info(`Simulator URL set: ${o}`)}),Si=S({name:`prismic preview`,description:`
|
|
310
310
|
Manage previews in a Prismic repository.
|
|
311
311
|
|
|
312
312
|
Run \`prismic docs view previews\` for details.
|
|
@@ -314,15 +314,15 @@ Start building 🚀`))):(console.info(`
|
|
|
314
314
|
Set up previews after a deploy, using both settings:
|
|
315
315
|
prismic preview add https://example.com/api/preview
|
|
316
316
|
prismic preview set-simulator https://example.com
|
|
317
|
-
`},commands:{add:{handler:
|
|
318
|
-
`)){if(r.length<4)continue;let t=r.slice(3),i=t.indexOf(` -> `);i!==-1&&(t=t.slice(i+4)),n.push(new URL(t,e))}return n}catch{return[]}}var
|
|
317
|
+
`},commands:{add:{handler:vi,description:`Add a preview URL`},list:{handler:yi,description:`List preview URLs and the simulator URL`},remove:{handler:bi,description:`Remove a preview URL`},"set-simulator":{handler:xi,description:`Set the slice simulator URL`}}});async function Ci(e){try{let{stdout:t}=await zt(`git`,[`rev-parse`,`--show-toplevel`],{nodeOptions:{cwd:en(e)},throwOnError:!0}),n=t.trim();return n?Ht(tn(await Qt(n))):void 0}catch{return}}async function wi(e){try{let{stdout:t}=await zt(`git`,[`status`,`--porcelain`,`--untracked-files=all`],{nodeOptions:{cwd:en(e)},throwOnError:!0}),n=[];for(let r of t.split(`
|
|
318
|
+
`)){if(r.length<4)continue;let t=r.slice(3),i=t.indexOf(` -> `);i!==-1&&(t=t.slice(i+4)),n.push(new URL(t,e))}return n}catch{return[]}}var Ti=F({name:`prismic pull`,description:`
|
|
319
319
|
Pull content types and slices from Prismic to local files.
|
|
320
320
|
|
|
321
321
|
Remote models are the source of truth. Local files are created, updated,
|
|
322
322
|
or deleted to match.
|
|
323
323
|
|
|
324
324
|
Run \`prismic docs view cli#pull-models-from-prismic\` for details.
|
|
325
|
-
`,options:{force:{type:`boolean`,short:`f`,description:`Skip the git history check and overwrite local changes`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await
|
|
325
|
+
`,options:{force:{type:`boolean`,short:`f`,description:`Skip the git history check and overwrite local changes`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await M(),{force:n=!1,env:r,repo:i=r??await t.getEnvironment()??await E()}=e,a=await D(),o=await L();console.info(`Pulling from repository: ${i}`);let[s,c,l]=await Promise.all([Ci(o),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!n&&s){let e=(await wi(s)).filter(e=>e.pathname.endsWith(`/model.json`)&&l.some(t=>R(t,e))||e.pathname.endsWith(`/index.json`)&&c.some(t=>R(t,e))).map(e=>z(o,e));if(e.length>0)throw new C(`
|
|
326
326
|
Local model files have uncommitted changes. Prismic keeps model history in
|
|
327
327
|
git. Commit model changes before you pull them, so this pull can't discard
|
|
328
328
|
your edits:
|
|
@@ -334,7 +334,7 @@ Start building 🚀`))):(console.info(`
|
|
|
334
334
|
Other options:
|
|
335
335
|
prismic push --force Keep local edits, overwrite remote
|
|
336
336
|
prismic pull --force Discard local edits, adopt remote
|
|
337
|
-
`)}let[
|
|
337
|
+
`)}let[u,d,f]=await Promise.all([t.getCustomTypes(),t.getSlices(),w({repo:i,getToken:g,host:a,onUnauthorized:P})]),p=m(f,{customTypes:u.map(e=>e.model),slices:d.map(e=>e.model)},{treatNonCanonicalAsChanged:!0});if(!n&&!s){let e=new Set([...p.customTypes.update,...p.customTypes.delete].map(e=>e.id)),t=new Set([...p.slices.update,...p.slices.delete].map(e=>e.id)),n=[...u.filter(t=>e.has(t.model.id)),...d.filter(e=>t.has(e.model.id))].map(e=>z(o,e.modelPath));if(n.length>0)throw new C(`
|
|
338
338
|
Pull would modify or delete local model files:
|
|
339
339
|
${n.join(`
|
|
340
340
|
`)}
|
|
@@ -342,7 +342,7 @@ Start building 🚀`))):(console.info(`
|
|
|
342
342
|
This project isn't in a git repo, so changes can't be tracked. Choose one:
|
|
343
343
|
prismic pull --force Discard local files, adopt remote
|
|
344
344
|
prismic push --force Keep local files, overwrite remote
|
|
345
|
-
`)}let
|
|
345
|
+
`)}let h=await t.writeModels(p);await t.generateTypes(),await Z([`connectPrismic`],{repo:await E(),getToken:g,host:a,onUnauthorized:P}).catch(()=>{});let _=p.customTypes.insert.length+p.customTypes.update.length,v=p.slices.insert.length+p.slices.update.length,y=p.customTypes.delete.length+p.slices.delete.length;for(let e of h)console.info(e);_===0&&v===0&&y===0?console.info(`Already up to date.`):(console.info(`Inserted ${p.customTypes.insert.length}, updated ${p.customTypes.update.length}, deleted ${p.customTypes.delete.length} types`),console.info(`Inserted ${p.slices.insert.length}, updated ${p.slices.update.length}, deleted ${p.slices.delete.length} slices`))}),Ei=F({name:`prismic push`,description:`
|
|
346
346
|
Push local content types and slices to Prismic.
|
|
347
347
|
|
|
348
348
|
Local models are the source of truth. Remote models are created,
|
|
@@ -353,7 +353,7 @@ Start building 🚀`))):(console.info(`
|
|
|
353
353
|
Deleting a remote model needs --force.
|
|
354
354
|
|
|
355
355
|
Run \`prismic docs view cli#push-models-to-prismic\` for details.
|
|
356
|
-
`,options:{force:{type:`boolean`,short:`f`,description:`Skip the git history and deletion checks`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await
|
|
356
|
+
`,options:{force:{type:`boolean`,short:`f`,description:`Skip the git history and deletion checks`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await M(),{force:n=!1,env:r,repo:i=r??await t.getEnvironment()??await E()}=e,a=await D(),o=await L();console.info(`Pushing to repository: ${i}`);let[s,c,l]=await Promise.all([Ci(o),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!n&&s){let e=(await wi(s)).filter(e=>e.pathname.endsWith(`/model.json`)&&l.some(t=>R(t,e))||e.pathname.endsWith(`/index.json`)&&c.some(t=>R(t,e))).map(e=>z(o,e));if(e.length>0)throw new C(`
|
|
357
357
|
Local model files have uncommitted changes. Prismic keeps model history in
|
|
358
358
|
git. Commit model changes before you push them:
|
|
359
359
|
|
|
@@ -362,50 +362,50 @@ Start building 🚀`))):(console.info(`
|
|
|
362
362
|
prismic push
|
|
363
363
|
|
|
364
364
|
Or skip the check with \`prismic push --force\`.
|
|
365
|
-
`)}let[
|
|
365
|
+
`)}let[u,d]=await Promise.all([t.getModels(),w({repo:i,getToken:g,host:a,onUnauthorized:P})]),f=m(u,d);if(!n){let e=Ht(c[0]),t=Ht(l[0]),n=[...f.customTypes.delete.map(t=>z(o,new URL(`${t.id}/index.json`,e))),...f.slices.delete.map(e=>z(o,new URL(`${He(e.name)}/model.json`,t)))];if(n.length>0)throw new C(`
|
|
366
366
|
Push would delete remote models. Re-run with --force to proceed.
|
|
367
367
|
|
|
368
368
|
Models that would be deleted:
|
|
369
369
|
${n.join(`
|
|
370
370
|
`)}
|
|
371
|
-
`)}try{await
|
|
372
|
-
Please try again, or manually delete any associated pages at: `+t)}if(a!==0)return new
|
|
371
|
+
`)}try{await ve(f,{repo:i,getToken:g,host:a,onUnauthorized:P})}catch(e){throw await Oi(e,f.customTypes.delete,{repo:i,getToken:g,host:a,onUnauthorized:P})}for(let{id:e}of f.slices.delete)await yt(e,{repo:i,getToken:g,host:a,onUnauthorized:P}).catch(t=>{let n=t instanceof Error?t.message:String(t);console.warn(`Failed to delete screenshots for slice "${e}"${n?`: ${n}`:`.`}`)});let p=[];f.slices.insert.length>0&&p.push(`createSlice`),f.customTypes.insert.some(e=>e.format===`page`)&&p.push(`createPageType`),p.length>0&&await Z(p,{repo:await E(),getToken:g,host:a,onUnauthorized:P}).catch(()=>{});let h=f.customTypes.insert.length+f.customTypes.update.length,_=f.slices.insert.length+f.slices.update.length,v=f.customTypes.delete.length+f.slices.delete.length;h===0&&_===0&&v===0?console.info(`Already up to date.`):(console.info(`Pushed ${h} type(s), ${_} slice(s).`),v>0&&console.info(`Deleted ${v} model(s).`))});const Di=W({hasExistingDocuments:At(!0)});async function Oi(e,t,n){if(!(e instanceof G)||!Vt(Di,e.body).success)return e;let{repo:r,host:i}=n;for(let{id:e}of t){let t=ki({repo:r,host:i,customTypeId:e}),a;try{a=(await he(e,n)).total}catch{return new C(`Could not check whether type "${e}" has associated pages.
|
|
372
|
+
Please try again, or manually delete any associated pages at: `+t)}if(a!==0)return new C(`Could not delete type "${e}" because it has ${a} associated ${a===1?`page`:`pages`}. \nDelete any associated pages manually before pushing at: `+t)}return e}function ki(e){let{repo:t,host:n,customTypeId:r}=e,i=new URL(`builder/working`,`https://${t}.${n}/`);return i.searchParams.set(`customTypes`,r),i.href}var Ai=F({name:`prismic repo list`,description:`List all Prismic repositories associated with your account.`,options:{json:{type:`boolean`,description:`Output as JSON`}}},async({values:e})=>{let{json:t}=e,n=await D(),{repositories:i}=await h({getToken:g,host:n,onUnauthorized:P});if(t){console.info(U(i.map(e=>({domain:e.domain,name:e.name??null,role:e.role??null,url:`https://${e.domain}.${n}/`}))));return}if(i.length===0){console.info(`No repositories found.`);return}let a=i.map(e=>{let t=e.name||`(no name)`;return[e.domain,t,ji(e.role)]});console.info(r(a,{headers:[`DOMAIN`,`NAME`,`ROLE`]}))});function ji(e){return typeof e==`string`?e:e?Object.entries(e).map(([e,t])=>`${t} (${e})`).join(`, `):``}const Mi=[`private`,`public`,`open`],Ni={name:`prismic repo set-api-access`,description:`
|
|
373
373
|
Set the Content API access level of a Prismic repository.
|
|
374
374
|
|
|
375
375
|
By default, this command reads the repository from prismic.config.json at the
|
|
376
376
|
project root.
|
|
377
377
|
|
|
378
378
|
Run \`prismic docs view repository-settings#configuration\` for details.
|
|
379
|
-
`,positionals:{level:{description:`Access level (${
|
|
379
|
+
`,positionals:{level:{description:`Access level (${Mi.join(`, `)})`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}};var Pi=F(Ni,async({positionals:e,values:t})=>{let[n]=e,{repo:r=await E()}=t;if(!Mi.includes(n))throw new C(`Invalid access level: ${n}. Must be one of: ${Mi.join(`, `)}`);let i=await D();await fe(n,{repo:r,getToken:g,host:i,onUnauthorized:P}),console.info(`Repository access set to: ${n}`)}),Fi=F({name:`prismic repo set-name`,description:`
|
|
380
380
|
Set the display name of a Prismic repository.
|
|
381
381
|
|
|
382
382
|
By default, this command reads the repository from prismic.config.json at the
|
|
383
383
|
project root.
|
|
384
|
-
`,positionals:{name:{description:`Display name for the repository`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({positionals:e,values:t})=>{let[n]=e,{repo:r=await
|
|
384
|
+
`,positionals:{name:{description:`Display name for the repository`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({positionals:e,values:t})=>{let[n]=e,{repo:r=await E()}=t,i=await D(),{repository:a}=await Et(n,{repo:r,getToken:g,host:i,onUnauthorized:P});console.info(`Repository name set to: ${a.name}`)}),Ii=F({name:`prismic repo view`,description:`
|
|
385
385
|
View details of a Prismic repository.
|
|
386
386
|
|
|
387
387
|
By default, this command reads the repository from prismic.config.json at the
|
|
388
388
|
project root.
|
|
389
|
-
`,options:{web:{type:`boolean`,short:`w`,description:`Open repository in browser`},json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({values:e})=>{let{repo:t=await
|
|
389
|
+
`,options:{web:{type:`boolean`,short:`w`,description:`Open repository in browser`},json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({values:e})=>{let{repo:t=await E(),web:n,json:r}=e,i=await D(),a=`https://${t}.${i}/`;if(n){Pe(new URL(a)),console.info(`Opening ${a}`);return}let[o,s]=await Promise.all([Je({repo:t,getToken:g,host:i,onUnauthorized:P}),re({repo:t,getToken:g,host:i,onUnauthorized:P}).catch(e=>{if(!sn(e))throw e})]);if(r){console.info(U({domain:t,name:o.name??null,url:a,apiAccess:s?.repository.api_access??null}));return}let c=o.name||`(no name)`;console.info(`Name: ${c}`),console.info(`URL: ${a}`),console.info(`Content API: ${s?.repository.api_access??`(unavailable)`}`)}),Li=S({name:`prismic repo`,description:`
|
|
390
390
|
Manage Prismic repositories.
|
|
391
391
|
|
|
392
392
|
Run \`prismic docs view repository-settings\` for details.
|
|
393
|
-
`,commands:{create:{handler:
|
|
393
|
+
`,commands:{create:{handler:ri,description:`Create a new repository`},list:{handler:Ai,description:`List repositories`},view:{handler:Ii,description:`View repository details`},"set-name":{handler:Fi,description:`Set repository display name`},"set-api-access":{handler:Pi,description:`Set Content API access level`}}}),Ri=F({name:`prismic slice add-variation`,description:`
|
|
394
394
|
Add a variation to a slice.
|
|
395
395
|
|
|
396
396
|
Run \`prismic docs view slices#slice-variations\` for details.
|
|
397
|
-
`,positionals:{name:{description:`Name of the variation`,required:!0}},options:{to:{type:`string`,required:!0,description:`ID of the slice`},id:{type:`string`,description:`Custom ID for the variation`},screenshot:{type:`string`,short:`s`,description:`Screenshot image file path or URL`}}},async({positionals:e,values:t})=>{let[n]=e,{to:r,id:i=
|
|
397
|
+
`,positionals:{name:{description:`Name of the variation`,required:!0}},options:{to:{type:`string`,required:!0,description:`ID of the slice`},id:{type:`string`,description:`Custom ID for the variation`},screenshot:{type:`string`,short:`s`,description:`Screenshot image file path or URL`}}},async({positionals:e,values:t})=>{let[n]=e,{to:r,id:i=ct(n),screenshot:a}=t,o=await M(),{model:s}=await o.getSlice(r);if(s.variations.some(e=>e.id===i))throw new C(`Variation "${i}" already exists in slice "${r}".`);let c=``;if(a){let e=await E(),t=await D(),n=/^https?:\/\//i.test(a)?new URL(a):tn(a),r=await qt(n);c=(await _e(r,{sliceId:s.id,variationId:i,repo:e,getToken:g,host:t,onUnauthorized:P})).toString()}s.variations.push({id:i,name:n,description:n,docURL:``,imageUrl:c,version:``,primary:{}}),await o.updateSlice(s),await o.generateTypes(),console.info(`Added variation "${n}" (id: "${i}") to slice "${r}"`)}),zi=F({name:`prismic slice connect`,description:`Connect a slice to a type's slice zone.`,sections:{EXAMPLES:`
|
|
398
398
|
Connect a slice to a type's default slice zone:
|
|
399
399
|
prismic slice connect hero --to blog_post
|
|
400
400
|
|
|
401
401
|
Connect to a named slice zone:
|
|
402
402
|
prismic slice connect hero --to blog_post --slice-zone page_slices
|
|
403
|
-
`},positionals:{id:{description:`ID of the slice`,required:!0}},options:{to:{type:`string`,required:!0,description:`ID of the content type`},"slice-zone":{type:`string`,description:`Slice zone field ID (default: "slices")`}}},async({positionals:e,values:t})=>{let[n]=e,{to:r,"slice-zone":i=`slices`}=t,a=await
|
|
403
|
+
`},positionals:{id:{description:`ID of the slice`,required:!0}},options:{to:{type:`string`,required:!0,description:`ID of the content type`},"slice-zone":{type:`string`,description:`Slice zone field ID (default: "slices")`}}},async({positionals:e,values:t})=>{let[n]=e,{to:r,"slice-zone":i=`slices`}=t,a=await M(),{model:o}=await a.getSlice(n),{model:s}=await a.getCustomType(r),c=Object.assign({},...Object.values(s.json))[i];if(!c||c.type!==`Slices`)throw new C(`Slice zone "${i}" not found in "${r}".`);if(c.config??={},c.config.choices??={},o.id in c.config.choices)throw new C(`Slice "${o.id}" is already connected to "${r}" in slice zone "${i}".`);c.config.choices[o.id]={type:`SharedSlice`},await a.updateCustomType(s),await a.generateTypes(),console.info(`Connected slice "${n}" to "${r}"`)}),Bi=F({name:`prismic slice create`,description:`Create a new slice.`,positionals:{name:{description:`Name of the slice`,required:!0}},options:{id:{type:`string`,description:`Custom ID for the slice`}}},async({positionals:e,values:t})=>{let[n]=e,{id:r=ze(n)}=t,i={id:r,name:n,type:`SharedSlice`,variations:[{id:`default`,name:`Default`,description:`Default`,docURL:``,imageUrl:``,version:``,primary:{}}]},a=await M();await a.createSlice(i),await a.generateTypes(),console.info(`Created slice "${n}" (id: "${r}")`),console.info(`Run \`prismic field add <type> --to-slice ${r}\` to add fields.`),console.info(`Run \`prismic slice connect ${r} --to <type>\` to connect the slice to a type.`)}),Vi=F({name:`prismic slice disconnect`,description:`Disconnect a slice from a type's slice zone.`,positionals:{id:{description:`ID of the slice`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the content type`},"slice-zone":{type:`string`,description:`Slice zone field ID (default: "slices")`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r,"slice-zone":i=`slices`}=t,a=await M(),{model:o}=await a.getSlice(n),{model:s}=await a.getCustomType(r),c=Object.assign({},...Object.values(s.json))[i];if(!c||c.type!==`Slices`)throw new C(`Slice zone "${i}" not found in "${r}".`);if(!c.config?.choices||!(o.id in c.config.choices))throw new C(`Slice "${o.id}" is not connected to "${r}" in slice zone "${i}".`);delete c.config.choices[o.id],await a.updateCustomType(s),await a.generateTypes(),console.info(`Disconnected slice "${n}" from "${r}"`)}),Hi=F({name:`prismic slice edit`,description:`Edit a slice.`,positionals:{id:{description:`ID of the slice`,required:!0}},options:{name:{type:`string`,short:`n`,description:`New name for the slice`}}},async({positionals:e,values:t})=>{let[n]=e,r=await M(),{model:i}=await r.getSlice(n);`name`in t&&(i.name=t.name),await r.updateSlice(i),await r.generateTypes(),console.info(`Slice updated: "${i.name}" (id: ${i.id})`)}),Ui=F({name:`prismic slice edit-variation`,description:`Edit a variation of a slice.`,positionals:{id:{description:`ID of the variation`,required:!0}},options:{"from-slice":{type:`string`,required:!0,description:`ID of the slice`},name:{type:`string`,short:`n`,description:`New name for the variation`},screenshot:{type:`string`,short:`s`,description:`Screenshot image file path or URL`}}},async({positionals:e,values:t})=>{let[n]=e,{"from-slice":r,screenshot:i}=t,a=await M(),{model:o}=await a.getSlice(r),s=o.variations.find(e=>e.id===n);if(!s)throw new C(`Variation "${n}" not found in slice "${r}".`);if(`name`in t&&(s.name=t.name),i){let e=await E(),t=await D(),n=/^https?:\/\//i.test(i)?new URL(i):tn(i),r=await qt(n);s.imageUrl=(await _e(r,{sliceId:o.id,variationId:s.id,repo:e,getToken:g,host:t,onUnauthorized:P})).toString()}await a.updateSlice(o),await a.generateTypes(),console.info(`Variation updated: "${n}" in slice "${r}"`)}),Wi=F({name:`prismic slice list`,description:`
|
|
404
404
|
List all slices.
|
|
405
405
|
|
|
406
406
|
Legacy slices from the Legacy Builder are marked with * and show the type
|
|
407
407
|
that defines them.
|
|
408
|
-
`,options:{legacy:{type:`boolean`,description:`List only legacy slices`},json:{type:`boolean`,description:`Output as JSON`}}},async({values:e})=>{let{legacy:t,json:n}=e,
|
|
408
|
+
`,options:{legacy:{type:`boolean`,description:`List only legacy slices`},json:{type:`boolean`,description:`Output as JSON`}}},async({values:e})=>{let{legacy:t,json:n}=e,i=await M(),a=t?[]:(await i.getSlices()).map(e=>e.model),o=(await i.getCustomTypes()).map(e=>e.model),s=b(o);if(n&&t){let e=s.map(e=>({id:e.id,definedIn:e.customTypeId,sliceZone:e.sliceZoneId}));console.info(U(e));return}if(n){console.info(U(a));return}if(a.length===0&&s.length===0){console.info(t?`No legacy slices found.`:`No slices found.`);return}let c=[...a.map(e=>[e.name,e.id,``]),...s.map(({id:e,model:t,customTypeId:n,sliceZoneId:r})=>[`${(`fieldset`in t?t.fieldset:t.config?.label)||e} *`,e,r===`body`?n:`${n} (${r} slice zone)`])];console.info(r(c,{headers:[`NAME`,`ID`,`DEFINED IN`]})),s.length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),Gi=F({name:`prismic slice remove`,description:`Remove a slice.`,positionals:{id:{description:`ID of the slice`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await M();await n.deleteSlice(t),await n.generateTypes(),console.info(`Slice removed: ${t}`)}),Ki=F({name:`prismic slice remove-variation`,description:`Remove a variation from a slice.`,positionals:{id:{description:`ID of the variation`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the slice`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r}=t,i=await M(),{model:a}=await i.getSlice(r),o=a.variations.find(e=>e.id===n);if(!o)throw new C(`Variation "${n}" not found in slice "${r}".`);a.variations=a.variations.filter(e=>e.id!==o.id),await i.updateSlice(a),await i.generateTypes(),console.info(`Removed variation "${n}" from slice "${r}"`)}),qi=F({name:`prismic slice upgrade-legacy`,description:`
|
|
409
409
|
Upgrade a legacy slice from the Legacy Builder.
|
|
410
410
|
|
|
411
411
|
The CLI and the Type Builder cannot edit legacy slices. Run
|
|
@@ -432,47 +432,47 @@ Please try again, or manually delete any associated pages at: `+t)}if(a!==0)retu
|
|
|
432
432
|
|
|
433
433
|
Merge a legacy slice into an existing variation with the same fields:
|
|
434
434
|
prismic slice upgrade-legacy hero --from landing_page --to hero --variation default
|
|
435
|
-
`},positionals:{id:{description:`ID of the legacy slice`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the type that contains the legacy slice`},"slice-zone":{type:`string`,description:`Slice zone field ID (default: "body")`},to:{type:`string`,description:`ID of the slice to upgrade to, created if missing (default: the legacy slice ID)`},variation:{type:`string`,description:`Variation to create, or to merge into if it has the same fields (default: "default" for a new slice, the legacy slice ID otherwise)`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r,"slice-zone":i=`body`,to:a,variation:o}=t,s=await
|
|
436
|
-
`)}function
|
|
435
|
+
`},positionals:{id:{description:`ID of the legacy slice`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the type that contains the legacy slice`},"slice-zone":{type:`string`,description:`Slice zone field ID (default: "body")`},to:{type:`string`,description:`ID of the slice to upgrade to, created if missing (default: the legacy slice ID)`},variation:{type:`string`,description:`Variation to create, or to merge into if it has the same fields (default: "default" for a new slice, the legacy slice ID otherwise)`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r,"slice-zone":i=`body`,to:a,variation:o}=t,s=await M(),c=(await s.getCustomTypes()).map(e=>e.model),l=(await s.getSlices()).map(e=>e.model),u=b(c),d=c.find(e=>e.id===r);if(!d)throw new C(`Type "${r}" not found.`);let f=u.find(e=>e.customTypeId===r&&e.sliceZoneId===i&&e.id===n);if(!f)throw new C(`Legacy slice "${n}" not found in the "${i}" slice zone of "${r}". Use --slice-zone to choose the slice zone.`);let p=`${r}::${i}::${n}`,m=a??ze(n),h=f.sliceZone.config?.choices?.[m];if(m!==n&&h&&h.type!==`SharedSlice`)throw new C(`The "${i}" slice zone of "${r}" also has legacy slice "${m}". Upgrade it first.`);let g=l.find(e=>e.id===m),_=ct(o??(g?n:`default`)),v=Xi(f,_),y;if(g){if(!a)throw new C(Ji(g,f,v));let e=g.variations.find(e=>e.id===_);if(e&&!Zi(e,v))throw new C(`Variation "${_}" of slice "${m}" has different fields than legacy slice "${n}". Use another ID with --variation.`);e?y=`Merged legacy slice "${n}" into variation "${_}" of slice "${m}"`:(g.variations.push(v),y=`Added legacy slice "${n}" to slice "${m}" as variation "${_}"`),g.legacyPaths={...g.legacyPaths,[p]:_},await s.updateSlice(g)}else{let{model:e}=f,t=`fieldset`in e?e.fieldset:void 0;g={id:m,type:`SharedSlice`,name:He(a??t??m),legacyPaths:{[p]:_},variations:[v]},y=`Upgraded legacy slice "${n}" to slice "${m}"`,await s.createSlice(g)}Qi(f,g.id),await s.updateCustomType(d),await s.generateTypes();let{directory:x}=await s.getSlice(g.id),ee=z(await L(),x),S=u.length-1;console.info(y),console.info(`After \`prismic push\`: ${Yi(f,m,_)}`),console.info(`Update the component in ${ee}, then deploy it with \`prismic push\`. Documents use the new shape after the next publish.`),S>0&&console.info(`\n${S} legacy ${S===1?`slice remains`:`slices remain`}. Run \`prismic slice list --legacy\` to list them.`)});function Ji(e,t,n){let{id:r,customTypeId:i,sliceZoneId:a}=t,o=`prismic slice upgrade-legacy ${r} --from ${i}${a===`body`?``:` --slice-zone ${a}`}`,s=e.variations.find(e=>Zi(e,n));return[`Slice "${e.id}" already exists. How do you want to upgrade legacy slice "${r}" of "${i}"? This changes how editors pick slices, so the project's owner should choose:`,` Add it to slice "${e.id}" as a new variation: ${o} --to ${e.id}`,...s?[` Merge it into variation "${s.id}", which has the same fields: ${o} --to ${e.id} --variation ${s.id}`]:[],` Upgrade it to a separate slice: ${o} --to <new-slice-id>`].join(`
|
|
436
|
+
`)}function Yi(e,t,n){let{model:r,id:i}=e,a=[];return(t!==i||n!=="default")&&a.push(`\`slice_type\` becomes "${t}" and \`variation\` becomes "${n}".`),r.type===`Group`?a.push("`slice.value` moves to `slice.items`."):r.type!==`Slice`&&a.push(`\`slice.value\` moves to \`slice.primary.${i}\`.`),a.join(` `)||"`slice.primary` and `slice.items` keep their shape."}function Xi(e,t){let{model:n}=e,r=t==="default"?`Default`:He(t),i={id:t,name:r,description:r,docURL:``,imageUrl:``,version:`initial`,primary:{},items:{}};switch(n.type){case`Slice`:i.primary=n[`non-repeat`]??{},i.items=n.repeat??{};break;case`Group`:i.items=n.config?.fields??{};break;default:i.primary={[e.id]:n}}return i}function Zi(e,t){return Xt(e.primary??{},t.primary??{})&&Xt(e.items??{},t.items??{})}function Qi({id:e,sliceZone:t},n){t.config.choices=Object.fromEntries(Object.entries(t.config.choices).filter(([t])=>t===e||t!==n).map(([t,r])=>t===e?[n,{type:`SharedSlice`}]:[t,r]))}var $i=F({name:`prismic slice view`,description:`View details of a slice.`,positionals:{id:{description:`ID of the slice`,required:!0}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t,{model:i}=await(await M()).getSlice(n);if(r)console.info(U(i));else{console.info(`ID: ${i.id}`),console.info(`Name: ${i.name}`);for(let e of i.variations??[])console.info(``),console.info(`${e.id}:`),console.info($n(e.primary??{}))}}),ea=S({name:`prismic slice`,description:`
|
|
437
437
|
Manage slices.
|
|
438
438
|
|
|
439
439
|
Run \`prismic docs view slices\` for details.
|
|
440
|
-
`,commands:{create:{handler:
|
|
440
|
+
`,commands:{create:{handler:Bi,description:`Create a new slice`},edit:{handler:Hi,description:`Edit a slice`},remove:{handler:Gi,description:`Remove a slice`},list:{handler:Wi,description:`List slices`},view:{handler:$i,description:`View a slice`},connect:{handler:zi,description:`Connect a slice to a type's slice zone`},disconnect:{handler:Vi,description:`Disconnect a slice from a type's slice zone`},"upgrade-legacy":{handler:qi,description:`Upgrade a legacy slice`},"add-variation":{handler:Ri,description:`Add a variation to a slice`},"edit-variation":{handler:Ui,description:`Edit a variation of a slice`},"remove-variation":{handler:Ki,description:`Remove a variation from a slice`}}}),ta=F({name:`prismic status`,description:`
|
|
441
441
|
Show local vs remote model differences.
|
|
442
442
|
|
|
443
443
|
Reports what would be pushed to or pulled from Prismic, plus any local
|
|
444
444
|
model files with uncommitted git changes that must be committed before
|
|
445
445
|
pull and push.
|
|
446
|
-
`,options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await
|
|
446
|
+
`,options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await M(),n=await E(),r=await t.getEnvironment(),{env:i,repo:a=i??r??n}=e,o=await D(),s=await g(),c=await L(),[l,u,d,f]=await Promise.all([Ci(c),t.getCustomTypeLibraries(),t.getSliceLibraries(),t.getModels()]),p,h;if(s){let[e,t]=await Promise.all([_(s,{host:o}),w({repo:a,getToken:g,host:o})]);p=e.type===`USER`?e.email:`${e.appName} (Write API token for ${e.domain})`,h=m(f,t)}let y=[];l&&(y=(await wi(l)).filter(e=>e.pathname.endsWith(`/model.json`)&&d.some(t=>R(t,e))||e.pathname.endsWith(`/index.json`)&&u.some(t=>R(t,e))).map(e=>z(c,e))),console.info(`Repository: ${n}`),a!==n&&console.info(`Environment: ${a}`),console.info(p?`Authenticated as: ${p}`:"Not logged in — log in with `prismic login` to compare with remote.");let x=b(f.customTypes).length;x>0&&console.info(`\n${x} legacy ${x===1?`slice needs`:`slices need`} upgrading. Run \`prismic slice list --legacy\`.`);let ee=h!==void 0&&!v(h.customTypes)&&!v(h.slices);if(ee&&y.length===0){console.info(``),console.info(`Already up to date.`);return}if(h){let e=[],t=[...h.customTypes.insert.map(e=>` ${e.id} (custom type)`),...h.slices.insert.map(e=>` ${e.id} (slice)`)];t.length>0&&e.push([`Local-only:`,...t]);let n=[...h.customTypes.delete.map(e=>` ${e.id} (custom type)`),...h.slices.delete.map(e=>` ${e.id} (slice)`)];n.length>0&&e.push([`Remote-only:`,...n]);let r=[...h.customTypes.update.map(e=>` ${e.id} (custom type)`),...h.slices.update.map(e=>` ${e.id} (slice)`)];r.length>0&&e.push([`Differ:`,...r]);for(let t of e){console.info(``);for(let e of t)console.info(e)}}let S=[];if(y.length>0&&(console.info(``),console.info(`Prismic keeps model history in git. Commit model changes before you push or pull them.`),S.push(`git add ${y.join(` `)}`),S.push(`git commit -m "Update Prismic models"`)),h&&!ee){let e=h.customTypes.insert.length+h.slices.insert.length,t=h.customTypes.update.length+h.slices.update.length,n=h.customTypes.delete.length+h.slices.delete.length;S.push(`prismic push # creates ${e}, updates ${t}, deletes ${n}`),S.push(`prismic pull # creates ${n}, updates ${t}, deletes ${e}`)}if(S.length>0){console.info(``),console.info(`Next:`);for(let e of S)console.info(` ${e}`)}});const na=j.PRISMIC_SYNC_POLL_MS??5e3;var ra=F({name:`prismic sync`,description:`
|
|
447
447
|
Watch Prismic and continuously pull changes to local files.
|
|
448
448
|
|
|
449
449
|
For one-time pulls, use \`prismic pull\`.
|
|
450
|
-
`,options:{watch:{type:`boolean`,short:`w`,description:`Watch for changes and sync continuously`,required:!0},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await
|
|
451
|
-
Watch stopped. Goodbye!`),
|
|
450
|
+
`,options:{watch:{type:`boolean`,short:`w`,description:`Watch for changes and sync continuously`,required:!0},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let t=await M(),{env:n,repo:r=n??await t.getEnvironment()??await E()}=e,i=await D();rt(`sync`,{watch:!0}),process.on(`SIGINT`,()=>{console.info(`
|
|
451
|
+
Watch stopped. Goodbye!`),ht(),process.exit(0)}),console.info(`Watching repository: ${r} (polling every ${na/1e3}s, Ctrl+C to stop)`);let a,o=0;for(;;){try{let e=await w({repo:r,getToken:g,host:i,onUnauthorized:P}),n=a&&m(e,a);if(!n||v(n.customTypes)||v(n.slices)){let r=!n,o=m(e,await t.getModels(),{treatNonCanonicalAsChanged:!0});for(let e of await t.writeModels(o))console.info(e);let s=[...v(o.slices)?[`slices`]:[],...v(o.customTypes)?[`custom types`]:[]];if((r||s.length>0)&&await t.generateTypes(),a=e,r)await Z([`connectPrismic`],{repo:await E(),getToken:g,host:i,onUnauthorized:P}).catch(()=>{}),console.info(`Initial sync complete.`);else if(s.length>0){let e=(/* @__PURE__ */ new Date()).toLocaleTimeString();console.info(`[${e}] Changes detected in ${s.join(` and `)}`)}}o=0}catch(e){o++;let t=await ln(e)??`Unknown error`;if(console.error(`Error checking for changes: ${t}`),o>=5)throw new C(`Too many consecutive errors (5), stopping watch.`)}await an(na)}});const ia=`0123456789abcdefghjkmnpqrstvwxyz`,aa=RegExp(`^pt_[${ia}]{16}$`);function oa(){let e=`pt_`;for(let t of rn(16))e+=ia[t&31];return e}function sa(e){return aa.test(e)}var ca=F({name:`prismic task-id`,description:`
|
|
452
452
|
Print a task ID for --task-id.
|
|
453
453
|
|
|
454
454
|
One ID covers one user request: pass it on every command for that request,
|
|
455
455
|
and run this again when the user asks for something else.
|
|
456
|
-
`},async()=>{console.info(
|
|
456
|
+
`},async()=>{console.info(oa())});const la=`Prismic CLI`;var ua=F({name:`prismic token create`,description:`
|
|
457
457
|
Create a new API token for a Prismic repository.
|
|
458
458
|
|
|
459
459
|
By default, this command reads the repository from prismic.config.json at the
|
|
460
460
|
project root.
|
|
461
|
-
`,options:{write:{type:`boolean`,description:`Create a write token`},"allow-releases":{type:`boolean`,description:`Allow access to releases (read tokens only)`},name:{type:`string`,short:`n`,description:`Name to identify the token (default: "${
|
|
461
|
+
`,options:{write:{type:`boolean`,description:`Create a write token`},"allow-releases":{type:`boolean`,description:`Allow access to releases (read tokens only)`},name:{type:`string`,short:`n`,description:`Name to identify the token (default: "${la}")`},json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await A(),write:r,"allow-releases":i,name:a=la,json:o}=e;if(r&&i)throw new C(`--allow-releases is only valid for access tokens (not with --write)`);let s=await D(),c,l;if(r)c=(await lt(a,{repo:n,getToken:g,host:s,onUnauthorized:P})).token;else{l=i?`master+releases`:`master`;let e=(await se({repo:n,getToken:g,host:s,onUnauthorized:P})).find(e=>e.name===a);e||=await Me(a,{repo:n,getToken:g,host:s,onUnauthorized:P}),c=(await Qe(e.id,l,{repo:n,getToken:g,host:s,onUnauthorized:P})).token}console.info(o?U({token:c,type:r?`write`:`access`,name:a,repository:n,...l?{scope:l}:{}}):`Token created: ${c}`)}),da=F({name:`prismic token delete`,description:`
|
|
462
462
|
Delete a token from a Prismic repository.
|
|
463
463
|
|
|
464
464
|
By default, this command reads the repository from prismic.config.json at the
|
|
465
465
|
project root.
|
|
466
|
-
`,positionals:{token:{description:`Token value`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
466
|
+
`,positionals:{token:{description:`Token value`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A()}=t,a=await D(),[o,s]=await Promise.all([se({repo:i,getToken:g,host:a,onUnauthorized:P}),ne({repo:i,getToken:g,host:a,onUnauthorized:P})]),c=o.flatMap(e=>e.wroom_auths).find(e=>e.token===n);if(c){await Ue(c.id,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Token deleted`);return}let l=s.tokens.find(e=>e.token===n);if(l)await Ae(l.token,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Token deleted`);else throw new C(`Token not found: ${n}`)}),fa=F({name:`prismic token list`,description:`
|
|
467
467
|
List all API tokens for a Prismic repository.
|
|
468
468
|
|
|
469
469
|
By default, this command reads the repository from prismic.config.json at the
|
|
470
470
|
project root.
|
|
471
|
-
`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await
|
|
471
|
+
`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await A(),json:i}=e,a=await D(),[o,s]=await Promise.all([se({repo:n,getToken:g,host:a,onUnauthorized:P}),ne({repo:n,getToken:g,host:a,onUnauthorized:P})]),c=o.flatMap(e=>e.wroom_auths.map(t=>({name:e.name,scope:t.scope,token:t.token,createdAt:new Date(t.created_at.$date).toISOString().split(`T`)[0]}))),l=s.tokens;if(i)console.info(U({accessTokens:c,writeTokens:l}));else{if(c.length>0){console.info(`ACCESS TOKENS`);let e=c.map(e=>[` ${e.name}`,e.scope,e.token,e.createdAt]);console.info(r(e))}else console.info(`ACCESS TOKENS (none)`);if(console.info(``),l.length>0){console.info(`WRITE TOKENS`);let e=l.map(e=>{let t=(/* @__PURE__ */ new Date(e.timestamp*1e3)).toISOString().split(`T`)[0];return[` ${e.app_name}`,e.token,t]});console.info(r(e))}else console.info(`WRITE TOKENS (none)`)}}),pa=S({name:`prismic token`,description:`
|
|
472
472
|
Manage API tokens for a Prismic repository.
|
|
473
473
|
|
|
474
474
|
Run \`prismic docs view repository-settings#configuration\` for details.
|
|
475
|
-
`,commands:{list:{handler:
|
|
475
|
+
`,commands:{list:{handler:fa,description:`List all tokens`},create:{handler:ua,description:`Create a new token`},delete:{handler:da,description:`Delete a token`}}}),ma=F({name:`prismic type add-tab`,description:`Add a tab to a content type.`,positionals:{name:{description:`Name of the tab`,required:!0}},options:{to:{type:`string`,required:!0,description:`ID of the content type`},"with-slice-zone":{type:`boolean`,description:`Add a slice zone to the tab`}}},async({positionals:e,values:t})=>{let[n]=e,{to:r,"with-slice-zone":i}=t,a=await M(),{model:o}=await a.getCustomType(r);if(n in o.json)throw new C(`Tab "${n}" already exists in "${r}".`);o.json[n]=i?{slices:{type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}}}:{},await a.updateCustomType(o),await a.generateTypes(),console.info(`Added tab "${n}" to "${r}"`)}),ha=F({name:`prismic type create`,description:`Create a new content type.`,positionals:{name:{description:`Name of the content type`,required:!0}},options:{format:{type:`string`,short:`f`,description:`Type format: "custom" (default) or "page"`},single:{type:`boolean`,short:`s`,description:`Allow only one document of this type`},id:{type:`string`,description:`Custom ID for the content type`}},sections:{FORMATS:`
|
|
476
476
|
custom A non-page type (e.g. settings, navigation, author, blog
|
|
477
477
|
category). This is the default.
|
|
478
478
|
page A page type with a URL (e.g. homepage, blog post, landing
|
|
@@ -487,11 +487,11 @@ Watch stopped. Goodbye!`),Me(`sync`,{watch:!0}),process.exit(0)}),console.info(`
|
|
|
487
487
|
|
|
488
488
|
Create with a custom ID:
|
|
489
489
|
prismic type create "Landing Page" --format page --id landing
|
|
490
|
-
`}},async({positionals:e,values:t})=>{let[n]=e,{format:r=`custom`,single:i=!1,id:a=
|
|
490
|
+
`}},async({positionals:e,values:t})=>{let[n]=e,{format:r=`custom`,single:i=!1,id:a=ze(n)}=t;if(r!==`custom`&&r!==`page`)throw new C(`Invalid format: "${r}". Use "custom" or "page".`);let o=await M();if((await o.getCustomTypes()).some(({model:e})=>e.id===a))throw new C(`Type "${a}" already exists. Run \`prismic type edit ${a}\` to change it.`);let s=r===`page`?{Main:{slices:{type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}}},"SEO & Metadata":{meta_title:{type:`Text`,config:{label:`Meta Title`,placeholder:`A title of the page used for social media and search engines`}},meta_description:{type:`Text`,config:{label:`Meta Description`,placeholder:`A brief summary of the page`}},meta_image:{type:`Image`,config:{label:`Meta Image`,constraint:{width:2400,height:1260},thumbnails:[]}}}}:{Main:{}};i||(s.Main={uid:{type:`UID`,config:{label:`UID`}},...s.Main});let c={id:a,label:n,repeatable:!i,status:!0,format:r,json:s},l=await o.createCustomType(c);await o.generateTypes(),console.info(`Created type "${n}" (id: "${a}", format: "${r}")`);for(let e of l)console.info(e);console.info(`Run \`prismic field add <type> --to-type ${a}\` to add fields.`),console.info(`Run \`prismic type view ${a}\` to view the type.`)}),ga=F({name:`prismic type edit`,description:`Edit a content type.`,positionals:{id:{description:`ID of the content type`,required:!0}},options:{name:{type:`string`,short:`n`,description:`New name for the type`},format:{type:`string`,short:`f`,description:`Type format: "custom" or "page"`}}},async({positionals:e,values:t})=>{let[n]=e;if(`format`in t&&t.format!==`custom`&&t.format!==`page`)throw new C(`Invalid format: "${t.format}". Use "custom" or "page".`);let r=await M(),{model:i}=await r.getCustomType(n);`name`in t&&(i.label=t.name),`format`in t&&(i.format=t.format),await r.updateCustomType(i),await r.generateTypes(),console.info(`Type updated: "${i.label}" (id: ${i.id})`)}),_a=F({name:`prismic type edit-tab`,description:`Edit a tab of a content type.`,positionals:{name:{description:`Current name of the tab`,required:!0}},options:{"from-type":{type:`string`,required:!0,description:`ID of the content type`},name:{type:`string`,short:`n`,description:`New name for the tab`},"with-slice-zone":{type:`boolean`,description:`Add a slice zone to the tab`},"without-slice-zone":{type:`boolean`,description:`Remove the slice zone from the tab`}}},async({positionals:e,values:t})=>{let[n]=e,{"from-type":r}=t,i=await M(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new C(`Tab "${n}" not found in "${r}".`);if(`with-slice-zone`in t&&`without-slice-zone`in t)throw new C(`Cannot use --with-slice-zone and --without-slice-zone together.`);if(`with-slice-zone`in t){let e=a.json[n];if(Object.values(e).some(e=>e.type===`Slices`))throw new C(`Tab "${n}" already has a slice zone.`);e.slices={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}}}if(`without-slice-zone`in t){let e=a.json[n],t=Object.entries(e).find(([,e])=>e.type===`Slices`);if(!t)throw new C(`Tab "${n}" does not have a slice zone.`);let[r,i]=t,o=i.type===`Slices`?i.config?.choices??{}:{};if(Object.keys(o).length>0)throw new C(`Cannot remove slice zone from "${n}": disconnect all slices first.`);delete e[r]}if(`name`in t){if(t.name in a.json)throw new C(`Tab "${t.name}" already exists in "${r}".`);let e={};for(let[r,i]of Object.entries(a.json))e[r===n?t.name:r]=i;a.json=e}await i.updateCustomType(a),await i.generateTypes(),console.info(`Tab updated: "${n}" in "${r}"`)}),va=F({name:`prismic type list`,description:`List all content types.`,options:{json:{type:`boolean`,description:`Output as JSON`}}},async({values:e})=>{let{json:t}=e,n=await(await M()).getCustomTypes();if(t){console.info(U(n.map(e=>e.model)));return}if(n.length===0){console.info(`No types found.`);return}let i=n.map(({model:e})=>[e.label||`(no name)`,e.id,e.format??``]);console.info(r(i,{headers:[`NAME`,`ID`,`FORMAT`]}))}),ya=F({name:`prismic type remove`,description:`Remove a content type.`,positionals:{id:{description:`ID of the content type`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await M();await n.deleteCustomType(t),await n.generateTypes(),console.info(`Type removed: ${t}`)}),ba=F({name:`prismic type remove-tab`,description:`Remove a tab from a content type.`,positionals:{name:{description:`Name of the tab`,required:!0}},options:{from:{type:`string`,required:!0,description:`ID of the content type`}}},async({positionals:e,values:t})=>{let[n]=e,{from:r}=t,i=await M(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new C(`Tab "${n}" not found in "${r}".`);if(Object.keys(a.json).length<=1)throw new C(`Cannot remove the last tab from "${r}".`);delete a.json[n],await i.updateCustomType(a),await i.generateTypes(),console.info(`Removed tab "${n}" from "${r}"`)}),xa=F({name:`prismic type view`,description:`View details of a content type.`,positionals:{id:{description:`ID of the content type`,required:!0}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t,{model:i}=await(await M()).getCustomType(n);if(r){console.info(U(i));return}let a=(await c()).routes?.find(e=>e.type===i.id);console.info(`ID: ${i.id}`),console.info(`Name: ${i.label||`(no name)`}`),console.info(`Format: ${i.format??`custom`}`),console.info(`Repeatable: ${i.repeatable}`),console.info(`Route: ${a?.path??`none`}`);for(let[e,t]of Object.entries(i.json)){console.info(``),console.info(`${e}:`),console.info($n(t));for(let[e,n]of Object.entries(t)){if(n.type!==`Slices`)continue;let t=Object.entries(n.config?.choices??{}).map(([e,t])=>t.type===`SharedSlice`?e:`${e} *`);console.info(`\n ${e} slices: ${t.join(`, `)||`(none)`}`)}}b([i]).length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),Sa=S({name:`prismic type`,description:`
|
|
491
491
|
Manage content types.
|
|
492
492
|
|
|
493
493
|
Run \`prismic docs view content-modeling\` for details.
|
|
494
|
-
`,commands:{create:{handler:
|
|
494
|
+
`,commands:{create:{handler:ha,description:`Create a new content type`},edit:{handler:ga,description:`Edit a content type`},remove:{handler:ya,description:`Remove a content type`},list:{handler:va,description:`List content types`},view:{handler:xa,description:`View a content type`},"add-tab":{handler:ma,description:`Add a tab to a content type`},"edit-tab":{handler:_a,description:`Edit a tab of a content type`},"remove-tab":{handler:ba,description:`Remove a tab from a content type`}}}),Ca=F({name:`prismic webhook create`,description:`
|
|
495
495
|
Create a new webhook in a Prismic repository.
|
|
496
496
|
|
|
497
497
|
By default, this command reads the repository from prismic.config.json at the
|
|
@@ -514,27 +514,27 @@ Watch stopped. Goodbye!`),Me(`sync`,{watch:!0}),process.exit(0)}),console.info(`
|
|
|
514
514
|
|
|
515
515
|
Create a named webhook with a secret:
|
|
516
516
|
prismic webhook create https://example.com/webhook --name "Deploy" --secret my-secret
|
|
517
|
-
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
517
|
+
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A(),name:a,secret:o,trigger:s=[]}=t;for(let e of s)if(!k.includes(e))throw new C(`Invalid trigger: ${e}\nValid triggers: ${k.join(`, `)}`);let c=await D(),l=!(s.length>0);await Le({url:n,name:a??null,secret:o??null,documentsPublished:s.includes(`documentsPublished`)||l,documentsUnpublished:s.includes(`documentsUnpublished`)||l,releasesCreated:s.includes(`releasesCreated`)||l,releasesUpdated:s.includes(`releasesUpdated`)||l,tagsCreated:s.includes(`tagsCreated`)||l,tagsDeleted:s.includes(`tagsDeleted`)||l},{repo:i,getToken:g,host:c,onUnauthorized:P}),console.info(`Webhook created: ${n}`),console.info(`Run \`prismic webhook set-triggers ${n}\` to configure triggers.`)}),wa=F({name:`prismic webhook disable`,description:`
|
|
518
518
|
Disable a webhook in a Prismic repository.
|
|
519
519
|
|
|
520
520
|
By default, this command reads the repository from prismic.config.json at the
|
|
521
521
|
project root.
|
|
522
|
-
`,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
522
|
+
`,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A()}=t,a=await D(),o=(await x({repo:i,getToken:g,host:a,onUnauthorized:P})).find(e=>e.config.url===n);if(!o)throw new C(`Webhook not found: ${n}`);if(!o.config.active){console.info(`Webhook already disabled: ${n}`);return}let s=o.config._id,c=structuredClone(o.config);c.active=!1,await y(s,c,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Webhook disabled: ${n}`)}),Ta=F({name:`prismic webhook enable`,description:`
|
|
523
523
|
Enable a webhook in a Prismic repository.
|
|
524
524
|
|
|
525
525
|
By default, this command reads the repository from prismic.config.json at the
|
|
526
526
|
project root.
|
|
527
|
-
`,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
527
|
+
`,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A()}=t,a=await D(),o=(await x({repo:i,getToken:g,host:a,onUnauthorized:P})).find(e=>e.config.url===n);if(!o)throw new C(`Webhook not found: ${n}`);if(o.config.active){console.info(`Webhook already enabled: ${n}`);return}let s=o.config._id,c=structuredClone(o.config);c.active=!0,await y(s,c,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Webhook enabled: ${n}`)}),Ea=F({name:`prismic webhook list`,description:`
|
|
528
528
|
List all webhooks in a Prismic repository.
|
|
529
529
|
|
|
530
530
|
By default, this command reads the repository from prismic.config.json at the
|
|
531
531
|
project root.
|
|
532
|
-
`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await
|
|
532
|
+
`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({values:e})=>{let{env:t,repo:n=t??await A(),json:i}=e,a=await D(),o=await x({repo:n,getToken:g,host:a,onUnauthorized:P});if(i){console.info(U(o.map(e=>e.config)));return}if(o.length===0){console.info(`No webhooks configured.`);return}let s=o.map(e=>{let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;return[`${e.config.url}${n}`,`[${t}]`]});console.info(r(s,{headers:[`URL`,`STATUS`]}))}),Da=F({name:`prismic webhook remove`,description:`
|
|
533
533
|
Delete a webhook from a Prismic repository.
|
|
534
534
|
|
|
535
535
|
By default, this command reads the repository from prismic.config.json at the
|
|
536
536
|
project root.
|
|
537
|
-
`,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
537
|
+
`,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A()}=t,a=await D(),o=(await x({repo:i,getToken:g,host:a,onUnauthorized:P})).find(e=>e.config.url===n);if(!o)throw new C(`Webhook not found: ${n}`);let s=o.config._id;await wt(s,{repo:i,getToken:g,host:a,onUnauthorized:P}),console.info(`Webhook removed: ${n}`)}),Oa=F({name:`prismic webhook set-triggers`,description:`
|
|
538
538
|
Update which events trigger a webhook.
|
|
539
539
|
|
|
540
540
|
By default, this command reads the repository from prismic.config.json at the
|
|
@@ -546,16 +546,16 @@ Watch stopped. Goodbye!`),Me(`sync`,{watch:!0}),process.exit(0)}),console.info(`
|
|
|
546
546
|
releasesUpdated When a release is edited or deleted
|
|
547
547
|
tagsCreated When a tag is created
|
|
548
548
|
tagsDeleted When a tag is deleted
|
|
549
|
-
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
549
|
+
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A(),trigger:a=[]}=t;for(let e of a)if(!k.includes(e))throw new C(`Invalid trigger: ${e}\nValid triggers: ${k.join(`, `)}`);let o=await D(),s=(await x({repo:i,getToken:g,host:o,onUnauthorized:P})).find(e=>e.config.url===n);if(!s)throw new C(`Webhook not found: ${n}`);let c=s.config._id;await y(c,{...s.config,documentsPublished:a.includes(`documentsPublished`),documentsUnpublished:a.includes(`documentsUnpublished`),releasesCreated:a.includes(`releasesCreated`),releasesUpdated:a.includes(`releasesUpdated`),tagsCreated:a.includes(`tagsCreated`),tagsDeleted:a.includes(`tagsDeleted`)},{repo:i,getToken:g,host:o,onUnauthorized:P}),console.info(`Webhook triggers updated: ${a.join(`, `)}`)}),ka=F({name:`prismic webhook view`,description:`
|
|
550
550
|
View details of a webhook in a Prismic repository.
|
|
551
551
|
|
|
552
552
|
By default, this command reads the repository from prismic.config.json at the
|
|
553
553
|
project root.
|
|
554
|
-
`,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
554
|
+
`,positionals:{url:{description:`Webhook URL`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await A()}=t,a=await D(),o=(await x({repo:i,getToken:g,host:a,onUnauthorized:P})).find(e=>e.config.url===n);if(!o)throw new C(`Webhook not found: ${n}`);let{config:s}=o;console.info(`URL: ${s.url}`),console.info(`Name: ${s.name||`(none)`}`),console.info(`Status: ${s.active?`enabled`:`disabled`}`),console.info(`Secret: ${s.secret?`(set)`:`(none)`}`);let c=[];for(let e of k)s[e]&&c.push(e);if(console.info(`Triggers: ${c.length>0?c.join(`, `):`(none)`}`),Object.keys(s.headers).length>0){console.info(`Headers:`);for(let[e,t]of Object.entries(s.headers))console.info(` ${e}: ${t}`)}else console.info(`Headers: (none)`)}),Aa=S({name:`prismic webhook`,description:`
|
|
555
555
|
Manage webhooks in a Prismic repository.
|
|
556
556
|
|
|
557
557
|
Run \`prismic docs view webhooks\` for details.
|
|
558
|
-
`,commands:{list:{handler:
|
|
558
|
+
`,commands:{list:{handler:Ea,description:`List all webhooks`},create:{handler:Ca,description:`Create a new webhook`},view:{handler:ka,description:`View webhook details`},remove:{handler:Da,description:`Delete a webhook`},enable:{handler:Ta,description:`Enable a webhook`},disable:{handler:wa,description:`Disable a webhook`},"set-triggers":{handler:Oa,description:`Update webhook triggers`}}}),ja=F({name:`prismic whoami`,description:`Show the currently logged in user.`},async()=>{let e=await D(),t=await _(await g(),{host:e});t.type===`Machine2Machine`?console.info(`${t.appName} (Write API token for ${t.domain})`):console.info(t.email)}),Ma=S({name:`prismic`,description:`Prismic CLI for managing repositories and configurations.`,sections:{DOCUMENTATION:"\n Run `prismic docs list` to browse available documentation topics.\n Run `prismic docs view <path>` to read a topic.\n ",MODELING:`
|
|
559
559
|
Pages are page types, built from slices and fields. Content that is
|
|
560
560
|
not a page is a custom type, such as an author or a navigation menu.
|
|
561
561
|
A page references a custom type with a content relationship field,
|
|
@@ -576,4 +576,4 @@ Watch stopped. Goodbye!`),Me(`sync`,{watch:!0}),process.exit(0)}),console.info(`
|
|
|
576
576
|
A repository can hold multiple preview URLs but only one simulator URL,
|
|
577
577
|
which the Page Builder loads live slice previews from.
|
|
578
578
|
Run \`prismic docs view previews\` for details.
|
|
579
|
-
`},commands:{init:{handler:
|
|
579
|
+
`},commands:{init:{handler:oi,description:`Initialize a Prismic project`},docs:{handler:zn,description:`Browse Prismic documentation`},gen:{handler:qr,description:`Generate files from local models`},pull:{handler:Ti,description:`Pull types and slices from Prismic`},push:{handler:Ei,description:`Push types and slices to Prismic`},sync:{handler:ra,description:`Sync types and slices from Prismic`},dev:{handler:dn,description:`Edit local models visually in the Type Builder`,hidden:!0},status:{handler:ta,description:`Show local vs remote model differences`},env:{handler:Kn,description:`Manage the active environment`},locale:{handler:mi,description:`Manage locales`},repo:{handler:Li,description:`Manage repositories`},type:{handler:Sa,description:`Manage content types`},field:{handler:Hr,description:`Manage fields`},slice:{handler:ea,description:`Manage slices`},preview:{handler:Si,description:`Manage preview and simulator URLs`},token:{handler:pa,description:`Manage API tokens`},webhook:{handler:Aa,description:`Manage webhooks`},login:{handler:hi,description:`Log in to Prismic`},logout:{handler:gi,description:`Log out of Prismic`},whoami:{handler:ja,description:`Show the currently logged in user`},"task-id":{handler:ca,description:`Print a task ID for --task-id`,hidden:mt()===void 0}}});const Na=[C,f,u,qe,oe,i,Ye,Ke,De,We,it,tt,Hn,st,$e,Ie,Gt,Ve,Pt,kt,B,G,Dt,Ut,ft,nt],Pa=[Dt,Ut];await Fa();async function Fa(){await Yt({npmPackageName:t,statePath:gt}),ge().catch(()=>{});let{positionals:[r=``],values:{version:i,help:a,repo:o=await E().catch(()=>void 0),"analytics-intent":s,"analytics-task-id":c,"user-intent":l=s,"task-id":u=c}}=Zt({options:{version:{type:`boolean`,short:`v`},help:{type:`boolean`,short:`h`},repo:{type:`string`,short:`r`},"user-intent":{type:`string`},"task-id":{type:`string`},"analytics-intent":{type:`string`},"analytics-task-id":{type:`string`}},allowPositionals:!0,strict:!1});if(i){console.info(e);return}let d=typeof o==`string`?o:void 0,f=typeof l==`string`?l:void 0,p=typeof u==`string`?u:void 0,m=!a&&r!==``&&r!==`task-id`&&mt()!==void 0?La(p,f):void 0;if(m){let e=p&&sa(p)?p:oa();console.error(`error: ${m}\nrerun with --task-id ${e} --user-intent "<what the user asked for>", and pass both on every command until the user asks for something else`),process.exitCode=1;return}if(!a){let e=await D(),t=j.PRISMIC_TOKEN?{}:await Oe(),r=!!(j.PRISMIC_TOKEN||t.expiresAt),i=j.PRISMIC_TELEMETRY_ENABLED??await n(),a=j.PRISMIC_SENTRY_ENABLED??(i&&j.PROD);if(a&&await Ia({host:e,repo:d,userIntent:f,taskId:p}),i&&await ue({host:e,loggedIn:r,repo:d,userIntent:f,taskId:p,store:t.store,storeReason:t.storeReason}),r&&(a||i)){let t=we();t?Zr({id:t}):le({getToken:g,host:e}).then(e=>{dt(e),Zr({id:e.shortId})}).catch(()=>{})}}let h=!a&&r&&r!==`sync`;try{h&&rt(r),await Ma(),h&&ht()}catch(e){process.exitCode=1;let t=await ln(e).catch(()=>void 0);if(h&&ht({error:t??e}),Na.some(t=>e instanceof t))console.error(t),Ra(e)&&await Qr(e);else throw console.error(`The CLI reached a bug. Report this if it keeps happening: https://github.com/prismicio/cli/issues`),await Qr(e),e}}async function Ia(n){let{host:r,repo:i,userIntent:a,taskId:o}=n;Jr({dsn:j.PRISMIC_SENTRY_DSN,appName:t,appVersion:e,environment:j.PRISMIC_SENTRY_ENVIRONMENT}),Yr(`host`,r),i&&(Yr(`repository`,i),Xr(`Repository Data`,{name:i})),o&&Yr(`taskId`,o),a&&Xr(`Agent Task`,{userIntent:a,taskId:o});try{Yr(`framework`,(await M()).id)}catch{}}function La(e,t){if(!e)return`missing --task-id`;if(!sa(e))return"--task-id must come from `prismic task-id`";if(!t)return`missing --user-intent`}function Ra(e){return e instanceof ft?e.reason===`misconfigured`:Pa.some(t=>e instanceof t)}export{};
|