prismic 1.15.0 → 1.16.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/index.mjs +49 -45
- package/dist/package-DLkZAhRl.mjs +1 -0
- package/dist/{segment-BDng6qf2.mjs → segment-zsn0WEf2.mjs} +1 -1
- package/dist/subprocesses/sendSegmentEvents.mjs +1 -1
- package/dist/subprocesses/updateVersionState.mjs +1 -1
- package/dist/{update-notifier-eHHpxTVI.mjs → update-notifier-CjfM6dH9.mjs} +1 -1
- package/package.json +1 -1
- package/dist/package-Bngy7G0H.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,M as f,N as p,O as m,P as h,R as g,S as _,T as v,U as y,V as b,W as x,X as S,Y as C,a as ee,b as te,d as w,f as ne,g as re,h as ie,i as ae,j as
|
|
2
|
+
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,M as f,N as p,O as m,P as h,R as g,S as _,T as v,U as y,V as b,W as x,X as S,Y as C,a as ee,b as te,d as w,f as ne,g as re,h as ie,i as ae,j as oe,l as T,m as se,n as ce,o as le,p as ue,q as de,r as fe,s as pe,t as me,u as E,v as he,w as ge,x as _e,z as ve}from"./core-C2WfsoNg.mjs";import{n as ye,t as be}from"./package-DLkZAhRl.mjs";import{A as D,B as xe,C as O,D as Se,E as Ce,F as we,M as Te,N as k,S as A,_ as j,a as Ee,c as De,d as Oe,f as ke,g as M,i as Ae,j as N,k as je,n as Me,o as P,r as Ne,s as F,t as Pe,v as I,w as Fe}from"./request-DEP7ruRD.mjs";import{c as Ie,i as Le,l as L,n as Re,o as ze,r as R,s as Be,t as Ve}from"./auth-BQ-T06tR.mjs";import{a as He,c as Ue,l as We,o as Ge,s as Ke,t as qe}from"./packageJson-DOQ8ITHb.mjs";import{i as Je,r as Ye,t as Xe}from"./segment-zsn0WEf2.mjs";import{t as Ze}from"./update-notifier-CjfM6dH9.mjs";import{parseArgs as Qe}from"node:util";import{realpath as $e,rm as et}from"node:fs/promises";import{fileURLToPath as tt,pathToFileURL as nt}from"node:url";import{createHash as rt}from"node:crypto";import{exec as it}from"node:child_process";import{homedir as at}from"node:os";import{setTimeout as ot}from"node:timers/promises";function z(e,t){return async function(){let{positionals:n={},options:r={}}=e,i=e.name.split(` `).length,a=process.argv.slice(1+i),o=Object.keys(n).length>0,s;try{s=Qe({args:a,options:{...r,help:{type:`boolean`,short:`h`}},allowPositionals:o,strict:!0})}catch(e){throw e instanceof TypeError&&`code`in e&&typeof e.code==`string`&&e.code.startsWith(`ERR_PARSE_ARGS_`)?new V(e.message):e}if(s.values.help){console.info(st(e));return}for(let[e,[t,r]]of Object.entries(n).entries())if(r.required&&!s.positionals[e])throw new V(`Missing required argument: <${t}>`);for(let[e,t]of Object.entries(r)){if(t.required&&!(e in s.values))throw new V(`Missing required option: --${e}`);if(t.deprecated&&e in s.values&&console.warn(`--${e} is deprecated. ${t.deprecated}`),t.dependsOn&&e in s.values){let n=Array.isArray(t.dependsOn)?t.dependsOn:[t.dependsOn];for(let t of n)if(!(t in s.values))throw new V(`--${e} can only be used with --${t}.`)}}await t(s)}}function st(t){let{description:n,sections:r,positionals:i={},options:a}=t,o=Object.keys(i),s=[m(n)];s.push(``),s.push(`USAGE`);let c=` ${t.name}`;if(o.length>0&&(c+=` `+o.map(e=>`<${e}>`).join(` `)),c+=` [options]`,s.push(c),o.length>0){s.push(``),s.push(`ARGUMENTS`);let t=[];for(let e in i){let n=i[e],r=n.description+(n.required?` (required)`:``);t.push([` <${e}>`,r])}s.push(e(t))}s.push(``),s.push(`OPTIONS`);let l=[];if(a){let e=Object.keys(a);for(let t of e){let e=a[t];if(e.deprecated)continue;let n=`${e.short?`-${e.short}, `:` `}--${t}${e.type===`string`?` string`:``}`,r=e.description+(e.required?` (required)`:``);l.push({left:n,description:r})}}l.push({left:`-h, --help`,description:`Show help for command`});let u=l.map(e=>[` ${e.left}`,e.description]);if(s.push(e(u)),r)for(let e in r){let t=m(r[e]);s.push(``),s.push(e);for(let e of t.split(`
|
|
3
3
|
`))s.push(e?` ${e}`:``)}s.push(``),s.push(`LEARN MORE`);let d=t.name.split(` `)[0];return s.push(` Use \`${d} <command> --help\` for more information about a command.`),s.join(`
|
|
4
|
-
`)}function B(e){let t=e.name.split(` `).length;return async function(){let{positionals:[n]}
|
|
4
|
+
`)}function B(e){let t=e.name.split(` `).length;return async function(){let{positionals:[n]}=Qe({args:process.argv.slice(1+t),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1}),r=n?e.commands[n]:void 0;if(r){await r.handler();return}if(n)throw new V(`Unknown command: ${n}`);console.info(ct(e))}}function ct(t){let{name:n,description:r,sections:i,commands:a}=t,o=[m(r)];o.push(``),o.push(`USAGE`),o.push(` ${n} <command> [options]`),o.push(``),o.push(`COMMANDS`);let s=Object.entries(a).filter(([,e])=>!e.hidden).map(([e,t])=>[` ${e}`,t.description]);if(o.push(e(s)),o.push(``),o.push(`OPTIONS`),o.push(` -h, --help Show help for command`),i)for(let e in i){let t=m(i[e]);o.push(``),o.push(e);for(let e of t.split(`
|
|
5
5
|
`))o.push(e?` ${e}`:``)}return o.push(``),o.push(`LEARN MORE`),o.push(` Use \`${n} <command> --help\` for more information about a command.`),o.join(`
|
|
6
|
-
`)}function lt(e,t){if(t.filter(t=>t in e).length>1)throw new V(`Only one of ${t.map(e=>`--${String(e)}`).join(` or `)} can be specified.`)}function ut(e,t){if(t.filter(t=>t in e).length===0)throw new V(`Specify one of ${t.map(e=>`--${String(e)}`).join(` or `)}.`)}function dt(e,t){lt(e,t),ut(e,t);let n=t.find(t=>t in e);return{key:n,value:e[n]}}var V=class extends Error{name=`CommandError`};const ft=D({path:k(),title:k(),description:
|
|
6
|
+
`)}function lt(e,t){if(t.filter(t=>t in e).length>1)throw new V(`Only one of ${t.map(e=>`--${String(e)}`).join(` or `)} can be specified.`)}function ut(e,t){if(t.filter(t=>t in e).length===0)throw new V(`Specify one of ${t.map(e=>`--${String(e)}`).join(` or `)}.`)}function dt(e,t){lt(e,t),ut(e,t);let n=t.find(t=>t in e);return{key:n,value:e[n]}}var V=class extends Error{name=`CommandError`};const ft=D({path:k(),title:k(),description:N(k())}),pt=D({path:k(),title:k(),description:N(k()),anchors:A(D({slug:k(),excerpt:k()}))});async function mt(e){return P(new URL(`api/index/`,_t(e?.host)),{schema:A(ft),unknownErrorMessage:`Failed to fetch documentation index`})}async function ht(e,t){return P(new URL(`api/index/${e}`,_t(t?.host)),{schema:pt,notFoundMessage:`Documentation page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation index`})}async function gt(e,t){return P(new URL(e,_t(t?.host)),{headers:{Accept:`text/markdown`},schema:k(),notFoundMessage:`Page not found: ${e}`,unknownErrorMessage:`Failed to fetch documentation page`})}function _t(e=`prismic.io`){return new URL(`https://${e}/docs/`)}var vt=z({name:`prismic docs list`,description:`
|
|
7
7
|
List available documentation pages.
|
|
8
8
|
|
|
9
9
|
With a path argument, list the anchors within that page.
|
|
10
|
-
`,positionals:{path:{description:`Documentation path to list anchors for`,required:!1}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:t,values:n})=>{let[r]=t,{json:i}=n;if(r){let t=await ht(r,{host:
|
|
10
|
+
`,positionals:{path:{description:`Documentation path to list anchors for`,required:!1}},options:{json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:t,values:n})=>{let[r]=t,{json:i}=n;if(r){let t=await ht(r,{host:L.PRISMIC_DOCS_HOST});if(i){console.info(F(t));return}if(t.anchors.length===0){console.info(`(no anchors)`);return}let n=t.anchors.map(e=>[`${r}#${e.slug}`,e.excerpt]);console.info(e(n,{headers:[`PATH`,`EXCERPT`]}))}else{let t=await mt({host:L.PRISMIC_DOCS_HOST});if(t.sort((e,t)=>e.path.localeCompare(t.path)),i){console.info(F(t));return}if(t.length===0){console.info(`No documentation pages found.`);return}let n=t.map(e=>[e.path,e.title,e.description??``]);console.info(e(n,{headers:[`PATH`,`TITLE`,`DESCRIPTION`]}))}});const yt=/[\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,bt=Object.hasOwnProperty;var xt=class{constructor(){this.occurrences,this.reset()}slug(e,t){let n=this,r=St(e,t===!0),i=r;for(;bt.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 St(e,t){return typeof e==`string`?(t||(e=e.toLowerCase()),e.replace(yt,``).replace(/ /g,`-`)):``}var Ct=z({name:`prismic docs view`,description:`
|
|
11
11
|
View a documentation page as Markdown.
|
|
12
12
|
|
|
13
13
|
Append #anchor to the path to view only the section under that heading.
|
|
14
|
-
`,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 gt(a,{host:
|
|
14
|
+
`,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 gt(a,{host:L.PRISMIC_DOCS_HOST});if(o){let e=wt(s,o);if(!e)throw new V(`Anchor not found: #${o}`);s=e}if(r){console.info(F({path:a,anchor:o,content:s}));return}console.info(s)});function wt(e,t){let n=e.split(`
|
|
15
15
|
`),r=new xt,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}else 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(`
|
|
16
16
|
`).trim()}var Tt=B({name:`prismic docs`,description:`Browse Prismic documentation.`,commands:{list:{handler:vt,description:`List available documentation pages`},view:{handler:Ct,description:`View a documentation page`}}}),Et=z({name:`prismic env active`,description:`
|
|
17
17
|
Print the active environment.
|
|
18
18
|
|
|
19
19
|
@experimental - This command may change or be removed in any release and does not follow semver.
|
|
20
|
-
`},async()=>{let e=await n(),t=await(await w()).getEnvironment();console.info(t??e)});const Dt=D({email:k(),shortId:k(),intercomHash:k(),repositories:A(D({domain:k(),name:
|
|
20
|
+
`},async()=>{let e=await n(),t=await(await w()).getEnvironment();console.info(t??e)});const Dt=D({email:k(),shortId:k(),intercomHash:k(),repositories:A(D({domain:k(),name:N(k()),role:N(we([k(),Te(k(),k())]))}))});async function H(e){return Ot(new URL(`profile`,kt(e.host)),e,{schema:Dt,unknownErrorMessage:`Failed to load your profile`})}function Ot(e,t,n={}){return P(e,{credentials:{"prismic-auth":t.token},...n})}function kt(e){return new URL(`https://user-service.${e}/`)}async function At(e){let{repo:t,token:n,host:r}=e,[i,a]=await Promise.all([H({token:n,host:r}),fe({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 jt=class extends Error{name=`InvalidEnvironmentError`;repo;env;availableEnvironments;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(`
|
|
21
21
|
`);super(m`
|
|
22
22
|
Environment "${e}" not found on repository "${n}".
|
|
23
23
|
|
|
@@ -27,11 +27,11 @@ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
27
27
|
List the environments available for the project.
|
|
28
28
|
|
|
29
29
|
@experimental - This command may change or be removed in any release and does not follow semver.
|
|
30
|
-
`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({values:t})=>{let r=await n(),{json:i,repo:a=r}=t,{token:o,host:s}=await
|
|
30
|
+
`,options:{json:{type:`boolean`,description:`Output as JSON`},repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({values:t})=>{let r=await n(),{json:i,repo:a=r}=t,{token:o,host:s}=await R(),c=await At({repo:a,token:o,host:s}),l;if(a===r&&(l=await(await w()).getEnvironment()??r),i){let e=c.map(e=>({domain:e.domain,kind:e.kind,active:e.domain===l}));console.info(F(e));return}let u=c.map(e=>[e.domain,e.kind,e.domain===l?`*`:``]);console.info(e(u,{headers:[`DOMAIN`,`KIND`,`ACTIVE`]}))}),Nt=z({name:`prismic env set`,description:`
|
|
31
31
|
Set the active environment.
|
|
32
32
|
|
|
33
33
|
@experimental - This command may change or be removed in any release and does not follow semver.
|
|
34
|
-
`,positionals:{environment:{description:`Environment domain`,required:!0}}},async({positionals:e})=>{let[t]=e,r=await n(),{token:i,host:a}=await
|
|
34
|
+
`,positionals:{environment:{description:`Environment domain`,required:!0}}},async({positionals:e})=>{let[t]=e,r=await n(),{token:i,host:a}=await R(),o=await At({repo:r,token:i,host:a});if(!o.some(e=>e.domain===t))throw new jt(t,o,r);let s=await w();if(t===r){await s.unsetEnvironment(),console.info(`Reset to the production environment "${r}".`);return}await s.setEnvironment(t),console.info(`Set the active environment to "${t}".`)}),Pt=z({name:`prismic env unset`,description:`
|
|
35
35
|
Reset the active environment to the production environment.
|
|
36
36
|
|
|
37
37
|
@experimental - This command may change or be removed in any release and does not follow semver.
|
|
@@ -115,15 +115,15 @@ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
115
115
|
|
|
116
116
|
Restrict a rich text field to a single block:
|
|
117
117
|
prismic field edit subtitle --from-type blog_post --single
|
|
118
|
-
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...It,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},"default-value":{type:`string`,description:`Default value (boolean: true/false, select: option value)`},"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)`},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)`}}},async({positionals:e,values:t})=>{let[n]=e,{field:r,save:i}=await Rt(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`:if(`default-value`in t){let e=t[`default-value`];if(e!==`true`&&e!==`false`)throw new V(`--default-value for boolean fields must be "true" or "false"`);r.config.default_value=e===`true`}`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=ln(t.min,`min`)),`max`in t&&(r.config.max=ln(t.max,`max`)),`step`in t&&(r.config.step=ln(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 V(`--allow accepts a single link type. Prismic links allow either one type or all types.`);else throw new V(`--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 V(`--field requires the field to be restricted to a custom type. Use --custom-type to specify one.`);if(e.length>1)throw new V(`--field requires the field to be restricted to a single custom type.`);let n=typeof e[0]==`string`?e[0]:e[0].id,i=await zt(t.field,n);r.config.customtypes=[{id:n,fields:i}]}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 V(`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 "".`);break}await i(),console.info(`Field updated: ${n}`)});function ln(e,t){if(e===void 0)return;let n=Number(e);if(Number.isNaN(n))throw new V(`--${t} must be a valid number, got "${e}"`);return n}var un=z({name:`prismic field remove`,description:`Remove a field from a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:It},async({positionals:e,values:t})=>{let[n]=e,{fields:r,fieldId:i,save:a}=await Rt(n,t);delete r[i],await a(),console.info(`Field removed: ${n}`)}),dn=z({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`},...It}},async({positionals:e,values:t})=>{let[n]=e,{key:r,value:i}=dt(t,[`before`,`after`]);if(n===i)throw new V(`Cannot reorder "${n}" relative to itself.`);let a=n.lastIndexOf(`.`),o=i.lastIndexOf(`.`);if((a===-1?``:n.slice(0,a))!==(o===-1?``:i.slice(0,o)))throw new V(`Cannot reorder "${n}" relative to "${i}": fields must be in the same container.`);let{source:s,anchor:c,save:l}=await Lt(n,i,t);y(s.fields,s.fieldId,c.fields,c.fieldId,r),await l(),console.info(`Field reordered: ${n}`)}),fn=z({name:`prismic field view`,description:`View details of a field in a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:{...It,json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{field:r,fieldId:i}=await Rt(n,t);if(t.json){console.info(
|
|
118
|
+
`},positionals:{id:{description:`Field ID`,required:!0}},options:{...It,label:{type:`string`,description:`Field label`},placeholder:{type:`string`,description:`Placeholder text`},"default-value":{type:`string`,description:`Default value (boolean: true/false, select: option value)`},"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)`},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)`}}},async({positionals:e,values:t})=>{let[n]=e,{field:r,save:i}=await Rt(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`:if(`default-value`in t){let e=t[`default-value`];if(e!==`true`&&e!==`false`)throw new V(`--default-value for boolean fields must be "true" or "false"`);r.config.default_value=e===`true`}`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=ln(t.min,`min`)),`max`in t&&(r.config.max=ln(t.max,`max`)),`step`in t&&(r.config.step=ln(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 V(`--allow accepts a single link type. Prismic links allow either one type or all types.`);else throw new V(`--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 V(`--field requires the field to be restricted to a custom type. Use --custom-type to specify one.`);if(e.length>1)throw new V(`--field requires the field to be restricted to a single custom type.`);let n=typeof e[0]==`string`?e[0]:e[0].id,i=await zt(t.field,n);r.config.customtypes=[{id:n,fields:i}]}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 V(`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 "".`);break}await i(),console.info(`Field updated: ${n}`)});function ln(e,t){if(e===void 0)return;let n=Number(e);if(Number.isNaN(n))throw new V(`--${t} must be a valid number, got "${e}"`);return n}var un=z({name:`prismic field remove`,description:`Remove a field from a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:It},async({positionals:e,values:t})=>{let[n]=e,{fields:r,fieldId:i,save:a}=await Rt(n,t);delete r[i],await a(),console.info(`Field removed: ${n}`)}),dn=z({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`},...It}},async({positionals:e,values:t})=>{let[n]=e,{key:r,value:i}=dt(t,[`before`,`after`]);if(n===i)throw new V(`Cannot reorder "${n}" relative to itself.`);let a=n.lastIndexOf(`.`),o=i.lastIndexOf(`.`);if((a===-1?``:n.slice(0,a))!==(o===-1?``:i.slice(0,o)))throw new V(`Cannot reorder "${n}" relative to "${i}": fields must be in the same container.`);let{source:s,anchor:c,save:l}=await Lt(n,i,t);y(s.fields,s.fieldId,c.fields,c.fieldId,r),await l(),console.info(`Field reordered: ${n}`)}),fn=z({name:`prismic field view`,description:`View details of a field in a slice or custom type.`,positionals:{id:{description:`Field ID`,required:!0}},options:{...It,json:{type:`boolean`,description:`Output as JSON`}}},async({positionals:e,values:t})=>{let[n]=e,{field:r,fieldId:i}=await Rt(n,t);if(t.json){console.info(F({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 Array.isArray(t)?console.info(`${l(e)}: ${t.join(`, `)}`):console.info(`${l(e)}: ${t}`)}}),pn=B({name:`prismic field`,description:`Manage fields in slices and content types.`,commands:{add:{handler:sn,description:`Add a field`},edit:{handler:cn,description:`Edit a field`},remove:{handler:un,description:`Remove a field`},reorder:{handler:dn,description:`Reorder a field`},view:{handler:fn,description:`View details of a field`}}}),mn=z({name:`prismic gen setup`,description:`
|
|
119
119
|
Generate framework-specific setup files for a Prismic project.
|
|
120
120
|
|
|
121
121
|
Installs dependencies, creates the Prismic client file, slice simulator
|
|
122
122
|
page, preview routes, and other files required by the detected framework.
|
|
123
123
|
Skips files that already exist.
|
|
124
|
-
`,options:{"no-install":{type:`boolean`,description:`Skip installing dependencies`}}},async({values:e})=>{if(await(await w()).setupProject(),!e[`no-install`])try{console.info(`Installing dependencies...`),await
|
|
124
|
+
`,options:{"no-install":{type:`boolean`,description:`Skip installing dependencies`}}},async({values:e})=>{if(await(await w()).setupProject(),!e[`no-install`])try{console.info(`Installing dependencies...`),await He()}catch{console.warn("Could not install dependencies automatically. Please install them manually (i.e. `npm install`).")}console.info(`Generated setup files.`)}),hn=z({name:`prismic gen slice-index`,description:`Generate the slice index file of each slice library.`},async()=>{let e=await w(),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.`)}),gn=z({name:`prismic gen types`,description:`Generate TypeScript types for slices and content types.`},async()=>{let e=await(await w()).generateTypes(),t=I(await _(),e);console.info(`Generated types at ${t}`)}),_n=B({name:`prismic gen`,description:`Generate files from local Prismic models.`,commands:{setup:{handler:mn,description:`Generate framework-specific Prismic setup`},"slice-index":{handler:hn,description:`Generate the slice index file of each slice library`},types:{handler:gn,description:`Generate TypeScript types from local models`}}});function vn(e){it(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start ""`:`xdg-open`} "${e.toString()}"`)}function G(e,t,n){let{getKey:r,equals:i=(e,t)=>JSON.stringify(e)===JSON.stringify(t)}=n,a={insert:[],update:[],delete:[]};for(let n of e){let e=t.find(e=>r(e)===r(n));e?i(n,e)||a.update.push(n):a.insert.push(n)}for(let n of t)e.some(e=>r(e)===r(n))||a.delete.push(n);return a}function yn(e){return K(new URL(`customtypes`,q(e.host)),e)}async function bn(e,t){await K(new URL(`customtypes/insert`,q(t.host)),t,{method:`POST`,json:e,unknownErrorMessage:`Failed to create type "${e.id}"`})}async function xn(e,t){await K(new URL(`customtypes/update`,q(t.host)),t,{method:`POST`,json:e,notFoundMessage:`Type not found: ${e.id}`,unknownErrorMessage:`Failed to update type "${e.id}"`})}async function Sn(e,t){await K(new URL(`customtypes/${encodeURIComponent(e)}`,q(t.host)),t,{method:`DELETE`,notFoundMessage:`Type not found: ${e}`,unknownErrorMessage:`Failed to delete type "${e}"`})}function Cn(e){return K(new URL(`slices`,q(e.host)),e)}async function wn(e,t){await K(new URL(`slices/insert`,q(t.host)),t,{method:`POST`,json:e,unknownErrorMessage:`Failed to create slice "${e.id}"`})}async function Tn(e,t){await K(new URL(`slices/update`,q(t.host)),t,{method:`POST`,json:e,notFoundMessage:`Slice not found: ${e.id}`,unknownErrorMessage:`Failed to update slice "${e.id}"`})}async function En(e,t){await K(new URL(`slices/${encodeURIComponent(e)}`,q(t.host)),t,{method:`DELETE`,notFoundMessage:`Slice not found: ${e}`,unknownErrorMessage:`Failed to delete slice "${e}"`})}const Dn=D({values:D({url:k(),fields:Te(k(),k())}),imgixEndpoint:k()}),On={"image/png":`.png`,"image/jpeg":`.jpg`,"image/gif":`.gif`,"image/webp":`.webp`};async function kn(e,t){await Mn(new URL(`delete`,Nn(t.host)),t,{method:`POST`,json:{sliceId:e}})}async function An(e,t){let{sliceId:n,variationId:r,repo:i,host:a}=t,o=e.type;if(!(o in On))throw new jn(o);let s=await Mn(new URL(`presigned-url`,Nn(a)),t,{schema:Dn}),c=On[o],l=`${i}/shared-slices/${n}/${r}/${rt(`sha1`).update(new Uint8Array(await e.arrayBuffer())).digest(`hex`)}${c}`,u=new FormData;for(let[e,t]of Object.entries(s.values.fields))u.append(e,t);u.set(`key`,l),u.set(`Content-Type`,o),u.set(`file`,e),await P(s.values.url,{method:`POST`,body:u});let d=new URL(l,M(s.imgixEndpoint));return d.searchParams.set(`auto`,`compress,format`),d}var jn=class extends Error{name=`UnsupportedFileTypeError`;constructor(e){super(`Unsupported file type: ${e||`unknown`}. Supported: ${Object.keys(On).join(`, `)}`)}};function K(e,t,n={}){return P(e,{headers:{repository:t.repo,Authorization:`Bearer ${t.token}`},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function Mn(e,t,n={}){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),P(r,{headers:{repository:t.repo,Authorization:`Bearer ${t.token}`},...n})}function q(e){return new URL(`https://customtypes.${e}/`)}function Nn(e){return new URL(`https://api.internal.${e}/screenshot/`)}async function Pn(e,t){let{repo:n,token:r,host:i}=t,{completedSteps:a}=await oe({repo:n,token:r,host:i}),o=e.filter(e=>!a.includes(e));for(let e of o)await p(e,{repo:n,token:r,host:i})}let J;const Y={tags:{},contexts:{}};function Fn(e){J=e,Y.contexts.Process={command:process.argv.join(` `),cwd:process.cwd()}}function In(e,t){Y.tags[e]=t}function Ln(e,t){Y.contexts[e]=t}function Rn(e){Y.user=e}async function zn(e){if(J)try{let t=new URL(J.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:J.appVersion,environment:J.environment||Bn(J.appVersion),tags:Y.tags,user:Y.user,contexts:{...Y.contexts,runtime:{name:`node`,version:process.versions.node}},exception:{values:[{type:n.name,value:n.message.slice(0,2500),stacktrace:Hn(n)}]},extra:{cause:n.cause,fullCommand:process.argv.join(` `)}},a=[JSON.stringify({event_id:r,sent_at:new Date().toISOString()}),JSON.stringify({type:`event`}),JSON.stringify(i)].join(`
|
|
125
125
|
`);await fetch(Vn(t),{method:`POST`,headers:{"Content-Type":`application/x-sentry-envelope`,"X-Sentry-Auth":`Sentry sentry_version=7, sentry_client=${J.appName}/${J.appVersion}, sentry_key=${t.username}`},body:a,signal:AbortSignal.timeout(2e3)})}catch{}}function Bn(e){let t=e.match(/-(.+?)\./);return t?t[1]:`production`}function Vn(e){return`${e.protocol}//${e.host}/api${e.pathname}/envelope/`}function Hn(e){let t=[];for(let n of(e.stack??``).split(`
|
|
126
|
-
`).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}async function Un(){if(process.env.AI_AGENT)return process.env.AI_AGENT.toLowerCase();if(process.env.CLAUDE_CODE_IS_COWORK===`1`||process.env.CLAUDE_CODE_IS_COWORK===`true`)return`claude-cowork`;if(process.env.CLAUDECODE===`1`||process.env.CLAUDE_CODE)return`claude-code`;if(process.env.CODEX_CI===`1`||process.env.CODEX_SANDBOX||process.env.CODEX_THREAD_ID)return`codex`;if(process.env.CURSOR_AGENT===`1`||process.env.CURSOR_EXTENSION_HOST_ROLE===`agent-exec`)return`cursor`;if(process.env.CLINE_ACTIVE===`true`)return`cline`;if(process.env.ANTIGRAVITY_AGENT)return`antigravity`;if(process.env.AUGMENT_AGENT===`1`)return`augment`;if(process.env.OPENCODE_CLIENT===`1`)return`opencode`;if(process.env.GEMINI_CLI===`1`)return`gemini-cli`;if(process.env.TRAE_AI_SHELL_ID)return`trae`;if(process.env.REPL_ID)return`replit`;if(process.env.COPILOT_MODEL||process.env.COPILOT_ALLOW_ALL||process.env.COPILOT_GITHUB_TOKEN)return`github-copilot`;let e=process.env.AGENT?.toLowerCase();if(e===`goose`||e===`amp`)return e;if(process.platform===`linux`&&await De(new URL(`file:///opt/.devin`)))return`devin`;if(process.env.IS_SANDBOX===`yes`)return`unknown-sandbox`}const Wn=D({id:k(),label:k(),customName:Se(k()),isMaster:O()});async function Gn(e){return(await Jn(new URL(`repository/locales`,Yn(e.host)),e,{schema:D({results:A(Wn)}),unknownErrorMessage:`Failed to load locales`})).results}async function Kn(e,t){return Jn(new URL(`repository/locales`,Yn(t.host)),t,{method:`POST`,json:{id:e.id,isMaster:e.isMaster??!1,...e.customName?{customName:e.customName}:{}},schema:Wn,unknownErrorMessage:`Failed to save locale`})}async function qn(e,t){await Jn(new URL(`repository/locales/${encodeURIComponent(e)}`,Yn(t.host)),t,{method:`DELETE`,notFoundMessage:`Locale not found: ${e}`,unknownErrorMessage:`Failed to remove locale`})}function Jn(e,t,n){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),
|
|
126
|
+
`).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}async function Un(){if(process.env.AI_AGENT)return process.env.AI_AGENT.toLowerCase();if(process.env.CLAUDE_CODE_IS_COWORK===`1`||process.env.CLAUDE_CODE_IS_COWORK===`true`)return`claude-cowork`;if(process.env.CLAUDECODE===`1`||process.env.CLAUDE_CODE)return`claude-code`;if(process.env.CODEX_CI===`1`||process.env.CODEX_SANDBOX||process.env.CODEX_THREAD_ID)return`codex`;if(process.env.CURSOR_AGENT===`1`||process.env.CURSOR_EXTENSION_HOST_ROLE===`agent-exec`)return`cursor`;if(process.env.CLINE_ACTIVE===`true`)return`cline`;if(process.env.ANTIGRAVITY_AGENT)return`antigravity`;if(process.env.AUGMENT_AGENT===`1`)return`augment`;if(process.env.OPENCODE_CLIENT===`1`)return`opencode`;if(process.env.GEMINI_CLI===`1`)return`gemini-cli`;if(process.env.TRAE_AI_SHELL_ID)return`trae`;if(process.env.REPL_ID)return`replit`;if(process.env.COPILOT_MODEL||process.env.COPILOT_ALLOW_ALL||process.env.COPILOT_GITHUB_TOKEN)return`github-copilot`;let e=process.env.AGENT?.toLowerCase();if(e===`goose`||e===`amp`)return e;if(process.platform===`linux`&&await De(new URL(`file:///opt/.devin`)))return`devin`;if(process.env.IS_SANDBOX===`yes`)return`unknown-sandbox`}const Wn=D({id:k(),label:k(),customName:Se(k()),isMaster:O()});async function Gn(e){return(await Jn(new URL(`repository/locales`,Yn(e.host)),e,{schema:D({results:A(Wn)}),unknownErrorMessage:`Failed to load locales`})).results}async function Kn(e,t){return Jn(new URL(`repository/locales`,Yn(t.host)),t,{method:`POST`,json:{id:e.id,isMaster:e.isMaster??!1,...e.customName?{customName:e.customName}:{}},schema:Wn,unknownErrorMessage:`Failed to save locale`})}async function qn(e,t){await Jn(new URL(`repository/locales/${encodeURIComponent(e)}`,Yn(t.host)),t,{method:`DELETE`,notFoundMessage:`Locale not found: ${e}`,unknownErrorMessage:`Failed to remove locale`})}function Jn(e,t,n){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),P(r,{headers:{Authorization:`Bearer ${t.token}`},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function Yn(e){return new URL(`https://api.internal.${e}/locale/`)}async function Xn(e){await Zn(new URL(`activation`,Qn(e.host)),e,{method:`POST`})}function Zn(e,t,n={}){let r=new URL(e);return r.searchParams.set(`repository`,t.repo),P(r,{credentials:{"prismic-auth":t.token},...n})}function Qn(e){return new URL(`https://api.internal.${e}/mcp/`)}const $n=D({documentsPublished:O(),documentsUnpublished:O(),releasesCreated:O(),releasesUpdated:O(),tagsCreated:O(),tagsDeleted:O()}),er=Object.keys($n.shape),tr=D({config:Fe($n,{_id:k(),url:k(),active:O(),name:Se(k()),secret:Se(k()),headers:Te(k(),k())})});function X(e){let{repo:t,host:n}=e;return Z(new URL(`app/settings/webhooks`,Q(t,n)),e,{schema:A(tr),unknownErrorMessage:`Failed to load webhooks`})}async function nr(e,t){let n=new FormData;n.set(`url`,e.url),n.set(`name`,e.name??``),n.set(`secret`,e.secret??``),n.set(`headers`,JSON.stringify({})),n.set(`active`,`on`),n.set(`documentsPublished`,e.documentsPublished.toString()),n.set(`documentsUnpublished`,e.documentsUnpublished.toString()),n.set(`releasesCreated`,e.releasesCreated.toString()),n.set(`releasesUpdated`,e.releasesUpdated.toString()),n.set(`tagsCreated`,e.tagsCreated.toString()),n.set(`tagsDeleted`,e.tagsDeleted.toString());let{repo:r,host:i}=t;await Z(new URL(`app/settings/webhooks/create`,Q(r,i)),t,{method:`POST`,body:n,unknownErrorMessage:`Failed to create webhook`})}async function rr(e,t,n){let r=new FormData;r.set(`url`,t.url),r.set(`name`,t.name??``),r.set(`secret`,t.secret??``),r.set(`headers`,JSON.stringify(t.headers??{})),r.set(`active`,t.active?`on`:`off`),r.set(`documentsPublished`,t.documentsPublished.toString()),r.set(`documentsUnpublished`,t.documentsUnpublished.toString()),r.set(`releasesCreated`,t.releasesCreated.toString()),r.set(`releasesUpdated`,t.releasesUpdated.toString()),r.set(`tagsCreated`,t.tagsCreated.toString()),r.set(`tagsDeleted`,t.tagsDeleted.toString());let{repo:i,host:a}=n;await Z(new URL(`app/settings/webhooks/${encodeURIComponent(e)}`,Q(i,a)),n,{method:`POST`,body:r,notFoundMessage:`Webhook not found: ${e}`,unknownErrorMessage:`Failed to update webhook`})}async function ir(e,t){let{repo:n,host:r}=t;await Z(new URL(`app/settings/webhooks/${encodeURIComponent(e)}/delete`,Q(n,r)),t,{method:`POST`,notFoundMessage:`Webhook not found: ${e}`,unknownErrorMessage:`Failed to delete webhook`})}const ar=D({id:k(),scope:k(),token:k(),created_at:D({$date:je()})}),or=D({id:k(),name:k(),wroom_auths:A(ar)}),sr=D({app_name:k(),token:k(),timestamp:je()}),cr=D({max_tokens:je(),tokens:A(sr)});function lr(e){let{repo:t,host:n}=e;return Z(new URL(`settings/security/contentapi`,Q(t,n)),e,{schema:A(or),unknownErrorMessage:`Failed to load OAuth apps`})}async function ur(e,t){let{repo:n,host:r}=t;return Z(new URL(`settings/security/oauthapp`,Q(n,r)),t,{method:`POST`,json:{app_name:e},schema:or,unknownErrorMessage:`Failed to create OAuth app`})}async function dr(e,t,n){let{repo:r,host:i}=n;return Z(new URL(`settings/security/authorizations`,Q(r,i)),n,{method:`POST`,json:{app:e,scope:t},schema:ar,unknownErrorMessage:`Failed to create token`})}async function fr(e,t){let{repo:n,host:r}=t;await Z(new URL(`settings/security/authorizations/${encodeURIComponent(e)}`,Q(n,r)),t,{method:`DELETE`,notFoundMessage:`Token not found: ${e}`,unknownErrorMessage:`Failed to delete token`})}function pr(e){let{repo:t,host:n}=e;return Z(new URL(`settings/security/customtypesapi`,Q(t,n)),e,{schema:cr,unknownErrorMessage:`Failed to load write tokens`})}async function mr(e,t){let{repo:n,host:r}=t;return Z(new URL(`settings/security/token`,Q(n,r)),t,{method:`POST`,json:{app_name:e},schema:sr,unknownErrorMessage:`Failed to create write token`})}async function hr(e,t){let{repo:n,host:r}=t;await Z(new URL(`settings/security/token/${encodeURIComponent(e)}`,Q(n,r)),t,{method:`DELETE`,notFoundMessage:`Token not found`,unknownErrorMessage:`Failed to delete write token`})}async function gr(e){let{domain:t,host:n}=e;return Cr(new URL(`app/dashboard/repositories/${encodeURIComponent(t)}/exists`,wr(n)),e,{schema:O()})}async function _r(e){let{domain:t,name:n,framework:r,agent:i,host:a}=e,o=new URL(`app/dashboard/repositories`,wr(a));o.searchParams.set(`app`,`cli`),i&&o.searchParams.set(`agent`,i),await Cr(o,e,{method:`POST`,json:{domain:t,name:n,framework:r,plan:`personal`},unknownErrorMessage:`Failed to create repository`})}const vr=D({repository:D({api_access:k()})});async function yr(e){let{repo:t,host:n}=e;return(await Z(new URL(`syncState`,Q(t,n)),e,{schema:vr,unknownErrorMessage:`Failed to load repository access`})).repository.api_access}async function br(e,t){let{repo:n,host:r}=t;await Z(new URL(`settings/security/apiaccess`,Q(n,r)),t,{method:`POST`,json:{api_access:e},unknownErrorMessage:`Failed to set repository access`})}const xr=D({repository:D({name:k()})});async function Sr(e,t){let n=new FormData;n.set(`displayname`,e);let{repo:r,host:i}=t;return(await Z(new URL(`app/settings/repository`,Q(r,i)),t,{method:`POST`,body:n,schema:xr,unknownErrorMessage:`Failed to set repository name`})).repository.name}function Z(e,t,n={}){return P(e,{credentials:{"prismic-auth":t.token},notFoundMessage:`Repository not found: ${t.repo}`,...n})}function Cr(e,t,n={}){return P(e,{credentials:{"prismic-auth":t.token},...n})}function Q(e,t){return new URL(`https://${e}.${t}/`)}function wr(e){return new URL(`https://${e}/`)}var Tr=z({name:`prismic repo create`,description:`Create a new Prismic repository.`,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)`}}},async({values:e})=>{let{name:t,lang:n}=e,{token:r,host:i}=await R(),a=await Er({name:t,lang:n,token:r,host:i});console.info(`Repository created: ${a}`),console.info(`URL: https://${a}.${i}/`)});async function Er(e){let{name:t,lang:n=`en-us`,token:r,host:i}=e,a=await Dr({token:r,host:i});if(!a)throw new V(`Failed to create a repository. Please try again.`);let o=(await w().catch(()=>void 0))?.id??`other`,s=await Un();return await _r({domain:a,name:t??a,framework:o,agent:s,token:r,host:i}),await Kn({id:n,isMaster:!0},{repo:a,token:r,host:i}),await Pn([`createPrismicProject`],{repo:a,token:r,host:i}).catch(()=>{}),await Xn({repo:a,token:r,host:i}).catch(()=>{}),a}async function Dr(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 gr({domain:e,token:t,host:n})){r=e;break}}return r}var Or=z({name:`prismic init`,description:`
|
|
127
127
|
Initialize a new Prismic project by creating a repository and
|
|
128
128
|
prismic.config.json file. Detects the project framework, installs
|
|
129
129
|
dependencies, and pulls models from Prismic.
|
|
@@ -131,48 +131,52 @@ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
131
131
|
Use --repo to connect to an existing repository instead. If a
|
|
132
132
|
slicemachine.config.json exists, its repository and settings will be
|
|
133
133
|
migrated.
|
|
134
|
-
`,options:{repo:{type:`string`,short:`r`,description:`Repository name`},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})=>{let{repo:t,lang:n,"no-browser":i,"no-setup":a}=e,o;try{o=await ge()}catch(e){if(!(e instanceof se))throw e}if(o&&!t)throw new V("A prismic.config.json file exists. Use `prismic init --repo <repository>` to connect it to an existing repository.");let c=o!==void 0&&t!==void 0,l;if(!o)try{l=await v()}catch(e){e instanceof ne&&console.warn(`Could not read slicemachine.config.json, ignoring.`)}let{host:u,token:d}=await
|
|
134
|
+
`,options:{repo:{type:`string`,short:`r`,description:`Repository name`},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})=>{let{repo:t,lang:n,"no-browser":i,"no-setup":a}=e,o;try{o=await ge()}catch(e){if(!(e instanceof se))throw e}if(o&&!t)throw new V("A prismic.config.json file exists. Use `prismic init --repo <repository>` to connect it to an existing repository.");let c=o!==void 0&&t!==void 0,l;if(!o)try{l=await v()}catch(e){e instanceof ne&&console.warn(`Could not read slicemachine.config.json, ignoring.`)}let{host:u,token:d}=await R(),p=d,h;try{h=await H({token:p,host:u})}catch(e){if(e instanceof Ae||e instanceof Me){if(L.PRISMIC_TOKEN)throw new V(`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 Re({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}`),p=(await R()).token,h=await H({token:p,host:u})}else throw e}let g=(t??l?.repositoryName)?.toLowerCase(),_;if(g){if(!h.repositories.some(e=>e.domain===g))throw new V(`Repository "${g}" not found in your account. Check the name or request access to the repository.`);if(!await he(g,{token:p,host:u}))throw new ie(g,u);_=await f({repo:g,token:p,host:u})}let y=await w();g||(g=await Er({lang:n,token:p,host:u}),console.info(`Created repository: ${g}`));try{let e=u===Ie?void 0:`https://${g}.cdn.${u}/api/v2/`;o?await r({repositoryName:g,documentAPIEndpoint:e}):await te({repositoryName:g,documentAPIEndpoint:e,libraries:l?.libraries,routes:[]})}catch(e){throw e instanceof re?new V(`Could not find a package.json file. Run this command from a project directory.`):new V(`Failed to create prismic.config.json.`)}if(l){try{await _e()}catch{}let{dependencies:e,devDependencies:t,peerDependencies:n}=await Ge(),r=Object.keys({...e,...t,...n}).filter(e=>e===`slice-machine-ui`||e.startsWith(`@slicemachine/adapter-`));r.length>0&&await Ke(r),console.info(`Migrated slicemachine.config.json to prismic.config.json`)}if(await y.initProject({setup:!a&&!o}),!a)try{console.info(`Installing dependencies...`),await He()}catch{console.warn("Could not install dependencies automatically. Please install them manually (i.e. `npm install`).")}let[x,S,C,ee]=await Promise.all([yn({repo:g,token:p,host:u}),Cn({repo:g,token:p,host:u}),y.getCustomTypes(),y.getSlices()]),ae=C.map(e=>e.model),oe=G(S,ee.map(e=>e.model),{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(s(e))===JSON.stringify(s(t))}),T=G(x,ae,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(b(e))===JSON.stringify(b(t))});if(c&&_?.starter){if(x.length===0&&S.length===0)throw new V(`Repository "${g}" has no starter models. Use a repository created from the starter in the Prismic dashboard.`);await jr(_.starter)}let ce=c&&[T,oe].some(e=>e.update.length>0||e.delete.length>0);if(!ce){for(let e of oe.update)await y.updateSlice(e);for(let e of oe.delete)await y.deleteSlice(e.id);for(let e of oe.insert)await y.createSlice(e);for(let e of T.update)await y.updateCustomType(e);for(let e of T.delete)await y.deleteCustomType(e.id);for(let e of T.insert)await y.createCustomType(e)}await y.generateTypes(),ce&&console.warn(m`
|
|
135
135
|
Local and remote models differ, so no model files were changed. The project is connected.
|
|
136
136
|
|
|
137
137
|
Choose the source of truth:
|
|
138
138
|
prismic pull --force Adopt remote models
|
|
139
139
|
prismic push --force Keep local models
|
|
140
|
-
`),c&&_?.starter
|
|
140
|
+
`),c&&_?.starter?(await Ar(y,_.starter,{repo:g,token:p,host:u}),ce||(console.info(`
|
|
141
|
+
---`),console.info(`
|
|
142
|
+
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://${g}.${u}/builder to preview pages live`),console.info(`
|
|
143
|
+
Start building 🚀`))):(console.info(`
|
|
144
|
+
---`),console.info(`\nInitialized Prismic for repository "${g}".`),console.info("Run `prismic type create <name>` to create a content type."),console.info("Run `prismic pull` to pull models from Prismic."))});async function kr(e){let t=await Ge(),n=e.id.split(`/`).at(-1);return!!(n&&t.name===n)}async function Ar(e,t,n){try{let t=await ae(n);await Promise.all(t.filter(e=>e.label===`Starter Preview`).map(e=>le(e.id,n))),t.some(t=>t.url===e.localPreviewUrl)||await me(e.localPreviewConfig,n)}catch(t){await zn(t),console.error(`Could not configure the local preview. Run \`prismic preview add ${e.localPreviewUrl} --name ${e.localPreviewConfig.name}\` manually. Continuing.`)}try{await pe(e.localSimulatorUrl,n)}catch(t){await zn(t),console.error(`Could not configure the local slice simulator. Run \`prismic preview set-simulator ${e.localSimulatorUrl}\` manually. Continuing.`)}await Pn([`instantStart_continueBuildingLocally`],n).catch(()=>{}),await kr(t)&&await Ue(n.repo)}async function jr(e){if(!await kr(e))return;let t=await _();await Promise.all([et(new URL(`.deployment`,t),{recursive:!0,force:!0}),et(new URL(`documents`,t),{recursive:!0,force:!0})])}var Mr=z({name:`prismic locale add`,description:`
|
|
141
145
|
Add a locale to a Prismic repository.
|
|
142
146
|
|
|
143
147
|
By default, this command reads the repository from prismic.config.json at the
|
|
144
148
|
project root.
|
|
145
|
-
`,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 E(),master:a=!1,name:o}=t,{token:s,host:c}=await
|
|
149
|
+
`,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 E(),master:a=!1,name:o}=t,{token:s,host:c}=await R();await Kn({id:n,isMaster:a,customName:o},{repo:i,token:s,host:c}),console.info(`Locale added: ${n}`)}),Nr=z({name:`prismic locale list`,description:`
|
|
146
150
|
List all locales in a Prismic repository.
|
|
147
151
|
|
|
148
152
|
By default, this command reads the repository from prismic.config.json at the
|
|
149
153
|
project root.
|
|
150
|
-
`,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:t})=>{let{env:n,repo:r=n??await E(),json:i}=t,{token:a,host:o}=await
|
|
154
|
+
`,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:t})=>{let{env:n,repo:r=n??await E(),json:i}=t,{token:a,host:o}=await R(),s=await Gn({repo:r,token:a,host:o});if(i){console.info(F(s));return}if(s.length===0){console.info(`No locales found.`);return}let c=s.map(e=>{let t=e.isMaster?` (master)`:``;return[e.id,`${e.label}${t}`]});console.info(e(c,{headers:[`ID`,`LABEL`]}))}),Pr=z({name:`prismic locale remove`,description:`
|
|
151
155
|
Remove a locale from a Prismic repository.
|
|
152
156
|
|
|
153
157
|
By default, this command reads the repository from prismic.config.json at the
|
|
154
158
|
project root.
|
|
155
|
-
`,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 E()}=t,{token:a,host:o}=await
|
|
159
|
+
`,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 E()}=t,{token:a,host:o}=await R();await qn(n,{repo:i,token:a,host:o}),console.info(`Locale removed: ${n}`)}),Fr=z({name:`prismic locale set-master`,description:`
|
|
156
160
|
Set the master locale for a Prismic repository.
|
|
157
161
|
|
|
158
162
|
By default, this command reads the repository from prismic.config.json at the
|
|
159
163
|
project root.
|
|
160
|
-
`,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 E()}=t,{token:a,host:o}=await
|
|
164
|
+
`,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 E()}=t,{token:a,host:o}=await R(),s=await Gn({repo:i,token:a,host:o}),c=s.find(e=>e.id===n);if(!c)throw new V(`Locale "${n}" not found. Available locales: ${s.map(e=>e.id).join(`, `)}`);if(c.isMaster)throw new V(`Locale "${n}" is already the master.`);await Kn({id:c.id,isMaster:!0,customName:c.customName??void 0},{repo:i,token:a,host:o}),console.info(`Master locale set: ${n}`)}),Ir=B({name:`prismic locale`,description:`Manage locales in a Prismic repository.`,commands:{add:{handler:Mr,description:`Add a locale`},list:{handler:Nr,description:`List locales`},remove:{handler:Pr,description:`Remove a locale`},"set-master":{handler:Fr,description:`Set the master locale`}}}),Lr=z({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 Re({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}`)}),Rr=z({name:`prismic logout`,description:`Log out of Prismic.`},async()=>{if(await Le())console.info(`Logged out of Prismic`);else throw new V(`Logout failed. You can log out manually by deleting the file.`)}),zr=z({name:`prismic preview add`,description:`
|
|
161
165
|
Add a preview configuration to a Prismic repository.
|
|
162
166
|
|
|
163
167
|
By default, this command reads the repository from prismic.config.json at the
|
|
164
168
|
project root.
|
|
165
|
-
`,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 E(),name:a}=t,o;try{o=new URL(n)}catch{throw new V(`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
|
|
169
|
+
`,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 E(),name:a}=t,o;try{o=new URL(n)}catch{throw new V(`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 R();await me({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.")}),Br=z({name:`prismic preview list`,description:`
|
|
166
170
|
List all preview configurations in a Prismic repository.
|
|
167
171
|
|
|
168
172
|
By default, this command reads the repository from prismic.config.json at the
|
|
169
173
|
project root.
|
|
170
|
-
`,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:t})=>{let{env:n,repo:r=n??await E(),json:i}=t,{token:a,host:o}=await
|
|
174
|
+
`,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:t})=>{let{env:n,repo:r=n??await E(),json:i}=t,{token:a,host:o}=await R(),[s,c]=await Promise.all([ae({repo:r,token:a,host:o}),ee({repo:r,token:a,host:o})]);if(i){console.info(F({previews:s,simulatorUrl:c??null}));return}if(s.length===0&&!c){console.info(`No preview configurations found.`);return}if(s.length>0){let t=s.map(e=>[e.url,e.label]);console.info(e(t,{headers:[`URL`,`NAME`]}))}c&&(s.length>0&&console.info(``),console.info(`Simulator: ${c}`))}),Vr=z({name:`prismic preview remove`,description:`
|
|
171
175
|
Remove a preview configuration from a Prismic repository.
|
|
172
176
|
|
|
173
177
|
By default, this command reads the repository from prismic.config.json at the
|
|
174
178
|
project root.
|
|
175
|
-
`,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 E()}=t,{token:a,host:o}=await
|
|
179
|
+
`,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 E()}=t,{token:a,host:o}=await R(),s=(await ae({repo:i,token:a,host:o})).find(e=>e.url===n);if(!s)throw new V(`Preview not found: ${n}`);await le(s.id,{repo:i,token:a,host:o}),console.info(`Preview removed: ${n}`)}),Hr=z({name:`prismic preview set-simulator`,description:`
|
|
176
180
|
Set the slice simulator URL for a Prismic repository.
|
|
177
181
|
|
|
178
182
|
If the URL pathname does not end with /slice-simulator, it is appended
|
|
@@ -180,13 +184,13 @@ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
180
184
|
|
|
181
185
|
By default, this command reads the repository from prismic.config.json at the
|
|
182
186
|
project root.
|
|
183
|
-
`,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 E()}=t,a;try{a=new URL(n)}catch{throw new V(`Invalid URL: ${n}`)}a.pathname.endsWith(`/slice-simulator`)||(a.pathname=a.pathname.replace(/\/+$/,``)+`/slice-simulator`);let o=a.toString(),{token:s,host:c}=await
|
|
187
|
+
`,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 E()}=t,a;try{a=new URL(n)}catch{throw new V(`Invalid URL: ${n}`)}a.pathname.endsWith(`/slice-simulator`)||(a.pathname=a.pathname.replace(/\/+$/,``)+`/slice-simulator`);let o=a.toString(),{token:s,host:c}=await R();await pe(o,{repo:i,token:s,host:c}),console.info(`Simulator URL set: ${o}`)}),Ur=B({name:`prismic preview`,description:`Manage preview configurations in a Prismic repository.`,commands:{add:{handler:zr,description:`Add a preview configuration`},list:{handler:Br,description:`List preview configurations`},remove:{handler:Vr,description:`Remove a preview configuration`},"set-simulator":{handler:Hr,description:`Set the slice simulator URL`}}});async function Wr(e){try{let{stdout:t}=await We(`git`,[`rev-parse`,`--show-toplevel`],{nodeOptions:{cwd:tt(e)},throwOnError:!0}),n=t.trim();return n?M(nt(await $e(n))):void 0}catch{return}}async function Gr(e){try{let{stdout:t}=await We(`git`,[`status`,`--porcelain`,`--untracked-files=all`],{nodeOptions:{cwd:tt(e)},throwOnError:!0}),n=[];for(let r of t.split(`
|
|
184
188
|
`)){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 Kr=z({name:`prismic pull`,description:`
|
|
185
189
|
Pull content types and slices from Prismic to local files.
|
|
186
190
|
|
|
187
191
|
Remote models are the source of truth. Local files are created, updated,
|
|
188
192
|
or deleted to match.
|
|
189
|
-
`,options:{force:{type:`boolean`,short:`f`,description:`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 w(),{force:r=!1,env:i,repo:a=i??await t.getEnvironment()??await n()}=e,{token:o,host:c}=await
|
|
193
|
+
`,options:{force:{type:`boolean`,short:`f`,description:`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 w(),{force:r=!1,env:i,repo:a=i??await t.getEnvironment()??await n()}=e,{token:o,host:c}=await R(),l=await _();console.info(`Pulling from repository: ${a}`);let[u,d,f]=await Promise.all([Wr(l),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!r&&u){let e=(await Gr(u)).filter(e=>e.pathname.endsWith(`/model.json`)&&f.some(t=>j(t,e))||e.pathname.endsWith(`/index.json`)&&d.some(t=>j(t,e))).map(e=>I(l,e));if(e.length>0)throw new V(`
|
|
190
194
|
Local model files have uncommitted changes. Commit them first so a
|
|
191
195
|
pull won't silently discard your edits:
|
|
192
196
|
|
|
@@ -197,7 +201,7 @@ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
197
201
|
Other options:
|
|
198
202
|
prismic push --force Keep local edits, overwrite remote
|
|
199
203
|
prismic pull --force Discard local edits, adopt remote
|
|
200
|
-
`)}let[p,m,h,g]=await Promise.all([t.getCustomTypes(),t.getSlices(),yn({repo:a,token:o,host:c}),Cn({repo:a,token:o,host:c})]),v=G(h,p.map(e=>e.model),{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(b(e))===JSON.stringify(t)}),y=G(g,m.map(e=>e.model),{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(s(e))===JSON.stringify(t)});if(!r&&!u){let e=new Set([...v.update,...v.delete].map(e=>e.id)),t=new Set([...y.update,...y.delete].map(e=>e.id)),n=[...p.filter(t=>e.has(t.model.id)),...m.filter(e=>t.has(e.model.id))].map(e=>
|
|
204
|
+
`)}let[p,m,h,g]=await Promise.all([t.getCustomTypes(),t.getSlices(),yn({repo:a,token:o,host:c}),Cn({repo:a,token:o,host:c})]),v=G(h,p.map(e=>e.model),{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(b(e))===JSON.stringify(t)}),y=G(g,m.map(e=>e.model),{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(s(e))===JSON.stringify(t)});if(!r&&!u){let e=new Set([...v.update,...v.delete].map(e=>e.id)),t=new Set([...y.update,...y.delete].map(e=>e.id)),n=[...p.filter(t=>e.has(t.model.id)),...m.filter(e=>t.has(e.model.id))].map(e=>I(l,e.modelPath));if(n.length>0)throw new V(`
|
|
201
205
|
Pull would modify or delete local model files:
|
|
202
206
|
${n.join(`
|
|
203
207
|
`)}
|
|
@@ -210,7 +214,7 @@ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
210
214
|
|
|
211
215
|
Local models are the source of truth. Remote models are created,
|
|
212
216
|
updated, or deleted to match.
|
|
213
|
-
`,options:{force:{type:`boolean`,short:`f`,description:`Skip safety 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 w(),{force:r=!1,env:i,repo:a=i??await t.getEnvironment()??await n()}=e,{token:o,host:c}=await
|
|
217
|
+
`,options:{force:{type:`boolean`,short:`f`,description:`Skip safety 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 w(),{force:r=!1,env:i,repo:a=i??await t.getEnvironment()??await n()}=e,{token:o,host:c}=await R(),l=await _();console.info(`Pushing to repository: ${a}`);let[u,d,f]=await Promise.all([Wr(l),t.getCustomTypeLibraries(),t.getSliceLibraries()]);if(!r&&u){let e=(await Gr(u)).filter(e=>e.pathname.endsWith(`/model.json`)&&f.some(t=>j(t,e))||e.pathname.endsWith(`/index.json`)&&d.some(t=>j(t,e))).map(e=>I(l,e));if(e.length>0)throw new V(`
|
|
214
218
|
Local model files have uncommitted changes. Commit them, then push:
|
|
215
219
|
|
|
216
220
|
git add ${e.join(` `)}
|
|
@@ -218,7 +222,7 @@ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
218
222
|
prismic push
|
|
219
223
|
|
|
220
224
|
Or skip the safety check with \`prismic push --force\`.
|
|
221
|
-
`)}let[p,m,h,g]=await Promise.all([t.getCustomTypes(),t.getSlices(),yn({repo:a,token:o,host:c}),Cn({repo:a,token:o,host:c})]),v=G(p.map(e=>e.model),h,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(b(e))===JSON.stringify(b(t))}),y=G(m.map(e=>e.model),g,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(s(e))===JSON.stringify(s(t))});if(!r){let e=M(d[0]),t=M(f[0]),n=[...v.delete.map(t=>
|
|
225
|
+
`)}let[p,m,h,g]=await Promise.all([t.getCustomTypes(),t.getSlices(),yn({repo:a,token:o,host:c}),Cn({repo:a,token:o,host:c})]),v=G(p.map(e=>e.model),h,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(b(e))===JSON.stringify(b(t))}),y=G(m.map(e=>e.model),g,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(s(e))===JSON.stringify(s(t))});if(!r){let e=M(d[0]),t=M(f[0]),n=[...v.delete.map(t=>I(l,new URL(`${t.id}/index.json`,e))),...y.delete.map(e=>I(l,new URL(`${C(e.name)}/model.json`,t)))];if(n.length>0)throw new V(`
|
|
222
226
|
Push would delete remote models. Re-run with --force to proceed.
|
|
223
227
|
|
|
224
228
|
Models that would be deleted:
|
|
@@ -226,33 +230,33 @@ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K a
|
|
|
226
230
|
`)}
|
|
227
231
|
`)}for(let e of v.insert)await bn(e,{repo:a,token:o,host:c});for(let e of v.update)await xn(e,{repo:a,token:o,host:c});for(let e of v.delete)await Jr(e,{repo:a,token:o,host:c});for(let e of y.insert)await wn(e,{repo:a,token:o,host:c});for(let e of y.update)await Tn(e,{repo:a,token:o,host:c});for(let e of y.delete.map(e=>e.id))await En(e,{repo:a,token:o,host:c}),await kn(e,{repo:a,token:o,host:c}).catch(t=>{let n=t instanceof Error?t.message:String(t);console.warn(`Failed to delete screenshots for slice "${e}"${n?`: ${n}`:`.`}`)});let x=[];y.insert.length>0&&x.push(`createSlice`),v.insert.some(e=>e.format===`page`)&&x.push(`createPageType`),x.length>0&&await Pn(x,{repo:await n(),token:o,host:c}).catch(()=>{});let S=v.insert.length+v.update.length,ee=y.insert.length+y.update.length,te=v.delete.length+y.delete.length;S===0&&ee===0&&te===0?console.info(`Already up to date.`):(console.info(`Pushed ${S} type(s), ${ee} slice(s).`),te>0&&console.info(`Deleted ${te} model(s).`))});async function Jr(e,t){let{repo:n,token:r,host:i}=t,{id:a,format:o}=e;try{await Sn(a,{repo:n,token:r,host:i})}catch(e){if(!await Yr(e))throw new V(`Could not delete type "${a}": ${e instanceof Error?e.message:String(e)}"
|
|
228
232
|
Please try again, or manually deleting the type at: `+Xr({repo:n,host:i,format:o??`custom`}));let t;try{t=await ce(a,{repo:n,token:r,host:i})}catch{throw new V(`Could not check whether type "${a}" has associated pages.
|
|
229
|
-
Please try again, or manually delete any associated pages at: `+Zr({repo:n,host:i,customTypeId:a}))}throw new V(`Could not delete type "${a}" because it has${t>0?` ${t}`:``} associated ${t===1?`page`:`pages`}. \nDelete any associated pages manually before pushing at: `+Zr({repo:n,host:i,customTypeId:a}))}}async function Yr(e){if(!(e instanceof
|
|
233
|
+
Please try again, or manually delete any associated pages at: `+Zr({repo:n,host:i,customTypeId:a}))}throw new V(`Could not delete type "${a}" because it has${t>0?` ${t}`:``} associated ${t===1?`page`:`pages`}. \nDelete any associated pages manually before pushing at: `+Zr({repo:n,host:i,customTypeId:a}))}}async function Yr(e){if(!(e instanceof Pe))return!1;let t=await e.text();return t.includes(`associated documents`)||t.includes(`Delete all documents belonging`)}function Xr(e){let{repo:t,host:n,format:r}=e,i=r===`custom`?`custom-types`:`page-types`;return new URL(`builder/types/${i}`,`https://${t}.${n}/`).href}function Zr(e){let{repo:t,host:n,customTypeId:r}=e,i=new URL(`builder/working`,`https://${t}.${n}/`);return i.searchParams.set(`customTypes`,r),i.href}var Qr=z({name:`prismic repo list`,description:`List all Prismic repositories associated with your account.`,options:{json:{type:`boolean`,description:`Output as JSON`}}},async({values:t})=>{let{json:n}=t,{token:r,host:i}=await R(),a=(await H({token:r,host:i})).repositories;if(n){console.info(F(a.map(e=>({domain:e.domain,name:e.name??null,role:e.role??null,url:`https://${e.domain}.${i}/`}))));return}if(a.length===0){console.info(`No repositories found.`);return}let o=a.map(e=>{let t=e.name||`(no name)`;return[e.domain,t,$r(e.role)]});console.info(e(o,{headers:[`DOMAIN`,`NAME`,`ROLE`]}))});function $r(e){return typeof e==`string`?e:e?Object.entries(e).map(([e,t])=>`${t} (${e})`).join(`, `):``}const ei=[`private`,`public`,`open`];var ti=z({name:`prismic repo set-api-access`,description:`
|
|
230
234
|
Set the Content API access level of a Prismic repository.
|
|
231
235
|
|
|
232
236
|
By default, this command reads the repository from prismic.config.json at the
|
|
233
237
|
project root.
|
|
234
|
-
`,positionals:{level:{description:`Access level (${ei.join(`, `)})`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({positionals:e,values:t})=>{let[r]=e,{repo:i=await n()}=t;if(!ei.includes(r))throw new V(`Invalid access level: ${r}. Must be one of: ${ei.join(`, `)}`);let{token:a,host:o}=await
|
|
238
|
+
`,positionals:{level:{description:`Access level (${ei.join(`, `)})`,required:!0}},options:{repo:{type:`string`,short:`r`,description:`Repository domain`}}},async({positionals:e,values:t})=>{let[r]=e,{repo:i=await n()}=t;if(!ei.includes(r))throw new V(`Invalid access level: ${r}. Must be one of: ${ei.join(`, `)}`);let{token:a,host:o}=await R();await br(r,{repo:i,token:a,host:o}),console.info(`Repository access set to: ${r}`)}),ni=z({name:`prismic repo set-name`,description:`
|
|
235
239
|
Set the display name of a Prismic repository.
|
|
236
240
|
|
|
237
241
|
By default, this command reads the repository from prismic.config.json at the
|
|
238
242
|
project root.
|
|
239
|
-
`,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[r]=e,{repo:i=await n()}=t,{token:a,host:o}=await
|
|
243
|
+
`,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[r]=e,{repo:i=await n()}=t,{token:a,host:o}=await R(),s=await Sr(r,{repo:i,token:a,host:o});console.info(`Repository name set to: ${s}`)}),ri=z({name:`prismic repo view`,description:`
|
|
240
244
|
View details of a Prismic repository.
|
|
241
245
|
|
|
242
246
|
By default, this command reads the repository from prismic.config.json at the
|
|
243
247
|
project root.
|
|
244
|
-
`,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 n(),web:r,json:i}=e,{token:a,host:o}=await
|
|
248
|
+
`,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 n(),web:r,json:i}=e,{token:a,host:o}=await R(),s=`https://${t}.${o}/`;if(r){vn(new URL(s)),console.info(`Opening ${s}`);return}let[c,l]=await Promise.all([H({token:a,host:o}),yr({repo:t,token:a,host:o})]),u=c.repositories.find(e=>e.domain===t);if(!u)throw new V(`Repository not found: ${t}`);if(i){console.info(F({domain:u.domain,name:u.name??null,url:s,apiAccess:l}));return}let d=u.name||`(no name)`;console.info(`Name: ${d}`),console.info(`URL: ${s}`),console.info(`Content API: ${l}`)}),ii=B({name:`prismic repo`,description:`Manage Prismic repositories.`,commands:{create:{handler:Tr,description:`Create a new repository`},list:{handler:Qr,description:`List repositories`},view:{handler:ri,description:`View repository details`},"set-name":{handler:ni,description:`Set repository display name`},"set-api-access":{handler:ti,description:`Set Content API access level`}}}),ai=z({name:`prismic slice add-variation`,description:`Add a variation to a slice.`,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[r]=e,{to:i,id:a=de(r),screenshot:o}=t,s=await w(),{model:c}=await s.getSlice(i);if(c.variations.some(e=>e.id===a))throw new V(`Variation "${a}" already exists in slice "${i}".`);let l=``;if(o){let e=await n(),{token:t,host:r}=await R(),i=await ke(/^https?:\/\//i.test(o)?new URL(o):nt(o)),s;try{s=await An(i,{sliceId:c.id,variationId:a,repo:e,token:t,host:r})}catch(e){throw e instanceof jn?new V(e.message):e}l=s.toString()}c.variations=[...c.variations,{id:a,name:r,description:r,docURL:``,imageUrl:l,version:``,primary:{}}],await s.updateSlice(c),await s.generateTypes(),console.info(`Added variation "${r}" (id: "${a}") to slice "${i}"`)}),oi=z({name:`prismic slice connect`,description:`Connect a slice to a type's slice zone.`,sections:{EXAMPLES:`
|
|
245
249
|
Connect a slice to a type's default slice zone:
|
|
246
250
|
prismic slice connect hero --to blog_post
|
|
247
251
|
|
|
248
252
|
Connect to a named slice zone:
|
|
249
253
|
prismic slice connect hero --to blog_post --slice-zone page_slices
|
|
250
|
-
`},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 w(),{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 V(`Slice zone "${i}" not found in "${r}".`);if(c.config??={},c.config.choices??={},o.id in c.config.choices)throw new V(`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}"`)}),si=z({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=S(n)}=t,i={id:r,name:n,type:`SharedSlice`,variations:[{id:`default`,name:`Default`,description:`Default`,docURL:``,imageUrl:``,version:``,primary:{}}]},a=await w();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.`)}),ci=z({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 w(),{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 V(`Slice zone "${i}" not found in "${r}".`);if(!c.config?.choices||!(o.id in c.config.choices))throw new V(`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}"`)}),li=z({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 w(),{model:i}=await r.getSlice(n);`name`in t&&(i.name=t.name),await r.updateSlice(i),await r.generateTypes(),console.info(`Slice updated: "${i.name}" (id: ${i.id})`)}),ui=z({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[r]=e,{"from-slice":i,screenshot:a}=t,o=await w(),{model:s}=await o.getSlice(i),c=s.variations.find(e=>e.id===r);if(!c)throw new V(`Variation "${r}" not found in slice "${i}".`);if(`name`in t&&(c.name=t.name),a){let e=await n(),{token:t,host:r}=await
|
|
254
|
+
`},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 w(),{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 V(`Slice zone "${i}" not found in "${r}".`);if(c.config??={},c.config.choices??={},o.id in c.config.choices)throw new V(`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}"`)}),si=z({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=S(n)}=t,i={id:r,name:n,type:`SharedSlice`,variations:[{id:`default`,name:`Default`,description:`Default`,docURL:``,imageUrl:``,version:``,primary:{}}]},a=await w();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.`)}),ci=z({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 w(),{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 V(`Slice zone "${i}" not found in "${r}".`);if(!c.config?.choices||!(o.id in c.config.choices))throw new V(`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}"`)}),li=z({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 w(),{model:i}=await r.getSlice(n);`name`in t&&(i.name=t.name),await r.updateSlice(i),await r.generateTypes(),console.info(`Slice updated: "${i.name}" (id: ${i.id})`)}),ui=z({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[r]=e,{"from-slice":i,screenshot:a}=t,o=await w(),{model:s}=await o.getSlice(i),c=s.variations.find(e=>e.id===r);if(!c)throw new V(`Variation "${r}" not found in slice "${i}".`);if(`name`in t&&(c.name=t.name),a){let e=await n(),{token:t,host:r}=await R(),i=await ke(/^https?:\/\//i.test(a)?new URL(a):nt(a)),o;try{o=await An(i,{sliceId:s.id,variationId:c.id,repo:e,token:t,host:r})}catch(e){throw e instanceof jn?new V(e.message):e}c.imageUrl=o.toString()}await o.updateSlice(s),await o.generateTypes(),console.info(`Variation updated: "${r}" in slice "${i}"`)}),di=z({name:`prismic slice list`,description:`List all slices.`,options:{json:{type:`boolean`,description:`Output as JSON`}}},async({values:t})=>{let{json:n}=t,r=await(await w()).getSlices();if(n){console.info(F(r.map(e=>e.model)));return}if(r.length===0){console.info(`No slices found.`);return}let i=r.map(({model:e})=>[e.name,e.id]);console.info(e(i,{headers:[`NAME`,`ID`]}))}),fi=z({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 w();await n.deleteSlice(t),await n.generateTypes(),console.info(`Slice removed: ${t}`)}),pi=z({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 w(),{model:a}=await i.getSlice(r),o=a.variations.find(e=>e.id===n);if(!o)throw new V(`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}"`)}),mi=z({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:t,values:n})=>{let[r]=t,{json:i}=n,{model:a}=await(await w()).getSlice(r);if(i){console.info(F(a));return}console.info(`ID: ${a.id}`),console.info(`Name: ${a.name}`);for(let t of a.variations??[]){console.info(``),console.info(`${t.id}:`);let n=Object.entries(t.primary??{});if(n.length===0)console.info(` (no fields)`);else{let t=n.map(([e,t])=>{let n=t.config,r=n?.label||``,i=n?.placeholder?`"${n.placeholder}"`:``;return[` ${e}`,t.type,r,i]});console.info(e(t))}}}),hi=B({name:`prismic slice`,description:`Manage slices.`,commands:{create:{handler:si,description:`Create a new slice`},edit:{handler:li,description:`Edit a slice`},remove:{handler:fi,description:`Remove a slice`},list:{handler:di,description:`List slices`},view:{handler:mi,description:`View a slice`},connect:{handler:oi,description:`Connect a slice to a type's slice zone`},disconnect:{handler:ci,description:`Disconnect a slice from a type's slice zone`},"add-variation":{handler:ai,description:`Add a variation to a slice`},"edit-variation":{handler:ui,description:`Edit a variation of a slice`},"remove-variation":{handler:pi,description:`Remove a variation from a slice`}}}),gi=z({name:`prismic status`,description:`
|
|
251
255
|
Show local vs remote model differences.
|
|
252
256
|
|
|
253
257
|
Reports what would be pushed to or pulled from Prismic, plus any local
|
|
254
258
|
model files with uncommitted git changes that would block pull and push.
|
|
255
|
-
`,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 w(),r=await n(),i=await t.getEnvironment(),{env:a,repo:o=a??i??r}=e,{token:c,host:l}=await
|
|
259
|
+
`,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 w(),r=await n(),i=await t.getEnvironment(),{env:a,repo:o=a??i??r}=e,{token:c,host:l}=await R(),u=await _(),[d,f,p,h,g]=await Promise.all([Wr(u),t.getCustomTypeLibraries(),t.getSliceLibraries(),t.getCustomTypes(),t.getSlices()]),v,y,x;if(c){let[e,t,n]=await Promise.all([H({token:c,host:l}),yn({repo:o,token:c,host:l}),Cn({repo:o,token:c,host:l})]);v=e.email,y=G(h.map(e=>e.model),t,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(b(e))===JSON.stringify(b(t))}),x=G(g.map(e=>e.model),n,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(s(e))===JSON.stringify(s(t))})}let S=[];d&&(S=(await Gr(d)).filter(e=>e.pathname.endsWith(`/model.json`)&&p.some(t=>j(t,e))||e.pathname.endsWith(`/index.json`)&&f.some(t=>j(t,e))).map(e=>I(u,e))),console.info(`Repository: ${r}`),o!==r&&console.info(`Environment: ${o}`),v?console.info(`Authenticated as: ${v}`):console.info("Not logged in — log in with `prismic login` to compare with remote.");let C=y!==void 0&&x!==void 0&&y.insert.length===0&&y.update.length===0&&y.delete.length===0&&x.insert.length===0&&x.update.length===0&&x.delete.length===0;if(C&&S.length===0){console.info(``),console.info(`Already up to date.`);return}if(y&&x){let e=[],t=[...y.insert.map(e=>` ${e.id} (custom type)`),...x.insert.map(e=>` ${e.id} (slice)`)];t.length>0&&e.push([`Local-only:`,...t]);let n=[...y.delete.map(e=>` ${e.id} (custom type)`),...x.delete.map(e=>` ${e.id} (slice)`)];n.length>0&&e.push([`Remote-only:`,...n]);let r=[...y.update.map(e=>` ${e.id} (custom type)`),...x.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)}}if(S.length>0&&(console.info(``),console.info(m`
|
|
256
260
|
Pull and push won't run while these model files have uncommitted git changes:
|
|
257
261
|
${S.join(`
|
|
258
262
|
`)}
|
|
@@ -262,33 +266,33 @@ Please try again, or manually delete any associated pages at: `+Zr({repo:n,host:
|
|
|
262
266
|
git commit -m "Update Prismic models"
|
|
263
267
|
|
|
264
268
|
Or override with \`prismic push --force\` (keep local) or \`prismic pull --force\` (discard local).
|
|
265
|
-
`)),y&&x&&!C){let e=y.insert.length+x.insert.length,t=y.update.length+x.update.length,n=y.delete.length+x.delete.length;console.info(``),console.info(`Next:`),console.info(` prismic push — would create ${e}, update ${t}, delete ${n}`),console.info(` prismic pull — would create ${n}, update ${t}, delete ${e}`)}});async function _i(e){if(e instanceof Ae||e instanceof
|
|
269
|
+
`)),y&&x&&!C){let e=y.insert.length+x.insert.length,t=y.update.length+x.update.length,n=y.delete.length+x.delete.length;console.info(``),console.info(`Next:`),console.info(` prismic push — would create ${e}, update ${t}, delete ${n}`),console.info(` prismic pull — would create ${n}, update ${t}, delete ${e}`)}});async function _i(e){if(e instanceof Ae||e instanceof Me){let{token:t}=await R();return t?L.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 Ae?"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 Pe||e instanceof Ee){let t=new URL(e.response.url);return t.search=``,m`
|
|
266
270
|
${e.message?`${e.message}\n\n`:``}Prismic responded with an unexpected error. Try again, and report it if it keeps happening.
|
|
267
271
|
|
|
268
272
|
Status: ${e.status} ${e.statusText}
|
|
269
273
|
URL: ${t}
|
|
270
274
|
Report: https://github.com/prismicio/cli/issues
|
|
271
|
-
`}if(e instanceof Error)return m(e.message)}let $,vi;async function yi(e){let{host:t,repo:n}=e;n&&($=n);let r=t===
|
|
275
|
+
`}if(e instanceof Error)return m(e.message)}let $,vi;async function yi(e){let{host:t,repo:n}=e;n&&($=n);let r=t===Ie?`cGjidifKefYb6EPaGaqpt8rQXkv5TD6P`:`Ng5oKJHCGpSWplZ9ymB7Pu7rm0sTDeiG`;vi=await Un(),await Xe({writeKey:r})}function bi(e){Je({userId:e.shortId,intercomHash:e.intercomHash})}function xi(e,t={}){let{watch:n}=t;Ye(`Prismic CLI Start`,{properties:{commandType:e,fullCommand:process.argv.join(` `),repository:$,watch:n,agent:vi},groupId:$?{Repository:$}:void 0})}function Si(e,t={}){let{watch:n,success:r=!process.exitCode,error:i}=t,a=i?i instanceof Error?i.message:String(i):void 0;Ye(`Prismic CLI End`,{properties:{commandType:e,fullCommand:process.argv.join(` `),success:r,repository:$,watch:n,error:a?.slice(0,512),agent:vi},groupId:$?{Repository:$}:void 0})}const Ci=D({telemetry:O()});async function wi(){try{return!((await Oe(new URL(`.prismicrc`,M(nt(at()))),{schema:Ci}).catch(()=>({telemetry:!0}))).telemetry===!1||(await Oe(new URL(`.prismicrc`,M(nt(process.cwd()))),{schema:Ci}).catch(()=>({telemetry:!0}))).telemetry===!1)}catch{return!0}}const Ti=L.PRISMIC_SYNC_POLL_MS??5e3;var Ei=z({name:`prismic sync`,description:`
|
|
272
276
|
Watch Prismic and continuously pull changes to local files.
|
|
273
277
|
|
|
274
278
|
For one-time pulls, use \`prismic pull\`.
|
|
275
|
-
`,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 w(),{env:r,repo:i=r??await t.getEnvironment()??await n()}=e,{token:a,host:o}=await
|
|
279
|
+
`,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 w(),{env:r,repo:i=r??await t.getEnvironment()??await n()}=e,{token:a,host:o}=await R();xi(`sync`,{watch:!0}),process.on(`SIGINT`,()=>{console.info(`
|
|
276
280
|
Watch stopped. Goodbye!`),Si(`sync`,{watch:!0}),process.exit(0)}),console.info(`Watching repository: ${i} (polling every ${Ti/1e3}s, Ctrl+C to stop)`);let c=``,l=0;for(;;){try{let[e,r]=await Promise.all([yn({repo:i,token:a,host:o}),Cn({repo:i,token:a,host:o})]),u=Di({remoteCustomTypes:e.map(e=>b(e)),remoteSlices:r.map(e=>s(e))});if(u!==c){let i=c===``,[l,d]=await Promise.all([t.getCustomTypes(),t.getSlices()]),f=l.map(e=>e.model),p=d.map(e=>e.model),m=[],h=G(r,p,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(s(e))===JSON.stringify(t)});if(h.insert.length+h.update.length+h.delete.length>0){for(let e of h.update)await t.updateSlice(e);for(let e of h.delete)await t.deleteSlice(e.id);for(let e of h.insert)await t.createSlice(e);m.push(`slices`)}let g=G(e,f,{getKey:e=>e.id,equals:(e,t)=>JSON.stringify(b(e))===JSON.stringify(t)});if(g.insert.length+g.update.length+g.delete.length>0){for(let e of g.update)await t.updateCustomType(e);for(let e of g.delete)await t.deleteCustomType(e.id);for(let e of g.insert)await t.createCustomType(e);m.push(`custom types`)}if((i||m.length>0)&&await t.generateTypes(),c=u,i)await Pn([`connectPrismic`],{repo:await n(),token:a,host:o}).catch(()=>{}),console.info(`Initial sync complete.`);else if(m.length>0){let e=new Date().toLocaleTimeString();console.info(`[${e}] Changes detected in ${m.join(` and `)}`)}}l=0}catch(e){l++;let t=await _i(e)??`Unknown error`;if(console.error(`Error checking for changes: ${t}`),l>=5)throw new V(`Too many consecutive errors (5), stopping watch.`)}await ot(Ti)}});function Di(e){return rt(`sha256`).update(JSON.stringify(e)).digest(`hex`)}const Oi=`Prismic CLI`;var ki=z({name:`prismic token create`,description:`
|
|
277
281
|
Create a new API token for a Prismic repository.
|
|
278
282
|
|
|
279
283
|
By default, this command reads the repository from prismic.config.json at the
|
|
280
284
|
project root.
|
|
281
|
-
`,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: "${Oi}")`},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 E(),write:r,"allow-releases":i,name:a=Oi,json:o}=e;if(r&&i)throw new V(`--allow-releases is only valid for access tokens (not with --write)`);let{token:s,host:c}=await
|
|
285
|
+
`,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: "${Oi}")`},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 E(),write:r,"allow-releases":i,name:a=Oi,json:o}=e;if(r&&i)throw new V(`--allow-releases is only valid for access tokens (not with --write)`);let{token:s,host:c}=await R(),l,u;if(r)l=(await mr(a,{repo:n,token:s,host:c})).token;else{u=i?`master+releases`:`master`;let e=(await lr({repo:n,token:s,host:c})).find(e=>e.name===a);e||=await ur(a,{repo:n,token:s,host:c}),l=(await dr(e.id,u,{repo:n,token:s,host:c})).token}if(o){console.info(F({token:l,type:r?`write`:`access`,name:a,repository:n,...u?{scope:u}:{}}));return}console.info(`Token created: ${l}`)}),Ai=z({name:`prismic token delete`,description:`
|
|
282
286
|
Delete a token from a Prismic repository.
|
|
283
287
|
|
|
284
288
|
By default, this command reads the repository from prismic.config.json at the
|
|
285
289
|
project root.
|
|
286
|
-
`,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 E()}=t,{token:a,host:o}=await
|
|
290
|
+
`,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 E()}=t,{token:a,host:o}=await R(),[s,c]=await Promise.all([lr({repo:i,token:a,host:o}),pr({repo:i,token:a,host:o})]),l=s.flatMap(e=>e.wroom_auths).find(e=>e.token===n);if(l){await fr(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 hr(u.token,{repo:i,token:a,host:o}),console.info(`Token deleted`);return}throw new V(`Token not found: ${n}`)}),ji=B({name:`prismic token`,description:`Manage API tokens for a Prismic repository.`,commands:{list:{handler:z({name:`prismic token list`,description:`
|
|
287
291
|
List all API tokens for a Prismic repository.
|
|
288
292
|
|
|
289
293
|
By default, this command reads the repository from prismic.config.json at the
|
|
290
294
|
project root.
|
|
291
|
-
`,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:t})=>{let{env:n,repo:r=n??await E(),json:i}=t,{token:a,host:o}=await
|
|
295
|
+
`,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:t})=>{let{env:n,repo:r=n??await E(),json:i}=t,{token:a,host:o}=await R(),[s,c]=await Promise.all([lr({repo:r,token:a,host:o}),pr({repo:r,token:a,host:o})]),l=s.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]}))),u=c.tokens;if(i){console.info(F({accessTokens:l,writeTokens:u}));return}if(l.length>0){console.info(`ACCESS TOKENS`);let t=l.map(e=>[` ${e.name}`,e.scope,e.token,e.createdAt]);console.info(e(t))}else console.info(`ACCESS TOKENS (none)`);if(console.info(``),u.length>0){console.info(`WRITE TOKENS`);let t=u.map(e=>{let t=new Date(e.timestamp*1e3).toISOString().split(`T`)[0];return[` ${e.app_name}`,e.token,t]});console.info(e(t))}else console.info(`WRITE TOKENS (none)`)}),description:`List all tokens`},create:{handler:ki,description:`Create a new token`},delete:{handler:Ai,description:`Delete a token`}}}),Mi=z({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 w(),{model:o}=await a.getCustomType(r);if(n in o.json)throw new V(`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}"`)}),Ni=z({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:`
|
|
292
296
|
custom A non-page type (e.g. settings, navigation, author, blog
|
|
293
297
|
category). This is the default.
|
|
294
298
|
page A page type with a URL (e.g. homepage, blog post, landing
|
|
@@ -303,7 +307,7 @@ Watch stopped. Goodbye!`),Si(`sync`,{watch:!0}),process.exit(0)}),console.info(`
|
|
|
303
307
|
|
|
304
308
|
Create with a custom ID:
|
|
305
309
|
prismic type create "Landing Page" --format page --id landing
|
|
306
|
-
`}},async({positionals:e,values:t})=>{let[n]=e,{format:r=`custom`,single:i=!1,id:a=S(n)}=t;if(r!==`custom`&&r!==`page`)throw new V(`Invalid format: "${r}". Use "custom" or "page".`);let o=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||(o.Main={uid:{type:`UID`,config:{label:`UID`}},...o.Main});let s={id:a,label:n,repeatable:!i,status:!0,format:r,json:o},c=await w();await c.createCustomType(s),await c.generateTypes(),console.info(`Created type "${n}" (id: "${a}", format: "${r}")`),console.info(`Run \`prismic field add <type> --to-type ${a}\` to add fields.`),console.info(`Run \`prismic type view ${a}\` to view the type.`)}),Pi=z({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 V(`Invalid format: "${t.format}". Use "custom" or "page".`);let r=await w(),{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})`)}),Fi=z({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 w(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new V(`Tab "${n}" not found in "${r}".`);if(`with-slice-zone`in t&&`without-slice-zone`in t)throw new V(`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 V(`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 V(`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 V(`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 V(`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}"`)}),Ii=z({name:`prismic type list`,description:`List all content types.`,options:{json:{type:`boolean`,description:`Output as JSON`}}},async({values:t})=>{let{json:n}=t,r=await(await w()).getCustomTypes();if(n){console.info(
|
|
310
|
+
`}},async({positionals:e,values:t})=>{let[n]=e,{format:r=`custom`,single:i=!1,id:a=S(n)}=t;if(r!==`custom`&&r!==`page`)throw new V(`Invalid format: "${r}". Use "custom" or "page".`);let o=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||(o.Main={uid:{type:`UID`,config:{label:`UID`}},...o.Main});let s={id:a,label:n,repeatable:!i,status:!0,format:r,json:o},c=await w();await c.createCustomType(s),await c.generateTypes(),console.info(`Created type "${n}" (id: "${a}", format: "${r}")`),console.info(`Run \`prismic field add <type> --to-type ${a}\` to add fields.`),console.info(`Run \`prismic type view ${a}\` to view the type.`)}),Pi=z({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 V(`Invalid format: "${t.format}". Use "custom" or "page".`);let r=await w(),{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})`)}),Fi=z({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 w(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new V(`Tab "${n}" not found in "${r}".`);if(`with-slice-zone`in t&&`without-slice-zone`in t)throw new V(`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 V(`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 V(`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 V(`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 V(`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}"`)}),Ii=z({name:`prismic type list`,description:`List all content types.`,options:{json:{type:`boolean`,description:`Output as JSON`}}},async({values:t})=>{let{json:n}=t,r=await(await w()).getCustomTypes();if(n){console.info(F(r.map(e=>e.model)));return}if(r.length===0){console.info(`No types found.`);return}let i=r.map(({model:e})=>[e.label||`(no name)`,e.id,e.format??``]);console.info(e(i,{headers:[`NAME`,`ID`,`FORMAT`]}))}),Li=z({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 w();await n.deleteCustomType(t),await n.generateTypes(),console.info(`Type removed: ${t}`)}),Ri=z({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 w(),{model:a}=await i.getCustomType(r);if(!(n in a.json))throw new V(`Tab "${n}" not found in "${r}".`);if(Object.keys(a.json).length<=1)throw new V(`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}"`)}),zi=z({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:t,values:n})=>{let[r]=t,{json:i}=n,{model:a}=await(await w()).getCustomType(r);if(i){console.info(F(a));return}console.info(`ID: ${a.id}`),console.info(`Name: ${a.label||`(no name)`}`),console.info(`Format: ${a.format}`),console.info(`Repeatable: ${a.repeatable}`);for(let[t,n]of Object.entries(a.json)){console.info(``),console.info(`${t}:`);let r=Object.entries(n);if(r.length===0)console.info(` (no fields)`);else{let t=r.map(([e,t])=>{let n=t.config,r=n?.label||``,i=n?.placeholder?`"${n.placeholder}"`:``;return[` ${e}`,t.type,r,i]});console.info(e(t))}}}),Bi=B({name:`prismic type`,description:`Manage content types.`,commands:{create:{handler:Ni,description:`Create a new content type`},edit:{handler:Pi,description:`Edit a content type`},remove:{handler:Li,description:`Remove a content type`},list:{handler:Ii,description:`List content types`},view:{handler:zi,description:`View a content type`},"add-tab":{handler:Mi,description:`Add a tab to a content type`},"edit-tab":{handler:Fi,description:`Edit a tab of a content type`},"remove-tab":{handler:Ri,description:`Remove a tab from a content type`}}}),Vi=z({name:`prismic webhook create`,description:`
|
|
307
311
|
Create a new webhook in a Prismic repository.
|
|
308
312
|
|
|
309
313
|
By default, this command reads the repository from prismic.config.json at the
|
|
@@ -326,27 +330,27 @@ Watch stopped. Goodbye!`),Si(`sync`,{watch:!0}),process.exit(0)}),console.info(`
|
|
|
326
330
|
|
|
327
331
|
Create a named webhook with a secret:
|
|
328
332
|
prismic webhook create https://example.com/webhook --name "Deploy" --secret my-secret
|
|
329
|
-
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await E(),name:a,secret:o,trigger:s=[]}=t;for(let e of s)if(!er.includes(e))throw new V(`Invalid trigger: ${e}\nValid triggers: ${er.join(`, `)}`);let{token:c,host:l}=await
|
|
333
|
+
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await E(),name:a,secret:o,trigger:s=[]}=t;for(let e of s)if(!er.includes(e))throw new V(`Invalid trigger: ${e}\nValid triggers: ${er.join(`, `)}`);let{token:c,host:l}=await R(),u=!(s.length>0);await nr({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.`)}),Hi=z({name:`prismic webhook disable`,description:`
|
|
330
334
|
Disable a webhook in a Prismic repository.
|
|
331
335
|
|
|
332
336
|
By default, this command reads the repository from prismic.config.json at the
|
|
333
337
|
project root.
|
|
334
|
-
`,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 E()}=t,{token:a,host:o}=await
|
|
338
|
+
`,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 E()}=t,{token:a,host:o}=await R(),s=(await X({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new V(`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 rr(c,l,{repo:i,token:a,host:o}),console.info(`Webhook disabled: ${n}`)}),Ui=z({name:`prismic webhook enable`,description:`
|
|
335
339
|
Enable a webhook in a Prismic repository.
|
|
336
340
|
|
|
337
341
|
By default, this command reads the repository from prismic.config.json at the
|
|
338
342
|
project root.
|
|
339
|
-
`,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 E()}=t,{token:a,host:o}=await
|
|
343
|
+
`,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 E()}=t,{token:a,host:o}=await R(),s=(await X({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new V(`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 rr(c,l,{repo:i,token:a,host:o}),console.info(`Webhook enabled: ${n}`)}),Wi=z({name:`prismic webhook list`,description:`
|
|
340
344
|
List all webhooks in a Prismic repository.
|
|
341
345
|
|
|
342
346
|
By default, this command reads the repository from prismic.config.json at the
|
|
343
347
|
project root.
|
|
344
|
-
`,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:t})=>{let{env:n,repo:r=n??await E(),json:i}=t,{token:a,host:o}=await
|
|
348
|
+
`,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:t})=>{let{env:n,repo:r=n??await E(),json:i}=t,{token:a,host:o}=await R(),s=await X({repo:r,token:a,host:o});if(i){console.info(F(s.map(e=>e.config)));return}if(s.length===0){console.info(`No webhooks configured.`);return}let c=s.map(e=>{let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;return[`${e.config.url}${n}`,`[${t}]`]});console.info(e(c,{headers:[`URL`,`STATUS`]}))}),Gi=z({name:`prismic webhook remove`,description:`
|
|
345
349
|
Delete a webhook from a Prismic repository.
|
|
346
350
|
|
|
347
351
|
By default, this command reads the repository from prismic.config.json at the
|
|
348
352
|
project root.
|
|
349
|
-
`,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 E()}=t,{token:a,host:o}=await
|
|
353
|
+
`,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 E()}=t,{token:a,host:o}=await R(),s=(await X({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new V(`Webhook not found: ${n}`);let c=s.config._id;await ir(c,{repo:i,token:a,host:o}),console.info(`Webhook removed: ${n}`)}),Ki=z({name:`prismic webhook set-triggers`,description:`
|
|
350
354
|
Update which events trigger a webhook.
|
|
351
355
|
|
|
352
356
|
By default, this command reads the repository from prismic.config.json at the
|
|
@@ -358,9 +362,9 @@ Watch stopped. Goodbye!`),Si(`sync`,{watch:!0}),process.exit(0)}),console.info(`
|
|
|
358
362
|
releasesUpdated When a release is edited or deleted
|
|
359
363
|
tagsCreated When a tag is created
|
|
360
364
|
tagsDeleted When a tag is deleted
|
|
361
|
-
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await E(),trigger:a=[]}=t;for(let e of a)if(!er.includes(e))throw new V(`Invalid trigger: ${e}\nValid triggers: ${er.join(`, `)}`);let{token:o,host:s}=await
|
|
365
|
+
`}},async({positionals:e,values:t})=>{let[n]=e,{env:r,repo:i=r??await E(),trigger:a=[]}=t;for(let e of a)if(!er.includes(e))throw new V(`Invalid trigger: ${e}\nValid triggers: ${er.join(`, `)}`);let{token:o,host:s}=await R(),c=(await X({repo:i,token:o,host:s})).find(e=>e.config.url===n);if(!c)throw new V(`Webhook not found: ${n}`);let l=c.config._id;await rr(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(`, `)}`)}),qi=z({name:`prismic webhook view`,description:`
|
|
362
366
|
View details of a webhook in a Prismic repository.
|
|
363
367
|
|
|
364
368
|
By default, this command reads the repository from prismic.config.json at the
|
|
365
369
|
project root.
|
|
366
|
-
`,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 E()}=t,{token:a,host:o}=await
|
|
370
|
+
`,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 E()}=t,{token:a,host:o}=await R(),s=(await X({repo:i,token:a,host:o})).find(e=>e.config.url===n);if(!s)throw new V(`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 er)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)`)}),Ji=B({name:`prismic webhook`,description:`Manage webhooks in a Prismic repository.`,commands:{list:{handler:Wi,description:`List all webhooks`},create:{handler:Vi,description:`Create a new webhook`},view:{handler:qi,description:`View webhook details`},remove:{handler:Gi,description:`Delete a webhook`},enable:{handler:Ui,description:`Enable a webhook`},disable:{handler:Hi,description:`Disable a webhook`},"set-triggers":{handler:Ki,description:`Update webhook triggers`}}}),Yi=z({name:`prismic whoami`,description:`Show the currently logged in user.`},async()=>{let{token:e,host:t}=await R(),n=await H({token:e,host:t});console.info(n.email)}),Xi=B({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 "},commands:{init:{handler:Or,description:`Initialize a Prismic project`},docs:{handler:Tt,description:`Browse Prismic documentation`},gen:{handler:_n,description:`Generate files from local models`},pull:{handler:Kr,description:`Pull types and slices from Prismic`},push:{handler:qr,description:`Push types and slices to Prismic`},sync:{handler:Ei,description:`Sync types and slices from Prismic`},status:{handler:gi,description:`Show local vs remote model differences`},env:{handler:Ft,description:`Manage the active environment`,hidden:!0},locale:{handler:Ir,description:`Manage locales`},repo:{handler:ii,description:`Manage repositories`},type:{handler:Bi,description:`Manage content types`},field:{handler:pn,description:`Manage fields`},slice:{handler:hi,description:`Manage slices`},preview:{handler:Ur,description:`Manage preview configurations`},token:{handler:ji,description:`Manage API tokens`},webhook:{handler:Ji,description:`Manage webhooks`},login:{handler:Lr,description:`Log in to Prismic`},logout:{handler:Rr,description:`Log out of Prismic`},whoami:{handler:Yi,description:`Show the currently logged in user`}}});const Zi=Ce({exp:N(je())});function Qi(e){try{let[,t]=e.split(`.`);return t?xe(Zi,JSON.parse(Buffer.from(t,`base64url`).toString())):void 0}catch{return}}const $i=[`login`,`logout`,`whoami`,`sync`,`docs`,`status`],ea=[V,h,a,ve,c,g,d,jn,T,jt,ue,se,ne,qe,re,ie,Ne,Ae,Me,Pe,Ee],ta=[Pe,Ee,ie];await na();async function na(){await Ze({npmPackageName:be,statePath:Be}),Ve().catch(()=>{});let{positionals:[e=``],values:{version:t,help:n,repo:r=await i()}}=Qe({options:{version:{type:`boolean`,short:`v`},help:{type:`boolean`,short:`h`},repo:{type:`string`,short:`r`}},allowPositionals:!0,strict:!1});if(t){console.info(ye);return}let a=typeof r==`string`?r:void 0;if(!n){let{token:e,host:t}=await R(),n=L.PRISMIC_TELEMETRY_ENABLED??await wi(),r=L.PRISMIC_SENTRY_ENABLED??(n&&L.PROD);if(r&&await ra({host:t,repo:a}),n&&await yi({host:t,repo:a}),e){let i=Qi(e)?.exp,a=Date.now()/1e3;(!i||i-a<=3600)&&process.on(`exit`,()=>ze()),(r||n)&&(!i||i>a)&&H({token:e,host:t}).then(e=>{bi(e),Rn({id:e.shortId})}).catch(()=>{})}}let o=!n&&e&&!$i.includes(e);try{o&&xi(e),await Xi(),o&&Si(e)}catch(t){process.exitCode=1;let n=await _i(t).catch(()=>void 0);if(o&&Si(e,{error:n??t}),ea.some(e=>t instanceof e))console.error(n),ta.some(e=>t instanceof e)&&await zn(t);else throw console.error(`The CLI reached a bug. Report this if it keeps happening: https://github.com/prismicio/cli/issues`),await zn(t),t}}async function ra(e){let{host:t,repo:n}=e;Fn({dsn:L.PRISMIC_SENTRY_DSN,appName:be,appVersion:ye,environment:L.PRISMIC_SENTRY_ENVIRONMENT}),In(`host`,t),n&&(In(`repository`,n),Ln(`Repository Data`,{name:n}));try{In(`framework`,(await w()).id)}catch{}}export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`prismic`,t=`1.16.0`;export{t as n,e as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./package-
|
|
1
|
+
import{n as e,t}from"./package-DLkZAhRl.mjs";import{fileURLToPath as n}from"node:url";import{spawn as r}from"node:child_process";const i=[],a=[],o=crypto.randomUUID();let s;async function c(e){let{writeKey:t}=e;process.on(`exit`,()=>d({writeKey:t}))}function l(n){s=n.userId,a.push({userId:n.userId,anonymousId:o,integrations:{Intercom:{user_hash:n.intercomHash}},context:{app:{name:t,version:e}},timestamp:new Date().toISOString()})}function u(n,r={}){let{properties:a,groupId:c}=r;i.push({event:n,properties:{nodeVersion:process.versions.node,...a},context:{app:{name:t,version:e},groupId:c},userId:s,anonymousId:o,timestamp:new Date().toISOString()})}function d(e){let{writeKey:t}=e;if(!(i.length===0&&a.length===0)){try{let e=Buffer.from(JSON.stringify({trackEvents:i.map(e=>({...e,userId:e.userId||s})),identifyEvents:a,writeKey:t})).toString(`base64`),o=n(new URL(`./subprocesses/sendSegmentEvents.mjs`,import.meta.url));r(process.execPath,[o,e],{detached:!0,stdio:`ignore`}).unref()}catch{}i.length=0,a.length=0}}async function f(e,t,n){let r={"Content-Type":`application/json`,Authorization:`Basic ${btoa(n+`:`)}`};await Promise.allSettled([...e.map(e=>fetch(`https://api.segment.io/v1/track`,{method:`POST`,headers:r,body:JSON.stringify(e)}).catch(()=>{})),...t.map(e=>fetch(`https://api.segment.io/v1/identify`,{method:`POST`,headers:r,body:JSON.stringify(e)}).catch(()=>{}))])}export{l as i,f as n,u as r,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../segment-
|
|
1
|
+
import{n as e}from"../segment-zsn0WEf2.mjs";const{trackEvents:t,identifyEvents:n,writeKey:r}=JSON.parse(Buffer.from(process.argv[2],`base64`).toString());try{await e(t,n,r)}catch{}export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../packageJson-DOQ8ITHb.mjs";import{n as e}from"../update-notifier-
|
|
1
|
+
import"../packageJson-DOQ8ITHb.mjs";import{n as e}from"../update-notifier-CjfM6dH9.mjs";const[t,n]=process.argv.slice(2);try{await e(t,new URL(n))}catch{}export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./package-
|
|
1
|
+
import{n as e}from"./package-DLkZAhRl.mjs";import{B as t,E as n,N as r,j as i,k as a,s as o}from"./request-DEP7ruRD.mjs";import{i as s}from"./packageJson-DOQ8ITHb.mjs";import{mkdir as c,readFile as l,writeFile as u}from"node:fs/promises";import{fileURLToPath as d}from"node:url";import{dirname as f}from"node:path";import{spawn as p}from"node:child_process";const m=n({latestKnownVersion:i(r()),lastUpdateCheckAt:i(a())});async function h(t){try{if(g())return;let n=await _(t.statePath),r=e;if(n?.latestKnownVersion&&v(n.latestKnownVersion,r)){let e=`Update available: ${r} → ${n.latestKnownVersion}. Run \`npx ${t.npmPackageName}@latest --version\` to update.`;process.on(`exit`,()=>{try{console.error(`\n${e}`)}catch{}})}(!n?.lastUpdateCheckAt||Date.now()-n.lastUpdateCheckAt>864e5)&&process.on(`exit`,()=>{b(t.npmPackageName,t.statePath)})}catch{}}function g(){return process.env.NO_UPDATE_NOTIFIER===`0`?!1:!!(process.env.NO_UPDATE_NOTIFIER===`1`||process.env.CI||!process.stderr.isTTY)}async function _(e){try{let n=await l(e,`utf-8`);return t(m,JSON.parse(n))}catch{return}}function v(e,t){if(e.includes(`-`)||t.includes(`-`))return!1;let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);if(n.length!==3||r.length!==3||n.some(e=>!Number.isFinite(e))||r.some(e=>!Number.isFinite(e)))return!1;for(let e=0;e<3;e++){if(n[e]>r[e])return!0;if(n[e]<r[e])return!1}return!1}async function y(e,t){let n=await s(e),r=d(t);await c(f(r),{recursive:!0}),await u(r,o({latestKnownVersion:n,lastUpdateCheckAt:Date.now()}))}function b(e,t){try{let n=d(new URL(`./subprocesses/updateVersionState.mjs`,import.meta.url));p(process.execPath,[n,e,t.href],{detached:!0,stdio:`ignore`}).unref()}catch{}}export{y as n,h as t};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=`prismic`,t=`1.15.0`;export{t as n,e as t};
|