@angeloashmore/prismic-cli-poc 0.0.0-canary.e58e691 → 0.0.0-canary.fe51fbb
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 +673 -280
- package/package.json +2 -1
- package/src/codegen-types.ts +82 -0
- package/src/codegen.ts +45 -0
- package/src/custom-type-add-field-boolean.ts +19 -5
- package/src/custom-type-add-field-color.ts +19 -6
- package/src/custom-type-add-field-date.ts +19 -6
- package/src/custom-type-add-field-embed.ts +19 -6
- package/src/custom-type-add-field-geo-point.ts +19 -6
- package/src/custom-type-add-field-image.ts +19 -6
- package/src/custom-type-add-field-key-text.ts +19 -6
- package/src/custom-type-add-field-link.ts +19 -5
- package/src/custom-type-add-field-number.ts +19 -6
- package/src/custom-type-add-field-rich-text.ts +19 -5
- package/src/custom-type-add-field-select.ts +19 -6
- package/src/custom-type-add-field-timestamp.ts +19 -6
- package/src/custom-type-add-field-uid.ts +19 -6
- package/src/custom-type-connect-slice.ts +18 -25
- package/src/custom-type-create.ts +22 -2
- package/src/custom-type-disconnect-slice.ts +18 -26
- package/src/custom-type-remove-field.ts +11 -1
- package/src/custom-type-remove.ts +14 -2
- package/src/custom-type-set-name.ts +11 -1
- package/src/docs.ts +149 -0
- package/src/index.ts +78 -51
- package/src/init.ts +3 -1
- package/src/lib/auth.ts +24 -1
- package/src/lib/custom-types-api.ts +74 -20
- package/src/lib/framework.ts +143 -0
- package/src/lib/slice.ts +5 -2
- package/src/lib/string.ts +6 -0
- package/src/login.ts +18 -9
- package/src/page-type-add-field-boolean.ts +38 -5
- package/src/page-type-add-field-color.ts +38 -6
- package/src/page-type-add-field-date.ts +38 -6
- package/src/page-type-add-field-embed.ts +38 -6
- package/src/page-type-add-field-geo-point.ts +38 -6
- package/src/page-type-add-field-image.ts +38 -6
- package/src/page-type-add-field-key-text.ts +38 -6
- package/src/page-type-add-field-link.ts +38 -5
- package/src/page-type-add-field-number.ts +38 -6
- package/src/page-type-add-field-rich-text.ts +38 -5
- package/src/page-type-add-field-select.ts +38 -6
- package/src/page-type-add-field-timestamp.ts +38 -6
- package/src/page-type-add-field-uid.ts +38 -6
- package/src/page-type-connect-slice.ts +18 -25
- package/src/page-type-create.ts +71 -3
- package/src/page-type-disconnect-slice.ts +18 -26
- package/src/page-type-remove-field.ts +11 -1
- package/src/page-type-remove.ts +14 -2
- package/src/page-type-set-name.ts +11 -1
- package/src/page-type-set-repeatable.ts +11 -1
- package/src/preview-get-simulator.ts +104 -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/pull.ts +36 -6
- package/src/push.ts +35 -11
- package/src/repo-create.ts +32 -0
- package/src/repo-get-access.ts +86 -0
- package/src/repo-set-access.ts +100 -0
- package/src/repo.ts +10 -0
- package/src/slice-add-field-boolean.ts +49 -2
- package/src/slice-add-field-color.ts +49 -3
- package/src/slice-add-field-date.ts +49 -3
- package/src/slice-add-field-embed.ts +49 -3
- package/src/slice-add-field-geo-point.ts +49 -3
- package/src/slice-add-field-image.ts +49 -3
- package/src/slice-add-field-key-text.ts +49 -3
- package/src/slice-add-field-link.ts +49 -2
- package/src/slice-add-field-number.ts +49 -3
- package/src/slice-add-field-rich-text.ts +49 -2
- package/src/slice-add-field-select.ts +49 -3
- package/src/slice-add-field-timestamp.ts +49 -3
- package/src/slice-add-variation.ts +15 -13
- package/src/slice-create.ts +78 -4
- package/src/slice-remove-field.ts +14 -9
- package/src/slice-remove-variation.ts +14 -10
- package/src/slice-remove.ts +11 -1
- package/src/slice-rename.ts +11 -1
- package/src/slice-set-screenshot.ts +235 -0
- package/src/slice-view.ts +3 -0
- package/src/slice.ts +5 -0
- package/src/status.ts +873 -0
- package/src/token-create.ts +23 -5
- package/src/token-delete.ts +29 -8
- package/src/token-list.ts +14 -3
- package/src/token-set-name.ts +38 -10
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,196 @@
|
|
|
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{createHash as l}from"node:crypto";import{homedir as u}from"node:os";import{pathToFileURL as d}from"node:url";import{exec as f}from"node:child_process";import{createServer as p}from"node:http";import{extname as m}from"node:path";var h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.prototype.hasOwnProperty,y=(e,t)=>()=>(e&&(t=e(e=0)),t),b=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),x=(e,t)=>{let n={};for(var r in e)h(n,r,{get:e[r],enumerable:!0});return t&&h(n,Symbol.toStringTag,{value:`Module`}),n},ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&h(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e},te=e=>v.call(e,`module.exports`)?e[`module.exports`]:ee(h({},`__esModule`,{value:!0}),e),ne=`0.0.0-canary.fe51fbb`,re=b(((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})),S=b(((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})),C=b(((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})),w=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(C());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ie=b(((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})),ae=b(((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})),oe=b(((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})),se=b(((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})),ce=b(((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})),le=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ce());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ue=b(((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})),de=b(((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=b(((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=b(((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})),pe=b(((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})),me=b(((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})),he=b(((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})),ge=b(((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=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(ae()),i=o(T()),a=o(w());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})),ve=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(_e());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ye=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(ae()),i=o(T()),a=o(w());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})),be=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ye());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),xe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(ae()),i=o(T()),a=o(w());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})),Se=b(((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=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(S()),r=c(ae()),i=c(T()),a=c(w()),o=c(me()),s=c(ge());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})),we=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ce());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Te=b(((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=b(((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})),De=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(S()),r=c(ae()),i=c(T()),a=c(w()),o=c(me()),s=c(le());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})),Oe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(De());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ke=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(S()),r=a(w()),i=a(se());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})),Ae=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ke());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),je=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(S()),r=a(w()),i=a(se());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})),Me=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(je());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ne=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(T()),i=o(w()),a=o(se());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})),Pe=b(((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})),Fe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(T()),i=o(w()),a=o(se());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})),Ie=b(((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})),Le=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(T()),i=o(w()),a=o(se());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})),Re=b(((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})),ze=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(ae()),i=o(T()),a=o(w());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})),Be=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ze());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ve=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(T()),i=o(w()),a=o(se());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})),He=b(((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})),Ue=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(S()),r=a(ae()),i=a(w());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,i.default),t.exports=e.default})),We=b(((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})),Ge=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(S()),r=a(ae()),i=a(w());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})),Ke=b(((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})),E=b((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=C(S()),n=C(w()),r=C(ae()),i=C(se()),a=C(le()),o=C(de()),s=C(T()),c=C(me()),l=C(ge()),u=C(ve()),d=C(be()),f=C(Se()),p=C(we()),m=C(Te()),h=C(Ee()),g=C(Oe()),_=C(Ae()),v=C(Me()),y=C(Pe()),b=C(Ie()),x=C(Re()),ee=C(Be()),te=C(He()),ne=C(We()),re=C(Ke());function C(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=b.default,e.oneLineCommaListsAnd=x.default,e.inlineLists=ee.default,e.oneLineInlineLists=te.default,e.stripIndent=ne.default,e.stripIndents=re.default}))(),qe=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 Je(e,t){return(!e||e.endsWith(`
|
|
5
|
+
`))&&!t?.force?e:e+`
|
|
6
|
+
`}function D(e,t){return Je(t)+e}function Ye(e,t){return(!e||e.endsWith(`
|
|
7
|
+
|
|
8
|
+
`))&&!t?.force?e:Je(e)+`
|
|
9
|
+
`}function O(e,t){return Ye(t)+e}const Xe=`https://prismic.io/docs/slices`,Ze={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 Qe=x({__addDisposableResource:()=>Et,__assign:()=>At,__asyncDelegator:()=>vt,__asyncGenerator:()=>_t,__asyncValues:()=>yt,__await:()=>gt,__awaiter:()=>ct,__classPrivateFieldGet:()=>Ct,__classPrivateFieldIn:()=>Tt,__classPrivateFieldSet:()=>wt,__createBinding:()=>jt,__decorate:()=>tt,__disposeResources:()=>Dt,__esDecorate:()=>rt,__exportStar:()=>ut,__extends:()=>$e,__generator:()=>lt,__importDefault:()=>St,__importStar:()=>xt,__makeTemplateObject:()=>bt,__metadata:()=>st,__param:()=>nt,__propKey:()=>at,__read:()=>ft,__rest:()=>et,__rewriteRelativeImportExtension:()=>Ot,__runInitializers:()=>it,__setFunctionName:()=>ot,__spread:()=>pt,__spreadArray:()=>ht,__spreadArrays:()=>mt,__values:()=>dt,default:()=>Ft});function $e(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);kt(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function et(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 tt(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 nt(e,t){return function(n,r){t(n,r,e)}}function rt(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 it(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 at(e){return typeof e==`symbol`?e:`${e}`}function ot(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,`name`,{configurable:!0,value:n?`${n} ${t}`:t})}function st(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function ct(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 lt(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 ut(e,t){for(var n in e)n!==`default`&&!Object.prototype.hasOwnProperty.call(t,n)&&jt(t,e,n)}function dt(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 ft(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 pt(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ft(arguments[t]));return e}function mt(){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 ht(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 gt(e){return this instanceof gt?(this.v=e,this):new gt(e)}function _t(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 gt?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 vt(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:gt(e[r](t)),done:!1}:i?i(t):t}:i}}function yt(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof dt==`function`?dt(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 bt(e,t){return Object.defineProperty?Object.defineProperty(e,`raw`,{value:t}):e.raw=t,e}function xt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=Nt(e),r=0;r<n.length;r++)n[r]!==`default`&&jt(t,e,n[r]);return Mt(t,e),t}function St(e){return e&&e.__esModule?e:{default:e}}function Ct(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 wt(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 Tt(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 Et(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 Dt(e){function t(t){e.error=e.hasError?new Pt(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 Ot(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 kt,At,jt,Mt,Nt,Pt,Ft,It=y((()=>{kt=function(e,t){return kt=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])},kt(e,t)},At=function(){return At=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},At.apply(this,arguments)},jt=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]}),Mt=Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t},Nt=function(e){return Nt=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Nt(e)},Pt=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},Ft={__extends:$e,__assign:At,__rest:et,__decorate:tt,__param:nt,__esDecorate:rt,__runInitializers:it,__propKey:at,__setFunctionName:ot,__metadata:st,__awaiter:ct,__generator:lt,__createBinding:jt,__exportStar:ut,__values:dt,__read:ft,__spread:pt,__spreadArrays:mt,__spreadArray:ht,__await:gt,__asyncGenerator:_t,__asyncDelegator:vt,__asyncValues:yt,__makeTemplateObject:bt,__importStar:xt,__importDefault:St,__classPrivateFieldGet:Ct,__classPrivateFieldSet:wt,__classPrivateFieldIn:Tt,__addDisposableResource:Et,__disposeResources:Dt,__rewriteRelativeImportExtension:Ot}})),Lt=b((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})),Rt=b((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.noCase=void 0;var t=Lt(),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)}})),zt=b((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.pascalCase=e.pascalCaseTransformMerge=e.pascalCaseTransform=void 0;var t=(It(),te(Qe)),n=Rt();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,zt.pascalCase)(e.filter(Boolean).join(` `),{transform:zt.pascalCaseTransformMerge});return/^[0-9]/.test(t)&&(t=`_${t}`),t},Bt={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 Vt(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 Ht=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 Ut(e){return e.path.map(e=>e.label?e.label:e.model?Ht({model:e.model,name:e.name}):e.name).join(` → `)}function Wt(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 Gt(e){switch(e.field.type){case`Link`:{let t=Ze.Link;switch(e.field.config?.select){case`document`:return t.contentRelationship;case`media`:return t.linkToMedia;default:return t.link}}default:{let t=Ze[e.field.type];if(typeof t==`string`)return t}}}function Kt(e){let t=`/**`,n=Ht({model:e.field,name:e.name}),r=Ut({path:e.path}),i=Wt({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**: ${Vt({path:[...e.path,{name:e.name,model:e.field}]})}`,t),e.tabName&&(t=D(` * - **Tab**: ${e.tabName}`,t));let o=Gt({field:e.field});return o&&(t=D(` * - **Documentation**: ${o}`,t)),t=D(` */`,t),t}function qt(e){return e.filter(Boolean).join(` | `)||`never`}function Jt(e){let t=Kt({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=qt(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<${qt(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}: ${qt(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?qt(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===Bt.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=Ut({path:c}),u=Yt({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=Ut({path:a}),l=Yt({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=Ut({path:a}),l=Yt({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 *${Ut({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=qt(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 Yt(e){let t=``,n=[],r=[];for(let i in e.fields){let a=e.fields[i],o=Jt({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 Xt(e){let t=``,n=[],r=[],i=k(e.model.id,`Document`,`Data`),a=Ht({name:e.model.id,model:e.model}),o=``;for(let t in e.model.json){let{uid:i,...a}=e.model.json[t],s=Yt({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 Zt(e){return`uid`in Object.assign({},...Object.values(e.json))}const Qt=e=>c.createHash(`sha1`).update(JSON.stringify(e)).digest(`hex`);function $t(e){if(e.cache){let t=Qt(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?qt(e.localeIDs.map(e=>`"${e}"`)):`string`,o=Zt(e.model)?`PrismicDocumentWithUID`:`PrismicDocumentWithoutUID`,s=Ht({name:e.model.id,model:e.model}),c=Xt({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=Qt(e.model);e.cache.set(t,l)}return l}function en(e){if(e.cache){let t=Qt([e.model,e.fieldConfigs]),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=k(e.model.id,`Slice`),a=Ht({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=Ut({path:i}),o=Yt({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=Ut({path:i}),o=Yt({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**: ${Xe}
|
|
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=qt(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**: ${Xe}
|
|
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=Qt([e.model,e.fieldConfigs]);e.cache.set(t,l)}return l}const tn=new qe({maxSize:1e3});function nn(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=$t({model:a,localeIDs:e.localeIDs,fieldConfigs:t,cache:n?tn: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} = ${qt(i)};`,r),o.push(e)}}if(e.sharedSliceModels)for(let i of e.sharedSliceModels){let e=en({model:i,fieldConfigs:t,cache:n?tn: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}function rn(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function an(e){return(void 0)?.get(e)}function on(e){return(void 0)?.get(e)}function sn(e,t){return(void 0)?.get(e)?.get(t)}function cn(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 ln(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??cn(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??sn(e.reference,c.lang)??(l?on(c.lang):null)??r.message??an(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 A(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},rn())}}}function un(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function j(e){return e instanceof dn}var dn=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function fn(e){return{kind:`validation`,type:`url`,reference:fn,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)&&ln(this,`URL`,e,t),e}}}function pn(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function mn(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function M(e,t){return{kind:`schema`,type:`array`,reference:M,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return A(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 ln(this,`type`,e,t);return e}}}function N(e){return{kind:`schema`,type:`boolean`,reference:N,expects:`boolean`,async:!1,message:e,get"~standard"(){return A(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:ln(this,`type`,e,t),e}}}function hn(e,t){return{kind:`schema`,type:`literal`,reference:hn,expects:cn(e),async:!1,literal:e,message:t,get"~standard"(){return A(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:ln(this,`type`,e,t),e}}}function gn(e,t){return{kind:`schema`,type:`nullable`,reference:gn,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return A(this)},"~run"(e,t){return e.value===null&&(this.default!==void 0&&(e.value=mn(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function _n(e){return{kind:`schema`,type:`number`,reference:_n,expects:`number`,async:!1,message:e,get"~standard"(){return A(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:ln(this,`type`,e,t),e}}}function P(e,t){return{kind:`schema`,type:`object`,reference:P,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return A(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]:mn(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]=pn(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(ln(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 ln(this,`type`,e,t);return e}}}function F(e,t){return{kind:`schema`,type:`optional`,reference:F,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return A(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=mn(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function I(e,t,n){return{kind:`schema`,type:`record`,reference:I,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return A(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},n)if(un(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 ln(this,`type`,e,t);return e}}}function L(e){return{kind:`schema`,type:`string`,reference:L,expects:`string`,async:!1,message:e,get"~standard"(){return A(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:ln(this,`type`,e,t),e}}}function R(){return{kind:`schema`,type:`unknown`,reference:R,expects:`unknown`,async:!1,get"~standard"(){return A(this)},"~run"(e){return e.typed=!0,e}}}function vn(e,t,n){let r=e[`~run`]({value:t},rn(n));if(r.issues)throw new dn(r.issues);return r.value}function yn(...e){return{...e[0],pipe:e,get"~standard"(){return A(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 z(e,t,n){let r=e[`~run`]({value:t},rn(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}async function B(e){let t=await En();return t.hostname=`${e}.${t.hostname}`,Sn(t)}async function bn(){let e=await En();return e.hostname=`api.internal.${e.hostname}`,Sn(e)}async function xn(){let e=await En();return e.hostname=`user-service.${e.hostname}`,Sn(e)}function Sn(e){let t=new URL(e);return t.pathname.endsWith(`/`)||(t.pathname+=`/`),t}const Cn=new URL(`.prismic`,Sn(d(u()))),wn=`https://prismic.io`;async function Tn(e,t){let n={token:e,host:t?.host};await s(Cn,JSON.stringify(n,null,2))}async function V(){let e=await H();if(!e)return!1;try{let t=await En();t.hostname=`user-service.${t.hostname}`;let n=new URL(`profile`,t);return(await fetch(n,{headers:{Accept:`application/json`,Cookie:`SESSION=fake_session; prismic-auth=${e}`}})).ok?!0:(await On(),!1)}catch{return!1}}async function H(){return(await Dn())?.token}async function En(){try{let e=await Dn();return e?.host?new URL(e.host):new URL(wn)}catch{return new URL(wn)}}async function Dn(){try{let e=await r(Cn,`utf-8`);return JSON.parse(e)}catch{return}}async function On(){try{await t(Cn)}catch{return!0}return await Dn()?(await o(Cn),!0):!1}async function U(e,n={}){let{start:r=d(process.cwd()),stop:i}=n,a=Sn(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 kn(e){try{return await t(e),!0}catch{return!1}}const An=P({id:L(),type:hn(`SharedSlice`),name:L(),description:F(L()),variations:M(P({id:L(),name:L(),description:F(L()),docURL:F(L()),version:F(L()),imageUrl:F(L()),primary:F(I(L(),R())),items:F(I(L(),R()))}))});async function W(e){if(!await U(`package.json`))return{ok:!1,error:`Could not find project root (no package.json found)`};let t=await jn(),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=z(An,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 jn(){let e=await Nn(),t=await U(`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 kn(new URL(`src`,n)))return new URL(`src/slices/`,n);case`nuxt`:if(await kn(new URL(`app`,n)))return new URL(`app/slices/`,n);case`sveltekit`:return new URL(`src/slices/`,n)}return new URL(`slices/`,n)}const Mn=P({dependencies:F(I(L(),L()))});async function Nn(){let e=await U(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=vn(Mn,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function Pn(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Fn=P({id:L(),label:F(L()),repeatable:N(),status:N(),format:F(L()),json:I(L(),R())});async function In(){let e=await En();return e.hostname=`customtypes.${e.hostname}`,e}async function Ln(e){let t=await H();if(!t)return{ok:!1,error:`Not authenticated`};let n=await In(),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=z(M(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 Rn(e){let t=await H();if(!t)return{ok:!1,error:`Not authenticated`};let n=await In(),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=z(M(An),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 zn(){let e=await U(`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=z(Fn,JSON.parse(e));n.success&&o.push(n.output)}catch{}}return{ok:!0,value:o}}async function Bn(){let e;try{e=await jn()}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=z(An,JSON.parse(e));i.success&&n.push(i.output)}catch{}}return{ok:!0,value:n}}async function Vn(e,t){let n=await H();if(!n)return{ok:!1,error:`Not authenticated`};let r=await In(),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 Hn(e,t){let n=await H();if(!n)return{ok:!1,error:`Not authenticated`};let r=await In(),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 Un(e,t){let n=await H();if(!n)return{ok:!1,error:`Not authenticated`};let r=await In(),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 Wn(e,t){let n=await H();if(!n)return{ok:!1,error:`Not authenticated`};let r=await In(),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 Gn(e,t){let n=await H();if(!n)return{ok:!1,error:`Not authenticated`};let r=await In(),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 Kn(e,t){let n=await H();if(!n)return{ok:!1,error:`Not authenticated`};let r=await In(),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 qn(){let{values:{help:t,output:n}}=e({args:process.argv.slice(4),options:{output:{type:`string`,short:`o`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Generate TypeScript types from local custom type and slice models.
|
|
169
|
+
|
|
170
|
+
USAGE
|
|
171
|
+
prismic codegen types [flags]
|
|
172
|
+
|
|
173
|
+
FLAGS
|
|
174
|
+
-o, --output string Output file path (default: "prismicio-types.d.ts")
|
|
175
|
+
-h, --help Show help for command
|
|
176
|
+
|
|
177
|
+
EXAMPLES
|
|
178
|
+
prismic codegen types
|
|
179
|
+
prismic codegen types --output custom.d.ts`);return}try{await G({output:n}),console.info(`Generated types written to ${n??`prismicio-types.d.ts`}`)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function G(e){let t=e?.output??`prismicio-types.d.ts`,[n,r]=await Promise.all([zn(),Bn()]);if(!n.ok)throw Error(`failed to read local custom types: ${n.error}`);if(!r.ok)throw Error(`failed to read local slices: ${r.error}`);let i=n.value,a=r.value;await s(t,`// Code generated by prismic-ts-codegen. DO NOT EDIT.
|
|
180
|
+
|
|
181
|
+
`+nn({customTypeModels:i,sharedSliceModels:a,typesProvider:`@prismicio/client`,clientIntegration:{includeCreateClientInterface:i.length>0||a.length>0,includeContentNamespace:!0}}))}async function Jn(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`types`:await qn();break;default:t&&(console.error(`Unknown codegen subcommand: ${t}\n`),process.exitCode=1),console.info(`Generate code from Prismic models.
|
|
182
|
+
|
|
183
|
+
USAGE
|
|
184
|
+
prismic codegen <command> [flags]
|
|
185
|
+
|
|
186
|
+
COMMANDS
|
|
187
|
+
types Generate TypeScript types from models pushed to Prismic
|
|
188
|
+
|
|
189
|
+
FLAGS
|
|
190
|
+
-h, --help Show help for command
|
|
191
|
+
|
|
192
|
+
LEARN MORE
|
|
193
|
+
Use \`prismic codegen <command> --help\` for more information about a command.`)}}function K(e){return JSON.stringify(e,null,2)}function q(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}const Yn=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function Xn(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c,types:l},positionals:[u,d]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing custom type.
|
|
3
194
|
|
|
4
195
|
USAGE
|
|
5
196
|
prismic custom-type add-field boolean <type-id> <field-id> [flags]
|
|
@@ -10,18 +201,19 @@ ARGUMENTS
|
|
|
10
201
|
|
|
11
202
|
FLAGS
|
|
12
203
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
13
|
-
-l, --label string Display label for the field
|
|
204
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
14
205
|
--default Set default value to true
|
|
15
206
|
--true-label string Label shown when toggle is on
|
|
16
207
|
--false-label string Label shown when toggle is off
|
|
208
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
17
209
|
-h, --help Show help for command
|
|
18
210
|
|
|
19
211
|
EXAMPLES
|
|
20
212
|
prismic custom-type add-field boolean homepage featured
|
|
21
213
|
prismic custom-type add-field boolean article published --default
|
|
22
|
-
prismic custom-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!
|
|
23
|
-
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
24
|
-
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let
|
|
214
|
+
prismic custom-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!u){console.error(`Missing required argument: type-id
|
|
215
|
+
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
216
|
+
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let f=await U(`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=z(Yn,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:`Boolean`,config:{label:i??q(d),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};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}" (Boolean) to "${g}" tab in ${u}`);try{await G({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Zn=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function Qn(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing custom type.
|
|
25
217
|
|
|
26
218
|
USAGE
|
|
27
219
|
prismic custom-type add-field color <type-id> <field-id> [flags]
|
|
@@ -32,16 +224,17 @@ ARGUMENTS
|
|
|
32
224
|
|
|
33
225
|
FLAGS
|
|
34
226
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
35
|
-
-l, --label string Display label for the field
|
|
227
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
36
228
|
-p, --placeholder string Placeholder text
|
|
229
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
37
230
|
-h, --help Show help for command
|
|
38
231
|
|
|
39
232
|
EXAMPLES
|
|
40
233
|
prismic custom-type add-field color homepage bg_color
|
|
41
234
|
prismic custom-type add-field color homepage accent --tab "Design"
|
|
42
|
-
prismic custom-type add-field color homepage text_color --label "Text Color"`);return}if(!
|
|
43
|
-
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
44
|
-
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let
|
|
235
|
+
prismic custom-type add-field color homepage text_color --label "Text Color"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
236
|
+
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
237
|
+
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let u=await U(`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=z(Zn,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:`Color`,config:{label:i??q(l),...a&&{placeholder:a}}};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}" (Color) to "${m}" tab in ${c}`);try{await G({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const $n=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function er(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types: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`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing custom type.
|
|
45
238
|
|
|
46
239
|
USAGE
|
|
47
240
|
prismic custom-type add-field date <type-id> <field-id> [flags]
|
|
@@ -52,17 +245,18 @@ ARGUMENTS
|
|
|
52
245
|
|
|
53
246
|
FLAGS
|
|
54
247
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
55
|
-
-l, --label string Display label for the field
|
|
248
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
56
249
|
-p, --placeholder string Placeholder text
|
|
57
250
|
--default string Default date value (YYYY-MM-DD format)
|
|
251
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
58
252
|
-h, --help Show help for command
|
|
59
253
|
|
|
60
254
|
EXAMPLES
|
|
61
255
|
prismic custom-type add-field date homepage publish_date
|
|
62
256
|
prismic custom-type add-field date event start_date --tab "Schedule"
|
|
63
|
-
prismic custom-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!
|
|
64
|
-
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
65
|
-
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let
|
|
257
|
+
prismic custom-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
258
|
+
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
259
|
+
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let d=await U(`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=z($n,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:`Date`,config:{label:i??q(u),...a&&{placeholder:a},...o&&{default:o}}};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}" (Date) to "${h}" tab in ${l}`);try{await G({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const tr=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function nr(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing custom type.
|
|
66
260
|
|
|
67
261
|
USAGE
|
|
68
262
|
prismic custom-type add-field embed <type-id> <field-id> [flags]
|
|
@@ -73,16 +267,17 @@ ARGUMENTS
|
|
|
73
267
|
|
|
74
268
|
FLAGS
|
|
75
269
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
76
|
-
-l, --label string Display label for the field
|
|
270
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
77
271
|
-p, --placeholder string Placeholder text
|
|
272
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
78
273
|
-h, --help Show help for command
|
|
79
274
|
|
|
80
275
|
EXAMPLES
|
|
81
276
|
prismic custom-type add-field embed homepage video
|
|
82
277
|
prismic custom-type add-field embed homepage youtube --tab "Media"
|
|
83
|
-
prismic custom-type add-field embed homepage media --label "Media Embed"`);return}if(!
|
|
84
|
-
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
85
|
-
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let
|
|
278
|
+
prismic custom-type add-field embed homepage media --label "Media Embed"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
279
|
+
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
280
|
+
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let u=await U(`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=z(tr,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:`Embed`,config:{label:i??q(l),...a&&{placeholder:a}}};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}" (Embed) to "${m}" tab in ${c}`);try{await G({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const rr=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function ir(){let{values:{help:t,tab:n,label:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing custom type.
|
|
86
281
|
|
|
87
282
|
USAGE
|
|
88
283
|
prismic custom-type add-field geo-point <type-id> <field-id> [flags]
|
|
@@ -93,15 +288,16 @@ ARGUMENTS
|
|
|
93
288
|
|
|
94
289
|
FLAGS
|
|
95
290
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
96
|
-
-l, --label string Display label for the field
|
|
291
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
292
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
97
293
|
-h, --help Show help for command
|
|
98
294
|
|
|
99
295
|
EXAMPLES
|
|
100
296
|
prismic custom-type add-field geo-point homepage location
|
|
101
297
|
prismic custom-type add-field geo-point store address --tab "Details"
|
|
102
|
-
prismic custom-type add-field geo-point event venue --label "Event Venue"`);return}if(!
|
|
103
|
-
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
104
|
-
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let
|
|
298
|
+
prismic custom-type add-field geo-point event venue --label "Event Venue"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
299
|
+
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
300
|
+
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let l=await U(`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=z(rr,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:`GeoPoint`,config:{label:i??q(c)}};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}" (GeoPoint) to "${p}" tab in ${o}`);try{await G({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const ar=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function or(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing custom type.
|
|
105
301
|
|
|
106
302
|
USAGE
|
|
107
303
|
prismic custom-type add-field image <type-id> <field-id> [flags]
|
|
@@ -112,16 +308,17 @@ ARGUMENTS
|
|
|
112
308
|
|
|
113
309
|
FLAGS
|
|
114
310
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
115
|
-
-l, --label string Display label for the field
|
|
311
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
116
312
|
-p, --placeholder string Placeholder text
|
|
313
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
117
314
|
-h, --help Show help for command
|
|
118
315
|
|
|
119
316
|
EXAMPLES
|
|
120
317
|
prismic custom-type add-field image homepage hero
|
|
121
318
|
prismic custom-type add-field image article thumbnail --tab "Media"
|
|
122
|
-
prismic custom-type add-field image product photo --label "Product Photo"`);return}if(!
|
|
123
|
-
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
124
|
-
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let
|
|
319
|
+
prismic custom-type add-field image product photo --label "Product Photo"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
320
|
+
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
321
|
+
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let u=await U(`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=z(ar,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:`Image`,config:{label:i??q(l),...a&&{placeholder:a}}};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}" (Image) to "${m}" tab in ${c}`);try{await G({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const sr=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function cr(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},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
322
|
|
|
126
323
|
USAGE
|
|
127
324
|
prismic custom-type add-field key-text <type-id> <field-id> [flags]
|
|
@@ -132,16 +329,17 @@ ARGUMENTS
|
|
|
132
329
|
|
|
133
330
|
FLAGS
|
|
134
331
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
135
|
-
-l, --label string Display label for the field
|
|
332
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
136
333
|
-p, --placeholder string Placeholder text
|
|
334
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
137
335
|
-h, --help Show help for command
|
|
138
336
|
|
|
139
337
|
EXAMPLES
|
|
140
338
|
prismic custom-type add-field key-text homepage title
|
|
141
339
|
prismic custom-type add-field key-text homepage meta_title --tab "SEO"
|
|
142
|
-
prismic custom-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!
|
|
143
|
-
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
144
|
-
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let
|
|
340
|
+
prismic custom-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
341
|
+
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
342
|
+
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let u=await U(`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=z(sr,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:`Text`,config:{label:i??q(l),...a&&{placeholder:a}}};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}" (Text) to "${m}" tab in ${c}`);try{await G({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const lr=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function ur(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u,types:d},positionals:[f,p]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing custom type.
|
|
145
343
|
|
|
146
344
|
USAGE
|
|
147
345
|
prismic custom-type add-field link <type-id> <field-id> [flags]
|
|
@@ -152,21 +350,22 @@ ARGUMENTS
|
|
|
152
350
|
|
|
153
351
|
FLAGS
|
|
154
352
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
155
|
-
-l, --label string Display label for the field
|
|
353
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
156
354
|
-p, --placeholder string Placeholder text
|
|
157
355
|
--variation string Slice variations (can be used multiple times)
|
|
158
356
|
--allow-text Allow text with link
|
|
159
357
|
--allow-target-blank Allow opening link in new tab
|
|
160
358
|
--repeatable Allow multiple links
|
|
359
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
161
360
|
-h, --help Show help for command
|
|
162
361
|
|
|
163
362
|
EXAMPLES
|
|
164
363
|
prismic custom-type add-field link homepage button
|
|
165
364
|
prismic custom-type add-field link homepage cta --allow-text
|
|
166
365
|
prismic custom-type add-field link homepage cta --variation Primary --variation Secondary
|
|
167
|
-
prismic custom-type add-field link homepage links --repeatable`);return}if(!
|
|
168
|
-
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
169
|
-
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let
|
|
366
|
+
prismic custom-type add-field link homepage links --repeatable`);return}if(!f){console.error(`Missing required argument: type-id
|
|
367
|
+
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!p){console.error(`Missing required argument: field-id
|
|
368
|
+
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let m=await U(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${f}/index.json`,m),g;try{let e=await r(h,`utf8`),t=z(lr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${f}\n`),console.error(`Create it first with: prismic custom-type create ${f}`),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 _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});for(let[e,t]of Object.entries(g.json))if(t[p]){console.error(`Field "${p}" already exists in tab "${e}"`),process.exitCode=1;return}let y={type:`Link`,config:{label:i??q(p),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};g.json[v][p]=y;try{await s(h,K(g))}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 "${p}" (Link) to "${v}" tab in ${f}`);try{await G({output:d}),console.info(`Updated types in ${d??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const dr=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function fr(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l,types: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`},min:{type:`string`},max:{type:`string`},step:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing custom type.
|
|
170
369
|
|
|
171
370
|
USAGE
|
|
172
371
|
prismic custom-type add-field number <type-id> <field-id> [flags]
|
|
@@ -177,19 +376,20 @@ ARGUMENTS
|
|
|
177
376
|
|
|
178
377
|
FLAGS
|
|
179
378
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
180
|
-
-l, --label string Display label for the field
|
|
379
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
181
380
|
-p, --placeholder string Placeholder text
|
|
182
381
|
--min number Minimum value
|
|
183
382
|
--max number Maximum value
|
|
184
383
|
--step number Step increment
|
|
384
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
185
385
|
-h, --help Show help for command
|
|
186
386
|
|
|
187
387
|
EXAMPLES
|
|
188
388
|
prismic custom-type add-field number homepage price
|
|
189
389
|
prismic custom-type add-field number product quantity --min 0 --max 100
|
|
190
|
-
prismic custom-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!
|
|
191
|
-
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
192
|
-
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let
|
|
390
|
+
prismic custom-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!d){console.error(`Missing required argument: type-id
|
|
391
|
+
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
392
|
+
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let p=o===void 0?void 0:Number(o),m=c===void 0?void 0:Number(c),h=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(p)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(m)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(h)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let g=await U(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`customtypes/${d}/index.json`,g),v;try{let e=await r(_,`utf8`),t=z(dr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${_.href}`),process.exitCode=1;return}v=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 y=Object.keys(v.json),b=n??y[0]??`Main`;v.json[b]||(v.json[b]={});for(let[e,t]of Object.entries(v.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let x={type:`Number`,config:{label:i??q(f),...a&&{placeholder:a},...p!==void 0&&{min:p},...m!==void 0&&{max:m},...h!==void 0&&{step:h}}};v.json[b][f]=x;try{await s(_,K(v))}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}" (Number) to "${b}" tab in ${d}`);try{await G({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const pr=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function mr(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l,types: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`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing custom type.
|
|
193
393
|
|
|
194
394
|
USAGE
|
|
195
395
|
prismic custom-type add-field rich-text <type-id> <field-id> [flags]
|
|
@@ -200,11 +400,12 @@ ARGUMENTS
|
|
|
200
400
|
|
|
201
401
|
FLAGS
|
|
202
402
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
203
|
-
-l, --label string Display label for the field
|
|
403
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
204
404
|
-p, --placeholder string Placeholder text
|
|
205
405
|
--single string Allowed block types for single-line (comma-separated)
|
|
206
406
|
--multi string Allowed block types for multi-line (comma-separated)
|
|
207
407
|
--allow-target-blank Allow opening links in new tab
|
|
408
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
208
409
|
-h, --help Show help for command
|
|
209
410
|
|
|
210
411
|
BLOCK TYPES
|
|
@@ -216,9 +417,9 @@ EXAMPLES
|
|
|
216
417
|
prismic custom-type add-field rich-text homepage body
|
|
217
418
|
prismic custom-type add-field rich-text article content --multi "paragraph,heading2,heading3,strong,em,hyperlink"
|
|
218
419
|
prismic custom-type add-field rich-text page tagline --single "heading1"
|
|
219
|
-
prismic custom-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!
|
|
220
|
-
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
221
|
-
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let
|
|
420
|
+
prismic custom-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!d){console.error(`Missing required argument: type-id
|
|
421
|
+
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
422
|
+
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let p=await U(`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=z(pr,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:`StructuredText`,config:{label:i??q(f),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!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}" (StructuredText) to "${_}" tab in ${d}`);try{await G({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const hr=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function gr(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c,types: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`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing custom type.
|
|
222
423
|
|
|
223
424
|
USAGE
|
|
224
425
|
prismic custom-type add-field select <type-id> <field-id> [flags]
|
|
@@ -229,18 +430,19 @@ ARGUMENTS
|
|
|
229
430
|
|
|
230
431
|
FLAGS
|
|
231
432
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
232
|
-
-l, --label string Display label for the field
|
|
433
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
233
434
|
-p, --placeholder string Placeholder text
|
|
234
435
|
--option string Add an option (can be used multiple times)
|
|
235
436
|
--default string Default selected value
|
|
437
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
236
438
|
-h, --help Show help for command
|
|
237
439
|
|
|
238
440
|
EXAMPLES
|
|
239
441
|
prismic custom-type add-field select homepage layout --option "full" --option "sidebar"
|
|
240
442
|
prismic custom-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
|
|
241
|
-
prismic custom-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!
|
|
242
|
-
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
243
|
-
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let
|
|
443
|
+
prismic custom-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!u){console.error(`Missing required argument: type-id
|
|
444
|
+
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
445
|
+
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let f=await U(`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=z(hr,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:`Select`,config:{label:i??q(d),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};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}" (Select) to "${g}" tab in ${u}`);try{await G({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const _r=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function vr(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types: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`},default:{type:`string`},types:{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
446
|
|
|
245
447
|
USAGE
|
|
246
448
|
prismic custom-type add-field timestamp <type-id> <field-id> [flags]
|
|
@@ -251,17 +453,18 @@ ARGUMENTS
|
|
|
251
453
|
|
|
252
454
|
FLAGS
|
|
253
455
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
254
|
-
-l, --label string Display label for the field
|
|
456
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
255
457
|
-p, --placeholder string Placeholder text
|
|
256
458
|
--default string Default timestamp value (ISO 8601 format)
|
|
459
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
257
460
|
-h, --help Show help for command
|
|
258
461
|
|
|
259
462
|
EXAMPLES
|
|
260
463
|
prismic custom-type add-field timestamp homepage event_time
|
|
261
464
|
prismic custom-type add-field timestamp event start --tab "Schedule"
|
|
262
|
-
prismic custom-type add-field timestamp article published_at --label "Published At"`);return}if(!
|
|
263
|
-
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
264
|
-
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let
|
|
465
|
+
prismic custom-type add-field timestamp article published_at --label "Published At"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
466
|
+
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
467
|
+
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let d=await U(`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=z(_r,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:`Timestamp`,config:{label:i??q(u),...a&&{placeholder:a},...o&&{default:o}}};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}" (Timestamp) to "${h}" tab in ${l}`);try{await G({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const yr=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function br(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing custom type.
|
|
265
468
|
|
|
266
469
|
USAGE
|
|
267
470
|
prismic custom-type add-field uid <type-id> <field-id> [flags]
|
|
@@ -272,16 +475,17 @@ ARGUMENTS
|
|
|
272
475
|
|
|
273
476
|
FLAGS
|
|
274
477
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
275
|
-
-l, --label string Display label for the field
|
|
478
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
276
479
|
-p, --placeholder string Placeholder text
|
|
480
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
277
481
|
-h, --help Show help for command
|
|
278
482
|
|
|
279
483
|
EXAMPLES
|
|
280
484
|
prismic custom-type add-field uid page uid
|
|
281
485
|
prismic custom-type add-field uid article slug --label "URL Slug"
|
|
282
|
-
prismic custom-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!
|
|
283
|
-
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
284
|
-
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let
|
|
486
|
+
prismic custom-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
487
|
+
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
488
|
+
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let u=await U(`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=z(yr,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:`UID`,config:{label:i??q(l),...a&&{placeholder:a}}};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}" (UID) to "${m}" tab in ${c}`);try{await G({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function xr(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await Xn();break;case`color`:await Qn();break;case`date`:await er();break;case`embed`:await nr();break;case`geo-point`:await ir();break;case`image`:await or();break;case`key-text`:await cr();break;case`link`:await ur();break;case`number`:await fr();break;case`rich-text`:await mr();break;case`select`:await gr();break;case`timestamp`:await vr();break;case`uid`:await br();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing custom type.
|
|
285
489
|
|
|
286
490
|
USAGE
|
|
287
491
|
prismic custom-type add-field <field-type> <type-id> <field-id> [flags]
|
|
@@ -311,7 +515,7 @@ EXAMPLES
|
|
|
311
515
|
prismic custom-type add-field key-text homepage meta_title --tab "SEO"
|
|
312
516
|
prismic custom-type add-field link homepage button --allow-text
|
|
313
517
|
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
|
|
518
|
+
prismic custom-type add-field select homepage layout --option "full" --option "sidebar"`)}}const Sr=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function Cr(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a custom type's slice zone.
|
|
315
519
|
|
|
316
520
|
USAGE
|
|
317
521
|
prismic custom-type connect-slice <type-id> <slice-id> [flags]
|
|
@@ -322,14 +526,15 @@ ARGUMENTS
|
|
|
322
526
|
|
|
323
527
|
FLAGS
|
|
324
528
|
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
529
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
325
530
|
-h, --help Show help for command
|
|
326
531
|
|
|
327
532
|
EXAMPLES
|
|
328
533
|
prismic custom-type connect-slice homepage CallToAction
|
|
329
534
|
prismic custom-type connect-slice homepage CallToAction --slice-zone slices
|
|
330
|
-
prismic custom-type connect-slice article HeroSection -z body`);return}if(!
|
|
331
|
-
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!
|
|
332
|
-
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let
|
|
535
|
+
prismic custom-type connect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
|
|
536
|
+
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
|
|
537
|
+
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await W(o);if(!c.ok){console.error(c.error),process.exitCode=1;return}let l=await U(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${a}/index.json`,l),d;try{let e=await r(u,`utf8`),t=z(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: ${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 f=n??`slices`,p,m;for(let[,e]of Object.entries(d.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===f){p=n,m=t;break}if(p)break}if(!p){if(n){console.error(`Slice zone "${n}" not found in custom type "${a}"`),process.exitCode=1;return}let e=Object.keys(d.json)[0]??`Main`;d.json[e]||(d.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};d.json[e][f]=t,p=t,m=f}if(p.config||={choices:{}},p.config.choices||(p.config.choices={}),o in p.config.choices){console.info(`Slice "${o}" is already connected to slice zone "${m}" in ${a}`);return}let h={type:`SharedSlice`};p.config.choices[o]=h;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(`Connected slice "${o}" to slice zone "${m}" in ${a}`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function wr(){let{values:{help:t,name:r,single:i,types:a},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new custom type in a Prismic repository.
|
|
333
538
|
|
|
334
539
|
USAGE
|
|
335
540
|
prismic custom-type create <id> [flags]
|
|
@@ -340,10 +545,11 @@ ARGUMENTS
|
|
|
340
545
|
FLAGS
|
|
341
546
|
-n, --name string Display name for the custom type
|
|
342
547
|
--single Create as a singleton (non-repeatable) type
|
|
548
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
343
549
|
-h, --help Show help for command
|
|
344
550
|
|
|
345
551
|
LEARN MORE
|
|
346
|
-
Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!
|
|
552
|
+
Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: id`),process.exitCode=1;return}let c={id:o,label:r??Tr(o),repeatable:!i,status:!0,format:`custom`,json:{Main:i?{}:{uid:{type:`UID`,config:{label:`UID`,placeholder:``}}}}},l=await U(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/`,l),d=new URL(o+`/`,u),f=new URL(`index.json`,d);try{await n(new URL(`.`,f),{recursive:!0}),await s(f,K(c))}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 ${f.href}`);try{await G({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic custom-type add-field`")}function Tr(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Er=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function Dr(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a custom type's slice zone.
|
|
347
553
|
|
|
348
554
|
USAGE
|
|
349
555
|
prismic custom-type disconnect-slice <type-id> <slice-id> [flags]
|
|
@@ -354,14 +560,15 @@ ARGUMENTS
|
|
|
354
560
|
|
|
355
561
|
FLAGS
|
|
356
562
|
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
563
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
357
564
|
-h, --help Show help for command
|
|
358
565
|
|
|
359
566
|
EXAMPLES
|
|
360
567
|
prismic custom-type disconnect-slice homepage CallToAction
|
|
361
568
|
prismic custom-type disconnect-slice homepage CallToAction --slice-zone slices
|
|
362
|
-
prismic custom-type disconnect-slice article HeroSection -z body`);return}if(!
|
|
363
|
-
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!
|
|
364
|
-
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let
|
|
569
|
+
prismic custom-type disconnect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
|
|
570
|
+
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
|
|
571
|
+
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await U(`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=z(Er,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=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){console.error(`Slice zone "${d}" not found in custom type "${a}"`),process.exitCode=1;return}if(!f.config?.choices||!(o in f.config.choices)){console.error(`Slice "${o}" is not connected to slice zone "${p}" in ${a}`),process.exitCode=1;return}delete f.config.choices[o];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(`Disconnected slice "${o}" from slice zone "${p}" in ${a}`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Or=P({id:L(),label:L(),repeatable:N(),status:N(),format:F(L()),json:I(L(),I(L(),R()))});async function kr(){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
572
|
|
|
366
573
|
USAGE
|
|
367
574
|
prismic custom-type list [flags]
|
|
@@ -372,7 +579,7 @@ FLAGS
|
|
|
372
579
|
|
|
373
580
|
EXAMPLES
|
|
374
581
|
prismic custom-type list
|
|
375
|
-
prismic custom-type list --json`);return}let a=await
|
|
582
|
+
prismic custom-type list --json`);return}let a=await U(`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=z(Or,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 Ar=P({id:L(),label:L(),repeatable:N(),status:N(),format:F(L()),json:I(L(),I(L(),R()))});async function jr(){let{values:{help:t,y:n,types:i},positionals:[a]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom type from the project.
|
|
376
583
|
|
|
377
584
|
USAGE
|
|
378
585
|
prismic custom-type remove <type-id> [flags]
|
|
@@ -382,12 +589,13 @@ ARGUMENTS
|
|
|
382
589
|
|
|
383
590
|
FLAGS
|
|
384
591
|
-y Confirm removal
|
|
592
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
385
593
|
-h, --help Show help for command
|
|
386
594
|
|
|
387
595
|
EXAMPLES
|
|
388
596
|
prismic custom-type remove settings
|
|
389
|
-
prismic custom-type remove settings -y`);return}if(!
|
|
390
|
-
`),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let
|
|
597
|
+
prismic custom-type remove settings -y`);return}if(!a){console.error(`Missing required argument: type-id
|
|
598
|
+
`),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let s=await U(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${a}/`,s),l=new URL(`index.json`,c),u;try{let e=await r(l,`utf8`),t=z(Ar,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}`),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(u.format===`page`){console.error(`"${a}" is not a custom type (format: page)`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove custom type "${a}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{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 "${a}"`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Mr=P({id:L(),label:L(),repeatable:N(),status:N(),format:F(L()),json:I(L(),I(L(),R()))});async function Nr(){let{values:{help:t,tab:n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a custom type.
|
|
391
599
|
|
|
392
600
|
USAGE
|
|
393
601
|
prismic custom-type remove-field <type-id> <field-id> [flags]
|
|
@@ -398,13 +606,14 @@ ARGUMENTS
|
|
|
398
606
|
|
|
399
607
|
FLAGS
|
|
400
608
|
--tab string Specific tab (searches all tabs if not specified)
|
|
609
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
401
610
|
-h, --help Show help for command
|
|
402
611
|
|
|
403
612
|
EXAMPLES
|
|
404
613
|
prismic custom-type remove-field settings title
|
|
405
|
-
prismic custom-type remove-field settings description --tab "Content"`);return}if(!
|
|
406
|
-
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
407
|
-
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let
|
|
614
|
+
prismic custom-type remove-field settings description --tab "Content"`);return}if(!a){console.error(`Missing required argument: type-id
|
|
615
|
+
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
616
|
+
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let c=await U(`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=z(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: ${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}if(u.format===`page`){console.error(`"${a}" is not a custom type (format: page)`),process.exitCode=1;return}let d;if(n){if(!u.json[n]){console.error(`Tab "${n}" not found in custom type "${a}"`),console.error(`Available tabs: ${Object.keys(u.json).join(`, `)}`),process.exitCode=1;return}if(!(o in u.json[n])){console.error(`Field "${o}" not found in tab "${n}"`),process.exitCode=1;return}delete u.json[n][o],d=n}else{for(let[e,t]of Object.entries(u.json))if(o in t){delete t[o],d=e;break}if(!d){console.error(`Field "${o}" not found in any tab of custom type "${a}"`),process.exitCode=1;return}}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(`Removed field "${o}" from tab "${d}" in custom type "${a}"`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Pr=P({id:L(),label:L(),repeatable:N(),status:N(),format:F(L()),json:I(L(),I(L(),R()))});async function Fr(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a custom type's display name (label).
|
|
408
617
|
|
|
409
618
|
USAGE
|
|
410
619
|
prismic custom-type set-name <type-id> <new-name> [flags]
|
|
@@ -414,13 +623,14 @@ ARGUMENTS
|
|
|
414
623
|
new-name New display name (required)
|
|
415
624
|
|
|
416
625
|
FLAGS
|
|
626
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
417
627
|
-h, --help Show help for command
|
|
418
628
|
|
|
419
629
|
EXAMPLES
|
|
420
630
|
prismic custom-type set-name settings "Site Settings"
|
|
421
|
-
prismic custom-type set-name menu "Navigation Menu"`);return}if(!
|
|
422
|
-
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!
|
|
423
|
-
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let
|
|
631
|
+
prismic custom-type set-name menu "Navigation Menu"`);return}if(!i){console.error(`Missing required argument: type-id
|
|
632
|
+
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: new-name
|
|
633
|
+
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let o=await U(`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=z(Pr,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}l.label=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(`Renamed custom type "${i}" to "${a}"`);try{await G({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ir=P({id:L(),label:L(),repeatable:N(),status:N(),format:F(L()),json:I(L(),I(L(),R()))});async function Lr(){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 U(`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=z(Ir,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 Rr(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await wr();break;case`list`:await kr();break;case`view`:await Lr();break;case`remove`:await jr();break;case`set-name`:await Fr();break;case`add-field`:await xr();break;case`remove-field`:await Nr();break;case`connect-slice`:await Cr();break;case`disconnect-slice`:await Dr();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,25 @@ 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.`)}}const
|
|
668
|
+
Use \`prismic custom-type <command> --help\` for more information about a command.`)}}const zr=`Fetch and display documentation from Prismic's docs site.
|
|
669
|
+
|
|
670
|
+
USAGE
|
|
671
|
+
prismic docs <path> [flags]
|
|
672
|
+
|
|
673
|
+
ARGUMENTS
|
|
674
|
+
path Documentation path with optional anchor (e.g., "nextjs" or "nextjs#set-up-a-prismic-client")
|
|
675
|
+
|
|
676
|
+
FLAGS
|
|
677
|
+
-h, --help Show help for command
|
|
678
|
+
|
|
679
|
+
EXAMPLES
|
|
680
|
+
prismic docs nextjs
|
|
681
|
+
prismic docs nextjs#set-up-a-prismic-client
|
|
682
|
+
|
|
683
|
+
LEARN MORE
|
|
684
|
+
Visit https://prismic.io/docs for the full documentation.`;function Br(e){let t=e.indexOf(`#`);return t===-1?{path:e}:{path:e.slice(0,t),anchor:e.slice(t+1)}}async function Vr(e){try{let t=await fetch(e);return t.status===404?{ok:!1,error:`Documentation not found: ${e}`}:t.ok?{ok:!0,content:await t.text()}:{ok:!1,error:`Failed to fetch documentation: ${t.status}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:String(e)}`}}}function Hr(e){let t=e.split(`-`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`[\\s-]+`);return RegExp(`^(#{1,6})\\s+${t}\\s*$`,`im`)}function Ur(e,t){let n=e.split(`
|
|
685
|
+
`),r=Hr(t),i=-1,a=0;for(let e=0;e<n.length;e++){let t=n[e].match(r);if(t){i=e,a=t[1].length;break}}if(i===-1)return{ok:!1,error:`Anchor not found: #${t}`};let o=n.length;for(let e=i+1;e<n.length;e++){let t=n[e].match(/^(#{1,6})\s/);if(t&&t[1].length<=a){o=e;break}}return{ok:!0,content:n.slice(i,o).join(`
|
|
686
|
+
`).trim()}}async function Wr(){let{positionals:[t],values:{help:n}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(zr);return}if(!t){console.info(zr);return}let{path:r,anchor:i}=Br(t),a=await Vr(`https://prismic.io/docs/${r}.md`);if(!a.ok){console.error(a.error),process.exitCode=1;return}let o=a.content;if(i){let e=Ur(o,i);if(!e.ok){console.error(e.error),process.exitCode=1;return}o=e.content}console.info(o)}const Gr=`prismic.config.json`,Kr=P({repositoryName:L(),apiEndpoint:F(yn(L(),fn())),localSliceMachineSimulatorURL:F(yn(L(),fn())),libraries:F(M(L())),adapter:F(L()),labs:F(P({legacySliceUpgrader:F(N())}))});async function qr(e,t=d(process.cwd())){let n=await Qr(t);return n.ok?(await s(n.path,K(e)),{ok:!0,config:e}):n}async function J(e=d(process.cwd())){let t=await Jr(e);if(t.ok)return t.config.repositoryName}async function Jr(e=d(process.cwd())){let t=await Zr(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=z(Kr,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new Yr(n.issues)}}catch{return{ok:!1,error:new Yr}}}var Yr=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function Xr(e,t=d(process.cwd())){let n=await Zr(t);if(!n.ok)return n;let r=await Jr(t);if(!r.ok)return r;let i={...r.config,...e};return await s(n.path,K(i)),{ok:!0,config:i}}async function Zr(e=d(process.cwd())){let t=await U(Gr,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new $r}}async function Qr(e=d(process.cwd())){let t=await U(`package.json`,{start:e});return t?{ok:!0,path:new URL(Gr,t)}:{ok:!1,error:new ei}}var $r=class extends Error{message=`Could not find a prismic.config.json file.`},ei=class extends Error{message=`Could not find a package.json file.`};async function ti(){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
687
|
|
|
460
688
|
Use this command to connect an existing Prismic repository to your project.
|
|
461
689
|
To create a new repository, use \`prismic repo create\` instead.
|
|
@@ -468,7 +696,7 @@ FLAGS
|
|
|
468
696
|
-h, --help Show help for command
|
|
469
697
|
|
|
470
698
|
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
|
|
699
|
+
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 Jr()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await qr({repositoryName:t.repo});if(!n.ok){n.error instanceof ei?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 Y(e,t={}){let{credentials:n=`include`}=t,r=new Headers(t.headers);if(r.set(`Accept`,`application/json`),n===`include`){let e=await H();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:vn(t.schema,o)}}catch(e){if(j(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 ni(a)}}var ni=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 ni{},Z=class extends ni{};async function ri(){let{values:{help:t,name:n,repo:r=await J()},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
700
|
|
|
473
701
|
By default, this command reads the repository from prismic.config.json at the
|
|
474
702
|
project root.
|
|
@@ -485,7 +713,7 @@ FLAGS
|
|
|
485
713
|
-h, --help Show help for command
|
|
486
714
|
|
|
487
715
|
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
|
|
716
|
+
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 V()){oi();return}let a=n?await ai(r,i,n):await ii(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof X?oi():(console.error(`Failed to add locale: ${K(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function ii(e,t){return await Y(new URL(`/app/settings/multilanguages`,await B(e)),{method:`POST`,body:{languages:[t]}})}async function ai(e,t,n){let[r,i]=t.split(`-`);return await Y(new URL(`/app/settings/multilanguages/custom`,await B(e)),{method:`POST`,body:{lang:{label:n,id:r||t},region:{label:n,id:i||r||t}}})}function oi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function si(){let{values:{help:t,repo:n=await J(),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.
|
|
489
717
|
|
|
490
718
|
By default, this command reads the repository from prismic.config.json at the
|
|
491
719
|
project root.
|
|
@@ -499,7 +727,7 @@ FLAGS
|
|
|
499
727
|
-h, --help Show help for command
|
|
500
728
|
|
|
501
729
|
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
|
|
730
|
+
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 V()){ui();return}let i=await li(n);if(!i.ok){i.error instanceof X?ui():j(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 ci=P({results:M(P({id:L(),label:L(),customName:gn(L()),isMaster:N()}))});async function li(e){let t=new URL(`/locale/repository/locales`,await bn());return t.searchParams.set(`repository`,e),await Y(t,{schema:ci})}function ui(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function di(){let{values:{repo:t=await J(),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
731
|
|
|
504
732
|
By default, this command reads the repository from prismic.config.json at the
|
|
505
733
|
project root.
|
|
@@ -515,7 +743,7 @@ FLAGS
|
|
|
515
743
|
-h, --help Show help for command
|
|
516
744
|
|
|
517
745
|
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
|
|
746
|
+
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 V()){pi();return}let i=await fi(t,r);if(!i.ok){i.error instanceof X?pi():(console.error(`Failed to remove locale: ${K(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function fi(e,t){let n=new URL(`/locale/repository/locales/${t}`,await bn());return n.searchParams.set(`repository`,e),await Y(n,{method:`DELETE`})}function pi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function mi(){let{values:{help:t,repo:n=await J()},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
747
|
|
|
520
748
|
By default, this command reads the repository from prismic.config.json at the
|
|
521
749
|
project root.
|
|
@@ -531,7 +759,7 @@ FLAGS
|
|
|
531
759
|
-h, --help Show help for command
|
|
532
760
|
|
|
533
761
|
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
|
|
762
|
+
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 V()){gi();return}let i=await li(n);if(!i.ok){i.error instanceof X?gi():j(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 hi(n,o);if(!s.ok){s.error instanceof X?gi():(console.error(`Failed to set default locale: ${K(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function hi(e,t){let n=new URL(`/locale/repository/locales`,await bn());return n.searchParams.set(`repository`,e),await Y(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function gi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function _i(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await ri();break;case`list`:await si();break;case`remove`:await di();break;case`set-default`:await mi();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
|
|
535
763
|
|
|
536
764
|
USAGE
|
|
537
765
|
prismic locale <command> [flags]
|
|
@@ -546,7 +774,7 @@ FLAGS
|
|
|
546
774
|
-h, --help Show help for command
|
|
547
775
|
|
|
548
776
|
LEARN MORE
|
|
549
|
-
Use \`prismic locale <command> --help\` for more information about a command.`)}}async function
|
|
777
|
+
Use \`prismic locale <command> --help\` for more information about a command.`)}}const vi=`https://prismic.io`;async function yi(){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
778
|
|
|
551
779
|
USAGE
|
|
552
780
|
prismic login [flags]
|
|
@@ -555,7 +783,7 @@ FLAGS
|
|
|
555
783
|
-h, --help Show help for command
|
|
556
784
|
|
|
557
785
|
LEARN MORE
|
|
558
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=
|
|
786
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=p((t,i)=>{if(t.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":vi,"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":vi,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await Tn(s),console.info(`Logged in to Prismic as ${o}`),i.writeHead(200,{"Access-Control-Allow-Origin":vi,"Content-Type":`application/json`}),i.end(JSON.stringify({success:!0})),clearTimeout(r),n.close(),e()}catch{i.writeHead(400,{"Access-Control-Allow-Origin":vi,"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),i=()=>{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=bi(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),xi(a)};n.on(`error`,e=>{e.code===`EADDRINUSE`&&n.listening===!1?n.listen(0,`0.0.0.0`,i):(clearTimeout(r),t(e))}),n.listen(5555,`0.0.0.0`,i)})}function bi(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 xi(e){f(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function Si(){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
787
|
|
|
560
788
|
USAGE
|
|
561
789
|
prismic logout [flags]
|
|
@@ -564,7 +792,7 @@ FLAGS
|
|
|
564
792
|
-h, --help Show help for command
|
|
565
793
|
|
|
566
794
|
LEARN MORE
|
|
567
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}await
|
|
795
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}await On()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const Ci=P({dependencies:F(I(L(),L())),devDependencies:F(I(L(),L()))});async function Q(){let e=await U(`package.json`);if(!e)return;let t=new URL(`.`,e),n;try{let t=await r(e,`utf8`),{dependencies:i={},devDependencies:a={}}=vn(Ci,JSON.parse(t)),o={...i,...a};`next`in o?n=`next`:`nuxt`in o?n=`nuxt`:`@sveltejs/kit`in o&&(n=`sveltekit`)}catch{}let i=!1;return n===`next`||n===`sveltekit`?i=await kn(new URL(`src/`,t)):n===`nuxt`&&(i=await kn(new URL(`app/`,t))),{framework:n,hasSrcDir:i,projectRoot:t}}function wi(e){switch(e){case`next`:return[`@prismicio/client`,`@prismicio/react`,`@prismicio/next`];case`nuxt`:return[`@nuxtjs/prismic`];case`sveltekit`:return[`@prismicio/client`,`@prismicio/svelte`];default:return[`@prismicio/client`]}}function Ti(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/prismicio.ts`:`prismicio.ts`;case`nuxt`:return null;case`sveltekit`:return`src/lib/prismicio.ts`;default:return`prismicio.ts`}}function Ei(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/slices/`:`slices/`;case`nuxt`:return e.hasSrcDir?`app/slices/`:`slices/`;case`sveltekit`:return`src/lib/slices/`;default:return`slices/`}}function Di(e){switch(e){case`next`:return[`.tsx`,`.ts`,`.jsx`,`.js`];case`nuxt`:return[`.vue`];case`sveltekit`:return[`.svelte`];default:return[`.tsx`,`.ts`,`.jsx`,`.js`]}}function Oi(e,t){switch(e.framework){case`next`:{let n=e.hasSrcDir?`src/app`:`app`;return t===`/slice-simulator`?{path:`${n}/slice-simulator/page`,extensions:[`.tsx`,`.ts`,`.jsx`,`.js`]}:t===`/api/preview`?{path:`${n}/api/preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/exit-preview`?{path:`${n}/api/exit-preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/revalidate`?{path:`${n}/api/revalidate/route`,extensions:[`.ts`,`.js`]}:null}case`nuxt`:return t===`/slice-simulator`?{path:`pages/slice-simulator`,extensions:[`.vue`]}:null;case`sveltekit`:return t===`/slice-simulator`?{path:`src/routes/slice-simulator/+page`,extensions:[`.svelte`]}:t===`/api/preview`?{path:`src/routes/api/preview/+server`,extensions:[`.ts`,`.js`]}:null;default:return null}}const ki=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function Ai(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ji(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c,types:l},positionals:[u,d]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing page type.
|
|
568
796
|
|
|
569
797
|
USAGE
|
|
570
798
|
prismic page-type add-field boolean <type-id> <field-id> [flags]
|
|
@@ -575,18 +803,19 @@ ARGUMENTS
|
|
|
575
803
|
|
|
576
804
|
FLAGS
|
|
577
805
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
578
|
-
-l, --label string Display label for the field
|
|
806
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
579
807
|
--default Set default value to true
|
|
580
808
|
--true-label string Label shown when toggle is on
|
|
581
809
|
--false-label string Label shown when toggle is off
|
|
810
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
582
811
|
-h, --help Show help for command
|
|
583
812
|
|
|
584
813
|
EXAMPLES
|
|
585
814
|
prismic page-type add-field boolean homepage featured
|
|
586
815
|
prismic page-type add-field boolean article published --default
|
|
587
|
-
prismic page-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!
|
|
588
|
-
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
589
|
-
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let
|
|
816
|
+
prismic page-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!u){console.error(`Missing required argument: type-id
|
|
817
|
+
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
818
|
+
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let f=await U(`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=z(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:`Boolean`,config:{label:i??q(d),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};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}" (Boolean) to "${g}" tab in ${u}`);try{await G({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await Q();if(v?.framework){let e=Ai(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Mi=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function Ni(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Pi(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing page type.
|
|
590
819
|
|
|
591
820
|
USAGE
|
|
592
821
|
prismic page-type add-field color <type-id> <field-id> [flags]
|
|
@@ -597,16 +826,17 @@ ARGUMENTS
|
|
|
597
826
|
|
|
598
827
|
FLAGS
|
|
599
828
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
600
|
-
-l, --label string Display label for the field
|
|
829
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
601
830
|
-p, --placeholder string Placeholder text
|
|
831
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
602
832
|
-h, --help Show help for command
|
|
603
833
|
|
|
604
834
|
EXAMPLES
|
|
605
835
|
prismic page-type add-field color homepage bg_color
|
|
606
836
|
prismic page-type add-field color homepage accent --tab "Design"
|
|
607
|
-
prismic page-type add-field color homepage text_color --label "Text Color"`);return}if(!
|
|
608
|
-
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
609
|
-
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let
|
|
837
|
+
prismic page-type add-field color homepage text_color --label "Text Color"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
838
|
+
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
839
|
+
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let u=await U(`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=z(Mi,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:`Color`,config:{label:i??q(l),...a&&{placeholder:a}}};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}" (Color) to "${m}" tab in ${c}`);try{await G({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let g=await Q();if(g?.framework){let e=Ni(g.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Fi=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function Ii(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Li(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types: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`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing page type.
|
|
610
840
|
|
|
611
841
|
USAGE
|
|
612
842
|
prismic page-type add-field date <type-id> <field-id> [flags]
|
|
@@ -617,17 +847,18 @@ ARGUMENTS
|
|
|
617
847
|
|
|
618
848
|
FLAGS
|
|
619
849
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
620
|
-
-l, --label string Display label for the field
|
|
850
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
621
851
|
-p, --placeholder string Placeholder text
|
|
622
852
|
--default string Default date value (YYYY-MM-DD format)
|
|
853
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
623
854
|
-h, --help Show help for command
|
|
624
855
|
|
|
625
856
|
EXAMPLES
|
|
626
857
|
prismic page-type add-field date homepage publish_date
|
|
627
858
|
prismic page-type add-field date event start_date --tab "Schedule"
|
|
628
|
-
prismic page-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!
|
|
629
|
-
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
630
|
-
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let
|
|
859
|
+
prismic page-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
860
|
+
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
861
|
+
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let d=await U(`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=z(Fi,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:`Date`,config:{label:i??q(u),...a&&{placeholder:a},...o&&{default:o}}};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}" (Date) to "${h}" tab in ${l}`);try{await G({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let _=await Q();if(_?.framework){let e=Ii(_.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Ri=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function zi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Bi(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing page type.
|
|
631
862
|
|
|
632
863
|
USAGE
|
|
633
864
|
prismic page-type add-field embed <type-id> <field-id> [flags]
|
|
@@ -638,16 +869,17 @@ ARGUMENTS
|
|
|
638
869
|
|
|
639
870
|
FLAGS
|
|
640
871
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
641
|
-
-l, --label string Display label for the field
|
|
872
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
642
873
|
-p, --placeholder string Placeholder text
|
|
874
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
643
875
|
-h, --help Show help for command
|
|
644
876
|
|
|
645
877
|
EXAMPLES
|
|
646
878
|
prismic page-type add-field embed homepage video
|
|
647
879
|
prismic page-type add-field embed homepage youtube --tab "Media"
|
|
648
|
-
prismic page-type add-field embed homepage media --label "Media Embed"`);return}if(!
|
|
649
|
-
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
650
|
-
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let
|
|
880
|
+
prismic page-type add-field embed homepage media --label "Media Embed"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
881
|
+
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
882
|
+
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let u=await U(`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=z(Ri,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:`Embed`,config:{label:i??q(l),...a&&{placeholder:a}}};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}" (Embed) to "${m}" tab in ${c}`);try{await G({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let g=await Q();if(g?.framework){let e=zi(g.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Vi=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function Hi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Ui(){let{values:{help:t,tab:n,label:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing page type.
|
|
651
883
|
|
|
652
884
|
USAGE
|
|
653
885
|
prismic page-type add-field geo-point <type-id> <field-id> [flags]
|
|
@@ -658,15 +890,16 @@ ARGUMENTS
|
|
|
658
890
|
|
|
659
891
|
FLAGS
|
|
660
892
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
661
|
-
-l, --label string Display label for the field
|
|
893
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
894
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
662
895
|
-h, --help Show help for command
|
|
663
896
|
|
|
664
897
|
EXAMPLES
|
|
665
898
|
prismic page-type add-field geo-point homepage location
|
|
666
899
|
prismic page-type add-field geo-point store address --tab "Details"
|
|
667
|
-
prismic page-type add-field geo-point event venue --label "Event Venue"`);return}if(!
|
|
668
|
-
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
669
|
-
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let
|
|
900
|
+
prismic page-type add-field geo-point event venue --label "Event Venue"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
901
|
+
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
902
|
+
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let l=await U(`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=z(Vi,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:`GeoPoint`,config:{label:i??q(c)}};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}" (GeoPoint) to "${p}" tab in ${o}`);try{await G({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let h=await Q();if(h?.framework){let e=Hi(h.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Wi=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function Gi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Ki(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing page type.
|
|
670
903
|
|
|
671
904
|
USAGE
|
|
672
905
|
prismic page-type add-field image <type-id> <field-id> [flags]
|
|
@@ -677,16 +910,17 @@ ARGUMENTS
|
|
|
677
910
|
|
|
678
911
|
FLAGS
|
|
679
912
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
680
|
-
-l, --label string Display label for the field
|
|
913
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
681
914
|
-p, --placeholder string Placeholder text
|
|
915
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
682
916
|
-h, --help Show help for command
|
|
683
917
|
|
|
684
918
|
EXAMPLES
|
|
685
919
|
prismic page-type add-field image homepage hero
|
|
686
920
|
prismic page-type add-field image article thumbnail --tab "Media"
|
|
687
|
-
prismic page-type add-field image product photo --label "Product Photo"`);return}if(!
|
|
688
|
-
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
689
|
-
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let
|
|
921
|
+
prismic page-type add-field image product photo --label "Product Photo"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
922
|
+
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
923
|
+
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let u=await U(`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=z(Wi,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:`Image`,config:{label:i??q(l),...a&&{placeholder:a}}};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}" (Image) to "${m}" tab in ${c}`);try{await G({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let g=await Q();if(g?.framework){let e=Gi(g.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const qi=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function Ji(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Yi(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},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
924
|
|
|
691
925
|
USAGE
|
|
692
926
|
prismic page-type add-field key-text <type-id> <field-id> [flags]
|
|
@@ -697,16 +931,17 @@ ARGUMENTS
|
|
|
697
931
|
|
|
698
932
|
FLAGS
|
|
699
933
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
700
|
-
-l, --label string Display label for the field
|
|
934
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
701
935
|
-p, --placeholder string Placeholder text
|
|
936
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
702
937
|
-h, --help Show help for command
|
|
703
938
|
|
|
704
939
|
EXAMPLES
|
|
705
940
|
prismic page-type add-field key-text homepage title
|
|
706
941
|
prismic page-type add-field key-text homepage meta_title --tab "SEO"
|
|
707
|
-
prismic page-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!
|
|
708
|
-
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
709
|
-
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let
|
|
942
|
+
prismic page-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
943
|
+
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
944
|
+
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let u=await U(`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=z(qi,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:`Text`,config:{label:i??q(l),...a&&{placeholder:a}}};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}" (Text) to "${m}" tab in ${c}`);try{await G({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let g=await Q();if(g?.framework){let e=Ji(g.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const Xi=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function Zi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Qi(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u,types:d},positionals:[f,p]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing page type.
|
|
710
945
|
|
|
711
946
|
USAGE
|
|
712
947
|
prismic page-type add-field link <type-id> <field-id> [flags]
|
|
@@ -717,21 +952,22 @@ ARGUMENTS
|
|
|
717
952
|
|
|
718
953
|
FLAGS
|
|
719
954
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
720
|
-
-l, --label string Display label for the field
|
|
955
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
721
956
|
-p, --placeholder string Placeholder text
|
|
722
957
|
--variation string Slice variations (can be used multiple times)
|
|
723
958
|
--allow-text Allow text with link
|
|
724
959
|
--allow-target-blank Allow opening link in new tab
|
|
725
960
|
--repeatable Allow multiple links
|
|
961
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
726
962
|
-h, --help Show help for command
|
|
727
963
|
|
|
728
964
|
EXAMPLES
|
|
729
965
|
prismic page-type add-field link homepage button
|
|
730
966
|
prismic page-type add-field link homepage cta --allow-text
|
|
731
967
|
prismic page-type add-field link homepage cta --variation Primary --variation Secondary
|
|
732
|
-
prismic page-type add-field link homepage links --repeatable`);return}if(!
|
|
733
|
-
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
734
|
-
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let
|
|
968
|
+
prismic page-type add-field link homepage links --repeatable`);return}if(!f){console.error(`Missing required argument: type-id
|
|
969
|
+
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!p){console.error(`Missing required argument: field-id
|
|
970
|
+
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let m=await U(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${f}/index.json`,m),g;try{let e=await r(h,`utf8`),t=z(Xi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${f}\n`),console.error(`Create it first with: prismic page-type create ${f}`),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 _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});for(let[e,t]of Object.entries(g.json))if(t[p]){console.error(`Field "${p}" already exists in tab "${e}"`),process.exitCode=1;return}let y={type:`Link`,config:{label:i??q(p),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};g.json[v][p]=y;try{await s(h,K(g))}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 "${p}" (Link) to "${v}" tab in ${f}`);try{await G({output:d}),console.info(`Updated types in ${d??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let b=await Q();if(b?.framework){let e=Zi(b.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const $i=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function ea(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ta(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l,types: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`},min:{type:`string`},max:{type:`string`},step:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing page type.
|
|
735
971
|
|
|
736
972
|
USAGE
|
|
737
973
|
prismic page-type add-field number <type-id> <field-id> [flags]
|
|
@@ -742,19 +978,20 @@ ARGUMENTS
|
|
|
742
978
|
|
|
743
979
|
FLAGS
|
|
744
980
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
745
|
-
-l, --label string Display label for the field
|
|
981
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
746
982
|
-p, --placeholder string Placeholder text
|
|
747
983
|
--min number Minimum value
|
|
748
984
|
--max number Maximum value
|
|
749
985
|
--step number Step increment
|
|
986
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
750
987
|
-h, --help Show help for command
|
|
751
988
|
|
|
752
989
|
EXAMPLES
|
|
753
990
|
prismic page-type add-field number homepage price
|
|
754
991
|
prismic page-type add-field number product quantity --min 0 --max 100
|
|
755
|
-
prismic page-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!
|
|
756
|
-
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
757
|
-
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let
|
|
992
|
+
prismic page-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!d){console.error(`Missing required argument: type-id
|
|
993
|
+
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
994
|
+
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let p=o===void 0?void 0:Number(o),m=c===void 0?void 0:Number(c),h=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(p)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(m)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(h)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let g=await U(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`customtypes/${d}/index.json`,g),v;try{let e=await r(_,`utf8`),t=z($i,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${_.href}`),process.exitCode=1;return}v=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 y=Object.keys(v.json),b=n??y[0]??`Main`;v.json[b]||(v.json[b]={});for(let[e,t]of Object.entries(v.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let x={type:`Number`,config:{label:i??q(f),...a&&{placeholder:a},...p!==void 0&&{min:p},...m!==void 0&&{max:m},...h!==void 0&&{step:h}}};v.json[b][f]=x;try{await s(_,K(v))}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}" (Number) to "${b}" tab in ${d}`);try{await G({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let ee=await Q();if(ee?.framework){let e=ea(ee.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const na=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function ra(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ia(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l,types: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`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing page type.
|
|
758
995
|
|
|
759
996
|
USAGE
|
|
760
997
|
prismic page-type add-field rich-text <type-id> <field-id> [flags]
|
|
@@ -765,11 +1002,12 @@ ARGUMENTS
|
|
|
765
1002
|
|
|
766
1003
|
FLAGS
|
|
767
1004
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
768
|
-
-l, --label string Display label for the field
|
|
1005
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
769
1006
|
-p, --placeholder string Placeholder text
|
|
770
1007
|
--single string Allowed block types for single-line (comma-separated)
|
|
771
1008
|
--multi string Allowed block types for multi-line (comma-separated)
|
|
772
1009
|
--allow-target-blank Allow opening links in new tab
|
|
1010
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
773
1011
|
-h, --help Show help for command
|
|
774
1012
|
|
|
775
1013
|
BLOCK TYPES
|
|
@@ -781,9 +1019,9 @@ EXAMPLES
|
|
|
781
1019
|
prismic page-type add-field rich-text homepage body
|
|
782
1020
|
prismic page-type add-field rich-text article content --multi "paragraph,heading2,heading3,strong,em,hyperlink"
|
|
783
1021
|
prismic page-type add-field rich-text page tagline --single "heading1"
|
|
784
|
-
prismic page-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!
|
|
785
|
-
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
786
|
-
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let
|
|
1022
|
+
prismic page-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!d){console.error(`Missing required argument: type-id
|
|
1023
|
+
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
1024
|
+
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let p=await U(`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=z(na,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:`StructuredText`,config:{label:i??q(f),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!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}" (StructuredText) to "${_}" tab in ${d}`);try{await G({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let y=await Q();if(y?.framework){let e=ra(y.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const aa=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function oa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function sa(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c,types: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`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing page type.
|
|
787
1025
|
|
|
788
1026
|
USAGE
|
|
789
1027
|
prismic page-type add-field select <type-id> <field-id> [flags]
|
|
@@ -794,18 +1032,19 @@ ARGUMENTS
|
|
|
794
1032
|
|
|
795
1033
|
FLAGS
|
|
796
1034
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
797
|
-
-l, --label string Display label for the field
|
|
1035
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
798
1036
|
-p, --placeholder string Placeholder text
|
|
799
1037
|
--option string Add an option (can be used multiple times)
|
|
800
1038
|
--default string Default selected value
|
|
1039
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
801
1040
|
-h, --help Show help for command
|
|
802
1041
|
|
|
803
1042
|
EXAMPLES
|
|
804
1043
|
prismic page-type add-field select homepage layout --option "full" --option "sidebar"
|
|
805
1044
|
prismic page-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
|
|
806
|
-
prismic page-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!
|
|
807
|
-
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
808
|
-
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let
|
|
1045
|
+
prismic page-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!u){console.error(`Missing required argument: type-id
|
|
1046
|
+
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
1047
|
+
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let f=await U(`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=z(aa,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:`Select`,config:{label:i??q(d),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};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}" (Select) to "${g}" tab in ${u}`);try{await G({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await Q();if(v?.framework){let e=oa(v.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const ca=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function la(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ua(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types: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`},default:{type:`string`},types:{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
1048
|
|
|
810
1049
|
USAGE
|
|
811
1050
|
prismic page-type add-field timestamp <type-id> <field-id> [flags]
|
|
@@ -816,17 +1055,18 @@ ARGUMENTS
|
|
|
816
1055
|
|
|
817
1056
|
FLAGS
|
|
818
1057
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
819
|
-
-l, --label string Display label for the field
|
|
1058
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
820
1059
|
-p, --placeholder string Placeholder text
|
|
821
1060
|
--default string Default timestamp value (ISO 8601 format)
|
|
1061
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
822
1062
|
-h, --help Show help for command
|
|
823
1063
|
|
|
824
1064
|
EXAMPLES
|
|
825
1065
|
prismic page-type add-field timestamp homepage event_time
|
|
826
1066
|
prismic page-type add-field timestamp event start --tab "Schedule"
|
|
827
|
-
prismic page-type add-field timestamp article published_at --label "Published At"`);return}if(!
|
|
828
|
-
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
829
|
-
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let
|
|
1067
|
+
prismic page-type add-field timestamp article published_at --label "Published At"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
1068
|
+
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
1069
|
+
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let d=await U(`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=z(ca,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:`Timestamp`,config:{label:i??q(u),...a&&{placeholder:a},...o&&{default:o}}};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}" (Timestamp) to "${h}" tab in ${l}`);try{await G({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let _=await Q();if(_?.framework){let e=la(_.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}const da=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});function fa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function pa(){let{values:{help:t,tab:n,label:i,placeholder:a,types: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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing page type.
|
|
830
1070
|
|
|
831
1071
|
USAGE
|
|
832
1072
|
prismic page-type add-field uid <type-id> <field-id> [flags]
|
|
@@ -837,16 +1077,17 @@ ARGUMENTS
|
|
|
837
1077
|
|
|
838
1078
|
FLAGS
|
|
839
1079
|
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
840
|
-
-l, --label string Display label for the field
|
|
1080
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
841
1081
|
-p, --placeholder string Placeholder text
|
|
1082
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
842
1083
|
-h, --help Show help for command
|
|
843
1084
|
|
|
844
1085
|
EXAMPLES
|
|
845
1086
|
prismic page-type add-field uid page uid
|
|
846
1087
|
prismic page-type add-field uid article slug --label "URL Slug"
|
|
847
|
-
prismic page-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!
|
|
848
|
-
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
849
|
-
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let
|
|
1088
|
+
prismic page-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
1089
|
+
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
1090
|
+
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let u=await U(`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=z(da,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:`UID`,config:{label:i??q(l),...a&&{placeholder:a}}};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}" (UID) to "${m}" tab in ${c}`);try{await G({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let g=await Q();if(g?.framework){let e=fa(g.framework);console.info(` Run \`prismic docs ${e}#write-page-components\` to learn how to implement a page file`)}}async function ma(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await ji();break;case`color`:await Pi();break;case`date`:await Li();break;case`embed`:await Bi();break;case`geo-point`:await Ui();break;case`image`:await Ki();break;case`key-text`:await Yi();break;case`link`:await Qi();break;case`number`:await ta();break;case`rich-text`:await ia();break;case`select`:await sa();break;case`timestamp`:await ua();break;case`uid`:await pa();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
|
|
850
1091
|
|
|
851
1092
|
USAGE
|
|
852
1093
|
prismic page-type add-field <field-type> <type-id> <field-id> [flags]
|
|
@@ -876,7 +1117,7 @@ EXAMPLES
|
|
|
876
1117
|
prismic page-type add-field key-text homepage meta_title --tab "SEO"
|
|
877
1118
|
prismic page-type add-field link homepage button --allow-text
|
|
878
1119
|
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
|
|
1120
|
+
prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const ha=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function ga(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a page type's slice zone.
|
|
880
1121
|
|
|
881
1122
|
USAGE
|
|
882
1123
|
prismic page-type connect-slice <type-id> <slice-id> [flags]
|
|
@@ -887,14 +1128,15 @@ ARGUMENTS
|
|
|
887
1128
|
|
|
888
1129
|
FLAGS
|
|
889
1130
|
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
1131
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
890
1132
|
-h, --help Show help for command
|
|
891
1133
|
|
|
892
1134
|
EXAMPLES
|
|
893
1135
|
prismic page-type connect-slice homepage CallToAction
|
|
894
1136
|
prismic page-type connect-slice homepage CallToAction --slice-zone slices
|
|
895
|
-
prismic page-type connect-slice article HeroSection -z body`);return}if(!
|
|
896
|
-
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!
|
|
897
|
-
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let
|
|
1137
|
+
prismic page-type connect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
|
|
1138
|
+
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
|
|
1139
|
+
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await W(o);if(!c.ok){console.error(c.error),process.exitCode=1;return}let l=await U(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${a}/index.json`,l),d;try{let e=await r(u,`utf8`),t=z(ha,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: ${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 f=n??`slices`,p,m;for(let[,e]of Object.entries(d.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===f){p=n,m=t;break}if(p)break}if(!p){if(n){console.error(`Slice zone "${n}" not found in page type "${a}"`),process.exitCode=1;return}let e=Object.keys(d.json)[0]??`Main`;d.json[e]||(d.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};d.json[e][f]=t,p=t,m=f}if(p.config||={choices:{}},p.config.choices||(p.config.choices={}),o in p.config.choices){console.info(`Slice "${o}" is already connected to slice zone "${m}" in ${a}`);return}let h={type:`SharedSlice`};p.config.choices[o]=h;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(`Connected slice "${o}" to slice zone "${m}" in ${a}`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}function _a(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function va(e){return`#write-page-components`}async function ya(){let{values:{help:t,name:r,single:i,types:a},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new page type in a Prismic repository.
|
|
898
1140
|
|
|
899
1141
|
USAGE
|
|
900
1142
|
prismic page-type create <id> [flags]
|
|
@@ -905,10 +1147,11 @@ ARGUMENTS
|
|
|
905
1147
|
FLAGS
|
|
906
1148
|
-n, --name string Display name for the page type
|
|
907
1149
|
--single Create as a singleton (non-repeatable) type
|
|
1150
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
908
1151
|
-h, --help Show help for command
|
|
909
1152
|
|
|
910
1153
|
LEARN MORE
|
|
911
|
-
Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!
|
|
1154
|
+
Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: id`),process.exitCode=1;return}let c={id:o,label:r??ba(o),repeatable:!i,status:!0,format:`page`,json:{Main:i?{}:{uid:{type:`UID`,config:{label:`UID`,placeholder:``}}},"SEO & Metadata":{meta_title:{type:`Text`,config:{label:`Meta Title`,placeholder:`A title of the page used for social media and search engines`}},meta_description:{type:`Text`,config:{label:`Meta Description`,placeholder:`A brief summary of the page`}},meta_image:{type:`Image`,config:{label:`Meta Image`,constraint:{width:2400,height:1260},thumbnails:[]}}}}},l=await U(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/`,l),d=new URL(o+`/`,u),f=new URL(`index.json`,d);try{await n(new URL(`.`,f),{recursive:!0}),await s(f,K(c))}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 ${f.href}`);try{await G({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic page-type add-field`");let p=await Q();if(p?.framework){let e=_a(p.framework),t=va(p.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement a page file`)}}function ba(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const xa=P({id:L(),label:L(),repeatable:N(),status:N(),format:L(),json:I(L(),I(L(),R()))});async function Sa(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a page type's slice zone.
|
|
912
1155
|
|
|
913
1156
|
USAGE
|
|
914
1157
|
prismic page-type disconnect-slice <type-id> <slice-id> [flags]
|
|
@@ -919,14 +1162,15 @@ ARGUMENTS
|
|
|
919
1162
|
|
|
920
1163
|
FLAGS
|
|
921
1164
|
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
1165
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
922
1166
|
-h, --help Show help for command
|
|
923
1167
|
|
|
924
1168
|
EXAMPLES
|
|
925
1169
|
prismic page-type disconnect-slice homepage CallToAction
|
|
926
1170
|
prismic page-type disconnect-slice homepage CallToAction --slice-zone slices
|
|
927
|
-
prismic page-type disconnect-slice article HeroSection -z body`);return}if(!
|
|
928
|
-
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!
|
|
929
|
-
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let
|
|
1171
|
+
prismic page-type disconnect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
|
|
1172
|
+
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
|
|
1173
|
+
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await U(`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=z(xa,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=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){console.error(`Slice zone "${d}" not found in page type "${a}"`),process.exitCode=1;return}if(!f.config?.choices||!(o in f.config.choices)){console.error(`Slice "${o}" is not connected to slice zone "${p}" in ${a}`),process.exitCode=1;return}delete f.config.choices[o];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(`Disconnected slice "${o}" from slice zone "${p}" in ${a}`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ca=P({id:L(),label:L(),repeatable:N(),status:N(),format:F(L()),json:I(L(),I(L(),R()))});async function wa(){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
1174
|
|
|
931
1175
|
USAGE
|
|
932
1176
|
prismic page-type list [flags]
|
|
@@ -937,7 +1181,7 @@ FLAGS
|
|
|
937
1181
|
|
|
938
1182
|
EXAMPLES
|
|
939
1183
|
prismic page-type list
|
|
940
|
-
prismic page-type list --json`);return}let a=await
|
|
1184
|
+
prismic page-type list --json`);return}let a=await U(`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=z(Ca,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 Ta=P({id:L(),label:L(),repeatable:N(),status:N(),format:F(L()),json:I(L(),I(L(),R()))});async function Ea(){let{values:{help:t,y:n,types:i},positionals:[a]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a page type from the project.
|
|
941
1185
|
|
|
942
1186
|
USAGE
|
|
943
1187
|
prismic page-type remove <type-id> [flags]
|
|
@@ -947,12 +1191,13 @@ ARGUMENTS
|
|
|
947
1191
|
|
|
948
1192
|
FLAGS
|
|
949
1193
|
-y Confirm removal
|
|
1194
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
950
1195
|
-h, --help Show help for command
|
|
951
1196
|
|
|
952
1197
|
EXAMPLES
|
|
953
1198
|
prismic page-type remove homepage
|
|
954
|
-
prismic page-type remove homepage -y`);return}if(!
|
|
955
|
-
`),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let
|
|
1199
|
+
prismic page-type remove homepage -y`);return}if(!a){console.error(`Missing required argument: type-id
|
|
1200
|
+
`),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let s=await U(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${a}/`,s),l=new URL(`index.json`,c),u;try{let e=await r(l,`utf8`),t=z(Ta,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}`),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(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove page type "${a}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{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 "${a}"`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Da=P({id:L(),label:L(),repeatable:N(),status:N(),format:F(L()),json:I(L(),I(L(),R()))});async function Oa(){let{values:{help:t,tab:n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a page type.
|
|
956
1201
|
|
|
957
1202
|
USAGE
|
|
958
1203
|
prismic page-type remove-field <type-id> <field-id> [flags]
|
|
@@ -963,13 +1208,14 @@ ARGUMENTS
|
|
|
963
1208
|
|
|
964
1209
|
FLAGS
|
|
965
1210
|
--tab string Specific tab (searches all tabs if not specified)
|
|
1211
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
966
1212
|
-h, --help Show help for command
|
|
967
1213
|
|
|
968
1214
|
EXAMPLES
|
|
969
1215
|
prismic page-type remove-field homepage title
|
|
970
|
-
prismic page-type remove-field homepage meta_title --tab "SEO & Metadata"`);return}if(!
|
|
971
|
-
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!
|
|
972
|
-
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let
|
|
1216
|
+
prismic page-type remove-field homepage meta_title --tab "SEO & Metadata"`);return}if(!a){console.error(`Missing required argument: type-id
|
|
1217
|
+
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1218
|
+
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let c=await U(`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=z(Da,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}if(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}let d;if(n){if(!u.json[n]){console.error(`Tab "${n}" not found in page type "${a}"`),console.error(`Available tabs: ${Object.keys(u.json).join(`, `)}`),process.exitCode=1;return}if(!(o in u.json[n])){console.error(`Field "${o}" not found in tab "${n}"`),process.exitCode=1;return}delete u.json[n][o],d=n}else{for(let[e,t]of Object.entries(u.json))if(o in t){delete t[o],d=e;break}if(!d){console.error(`Field "${o}" not found in any tab of page type "${a}"`),process.exitCode=1;return}}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(`Removed field "${o}" from tab "${d}" in page type "${a}"`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const ka=P({id:L(),label:L(),repeatable:N(),status:N(),format:F(L()),json:I(L(),I(L(),R()))});async function Aa(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a page type's display name (label).
|
|
973
1219
|
|
|
974
1220
|
USAGE
|
|
975
1221
|
prismic page-type set-name <type-id> <new-name> [flags]
|
|
@@ -979,13 +1225,14 @@ ARGUMENTS
|
|
|
979
1225
|
new-name New display name (required)
|
|
980
1226
|
|
|
981
1227
|
FLAGS
|
|
1228
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
982
1229
|
-h, --help Show help for command
|
|
983
1230
|
|
|
984
1231
|
EXAMPLES
|
|
985
1232
|
prismic page-type set-name homepage "Home Page"
|
|
986
|
-
prismic page-type set-name blog_post "Blog Post"`);return}if(!
|
|
987
|
-
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!
|
|
988
|
-
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let
|
|
1233
|
+
prismic page-type set-name blog_post "Blog Post"`);return}if(!i){console.error(`Missing required argument: type-id
|
|
1234
|
+
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: new-name
|
|
1235
|
+
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let o=await U(`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=z(ka,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}l.label=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(`Renamed page type "${i}" to "${a}"`);try{await G({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const ja=P({id:L(),label:L(),repeatable:N(),status:N(),format:F(L()),json:I(L(),I(L(),R()))});async function Ma(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set whether a page type is repeatable.
|
|
989
1236
|
|
|
990
1237
|
USAGE
|
|
991
1238
|
prismic page-type set-repeatable <type-id> <true|false> [flags]
|
|
@@ -995,13 +1242,14 @@ ARGUMENTS
|
|
|
995
1242
|
true|false Repeatable value (required)
|
|
996
1243
|
|
|
997
1244
|
FLAGS
|
|
1245
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
998
1246
|
-h, --help Show help for command
|
|
999
1247
|
|
|
1000
1248
|
EXAMPLES
|
|
1001
1249
|
prismic page-type set-repeatable homepage true
|
|
1002
|
-
prismic page-type set-repeatable settings false`);return}if(!
|
|
1003
|
-
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(!
|
|
1004
|
-
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(
|
|
1250
|
+
prismic page-type set-repeatable settings false`);return}if(!i){console.error(`Missing required argument: type-id
|
|
1251
|
+
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: true|false
|
|
1252
|
+
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(a!==`true`&&a!==`false`){console.error(`Invalid value: "${a}". Must be "true" or "false".`),process.exitCode=1;return}let o=a===`true`,c=await U(`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=z(ja,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}if(u.format!==`page`){console.error(`"${i}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}u.repeatable=o;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}let d=o?`repeatable`:`singleton`;console.info(`Set page type "${i}" to ${d}`);try{await G({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Na=P({id:L(),label:L(),repeatable:N(),status:N(),format:F(L()),json:I(L(),I(L(),R()))});async function Pa(){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
1253
|
|
|
1006
1254
|
USAGE
|
|
1007
1255
|
prismic page-type view <type-id> [flags]
|
|
@@ -1016,7 +1264,7 @@ FLAGS
|
|
|
1016
1264
|
EXAMPLES
|
|
1017
1265
|
prismic page-type view homepage
|
|
1018
1266
|
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
|
|
1267
|
+
`),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await U(`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=z(Na,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 Fa(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await ya();break;case`list`:await wa();break;case`view`:await Pa();break;case`remove`:await Ea();break;case`set-name`:await Aa();break;case`set-repeatable`:await Ma();break;case`add-field`:await ma();break;case`remove-field`:await Oa();break;case`connect-slice`:await ga();break;case`disconnect-slice`:await Sa();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
|
|
1020
1268
|
|
|
1021
1269
|
USAGE
|
|
1022
1270
|
prismic page-type <command> [flags]
|
|
@@ -1037,7 +1285,7 @@ FLAGS
|
|
|
1037
1285
|
-h, --help Show help for command
|
|
1038
1286
|
|
|
1039
1287
|
LEARN MORE
|
|
1040
|
-
Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function
|
|
1288
|
+
Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function Ia(){let{values:{help:t,name:n,repo:r=await J()},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
1289
|
|
|
1042
1290
|
By default, this command reads the repository from prismic.config.json at the
|
|
1043
1291
|
project root.
|
|
@@ -1054,7 +1302,21 @@ FLAGS
|
|
|
1054
1302
|
-h, --help Show help for command
|
|
1055
1303
|
|
|
1056
1304
|
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
|
|
1305
|
+
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 V()){za();return}let a=La(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await Ra(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof X?za():(console.error(`Failed to add preview: ${K(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function La(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 Ra(e,t){return await Y(new URL(`/previews/new`,await B(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function za(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ba(){let{values:{help:t,repo:n=await J(),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.
|
|
1306
|
+
|
|
1307
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1308
|
+
project root.
|
|
1309
|
+
|
|
1310
|
+
USAGE
|
|
1311
|
+
prismic preview get-simulator [flags]
|
|
1312
|
+
|
|
1313
|
+
FLAGS
|
|
1314
|
+
--json Output as JSON
|
|
1315
|
+
-r, --repo string Repository domain
|
|
1316
|
+
-h, --help Show help for command
|
|
1317
|
+
|
|
1318
|
+
LEARN MORE
|
|
1319
|
+
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 V()){Ua();return}let i=await Ha(n);if(!i.ok){i.error instanceof X?Ua():j(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 Va=P({simulator_url:F(L())});async function Ha(e){return await Y(new URL(`/core/repository`,await B(e)),{schema:Va})}function Ua(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Wa(){let{values:{help:t,repo:n=await J(),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
1320
|
|
|
1059
1321
|
By default, this command reads the repository from prismic.config.json at the
|
|
1060
1322
|
project root.
|
|
@@ -1068,7 +1330,7 @@ FLAGS
|
|
|
1068
1330
|
-h, --help Show help for command
|
|
1069
1331
|
|
|
1070
1332
|
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
|
|
1333
|
+
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 V()){qa();return}let i=await Ka(n);if(!i.ok){i.error instanceof X?qa():j(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 Ga=P({results:M(P({id:L(),label:L(),url:L()}))});async function Ka(e){return await Y(new URL(`/core/repository/preview_configs`,await B(e)),{schema:Ga})}function qa(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ja(){let{values:{help:t,repo:n=await J()},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
1334
|
|
|
1073
1335
|
By default, this command reads the repository from prismic.config.json at the
|
|
1074
1336
|
project root.
|
|
@@ -1084,7 +1346,20 @@ FLAGS
|
|
|
1084
1346
|
-h, --help Show help for command
|
|
1085
1347
|
|
|
1086
1348
|
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
|
|
1349
|
+
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 V()){Xa();return}let i=await Ka(n);if(!i.ok){i.error instanceof X?Xa():(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 Ya(n,a.id);if(!o.ok){o.error instanceof X?Xa():(console.error(`Failed to remove preview: ${K(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function Ya(e,t){return await Y(new URL(`/previews/delete/${t}`,await B(e)),{method:`POST`,body:{}})}function Xa(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Za(){let{values:{help:t,repo:n=await J()}}=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.
|
|
1350
|
+
|
|
1351
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1352
|
+
project root.
|
|
1353
|
+
|
|
1354
|
+
USAGE
|
|
1355
|
+
prismic preview remove-simulator [flags]
|
|
1356
|
+
|
|
1357
|
+
FLAGS
|
|
1358
|
+
-r, --repo string Repository domain
|
|
1359
|
+
-h, --help Show help for command
|
|
1360
|
+
|
|
1361
|
+
LEARN MORE
|
|
1362
|
+
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 V()){$a();return}let r=await Qa(n);if(!r.ok){r.error instanceof X?$a():(console.error(`Failed to remove simulator URL: ${K(r.value)}`),process.exitCode=1);return}console.info(`Simulator URL removed.`)}async function Qa(e){return await Y(new URL(`/core/repository`,await B(e)),{method:`PATCH`,body:{simulator_url:``}})}function $a(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function eo(){let{values:{help:t,repo:n=await J()},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
1363
|
|
|
1089
1364
|
By default, this command reads the repository from prismic.config.json at the
|
|
1090
1365
|
project root.
|
|
@@ -1101,22 +1376,48 @@ FLAGS
|
|
|
1101
1376
|
-h, --help Show help for command
|
|
1102
1377
|
|
|
1103
1378
|
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
|
|
1379
|
+
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 V()){no();return}let a=La(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await Ka(n);if(!o.ok){o.error instanceof X?no():(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 to(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof X?no():(console.error(`Failed to update preview: ${K(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function to(e,t,n){return await Y(new URL(`/previews/save/${t}`,await B(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function no(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ro(){let{values:{help:t,repo:n=await J()},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.
|
|
1380
|
+
|
|
1381
|
+
If the URL pathname does not end with /slice-simulator, it is appended
|
|
1382
|
+
automatically.
|
|
1383
|
+
|
|
1384
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1385
|
+
project root.
|
|
1386
|
+
|
|
1387
|
+
USAGE
|
|
1388
|
+
prismic preview set-simulator <url> [flags]
|
|
1389
|
+
|
|
1390
|
+
ARGUMENTS
|
|
1391
|
+
<url> Simulator URL (e.g. https://example.com/slice-simulator)
|
|
1392
|
+
|
|
1393
|
+
FLAGS
|
|
1394
|
+
-r, --repo string Repository domain
|
|
1395
|
+
-h, --help Show help for command
|
|
1396
|
+
|
|
1397
|
+
EXAMPLES
|
|
1398
|
+
prismic preview set-simulator https://my-site.com
|
|
1399
|
+
prismic preview set-simulator http://localhost:3000/slice-simulator
|
|
1400
|
+
|
|
1401
|
+
LEARN MORE
|
|
1402
|
+
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 V()){oo();return}let i=io(r);if(!i){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let a=await ao(n,i);if(!a.ok){a.error instanceof X?oo():(console.error(`Failed to set simulator URL: ${K(a.value)}`),process.exitCode=1);return}console.info(`Simulator URL set: ${i}`)}function io(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 ao(e,t){return await Y(new URL(`/core/repository`,await B(e)),{method:`PATCH`,body:{simulator_url:t}})}function oo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function so(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await Ia();break;case`list`:await Wa();break;case`remove`:await Ja();break;case`set-name`:await eo();break;case`set-simulator`:await ro();break;case`get-simulator`:await Ba();break;case`remove-simulator`:await Za();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
|
|
1105
1403
|
|
|
1106
1404
|
USAGE
|
|
1107
1405
|
prismic preview <command> [flags]
|
|
1108
1406
|
|
|
1109
1407
|
COMMANDS
|
|
1110
|
-
add
|
|
1111
|
-
list
|
|
1112
|
-
remove
|
|
1113
|
-
set-name
|
|
1408
|
+
add Add a preview configuration
|
|
1409
|
+
list List preview configurations
|
|
1410
|
+
remove Remove a preview configuration
|
|
1411
|
+
set-name Update a preview's name
|
|
1412
|
+
set-simulator Set the slice simulator URL
|
|
1413
|
+
get-simulator Show the slice simulator URL
|
|
1414
|
+
remove-simulator Remove the slice simulator URL
|
|
1114
1415
|
|
|
1115
1416
|
FLAGS
|
|
1116
1417
|
-h, --help Show help for command
|
|
1117
1418
|
|
|
1118
1419
|
LEARN MORE
|
|
1119
|
-
Use \`prismic preview <command> --help\` for more information about a command.`)}}
|
|
1420
|
+
Use \`prismic preview <command> --help\` for more information about a command.`)}}async function co(){let{values:{help:t,repo:r=await J(),"dry-run":i,"types-only":a,"slices-only":o,json:c,types:l}}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Pull custom types and slices from Prismic to local files.
|
|
1120
1421
|
|
|
1121
1422
|
By default, this command reads the repository from prismic.config.json at the
|
|
1122
1423
|
project root.
|
|
@@ -1130,15 +1431,16 @@ FLAGS
|
|
|
1130
1431
|
--types-only Only pull custom types
|
|
1131
1432
|
--slices-only Only pull slices
|
|
1132
1433
|
--json Output as JSON
|
|
1434
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1133
1435
|
-h, --help Show help for command
|
|
1134
1436
|
|
|
1135
1437
|
EXAMPLES
|
|
1136
1438
|
prismic pull
|
|
1137
1439
|
prismic pull --repo my-repo
|
|
1138
1440
|
prismic pull --dry-run
|
|
1139
|
-
prismic pull --types-only`);return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await
|
|
1140
|
-
Writing custom types:`);let e=new URL(`customtypes/`,
|
|
1141
|
-
Writing slices:`);let e=await
|
|
1441
|
+
prismic pull --types-only`);return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await V()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}c||console.info(`Pulling from repository: ${r}\n`);let u=!o,d=!a,[f,p]=await Promise.all([u?Ln(r):Promise.resolve({ok:!0,value:[]}),d?Rn(r):Promise.resolve({ok:!0,value:[]})]);if(!f.ok){console.error(`Failed to fetch custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch slices: ${p.error}`),process.exitCode=1;return}let m=f.value,h=p.value;if(c||(u&&console.info(`Fetching custom types... ${m.length} types`),d&&console.info(`Fetching slices... ${h.length} slices`)),i){if(c)console.info(K({customTypes:m,slices:h}));else{if(console.info(``),u&&m.length>0){console.info(`Would write custom types:`);for(let e of m)console.info(` customtypes/${e.id}/index.json`)}if(d&&h.length>0){let e=lo(await jn());console.info(`Would write slices:`);for(let t of h)console.info(` ${e}${Pn(t.name)}/model.json`)}console.info(`\nDry run complete: ${m.length} custom types, ${h.length} slices`)}return}let g=await U(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`.`,g),v=[],y=[];if(u&&m.length>0){c||console.info(`
|
|
1442
|
+
Writing custom types:`);let e=new URL(`customtypes/`,_);for(let t of m){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`;v.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(d&&h.length>0){c||console.info(`
|
|
1443
|
+
Writing slices:`);let e=await jn();for(let t of h){let r=new URL(`${Pn(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await s(i,K(t));let a=`${lo(e)}${Pn(t.name)}/model.json`;y.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}}}if(c?console.info(K({writtenTypes:v,writtenSlices:y})):console.info(`\nPull complete: ${v.length} custom types, ${y.length} slices`),!c)try{await G({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}function lo(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}function uo(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 fo(){let{values:{help:t,repo:n=await J(),"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.
|
|
1142
1444
|
|
|
1143
1445
|
By default, this command reads the repository from prismic.config.json at the
|
|
1144
1446
|
project root.
|
|
@@ -1160,10 +1462,10 @@ EXAMPLES
|
|
|
1160
1462
|
prismic push --repo my-repo
|
|
1161
1463
|
prismic push --dry-run
|
|
1162
1464
|
prismic push --types-only
|
|
1163
|
-
prismic push --delete`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await
|
|
1164
|
-
No changes to push.`);return}if(r){if(s)console.info(
|
|
1165
|
-
Pushing custom types:`);for(let e of v.toInsert){let t=await
|
|
1166
|
-
Pushing slices:`);for(let e of y.toInsert){let t=await
|
|
1465
|
+
prismic push --delete`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await V()){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?zn():Promise.resolve({ok:!0,value:[]}),l?Bn():Promise.resolve({ok:!0,value:[]}),c?Ln(n):Promise.resolve({ok:!0,value:[]}),l?Rn(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?uo([...m],[...g]):{toInsert:[],toUpdate:[],toDelete:[]},y=l?uo([...h],[..._]):{toInsert:[],toUpdate:[],toDelete:[]};o||(v.toDelete=[],y.toDelete=[]);let b=v.toInsert.length+v.toUpdate.length+v.toDelete.length+y.toInsert.length+y.toUpdate.length+y.toDelete.length;if(b===0){s?console.info(K({customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}})):console.info(`
|
|
1466
|
+
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: ${b} changes would be made`)}return}let x={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(`
|
|
1467
|
+
Pushing custom types:`);for(let e of v.toInsert){let t=await Vn(n,e);if(!t.ok){console.error(`Failed to insert custom type ${e.id}: ${t.error}`),process.exitCode=1;return}x.customTypes.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of v.toUpdate){let t=await Hn(n,e);if(!t.ok){console.error(`Failed to update custom type ${e.id}: ${t.error}`),process.exitCode=1;return}x.customTypes.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of v.toDelete){let t=await Un(n,e);if(!t.ok){console.error(`Failed to delete custom type ${e}: ${t.error}`),process.exitCode=1;return}x.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(`
|
|
1468
|
+
Pushing slices:`);for(let e of y.toInsert){let t=await Wn(n,e);if(!t.ok){console.error(`Failed to insert slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of y.toUpdate){let t=await Gn(n,e);if(!t.ok){console.error(`Failed to update slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of y.toDelete){let t=await Kn(n,e);if(!t.ok){console.error(`Failed to delete slice ${e}: ${t.error}`),process.exitCode=1;return}x.slices.deleted.push(e),s||console.info(` - ${e}`)}}if(s)console.info(K(x));else{let e=x.customTypes.inserted.length+x.customTypes.updated.length+x.customTypes.deleted.length+x.slices.inserted.length+x.slices.updated.length+x.slices.deleted.length;console.info(`\nPush complete: ${e} changes`)}}const po=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;function mo(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ho(e){switch(e){case`nuxt`:return`#configure-the-modules-prismic-client`;default:return`#set-up-a-prismic-client`}}async function go(){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.
|
|
1167
1469
|
|
|
1168
1470
|
Creates prismic.config.json in the current directory. If a config file already
|
|
1169
1471
|
exists, use --replace to update it with the new repository.
|
|
@@ -1182,7 +1484,20 @@ FLAGS
|
|
|
1182
1484
|
-h, --help Show help for command
|
|
1183
1485
|
|
|
1184
1486
|
LEARN MORE
|
|
1185
|
-
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(!
|
|
1487
|
+
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(!po.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 V()){vo();return}let o=await Jr();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 _o(a,n);if(!s.ok){s.error instanceof X?vo():(console.error(`Failed to create repository: ${K(s.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await Xr({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 qr({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 B(a)}`);let c=await Q();if(c?.framework){let e=mo(c.framework),t=ho(c.framework),n=Ti(c),r=n?`creating ${n}`:`configuring Prismic`;console.info(),console.info(`Next: Run \`prismic docs ${e}${t}\` for instructions on ${r}`)}}async function _o(e,t=e){return await Y(new URL(`/app/dashboard/repositories`,await En()),{method:`POST`,body:{domain:e,name:t,framework:`next`,plan:`personal`,usageIntent:`Exploring Prismic's features for future projects.`,usageIntentIndex:0}})}function vo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const yo=P({repository:P({api_access:L()})});async function bo(){let{values:{help:t,repo:n=await J()}}=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.
|
|
1488
|
+
|
|
1489
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1490
|
+
project root.
|
|
1491
|
+
|
|
1492
|
+
USAGE
|
|
1493
|
+
prismic repo get-access [flags]
|
|
1494
|
+
|
|
1495
|
+
FLAGS
|
|
1496
|
+
-r, --repo string Repository domain
|
|
1497
|
+
-h, --help Show help for command
|
|
1498
|
+
|
|
1499
|
+
LEARN MORE
|
|
1500
|
+
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 V()){So();return}let r=await xo(n);if(!r.ok){r.error instanceof X?So():(console.error(`Failed to get repository access: ${K(r.value)}`),process.exitCode=1);return}console.info(r.value.repository.api_access)}async function xo(e){let t=await B(e);return await Y(new URL(`syncState`,t),{schema:yo})}function So(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Co=P({repositories:M(P({domain:L(),name:F(L()),role:L()}))});async function wo(){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.
|
|
1186
1501
|
|
|
1187
1502
|
USAGE
|
|
1188
1503
|
prismic repo list [flags]
|
|
@@ -1192,7 +1507,23 @@ FLAGS
|
|
|
1192
1507
|
-h, --help Show help for command
|
|
1193
1508
|
|
|
1194
1509
|
LEARN MORE
|
|
1195
|
-
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await
|
|
1510
|
+
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await V()){Eo();return}let r=await To();if(!r.ok){r.error instanceof X?Eo():(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 B(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 To(){return await Y(new URL(`profile`,await xn()),{schema:Co})}function Eo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Do=[`private`,`public`,`open`];async function Oo(){let{values:{help:t,repo:n=await J()},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.
|
|
1511
|
+
|
|
1512
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1513
|
+
project root.
|
|
1514
|
+
|
|
1515
|
+
USAGE
|
|
1516
|
+
prismic repo set-access <level> [flags]
|
|
1517
|
+
|
|
1518
|
+
ARGUMENTS
|
|
1519
|
+
<level> The access level to set (private, public, open)
|
|
1520
|
+
|
|
1521
|
+
FLAGS
|
|
1522
|
+
-r, --repo string Repository domain
|
|
1523
|
+
-h, --help Show help for command
|
|
1524
|
+
|
|
1525
|
+
LEARN MORE
|
|
1526
|
+
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(!Do.includes(r)){console.error(`Invalid access level: ${r}. Must be one of: ${Do.join(`, `)}`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await V()){Ao();return}let i=await ko(n,r);if(!i.ok){i.error instanceof X?Ao():(console.error(`Failed to set repository access: ${K(i.value)}`),process.exitCode=1);return}console.info(`Repository access set to: ${r}`)}async function ko(e,t){let n=await B(e);return await Y(new URL(`settings/security/apiaccess`,n),{method:`POST`,body:{api_access:t}})}function Ao(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function jo(){let{values:{help:t,repo:n=await J()},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.
|
|
1196
1527
|
|
|
1197
1528
|
By default, this command reads the repository from prismic.config.json at the
|
|
1198
1529
|
project root.
|
|
@@ -1208,7 +1539,7 @@ FLAGS
|
|
|
1208
1539
|
-h, --help Show help for command
|
|
1209
1540
|
|
|
1210
1541
|
LEARN MORE
|
|
1211
|
-
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
|
|
1542
|
+
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 V()){No();return}let i=await Mo(n,r);if(!i.ok){i.error instanceof X?No():j(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 Mo(e,t){let n=await B(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await Y(r,{method:`POST`,body:i,schema:P({repository:P({name:L()})})})}function No(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Po=P({repositories:M(P({domain:L(),name:F(L())}))});async function Fo(){let{values:{help:t,repo:n=await J(),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.
|
|
1212
1543
|
|
|
1213
1544
|
By default, this command reads the repository from prismic.config.json at the
|
|
1214
1545
|
project root.
|
|
@@ -1222,7 +1553,7 @@ FLAGS
|
|
|
1222
1553
|
-h, --help Show help for command
|
|
1223
1554
|
|
|
1224
1555
|
LEARN MORE
|
|
1225
|
-
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
|
|
1556
|
+
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 B(n);if(r){Lo(i.toString()),console.info(`Opening ${i}`);return}if(!await V()){Ro();return}let a=await Io();if(!a.ok){a.error instanceof X?Ro():(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 Io(){return await Y(new URL(`profile`,await xn()),{schema:Po})}function Lo(e){f(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function Ro(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function zo(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await go();break;case`list`:await wo();break;case`view`:await Fo();break;case`get-access`:await bo();break;case`set-access`:await Oo();break;case`set-name`:await jo();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
|
|
1226
1557
|
|
|
1227
1558
|
USAGE
|
|
1228
1559
|
prismic repo <command> [flags]
|
|
@@ -1231,13 +1562,15 @@ COMMANDS
|
|
|
1231
1562
|
create Create a new Prismic repository
|
|
1232
1563
|
list List all repositories
|
|
1233
1564
|
view View repository details
|
|
1565
|
+
get-access Get Content API access level
|
|
1566
|
+
set-access Set Content API access level
|
|
1234
1567
|
set-name Set repository display name
|
|
1235
1568
|
|
|
1236
1569
|
FLAGS
|
|
1237
1570
|
-h, --help Show help for command
|
|
1238
1571
|
|
|
1239
1572
|
LEARN MORE
|
|
1240
|
-
Use \`prismic repo <command> --help\` for more information about a command.`)}}async function
|
|
1573
|
+
Use \`prismic repo <command> --help\` for more information about a command.`)}}function Bo(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Vo(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Ho(){let{values:{help:t,variation:n,label:r,default:i,"true-label":a,"false-label":o,types:c},positionals:[l,u]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing slice.
|
|
1241
1574
|
|
|
1242
1575
|
USAGE
|
|
1243
1576
|
prismic slice add-field boolean <slice-id> <field-id> [flags]
|
|
@@ -1248,18 +1581,19 @@ ARGUMENTS
|
|
|
1248
1581
|
|
|
1249
1582
|
FLAGS
|
|
1250
1583
|
-v, --variation string Target variation (default: first variation)
|
|
1251
|
-
-l, --label string Display label for the field
|
|
1584
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1252
1585
|
--default Set default value to true
|
|
1253
1586
|
--true-label string Label shown when toggle is on
|
|
1254
1587
|
--false-label string Label shown when toggle is off
|
|
1588
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1255
1589
|
-h, --help Show help for command
|
|
1256
1590
|
|
|
1257
1591
|
EXAMPLES
|
|
1258
1592
|
prismic slice add-field boolean my_slice featured
|
|
1259
1593
|
prismic slice add-field boolean hero show_overlay --default
|
|
1260
|
-
prismic slice add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!
|
|
1261
|
-
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1262
|
-
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1594
|
+
prismic slice add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: slice-id
|
|
1595
|
+
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
1596
|
+
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let d=await W(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:`Boolean`,config:{label:r??q(u),...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};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}" (Boolean) to "${m.id}" variation in ${l}`);try{await G({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await Q();if(g?.framework){let e=Bo(g.framework),t=Vo(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function Uo(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Wo(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Go(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing slice.
|
|
1263
1597
|
|
|
1264
1598
|
USAGE
|
|
1265
1599
|
prismic slice add-field color <slice-id> <field-id> [flags]
|
|
@@ -1270,16 +1604,17 @@ ARGUMENTS
|
|
|
1270
1604
|
|
|
1271
1605
|
FLAGS
|
|
1272
1606
|
-v, --variation string Target variation (default: first variation)
|
|
1273
|
-
-l, --label string Display label for the field
|
|
1607
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1274
1608
|
-p, --placeholder string Placeholder text
|
|
1609
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1275
1610
|
-h, --help Show help for command
|
|
1276
1611
|
|
|
1277
1612
|
EXAMPLES
|
|
1278
1613
|
prismic slice add-field color my_slice background_color
|
|
1279
1614
|
prismic slice add-field color hero accent --label "Accent Color"
|
|
1280
|
-
prismic slice add-field color banner theme_color --variation "dark"`);return}if(!
|
|
1281
|
-
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1282
|
-
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1615
|
+
prismic slice add-field color banner theme_color --variation "dark"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1616
|
+
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1617
|
+
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let l=await W(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Color`,config:{label:r??q(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,K(u))}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 "${c}" (Color) to "${f.id}" variation in ${o}`);try{await G({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let m=await Q();if(m?.framework){let e=Uo(m.framework),t=Wo(m.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function Ko(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function qo(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Jo(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date picker field to an existing slice.
|
|
1283
1618
|
|
|
1284
1619
|
USAGE
|
|
1285
1620
|
prismic slice add-field date <slice-id> <field-id> [flags]
|
|
@@ -1290,16 +1625,17 @@ ARGUMENTS
|
|
|
1290
1625
|
|
|
1291
1626
|
FLAGS
|
|
1292
1627
|
-v, --variation string Target variation (default: first variation)
|
|
1293
|
-
-l, --label string Display label for the field
|
|
1628
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1294
1629
|
-p, --placeholder string Placeholder text
|
|
1630
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1295
1631
|
-h, --help Show help for command
|
|
1296
1632
|
|
|
1297
1633
|
EXAMPLES
|
|
1298
1634
|
prismic slice add-field date my_slice publish_date
|
|
1299
1635
|
prismic slice add-field date event start_date --label "Start Date"
|
|
1300
|
-
prismic slice add-field date promo end_date --variation "countdown"`);return}if(!
|
|
1301
|
-
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1302
|
-
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1636
|
+
prismic slice add-field date promo end_date --variation "countdown"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1637
|
+
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1638
|
+
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let l=await W(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Date`,config:{label:r??q(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,K(u))}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 "${c}" (Date) to "${f.id}" variation in ${o}`);try{await G({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let m=await Q();if(m?.framework){let e=Ko(m.framework),t=qo(m.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function Yo(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Xo(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Zo(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed (oEmbed) field to an existing slice.
|
|
1303
1639
|
|
|
1304
1640
|
USAGE
|
|
1305
1641
|
prismic slice add-field embed <slice-id> <field-id> [flags]
|
|
@@ -1310,16 +1646,17 @@ ARGUMENTS
|
|
|
1310
1646
|
|
|
1311
1647
|
FLAGS
|
|
1312
1648
|
-v, --variation string Target variation (default: first variation)
|
|
1313
|
-
-l, --label string Display label for the field
|
|
1649
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1314
1650
|
-p, --placeholder string Placeholder text
|
|
1651
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1315
1652
|
-h, --help Show help for command
|
|
1316
1653
|
|
|
1317
1654
|
EXAMPLES
|
|
1318
1655
|
prismic slice add-field embed my_slice video
|
|
1319
1656
|
prismic slice add-field embed gallery media --label "Media Embed"
|
|
1320
|
-
prismic slice add-field embed social tweet --variation "twitter"`);return}if(!
|
|
1321
|
-
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1322
|
-
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1657
|
+
prismic slice add-field embed social tweet --variation "twitter"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1658
|
+
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1659
|
+
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let l=await W(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Embed`,config:{label:r??q(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,K(u))}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 "${c}" (Embed) to "${f.id}" variation in ${o}`);try{await G({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let m=await Q();if(m?.framework){let e=Yo(m.framework),t=Xo(m.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function Qo(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function $o(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function es(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geographic coordinates field to an existing slice.
|
|
1323
1660
|
|
|
1324
1661
|
USAGE
|
|
1325
1662
|
prismic slice add-field geo-point <slice-id> <field-id> [flags]
|
|
@@ -1330,15 +1667,16 @@ ARGUMENTS
|
|
|
1330
1667
|
|
|
1331
1668
|
FLAGS
|
|
1332
1669
|
-v, --variation string Target variation (default: first variation)
|
|
1333
|
-
-l, --label string Display label for the field
|
|
1670
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1671
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1334
1672
|
-h, --help Show help for command
|
|
1335
1673
|
|
|
1336
1674
|
EXAMPLES
|
|
1337
1675
|
prismic slice add-field geo-point my_slice location
|
|
1338
1676
|
prismic slice add-field geo-point store coordinates --label "Store Location"
|
|
1339
|
-
prismic slice add-field geo-point map marker --variation "interactive"`);return}if(!
|
|
1340
|
-
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1341
|
-
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1677
|
+
prismic slice add-field geo-point map marker --variation "interactive"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1678
|
+
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1679
|
+
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let c=await W(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:`GeoPoint`,config:{label:r??q(o)}};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}" (GeoPoint) to "${d.id}" variation in ${a}`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let p=await Q();if(p?.framework){let e=Qo(p.framework),t=$o(p.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ts(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ns(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function rs(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing slice.
|
|
1342
1680
|
|
|
1343
1681
|
USAGE
|
|
1344
1682
|
prismic slice add-field image <slice-id> <field-id> [flags]
|
|
@@ -1349,15 +1687,16 @@ ARGUMENTS
|
|
|
1349
1687
|
|
|
1350
1688
|
FLAGS
|
|
1351
1689
|
-v, --variation string Target variation (default: first variation)
|
|
1352
|
-
-l, --label string Display label for the field
|
|
1690
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1691
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1353
1692
|
-h, --help Show help for command
|
|
1354
1693
|
|
|
1355
1694
|
EXAMPLES
|
|
1356
1695
|
prismic slice add-field image my_slice background
|
|
1357
1696
|
prismic slice add-field image hero banner --label "Hero Banner"
|
|
1358
|
-
prismic slice add-field image gallery thumbnail --variation "grid"`);return}if(!
|
|
1359
|
-
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1360
|
-
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1697
|
+
prismic slice add-field image gallery thumbnail --variation "grid"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1698
|
+
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1699
|
+
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let c=await W(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:`Image`,config:{label:r??q(o)}};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}" (Image) to "${d.id}" variation in ${a}`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let p=await Q();if(p?.framework){let e=ts(p.framework),t=ns(p.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function is(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function as(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function os(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing slice.
|
|
1361
1700
|
|
|
1362
1701
|
USAGE
|
|
1363
1702
|
prismic slice add-field key-text <slice-id> <field-id> [flags]
|
|
@@ -1368,16 +1707,17 @@ ARGUMENTS
|
|
|
1368
1707
|
|
|
1369
1708
|
FLAGS
|
|
1370
1709
|
-v, --variation string Target variation (default: first variation)
|
|
1371
|
-
-l, --label string Display label for the field
|
|
1710
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1372
1711
|
-p, --placeholder string Placeholder text
|
|
1712
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1373
1713
|
-h, --help Show help for command
|
|
1374
1714
|
|
|
1375
1715
|
EXAMPLES
|
|
1376
1716
|
prismic slice add-field key-text my_slice title
|
|
1377
1717
|
prismic slice add-field key-text hero heading --label "Heading"
|
|
1378
|
-
prismic slice add-field key-text cta button_text --placeholder "Enter button text"`);return}if(!
|
|
1379
|
-
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1380
|
-
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1718
|
+
prismic slice add-field key-text cta button_text --placeholder "Enter button text"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1719
|
+
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1720
|
+
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let l=await W(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Text`,config:{label:r??q(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,K(u))}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 "${c}" (Text) to "${f.id}" variation in ${o}`);try{await G({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let m=await Q();if(m?.framework){let e=is(m.framework),t=as(m.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ss(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function cs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ls(){let{values:{help:t,variation:n,label:r,placeholder:i,"allow-text":a,"allow-target-blank":o,repeatable:c,types:l},positionals:[u,d]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing slice.
|
|
1381
1721
|
|
|
1382
1722
|
USAGE
|
|
1383
1723
|
prismic slice add-field link <slice-id> <field-id> [flags]
|
|
@@ -1388,20 +1728,21 @@ ARGUMENTS
|
|
|
1388
1728
|
|
|
1389
1729
|
FLAGS
|
|
1390
1730
|
-v, --variation string Target variation (default: first variation)
|
|
1391
|
-
-l, --label string Display label for the field
|
|
1731
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1392
1732
|
-p, --placeholder string Placeholder text
|
|
1393
1733
|
--allow-text Allow text with link
|
|
1394
1734
|
--allow-target-blank Allow opening link in new tab
|
|
1395
1735
|
--repeatable Allow multiple links
|
|
1736
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1396
1737
|
-h, --help Show help for command
|
|
1397
1738
|
|
|
1398
1739
|
EXAMPLES
|
|
1399
1740
|
prismic slice add-field link my_slice button
|
|
1400
1741
|
prismic slice add-field link cta primary_link --allow-text
|
|
1401
1742
|
prismic slice add-field link navigation links --repeatable
|
|
1402
|
-
prismic slice add-field link hero cta --allow-text --allow-target-blank`);return}if(!
|
|
1403
|
-
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1404
|
-
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1743
|
+
prismic slice add-field link hero cta --allow-text --allow-target-blank`);return}if(!u){console.error(`Missing required argument: slice-id
|
|
1744
|
+
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
1745
|
+
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let f=await W(u);if(!f.ok){console.error(f.error),process.exitCode=1;return}let{model:p,modelPath:m}=f;if(p.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let h=n?p.variations.find(e=>e.id===n):p.variations[0];if(!h){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${p.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}h.primary||={};for(let e of p.variations)if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}let g={type:`Link`,config:{label:r??q(d),...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...c&&{repeat:!0}}};h.primary[d]=g;try{await s(m,K(p))}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 "${d}" (Link) to "${h.id}" variation in ${u}`);try{await G({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let _=await Q();if(_?.framework){let e=ss(_.framework),t=cs(_.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function us(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ds(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function fs(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing slice.
|
|
1405
1746
|
|
|
1406
1747
|
USAGE
|
|
1407
1748
|
prismic slice add-field number <slice-id> <field-id> [flags]
|
|
@@ -1412,16 +1753,17 @@ ARGUMENTS
|
|
|
1412
1753
|
|
|
1413
1754
|
FLAGS
|
|
1414
1755
|
-v, --variation string Target variation (default: first variation)
|
|
1415
|
-
-l, --label string Display label for the field
|
|
1756
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1416
1757
|
-p, --placeholder string Placeholder text
|
|
1758
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1417
1759
|
-h, --help Show help for command
|
|
1418
1760
|
|
|
1419
1761
|
EXAMPLES
|
|
1420
1762
|
prismic slice add-field number my_slice price
|
|
1421
1763
|
prismic slice add-field number product quantity --label "Quantity"
|
|
1422
|
-
prismic slice add-field number stats count --variation "detailed"`);return}if(!
|
|
1423
|
-
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1424
|
-
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1764
|
+
prismic slice add-field number stats count --variation "detailed"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1765
|
+
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1766
|
+
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let l=await W(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Number`,config:{label:r??q(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,K(u))}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 "${c}" (Number) to "${f.id}" variation in ${o}`);try{await G({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let m=await Q();if(m?.framework){let e=us(m.framework),t=ds(m.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ps(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ms(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function hs(){let{values:{help:t,variation:n,label:r,placeholder:i,single:a,multi:o,"allow-target-blank":c,types:l},positionals:[u,d]}=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`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing slice.
|
|
1425
1767
|
|
|
1426
1768
|
USAGE
|
|
1427
1769
|
prismic slice add-field rich-text <slice-id> <field-id> [flags]
|
|
@@ -1432,11 +1774,12 @@ ARGUMENTS
|
|
|
1432
1774
|
|
|
1433
1775
|
FLAGS
|
|
1434
1776
|
-v, --variation string Target variation (default: first variation)
|
|
1435
|
-
-l, --label string Display label for the field
|
|
1777
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1436
1778
|
-p, --placeholder string Placeholder text
|
|
1437
1779
|
--single string Allowed block types for single-line (comma-separated)
|
|
1438
1780
|
--multi string Allowed block types for multi-line (comma-separated)
|
|
1439
1781
|
--allow-target-blank Allow opening links in new tab
|
|
1782
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1440
1783
|
-h, --help Show help for command
|
|
1441
1784
|
|
|
1442
1785
|
BLOCK TYPES
|
|
@@ -1448,9 +1791,9 @@ EXAMPLES
|
|
|
1448
1791
|
prismic slice add-field rich-text my_slice body
|
|
1449
1792
|
prismic slice add-field rich-text article content --multi "paragraph,heading2,heading3,strong,em,hyperlink"
|
|
1450
1793
|
prismic slice add-field rich-text hero tagline --single "heading1"
|
|
1451
|
-
prismic slice add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!
|
|
1452
|
-
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1453
|
-
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1794
|
+
prismic slice add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: slice-id
|
|
1795
|
+
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
1796
|
+
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let f=await W(u);if(!f.ok){console.error(f.error),process.exitCode=1;return}let{model:p,modelPath:m}=f;if(p.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let h=n?p.variations.find(e=>e.id===n):p.variations[0];if(!h){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${p.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}h.primary||={};for(let e of p.variations)if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}let g={type:`StructuredText`,config:{label:r??q(d),...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...c&&{allowTargetBlank:!0}}};h.primary[d]=g;try{await s(m,K(p))}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 "${d}" (StructuredText) to "${h.id}" variation in ${u}`);try{await G({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let _=await Q();if(_?.framework){let e=ps(_.framework),t=ms(_.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function gs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function _s(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function vs(){let{values:{help:t,variation:n,label:r,placeholder:i,option:a,default:o,types: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`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing slice.
|
|
1454
1797
|
|
|
1455
1798
|
USAGE
|
|
1456
1799
|
prismic slice add-field select <slice-id> <field-id> [flags]
|
|
@@ -1461,18 +1804,19 @@ ARGUMENTS
|
|
|
1461
1804
|
|
|
1462
1805
|
FLAGS
|
|
1463
1806
|
-v, --variation string Target variation (default: first variation)
|
|
1464
|
-
-l, --label string Display label for the field
|
|
1807
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1465
1808
|
-p, --placeholder string Placeholder text
|
|
1466
1809
|
--option string Add an option (can be used multiple times)
|
|
1467
1810
|
--default string Default selected value
|
|
1811
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1468
1812
|
-h, --help Show help for command
|
|
1469
1813
|
|
|
1470
1814
|
EXAMPLES
|
|
1471
1815
|
prismic slice add-field select my_slice layout --option "full" --option "sidebar"
|
|
1472
1816
|
prismic slice add-field select hero style --option "light" --option "dark" --default "light"
|
|
1473
|
-
prismic slice add-field select product size --option "small" --option "medium" --option "large" --label "Size"`);return}if(!
|
|
1474
|
-
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1475
|
-
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1817
|
+
prismic slice add-field select product size --option "small" --option "medium" --option "large" --label "Size"`);return}if(!l){console.error(`Missing required argument: slice-id
|
|
1818
|
+
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
1819
|
+
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let d=await W(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:`Select`,config:{label:r??q(u),...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};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}" (Select) to "${m.id}" variation in ${l}`);try{await G({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await Q();if(g?.framework){let e=gs(g.framework),t=_s(g.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}function ys(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function bs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function xs(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing slice.
|
|
1476
1820
|
|
|
1477
1821
|
USAGE
|
|
1478
1822
|
prismic slice add-field timestamp <slice-id> <field-id> [flags]
|
|
@@ -1483,16 +1827,17 @@ ARGUMENTS
|
|
|
1483
1827
|
|
|
1484
1828
|
FLAGS
|
|
1485
1829
|
-v, --variation string Target variation (default: first variation)
|
|
1486
|
-
-l, --label string Display label for the field
|
|
1830
|
+
-l, --label string Display label for the field (inferred from field-id if omitted)
|
|
1487
1831
|
-p, --placeholder string Placeholder text
|
|
1832
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1488
1833
|
-h, --help Show help for command
|
|
1489
1834
|
|
|
1490
1835
|
EXAMPLES
|
|
1491
1836
|
prismic slice add-field timestamp my_slice created_at
|
|
1492
1837
|
prismic slice add-field timestamp event start_time --label "Event Start"
|
|
1493
|
-
prismic slice add-field timestamp schedule meeting_time --variation "detailed"`);return}if(!
|
|
1494
|
-
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1495
|
-
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let
|
|
1838
|
+
prismic slice add-field timestamp schedule meeting_time --variation "detailed"`);return}if(!o){console.error(`Missing required argument: slice-id
|
|
1839
|
+
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
1840
|
+
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let l=await W(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Timestamp`,config:{label:r??q(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,K(u))}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 "${c}" (Timestamp) to "${f.id}" variation in ${o}`);try{await G({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let m=await Q();if(m?.framework){let e=ys(m.framework),t=bs(m.framework);console.info(` Run \`prismic docs ${e}${t}\` to learn how to implement the slice's component`)}}async function Ss(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await Ho();break;case`color`:await Go();break;case`date`:await Jo();break;case`embed`:await Zo();break;case`geo-point`:await es();break;case`image`:await rs();break;case`key-text`:await os();break;case`link`:await ls();break;case`number`:await fs();break;case`rich-text`:await hs();break;case`select`:await vs();break;case`timestamp`:await xs();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
|
|
1496
1841
|
|
|
1497
1842
|
USAGE
|
|
1498
1843
|
prismic slice add-field <field-type> <slice-id> <field-id> [flags]
|
|
@@ -1521,7 +1866,7 @@ EXAMPLES
|
|
|
1521
1866
|
prismic slice add-field key-text my_slice title --label "Title"
|
|
1522
1867
|
prismic slice add-field link my_slice cta --allow-text
|
|
1523
1868
|
prismic slice add-field rich-text my_slice body --multi "paragraph,heading2,strong,em"
|
|
1524
|
-
prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function
|
|
1869
|
+
prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function Cs(){let{values:{help:t,name:n,"copy-from":r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{name:{type:`string`},"copy-from":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new variation to a slice.
|
|
1525
1870
|
|
|
1526
1871
|
USAGE
|
|
1527
1872
|
prismic slice add-variation <slice-id> <variation-id> [flags]
|
|
@@ -1533,14 +1878,34 @@ ARGUMENTS
|
|
|
1533
1878
|
FLAGS
|
|
1534
1879
|
--name string Display name for the variation
|
|
1535
1880
|
--copy-from string Copy fields from an existing variation
|
|
1881
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1536
1882
|
-h, --help Show help for command
|
|
1537
1883
|
|
|
1538
1884
|
EXAMPLES
|
|
1539
1885
|
prismic slice add-variation MySlice withImage
|
|
1540
1886
|
prismic slice add-variation MySlice withImage --name "With Image"
|
|
1541
|
-
prismic slice add-variation MySlice withImage --copy-from default`);return}if(!
|
|
1542
|
-
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!
|
|
1543
|
-
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let
|
|
1887
|
+
prismic slice add-variation MySlice withImage --copy-from default`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1888
|
+
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: variation-id
|
|
1889
|
+
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let c=await W(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.some(e=>e.id===o)){console.error(`Variation "${o}" already exists in slice "${a}"`),process.exitCode=1;return}let d;if(r){let e=l.variations.find(e=>e.id===r);if(!e){console.error(`Source variation not found: ${r}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d={...structuredClone(e),id:o,name:n??Pn(o)}}else d={id:o,name:n??Pn(o),description:o,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}};let f={...l,variations:[...l.variations,d]};try{await s(u,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 variation "${o}" to slice "${a}"`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const ws=P({uploadEndpoint:L(),requiredFormDataFields:I(L(),L()),imgixEndpoint:L()});async function Ts(e){let{data:t,repo:n,sliceId:r,variationId:i,filename:a}=e,o=await Y(`https://acl-provider.prismic.io/create`,{method:`POST`,body:{},schema:ws});if(!o.ok)throw Error(`Failed to get upload credentials from Prismic`);let{uploadEndpoint:s,requiredFormDataFields:c,imgixEndpoint:u}=o.value,d=l(`md5`).update(t).digest(`hex`),f=m(a).toLowerCase().slice(1)||`png`,p=`${n}/shared-slices/${r}/${i}/${d}.${f}`,h=new FormData;for(let[e,t]of Object.entries(c))h.append(e,t);h.append(`key`,p),h.append(`Content-Type`,Es(f)),h.append(`file`,new Blob([new Uint8Array(t)],{type:Es(f)}),a);let g=await fetch(s,{method:`POST`,body:h});if(!g.ok){let e=await g.text();throw Error(`Failed to upload screenshot: ${e}`)}return`${u}/${p}?auto=compress,format`}function Es(e){switch(e){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;default:return`image/png`}}async function Ds(){let{values:{help:t,variation:n,repo:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,short:`v`,default:`default`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set a screenshot for a slice variation.
|
|
1890
|
+
|
|
1891
|
+
USAGE
|
|
1892
|
+
prismic slice set-screenshot <slice-id> <image-path> [flags]
|
|
1893
|
+
|
|
1894
|
+
ARGUMENTS
|
|
1895
|
+
slice-id Slice identifier (required)
|
|
1896
|
+
image-path Path to the image file (required)
|
|
1897
|
+
|
|
1898
|
+
FLAGS
|
|
1899
|
+
-v, --variation string Variation ID (default: "default")
|
|
1900
|
+
-r, --repo string Repository name (uses config if not provided)
|
|
1901
|
+
-h, --help Show help for command
|
|
1902
|
+
|
|
1903
|
+
EXAMPLES
|
|
1904
|
+
prismic slice set-screenshot MySlice ./screenshot.png
|
|
1905
|
+
prismic slice set-screenshot MySlice ./screenshot.png --variation dark
|
|
1906
|
+
prismic slice set-screenshot MySlice ./screenshot.png --repo my-repo`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1907
|
+
`),console.error(`Usage: prismic slice set-screenshot <slice-id> <image-path>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: image-path
|
|
1908
|
+
`),console.error(`Usage: prismic slice set-screenshot <slice-id> <image-path>`),process.exitCode=1;return}if(!await V()){console.error(`You must be logged in to set a screenshot.`),console.error("Run `prismic login` to authenticate."),process.exitCode=1;return}let c=i??await J();if(!c){console.error(`Could not determine repository.`),console.error(`Use --repo flag or run from a directory with prismic.config.json`),process.exitCode=1;return}let l=await W(a);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l,f=u.variations.findIndex(e=>e.id===n);if(f===-1){console.error(`Variation "${n}" not found in slice "${a}"`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let p;try{p=await r(o)}catch(e){e instanceof Error?console.error(`Failed to read image file: ${e.message}`):console.error(`Failed to read image file`),process.exitCode=1;return}let m;try{m=await Ts({data:p,repo:c,sliceId:a,variationId:n??`default`,filename:o})}catch(e){e instanceof Error?console.error(`Failed to upload screenshot: ${e.message}`):console.error(`Failed to upload screenshot`),process.exitCode=1;return}u.variations[f].imageUrl=m;try{await s(d,K(u))}catch(e){e instanceof Error?console.error(`Failed to update slice model: ${e.message}`):console.error(`Failed to update slice model`),process.exitCode=1;return}console.info(`Screenshot set for slice "${a}" variation "${n}"`),console.info(`URL: ${m}`)}async function Os(){let{values:{help:t,name:i,types:a,screenshot:o,repo:c},positionals:[l]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},screenshot:{type:`string`},repo:{type:`string`,short:`r`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new slice in a Prismic project.
|
|
1544
1909
|
|
|
1545
1910
|
USAGE
|
|
1546
1911
|
prismic slice create <id> [flags]
|
|
@@ -1549,11 +1914,14 @@ ARGUMENTS
|
|
|
1549
1914
|
id Slice identifier (required)
|
|
1550
1915
|
|
|
1551
1916
|
FLAGS
|
|
1552
|
-
-n, --name string
|
|
1553
|
-
|
|
1917
|
+
-n, --name string Display name for the slice
|
|
1918
|
+
--screenshot string Path to screenshot image for default variation
|
|
1919
|
+
-r, --repo string Repository name (required for screenshot)
|
|
1920
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1921
|
+
-h, --help Show help for command
|
|
1554
1922
|
|
|
1555
1923
|
LEARN MORE
|
|
1556
|
-
Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!
|
|
1924
|
+
Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!l){console.error(`Missing required argument: id`),process.exitCode=1;return}let u;if(o){if(!await V()){console.error(`You must be logged in to upload a screenshot.`),console.error("Run `prismic login` to authenticate."),process.exitCode=1;return}let e=c??await J();if(!e){console.error(`Could not determine repository for screenshot upload.`),console.error(`Use --repo flag or run from a directory with prismic.config.json`),process.exitCode=1;return}let t;try{t=await r(o)}catch(e){e instanceof Error?console.error(`Failed to read screenshot file: ${e.message}`):console.error(`Failed to read screenshot file`),process.exitCode=1;return}try{u=await Ts({data:t,repo:e,sliceId:l,variationId:`default`,filename:o})}catch(e){e instanceof Error?console.error(`Failed to upload screenshot: ${e.message}`):console.error(`Failed to upload screenshot`),process.exitCode=1;return}}let d={id:l,type:`SharedSlice`,name:i??Ms(l),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:u??``,docURL:``,version:`initial`,primary:{},items:{}}]},f=await ks(),p=new URL(Ms(d.name)+`/`,f),m=new URL(`model.json`,p);try{await n(new URL(`.`,m),{recursive:!0}),await s(m,K(d))}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 ${m.href}`);try{await G({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic slice add-field`")}async function ks(){let e=await js(),t=await U(`package.json`);switch(e){case`next`:if(await kn(new URL(`src`,t)))return new URL(`src/slices/`,t);case`nuxt`:if(await kn(new URL(`app`,t)))return new URL(`app/slices/`,t);case`sveltekit`:return new URL(`src/slices/`,t)}return new URL(`slices/`,t)}const As=P({dependencies:F(I(L(),L()))});async function js(){let e=await U(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=vn(As,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function Ms(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Ns(){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.
|
|
1557
1925
|
|
|
1558
1926
|
USAGE
|
|
1559
1927
|
prismic slice list [flags]
|
|
@@ -1564,7 +1932,7 @@ FLAGS
|
|
|
1564
1932
|
|
|
1565
1933
|
EXAMPLES
|
|
1566
1934
|
prismic slice list
|
|
1567
|
-
prismic slice list --json`);return}let a=await
|
|
1935
|
+
prismic slice list --json`);return}let a=await jn(),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=z(An,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 Ps(){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.
|
|
1568
1936
|
|
|
1569
1937
|
USAGE
|
|
1570
1938
|
prismic slice list-variations <slice-id> [flags]
|
|
@@ -1579,7 +1947,7 @@ FLAGS
|
|
|
1579
1947
|
EXAMPLES
|
|
1580
1948
|
prismic slice list-variations MySlice
|
|
1581
1949
|
prismic slice list-variations MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1582
|
-
`),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await
|
|
1950
|
+
`),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await W(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 Fs(){let{values:{help:t,y:n,types:r},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a slice from the project.
|
|
1583
1951
|
|
|
1584
1952
|
USAGE
|
|
1585
1953
|
prismic slice remove <slice-id> [flags]
|
|
@@ -1589,12 +1957,13 @@ ARGUMENTS
|
|
|
1589
1957
|
|
|
1590
1958
|
FLAGS
|
|
1591
1959
|
-y Confirm removal
|
|
1960
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1592
1961
|
-h, --help Show help for command
|
|
1593
1962
|
|
|
1594
1963
|
EXAMPLES
|
|
1595
1964
|
prismic slice remove MySlice
|
|
1596
|
-
prismic slice remove MySlice -y`);return}if(!
|
|
1597
|
-
`),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let
|
|
1965
|
+
prismic slice remove MySlice -y`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1966
|
+
`),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let a=await W(i);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{modelPath:s}=a,c=new URL(`.`,s);if(!n){console.error(`Refusing to remove slice "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{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 "${i}"`);try{await G({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Is(){let{values:{help:t,variation:n,zone:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,default:`default`},zone:{type:`string`,default:`primary`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a slice variation.
|
|
1598
1967
|
|
|
1599
1968
|
USAGE
|
|
1600
1969
|
prismic slice remove-field <slice-id> <field-id> [flags]
|
|
@@ -1606,14 +1975,15 @@ ARGUMENTS
|
|
|
1606
1975
|
FLAGS
|
|
1607
1976
|
--variation string Target variation (default: "default")
|
|
1608
1977
|
--zone string Field zone: "primary" or "items" (default: "primary")
|
|
1978
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1609
1979
|
-h, --help Show help for command
|
|
1610
1980
|
|
|
1611
1981
|
EXAMPLES
|
|
1612
1982
|
prismic slice remove-field MySlice title
|
|
1613
1983
|
prismic slice remove-field MySlice title --variation withImage
|
|
1614
|
-
prismic slice remove-field MySlice item_title --zone items`);return}if(!
|
|
1615
|
-
`),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(!
|
|
1616
|
-
`),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
|
|
1984
|
+
prismic slice remove-field MySlice item_title --zone items`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1985
|
+
`),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1986
|
+
`),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 c=await W(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c,d=l.variations.find(e=>e.id===n);if(!d){console.error(`Variation not found: ${n}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let f=r===`primary`?d.primary:d.items;if(!f||!(o in f)){console.error(`Field "${o}" not found in ${r} zone of variation "${n}"`),process.exitCode=1;return}delete f[o];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(`Removed field "${o}" from ${r} zone in variation "${n}" of slice "${a}"`);try{await G({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Ls(){let{values:{help:t,types:n},positionals:[r,i]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a variation from a slice.
|
|
1617
1987
|
|
|
1618
1988
|
USAGE
|
|
1619
1989
|
prismic slice remove-variation <slice-id> <variation-id> [flags]
|
|
@@ -1623,12 +1993,13 @@ ARGUMENTS
|
|
|
1623
1993
|
variation-id Variation to remove (required)
|
|
1624
1994
|
|
|
1625
1995
|
FLAGS
|
|
1996
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1626
1997
|
-h, --help Show help for command
|
|
1627
1998
|
|
|
1628
1999
|
EXAMPLES
|
|
1629
|
-
prismic slice remove-variation MySlice withImage`);return}if(!
|
|
1630
|
-
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!
|
|
1631
|
-
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let
|
|
2000
|
+
prismic slice remove-variation MySlice withImage`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
2001
|
+
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: variation-id
|
|
2002
|
+
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let a=await W(r);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{model:o,modelPath:c}=a;if(!o.variations.some(e=>e.id===i)){console.error(`Variation not found: ${i}`),console.error(`Available variations: ${o.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.variations.length===1){console.error(`Cannot remove the last variation from a slice.`),process.exitCode=1;return}let l={...o,variations:o.variations.filter(e=>e.id!==i)};try{await s(c,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(`Removed variation "${i}" from slice "${r}"`);try{await G({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Rs(){let{values:{help:t,id:n,types:r},positionals:[i,o]}=e({args:process.argv.slice(4),options:{id:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Rename a slice (updates name field, optionally id and directory).
|
|
1632
2003
|
|
|
1633
2004
|
USAGE
|
|
1634
2005
|
prismic slice rename <slice-id> <new-name> [flags]
|
|
@@ -1639,13 +2010,14 @@ ARGUMENTS
|
|
|
1639
2010
|
|
|
1640
2011
|
FLAGS
|
|
1641
2012
|
--id string Also change the slice ID (renames directory)
|
|
2013
|
+
--types string Output file for generated types (default: "prismicio-types.d.ts")
|
|
1642
2014
|
-h, --help Show help for command
|
|
1643
2015
|
|
|
1644
2016
|
EXAMPLES
|
|
1645
2017
|
prismic slice rename MySlice "My New Name"
|
|
1646
|
-
prismic slice rename MySlice "My New Name" --id NewSliceId`);return}if(!
|
|
1647
|
-
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}if(!
|
|
1648
|
-
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let
|
|
2018
|
+
prismic slice rename MySlice "My New Name" --id NewSliceId`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
2019
|
+
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: new-name
|
|
2020
|
+
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let c=await W(i);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;l.name=o,n&&(l.id=n);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}if(n){let e=await jn(),t=new URL(`.`,u),r=new URL(Pn(o)+`/`,e);if(t.href!==r.href)try{await a(t,r),console.info(`Renamed slice "${i}" to "${n}" (${o})`),console.info(`Moved directory to ${r.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 "${i}" to "${n}" (${o})`)}else console.info(`Renamed slice "${i}" to "${o}"`);try{await G({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function zs(){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.
|
|
1649
2021
|
|
|
1650
2022
|
USAGE
|
|
1651
2023
|
prismic slice view <slice-id> [flags]
|
|
@@ -1660,8 +2032,8 @@ FLAGS
|
|
|
1660
2032
|
EXAMPLES
|
|
1661
2033
|
prismic slice view MySlice
|
|
1662
2034
|
prismic slice view MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1663
|
-
`),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await
|
|
1664
|
-
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
|
|
2035
|
+
`),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await W(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(`
|
|
2036
|
+
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`),e.imageUrl&&console.info(` Screenshot: ${e.imageUrl}`)}}async function Bs(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Os();break;case`list`:await Ns();break;case`view`:await zs();break;case`rename`:await Rs();break;case`remove`:await Fs();break;case`add-field`:await Ss();break;case`remove-field`:await Is();break;case`add-variation`:await Cs();break;case`remove-variation`:await Ls();break;case`list-variations`:await Ps();break;case`set-screenshot`:await Ds();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
|
|
1665
2037
|
|
|
1666
2038
|
USAGE
|
|
1667
2039
|
prismic slice <command> [flags]
|
|
@@ -1677,12 +2049,45 @@ COMMANDS
|
|
|
1677
2049
|
add-variation Add a variation to a slice
|
|
1678
2050
|
remove-variation Remove a variation from a slice
|
|
1679
2051
|
list-variations List all variations of a slice
|
|
2052
|
+
set-screenshot Set a screenshot for a slice variation
|
|
1680
2053
|
|
|
1681
2054
|
FLAGS
|
|
1682
2055
|
-h, --help Show help for command
|
|
1683
2056
|
|
|
1684
2057
|
LEARN MORE
|
|
1685
|
-
Use \`prismic slice <command> --help\` for more information about a command.`)}}async function
|
|
2058
|
+
Use \`prismic slice <command> --help\` for more information about a command.`)}}const Vs={documentsPublished:`document.published`,documentsUnpublished:`document.unpublished`,releasesCreated:`release.created`,releasesUpdated:`release.updated`,tagsCreated:`tag.created`,tagsDeleted:`tag.deleted`};async function Hs(){let{values:{help:t,repo:n=await J()},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.
|
|
2059
|
+
|
|
2060
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
2061
|
+
project root.
|
|
2062
|
+
|
|
2063
|
+
USAGE
|
|
2064
|
+
prismic webhook view <url> [flags]
|
|
2065
|
+
|
|
2066
|
+
ARGUMENTS
|
|
2067
|
+
<url> Webhook URL
|
|
2068
|
+
|
|
2069
|
+
FLAGS
|
|
2070
|
+
-r, --repo string Repository domain
|
|
2071
|
+
-h, --help Show help for command
|
|
2072
|
+
|
|
2073
|
+
LEARN MORE
|
|
2074
|
+
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 V()){Us();return}let i=await $(n);if(!i.ok){i.error instanceof X?Us():(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(Vs))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 Us(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Ws=P({config:P({_id:L(),url:L(),active:N(),name:gn(L()),secret:gn(L()),headers:I(L(),L()),documentsPublished:N(),documentsUnpublished:N(),releasesCreated:N(),releasesUpdated:N(),tagsCreated:N(),tagsDeleted:N()})});async function $(e){return await Y(new URL(`/app/settings/webhooks`,await B(e)),{schema:M(Ws)})}function Gs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`;default:return``}}function Ks(e,t){return e?`\`prismic docs ${t?`${e}${t}`:e}\``:``}function qs(e){switch(e){case`nuxt`:return`#configure-the-modules-prismic-client`;default:return`#set-up-a-prismic-client`}}function Js(e){switch(e){case`next`:return`#set-up-previews-in-next-js`;case`sveltekit`:return`#set-up-previews-in-sveltekit`;default:return``}}function Ys(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}function Xs(e,t){let n=[],r=Gs(t.framework),i=e.filter(e=>!e.done&&e.hint===`not installed`);if(i.length>0){let e=i.map(e=>e.label).join(` `);n.push({action:`Install dependencies: Run \`npm install ${e}\``})}if(e.find(e=>!e.done&&e.hint?.includes(`client`))){let e=Ks(r,qs(t.framework));n.push({action:`Create Prismic client file: Run ${e} and create the file as shown`})}return n}function Zs(e){let t=[],n=e.some(e=>e.status===`to_push`),r=e.some(e=>e.status===`to_pull`);return n&&t.push({action:"Push local models to Prismic: Run `prismic push`"}),r&&t.push({action:"Pull remote models from Prismic: Run `prismic pull`"}),t}function Qs(e,t,n,r){let i=[],a=Gs(r.framework);if(t.length>0){let e=Ks(a,Ys(r.framework));i.push({action:`Implement slice components: Run ${e} and create each component file`})}let o=e.some(e=>e.status===`to_pull`),s=e.some(e=>e.status===`to_push`);if(o&&i.push({action:"Pull remote models from Prismic: Run `prismic pull`"}),n.length>0){let e=[...n].sort()[0];i.push({action:`Connect slice to page type: Run \`prismic page-type connect-slice <type-id> ${e}\``})}return s&&i.push({action:"Push local models to Prismic: Run `prismic push`"}),i}function $s(e,t){let n=[],r=Gs(t.framework);if(e.find(e=>e.label===`/slice-simulator route`&&!e.done)){let e=Ks(r,`#set-up-live-previewing`);n.push({action:`Create /slice-simulator route: Run ${e} and create the route file as shown`})}e.find(e=>e.label===`Slice simulator URL`&&!e.done)&&n.push({action:"Configure slice simulator URL: Run `prismic preview set-simulator`"});let i=e.find(e=>e.label===`/api/preview endpoint`&&!e.done),a=e.find(e=>e.label===`/api/exit-preview endpoint`&&!e.done);if(i||a){let e=Ks(r,Js(t.framework));n.push({action:`Create preview endpoints: Run ${e} and create the endpoint files as shown`})}return e.find(e=>e.label===`Preview environment`&&!e.done)&&n.push({action:"Add preview environment: Run `prismic preview add`"}),n}function ec(e,t){let n=[],r=Gs(t.framework);if(e.find(e=>e.label===`/api/revalidate endpoint`&&!e.done)){let e=Ks(r,`#handle-content-changes`);n.push({action:`Create /api/revalidate endpoint: Run ${e} and create the endpoint as shown`})}return e.find(e=>e.label===`Revalidation webhook`&&!e.done)&&n.push({action:"Create revalidation webhook: Run `prismic webhook create`"}),n}async function tc(){let{values:{help:t,repo:n=await J()}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Show the status of the current Prismic project.
|
|
2075
|
+
|
|
2076
|
+
Each section with incomplete items includes "Next steps:" with actionable
|
|
2077
|
+
instructions.
|
|
2078
|
+
|
|
2079
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
2080
|
+
project root.
|
|
2081
|
+
|
|
2082
|
+
USAGE
|
|
2083
|
+
prismic status [flags]
|
|
2084
|
+
|
|
2085
|
+
FLAGS
|
|
2086
|
+
-r, --repo string Repository domain
|
|
2087
|
+
-h, --help Show help for command
|
|
2088
|
+
|
|
2089
|
+
LEARN MORE
|
|
2090
|
+
Use \`prismic <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 V()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}let r=await Q();if(!r){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let[i,a,o,s,c,l,u,d]=await Promise.all([ic(n),oc(n),$(n),zn(),Ln(n),Bn(),Rn(n),cc(r)]),f=await B(n);console.info(`Repository: ${n}`),console.info(`URL: ${f.href}`),console.info(``);let p=[],m=await lc(r,d);if(m.nextSteps=Xs(m.items,r),p.push(m),s.ok&&c.ok){let{pageTypes:e,customTypes:t,pageTypeStatuses:n,customTypeStatuses:r}=fc(s.value,c.value);e.nextSteps=Zs(n),t.nextSteps=Zs(r),p.push(e),p.push(t)}if(l.ok&&u.ok){let{section:e,statuses:t,missingComponents:n,slicesReadyToConnect:i}=await gc(l.value,u.value,r,s.ok?s.value:[]);e.nextSteps=Qs(t,n,i,r),p.push(e)}let h=await yc(r,a.ok?a.value:void 0,i.ok?i.value.simulator_url:void 0);if(h.nextSteps=$s(h.items,r),p.push(h),r.framework===`next`){let e=await xc(r,o.ok?o.value:[]);e.nextSteps=ec(e.items,r),p.push(e)}for(let e of p)nc(e)}function nc(e){let t=e.items.filter(e=>!e.done).length,n=t>0?`${e.title} (${t} remaining)`:e.title;console.info(n);let r=e.items.filter(e=>e.done),i=e.items.filter(e=>!e.done);if(r.length>0)if(r.length===1){let e=r[0],t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ✓ ${e.label}${t}`)}else{let e=r.map(e=>e.label).join(`, `),t=r.every(e=>e.hint===r[0].hint)&&r[0].hint?` \u2014 ${r[0].hint}`:``;console.info(` ✓ ${e}${t}`)}for(let e of i){let t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ○ ${e.label}${t}`)}if(e.nextSteps&&e.nextSteps.length>0){console.info(``),console.info(` Next steps:`);for(let t of e.nextSteps)console.info(` - ${t.action}`)}console.info(``)}const rc=P({simulator_url:F(L())});async function ic(e){let t=await Y(new URL(`/core/repository`,await B(e)),{schema:rc});return t.ok?{ok:!0,value:t.value}:{ok:!1}}const ac=P({results:M(P({id:L(),label:L(),url:L()}))});async function oc(e){let t=await Y(new URL(`/core/repository/preview_configs`,await B(e)),{schema:ac});return t.ok?{ok:!0,value:t.value.results}:{ok:!1}}const sc=P({dependencies:F(I(L(),L())),devDependencies:F(I(L(),L()))});async function cc(e){let t=new URL(`package.json`,e.projectRoot);try{let e=await r(t,`utf8`),{dependencies:n={},devDependencies:i={}}=vn(sc,JSON.parse(e));return new Set([...Object.keys(n),...Object.keys(i)])}catch{return new Set}}async function lc(e,t){let n=[],r=wi(e.framework);for(let e of r)n.push({done:t.has(e),label:e,hint:t.has(e)?`installed`:`not installed`});let i=Ti(e);if(i){let t=await kn(new URL(i,e.projectRoot));n.push({done:t,label:i,hint:t?void 0:`create Prismic client file`})}else if(e.framework===`nuxt`){let t=await uc(e);n.push({done:t,label:`nuxt.config.ts`,hint:t?`prismic configured`:`add @nuxtjs/prismic to modules`})}return{title:`Setup`,items:n}}async function uc(e){let t=new URL(`nuxt.config.ts`,e.projectRoot);try{let e=await r(t,`utf8`);return e.includes(`@nuxtjs/prismic`)||e.includes(`prismic:`)}catch{return!1}}function dc(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[];for(let t of e){let e=t.label||t.id,n=r.get(t.id);n&&JSON.stringify(t)===JSON.stringify(n)?i.push({id:t.id,label:e,status:`in_sync`}):i.push({id:t.id,label:e,status:`to_push`})}for(let e of t)if(!n.has(e.id)){let t=e.label||e.id;i.push({id:e.id,label:t,status:`to_pull`})}return i}function fc(e,t){let n=dc(e,t),r=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return a&&a.format===`page`}),i=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return!a||a.format!==`page`}),a=r.map(e=>({done:e.status===`in_sync`,label:e.label,hint:pc(e.status)})),o=i.map(e=>({done:e.status===`in_sync`,label:e.label,hint:pc(e.status)}));return{pageTypes:{title:`Page Types`,items:a},customTypes:{title:`Custom Types`,items:o},pageTypeStatuses:r,customTypeStatuses:i}}function pc(e){switch(e){case`in_sync`:return`in sync`;case`to_push`:return`to push`;case`to_pull`:return`to pull`}}function mc(e){for(let t of e.variations){let e=Object.keys(t.primary??{}),n=Object.keys(t.items??{});if(e.length>0||n.length>0)return!0}return!1}function hc(e,t){for(let n of t)for(let t of Object.values(n.json))for(let n of Object.values(t)){let t=n;if(t.type===`Slices`&&t.config?.choices?.[e])return!0}return!1}async function gc(e,t,n,r){let i=dc(e,t),a=[],o=[],s=[],c=Ei(n),l=Di(n.framework);for(let t of i){let i=e.find(e=>e.id===t.id);if(i){let e=mc(i),n=hc(t.id,r);e&&!n&&s.push(t.label)}let u=await _c(n,c,t.id,l);t.status===`in_sync`&&u?a.push({done:!0,label:t.label,hint:`component implemented`}):t.status===`in_sync`&&!u?(a.push({done:!1,label:t.label,hint:`missing component`}),o.push(t.label)):a.push({done:!1,label:t.label,hint:pc(t.status)})}return{section:{title:`Slices`,items:a},statuses:i,missingComponents:o,slicesReadyToConnect:s}}async function _c(e,t,n,r){let i=vc(n);for(let n of r)if(await kn(new URL(`${t}${i}/index${n}`,e.projectRoot)))return!0;return!1}function vc(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function yc(e,t,n){let r=[];r.push({done:!!n,label:`Slice simulator URL`,hint:n?`configured`:"run `prismic preview set-simulator`"});let i=Oi(e,`/slice-simulator`);if(i){let t=await bc(e,i);r.push({done:t,label:`/slice-simulator route`,hint:t?void 0:`create route for Page Builder`})}let a=t&&t.length>0;if(r.push({done:!!a,label:`Preview environment`,hint:a?void 0:"run `prismic preview add`"}),e.framework!==`nuxt`){let t=Oi(e,`/api/preview`);if(t){let n=await bc(e,t);r.push({done:n,label:`/api/preview endpoint`,hint:n?void 0:`create preview endpoint`})}}if(e.framework===`next`){let t=Oi(e,`/api/exit-preview`);if(t){let n=await bc(e,t);r.push({done:n,label:`/api/exit-preview endpoint`,hint:n?void 0:`create exit-preview endpoint`})}}return{title:`Preview`,items:r}}async function bc(e,t){for(let n of t.extensions)if(await kn(new URL(`${t.path}${n}`,e.projectRoot)))return!0;return!1}async function xc(e,t){let n=[],r=Oi(e,`/api/revalidate`);if(r){let t=await bc(e,r);n.push({done:t,label:`/api/revalidate endpoint`,hint:t?void 0:`create for ISR`})}let i=t.some(e=>e.config.active&&e.config.url.toLowerCase().includes(`revalidate`));return n.push({done:i,label:`Revalidation webhook`,hint:i?`configured`:"run `prismic webhook create`"}),{title:`Deployment`,items:n}}async function Sc(){let{values:{help:t,repo:n=await J(),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.
|
|
1686
2091
|
|
|
1687
2092
|
By default, this command reads the repository from prismic.config.json at the
|
|
1688
2093
|
project root.
|
|
@@ -1696,7 +2101,7 @@ FLAGS
|
|
|
1696
2101
|
-h, --help Show help for command
|
|
1697
2102
|
|
|
1698
2103
|
LEARN MORE
|
|
1699
|
-
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
|
|
2104
|
+
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 V()){Nc();return}let[i,a]=await Promise.all([kc(n),Ac(n)]);if(!i.ok){i.error instanceof X||i.error instanceof Z?Nc():j(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?Nc():j(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=jc(e.token),n=Mc(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=jc(e.token),n=Mc(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const Cc=P({$date:_n()}),wc=P({id:L(),origin:L(),domain:L(),app:L(),scope:L(),expired_at:Cc,created_at:Cc,owner:gn(L()),token:L()}),Tc=P({id:L(),secret:L(),name:L(),owner:L(),created_at:Cc,authorized_domains:M(L()),wroom_auths:M(wc)}),Ec=P({app_name:L(),token:L(),timestamp:_n()}),Dc=P({max_tokens:_n(),tokens:M(Ec)}),Oc=M(Tc);async function kc(e){return await Y(new URL(`settings/security/contentapi`,await B(e)),{schema:Oc})}async function Ac(e){return await Y(new URL(`settings/security/customtypesapi`,await B(e)),{schema:Dc})}function jc(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function Mc(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function Nc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Pc(){let{values:{help:t,repo:n=await J(),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.
|
|
1700
2105
|
|
|
1701
2106
|
By default, this command reads the repository from prismic.config.json at the
|
|
1702
2107
|
project root.
|
|
@@ -1713,7 +2118,7 @@ FLAGS
|
|
|
1713
2118
|
-h, --help Show help for command
|
|
1714
2119
|
|
|
1715
2120
|
LEARN MORE
|
|
1716
|
-
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
|
|
2121
|
+
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 V()){Lc();return}if(i){let e=await Fc(n,a);if(!e.ok){e.error instanceof X||e.error instanceof Z?Lc():j(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 Ic(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof X||e.error instanceof Z?Lc():j(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 Fc(e,t){return await Y(new URL(`settings/security/token`,await B(e)),{method:`POST`,body:{app_name:t},schema:Ec})}async function Ic(e,t,n){let r=await kc(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 B(e)),{method:`POST`,body:{app_name:t},schema:Tc});if(!n.ok)return n;i=n.value}return await Y(new URL(`settings/security/authorizations`,await B(e)),{method:`POST`,body:{app:i.id,scope:n},schema:wc})}function Lc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Rc(){let{values:{help:t,repo:n=await J()},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.
|
|
1717
2122
|
|
|
1718
2123
|
By default, this command reads the repository from prismic.config.json at the
|
|
1719
2124
|
project root.
|
|
@@ -1729,7 +2134,7 @@ FLAGS
|
|
|
1729
2134
|
-h, --help Show help for command
|
|
1730
2135
|
|
|
1731
2136
|
LEARN MORE
|
|
1732
|
-
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
|
|
2137
|
+
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 V()){zc();return}let[i,a]=await Promise.all([kc(n),Ac(n)]);if(!i.ok){i.error instanceof X||i.error instanceof Z?zc():j(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?zc():j(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 B(n)),{method:`DELETE`});if(!e.ok){e.error instanceof X||e.error instanceof Z?zc():(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 B(n)),{method:`DELETE`});if(!e.ok){e.error instanceof X||e.error instanceof Z?zc():(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 zc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Bc(){let{values:{help:t,repo:n=await J()},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.
|
|
1733
2138
|
|
|
1734
2139
|
Note: Only access tokens can be renamed. Write tokens cannot be renamed without
|
|
1735
2140
|
changing the token value.
|
|
@@ -1749,7 +2154,7 @@ FLAGS
|
|
|
1749
2154
|
-h, --help Show help for command
|
|
1750
2155
|
|
|
1751
2156
|
LEARN MORE
|
|
1752
|
-
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
|
|
2157
|
+
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 V()){Vc();return}let[a,o]=await Promise.all([kc(n),Ac(n)]);if(!a.ok){a.error instanceof X||a.error instanceof Z?Vc():j(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?Vc():j(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 B(n)),{method:`POST`,body:{name:i},schema:Tc});if(!e.ok){e.error instanceof X||e.error instanceof Z?Vc():j(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 Vc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Hc(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Sc();break;case`create`:await Pc();break;case`set-name`:await Bc();break;case`delete`:await Rc();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
|
|
1753
2158
|
|
|
1754
2159
|
USAGE
|
|
1755
2160
|
prismic token <command> [flags]
|
|
@@ -1764,23 +2169,7 @@ FLAGS
|
|
|
1764
2169
|
-h, --help Show help for command
|
|
1765
2170
|
|
|
1766
2171
|
LEARN MORE
|
|
1767
|
-
Use \`prismic token <command> --help\` for more information about a command.`)}}
|
|
1768
|
-
|
|
1769
|
-
By default, this command reads the repository from prismic.config.json at the
|
|
1770
|
-
project root.
|
|
1771
|
-
|
|
1772
|
-
USAGE
|
|
1773
|
-
prismic webhook view <url> [flags]
|
|
1774
|
-
|
|
1775
|
-
ARGUMENTS
|
|
1776
|
-
<url> Webhook URL
|
|
1777
|
-
|
|
1778
|
-
FLAGS
|
|
1779
|
-
-r, --repo string Repository domain
|
|
1780
|
-
-h, --help Show help for command
|
|
1781
|
-
|
|
1782
|
-
LEARN MORE
|
|
1783
|
-
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()){hi();return}let i=await Q(n);if(!i.ok){i.error instanceof q?hi():(console.error(`Failed to view webhook: ${z(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(Z))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 hi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const gi=E({config:E({_id:k(),url:k(),active:C(),name:w(k()),secret:w(k()),headers:O(k(),k()),documentsPublished:C(),documentsUnpublished:C(),releasesCreated:C(),releasesUpdated:C(),tagsCreated:C(),tagsDeleted:C()})});async function Q(e){return await K(new URL(`/app/settings/webhooks`,await F(e)),{schema:S(gi)})}async function _i(){let{values:{help:t,repo:n=await W()},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.
|
|
2172
|
+
Use \`prismic token <command> --help\` for more information about a command.`)}}async function Uc(){let{values:{help:t,repo:n=await J()},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.
|
|
1784
2173
|
|
|
1785
2174
|
By default, this command reads the repository from prismic.config.json at the
|
|
1786
2175
|
project root.
|
|
@@ -1796,7 +2185,7 @@ FLAGS
|
|
|
1796
2185
|
-h, --help Show help for command
|
|
1797
2186
|
|
|
1798
2187
|
LEARN MORE
|
|
1799
|
-
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
|
|
2188
|
+
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 V()){Gc();return}let i=await $(n);if(!i.ok){i.error instanceof X?Gc():(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 Wc(n,a.config._id,o);if(!s.ok){s.error instanceof X?Gc():(console.error(`Failed to enable webhook: ${K(s.value)}`),process.exitCode=1);return}console.info(`Webhook enabled: ${r}`)}async function Wc(e,t,n){let r=new URL(`/app/settings/webhooks/${t}`,await B(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 Gc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Kc(){let{values:{help:t,repo:n=await J()},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.
|
|
1800
2189
|
|
|
1801
2190
|
By default, this command reads the repository from prismic.config.json at the
|
|
1802
2191
|
project root.
|
|
@@ -1814,7 +2203,7 @@ FLAGS
|
|
|
1814
2203
|
-h, --help Show help for command
|
|
1815
2204
|
|
|
1816
2205
|
LEARN MORE
|
|
1817
|
-
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
|
|
2206
|
+
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 V()){qc();return}let o=await $(n);if(!o.ok){o.error instanceof X?qc():(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 Wc(n,s.config._id,c);if(!l.ok){l.error instanceof X?qc():(console.error(`Failed to add header: ${K(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function qc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Jc=Object.values(Vs);async function Yc(){let{values:{help:t,repo:n=await J(),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.
|
|
1818
2207
|
|
|
1819
2208
|
By default, this command reads the repository from prismic.config.json at the
|
|
1820
2209
|
project root.
|
|
@@ -1843,7 +2232,7 @@ TRIGGERS
|
|
|
1843
2232
|
If no triggers specified, all are enabled.
|
|
1844
2233
|
|
|
1845
2234
|
LEARN MORE
|
|
1846
|
-
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(!
|
|
2235
|
+
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(!Jc.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${Jc.join(`, `)}`),process.exitCode=1;return}if(!await V()){Zc();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(Vs).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await Xc(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof X?Zc():(console.error(`Failed to create webhook: ${K(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function Xc(e,t){let n=new URL(`/app/settings/webhooks/create`,await B(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 Zc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Qc(){let{values:{help:t,repo:n=await J()},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.
|
|
1847
2236
|
|
|
1848
2237
|
By default, this command reads the repository from prismic.config.json at the
|
|
1849
2238
|
project root.
|
|
@@ -1859,7 +2248,7 @@ FLAGS
|
|
|
1859
2248
|
-h, --help Show help for command
|
|
1860
2249
|
|
|
1861
2250
|
LEARN MORE
|
|
1862
|
-
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
|
|
2251
|
+
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 V()){$c();return}let i=await $(n);if(!i.ok){i.error instanceof X?$c():(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 Wc(n,a.config._id,o);if(!s.ok){s.error instanceof X?$c():(console.error(`Failed to disable webhook: ${K(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function $c(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function el(){let{values:{help:t,repo:n=await J(),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.
|
|
1863
2252
|
|
|
1864
2253
|
By default, this command reads the repository from prismic.config.json at the
|
|
1865
2254
|
project root.
|
|
@@ -1873,7 +2262,7 @@ FLAGS
|
|
|
1873
2262
|
-h, --help Show help for command
|
|
1874
2263
|
|
|
1875
2264
|
LEARN MORE
|
|
1876
|
-
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
|
|
2265
|
+
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 V()){tl();return}let i=await $(n);if(!i.ok){i.error instanceof X?tl():j(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 tl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function nl(){let{values:{help:t,repo:n=await J()},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.
|
|
1877
2266
|
|
|
1878
2267
|
By default, this command reads the repository from prismic.config.json at the
|
|
1879
2268
|
project root.
|
|
@@ -1889,7 +2278,7 @@ FLAGS
|
|
|
1889
2278
|
-h, --help Show help for command
|
|
1890
2279
|
|
|
1891
2280
|
LEARN MORE
|
|
1892
|
-
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
|
|
2281
|
+
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 V()){il();return}let i=await $(n);if(!i.ok){i.error instanceof X?il():(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 rl(n,a.config._id);if(!o.ok){o.error instanceof X?il():(console.error(`Failed to remove webhook: ${K(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function rl(e,t){return await Y(new URL(`/app/settings/webhooks/${t}/delete`,await B(e)),{method:`POST`})}function il(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function al(){let{values:{help:t,repo:n=await J()},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.
|
|
1893
2282
|
|
|
1894
2283
|
By default, this command reads the repository from prismic.config.json at the
|
|
1895
2284
|
project root.
|
|
@@ -1906,7 +2295,7 @@ FLAGS
|
|
|
1906
2295
|
-h, --help Show help for command
|
|
1907
2296
|
|
|
1908
2297
|
LEARN MORE
|
|
1909
|
-
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
|
|
2298
|
+
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 V()){ol();return}let a=await $(n);if(!a.ok){a.error instanceof X?ol():(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 Wc(n,o.config._id,s);if(!c.ok){c.error instanceof X?ol():(console.error(`Failed to remove header: ${K(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function ol(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const sl=Object.values(Vs);async function cl(){let{values:{help:t,repo:n=await J(),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.
|
|
1910
2299
|
|
|
1911
2300
|
By default, this command reads the repository from prismic.config.json at the
|
|
1912
2301
|
project root.
|
|
@@ -1931,7 +2320,7 @@ TRIGGERS
|
|
|
1931
2320
|
tag.deleted When a tag is deleted
|
|
1932
2321
|
|
|
1933
2322
|
LEARN MORE
|
|
1934
|
-
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(!
|
|
2323
|
+
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(!sl.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${sl.join(`, `)}`),process.exitCode=1;return}if(!await V()){ll();return}let a=await $(n);if(!a.ok){a.error instanceof X?ll():(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(Vs).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await Wc(n,o.config._id,{...o.config,...c});if(!l.ok){l.error instanceof X?ll():(console.error(`Failed to update webhook triggers: ${K(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function ll(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ul(){let{values:{help:t,repo:n=await J()},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.
|
|
1935
2324
|
|
|
1936
2325
|
By default, this command reads the repository from prismic.config.json at the
|
|
1937
2326
|
project root.
|
|
@@ -1947,7 +2336,7 @@ FLAGS
|
|
|
1947
2336
|
-h, --help Show help for command
|
|
1948
2337
|
|
|
1949
2338
|
LEARN MORE
|
|
1950
|
-
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
|
|
2339
|
+
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 V()){dl();return}let i=await $(n);if(!i.ok){i.error instanceof X?dl():(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 dl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function fl(){let{values:{help:t,repo:n=await J()},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.
|
|
1951
2340
|
|
|
1952
2341
|
By default, this command reads the repository from prismic.config.json at the
|
|
1953
2342
|
project root.
|
|
@@ -1963,7 +2352,7 @@ FLAGS
|
|
|
1963
2352
|
-h, --help Show help for command
|
|
1964
2353
|
|
|
1965
2354
|
LEARN MORE
|
|
1966
|
-
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
|
|
2355
|
+
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 V()){ml();return}let i=await $(n);if(!i.ok){i.error instanceof X?ml():(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 pl(n,a.config._id);if(!o.ok){o.error instanceof X?ml():(console.error(`Failed to test webhook: ${K(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function pl(e,t){return await Y(new URL(`/app/settings/webhooks/${t}/trigger`,await B(e)),{method:`POST`})}function ml(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function hl(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await el();break;case`create`:await Yc();break;case`view`:await Hs();break;case`remove`:await nl();break;case`test`:await fl();break;case`enable`:await Uc();break;case`disable`:await Qc();break;case`status`:await ul();break;case`add-header`:await Kc();break;case`remove-header`:await al();break;case`set-triggers`:await cl();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
|
|
1967
2356
|
|
|
1968
2357
|
USAGE
|
|
1969
2358
|
prismic webhook <command> [flags]
|
|
@@ -1985,7 +2374,7 @@ FLAGS
|
|
|
1985
2374
|
-h, --help Show help for command
|
|
1986
2375
|
|
|
1987
2376
|
LEARN MORE
|
|
1988
|
-
Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function
|
|
2377
|
+
Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function gl(){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.
|
|
1989
2378
|
|
|
1990
2379
|
USAGE
|
|
1991
2380
|
prismic whoami [flags]
|
|
@@ -1994,7 +2383,7 @@ FLAGS
|
|
|
1994
2383
|
-h, --help Show help for command
|
|
1995
2384
|
|
|
1996
2385
|
LEARN MORE
|
|
1997
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}if(!await
|
|
2386
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}if(!await V()){vl();return}let n=await _l();if(!n.ok){n.error instanceof X?vl():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function _l(){return await Y(new URL(`profile`,await xn()),{schema:P({email:L()})})}function vl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:yl,values:{version:bl}}=e({options:{help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`}},allowPositionals:!0,strict:!1});if(bl)console.info(ne);else switch(yl[0]){case`init`:await ti();break;case`login`:await yi();break;case`logout`:await Si();break;case`whoami`:await gl();break;case`status`:await tc();break;case`repo`:await zo();break;case`locale`:await _i();break;case`page-type`:await Fa();break;case`custom-type`:await Rr();break;case`slice`:await Bs();break;case`pull`:await co();break;case`push`:await fo();break;case`codegen`:await Jn();break;case`docs`:await Wr();break;case`preview`:await so();break;case`token`:await Hc();break;case`webhook`:await hl();break;default:yl[0]&&(console.error(`Unknown command: ${yl[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
|
|
1998
2387
|
|
|
1999
2388
|
USAGE
|
|
2000
2389
|
prismic <command> [flags]
|
|
@@ -2004,6 +2393,7 @@ COMMANDS
|
|
|
2004
2393
|
login Log in to Prismic
|
|
2005
2394
|
logout Log out of Prismic
|
|
2006
2395
|
whoami Show the currently logged in user
|
|
2396
|
+
status Show the status of the current project
|
|
2007
2397
|
repo Manage Prismic repositories
|
|
2008
2398
|
locale Manage locales in a repository
|
|
2009
2399
|
page-type Manage page types in a repository
|
|
@@ -2011,12 +2401,15 @@ COMMANDS
|
|
|
2011
2401
|
slice Manage slices in a project
|
|
2012
2402
|
pull Pull types and slices from Prismic
|
|
2013
2403
|
push Push types and slices to Prismic
|
|
2404
|
+
codegen Generate code from Prismic models
|
|
2405
|
+
docs Fetch documentation from Prismic
|
|
2014
2406
|
preview Manage preview configurations
|
|
2015
2407
|
token Manage API tokens in a repository
|
|
2016
2408
|
webhook Manage webhooks in a repository
|
|
2017
2409
|
|
|
2018
2410
|
FLAGS
|
|
2019
|
-
-
|
|
2411
|
+
-v, --version Show CLI version
|
|
2412
|
+
-h, --help Show help for command
|
|
2020
2413
|
|
|
2021
2414
|
LEARN MORE
|
|
2022
2415
|
Use \`prismic <command> --help\` for more information about a command.`)}export{};
|