@angeloashmore/prismic-cli-poc 0.0.0-canary.d96e685 → 0.0.0-canary.e58e691
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 +156 -107
- package/package.json +1 -1
- package/src/index.ts +10 -0
- package/src/lib/custom-types-api.ts +384 -0
- package/src/pull.ts +212 -0
- package/src/push.ts +381 -0
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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{pathToFileURL as c}from"node:url";import{homedir as l}from"node:os";import{exec as u}from"node:child_process";import{createServer as d}from"node:http";function f(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function p(e){return(void 0)?.get(e)}function m(e){return(void 0)?.get(e)}function h(e,t){return(void 0)?.get(e)?.get(t)}function g(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 _(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??g(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??h(e.reference,c.lang)??(l?m(c.lang):null)??r.message??p(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 v(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},f())}}}function y(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function b(e){return e instanceof
|
|
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{pathToFileURL as c}from"node:url";import{homedir as l}from"node:os";import{exec as u}from"node:child_process";import{createServer as d}from"node:http";function f(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function p(e){return(void 0)?.get(e)}function m(e){return(void 0)?.get(e)}function h(e,t){return(void 0)?.get(e)?.get(t)}function g(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 _(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??g(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??h(e.reference,c.lang)??(l?m(c.lang):null)??r.message??p(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 v(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},f())}}}function y(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function b(e){return e instanceof x}var x=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function ee(e){return{kind:`validation`,type:`url`,reference:ee,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)&&_(this,`URL`,e,t),e}}}function te(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function ne(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function S(e,t){return{kind:`schema`,type:`array`,reference:S,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return v(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 _(this,`type`,e,t);return e}}}function C(e){return{kind:`schema`,type:`boolean`,reference:C,expects:`boolean`,async:!1,message:e,get"~standard"(){return v(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:_(this,`type`,e,t),e}}}function re(e,t){return{kind:`schema`,type:`literal`,reference:re,expects:g(e),async:!1,literal:e,message:t,get"~standard"(){return v(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:_(this,`type`,e,t),e}}}function w(e,t){return{kind:`schema`,type:`nullable`,reference:w,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return v(this)},"~run"(e,t){return e.value===null&&(this.default!==void 0&&(e.value=ne(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function T(e){return{kind:`schema`,type:`number`,reference:T,expects:`number`,async:!1,message:e,get"~standard"(){return v(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:_(this,`type`,e,t),e}}}function E(e,t){return{kind:`schema`,type:`object`,reference:E,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return v(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]:ne(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]=te(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(_(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 _(this,`type`,e,t);return e}}}function D(e,t){return{kind:`schema`,type:`optional`,reference:D,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return v(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=ne(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function O(e,t,n){return{kind:`schema`,type:`record`,reference:O,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return v(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},n)if(y(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 _(this,`type`,e,t);return e}}}function k(e){return{kind:`schema`,type:`string`,reference:k,expects:`string`,async:!1,message:e,get"~standard"(){return v(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:_(this,`type`,e,t),e}}}function A(){return{kind:`schema`,type:`unknown`,reference:A,expects:`unknown`,async:!1,get"~standard"(){return v(this)},"~run"(e){return e.typed=!0,e}}}function ie(e,t,n){let r=e[`~run`]({value:t},f(n));if(r.issues)throw new x(r.issues);return r.value}function ae(...e){return{...e[0],pipe:e,get"~standard"(){return v(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 j(e,t,n){let r=e[`~run`]({value:t},f(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}const oe=new URL(`.prismic`,I(c(l()))),se=`https://prismic.io`;async function ce(e,t){let n={token:e,host:t?.host};await s(oe,JSON.stringify(n,null,2))}async function M(){return!!await N()}async function N(){return(await le())?.token}async function P(){try{let e=await le();return e?.host?new URL(e.host):new URL(se)}catch{return new URL(se)}}async function le(){try{let e=await r(oe,`utf-8`);return JSON.parse(e)}catch{return}}async function ue(){try{await t(oe)}catch{return!0}return await le()?(await o(oe),!0):!1}async function F(e){let t=await P();return t.hostname=`${e}.${t.hostname}`,I(t)}async function de(){let e=await P();return e.hostname=`api.internal.${e.hostname}`,I(e)}async function fe(){let e=await P();return e.hostname=`user-service.${e.hostname}`,I(e)}function I(e){let t=new URL(e);return t.pathname.endsWith(`/`)||(t.pathname+=`/`),t}async function L(e,n={}){let{start:r=c(process.cwd()),stop:i}=n,a=I(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 R(e){try{return await t(e),!0}catch{return!1}}function z(e){return JSON.stringify(e,null,2)}const pe=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function me(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing custom type.
|
|
3
3
|
|
|
4
4
|
USAGE
|
|
5
5
|
prismic custom-type add-field boolean <type-id> <field-id> [flags]
|
|
@@ -21,7 +21,7 @@ EXAMPLES
|
|
|
21
21
|
prismic custom-type add-field boolean article published --default
|
|
22
22
|
prismic custom-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
23
23
|
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
24
|
-
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
24
|
+
`),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await L(`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=j(pe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Boolean`,config:{...i&&{label:i},...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};p.json[h][u]=g;try{await s(f,z(p))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${u}" (Boolean) to "${h}" tab in ${l}`)}const he=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function ge(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing custom type.
|
|
25
25
|
|
|
26
26
|
USAGE
|
|
27
27
|
prismic custom-type add-field color <type-id> <field-id> [flags]
|
|
@@ -41,7 +41,7 @@ EXAMPLES
|
|
|
41
41
|
prismic custom-type add-field color homepage accent --tab "Design"
|
|
42
42
|
prismic custom-type add-field color homepage text_color --label "Text Color"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
43
43
|
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
44
|
-
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
44
|
+
`),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`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=j(he,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Color`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Color) to "${p}" tab in ${o}`)}const _e=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function ve(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing custom type.
|
|
45
45
|
|
|
46
46
|
USAGE
|
|
47
47
|
prismic custom-type add-field date <type-id> <field-id> [flags]
|
|
@@ -62,7 +62,7 @@ EXAMPLES
|
|
|
62
62
|
prismic custom-type add-field date event start_date --tab "Schedule"
|
|
63
63
|
prismic custom-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
64
64
|
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
65
|
-
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
65
|
+
`),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await L(`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=j(_e,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Date`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,z(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Date) to "${m}" tab in ${c}`)}const ye=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function be(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing custom type.
|
|
66
66
|
|
|
67
67
|
USAGE
|
|
68
68
|
prismic custom-type add-field embed <type-id> <field-id> [flags]
|
|
@@ -82,7 +82,7 @@ EXAMPLES
|
|
|
82
82
|
prismic custom-type add-field embed homepage youtube --tab "Media"
|
|
83
83
|
prismic custom-type add-field embed homepage media --label "Media Embed"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
84
84
|
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
85
|
-
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
85
|
+
`),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`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=j(ye,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Embed`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Embed) to "${p}" tab in ${o}`)}const xe=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Se(){let{values:{help:t,tab:n,label:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing custom type.
|
|
86
86
|
|
|
87
87
|
USAGE
|
|
88
88
|
prismic custom-type add-field geo-point <type-id> <field-id> [flags]
|
|
@@ -101,7 +101,7 @@ EXAMPLES
|
|
|
101
101
|
prismic custom-type add-field geo-point store address --tab "Details"
|
|
102
102
|
prismic custom-type add-field geo-point event venue --label "Event Venue"`);return}if(!a){console.error(`Missing required argument: type-id
|
|
103
103
|
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
104
|
-
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
104
|
+
`),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await L(`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=j(xe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}\n`),console.error(`Create it first with: prismic custom-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let d=Object.keys(u.json),f=n??d[0]??`Main`;u.json[f]||(u.json[f]={});for(let[e,t]of Object.entries(u.json))if(t[o]){console.error(`Field "${o}" already exists in tab "${e}"`),process.exitCode=1;return}let p={type:`GeoPoint`,config:{...i&&{label:i}}};u.json[f][o]=p;try{await s(l,z(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${o}" (GeoPoint) to "${f}" tab in ${a}`)}const Ce=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function we(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing custom type.
|
|
105
105
|
|
|
106
106
|
USAGE
|
|
107
107
|
prismic custom-type add-field image <type-id> <field-id> [flags]
|
|
@@ -121,7 +121,7 @@ EXAMPLES
|
|
|
121
121
|
prismic custom-type add-field image article thumbnail --tab "Media"
|
|
122
122
|
prismic custom-type add-field image product photo --label "Product Photo"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
123
123
|
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
124
|
-
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
124
|
+
`),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`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=j(Ce,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Image`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Image) to "${p}" tab in ${o}`)}const Te=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Ee(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing custom type.
|
|
125
125
|
|
|
126
126
|
USAGE
|
|
127
127
|
prismic custom-type add-field key-text <type-id> <field-id> [flags]
|
|
@@ -141,7 +141,7 @@ EXAMPLES
|
|
|
141
141
|
prismic custom-type add-field key-text homepage meta_title --tab "SEO"
|
|
142
142
|
prismic custom-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
143
143
|
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
144
|
-
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
144
|
+
`),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`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=j(Te,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Text`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (Text) to "${p}" tab in ${o}`)}const De=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Oe(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing custom type.
|
|
145
145
|
|
|
146
146
|
USAGE
|
|
147
147
|
prismic custom-type add-field link <type-id> <field-id> [flags]
|
|
@@ -166,7 +166,7 @@ EXAMPLES
|
|
|
166
166
|
prismic custom-type add-field link homepage cta --variation Primary --variation Secondary
|
|
167
167
|
prismic custom-type add-field link homepage links --repeatable`);return}if(!d){console.error(`Missing required argument: type-id
|
|
168
168
|
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
169
|
-
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await
|
|
169
|
+
`),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await L(`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=j(De,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${d}\n`),console.error(`Create it first with: prismic custom-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});for(let[e,t]of Object.entries(h.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let v={type:`Link`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};h.json[_][f]=v;try{await s(m,z(h))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${f}" (Link) to "${_}" tab in ${d}`)}const ke=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Ae(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing custom type.
|
|
170
170
|
|
|
171
171
|
USAGE
|
|
172
172
|
prismic custom-type add-field number <type-id> <field-id> [flags]
|
|
@@ -189,7 +189,7 @@ EXAMPLES
|
|
|
189
189
|
prismic custom-type add-field number product quantity --min 0 --max 100
|
|
190
190
|
prismic custom-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!u){console.error(`Missing required argument: type-id
|
|
191
191
|
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
192
|
-
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await
|
|
192
|
+
`),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await L(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${u}/index.json`,h),_;try{let e=await r(g,`utf8`),t=j(ke,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});for(let[e,t]of Object.entries(_.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let b={type:`Number`,config:{...i&&{label:i},...a&&{placeholder:a},...f!==void 0&&{min:f},...p!==void 0&&{max:p},...m!==void 0&&{step:m}}};_.json[y][d]=b;try{await s(g,z(_))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${d}" (Number) to "${y}" tab in ${u}`)}const je=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Me(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing custom type.
|
|
193
193
|
|
|
194
194
|
USAGE
|
|
195
195
|
prismic custom-type add-field rich-text <type-id> <field-id> [flags]
|
|
@@ -218,7 +218,7 @@ EXAMPLES
|
|
|
218
218
|
prismic custom-type add-field rich-text page tagline --single "heading1"
|
|
219
219
|
prismic custom-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: type-id
|
|
220
220
|
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
221
|
-
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await
|
|
221
|
+
`),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await L(`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=j(je,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`StructuredText`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};m.json[g][d]=_;try{await s(p,z(m))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${d}" (StructuredText) to "${g}" tab in ${u}`)}const Ne=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Pe(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing custom type.
|
|
222
222
|
|
|
223
223
|
USAGE
|
|
224
224
|
prismic custom-type add-field select <type-id> <field-id> [flags]
|
|
@@ -240,7 +240,7 @@ EXAMPLES
|
|
|
240
240
|
prismic custom-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
|
|
241
241
|
prismic custom-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
242
242
|
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
243
|
-
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
243
|
+
`),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await L(`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=j(Ne,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Select`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};p.json[h][u]=g;try{await s(f,z(p))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${u}" (Select) to "${h}" tab in ${l}`)}const Fe=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Ie(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing custom type.
|
|
244
244
|
|
|
245
245
|
USAGE
|
|
246
246
|
prismic custom-type add-field timestamp <type-id> <field-id> [flags]
|
|
@@ -261,7 +261,7 @@ EXAMPLES
|
|
|
261
261
|
prismic custom-type add-field timestamp event start --tab "Schedule"
|
|
262
262
|
prismic custom-type add-field timestamp article published_at --label "Published At"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
263
263
|
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
264
|
-
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
264
|
+
`),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await L(`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=j(Fe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Timestamp`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,z(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Timestamp) to "${m}" tab in ${c}`)}const Le=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Re(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing custom type.
|
|
265
265
|
|
|
266
266
|
USAGE
|
|
267
267
|
prismic custom-type add-field uid <type-id> <field-id> [flags]
|
|
@@ -281,7 +281,7 @@ EXAMPLES
|
|
|
281
281
|
prismic custom-type add-field uid article slug --label "URL Slug"
|
|
282
282
|
prismic custom-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
283
283
|
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
284
|
-
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
284
|
+
`),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`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=j(Le,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`UID`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (UID) to "${p}" tab in ${o}`)}async function ze(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await me();break;case`color`:await ge();break;case`date`:await ve();break;case`embed`:await be();break;case`geo-point`:await Se();break;case`image`:await we();break;case`key-text`:await Ee();break;case`link`:await Oe();break;case`number`:await Ae();break;case`rich-text`:await Me();break;case`select`:await Pe();break;case`timestamp`:await Ie();break;case`uid`:await Re();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing custom type.
|
|
285
285
|
|
|
286
286
|
USAGE
|
|
287
287
|
prismic custom-type add-field <field-type> <type-id> <field-id> [flags]
|
|
@@ -311,7 +311,7 @@ EXAMPLES
|
|
|
311
311
|
prismic custom-type add-field key-text homepage meta_title --tab "SEO"
|
|
312
312
|
prismic custom-type add-field link homepage button --allow-text
|
|
313
313
|
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
|
|
314
|
+
prismic custom-type add-field select homepage layout --option "full" --option "sidebar"`)}}const B=E({id:k(),type:re(`SharedSlice`),name:k(),description:D(k()),variations:S(E({id:k(),name:k(),description:D(k()),docURL:D(k()),version:D(k()),imageUrl:D(k()),primary:D(O(k(),A())),items:D(O(k(),A()))}))});async function V(e){if(!await L(`package.json`))return{ok:!1,error:`Could not find project root (no package.json found)`};let t=await H(),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=j(B,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 H(){let e=await Ve(),t=await L(`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 R(new URL(`src`,n)))return new URL(`src/slices/`,n);case`nuxt`:if(await R(new URL(`app`,n)))return new URL(`app/slices/`,n);case`sveltekit`:return new URL(`src/slices/`,n)}return new URL(`slices/`,n)}const Be=E({dependencies:D(O(k(),k()))});async function Ve(){let e=await L(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=ie(Be,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function U(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const He=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Ue(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a custom type's slice zone.
|
|
315
315
|
|
|
316
316
|
USAGE
|
|
317
317
|
prismic custom-type connect-slice <type-id> <slice-id> [flags]
|
|
@@ -329,7 +329,7 @@ EXAMPLES
|
|
|
329
329
|
prismic custom-type connect-slice homepage CallToAction --slice-zone slices
|
|
330
330
|
prismic custom-type connect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
331
331
|
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
|
|
332
|
-
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await V(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await
|
|
332
|
+
`),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await V(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await L(`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=j(He,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){if(n){console.error(`Slice zone "${n}" not found in custom type "${i}"`),process.exitCode=1;return}let e=Object.keys(u.json)[0]??`Main`;u.json[e]||(u.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};u.json[e][d]=t,f=t,p=d}if(f.config||={choices:{}},f.config.choices||(f.config.choices={}),a in f.config.choices){console.info(`Slice "${a}" is already connected to slice zone "${p}" in ${i}`);return}let m={type:`SharedSlice`};f.config.choices[a]=m;try{await s(l,z(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Connected slice "${a}" to slice zone "${p}" in ${i}`)}async function We(){let{values:{help:t,name:r,single:i},positionals:[a]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new custom type in a Prismic repository.
|
|
333
333
|
|
|
334
334
|
USAGE
|
|
335
335
|
prismic custom-type create <id> [flags]
|
|
@@ -343,7 +343,7 @@ FLAGS
|
|
|
343
343
|
-h, --help Show help for command
|
|
344
344
|
|
|
345
345
|
LEARN MORE
|
|
346
|
-
Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??
|
|
346
|
+
Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??Ge(a),repeatable:!i,status:!0,format:`custom`,json:{Main:{}}},c=await L(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/`,c),u=new URL(a+`/`,l),d=new URL(`index.json`,u);try{await n(new URL(`.`,d),{recursive:!0}),await s(d,z(o))}catch(e){e instanceof Error?console.error(`Failed to create custom type: ${e.message}`):console.error(`Failed to create custom type`),process.exitCode=1;return}console.info(`Created custom type at ${d.href}`)}function Ge(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Ke=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function qe(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a custom type's slice zone.
|
|
347
347
|
|
|
348
348
|
USAGE
|
|
349
349
|
prismic custom-type disconnect-slice <type-id> <slice-id> [flags]
|
|
@@ -361,7 +361,7 @@ EXAMPLES
|
|
|
361
361
|
prismic custom-type disconnect-slice homepage CallToAction --slice-zone slices
|
|
362
362
|
prismic custom-type disconnect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
363
363
|
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
|
|
364
|
-
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await
|
|
364
|
+
`),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await L(`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=j(Ke,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let u=n??`slices`,d,f;for(let[,e]of Object.entries(l.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===u){d=n,f=t;break}if(d)break}if(!d){console.error(`Slice zone "${u}" not found in custom type "${i}"`),process.exitCode=1;return}if(!d.config?.choices||!(a in d.config.choices)){console.error(`Slice "${a}" is not connected to slice zone "${f}" in ${i}`),process.exitCode=1;return}delete d.config.choices[a];try{await s(c,z(l))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Disconnected slice "${a}" from slice zone "${f}" in ${i}`)}const Je=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function Ye(){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
365
|
|
|
366
366
|
USAGE
|
|
367
367
|
prismic custom-type list [flags]
|
|
@@ -372,7 +372,7 @@ FLAGS
|
|
|
372
372
|
|
|
373
373
|
EXAMPLES
|
|
374
374
|
prismic custom-type list
|
|
375
|
-
prismic custom-type list --json`);return}let a=await
|
|
375
|
+
prismic custom-type list --json`);return}let a=await L(`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=j(Je,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 Xe=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function Ze(){let{values:{help:t,y:n},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom type from the project.
|
|
376
376
|
|
|
377
377
|
USAGE
|
|
378
378
|
prismic custom-type remove <type-id> [flags]
|
|
@@ -387,7 +387,7 @@ FLAGS
|
|
|
387
387
|
EXAMPLES
|
|
388
388
|
prismic custom-type remove settings
|
|
389
389
|
prismic custom-type remove settings -y`);return}if(!i){console.error(`Missing required argument: type-id
|
|
390
|
-
`),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let a=await
|
|
390
|
+
`),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let s=new URL(`customtypes/${i}/`,a),c=new URL(`index.json`,s),l;try{let e=await r(c,`utf8`),t=j(Xe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(l.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove custom type "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove custom type: ${e.message}`):console.error(`Failed to remove custom type`),process.exitCode=1;return}console.info(`Removed custom type "${i}"`)}const Qe=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function $e(){let{values:{help:t,tab:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a custom type.
|
|
391
391
|
|
|
392
392
|
USAGE
|
|
393
393
|
prismic custom-type remove-field <type-id> <field-id> [flags]
|
|
@@ -404,7 +404,7 @@ EXAMPLES
|
|
|
404
404
|
prismic custom-type remove-field settings title
|
|
405
405
|
prismic custom-type remove-field settings description --tab "Content"`);return}if(!i){console.error(`Missing required argument: type-id
|
|
406
406
|
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
|
|
407
|
-
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await
|
|
407
|
+
`),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await L(`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=j(Qe,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(l.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}let u;if(n){if(!l.json[n]){console.error(`Tab "${n}" not found in custom type "${i}"`),console.error(`Available tabs: ${Object.keys(l.json).join(`, `)}`),process.exitCode=1;return}if(!(a in l.json[n])){console.error(`Field "${a}" not found in tab "${n}"`),process.exitCode=1;return}delete l.json[n][a],u=n}else{for(let[e,t]of Object.entries(l.json))if(a in t){delete t[a],u=e;break}if(!u){console.error(`Field "${a}" not found in any tab of custom type "${i}"`),process.exitCode=1;return}}try{await s(c,z(l))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Removed field "${a}" from tab "${u}" in custom type "${i}"`)}const et=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function tt(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a custom type's display name (label).
|
|
408
408
|
|
|
409
409
|
USAGE
|
|
410
410
|
prismic custom-type set-name <type-id> <new-name> [flags]
|
|
@@ -420,7 +420,7 @@ EXAMPLES
|
|
|
420
420
|
prismic custom-type set-name settings "Site Settings"
|
|
421
421
|
prismic custom-type set-name menu "Navigation Menu"`);return}if(!n){console.error(`Missing required argument: type-id
|
|
422
422
|
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: new-name
|
|
423
|
-
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await
|
|
423
|
+
`),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${n}/index.json`,a),c;try{let e=await r(o,`utf8`),t=j(et,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${o.href}`),process.exitCode=1;return}c=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${n}\n`),console.error(`Create it first with: prismic custom-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(c.format===`page`){console.error(`"${n}" is not a custom type (format: page)`),process.exitCode=1;return}c.label=i;try{await s(o,z(c))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Renamed custom type "${n}" to "${i}"`)}const nt=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function rt(){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
424
|
|
|
425
425
|
USAGE
|
|
426
426
|
prismic custom-type view <type-id> [flags]
|
|
@@ -435,7 +435,7 @@ FLAGS
|
|
|
435
435
|
EXAMPLES
|
|
436
436
|
prismic custom-type view settings
|
|
437
437
|
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
|
|
438
|
+
`),console.error(`Usage: prismic custom-type view <type-id>`),process.exitCode=1;return}let a=await L(`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=j(nt,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 it(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await We();break;case`list`:await Ye();break;case`view`:await rt();break;case`remove`:await Ze();break;case`set-name`:await tt();break;case`add-field`:await ze();break;case`remove-field`:await $e();break;case`connect-slice`:await Ue();break;case`disconnect-slice`:await qe();break;default:t&&(console.error(`Unknown custom-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage custom types in a Prismic repository.
|
|
439
439
|
|
|
440
440
|
USAGE
|
|
441
441
|
prismic custom-type <command> [flags]
|
|
@@ -455,7 +455,7 @@ FLAGS
|
|
|
455
455
|
-h, --help Show help for command
|
|
456
456
|
|
|
457
457
|
LEARN MORE
|
|
458
|
-
Use \`prismic custom-type <command> --help\` for more information about a command.`)}}const
|
|
458
|
+
Use \`prismic custom-type <command> --help\` for more information about a command.`)}}const at=`prismic.config.json`,ot=E({repositoryName:k(),apiEndpoint:D(ae(k(),ee())),localSliceMachineSimulatorURL:D(ae(k(),ee())),libraries:D(S(k())),adapter:D(k()),labs:D(E({legacySliceUpgrader:D(C())}))});async function st(e,t=c(process.cwd())){let n=await dt(t);return n.ok?(await s(n.path,z(e)),{ok:!0,config:e}):n}async function W(e=c(process.cwd())){let t=await G(e);if(t.ok)return t.config.repositoryName}async function G(e=c(process.cwd())){let t=await ut(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=j(ot,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new ct(n.issues)}}catch{return{ok:!1,error:new ct}}}var ct=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function lt(e,t=c(process.cwd())){let n=await ut(t);if(!n.ok)return n;let r=await G(t);if(!r.ok)return r;let i={...r.config,...e};return await s(n.path,z(i)),{ok:!0,config:i}}async function ut(e=c(process.cwd())){let t=await L(at,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new ft}}async function dt(e=c(process.cwd())){let t=await L(`package.json`,{start:e});return t?{ok:!0,path:new URL(at,t)}:{ok:!1,error:new pt}}var ft=class extends Error{message=`Could not find a prismic.config.json file.`},pt=class extends Error{message=`Could not find a package.json file.`};async function mt(){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
459
|
|
|
460
460
|
Use this command to connect an existing Prismic repository to your project.
|
|
461
461
|
To create a new repository, use \`prismic repo create\` instead.
|
|
@@ -468,7 +468,7 @@ FLAGS
|
|
|
468
468
|
-h, --help Show help for command
|
|
469
469
|
|
|
470
470
|
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
|
|
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 G()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await st({repositoryName:t.repo});if(!n.ok){n.error instanceof pt?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 K(e,t={}){let{credentials:n=`include`}=t,r=new Headers(t.headers);if(r.set(`Accept`,`application/json`),n===`include`){let e=await N();e&&r.set(`Cookie`,`SESSION=fake_session; prismic-auth=${e}`)}!r.has(`Content-Type`)&&t.body&&r.set(`Content-Type`,`application/json`),t.body instanceof FormData&&r.delete(`Content-Type`);let i=r.get(`Content-Type`)===`application/json`?JSON.stringify(t.body):t.body,a=await fetch(e,{...t,body:i,headers:r}),o=await a.clone().json().catch(()=>a.clone().text());if(a.ok){if(!t?.schema)return{ok:!0,value:o};try{return{ok:!0,value:ie(t.schema,o)}}catch(e){if(b(e))return{ok:!1,value:o,error:e};throw e}}else if(a.status===401)return{ok:!1,value:o,error:new J(a)};else if(a.status===403)return{ok:!1,value:o,error:new q(a)};else return{ok:!1,value:o,error:new ht(a)}}var ht=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}},q=class extends ht{},J=class extends ht{};async function gt(){let{values:{help:t,name:n,repo:r=await W()},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
472
|
|
|
473
473
|
By default, this command reads the repository from prismic.config.json at the
|
|
474
474
|
project root.
|
|
@@ -485,7 +485,7 @@ FLAGS
|
|
|
485
485
|
-h, --help Show help for command
|
|
486
486
|
|
|
487
487
|
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
|
|
488
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){yt();return}let a=n?await vt(r,i,n):await _t(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof q?yt():(console.error(`Failed to add locale: ${z(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function _t(e,t){return await K(new URL(`/app/settings/multilanguages`,await F(e)),{method:`POST`,body:{languages:[t]}})}async function vt(e,t,n){let[r,i]=t.split(`-`);return await K(new URL(`/app/settings/multilanguages/custom`,await F(e)),{method:`POST`,body:{lang:{label:n,id:r||t},region:{label:n,id:i||r||t}}})}function yt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function bt(){let{values:{help:t,repo:n=await W(),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
489
|
|
|
490
490
|
By default, this command reads the repository from prismic.config.json at the
|
|
491
491
|
project root.
|
|
@@ -499,7 +499,7 @@ FLAGS
|
|
|
499
499
|
-h, --help Show help for command
|
|
500
500
|
|
|
501
501
|
LEARN MORE
|
|
502
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await
|
|
502
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Ct();return}let i=await St(n);if(!i.ok){i.error instanceof q?Ct():b(i.error)?(console.error(`Failed to list locales: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(z(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const xt=E({results:S(E({id:k(),label:k(),customName:w(k()),isMaster:C()}))});async function St(e){let t=new URL(`/locale/repository/locales`,await de());return t.searchParams.set(`repository`,e),await K(t,{schema:xt})}function Ct(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function wt(){let{values:{repo:t=await W(),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
503
|
|
|
504
504
|
By default, this command reads the repository from prismic.config.json at the
|
|
505
505
|
project root.
|
|
@@ -515,7 +515,7 @@ FLAGS
|
|
|
515
515
|
-h, --help Show help for command
|
|
516
516
|
|
|
517
517
|
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
|
|
518
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!t){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Et();return}let i=await Tt(t,r);if(!i.ok){i.error instanceof q?Et():(console.error(`Failed to remove locale: ${z(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function Tt(e,t){let n=new URL(`/locale/repository/locales/${t}`,await de());return n.searchParams.set(`repository`,e),await K(n,{method:`DELETE`})}function Et(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Dt(){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(`Set the default locale for a Prismic repository.
|
|
519
519
|
|
|
520
520
|
By default, this command reads the repository from prismic.config.json at the
|
|
521
521
|
project root.
|
|
@@ -531,7 +531,7 @@ FLAGS
|
|
|
531
531
|
-h, --help Show help for command
|
|
532
532
|
|
|
533
533
|
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
|
|
534
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){kt();return}let i=await St(n);if(!i.ok){i.error instanceof q?kt():b(i.error)?(console.error(`Failed to set default locale: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set default locale: ${z(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 Ot(n,o);if(!s.ok){s.error instanceof q?kt():(console.error(`Failed to set default locale: ${z(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function Ot(e,t){let n=new URL(`/locale/repository/locales`,await de());return n.searchParams.set(`repository`,e),await K(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function kt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function At(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await gt();break;case`list`:await bt();break;case`remove`:await wt();break;case`set-default`:await Dt();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
|
|
535
535
|
|
|
536
536
|
USAGE
|
|
537
537
|
prismic locale <command> [flags]
|
|
@@ -546,7 +546,7 @@ FLAGS
|
|
|
546
546
|
-h, --help Show help for command
|
|
547
547
|
|
|
548
548
|
LEARN MORE
|
|
549
|
-
Use \`prismic locale <command> --help\` for more information about a command.`)}}async function
|
|
549
|
+
Use \`prismic locale <command> --help\` for more information about a command.`)}}async function jt(){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
550
|
|
|
551
551
|
USAGE
|
|
552
552
|
prismic login [flags]
|
|
@@ -555,7 +555,7 @@ FLAGS
|
|
|
555
555
|
-h, --help Show help for command
|
|
556
556
|
|
|
557
557
|
LEARN MORE
|
|
558
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=d((t,i)=>{if(t.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();return}if(t.method===`POST`){let a=``;t.on(`data`,e=>{a+=e.toString()}),t.on(`end`,async()=>{try{let{cookies:t,email:o}=JSON.parse(a),s=t.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!s){i.writeHead(400,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await
|
|
558
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=d((t,i)=>{if(t.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();return}if(t.method===`POST`){let a=``;t.on(`data`,e=>{a+=e.toString()}),t.on(`end`,async()=>{try{let{cookies:t,email:o}=JSON.parse(a),s=t.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!s){i.writeHead(400,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await ce(s),console.info(`Logged in to Prismic as ${o}`),i.writeHead(200,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({success:!0})),clearTimeout(r),n.close(),e()}catch{i.writeHead(400,{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}))}});return}i.writeHead(404),i.end()}),r=setTimeout(()=>{n.close(),t(Error(`Login timed out. Please try again.`))},18e4);n.listen(0,`127.0.0.1`,()=>{let e=n.address();if(!e||typeof e==`string`){clearTimeout(r),n.close(),t(Error(`Failed to start login server`));return}let i=e.port,a=Mt(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),Nt(a)}),n.on(`error`,e=>{clearTimeout(r),t(e)})})}function Mt(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 Nt(e){u(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function Pt(){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
559
|
|
|
560
560
|
USAGE
|
|
561
561
|
prismic logout [flags]
|
|
@@ -564,7 +564,7 @@ FLAGS
|
|
|
564
564
|
-h, --help Show help for command
|
|
565
565
|
|
|
566
566
|
LEARN MORE
|
|
567
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}await
|
|
567
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}await ue()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const Ft=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function It(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing page type.
|
|
568
568
|
|
|
569
569
|
USAGE
|
|
570
570
|
prismic page-type add-field boolean <type-id> <field-id> [flags]
|
|
@@ -586,7 +586,7 @@ EXAMPLES
|
|
|
586
586
|
prismic page-type add-field boolean article published --default
|
|
587
587
|
prismic page-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
588
588
|
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
589
|
-
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
589
|
+
`),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let d=await L(`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=j(Ft,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Boolean`,config:{...i&&{label:i},...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};p.json[h][u]=g;try{await s(f,z(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${u}" (Boolean) to "${h}" tab in ${l}`)}const Lt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Rt(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing page type.
|
|
590
590
|
|
|
591
591
|
USAGE
|
|
592
592
|
prismic page-type add-field color <type-id> <field-id> [flags]
|
|
@@ -606,7 +606,7 @@ EXAMPLES
|
|
|
606
606
|
prismic page-type add-field color homepage accent --tab "Design"
|
|
607
607
|
prismic page-type add-field color homepage text_color --label "Text Color"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
608
608
|
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
609
|
-
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
609
|
+
`),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`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=j(Lt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Color`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Color) to "${p}" tab in ${o}`)}const zt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Bt(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing page type.
|
|
610
610
|
|
|
611
611
|
USAGE
|
|
612
612
|
prismic page-type add-field date <type-id> <field-id> [flags]
|
|
@@ -627,7 +627,7 @@ EXAMPLES
|
|
|
627
627
|
prismic page-type add-field date event start_date --tab "Schedule"
|
|
628
628
|
prismic page-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
629
629
|
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
630
|
-
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
630
|
+
`),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let u=await L(`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=j(zt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Date`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,z(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Date) to "${m}" tab in ${c}`)}const Vt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Ht(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing page type.
|
|
631
631
|
|
|
632
632
|
USAGE
|
|
633
633
|
prismic page-type add-field embed <type-id> <field-id> [flags]
|
|
@@ -647,7 +647,7 @@ EXAMPLES
|
|
|
647
647
|
prismic page-type add-field embed homepage youtube --tab "Media"
|
|
648
648
|
prismic page-type add-field embed homepage media --label "Media Embed"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
649
649
|
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
650
|
-
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
650
|
+
`),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`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=j(Vt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Embed`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Embed) to "${p}" tab in ${o}`)}const Ut=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Wt(){let{values:{help:t,tab:n,label:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing page type.
|
|
651
651
|
|
|
652
652
|
USAGE
|
|
653
653
|
prismic page-type add-field geo-point <type-id> <field-id> [flags]
|
|
@@ -666,7 +666,7 @@ EXAMPLES
|
|
|
666
666
|
prismic page-type add-field geo-point store address --tab "Details"
|
|
667
667
|
prismic page-type add-field geo-point event venue --label "Event Venue"`);return}if(!a){console.error(`Missing required argument: type-id
|
|
668
668
|
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
669
|
-
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await
|
|
669
|
+
`),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let c=await L(`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=j(Ut,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=Object.keys(u.json),f=n??d[0]??`Main`;u.json[f]||(u.json[f]={});for(let[e,t]of Object.entries(u.json))if(t[o]){console.error(`Field "${o}" already exists in tab "${e}"`),process.exitCode=1;return}let p={type:`GeoPoint`,config:{...i&&{label:i}}};u.json[f][o]=p;try{await s(l,z(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${o}" (GeoPoint) to "${f}" tab in ${a}`)}const Gt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Kt(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing page type.
|
|
670
670
|
|
|
671
671
|
USAGE
|
|
672
672
|
prismic page-type add-field image <type-id> <field-id> [flags]
|
|
@@ -686,7 +686,7 @@ EXAMPLES
|
|
|
686
686
|
prismic page-type add-field image article thumbnail --tab "Media"
|
|
687
687
|
prismic page-type add-field image product photo --label "Product Photo"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
688
688
|
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
689
|
-
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
689
|
+
`),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`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=j(Gt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Image`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Image) to "${p}" tab in ${o}`)}const qt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Jt(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing page type.
|
|
690
690
|
|
|
691
691
|
USAGE
|
|
692
692
|
prismic page-type add-field key-text <type-id> <field-id> [flags]
|
|
@@ -706,7 +706,7 @@ EXAMPLES
|
|
|
706
706
|
prismic page-type add-field key-text homepage meta_title --tab "SEO"
|
|
707
707
|
prismic page-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
708
708
|
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
709
|
-
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
709
|
+
`),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`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=j(qt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`Text`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (Text) to "${p}" tab in ${o}`)}const Yt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Xt(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing page type.
|
|
710
710
|
|
|
711
711
|
USAGE
|
|
712
712
|
prismic page-type add-field link <type-id> <field-id> [flags]
|
|
@@ -731,7 +731,7 @@ EXAMPLES
|
|
|
731
731
|
prismic page-type add-field link homepage cta --variation Primary --variation Secondary
|
|
732
732
|
prismic page-type add-field link homepage links --repeatable`);return}if(!d){console.error(`Missing required argument: type-id
|
|
733
733
|
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
|
|
734
|
-
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await
|
|
734
|
+
`),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let p=await L(`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=j(Yt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});for(let[e,t]of Object.entries(h.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let v={type:`Link`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};h.json[_][f]=v;try{await s(m,z(h))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${f}" (Link) to "${_}" tab in ${d}`)}const Zt=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function Qt(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing page type.
|
|
735
735
|
|
|
736
736
|
USAGE
|
|
737
737
|
prismic page-type add-field number <type-id> <field-id> [flags]
|
|
@@ -754,7 +754,7 @@ EXAMPLES
|
|
|
754
754
|
prismic page-type add-field number product quantity --min 0 --max 100
|
|
755
755
|
prismic page-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!u){console.error(`Missing required argument: type-id
|
|
756
756
|
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
757
|
-
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await
|
|
757
|
+
`),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let f=o===void 0?void 0:Number(o),p=c===void 0?void 0:Number(c),m=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(f)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(p)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(m)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let h=await L(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${u}/index.json`,h),_;try{let e=await r(g,`utf8`),t=j(Zt,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});for(let[e,t]of Object.entries(_.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let b={type:`Number`,config:{...i&&{label:i},...a&&{placeholder:a},...f!==void 0&&{min:f},...p!==void 0&&{max:p},...m!==void 0&&{step:m}}};_.json[y][d]=b;try{await s(g,z(_))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${d}" (Number) to "${y}" tab in ${u}`)}const $t=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function en(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing page type.
|
|
758
758
|
|
|
759
759
|
USAGE
|
|
760
760
|
prismic page-type add-field rich-text <type-id> <field-id> [flags]
|
|
@@ -783,7 +783,7 @@ EXAMPLES
|
|
|
783
783
|
prismic page-type add-field rich-text page tagline --single "heading1"
|
|
784
784
|
prismic page-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: type-id
|
|
785
785
|
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
|
|
786
|
-
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await
|
|
786
|
+
`),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let f=await L(`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=j($t,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`StructuredText`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};m.json[g][d]=_;try{await s(p,z(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${d}" (StructuredText) to "${g}" tab in ${u}`)}const tn=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function nn(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing page type.
|
|
787
787
|
|
|
788
788
|
USAGE
|
|
789
789
|
prismic page-type add-field select <type-id> <field-id> [flags]
|
|
@@ -805,7 +805,7 @@ EXAMPLES
|
|
|
805
805
|
prismic page-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
|
|
806
806
|
prismic page-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
807
807
|
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
808
|
-
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await
|
|
808
|
+
`),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let d=await L(`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=j(tn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Select`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};p.json[h][u]=g;try{await s(f,z(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${u}" (Select) to "${h}" tab in ${l}`)}const rn=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function an(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing page type.
|
|
809
809
|
|
|
810
810
|
USAGE
|
|
811
811
|
prismic page-type add-field timestamp <type-id> <field-id> [flags]
|
|
@@ -826,7 +826,7 @@ EXAMPLES
|
|
|
826
826
|
prismic page-type add-field timestamp event start --tab "Schedule"
|
|
827
827
|
prismic page-type add-field timestamp article published_at --label "Published At"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
828
828
|
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
829
|
-
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await
|
|
829
|
+
`),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let u=await L(`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=j(rn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Timestamp`,config:{...i&&{label:i},...a&&{placeholder:a},...o&&{default:o}}};f.json[m][l]=h;try{await s(d,z(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Timestamp) to "${m}" tab in ${c}`)}const on=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function sn(){let{values:{help:t,tab:n,label:i,placeholder:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing page type.
|
|
830
830
|
|
|
831
831
|
USAGE
|
|
832
832
|
prismic page-type add-field uid <type-id> <field-id> [flags]
|
|
@@ -846,7 +846,7 @@ EXAMPLES
|
|
|
846
846
|
prismic page-type add-field uid article slug --label "URL Slug"
|
|
847
847
|
prismic page-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
848
848
|
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
|
|
849
|
-
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await
|
|
849
|
+
`),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let l=await L(`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=j(on,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`UID`,config:{...i&&{label:i},...a&&{placeholder:a}}};d.json[p][c]=m;try{await s(u,z(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (UID) to "${p}" tab in ${o}`)}async function cn(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await It();break;case`color`:await Rt();break;case`date`:await Bt();break;case`embed`:await Ht();break;case`geo-point`:await Wt();break;case`image`:await Kt();break;case`key-text`:await Jt();break;case`link`:await Xt();break;case`number`:await Qt();break;case`rich-text`:await en();break;case`select`:await nn();break;case`timestamp`:await an();break;case`uid`:await sn();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
|
|
850
850
|
|
|
851
851
|
USAGE
|
|
852
852
|
prismic page-type add-field <field-type> <type-id> <field-id> [flags]
|
|
@@ -876,7 +876,7 @@ EXAMPLES
|
|
|
876
876
|
prismic page-type add-field key-text homepage meta_title --tab "SEO"
|
|
877
877
|
prismic page-type add-field link homepage button --allow-text
|
|
878
878
|
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
|
|
879
|
+
prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const ln=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function un(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a page type's slice zone.
|
|
880
880
|
|
|
881
881
|
USAGE
|
|
882
882
|
prismic page-type connect-slice <type-id> <slice-id> [flags]
|
|
@@ -894,7 +894,7 @@ EXAMPLES
|
|
|
894
894
|
prismic page-type connect-slice homepage CallToAction --slice-zone slices
|
|
895
895
|
prismic page-type connect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
896
896
|
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
|
|
897
|
-
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await V(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await
|
|
897
|
+
`),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await V(a);if(!o.ok){console.error(o.error),process.exitCode=1;return}let c=await L(`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=j(ln,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){if(n){console.error(`Slice zone "${n}" not found in page type "${i}"`),process.exitCode=1;return}let e=Object.keys(u.json)[0]??`Main`;u.json[e]||(u.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};u.json[e][d]=t,f=t,p=d}if(f.config||={choices:{}},f.config.choices||(f.config.choices={}),a in f.config.choices){console.info(`Slice "${a}" is already connected to slice zone "${p}" in ${i}`);return}let m={type:`SharedSlice`};f.config.choices[a]=m;try{await s(l,z(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Connected slice "${a}" to slice zone "${p}" in ${i}`)}async function dn(){let{values:{help:t,name:r,single:i},positionals:[a]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new page type in a Prismic repository.
|
|
898
898
|
|
|
899
899
|
USAGE
|
|
900
900
|
prismic page-type create <id> [flags]
|
|
@@ -908,7 +908,7 @@ FLAGS
|
|
|
908
908
|
-h, --help Show help for command
|
|
909
909
|
|
|
910
910
|
LEARN MORE
|
|
911
|
-
Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??
|
|
911
|
+
Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,label:r??fn(a),repeatable:!i,status:!0,format:`page`,json:{Main:{},"SEO & Metadata":{}}},c=await L(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/`,c),u=new URL(a+`/`,l),d=new URL(`index.json`,u);try{await n(new URL(`.`,d),{recursive:!0}),await s(d,z(o))}catch(e){e instanceof Error?console.error(`Failed to create page type: ${e.message}`):console.error(`Failed to create page type`),process.exitCode=1;return}console.info(`Created page type at ${d.href}`)}function fn(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const pn=E({id:k(),label:k(),repeatable:C(),status:C(),format:k(),json:O(k(),O(k(),A()))});async function mn(){let{values:{help:t,"slice-zone":n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a page type's slice zone.
|
|
912
912
|
|
|
913
913
|
USAGE
|
|
914
914
|
prismic page-type disconnect-slice <type-id> <slice-id> [flags]
|
|
@@ -926,7 +926,7 @@ EXAMPLES
|
|
|
926
926
|
prismic page-type disconnect-slice homepage CallToAction --slice-zone slices
|
|
927
927
|
prismic page-type disconnect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
928
928
|
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: slice-id
|
|
929
|
-
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await
|
|
929
|
+
`),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let o=await L(`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=j(pn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let u=n??`slices`,d,f;for(let[,e]of Object.entries(l.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===u){d=n,f=t;break}if(d)break}if(!d){console.error(`Slice zone "${u}" not found in page type "${i}"`),process.exitCode=1;return}if(!d.config?.choices||!(a in d.config.choices)){console.error(`Slice "${a}" is not connected to slice zone "${f}" in ${i}`),process.exitCode=1;return}delete d.config.choices[a];try{await s(c,z(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Disconnected slice "${a}" from slice zone "${f}" in ${i}`)}const hn=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function gn(){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
930
|
|
|
931
931
|
USAGE
|
|
932
932
|
prismic page-type list [flags]
|
|
@@ -937,7 +937,7 @@ FLAGS
|
|
|
937
937
|
|
|
938
938
|
EXAMPLES
|
|
939
939
|
prismic page-type list
|
|
940
|
-
prismic page-type list --json`);return}let a=await
|
|
940
|
+
prismic page-type list --json`);return}let a=await L(`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=j(hn,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 _n=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function vn(){let{values:{help:t,y:n},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a page type from the project.
|
|
941
941
|
|
|
942
942
|
USAGE
|
|
943
943
|
prismic page-type remove <type-id> [flags]
|
|
@@ -952,7 +952,7 @@ FLAGS
|
|
|
952
952
|
EXAMPLES
|
|
953
953
|
prismic page-type remove homepage
|
|
954
954
|
prismic page-type remove homepage -y`);return}if(!i){console.error(`Missing required argument: type-id
|
|
955
|
-
`),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let a=await
|
|
955
|
+
`),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let s=new URL(`customtypes/${i}/`,a),c=new URL(`index.json`,s),l;try{let e=await r(c,`utf8`),t=j(_n,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove page type "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove page type: ${e.message}`):console.error(`Failed to remove page type`),process.exitCode=1;return}console.info(`Removed page type "${i}"`)}const yn=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function bn(){let{values:{help:t,tab:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a page type.
|
|
956
956
|
|
|
957
957
|
USAGE
|
|
958
958
|
prismic page-type remove-field <type-id> <field-id> [flags]
|
|
@@ -969,7 +969,7 @@ EXAMPLES
|
|
|
969
969
|
prismic page-type remove-field homepage title
|
|
970
970
|
prismic page-type remove-field homepage meta_title --tab "SEO & Metadata"`);return}if(!i){console.error(`Missing required argument: type-id
|
|
971
971
|
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
|
|
972
|
-
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await
|
|
972
|
+
`),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let o=await L(`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=j(yn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}let u;if(n){if(!l.json[n]){console.error(`Tab "${n}" not found in page type "${i}"`),console.error(`Available tabs: ${Object.keys(l.json).join(`, `)}`),process.exitCode=1;return}if(!(a in l.json[n])){console.error(`Field "${a}" not found in tab "${n}"`),process.exitCode=1;return}delete l.json[n][a],u=n}else{for(let[e,t]of Object.entries(l.json))if(a in t){delete t[a],u=e;break}if(!u){console.error(`Field "${a}" not found in any tab of page type "${i}"`),process.exitCode=1;return}}try{await s(c,z(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Removed field "${a}" from tab "${u}" in page type "${i}"`)}const xn=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function Sn(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a page type's display name (label).
|
|
973
973
|
|
|
974
974
|
USAGE
|
|
975
975
|
prismic page-type set-name <type-id> <new-name> [flags]
|
|
@@ -985,7 +985,7 @@ EXAMPLES
|
|
|
985
985
|
prismic page-type set-name homepage "Home Page"
|
|
986
986
|
prismic page-type set-name blog_post "Blog Post"`);return}if(!n){console.error(`Missing required argument: type-id
|
|
987
987
|
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: new-name
|
|
988
|
-
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await
|
|
988
|
+
`),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let a=await L(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${n}/index.json`,a),c;try{let e=await r(o,`utf8`),t=j(xn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${o.href}`),process.exitCode=1;return}c=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${n}\n`),console.error(`Create it first with: prismic page-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(c.format!==`page`){console.error(`"${n}" is not a page type (format: ${c.format??`custom`})`),process.exitCode=1;return}c.label=i;try{await s(o,z(c))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Renamed page type "${n}" to "${i}"`)}const Cn=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function wn(){let{values:{help:t},positionals:[n,i]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set whether a page type is repeatable.
|
|
989
989
|
|
|
990
990
|
USAGE
|
|
991
991
|
prismic page-type set-repeatable <type-id> <true|false> [flags]
|
|
@@ -1001,7 +1001,7 @@ EXAMPLES
|
|
|
1001
1001
|
prismic page-type set-repeatable homepage true
|
|
1002
1002
|
prismic page-type set-repeatable settings false`);return}if(!n){console.error(`Missing required argument: type-id
|
|
1003
1003
|
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: true|false
|
|
1004
|
-
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(i!==`true`&&i!==`false`){console.error(`Invalid value: "${i}". Must be "true" or "false".`),process.exitCode=1;return}let a=i===`true`,o=await
|
|
1004
|
+
`),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(i!==`true`&&i!==`false`){console.error(`Invalid value: "${i}". Must be "true" or "false".`),process.exitCode=1;return}let a=i===`true`,o=await L(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${n}/index.json`,o),l;try{let e=await r(c,`utf8`),t=j(Cn,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${n}\n`),console.error(`Create it first with: prismic page-type create ${n}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${n}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}l.repeatable=a;try{await s(c,z(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}let u=a?`repeatable`:`singleton`;console.info(`Set page type "${n}" to ${u}`)}const Tn=E({id:k(),label:k(),repeatable:C(),status:C(),format:D(k()),json:O(k(),O(k(),A()))});async function En(){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
1005
|
|
|
1006
1006
|
USAGE
|
|
1007
1007
|
prismic page-type view <type-id> [flags]
|
|
@@ -1016,7 +1016,7 @@ FLAGS
|
|
|
1016
1016
|
EXAMPLES
|
|
1017
1017
|
prismic page-type view homepage
|
|
1018
1018
|
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
|
|
1019
|
+
`),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await L(`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=j(Tn,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 Dn(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await dn();break;case`list`:await gn();break;case`view`:await En();break;case`remove`:await vn();break;case`set-name`:await Sn();break;case`set-repeatable`:await wn();break;case`add-field`:await cn();break;case`remove-field`:await bn();break;case`connect-slice`:await un();break;case`disconnect-slice`:await mn();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
|
|
1020
1020
|
|
|
1021
1021
|
USAGE
|
|
1022
1022
|
prismic page-type <command> [flags]
|
|
@@ -1037,7 +1037,7 @@ FLAGS
|
|
|
1037
1037
|
-h, --help Show help for command
|
|
1038
1038
|
|
|
1039
1039
|
LEARN MORE
|
|
1040
|
-
Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function
|
|
1040
|
+
Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function On(){let{values:{help:t,name:n,repo:r=await W()},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
1041
|
|
|
1042
1042
|
By default, this command reads the repository from prismic.config.json at the
|
|
1043
1043
|
project root.
|
|
@@ -1054,7 +1054,7 @@ FLAGS
|
|
|
1054
1054
|
-h, --help Show help for command
|
|
1055
1055
|
|
|
1056
1056
|
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
|
|
1057
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){jn();return}let a=kn(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await An(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof q?jn():(console.error(`Failed to add preview: ${z(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function kn(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 An(e,t){return await K(new URL(`/previews/new`,await F(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function jn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Mn(){let{values:{help:t,repo:n=await W(),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
1058
|
|
|
1059
1059
|
By default, this command reads the repository from prismic.config.json at the
|
|
1060
1060
|
project root.
|
|
@@ -1068,7 +1068,7 @@ FLAGS
|
|
|
1068
1068
|
-h, --help Show help for command
|
|
1069
1069
|
|
|
1070
1070
|
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
|
|
1071
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Fn();return}let i=await Pn(n);if(!i.ok){i.error instanceof q?Fn():b(i.error)?(console.error(`Failed to list previews: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list previews: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(z(a));else for(let e of a)console.info(`${e.url} ${e.label}`)}const Nn=E({results:S(E({id:k(),label:k(),url:k()}))});async function Pn(e){return await K(new URL(`/core/repository/preview_configs`,await F(e)),{schema:Nn})}function Fn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function In(){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(`Remove a preview configuration from a Prismic repository.
|
|
1072
1072
|
|
|
1073
1073
|
By default, this command reads the repository from prismic.config.json at the
|
|
1074
1074
|
project root.
|
|
@@ -1084,7 +1084,7 @@ FLAGS
|
|
|
1084
1084
|
-h, --help Show help for command
|
|
1085
1085
|
|
|
1086
1086
|
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
|
|
1087
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Rn();return}let i=await Pn(n);if(!i.ok){i.error instanceof q?Rn():(console.error(`Failed to fetch previews: ${z(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 Ln(n,a.id);if(!o.ok){o.error instanceof q?Rn():(console.error(`Failed to remove preview: ${z(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function Ln(e,t){return await K(new URL(`/previews/delete/${t}`,await F(e)),{method:`POST`,body:{}})}function Rn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function zn(){let{values:{help:t,repo:n=await W()},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
1088
|
|
|
1089
1089
|
By default, this command reads the repository from prismic.config.json at the
|
|
1090
1090
|
project root.
|
|
@@ -1101,7 +1101,7 @@ FLAGS
|
|
|
1101
1101
|
-h, --help Show help for command
|
|
1102
1102
|
|
|
1103
1103
|
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
|
|
1104
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Vn();return}let a=kn(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await Pn(n);if(!o.ok){o.error instanceof q?Vn():(console.error(`Failed to fetch previews: ${z(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 Bn(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof q?Vn():(console.error(`Failed to update preview: ${z(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function Bn(e,t,n){return await K(new URL(`/previews/save/${t}`,await F(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function Vn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Hn(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await On();break;case`list`:await Mn();break;case`remove`:await In();break;case`set-name`:await zn();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
|
|
1105
1105
|
|
|
1106
1106
|
USAGE
|
|
1107
1107
|
prismic preview <command> [flags]
|
|
@@ -1116,7 +1116,54 @@ FLAGS
|
|
|
1116
1116
|
-h, --help Show help for command
|
|
1117
1117
|
|
|
1118
1118
|
LEARN MORE
|
|
1119
|
-
Use \`prismic preview <command> --help\` for more information about a command.`)}}const Gn
|
|
1119
|
+
Use \`prismic preview <command> --help\` for more information about a command.`)}}const Un=E({id:k(),label:D(k()),repeatable:C(),status:C(),format:D(k()),json:O(k(),A())});async function Y(){let e=await P();return e.hostname=`customtypes.${e.hostname}`,e}async function Wn(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Y(),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=j(S(Un),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 Gn(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Y(),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=j(S(B),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 Kn(){let e=await L(`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=j(Un,JSON.parse(e));n.success&&o.push(n.output)}catch{}}return{ok:!0,value:o}}async function qn(){let e;try{e=await H()}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=j(B,JSON.parse(e));i.success&&n.push(i.output)}catch{}}return{ok:!0,value:n}}async function Jn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),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 Yn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),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 Xn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),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 Zn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),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 Qn(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),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 $n(e,t){let n=await N();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Y(),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 er(){let{values:{help:t,repo:r=await W(),"dry-run":i,"types-only":a,"slices-only":o,json:c}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Pull custom types and slices from Prismic to local files.
|
|
1120
|
+
|
|
1121
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1122
|
+
project root.
|
|
1123
|
+
|
|
1124
|
+
USAGE
|
|
1125
|
+
prismic pull [flags]
|
|
1126
|
+
|
|
1127
|
+
FLAGS
|
|
1128
|
+
-r, --repo string Repository domain
|
|
1129
|
+
--dry-run Show what would be pulled without writing files
|
|
1130
|
+
--types-only Only pull custom types
|
|
1131
|
+
--slices-only Only pull slices
|
|
1132
|
+
--json Output as JSON
|
|
1133
|
+
-h, --help Show help for command
|
|
1134
|
+
|
|
1135
|
+
EXAMPLES
|
|
1136
|
+
prismic pull
|
|
1137
|
+
prismic pull --repo my-repo
|
|
1138
|
+
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 M()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}c||console.info(`Pulling from repository: ${r}\n`);let l=!o,u=!a,[d,f]=await Promise.all([l?Wn(r):Promise.resolve({ok:!0,value:[]}),u?Gn(r):Promise.resolve({ok:!0,value:[]})]);if(!d.ok){console.error(`Failed to fetch custom types: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch slices: ${f.error}`),process.exitCode=1;return}let p=d.value,m=f.value;if(c||(l&&console.info(`Fetching custom types... ${p.length} types`),u&&console.info(`Fetching slices... ${m.length} slices`)),i){if(c)console.info(z({customTypes:p,slices:m}));else{if(console.info(``),l&&p.length>0){console.info(`Would write custom types:`);for(let e of p)console.info(` customtypes/${e.id}/index.json`)}if(u&&m.length>0){let e=tr(await H());console.info(`Would write slices:`);for(let t of m)console.info(` ${e}${U(t.name)}/model.json`)}console.info(`\nDry run complete: ${p.length} custom types, ${m.length} slices`)}return}let h=await L(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`.`,h),_=[],v=[];if(l&&p.length>0){c||console.info(`
|
|
1140
|
+
Writing custom types:`);let e=new URL(`customtypes/`,g);for(let t of p){let r=new URL(`${t.id}/`,e),i=new URL(`index.json`,r);try{await n(r,{recursive:!0}),await s(i,z(t));let e=`customtypes/${t.id}/index.json`;_.push(e),c||console.info(` ${e}`)}catch(e){console.error(`Failed to write custom type ${t.id}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(u&&m.length>0){c||console.info(`
|
|
1141
|
+
Writing slices:`);let e=await H();for(let t of m){let r=new URL(`${U(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await s(i,z(t));let a=`${tr(e)}${U(t.name)}/model.json`;v.push(a),c||console.info(` ${a}`)}catch(e){console.error(`Failed to write slice ${t.name}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}c?console.info(z({writtenTypes:_,writtenSlices:v})):console.info(`\nPull complete: ${_.length} custom types, ${v.length} slices`)}function tr(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}function nr(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 rr(){let{values:{help:t,repo:n=await W(),"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
|
+
|
|
1143
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1144
|
+
project root.
|
|
1145
|
+
|
|
1146
|
+
USAGE
|
|
1147
|
+
prismic push [flags]
|
|
1148
|
+
|
|
1149
|
+
FLAGS
|
|
1150
|
+
-r, --repo string Repository domain
|
|
1151
|
+
--dry-run Show what would be pushed without making changes
|
|
1152
|
+
--types-only Only push custom types
|
|
1153
|
+
--slices-only Only push slices
|
|
1154
|
+
--delete Delete remote models that don't exist locally (dangerous)
|
|
1155
|
+
--json Output as JSON
|
|
1156
|
+
-h, --help Show help for command
|
|
1157
|
+
|
|
1158
|
+
EXAMPLES
|
|
1159
|
+
prismic push
|
|
1160
|
+
prismic push --repo my-repo
|
|
1161
|
+
prismic push --dry-run
|
|
1162
|
+
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 M()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}s||console.info(`Pushing to repository: ${n}\n`);let c=!a,l=!i,[u,d,f,p]=await Promise.all([c?Kn():Promise.resolve({ok:!0,value:[]}),l?qn():Promise.resolve({ok:!0,value:[]}),c?Wn(n):Promise.resolve({ok:!0,value:[]}),l?Gn(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?nr([...m],[...g]):{toInsert:[],toUpdate:[],toDelete:[]},y=l?nr([...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(z({customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}})):console.info(`
|
|
1164
|
+
No changes to push.`);return}if(r){if(s)console.info(z({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(`
|
|
1165
|
+
Pushing custom types:`);for(let e of v.toInsert){let t=await Jn(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 Yn(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 Xn(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(`
|
|
1166
|
+
Pushing slices:`);for(let e of y.toInsert){let t=await Zn(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 Qn(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 $n(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(z(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 ir=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;async function ar(){let{values:{help:t,name:n,"no-config":r,replace:i},positionals:[a]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},name:{type:`string`,short:`n`},"no-config":{type:`boolean`},replace:{type:`boolean`}},allowPositionals:!0});if(t){console.info(`Create a new Prismic repository.
|
|
1120
1167
|
|
|
1121
1168
|
Creates prismic.config.json in the current directory. If a config file already
|
|
1122
1169
|
exists, use --replace to update it with the new repository.
|
|
@@ -1135,7 +1182,7 @@ FLAGS
|
|
|
1135
1182
|
-h, --help Show help for command
|
|
1136
1183
|
|
|
1137
1184
|
LEARN MORE
|
|
1138
|
-
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: domain`),process.exitCode=1;return}if(!
|
|
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(!ir.test(a)){console.error(`Invalid domain format.`),console.error(`Must be at least 4 characters, start and end with alphanumeric, and contain only alphanumerics and hyphens.`),process.exitCode=1;return}if(!await M()){sr();return}let o=await G();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 or(a,n);if(!s.ok){s.error instanceof q?sr():(console.error(`Failed to create repository: ${z(s.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await lt({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 st({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 F(a)}`)}async function or(e,t=e){return await K(new URL(`/app/dashboard/repositories`,await P()),{method:`POST`,body:{domain:e,name:t,framework:`next`,plan:`personal`,usageIntent:`Exploring Prismic's features for future projects.`,usageIntentIndex:0}})}function sr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const cr=E({repositories:S(E({domain:k(),name:D(k()),role:k()}))});async function lr(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},json:{type:`boolean`}}});if(t){console.info(`List all Prismic repositories.
|
|
1139
1186
|
|
|
1140
1187
|
USAGE
|
|
1141
1188
|
prismic repo list [flags]
|
|
@@ -1145,7 +1192,7 @@ FLAGS
|
|
|
1145
1192
|
-h, --help Show help for command
|
|
1146
1193
|
|
|
1147
1194
|
LEARN MORE
|
|
1148
|
-
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await
|
|
1195
|
+
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await M()){dr();return}let r=await ur();if(!r.ok){r.error instanceof q?dr():(console.error(`Failed to fetch repositories: ${z(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 F(e.domain)).toString()})));console.info(z(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 ur(){return await K(new URL(`profile`,await fe()),{schema:cr})}function dr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function fr(){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(`Set the display name of a Prismic repository.
|
|
1149
1196
|
|
|
1150
1197
|
By default, this command reads the repository from prismic.config.json at the
|
|
1151
1198
|
project root.
|
|
@@ -1161,7 +1208,7 @@ FLAGS
|
|
|
1161
1208
|
-h, --help Show help for command
|
|
1162
1209
|
|
|
1163
1210
|
LEARN MORE
|
|
1164
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await
|
|
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 M()){mr();return}let i=await pr(n,r);if(!i.ok){i.error instanceof q?mr():b(i.error)?(console.error(`Failed to set repository name: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set repository name: ${z(i.value)}`),process.exitCode=1);return}console.info(`Repository name set to: ${i.value.repository.name}`)}async function pr(e,t){let n=await F(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await K(r,{method:`POST`,body:i,schema:E({repository:E({name:k()})})})}function mr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const hr=E({repositories:S(E({domain:k(),name:D(k())}))});async function gr(){let{values:{help:t,repo:n=await W(),web:r}}=e({args:process.argv.slice(4),options:{web:{type:`boolean`,short:`w`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}}});if(t){console.info(`View a Prismic repository.
|
|
1165
1212
|
|
|
1166
1213
|
By default, this command reads the repository from prismic.config.json at the
|
|
1167
1214
|
project root.
|
|
@@ -1175,7 +1222,7 @@ FLAGS
|
|
|
1175
1222
|
-h, --help Show help for command
|
|
1176
1223
|
|
|
1177
1224
|
LEARN MORE
|
|
1178
|
-
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}let i=await
|
|
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 F(n);if(r){vr(i.toString()),console.info(`Opening ${i}`);return}if(!await M()){yr();return}let a=await _r();if(!a.ok){a.error instanceof q?yr():(console.error(`Failed to fetch repository info: ${z(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 _r(){return await K(new URL(`profile`,await fe()),{schema:hr})}function vr(e){u(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function yr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function br(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await ar();break;case`list`:await lr();break;case`view`:await gr();break;case`set-name`:await fr();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
|
|
1179
1226
|
|
|
1180
1227
|
USAGE
|
|
1181
1228
|
prismic repo <command> [flags]
|
|
@@ -1190,7 +1237,7 @@ FLAGS
|
|
|
1190
1237
|
-h, --help Show help for command
|
|
1191
1238
|
|
|
1192
1239
|
LEARN MORE
|
|
1193
|
-
Use \`prismic repo <command> --help\` for more information about a command.`)}}async function
|
|
1240
|
+
Use \`prismic repo <command> --help\` for more information about a command.`)}}async function xr(){let{values:{help:t,variation:n,label:r,default:i,"true-label":a,"false-label":o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing slice.
|
|
1194
1241
|
|
|
1195
1242
|
USAGE
|
|
1196
1243
|
prismic slice add-field boolean <slice-id> <field-id> [flags]
|
|
@@ -1212,7 +1259,7 @@ EXAMPLES
|
|
|
1212
1259
|
prismic slice add-field boolean hero show_overlay --default
|
|
1213
1260
|
prismic slice add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!c){console.error(`Missing required argument: slice-id
|
|
1214
1261
|
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
1215
|
-
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let u=await V(c);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${c}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${c}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};for(let e of d.variations)if(e.primary?.[l]){console.error(`Field "${l}" already exists in variation "${e.id}"`),process.exitCode=1;return}let m={type:`Boolean`,config:{...r&&{label:r},...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};p.primary[l]=m;try{await s(f,
|
|
1262
|
+
`),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let u=await V(c);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${c}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${c}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};for(let e of d.variations)if(e.primary?.[l]){console.error(`Field "${l}" already exists in variation "${e.id}"`),process.exitCode=1;return}let m={type:`Boolean`,config:{...r&&{label:r},...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};p.primary[l]=m;try{await s(f,z(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${l}" (Boolean) to "${p.id}" variation in ${c}`)}async function Sr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing slice.
|
|
1216
1263
|
|
|
1217
1264
|
USAGE
|
|
1218
1265
|
prismic slice add-field color <slice-id> <field-id> [flags]
|
|
@@ -1232,7 +1279,7 @@ EXAMPLES
|
|
|
1232
1279
|
prismic slice add-field color hero accent --label "Accent Color"
|
|
1233
1280
|
prismic slice add-field color banner theme_color --variation "dark"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1234
1281
|
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1235
|
-
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Color`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,
|
|
1282
|
+
`),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Color`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Color) to "${d.id}" variation in ${a}`)}async function Cr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date picker field to an existing slice.
|
|
1236
1283
|
|
|
1237
1284
|
USAGE
|
|
1238
1285
|
prismic slice add-field date <slice-id> <field-id> [flags]
|
|
@@ -1252,7 +1299,7 @@ EXAMPLES
|
|
|
1252
1299
|
prismic slice add-field date event start_date --label "Start Date"
|
|
1253
1300
|
prismic slice add-field date promo end_date --variation "countdown"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1254
1301
|
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1255
|
-
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Date`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,
|
|
1302
|
+
`),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Date`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Date) to "${d.id}" variation in ${a}`)}async function wr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed (oEmbed) field to an existing slice.
|
|
1256
1303
|
|
|
1257
1304
|
USAGE
|
|
1258
1305
|
prismic slice add-field embed <slice-id> <field-id> [flags]
|
|
@@ -1272,7 +1319,7 @@ EXAMPLES
|
|
|
1272
1319
|
prismic slice add-field embed gallery media --label "Media Embed"
|
|
1273
1320
|
prismic slice add-field embed social tweet --variation "twitter"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1274
1321
|
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1275
|
-
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Embed`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,
|
|
1322
|
+
`),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Embed`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Embed) to "${d.id}" variation in ${a}`)}async function Tr(){let{values:{help:t,variation:n,label:r},positionals:[i,a]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geographic coordinates field to an existing slice.
|
|
1276
1323
|
|
|
1277
1324
|
USAGE
|
|
1278
1325
|
prismic slice add-field geo-point <slice-id> <field-id> [flags]
|
|
@@ -1291,7 +1338,7 @@ EXAMPLES
|
|
|
1291
1338
|
prismic slice add-field geo-point store coordinates --label "Store Location"
|
|
1292
1339
|
prismic slice add-field geo-point map marker --variation "interactive"`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1293
1340
|
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
|
|
1294
|
-
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.length===0){console.error(`Slice "${i}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let u=n?c.variations.find(e=>e.id===n):c.variations[0];if(!u){console.error(`Variation "${n}" not found in slice "${i}"\n`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u.primary||={};for(let e of c.variations)if(e.primary?.[a]){console.error(`Field "${a}" already exists in variation "${e.id}"`),process.exitCode=1;return}let d={type:`GeoPoint`,config:{...r&&{label:r}}};u.primary[a]=d;try{await s(l,
|
|
1341
|
+
`),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.length===0){console.error(`Slice "${i}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let u=n?c.variations.find(e=>e.id===n):c.variations[0];if(!u){console.error(`Variation "${n}" not found in slice "${i}"\n`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u.primary||={};for(let e of c.variations)if(e.primary?.[a]){console.error(`Field "${a}" already exists in variation "${e.id}"`),process.exitCode=1;return}let d={type:`GeoPoint`,config:{...r&&{label:r}}};u.primary[a]=d;try{await s(l,z(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${a}" (GeoPoint) to "${u.id}" variation in ${i}`)}async function Er(){let{values:{help:t,variation:n,label:r},positionals:[i,a]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing slice.
|
|
1295
1342
|
|
|
1296
1343
|
USAGE
|
|
1297
1344
|
prismic slice add-field image <slice-id> <field-id> [flags]
|
|
@@ -1310,7 +1357,7 @@ EXAMPLES
|
|
|
1310
1357
|
prismic slice add-field image hero banner --label "Hero Banner"
|
|
1311
1358
|
prismic slice add-field image gallery thumbnail --variation "grid"`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1312
1359
|
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
|
|
1313
|
-
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.length===0){console.error(`Slice "${i}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let u=n?c.variations.find(e=>e.id===n):c.variations[0];if(!u){console.error(`Variation "${n}" not found in slice "${i}"\n`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u.primary||={};for(let e of c.variations)if(e.primary?.[a]){console.error(`Field "${a}" already exists in variation "${e.id}"`),process.exitCode=1;return}let d={type:`Image`,config:{...r&&{label:r}}};u.primary[a]=d;try{await s(l,
|
|
1360
|
+
`),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.length===0){console.error(`Slice "${i}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let u=n?c.variations.find(e=>e.id===n):c.variations[0];if(!u){console.error(`Variation "${n}" not found in slice "${i}"\n`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u.primary||={};for(let e of c.variations)if(e.primary?.[a]){console.error(`Field "${a}" already exists in variation "${e.id}"`),process.exitCode=1;return}let d={type:`Image`,config:{...r&&{label:r}}};u.primary[a]=d;try{await s(l,z(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${a}" (Image) to "${u.id}" variation in ${i}`)}async function Dr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing slice.
|
|
1314
1361
|
|
|
1315
1362
|
USAGE
|
|
1316
1363
|
prismic slice add-field key-text <slice-id> <field-id> [flags]
|
|
@@ -1330,7 +1377,7 @@ EXAMPLES
|
|
|
1330
1377
|
prismic slice add-field key-text hero heading --label "Heading"
|
|
1331
1378
|
prismic slice add-field key-text cta button_text --placeholder "Enter button text"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1332
1379
|
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1333
|
-
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Text`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,
|
|
1380
|
+
`),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Text`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Text) to "${d.id}" variation in ${a}`)}async function Or(){let{values:{help:t,variation:n,label:r,placeholder:i,"allow-text":a,"allow-target-blank":o,repeatable:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing slice.
|
|
1334
1381
|
|
|
1335
1382
|
USAGE
|
|
1336
1383
|
prismic slice add-field link <slice-id> <field-id> [flags]
|
|
@@ -1354,7 +1401,7 @@ EXAMPLES
|
|
|
1354
1401
|
prismic slice add-field link navigation links --repeatable
|
|
1355
1402
|
prismic slice add-field link hero cta --allow-text --allow-target-blank`);return}if(!l){console.error(`Missing required argument: slice-id
|
|
1356
1403
|
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
1357
|
-
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let d=await V(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`Link`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...c&&{repeat:!0}}};m.primary[u]=h;try{await s(p,
|
|
1404
|
+
`),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let d=await V(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`Link`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...c&&{repeat:!0}}};m.primary[u]=h;try{await s(p,z(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${u}" (Link) to "${m.id}" variation in ${l}`)}async function kr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing slice.
|
|
1358
1405
|
|
|
1359
1406
|
USAGE
|
|
1360
1407
|
prismic slice add-field number <slice-id> <field-id> [flags]
|
|
@@ -1374,7 +1421,7 @@ EXAMPLES
|
|
|
1374
1421
|
prismic slice add-field number product quantity --label "Quantity"
|
|
1375
1422
|
prismic slice add-field number stats count --variation "detailed"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1376
1423
|
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1377
|
-
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Number`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,
|
|
1424
|
+
`),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Number`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Number) to "${d.id}" variation in ${a}`)}async function Ar(){let{values:{help:t,variation:n,label:r,placeholder:i,single:a,multi:o,"allow-target-blank":c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing slice.
|
|
1378
1425
|
|
|
1379
1426
|
USAGE
|
|
1380
1427
|
prismic slice add-field rich-text <slice-id> <field-id> [flags]
|
|
@@ -1403,7 +1450,7 @@ EXAMPLES
|
|
|
1403
1450
|
prismic slice add-field rich-text hero tagline --single "heading1"
|
|
1404
1451
|
prismic slice add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!l){console.error(`Missing required argument: slice-id
|
|
1405
1452
|
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
|
|
1406
|
-
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let d=await V(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`StructuredText`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...c&&{allowTargetBlank:!0}}};m.primary[u]=h;try{await s(p,
|
|
1453
|
+
`),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let d=await V(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`StructuredText`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...c&&{allowTargetBlank:!0}}};m.primary[u]=h;try{await s(p,z(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${u}" (StructuredText) to "${m.id}" variation in ${l}`)}async function jr(){let{values:{help:t,variation:n,label:r,placeholder:i,option:a,default:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing slice.
|
|
1407
1454
|
|
|
1408
1455
|
USAGE
|
|
1409
1456
|
prismic slice add-field select <slice-id> <field-id> [flags]
|
|
@@ -1425,7 +1472,7 @@ EXAMPLES
|
|
|
1425
1472
|
prismic slice add-field select hero style --option "light" --option "dark" --default "light"
|
|
1426
1473
|
prismic slice add-field select product size --option "small" --option "medium" --option "large" --label "Size"`);return}if(!c){console.error(`Missing required argument: slice-id
|
|
1427
1474
|
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
|
|
1428
|
-
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let u=await V(c);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${c}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${c}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};for(let e of d.variations)if(e.primary?.[l]){console.error(`Field "${l}" already exists in variation "${e.id}"`),process.exitCode=1;return}let m={type:`Select`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};p.primary[l]=m;try{await s(f,
|
|
1475
|
+
`),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let u=await V(c);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${c}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${c}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};for(let e of d.variations)if(e.primary?.[l]){console.error(`Field "${l}" already exists in variation "${e.id}"`),process.exitCode=1;return}let m={type:`Select`,config:{...r&&{label:r},...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};p.primary[l]=m;try{await s(f,z(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${l}" (Select) to "${p.id}" variation in ${c}`)}async function Mr(){let{values:{help:t,variation:n,label:r,placeholder:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing slice.
|
|
1429
1476
|
|
|
1430
1477
|
USAGE
|
|
1431
1478
|
prismic slice add-field timestamp <slice-id> <field-id> [flags]
|
|
@@ -1445,7 +1492,7 @@ EXAMPLES
|
|
|
1445
1492
|
prismic slice add-field timestamp event start_time --label "Event Start"
|
|
1446
1493
|
prismic slice add-field timestamp schedule meeting_time --variation "detailed"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1447
1494
|
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
|
|
1448
|
-
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Timestamp`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,
|
|
1495
|
+
`),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let c=await V(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Timestamp`,config:{...r&&{label:r},...i&&{placeholder:i}}};d.primary[o]=f;try{await s(u,z(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Timestamp) to "${d.id}" variation in ${a}`)}async function Nr(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await xr();break;case`color`:await Sr();break;case`date`:await Cr();break;case`embed`:await wr();break;case`geo-point`:await Tr();break;case`image`:await Er();break;case`key-text`:await Dr();break;case`link`:await Or();break;case`number`:await kr();break;case`rich-text`:await Ar();break;case`select`:await jr();break;case`timestamp`:await Mr();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
|
|
1449
1496
|
|
|
1450
1497
|
USAGE
|
|
1451
1498
|
prismic slice add-field <field-type> <slice-id> <field-id> [flags]
|
|
@@ -1474,7 +1521,7 @@ EXAMPLES
|
|
|
1474
1521
|
prismic slice add-field key-text my_slice title --label "Title"
|
|
1475
1522
|
prismic slice add-field link my_slice cta --allow-text
|
|
1476
1523
|
prismic slice add-field rich-text my_slice body --multi "paragraph,heading2,strong,em"
|
|
1477
|
-
prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function
|
|
1524
|
+
prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function Pr(){let{values:{help:t,name:n,"copy-from":r},positionals:[i,a]}=e({args:process.argv.slice(4),options:{name:{type:`string`},"copy-from":{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new variation to a slice.
|
|
1478
1525
|
|
|
1479
1526
|
USAGE
|
|
1480
1527
|
prismic slice add-variation <slice-id> <variation-id> [flags]
|
|
@@ -1493,7 +1540,7 @@ EXAMPLES
|
|
|
1493
1540
|
prismic slice add-variation MySlice withImage --name "With Image"
|
|
1494
1541
|
prismic slice add-variation MySlice withImage --copy-from default`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1495
1542
|
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: variation-id
|
|
1496
|
-
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.some(e=>e.id===a)){console.error(`Variation "${a}" already exists in slice "${i}"`),process.exitCode=1;return}let u;if(r){let e=c.variations.find(e=>e.id===r);if(!e){console.error(`Source variation not found: ${r}`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u={...structuredClone(e),id:a,name:n??
|
|
1543
|
+
`),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;if(c.variations.some(e=>e.id===a)){console.error(`Variation "${a}" already exists in slice "${i}"`),process.exitCode=1;return}let u;if(r){let e=c.variations.find(e=>e.id===r);if(!e){console.error(`Source variation not found: ${r}`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}u={...structuredClone(e),id:a,name:n??U(a)}}else u={id:a,name:n??U(a),description:a,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}};let d={...c,variations:[...c.variations,u]};try{await s(l,z(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added variation "${a}" to slice "${i}"`)}async function Fr(){let{values:{help:t,name:r},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new slice in a Prismic project.
|
|
1497
1544
|
|
|
1498
1545
|
USAGE
|
|
1499
1546
|
prismic slice create <id> [flags]
|
|
@@ -1506,7 +1553,7 @@ FLAGS
|
|
|
1506
1553
|
-h, --help Show help for command
|
|
1507
1554
|
|
|
1508
1555
|
LEARN MORE
|
|
1509
|
-
Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: id`),process.exitCode=1;return}let a={id:i,type:`SharedSlice`,name:r??
|
|
1556
|
+
Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: id`),process.exitCode=1;return}let a={id:i,type:`SharedSlice`,name:r??zr(i),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}}]},o=await Ir(),c=new URL(zr(a.name)+`/`,o),l=new URL(`model.json`,c);try{await n(new URL(`.`,l),{recursive:!0}),await s(l,z(a))}catch(e){e instanceof Error?console.error(`Failed to create slice: ${e.message}`):console.error(`Failed to create slice`),process.exitCode=1;return}console.info(`Created slice at ${l.href}`)}async function Ir(){let e=await Rr(),t=await L(`package.json`);switch(e){case`next`:if(await R(new URL(`src`,t)))return new URL(`src/slices/`,t);case`nuxt`:if(await R(new URL(`app`,t)))return new URL(`app/slices/`,t);case`sveltekit`:return new URL(`src/slices/`,t)}return new URL(`slices/`,t)}const Lr=E({dependencies:D(O(k(),k()))});async function Rr(){let e=await L(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=ie(Lr,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function zr(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Br(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all slices in a Prismic project.
|
|
1510
1557
|
|
|
1511
1558
|
USAGE
|
|
1512
1559
|
prismic slice list [flags]
|
|
@@ -1517,7 +1564,7 @@ FLAGS
|
|
|
1517
1564
|
|
|
1518
1565
|
EXAMPLES
|
|
1519
1566
|
prismic slice list
|
|
1520
|
-
prismic slice list --json`);return}let a=await
|
|
1567
|
+
prismic slice list --json`);return}let a=await H(),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=j(B,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 Vr(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all variations for a slice.
|
|
1521
1568
|
|
|
1522
1569
|
USAGE
|
|
1523
1570
|
prismic slice list-variations <slice-id> [flags]
|
|
@@ -1532,7 +1579,7 @@ FLAGS
|
|
|
1532
1579
|
EXAMPLES
|
|
1533
1580
|
prismic slice list-variations MySlice
|
|
1534
1581
|
prismic slice list-variations MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1535
|
-
`),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await V(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
|
|
1582
|
+
`),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await V(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 Hr(){let{values:{help:t,y:n},positionals:[r]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a slice from the project.
|
|
1536
1583
|
|
|
1537
1584
|
USAGE
|
|
1538
1585
|
prismic slice remove <slice-id> [flags]
|
|
@@ -1547,7 +1594,7 @@ FLAGS
|
|
|
1547
1594
|
EXAMPLES
|
|
1548
1595
|
prismic slice remove MySlice
|
|
1549
1596
|
prismic slice remove MySlice -y`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1550
|
-
`),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let i=await V(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{modelPath:a}=i,s=new URL(`.`,a);if(!n){console.error(`Refusing to remove slice "${r}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove slice: ${e.message}`):console.error(`Failed to remove slice`),process.exitCode=1;return}console.info(`Removed slice "${r}"`)}async function
|
|
1597
|
+
`),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let i=await V(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{modelPath:a}=i,s=new URL(`.`,a);if(!n){console.error(`Refusing to remove slice "${r}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(s,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove slice: ${e.message}`):console.error(`Failed to remove slice`),process.exitCode=1;return}console.info(`Removed slice "${r}"`)}async function Ur(){let{values:{help:t,variation:n,zone:r},positionals:[i,a]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,default:`default`},zone:{type:`string`,default:`primary`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a slice variation.
|
|
1551
1598
|
|
|
1552
1599
|
USAGE
|
|
1553
1600
|
prismic slice remove-field <slice-id> <field-id> [flags]
|
|
@@ -1566,7 +1613,7 @@ EXAMPLES
|
|
|
1566
1613
|
prismic slice remove-field MySlice title --variation withImage
|
|
1567
1614
|
prismic slice remove-field MySlice item_title --zone items`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1568
1615
|
`),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: field-id
|
|
1569
|
-
`),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(r!==`primary`&&r!==`items`){console.error(`Invalid zone: ${r}. Must be "primary" or "items".`),process.exitCode=1;return}let o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o,u=c.variations.find(e=>e.id===n);if(!u){console.error(`Variation not found: ${n}`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let d=r===`primary`?u.primary:u.items;if(!d||!(a in d)){console.error(`Field "${a}" not found in ${r} zone of variation "${n}"`),process.exitCode=1;return}delete d[a];try{await s(l,
|
|
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 o=await V(i);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o,u=c.variations.find(e=>e.id===n);if(!u){console.error(`Variation not found: ${n}`),console.error(`Available variations: ${c.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let d=r===`primary`?u.primary:u.items;if(!d||!(a in d)){console.error(`Field "${a}" not found in ${r} zone of variation "${n}"`),process.exitCode=1;return}delete d[a];try{await s(l,z(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed field "${a}" from ${r} zone in variation "${n}" of slice "${i}"`)}async function Wr(){let{values:{help:t},positionals:[n,r]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a variation from a slice.
|
|
1570
1617
|
|
|
1571
1618
|
USAGE
|
|
1572
1619
|
prismic slice remove-variation <slice-id> <variation-id> [flags]
|
|
@@ -1581,7 +1628,7 @@ FLAGS
|
|
|
1581
1628
|
EXAMPLES
|
|
1582
1629
|
prismic slice remove-variation MySlice withImage`);return}if(!n){console.error(`Missing required argument: slice-id
|
|
1583
1630
|
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!r){console.error(`Missing required argument: variation-id
|
|
1584
|
-
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let i=await V(n);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a,modelPath:o}=i;if(!a.variations.some(e=>e.id===r)){console.error(`Variation not found: ${r}`),console.error(`Available variations: ${a.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(a.variations.length===1){console.error(`Cannot remove the last variation from a slice.`),process.exitCode=1;return}let c={...a,variations:a.variations.filter(e=>e.id!==r)};try{await s(o,
|
|
1631
|
+
`),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let i=await V(n);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a,modelPath:o}=i;if(!a.variations.some(e=>e.id===r)){console.error(`Variation not found: ${r}`),console.error(`Available variations: ${a.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(a.variations.length===1){console.error(`Cannot remove the last variation from a slice.`),process.exitCode=1;return}let c={...a,variations:a.variations.filter(e=>e.id!==r)};try{await s(o,z(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed variation "${r}" from slice "${n}"`)}async function Gr(){let{values:{help:t,id:n},positionals:[r,i]}=e({args:process.argv.slice(4),options:{id:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Rename a slice (updates name field, optionally id and directory).
|
|
1585
1632
|
|
|
1586
1633
|
USAGE
|
|
1587
1634
|
prismic slice rename <slice-id> <new-name> [flags]
|
|
@@ -1598,7 +1645,7 @@ EXAMPLES
|
|
|
1598
1645
|
prismic slice rename MySlice "My New Name"
|
|
1599
1646
|
prismic slice rename MySlice "My New Name" --id NewSliceId`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1600
1647
|
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: new-name
|
|
1601
|
-
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let o=await V(r);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;c.name=i,n&&(c.id=n);try{await s(l,
|
|
1648
|
+
`),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let o=await V(r);if(!o.ok){console.error(o.error),process.exitCode=1;return}let{model:c,modelPath:l}=o;c.name=i,n&&(c.id=n);try{await s(l,z(c))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}if(n){let e=await H(),t=new URL(`.`,l),o=new URL(U(i)+`/`,e);if(t.href!==o.href)try{await a(t,o),console.info(`Renamed slice "${r}" to "${n}" (${i})`),console.info(`Moved directory to ${o.href}`)}catch(e){e instanceof Error?console.error(`Failed to rename directory: ${e.message}`):console.error(`Failed to rename directory`),process.exitCode=1;return}else console.info(`Renamed slice "${r}" to "${n}" (${i})`)}else console.info(`Renamed slice "${r}" to "${i}"`)}async function Kr(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific slice.
|
|
1602
1649
|
|
|
1603
1650
|
USAGE
|
|
1604
1651
|
prismic slice view <slice-id> [flags]
|
|
@@ -1614,7 +1661,7 @@ EXAMPLES
|
|
|
1614
1661
|
prismic slice view MySlice
|
|
1615
1662
|
prismic slice view MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1616
1663
|
`),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await V(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(`
|
|
1617
|
-
Variations:`);for(let e of a.variations){let t=Object.keys(e.primary??{}).length,n=Object.keys(e.items??{}).length;console.info(` - ${e.id} (${e.name}): ${t} primary fields, ${n} items fields`)}}async function
|
|
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 qr(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Fr();break;case`list`:await Br();break;case`view`:await Kr();break;case`rename`:await Gr();break;case`remove`:await Hr();break;case`add-field`:await Nr();break;case`remove-field`:await Ur();break;case`add-variation`:await Pr();break;case`remove-variation`:await Wr();break;case`list-variations`:await Vr();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
|
|
1618
1665
|
|
|
1619
1666
|
USAGE
|
|
1620
1667
|
prismic slice <command> [flags]
|
|
@@ -1635,7 +1682,7 @@ FLAGS
|
|
|
1635
1682
|
-h, --help Show help for command
|
|
1636
1683
|
|
|
1637
1684
|
LEARN MORE
|
|
1638
|
-
Use \`prismic slice <command> --help\` for more information about a command.`)}}async function
|
|
1685
|
+
Use \`prismic slice <command> --help\` for more information about a command.`)}}async function Jr(){let{values:{help:t,repo:n=await W(),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.
|
|
1639
1686
|
|
|
1640
1687
|
By default, this command reads the repository from prismic.config.json at the
|
|
1641
1688
|
project root.
|
|
@@ -1649,7 +1696,7 @@ FLAGS
|
|
|
1649
1696
|
-h, --help Show help for command
|
|
1650
1697
|
|
|
1651
1698
|
LEARN MORE
|
|
1652
|
-
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
|
|
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 M()){ai();return}let[i,a]=await Promise.all([ti(n),ni(n)]);if(!i.ok){i.error instanceof q||i.error instanceof J?ai():b(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${z(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof q||a.error instanceof J?ai():b(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${z(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${z(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(z({accessTokens:o,writeTokens:s}));else{if(o.length>0){console.info(`ACCESS TOKENS`);for(let e of o){let t=ri(e.token),n=ii(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=ri(e.token),n=ii(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const Yr=E({$date:T()}),Xr=E({id:k(),origin:k(),domain:k(),app:k(),scope:k(),expired_at:Yr,created_at:Yr,owner:w(k()),token:k()}),Zr=E({id:k(),secret:k(),name:k(),owner:k(),created_at:Yr,authorized_domains:S(k()),wroom_auths:S(Xr)}),Qr=E({app_name:k(),token:k(),timestamp:T()}),$r=E({max_tokens:T(),tokens:S(Qr)}),ei=S(Zr);async function ti(e){return await K(new URL(`settings/security/contentapi`,await F(e)),{schema:ei})}async function ni(e){return await K(new URL(`settings/security/customtypesapi`,await F(e)),{schema:$r})}function ri(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function ii(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function ai(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function oi(){let{values:{help:t,repo:n=await W(),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.
|
|
1653
1700
|
|
|
1654
1701
|
By default, this command reads the repository from prismic.config.json at the
|
|
1655
1702
|
project root.
|
|
@@ -1666,7 +1713,7 @@ FLAGS
|
|
|
1666
1713
|
-h, --help Show help for command
|
|
1667
1714
|
|
|
1668
1715
|
LEARN MORE
|
|
1669
|
-
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
|
|
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 M()){li();return}if(i){let e=await si(n,a);if(!e.ok){e.error instanceof q||e.error instanceof J?li():b(e.error)?(console.error(`Failed to create write token: Invalid response: ${z(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create write token: ${z(e.value)}`),process.exitCode=1);return}r?console.info(z(e.value)):console.info(`Token created: ${e.value.token}`)}else{let e=await ci(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof q||e.error instanceof J?li():b(e.error)?(console.error(`Failed to create access token: Invalid response: ${z(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create access token: ${z(e.value)}`),process.exitCode=1);return}r?console.info(z(e.value)):console.info(`Token created: ${e.value.token}`)}}async function si(e,t){return await K(new URL(`settings/security/token`,await F(e)),{method:`POST`,body:{app_name:t},schema:Qr})}async function ci(e,t,n){let r=await ti(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await K(new URL(`settings/security/oauthapp`,await F(e)),{method:`POST`,body:{app_name:t},schema:Zr});if(!n.ok)return n;i=n.value}return await K(new URL(`settings/security/authorizations`,await F(e)),{method:`POST`,body:{app:i.id,scope:n},schema:Xr})}function li(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ui(){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(`Delete a token from a Prismic repository.
|
|
1670
1717
|
|
|
1671
1718
|
By default, this command reads the repository from prismic.config.json at the
|
|
1672
1719
|
project root.
|
|
@@ -1682,7 +1729,7 @@ FLAGS
|
|
|
1682
1729
|
-h, --help Show help for command
|
|
1683
1730
|
|
|
1684
1731
|
LEARN MORE
|
|
1685
|
-
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
|
|
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 M()){X();return}let[i,a]=await Promise.all([ti(n),ni(n)]);if(!i.ok){i.error instanceof q||i.error instanceof J?X():b(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${z(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof q||a.error instanceof J?X():b(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${z(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${z(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 K(new URL(`settings/security/authorizations/${o.id}`,await F(n)),{method:`DELETE`});if(!e.ok){e.error instanceof q||e.error instanceof J?X():(console.error(`Failed to delete token: ${z(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 K(new URL(`settings/security/token/${s.token}`,await F(n)),{method:`DELETE`});if(!e.ok){e.error instanceof q||e.error instanceof J?X():(console.error(`Failed to delete token: ${z(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}console.error(`Token not found: ${r}`),process.exitCode=1}function X(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function di(){let{values:{help:t,repo:n=await W()},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.
|
|
1686
1733
|
|
|
1687
1734
|
Note: Only access tokens can be renamed. Write tokens cannot be renamed without
|
|
1688
1735
|
changing the token value.
|
|
@@ -1702,7 +1749,7 @@ FLAGS
|
|
|
1702
1749
|
-h, --help Show help for command
|
|
1703
1750
|
|
|
1704
1751
|
LEARN MORE
|
|
1705
|
-
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
|
|
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 M()){fi();return}let[a,o]=await Promise.all([ti(n),ni(n)]);if(!a.ok){a.error instanceof q||a.error instanceof J?fi():b(a.error)?(console.error(`Failed to list access tokens: Invalid response: ${z(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${z(a.value)}`),process.exitCode=1);return}if(!o.ok){o.error instanceof q||o.error instanceof J?fi():b(o.error)?(console.error(`Failed to list write tokens: Invalid response: ${z(o.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${z(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 K(new URL(`settings/security/oauthapp/${s.id}`,await F(n)),{method:`POST`,body:{name:i},schema:Zr});if(!e.ok){e.error instanceof q||e.error instanceof J?fi():b(e.error)?(console.error(`Failed to rename token: Invalid response: ${z(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to rename token: ${z(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 fi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function pi(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Jr();break;case`create`:await oi();break;case`set-name`:await di();break;case`delete`:await ui();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
|
|
1706
1753
|
|
|
1707
1754
|
USAGE
|
|
1708
1755
|
prismic token <command> [flags]
|
|
@@ -1717,7 +1764,7 @@ FLAGS
|
|
|
1717
1764
|
-h, --help Show help for command
|
|
1718
1765
|
|
|
1719
1766
|
LEARN MORE
|
|
1720
|
-
Use \`prismic token <command> --help\` for more information about a command.`)}}const
|
|
1767
|
+
Use \`prismic token <command> --help\` for more information about a command.`)}}const Z={documentsPublished:`document.published`,documentsUnpublished:`document.unpublished`,releasesCreated:`release.created`,releasesUpdated:`release.updated`,tagsCreated:`tag.created`,tagsDeleted:`tag.deleted`};async function mi(){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(`View details of a webhook in a Prismic repository.
|
|
1721
1768
|
|
|
1722
1769
|
By default, this command reads the repository from prismic.config.json at the
|
|
1723
1770
|
project root.
|
|
@@ -1733,7 +1780,7 @@ FLAGS
|
|
|
1733
1780
|
-h, --help Show help for command
|
|
1734
1781
|
|
|
1735
1782
|
LEARN MORE
|
|
1736
|
-
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
|
|
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.
|
|
1737
1784
|
|
|
1738
1785
|
By default, this command reads the repository from prismic.config.json at the
|
|
1739
1786
|
project root.
|
|
@@ -1749,7 +1796,7 @@ FLAGS
|
|
|
1749
1796
|
-h, --help Show help for command
|
|
1750
1797
|
|
|
1751
1798
|
LEARN MORE
|
|
1752
|
-
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
|
|
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 M()){vi();return}let i=await Q(n);if(!i.ok){i.error instanceof q?vi():(console.error(`Failed to enable 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}if(a.config.active){console.info(`Webhook already enabled: ${r}`);return}let o=structuredClone(a.config);o.active=!0;let s=await $(n,a.config._id,o);if(!s.ok){s.error instanceof q?vi():(console.error(`Failed to enable webhook: ${z(s.value)}`),process.exitCode=1);return}console.info(`Webhook enabled: ${r}`)}async function $(e,t,n){let r=new URL(`/app/settings/webhooks/${t}`,await F(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 K(r,{method:`POST`,body:i})}function vi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function yi(){let{values:{help:t,repo:n=await W()},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.
|
|
1753
1800
|
|
|
1754
1801
|
By default, this command reads the repository from prismic.config.json at the
|
|
1755
1802
|
project root.
|
|
@@ -1767,7 +1814,7 @@ FLAGS
|
|
|
1767
1814
|
-h, --help Show help for command
|
|
1768
1815
|
|
|
1769
1816
|
LEARN MORE
|
|
1770
|
-
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
|
|
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 M()){bi();return}let o=await Q(n);if(!o.ok){o.error instanceof q?bi():(console.error(`Failed to add header: ${z(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 $(n,s.config._id,c);if(!l.ok){l.error instanceof q?bi():(console.error(`Failed to add header: ${z(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function bi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const xi=Object.values(Z);async function Si(){let{values:{help:t,repo:n=await W(),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.
|
|
1771
1818
|
|
|
1772
1819
|
By default, this command reads the repository from prismic.config.json at the
|
|
1773
1820
|
project root.
|
|
@@ -1796,7 +1843,7 @@ TRIGGERS
|
|
|
1796
1843
|
If no triggers specified, all are enabled.
|
|
1797
1844
|
|
|
1798
1845
|
LEARN MORE
|
|
1799
|
-
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(!
|
|
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(!xi.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${xi.join(`, `)}`),process.exitCode=1;return}if(!await M()){wi();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(Z).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await Ci(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof q?wi():(console.error(`Failed to create webhook: ${z(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function Ci(e,t){let n=new URL(`/app/settings/webhooks/create`,await F(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 K(n,{method:`POST`,body:r})}function wi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ti(){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(`Disable a webhook in a Prismic repository.
|
|
1800
1847
|
|
|
1801
1848
|
By default, this command reads the repository from prismic.config.json at the
|
|
1802
1849
|
project root.
|
|
@@ -1812,7 +1859,7 @@ FLAGS
|
|
|
1812
1859
|
-h, --help Show help for command
|
|
1813
1860
|
|
|
1814
1861
|
LEARN MORE
|
|
1815
|
-
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
|
|
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 M()){Ei();return}let i=await Q(n);if(!i.ok){i.error instanceof q?Ei():(console.error(`Failed to disable 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}if(!a.config.active){console.info(`Webhook already disabled: ${r}`);return}let o=structuredClone(a.config);o.active=!1;let s=await $(n,a.config._id,o);if(!s.ok){s.error instanceof q?Ei():(console.error(`Failed to disable webhook: ${z(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function Ei(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Di(){let{values:{help:t,repo:n=await W(),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.
|
|
1816
1863
|
|
|
1817
1864
|
By default, this command reads the repository from prismic.config.json at the
|
|
1818
1865
|
project root.
|
|
@@ -1826,7 +1873,7 @@ FLAGS
|
|
|
1826
1873
|
-h, --help Show help for command
|
|
1827
1874
|
|
|
1828
1875
|
LEARN MORE
|
|
1829
|
-
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
|
|
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 M()){Oi();return}let i=await Q(n);if(!i.ok){i.error instanceof q?Oi():b(i.error)?(console.error(`Failed to list webhooks: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list webhooks: ${z(i.value)}`),process.exitCode=1);return}let a=i.value;if(r)console.info(z(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 Oi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ki(){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(`Delete a webhook from a Prismic repository.
|
|
1830
1877
|
|
|
1831
1878
|
By default, this command reads the repository from prismic.config.json at the
|
|
1832
1879
|
project root.
|
|
@@ -1842,7 +1889,7 @@ FLAGS
|
|
|
1842
1889
|
-h, --help Show help for command
|
|
1843
1890
|
|
|
1844
1891
|
LEARN MORE
|
|
1845
|
-
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
|
|
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 M()){ji();return}let i=await Q(n);if(!i.ok){i.error instanceof q?ji():(console.error(`Failed to remove 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 o=await Ai(n,a.config._id);if(!o.ok){o.error instanceof q?ji():(console.error(`Failed to remove webhook: ${z(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function Ai(e,t){return await K(new URL(`/app/settings/webhooks/${t}/delete`,await F(e)),{method:`POST`})}function ji(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Mi(){let{values:{help:t,repo:n=await W()},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.
|
|
1846
1893
|
|
|
1847
1894
|
By default, this command reads the repository from prismic.config.json at the
|
|
1848
1895
|
project root.
|
|
@@ -1859,7 +1906,7 @@ FLAGS
|
|
|
1859
1906
|
-h, --help Show help for command
|
|
1860
1907
|
|
|
1861
1908
|
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(!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
|
|
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 M()){Ni();return}let a=await Q(n);if(!a.ok){a.error instanceof q?Ni():(console.error(`Failed to remove header: ${z(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 $(n,o.config._id,s);if(!c.ok){c.error instanceof q?Ni():(console.error(`Failed to remove header: ${z(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function Ni(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Pi=Object.values(Z);async function Fi(){let{values:{help:t,repo:n=await W(),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.
|
|
1863
1910
|
|
|
1864
1911
|
By default, this command reads the repository from prismic.config.json at the
|
|
1865
1912
|
project root.
|
|
@@ -1884,7 +1931,7 @@ TRIGGERS
|
|
|
1884
1931
|
tag.deleted When a tag is deleted
|
|
1885
1932
|
|
|
1886
1933
|
LEARN MORE
|
|
1887
|
-
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(!
|
|
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(!Pi.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${Pi.join(`, `)}`),process.exitCode=1;return}if(!await M()){Ii();return}let a=await Q(n);if(!a.ok){a.error instanceof q?Ii():(console.error(`Failed to update webhook triggers: ${z(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(Z).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await $(n,o.config._id,{...o.config,...c});if(!l.ok){l.error instanceof q?Ii():(console.error(`Failed to update webhook triggers: ${z(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function Ii(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Li(){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(`Show the enabled/disabled status of a webhook.
|
|
1888
1935
|
|
|
1889
1936
|
By default, this command reads the repository from prismic.config.json at the
|
|
1890
1937
|
project root.
|
|
@@ -1900,7 +1947,7 @@ FLAGS
|
|
|
1900
1947
|
-h, --help Show help for command
|
|
1901
1948
|
|
|
1902
1949
|
LEARN MORE
|
|
1903
|
-
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
|
|
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 M()){Ri();return}let i=await Q(n);if(!i.ok){i.error instanceof q?Ri():(console.error(`Failed to get webhook status: ${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 o=a.config.active?`enabled`:`disabled`;console.info(o)}function Ri(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function zi(){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(`Trigger a test webhook in a Prismic repository.
|
|
1904
1951
|
|
|
1905
1952
|
By default, this command reads the repository from prismic.config.json at the
|
|
1906
1953
|
project root.
|
|
@@ -1916,7 +1963,7 @@ FLAGS
|
|
|
1916
1963
|
-h, --help Show help for command
|
|
1917
1964
|
|
|
1918
1965
|
LEARN MORE
|
|
1919
|
-
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
|
|
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 M()){Vi();return}let i=await Q(n);if(!i.ok){i.error instanceof q?Vi():(console.error(`Failed to test 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 o=await Bi(n,a.config._id);if(!o.ok){o.error instanceof q?Vi():(console.error(`Failed to test webhook: ${z(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function Bi(e,t){return await K(new URL(`/app/settings/webhooks/${t}/trigger`,await F(e)),{method:`POST`})}function Vi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Hi(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Di();break;case`create`:await Si();break;case`view`:await mi();break;case`remove`:await ki();break;case`test`:await zi();break;case`enable`:await _i();break;case`disable`:await Ti();break;case`status`:await Li();break;case`add-header`:await yi();break;case`remove-header`:await Mi();break;case`set-triggers`:await Fi();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
|
|
1920
1967
|
|
|
1921
1968
|
USAGE
|
|
1922
1969
|
prismic webhook <command> [flags]
|
|
@@ -1938,7 +1985,7 @@ FLAGS
|
|
|
1938
1985
|
-h, --help Show help for command
|
|
1939
1986
|
|
|
1940
1987
|
LEARN MORE
|
|
1941
|
-
Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function
|
|
1988
|
+
Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function Ui(){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.
|
|
1942
1989
|
|
|
1943
1990
|
USAGE
|
|
1944
1991
|
prismic whoami [flags]
|
|
@@ -1947,7 +1994,7 @@ FLAGS
|
|
|
1947
1994
|
-h, --help Show help for command
|
|
1948
1995
|
|
|
1949
1996
|
LEARN MORE
|
|
1950
|
-
Use \`prismic <command> --help\` for more information about a command.`);return}if(!await
|
|
1997
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}if(!await M()){Gi();return}let n=await Wi();if(!n.ok){n.error instanceof q?Gi():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function Wi(){return await K(new URL(`profile`,await fe()),{schema:E({email:k()})})}function Gi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:Ki}=e({options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(Ki[0]){case`init`:await mt();break;case`login`:await jt();break;case`logout`:await Pt();break;case`whoami`:await Ui();break;case`repo`:await br();break;case`locale`:await At();break;case`page-type`:await Dn();break;case`custom-type`:await it();break;case`slice`:await qr();break;case`pull`:await er();break;case`push`:await rr();break;case`preview`:await Hn();break;case`token`:await pi();break;case`webhook`:await Hi();break;default:Ki[0]&&(console.error(`Unknown command: ${Ki[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
|
|
1951
1998
|
|
|
1952
1999
|
USAGE
|
|
1953
2000
|
prismic <command> [flags]
|
|
@@ -1962,6 +2009,8 @@ COMMANDS
|
|
|
1962
2009
|
page-type Manage page types in a repository
|
|
1963
2010
|
custom-type Manage custom types in a repository
|
|
1964
2011
|
slice Manage slices in a project
|
|
2012
|
+
pull Pull types and slices from Prismic
|
|
2013
|
+
push Push types and slices to Prismic
|
|
1965
2014
|
preview Manage preview configurations
|
|
1966
2015
|
token Manage API tokens in a repository
|
|
1967
2016
|
webhook Manage webhooks in a repository
|