prismic 1.23.0 → 1.24.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-CuXozoyY.mjs +189 -0
- package/dist/{auth-NkX7Docj.mjs → auth-CsokWsVo.mjs} +2 -2
- package/dist/index.mjs +94 -94
- package/dist/{nextjs-TJI3bKFA.mjs → nextjs-D65xFGap.mjs} +51 -51
- package/dist/{nuxt-DfWyc1bJ.mjs → nuxt-YzpEi3A5.mjs} +11 -11
- package/dist/package-DCbOjRWH.mjs +1 -0
- package/dist/packageJson-B1_pkZr8.mjs +2 -0
- package/dist/request-Dx4vx1nN.mjs +30 -0
- package/dist/{segment-yGieXuDf.mjs → segment-DkMwCXor.mjs} +1 -1
- package/dist/subprocesses/refreshToken.mjs +1 -1
- package/dist/subprocesses/sendSegmentEvents.mjs +1 -1
- package/dist/subprocesses/updateVersionState.mjs +1 -1
- package/dist/sveltekit-7mpC1weE.mjs +273 -0
- package/dist/sveltekit-CpIdkani.mjs +1 -0
- package/dist/sveltekit2-C9cZPBvU.mjs +50 -0
- package/dist/{update-notifier-ChP_LYxw.mjs → update-notifier-d8fLG6jz.mjs} +1 -1
- package/package.json +7 -7
- package/dist/adapters-Bt9QKcJb.mjs +0 -191
- package/dist/package-Dyw1b366.mjs +0 -1
- package/dist/packageJson-Bxht6H4y.mjs +0 -2
- package/dist/request-DJTl_0US.mjs +0 -30
- package/dist/sveltekit-CC1sBn9O.mjs +0 -302
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as
|
|
2
|
+
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as ee,Y as te,Z as ne,a as re,at as ie,b as ae,c as w,ct as T,dt as oe,et as se,f as ce,ft as le,g as ue,h as de,i as fe,it as pe,j as me,k as he,l as E,lt as ge,m as _e,n as ve,nt as D,o as ye,ot as be,p as xe,q as Se,r as Ce,rt as O,tt as k,ut as A,v as we,w as Te,x as j,y as Ee,z as De}from"./adapters-CuXozoyY.mjs";import{n as Oe,t as ke}from"./package-DCbOjRWH.mjs";import{A as Ae,E as je,F as Me,I as M,M as Ne,N,O as Pe,P,R as Fe,T as F,U as Ie,W as Le,_ as Re,a as I,b as L,c as R,f as ze,g as Be,i as Ve,j as He,k as Ue,n as z,o as We,p as Ge,r as Ke,s as B,t as qe,v as Je,w as V,y as H,z as Ye}from"./request-Dx4vx1nN.mjs";import{_ as Xe,c as Ze,d as Qe,f as $e,g as et,h as tt,i as nt,l as rt,m as it,n as at,o as ot,p as st,r as U,s as ct,t as lt,u as ut,y as W}from"./auth-CsokWsVo.mjs";import{c as dt,d as ft,f as pt,i as mt,l as G,o as ht,t as gt,u as _t}from"./packageJson-B1_pkZr8.mjs";import{t as vt}from"./update-notifier-d8fLG6jz.mjs";import{isDeepStrictEqual as yt,parseArgs as bt}from"node:util";import{realpath as xt,rm as St}from"node:fs/promises";import{fileURLToPath as Ct,pathToFileURL as wt}from"node:url";import{createHash as Tt,randomBytes as Et}from"node:crypto";import{exec as Dt}from"node:child_process";import{setTimeout as Ot}from"node:timers/promises";const kt=N({error:Pe(`invalid_auth_context`)});function At(e){return e instanceof I&&Le(kt,e.body).success}async function jt(e){if(e instanceof I||e instanceof z){let{token:t}=await U();return t?W.PRISMIC_TOKEN?At(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 I?"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 qe||e instanceof We){let t=new URL(e.response.url);t.search=``;let n=e.message?`${e.message}\n\n`:``;return be`
|
|
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 be(e.message)}function Mt(e){let t=process.platform===`darwin`?`open`:process.platform===`win32`?`start ""`:`xdg-open`;Dt(`${t} "${e.toString()}"`)}const Nt=W.PRISMIC_SYNC_POLL_MS??5e3;var Pt=D({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{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J 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
|
|
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})=>{ie(e,[`continue`,`new`]);let t=await E(),{repo:n=await t.getEnvironment()??await y(),continue:r,new:i,"no-browser":a}=e,{token:o,host:s}=await U(),c=await Ft(),l=await Bt(t,c,{token:o,host:s,continueSession:r,newSession:i}),u;l?(u={...l,pid:process.pid},console.info(`Continuing your session for ${n}...`)):(console.info(`Preparing your session for ${n}...`),u=await Rt({repo:n,token:o,host:s}));let d={repo:n,token:o,host:s,releaseId:u.releaseId},f=(e=!0)=>Wt(t,d,u,c,{push:e,onPull:e=>Xt(`↓ Pulled ${Yt(e)}`),onPush:e=>Xt(`↑ Pushed ${Yt(e)}`),onDelete:e=>Xt(`− Deleted ${Yt(e)}`)}),p=async()=>{try{return await f(!1),await zt(d,c),!0}catch(e){return console.error(`Could not end the session: ${await jt(e)}\nRun \`prismic dev --continue\` to continue it.`),!1}},m=Ht();try{let e=Be([...await t.getCustomTypeLibraries(),...await t.getSliceLibraries()],m.signal),i=r?await f():await Ut(t,d,u,c),o=i.customTypes.length,l=i.slices.length;console.info(`Ready. Loaded ${o} ${o===1?`type`:`types`} and ${l} ${l===1?`slice`:`slices`} from your project.\n`);let p=new URL(`builder/types`,`https://${n}.${s}/`);p.searchParams.set(`r`,d.releaseId),console.info(`Type Builder: ${p}`),a?console.info(`Open the URL above to start editing. Changes sync both ways while this runs.`):(Mt(p),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&&Xt(`! ${e}`,console.error),h=e};await Gt(f,e,m.signal,{onSync:()=>{h=void 0},onRecover:()=>Xt(`Back in sync.`),onUnreachable:()=>g(`Cannot reach Prismic. Retrying...`),onError:async e=>g(await jt(Qt(e))??`Unknown error`)})}catch(e){throw m.abort(),await Kt(e,p)}console.info(`
|
|
20
|
+
Ending the session...`),await p()&&console.info(`Session ended.`)});async function Ft(){let e=Tt(`sha256`).update(Ct(await j())).digest(`hex`);return new URL(`dev/${e}.json`,et)}async function It(e){return ze(e,{schema:tn}).catch(()=>void 0)}async function Lt(e,t){await Re(e,R(t))}async function Rt({repo:e,token:t,host:n}){return{repo:e,releaseId:await Se({label:`prismic dev`,hidden:!0},{repo:e,token:t,host:n}).catch(e=>{throw Qt(e)}),pid:process.pid,synced:{}}}async function zt({releaseId:e,...t},n){await u(e,t),await St(n,{force:!0})}async function Bt(e,t,n){let{token:r,host:i,continueSession:a,newSession:o}=n,s=await It(t);if(s&&Zt(s.pid))throw new k(`A session is already running for this project. Press Ctrl+C in its terminal to end it, or run \`kill ${s.pid}\`.`);if(a){if(!s)throw new k("There is no session to continue. Run `prismic dev` to start a new one.");return s}if(s){if(!o&&await Vt(e,{repo:s.repo,token:r,host:i,releaseId:s.releaseId},s.synced))throw new k("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 u(s.releaseId,{repo:s.repo,token:r,host:i}).catch(()=>{})}}async function Vt(e,t,n){let r=await f(t).catch(e=>{if(!(e instanceof Ke))throw Qt(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 Ht(){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 Ut(e,t,n,r){let i=await e.getModels(),a=await f(t);return await S(o(i,a),t),n.synced=K(i),await Lt(r,n),i}async function Wt(e,t,n,r,i){let{push:a,onPull:s,onPush:c,onDelete:l}=i,[u,d]=await Promise.all([e.getModels(),f(t)]),p=K(u),m=K(d),h=qt(p,m,n.synced),g=u;if(h.pull.length>0){await e.writeModels(o(Jt(d,h.pull),Jt(u,h.pull))),await e.generateTypes(),g=await e.getModels();let t=K(g);for(let e of h.pull)e in t?n.synced[e]=t[e]:delete n.synced[e];await Lt(r,n)}let _=h.pull.filter(e=>e in m);_.length>0&&s(_);let v=a?h.push:[];await S(o(Jt(u,v),Jt(d,v)),t);let y=v.filter(e=>e in p);y.length>0&&c(y);let b=[...h.pull.filter(e=>!(e in m)),...v.filter(e=>!(e in p))];return b.length>0&&l(b),n.synced=K(g),await Lt(r,n),g}async function Gt(e,t,n,r){let{onSync:i,onRecover:a,onUnreachable:o,onError:s}=r,c=0;for(;;){if(await t(Nt),n.aborted)return;try{await e(),c>=6&&a(),c=0,i()}catch(e){if(e instanceof I||e instanceof z||e instanceof Ke)throw e;let t=e instanceof Ve?e.status>=500||e.status===429:e instanceof TypeError&&e.message===`fetch failed`;if(t&&++c<6)continue;t?o():await s(e)}}}async function Kt(e,t){return e instanceof I?new k("Your login expired. Run `prismic login`, then `prismic dev --continue` to continue the session."):e instanceof Ke?new k("The session ended. Run `prismic dev` to start a new one."):(e instanceof z||await t(),Qt(e))}function qt(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=>Tt(`sha256`).update(JSON.stringify(e)).digest(`hex`);return Object.fromEntries([...e.customTypes.map(e=>[`type:${e.id}`,t(m(e))]),...e.slices.map(e=>[`slice:${e.id}`,t(g(e))])])}function Jt(e,t){return{customTypes:e.customTypes.filter(e=>t.includes(`type:${e.id}`)),slices:e.slices.filter(e=>t.includes(`slice:${e.id}`))}}function Yt(e){return e.map(e=>e.slice(e.indexOf(`:`)+1)).join(`, `)}function Xt(e,t=console.info){t(`${(/* @__PURE__ */ new Date()).toTimeString().slice(0,8)} ${e.replaceAll(`
|
|
21
21
|
`,`
|
|
22
|
-
`)}`)}function Zt(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function Qt(e){if(!(e instanceof Ve))return e;switch(Le(N({error:M()}),e.body).data?.error){case`missing_right`:return new
|
|
23
|
-
`)):e}const $t=V(N({id:M(),error:M()})),en=N({details:N({customTypes:$t,slices:$t})}),tn=N({repo:M(),releaseId:M(),pid:Ne(),synced:Me(M(),M())}),nn=N({path:M(),title:M(),description:P(M())}),rn=N({path:M(),title:M(),description:P(M()),anchors:V(N({slug:M(),excerpt:M()}))});async function an(e){let t=new URL(`api/index/`,cn(e.host));return B(t,{schema:V(nn),unknownErrorMessage:`Failed to fetch documentation index`})}async function on(e,t){let n=new URL(`api/index/${e}`,cn(t.host));return B(n,{schema:rn,notFoundMessage:`Documentation page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation index`})}async function sn(e,t){let n=new URL(e,cn(t.host));return B(n,{headers:{Accept:`text/markdown`,...t.headers},schema:M(),notFoundMessage:`Page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation page`})}function cn(e=`prismic.io`){return new URL(`https://${e}/docs/`)}var ln=
|
|
22
|
+
`)}`)}function Zt(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function Qt(e){if(!(e instanceof Ve))return e;switch(Le(N({error:M()}),e.body).data?.error){case`missing_right`:return new k(`To edit models in the Type Builder, you need an Administrator, Owner, or Super User role on this repository.`);case`LEGACY_REPOSITORY`:return new k(`Local mode does not support this repository yet.`)}let t=Le(en,e.body).data?.details;return t?new k([...t.customTypes,...t.slices].map(({id:e,error:t})=>`Could not push ${e}: ${t}`).join(`
|
|
23
|
+
`)):e}const $t=V(N({id:M(),error:M()})),en=N({details:N({customTypes:$t,slices:$t})}),tn=N({repo:M(),releaseId:M(),pid:Ne(),synced:Me(M(),M())}),nn=N({path:M(),title:M(),description:P(M())}),rn=N({path:M(),title:M(),description:P(M()),anchors:V(N({slug:M(),excerpt:M()}))});async function an(e){let t=new URL(`api/index/`,cn(e.host));return B(t,{schema:V(nn),unknownErrorMessage:`Failed to fetch documentation index`})}async function on(e,t){let n=new URL(`api/index/${e}`,cn(t.host));return B(n,{schema:rn,notFoundMessage:`Documentation page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation index`})}async function sn(e,t){let n=new URL(e,cn(t.host));return B(n,{headers:{Accept:`text/markdown`,...t.headers},schema:M(),notFoundMessage:`Page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation page`})}function cn(e=`prismic.io`){return new URL(`https://${e}/docs/`)}var ln=D({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:r}=t;if(n){let e=await on(n,{host:W.PRISMIC_DOCS_HOST});if(r){console.info(R(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(
|
|
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:r}=t;if(n){let e=await on(n,{host:W.PRISMIC_DOCS_HOST});if(r){console.info(R(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(T(t,{headers:[`PATH`,`EXCERPT`]}))}else{let e=await an({host:W.PRISMIC_DOCS_HOST});if(e.sort((e,t)=>e.path.localeCompare(t.path)),r){console.info(R(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(T(t,{headers:[`PATH`,`TITLE`,`DESCRIPTION`]}))}});const un=/[\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,dn=Object.hasOwnProperty;var fn=class{constructor(){this.occurrences,this.reset()}slug(e,t){let n=this,r=pn(e,t===!0),i=r;for(;dn.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 pn(e,t){return typeof e==`string`?(t||(e=e.toLowerCase()),e.replace(un,``).replace(/ /g,`-`)):``}var mn=D({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 sn(a,{host:W.PRISMIC_DOCS_HOST,headers:ct()});if(o){let e=hn(s,o);if(!e)throw new
|
|
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 sn(a,{host:W.PRISMIC_DOCS_HOST,headers:ct()});if(o){let e=hn(s,o);if(!e)throw new k(`Anchor not found: #${o}`);s=e}console.info(r?R({path:a,anchor:o,content:s}):s)});function hn(e,t){let n=e.split(`
|
|
32
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 gn=
|
|
34
|
-
`);super(
|
|
33
|
+
`).trim()}var gn=O({name:`prismic docs`,description:`Browse Prismic documentation.`,commands:{list:{handler:ln,description:`List available documentation pages`},view:{handler:mn,description:`View a documentation page`}}}),_n=D({name:`prismic env active`,description:`Print the active environment.`},async()=>{let e=await y(),t=await(await E()).getEnvironment();console.info(t??e)});async function vn(e){let{repo:t,token:n,host:r}=e,[i,a]=await Promise.all([tt(n,{host:r}),ee({repo:t,token:n,host:r})]);return i.type===`Machine2Machine`?a.filter(e=>e.domain===i.domain):a.filter(e=>(e.kind===`prod`||e.kind===`stage`)&&e.users.some(e=>e.id===i.shortId))}var yn=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(be`
|
|
35
35
|
Environment "${e}" not found on repository "${n}".
|
|
36
36
|
|
|
37
37
|
Available environments:
|
|
38
38
|
${r}
|
|
39
|
-
`)}}},bn=
|
|
39
|
+
`)}}},bn=D({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 y(),{json:n,repo:r=t}=e,{token:i,host:a}=await U(),o=await vn({repo:r,token:i,host:a}),s;if(r===t&&(s=await(await E()).getEnvironment()??t),n){let e=o.map(e=>({domain:e.domain,kind:e.kind,active:e.domain===s}));console.info(R(e));return}let c=o.map(e=>[e.domain,e.kind,e.domain===s?`*`:``]);console.info(T(c,{headers:[`DOMAIN`,`KIND`,`ACTIVE`]}))}),xn=D({name:`prismic env set`,description:`Set the active environment.`,positionals:{environment:{description:`Environment domain`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await y(),{token:r,host:i}=await U(),a=await vn({repo:n,token:r,host:i});if(!a.some(e=>e.domain===t))throw new yn(t,a,n);let o=await E();t===n?(await o.unsetEnvironment(),console.info(`Reset to the production environment "${n}".`)):(await o.setEnvironment(t),console.info(`Set the active environment to "${t}".`));let s=await o.getSetupInstructions();s&&console.info(`\n${s}`)}),Sn=D({name:`prismic env unset`,description:`Reset the active environment to the production environment.`},async()=>{let e=await y();await(await E()).unsetEnvironment(),console.info(`Reset to the production environment "${e}".`)}),Cn=O({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:xn,description:`Set the active environment`},unset:{handler:Sn,description:`Reset to the production environment`},active:{handler:_n,description:`Print the active environment`},list:{handler:bn,description:`List environments`}}});const q={"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`}},wn={"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 Tn(e,t,r){let{variation:
|
|
43
|
+
`,commands:{set:{handler:xn,description:`Set the active environment`},unset:{handler:Sn,description:`Reset to the production environment`},active:{handler:_n,description:`Print the active environment`},list:{handler:bn,description:`List environments`}}});const q={"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`}},wn={"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 Tn(e,t,r){let{variation:a=`default`}=r,{key:o,value:s}=pe(r,[`from-slice`,`from-type`]),c=await E(),l,u,d;if(o===`from-slice`){let{model:r}=await c.getSlice(s);l=n(e,r,a),u=n(t,r,a),d=async()=>{await c.updateSlice(r),await c.generateTypes()}}else{let{model:n}=await c.getCustomType(s);l=De(e,n),u=De(t,n),d=async()=>{await c.updateCustomType(n),await c.generateTypes()}}if(!(l.fieldId in l.fields))throw new i(e);if(!(u.fieldId in u.fields))throw new i(t);return{source:l,anchor:u,save:d}}async function J(e,t){let{tab:n=`Main`,variation:r=`default`}=t,{key:i,value:o}=pe(t,[`to-slice`,`to-type`]),s=i===`to-slice`?await On(e,o,r):await kn(e,o,n);if(s.fieldId in s.fields)throw new a(e);return s}async function En(e,t){let{variation:n=`default`}=t,{key:r,value:a}=pe(t,[`from-slice`,`from-type`]),o=r===`from-slice`?await On(e,a,n):await kn(e,a),s=o.fields[o.fieldId];if(!s)throw new i(e);return{...o,field:s}}async function Dn(e,t){let n=await(await E()).getCustomTypes();return v(e,t,n.map(({model:e})=>e))}async function On(e,t,r){let i=await E(),{model:a}=await i.getSlice(t);return{...n(e,a,r),save:async()=>{await i.updateSlice(a),await i.generateTypes()}}}async function kn(e,t,n){let r=await E(),{model:i}=await r.getCustomType(t);return{...De(e,i,n),save:async()=>{await r.updateCustomType(i),await r.generateTypes()}}}function Y(e,t){if(e===void 0)return;let n=Number(e);if(Number.isNaN(n))throw new k(`--${t} must be a valid number, got "${e}"`);return n}function An(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 T(n)}const jn={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:{...q,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 Mn=
|
|
47
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,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 Mn=D(jn,async({positionals:e,values:t})=>{let[n]=e;ie(t,[`default-true`,`default-false`]);let{label:r,"true-label":i,"false-label":a}=t,{fields:o,fieldId:s,save:c}=await J(n,t),l={type:`Boolean`,config:{label:r??A(s),default_value:!t[`default-false`]&&t[`default-true`],placeholder_true:i,placeholder_false:a}};p(o,s,l),await c(),console.info(`Field added: ${n}`)});const Nn={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:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Pn=
|
|
51
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Pn=D(Nn,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await J(n,t),c={type:`Color`,config:{label:r??A(o),placeholder:i}};p(a,o,c),await s(),console.info(`Field added: ${n}`)});const Fn={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 m()&&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:{...q,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 In=
|
|
82
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...q,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 In=D(Fn,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 k(`--field requires exactly one --custom-type.`);let{fields:s,fieldId:c,save:l}=await J(n,t),u=a;if(o&&a){let e=await Dn(o,a[0]);u=[{id:a[0],fields:e}]}let d={type:`Link`,config:{label:r??A(c),select:`document`,tags:i,customtypes:u}};p(s,c,d),await l(),console.info(`Field added: ${n}`)});const Ln={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:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var Rn=
|
|
86
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var Rn=D(Ln,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,default:a}=t,{fields:o,fieldId:s,save:c}=await J(n,t),l={type:`Date`,config:{label:r??A(s),placeholder:i,default:a}};p(o,s,l),await c(),console.info(`Field added: ${n}`)});const zn={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:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Bn=
|
|
90
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Bn=D(zn,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await J(n,t),c={type:`Embed`,config:{label:r??A(o),placeholder:i}};p(a,o,c),await s(),console.info(`Field added: ${n}`)});const Vn={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:{...q,label:{type:`string`,description:`Field label`}}};var Hn=
|
|
94
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,label:{type:`string`,description:`Field label`}}};var Hn=D(Vn,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await J(n,t),s={type:`GeoPoint`,config:{label:r??A(a)}};p(i,a,s),await o(),console.info(`Field added: ${n}`)});const Un={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:{...q,label:{type:`string`,description:`Field label`}}};var Wn=
|
|
98
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,label:{type:`string`,description:`Field label`}}};var Wn=D(Un,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await J(n,t),s={type:`Group`,config:{label:r??A(a)}};p(i,a,s),await o(),console.info(`Field added: ${n}`)});const Gn={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:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Kn=
|
|
102
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Kn=D(Gn,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await J(n,t),c={type:`Image`,config:{label:r??A(o),placeholder:i}};p(a,o,c),await s(),console.info(`Field added: ${n}`)});const qn={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:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},catalog:{type:`string`,description:`Integration catalog ID`}}};var Jn=
|
|
106
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},catalog:{type:`string`,description:`Integration catalog ID`}}};var Jn=D(qn,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,catalog:a}=t,{fields:o,fieldId:s,save:c}=await J(n,t),l={type:`IntegrationFields`,config:{label:r??A(s),placeholder:i,catalog:a}};p(o,s,l),await c(),console.info(`Field added: ${n}`)});const Yn={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 m()&&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:{...q,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 Xn=
|
|
122
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...q,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 Xn=D(Yn,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 k(`--allow accepts a single link type. Prismic links allow either one type or all types.`);if(a&&!r.includes(a))throw new k(`--allow must be one of: ${r.join(`, `)}`);let d=a;if(u&&(d===`media`||d===`web`))throw new k(`--custom-type cannot be used with --allow ${d}`);let{fields:f,fieldId:m,save:h}=await J(n,t),g={type:`Link`,config:{label:i??A(m),select:d,allowTargetBlank:o,allowText:s,repeat:c,variants:l,customtypes:u}};p(f,m,g),await h(),console.info(`Field added: ${n}`)});const Zn={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:{...q,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 Qn=
|
|
126
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,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 Qn=D(Zn,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,a=Y(t.min,`min`),o=Y(t.max,`max`),s=Y(t.step,`step`),{fields:c,fieldId:l,save:u}=await J(n,t),d={type:`Number`,config:{label:r??A(l),placeholder:i,min:a,max:o,step:s}};p(c,l,d),await u(),console.info(`Field added: ${n}`)});const $n={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 m()&&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:{...q,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 er=
|
|
140
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...q,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 er=D($n,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 J(n,t),f={type:`StructuredText`,config:{label:r??A(u),placeholder:i,...o?{single:a}:{multi:a},labels:s?.split(`,`).map(e=>e.trim()).filter(Boolean),allowTargetBlank:c}};p(l,u,f),await d(),console.info(`Field added: ${n}`)});const tr={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 m()&&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:{...q,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 nr=
|
|
150
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...q,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 nr=D(tr,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 J(n,t),u={type:`Select`,config:{label:r??A(c),placeholder:i,default_value:a,options:o}};p(s,c,u),await l(),console.info(`Field added: ${n}`)});const rr={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:{...q,label:{type:`string`,description:`Field label`}}};var ir=
|
|
154
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,label:{type:`string`,description:`Field label`}}};var ir=D(rr,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await J(n,t),s={type:`Table`,config:{label:r??A(a)}};p(i,a,s),await o(),console.info(`Field added: ${n}`)});const ar={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 m()&&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:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var or=
|
|
165
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var or=D(ar,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await J(n,t),c={type:`Text`,config:{label:r??A(o),placeholder:i}};p(a,o,c),await s(),console.info(`Field added: ${n}`)});const sr={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:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var cr=
|
|
169
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...q,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var cr=D(sr,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,default:a}=t,{fields:o,fieldId:s,save:c}=await J(n,t),l={type:`Timestamp`,config:{label:r??A(s),placeholder:i,default:a}};p(o,s,l),await c(),console.info(`Field added: ${n}`)});const lr={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":q[`to-type`],tab:q.tab,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var ur=
|
|
173
|
+
`,options:{"to-type":q[`to-type`],tab:q.tab,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var ur=D(lr,async({values:e})=>{let{label:t=`UID`,placeholder:n}=e,{fields:r,fieldId:i,save:a}=await J(`uid`,e);p(r,i,{type:`UID`,config:{label:t,placeholder:n}}),await a(),console.info(`Field added: uid`)}),dr=O({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.
|
|
@@ -193,38 +193,38 @@ Ending the session...`),await m()&&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:{...wn,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 pr=
|
|
196
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...wn,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 pr=D(fr,async({positionals:e,values:t})=>{let[n]=e,{field:r,save:i}=await En(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`:ie(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=Y(t.min,`min`)),`max`in t&&(r.config.max=Y(t.max,`max`)),`step`in t&&(r.config.step=Y(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 k(`--allow accepts a single link type. Prismic links allow either one type or all types.`);else throw new k(`--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 k(`--field requires the field to be restricted to a custom type. Use --custom-type to specify one.`);if(e.length>1)throw new k(`--field requires the field to be restricted to a single custom type.`);let[n]=e,i=typeof n==`string`?n:n.id,a=await Dn(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 k(`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}`)}),mr=D({name:`prismic field remove`,description:`Remove a field from a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:wn},async({positionals:e,values:t})=>{let[n]=e,{fields:r,fieldId:i,save:a}=await En(n,t);delete r[i],await a(),console.info(`Field removed: ${n}`)});const hr={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`},...wn}};var gr=D(hr,async({positionals:e,values:t})=>{let[n]=e,{key:r,value:i}=pe(t,[`before`,`after`]);if(n===i)throw new k(`Cannot reorder "${n}" relative to itself.`);if(n.split(`.`).slice(0,-1).join(`.`)!==i.split(`.`).slice(0,-1).join(`.`))throw new k(`Cannot reorder "${n}" relative to "${i}": fields must be in the same container.`);let{source:o,anchor:s,save:c}=await Tn(n,i,t);if(o.fields!==s.fields&&o.fieldId in s.fields)throw new a(o.fieldId);let l=o.fields[o.fieldId];delete o.fields[o.fieldId];let u=Object.entries(s.fields);for(let[e]of u)delete s.fields[e];for(let[e,t]of u)r===`before`&&e===s.fieldId&&(s.fields[o.fieldId]=l),s.fields[e]=t,r===`after`&&e===s.fieldId&&(s.fields[o.fieldId]=l);await c(),console.info(`Field reordered: ${n}`)});const _r={name:`prismic field view`,description:`View details of a field in a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:{...wn,json:{type:`boolean`,description:`Output as JSON`}}};var vr=D(_r,async({positionals:e,values:t})=>{let[n]=e,{field:r,fieldId:i}=await En(n,t);if(t.json)console.info(R({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)?`${A(e)}: ${t.join(`, `)}`:`${A(e)}: ${t}`)}}}),yr=O({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:dr,description:`Add a field`},edit:{handler:pr,description:`Edit a field`},remove:{handler:mr,description:`Remove a field`},reorder:{handler:gr,description:`Reorder a field`},view:{handler:vr,description:`View details of a field`}}}),br=
|
|
200
|
+
`,commands:{add:{handler:dr,description:`Add a field`},edit:{handler:pr,description:`Edit a field`},remove:{handler:mr,description:`Remove a field`},reorder:{handler:gr,description:`Reorder a field`},view:{handler:vr,description:`View details of a field`}}}),br=D({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 E(),{model:i}=await n.getCustomType(t);if(i.format!==`page`)throw new k(`"${t}" is not a page type.`);let{routes:a=[]}=await r(),o=!ae(a,t)&&a.find(e=>e.type===t&&!e.uid);o&&console.info(`The route ${o.path} has optional or repeated params, so the page uses the default path ${ue(i)}. Move it to match the route.\n`);let s=await n.writePageFiles(i);if(s.length===0){console.info(`Generated the page for "${t}".`);return}let c=await j();for(let e of s){let t=L(c,e.path);console.info(`${t} already exists. Generated code:\n\n${e.contents}`),console.info(`Merge this into ${t}.\n`)}}),xr=D({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 E(),n=await G();await t.setupProject();for(let{name:e,from:t,to:r}of ht(n,await G()))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 dt()}catch{console.warn(`Could not install dependencies. Run \`${await mt()}\` to finish.\nThe rest of the setup is done.`)}console.info(`Generated setup files.`);let r=await t.getSetupInstructions();r&&console.info(`\n${r}`)}),Sr=D({name:`prismic gen slice-index`,description:`Generate the slice index file of each slice library.`},async()=>{let e=await E(),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.`)}),Cr=D({name:`prismic gen types`,description:`Generate TypeScript types for slices and content types.`},async()=>{let e=await(await E()).generateTypes(),t=await j(),n=L(t,e);console.info(`Generated types at ${n}`)}),wr=O({name:`prismic gen`,description:`Generate files from local Prismic models.`,commands:{page:{handler:br,description:`Generate the page files for a page type`},setup:{handler:xr,description:`Generate framework-specific Prismic setup`},"slice-index":{handler:Sr,description:`Generate the slice index file of each slice library`},types:{handler:Cr,description:`Generate TypeScript types from local models`}}});const Tr=N({id:M(),revision:M(),framework:M(),deploymentUrl:Ye()}),Er=N({name:P(M()),starter:He(Tr),framework:P(M()),quotas:P(N({sliceMachineEnabled:F()}))});function Dr(e){return Mr(Pr(e.host),e,{schema:Er})}async function Or(e,t){await Mr(new URL(`type-builder`,Pr(t.host)),t,{method:`PATCH`,json:{framework:e}})}const kr=N({completedSteps:V(M())});async function Ar(e){return Nr(new URL(`onboarding`,Pr(e.host)),e,{schema:kr})}async function jr(e,t){return Nr(new URL(`onboarding/${encodeURIComponent(e)}/toggle`,Pr(t.host)),t,{method:`PATCH`,schema:kr})}function Mr(e,t,n={}){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),B(r,{headers:{Authorization:`Bearer ${t.token}`,repository:t.repo},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function Nr(e,t,n={}){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),B(r,{credentials:{"prismic-auth":t.token},...n})}function Pr(e){return new URL(`https://api.internal.${e}/repository/`)}const Fr=N({email:M(),shortId:M(),intercomHash:M()}),Ir=N({domain:M(),name:P(M()),role:P(Fe([M(),Me(M(),M())]))}),Lr=N({repositories:V(Ir)});async function Rr(e){let t=new URL(`user/profile`,`https://api.internal.${e.host}/`);return B(t,{headers:{Authorization:`Bearer ${e.token}`},schema:Fr,unknownErrorMessage:`Failed to load your profile`})}async function zr(e){let t=new URL(`user/repositories`,`https://api.internal.${e.host}/`);return(await B(t,{headers:{Authorization:`Bearer ${e.token}`},schema:Lr,unknownErrorMessage:`Failed to load your repositories`})).repositories}async function Br(e,t){let{repo:n,token:r,host:i}=t,{completedSteps:a}=await Ar({repo:n,token:r,host:i}),o=e.filter(e=>!a.includes(e));for(let e of o)await jr(e,{repo:n,token:r,host:i})}let X;const Z={tags:{},contexts:{}};function Vr(e){X=e,Z.contexts.Process={command:process.argv.join(` `),cwd:process.cwd()}}function Hr(e,t){Z.tags[e]=t}function Ur(e,t){Z.contexts[e]=t}function Wr(e){Z.user=e}async function Gr(e){if(X)try{let t=new URL(X.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:X.appVersion,environment:X.environment||Kr(X.appVersion),tags:Z.tags,user:Z.user,contexts:{...Z.contexts,runtime:{name:`node`,version:process.versions.node}},exception:{values:[{type:n.name,value:n.message.slice(0,2500),stacktrace:Jr(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(qr(t),{method:`POST`,headers:{"Content-Type":`application/x-sentry-envelope`,"X-Sentry-Auth":`Sentry sentry_version=7, sentry_client=${X.appName}/${X.appVersion}, sentry_key=${t.username}`},body:a,signal:AbortSignal.timeout(2e3)})}catch{}}function Kr(e){let t=e.match(/-(.+?)\./);return t?t[1]:`production`}function qr(e){return`${e.protocol}//${e.host}/api${e.pathname}/envelope/`}function Jr(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 Yr=N({id:M(),label:M(),customName:Ae(M()),isMaster:F()});async function Xr(e){return(await $r(new URL(`repository/locales`,ei(e.host)),e,{schema:N({results:V(Yr)}),unknownErrorMessage:`Failed to load locales`})).results}async function Zr(e,t){return $r(new URL(`repository/locales`,ei(t.host)),t,{method:`POST`,json:{id:e.id,isMaster:e.isMaster??!1,...e.customName?{customName:e.customName}:{}},schema:Yr,unknownErrorMessage:`Failed to save locale`})}async function Qr(e,t){await $r(new URL(`repository/locales/${encodeURIComponent(e)}`,ei(t.host)),t,{method:`DELETE`,notFoundMessage:`Locale not found: ${e}`,unknownErrorMessage:`Failed to remove locale`})}function $r(e,t,n){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),B(r,{headers:{Authorization:`Bearer ${t.token}`},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function ei(e){return new URL(`https://api.internal.${e}/locale/`)}const ti=N({documentsPublished:F(),documentsUnpublished:F(),releasesCreated:F(),releasesUpdated:F(),tagsCreated:F(),tagsDeleted:F()}),ni=Object.keys(ti.shape),ri=N({config:je(ti,{_id:M(),url:M(),active:F(),name:Ae(M()),secret:Ae(M()),headers:Me(M(),M())})});function ii(e){let{repo:t,host:n}=e;return Q(new URL(`app/settings/webhooks`,$(t,n)),e,{schema:V(ri),unknownErrorMessage:`Failed to load webhooks`})}async function ai(e,t){let n=ci({...e,active:!0,headers:{}}),{repo:r,host:i}=t;await Q(new URL(`app/settings/webhooks/create`,$(r,i)),t,{method:`POST`,body:n,unknownErrorMessage:`Failed to create webhook`})}async function oi(e,t,n){let r=ci(t),{repo:i,host:a}=n;await Q(new URL(`app/settings/webhooks/${encodeURIComponent(e)}`,$(i,a)),n,{method:`POST`,body:r,notFoundMessage:`Webhook not found: ${e}`,unknownErrorMessage:`Failed to update webhook`})}async function si(e,t){let{repo:n,host:r}=t;await Q(new URL(`app/settings/webhooks/${encodeURIComponent(e)}/delete`,$(n,r)),t,{method:`POST`,notFoundMessage:`Webhook not found: ${e}`,unknownErrorMessage:`Failed to delete webhook`})}function ci(e){let t=new FormData;return t.set(`url`,e.url),t.set(`name`,e.name??``),t.set(`secret`,e.secret??``),t.set(`headers`,JSON.stringify(e.headers??{})),t.set(`active`,e.active?`on`:`off`),t.set(`documentsPublished`,e.documentsPublished.toString()),t.set(`documentsUnpublished`,e.documentsUnpublished.toString()),t.set(`releasesCreated`,e.releasesCreated.toString()),t.set(`releasesUpdated`,e.releasesUpdated.toString()),t.set(`tagsCreated`,e.tagsCreated.toString()),t.set(`tagsDeleted`,e.tagsDeleted.toString()),t}const li=N({id:M(),scope:M(),token:M(),created_at:N({$date:Ne()})}),ui=N({id:M(),name:M(),wroom_auths:V(li)}),di=N({app_name:M(),token:M(),timestamp:Ne()}),fi=N({max_tokens:Ne(),tokens:V(di)});function pi(e){let{repo:t,host:n}=e;return Q(new URL(`settings/security/contentapi`,$(t,n)),e,{schema:V(ui),unknownErrorMessage:`Failed to load OAuth apps`})}async function mi(e,t){let{repo:n,host:r}=t;return Q(new URL(`settings/security/oauthapp`,$(n,r)),t,{method:`POST`,json:{app_name:e},schema:ui,unknownErrorMessage:`Failed to create OAuth app`})}async function hi(e,t,n){let{repo:r,host:i}=n;return Q(new URL(`settings/security/authorizations`,$(r,i)),n,{method:`POST`,json:{app:e,scope:t},schema:li,unknownErrorMessage:`Failed to create token`})}async function gi(e,t){let{repo:n,host:r}=t;await Q(new URL(`settings/security/authorizations/${encodeURIComponent(e)}`,$(n,r)),t,{method:`DELETE`,notFoundMessage:`Token not found: ${e}`,unknownErrorMessage:`Failed to delete token`})}function _i(e){let{repo:t,host:n}=e;return Q(new URL(`settings/security/customtypesapi`,$(t,n)),e,{schema:fi,unknownErrorMessage:`Failed to load write tokens`})}async function vi(e,t){let{repo:n,host:r}=t;return Q(new URL(`settings/security/token`,$(n,r)),t,{method:`POST`,json:{app_name:e},schema:di,unknownErrorMessage:`Failed to create write token`})}async function yi(e,t){let{repo:n,host:r}=t;await Q(new URL(`settings/security/token/${encodeURIComponent(e)}`,$(n,r)),t,{method:`DELETE`,notFoundMessage:`Token not found`,unknownErrorMessage:`Failed to delete write token`})}async function bi(e){let{domain:t,host:n}=e;return Di(new URL(`app/dashboard/repositories/${encodeURIComponent(t)}/exists`,Oi(n)),e,{schema:F()})}async function xi(e){let{domain:t,name:n,framework:r,agent:i,host:a}=e,o=new URL(`app/dashboard/repositories`,Oi(a));o.searchParams.set(`app`,`cli`),i&&o.searchParams.set(`agent`,i),await Di(o,e,{method:`POST`,json:{domain:t,name:n,framework:r,plan:`personal`},unknownErrorMessage:`Failed to create repository`})}const Si=N({repository:N({api_access:M()})});async function Ci(e){let{repo:t,host:n}=e;return(await Q(new URL(`syncState`,$(t,n)),e,{schema:Si,unknownErrorMessage:`Failed to load repository access`})).repository.api_access}async function wi(e,t){let{repo:n,host:r}=t;await Q(new URL(`settings/security/apiaccess`,$(n,r)),t,{method:`POST`,json:{api_access:e},unknownErrorMessage:`Failed to set repository access`})}const Ti=N({repository:N({name:M()})});async function Ei(e,t){let n=new FormData;n.set(`displayname`,e);let{repo:r,host:i}=t;return(await Q(new URL(`app/settings/repository`,$(r,i)),t,{method:`POST`,body:n,schema:Ti,unknownErrorMessage:`Failed to set repository name`})).repository.name}function Q(e,t,n={}){return B(e,{credentials:{"prismic-auth":t.token},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function Di(e,t,n={}){return B(e,{credentials:{"prismic-auth":t.token},...n})}function $(e,t){return new URL(`https://${e}.${t}/`)}function Oi(e){return new URL(`https://${e}/`)}const ki={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: ${Ce.join(`, `)} (default: detected from the project)`}}};var Ai=D(ki,async({values:e})=>{let t=await E().catch(()=>void 0),{name:n,lang:r,framework:i=t?.id}=e;if(!i)throw new k(`
|
|
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 <${Ce.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(!Ce.includes(i))throw new k(`Unsupported framework "${i}". Use one of: ${Ce.join(`, `)}.`);let{token:a,host:o}=await U(),s=await ji({name:n,lang:r,framework:i,token:a,host:o});console.info(`Repository created: ${s}`),console.info(`URL: https://${s}.${o}/`)});async function ji(e){let{name:t,lang:n=`en-us`,framework:r,token:i,host:a}=e,o=await Mi({token:i,host:a});if(!o)throw new k(`Failed to create a repository. Please try again.`);let s=it();return await xi({domain:o,name:t??o,framework:r,agent:s,token:i,host:a}),await Zr({id:n,isMaster:!0},{repo:o,token:i,host:a}),await Br([`createPrismicProject`],{repo:o,token:i,host:a}).catch(()=>{}),o}async function Mi(e){let{token:t,host:n}=e,r;for(let e=0;e<5;e++){let e=crypto.randomUUID().replace(/-/g,``).slice(0,8);if(await bi({domain:e,token:t,host:n})){r=e;break}}return r}var Ni=D({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 m()&&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})=>{ie(e,[`repo`,`repo-name`]);let{repo:t,lang:n,"no-browser":i,"no-setup":a}=e,s;try{s=await r()}catch(e){if(!(e instanceof _e))throw e}if(s&&!t)throw new k(`
|
|
239
|
+
This project is already set up for Prismic (repository: ${s.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 s
|
|
244
|
+
`);let c=s!==void 0&&t!==void 0,u;if(!s)try{u=await Te()}catch(e){e instanceof ce&&console.warn(`Could not read slicemachine.config.json, ignoring.`)}let{host:d,token:p}=await U(),m=p;try{await Rr({token:m,host:d})}catch(e){if(e instanceof I||e instanceof z){if(W.PRISMIC_TOKEN)throw e;console.info(`Not logged in. Starting login...`);let{email:t}=await at({onReady:e=>{i?console.info(`Open this URL to log in: ${e}`):(console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${e}`),Mt(e))}});console.info(`Logged in as ${t}`),m=(await U()).token}else throw e}let h=(t??u?.repositoryName)?.toLowerCase(),g;h&&(g=await Dr({repo:h,token:m,host:d}).catch(e=>{throw e instanceof z?new k(`Repository "${h}" not found in your account. Check the name or request access to the repository.`):e}));let _;try{_=await E()}catch(e){throw e instanceof re||e instanceof gt?new k(`
|
|
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 <${Ce.join(`|`)}>\`.
|
|
251
251
|
Connect the project later with \`prismic init --repo <domain>\`.
|
|
252
|
-
`):e}let
|
|
252
|
+
`):e}let v=W.PRISMIC_TYPE_BUILDER_ENABLED??g?.quotas?.sliceMachineEnabled;if(h&&g&&(!v||g.framework!==_.id))try{await Or(_.id,{repo:h,token:m,host:d}),v||console.info(`Turned on the Type Builder for repository "${h}".`)}catch(e){if(!(e instanceof z))throw e;if(!v)throw new k(`Repository "${h}" 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 ${_.id}. Ask a repository administrator to run \`prismic init\`.`)}h||(h=await ji({name:e[`repo-name`],lang:n,framework:_.id,token:m,host:d}),console.info(`Created repository: ${h}`));try{let e=d===`prismic.io`?void 0:`https://${h}.cdn.${d}/api/v2/`;s?await b({repositoryName:h,documentAPIEndpoint:e}):await we({repositoryName:h,documentAPIEndpoint:e,libraries:u?.libraries,routes:[]})}catch(e){throw e instanceof de?new k(`Could not find a package.json file. Run this command from a project directory.`):new k(`Failed to create prismic.config.json.`)}if(u){try{await Ee()}catch{}let{dependencies:e,devDependencies:t,peerDependencies:n}=await G(),r=Object.keys({...e,...t,...n}).filter(e=>e===`slice-machine-ui`||e.startsWith(`@slicemachine/adapter-`));r.length>0&&await _t(r),console.info(`Migrated slicemachine.config.json to prismic.config.json`)}let y=await G();await _.initProject({setup:!a&&!s});for(let{name:e,from:t,to:n}of ht(y,await G()))console.info(`Updated ${e} from ${t} to ${n}. Check your code for breaking changes in the new version.`);if(!a)try{console.info(`Installing dependencies...`),await dt()}catch{console.warn(`Could not install dependencies. Run \`${await mt()}\` to finish.\nThe rest of the setup is done, so you don't need to run \`prismic init\` again.`)}let[x,S]=await Promise.all([f({repo:h,token:m,host:d}),_.getModels()]),C=o(x,S);if(c&&g?.starter){if(x.customTypes.length===0&&x.slices.length===0)throw new k(`Repository "${h}" has no starter models. Use a repository created from the starter in the Prismic dashboard.`);await Ii(g.starter)}let ee=c&&[C.customTypes,C.slices].some(e=>e.update.length>0||e.delete.length>0);if(!ee)for(let e of await _.writeModels(C))console.info(e);await _.generateTypes(),l(x.customTypes).length>0&&console.info("\nRun `prismic slice list --legacy` to find legacy slices to upgrade."),ee&&console.warn(be`
|
|
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
|
+
`),c&&g?.starter?(await Fi(_,g.starter,{repo:h,token:m,host:d}),ee||(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://${h}.${d}/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 "${h}".`),console.info("Run `prismic type create <name>` to create a content type."),console.info("Run `prismic pull` to pull models from Prismic."));let te=await _.getSetupInstructions();te&&console.info(`\n${te}`)});async function Pi(e){let t=await G(),n=e.id.split(`/`).at(-1);return!!(n&&t.name===n)}async function Fi(t,n,r){try{let n=await ne(r);await Promise.all(n.filter(e=>e.label===`Starter Preview`).map(t=>e(t.id,r))),n.some(e=>e.url===t.localPreviewUrl)||await d(t.localPreviewConfig,r)}catch(e){await Gr(e),console.error(`Could not configure the local preview. Run \`prismic preview add ${t.localPreviewUrl} --name ${t.localPreviewConfig.name}\` manually. Continuing.`)}try{await se(t.localSimulatorUrl,r)}catch(e){await Gr(e),console.error(`Could not configure the local slice simulator. Run \`prismic preview set-simulator ${t.localSimulatorUrl}\` manually. Continuing.`)}await Br([`instantStart_continueBuildingLocally`],r).catch(()=>{}),await Pi(n)&&await ft(r.repo)}async function Ii(e){if(!await Pi(e))return;let t=await j();await Promise.all([St(new URL(`.deployment`,t),{recursive:!0,force:!0}),St(new URL(`documents`,t),{recursive:!0,force:!0})])}var Li=D({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 w(),master:a=!1,name:o}=t,{token:s,host:c}=await U();await Zr({id:n,isMaster:a,customName:o},{repo:i,token:s,host:c}),console.info(`Locale added: ${n}`)}),Ri=D({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 w(),json:r}=e,{token:i,host:a}=await U(),o=await Xr({repo:n,token:i,host:a});if(r){console.info(R(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(T(s,{headers:[`ID`,`LABEL`]}))}),zi=D({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 w()}=t,{token:a,host:o}=await U();await Qr(n,{repo:i,token:a,host:o}),console.info(`Locale removed: ${n}`)}),Bi=D({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 w()}=t,{token:a,host:o}=await U(),s=await Xr({repo:i,token:a,host:o}),c=s.find(e=>e.id===n);if(!c)throw new k(`Locale "${n}" not found. Available locales: ${s.map(e=>e.id).join(`, `)}`);if(c.isMaster)throw new k(`Locale "${n}" is already the master.`);await Zr({id:c.id,isMaster:!0,customName:c.customName??void 0},{repo:i,token:a,host:o}),console.info(`Master locale set: ${n}`)}),Vi=O({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:Li,description:`Add a locale`},list:{handler:Ri,description:`List locales`},remove:{handler:zi,description:`Remove a locale`},"set-master":{handler:Bi,description:`Set the master locale`}}}),Hi=D({name:`prismic login`,description:`Log in to Prismic via browser.`,options:{"no-browser":{type:`boolean`,description:`Skip opening the browser automatically`}}},async({values:e})=>{let{"no-browser":t}=e,{email:n}=await at({onReady:e=>{t?console.info(`Open this URL to log in: ${e}`):(console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${e}`),Mt(e))}});console.info(`Logged in to Prismic as ${n}`)}),Ui=D({name:`prismic logout`,description:`Log out of Prismic.`},async()=>{if(await nt())console.info(`Logged out of Prismic`);else throw new k(`Logout failed. You can log out manually by deleting the file.`)}),Wi=D({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 w(),name:a}=t,o;try{o=new URL(n)}catch{throw new k(`Invalid URL: ${n}`)}let s=a||o.hostname,c=`${o.protocol}//${o.host}`,l=o.pathname===`/`?void 0:o.pathname,{token:u,host:f}=await U();await d({name:s,websiteURL:c,resolverPath:l},{repo:i,token:u,host:f}),console.info(`Preview added: ${n}`),console.info("Run `prismic preview set-simulator <url>` to set the slice simulator URL.");try{let e=await(await E()).getSetupInstructions();e&&console.info(`\n${e}`)}catch(e){if(!(e instanceof re||e instanceof gt))throw e}}),Gi=D({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:
|
|
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 w(),json:r}=e,{token:i,host:a}=await U(),[o,s]=await Promise.all([ne({repo:n,token:i,host:a}),_({repo:n,token:i,host:a})]);if(r)console.info(R({previews:o,simulatorUrl:s??null}));else if(o.length===0&&!s)console.info(`No preview configurations found.`);else{if(o.length>0){let e=o.map(e=>[e.url,e.label]);console.info(T(e,{headers:[`URL`,`NAME`]}))}s&&(o.length>0&&console.info(``),console.info(`Simulator: ${s}`))}}),Ki=D({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:
|
|
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:t,values:n})=>{let[r]=t,{env:i,repo:a=i??await w()}=n,{token:o,host:s}=await U(),c=(await ne({repo:a,token:o,host:s})).find(e=>e.url===r);if(!c)throw new k(`Preview not found: ${r}`);await e(c.id,{repo:a,token:o,host:s}),console.info(`Preview removed: ${r}`)}),qi=D({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 w()}=t,a;try{a=new URL(n)}catch{throw new k(`Invalid URL: ${n}`)}a.pathname.endsWith(`/slice-simulator`)||(a.pathname=a.pathname.replace(/\/+$/,``)+`/slice-simulator`);let o=a.toString(),{token:s,host:c}=await U();await se(o,{repo:i,token:s,host:c}),console.info(`Simulator URL set: ${o}`)}),Ji=O({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:Wi,description:`Add a preview URL`},list:{handler:Gi,description:`List preview URLs and the simulator URL`},remove:{handler:Ki,description:`Remove a preview URL`},"set-simulator":{handler:qi,description:`Set the slice simulator URL`}}});async function Yi(e){try{let{stdout:t}=await pt(`git`,[`rev-parse`,`--show-toplevel`],{nodeOptions:{cwd:Ct(e)},throwOnError:!0}),n=t.trim();return n?Je(wt(await xt(n))):void 0}catch{return}}async function Xi(e){try{let{stdout:t}=await pt(`git`,[`status`,`--porcelain`,`--untracked-files=all`],{nodeOptions:{cwd:Ct(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 Zi=D({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 E(),{force:n=!1,env:r,repo:i=r??await t.getEnvironment()??await y()}=e,{token:a,host:s}=await U(),c=await j();console.info(`Pulling from repository: ${i}`);let[l,u,d]=await Promise.all([Yi(c),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!n&&l){let e=(await Xi(l)).filter(e=>e.pathname.endsWith(`/model.json`)&&d.some(t=>H(t,e))||e.pathname.endsWith(`/index.json`)&&u.some(t=>H(t,e))).map(e=>L(c,e));if(e.length>0)throw new k(`
|
|
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[p,m,h]=await Promise.all([t.getCustomTypes(),t.getSlices(),
|
|
337
|
+
`)}let[p,m,h]=await Promise.all([t.getCustomTypes(),t.getSlices(),f({repo:i,token:a,host:s})]),g=o(h,{customTypes:p.map(e=>e.model),slices:m.map(e=>e.model)},{treatNonCanonicalAsChanged:!0});if(!n&&!l){let e=new Set([...g.customTypes.update,...g.customTypes.delete].map(e=>e.id)),t=new Set([...g.slices.update,...g.slices.delete].map(e=>e.id)),n=[...p.filter(t=>e.has(t.model.id)),...m.filter(e=>t.has(e.model.id))].map(e=>L(c,e.modelPath));if(n.length>0)throw new k(`
|
|
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 _=await t.writeModels(g);await t.generateTypes(),await
|
|
345
|
+
`)}let _=await t.writeModels(g);await t.generateTypes(),await Br([`connectPrismic`],{repo:await y(),token:a,host:s}).catch(()=>{});let v=g.customTypes.insert.length+g.customTypes.update.length,b=g.slices.insert.length+g.slices.update.length,x=g.customTypes.delete.length+g.slices.delete.length;for(let e of _)console.info(e);v===0&&b===0&&x===0?console.info(`Already up to date.`):(console.info(`Inserted ${g.customTypes.insert.length}, updated ${g.customTypes.update.length}, deleted ${g.customTypes.delete.length} types`),console.info(`Inserted ${g.slices.insert.length}, updated ${g.slices.update.length}, deleted ${g.slices.delete.length} slices`))}),Qi=D({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 E(),{force:n=!1,env:r,repo:i=r??await t.getEnvironment()??await y()}=e,{token:a,host:s}=await U(),c=await j();console.info(`Pushing to repository: ${i}`);let[l,u,d]=await Promise.all([Yi(c),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!n&&l){let e=(await Xi(l)).filter(e=>e.pathname.endsWith(`/model.json`)&&d.some(t=>H(t,e))||e.pathname.endsWith(`/index.json`)&&u.some(t=>H(t,e))).map(e=>L(c,e));if(e.length>0)throw new k(`
|
|
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[m
|
|
365
|
+
`)}let[p,m]=await Promise.all([t.getModels(),f({repo:i,token:a,host:s})]),h=o(p,m);if(!n){let e=Je(u[0]),t=Je(d[0]),n=[...h.customTypes.delete.map(t=>L(c,new URL(`${t.id}/index.json`,e))),...h.slices.delete.map(e=>L(c,new URL(`${oe(e.name)}/model.json`,t)))];if(n.length>0)throw new k(`
|
|
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 S(h,{repo:i,token:a,host:s})}catch(e){throw await ea(e,h.customTypes.delete,{repo:i,token:a,host:s})}for(let{id:e}of h.slices.delete)await x(e,{repo:i,token:a,host:s}).catch(t=>{let n=t instanceof Error?t.message:String(t);console.warn(`Failed to delete screenshots for slice "${e}"${n?`: ${n}`:`.`}`)});let g=[];h.slices.insert.length>0&&g.push(`createSlice`),h.customTypes.insert.some(e=>e.format===`page`)&&g.push(`createPageType`),g.length>0&&await Br(g,{repo:await y(),token:a,host:s}).catch(()=>{});let _=h.customTypes.insert.length+h.customTypes.update.length,v=h.slices.insert.length+h.slices.update.length,b=h.customTypes.delete.length+h.slices.delete.length;_===0&&v===0&&b===0?console.info(`Already up to date.`):(console.info(`Pushed ${_} type(s), ${v} slice(s).`),b>0&&console.info(`Deleted ${b} model(s).`))});const $i=N({hasExistingDocuments:Pe(!0)});async function ea(e,t,n){if(!(e instanceof z)||!Le($i,e.body).success)return e;let{repo:r,host:i}=n;for(let{id:e}of t){let t=ta({repo:r,host:i,customTypeId:e}),a;try{a=await te(e,n)}catch{return new k(`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 k(`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 ta(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 na=D({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,{token:n,host:r}=await U(),i=await zr({token:n,host:r});if(t){console.info(R(i.map(e=>({domain:e.domain,name:e.name??null,role:e.role??null,url:`https://${e.domain}.${r}/`}))));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,ra(e.role)]});console.info(T(a,{headers:[`DOMAIN`,`NAME`,`ROLE`]}))});function ra(e){return typeof e==`string`?e:e?Object.entries(e).map(([e,t])=>`${t} (${e})`).join(`, `):``}const ia=[`private`,`public`,`open`],aa={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 (${ia.join(`, `)})`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}};var oa=D(aa,async({positionals:e,values:t})=>{let[n]=e,{repo:r=await y()}=t;if(!ia.includes(n))throw new k(`Invalid access level: ${n}. Must be one of: ${ia.join(`, `)}`);let{token:i,host:a}=await U();await wi(n,{repo:r,token:i,host:a}),console.info(`Repository access set to: ${n}`)}),sa=D({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:
|
|
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 y()}=t,{token:i,host:a}=await U(),o=await Ei(n,{repo:r,token:i,host:a});console.info(`Repository name set to: ${o}`)}),ca=D({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 y(),web:n,json:r}=e,{token:i,host:a}=await U(),o=`https://${t}.${a}/`;if(n){Mt(new URL(o)),console.info(`Opening ${o}`);return}let[s,c]=await Promise.all([Dr({repo:t,token:i,host:a}),Ci({repo:t,token:i,host:a}).catch(e=>{if(!At(e))throw e})]);if(r){console.info(R({domain:t,name:s.name??null,url:o,apiAccess:c??null}));return}let l=s.name||`(no name)`;console.info(`Name: ${l}`),console.info(`URL: ${o}`),console.info(`Content API: ${c??`(unavailable)`}`)}),la=O({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:Ai,description:`Create a new repository`},list:{handler:na,description:`List repositories`},view:{handler:ca,description:`View repository details`},"set-name":{handler:sa,description:`Set repository display name`},"set-api-access":{handler:oa,description:`Set Content API access level`}}}),ua=D({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:
|
|
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=ge(n),screenshot:a}=t,o=await E(),{model:s}=await o.getSlice(r);if(s.variations.some(e=>e.id===i))throw new k(`Variation "${i}" already exists in slice "${r}".`);let c=``;if(a){let e=await y(),{token:t,host:n}=await U(),r=/^https?:\/\//i.test(a)?new URL(a):wt(a),o=await Ge(r);c=(await C(o,{sliceId:s.id,variationId:i,repo:e,token:t,host:n})).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}"`)}),da=D({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 E(),{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 k(`Slice zone "${i}" not found in "${r}".`);if(c.config??={},c.config.choices??={},o.id in c.config.choices)throw new k(`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}"`)}),fa=D({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=le(n)}=t,i={id:r,name:n,type:`SharedSlice`,variations:[{id:`default`,name:`Default`,description:`Default`,docURL:``,imageUrl:``,version:``,primary:{}}]},a=await E();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.`)}),pa=D({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 E(),{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 k(`Slice zone "${i}" not found in "${r}".`);if(!c.config?.choices||!(o.id in c.config.choices))throw new k(`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}"`)}),ma=D({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 E(),{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})`)}),ha=D({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 E(),{model:o}=await a.getSlice(r),s=o.variations.find(e=>e.id===n);if(!s)throw new k(`Variation "${n}" not found in slice "${r}".`);if(`name`in t&&(s.name=t.name),i){let e=await y(),{token:t,host:n}=await U(),r=/^https?:\/\//i.test(i)?new URL(i):wt(i),a=await Ge(r);s.imageUrl=(await C(a,{sliceId:o.id,variationId:s.id,repo:e,token:t,host:n})).toString()}await a.updateSlice(o),await a.generateTypes(),console.info(`Variation updated: "${n}" in slice "${r}"`)}),ga=D({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,r=await
|
|
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,r=await E(),i=t?[]:(await r.getSlices()).map(e=>e.model),a=(await r.getCustomTypes()).map(e=>e.model),o=l(a);if(n&&t){let e=o.map(e=>({id:e.id,definedIn:e.customTypeId,sliceZone:e.sliceZoneId}));console.info(R(e));return}if(n){console.info(R(i));return}if(i.length===0&&o.length===0){console.info(t?`No legacy slices found.`:`No slices found.`);return}let s=[...i.map(e=>[e.name,e.id,``]),...o.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(T(s,{headers:[`NAME`,`ID`,`DEFINED IN`]})),o.length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),_a=D({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 E();await n.deleteSlice(t),await n.generateTypes(),console.info(`Slice removed: ${t}`)}),va=D({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 E(),{model:a}=await i.getSlice(r),o=a.variations.find(e=>e.id===n);if(!o)throw new k(`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}"`)}),ya=D({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 E(),c=(await s.getCustomTypes()).map(e=>e.model),u=(await s.getSlices()).map(e=>e.model),d=l(c),f=c.find(e=>e.id===r);if(!f)throw new k(`Type "${r}" not found.`);let p=d.find(e=>e.customTypeId===r&&e.sliceZoneId===i&&e.id===n);if(!p)throw new k(`Legacy slice "${n}" not found in the "${i}" slice zone of "${r}". Use --slice-zone to choose the slice zone.`);let m=`${r}::${i}::${n}`,h=a??le(n),g=p.sliceZone.config?.choices?.[h];if(h!==n&&g&&g.type!==`SharedSlice`)throw new k(`The "${i}" slice zone of "${r}" also has legacy slice "${h}". Upgrade it first.`);let _=u.find(e=>e.id===h),v=ge(o??(_?n:`default`)),y=Sa(p,v),b;if(_){if(!a)throw new k(ba(_,p,y));let e=_.variations.find(e=>e.id===v);if(e&&!Ca(e,y))throw new k(`Variation "${v}" of slice "${h}" has different fields than legacy slice "${n}". Use another ID with --variation.`);e?b=`Merged legacy slice "${n}" into variation "${v}" of slice "${h}"`:(_.variations.push(y),b=`Added legacy slice "${n}" to slice "${h}" as variation "${v}"`),_.legacyPaths={..._.legacyPaths,[m]:v},await s.updateSlice(_)}else{let{model:e}=p,t=`fieldset`in e?e.fieldset:void 0;_={id:h,type:`SharedSlice`,name:oe(a??t??h),legacyPaths:{[m]:v},variations:[y]},b=`Upgraded legacy slice "${n}" to slice "${h}"`,await s.createSlice(_)}wa(p,_.id),await s.updateCustomType(f),await s.generateTypes();let{directory:x}=await s.getSlice(_.id),S=L(await j(),x),C=d.length-1;console.info(b),console.info(`After \`prismic push\`: ${xa(p,h,v)}`),console.info(`Update the component in ${S}, then deploy it with \`prismic push\`. Documents use the new shape after the next publish.`),C>0&&console.info(`\n${C} legacy ${C===1?`slice remains`:`slices remain`}. Run \`prismic slice list --legacy\` to list them.`)});function ba(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=>Ca(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 xa(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 Sa(e,t){let{model:n}=e,r=t==="default"?`Default`:oe(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 Ca(e,t){return yt(e.primary??{},t.primary??{})&&yt(e.items??{},t.items??{})}function wa({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 Ta=D({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 E()).getSlice(n);if(r)console.info(R(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(An(e.primary??{}))}}),Ea=O({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:fa,description:`Create a new slice`},edit:{handler:ma,description:`Edit a slice`},remove:{handler:_a,description:`Remove a slice`},list:{handler:ga,description:`List slices`},view:{handler:Ta,description:`View a slice`},connect:{handler:da,description:`Connect a slice to a type's slice zone`},disconnect:{handler:pa,description:`Disconnect a slice from a type's slice zone`},"upgrade-legacy":{handler:ya,description:`Upgrade a legacy slice`},"add-variation":{handler:ua,description:`Add a variation to a slice`},"edit-variation":{handler:ha,description:`Edit a variation of a slice`},"remove-variation":{handler:va,description:`Remove a variation from a slice`}}}),Da=D({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 E(),n=await y(),r=await t.getEnvironment(),{env:i,repo:a=i??r??n}=e,{token:c,host:u}=await U(),d=await j(),[p,m,h,g]=await Promise.all([Yi(d),t.getCustomTypeLibraries(),t.getSliceLibraries(),t.getModels()]),_,v;if(c){let[e,t]=await Promise.all([tt(c,{host:u}),f({repo:a,token:c,host:u})]);_=e.type===`USER`?e.email:`${e.appName} (Write API token for ${e.domain})`,v=o(g,t)}let b=[];p&&(b=(await Xi(p)).filter(e=>e.pathname.endsWith(`/model.json`)&&h.some(t=>H(t,e))||e.pathname.endsWith(`/index.json`)&&m.some(t=>H(t,e))).map(e=>L(d,e))),console.info(`Repository: ${n}`),a!==n&&console.info(`Environment: ${a}`),console.info(_?`Authenticated as: ${_}`:"Not logged in — log in with `prismic login` to compare with remote.");let x=l(g.customTypes).length;x>0&&console.info(`\n${x} legacy ${x===1?`slice needs`:`slices need`} upgrading. Run \`prismic slice list --legacy\`.`);let S=v!==void 0&&!s(v.customTypes)&&!s(v.slices);if(S&&b.length===0){console.info(``),console.info(`Already up to date.`);return}if(v){let e=[],t=[...v.customTypes.insert.map(e=>` ${e.id} (custom type)`),...v.slices.insert.map(e=>` ${e.id} (slice)`)];t.length>0&&e.push([`Local-only:`,...t]);let n=[...v.customTypes.delete.map(e=>` ${e.id} (custom type)`),...v.slices.delete.map(e=>` ${e.id} (slice)`)];n.length>0&&e.push([`Remote-only:`,...n]);let r=[...v.customTypes.update.map(e=>` ${e.id} (custom type)`),...v.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 C=[];if(b.length>0&&(console.info(``),console.info(`Prismic keeps model history in git. Commit model changes before you push or pull them.`),C.push(`git add ${b.join(` `)}`),C.push(`git commit -m "Update Prismic models"`)),v&&!S){let e=v.customTypes.insert.length+v.slices.insert.length,t=v.customTypes.update.length+v.slices.update.length,n=v.customTypes.delete.length+v.slices.delete.length;C.push(`prismic push # creates ${e}, updates ${t}, deletes ${n}`),C.push(`prismic pull # creates ${n}, updates ${t}, deletes ${e}`)}if(C.length>0){console.info(``),console.info(`Next:`);for(let e of C)console.info(` ${e}`)}});const Oa=W.PRISMIC_SYNC_POLL_MS??5e3;var ka=D({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!`),Qe(`sync`,{watch:!0}),process.exit(0)}),console.info(`Watching repository: ${
|
|
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 E(),{env:n,repo:r=n??await t.getEnvironment()??await y()}=e,{token:i,host:a}=await U();$e(`sync`,{watch:!0}),process.on(`SIGINT`,()=>{console.info(`
|
|
451
|
+
Watch stopped. Goodbye!`),Qe(`sync`,{watch:!0}),process.exit(0)}),console.info(`Watching repository: ${r} (polling every ${Oa/1e3}s, Ctrl+C to stop)`);let c,l=0;for(;;){try{let e=await f({repo:r,token:i,host:a}),n=c&&o(e,c);if(!n||s(n.customTypes)||s(n.slices)){let r=!n,l=o(e,await t.getModels(),{treatNonCanonicalAsChanged:!0});for(let e of await t.writeModels(l))console.info(e);let u=[...s(l.slices)?[`slices`]:[],...s(l.customTypes)?[`custom types`]:[]];if((r||u.length>0)&&await t.generateTypes(),c=e,r)await Br([`connectPrismic`],{repo:await y(),token:i,host:a}).catch(()=>{}),console.info(`Initial sync complete.`);else if(u.length>0){let e=(/* @__PURE__ */ new Date()).toLocaleTimeString();console.info(`[${e}] Changes detected in ${u.join(` and `)}`)}}l=0}catch(e){l++;let t=await jt(e)??`Unknown error`;if(console.error(`Error checking for changes: ${t}`),l>=5)throw new k(`Too many consecutive errors (5), stopping watch.`)}await Ot(Oa)}});const Aa=`0123456789abcdefghjkmnpqrstvwxyz`,ja=RegExp(`^pt_[${Aa}]{16}$`);function Ma(){let e=`pt_`;for(let t of Et(16))e+=Aa[t&31];return e}function Na(e){return ja.test(e)}var Pa=D({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(Ma())});const Fa=`Prismic CLI`;var Ia=D({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: "${Fa}")`},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 w(),write:r,"allow-releases":i,name:a=Fa,json:o}=e;if(r&&i)throw new k(`--allow-releases is only valid for access tokens (not with --write)`);let{token:s,host:c}=await U(),l,u;if(r)l=(await vi(a,{repo:n,token:s,host:c})).token;else{u=i?`master+releases`:`master`;let e=(await pi({repo:n,token:s,host:c})).find(e=>e.name===a);e||=await mi(a,{repo:n,token:s,host:c}),l=(await hi(e.id,u,{repo:n,token:s,host:c})).token}console.info(o?R({token:l,type:r?`write`:`access`,name:a,repository:n,...u?{scope:u}:{}}):`Token created: ${l}`)}),La=D({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 w()}=t,{token:a,host:o}=await U(),[s,c]=await Promise.all([pi({repo:i,token:a,host:o}),_i({repo:i,token:a,host:o})]),l=s.flatMap(e=>e.wroom_auths).find(e=>e.token===n);if(l){await gi(l.id,{repo:i,token:a,host:o}),console.info(`Token deleted`);return}let u=c.tokens.find(e=>e.token===n);if(u)await yi(u.token,{repo:i,token:a,host:o}),console.info(`Token deleted`);else throw new k(`Token not found: ${n}`)}),Ra=D({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 w(),json:r}=e,{token:i,host:a}=await U(),[o,s]=await Promise.all([pi({repo:n,token:i,host:a}),_i({repo:n,token:i,host:a})]),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(r)console.info(R({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(T(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(T(e))}else console.info(`WRITE TOKENS (none)`)}}),za=O({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:Ra,description:`List all tokens`},create:{handler:Ia,description:`Create a new token`},delete:{handler:La,description:`Delete a token`}}}),Ba=D({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 E(),{model:o}=await a.getCustomType(r);if(n in o.json)throw new k(`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}"`)}),Va=D({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!`),Qe(`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=le(n)}=t;if(r!==`custom`&&r!==`page`)throw new k(`Invalid format: "${r}". Use "custom" or "page".`);let o=await E();if((await o.getCustomTypes()).some(({model:e})=>e.id===a))throw new k(`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.`)}),Ha=D({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 k(`Invalid format: "${t.format}". Use "custom" or "page".`);let r=await E(),{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})`)}),Ua=D({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 E(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new k(`Tab "${n}" not found in "${r}".`);if(`with-slice-zone`in t&&`without-slice-zone`in t)throw new k(`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 k(`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 k(`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 k(`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 k(`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}"`)}),Wa=D({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 E()).getCustomTypes();if(t){console.info(R(n.map(e=>e.model)));return}if(n.length===0){console.info(`No types found.`);return}let r=n.map(({model:e})=>[e.label||`(no name)`,e.id,e.format??``]);console.info(T(r,{headers:[`NAME`,`ID`,`FORMAT`]}))}),Ga=D({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 E();await n.deleteCustomType(t),await n.generateTypes(),console.info(`Type removed: ${t}`)}),Ka=D({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 E(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new k(`Tab "${n}" not found in "${r}".`);if(Object.keys(a.json).length<=1)throw new k(`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}"`)}),qa=D({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:i}=t,{model:a}=await(await E()).getCustomType(n);if(i){console.info(R(a));return}let o=(await r()).routes?.find(e=>e.type===a.id);console.info(`ID: ${a.id}`),console.info(`Name: ${a.label||`(no name)`}`),console.info(`Format: ${a.format??`custom`}`),console.info(`Repeatable: ${a.repeatable}`),console.info(`Route: ${o?.path??`none`}`);for(let[e,t]of Object.entries(a.json)){console.info(``),console.info(`${e}:`),console.info(An(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)`}`)}}l([a]).length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),Ja=O({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:Va,description:`Create a new content type`},edit:{handler:Ha,description:`Edit a content type`},remove:{handler:Ga,description:`Remove a content type`},list:{handler:Wa,description:`List content types`},view:{handler:qa,description:`View a content type`},"add-tab":{handler:Ba,description:`Add a tab to a content type`},"edit-tab":{handler:Ua,description:`Edit a tab of a content type`},"remove-tab":{handler:Ka,description:`Remove a tab from a content type`}}}),Ya=D({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!`),Qe(`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 w(),name:a,secret:o,trigger:s=[]}=t;for(let e of s)if(!ni.includes(e))throw new k(`Invalid trigger: ${e}\nValid triggers: ${ni.join(`, `)}`);let{token:c,host:l}=await U(),u=!(s.length>0);await ai({url:n,name:a??null,secret:o??null,documentsPublished:s.includes(`documentsPublished`)||u,documentsUnpublished:s.includes(`documentsUnpublished`)||u,releasesCreated:s.includes(`releasesCreated`)||u,releasesUpdated:s.includes(`releasesUpdated`)||u,tagsCreated:s.includes(`tagsCreated`)||u,tagsDeleted:s.includes(`tagsDeleted`)||u},{repo:i,token:c,host:l}),console.info(`Webhook created: ${n}`),console.info(`Run \`prismic webhook set-triggers ${n}\` to configure triggers.`)}),Xa=D({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 w()}=t,{token:a,host:o}=await U(),s=(await ii({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new k(`Webhook not found: ${n}`);if(!s.config.active){console.info(`Webhook already disabled: ${n}`);return}let c=s.config._id,l=structuredClone(s.config);l.active=!1,await oi(c,l,{repo:i,token:a,host:o}),console.info(`Webhook disabled: ${n}`)}),Za=D({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 w()}=t,{token:a,host:o}=await U(),s=(await ii({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new k(`Webhook not found: ${n}`);if(s.config.active){console.info(`Webhook already enabled: ${n}`);return}let c=s.config._id,l=structuredClone(s.config);l.active=!0,await oi(c,l,{repo:i,token:a,host:o}),console.info(`Webhook enabled: ${n}`)}),Qa=D({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 w(),json:r}=e,{token:i,host:a}=await U(),o=await ii({repo:n,token:i,host:a});if(r){console.info(R(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(T(s,{headers:[`URL`,`STATUS`]}))}),$a=D({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 w()}=t,{token:a,host:o}=await U(),s=(await ii({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new k(`Webhook not found: ${n}`);let c=s.config._id;await si(c,{repo:i,token:a,host:o}),console.info(`Webhook removed: ${n}`)}),eo=D({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!`),Qe(`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 w(),trigger:a=[]}=t;for(let e of a)if(!ni.includes(e))throw new k(`Invalid trigger: ${e}\nValid triggers: ${ni.join(`, `)}`);let{token:o,host:s}=await U(),c=(await ii({repo:i,token:o,host:s})).find(e=>e.config.url===n);if(!c)throw new k(`Webhook not found: ${n}`);let l=c.config._id;await oi(l,{...c.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,token:o,host:s}),console.info(`Webhook triggers updated: ${a.join(`, `)}`)}),to=D({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 w()}=t,{token:a,host:o}=await U(),s=(await ii({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new k(`Webhook not found: ${n}`);let{config:c}=s;console.info(`URL: ${c.url}`),console.info(`Name: ${c.name||`(none)`}`),console.info(`Status: ${c.active?`enabled`:`disabled`}`),console.info(`Secret: ${c.secret?`(set)`:`(none)`}`);let l=[];for(let e of ni)c[e]&&l.push(e);if(console.info(`Triggers: ${l.length>0?l.join(`, `):`(none)`}`),Object.keys(c.headers).length>0){console.info(`Headers:`);for(let[e,t]of Object.entries(c.headers))console.info(` ${e}: ${t}`)}else console.info(`Headers: (none)`)}),no=O({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:Qa,description:`List all webhooks`},create:{handler:Ya,description:`Create a new webhook`},view:{handler:to,description:`View webhook details`},remove:{handler:$a,description:`Delete a webhook`},enable:{handler:Za,description:`Enable a webhook`},disable:{handler:Xa,description:`Disable a webhook`},"set-triggers":{handler:eo,description:`Update webhook triggers`}}}),ro=D({name:`prismic whoami`,description:`Show the currently logged in user.`},async()=>{let{token:e,host:t}=await U(),n=await tt(e,{host:t});n.type===`Machine2Machine`?console.info(`${n.appName} (Write API token for ${n.domain})`):console.info(n.email)}),io=O({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!`),Qe(`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:Ni,description:`Initialize a Prismic project`},docs:{handler:gn,description:`Browse Prismic documentation`},gen:{handler:wr,description:`Generate files from local models`},pull:{handler:Zi,description:`Pull types and slices from Prismic`},push:{handler:Qi,description:`Push types and slices to Prismic`},sync:{handler:ka,description:`Sync types and slices from Prismic`},dev:{handler:Pt,description:`Edit local models visually in the Type Builder`,hidden:!0},status:{handler:Da,description:`Show local vs remote model differences`},env:{handler:Cn,description:`Manage the active environment`},locale:{handler:Vi,description:`Manage locales`},repo:{handler:la,description:`Manage repositories`},type:{handler:Ja,description:`Manage content types`},field:{handler:yr,description:`Manage fields`},slice:{handler:Ea,description:`Manage slices`},preview:{handler:Ji,description:`Manage preview and simulator URLs`},token:{handler:za,description:`Manage API tokens`},webhook:{handler:no,description:`Manage webhooks`},login:{handler:Hi,description:`Log in to Prismic`},logout:{handler:Ui,description:`Log out of Prismic`},whoami:{handler:ro,description:`Show the currently logged in user`},"task-id":{handler:Pa,description:`Print a task ID for --task-id`,hidden:it()===void 0}}});const ao=Ue({exp:P(Ne())});function oo(e){try{let[,t]=e.split(`.`);if(!t)return;let n=JSON.parse(Buffer.from(t,`base64url`).toString());return Ie(ao,n)}catch{return}}const so=[k,a,i,me,h,t,he,c,re,fe,ye,ve,yn,xe,_e,ce,gt,de,Ke,I,z,qe,We],co=[qe,We];await lo();async function lo(){await vt({npmPackageName:ke,statePath:Xe}),lt().catch(()=>{});let{positionals:[e=``],values:{version:t,help:n,repo:r=await y().catch(()=>void 0),"analytics-intent":i,"analytics-task-id":a,"user-intent":o=i,"task-id":s=a}}=bt({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(t){console.info(Oe);return}let c=typeof r==`string`?r:void 0,l=typeof o==`string`?o:void 0,u=typeof s==`string`?s:void 0,d=!n&&e!==``&&e!==`task-id`&&it()!==void 0?fo(u,l):void 0;if(d){console.error(`error: ${d}\nrun \`prismic task-id\` once per user request, then pass --task-id <id> --user-intent "<what the user asked for>" on every command until the user asks for something else`),process.exitCode=1;return}if(!n){let{token:e,host:t}=await U(),n=W.PRISMIC_TELEMETRY_ENABLED??await ut(),r=W.PRISMIC_SENTRY_ENABLED??(n&&W.PROD);if(r&&await uo({host:t,repo:c,userIntent:l,taskId:u}),n&&await rt({host:t,repo:c,userIntent:l,taskId:u}),e){let i=oo(e)?.exp,a=Date.now()/1e3;if((!i||i-a<=3600)&&process.on(`exit`,()=>ot()),r||n){let n=Ze();n?Wr({id:n}):(!i||i>a)&&Rr({token:e,host:t}).then(e=>{st(e),Wr({id:e.shortId})}).catch(()=>{})}}}let f=!n&&e&&e!==`sync`;try{f&&$e(e),await io(),f&&Qe(e)}catch(t){process.exitCode=1;let n=await jt(t).catch(()=>void 0);if(f&&Qe(e,{error:n??t}),so.some(e=>t instanceof e))console.error(n),co.some(e=>t instanceof e)&&await Gr(t);else throw console.error(`The CLI reached a bug. Report this if it keeps happening: https://github.com/prismicio/cli/issues`),await Gr(t),t}}async function uo(e){let{host:t,repo:n,userIntent:r,taskId:i}=e;Vr({dsn:W.PRISMIC_SENTRY_DSN,appName:ke,appVersion:Oe,environment:W.PRISMIC_SENTRY_ENVIRONMENT}),Hr(`host`,t),n&&(Hr(`repository`,n),Ur(`Repository Data`,{name:n})),i&&Hr(`taskId`,i),r&&Ur(`Agent Task`,{userIntent:r,taskId:i});try{Hr(`framework`,(await E()).id)}catch{}}function fo(e,t){if(!e)return`missing --task-id`;if(!Na(e))return"--task-id must come from `prismic task-id`";if(!t)return`missing --user-intent`}export{};
|