prismic 1.21.0 → 1.22.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-DPb0t6EU.mjs +191 -0
- package/dist/{auth-Bi0hYnVj.mjs → auth-D17Z0IuK.mjs} +1 -1
- package/dist/index.mjs +124 -99
- package/dist/{nextjs-DP-ui31G.mjs → nextjs-Cj6xZEd3.mjs} +55 -55
- package/dist/{nuxt-V2Y8WzY1.mjs → nuxt-BwU_wt1u.mjs} +12 -12
- package/dist/package-BmR9etBQ.mjs +1 -0
- package/dist/{segment-CGLmVq2C.mjs → segment-DiEeqnUu.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-q63_SgMi.mjs → sveltekit-C7Mpsvl-.mjs} +31 -31
- package/dist/{update-notifier-CWyOCy0G.mjs → update-notifier-BBo9CSjK.mjs} +1 -1
- package/package.json +1 -1
- package/dist/adapters-BAbISLsD.mjs +0 -189
- package/dist/package-IViHhlnH.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,41 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{$ as e,A as t,B as n,C as r,
|
|
3
|
-
--task-id and --user-intent group the commands of one user request together.
|
|
4
|
-
Run \`prismic task-id\` when the user asks for something, then pass that id on
|
|
5
|
-
every command until they ask for something else — creating a slice, adding its
|
|
6
|
-
fields and pushing them are one request, and the next slice is another. Pass
|
|
7
|
-
what the user asked for as --user-intent. Analytics only — no effect on behavior.
|
|
8
|
-
`}:e.sections;console.info(vt(e.description,n,e.name,r))}}function _t(e){let t=ht?{...e,...gt}:e,n=[];for(let[e,r]of Object.entries(t)){if(r.deprecated||r.hidden)continue;let t=r.short?`-${r.short}, `:` `,i=r.type===`string`?` string`:``,a=r.description+(r.required?` (required)`:``);n.push([` ${t}--${e}${i}`,a])}return n.push([` -h, --help`,`Show help for command`]),n}function vt(e,t,n,r={}){let a=[i(e)];for(let[e,n]of Object.entries(t))a.push(``,e,n);for(let[e,t]of Object.entries(r))a.push(``,e,...i(t).split(`
|
|
9
|
-
`).map(e=>e?` ${e}`:``));return a.push(``,`LEARN MORE`,` Use \`${n} <command> --help\` for more information about a command.`),a.join(`
|
|
10
|
-
`)}function yt(e,t){let n=t.filter(t=>t in e),r=t.map(e=>`--${String(e)}`).join(` or `);if(n.length>1)throw new U(`Only one of ${r} can be specified.`);if(n.length===0)throw new U(`Specify one of ${r}.`);return{key:n[0],value:e[n[0]]}}function bt(e,t){let n=t.filter(t=>t in e),r=t.map(e=>`--${String(e)}`).join(` or `);if(n.length>1)throw new U(`Only one of ${r} can be specified.`)}var U=class extends Error{name=`CommandError`};const xt=N({path:A(),title:A(),description:k(A())}),St=N({path:A(),title:A(),description:k(A()),anchors:j(N({slug:A(),excerpt:A()}))});async function Ct(e){let t=new URL(`api/index/`,Et(e.host));return F(t,{schema:j(xt),unknownErrorMessage:`Failed to fetch documentation index`})}async function wt(e,t){let n=new URL(`api/index/${e}`,Et(t.host));return F(n,{schema:St,notFoundMessage:`Documentation page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation index`})}async function Tt(e,t){let n=new URL(e,Et(t.host));return F(n,{headers:{Accept:`text/markdown`,...t.headers},schema:A(),notFoundMessage:`Page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation page`})}function Et(e=`prismic.io`){return new URL(`https://${e}/docs/`)}var Dt=V({name:`prismic docs list`,description:`
|
|
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 w,Y as ee,Z as T,_ as te,at as E,b as D,d as ne,et as re,f as ie,h as ae,i as oe,it as se,j as O,k as ce,m as le,n as ue,o as k,ot as de,p as fe,q as pe,r as me,rt as A,s as j,st as he,tt as ge,v as _e,w as ve,x as M,y as ye,z as be}from"./adapters-DPb0t6EU.mjs";import{n as xe,t as Se}from"./package-BmR9etBQ.mjs";import{A as Ce,C as N,D as we,E as Te,H as Ee,I as De,L as Oe,M as P,N as ke,O as Ae,P as F,S as I,V as je,_ as L,a as Me,f as Ne,g as Pe,i as Fe,j as R,k as Ie,n as z,o as B,r as Le,s as V,t as Re,v as H,w as ze}from"./request-DozpYv-V.mjs";import{_ as U,c as Be,d as Ve,f as He,h as Ue,i as We,l as Ge,m as Ke,n as qe,o as Je,p as Ye,r as W,s as Xe,t as Ze,u as Qe}from"./auth-D17Z0IuK.mjs";import{a as $e,c as G,d as et,i as tt,l as nt,s as rt,t as it,u as at}from"./packageJson-Bvm9nRNl.mjs";import{t as ot}from"./update-notifier-BBo9CSjK.mjs";import{isDeepStrictEqual as st,parseArgs as ct}from"node:util";import{realpath as lt,rm as ut}from"node:fs/promises";import{fileURLToPath as dt,pathToFileURL as ft}from"node:url";import{randomBytes as pt}from"node:crypto";import{exec as mt}from"node:child_process";import{setTimeout as ht}from"node:timers/promises";const gt=R({path:F(),title:F(),description:P(F())}),_t=R({path:F(),title:F(),description:P(F()),anchors:I(R({slug:F(),excerpt:F()}))});async function vt(e){let t=new URL(`api/index/`,xt(e.host));return B(t,{schema:I(gt),unknownErrorMessage:`Failed to fetch documentation index`})}async function yt(e,t){let n=new URL(`api/index/${e}`,xt(t.host));return B(n,{schema:_t,notFoundMessage:`Documentation page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation index`})}async function bt(e,t){let n=new URL(e,xt(t.host));return B(n,{headers:{Accept:`text/markdown`,...t.headers},schema:F(),notFoundMessage:`Page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation page`})}function xt(e=`prismic.io`){return new URL(`https://${e}/docs/`)}var St=T({name:`prismic docs list`,description:`
|
|
11
3
|
List available documentation pages.
|
|
12
4
|
|
|
13
5
|
With a path argument, list the anchors within that page.
|
|
14
|
-
`,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
|
|
6
|
+
`,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 yt(n,{host:U.PRISMIC_DOCS_HOST});if(r){console.info(V(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(A(t,{headers:[`PATH`,`EXCERPT`]}))}else{let e=await vt({host:U.PRISMIC_DOCS_HOST});if(e.sort((e,t)=>e.path.localeCompare(t.path)),r){console.info(V(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(A(t,{headers:[`PATH`,`TITLE`,`DESCRIPTION`]}))}});const Ct=/[\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,wt=Object.hasOwnProperty;var Tt=class{constructor(){this.occurrences,this.reset()}slug(e,t){let n=this,r=Et(e,t===!0),i=r;for(;wt.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 Et(e,t){return typeof e==`string`?(t||(e=e.toLowerCase()),e.replace(Ct,``).replace(/ /g,`-`)):``}var Dt=T({name:`prismic docs view`,description:`
|
|
15
7
|
View a documentation page as Markdown.
|
|
16
8
|
|
|
17
9
|
Append #anchor to the path to view only the section under that heading.
|
|
18
|
-
`,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
|
|
19
|
-
`),r=new
|
|
20
|
-
`).trim()}var
|
|
21
|
-
`);super(
|
|
10
|
+
`,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 bt(a,{host:U.PRISMIC_DOCS_HOST,headers:Xe()});if(o){let e=Ot(s,o);if(!e)throw new w(`Anchor not found: #${o}`);s=e}if(r){console.info(V({path:a,anchor:o,content:s}));return}console.info(s)});function Ot(e,t){let n=e.split(`
|
|
11
|
+
`),r=new Tt,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(`
|
|
12
|
+
`).trim()}var kt=_({name:`prismic docs`,description:`Browse Prismic documentation.`,commands:{list:{handler:St,description:`List available documentation pages`},view:{handler:Dt,description:`View a documentation page`}}}),At=T({name:`prismic env active`,description:`Print the active environment.`},async()=>{let e=await M(),t=await(await j()).getEnvironment();console.info(t??e)});const jt=R({email:F(),shortId:F(),intercomHash:F()});async function Mt(e){let t=new URL(`user/profile`,`https://api.internal.${e.host}/`);return B(t,{headers:{Authorization:`Bearer ${e.token}`},schema:jt,unknownErrorMessage:`Failed to load your profile`})}async function Nt(e){let{repo:t,token:n,host:r}=e,[i,a]=await Promise.all([Mt({token:n,host:r}),s({repo:t,token:n,host:r})]);return a.filter(e=>(e.kind===`prod`||e.kind===`stage`)&&e.users.some(e=>e.id===i.shortId))}var Pt=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(`
|
|
13
|
+
`);super(ge`
|
|
22
14
|
Environment "${e}" not found on repository "${n}".
|
|
23
15
|
|
|
24
16
|
Available environments:
|
|
25
17
|
${r}
|
|
26
|
-
`)}}},
|
|
18
|
+
`)}}},Ft=T({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 M(),{json:n,repo:r=t}=e,{token:i,host:a}=await W(),o=await Nt({repo:r,token:i,host:a}),s;if(r===t&&(s=await(await j()).getEnvironment()??t),n){let e=o.map(e=>({domain:e.domain,kind:e.kind,active:e.domain===s}));console.info(V(e));return}let c=o.map(e=>[e.domain,e.kind,e.domain===s?`*`:``]);console.info(A(c,{headers:[`DOMAIN`,`KIND`,`ACTIVE`]}))}),It=T({name:`prismic env set`,description:`Set the active environment.`,positionals:{environment:{description:`Environment domain`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await M(),{token:r,host:i}=await W(),a=await Nt({repo:n,token:r,host:i});if(!a.some(e=>e.domain===t))throw new Pt(t,a,n);let o=await j();if(t===n){await o.unsetEnvironment(),console.info(`Reset to the production environment "${n}".`);return}await o.setEnvironment(t),console.info(`Set the active environment to "${t}".`)}),Lt=T({name:`prismic env unset`,description:`Reset the active environment to the production environment.`},async()=>{let e=await M();await(await j()).unsetEnvironment(),console.info(`Reset to the production environment "${e}".`)}),Rt=_({name:`prismic env`,description:`
|
|
27
19
|
Manage the active environment for a Prismic project.
|
|
28
20
|
|
|
29
21
|
Run \`prismic docs view environments\` for details.
|
|
30
|
-
`,commands:{set:{handler:
|
|
22
|
+
`,commands:{set:{handler:It,description:`Set the active environment`},unset:{handler:Lt,description:`Reset to the production environment`},active:{handler:At,description:`Print the active environment`},list:{handler:Ft,description:`List environments`}}});const K={"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`}},zt={"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 Bt(t,n,r){let{variation:i=`default`}=r,{key:o,value:s}=e(r,[`from-slice`,`from-type`]),c=await j(),u,d,p;if(o===`from-slice`){let{model:e}=await c.getSlice(s);u=f(t,e,i),d=f(n,e,i),p=async()=>{await c.updateSlice(e),await c.generateTypes()}}else{let{model:e}=await c.getCustomType(s);u=l(t,e),d=l(n,e),p=async()=>{await c.updateCustomType(e),await c.generateTypes()}}if(!(u.fieldId in u.fields))throw new a(t);if(!(d.fieldId in d.fields))throw new a(n);return{source:u,anchor:d,save:p}}async function q(t,n){let{tab:r=`Main`,variation:i=`default`}=n,{key:a,value:o}=e(n,[`to-slice`,`to-type`]),s=a===`to-slice`?await Ut(t,o,i):await Wt(t,o,r);if(s.fieldId in s.fields)throw new b(t);return s}async function Vt(t,n){let{variation:r=`default`}=n,{key:i,value:o}=e(n,[`from-slice`,`from-type`]),s=i===`from-slice`?await Ut(t,o,r):await Wt(t,o),c=s.fields[s.fieldId];if(!c)throw new a(t);return{...s,field:c}}async function Ht(e,t){let n=await(await j()).getCustomTypes();return o(e,t,n.map(({model:e})=>e))}async function Ut(e,t,n){let r=await j(),{model:i}=await r.getSlice(t);return{...f(e,i,n),save:async()=>{await r.updateSlice(i),await r.generateTypes()}}}async function Wt(e,t,n){let r=await j(),{model:i}=await r.getCustomType(t);return{...l(e,i,n),save:async()=>{await r.updateCustomType(i),await r.generateTypes()}}}function J(e,t){if(e===void 0)return;let n=Number(e);if(Number.isNaN(n))throw new w(`--${t} must be a valid number, got "${e}"`);return n}function Gt(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 A(n)}const Kt={name:`prismic field add boolean`,description:`
|
|
31
23
|
Add a boolean field to a slice or custom type.
|
|
32
24
|
|
|
33
25
|
Run \`prismic docs view fields/boolean\` for details.
|
|
34
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
26
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,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 qt=T(Kt,async({positionals:e,values:t})=>{let[n]=e;re(t,[`default-true`,`default-false`]);let{label:r,"true-label":i,"false-label":a}=t,{fields:o,fieldId:s,save:c}=await q(n,t),l={type:`Boolean`,config:{label:r??E(s),default_value:!t[`default-false`]&&t[`default-true`],placeholder_true:i,placeholder_false:a}};O(o,s,l),await c(),console.info(`Field added: ${n}`)});const Jt={name:`prismic field add color`,description:`
|
|
35
27
|
Add a color field to a slice or custom type.
|
|
36
28
|
|
|
37
29
|
Run \`prismic docs view fields/color\` for details.
|
|
38
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
30
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Yt=T(Jt,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await q(n,t),c={type:`Color`,config:{label:r??E(o),placeholder:i}};O(a,o,c),await s(),console.info(`Field added: ${n}`)});const Xt={name:`prismic field add content-relationship`,description:`
|
|
39
31
|
Add a content relationship field to a slice or custom type.
|
|
40
32
|
|
|
41
33
|
Content relationships fetch and display data from related documents
|
|
@@ -66,31 +58,31 @@ import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
66
58
|
|
|
67
59
|
Fetch fields from the related document:
|
|
68
60
|
prismic field add content-relationship author --to-type blog_post --custom-type author --field name --field bio
|
|
69
|
-
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
61
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...K,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 Zt=T(Xt,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 w(`--field requires exactly one --custom-type.`);let{fields:s,fieldId:c,save:l}=await q(n,t),u=a;if(o&&a){let e=await Ht(o,a[0]);u=[{id:a[0],fields:e}]}let d={type:`Link`,config:{label:r??E(c),select:`document`,tags:i,customtypes:u}};O(s,c,d),await l(),console.info(`Field added: ${n}`)});const Qt={name:`prismic field add date`,description:`
|
|
70
62
|
Add a date field to a slice or custom type.
|
|
71
63
|
|
|
72
64
|
Run \`prismic docs view fields/date\` for details.
|
|
73
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
65
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var $t=T(Qt,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,default:a}=t,{fields:o,fieldId:s,save:c}=await q(n,t),l={type:`Date`,config:{label:r??E(s),placeholder:i,default:a}};O(o,s,l),await c(),console.info(`Field added: ${n}`)});const en={name:`prismic field add embed`,description:`
|
|
74
66
|
Add an embed field to a slice or custom type.
|
|
75
67
|
|
|
76
68
|
Run \`prismic docs view fields/embed\` for details.
|
|
77
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
69
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var tn=T(en,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await q(n,t),c={type:`Embed`,config:{label:r??E(o),placeholder:i}};O(a,o,c),await s(),console.info(`Field added: ${n}`)});const nn={name:`prismic field add geopoint`,description:`
|
|
78
70
|
Add a geopoint field to a slice or custom type.
|
|
79
71
|
|
|
80
72
|
Run \`prismic docs view fields/geopoint\` for details.
|
|
81
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
73
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,label:{type:`string`,description:`Field label`}}};var rn=T(nn,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await q(n,t),s={type:`GeoPoint`,config:{label:r??E(a)}};O(i,a,s),await o(),console.info(`Field added: ${n}`)});const an={name:`prismic field add group`,description:`
|
|
82
74
|
Add a group field to a slice or custom type.
|
|
83
75
|
|
|
84
76
|
Run \`prismic docs view fields/repeatable-group\` for details.
|
|
85
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
77
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,label:{type:`string`,description:`Field label`}}};var on=T(an,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await q(n,t),s={type:`Group`,config:{label:r??E(a)}};O(i,a,s),await o(),console.info(`Field added: ${n}`)});const sn={name:`prismic field add image`,description:`
|
|
86
78
|
Add an image field to a slice or custom type.
|
|
87
79
|
|
|
88
80
|
Run \`prismic docs view fields/image\` for details.
|
|
89
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
81
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var cn=T(sn,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await q(n,t),c={type:`Image`,config:{label:r??E(o),placeholder:i}};O(a,o,c),await s(),console.info(`Field added: ${n}`)});const ln={name:`prismic field add integration`,description:`
|
|
90
82
|
Add an integration field to a slice or custom type.
|
|
91
83
|
|
|
92
84
|
Run \`prismic docs view fields/integration\` for details.
|
|
93
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
85
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},catalog:{type:`string`,description:`Integration catalog ID`}}};var un=T(ln,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,catalog:a}=t,{fields:o,fieldId:s,save:c}=await q(n,t),l={type:`IntegrationFields`,config:{label:r??E(s),placeholder:i,catalog:a}};O(o,s,l),await c(),console.info(`Field added: ${n}`)});const dn={name:`prismic field add link`,description:`
|
|
94
86
|
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.
|
|
95
87
|
|
|
96
88
|
Run \`prismic docs view fields/link\` for details.
|
|
@@ -106,11 +98,11 @@ import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
106
98
|
|
|
107
99
|
Allow any link type, but restrict document links to a type:
|
|
108
100
|
prismic field add link cta --to-type landing_page --custom-type page
|
|
109
|
-
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
101
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...K,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 fn=T(dn,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 w(`--allow accepts a single link type. Prismic links allow either one type or all types.`);if(a&&!r.includes(a))throw new w(`--allow must be one of: ${r.join(`, `)}`);let d=a;if(u&&(d===`media`||d===`web`))throw new w(`--custom-type cannot be used with --allow ${d}`);let{fields:f,fieldId:p,save:m}=await q(n,t),h={type:`Link`,config:{label:i??E(p),select:d,allowTargetBlank:o,allowText:s,repeat:c,variants:l,customtypes:u}};O(f,p,h),await m(),console.info(`Field added: ${n}`)});const pn={name:`prismic field add number`,description:`
|
|
110
102
|
Add a number field to a slice or custom type.
|
|
111
103
|
|
|
112
104
|
Run \`prismic docs view fields/number\` for details.
|
|
113
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
105
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,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 mn=T(pn,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,a=J(t.min,`min`),o=J(t.max,`max`),s=J(t.step,`step`),{fields:c,fieldId:l,save:u}=await q(n,t),d={type:`Number`,config:{label:r??E(l),placeholder:i,min:a,max:o,step:s}};O(c,l,d),await u(),console.info(`Field added: ${n}`)});const hn={name:`prismic field add rich-text`,description:`
|
|
114
106
|
Add a rich text field to a slice or custom type.
|
|
115
107
|
|
|
116
108
|
Run \`prismic docs view fields/rich-text\` for details.
|
|
@@ -124,7 +116,7 @@ import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
124
116
|
|
|
125
117
|
Add a body field with only headings and paragraphs:
|
|
126
118
|
prismic field add rich-text body --to-type blog_post --allow heading1,heading2,paragraph,strong,em,hyperlink
|
|
127
|
-
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
119
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...K,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 gn=T(hn,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 q(n,t),f={type:`StructuredText`,config:{label:r??E(u),placeholder:i,...o?{single:a}:{multi:a},labels:s?.split(`,`).map(e=>e.trim()).filter(Boolean),allowTargetBlank:c}};O(l,u,f),await d(),console.info(`Field added: ${n}`)});const _n={name:`prismic field add select`,description:`
|
|
128
120
|
Add a select field to a slice or custom type.
|
|
129
121
|
|
|
130
122
|
Run \`prismic docs view fields/select\` for details.
|
|
@@ -134,11 +126,11 @@ import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
134
126
|
|
|
135
127
|
With a default value:
|
|
136
128
|
prismic field add select layout --to-type landing_page --option full --option centered --option sidebar --default-value full
|
|
137
|
-
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
129
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...K,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 vn=T(_n,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 q(n,t),u={type:`Select`,config:{label:r??E(c),placeholder:i,default_value:a,options:o}};O(s,c,u),await l(),console.info(`Field added: ${n}`)});const yn={name:`prismic field add table`,description:`
|
|
138
130
|
Add a table field to a slice or custom type.
|
|
139
131
|
|
|
140
132
|
Run \`prismic docs view fields/table\` for details.
|
|
141
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
133
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,label:{type:`string`,description:`Field label`}}};var bn=T(yn,async({positionals:e,values:t})=>{let[n]=e,{label:r}=t,{fields:i,fieldId:a,save:o}=await q(n,t),s={type:`Table`,config:{label:r??E(a)}};O(i,a,s),await o(),console.info(`Field added: ${n}`)});const xn={name:`prismic field add text`,description:`
|
|
142
134
|
Add a text field to a slice or custom type.
|
|
143
135
|
|
|
144
136
|
A text field holds a short plain string with no formatting.
|
|
@@ -149,15 +141,15 @@ import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
149
141
|
prismic field add rich-text title --to-type blog_post --allow heading1 --single
|
|
150
142
|
|
|
151
143
|
Run \`prismic docs view fields/text\` for details.
|
|
152
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
144
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var Sn=T(xn,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i}=t,{fields:a,fieldId:o,save:s}=await q(n,t),c={type:`Text`,config:{label:r??E(o),placeholder:i}};O(a,o,c),await s(),console.info(`Field added: ${n}`)});const Cn={name:`prismic field add timestamp`,description:`
|
|
153
145
|
Add a timestamp field to a slice or custom type.
|
|
154
146
|
|
|
155
147
|
Run \`prismic docs view fields/timestamp\` for details.
|
|
156
|
-
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
148
|
+
`,positionals:{id:{description:`Field ID`,required:!0}},options:{...K,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},default:{type:`string`,description:`Default value`}}};var wn=T(Cn,async({positionals:e,values:t})=>{let[n]=e,{label:r,placeholder:i,default:a}=t,{fields:o,fieldId:s,save:c}=await q(n,t),l={type:`Timestamp`,config:{label:r??E(s),placeholder:i,default:a}};O(o,s,l),await c(),console.info(`Field added: ${n}`)});const Tn={name:`prismic field add uid`,description:`
|
|
157
149
|
Add a UID field to a content type.
|
|
158
150
|
|
|
159
151
|
Run \`prismic docs view fields/uid\` for details.
|
|
160
|
-
`,options:{"to-type":
|
|
152
|
+
`,options:{"to-type":K[`to-type`],tab:K.tab,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`}}};var En=T(Tn,async({values:e})=>{let{label:t=`UID`,placeholder:n}=e,{fields:r,fieldId:i,save:a}=await q(`uid`,e);O(r,i,{type:`UID`,config:{label:t,placeholder:n}}),await a(),console.info(`Field added: uid`)}),Dn=_({name:`prismic field add`,description:`
|
|
161
153
|
Add a field to a slice or custom type.
|
|
162
154
|
|
|
163
155
|
Run \`prismic docs view fields\` for details.
|
|
@@ -167,7 +159,7 @@ import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
167
159
|
prismic field add text my_group.description --to-type blog_post
|
|
168
160
|
|
|
169
161
|
The group must already exist. Only one level of nesting is supported.
|
|
170
|
-
`},commands:{boolean:{handler:
|
|
162
|
+
`},commands:{boolean:{handler:qt,description:`Add a boolean field`},color:{handler:Yt,description:`Add a color field`},"content-relationship":{handler:Zt,description:`Add a content relationship field for fetching data from related documents (not for navigation -- use link)`},date:{handler:$t,description:`Add a date field`},embed:{handler:tn,description:`Add an embed field`},geopoint:{handler:rn,description:`Add a geopoint field`},group:{handler:on,description:`Add a group field`},image:{handler:cn,description:`Add an image field`},integration:{handler:un,description:`Add an integration field`},link:{handler:fn,description:`Add a link field for URLs, documents, or media (navigational)`},number:{handler:mn,description:`Add a number field`},"rich-text":{handler:gn,description:`Add a rich text field`},select:{handler:vn,description:`Add a select field`},table:{handler:bn,description:`Add a table field`},text:{handler:Sn,description:`Add a text field for short plain strings (not for titles or headings -- use rich-text --allow heading1 --single)`},timestamp:{handler:wn,description:`Add a timestamp field`},uid:{handler:En,description:`Add a UID field`}}});const On={name:`prismic field edit`,description:`Edit an existing field in a slice or custom type.`,sections:{"FIELD TYPE OPTIONS":`
|
|
171
163
|
Options vary by field type. Only options matching the field's
|
|
172
164
|
type will be applied. See \`prismic field add <type> --help\`
|
|
173
165
|
for type-specific option details.
|
|
@@ -180,38 +172,38 @@ import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
180
172
|
|
|
181
173
|
Restrict a rich text field to a single block:
|
|
182
174
|
prismic field edit subtitle --from-type blog_post --single
|
|
183
|
-
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...
|
|
175
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...zt,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 kn=T(On,async({positionals:e,values:t})=>{let[n]=e,{field:r,save:i}=await Vt(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`:re(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=J(t.min,`min`)),`max`in t&&(r.config.max=J(t.max,`max`)),`step`in t&&(r.config.step=J(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 w(`--allow accepts a single link type. Prismic links allow either one type or all types.`);else throw new w(`--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 w(`--field requires the field to be restricted to a custom type. Use --custom-type to specify one.`);if(e.length>1)throw new w(`--field requires the field to be restricted to a single custom type.`);let[n]=e,i=typeof n==`string`?n:n.id,a=await Ht(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 w(`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}`)}),An=T({name:`prismic field remove`,description:`Remove a field from a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:zt},async({positionals:e,values:t})=>{let[n]=e,{fields:r,fieldId:i,save:a}=await Vt(n,t);delete r[i],await a(),console.info(`Field removed: ${n}`)});const jn={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`},...zt}};var Mn=T(jn,async({positionals:t,values:n})=>{let[r]=t,{key:i,value:a}=e(n,[`before`,`after`]);if(r===a)throw new w(`Cannot reorder "${r}" relative to itself.`);if(r.split(`.`).slice(0,-1).join(`.`)!==a.split(`.`).slice(0,-1).join(`.`))throw new w(`Cannot reorder "${r}" relative to "${a}": fields must be in the same container.`);let{source:o,anchor:s,save:c}=await Bt(r,a,n);if(o.fields!==s.fields&&o.fieldId in s.fields)throw new b(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)i===`before`&&e===s.fieldId&&(s.fields[o.fieldId]=l),s.fields[e]=t,i===`after`&&e===s.fieldId&&(s.fields[o.fieldId]=l);await c(),console.info(`Field reordered: ${r}`)});const Nn={name:`prismic field view`,description:`View details of a field in a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:{...zt,json:{type:`boolean`,description:`Output as JSON`}}};var Pn=T(Nn,async({positionals:e,values:t})=>{let[n]=e,{field:r,fieldId:i}=await Vt(n,t);if(t.json){console.info(V({id:i,...r}));return}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)?`${E(e)}: ${t.join(`, `)}`:`${E(e)}: ${t}`)}}}),Fn=_({name:`prismic field`,description:`
|
|
184
176
|
Manage fields in slices and content types.
|
|
185
177
|
|
|
186
178
|
Run \`prismic docs view fields\` for details.
|
|
187
|
-
`,commands:{add:{handler:
|
|
179
|
+
`,commands:{add:{handler:Dn,description:`Add a field`},edit:{handler:kn,description:`Edit a field`},remove:{handler:An,description:`Remove a field`},reorder:{handler:Mn,description:`Reorder a field`},view:{handler:Pn,description:`View details of a field`}}}),In=T({name:`prismic gen page`,description:`
|
|
188
180
|
Generate the page files for a page type.
|
|
189
181
|
|
|
190
182
|
Uses the type's route in prismic.config.json. Existing files are not
|
|
191
183
|
changed: their generated code is printed instead.
|
|
192
|
-
`,positionals:{"type-id":{description:`ID of the page type`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await
|
|
184
|
+
`,positionals:{"type-id":{description:`ID of the page type`,required:!0}}},async({positionals:e})=>{let[t]=e,n=await j(),{model:r}=await n.getCustomType(t);if(r.format!==`page`)throw new w(`"${t}" is not a page type.`);let{routes:i=[]}=await y(),a=!ye(i,t)&&i.find(e=>e.type===t&&!e.uid);a&&console.info(`The route ${a.path} has optional or repeated params, so the page uses the default path ${ae(r)}. Move it to match the route.\n`);let o=await n.writePageFiles(r);if(o.length===0){console.info(`Generated the page for "${t}".`);return}let s=await D();for(let e of o){let t=H(s,e.path);console.info(`${t} already exists. Generated code:\n\n${e.contents}`),console.info(`Merge this into ${t}.\n`)}}),Ln=T({name:`prismic gen setup`,description:`
|
|
193
185
|
Generate framework-specific setup files for a Prismic project.
|
|
194
186
|
|
|
195
187
|
Installs dependencies, creates the Prismic client file, slice simulator
|
|
196
188
|
page, preview routes, and other files required by the detected framework.
|
|
197
189
|
Skips files that already exist.
|
|
198
|
-
`,options:{"no-install":{type:`boolean`,description:`Skip installing dependencies`}}},async({values:e})=>{let t=await
|
|
199
|
-
`);await fetch(
|
|
200
|
-
`).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
|
|
190
|
+
`,options:{"no-install":{type:`boolean`,description:`Skip installing dependencies`}}},async({values:e})=>{let t=await j(),n=await G();await t.setupProject();for(let{name:e,from:t,to:r}of $e(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 rt()}catch{console.warn(`Could not install dependencies. Run \`${await tt()}\` to finish.\nThe rest of the setup is done.`)}console.info(`Generated setup files.`);let r=await t.getSetupInstructions();r&&console.info(`\n${r}`)}),Rn=T({name:`prismic gen slice-index`,description:`Generate the slice index file of each slice library.`},async()=>{let e=await j(),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.`)}),zn=T({name:`prismic gen types`,description:`Generate TypeScript types for slices and content types.`},async()=>{let e=await(await j()).generateTypes(),t=await D(),n=H(t,e);console.info(`Generated types at ${n}`)}),Bn=_({name:`prismic gen`,description:`Generate files from local Prismic models.`,commands:{page:{handler:In,description:`Generate the page files for a page type`},setup:{handler:Ln,description:`Generate framework-specific Prismic setup`},"slice-index":{handler:Rn,description:`Generate the slice index file of each slice library`},types:{handler:zn,description:`Generate TypeScript types from local models`}}});function Vn(e){let t=process.platform===`darwin`?`open`:process.platform===`win32`?`start ""`:`xdg-open`;mt(`${t} "${e.toString()}"`)}const Hn=R({id:F(),revision:F(),framework:F(),deploymentUrl:Oe()}),Un=R({name:P(F()),starter:Ie(Hn),framework:P(F()),quotas:P(R({sliceMachineEnabled:N()}))});function Wn(e){return Yn(Zn(e.host),e,{schema:Un})}async function Gn(e,t){await Yn(new URL(`type-builder`,Zn(t.host)),t,{method:`PATCH`,json:{framework:e}})}const Kn=R({completedSteps:I(F())});async function qn(e){return Xn(new URL(`onboarding`,Zn(e.host)),e,{schema:Kn})}async function Jn(e,t){return Xn(new URL(`onboarding/${encodeURIComponent(e)}/toggle`,Zn(t.host)),t,{method:`PATCH`,schema:Kn})}function Yn(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 Xn(e,t,n={}){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),B(r,{credentials:{"prismic-auth":t.token},...n})}function Zn(e){return new URL(`https://api.internal.${e}/repository/`)}async function Qn(e,t){let{repo:n,token:r,host:i}=t,{completedSteps:a}=await qn({repo:n,token:r,host:i}),o=e.filter(e=>!a.includes(e));for(let e of o)await Jn(e,{repo:n,token:r,host:i})}let Y;const X={tags:{},contexts:{}};function $n(e){Y=e,X.contexts.Process={command:process.argv.join(` `),cwd:process.cwd()}}function er(e,t){X.tags[e]=t}function tr(e,t){X.contexts[e]=t}function nr(e){X.user=e}async function rr(e){if(Y)try{let t=new URL(Y.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:Y.appVersion,environment:Y.environment||ir(Y.appVersion),tags:X.tags,user:X.user,contexts:{...X.contexts,runtime:{name:`node`,version:process.versions.node}},exception:{values:[{type:n.name,value:n.message.slice(0,2500),stacktrace:or(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(`
|
|
191
|
+
`);await fetch(ar(t),{method:`POST`,headers:{"Content-Type":`application/x-sentry-envelope`,"X-Sentry-Auth":`Sentry sentry_version=7, sentry_client=${Y.appName}/${Y.appVersion}, sentry_key=${t.username}`},body:a,signal:AbortSignal.timeout(2e3)})}catch{}}function ir(e){let t=e.match(/-(.+?)\./);return t?t[1]:`production`}function ar(e){return`${e.protocol}//${e.host}/api${e.pathname}/envelope/`}function or(e){let t=[];for(let n of(e.stack??``).split(`
|
|
192
|
+
`).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 sr=R({id:F(),label:F(),customName:Ae(F()),isMaster:N()});async function cr(e){return(await dr(new URL(`repository/locales`,fr(e.host)),e,{schema:R({results:I(sr)}),unknownErrorMessage:`Failed to load locales`})).results}async function lr(e,t){return dr(new URL(`repository/locales`,fr(t.host)),t,{method:`POST`,json:{id:e.id,isMaster:e.isMaster??!1,...e.customName?{customName:e.customName}:{}},schema:sr,unknownErrorMessage:`Failed to save locale`})}async function ur(e,t){await dr(new URL(`repository/locales/${encodeURIComponent(e)}`,fr(t.host)),t,{method:`DELETE`,notFoundMessage:`Locale not found: ${e}`,unknownErrorMessage:`Failed to remove locale`})}function dr(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 fr(e){return new URL(`https://api.internal.${e}/locale/`)}async function pr(e){await mr(new URL(`activation`,hr(e.host)),e,{method:`POST`})}function mr(e,t,n={}){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),B(r,{credentials:{"prismic-auth":t.token},...n})}function hr(e){return new URL(`https://api.internal.${e}/mcp/`)}const gr=R({documentsPublished:N(),documentsUnpublished:N(),releasesCreated:N(),releasesUpdated:N(),tagsCreated:N(),tagsDeleted:N()}),_r=Object.keys(gr.shape),vr=R({config:ze(gr,{_id:F(),url:F(),active:N(),name:Ae(F()),secret:Ae(F()),headers:ke(F(),F())})});function Z(e){let{repo:t,host:n}=e;return Q(new URL(`app/settings/webhooks`,$(t,n)),e,{schema:I(vr),unknownErrorMessage:`Failed to load webhooks`})}async function yr(e,t){let n=Sr({...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 br(e,t,n){let r=Sr(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 xr(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 Sr(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 Cr=R({id:F(),scope:F(),token:F(),created_at:R({$date:Ce()})}),wr=R({id:F(),name:F(),wroom_auths:I(Cr)}),Tr=R({app_name:F(),token:F(),timestamp:Ce()}),Er=R({max_tokens:Ce(),tokens:I(Tr)});function Dr(e){let{repo:t,host:n}=e;return Q(new URL(`settings/security/contentapi`,$(t,n)),e,{schema:I(wr),unknownErrorMessage:`Failed to load OAuth apps`})}async function Or(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:wr,unknownErrorMessage:`Failed to create OAuth app`})}async function kr(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:Cr,unknownErrorMessage:`Failed to create token`})}async function Ar(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 jr(e){let{repo:t,host:n}=e;return Q(new URL(`settings/security/customtypesapi`,$(t,n)),e,{schema:Er,unknownErrorMessage:`Failed to load write tokens`})}async function Mr(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:Tr,unknownErrorMessage:`Failed to create write token`})}async function Nr(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 Pr(e){let{domain:t,host:n}=e;return Vr(new URL(`app/dashboard/repositories/${encodeURIComponent(t)}/exists`,Hr(n)),e,{schema:N()})}async function Fr(e){let{domain:t,name:n,framework:r,agent:i,host:a}=e,o=new URL(`app/dashboard/repositories`,Hr(a));o.searchParams.set(`app`,`cli`),i&&o.searchParams.set(`agent`,i),await Vr(o,e,{method:`POST`,json:{domain:t,name:n,framework:r,plan:`personal`},unknownErrorMessage:`Failed to create repository`})}const Ir=R({repository:R({api_access:F()})});async function Lr(e){let{repo:t,host:n}=e;return(await Q(new URL(`syncState`,$(t,n)),e,{schema:Ir,unknownErrorMessage:`Failed to load repository access`})).repository.api_access}async function Rr(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 zr=R({repository:R({name:F()})});async function Br(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:zr,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 Vr(e,t,n={}){return B(e,{credentials:{"prismic-auth":t.token},...n})}function $(e,t){return new URL(`https://${e}.${t}/`)}function Hr(e){return new URL(`https://${e}/`)}const Ur={name:`prismic repo create`,description:`
|
|
201
193
|
Create a new Prismic repository.
|
|
202
194
|
|
|
203
195
|
The CLI generates a random domain, shown in the output. The domain cannot
|
|
204
196
|
be chosen or changed. --name sets only the display name, which
|
|
205
197
|
\`prismic repo set-name\` can change later.
|
|
206
|
-
`,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: ${
|
|
198
|
+
`,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: ${ue.join(`, `)} (default: detected from the project)`}}};var Wr=T(Ur,async({values:e})=>{let t=await j().catch(()=>void 0),{name:n,lang:r,framework:i=t?.id}=e;if(!i)throw new w(`
|
|
207
199
|
No supported framework found. The CLI needs a Next.js, Nuxt, or SvelteKit project to work with a repository.
|
|
208
200
|
|
|
209
201
|
Do one of the following:
|
|
210
202
|
- Run this command inside an existing Next.js, Nuxt, or SvelteKit project.
|
|
211
203
|
- Create the project first, then run \`prismic init\` to create and connect a repository.
|
|
212
|
-
- Pass --framework <${
|
|
204
|
+
- Pass --framework <${ue.join(`|`)}> to create the repository now.
|
|
213
205
|
You still need a compatible project to use it. Connect one later with \`prismic init --repo <domain>\`.
|
|
214
|
-
`);if(!
|
|
206
|
+
`);if(!ue.includes(i))throw new w(`Unsupported framework "${i}". Use one of: ${ue.join(`, `)}.`);let{token:a,host:o}=await W(),s=await Gr({name:n,lang:r,framework:i,token:a,host:o});console.info(`Repository created: ${s}`),console.info(`URL: https://${s}.${o}/`)});async function Gr(e){let{name:t,lang:n=`en-us`,framework:r,token:i,host:a}=e,o=await Kr({token:i,host:a});if(!o)throw new w(`Failed to create a repository. Please try again.`);let s=Ke();return await Fr({domain:o,name:t??o,framework:r,agent:s,token:i,host:a}),await lr({id:n,isMaster:!0},{repo:o,token:i,host:a}),await Qn([`createPrismicProject`],{repo:o,token:i,host:a}).catch(()=>{}),await pr({repo:o,token:i,host:a}).catch(()=>{}),o}async function Kr(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 Pr({domain:e,token:t,host:n})){r=e;break}}return r}var qr=T({name:`prismic init`,description:`
|
|
215
207
|
Initialize a new Prismic project by creating a repository and
|
|
216
208
|
prismic.config.json file. Detects the project framework, installs
|
|
217
209
|
dependencies, and pulls models from Prismic. The CLI generates a random
|
|
@@ -222,70 +214,70 @@ import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
222
214
|
migrated.
|
|
223
215
|
|
|
224
216
|
Run \`prismic docs view cli#set-up-a-type-builder-project\` for details.
|
|
225
|
-
`,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})=>{
|
|
226
|
-
This project is already set up for Prismic (repository: ${
|
|
217
|
+
`,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})=>{re(e,[`repo`,`repo-name`]);let{repo:t,lang:n,"no-browser":i,"no-setup":a}=e,o;try{o=await y()}catch(e){if(!(e instanceof fe))throw e}if(o&&!t)throw new w(`
|
|
218
|
+
This project is already set up for Prismic (repository: ${o.repositoryName}).
|
|
227
219
|
|
|
228
220
|
Do one of the following:
|
|
229
221
|
- Run \`prismic gen setup\` to add missing framework files and install dependencies.
|
|
230
222
|
- Run \`prismic init --repo <domain>\` to connect the project to a different repository.
|
|
231
|
-
`);let
|
|
223
|
+
`);let s=o!==void 0&&t!==void 0,c;if(!o)try{c=await r()}catch(e){e instanceof ne&&console.warn(`Could not read slicemachine.config.json, ignoring.`)}let{host:l,token:u}=await W(),d=u;try{await Mt({token:d,host:l})}catch(e){if(e instanceof Fe||e instanceof z){if(U.PRISMIC_TOKEN)throw new w(`PRISMIC_TOKEN is invalid or expired. Unset it to log in with a browser, or replace it with a valid token.`);console.info(`Not logged in. Starting login...`);let{email:e}=await qe({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}`),Vn(e))}});console.info(`Logged in as ${e}`),d=(await W()).token}else throw e}let f=(t??c?.repositoryName)?.toLowerCase(),h;f&&(h=await Wn({repo:f,token:d,host:l}).catch(e=>{throw e instanceof z?new w(`Repository "${f}" not found in your account. Check the name or request access to the repository.`):e}));let _;try{_=await j()}catch(e){throw e instanceof oe||e instanceof it?new w(`
|
|
232
224
|
No supported framework found. \`prismic init\` needs a Next.js, Nuxt, or SvelteKit project.
|
|
233
225
|
|
|
234
226
|
Do one of the following:
|
|
235
227
|
- Run this command inside an existing Next.js, Nuxt, or SvelteKit project.
|
|
236
228
|
- Create the project first, then run \`prismic init\` again.
|
|
237
|
-
- To create the repository now, run \`prismic repo create --framework <${
|
|
229
|
+
- To create the repository now, run \`prismic repo create --framework <${ue.join(`|`)}>\`.
|
|
238
230
|
Connect the project later with \`prismic init --repo <domain>\`.
|
|
239
|
-
`):e}h||(
|
|
231
|
+
`):e}let v=U.PRISMIC_TYPE_BUILDER_ENABLED??h?.quotas?.sliceMachineEnabled;if(f&&h&&(!v||h.framework!==_.id))try{await Gn(_.id,{repo:f,token:d,host:l}),v||console.info(`Turned on the Type Builder for repository "${f}".`)}catch(e){if(!(e instanceof z))throw e;if(!v)throw new w(`Repository "${f}" 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\`.`)}f||(f=await Gr({name:e[`repo-name`],lang:n,framework:_.id,token:d,host:l}),console.info(`Created repository: ${f}`));try{let e=l===`prismic.io`?void 0:`https://${f}.cdn.${l}/api/v2/`;o?await ve({repositoryName:f,documentAPIEndpoint:e}):await te({repositoryName:f,documentAPIEndpoint:e,libraries:c?.libraries,routes:[]})}catch(e){throw e instanceof le?new w(`Could not find a package.json file. Run this command from a project directory.`):new w(`Failed to create prismic.config.json.`)}if(c){try{await _e()}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 nt(r),console.info(`Migrated slicemachine.config.json to prismic.config.json`)}let b=await G();await _.initProject({setup:!a&&!o});for(let{name:e,from:t,to:n}of $e(b,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 rt()}catch{console.warn(`Could not install dependencies. Run \`${await tt()}\` 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([g({repo:f,token:d,host:l}),_.getModels()]),C=p(x,S);if(s&&h?.starter){if(x.customTypes.length===0&&x.slices.length===0)throw new w(`Repository "${f}" has no starter models. Use a repository created from the starter in the Prismic dashboard.`);await Xr(h.starter)}let ee=s&&[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(),m(x.customTypes).length>0&&console.info("\nRun `prismic slice list --legacy` to find legacy slices to upgrade."),ee&&console.warn(ge`
|
|
240
232
|
Local and remote models differ, so no model files were changed. The project is connected.
|
|
241
233
|
|
|
242
234
|
Choose the source of truth:
|
|
243
235
|
prismic pull --force Adopt remote models
|
|
244
236
|
prismic push --force Keep local models
|
|
245
|
-
`),
|
|
237
|
+
`),s&&h?.starter?(await Yr(_,h.starter,{repo:f,token:d,host:l}),ee||(console.info(`
|
|
246
238
|
---`),console.info(`
|
|
247
|
-
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://${
|
|
239
|
+
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://${f}.${l}/builder to preview pages live`),console.info(`
|
|
248
240
|
Start building 🚀`))):(console.info(`
|
|
249
|
-
---`),console.info(`\nInitialized Prismic for repository "${
|
|
241
|
+
---`),console.info(`\nInitialized Prismic for repository "${f}".`),console.info("Run `prismic type create <name>` to create a content type."),console.info("Run `prismic pull` to pull models from Prismic."));let T=await _.getSetupInstructions();T&&console.info(`\n${T}`)});async function Jr(e){let t=await G(),n=e.id.split(`/`).at(-1);return!!(n&&t.name===n)}async function Yr(e,t,n){try{let t=await d(n);await Promise.all(t.filter(e=>e.label===`Starter Preview`).map(e=>u(e.id,n))),t.some(t=>t.url===e.localPreviewUrl)||await x(e.localPreviewConfig,n)}catch(t){await rr(t),console.error(`Could not configure the local preview. Run \`prismic preview add ${e.localPreviewUrl} --name ${e.localPreviewConfig.name}\` manually. Continuing.`)}try{await ee(e.localSimulatorUrl,n)}catch(t){await rr(t),console.error(`Could not configure the local slice simulator. Run \`prismic preview set-simulator ${e.localSimulatorUrl}\` manually. Continuing.`)}await Qn([`instantStart_continueBuildingLocally`],n).catch(()=>{}),await Jr(t)&&await at(n.repo)}async function Xr(e){if(!await Jr(e))return;let t=await D();await Promise.all([ut(new URL(`.deployment`,t),{recursive:!0,force:!0}),ut(new URL(`documents`,t),{recursive:!0,force:!0})])}var Zr=T({name:`prismic locale add`,description:`
|
|
250
242
|
Add a locale to a Prismic repository.
|
|
251
243
|
|
|
252
244
|
By default, this command reads the repository from prismic.config.json at the
|
|
253
245
|
project root.
|
|
254
|
-
`,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
|
|
246
|
+
`,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 k(),master:a=!1,name:o}=t,{token:s,host:c}=await W();await lr({id:n,isMaster:a,customName:o},{repo:i,token:s,host:c}),console.info(`Locale added: ${n}`)}),Qr=T({name:`prismic locale list`,description:`
|
|
255
247
|
List all locales in a Prismic repository.
|
|
256
248
|
|
|
257
249
|
By default, this command reads the repository from prismic.config.json at the
|
|
258
250
|
project root.
|
|
259
|
-
`,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
|
|
251
|
+
`,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 k(),json:r}=e,{token:i,host:a}=await W(),o=await cr({repo:n,token:i,host:a});if(r){console.info(V(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(A(s,{headers:[`ID`,`LABEL`]}))}),$r=T({name:`prismic locale remove`,description:`
|
|
260
252
|
Remove a locale from a Prismic repository.
|
|
261
253
|
|
|
262
254
|
By default, this command reads the repository from prismic.config.json at the
|
|
263
255
|
project root.
|
|
264
|
-
`,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
|
|
256
|
+
`,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 k()}=t,{token:a,host:o}=await W();await ur(n,{repo:i,token:a,host:o}),console.info(`Locale removed: ${n}`)}),ei=T({name:`prismic locale set-master`,description:`
|
|
265
257
|
Set the master locale for a Prismic repository.
|
|
266
258
|
|
|
267
259
|
By default, this command reads the repository from prismic.config.json at the
|
|
268
260
|
project root.
|
|
269
|
-
`,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
|
|
261
|
+
`,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 k()}=t,{token:a,host:o}=await W(),s=await cr({repo:i,token:a,host:o}),c=s.find(e=>e.id===n);if(!c)throw new w(`Locale "${n}" not found. Available locales: ${s.map(e=>e.id).join(`, `)}`);if(c.isMaster)throw new w(`Locale "${n}" is already the master.`);await lr({id:c.id,isMaster:!0,customName:c.customName??void 0},{repo:i,token:a,host:o}),console.info(`Master locale set: ${n}`)}),ti=_({name:`prismic locale`,description:`
|
|
270
262
|
Manage locales in a Prismic repository.
|
|
271
263
|
|
|
272
264
|
Run \`prismic docs view locales\` for details.
|
|
273
|
-
`,commands:{add:{handler:
|
|
265
|
+
`,commands:{add:{handler:Zr,description:`Add a locale`},list:{handler:Qr,description:`List locales`},remove:{handler:$r,description:`Remove a locale`},"set-master":{handler:ei,description:`Set the master locale`}}}),ni=T({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 qe({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}`),Vn(e))}});console.info(`Logged in to Prismic as ${n}`)}),ri=T({name:`prismic logout`,description:`Log out of Prismic.`},async()=>{if(await We())console.info(`Logged out of Prismic`);else throw new w(`Logout failed. You can log out manually by deleting the file.`)}),ii=T({name:`prismic preview add`,description:`
|
|
274
266
|
Add a preview configuration to a Prismic repository.
|
|
275
267
|
|
|
276
268
|
By default, this command reads the repository from prismic.config.json at the
|
|
277
269
|
project root.
|
|
278
|
-
`,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
|
|
270
|
+
`,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 k(),name:a}=t,o;try{o=new URL(n)}catch{throw new w(`Invalid URL: ${n}`)}let s=a||o.hostname,c=`${o.protocol}//${o.host}`,l=o.pathname===`/`?void 0:o.pathname,{token:u,host:d}=await W();await x({name:s,websiteURL:c,resolverPath:l},{repo:i,token:u,host:d}),console.info(`Preview added: ${n}`),console.info("Run `prismic preview set-simulator <url>` to set the slice simulator URL.");try{let e=await(await j()).getSetupInstructions();e&&console.info(`\n${e}`)}catch(e){if(!(e instanceof oe||e instanceof it))throw e}}),ai=T({name:`prismic preview list`,description:`
|
|
279
271
|
List all preview configurations in a Prismic repository.
|
|
280
272
|
|
|
281
273
|
By default, this command reads the repository from prismic.config.json at the
|
|
282
274
|
project root.
|
|
283
|
-
`,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
|
|
275
|
+
`,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 k(),json:r}=e,{token:i,host:a}=await W(),[o,s]=await Promise.all([d({repo:n,token:i,host:a}),pe({repo:n,token:i,host:a})]);if(r){console.info(V({previews:o,simulatorUrl:s??null}));return}if(o.length===0&&!s){console.info(`No preview configurations found.`);return}if(o.length>0){let e=o.map(e=>[e.url,e.label]);console.info(A(e,{headers:[`URL`,`NAME`]}))}s&&(o.length>0&&console.info(``),console.info(`Simulator: ${s}`))}),oi=T({name:`prismic preview remove`,description:`
|
|
284
276
|
Remove a preview configuration from a Prismic repository.
|
|
285
277
|
|
|
286
278
|
By default, this command reads the repository from prismic.config.json at the
|
|
287
279
|
project root.
|
|
288
|
-
`,positionals:{url:{description:`Preview URL to remove`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
280
|
+
`,positionals:{url:{description:`Preview URL to remove`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository or environment domain`},env:{type:`string`,short:`e`,description:`Alias for --repo`,deprecated:"Use `prismic env` or --repo instead."}}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await k()}=t,{token:a,host:o}=await W(),s=(await d({repo:i,token:a,host:o})).find(e=>e.url===n);if(!s)throw new w(`Preview not found: ${n}`);await u(s.id,{repo:i,token:a,host:o}),console.info(`Preview removed: ${n}`)}),si=T({name:`prismic preview set-simulator`,description:`
|
|
289
281
|
Set the slice simulator URL for a Prismic repository.
|
|
290
282
|
|
|
291
283
|
If the URL pathname does not end with /slice-simulator, it is appended
|
|
@@ -293,7 +285,7 @@ Start building 🚀`))):(console.info(`
|
|
|
293
285
|
|
|
294
286
|
By default, this command reads the repository from prismic.config.json at the
|
|
295
287
|
project root.
|
|
296
|
-
`,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
|
|
288
|
+
`,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 k()}=t,a;try{a=new URL(n)}catch{throw new w(`Invalid URL: ${n}`)}a.pathname.endsWith(`/slice-simulator`)||(a.pathname=a.pathname.replace(/\/+$/,``)+`/slice-simulator`);let o=a.toString(),{token:s,host:c}=await W();await ee(o,{repo:i,token:s,host:c}),console.info(`Simulator URL set: ${o}`)}),ci=_({name:`prismic preview`,description:`
|
|
297
289
|
Manage previews in a Prismic repository.
|
|
298
290
|
|
|
299
291
|
Run \`prismic docs view previews\` for details.
|
|
@@ -301,15 +293,15 @@ Start building 🚀`))):(console.info(`
|
|
|
301
293
|
Set up previews after a deploy, using both settings:
|
|
302
294
|
prismic preview add https://example.com/api/preview
|
|
303
295
|
prismic preview set-simulator https://example.com
|
|
304
|
-
`},commands:{add:{handler:
|
|
305
|
-
`)){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
|
|
296
|
+
`},commands:{add:{handler:ii,description:`Add a preview URL`},list:{handler:ai,description:`List preview URLs and the simulator URL`},remove:{handler:oi,description:`Remove a preview URL`},"set-simulator":{handler:si,description:`Set the slice simulator URL`}}});async function li(e){try{let{stdout:t}=await et(`git`,[`rev-parse`,`--show-toplevel`],{nodeOptions:{cwd:dt(e)},throwOnError:!0}),n=t.trim();return n?Pe(ft(await lt(n))):void 0}catch{return}}async function ui(e){try{let{stdout:t}=await et(`git`,[`status`,`--porcelain`,`--untracked-files=all`],{nodeOptions:{cwd:dt(e)},throwOnError:!0}),n=[];for(let r of t.split(`
|
|
297
|
+
`)){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 di=T({name:`prismic pull`,description:`
|
|
306
298
|
Pull content types and slices from Prismic to local files.
|
|
307
299
|
|
|
308
300
|
Remote models are the source of truth. Local files are created, updated,
|
|
309
301
|
or deleted to match.
|
|
310
302
|
|
|
311
303
|
Run \`prismic docs view cli#pull-models-from-prismic\` for details.
|
|
312
|
-
`,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
|
|
304
|
+
`,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 j(),{force:n=!1,env:r,repo:i=r??await t.getEnvironment()??await M()}=e,{token:a,host:o}=await W(),s=await D();console.info(`Pulling from repository: ${i}`);let[c,l,u]=await Promise.all([li(s),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!n&&c){let e=(await ui(c)).filter(e=>e.pathname.endsWith(`/model.json`)&&u.some(t=>L(t,e))||e.pathname.endsWith(`/index.json`)&&l.some(t=>L(t,e))).map(e=>H(s,e));if(e.length>0)throw new w(`
|
|
313
305
|
Local model files have uncommitted changes. Prismic keeps model history in
|
|
314
306
|
git. Commit model changes before you pull them, so this pull can't discard
|
|
315
307
|
your edits:
|
|
@@ -321,7 +313,7 @@ Start building 🚀`))):(console.info(`
|
|
|
321
313
|
Other options:
|
|
322
314
|
prismic push --force Keep local edits, overwrite remote
|
|
323
315
|
prismic pull --force Discard local edits, adopt remote
|
|
324
|
-
`)}let[
|
|
316
|
+
`)}let[d,f,m]=await Promise.all([t.getCustomTypes(),t.getSlices(),g({repo:i,token:a,host:o})]),h=p(m,{customTypes:d.map(e=>e.model),slices:f.map(e=>e.model)},{treatNonCanonicalAsChanged:!0});if(!n&&!c){let e=new Set([...h.customTypes.update,...h.customTypes.delete].map(e=>e.id)),t=new Set([...h.slices.update,...h.slices.delete].map(e=>e.id)),n=[...d.filter(t=>e.has(t.model.id)),...f.filter(e=>t.has(e.model.id))].map(e=>H(s,e.modelPath));if(n.length>0)throw new w(`
|
|
325
317
|
Pull would modify or delete local model files:
|
|
326
318
|
${n.join(`
|
|
327
319
|
`)}
|
|
@@ -329,7 +321,7 @@ Start building 🚀`))):(console.info(`
|
|
|
329
321
|
This project isn't in a git repo, so changes can't be tracked. Choose one:
|
|
330
322
|
prismic pull --force Discard local files, adopt remote
|
|
331
323
|
prismic push --force Keep local files, overwrite remote
|
|
332
|
-
`)}let _=await t.writeModels(
|
|
324
|
+
`)}let _=await t.writeModels(h);await t.generateTypes(),await Qn([`connectPrismic`],{repo:await M(),token:a,host:o}).catch(()=>{});let v=h.customTypes.insert.length+h.customTypes.update.length,y=h.slices.insert.length+h.slices.update.length,b=h.customTypes.delete.length+h.slices.delete.length;for(let e of _)console.info(e);if(v===0&&y===0&&b===0){console.info(`Already up to date.`);return}console.info(`Inserted ${h.customTypes.insert.length}, updated ${h.customTypes.update.length}, deleted ${h.customTypes.delete.length} types`),console.info(`Inserted ${h.slices.insert.length}, updated ${h.slices.update.length}, deleted ${h.slices.delete.length} slices`)}),fi=T({name:`prismic push`,description:`
|
|
333
325
|
Push local content types and slices to Prismic.
|
|
334
326
|
|
|
335
327
|
Local models are the source of truth. Remote models are created,
|
|
@@ -340,7 +332,7 @@ Start building 🚀`))):(console.info(`
|
|
|
340
332
|
Deleting a remote model needs --force.
|
|
341
333
|
|
|
342
334
|
Run \`prismic docs view cli#push-models-to-prismic\` for details.
|
|
343
|
-
`,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
|
|
335
|
+
`,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 j(),{force:r=!1,env:i,repo:a=i??await t.getEnvironment()??await M()}=e,{token:o,host:s}=await W(),c=await D();console.info(`Pushing to repository: ${a}`);let[l,u,d]=await Promise.all([li(c),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!r&&l){let e=(await ui(l)).filter(e=>e.pathname.endsWith(`/model.json`)&&d.some(t=>L(t,e))||e.pathname.endsWith(`/index.json`)&&u.some(t=>L(t,e))).map(e=>H(c,e));if(e.length>0)throw new w(`
|
|
344
336
|
Local model files have uncommitted changes. Prismic keeps model history in
|
|
345
337
|
git. Commit model changes before you push them:
|
|
346
338
|
|
|
@@ -349,90 +341,123 @@ Start building 🚀`))):(console.info(`
|
|
|
349
341
|
prismic push
|
|
350
342
|
|
|
351
343
|
Or skip the check with \`prismic push --force\`.
|
|
352
|
-
`)}let[
|
|
344
|
+
`)}let[f,m]=await Promise.all([t.getModels(),g({repo:a,token:o,host:s})]),h=p(f,m);if(!r){let e=Pe(u[0]),t=Pe(d[0]),n=[...h.customTypes.delete.map(t=>H(c,new URL(`${t.id}/index.json`,e))),...h.slices.delete.map(e=>H(c,new URL(`${de(e.name)}/model.json`,t)))];if(n.length>0)throw new w(`
|
|
353
345
|
Push would delete remote models. Re-run with --force to proceed.
|
|
354
346
|
|
|
355
347
|
Models that would be deleted:
|
|
356
348
|
${n.join(`
|
|
357
349
|
`)}
|
|
358
|
-
`)}try{await
|
|
359
|
-
Please try again, or manually delete any associated pages at: `+t)}if(a!==0)return new
|
|
350
|
+
`)}try{await pi(h,{repo:a,token:o,host:s})}catch(e){throw await hi(e,h.customTypes.delete,{repo:a,token:o,host:s})}for(let{id:e}of h.slices.delete)await n(e,{repo:a,token:o,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 _=[];h.slices.insert.length>0&&_.push(`createSlice`),h.customTypes.insert.some(e=>e.format===`page`)&&_.push(`createPageType`),_.length>0&&await Qn(_,{repo:await M(),token:o,host:s}).catch(()=>{});let v=h.customTypes.insert.length+h.customTypes.update.length,y=h.slices.insert.length+h.slices.update.length,b=h.customTypes.delete.length+h.slices.delete.length;v===0&&y===0&&b===0?console.info(`Already up to date.`):(console.info(`Pushed ${v} type(s), ${y} slice(s).`),b>0&&console.info(`Deleted ${b} model(s).`))});async function pi({customTypes:e,slices:t},n){let r=(e,t)=>({type:e,id:t.id,payload:t}),i=[...e.insert.map(e=>r(`CUSTOM_TYPE_INSERT`,e)),...e.update.map(e=>r(`CUSTOM_TYPE_UPDATE`,e)),...e.delete.map(({id:e})=>r(`CUSTOM_TYPE_DELETE`,{id:e})),...t.insert.map(e=>r(`SLICE_INSERT`,e)),...t.update.map(e=>r(`SLICE_UPDATE`,e)),...t.delete.map(({id:e})=>r(`SLICE_DELETE`,{id:e}))];i.length>0&&await be(i,n)}const mi=R({hasExistingDocuments:Te(!0)});async function hi(e,t,n){if(!(e instanceof z)||!Ee(mi,e.body).success)return e;let{repo:r,host:i}=n;for(let{id:e}of t){let t=gi({repo:r,host:i,customTypeId:e}),a;try{a=await C(e,n)}catch{return new w(`Could not check whether type "${e}" has associated pages.
|
|
351
|
+
Please try again, or manually delete any associated pages at: `+t)}if(a!==0)return new w(`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 gi(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}const _i=I(R({domain:F(),name:P(F()),role:P(De([F(),ke(F(),F())]))}));async function vi(e){let t=new URL(`repositories`,`https://user-service.${e.host}/`);return B(t,{credentials:{"prismic-auth":e.token},schema:_i,unknownErrorMessage:`Failed to load your repositories`})}var yi=T({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 W(),i=await vi({token:n,host:r});if(t){console.info(V(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,bi(e.role)]});console.info(A(a,{headers:[`DOMAIN`,`NAME`,`ROLE`]}))});function bi(e){return typeof e==`string`?e:e?Object.entries(e).map(([e,t])=>`${t} (${e})`).join(`, `):``}const xi=[`private`,`public`,`open`],Si={name:`prismic repo set-api-access`,description:`
|
|
360
352
|
Set the Content API access level of a Prismic repository.
|
|
361
353
|
|
|
362
354
|
By default, this command reads the repository from prismic.config.json at the
|
|
363
355
|
project root.
|
|
364
356
|
|
|
365
357
|
Run \`prismic docs view repository-settings#configuration\` for details.
|
|
366
|
-
`,positionals:{level:{description:`Access level (${
|
|
358
|
+
`,positionals:{level:{description:`Access level (${xi.join(`, `)})`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}};var Ci=T(Si,async({positionals:e,values:t})=>{let[n]=e,{repo:r=await M()}=t;if(!xi.includes(n))throw new w(`Invalid access level: ${n}. Must be one of: ${xi.join(`, `)}`);let{token:i,host:a}=await W();await Rr(n,{repo:r,token:i,host:a}),console.info(`Repository access set to: ${n}`)}),wi=T({name:`prismic repo set-name`,description:`
|
|
367
359
|
Set the display name of a Prismic repository.
|
|
368
360
|
|
|
369
361
|
By default, this command reads the repository from prismic.config.json at the
|
|
370
362
|
project root.
|
|
371
|
-
`,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
|
|
363
|
+
`,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 M()}=t,{token:i,host:a}=await W(),o=await Br(n,{repo:r,token:i,host:a});console.info(`Repository name set to: ${o}`)}),Ti=T({name:`prismic repo view`,description:`
|
|
372
364
|
View details of a Prismic repository.
|
|
373
365
|
|
|
374
366
|
By default, this command reads the repository from prismic.config.json at the
|
|
375
367
|
project root.
|
|
376
|
-
`,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
|
|
368
|
+
`,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 M(),web:n,json:r}=e,{token:i,host:a}=await W(),o=`https://${t}.${a}/`;if(n){Vn(new URL(o)),console.info(`Opening ${o}`);return}let[s,c]=await Promise.all([Wn({repo:t,token:i,host:a}),Lr({repo:t,token:i,host:a})]);if(r){console.info(V({domain:t,name:s.name??null,url:o,apiAccess:c}));return}let l=s.name||`(no name)`;console.info(`Name: ${l}`),console.info(`URL: ${o}`),console.info(`Content API: ${c}`)}),Ei=_({name:`prismic repo`,description:`
|
|
377
369
|
Manage Prismic repositories.
|
|
378
370
|
|
|
379
371
|
Run \`prismic docs view repository-settings\` for details.
|
|
380
|
-
`,commands:{create:{handler:
|
|
372
|
+
`,commands:{create:{handler:Wr,description:`Create a new repository`},list:{handler:yi,description:`List repositories`},view:{handler:Ti,description:`View repository details`},"set-name":{handler:wi,description:`Set repository display name`},"set-api-access":{handler:Ci,description:`Set Content API access level`}}}),Di=T({name:`prismic slice add-variation`,description:`
|
|
381
373
|
Add a variation to a slice.
|
|
382
374
|
|
|
383
375
|
Run \`prismic docs view slices#slice-variations\` for details.
|
|
384
|
-
`,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:
|
|
376
|
+
`,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=se(n),screenshot:a}=t,o=await j(),{model:s}=await o.getSlice(r);if(s.variations.some(e=>e.id===i))throw new w(`Variation "${i}" already exists in slice "${r}".`);let c=``;if(a){let e=await M(),{token:t,host:n}=await W(),r=/^https?:\/\//i.test(a)?new URL(a):ft(a),o=await Ne(r);c=(await S(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}"`)}),Oi=T({name:`prismic slice connect`,description:`Connect a slice to a type's slice zone.`,sections:{EXAMPLES:`
|
|
385
377
|
Connect a slice to a type's default slice zone:
|
|
386
378
|
prismic slice connect hero --to blog_post
|
|
387
379
|
|
|
388
380
|
Connect to a named slice zone:
|
|
389
381
|
prismic slice connect hero --to blog_post --slice-zone page_slices
|
|
390
|
-
`},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
|
|
382
|
+
`},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 j(),{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 w(`Slice zone "${i}" not found in "${r}".`);if(c.config??={},c.config.choices??={},o.id in c.config.choices)throw new w(`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}"`)}),ki=T({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=he(n)}=t,i={id:r,name:n,type:`SharedSlice`,variations:[{id:`default`,name:`Default`,description:`Default`,docURL:``,imageUrl:``,version:``,primary:{}}]},a=await j();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.`)}),Ai=T({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 j(),{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 w(`Slice zone "${i}" not found in "${r}".`);if(!c.config?.choices||!(o.id in c.config.choices))throw new w(`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}"`)}),ji=T({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 j(),{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})`)}),Mi=T({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 j(),{model:o}=await a.getSlice(r),s=o.variations.find(e=>e.id===n);if(!s)throw new w(`Variation "${n}" not found in slice "${r}".`);if(`name`in t&&(s.name=t.name),i){let e=await M(),{token:t,host:n}=await W(),r=/^https?:\/\//i.test(i)?new URL(i):ft(i),a=await Ne(r);s.imageUrl=(await S(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}"`)}),Ni=T({name:`prismic slice list`,description:`
|
|
383
|
+
List all slices.
|
|
384
|
+
|
|
385
|
+
Legacy slices from the Legacy Builder are marked with * and show the type
|
|
386
|
+
that defines them.
|
|
387
|
+
`,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 j(),i=t?[]:(await r.getSlices()).map(e=>e.model),a=(await r.getCustomTypes()).map(e=>e.model),o=m(a);if(n&&t){let e=o.map(e=>({id:e.id,definedIn:e.customTypeId,sliceZone:e.sliceZoneId}));console.info(V(e));return}if(n){console.info(V(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(A(s,{headers:[`NAME`,`ID`,`DEFINED IN`]})),o.length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),Pi=T({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 j();await n.deleteSlice(t),await n.generateTypes(),console.info(`Slice removed: ${t}`)}),Fi=T({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 j(),{model:a}=await i.getSlice(r),o=a.variations.find(e=>e.id===n);if(!o)throw new w(`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}"`)}),Ii=T({name:`prismic slice upgrade-legacy`,description:`
|
|
388
|
+
Upgrade a legacy slice from the Legacy Builder.
|
|
389
|
+
|
|
390
|
+
The CLI and the Type Builder cannot edit legacy slices. Run
|
|
391
|
+
\`prismic slice list --legacy\` to list them.
|
|
392
|
+
|
|
393
|
+
Each legacy slice becomes its own slice unless --to names an existing
|
|
394
|
+
slice, which gets it as a new variation. Legacy slices with the same ID
|
|
395
|
+
in several types are often the same component. Combining them is a content
|
|
396
|
+
modeling decision for the project's owner, since it changes how editors pick
|
|
397
|
+
slices. Get their choice before upgrading them.
|
|
398
|
+
|
|
399
|
+
Only local models change. After \`prismic push\`, Prismic returns the
|
|
400
|
+
slice's content in its upgraded shape, so deploy the updated component
|
|
401
|
+
with the push.
|
|
402
|
+
`,sections:{EXAMPLES:`
|
|
403
|
+
Upgrade a legacy slice:
|
|
404
|
+
prismic slice upgrade-legacy hero --from blog_post
|
|
405
|
+
|
|
406
|
+
Upgrade a legacy slice that is not in the "body" slice zone:
|
|
407
|
+
prismic slice upgrade-legacy hero --from blog_post --slice-zone page_slices
|
|
408
|
+
|
|
409
|
+
Add a legacy slice to an existing slice as a new variation:
|
|
410
|
+
prismic slice upgrade-legacy hero --from landing_page --to hero --variation landing
|
|
411
|
+
|
|
412
|
+
Merge a legacy slice into an existing variation with the same fields:
|
|
413
|
+
prismic slice upgrade-legacy hero --from landing_page --to hero --variation default
|
|
414
|
+
`},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 j(),c=(await s.getCustomTypes()).map(e=>e.model),l=(await s.getSlices()).map(e=>e.model),u=m(c),d=c.find(e=>e.id===r);if(!d)throw new w(`Type "${r}" not found.`);let f=u.find(e=>e.customTypeId===r&&e.sliceZoneId===i&&e.id===n);if(!f)throw new w(`Legacy slice "${n}" not found in the "${i}" slice zone of "${r}". Use --slice-zone to choose the slice zone.`);let p=`${r}::${i}::${n}`,h=a??he(n),g=f.sliceZone.config?.choices?.[h];if(h!==n&&g&&g.type!==`SharedSlice`)throw new w(`The "${i}" slice zone of "${r}" also has legacy slice "${h}". Upgrade it first.`);let _=l.find(e=>e.id===h),v=se(o??(_?n:`default`)),y=zi(f,v),b;if(_){if(!a)throw new w(Li(_,f,y));let e=_.variations.find(e=>e.id===v);if(e&&!Bi(e,y))throw new w(`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,[p]:v},await s.updateSlice(_)}else{let{model:e}=f,t=`fieldset`in e?e.fieldset:void 0;_={id:h,type:`SharedSlice`,name:de(a??t??h),legacyPaths:{[p]:v},variations:[y]},b=`Upgraded legacy slice "${n}" to slice "${h}"`,await s.createSlice(_)}Vi(f,_.id),await s.updateCustomType(d),await s.generateTypes();let{directory:x}=await s.getSlice(_.id),S=H(await D(),x),C=u.length-1;console.info(b),console.info(`After \`prismic push\`: ${Ri(f,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 Li(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=>Bi(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(`
|
|
415
|
+
`)}function Ri(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 zi(e,t){let{model:n}=e,r=t==="default"?`Default`:de(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 Bi(e,t){return st(e.primary??{},t.primary??{})&&st(e.items??{},t.items??{})}function Vi({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 Hi=T({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 j()).getSlice(n);if(r){console.info(V(i));return}console.info(`ID: ${i.id}`),console.info(`Name: ${i.name}`);for(let e of i.variations??[])console.info(``),console.info(`${e.id}:`),console.info(Gt(e.primary??{}))}),Ui=_({name:`prismic slice`,description:`
|
|
391
416
|
Manage slices.
|
|
392
417
|
|
|
393
418
|
Run \`prismic docs view slices\` for details.
|
|
394
|
-
`,commands:{create:{handler:
|
|
419
|
+
`,commands:{create:{handler:ki,description:`Create a new slice`},edit:{handler:ji,description:`Edit a slice`},remove:{handler:Pi,description:`Remove a slice`},list:{handler:Ni,description:`List slices`},view:{handler:Hi,description:`View a slice`},connect:{handler:Oi,description:`Connect a slice to a type's slice zone`},disconnect:{handler:Ai,description:`Disconnect a slice from a type's slice zone`},"upgrade-legacy":{handler:Ii,description:`Upgrade a legacy slice`},"add-variation":{handler:Di,description:`Add a variation to a slice`},"edit-variation":{handler:Mi,description:`Edit a variation of a slice`},"remove-variation":{handler:Fi,description:`Remove a variation from a slice`}}}),Wi=T({name:`prismic status`,description:`
|
|
395
420
|
Show local vs remote model differences.
|
|
396
421
|
|
|
397
422
|
Reports what would be pushed to or pulled from Prismic, plus any local
|
|
398
423
|
model files with uncommitted git changes that must be committed before
|
|
399
424
|
pull and push.
|
|
400
|
-
`,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
|
|
425
|
+
`,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 j(),n=await M(),r=await t.getEnvironment(),{env:i,repo:a=i??r??n}=e,{token:o,host:s}=await W(),l=await D(),[u,d,f,h]=await Promise.all([li(l),t.getCustomTypeLibraries(),t.getSliceLibraries(),t.getModels()]),_,v;if(o){let[e,t]=await Promise.all([Mt({token:o,host:s}),g({repo:a,token:o,host:s})]);_=e.email,v=p(h,t)}let y=[];u&&(y=(await ui(u)).filter(e=>e.pathname.endsWith(`/model.json`)&&f.some(t=>L(t,e))||e.pathname.endsWith(`/index.json`)&&d.some(t=>L(t,e))).map(e=>H(l,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 b=m(h.customTypes).length;b>0&&console.info(`\n${b} legacy ${b===1?`slice needs`:`slices need`} upgrading. Run \`prismic slice list --legacy\`.`);let x=v!==void 0&&!c(v.customTypes)&&!c(v.slices);if(x&&y.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 S=[];if(y.length>0&&(console.info(``),console.info(`Prismic keeps model history in git. Commit model changes before you push or pull them.`),S.push(`git add ${y.join(` `)}`),S.push(`git commit -m "Update Prismic models"`)),v&&!x){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;S.push(`prismic push # creates ${e}, updates ${t}, deletes ${n}`),S.push(`prismic pull # creates ${n}, updates ${t}, deletes ${e}`)}if(S.length>0){console.info(``),console.info(`Next:`);for(let e of S)console.info(` ${e}`)}});async function Gi(e){if(e instanceof Fe||e instanceof z){let{token:t}=await W();return t?U.PRISMIC_TOKEN?`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 Fe?"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 Re||e instanceof Me){let t=new URL(e.response.url);t.search=``;let n=e.message?`${e.message}\n\n`:``;return ge`
|
|
401
426
|
${n}Prismic responded with an unexpected error. Try again, and report it if it keeps happening.
|
|
402
427
|
|
|
403
428
|
Status: ${e.status} ${e.statusText}
|
|
404
429
|
URL: ${t}
|
|
405
430
|
Report: https://github.com/prismicio/cli/issues
|
|
406
|
-
`}if(e instanceof Error)return
|
|
431
|
+
`}if(e instanceof Error)return ge(e.message)}const Ki=U.PRISMIC_SYNC_POLL_MS??5e3;var qi=T({name:`prismic sync`,description:`
|
|
407
432
|
Watch Prismic and continuously pull changes to local files.
|
|
408
433
|
|
|
409
434
|
For one-time pulls, use \`prismic pull\`.
|
|
410
|
-
`,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
|
|
411
|
-
Watch stopped. Goodbye!`),Ve(`sync`,{watch:!0}),process.exit(0)}),console.info(`Watching repository: ${r} (polling every ${
|
|
435
|
+
`,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 j(),{env:n,repo:r=n??await t.getEnvironment()??await M()}=e,{token:i,host:a}=await W();He(`sync`,{watch:!0}),process.on(`SIGINT`,()=>{console.info(`
|
|
436
|
+
Watch stopped. Goodbye!`),Ve(`sync`,{watch:!0}),process.exit(0)}),console.info(`Watching repository: ${r} (polling every ${Ki/1e3}s, Ctrl+C to stop)`);let o,s=0;for(;;){try{let e=await g({repo:r,token:i,host:a}),n=o&&p(e,o);if(!n||c(n.customTypes)||c(n.slices)){let r=!n,s=p(e,await t.getModels(),{treatNonCanonicalAsChanged:!0});for(let e of await t.writeModels(s))console.info(e);let l=[...c(s.slices)?[`slices`]:[],...c(s.customTypes)?[`custom types`]:[]];if((r||l.length>0)&&await t.generateTypes(),o=e,r)await Qn([`connectPrismic`],{repo:await M(),token:i,host:a}).catch(()=>{}),console.info(`Initial sync complete.`);else if(l.length>0){let e=(/* @__PURE__ */ new Date()).toLocaleTimeString();console.info(`[${e}] Changes detected in ${l.join(` and `)}`)}}s=0}catch(e){s++;let t=await Gi(e)??`Unknown error`;if(console.error(`Error checking for changes: ${t}`),s>=5)throw new w(`Too many consecutive errors (5), stopping watch.`)}await ht(Ki)}});const Ji=`0123456789abcdefghjkmnpqrstvwxyz`,Yi=RegExp(`^pt_[${Ji}]{16}$`);function Xi(){let e=`pt_`;for(let t of pt(16))e+=Ji[t&31];return e}function Zi(e){return Yi.test(e)}var Qi=T({name:`prismic task-id`,description:`
|
|
412
437
|
Print a task ID for --task-id.
|
|
413
438
|
|
|
414
439
|
One ID covers one user request: pass it on every command for that request,
|
|
415
440
|
and run this again when the user asks for something else.
|
|
416
|
-
`},async()=>{console.info(
|
|
441
|
+
`},async()=>{console.info(Xi())});const $i=`Prismic CLI`;var ea=T({name:`prismic token create`,description:`
|
|
417
442
|
Create a new API token for a Prismic repository.
|
|
418
443
|
|
|
419
444
|
By default, this command reads the repository from prismic.config.json at the
|
|
420
445
|
project root.
|
|
421
|
-
`,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: "${
|
|
446
|
+
`,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: "${$i}")`},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 k(),write:r,"allow-releases":i,name:a=$i,json:o}=e;if(r&&i)throw new w(`--allow-releases is only valid for access tokens (not with --write)`);let{token:s,host:c}=await W(),l,u;if(r)l=(await Mr(a,{repo:n,token:s,host:c})).token;else{u=i?`master+releases`:`master`;let e=(await Dr({repo:n,token:s,host:c})).find(e=>e.name===a);e||=await Or(a,{repo:n,token:s,host:c}),l=(await kr(e.id,u,{repo:n,token:s,host:c})).token}if(o){console.info(V({token:l,type:r?`write`:`access`,name:a,repository:n,...u?{scope:u}:{}}));return}console.info(`Token created: ${l}`)}),ta=T({name:`prismic token delete`,description:`
|
|
422
447
|
Delete a token from a Prismic repository.
|
|
423
448
|
|
|
424
449
|
By default, this command reads the repository from prismic.config.json at the
|
|
425
450
|
project root.
|
|
426
|
-
`,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
|
|
427
|
-
Manage API tokens for a Prismic repository.
|
|
428
|
-
|
|
429
|
-
Run \`prismic docs view repository-settings#configuration\` for details.
|
|
430
|
-
`,commands:{list:{handler:V({name:`prismic token list`,description:`
|
|
451
|
+
`,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 k()}=t,{token:a,host:o}=await W(),[s,c]=await Promise.all([Dr({repo:i,token:a,host:o}),jr({repo:i,token:a,host:o})]),l=s.flatMap(e=>e.wroom_auths).find(e=>e.token===n);if(l){await Ar(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 Nr(u.token,{repo:i,token:a,host:o}),console.info(`Token deleted`);return}throw new w(`Token not found: ${n}`)}),na=T({name:`prismic token list`,description:`
|
|
431
452
|
List all API tokens for a Prismic repository.
|
|
432
453
|
|
|
433
454
|
By default, this command reads the repository from prismic.config.json at the
|
|
434
455
|
project root.
|
|
435
|
-
`,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
|
|
456
|
+
`,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 k(),json:r}=e,{token:i,host:a}=await W(),[o,s]=await Promise.all([Dr({repo:n,token:i,host:a}),jr({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(V({accessTokens:c,writeTokens:l}));return}if(c.length>0){console.info(`ACCESS TOKENS`);let e=c.map(e=>[` ${e.name}`,e.scope,e.token,e.createdAt]);console.info(A(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(A(e))}else console.info(`WRITE TOKENS (none)`)}),ra=_({name:`prismic token`,description:`
|
|
457
|
+
Manage API tokens for a Prismic repository.
|
|
458
|
+
|
|
459
|
+
Run \`prismic docs view repository-settings#configuration\` for details.
|
|
460
|
+
`,commands:{list:{handler:na,description:`List all tokens`},create:{handler:ea,description:`Create a new token`},delete:{handler:ta,description:`Delete a token`}}}),ia=T({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 j(),{model:o}=await a.getCustomType(r);if(n in o.json)throw new w(`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}"`)}),aa=T({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:`
|
|
436
461
|
custom A non-page type (e.g. settings, navigation, author, blog
|
|
437
462
|
category). This is the default.
|
|
438
463
|
page A page type with a URL (e.g. homepage, blog post, landing
|
|
@@ -447,11 +472,11 @@ Watch stopped. Goodbye!`),Ve(`sync`,{watch:!0}),process.exit(0)}),console.info(`
|
|
|
447
472
|
|
|
448
473
|
Create with a custom ID:
|
|
449
474
|
prismic type create "Landing Page" --format page --id landing
|
|
450
|
-
`}},async({positionals:e,values:t})=>{let[n]=e,{format:r=`custom`,single:i=!1,id:a=
|
|
475
|
+
`}},async({positionals:e,values:t})=>{let[n]=e,{format:r=`custom`,single:i=!1,id:a=he(n)}=t;if(r!==`custom`&&r!==`page`)throw new w(`Invalid format: "${r}". Use "custom" or "page".`);let o=await j();if((await o.getCustomTypes()).some(({model:e})=>e.id===a))throw new w(`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.`)}),oa=T({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 w(`Invalid format: "${t.format}". Use "custom" or "page".`);let r=await j(),{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})`)}),sa=T({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 j(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new w(`Tab "${n}" not found in "${r}".`);if(`with-slice-zone`in t&&`without-slice-zone`in t)throw new w(`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 w(`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 w(`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 w(`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 w(`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}"`)}),ca=T({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 j()).getCustomTypes();if(t){console.info(V(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(A(r,{headers:[`NAME`,`ID`,`FORMAT`]}))}),la=T({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 j();await n.deleteCustomType(t),await n.generateTypes(),console.info(`Type removed: ${t}`)}),ua=T({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 j(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new w(`Tab "${n}" not found in "${r}".`);if(Object.keys(a.json).length<=1)throw new w(`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}"`)}),da=T({name:`prismic type view`,description:`View details of a content type.`,positionals:{id:{description:`ID of the content type`,required:!0}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{json:r}=t,{model:i}=await(await j()).getCustomType(n);if(r){console.info(V(i));return}let a=(await y()).routes?.find(e=>e.type===i.id);console.info(`ID: ${i.id}`),console.info(`Name: ${i.label||`(no name)`}`),console.info(`Format: ${i.format??`custom`}`),console.info(`Repeatable: ${i.repeatable}`),console.info(`Route: ${a?.path??`none`}`);for(let[e,t]of Object.entries(i.json)){console.info(``),console.info(`${e}:`),console.info(Gt(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)`}`)}}m([i]).length>0&&console.info("\n* Legacy slice. Run `prismic slice upgrade-legacy --help` to upgrade it.")}),fa=_({name:`prismic type`,description:`
|
|
451
476
|
Manage content types.
|
|
452
477
|
|
|
453
478
|
Run \`prismic docs view content-modeling\` for details.
|
|
454
|
-
`,commands:{create:{handler:
|
|
479
|
+
`,commands:{create:{handler:aa,description:`Create a new content type`},edit:{handler:oa,description:`Edit a content type`},remove:{handler:la,description:`Remove a content type`},list:{handler:ca,description:`List content types`},view:{handler:da,description:`View a content type`},"add-tab":{handler:ia,description:`Add a tab to a content type`},"edit-tab":{handler:sa,description:`Edit a tab of a content type`},"remove-tab":{handler:ua,description:`Remove a tab from a content type`}}}),pa=T({name:`prismic webhook create`,description:`
|
|
455
480
|
Create a new webhook in a Prismic repository.
|
|
456
481
|
|
|
457
482
|
By default, this command reads the repository from prismic.config.json at the
|
|
@@ -474,27 +499,27 @@ Watch stopped. Goodbye!`),Ve(`sync`,{watch:!0}),process.exit(0)}),console.info(`
|
|
|
474
499
|
|
|
475
500
|
Create a named webhook with a secret:
|
|
476
501
|
prismic webhook create https://example.com/webhook --name "Deploy" --secret my-secret
|
|
477
|
-
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
502
|
+
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await k(),name:a,secret:o,trigger:s=[]}=t;for(let e of s)if(!_r.includes(e))throw new w(`Invalid trigger: ${e}\nValid triggers: ${_r.join(`, `)}`);let{token:c,host:l}=await W(),u=!(s.length>0);await yr({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.`)}),ma=T({name:`prismic webhook disable`,description:`
|
|
478
503
|
Disable a webhook in a Prismic repository.
|
|
479
504
|
|
|
480
505
|
By default, this command reads the repository from prismic.config.json at the
|
|
481
506
|
project root.
|
|
482
|
-
`,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
|
|
507
|
+
`,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 k()}=t,{token:a,host:o}=await W(),s=(await Z({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new w(`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 br(c,l,{repo:i,token:a,host:o}),console.info(`Webhook disabled: ${n}`)}),ha=T({name:`prismic webhook enable`,description:`
|
|
483
508
|
Enable a webhook in a Prismic repository.
|
|
484
509
|
|
|
485
510
|
By default, this command reads the repository from prismic.config.json at the
|
|
486
511
|
project root.
|
|
487
|
-
`,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
|
|
512
|
+
`,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 k()}=t,{token:a,host:o}=await W(),s=(await Z({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new w(`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 br(c,l,{repo:i,token:a,host:o}),console.info(`Webhook enabled: ${n}`)}),ga=T({name:`prismic webhook list`,description:`
|
|
488
513
|
List all webhooks in a Prismic repository.
|
|
489
514
|
|
|
490
515
|
By default, this command reads the repository from prismic.config.json at the
|
|
491
516
|
project root.
|
|
492
|
-
`,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
|
|
517
|
+
`,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 k(),json:r}=e,{token:i,host:a}=await W(),o=await Z({repo:n,token:i,host:a});if(r){console.info(V(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(A(s,{headers:[`URL`,`STATUS`]}))}),_a=T({name:`prismic webhook remove`,description:`
|
|
493
518
|
Delete a webhook from a Prismic repository.
|
|
494
519
|
|
|
495
520
|
By default, this command reads the repository from prismic.config.json at the
|
|
496
521
|
project root.
|
|
497
|
-
`,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 k()}=t,{token:a,host:o}=await W(),s=(await Z({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new w(`Webhook not found: ${n}`);let c=s.config._id;await xr(c,{repo:i,token:a,host:o}),console.info(`Webhook removed: ${n}`)}),va=T({name:`prismic webhook set-triggers`,description:`
|
|
498
523
|
Update which events trigger a webhook.
|
|
499
524
|
|
|
500
525
|
By default, this command reads the repository from prismic.config.json at the
|
|
@@ -506,16 +531,16 @@ Watch stopped. Goodbye!`),Ve(`sync`,{watch:!0}),process.exit(0)}),console.info(`
|
|
|
506
531
|
releasesUpdated When a release is edited or deleted
|
|
507
532
|
tagsCreated When a tag is created
|
|
508
533
|
tagsDeleted When a tag is deleted
|
|
509
|
-
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await
|
|
534
|
+
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await k(),trigger:a=[]}=t;for(let e of a)if(!_r.includes(e))throw new w(`Invalid trigger: ${e}\nValid triggers: ${_r.join(`, `)}`);let{token:o,host:s}=await W(),c=(await Z({repo:i,token:o,host:s})).find(e=>e.config.url===n);if(!c)throw new w(`Webhook not found: ${n}`);let l=c.config._id;await br(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(`, `)}`)}),ya=T({name:`prismic webhook view`,description:`
|
|
510
535
|
View details of a webhook in a Prismic repository.
|
|
511
536
|
|
|
512
537
|
By default, this command reads the repository from prismic.config.json at the
|
|
513
538
|
project root.
|
|
514
|
-
`,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
|
|
539
|
+
`,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 k()}=t,{token:a,host:o}=await W(),s=(await Z({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new w(`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 _r)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)`)}),ba=_({name:`prismic webhook`,description:`
|
|
515
540
|
Manage webhooks in a Prismic repository.
|
|
516
541
|
|
|
517
542
|
Run \`prismic docs view webhooks\` for details.
|
|
518
|
-
`,commands:{list:{handler:
|
|
543
|
+
`,commands:{list:{handler:ga,description:`List all webhooks`},create:{handler:pa,description:`Create a new webhook`},view:{handler:ya,description:`View webhook details`},remove:{handler:_a,description:`Delete a webhook`},enable:{handler:ha,description:`Enable a webhook`},disable:{handler:ma,description:`Disable a webhook`},"set-triggers":{handler:va,description:`Update webhook triggers`}}}),xa=T({name:`prismic whoami`,description:`Show the currently logged in user.`},async()=>{let{token:e,host:t}=await W(),n=await Mt({token:e,host:t});console.info(n.email)}),Sa=_({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:`
|
|
519
544
|
Pages are page types, built from slices and fields. Content that is
|
|
520
545
|
not a page is a custom type, such as an author or a navigation menu.
|
|
521
546
|
A page references a custom type with a content relationship field,
|
|
@@ -536,4 +561,4 @@ Watch stopped. Goodbye!`),Ve(`sync`,{watch:!0}),process.exit(0)}),console.info(`
|
|
|
536
561
|
A repository can hold multiple preview URLs but only one simulator URL,
|
|
537
562
|
which the Page Builder loads live slice previews from.
|
|
538
563
|
Run \`prismic docs view previews\` for details.
|
|
539
|
-
`},commands:{init:{handler:
|
|
564
|
+
`},commands:{init:{handler:qr,description:`Initialize a Prismic project`},docs:{handler:kt,description:`Browse Prismic documentation`},gen:{handler:Bn,description:`Generate files from local models`},pull:{handler:di,description:`Pull types and slices from Prismic`},push:{handler:fi,description:`Push types and slices to Prismic`},sync:{handler:qi,description:`Sync types and slices from Prismic`},status:{handler:Wi,description:`Show local vs remote model differences`},env:{handler:Rt,description:`Manage the active environment`},locale:{handler:ti,description:`Manage locales`},repo:{handler:Ei,description:`Manage repositories`},type:{handler:fa,description:`Manage content types`},field:{handler:Fn,description:`Manage fields`},slice:{handler:Ui,description:`Manage slices`},preview:{handler:ci,description:`Manage preview and simulator URLs`},token:{handler:ra,description:`Manage API tokens`},webhook:{handler:ba,description:`Manage webhooks`},login:{handler:ni,description:`Log in to Prismic`},logout:{handler:ri,description:`Log out of Prismic`},whoami:{handler:xa,description:`Show the currently logged in user`},"task-id":{handler:Qi,description:`Print a task ID for --task-id`,hidden:Ke()===void 0}}});const Ca=we({exp:P(Ce())});function wa(e){try{let[,t]=e.split(`.`);if(!t)return;let n=JSON.parse(Buffer.from(t,`base64url`).toString());return je(Ca,n)}catch{return}}const Ta=[w,b,a,t,i,ce,h,v,oe,me,Pt,ie,fe,ne,it,le,Le,Fe,z,Re,Me],Ea=[Re,Me];await Da();async function Da(){await ot({npmPackageName:Se,statePath:Ue}),Ze().catch(()=>{});let{positionals:[e=``],values:{version:t,help:n,repo:r=await M().catch(()=>void 0),"analytics-intent":i,"analytics-task-id":a,"user-intent":o=i,"task-id":s=a}}=ct({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(xe);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`&&Ke()!==void 0?ka(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 W(),n=U.PRISMIC_TELEMETRY_ENABLED??await Qe(),r=U.PRISMIC_SENTRY_ENABLED??(n&&U.PROD);if(r&&await Oa({host:t,repo:c,userIntent:l,taskId:u}),n&&await Ge({host:t,repo:c,userIntent:l,taskId:u}),e){let i=wa(e)?.exp,a=Date.now()/1e3;if((!i||i-a<=3600)&&process.on(`exit`,()=>Je()),r||n){let n=Be();n?nr({id:n}):(!i||i>a)&&Mt({token:e,host:t}).then(e=>{Ye(e),nr({id:e.shortId})}).catch(()=>{})}}}let f=!n&&e&&e!==`sync`;try{f&&He(e),await Sa(),f&&Ve(e)}catch(t){process.exitCode=1;let n=await Gi(t).catch(()=>void 0);if(f&&Ve(e,{error:n??t}),Ta.some(e=>t instanceof e))console.error(n),Ea.some(e=>t instanceof e)&&await rr(t);else throw console.error(`The CLI reached a bug. Report this if it keeps happening: https://github.com/prismicio/cli/issues`),await rr(t),t}}async function Oa(e){let{host:t,repo:n,userIntent:r,taskId:i}=e;$n({dsn:U.PRISMIC_SENTRY_DSN,appName:Se,appVersion:xe,environment:U.PRISMIC_SENTRY_ENVIRONMENT}),er(`host`,t),n&&(er(`repository`,n),tr(`Repository Data`,{name:n})),i&&er(`taskId`,i),r&&tr(`Agent Task`,{userIntent:r,taskId:i});try{er(`framework`,(await j()).id)}catch{}}function ka(e,t){if(!e)return`missing --task-id`;if(!Zi(e))return"--task-id must come from `prismic task-id`";if(!t)return`missing --user-intent`}export{};
|