@angeloashmore/prismic-cli-poc 0.0.0-canary.2ff9563 → 0.0.0-canary.6fd8413
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 +493 -186
- package/package.json +2 -1
- package/src/codegen-types.ts +105 -0
- package/src/codegen.ts +45 -0
- package/src/custom-type-add-field-boolean.ts +3 -2
- package/src/custom-type-add-field-color.ts +3 -2
- package/src/custom-type-add-field-date.ts +3 -2
- package/src/custom-type-add-field-embed.ts +3 -2
- package/src/custom-type-add-field-geo-point.ts +3 -2
- package/src/custom-type-add-field-image.ts +3 -2
- package/src/custom-type-add-field-key-text.ts +3 -2
- package/src/custom-type-add-field-link.ts +3 -2
- package/src/custom-type-add-field-number.ts +3 -2
- package/src/custom-type-add-field-rich-text.ts +3 -2
- package/src/custom-type-add-field-select.ts +3 -2
- package/src/custom-type-add-field-timestamp.ts +3 -2
- package/src/custom-type-add-field-uid.ts +3 -2
- package/src/index.ts +14 -4
- package/src/lib/custom-types-api.ts +384 -0
- package/src/lib/string.ts +6 -0
- package/src/page-type-add-field-boolean.ts +3 -2
- package/src/page-type-add-field-color.ts +3 -2
- package/src/page-type-add-field-date.ts +3 -2
- package/src/page-type-add-field-embed.ts +3 -2
- package/src/page-type-add-field-geo-point.ts +3 -2
- package/src/page-type-add-field-image.ts +3 -2
- package/src/page-type-add-field-key-text.ts +3 -2
- package/src/page-type-add-field-link.ts +3 -2
- package/src/page-type-add-field-number.ts +3 -2
- package/src/page-type-add-field-rich-text.ts +3 -2
- package/src/page-type-add-field-select.ts +3 -2
- package/src/page-type-add-field-timestamp.ts +3 -2
- package/src/page-type-add-field-uid.ts +3 -2
- package/src/preview-get-simulator.ts +106 -0
- package/src/preview-remove-simulator.ts +80 -0
- package/src/preview-set-simulator.ts +116 -0
- package/src/preview.ts +19 -4
- package/src/{sync.ts → pull.ts} +17 -114
- package/src/push.ts +381 -0
- package/src/repo-get-access.ts +89 -0
- package/src/repo-set-access.ts +104 -0
- package/src/repo.ts +10 -0
- package/src/slice-add-field-boolean.ts +3 -2
- package/src/slice-add-field-color.ts +3 -2
- package/src/slice-add-field-date.ts +3 -2
- package/src/slice-add-field-embed.ts +3 -2
- package/src/slice-add-field-geo-point.ts +3 -2
- package/src/slice-add-field-image.ts +3 -2
- package/src/slice-add-field-key-text.ts +3 -2
- package/src/slice-add-field-link.ts +3 -2
- package/src/slice-add-field-number.ts +3 -2
- package/src/slice-add-field-rich-text.ts +3 -2
- package/src/slice-add-field-select.ts +3 -2
- package/src/slice-add-field-timestamp.ts +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,215 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as r,readdir as i,rename as a,rm as o,writeFile as s}from"node:fs/promises";import
|
|
2
|
+
import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as r,readdir as i,rename as a,rm as o,writeFile as s}from"node:fs/promises";import*as c from"node:crypto";import{homedir as l}from"node:os";import{pathToFileURL as u}from"node:url";import{exec as d}from"node:child_process";import{createServer as f}from"node:http";var p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,_=(e,t)=>()=>(e&&(t=e(e=0)),t),v=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),y=(e,t)=>{let n={};for(var r in e)p(n,r,{get:e[r],enumerable:!0});return t&&p(n,Symbol.toStringTag,{value:`Module`}),n},ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e},b=e=>g.call(e,`module.exports`)?e[`module.exports`]:ee(p({},`__esModule`,{value:!0}),e),te=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),r=i([``,``],[``,``]);function i(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}e.default=function(){function e(){var t=this,n=[...arguments];return a(this,e),this.tag=function(e){var n=[...arguments].slice(1);return typeof e==`function`?t.interimTag.bind(t,e):typeof e==`string`?t.transformEndResult(e):(e=e.map(t.transformString.bind(t)),t.transformEndResult(e.reduce(t.processSubstitutions.bind(t,n))))},n.length>0&&Array.isArray(n[0])&&(n=n[0]),this.transformers=n.map(function(e){return typeof e==`function`?e():e}),this.tag}return n(e,[{key:`interimTag`,value:function(e,t){var n=[...arguments].slice(2);return this.tag(r,e.apply(void 0,[t].concat(n)))}},{key:`processSubstitutions`,value:function(e,t,n){return`${t}${this.transformSubstitution(e.shift(),t)}${n}`}},{key:`transformString`,value:function(e){return this.transformers.reduce(function(e,t){return t.onString?t.onString(e):e},e)}},{key:`transformSubstitution`,value:function(e,t){return this.transformers.reduce(function(e,n){return n.onSubstitution?n.onSubstitution(e,t):e},e)}},{key:`transformEndResult`,value:function(e){return this.transformers.reduce(function(e,t){return t.onEndResult?t.onEndResult(e):e},e)}}]),e}(),t.exports=e.default})),x=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(te());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ne=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:``;return{onEndResult:function(t){if(e===``)return t.trim();if(e=e.toLowerCase(),e===`start`||e===`left`)return t.replace(/^\s*/,``);if(e===`end`||e===`right`)return t.replace(/\s*$/,``);throw Error(`Side not supported: `+e)}}},t.exports=e.default})),S=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ne());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),re=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});function n(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}else return Array.from(e)}e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`initial`;return{onEndResult:function(t){if(e===`initial`){var r=t.match(/^[^\S\n]*(?=\S)/gm),i=r&&Math.min.apply(Math,n(r.map(function(e){return e.length})));if(i){var a=RegExp(`^.{`+i+`}`,`gm`);return t.replace(a,``)}return t}if(e===`all`)return t.replace(/^[^\S\n]+/gm,``);throw Error(`Unknown type: `+e)}}},t.exports=e.default})),C=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(re());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ie=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onEndResult:function(n){if(e==null||t==null)throw Error(`replaceResultTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),ae=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ie());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),w=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onSubstitution:function(n,r){if(e==null||t==null)throw Error(`replaceSubstitutionTransformer requires at least 2 arguments.`);return n==null?n:n.toString().replace(e,t)}}},t.exports=e.default})),oe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(w());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),se=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onString:function(n){if(e==null||t==null)throw Error(`replaceStringTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),ce=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(se());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),le=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n={separator:``,conjunction:``,serial:!1};e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:n;return{onSubstitution:function(t,n){if(Array.isArray(t)){var r=t.length,i=e.separator,a=e.conjunction,o=e.serial,s=n.match(/(\n?[^\S\n]+)$/);if(t=s?t.join(i+s[1]):t.join(i+` `),a&&r>1){var c=t.lastIndexOf(i);t=t.slice(0,c)+(o?i:``)+` `+a+t.slice(c+1)}}return t}}},t.exports=e.default})),T=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(le());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ue=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e){return{onSubstitution:function(t,n){if(e!=null&&typeof e==`string`)typeof t==`string`&&t.includes(e)&&(t=t.split(e));else throw Error(`You need to specify a string character to split by.`);return t}}},t.exports=e.default})),de=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ue());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),fe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(e){return e!=null&&!Number.isNaN(e)&&typeof e!=`boolean`};e.default=function(){return{onSubstitution:function(e){return Array.isArray(e)?e.filter(n):n(e)?e:``}}},t.exports=e.default})),pe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(fe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),me=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(C()),i=o(T()),a=o(S());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`}),r.default,a.default),t.exports=e.default})),he=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(me());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ge=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(C()),i=o(T()),a=o(S());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`and`}),r.default,a.default),t.exports=e.default})),_e=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ge());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ve=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(C()),i=o(T()),a=o(S());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`or`}),r.default,a.default),t.exports=e.default})),ye=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ve());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),be=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(x()),r=c(C()),i=c(T()),a=c(S()),o=c(de()),s=c(pe());function c(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,o.default)(`
|
|
3
|
+
`),s.default,i.default,r.default,a.default),t.exports=e.default})),xe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(be());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Se=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(xe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ce=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(xe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),we=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(x()),r=c(C()),i=c(T()),a=c(S()),o=c(de()),s=c(oe());function c(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,o.default)(`
|
|
4
|
+
`),i.default,r.default,a.default,(0,s.default)(/&/g,`&`),(0,s.default)(/</g,`<`),(0,s.default)(/>/g,`>`),(0,s.default)(/"/g,`"`),(0,s.default)(/'/g,`'`),(0,s.default)(/`/g,```)),t.exports=e.default})),Te=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(we());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ee=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(x()),r=a(S()),i=a(ae());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)(/(?:\n(?:\s*))+/g,` `),r.default),t.exports=e.default})),De=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ee());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Oe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(x()),r=a(S()),i=a(ae());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)(/(?:\n\s*)/g,``),r.default),t.exports=e.default})),ke=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Oe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ae=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(T()),i=o(S()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),je=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ae());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Me=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(T()),i=o(S()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`,conjunction:`or`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Ne=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Me());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Pe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(T()),i=o(S()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`,conjunction:`and`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Fe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Pe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ie=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(C()),i=o(T()),a=o(S());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(i.default,r.default,a.default),t.exports=e.default})),Le=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ie());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Re=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(x()),r=o(T()),i=o(S()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),ze=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Re());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Be=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(x()),r=a(C()),i=a(S());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,i.default),t.exports=e.default})),Ve=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Be());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),He=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(x()),r=a(C()),i=a(S());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)(`all`),i.default),t.exports=e.default})),Ue=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(He());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),E=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.stripIndents=e.stripIndent=e.oneLineInlineLists=e.inlineLists=e.oneLineCommaListsAnd=e.oneLineCommaListsOr=e.oneLineCommaLists=e.oneLineTrim=e.oneLine=e.safeHtml=e.source=e.codeBlock=e.html=e.commaListsOr=e.commaListsAnd=e.commaLists=e.removeNonPrintingValuesTransformer=e.splitStringTransformer=e.inlineArrayTransformer=e.replaceStringTransformer=e.replaceSubstitutionTransformer=e.replaceResultTransformer=e.stripIndentTransformer=e.trimResultTransformer=e.TemplateTag=void 0;var t=w(x()),n=w(S()),r=w(C()),i=w(ae()),a=w(oe()),o=w(ce()),s=w(T()),c=w(de()),l=w(pe()),u=w(he()),d=w(_e()),f=w(ye()),p=w(xe()),m=w(Se()),h=w(Ce()),g=w(Te()),_=w(De()),v=w(ke()),y=w(je()),ee=w(Ne()),b=w(Fe()),te=w(Le()),ne=w(ze()),re=w(Ve()),ie=w(Ue());function w(e){return e&&e.__esModule?e:{default:e}}e.TemplateTag=t.default,e.trimResultTransformer=n.default,e.stripIndentTransformer=r.default,e.replaceResultTransformer=i.default,e.replaceSubstitutionTransformer=a.default,e.replaceStringTransformer=o.default,e.inlineArrayTransformer=s.default,e.splitStringTransformer=c.default,e.removeNonPrintingValuesTransformer=l.default,e.commaLists=u.default,e.commaListsAnd=d.default,e.commaListsOr=f.default,e.html=p.default,e.codeBlock=m.default,e.source=h.default,e.safeHtml=g.default,e.oneLine=_.default,e.oneLineTrim=v.default,e.oneLineCommaLists=y.default,e.oneLineCommaListsOr=ee.default,e.oneLineCommaListsAnd=b.default,e.inlineLists=te.default,e.oneLineInlineLists=ne.default,e.stripIndent=re.default,e.stripIndents=ie.default}))(),We=class extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge==`number`&&e.maxAge===0)throw TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||1/0,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if(typeof this.onEviction==`function`)for(let[t,n]of e)this.onEviction(t,n.value)}_deleteIfExpired(e,t){return typeof t.expiry==`number`&&t.expiry<=Date.now()?(typeof this.onEviction==`function`&&this.onEviction(e,t.value),this.delete(e)):!1}_getOrDeleteIfExpired(e,t){if(this._deleteIfExpired(e,t)===!1)return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){let n=t.get(e);return this._getItemValue(e,n)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield e)}for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield e)}}get(e){if(this.cache.has(e)){let t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){let t=this.oldCache.get(e);if(this._deleteIfExpired(e,t)===!1)return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:n=this.maxAge}={}){let r=typeof n==`number`&&n!==1/0?Date.now()+n:void 0;return this.cache.has(e)?this.cache.set(e,{value:t,expiry:r}):this._set(e,{value:t,expiry:r}),this}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):this.oldCache.has(e)?!this._deleteIfExpired(e,this.oldCache.get(e)):!1}peek(e){if(this.cache.has(e))return this._peek(e,this.cache);if(this.oldCache.has(e))return this._peek(e,this.oldCache)}delete(e){let t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw TypeError("`maxSize` must be a number greater than 0");let t=[...this._entriesAscending()],n=t.length-e;n<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(n>0&&this._emitEvictions(t.slice(0,n)),this.oldCache=new Map(t.slice(n)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this.cache.has(n)||this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}}*entriesAscending(){for(let[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(let t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[n,r]of this.entriesAscending())e.call(t,r,n,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}};function Ge(e,t){return(!e||e.endsWith(`
|
|
5
|
+
`))&&!t?.force?e:e+`
|
|
6
|
+
`}function D(e,t){return Ge(t)+e}function Ke(e,t){return(!e||e.endsWith(`
|
|
7
|
+
|
|
8
|
+
`))&&!t?.force?e:Ge(e)+`
|
|
9
|
+
`}function O(e,t){return Ke(t)+e}const qe=`https://prismic.io/docs/slices`,Je={UID:`https://prismic.io/docs/fields/uid`,Boolean:`https://prismic.io/docs/fields/boolean`,Color:`https://prismic.io/docs/fields/color`,Date:`https://prismic.io/docs/fields/date`,Timestamp:`https://prismic.io/docs/fields/timestamp`,Number:`https://prismic.io/docs/fields/number`,Text:`https://prismic.io/docs/fields/text`,Select:`https://prismic.io/docs/fields/select`,StructuredText:`https://prismic.io/docs/fields/rich-text`,Image:`https://prismic.io/docs/fields/image`,Link:{contentRelationship:`https://prismic.io/docs/fields/content-relationship`,link:`https://prismic.io/docs/fields/link`,linkToMedia:`https://prismic.io/docs/fields/link-to-media`},Embed:`https://prismic.io/docs/fields/embed`,GeoPoint:`https://prismic.io/docs/fields/geopoint`,Table:`https://prismic.io/docs/fields/table`,Group:`https://prismic.io/docs/fields/repeatable-group`,IntegrationFields:`https://prismic.io/docs/fields/integration`,Slices:`https://prismic.io/docs/slices`,Choice:`https://prismic.io/docs/slices`};var Ye=y({__addDisposableResource:()=>Ct,__assign:()=>Dt,__asyncDelegator:()=>ht,__asyncGenerator:()=>mt,__asyncValues:()=>gt,__await:()=>pt,__awaiter:()=>at,__classPrivateFieldGet:()=>bt,__classPrivateFieldIn:()=>St,__classPrivateFieldSet:()=>xt,__createBinding:()=>Ot,__decorate:()=>Qe,__disposeResources:()=>wt,__esDecorate:()=>et,__exportStar:()=>st,__extends:()=>Xe,__generator:()=>ot,__importDefault:()=>yt,__importStar:()=>vt,__makeTemplateObject:()=>_t,__metadata:()=>it,__param:()=>$e,__propKey:()=>nt,__read:()=>lt,__rest:()=>Ze,__rewriteRelativeImportExtension:()=>Tt,__runInitializers:()=>tt,__setFunctionName:()=>rt,__spread:()=>ut,__spreadArray:()=>ft,__spreadArrays:()=>dt,__values:()=>ct,default:()=>Mt});function Xe(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Et(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Ze(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Qe(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function $e(e,t){return function(n,r){t(n,r,e)}}function et(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else (d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0}function tt(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function nt(e){return typeof e==`symbol`?e:`${e}`}function rt(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,`name`,{configurable:!0,value:n?`${n} ${t}`:t})}function it(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function at(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function ot(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function st(e,t){for(var n in e)n!==`default`&&!Object.prototype.hasOwnProperty.call(t,n)&&Ot(t,e,n)}function ct(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function lt(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function ut(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(lt(arguments[t]));return e}function dt(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function ft(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function pt(e){return this instanceof pt?(this.v=e,this):new pt(e)}function mt(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof pt?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function ht(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:pt(e[r](t)),done:!1}:i?i(t):t}:i}}function gt(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ct==`function`?ct(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function _t(e,t){return Object.defineProperty?Object.defineProperty(e,`raw`,{value:t}):e.raw=t,e}function vt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=At(e),r=0;r<n.length;r++)n[r]!==`default`&&Ot(t,e,n[r]);return kt(t,e),t}function yt(e){return e&&e.__esModule?e:{default:e}}function bt(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function xt(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function St(e,t){if(t===null||typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Cannot use 'in' operator on non-object`);return typeof e==`function`?t===e:e.has(t)}function Ct(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}function wt(e){function t(t){e.error=e.hasError?new jt(t,e.error,`An error was suppressed during disposal.`):t,e.hasError=!0}var n,r=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(i,function(e){return t(e),i()})}else r|=1}catch(e){t(e)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return i()}function Tt(e,t){return typeof e==`string`&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,n,r,i,a){return n?t?`.jsx`:`.js`:r&&(!i||!a)?e:r+i+`.`+a.toLowerCase()+`js`}):e}var Et,Dt,Ot,kt,At,jt,Mt,Nt=_((()=>{Et=function(e,t){return Et=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Et(e,t)},Dt=function(){return Dt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Dt.apply(this,arguments)},Ot=Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),kt=Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t},At=function(e){return At=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},At(e)},jt=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},Mt={__extends:Xe,__assign:Dt,__rest:Ze,__decorate:Qe,__param:$e,__esDecorate:et,__runInitializers:tt,__propKey:nt,__setFunctionName:rt,__metadata:it,__awaiter:at,__generator:ot,__createBinding:Ot,__exportStar:st,__values:ct,__read:lt,__spread:ut,__spreadArrays:dt,__spreadArray:ft,__await:pt,__asyncGenerator:mt,__asyncDelegator:ht,__asyncValues:gt,__makeTemplateObject:_t,__importStar:vt,__importDefault:yt,__classPrivateFieldGet:bt,__classPrivateFieldSet:xt,__classPrivateFieldIn:St,__addDisposableResource:Ct,__disposeResources:wt,__rewriteRelativeImportExtension:Tt}})),Pt=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.lowerCase=e.localeLowerCase=void 0;var t={tr:{regexp:/\u0130|\u0049|\u0049\u0307/g,map:{İ:`i`,I:`ı`,İ:`i`}},az:{regexp:/\u0130/g,map:{İ:`i`,I:`ı`,İ:`i`}},lt:{regexp:/\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,map:{I:`i̇`,J:`j̇`,Į:`į̇`,Ì:`i̇̀`,Í:`i̇́`,Ĩ:`i̇̃`}}};function n(e,n){var i=t[n.toLowerCase()];return r(i?e.replace(i.regexp,function(e){return i.map[e]}):e)}e.localeLowerCase=n;function r(e){return e.toLowerCase()}e.lowerCase=r})),Ft=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.noCase=void 0;var t=Pt(),n=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],r=/[^A-Z0-9]+/gi;function i(e,i){i===void 0&&(i={});for(var o=i.splitRegexp,s=o===void 0?n:o,c=i.stripRegexp,l=c===void 0?r:c,u=i.transform,d=u===void 0?t.lowerCase:u,f=i.delimiter,p=f===void 0?` `:f,m=a(a(e,s,`$1\0$2`),l,`\0`),h=0,g=m.length;m.charAt(h)===`\0`;)h++;for(;m.charAt(g-1)===`\0`;)g--;return m.slice(h,g).split(`\0`).map(d).join(p)}e.noCase=i;function a(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce(function(e,t){return e.replace(t,n)},e)}})),It=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.pascalCase=e.pascalCaseTransformMerge=e.pascalCaseTransform=void 0;var t=(Nt(),b(Ye)),n=Ft();function r(e,t){var n=e.charAt(0),r=e.substr(1).toLowerCase();return t>0&&n>=`0`&&n<=`9`?`_`+n+r:``+n.toUpperCase()+r}e.pascalCaseTransform=r;function i(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}e.pascalCaseTransformMerge=i;function a(e,i){return i===void 0&&(i={}),n.noCase(e,t.__assign({delimiter:``,transform:r},i))}e.pascalCase=a}))();const k=(...e)=>{let t=(0,It.pascalCase)(e.filter(Boolean).join(` `),{transform:It.pascalCaseTransformMerge});return/^[0-9]/.test(t)&&(t=`_${t}`),t},Lt={Boolean:`Boolean`,Color:`Color`,Date:`Date`,Embed:`Embed`,GeoPoint:`GeoPoint`,Group:`Group`,Image:`Image`,Integration:`IntegrationFields`,Link:`Link`,Number:`Number`,Select:`Select`,Slices:`Slices`,StructuredText:`StructuredText`,Table:`Table`,Text:`Text`,Timestamp:`Timestamp`,UID:`UID`,IntegrationFields:`IntegrationFields`,Range:`Range`,Separator:`Separator`,LegacySlices:`Choice`};function Rt(e){let t=``;for(let n=0;n<e.path.length;n++){n>0&&(t+=`.`);let r=e.path[n];if(r.model&&`type`in r.model&&(r.model.type===`Group`||r.model.type===`Slices`))t+=`${r.name}[]`;else{if(r.name===`items`){let i=e.path[n-1];if(i.model&&`json`in i.model||i.model&&`type`in i.model&&i.model.type===`SharedSlice`){t+=`${r.name}[]`;continue}}t+=r.name}}return t}const zt=e=>{if(`json`in e.model)return e.model.label||e.model.id;if(`type`in e.model&&e.model.type===`SharedSlice`)return e.model.name;if(`type`in e.model&&e.model.type===`Slice`)return e.model.fieldset||e.name;if(`type`in e.model){if(e.model.config&&`label`in e.model.config)return e.model.config.label||e.name;if(e.model.config&&`fieldset`in e.model)return e.model.fieldset||e.name}return`\`${e.name}\``};function Bt(e){return e.path.map(e=>e.label?e.label:e.model?zt({model:e.model,name:e.name}):e.name).join(` → `)}function Vt(e){switch(e.field.type){case`StructuredText`:return`Rich Text`;case`IntegrationFields`:{let t=e.field.config?.catalog;return`Integration Fields (Catalog: ${t?`\`${t}\``:`*unknown*`})`}case`Link`:switch(e.field.config?.select){case`document`:return`Content Relationship`;case`media`:return`Link to Media`;default:return`Link`}case`Slices`:return`Slice Zone`;default:return e.field.type}}function Ht(e){switch(e.field.type){case`Link`:{let t=Je.Link;switch(e.field.config?.select){case`document`:return t.contentRelationship;case`media`:return t.linkToMedia;default:return t.link}}default:{let t=Je[e.field.type];if(typeof t==`string`)return t}}}function Ut(e){let t=`/**`,n=zt({model:e.field,name:e.name}),r=Bt({path:e.path}),i=Vt({field:e.field});t=D(` * ${n} field in *${r}*`,t),t=D(` *`,t),t=D(` * - **Field Type**: ${i}`,t),t=D(` * - **Placeholder**: ${e.field.config&&`placeholder`in e.field.config&&e.field.config.placeholder||`*None*`}`,t);let a=e.field.config&&`default_value`in e.field.config?e.field.config.default_value:void 0;a!==void 0&&(t=D(` * - **Default Value**: ${typeof a==`boolean`?`${a}`:a}`,t)),t=D(` * - **API ID Path**: ${Rt({path:[...e.path,{name:e.name,model:e.field}]})}`,t),e.tabName&&(t=D(` * - **Tab**: ${e.tabName}`,t));let o=Ht({field:e.field});return o&&(t=D(` * - **Documentation**: ${o}`,t)),t=D(` */`,t),t}function A(e){return e.filter(Boolean).join(` | `)||`never`}function Wt(e){let t=Ut({name:e.name,field:e.field,path:e.path,tabName:e.tabName}),n=[],r=[],i=e.name.includes(`-`)||e.name.includes(`:`)||/^[0-9]/.test(e.name)?`"${e.name}"`:e.name;switch(e.field.type){case`UID`:break;case`Boolean`:t=D(`${i}: prismic.BooleanField;`,t);break;case`Color`:t=D(`${i}: prismic.ColorField;`,t);break;case`Date`:t=D(`${i}: prismic.DateField;`,t);break;case`Embed`:{let n=[];if(e.fieldConfigs.embed?.providerTypes)for(let t in e.fieldConfigs.embed?.providerTypes){let r=e.fieldConfigs.embed?.providerTypes[t];n.push(`({ provider_name: "${t}" } & ${r})`)}let r=A(n);t=n.length>0?D(`${i}: prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${r})>`,t):D(`${i}: prismic.EmbedField`,t);break}case`GeoPoint`:t=D(`${i}: prismic.GeoPointField;`,t);break;case`Image`:t=e.field.config?.thumbnails&&e.field.config.thumbnails.length>0?D(`${i}: prismic.ImageField<${A(e.field.config.thumbnails.map(e=>`"${e.name}"`))}>;`,t):D(`${i}: prismic.ImageField<never>;`,t);break;case`IntegrationFields`:{let n=e.field.config?.catalog?e.fieldConfigs.integrationFields?.catalogTypes?.[e.field.config.catalog]:void 0;t=D(n?`${i}: prismic.IntegrationField<${n}>;`:`${i}: prismic.IntegrationField;`,t);break}case`Link`:{let n=e.field.config&&`variants`in e.field.config&&Array.isArray(e.field.config.variants)&&e.field.config.variants.length>0?e.field.config.variants.map(e=>`"${e.replace(/\"/g,`\\"`)}"`).join(` | `):`never`;switch(e.field.config?.select){case`document`:t=`customtypes`in e.field.config&&e.field.config.customtypes&&e.field.config.customtypes.length>0?D(`${i}: ${A(e.field.config.customtypes.map(e=>typeof e==`string`?`prismic.ContentRelationshipField<"${e}">`:`ContentRelationshipFieldWithData<${JSON.stringify([e])}>`))};`,t):D(`${i}: prismic.ContentRelationshipField;`,t);break;case`media`:t=D(`${i}: prismic.LinkToMediaField<prismic.FieldState, ${n}>;`,t);break;default:{let r=`prismic.LinkField<string, string, unknown, prismic.FieldState, ${n}>`;e.field.config?.repeat&&(r=`prismic.Repeatable<${r}>`),t=D(`${i}: ${r};`,t);break}}break}case`Number`:t=D(`${i}: prismic.NumberField;`,t);break;case`StructuredText`:t=D(`${i}: prismic.RichTextField;`,t);break;case`Select`:{let n=(e.field.config?.options)?.map(e=>`"${e}"`)||[],r=n.length?A(n):`string`;t=e.field.config?.default_value?D(`${i}: prismic.SelectField<${r}, "filled">;`,t):D(`${i}: prismic.SelectField${n.length>0?`<${r}>`:``};`,t);break}case`Table`:t=D(`${i}: prismic.TableField;`,t);break;case`Text`:t=D(`${i}: prismic.KeyTextField;`,t);break;case`Timestamp`:t=D(`${i}: prismic.TimestampField;`,t);break;case`Group`:{let a=e.path.filter(e=>e.model!==void 0&&`type`in e.model&&e.model.type===Lt.Group),o=a.length>0,s;if(e.path[0].model&&`type`in e.path[0].model&&e.path[0].model.type===`SharedSlice`){let[t,n,r]=e.path;s=k(t.name,`Slice`,n.name,r.name,...a.map(e=>e.name),e.name,`Item`)}else s=k(e.path[0].name,`Document`,`Data`,...a.map(e=>e.name),e.name,`Item`);let c=[...e.path,{name:i,model:e.field}],l=Bt({path:c}),u=Gt({fields:e.field.config?.fields||{},fieldConfigs:e.fieldConfigs,path:c});n.push(...u.auxiliaryTypes),r.push(...u.contentTypeNames),n.push({name:s,code:E.source`
|
|
10
|
+
/**
|
|
11
|
+
* Item in *${l}*
|
|
12
|
+
*/
|
|
13
|
+
export interface ${s} {
|
|
14
|
+
${u.code}
|
|
15
|
+
}
|
|
16
|
+
`}),r.push(s),t=D(o?`${i}: prismic.NestedGroupField<Simplify<${s}>>;`:`${i}: prismic.GroupField<Simplify<${s}>>;`,t);break}case`Slices`:{let a=[];if(e.field.config?.choices)for(let t in e.field.config.choices){let i=e.field.config.choices[t];if(i.type===`SharedSlice`)a.push(k(t,`Slice`));else if(i.type===`Slice`){let o=k(e.path[0].name,`Document`,`Data`,e.name,t,`Slice`),s;if(i[`non-repeat`]&&Object.keys(i[`non-repeat`]).length>0){s=k(o,`Primary`);let a=[...e.path,{name:e.name,model:e.field},{name:t,model:i},{name:`primary`,label:`Primary`}],c=Bt({path:a}),l=Gt({fields:i[`non-repeat`],fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=E.stripIndent`
|
|
17
|
+
/**
|
|
18
|
+
* Primary content in *${c}*
|
|
19
|
+
*/
|
|
20
|
+
`;u=l.code?D(E.source`
|
|
21
|
+
export interface ${s} {
|
|
22
|
+
${l.code}
|
|
23
|
+
}
|
|
24
|
+
`,u):D(`export interface ${s} {}`,u),n.push({name:s,code:u}),r.push(s)}let c;if(i.repeat&&Object.keys(i.repeat).length>0){c=k(o,`Item`);let a=[...e.path,{name:e.name,model:e.field},{name:t,model:i},{name:`items`,label:`Items`}],s=Bt({path:a}),l=Gt({fields:i.repeat,fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=E.stripIndent`
|
|
25
|
+
/**
|
|
26
|
+
* Item content in *${s}*
|
|
27
|
+
*/
|
|
28
|
+
`;u=l.code?D(E.source`
|
|
29
|
+
export interface ${c} {
|
|
30
|
+
${l.code}
|
|
31
|
+
}
|
|
32
|
+
`,u):D(`export interface ${c} {}`,u),n.push({name:c,code:u}),r.push(c)}n.push({name:o,code:E.stripIndent`
|
|
33
|
+
/**
|
|
34
|
+
* Slice for *${Bt({path:[...e.path,{name:e.name,model:e.field}]})}*
|
|
35
|
+
*/
|
|
36
|
+
export type ${o} = prismic.Slice<"${t}", ${s?`Simplify<${s}>`:`Record<string, never>`}, ${c?`Simplify<${c}>`:`never`}>
|
|
37
|
+
`}),a.push(o)}}let o=k(e.path[0].name,`Document`,`Data`,e.name,`Slice`),s=A(a);n.push({name:o,code:`type ${o} = ${s}`}),r.push(o),t=D(`${i}: prismic.SliceZone<${o}>;`,t);break}default:t=D(`${i}: unknown;`,t)}return{code:t,auxiliaryTypes:n,contentTypeNames:r}}function Gt(e){let t=``,n=[],r=[];for(let i in e.fields){let a=e.fields[i],o=Wt({name:i,field:a,path:e.path,fieldConfigs:e.fieldConfigs,tabName:e.tabName});t=O(o.code,t),n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames)}return{code:t,auxiliaryTypes:n,contentTypeNames:r}}function Kt(e){let t=``,n=[],r=[],i=k(e.model.id,`Document`,`Data`),a=zt({name:e.model.id,model:e.model}),o=``;for(let t in e.model.json){let{uid:i,...a}=e.model.json[t],s=Gt({fields:a,fieldConfigs:e.fieldConfigs,path:[{name:e.model.id,model:e.model}],tabName:t});o+=s.code,n.push(...s.auxiliaryTypes),r.push(...s.contentTypeNames)}return t=o?E.source`
|
|
38
|
+
/**
|
|
39
|
+
* Content for ${a} documents
|
|
40
|
+
*/
|
|
41
|
+
interface ${i} {
|
|
42
|
+
${o}
|
|
43
|
+
}
|
|
44
|
+
`:`interface ${i} {}`,{name:i,code:t,auxiliaryTypes:n,contentTypeNames:r}}function qt(e){return`uid`in Object.assign({},...Object.values(e.json))}const Jt=e=>c.createHash(`sha1`).update(JSON.stringify(e)).digest(`hex`);function Yt(e){if(e.cache){let t=Jt(e.model),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=k(e.model.id,`Document`),a=e.localeIDs&&e.localeIDs.length>0?A(e.localeIDs.map(e=>`"${e}"`)):`string`,o=qt(e.model)?`PrismicDocumentWithUID`:`PrismicDocumentWithoutUID`,s=zt({name:e.model.id,model:e.model}),c=Kt({model:e.model,fieldConfigs:e.fieldConfigs});n.push(...c.auxiliaryTypes),r.push(c.name),r.push(...c.contentTypeNames),t=O(c.code,t),t=O(E.source`
|
|
45
|
+
/**
|
|
46
|
+
* ${s} document from Prismic
|
|
47
|
+
*
|
|
48
|
+
* - **API ID**: \`${e.model.id}\`
|
|
49
|
+
* - **Repeatable**: \`${e.model.repeatable.toString()}\`
|
|
50
|
+
* - **Documentation**: ${`https://prismic.io/docs/content-modeling`}
|
|
51
|
+
*
|
|
52
|
+
* @typeParam Lang - Language API ID of the document.
|
|
53
|
+
*/
|
|
54
|
+
export type ${i}<Lang extends string = ${a}> = prismic.${o}<Simplify<${c.name}>, "${e.model.id}", Lang>;
|
|
55
|
+
`,t);let l={name:i,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=Jt(e.model);e.cache.set(t,l)}return l}function Xt(e){if(e.cache){let t=Jt([e.model,e.fieldConfigs]),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=k(e.model.id,`Slice`),a=zt({name:e.model.id,model:e.model}),o=[];for(let s of e.model.variations){let c=k(i,s.id),l;if(s.primary&&Object.keys(s.primary).length>0){l=k(c,`Primary`);let i=[{name:e.model.id,model:e.model},{name:s.id,label:s.name},{name:`primary`,label:`Primary`}],a=Bt({path:i}),o=Gt({fields:s.primary,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(l);let u=E.stripIndent`
|
|
56
|
+
/**
|
|
57
|
+
* Primary content in *${a}*
|
|
58
|
+
*/
|
|
59
|
+
`;t=O(o.code?E.source`
|
|
60
|
+
${u}
|
|
61
|
+
export interface ${l} {
|
|
62
|
+
${o.code}
|
|
63
|
+
}
|
|
64
|
+
`:E.source`
|
|
65
|
+
${u}
|
|
66
|
+
export interface ${l} {}
|
|
67
|
+
`,t)}let u;if(s.items&&Object.keys(s.items).length>0){u=k(c,`Item`);let i=[{name:e.model.id,model:e.model},{name:`items`,label:`Items`}],a=Bt({path:i}),o=Gt({fields:s.items,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(u);let l=E.stripIndent`
|
|
68
|
+
/**
|
|
69
|
+
* Primary content in *${a}*
|
|
70
|
+
*/
|
|
71
|
+
`;t=O(o.code?E.source`
|
|
72
|
+
${l}
|
|
73
|
+
export interface ${u} {
|
|
74
|
+
${o.code}
|
|
75
|
+
}
|
|
76
|
+
`:E.source`
|
|
77
|
+
${l}
|
|
78
|
+
export interface ${u} {}
|
|
79
|
+
`,t)}t=O(E.source`
|
|
80
|
+
/**
|
|
81
|
+
* ${s.name} variation for ${a} Slice
|
|
82
|
+
*
|
|
83
|
+
* - **API ID**: \`${s.id}\`
|
|
84
|
+
* - **Description**: ${s.description||`*None*`}
|
|
85
|
+
* - **Documentation**: ${qe}
|
|
86
|
+
*/
|
|
87
|
+
export type ${c} = prismic.SharedSliceVariation<"${s.id}", ${l?`Simplify<${l}>`:`Record<string, never>`}, ${u?`Simplify<${u}>`:`never`}>;
|
|
88
|
+
`,t),o.push(c)}let s=k(i,`Variation`),c=A(o);r.push(s),r.push(...o),t=O(E.source`
|
|
89
|
+
/**
|
|
90
|
+
* Slice variation for *${a}*
|
|
91
|
+
*/
|
|
92
|
+
type ${s} = ${o.length>0?c:`never`}
|
|
93
|
+
`,t),t=O(E.source`
|
|
94
|
+
/**
|
|
95
|
+
* ${a} Shared Slice
|
|
96
|
+
*
|
|
97
|
+
* - **API ID**: \`${e.model.id}\`
|
|
98
|
+
* - **Description**: ${e.model.description||`*None*`}
|
|
99
|
+
* - **Documentation**: ${qe}
|
|
100
|
+
*/
|
|
101
|
+
export type ${i} = prismic.SharedSlice<"${e.model.id}", ${s}>;
|
|
102
|
+
`,t);let l={name:i,variationNames:o,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=Jt([e.model,e.fieldConfigs]);e.cache.set(t,l)}return l}const Zt=new We({maxSize:1e3});function Qt(e={}){let t=e.fieldConfigs||{},n=e.cache??!0,r=``,i=e.typesProvider||`@prismicio/types`,a=`prismic`;r=D(`import type * as prismic from "${i}";`,r),(e.clientIntegration?.includeCreateClientInterface||e.clientIntegration?.includeContentNamespace)&&i!==`@prismicio/client`&&(a=`prismicClient`,r=D(`import type * as ${a} from "@prismicio/client";`,r)),r=O(`type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };`,r),r=O(`
|
|
103
|
+
type PickContentRelationshipFieldData<
|
|
104
|
+
TRelationship extends prismic.CustomTypeModelFetchCustomTypeLevel1 | prismic.CustomTypeModelFetchCustomTypeLevel2 | prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2,
|
|
105
|
+
TData extends Record<string, prismic.AnyRegularField | prismic.GroupField | prismic.NestedGroupField | prismic.SliceZone>,
|
|
106
|
+
TLang extends string
|
|
107
|
+
> = |
|
|
108
|
+
// Content relationship fields
|
|
109
|
+
{
|
|
110
|
+
[TSubRelationship in Extract<
|
|
111
|
+
TRelationship["fields"][number], prismic.CustomTypeModelFetchContentRelationshipLevel1
|
|
112
|
+
> as TSubRelationship["id"]]:
|
|
113
|
+
ContentRelationshipFieldWithData<TSubRelationship["customtypes"], TLang>;
|
|
114
|
+
} &
|
|
115
|
+
// Group
|
|
116
|
+
{
|
|
117
|
+
[TGroup in Extract<
|
|
118
|
+
TRelationship["fields"][number], prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2
|
|
119
|
+
> as TGroup["id"]]:
|
|
120
|
+
TData[TGroup["id"]] extends prismic.GroupField<infer TGroupData>
|
|
121
|
+
? prismic.GroupField<PickContentRelationshipFieldData<TGroup, TGroupData, TLang>>
|
|
122
|
+
: never
|
|
123
|
+
} &
|
|
124
|
+
// Other fields
|
|
125
|
+
{
|
|
126
|
+
[TFieldKey in Extract<TRelationship["fields"][number], string>]:
|
|
127
|
+
TFieldKey extends keyof TData ? TData[TFieldKey] : never;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
type ContentRelationshipFieldWithData<
|
|
131
|
+
TCustomType extends readonly (prismic.CustomTypeModelFetchCustomTypeLevel1 | string)[] | readonly (prismic.CustomTypeModelFetchCustomTypeLevel2 | string)[],
|
|
132
|
+
TLang extends string = string
|
|
133
|
+
> = {
|
|
134
|
+
[ID in Exclude<TCustomType[number], string>["id"]]:
|
|
135
|
+
prismic.ContentRelationshipField<
|
|
136
|
+
ID,
|
|
137
|
+
TLang,
|
|
138
|
+
PickContentRelationshipFieldData<
|
|
139
|
+
Extract<TCustomType[number], { id: ID }>,
|
|
140
|
+
Extract<prismic.Content.AllDocumentTypes, { type: ID }>["data"],
|
|
141
|
+
TLang
|
|
142
|
+
>
|
|
143
|
+
>
|
|
144
|
+
}[Exclude<TCustomType[number], string>["id"]];
|
|
145
|
+
`,r);let o=[];if(e.customTypeModels){let i=[];for(let a of e.customTypeModels){let s=Yt({model:a,localeIDs:e.localeIDs,fieldConfigs:t,cache:n?Zt:void 0});for(let e of s.auxiliaryTypes)r=O(e.code,r);r=O(s.code,r),i.push(s.name),o.push(s.name),o.push(...s.contentTypeNames)}if(e.customTypeModels.length>0){let e=`AllDocumentTypes`;r=O(`export type ${e} = ${A(i)};`,r),o.push(e)}}if(e.sharedSliceModels)for(let i of e.sharedSliceModels){let e=Xt({model:i,fieldConfigs:t,cache:n?Zt:void 0});for(let t of e.auxiliaryTypes)r=O(t.code,r);r=O(e.code,r),o.push(e.name),o.push(...e.contentTypeNames)}if(e.clientIntegration?.includeCreateClientInterface||e.clientIntegration?.includeContentNamespace){let t=``;e.clientIntegration.includeCreateClientInterface&&((e.customTypeModels?.length||0)>0?(t=O(`interface CreateClient {
|
|
146
|
+
(repositoryNameOrEndpoint: string, options?: ${a}.ClientConfig): ${a}.Client<AllDocumentTypes>;
|
|
147
|
+
}`,t),t=O(`interface CreateWriteClient {
|
|
148
|
+
(repositoryNameOrEndpoint: string, options: ${a}.WriteClientConfig): ${a}.WriteClient<AllDocumentTypes>;
|
|
149
|
+
}`,t),t=O(`interface CreateMigration {
|
|
150
|
+
(): ${a}.Migration<AllDocumentTypes>;
|
|
151
|
+
}`,t)):(t=O(`interface CreateClient {
|
|
152
|
+
(repositoryNameOrEndpoint: string, options?: ${a}.ClientConfig): ${a}.Client;
|
|
153
|
+
}`,t),t=O(`interface CreateWriteClient {
|
|
154
|
+
(repositoryNameOrEndpoint: string, options?: ${a}.WriteClientConfig): ${a}.WriteClient;
|
|
155
|
+
}`,t),t=O(`interface CreateMigration {
|
|
156
|
+
(): ${a}.Migration;
|
|
157
|
+
}`,t))),e.clientIntegration.includeContentNamespace&&(t=O(E.source`
|
|
158
|
+
namespace Content {
|
|
159
|
+
export type {
|
|
160
|
+
${o.join(`,
|
|
161
|
+
`)}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
`,t)),r=O(E.source`
|
|
165
|
+
declare module "@prismicio/client" {
|
|
166
|
+
${t}
|
|
167
|
+
}
|
|
168
|
+
`,r)}return r}async function j(e){let t=await on();return t.hostname=`${e}.${t.hostname}`,tn(t)}async function $t(){let e=await on();return e.hostname=`api.internal.${e.hostname}`,tn(e)}async function en(){let e=await on();return e.hostname=`user-service.${e.hostname}`,tn(e)}function tn(e){let t=new URL(e);return t.pathname.endsWith(`/`)||(t.pathname+=`/`),t}const nn=new URL(`.prismic`,tn(u(l()))),rn=`https://prismic.io`;async function an(e,t){let n={token:e,host:t?.host};await s(nn,JSON.stringify(n,null,2))}async function M(){return!!await N()}async function N(){return(await sn())?.token}async function on(){try{let e=await sn();return e?.host?new URL(e.host):new URL(rn)}catch{return new URL(rn)}}async function sn(){try{let e=await r(nn,`utf-8`);return JSON.parse(e)}catch{return}}async function cn(){try{await t(nn)}catch{return!0}return await sn()?(await o(nn),!0):!1}function ln(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function un(e){return(void 0)?.get(e)}function dn(e){return(void 0)?.get(e)}function fn(e,t){return(void 0)?.get(e)?.get(t)}function pn(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function P(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??pn(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??fn(e.reference,c.lang)??(l?dn(c.lang):null)??r.message??un(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function F(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},ln())}}}function mn(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function I(e){return e instanceof hn}var hn=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function gn(e){return{kind:`validation`,type:`url`,reference:gn,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&P(this,`URL`,e,t),e}}}function _n(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function vn(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function L(e,t){return{kind:`schema`,type:`array`,reference:L,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return F(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else P(this,`type`,e,t);return e}}}function R(e){return{kind:`schema`,type:`boolean`,reference:R,expects:`boolean`,async:!1,message:e,get"~standard"(){return F(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:P(this,`type`,e,t),e}}}function yn(e,t){return{kind:`schema`,type:`literal`,reference:yn,expects:pn(e),async:!1,literal:e,message:t,get"~standard"(){return F(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:P(this,`type`,e,t),e}}}function bn(e,t){return{kind:`schema`,type:`nullable`,reference:bn,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return F(this)},"~run"(e,t){return e.value===null&&(this.default!==void 0&&(e.value=vn(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function xn(e){return{kind:`schema`,type:`number`,reference:xn,expects:`number`,async:!1,message:e,get"~standard"(){return F(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:P(this,`type`,e,t),e}}}function z(e,t){return{kind:`schema`,type:`object`,reference:z,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return F(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`)for(let r in e.typed=!0,e.value={},this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:vn(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=_n(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(P(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}else P(this,`type`,e,t);return e}}}function B(e,t){return{kind:`schema`,type:`optional`,reference:B,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return F(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=vn(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function V(e,t,n){return{kind:`schema`,type:`record`,reference:V,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return F(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},n)if(mn(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else P(this,`type`,e,t);return e}}}function H(e){return{kind:`schema`,type:`string`,reference:H,expects:`string`,async:!1,message:e,get"~standard"(){return F(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:P(this,`type`,e,t),e}}}function U(){return{kind:`schema`,type:`unknown`,reference:U,expects:`unknown`,async:!1,get"~standard"(){return F(this)},"~run"(e){return e.typed=!0,e}}}function Sn(e,t,n){let r=e[`~run`]({value:t},ln(n));if(r.issues)throw new hn(r.issues);return r.value}function Cn(...e){return{...e[0],pipe:e,get"~standard"(){return F(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function W(e,t,n){let r=e[`~run`]({value:t},ln(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}async function G(e,n={}){let{start:r=u(process.cwd()),stop:i}=n,a=tn(r);for(;;){let n=new URL(e,a);try{return await t(n),n}catch{}if(typeof i==`string`){let e=new URL(i,a);try{await t(e);return}catch{}}else if(i instanceof URL&&i.href===a.href)return;let r=new URL(`..`,a);if(r.href===a.href)return;a=r}}async function wn(e){try{return await t(e),!0}catch{return!1}}function K(e){return JSON.stringify(e,null,2)}const Tn=`prismic.config.json`,En=z({repositoryName:H(),apiEndpoint:B(Cn(H(),gn())),localSliceMachineSimulatorURL:B(Cn(H(),gn())),libraries:B(L(H())),adapter:B(H()),labs:B(z({legacySliceUpgrader:B(R())}))});async function Dn(e,t=u(process.cwd())){let n=await Mn(t);return n.ok?(await s(n.path,K(e)),{ok:!0,config:e}):n}async function q(e=u(process.cwd())){let t=await On(e);if(t.ok)return t.config.repositoryName}async function On(e=u(process.cwd())){let t=await jn(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=W(En,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new kn(n.issues)}}catch{return{ok:!1,error:new kn}}}var kn=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function An(e,t=u(process.cwd())){let n=await jn(t);if(!n.ok)return n;let r=await On(t);if(!r.ok)return r;let i={...r.config,...e};return await s(n.path,K(i)),{ok:!0,config:i}}async function jn(e=u(process.cwd())){let t=await G(Tn,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new Nn}}async function Mn(e=u(process.cwd())){let t=await G(`package.json`,{start:e});return t?{ok:!0,path:new URL(Tn,t)}:{ok:!1,error:new Pn}}var Nn=class extends Error{message=`Could not find a prismic.config.json file.`},Pn=class extends Error{message=`Could not find a package.json file.`};const Fn=z({id:H(),type:yn(`SharedSlice`),name:H(),description:B(H()),variations:L(z({id:H(),name:H(),description:B(H()),docURL:B(H()),version:B(H()),imageUrl:B(H()),primary:B(V(H(),U())),items:B(V(H(),U()))}))});async function J(e){if(!await G(`package.json`))return{ok:!1,error:`Could not find project root (no package.json found)`};let t=await In(),n;try{n=await i(t,{withFileTypes:!1})}catch{return{ok:!1,error:`No slices directory found at ${t.href}`}}for(let i of n){let n=new URL(`${i}/model.json`,t);try{let t=await r(n,`utf8`),i=JSON.parse(t);if(i.id===e){let e=W(Fn,i);return e.success?{ok:!0,model:e.output,modelPath:n}:{ok:!1,error:`Invalid slice model at ${n.href}`}}}catch{}}return{ok:!1,error:`Slice not found: ${e}\n\nCreate it first with: prismic slice create ${e}`}}async function In(){let e=await Rn(),t=await G(`package.json`);if(!t)throw Error(`Could not find project root (no package.json found)`);let n=new URL(`.`,t);switch(e){case`next`:if(await wn(new URL(`src`,n)))return new URL(`src/slices/`,n);case`nuxt`:if(await wn(new URL(`app`,n)))return new URL(`app/slices/`,n);case`sveltekit`:return new URL(`src/slices/`,n)}return new URL(`slices/`,n)}const Ln=z({dependencies:B(V(H(),H()))});async function Rn(){let e=await G(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=Sn(Ln,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function zn(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Bn=z({id:H(),label:B(H()),repeatable:R(),status:R(),format:B(H()),json:V(H(),U())});async function Vn(){let e=await on();return e.hostname=`customtypes.${e.hostname}`,e}async function Hn(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Vn(),r=new URL(`customtypes`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=W(L(Bn),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Un(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Vn(),r=new URL(`slices`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=W(L(Fn),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Wn(){let e=await G(`package.json`);if(!e)return{ok:!1,error:`Could not find project root (no package.json found)`};let t=new URL(`.`,e),n=new URL(`customtypes/`,t),a;try{a=await i(n,{withFileTypes:!1})}catch{return{ok:!0,value:[]}}let o=[];for(let e of a){let t=new URL(`${e}/index.json`,n);try{let e=await r(t,`utf8`),n=W(Bn,JSON.parse(e));n.success&&o.push(n.output)}catch{}}return{ok:!0,value:o}}async function Gn(){let e;try{e=await In()}catch{return{ok:!1,error:`Could not find project root (no package.json found)`}}let t;try{t=await i(e,{withFileTypes:!1})}catch{return{ok:!0,value:[]}}let n=[];for(let i of t){let t=new URL(`${i}/model.json`,e);try{let e=await r(t,`utf8`),i=W(Fn,JSON.parse(e));i.success&&n.push(i.output)}catch{}}return{ok:!0,value:n}}async function Kn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`customtypes/insert`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function qn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`customtypes/update`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Jn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`customtypes/${encodeURIComponent(t)}`,r);try{let t=await fetch(i,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,repository:e}});return t.ok?{ok:!0,value:void 0}:t.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:t.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${t.status} ${t.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Yn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`slices/insert`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Xn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`slices/update`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Zn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Vn(),i=new URL(`slices/${encodeURIComponent(t)}`,r);try{let t=await fetch(i,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,repository:e}});return t.ok?{ok:!0,value:void 0}:t.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:t.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${t.status} ${t.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Y(e,t={}){let{credentials:n=`include`}=t,r=new Headers(t.headers);if(r.set(`Accept`,`application/json`),n===`include`){let e=await N();e&&r.set(`Cookie`,`SESSION=fake_session; prismic-auth=${e}`)}!r.has(`Content-Type`)&&t.body&&r.set(`Content-Type`,`application/json`),t.body instanceof FormData&&r.delete(`Content-Type`);let i=r.get(`Content-Type`)===`application/json`?JSON.stringify(t.body):t.body,a=await fetch(e,{...t,body:i,headers:r}),o=await a.clone().json().catch(()=>a.clone().text());if(a.ok){if(!t?.schema)return{ok:!0,value:o};try{return{ok:!0,value:Sn(t.schema,o)}}catch(e){if(I(e))return{ok:!1,value:o,error:e};throw e}}else if(a.status===401)return{ok:!1,value:o,error:new Z(a)};else if(a.status===403)return{ok:!1,value:o,error:new X(a)};else return{ok:!1,value:o,error:new Qn(a)}}var Qn=class extends Error{name=`RequestError`;response;constructor(e){super(`fetch failed: ${e.url}`),this.response=e}async text(){return this.response.clone().text()}async json(){return this.response.clone().json()}get status(){return this.response.status}get statusText(){return this.response.statusText}},X=class extends Qn{},Z=class extends Qn{};async function $n(){let{values:{help:t,repo:n=await q(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all locales in a Prismic repository.
|
|
169
|
+
|
|
170
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
171
|
+
project root.
|
|
172
|
+
|
|
173
|
+
USAGE
|
|
174
|
+
prismic locale list [flags]
|
|
175
|
+
|
|
176
|
+
FLAGS
|
|
177
|
+
--json Output as JSON
|
|
178
|
+
-r, --repo string Repository domain
|
|
179
|
+
-h, --help Show help for command
|
|
180
|
+
|
|
181
|
+
LEARN MORE
|
|
182
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){nr();return}let i=await tr(n);if(!i.ok){i.error instanceof X?nr():I(i.error)?(console.error(`Failed to list locales: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(K(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const er=z({results:L(z({id:H(),label:H(),customName:bn(H()),isMaster:R()}))});async function tr(e){let t=new URL(`/locale/repository/locales`,await $t());return t.searchParams.set(`repository`,e),await Y(t,{schema:er})}function nr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function rr(){let{values:{help:t,repo:n=await q(),output:r=`prismicio-types.d.ts`}}=e({args:process.argv.slice(4),options:{output:{type:`string`,short:`o`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Generate TypeScript types from models pushed to Prismic.
|
|
183
|
+
|
|
184
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
185
|
+
project root.
|
|
186
|
+
|
|
187
|
+
USAGE
|
|
188
|
+
prismic codegen types [flags]
|
|
189
|
+
|
|
190
|
+
FLAGS
|
|
191
|
+
-o, --output string Output file path (default: "prismicio-types.d.ts")
|
|
192
|
+
-r, --repo string Repository domain
|
|
193
|
+
-h, --help Show help for command
|
|
194
|
+
|
|
195
|
+
EXAMPLES
|
|
196
|
+
prismic codegen types
|
|
197
|
+
prismic codegen types --repo my-repo
|
|
198
|
+
prismic codegen types --output custom.d.ts`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}let[i,a,o]=await Promise.all([Hn(n),Un(n),tr(n)]);if(!i.ok){console.error(`Failed to fetch custom types: ${i.error}`),process.exitCode=1;return}if(!a.ok){console.error(`Failed to fetch slices: ${a.error}`),process.exitCode=1;return}if(!o.ok){console.error(`Failed to fetch locales: ${o.error}`),process.exitCode=1;return}let c=i.value,l=a.value;await s(r,`// Code generated by prismic-ts-codegen. DO NOT EDIT.
|
|
199
|
+
|
|
200
|
+
`+Qt({customTypeModels:c,sharedSliceModels:l,localeIDs:o.value.results.map(e=>e.id),typesProvider:`@prismicio/client`,clientIntegration:{includeCreateClientInterface:c.length>0||l.length>0,includeContentNamespace:!0}})),console.info(`Generated types written to ${r}`)}async function ir(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`types`:await rr();break;default:t&&(console.error(`Unknown codegen subcommand: ${t}\n`),process.exitCode=1),console.info(`Generate code from Prismic models.
|
|
201
|
+
|
|
202
|
+
USAGE
|
|
203
|
+
prismic codegen <command> [flags]
|
|
204
|
+
|
|
205
|
+
COMMANDS
|
|
206
|
+
types Generate TypeScript types from models pushed to Prismic
|
|
207
|
+
|
|
208
|
+
FLAGS
|
|
209
|
+
-h, --help Show help for command
|
|
210
|
+
|
|
211
|
+
LEARN MORE
|
|
212
|
+
Use \`prismic codegen <command> --help\` for more information about a command.`)}}function Q(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}const ar=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function or(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing custom type.
|
|
3
213
|
|
|
4
214
|
USAGE
|
|
5
215
|
prismic custom-type add-field boolean <type-id> <field-id> [flags]
|
|
@@ -10,7 +220,7 @@ ARGUMENTS
|
|
|
10
220
|
|
|
11
221
|
FLAGS
|
|
12
222
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
13
|
-
-l, --label string Display label for the field
|
|
223
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
14
224
|
--default Set default value to true
|
|
15
225
|
--true-label string Label shown when toggle is on
|
|
16
226
|
--false-label string Label shown when toggle is off
|
|
@@ -21,7 +231,7 @@ EXAMPLES
|
|
|
21
231
|
prismic custom-type add-field boolean article published --default
|
|
22
232
|
prismic custom-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
23
233
|
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
24
|
-
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
234
|
+
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await G(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=W(ar,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Boolean`,config:{label:i??Q(u),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};p.json[h][u]=g;try{await s(f,K(p))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${u}" (Boolean) to "${h}" tab in ${l}`)}const sr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function cr(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing custom type.
|
|
25
235
|
|
|
26
236
|
USAGE
|
|
27
237
|
prismic custom-type add-field color <type-id> <field-id> [flags]
|
|
@@ -32,7 +242,7 @@ ARGUMENTS
|
|
|
32
242
|
|
|
33
243
|
FLAGS
|
|
34
244
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
35
|
-
-l, --label string Display label for the field
|
|
245
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
36
246
|
-p, --placeholder string Placeholder text
|
|
37
247
|
-h, --help Show help for command
|
|
38
248
|
|
|
@@ -41,7 +251,7 @@ EXAMPLES
|
|
|
41
251
|
prismic custom-type add-field color homepage accent --tab "Design"
|
|
42
252
|
prismic custom-type add-field color homepage text_color --label "Text Color"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
43
253
|
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
44
|
-
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
254
|
+
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=W(sr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Color`,config:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Color) to "${p}" tab in ${o}`)}const lr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function ur(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing custom type.
|
|
45
255
|
|
|
46
256
|
USAGE
|
|
47
257
|
prismic custom-type add-field date <type-id> <field-id> [flags]
|
|
@@ -52,7 +262,7 @@ ARGUMENTS
|
|
|
52
262
|
|
|
53
263
|
FLAGS
|
|
54
264
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
55
|
-
-l, --label string Display label for the field
|
|
265
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
56
266
|
-p, --placeholder string Placeholder text
|
|
57
267
|
--default string Default date value (YYYY-MM-DD format)
|
|
58
268
|
-h, --help Show help for command
|
|
@@ -62,7 +272,7 @@ EXAMPLES
|
|
|
62
272
|
prismic custom-type add-field date event start_date --tab "Schedule"
|
|
63
273
|
prismic custom-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
64
274
|
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
65
|
-
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
275
|
+
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await G(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=W(lr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Date`,config:{label:i??Q(l),...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,K(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Date) to "${m}" tab in ${c}`)}const dr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function fr(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing custom type.
|
|
66
276
|
|
|
67
277
|
USAGE
|
|
68
278
|
prismic custom-type add-field embed <type-id> <field-id> [flags]
|
|
@@ -73,7 +283,7 @@ ARGUMENTS
|
|
|
73
283
|
|
|
74
284
|
FLAGS
|
|
75
285
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
76
|
-
-l, --label string Display label for the field
|
|
286
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
77
287
|
-p, --placeholder string Placeholder text
|
|
78
288
|
-h, --help Show help for command
|
|
79
289
|
|
|
@@ -82,7 +292,7 @@ EXAMPLES
|
|
|
82
292
|
prismic custom-type add-field embed homepage youtube --tab "Media"
|
|
83
293
|
prismic custom-type add-field embed homepage media --label "Media Embed"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
84
294
|
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
85
|
-
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
295
|
+
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=W(dr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Embed`,config:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Embed) to "${p}" tab in ${o}`)}const pr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function mr(){let{values:{help:t,tab:n,label:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing custom type.
|
|
86
296
|
|
|
87
297
|
USAGE
|
|
88
298
|
prismic custom-type add-field geo-point <type-id> <field-id> [flags]
|
|
@@ -93,7 +303,7 @@ ARGUMENTS
|
|
|
93
303
|
|
|
94
304
|
FLAGS
|
|
95
305
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
96
|
-
-l, --label string Display label for the field
|
|
306
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
97
307
|
-h, --help Show help for command
|
|
98
308
|
|
|
99
309
|
EXAMPLES
|
|
@@ -101,7 +311,7 @@ EXAMPLES
|
|
|
101
311
|
prismic custom-type add-field geo-point store address --tab "Details"
|
|
102
312
|
prismic custom-type add-field geo-point event venue --label "Event Venue"`);return}if(!a){console.error(`Missing required argument: type-id
|
|
103
313
|
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
104
|
-
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
314
|
+
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await G(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=W(pr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}\n`),console.error(`Create it first with: prismic custom-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let d=Object.keys(u.json),f=n??d[0]??`Main`;u.json[f]||(u.json[f]={});for(let[e,t]of Object.entries(u.json))if(t[o]){console.error(`Field "${o}" already exists in tab "${e}"`),process.exitCode=1;return}let p={type:`GeoPoint`,config:{label:i??Q(o)}};u.json[f][o]=p;try{await s(l,K(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${o}" (GeoPoint) to "${f}" tab in ${a}`)}const hr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function gr(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing custom type.
|
|
105
315
|
|
|
106
316
|
USAGE
|
|
107
317
|
prismic custom-type add-field image <type-id> <field-id> [flags]
|
|
@@ -112,7 +322,7 @@ ARGUMENTS
|
|
|
112
322
|
|
|
113
323
|
FLAGS
|
|
114
324
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
115
|
-
-l, --label string Display label for the field
|
|
325
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
116
326
|
-p, --placeholder string Placeholder text
|
|
117
327
|
-h, --help Show help for command
|
|
118
328
|
|
|
@@ -121,7 +331,7 @@ EXAMPLES
|
|
|
121
331
|
prismic custom-type add-field image article thumbnail --tab "Media"
|
|
122
332
|
prismic custom-type add-field image product photo --label "Product Photo"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
123
333
|
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
124
|
-
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
334
|
+
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=W(hr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Image`,config:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Image) to "${p}" tab in ${o}`)}const _r=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function vr(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing custom type.
|
|
125
335
|
|
|
126
336
|
USAGE
|
|
127
337
|
prismic custom-type add-field key-text <type-id> <field-id> [flags]
|
|
@@ -132,7 +342,7 @@ ARGUMENTS
|
|
|
132
342
|
|
|
133
343
|
FLAGS
|
|
134
344
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
135
|
-
-l, --label string Display label for the field
|
|
345
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
136
346
|
-p, --placeholder string Placeholder text
|
|
137
347
|
-h, --help Show help for command
|
|
138
348
|
|
|
@@ -141,7 +351,7 @@ EXAMPLES
|
|
|
141
351
|
prismic custom-type add-field key-text homepage meta_title --tab "SEO"
|
|
142
352
|
prismic custom-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
143
353
|
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
144
|
-
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
354
|
+
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=W(_r,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Text`,config:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Text) to "${p}" tab in ${o}`)}const yr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function br(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing custom type.
|
|
145
355
|
|
|
146
356
|
USAGE
|
|
147
357
|
prismic custom-type add-field link <type-id> <field-id> [flags]
|
|
@@ -152,7 +362,7 @@ ARGUMENTS
|
|
|
152
362
|
|
|
153
363
|
FLAGS
|
|
154
364
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
155
|
-
-l, --label string Display label for the field
|
|
365
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
156
366
|
-p, --placeholder string Placeholder text
|
|
157
367
|
--variation string Slice variations (can be used multiple times)
|
|
158
368
|
--allow-text Allow text with link
|
|
@@ -166,7 +376,7 @@ EXAMPLES
|
|
|
166
376
|
prismic custom-type add-field link homepage cta --variation Primary --variation Secondary
|
|
167
377
|
prismic custom-type add-field link homepage links --repeatable`);return}if(!d){console.error(`Missing required argument: type-id
|
|
168
378
|
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
169
|
-
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await
|
|
379
|
+
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await G(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${d}/index.json`,p),h;try{let e=await r(m,`utf8`),t=W(yr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${d}\n`),console.error(`Create it first with: prismic custom-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});for(let[e,t]of Object.entries(h.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let v={type:`Link`,config:{label:i??Q(f),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};h.json[_][f]=v;try{await s(m,K(h))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${f}" (Link) to "${_}" tab in ${d}`)}const xr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Sr(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing custom type.
|
|
170
380
|
|
|
171
381
|
USAGE
|
|
172
382
|
prismic custom-type add-field number <type-id> <field-id> [flags]
|
|
@@ -177,7 +387,7 @@ ARGUMENTS
|
|
|
177
387
|
|
|
178
388
|
FLAGS
|
|
179
389
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
180
|
-
-l, --label string Display label for the field
|
|
390
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
181
391
|
-p, --placeholder string Placeholder text
|
|
182
392
|
--min number Minimum value
|
|
183
393
|
--max number Maximum value
|
|
@@ -189,7 +399,7 @@ EXAMPLES
|
|
|
189
399
|
prismic custom-type add-field number product quantity --min 0 --max 100
|
|
190
400
|
prismic custom-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!u){console.error(`Missing required argument: type-id
|
|
191
401
|
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
192
|
-
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await
|
|
402
|
+
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await G(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${u}/index.json`,h),_;try{let e=await r(g,`utf8`),t=W(xr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});for(let[e,t]of Object.entries(_.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let ee={type:`Number`,config:{label:i??Q(d),...a&&{placeholder:a},...f!==void 0&&{min:f},...p!==void 0&&{max:p},...m!==void 0&&{step:m}}};_.json[y][d]=ee;try{await s(g,K(_))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${d}" (Number) to "${y}" tab in ${u}`)}const Cr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function wr(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing custom type.
|
|
193
403
|
|
|
194
404
|
USAGE
|
|
195
405
|
prismic custom-type add-field rich-text <type-id> <field-id> [flags]
|
|
@@ -200,7 +410,7 @@ ARGUMENTS
|
|
|
200
410
|
|
|
201
411
|
FLAGS
|
|
202
412
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
203
|
-
-l, --label string Display label for the field
|
|
413
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
204
414
|
-p, --placeholder string Placeholder text
|
|
205
415
|
--single string Allowed block types for single-line (comma-separated)
|
|
206
416
|
--multi string Allowed block types for multi-line (comma-separated)
|
|
@@ -218,7 +428,7 @@ EXAMPLES
|
|
|
218
428
|
prismic custom-type add-field rich-text page tagline --single "heading1"
|
|
219
429
|
prismic custom-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: type-id
|
|
220
430
|
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
221
|
-
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await
|
|
431
|
+
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await G(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${u}/index.json`,f),m;try{let e=await r(p,`utf8`),t=W(Cr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`StructuredText`,config:{label:i??Q(d),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};m.json[g][d]=_;try{await s(p,K(m))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${d}" (StructuredText) to "${g}" tab in ${u}`)}const Tr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Er(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing custom type.
|
|
222
432
|
|
|
223
433
|
USAGE
|
|
224
434
|
prismic custom-type add-field select <type-id> <field-id> [flags]
|
|
@@ -229,7 +439,7 @@ ARGUMENTS
|
|
|
229
439
|
|
|
230
440
|
FLAGS
|
|
231
441
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
232
|
-
-l, --label string Display label for the field
|
|
442
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
233
443
|
-p, --placeholder string Placeholder text
|
|
234
444
|
--option string Add an option (can be used multiple times)
|
|
235
445
|
--default string Default selected value
|
|
@@ -240,7 +450,7 @@ EXAMPLES
|
|
|
240
450
|
prismic custom-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
|
|
241
451
|
prismic custom-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
242
452
|
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
243
|
-
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
453
|
+
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await G(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=W(Tr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Select`,config:{label:i??Q(u),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};p.json[h][u]=g;try{await s(f,K(p))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${u}" (Select) to "${h}" tab in ${l}`)}const Dr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Or(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing custom type.
|
|
244
454
|
|
|
245
455
|
USAGE
|
|
246
456
|
prismic custom-type add-field timestamp <type-id> <field-id> [flags]
|
|
@@ -251,7 +461,7 @@ ARGUMENTS
|
|
|
251
461
|
|
|
252
462
|
FLAGS
|
|
253
463
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
254
|
-
-l, --label string Display label for the field
|
|
464
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
255
465
|
-p, --placeholder string Placeholder text
|
|
256
466
|
--default string Default timestamp value (ISO 8601 format)
|
|
257
467
|
-h, --help Show help for command
|
|
@@ -261,7 +471,7 @@ EXAMPLES
|
|
|
261
471
|
prismic custom-type add-field timestamp event start --tab "Schedule"
|
|
262
472
|
prismic custom-type add-field timestamp article published_at --label "Published At"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
263
473
|
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
264
|
-
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
474
|
+
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await G(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=W(Dr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Timestamp`,config:{label:i??Q(l),...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,K(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Timestamp) to "${m}" tab in ${c}`)}const kr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Ar(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing custom type.
|
|
265
475
|
|
|
266
476
|
USAGE
|
|
267
477
|
prismic custom-type add-field uid <type-id> <field-id> [flags]
|
|
@@ -272,7 +482,7 @@ ARGUMENTS
|
|
|
272
482
|
|
|
273
483
|
FLAGS
|
|
274
484
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
275
|
-
-l, --label string Display label for the field
|
|
485
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
276
486
|
-p, --placeholder string Placeholder text
|
|
277
487
|
-h, --help Show help for command
|
|
278
488
|
|
|
@@ -281,7 +491,7 @@ EXAMPLES
|
|
|
281
491
|
prismic custom-type add-field uid article slug --label "URL Slug"
|
|
282
492
|
prismic custom-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
283
493
|
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
284
|
-
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
494
|
+
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=W(kr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`UID`,config:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (UID) to "${p}" tab in ${o}`)}async function jr(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await or();break;case`color`:await cr();break;case`date`:await ur();break;case`embed`:await fr();break;case`geo-point`:await mr();break;case`image`:await gr();break;case`key-text`:await vr();break;case`link`:await br();break;case`number`:await Sr();break;case`rich-text`:await wr();break;case`select`:await Er();break;case`timestamp`:await Or();break;case`uid`:await Ar();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing custom type.
|
|
285
495
|
|
|
286
496
|
USAGE
|
|
287
497
|
prismic custom-type add-field <field-type> <type-id> <field-id> [flags]
|
|
@@ -311,7 +521,7 @@ EXAMPLES
|
|
|
311
521
|
prismic custom-type add-field key-text homepage meta_title --tab "SEO"
|
|
312
522
|
prismic custom-type add-field link homepage button --allow-text
|
|
313
523
|
prismic custom-type add-field rich-text homepage body --multi "paragraph,heading2,strong,em"
|
|
314
|
-
prismic custom-type add-field select homepage layout --option "full" --option "sidebar"`)}}const
|
|
524
|
+
prismic custom-type add-field select homepage layout --option "full" --option "sidebar"`)}}const Mr=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Nr(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a custom type's slice zone.
|
|
315
525
|
|
|
316
526
|
USAGE
|
|
317
527
|
prismic custom-type connect-slice <type-id> <slice-id> [flags]
|
|
@@ -329,7 +539,7 @@ EXAMPLES
|
|
|
329
539
|
prismic custom-type connect-slice homepage CallToAction --slice-zone slices
|
|
330
540
|
prismic custom-type connect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
331
541
|
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
|
|
332
|
-
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await
|
|
542
|
+
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await J(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await G(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${i}/index.json`,c),u;try{let e=await r(l,`utf8`),t=W(Mr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){if(n){console.error(`Slice zone "${n}" not found in custom type "${i}"`),process.exitCode=1;return}let e=Object.keys(u.json)[0]??`Main`;u.json[e]||(u.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};u.json[e][d]=t,f=t,p=d}if(f.config||={choices:{}},f.config.choices||(f.config.choices={}),a in f.config.choices){console.info(`Slice "${a}" is already connected to slice zone "${p}" in ${i}`);return}let m={type:`SharedSlice`};f.config.choices[a]=m;try{await s(l,K(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Connected slice "${a}" to slice zone "${p}" in ${i}`)}async function Pr(){let{values:{help:t,name:r,single:i},positionals:[a]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new custom type in a Prismic repository.
|
|
333
543
|
|
|
334
544
|
USAGE
|
|
335
545
|
prismic custom-type create <id> [flags]
|
|
@@ -343,7 +553,7 @@ FLAGS
|
|
|
343
553
|
-h, --help Show help for command
|
|
344
554
|
|
|
345
555
|
LEARN MORE
|
|
346
|
-
Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??
|
|
556
|
+
Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??Fr(a),repeatable:!i,status:!0,format:`custom`,json:{Main:{}}},c=await G(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/`,c),u=new URL(a+`/`,l),d=new URL(`index.json`,u);try{await n(new URL(`.`,d),{recursive:!0}),await s(d,K(o))}catch(e){e instanceof Error?console.error(`Failed to create custom type: ${e.message}`):console.error(`Failed to create custom type`),process.exitCode=1;return}console.info(`Created custom type at ${d.href}`)}function Fr(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Ir=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Lr(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a custom type's slice zone.
|
|
347
557
|
|
|
348
558
|
USAGE
|
|
349
559
|
prismic custom-type disconnect-slice <type-id> <slice-id> [flags]
|
|
@@ -361,7 +571,7 @@ EXAMPLES
|
|
|
361
571
|
prismic custom-type disconnect-slice homepage CallToAction --slice-zone slices
|
|
362
572
|
prismic custom-type disconnect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
363
573
|
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
|
|
364
|
-
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await
|
|
574
|
+
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await G(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=W(Ir,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let u=n??`slices`,d,f;for(let[,e]of Object.entries(l.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===u){d=n,f=t;break}if(d)break}if(!d){console.error(`Slice zone "${u}" not found in custom type "${i}"`),process.exitCode=1;return}if(!d.config?.choices||!(a in d.config.choices)){console.error(`Slice "${a}" is not connected to slice zone "${f}" in ${i}`),process.exitCode=1;return}delete d.config.choices[a];try{await s(c,K(l))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Disconnected slice "${a}" from slice zone "${f}" in ${i}`)}const Rr=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function zr(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all custom types in a Prismic project.
|
|
365
575
|
|
|
366
576
|
USAGE
|
|
367
577
|
prismic custom-type list [flags]
|
|
@@ -372,7 +582,7 @@ FLAGS
|
|
|
372
582
|
|
|
373
583
|
EXAMPLES
|
|
374
584
|
prismic custom-type list
|
|
375
|
-
prismic custom-type list --json`);return}let a=await
|
|
585
|
+
prismic custom-type list --json`);return}let a=await G(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No custom types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=W(Rr,JSON.parse(e));n.success&&n.output.format!==`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No custom types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const Br=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Vr(){let{values:{help:t,y:n},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom type from the project.
|
|
376
586
|
|
|
377
587
|
USAGE
|
|
378
588
|
prismic custom-type remove <type-id> [flags]
|
|
@@ -387,7 +597,7 @@ FLAGS
|
|
|
387
597
|
EXAMPLES
|
|
388
598
|
prismic custom-type remove settings
|
|
389
599
|
prismic custom-type remove settings -y`);return}if(!i){console.error(`Missing required argument: type-id
|
|
390
|
-
`),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let a=await
|
|
600
|
+
`),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let a=await G(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let s=new URL(`customtypes/${i}/`,a),c=new URL(`index.json`,s),l;try{let e=await r(c,`utf8`),t=W(Br,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(l.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove custom type "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove custom type: ${e.message}`):console.error(`Failed to remove custom type`),process.exitCode=1;return}console.info(`Removed custom type "${i}"`)}const Hr=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Ur(){let{values:{help:t,tab:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a custom type.
|
|
391
601
|
|
|
392
602
|
USAGE
|
|
393
603
|
prismic custom-type remove-field <type-id> <field-id> [flags]
|
|
@@ -404,7 +614,7 @@ EXAMPLES
|
|
|
404
614
|
prismic custom-type remove-field settings title
|
|
405
615
|
prismic custom-type remove-field settings description --tab "Content"`);return}if(!i){console.error(`Missing required argument: type-id
|
|
406
616
|
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
|
|
407
|
-
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await
|
|
617
|
+
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await G(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=W(Hr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(l.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}let u;if(n){if(!l.json[n]){console.error(`Tab "${n}" not found in custom type "${i}"`),console.error(`Available tabs: ${Object.keys(l.json).join(`, `)}`),process.exitCode=1;return}if(!(a in l.json[n])){console.error(`Field "${a}" not found in tab "${n}"`),process.exitCode=1;return}delete l.json[n][a],u=n}else{for(let[e,t]of Object.entries(l.json))if(a in t){delete t[a],u=e;break}if(!u){console.error(`Field "${a}" not found in any tab of custom type "${i}"`),process.exitCode=1;return}}try{await s(c,K(l))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Removed field "${a}" from tab "${u}" in custom type "${i}"`)}const Wr=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Gr(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a custom type's display name (label).
|
|
408
618
|
|
|
409
619
|
USAGE
|
|
410
620
|
prismic custom-type set-name <type-id> <new-name> [flags]
|
|
@@ -420,7 +630,7 @@ EXAMPLES
|
|
|
420
630
|
prismic custom-type set-name settings "Site Settings"
|
|
421
631
|
prismic custom-type set-name menu "Navigation Menu"`);return}if(!n){console.error(`Missing required argument: type-id
|
|
422
632
|
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: new-name
|
|
423
|
-
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await
|
|
633
|
+
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await G(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${n}/index.json`,a),c;try{let e=await r(o,`utf8`),t=W(Wr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${o.href}`),process.exitCode=1;return}c=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${n}\n`),console.error(`Create it first with: prismic custom-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(c.format===`page`){console.error(`"${n}" is not a custom type (format: page)`),process.exitCode=1;return}c.label=i;try{await s(o,K(c))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Renamed custom type "${n}" to "${i}"`)}const Kr=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function qr(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific custom type.
|
|
424
634
|
|
|
425
635
|
USAGE
|
|
426
636
|
prismic custom-type view <type-id> [flags]
|
|
@@ -435,7 +645,7 @@ FLAGS
|
|
|
435
645
|
EXAMPLES
|
|
436
646
|
prismic custom-type view settings
|
|
437
647
|
prismic custom-type view settings --json`);return}if(!i){console.error(`Missing required argument: type-id
|
|
438
|
-
`),console.error(`Usage: prismic custom-type view <type-id>`),process.exitCode=1;return}let a=await
|
|
648
|
+
`),console.error(`Usage: prismic custom-type view <type-id>`),process.exitCode=1;return}let a=await G(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=W(Kr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(s.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function Jr(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Pr();break;case`list`:await zr();break;case`view`:await qr();break;case`remove`:await Vr();break;case`set-name`:await Gr();break;case`add-field`:await jr();break;case`remove-field`:await Ur();break;case`connect-slice`:await Nr();break;case`disconnect-slice`:await Lr();break;default:t&&(console.error(`Unknown custom-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage custom types in a Prismic repository.
|
|
439
649
|
|
|
440
650
|
USAGE
|
|
441
651
|
prismic custom-type <command> [flags]
|
|
@@ -455,7 +665,7 @@ FLAGS
|
|
|
455
665
|
-h, --help Show help for command
|
|
456
666
|
|
|
457
667
|
LEARN MORE
|
|
458
|
-
Use \`prismic custom-type <command> --help\` for more information about a command.`)}}
|
|
668
|
+
Use \`prismic custom-type <command> --help\` for more information about a command.`)}}async function Yr(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`},repo:{type:`string`,short:`r`}}});if(t.help){console.info(`Initialize a Prismic project by creating a prismic.config.json file.
|
|
459
669
|
|
|
460
670
|
Use this command to connect an existing Prismic repository to your project.
|
|
461
671
|
To create a new repository, use \`prismic repo create\` instead.
|
|
@@ -468,7 +678,7 @@ FLAGS
|
|
|
468
678
|
-h, --help Show help for command
|
|
469
679
|
|
|
470
680
|
LEARN MORE
|
|
471
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}if(!t.repo){console.error(`Missing required flag: --repo`),process.exitCode=1;return}if((await
|
|
681
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}if(!t.repo){console.error(`Missing required flag: --repo`),process.exitCode=1;return}if((await On()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await Dn({repositoryName:t.repo});if(!n.ok){n.error instanceof Pn?console.error(`Could not find a package.json file. Run this command from a project directory.`):console.error(`Failed to create config file.`),process.exitCode=1;return}console.info(`Created prismic.config.json for repository "${t.repo}"`)}async function Xr(){let{values:{help:t,name:n,repo:r=await q()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new locale to a Prismic repository.
|
|
472
682
|
|
|
473
683
|
By default, this command reads the repository from prismic.config.json at the
|
|
474
684
|
project root.
|
|
@@ -485,21 +695,7 @@ FLAGS
|
|
|
485
695
|
-h, --help Show help for command
|
|
486
696
|
|
|
487
697
|
LEARN MORE
|
|
488
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
489
|
-
|
|
490
|
-
By default, this command reads the repository from prismic.config.json at the
|
|
491
|
-
project root.
|
|
492
|
-
|
|
493
|
-
USAGE
|
|
494
|
-
prismic locale list [flags]
|
|
495
|
-
|
|
496
|
-
FLAGS
|
|
497
|
-
--json Output as JSON
|
|
498
|
-
-r, --repo string Repository domain
|
|
499
|
-
-h, --help Show help for command
|
|
500
|
-
|
|
501
|
-
LEARN MORE
|
|
502
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){wt();return}let i=await Ct(n);if(!i.ok){i.error instanceof K?wt():b(i.error)?(console.error(`Failed to list locales: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(z(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const St=T({results:x(T({id:O(),label:O(),customName:C(O()),isMaster:S()}))});async function Ct(e){let t=new URL(`/locale/repository/locales`,await de());return t.searchParams.set(`repository`,e),await G(t,{schema:St})}function wt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Tt(){let{values:{repo:t=await U(),help:n},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(`Remove a locale from a Prismic repository.
|
|
698
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){$r();return}let a=n?await Qr(r,i,n):await Zr(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof X?$r():(console.error(`Failed to add locale: ${K(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function Zr(e,t){return await Y(new URL(`/app/settings/multilanguages`,await j(e)),{method:`POST`,body:{languages:[t]}})}async function Qr(e,t,n){let[r,i]=t.split(`-`);return await Y(new URL(`/app/settings/multilanguages/custom`,await j(e)),{method:`POST`,body:{lang:{label:n,id:r||t},region:{label:n,id:i||r||t}}})}function $r(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ei(){let{values:{repo:t=await q(),help:n},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(`Remove a locale from a Prismic repository.
|
|
503
699
|
|
|
504
700
|
By default, this command reads the repository from prismic.config.json at the
|
|
505
701
|
project root.
|
|
@@ -515,7 +711,7 @@ FLAGS
|
|
|
515
711
|
-h, --help Show help for command
|
|
516
712
|
|
|
517
713
|
LEARN MORE
|
|
518
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!t){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
714
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!t){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ni();return}let i=await ti(t,r);if(!i.ok){i.error instanceof X?ni():(console.error(`Failed to remove locale: ${K(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function ti(e,t){let n=new URL(`/locale/repository/locales/${t}`,await $t());return n.searchParams.set(`repository`,e),await Y(n,{method:`DELETE`})}function ni(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ri(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the default locale for a Prismic repository.
|
|
519
715
|
|
|
520
716
|
By default, this command reads the repository from prismic.config.json at the
|
|
521
717
|
project root.
|
|
@@ -531,7 +727,7 @@ FLAGS
|
|
|
531
727
|
-h, --help Show help for command
|
|
532
728
|
|
|
533
729
|
LEARN MORE
|
|
534
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
730
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ai();return}let i=await tr(n);if(!i.ok){i.error instanceof X?ai():I(i.error)?(console.error(`Failed to set default locale: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set default locale: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.results,o=a.find(e=>e.id===r);if(!o){console.error(`Locale "${r}" not found in repository. Available locales: ${a.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.isMaster){console.error(`Locale "${r}" is already the default.`),process.exitCode=1;return}let s=await ii(n,o);if(!s.ok){s.error instanceof X?ai():(console.error(`Failed to set default locale: ${K(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function ii(e,t){let n=new URL(`/locale/repository/locales`,await $t());return n.searchParams.set(`repository`,e),await Y(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function ai(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function oi(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await Xr();break;case`list`:await $n();break;case`remove`:await ei();break;case`set-default`:await ri();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
|
|
535
731
|
|
|
536
732
|
USAGE
|
|
537
733
|
prismic locale <command> [flags]
|
|
@@ -546,7 +742,7 @@ FLAGS
|
|
|
546
742
|
-h, --help Show help for command
|
|
547
743
|
|
|
548
744
|
LEARN MORE
|
|
549
|
-
Use \`prismic locale <command> --help\` for more information about a command.`)}}async function
|
|
745
|
+
Use \`prismic locale <command> --help\` for more information about a command.`)}}async function si(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log in to Prismic via browser.
|
|
550
746
|
|
|
551
747
|
USAGE
|
|
552
748
|
prismic login [flags]
|
|
@@ -555,7 +751,7 @@ FLAGS
|
|
|
555
751
|
-h, --help Show help for command
|
|
556
752
|
|
|
557
753
|
LEARN MORE
|
|
558
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=
|
|
754
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=f((t,i)=>{if(t.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();return}if(t.method===`POST`){let a=``;t.on(`data`,e=>{a+=e.toString()}),t.on(`end`,async()=>{try{let{cookies:t,email:o}=JSON.parse(a),s=t.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!s){i.writeHead(400,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await an(s),console.info(`Logged in to Prismic as ${o}`),i.writeHead(200,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({success:!0})),clearTimeout(r),n.close(),e()}catch{i.writeHead(400,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}))}});return}i.writeHead(404),i.end()}),r=setTimeout(()=>{n.close(),t(Error(`Login timed out. Please try again.`))},18e4);n.listen(0,`127.0.0.1`,()=>{let e=n.address();if(!e||typeof e==`string`){clearTimeout(r),n.close(),t(Error(`Failed to start login server`));return}let i=e.port,a=ci(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),li(a)}),n.on(`error`,e=>{clearTimeout(r),t(e)})})}function ci(e){let t=new URL(`https://prismic.io/dashboard/cli/login`);return t.searchParams.set(`source`,`slice-machine`),t.searchParams.set(`port`,e.toString()),t}function li(e){d(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function ui(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log out of Prismic.
|
|
559
755
|
|
|
560
756
|
USAGE
|
|
561
757
|
prismic logout [flags]
|
|
@@ -564,7 +760,7 @@ FLAGS
|
|
|
564
760
|
-h, --help Show help for command
|
|
565
761
|
|
|
566
762
|
LEARN MORE
|
|
567
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}await
|
|
763
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}await cn()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const di=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function fi(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing page type.
|
|
568
764
|
|
|
569
765
|
USAGE
|
|
570
766
|
prismic page-type add-field boolean <type-id> <field-id> [flags]
|
|
@@ -575,7 +771,7 @@ ARGUMENTS
|
|
|
575
771
|
|
|
576
772
|
FLAGS
|
|
577
773
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
578
|
-
-l, --label string Display label for the field
|
|
774
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
579
775
|
--default Set default value to true
|
|
580
776
|
--true-label string Label shown when toggle is on
|
|
581
777
|
--false-label string Label shown when toggle is off
|
|
@@ -586,7 +782,7 @@ EXAMPLES
|
|
|
586
782
|
prismic page-type add-field boolean article published --default
|
|
587
783
|
prismic page-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
588
784
|
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
589
|
-
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
785
|
+
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await G(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=W(di,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Boolean`,config:{label:i??Q(u),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};p.json[h][u]=g;try{await s(f,K(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${u}" (Boolean) to "${h}" tab in ${l}`)}const pi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function mi(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing page type.
|
|
590
786
|
|
|
591
787
|
USAGE
|
|
592
788
|
prismic page-type add-field color <type-id> <field-id> [flags]
|
|
@@ -597,7 +793,7 @@ ARGUMENTS
|
|
|
597
793
|
|
|
598
794
|
FLAGS
|
|
599
795
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
600
|
-
-l, --label string Display label for the field
|
|
796
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
601
797
|
-p, --placeholder string Placeholder text
|
|
602
798
|
-h, --help Show help for command
|
|
603
799
|
|
|
@@ -606,7 +802,7 @@ EXAMPLES
|
|
|
606
802
|
prismic page-type add-field color homepage accent --tab "Design"
|
|
607
803
|
prismic page-type add-field color homepage text_color --label "Text Color"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
608
804
|
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
609
|
-
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
805
|
+
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=W(pi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Color`,config:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Color) to "${p}" tab in ${o}`)}const hi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function gi(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing page type.
|
|
610
806
|
|
|
611
807
|
USAGE
|
|
612
808
|
prismic page-type add-field date <type-id> <field-id> [flags]
|
|
@@ -617,7 +813,7 @@ ARGUMENTS
|
|
|
617
813
|
|
|
618
814
|
FLAGS
|
|
619
815
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
620
|
-
-l, --label string Display label for the field
|
|
816
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
621
817
|
-p, --placeholder string Placeholder text
|
|
622
818
|
--default string Default date value (YYYY-MM-DD format)
|
|
623
819
|
-h, --help Show help for command
|
|
@@ -627,7 +823,7 @@ EXAMPLES
|
|
|
627
823
|
prismic page-type add-field date event start_date --tab "Schedule"
|
|
628
824
|
prismic page-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
629
825
|
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
630
|
-
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
826
|
+
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await G(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=W(hi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Date`,config:{label:i??Q(l),...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,K(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Date) to "${m}" tab in ${c}`)}const _i=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function vi(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing page type.
|
|
631
827
|
|
|
632
828
|
USAGE
|
|
633
829
|
prismic page-type add-field embed <type-id> <field-id> [flags]
|
|
@@ -638,7 +834,7 @@ ARGUMENTS
|
|
|
638
834
|
|
|
639
835
|
FLAGS
|
|
640
836
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
641
|
-
-l, --label string Display label for the field
|
|
837
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
642
838
|
-p, --placeholder string Placeholder text
|
|
643
839
|
-h, --help Show help for command
|
|
644
840
|
|
|
@@ -647,7 +843,7 @@ EXAMPLES
|
|
|
647
843
|
prismic page-type add-field embed homepage youtube --tab "Media"
|
|
648
844
|
prismic page-type add-field embed homepage media --label "Media Embed"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
649
845
|
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
650
|
-
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
846
|
+
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=W(_i,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Embed`,config:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Embed) to "${p}" tab in ${o}`)}const yi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function bi(){let{values:{help:t,tab:n,label:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing page type.
|
|
651
847
|
|
|
652
848
|
USAGE
|
|
653
849
|
prismic page-type add-field geo-point <type-id> <field-id> [flags]
|
|
@@ -658,7 +854,7 @@ ARGUMENTS
|
|
|
658
854
|
|
|
659
855
|
FLAGS
|
|
660
856
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
661
|
-
-l, --label string Display label for the field
|
|
857
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
662
858
|
-h, --help Show help for command
|
|
663
859
|
|
|
664
860
|
EXAMPLES
|
|
@@ -666,7 +862,7 @@ EXAMPLES
|
|
|
666
862
|
prismic page-type add-field geo-point store address --tab "Details"
|
|
667
863
|
prismic page-type add-field geo-point event venue --label "Event Venue"`);return}if(!a){console.error(`Missing required argument: type-id
|
|
668
864
|
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
669
|
-
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
865
|
+
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await G(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=W(yi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=Object.keys(u.json),f=n??d[0]??`Main`;u.json[f]||(u.json[f]={});for(let[e,t]of Object.entries(u.json))if(t[o]){console.error(`Field "${o}" already exists in tab "${e}"`),process.exitCode=1;return}let p={type:`GeoPoint`,config:{label:i??Q(o)}};u.json[f][o]=p;try{await s(l,K(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${o}" (GeoPoint) to "${f}" tab in ${a}`)}const xi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Si(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing page type.
|
|
670
866
|
|
|
671
867
|
USAGE
|
|
672
868
|
prismic page-type add-field image <type-id> <field-id> [flags]
|
|
@@ -677,7 +873,7 @@ ARGUMENTS
|
|
|
677
873
|
|
|
678
874
|
FLAGS
|
|
679
875
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
680
|
-
-l, --label string Display label for the field
|
|
876
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
681
877
|
-p, --placeholder string Placeholder text
|
|
682
878
|
-h, --help Show help for command
|
|
683
879
|
|
|
@@ -686,7 +882,7 @@ EXAMPLES
|
|
|
686
882
|
prismic page-type add-field image article thumbnail --tab "Media"
|
|
687
883
|
prismic page-type add-field image product photo --label "Product Photo"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
688
884
|
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
689
|
-
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
885
|
+
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=W(xi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Image`,config:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Image) to "${p}" tab in ${o}`)}const Ci=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function wi(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing page type.
|
|
690
886
|
|
|
691
887
|
USAGE
|
|
692
888
|
prismic page-type add-field key-text <type-id> <field-id> [flags]
|
|
@@ -697,7 +893,7 @@ ARGUMENTS
|
|
|
697
893
|
|
|
698
894
|
FLAGS
|
|
699
895
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
700
|
-
-l, --label string Display label for the field
|
|
896
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
701
897
|
-p, --placeholder string Placeholder text
|
|
702
898
|
-h, --help Show help for command
|
|
703
899
|
|
|
@@ -706,7 +902,7 @@ EXAMPLES
|
|
|
706
902
|
prismic page-type add-field key-text homepage meta_title --tab "SEO"
|
|
707
903
|
prismic page-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
708
904
|
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
709
|
-
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
905
|
+
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=W(Ci,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Text`,config:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Text) to "${p}" tab in ${o}`)}const Ti=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Ei(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing page type.
|
|
710
906
|
|
|
711
907
|
USAGE
|
|
712
908
|
prismic page-type add-field link <type-id> <field-id> [flags]
|
|
@@ -717,7 +913,7 @@ ARGUMENTS
|
|
|
717
913
|
|
|
718
914
|
FLAGS
|
|
719
915
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
720
|
-
-l, --label string Display label for the field
|
|
916
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
721
917
|
-p, --placeholder string Placeholder text
|
|
722
918
|
--variation string Slice variations (can be used multiple times)
|
|
723
919
|
--allow-text Allow text with link
|
|
@@ -731,7 +927,7 @@ EXAMPLES
|
|
|
731
927
|
prismic page-type add-field link homepage cta --variation Primary --variation Secondary
|
|
732
928
|
prismic page-type add-field link homepage links --repeatable`);return}if(!d){console.error(`Missing required argument: type-id
|
|
733
929
|
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
734
|
-
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await
|
|
930
|
+
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await G(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${d}/index.json`,p),h;try{let e=await r(m,`utf8`),t=W(Ti,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});for(let[e,t]of Object.entries(h.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let v={type:`Link`,config:{label:i??Q(f),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};h.json[_][f]=v;try{await s(m,K(h))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${f}" (Link) to "${_}" tab in ${d}`)}const Di=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Oi(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing page type.
|
|
735
931
|
|
|
736
932
|
USAGE
|
|
737
933
|
prismic page-type add-field number <type-id> <field-id> [flags]
|
|
@@ -742,7 +938,7 @@ ARGUMENTS
|
|
|
742
938
|
|
|
743
939
|
FLAGS
|
|
744
940
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
745
|
-
-l, --label string Display label for the field
|
|
941
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
746
942
|
-p, --placeholder string Placeholder text
|
|
747
943
|
--min number Minimum value
|
|
748
944
|
--max number Maximum value
|
|
@@ -754,7 +950,7 @@ EXAMPLES
|
|
|
754
950
|
prismic page-type add-field number product quantity --min 0 --max 100
|
|
755
951
|
prismic page-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!u){console.error(`Missing required argument: type-id
|
|
756
952
|
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
757
|
-
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await
|
|
953
|
+
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await G(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${u}/index.json`,h),_;try{let e=await r(g,`utf8`),t=W(Di,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});for(let[e,t]of Object.entries(_.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let ee={type:`Number`,config:{label:i??Q(d),...a&&{placeholder:a},...f!==void 0&&{min:f},...p!==void 0&&{max:p},...m!==void 0&&{step:m}}};_.json[y][d]=ee;try{await s(g,K(_))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${d}" (Number) to "${y}" tab in ${u}`)}const ki=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Ai(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing page type.
|
|
758
954
|
|
|
759
955
|
USAGE
|
|
760
956
|
prismic page-type add-field rich-text <type-id> <field-id> [flags]
|
|
@@ -765,7 +961,7 @@ ARGUMENTS
|
|
|
765
961
|
|
|
766
962
|
FLAGS
|
|
767
963
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
768
|
-
-l, --label string Display label for the field
|
|
964
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
769
965
|
-p, --placeholder string Placeholder text
|
|
770
966
|
--single string Allowed block types for single-line (comma-separated)
|
|
771
967
|
--multi string Allowed block types for multi-line (comma-separated)
|
|
@@ -783,7 +979,7 @@ EXAMPLES
|
|
|
783
979
|
prismic page-type add-field rich-text page tagline --single "heading1"
|
|
784
980
|
prismic page-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: type-id
|
|
785
981
|
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
786
|
-
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await
|
|
982
|
+
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await G(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${u}/index.json`,f),m;try{let e=await r(p,`utf8`),t=W(ki,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`StructuredText`,config:{label:i??Q(d),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};m.json[g][d]=_;try{await s(p,K(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${d}" (StructuredText) to "${g}" tab in ${u}`)}const ji=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Mi(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing page type.
|
|
787
983
|
|
|
788
984
|
USAGE
|
|
789
985
|
prismic page-type add-field select <type-id> <field-id> [flags]
|
|
@@ -794,7 +990,7 @@ ARGUMENTS
|
|
|
794
990
|
|
|
795
991
|
FLAGS
|
|
796
992
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
797
|
-
-l, --label string Display label for the field
|
|
993
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
798
994
|
-p, --placeholder string Placeholder text
|
|
799
995
|
--option string Add an option (can be used multiple times)
|
|
800
996
|
--default string Default selected value
|
|
@@ -805,7 +1001,7 @@ EXAMPLES
|
|
|
805
1001
|
prismic page-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
|
|
806
1002
|
prismic page-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
807
1003
|
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
808
|
-
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
1004
|
+
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await G(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=W(ji,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Select`,config:{label:i??Q(u),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};p.json[h][u]=g;try{await s(f,K(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${u}" (Select) to "${h}" tab in ${l}`)}const Ni=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Pi(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing page type.
|
|
809
1005
|
|
|
810
1006
|
USAGE
|
|
811
1007
|
prismic page-type add-field timestamp <type-id> <field-id> [flags]
|
|
@@ -816,7 +1012,7 @@ ARGUMENTS
|
|
|
816
1012
|
|
|
817
1013
|
FLAGS
|
|
818
1014
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
819
|
-
-l, --label string Display label for the field
|
|
1015
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
820
1016
|
-p, --placeholder string Placeholder text
|
|
821
1017
|
--default string Default timestamp value (ISO 8601 format)
|
|
822
1018
|
-h, --help Show help for command
|
|
@@ -826,7 +1022,7 @@ EXAMPLES
|
|
|
826
1022
|
prismic page-type add-field timestamp event start --tab "Schedule"
|
|
827
1023
|
prismic page-type add-field timestamp article published_at --label "Published At"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
828
1024
|
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
829
|
-
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
1025
|
+
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await G(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=W(Ni,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Timestamp`,config:{label:i??Q(l),...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,K(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Timestamp) to "${m}" tab in ${c}`)}const Fi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Ii(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing page type.
|
|
830
1026
|
|
|
831
1027
|
USAGE
|
|
832
1028
|
prismic page-type add-field uid <type-id> <field-id> [flags]
|
|
@@ -837,7 +1033,7 @@ ARGUMENTS
|
|
|
837
1033
|
|
|
838
1034
|
FLAGS
|
|
839
1035
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
840
|
-
-l, --label string Display label for the field
|
|
1036
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
841
1037
|
-p, --placeholder string Placeholder text
|
|
842
1038
|
-h, --help Show help for command
|
|
843
1039
|
|
|
@@ -846,7 +1042,7 @@ EXAMPLES
|
|
|
846
1042
|
prismic page-type add-field uid article slug --label "URL Slug"
|
|
847
1043
|
prismic page-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
848
1044
|
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
849
|
-
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
1045
|
+
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await G(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=W(Fi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`UID`,config:{label:i??Q(c),...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,K(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (UID) to "${p}" tab in ${o}`)}async function Li(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await fi();break;case`color`:await mi();break;case`date`:await gi();break;case`embed`:await vi();break;case`geo-point`:await bi();break;case`image`:await Si();break;case`key-text`:await wi();break;case`link`:await Ei();break;case`number`:await Oi();break;case`rich-text`:await Ai();break;case`select`:await Mi();break;case`timestamp`:await Pi();break;case`uid`:await Ii();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
|
|
850
1046
|
|
|
851
1047
|
USAGE
|
|
852
1048
|
prismic page-type add-field <field-type> <type-id> <field-id> [flags]
|
|
@@ -876,7 +1072,7 @@ EXAMPLES
|
|
|
876
1072
|
prismic page-type add-field key-text homepage meta_title --tab "SEO"
|
|
877
1073
|
prismic page-type add-field link homepage button --allow-text
|
|
878
1074
|
prismic page-type add-field rich-text homepage body --multi "paragraph,heading2,strong,em"
|
|
879
|
-
prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const
|
|
1075
|
+
prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const Ri=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function zi(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a page type's slice zone.
|
|
880
1076
|
|
|
881
1077
|
USAGE
|
|
882
1078
|
prismic page-type connect-slice <type-id> <slice-id> [flags]
|
|
@@ -894,7 +1090,7 @@ EXAMPLES
|
|
|
894
1090
|
prismic page-type connect-slice homepage CallToAction --slice-zone slices
|
|
895
1091
|
prismic page-type connect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
896
1092
|
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
|
|
897
|
-
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await
|
|
1093
|
+
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await J(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await G(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${i}/index.json`,c),u;try{let e=await r(l,`utf8`),t=W(Ri,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){if(n){console.error(`Slice zone "${n}" not found in page type "${i}"`),process.exitCode=1;return}let e=Object.keys(u.json)[0]??`Main`;u.json[e]||(u.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};u.json[e][d]=t,f=t,p=d}if(f.config||={choices:{}},f.config.choices||(f.config.choices={}),a in f.config.choices){console.info(`Slice "${a}" is already connected to slice zone "${p}" in ${i}`);return}let m={type:`SharedSlice`};f.config.choices[a]=m;try{await s(l,K(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Connected slice "${a}" to slice zone "${p}" in ${i}`)}async function Bi(){let{values:{help:t,name:r,single:i},positionals:[a]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new page type in a Prismic repository.
|
|
898
1094
|
|
|
899
1095
|
USAGE
|
|
900
1096
|
prismic page-type create <id> [flags]
|
|
@@ -908,7 +1104,7 @@ FLAGS
|
|
|
908
1104
|
-h, --help Show help for command
|
|
909
1105
|
|
|
910
1106
|
LEARN MORE
|
|
911
|
-
Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??
|
|
1107
|
+
Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??Vi(a),repeatable:!i,status:!0,format:`page`,json:{Main:{},"SEO & Metadata":{}}},c=await G(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/`,c),u=new URL(a+`/`,l),d=new URL(`index.json`,u);try{await n(new URL(`.`,d),{recursive:!0}),await s(d,K(o))}catch(e){e instanceof Error?console.error(`Failed to create page type: ${e.message}`):console.error(`Failed to create page type`),process.exitCode=1;return}console.info(`Created page type at ${d.href}`)}function Vi(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Hi=z({id:H(),label:H(),repeatable:R(),status:R(),format:H(),json:V(H(),V(H(),U()))});async function Ui(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a page type's slice zone.
|
|
912
1108
|
|
|
913
1109
|
USAGE
|
|
914
1110
|
prismic page-type disconnect-slice <type-id> <slice-id> [flags]
|
|
@@ -926,7 +1122,7 @@ EXAMPLES
|
|
|
926
1122
|
prismic page-type disconnect-slice homepage CallToAction --slice-zone slices
|
|
927
1123
|
prismic page-type disconnect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
928
1124
|
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
|
|
929
|
-
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await
|
|
1125
|
+
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await G(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=W(Hi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let u=n??`slices`,d,f;for(let[,e]of Object.entries(l.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===u){d=n,f=t;break}if(d)break}if(!d){console.error(`Slice zone "${u}" not found in page type "${i}"`),process.exitCode=1;return}if(!d.config?.choices||!(a in d.config.choices)){console.error(`Slice "${a}" is not connected to slice zone "${f}" in ${i}`),process.exitCode=1;return}delete d.config.choices[a];try{await s(c,K(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Disconnected slice "${a}" from slice zone "${f}" in ${i}`)}const Wi=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Gi(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all page types in a Prismic project.
|
|
930
1126
|
|
|
931
1127
|
USAGE
|
|
932
1128
|
prismic page-type list [flags]
|
|
@@ -937,7 +1133,7 @@ FLAGS
|
|
|
937
1133
|
|
|
938
1134
|
EXAMPLES
|
|
939
1135
|
prismic page-type list
|
|
940
|
-
prismic page-type list --json`);return}let a=await
|
|
1136
|
+
prismic page-type list --json`);return}let a=await G(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=W(Wi,JSON.parse(e));n.success&&n.output.format===`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const Ki=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function qi(){let{values:{help:t,y:n},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a page type from the project.
|
|
941
1137
|
|
|
942
1138
|
USAGE
|
|
943
1139
|
prismic page-type remove <type-id> [flags]
|
|
@@ -952,7 +1148,7 @@ FLAGS
|
|
|
952
1148
|
EXAMPLES
|
|
953
1149
|
prismic page-type remove homepage
|
|
954
1150
|
prismic page-type remove homepage -y`);return}if(!i){console.error(`Missing required argument: type-id
|
|
955
|
-
`),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let a=await
|
|
1151
|
+
`),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let a=await G(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let s=new URL(`customtypes/${i}/`,a),c=new URL(`index.json`,s),l;try{let e=await r(c,`utf8`),t=W(Ki,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove page type "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove page type: ${e.message}`):console.error(`Failed to remove page type`),process.exitCode=1;return}console.info(`Removed page type "${i}"`)}const Ji=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Yi(){let{values:{help:t,tab:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a page type.
|
|
956
1152
|
|
|
957
1153
|
USAGE
|
|
958
1154
|
prismic page-type remove-field <type-id> <field-id> [flags]
|
|
@@ -969,7 +1165,7 @@ EXAMPLES
|
|
|
969
1165
|
prismic page-type remove-field homepage title
|
|
970
1166
|
prismic page-type remove-field homepage meta_title --tab "SEO & Metadata"`);return}if(!i){console.error(`Missing required argument: type-id
|
|
971
1167
|
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
|
|
972
|
-
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await
|
|
1168
|
+
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await G(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=W(Ji,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}let u;if(n){if(!l.json[n]){console.error(`Tab "${n}" not found in page type "${i}"`),console.error(`Available tabs: ${Object.keys(l.json).join(`, `)}`),process.exitCode=1;return}if(!(a in l.json[n])){console.error(`Field "${a}" not found in tab "${n}"`),process.exitCode=1;return}delete l.json[n][a],u=n}else{for(let[e,t]of Object.entries(l.json))if(a in t){delete t[a],u=e;break}if(!u){console.error(`Field "${a}" not found in any tab of page type "${i}"`),process.exitCode=1;return}}try{await s(c,K(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Removed field "${a}" from tab "${u}" in page type "${i}"`)}const Xi=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function Zi(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a page type's display name (label).
|
|
973
1169
|
|
|
974
1170
|
USAGE
|
|
975
1171
|
prismic page-type set-name <type-id> <new-name> [flags]
|
|
@@ -985,7 +1181,7 @@ EXAMPLES
|
|
|
985
1181
|
prismic page-type set-name homepage "Home Page"
|
|
986
1182
|
prismic page-type set-name blog_post "Blog Post"`);return}if(!n){console.error(`Missing required argument: type-id
|
|
987
1183
|
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: new-name
|
|
988
|
-
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await
|
|
1184
|
+
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await G(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${n}/index.json`,a),c;try{let e=await r(o,`utf8`),t=W(Xi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${o.href}`),process.exitCode=1;return}c=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${n}\n`),console.error(`Create it first with: prismic page-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(c.format!==`page`){console.error(`"${n}" is not a page type (format: ${c.format??`custom`})`),process.exitCode=1;return}c.label=i;try{await s(o,K(c))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Renamed page type "${n}" to "${i}"`)}const Qi=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function $i(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set whether a page type is repeatable.
|
|
989
1185
|
|
|
990
1186
|
USAGE
|
|
991
1187
|
prismic page-type set-repeatable <type-id> <true|false> [flags]
|
|
@@ -1001,7 +1197,7 @@ EXAMPLES
|
|
|
1001
1197
|
prismic page-type set-repeatable homepage true
|
|
1002
1198
|
prismic page-type set-repeatable settings false`);return}if(!n){console.error(`Missing required argument: type-id
|
|
1003
1199
|
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: true|false
|
|
1004
|
-
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(i!==`true`&&i!==`false`){console.error(`Invalid value: "${i}". Must be "true" or "false".`),process.exitCode=1;return}let a=i===`true`,o=await
|
|
1200
|
+
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(i!==`true`&&i!==`false`){console.error(`Invalid value: "${i}". Must be "true" or "false".`),process.exitCode=1;return}let a=i===`true`,o=await G(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${n}/index.json`,o),l;try{let e=await r(c,`utf8`),t=W(Qi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${n}\n`),console.error(`Create it first with: prismic page-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${n}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}l.repeatable=a;try{await s(c,K(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}let u=a?`repeatable`:`singleton`;console.info(`Set page type "${n}" to ${u}`)}const ea=z({id:H(),label:H(),repeatable:R(),status:R(),format:B(H()),json:V(H(),V(H(),U()))});async function ta(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific page type.
|
|
1005
1201
|
|
|
1006
1202
|
USAGE
|
|
1007
1203
|
prismic page-type view <type-id> [flags]
|
|
@@ -1016,7 +1212,7 @@ FLAGS
|
|
|
1016
1212
|
EXAMPLES
|
|
1017
1213
|
prismic page-type view homepage
|
|
1018
1214
|
prismic page-type view homepage --json`);return}if(!i){console.error(`Missing required argument: type-id
|
|
1019
|
-
`),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await
|
|
1215
|
+
`),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await G(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=W(ea,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(s.format!==`page`){console.error(`"${i}" is not a page type (format: ${s.format??`custom`})`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function na(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Bi();break;case`list`:await Gi();break;case`view`:await ta();break;case`remove`:await qi();break;case`set-name`:await Zi();break;case`set-repeatable`:await $i();break;case`add-field`:await Li();break;case`remove-field`:await Yi();break;case`connect-slice`:await zi();break;case`disconnect-slice`:await Ui();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
|
|
1020
1216
|
|
|
1021
1217
|
USAGE
|
|
1022
1218
|
prismic page-type <command> [flags]
|
|
@@ -1037,7 +1233,7 @@ FLAGS
|
|
|
1037
1233
|
-h, --help Show help for command
|
|
1038
1234
|
|
|
1039
1235
|
LEARN MORE
|
|
1040
|
-
Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function
|
|
1236
|
+
Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function ra(){let{values:{help:t,name:n,repo:r=await q()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a preview configuration to a Prismic repository.
|
|
1041
1237
|
|
|
1042
1238
|
By default, this command reads the repository from prismic.config.json at the
|
|
1043
1239
|
project root.
|
|
@@ -1054,7 +1250,21 @@ FLAGS
|
|
|
1054
1250
|
-h, --help Show help for command
|
|
1055
1251
|
|
|
1056
1252
|
LEARN MORE
|
|
1057
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
1253
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){oa();return}let a=ia(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await aa(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof X?oa():(console.error(`Failed to add preview: ${K(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function ia(e){try{let t=new URL(e);return{websiteURL:`${t.protocol}//${t.host}`,resolverPath:t.pathname===`/`?void 0:t.pathname,hostname:t.hostname}}catch{return}}async function aa(e,t){return await Y(new URL(`/previews/new`,await j(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function oa(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function sa(){let{values:{help:t,repo:n=await q(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Show the slice simulator URL for a Prismic repository.
|
|
1254
|
+
|
|
1255
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1256
|
+
project root.
|
|
1257
|
+
|
|
1258
|
+
USAGE
|
|
1259
|
+
prismic preview get-simulator [flags]
|
|
1260
|
+
|
|
1261
|
+
FLAGS
|
|
1262
|
+
--json Output as JSON
|
|
1263
|
+
-r, --repo string Repository domain
|
|
1264
|
+
-h, --help Show help for command
|
|
1265
|
+
|
|
1266
|
+
LEARN MORE
|
|
1267
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ua();return}let i=await la(n);if(!i.ok){i.error instanceof X?ua():I(i.error)?(console.error(`Failed to get simulator URL: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to get simulator URL: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.simulator_url;if(!a){r?console.info(K({simulator_url:null})):console.info(`No simulator URL configured.`);return}r?console.info(K({simulator_url:a})):console.info(a)}const ca=z({simulator_url:B(H())});async function la(e){return await Y(new URL(`/core/repository`,await j(e)),{schema:ca})}function ua(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function da(){let{values:{help:t,repo:n=await q(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all preview configurations in a Prismic repository.
|
|
1058
1268
|
|
|
1059
1269
|
By default, this command reads the repository from prismic.config.json at the
|
|
1060
1270
|
project root.
|
|
@@ -1068,7 +1278,7 @@ FLAGS
|
|
|
1068
1278
|
-h, --help Show help for command
|
|
1069
1279
|
|
|
1070
1280
|
LEARN MORE
|
|
1071
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
1281
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ma();return}let i=await pa(n);if(!i.ok){i.error instanceof X?ma():I(i.error)?(console.error(`Failed to list previews: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list previews: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(K(a));else for(let e of a)console.info(`${e.url} ${e.label}`)}const fa=z({results:L(z({id:H(),label:H(),url:H()}))});async function pa(e){return await Y(new URL(`/core/repository/preview_configs`,await j(e)),{schema:fa})}function ma(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ha(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a preview configuration from a Prismic repository.
|
|
1072
1282
|
|
|
1073
1283
|
By default, this command reads the repository from prismic.config.json at the
|
|
1074
1284
|
project root.
|
|
@@ -1084,7 +1294,20 @@ FLAGS
|
|
|
1084
1294
|
-h, --help Show help for command
|
|
1085
1295
|
|
|
1086
1296
|
LEARN MORE
|
|
1087
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
1297
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){_a();return}let i=await pa(n);if(!i.ok){i.error instanceof X?_a():(console.error(`Failed to fetch previews: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.results.find(e=>e.url===r);if(!a){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let o=await ga(n,a.id);if(!o.ok){o.error instanceof X?_a():(console.error(`Failed to remove preview: ${K(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function ga(e,t){return await Y(new URL(`/previews/delete/${t}`,await j(e)),{method:`POST`,body:{}})}function _a(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function va(){let{values:{help:t,repo:n=await q()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Remove the slice simulator URL from a Prismic repository.
|
|
1298
|
+
|
|
1299
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1300
|
+
project root.
|
|
1301
|
+
|
|
1302
|
+
USAGE
|
|
1303
|
+
prismic preview remove-simulator [flags]
|
|
1304
|
+
|
|
1305
|
+
FLAGS
|
|
1306
|
+
-r, --repo string Repository domain
|
|
1307
|
+
-h, --help Show help for command
|
|
1308
|
+
|
|
1309
|
+
LEARN MORE
|
|
1310
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ba();return}let r=await ya(n);if(!r.ok){r.error instanceof X?ba():(console.error(`Failed to remove simulator URL: ${K(r.value)}`),process.exitCode=1);return}console.info(`Simulator URL removed.`)}async function ya(e){return await Y(new URL(`/core/repository`,await j(e)),{method:`PATCH`,body:{simulator_url:``}})}function ba(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function xa(){let{values:{help:t,repo:n=await q()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update the name of a preview configuration.
|
|
1088
1311
|
|
|
1089
1312
|
By default, this command reads the repository from prismic.config.json at the
|
|
1090
1313
|
project root.
|
|
@@ -1101,22 +1324,95 @@ FLAGS
|
|
|
1101
1324
|
-h, --help Show help for command
|
|
1102
1325
|
|
|
1103
1326
|
LEARN MORE
|
|
1104
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
1327
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Ca();return}let a=ia(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await pa(n);if(!o.ok){o.error instanceof X?Ca():(console.error(`Failed to fetch previews: ${K(o.value)}`),process.exitCode=1);return}let s=o.value.results.find(e=>e.url===r);if(!s){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let c=await Sa(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof X?Ca():(console.error(`Failed to update preview: ${K(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function Sa(e,t,n){return await Y(new URL(`/previews/save/${t}`,await j(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function Ca(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function wa(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the slice simulator URL for a Prismic repository.
|
|
1328
|
+
|
|
1329
|
+
If the URL pathname does not end with /slice-simulator, it is appended
|
|
1330
|
+
automatically.
|
|
1331
|
+
|
|
1332
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1333
|
+
project root.
|
|
1334
|
+
|
|
1335
|
+
USAGE
|
|
1336
|
+
prismic preview set-simulator <url> [flags]
|
|
1337
|
+
|
|
1338
|
+
ARGUMENTS
|
|
1339
|
+
<url> Simulator URL (e.g. https://example.com/slice-simulator)
|
|
1340
|
+
|
|
1341
|
+
FLAGS
|
|
1342
|
+
-r, --repo string Repository domain
|
|
1343
|
+
-h, --help Show help for command
|
|
1344
|
+
|
|
1345
|
+
EXAMPLES
|
|
1346
|
+
prismic preview set-simulator https://my-site.com
|
|
1347
|
+
prismic preview set-simulator http://localhost:3000/slice-simulator
|
|
1348
|
+
|
|
1349
|
+
LEARN MORE
|
|
1350
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Da();return}let i=Ta(r);if(!i){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let a=await Ea(n,i);if(!a.ok){a.error instanceof X?Da():(console.error(`Failed to set simulator URL: ${K(a.value)}`),process.exitCode=1);return}console.info(`Simulator URL set: ${i}`)}function Ta(e){try{let t=new URL(e);return t.pathname.endsWith(`/slice-simulator`)||(t.pathname=t.pathname.replace(/\/+$/,``)+`/slice-simulator`),t.toString()}catch{return}}async function Ea(e,t){return await Y(new URL(`/core/repository`,await j(e)),{method:`PATCH`,body:{simulator_url:t}})}function Da(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Oa(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await ra();break;case`list`:await da();break;case`remove`:await ha();break;case`set-name`:await xa();break;case`set-simulator`:await wa();break;case`get-simulator`:await sa();break;case`remove-simulator`:await va();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
|
|
1105
1351
|
|
|
1106
1352
|
USAGE
|
|
1107
1353
|
prismic preview <command> [flags]
|
|
1108
1354
|
|
|
1109
1355
|
COMMANDS
|
|
1110
|
-
add
|
|
1111
|
-
list
|
|
1112
|
-
remove
|
|
1113
|
-
set-name
|
|
1356
|
+
add Add a preview configuration
|
|
1357
|
+
list List preview configurations
|
|
1358
|
+
remove Remove a preview configuration
|
|
1359
|
+
set-name Update a preview's name
|
|
1360
|
+
set-simulator Set the slice simulator URL
|
|
1361
|
+
get-simulator Show the slice simulator URL
|
|
1362
|
+
remove-simulator Remove the slice simulator URL
|
|
1114
1363
|
|
|
1115
1364
|
FLAGS
|
|
1116
1365
|
-h, --help Show help for command
|
|
1117
1366
|
|
|
1118
1367
|
LEARN MORE
|
|
1119
|
-
Use \`prismic preview <command> --help\` for more information about a command.`)}}
|
|
1368
|
+
Use \`prismic preview <command> --help\` for more information about a command.`)}}async function ka(){let{values:{help:t,repo:r=await q(),"dry-run":i,"types-only":a,"slices-only":o,json:c}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Pull custom types and slices from Prismic to local files.
|
|
1369
|
+
|
|
1370
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1371
|
+
project root.
|
|
1372
|
+
|
|
1373
|
+
USAGE
|
|
1374
|
+
prismic pull [flags]
|
|
1375
|
+
|
|
1376
|
+
FLAGS
|
|
1377
|
+
-r, --repo string Repository domain
|
|
1378
|
+
--dry-run Show what would be pulled without writing files
|
|
1379
|
+
--types-only Only pull custom types
|
|
1380
|
+
--slices-only Only pull slices
|
|
1381
|
+
--json Output as JSON
|
|
1382
|
+
-h, --help Show help for command
|
|
1383
|
+
|
|
1384
|
+
EXAMPLES
|
|
1385
|
+
prismic pull
|
|
1386
|
+
prismic pull --repo my-repo
|
|
1387
|
+
prismic pull --dry-run
|
|
1388
|
+
prismic pull --types-only`);return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}c||console.info(`Pulling from repository: ${r}\n`);let l=!o,u=!a,[d,f]=await Promise.all([l?Hn(r):Promise.resolve({ok:!0,value:[]}),u?Un(r):Promise.resolve({ok:!0,value:[]})]);if(!d.ok){console.error(`Failed to fetch custom types: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch slices: ${f.error}`),process.exitCode=1;return}let p=d.value,m=f.value;if(c||(l&&console.info(`Fetching custom types... ${p.length} types`),u&&console.info(`Fetching slices... ${m.length} slices`)),i){if(c)console.info(K({customTypes:p,slices:m}));else{if(console.info(``),l&&p.length>0){console.info(`Would write custom types:`);for(let e of p)console.info(` customtypes/${e.id}/index.json`)}if(u&&m.length>0){let e=Aa(await In());console.info(`Would write slices:`);for(let t of m)console.info(` ${e}${zn(t.name)}/model.json`)}console.info(`\nDry run complete: ${p.length} custom types, ${m.length} slices`)}return}let h=await G(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`.`,h),_=[],v=[];if(l&&p.length>0){c||console.info(`
|
|
1389
|
+
Writing custom types:`);let e=new URL(`customtypes/`,g);for(let t of p){let r=new URL(`${t.id}/`,e),i=new URL(`index.json`,r);try{await n(r,{recursive:!0}),await s(i,K(t));let e=`customtypes/${t.id}/index.json`;_.push(e),c||console.info(` ${e}`)}catch(e){console.error(`Failed to write custom type ${t.id}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(u&&m.length>0){c||console.info(`
|
|
1390
|
+
Writing slices:`);let e=await In();for(let t of m){let r=new URL(`${zn(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await s(i,K(t));let a=`${Aa(e)}${zn(t.name)}/model.json`;v.push(a),c||console.info(` ${a}`)}catch(e){console.error(`Failed to write slice ${t.name}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}c?console.info(K({writtenTypes:_,writtenSlices:v})):console.info(`\nPull complete: ${_.length} custom types, ${v.length} slices`)}function Aa(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}function ja(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[],a=[],o=[];for(let t of e){let e=r.get(t.id);e?JSON.stringify(t)!==JSON.stringify(e)&&a.push(t):i.push(t)}for(let e of t)n.has(e.id)||o.push(e.id);return{toInsert:i,toUpdate:a,toDelete:o}}async function Ma(){let{values:{help:t,repo:n=await q(),"dry-run":r,"types-only":i,"slices-only":a,delete:o,json:s}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},delete:{type:`boolean`},json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Push custom types and slices to Prismic from local files.
|
|
1391
|
+
|
|
1392
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1393
|
+
project root.
|
|
1394
|
+
|
|
1395
|
+
USAGE
|
|
1396
|
+
prismic push [flags]
|
|
1397
|
+
|
|
1398
|
+
FLAGS
|
|
1399
|
+
-r, --repo string Repository domain
|
|
1400
|
+
--dry-run Show what would be pushed without making changes
|
|
1401
|
+
--types-only Only push custom types
|
|
1402
|
+
--slices-only Only push slices
|
|
1403
|
+
--delete Delete remote models that don't exist locally (dangerous)
|
|
1404
|
+
--json Output as JSON
|
|
1405
|
+
-h, --help Show help for command
|
|
1406
|
+
|
|
1407
|
+
EXAMPLES
|
|
1408
|
+
prismic push
|
|
1409
|
+
prismic push --repo my-repo
|
|
1410
|
+
prismic push --dry-run
|
|
1411
|
+
prismic push --types-only
|
|
1412
|
+
prismic push --delete`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}s||console.info(`Pushing to repository: ${n}\n`);let c=!a,l=!i,[u,d,f,p]=await Promise.all([c?Wn():Promise.resolve({ok:!0,value:[]}),l?Gn():Promise.resolve({ok:!0,value:[]}),c?Hn(n):Promise.resolve({ok:!0,value:[]}),l?Un(n):Promise.resolve({ok:!0,value:[]})]);if(!u.ok){console.error(`Failed to read local custom types: ${u.error}`),process.exitCode=1;return}if(!d.ok){console.error(`Failed to read local slices: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch remote custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch remote slices: ${p.error}`),process.exitCode=1;return}let m=u.value,h=d.value,g=f.value,_=p.value;s||(c&&(console.info(`Local custom types: ${m.length}`),console.info(`Remote custom types: ${g.length}`)),l&&(console.info(`Local slices: ${h.length}`),console.info(`Remote slices: ${_.length}`)));let v=c?ja([...m],[...g]):{toInsert:[],toUpdate:[],toDelete:[]},y=l?ja([...h],[..._]):{toInsert:[],toUpdate:[],toDelete:[]};o||(v.toDelete=[],y.toDelete=[]);let ee=v.toInsert.length+v.toUpdate.length+v.toDelete.length+y.toInsert.length+y.toUpdate.length+y.toDelete.length;if(ee===0){s?console.info(K({customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}})):console.info(`
|
|
1413
|
+
No changes to push.`);return}if(r){if(s)console.info(K({customTypes:{toInsert:v.toInsert.map(e=>e.id),toUpdate:v.toUpdate.map(e=>e.id),toDelete:v.toDelete},slices:{toInsert:y.toInsert.map(e=>e.id),toUpdate:y.toUpdate.map(e=>e.id),toDelete:y.toDelete}}));else{if(console.info(``),c){if(v.toInsert.length>0){console.info(`Would insert custom types:`);for(let e of v.toInsert)console.info(` + ${e.id}`)}if(v.toUpdate.length>0){console.info(`Would update custom types:`);for(let e of v.toUpdate)console.info(` ~ ${e.id}`)}if(v.toDelete.length>0){console.info(`Would delete custom types:`);for(let e of v.toDelete)console.info(` - ${e}`)}}if(l){if(y.toInsert.length>0){console.info(`Would insert slices:`);for(let e of y.toInsert)console.info(` + ${e.id}`)}if(y.toUpdate.length>0){console.info(`Would update slices:`);for(let e of y.toUpdate)console.info(` ~ ${e.id}`)}if(y.toDelete.length>0){console.info(`Would delete slices:`);for(let e of y.toDelete)console.info(` - ${e}`)}}console.info(`\nDry run complete: ${ee} changes would be made`)}return}let b={customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}};if(c){!s&&(v.toInsert.length>0||v.toUpdate.length>0||v.toDelete.length>0)&&console.info(`
|
|
1414
|
+
Pushing custom types:`);for(let e of v.toInsert){let t=await Kn(n,e);if(!t.ok){console.error(`Failed to insert custom type ${e.id}: ${t.error}`),process.exitCode=1;return}b.customTypes.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of v.toUpdate){let t=await qn(n,e);if(!t.ok){console.error(`Failed to update custom type ${e.id}: ${t.error}`),process.exitCode=1;return}b.customTypes.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of v.toDelete){let t=await Jn(n,e);if(!t.ok){console.error(`Failed to delete custom type ${e}: ${t.error}`),process.exitCode=1;return}b.customTypes.deleted.push(e),s||console.info(` - ${e}`)}}if(l){!s&&(y.toInsert.length>0||y.toUpdate.length>0||y.toDelete.length>0)&&console.info(`
|
|
1415
|
+
Pushing slices:`);for(let e of y.toInsert){let t=await Yn(n,e);if(!t.ok){console.error(`Failed to insert slice ${e.id}: ${t.error}`),process.exitCode=1;return}b.slices.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of y.toUpdate){let t=await Xn(n,e);if(!t.ok){console.error(`Failed to update slice ${e.id}: ${t.error}`),process.exitCode=1;return}b.slices.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of y.toDelete){let t=await Zn(n,e);if(!t.ok){console.error(`Failed to delete slice ${e}: ${t.error}`),process.exitCode=1;return}b.slices.deleted.push(e),s||console.info(` - ${e}`)}}if(s)console.info(K(b));else{let e=b.customTypes.inserted.length+b.customTypes.updated.length+b.customTypes.deleted.length+b.slices.inserted.length+b.slices.updated.length+b.slices.deleted.length;console.info(`\nPush complete: ${e} changes`)}}const Na=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;async function Pa(){let{values:{help:t,name:n,"no-config":r,replace:i},positionals:[a]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},name:{type:`string`,short:`n`},"no-config":{type:`boolean`},replace:{type:`boolean`}},allowPositionals:!0});if(t){console.info(`Create a new Prismic repository.
|
|
1120
1416
|
|
|
1121
1417
|
Creates prismic.config.json in the current directory. If a config file already
|
|
1122
1418
|
exists, use --replace to update it with the new repository.
|
|
@@ -1135,7 +1431,20 @@ FLAGS
|
|
|
1135
1431
|
-h, --help Show help for command
|
|
1136
1432
|
|
|
1137
1433
|
LEARN MORE
|
|
1138
|
-
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: domain`),process.exitCode=1;return}if(!
|
|
1434
|
+
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: domain`),process.exitCode=1;return}if(!Na.test(a)){console.error(`Invalid domain format.`),console.error(`Must be at least 4 characters, start and end with alphanumeric, and contain only alphanumerics and hyphens.`),process.exitCode=1;return}if(!await M()){Ia();return}let o=await On();if(!r&&o.ok&&!i){console.error(`This project already has a repository: ${o.config.repositoryName}`),console.error(`Use --replace to replace it, or --no-config to skip config creation.`),process.exitCode=1;return}let s=await Fa(a,n);if(!s.ok){s.error instanceof X?Ia():(console.error(`Failed to create repository: ${K(s.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await An({repositoryName:a});e.ok?console.info(`Updated prismic.config.json`):console.warn(`Could not update prismic.config.json: `+e.error.message)}else{let e=await Dn({repositoryName:a});e.ok?console.info(`Created prismic.config.json`):console.warn(`Could not create prismic.config.json: `+e.error.message)}console.info(`Repository created: ${a}`),console.info(`URL: ${await j(a)}`)}async function Fa(e,t=e){return await Y(new URL(`/app/dashboard/repositories`,await on()),{method:`POST`,body:{domain:e,name:t,framework:`next`,plan:`personal`,usageIntent:`Exploring Prismic's features for future projects.`,usageIntentIndex:0}})}function Ia(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const La=z({repository:z({api_access:H()})});async function Ra(){let{values:{help:t,repo:n=await q()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Get the Content API access level of a Prismic repository.
|
|
1435
|
+
|
|
1436
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1437
|
+
project root.
|
|
1438
|
+
|
|
1439
|
+
USAGE
|
|
1440
|
+
prismic repo get-access [flags]
|
|
1441
|
+
|
|
1442
|
+
FLAGS
|
|
1443
|
+
-r, --repo string Repository domain
|
|
1444
|
+
-h, --help Show help for command
|
|
1445
|
+
|
|
1446
|
+
LEARN MORE
|
|
1447
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Ba();return}let r=await za(n);if(!r.ok){r.error instanceof X?Ba():(console.error(`Failed to get repository access: ${K(r.value)}`),process.exitCode=1);return}console.info(r.value.repository.api_access)}async function za(e){let t=await j(e);return await Y(new URL(`syncState`,t),{schema:La})}function Ba(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Va=z({repositories:L(z({domain:H(),name:B(H()),role:H()}))});async function Ha(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},json:{type:`boolean`}}});if(t){console.info(`List all Prismic repositories.
|
|
1139
1448
|
|
|
1140
1449
|
USAGE
|
|
1141
1450
|
prismic repo list [flags]
|
|
@@ -1145,7 +1454,23 @@ FLAGS
|
|
|
1145
1454
|
-h, --help Show help for command
|
|
1146
1455
|
|
|
1147
1456
|
LEARN MORE
|
|
1148
|
-
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await M()){
|
|
1457
|
+
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await M()){Wa();return}let r=await Ua();if(!r.ok){r.error instanceof X?Wa():(console.error(`Failed to fetch repositories: ${K(r.value)}`),process.exitCode=1);return}let i=r.value.repositories;if(n){let e=await Promise.all(i.map(async e=>({domain:e.domain,name:e.name||null,role:e.role,url:(await j(e.domain)).toString()})));console.info(K(e));return}if(i.length===0){console.info(`No repositories found.`);return}for(let e of i){let t=e.name||`(no name)`;console.info(`${e.domain} ${t} ${e.role}`)}}async function Ua(){return await Y(new URL(`profile`,await en()),{schema:Va})}function Wa(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Ga=[`private`,`public`,`open`];async function Ka(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the Content API access level of a Prismic repository.
|
|
1458
|
+
|
|
1459
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1460
|
+
project root.
|
|
1461
|
+
|
|
1462
|
+
USAGE
|
|
1463
|
+
prismic repo set-access <level> [flags]
|
|
1464
|
+
|
|
1465
|
+
ARGUMENTS
|
|
1466
|
+
<level> The access level to set (private, public, open)
|
|
1467
|
+
|
|
1468
|
+
FLAGS
|
|
1469
|
+
-r, --repo string Repository domain
|
|
1470
|
+
-h, --help Show help for command
|
|
1471
|
+
|
|
1472
|
+
LEARN MORE
|
|
1473
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <level>`),process.exitCode=1;return}if(!Ga.includes(r)){console.error(`Invalid access level: ${r}. Must be one of: ${Ga.join(`, `)}`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Ja();return}let i=await qa(n,r);if(!i.ok){i.error instanceof X?Ja():(console.error(`Failed to set repository access: ${K(i.value)}`),process.exitCode=1);return}console.info(`Repository access set to: ${r}`)}async function qa(e,t){let n=await j(e);return await Y(new URL(`settings/security/apiaccess`,n),{method:`POST`,body:{api_access:t}})}function Ja(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ya(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the display name of a Prismic repository.
|
|
1149
1474
|
|
|
1150
1475
|
By default, this command reads the repository from prismic.config.json at the
|
|
1151
1476
|
project root.
|
|
@@ -1161,7 +1486,7 @@ FLAGS
|
|
|
1161
1486
|
-h, --help Show help for command
|
|
1162
1487
|
|
|
1163
1488
|
LEARN MORE
|
|
1164
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
1489
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Za();return}let i=await Xa(n,r);if(!i.ok){i.error instanceof X?Za():I(i.error)?(console.error(`Failed to set repository name: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set repository name: ${K(i.value)}`),process.exitCode=1);return}console.info(`Repository name set to: ${i.value.repository.name}`)}async function Xa(e,t){let n=await j(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await Y(r,{method:`POST`,body:i,schema:z({repository:z({name:H()})})})}function Za(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Qa=z({repositories:L(z({domain:H(),name:B(H())}))});async function $a(){let{values:{help:t,repo:n=await q(),web:r}}=e({args:process.argv.slice(4),options:{web:{type:`boolean`,short:`w`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}}});if(t){console.info(`View a Prismic repository.
|
|
1165
1490
|
|
|
1166
1491
|
By default, this command reads the repository from prismic.config.json at the
|
|
1167
1492
|
project root.
|
|
@@ -1175,7 +1500,7 @@ FLAGS
|
|
|
1175
1500
|
-h, --help Show help for command
|
|
1176
1501
|
|
|
1177
1502
|
LEARN MORE
|
|
1178
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}let i=await
|
|
1503
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}let i=await j(n);if(r){to(i.toString()),console.info(`Opening ${i}`);return}if(!await M()){no();return}let a=await eo();if(!a.ok){a.error instanceof X?no():(console.error(`Failed to fetch repository info: ${K(a.value)}`),process.exitCode=1);return}let o=a.value.repositories.find(e=>e.domain===n);if(!o){console.error(`Repository not found: ${n}`),process.exitCode=1;return}let s=o.name||`(no name)`;console.info(`Name: ${s}`),console.info(`URL: ${i}`)}async function eo(){return await Y(new URL(`profile`,await en()),{schema:Qa})}function to(e){d(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function no(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ro(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Pa();break;case`list`:await Ha();break;case`view`:await $a();break;case`get-access`:await Ra();break;case`set-access`:await Ka();break;case`set-name`:await Ya();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
|
|
1179
1504
|
|
|
1180
1505
|
USAGE
|
|
1181
1506
|
prismic repo <command> [flags]
|
|
@@ -1184,13 +1509,15 @@ COMMANDS
|
|
|
1184
1509
|
create Create a new Prismic repository
|
|
1185
1510
|
list List all repositories
|
|
1186
1511
|
view View repository details
|
|
1512
|
+
get-access Get Content API access level
|
|
1513
|
+
set-access Set Content API access level
|
|
1187
1514
|
set-name Set repository display name
|
|
1188
1515
|
|
|
1189
1516
|
FLAGS
|
|
1190
1517
|
-h, --help Show help for command
|
|
1191
1518
|
|
|
1192
1519
|
LEARN MORE
|
|
1193
|
-
Use \`prismic repo <command> --help\` for more information about a command.`)}}async function
|
|
1520
|
+
Use \`prismic repo <command> --help\` for more information about a command.`)}}async function io(){let{values:{help:t,variation:n,label:r,default:i,"true-label":a,"false-label":o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing slice.
|
|
1194
1521
|
|
|
1195
1522
|
USAGE
|
|
1196
1523
|
prismic slice add-field boolean <slice-id> <field-id> [flags]
|
|
@@ -1201,7 +1528,7 @@ ARGUMENTS
|
|
|
1201
1528
|
|
|
1202
1529
|
FLAGS
|
|
1203
1530
|
-v, --variation string Target variation (default: first variation)
|
|
1204
|
-
-l, --label string Display label for the field
|
|
1531
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1205
1532
|
--default Set default value to true
|
|
1206
1533
|
--true-label string Label shown when toggle is on
|
|
1207
1534
|
--false-label string Label shown when toggle is off
|
|
@@ -1212,7 +1539,7 @@ EXAMPLES
|
|
|
1212
1539
|
prismic slice add-field boolean hero show_overlay --default
|
|
1213
1540
|
prismic slice add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!c){console.error(`Missing required argument: slice-id
|
|
1214
1541
|
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
1215
|
-
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
1542
|
+
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let u=await J(c);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${c}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${c}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};for(let e of d.variations)if(e.primary?.[l]){console.error(`Field "${l}" already exists in variation "${e.id}"`),process.exitCode=1;return}let m={type:`Boolean`,config:{label:r??Q(l),...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};p.primary[l]=m;try{await s(f,K(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${l}" (Boolean) to "${p.id}" variation in ${c}`)}async function ao(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing slice.
|
|
1216
1543
|
|
|
1217
1544
|
USAGE
|
|
1218
1545
|
prismic slice add-field color <slice-id> <field-id> [flags]
|
|
@@ -1223,7 +1550,7 @@ ARGUMENTS
|
|
|
1223
1550
|
|
|
1224
1551
|
FLAGS
|
|
1225
1552
|
-v, --variation string Target variation (default: first variation)
|
|
1226
|
-
-l, --label string Display label for the field
|
|
1553
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1227
1554
|
-p, --placeholder string Placeholder text
|
|
1228
1555
|
-h, --help Show help for command
|
|
1229
1556
|
|
|
@@ -1232,7 +1559,7 @@ EXAMPLES
|
|
|
1232
1559
|
prismic slice add-field color hero accent --label "Accent Color"
|
|
1233
1560
|
prismic slice add-field color banner theme_color --variation "dark"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1234
1561
|
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1235
|
-
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1562
|
+
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Color`,config:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Color) to "${d.id}" variation in ${a}`)}async function oo(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date picker field to an existing slice.
|
|
1236
1563
|
|
|
1237
1564
|
USAGE
|
|
1238
1565
|
prismic slice add-field date <slice-id> <field-id> [flags]
|
|
@@ -1243,7 +1570,7 @@ ARGUMENTS
|
|
|
1243
1570
|
|
|
1244
1571
|
FLAGS
|
|
1245
1572
|
-v, --variation string Target variation (default: first variation)
|
|
1246
|
-
-l, --label string Display label for the field
|
|
1573
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1247
1574
|
-p, --placeholder string Placeholder text
|
|
1248
1575
|
-h, --help Show help for command
|
|
1249
1576
|
|
|
@@ -1252,7 +1579,7 @@ EXAMPLES
|
|
|
1252
1579
|
prismic slice add-field date event start_date --label "Start Date"
|
|
1253
1580
|
prismic slice add-field date promo end_date --variation "countdown"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1254
1581
|
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1255
|
-
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1582
|
+
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Date`,config:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Date) to "${d.id}" variation in ${a}`)}async function so(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed (oEmbed) field to an existing slice.
|
|
1256
1583
|
|
|
1257
1584
|
USAGE
|
|
1258
1585
|
prismic slice add-field embed <slice-id> <field-id> [flags]
|
|
@@ -1263,7 +1590,7 @@ ARGUMENTS
|
|
|
1263
1590
|
|
|
1264
1591
|
FLAGS
|
|
1265
1592
|
-v, --variation string Target variation (default: first variation)
|
|
1266
|
-
-l, --label string Display label for the field
|
|
1593
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1267
1594
|
-p, --placeholder string Placeholder text
|
|
1268
1595
|
-h, --help Show help for command
|
|
1269
1596
|
|
|
@@ -1272,7 +1599,7 @@ EXAMPLES
|
|
|
1272
1599
|
prismic slice add-field embed gallery media --label "Media Embed"
|
|
1273
1600
|
prismic slice add-field embed social tweet --variation "twitter"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1274
1601
|
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1275
|
-
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1602
|
+
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Embed`,config:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Embed) to "${d.id}" variation in ${a}`)}async function co(){let{values:{help:t,variation:n,label:r},positionals:[i,a]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geographic coordinates field to an existing slice.
|
|
1276
1603
|
|
|
1277
1604
|
USAGE
|
|
1278
1605
|
prismic slice add-field geo-point <slice-id> <field-id> [flags]
|
|
@@ -1283,7 +1610,7 @@ ARGUMENTS
|
|
|
1283
1610
|
|
|
1284
1611
|
FLAGS
|
|
1285
1612
|
-v, --variation string Target variation (default: first variation)
|
|
1286
|
-
-l, --label string Display label for the field
|
|
1613
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1287
1614
|
-h, --help Show help for command
|
|
1288
1615
|
|
|
1289
1616
|
EXAMPLES
|
|
@@ -1291,7 +1618,7 @@ EXAMPLES
|
|
|
1291
1618
|
prismic slice add-field geo-point store coordinates --label "Store Location"
|
|
1292
1619
|
prismic slice add-field geo-point map marker --variation "interactive"`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1293
1620
|
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
|
|
1294
|
-
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let o=await
|
|
1621
|
+
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let o=await J(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.length===0){console.error(`Slice "${i}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let u=n?c.variations.find(e=>e.id===n):c.variations[0];if(!u){console.error(`Variation "${n}" not found in slice "${i}"\n`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u.primary||={};for(let e of c.variations)if(e.primary?.[a]){console.error(`Field "${a}" already exists in variation "${e.id}"`),process.exitCode=1;return}let d={type:`GeoPoint`,config:{label:r??Q(a)}};u.primary[a]=d;try{await s(l,K(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${a}" (GeoPoint) to "${u.id}" variation in ${i}`)}async function lo(){let{values:{help:t,variation:n,label:r},positionals:[i,a]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing slice.
|
|
1295
1622
|
|
|
1296
1623
|
USAGE
|
|
1297
1624
|
prismic slice add-field image <slice-id> <field-id> [flags]
|
|
@@ -1302,7 +1629,7 @@ ARGUMENTS
|
|
|
1302
1629
|
|
|
1303
1630
|
FLAGS
|
|
1304
1631
|
-v, --variation string Target variation (default: first variation)
|
|
1305
|
-
-l, --label string Display label for the field
|
|
1632
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1306
1633
|
-h, --help Show help for command
|
|
1307
1634
|
|
|
1308
1635
|
EXAMPLES
|
|
@@ -1310,7 +1637,7 @@ EXAMPLES
|
|
|
1310
1637
|
prismic slice add-field image hero banner --label "Hero Banner"
|
|
1311
1638
|
prismic slice add-field image gallery thumbnail --variation "grid"`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1312
1639
|
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
|
|
1313
|
-
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let o=await
|
|
1640
|
+
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let o=await J(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.length===0){console.error(`Slice "${i}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let u=n?c.variations.find(e=>e.id===n):c.variations[0];if(!u){console.error(`Variation "${n}" not found in slice "${i}"\n`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u.primary||={};for(let e of c.variations)if(e.primary?.[a]){console.error(`Field "${a}" already exists in variation "${e.id}"`),process.exitCode=1;return}let d={type:`Image`,config:{label:r??Q(a)}};u.primary[a]=d;try{await s(l,K(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${a}" (Image) to "${u.id}" variation in ${i}`)}async function uo(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing slice.
|
|
1314
1641
|
|
|
1315
1642
|
USAGE
|
|
1316
1643
|
prismic slice add-field key-text <slice-id> <field-id> [flags]
|
|
@@ -1321,7 +1648,7 @@ ARGUMENTS
|
|
|
1321
1648
|
|
|
1322
1649
|
FLAGS
|
|
1323
1650
|
-v, --variation string Target variation (default: first variation)
|
|
1324
|
-
-l, --label string Display label for the field
|
|
1651
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1325
1652
|
-p, --placeholder string Placeholder text
|
|
1326
1653
|
-h, --help Show help for command
|
|
1327
1654
|
|
|
@@ -1330,7 +1657,7 @@ EXAMPLES
|
|
|
1330
1657
|
prismic slice add-field key-text hero heading --label "Heading"
|
|
1331
1658
|
prismic slice add-field key-text cta button_text --placeholder "Enter button text"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1332
1659
|
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1333
|
-
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1660
|
+
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Text`,config:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Text) to "${d.id}" variation in ${a}`)}async function fo(){let{values:{help:t,variation:n,label:r,placeholder:i,"allow-text":a,"allow-target-blank":o,repeatable:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing slice.
|
|
1334
1661
|
|
|
1335
1662
|
USAGE
|
|
1336
1663
|
prismic slice add-field link <slice-id> <field-id> [flags]
|
|
@@ -1341,7 +1668,7 @@ ARGUMENTS
|
|
|
1341
1668
|
|
|
1342
1669
|
FLAGS
|
|
1343
1670
|
-v, --variation string Target variation (default: first variation)
|
|
1344
|
-
-l, --label string Display label for the field
|
|
1671
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1345
1672
|
-p, --placeholder string Placeholder text
|
|
1346
1673
|
--allow-text Allow text with link
|
|
1347
1674
|
--allow-target-blank Allow opening link in new tab
|
|
@@ -1354,7 +1681,7 @@ EXAMPLES
|
|
|
1354
1681
|
prismic slice add-field link navigation links --repeatable
|
|
1355
1682
|
prismic slice add-field link hero cta --allow-text --allow-target-blank`);return}if(!l){console.error(`Missing required argument: slice-id
|
|
1356
1683
|
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
1357
|
-
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
1684
|
+
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let d=await J(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`Link`,config:{label:r??Q(u),...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...c&&{repeat:!0}}};m.primary[u]=h;try{await s(p,K(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${u}" (Link) to "${m.id}" variation in ${l}`)}async function po(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing slice.
|
|
1358
1685
|
|
|
1359
1686
|
USAGE
|
|
1360
1687
|
prismic slice add-field number <slice-id> <field-id> [flags]
|
|
@@ -1365,7 +1692,7 @@ ARGUMENTS
|
|
|
1365
1692
|
|
|
1366
1693
|
FLAGS
|
|
1367
1694
|
-v, --variation string Target variation (default: first variation)
|
|
1368
|
-
-l, --label string Display label for the field
|
|
1695
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1369
1696
|
-p, --placeholder string Placeholder text
|
|
1370
1697
|
-h, --help Show help for command
|
|
1371
1698
|
|
|
@@ -1374,7 +1701,7 @@ EXAMPLES
|
|
|
1374
1701
|
prismic slice add-field number product quantity --label "Quantity"
|
|
1375
1702
|
prismic slice add-field number stats count --variation "detailed"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1376
1703
|
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1377
|
-
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1704
|
+
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Number`,config:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Number) to "${d.id}" variation in ${a}`)}async function mo(){let{values:{help:t,variation:n,label:r,placeholder:i,single:a,multi:o,"allow-target-blank":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing slice.
|
|
1378
1705
|
|
|
1379
1706
|
USAGE
|
|
1380
1707
|
prismic slice add-field rich-text <slice-id> <field-id> [flags]
|
|
@@ -1385,7 +1712,7 @@ ARGUMENTS
|
|
|
1385
1712
|
|
|
1386
1713
|
FLAGS
|
|
1387
1714
|
-v, --variation string Target variation (default: first variation)
|
|
1388
|
-
-l, --label string Display label for the field
|
|
1715
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1389
1716
|
-p, --placeholder string Placeholder text
|
|
1390
1717
|
--single string Allowed block types for single-line (comma-separated)
|
|
1391
1718
|
--multi string Allowed block types for multi-line (comma-separated)
|
|
@@ -1403,7 +1730,7 @@ EXAMPLES
|
|
|
1403
1730
|
prismic slice add-field rich-text hero tagline --single "heading1"
|
|
1404
1731
|
prismic slice add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!l){console.error(`Missing required argument: slice-id
|
|
1405
1732
|
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
1406
|
-
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
1733
|
+
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let d=await J(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`StructuredText`,config:{label:r??Q(u),...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...c&&{allowTargetBlank:!0}}};m.primary[u]=h;try{await s(p,K(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${u}" (StructuredText) to "${m.id}" variation in ${l}`)}async function ho(){let{values:{help:t,variation:n,label:r,placeholder:i,option:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing slice.
|
|
1407
1734
|
|
|
1408
1735
|
USAGE
|
|
1409
1736
|
prismic slice add-field select <slice-id> <field-id> [flags]
|
|
@@ -1414,7 +1741,7 @@ ARGUMENTS
|
|
|
1414
1741
|
|
|
1415
1742
|
FLAGS
|
|
1416
1743
|
-v, --variation string Target variation (default: first variation)
|
|
1417
|
-
-l, --label string Display label for the field
|
|
1744
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1418
1745
|
-p, --placeholder string Placeholder text
|
|
1419
1746
|
--option string Add an option (can be used multiple times)
|
|
1420
1747
|
--default string Default selected value
|
|
@@ -1425,7 +1752,7 @@ EXAMPLES
|
|
|
1425
1752
|
prismic slice add-field select hero style --option "light" --option "dark" --default "light"
|
|
1426
1753
|
prismic slice add-field select product size --option "small" --option "medium" --option "large" --label "Size"`);return}if(!c){console.error(`Missing required argument: slice-id
|
|
1427
1754
|
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
1428
|
-
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
1755
|
+
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let u=await J(c);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${c}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${c}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};for(let e of d.variations)if(e.primary?.[l]){console.error(`Field "${l}" already exists in variation "${e.id}"`),process.exitCode=1;return}let m={type:`Select`,config:{label:r??Q(l),...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};p.primary[l]=m;try{await s(f,K(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${l}" (Select) to "${p.id}" variation in ${c}`)}async function go(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing slice.
|
|
1429
1756
|
|
|
1430
1757
|
USAGE
|
|
1431
1758
|
prismic slice add-field timestamp <slice-id> <field-id> [flags]
|
|
@@ -1436,7 +1763,7 @@ ARGUMENTS
|
|
|
1436
1763
|
|
|
1437
1764
|
FLAGS
|
|
1438
1765
|
-v, --variation string Target variation (default: first variation)
|
|
1439
|
-
-l, --label string Display label for the field
|
|
1766
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1440
1767
|
-p, --placeholder string Placeholder text
|
|
1441
1768
|
-h, --help Show help for command
|
|
1442
1769
|
|
|
@@ -1445,7 +1772,7 @@ EXAMPLES
|
|
|
1445
1772
|
prismic slice add-field timestamp event start_time --label "Event Start"
|
|
1446
1773
|
prismic slice add-field timestamp schedule meeting_time --variation "detailed"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1447
1774
|
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1448
|
-
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
1775
|
+
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let c=await J(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Timestamp`,config:{label:r??Q(o),...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,K(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Timestamp) to "${d.id}" variation in ${a}`)}async function _o(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await io();break;case`color`:await ao();break;case`date`:await oo();break;case`embed`:await so();break;case`geo-point`:await co();break;case`image`:await lo();break;case`key-text`:await uo();break;case`link`:await fo();break;case`number`:await po();break;case`rich-text`:await mo();break;case`select`:await ho();break;case`timestamp`:await go();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
|
|
1449
1776
|
|
|
1450
1777
|
USAGE
|
|
1451
1778
|
prismic slice add-field <field-type> <slice-id> <field-id> [flags]
|
|
@@ -1474,7 +1801,7 @@ EXAMPLES
|
|
|
1474
1801
|
prismic slice add-field key-text my_slice title --label "Title"
|
|
1475
1802
|
prismic slice add-field link my_slice cta --allow-text
|
|
1476
1803
|
prismic slice add-field rich-text my_slice body --multi "paragraph,heading2,strong,em"
|
|
1477
|
-
prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function
|
|
1804
|
+
prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function vo(){let{values:{help:t,name:n,"copy-from":r},positionals:[i,a]}=e({args:process.argv.slice(4),options:{name:{type:`string`},"copy-from":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new variation to a slice.
|
|
1478
1805
|
|
|
1479
1806
|
USAGE
|
|
1480
1807
|
prismic slice add-variation <slice-id> <variation-id> [flags]
|
|
@@ -1493,7 +1820,7 @@ EXAMPLES
|
|
|
1493
1820
|
prismic slice add-variation MySlice withImage --name "With Image"
|
|
1494
1821
|
prismic slice add-variation MySlice withImage --copy-from default`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1495
1822
|
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: variation-id
|
|
1496
|
-
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let o=await
|
|
1823
|
+
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let o=await J(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.some(e=>e.id===a)){console.error(`Variation "${a}" already exists in slice "${i}"`),process.exitCode=1;return}let u;if(r){let e=c.variations.find(e=>e.id===r);if(!e){console.error(`Source variation not found: ${r}`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u={...structuredClone(e),id:a,name:n??zn(a)}}else u={id:a,name:n??zn(a),description:a,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}};let d={...c,variations:[...c.variations,u]};try{await s(l,K(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added variation "${a}" to slice "${i}"`)}async function yo(){let{values:{help:t,name:r},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new slice in a Prismic project.
|
|
1497
1824
|
|
|
1498
1825
|
USAGE
|
|
1499
1826
|
prismic slice create <id> [flags]
|
|
@@ -1506,7 +1833,7 @@ FLAGS
|
|
|
1506
1833
|
-h, --help Show help for command
|
|
1507
1834
|
|
|
1508
1835
|
LEARN MORE
|
|
1509
|
-
Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: id`),process.exitCode=1;return}let a={id:i,type:`SharedSlice`,name:r??
|
|
1836
|
+
Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: id`),process.exitCode=1;return}let a={id:i,type:`SharedSlice`,name:r??Co(i),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}}]},o=await bo(),c=new URL(Co(a.name)+`/`,o),l=new URL(`model.json`,c);try{await n(new URL(`.`,l),{recursive:!0}),await s(l,K(a))}catch(e){e instanceof Error?console.error(`Failed to create slice: ${e.message}`):console.error(`Failed to create slice`),process.exitCode=1;return}console.info(`Created slice at ${l.href}`)}async function bo(){let e=await So(),t=await G(`package.json`);switch(e){case`next`:if(await wn(new URL(`src`,t)))return new URL(`src/slices/`,t);case`nuxt`:if(await wn(new URL(`app`,t)))return new URL(`app/slices/`,t);case`sveltekit`:return new URL(`src/slices/`,t)}return new URL(`slices/`,t)}const xo=z({dependencies:B(V(H(),H()))});async function So(){let e=await G(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=Sn(xo,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function Co(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function wo(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all slices in a Prismic project.
|
|
1510
1837
|
|
|
1511
1838
|
USAGE
|
|
1512
1839
|
prismic slice list [flags]
|
|
@@ -1517,7 +1844,7 @@ FLAGS
|
|
|
1517
1844
|
|
|
1518
1845
|
EXAMPLES
|
|
1519
1846
|
prismic slice list
|
|
1520
|
-
prismic slice list --json`);return}let a=await
|
|
1847
|
+
prismic slice list --json`);return}let a=await In(),o;try{o=await i(a,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}let s=[];for(let e of o){let t=new URL(`${e}/model.json`,a);try{let e=await r(t,`utf8`),n=W(Fn,JSON.parse(e));n.success&&s.push({id:n.output.id,name:n.output.name})}catch{}}if(s.length===0){n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}if(n)console.info(JSON.stringify(s,null,2));else{console.info(`ID NAME`);for(let e of s)console.info(`${e.id}\t${e.name}`)}}async function To(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all variations for a slice.
|
|
1521
1848
|
|
|
1522
1849
|
USAGE
|
|
1523
1850
|
prismic slice list-variations <slice-id> [flags]
|
|
@@ -1532,7 +1859,7 @@ FLAGS
|
|
|
1532
1859
|
EXAMPLES
|
|
1533
1860
|
prismic slice list-variations MySlice
|
|
1534
1861
|
prismic slice list-variations MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1535
|
-
`),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await
|
|
1862
|
+
`),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await J(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i,o=a.variations.map(e=>({id:e.id,name:e.name}));if(n){console.info(JSON.stringify(o,null,2));return}console.info(`ID NAME`);for(let e of o)console.info(`${e.id}\t${e.name}`)}async function Eo(){let{values:{help:t,y:n},positionals:[r]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a slice from the project.
|
|
1536
1863
|
|
|
1537
1864
|
USAGE
|
|
1538
1865
|
prismic slice remove <slice-id> [flags]
|
|
@@ -1547,7 +1874,7 @@ FLAGS
|
|
|
1547
1874
|
EXAMPLES
|
|
1548
1875
|
prismic slice remove MySlice
|
|
1549
1876
|
prismic slice remove MySlice -y`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1550
|
-
`),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let i=await
|
|
1877
|
+
`),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let i=await J(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{modelPath:a}=i,s=new URL(`.`,a);if(!n){console.error(`Refusing to remove slice "${r}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove slice: ${e.message}`):console.error(`Failed to remove slice`),process.exitCode=1;return}console.info(`Removed slice "${r}"`)}async function Do(){let{values:{help:t,variation:n,zone:r},positionals:[i,a]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,default:`default`},zone:{type:`string`,default:`primary`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a slice variation.
|
|
1551
1878
|
|
|
1552
1879
|
USAGE
|
|
1553
1880
|
prismic slice remove-field <slice-id> <field-id> [flags]
|
|
@@ -1566,7 +1893,7 @@ EXAMPLES
|
|
|
1566
1893
|
prismic slice remove-field MySlice title --variation withImage
|
|
1567
1894
|
prismic slice remove-field MySlice item_title --zone items`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1568
1895
|
`),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
|
|
1569
|
-
`),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(r!==`primary`&&r!==`items`){console.error(`Invalid zone: ${r}. Must be "primary" or "items".`),process.exitCode=1;return}let o=await
|
|
1896
|
+
`),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(r!==`primary`&&r!==`items`){console.error(`Invalid zone: ${r}. Must be "primary" or "items".`),process.exitCode=1;return}let o=await J(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o,u=c.variations.find(e=>e.id===n);if(!u){console.error(`Variation not found: ${n}`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let d=r===`primary`?u.primary:u.items;if(!d||!(a in d)){console.error(`Field "${a}" not found in ${r} zone of variation "${n}"`),process.exitCode=1;return}delete d[a];try{await s(l,K(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed field "${a}" from ${r} zone in variation "${n}" of slice "${i}"`)}async function Oo(){let{values:{help:t},positionals:[n,r]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a variation from a slice.
|
|
1570
1897
|
|
|
1571
1898
|
USAGE
|
|
1572
1899
|
prismic slice remove-variation <slice-id> <variation-id> [flags]
|
|
@@ -1581,7 +1908,7 @@ FLAGS
|
|
|
1581
1908
|
EXAMPLES
|
|
1582
1909
|
prismic slice remove-variation MySlice withImage`);return}if(!n){console.error(`Missing required argument: slice-id
|
|
1583
1910
|
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!r){console.error(`Missing required argument: variation-id
|
|
1584
|
-
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let i=await
|
|
1911
|
+
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let i=await J(n);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a,modelPath:o}=i;if(!a.variations.some(e=>e.id===r)){console.error(`Variation not found: ${r}`),console.error(`Available variations: ${a.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(a.variations.length===1){console.error(`Cannot remove the last variation from a slice.`),process.exitCode=1;return}let c={...a,variations:a.variations.filter(e=>e.id!==r)};try{await s(o,K(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed variation "${r}" from slice "${n}"`)}async function ko(){let{values:{help:t,id:n},positionals:[r,i]}=e({args:process.argv.slice(4),options:{id:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Rename a slice (updates name field, optionally id and directory).
|
|
1585
1912
|
|
|
1586
1913
|
USAGE
|
|
1587
1914
|
prismic slice rename <slice-id> <new-name> [flags]
|
|
@@ -1598,7 +1925,7 @@ EXAMPLES
|
|
|
1598
1925
|
prismic slice rename MySlice "My New Name"
|
|
1599
1926
|
prismic slice rename MySlice "My New Name" --id NewSliceId`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1600
1927
|
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: new-name
|
|
1601
|
-
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let o=await
|
|
1928
|
+
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let o=await J(r);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;c.name=i,n&&(c.id=n);try{await s(l,K(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}if(n){let e=await In(),t=new URL(`.`,l),o=new URL(zn(i)+`/`,e);if(t.href!==o.href)try{await a(t,o),console.info(`Renamed slice "${r}" to "${n}" (${i})`),console.info(`Moved directory to ${o.href}`)}catch(e){e instanceof Error?console.error(`Failed to rename directory: ${e.message}`):console.error(`Failed to rename directory`),process.exitCode=1;return}else console.info(`Renamed slice "${r}" to "${n}" (${i})`)}else console.info(`Renamed slice "${r}" to "${i}"`)}async function Ao(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific slice.
|
|
1602
1929
|
|
|
1603
1930
|
USAGE
|
|
1604
1931
|
prismic slice view <slice-id> [flags]
|
|
@@ -1613,8 +1940,8 @@ FLAGS
|
|
|
1613
1940
|
EXAMPLES
|
|
1614
1941
|
prismic slice view MySlice
|
|
1615
1942
|
prismic slice view MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1616
|
-
`),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await
|
|
1617
|
-
Variations:`);for(let e of a.variations){let t=Object.keys(e.primary??{}).length,n=Object.keys(e.items??{}).length;console.info(` - ${e.id} (${e.name}): ${t} primary fields, ${n} items fields`)}}async function
|
|
1943
|
+
`),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await J(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i;if(n){console.info(JSON.stringify(a,null,2));return}console.info(`ID: ${a.id}`),console.info(`Name: ${a.name}`),a.description&&console.info(`Description: ${a.description}`),console.info(`Variations: ${a.variations.length}`),console.info(`
|
|
1944
|
+
Variations:`);for(let e of a.variations){let t=Object.keys(e.primary??{}).length,n=Object.keys(e.items??{}).length;console.info(` - ${e.id} (${e.name}): ${t} primary fields, ${n} items fields`)}}async function jo(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await yo();break;case`list`:await wo();break;case`view`:await Ao();break;case`rename`:await ko();break;case`remove`:await Eo();break;case`add-field`:await _o();break;case`remove-field`:await Do();break;case`add-variation`:await vo();break;case`remove-variation`:await Oo();break;case`list-variations`:await To();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
|
|
1618
1945
|
|
|
1619
1946
|
USAGE
|
|
1620
1947
|
prismic slice <command> [flags]
|
|
@@ -1635,29 +1962,7 @@ FLAGS
|
|
|
1635
1962
|
-h, --help Show help for command
|
|
1636
1963
|
|
|
1637
1964
|
LEARN MORE
|
|
1638
|
-
Use \`prismic slice <command> --help\` for more information about a command.`)}}
|
|
1639
|
-
|
|
1640
|
-
By default, this command reads the repository from prismic.config.json at the
|
|
1641
|
-
project root.
|
|
1642
|
-
|
|
1643
|
-
USAGE
|
|
1644
|
-
prismic sync [flags]
|
|
1645
|
-
|
|
1646
|
-
FLAGS
|
|
1647
|
-
-r, --repo string Repository domain
|
|
1648
|
-
--dry-run Show what would be synced without writing files
|
|
1649
|
-
--types-only Only sync custom types
|
|
1650
|
-
--slices-only Only sync slices
|
|
1651
|
-
--json Output as JSON
|
|
1652
|
-
-h, --help Show help for command
|
|
1653
|
-
|
|
1654
|
-
EXAMPLES
|
|
1655
|
-
prismic sync
|
|
1656
|
-
prismic sync --repo my-repo
|
|
1657
|
-
prismic sync --dry-run
|
|
1658
|
-
prismic sync --types-only`);return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}c||console.info(`Syncing from repository: ${r}\n`);let l=!o,u=!a,[d,f]=await Promise.all([l?Lr(r):Promise.resolve({ok:!0,value:[]}),u?Rr(r):Promise.resolve({ok:!0,value:[]})]);if(!d.ok){console.error(`Failed to fetch custom types: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch slices: ${f.error}`),process.exitCode=1;return}let p=d.value,m=f.value;if(c||(l&&console.info(`Fetching custom types... ${p.length} types`),u&&console.info(`Fetching slices... ${m.length} slices`)),i){if(c)console.info(z({customTypes:p,slices:m}));else{if(console.info(``),l&&p.length>0){console.info(`Would write custom types:`);for(let e of p)console.info(` customtypes/${e.id}/index.json`)}if(u&&m.length>0){let e=zr(await V());console.info(`Would write slices:`);for(let t of m)console.info(` ${e}${H(t.name)}/model.json`)}console.info(`\nDry run complete: ${p.length} custom types, ${m.length} slices`)}return}let h=await L(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`.`,h),_=[],v=[];if(l&&p.length>0){c||console.info(`
|
|
1659
|
-
Writing custom types:`);let e=new URL(`customtypes/`,g);for(let t of p){let r=new URL(`${t.id}/`,e),i=new URL(`index.json`,r);try{await n(r,{recursive:!0}),await s(i,z(t));let e=`customtypes/${t.id}/index.json`;_.push(e),c||console.info(` ${e}`)}catch(e){console.error(`Failed to write custom type ${t.id}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(u&&m.length>0){c||console.info(`
|
|
1660
|
-
Writing slices:`);let e=await V();for(let t of m){let r=new URL(`${H(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await s(i,z(t));let a=`${zr(e)}${H(t.name)}/model.json`;v.push(a),c||console.info(` ${a}`)}catch(e){console.error(`Failed to write slice ${t.name}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}c?console.info(z({writtenTypes:_,writtenSlices:v})):console.info(`\nSync complete: ${_.length} custom types, ${v.length} slices`)}async function Ir(){let e=await P();return e.hostname=`customtypes.${e.hostname}`,e}async function Lr(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Ir(),r=new URL(`customtypes`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=A(x(Pr),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Rr(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Ir(),r=new URL(`slices`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=A(x(Be),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}function zr(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}async function Br(){let{values:{help:t,repo:n=await U(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all API tokens for a Prismic repository.
|
|
1965
|
+
Use \`prismic slice <command> --help\` for more information about a command.`)}}async function Mo(){let{values:{help:t,repo:n=await q(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all API tokens for a Prismic repository.
|
|
1661
1966
|
|
|
1662
1967
|
By default, this command reads the repository from prismic.config.json at the
|
|
1663
1968
|
project root.
|
|
@@ -1671,7 +1976,7 @@ FLAGS
|
|
|
1671
1976
|
-h, --help Show help for command
|
|
1672
1977
|
|
|
1673
1978
|
LEARN MORE
|
|
1674
|
-
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
1979
|
+
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Uo();return}let[i,a]=await Promise.all([zo(n),Bo(n)]);if(!i.ok){i.error instanceof X||i.error instanceof Z?Uo():I(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${K(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof X||a.error instanceof Z?Uo():I(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${K(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${K(a.value)}`),process.exitCode=1);return}let o=i.value.flatMap(e=>e.wroom_auths.map(t=>({name:e.name,appId:e.id,authId:t.id,scope:t.scope,token:t.token,createdAt:t.created_at.$date}))),s=a.value.tokens;if(r)console.info(K({accessTokens:o,writeTokens:s}));else{if(o.length>0){console.info(`ACCESS TOKENS`);for(let e of o){let t=Vo(e.token),n=Ho(e.createdAt);console.info(` ${e.name} ${e.scope} ${t} ${n}`)}}else console.info(`ACCESS TOKENS (none)`);if(console.info(``),s.length>0){console.info(`WRITE TOKENS`);for(let e of s){let t=Vo(e.token),n=Ho(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const No=z({$date:xn()}),Po=z({id:H(),origin:H(),domain:H(),app:H(),scope:H(),expired_at:No,created_at:No,owner:bn(H()),token:H()}),Fo=z({id:H(),secret:H(),name:H(),owner:H(),created_at:No,authorized_domains:L(H()),wroom_auths:L(Po)}),Io=z({app_name:H(),token:H(),timestamp:xn()}),Lo=z({max_tokens:xn(),tokens:L(Io)}),Ro=L(Fo);async function zo(e){return await Y(new URL(`settings/security/contentapi`,await j(e)),{schema:Ro})}async function Bo(e){return await Y(new URL(`settings/security/customtypesapi`,await j(e)),{schema:Lo})}function Vo(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function Ho(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function Uo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Wo(){let{values:{help:t,repo:n=await q(),json:r,write:i,name:a=`Prismic CLI`,"allow-releases":o}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`},write:{type:`boolean`,short:`w`},name:{type:`string`,short:`n`},"allow-releases":{type:`boolean`}},allowPositionals:!1});if(t){console.info(`Create a new API token for a Prismic repository.
|
|
1675
1980
|
|
|
1676
1981
|
By default, this command reads the repository from prismic.config.json at the
|
|
1677
1982
|
project root.
|
|
@@ -1688,7 +1993,7 @@ FLAGS
|
|
|
1688
1993
|
-h, --help Show help for command
|
|
1689
1994
|
|
|
1690
1995
|
LEARN MORE
|
|
1691
|
-
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(i&&o){console.error(`--allow-releases is only valid for access tokens (not with --write)`),process.exitCode=1;return}if(!await M()){
|
|
1996
|
+
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(i&&o){console.error(`--allow-releases is only valid for access tokens (not with --write)`),process.exitCode=1;return}if(!await M()){qo();return}if(i){let e=await Go(n,a);if(!e.ok){e.error instanceof X||e.error instanceof Z?qo():I(e.error)?(console.error(`Failed to create write token: Invalid response: ${K(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create write token: ${K(e.value)}`),process.exitCode=1);return}r?console.info(K(e.value)):console.info(`Token created: ${e.value.token}`)}else{let e=await Ko(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof X||e.error instanceof Z?qo():I(e.error)?(console.error(`Failed to create access token: Invalid response: ${K(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create access token: ${K(e.value)}`),process.exitCode=1);return}r?console.info(K(e.value)):console.info(`Token created: ${e.value.token}`)}}async function Go(e,t){return await Y(new URL(`settings/security/token`,await j(e)),{method:`POST`,body:{app_name:t},schema:Io})}async function Ko(e,t,n){let r=await zo(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await Y(new URL(`settings/security/oauthapp`,await j(e)),{method:`POST`,body:{app_name:t},schema:Fo});if(!n.ok)return n;i=n.value}return await Y(new URL(`settings/security/authorizations`,await j(e)),{method:`POST`,body:{app:i.id,scope:n},schema:Po})}function qo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Jo(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a token from a Prismic repository.
|
|
1692
1997
|
|
|
1693
1998
|
By default, this command reads the repository from prismic.config.json at the
|
|
1694
1999
|
project root.
|
|
@@ -1704,7 +2009,7 @@ FLAGS
|
|
|
1704
2009
|
-h, --help Show help for command
|
|
1705
2010
|
|
|
1706
2011
|
LEARN MORE
|
|
1707
|
-
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
2012
|
+
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Yo();return}let[i,a]=await Promise.all([zo(n),Bo(n)]);if(!i.ok){i.error instanceof X||i.error instanceof Z?Yo():I(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${K(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof X||a.error instanceof Z?Yo():I(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${K(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${K(a.value)}`),process.exitCode=1);return}let o;for(let e of i.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){o=t;break}if(o)break}if(o){let e=await Y(new URL(`settings/security/authorizations/${o.id}`,await j(n)),{method:`DELETE`});if(!e.ok){e.error instanceof X||e.error instanceof Z?Yo():(console.error(`Failed to delete token: ${K(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}let s=a.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r));if(s){let e=await Y(new URL(`settings/security/token/${s.token}`,await j(n)),{method:`DELETE`});if(!e.ok){e.error instanceof X||e.error instanceof Z?Yo():(console.error(`Failed to delete token: ${K(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}console.error(`Token not found: ${r}`),process.exitCode=1}function Yo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Xo(){let{values:{help:t,repo:n=await q()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the name of a token in a Prismic repository.
|
|
1708
2013
|
|
|
1709
2014
|
Note: Only access tokens can be renamed. Write tokens cannot be renamed without
|
|
1710
2015
|
changing the token value.
|
|
@@ -1724,7 +2029,7 @@ FLAGS
|
|
|
1724
2029
|
-h, --help Show help for command
|
|
1725
2030
|
|
|
1726
2031
|
LEARN MORE
|
|
1727
|
-
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: name`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
2032
|
+
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: name`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Zo();return}let[a,o]=await Promise.all([zo(n),Bo(n)]);if(!a.ok){a.error instanceof X||a.error instanceof Z?Zo():I(a.error)?(console.error(`Failed to list access tokens: Invalid response: ${K(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${K(a.value)}`),process.exitCode=1);return}if(!o.ok){o.error instanceof X||o.error instanceof Z?Zo():I(o.error)?(console.error(`Failed to list write tokens: Invalid response: ${K(o.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${K(o.value)}`),process.exitCode=1);return}let s;for(let e of a.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){s=e;break}if(s)break}if(s){let e=await Y(new URL(`settings/security/oauthapp/${s.id}`,await j(n)),{method:`POST`,body:{name:i},schema:Fo});if(!e.ok){e.error instanceof X||e.error instanceof Z?Zo():I(e.error)?(console.error(`Failed to rename token: Invalid response: ${K(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to rename token: ${K(e.value)}`),process.exitCode=1);return}console.info(`Token renamed to: ${i}`);return}if(o.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r))){console.error(`Write tokens cannot be renamed. Delete and create a new token with the desired name.`),process.exitCode=1;return}console.error(`Token not found: ${r}`),process.exitCode=1}function Zo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Qo(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Mo();break;case`create`:await Wo();break;case`set-name`:await Xo();break;case`delete`:await Jo();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
|
|
1728
2033
|
|
|
1729
2034
|
USAGE
|
|
1730
2035
|
prismic token <command> [flags]
|
|
@@ -1739,7 +2044,7 @@ FLAGS
|
|
|
1739
2044
|
-h, --help Show help for command
|
|
1740
2045
|
|
|
1741
2046
|
LEARN MORE
|
|
1742
|
-
Use \`prismic token <command> --help\` for more information about a command.`)}}const
|
|
2047
|
+
Use \`prismic token <command> --help\` for more information about a command.`)}}const $o={documentsPublished:`document.published`,documentsUnpublished:`document.unpublished`,releasesCreated:`release.created`,releasesUpdated:`release.updated`,tagsCreated:`tag.created`,tagsDeleted:`tag.deleted`};async function es(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a webhook in a Prismic repository.
|
|
1743
2048
|
|
|
1744
2049
|
By default, this command reads the repository from prismic.config.json at the
|
|
1745
2050
|
project root.
|
|
@@ -1755,7 +2060,7 @@ FLAGS
|
|
|
1755
2060
|
-h, --help Show help for command
|
|
1756
2061
|
|
|
1757
2062
|
LEARN MORE
|
|
1758
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
2063
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ts();return}let i=await $(n);if(!i.ok){i.error instanceof X?ts():(console.error(`Failed to view webhook: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let{config:o}=a;console.info(`URL: ${o.url}`),console.info(`Name: ${o.name||`(none)`}`),console.info(`Status: ${o.active?`enabled`:`disabled`}`),console.info(`Secret: ${o.secret?`(set)`:`(none)`}`);let s=[];for(let[e,t]of Object.entries($o))o[e]&&s.push(t);if(console.info(`Triggers: ${s.length>0?s.join(`, `):`(none)`}`),Object.keys(o.headers).length>0){console.info(`Headers:`);for(let[e,t]of Object.entries(o.headers))console.info(` ${e}: ${t}`)}else console.info(`Headers: (none)`)}function ts(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const ns=z({config:z({_id:H(),url:H(),active:R(),name:bn(H()),secret:bn(H()),headers:V(H(),H()),documentsPublished:R(),documentsUnpublished:R(),releasesCreated:R(),releasesUpdated:R(),tagsCreated:R(),tagsDeleted:R()})});async function $(e){return await Y(new URL(`/app/settings/webhooks`,await j(e)),{schema:L(ns)})}async function rs(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Enable a webhook in a Prismic repository.
|
|
1759
2064
|
|
|
1760
2065
|
By default, this command reads the repository from prismic.config.json at the
|
|
1761
2066
|
project root.
|
|
@@ -1771,7 +2076,7 @@ FLAGS
|
|
|
1771
2076
|
-h, --help Show help for command
|
|
1772
2077
|
|
|
1773
2078
|
LEARN MORE
|
|
1774
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
2079
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){as();return}let i=await $(n);if(!i.ok){i.error instanceof X?as():(console.error(`Failed to enable webhook: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(a.config.active){console.info(`Webhook already enabled: ${r}`);return}let o=structuredClone(a.config);o.active=!0;let s=await is(n,a.config._id,o);if(!s.ok){s.error instanceof X?as():(console.error(`Failed to enable webhook: ${K(s.value)}`),process.exitCode=1);return}console.info(`Webhook enabled: ${r}`)}async function is(e,t,n){let r=new URL(`/app/settings/webhooks/${t}`,await j(e)),i=new FormData;return i.set(`url`,n.url),i.set(`name`,n.name??``),i.set(`secret`,n.secret??``),i.set(`headers`,JSON.stringify(n.headers??{})),i.set(`active`,n.active?`on`:`off`),i.set(`documentsPublished`,n.documentsUnpublished.toString()),i.set(`documentsUnpublished`,n.documentsUnpublished.toString()),i.set(`releasesCreated`,n.documentsUnpublished.toString()),i.set(`releasesUpdated`,n.documentsUnpublished.toString()),i.set(`tagsCreated`,n.documentsUnpublished.toString()),i.set(`documentsPublished`,n.documentsUnpublished.toString()),await Y(r,{method:`POST`,body:i})}function as(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function os(){let{values:{help:t,repo:n=await q()},positionals:[r,i,a]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a custom HTTP header to a webhook.
|
|
1775
2080
|
|
|
1776
2081
|
By default, this command reads the repository from prismic.config.json at the
|
|
1777
2082
|
project root.
|
|
@@ -1789,7 +2094,7 @@ FLAGS
|
|
|
1789
2094
|
-h, --help Show help for command
|
|
1790
2095
|
|
|
1791
2096
|
LEARN MORE
|
|
1792
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: <value>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
2097
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: <value>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ss();return}let o=await $(n);if(!o.ok){o.error instanceof X?ss():(console.error(`Failed to add header: ${K(o.value)}`),process.exitCode=1);return}let s=o.value.find(e=>e.config.url===r);if(!s){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let c=structuredClone(s.config);c.headers[i]=a;let l=await is(n,s.config._id,c);if(!l.ok){l.error instanceof X?ss():(console.error(`Failed to add header: ${K(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function ss(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const cs=Object.values($o);async function ls(){let{values:{help:t,repo:n=await q(),name:r,secret:i,trigger:a=[]},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},secret:{type:`string`,short:`s`},trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new webhook in a Prismic repository.
|
|
1793
2098
|
|
|
1794
2099
|
By default, this command reads the repository from prismic.config.json at the
|
|
1795
2100
|
project root.
|
|
@@ -1818,7 +2123,7 @@ TRIGGERS
|
|
|
1818
2123
|
If no triggers specified, all are enabled.
|
|
1819
2124
|
|
|
1820
2125
|
LEARN MORE
|
|
1821
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}for(let e of a)if(!
|
|
2126
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}for(let e of a)if(!cs.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${cs.join(`, `)}`),process.exitCode=1;return}if(!await M()){ds();return}let s=!(a.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of a){let[t]=Object.entries($o).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await us(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof X?ds():(console.error(`Failed to create webhook: ${K(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function us(e,t){let n=new URL(`/app/settings/webhooks/create`,await j(e)),r=new FormData;return r.set(`url`,t.url),r.set(`name`,t.name??``),r.set(`secret`,t.secret??``),r.set(`headers`,JSON.stringify({})),r.set(`active`,`on`),r.set(`documentsPublished`,t.documentsUnpublished.toString()),r.set(`documentsUnpublished`,t.documentsUnpublished.toString()),r.set(`releasesCreated`,t.documentsUnpublished.toString()),r.set(`releasesUpdated`,t.documentsUnpublished.toString()),r.set(`tagsCreated`,t.documentsUnpublished.toString()),r.set(`documentsPublished`,t.documentsUnpublished.toString()),await Y(n,{method:`POST`,body:r})}function ds(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function fs(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disable a webhook in a Prismic repository.
|
|
1822
2127
|
|
|
1823
2128
|
By default, this command reads the repository from prismic.config.json at the
|
|
1824
2129
|
project root.
|
|
@@ -1834,7 +2139,7 @@ FLAGS
|
|
|
1834
2139
|
-h, --help Show help for command
|
|
1835
2140
|
|
|
1836
2141
|
LEARN MORE
|
|
1837
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
2142
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ps();return}let i=await $(n);if(!i.ok){i.error instanceof X?ps():(console.error(`Failed to disable webhook: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!a.config.active){console.info(`Webhook already disabled: ${r}`);return}let o=structuredClone(a.config);o.active=!1;let s=await is(n,a.config._id,o);if(!s.ok){s.error instanceof X?ps():(console.error(`Failed to disable webhook: ${K(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function ps(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ms(){let{values:{help:t,repo:n=await q(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all webhooks in a Prismic repository.
|
|
1838
2143
|
|
|
1839
2144
|
By default, this command reads the repository from prismic.config.json at the
|
|
1840
2145
|
project root.
|
|
@@ -1848,7 +2153,7 @@ FLAGS
|
|
|
1848
2153
|
-h, --help Show help for command
|
|
1849
2154
|
|
|
1850
2155
|
LEARN MORE
|
|
1851
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
2156
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){hs();return}let i=await $(n);if(!i.ok){i.error instanceof X?hs():I(i.error)?(console.error(`Failed to list webhooks: Invalid response: ${K(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list webhooks: ${K(i.value)}`),process.exitCode=1);return}let a=i.value;if(r)console.info(K(a.map(e=>e.config)));else{if(a.length===0){console.info(`No webhooks configured.`);return}for(let e of a){let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;console.info(`${e.config.url}${n} [${t}]`)}}}function hs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function gs(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a webhook from a Prismic repository.
|
|
1852
2157
|
|
|
1853
2158
|
By default, this command reads the repository from prismic.config.json at the
|
|
1854
2159
|
project root.
|
|
@@ -1864,7 +2169,7 @@ FLAGS
|
|
|
1864
2169
|
-h, --help Show help for command
|
|
1865
2170
|
|
|
1866
2171
|
LEARN MORE
|
|
1867
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
2172
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){vs();return}let i=await $(n);if(!i.ok){i.error instanceof X?vs():(console.error(`Failed to remove webhook: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await _s(n,a.config._id);if(!o.ok){o.error instanceof X?vs():(console.error(`Failed to remove webhook: ${K(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function _s(e,t){return await Y(new URL(`/app/settings/webhooks/${t}/delete`,await j(e)),{method:`POST`})}function vs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ys(){let{values:{help:t,repo:n=await q()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom HTTP header from a webhook.
|
|
1868
2173
|
|
|
1869
2174
|
By default, this command reads the repository from prismic.config.json at the
|
|
1870
2175
|
project root.
|
|
@@ -1881,7 +2186,7 @@ FLAGS
|
|
|
1881
2186
|
-h, --help Show help for command
|
|
1882
2187
|
|
|
1883
2188
|
LEARN MORE
|
|
1884
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
2189
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){bs();return}let a=await $(n);if(!a.ok){a.error instanceof X?bs():(console.error(`Failed to remove header: ${K(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===r);if(!o){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!(i in o.config.headers)){console.error(`Header not found: ${i}`),process.exitCode=1;return}let s=structuredClone(o.config);delete s.headers[i];let c=await is(n,o.config._id,s);if(!c.ok){c.error instanceof X?bs():(console.error(`Failed to remove header: ${K(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function bs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const xs=Object.values($o);async function Ss(){let{values:{help:t,repo:n=await q(),trigger:r},positionals:[i]}=e({args:process.argv.slice(4),options:{trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update which events trigger a webhook.
|
|
1885
2190
|
|
|
1886
2191
|
By default, this command reads the repository from prismic.config.json at the
|
|
1887
2192
|
project root.
|
|
@@ -1906,7 +2211,7 @@ TRIGGERS
|
|
|
1906
2211
|
tag.deleted When a tag is deleted
|
|
1907
2212
|
|
|
1908
2213
|
LEARN MORE
|
|
1909
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!r||r.length===0){console.error(`Missing required option: --trigger`),process.exitCode=1;return}for(let e of r)if(!
|
|
2214
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!r||r.length===0){console.error(`Missing required option: --trigger`),process.exitCode=1;return}for(let e of r)if(!xs.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${xs.join(`, `)}`),process.exitCode=1;return}if(!await M()){Cs();return}let a=await $(n);if(!a.ok){a.error instanceof X?Cs():(console.error(`Failed to update webhook triggers: ${K(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===i);if(!o){console.error(`Webhook not found: ${i}`),process.exitCode=1;return}let s=!(r.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of r){let[t]=Object.entries($o).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await is(n,o.config._id,{...o.config,...c});if(!l.ok){l.error instanceof X?Cs():(console.error(`Failed to update webhook triggers: ${K(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function Cs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ws(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Show the enabled/disabled status of a webhook.
|
|
1910
2215
|
|
|
1911
2216
|
By default, this command reads the repository from prismic.config.json at the
|
|
1912
2217
|
project root.
|
|
@@ -1922,7 +2227,7 @@ FLAGS
|
|
|
1922
2227
|
-h, --help Show help for command
|
|
1923
2228
|
|
|
1924
2229
|
LEARN MORE
|
|
1925
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
2230
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Ts();return}let i=await $(n);if(!i.ok){i.error instanceof X?Ts():(console.error(`Failed to get webhook status: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=a.config.active?`enabled`:`disabled`;console.info(o)}function Ts(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Es(){let{values:{help:t,repo:n=await q()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Trigger a test webhook in a Prismic repository.
|
|
1926
2231
|
|
|
1927
2232
|
By default, this command reads the repository from prismic.config.json at the
|
|
1928
2233
|
project root.
|
|
@@ -1938,7 +2243,7 @@ FLAGS
|
|
|
1938
2243
|
-h, --help Show help for command
|
|
1939
2244
|
|
|
1940
2245
|
LEARN MORE
|
|
1941
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){
|
|
2246
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Os();return}let i=await $(n);if(!i.ok){i.error instanceof X?Os():(console.error(`Failed to test webhook: ${K(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await Ds(n,a.config._id);if(!o.ok){o.error instanceof X?Os():(console.error(`Failed to test webhook: ${K(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function Ds(e,t){return await Y(new URL(`/app/settings/webhooks/${t}/trigger`,await j(e)),{method:`POST`})}function Os(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ks(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await ms();break;case`create`:await ls();break;case`view`:await es();break;case`remove`:await gs();break;case`test`:await Es();break;case`enable`:await rs();break;case`disable`:await fs();break;case`status`:await ws();break;case`add-header`:await os();break;case`remove-header`:await ys();break;case`set-triggers`:await Ss();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
|
|
1942
2247
|
|
|
1943
2248
|
USAGE
|
|
1944
2249
|
prismic webhook <command> [flags]
|
|
@@ -1960,7 +2265,7 @@ FLAGS
|
|
|
1960
2265
|
-h, --help Show help for command
|
|
1961
2266
|
|
|
1962
2267
|
LEARN MORE
|
|
1963
|
-
Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function
|
|
2268
|
+
Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function As(){let{values:{help:t}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t){console.info(`Show the currently logged in user.
|
|
1964
2269
|
|
|
1965
2270
|
USAGE
|
|
1966
2271
|
prismic whoami [flags]
|
|
@@ -1969,7 +2274,7 @@ FLAGS
|
|
|
1969
2274
|
-h, --help Show help for command
|
|
1970
2275
|
|
|
1971
2276
|
LEARN MORE
|
|
1972
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}if(!await M()){
|
|
2277
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}if(!await M()){Ms();return}let n=await js();if(!n.ok){n.error instanceof X?Ms():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function js(){return await Y(new URL(`profile`,await en()),{schema:z({email:H()})})}function Ms(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:Ns}=e({options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(Ns[0]){case`init`:await Yr();break;case`login`:await si();break;case`logout`:await ui();break;case`whoami`:await As();break;case`repo`:await ro();break;case`locale`:await oi();break;case`page-type`:await na();break;case`custom-type`:await Jr();break;case`slice`:await jo();break;case`pull`:await ka();break;case`push`:await Ma();break;case`codegen`:await ir();break;case`preview`:await Oa();break;case`token`:await Qo();break;case`webhook`:await ks();break;default:Ns[0]&&(console.error(`Unknown command: ${Ns[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
|
|
1973
2278
|
|
|
1974
2279
|
USAGE
|
|
1975
2280
|
prismic <command> [flags]
|
|
@@ -1984,7 +2289,9 @@ COMMANDS
|
|
|
1984
2289
|
page-type Manage page types in a repository
|
|
1985
2290
|
custom-type Manage custom types in a repository
|
|
1986
2291
|
slice Manage slices in a project
|
|
1987
|
-
|
|
2292
|
+
pull Pull types and slices from Prismic
|
|
2293
|
+
push Push types and slices to Prismic
|
|
2294
|
+
codegen Generate code from Prismic models
|
|
1988
2295
|
preview Manage preview configurations
|
|
1989
2296
|
token Manage API tokens in a repository
|
|
1990
2297
|
webhook Manage webhooks in a repository
|