@angeloashmore/prismic-cli-poc 0.0.0-canary.2ff9563
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/LICENSE +202 -0
- package/README.md +98 -0
- package/dist/index.mjs +1996 -0
- package/package.json +52 -0
- package/src/custom-type-add-field-boolean.ts +171 -0
- package/src/custom-type-add-field-color.ts +158 -0
- package/src/custom-type-add-field-date.ts +161 -0
- package/src/custom-type-add-field-embed.ts +158 -0
- package/src/custom-type-add-field-geo-point.ts +155 -0
- package/src/custom-type-add-field-image.ts +158 -0
- package/src/custom-type-add-field-key-text.ts +158 -0
- package/src/custom-type-add-field-link.ts +180 -0
- package/src/custom-type-add-field-number.ts +190 -0
- package/src/custom-type-add-field-rich-text.ts +181 -0
- package/src/custom-type-add-field-select.ts +164 -0
- package/src/custom-type-add-field-timestamp.ts +161 -0
- package/src/custom-type-add-field-uid.ts +158 -0
- package/src/custom-type-add-field.ts +111 -0
- package/src/custom-type-connect-slice.ts +221 -0
- package/src/custom-type-create.ts +92 -0
- package/src/custom-type-disconnect-slice.ts +179 -0
- package/src/custom-type-list.ts +110 -0
- package/src/custom-type-remove-field.ts +161 -0
- package/src/custom-type-remove.ts +126 -0
- package/src/custom-type-set-name.ts +128 -0
- package/src/custom-type-view.ts +118 -0
- package/src/custom-type.ts +85 -0
- package/src/index.ts +100 -0
- package/src/init.ts +62 -0
- package/src/lib/auth.ts +60 -0
- package/src/lib/config.ts +111 -0
- package/src/lib/file.ts +49 -0
- package/src/lib/json.ts +3 -0
- package/src/lib/request.ts +116 -0
- package/src/lib/slice.ts +112 -0
- package/src/lib/url.ts +25 -0
- package/src/locale-add.ts +116 -0
- package/src/locale-list.ts +107 -0
- package/src/locale-remove.ts +88 -0
- package/src/locale-set-default.ts +131 -0
- package/src/locale.ts +60 -0
- package/src/login.ts +143 -0
- package/src/logout.ts +36 -0
- package/src/page-type-add-field-boolean.ts +171 -0
- package/src/page-type-add-field-color.ts +158 -0
- package/src/page-type-add-field-date.ts +161 -0
- package/src/page-type-add-field-embed.ts +158 -0
- package/src/page-type-add-field-geo-point.ts +155 -0
- package/src/page-type-add-field-image.ts +158 -0
- package/src/page-type-add-field-key-text.ts +158 -0
- package/src/page-type-add-field-link.ts +180 -0
- package/src/page-type-add-field-number.ts +190 -0
- package/src/page-type-add-field-rich-text.ts +181 -0
- package/src/page-type-add-field-select.ts +164 -0
- package/src/page-type-add-field-timestamp.ts +161 -0
- package/src/page-type-add-field-uid.ts +158 -0
- package/src/page-type-add-field.ts +111 -0
- package/src/page-type-connect-slice.ts +221 -0
- package/src/page-type-create.ts +93 -0
- package/src/page-type-disconnect-slice.ts +179 -0
- package/src/page-type-list.ts +109 -0
- package/src/page-type-remove-field.ts +161 -0
- package/src/page-type-remove.ts +126 -0
- package/src/page-type-set-name.ts +128 -0
- package/src/page-type-set-repeatable.ts +137 -0
- package/src/page-type-view.ts +118 -0
- package/src/page-type.ts +90 -0
- package/src/preview-add.ts +126 -0
- package/src/preview-list.ts +106 -0
- package/src/preview-remove.ts +109 -0
- package/src/preview-set-name.ts +137 -0
- package/src/preview.ts +60 -0
- package/src/repo-create.ts +136 -0
- package/src/repo-list.ts +100 -0
- package/src/repo-set-name.ts +102 -0
- package/src/repo-view.ts +113 -0
- package/src/repo.ts +60 -0
- package/src/slice-add-field-boolean.ts +150 -0
- package/src/slice-add-field-color.ts +137 -0
- package/src/slice-add-field-date.ts +137 -0
- package/src/slice-add-field-embed.ts +137 -0
- package/src/slice-add-field-geo-point.ts +134 -0
- package/src/slice-add-field-image.ts +134 -0
- package/src/slice-add-field-key-text.ts +137 -0
- package/src/slice-add-field-link.ts +155 -0
- package/src/slice-add-field-number.ts +137 -0
- package/src/slice-add-field-rich-text.ts +160 -0
- package/src/slice-add-field-select.ts +143 -0
- package/src/slice-add-field-timestamp.ts +137 -0
- package/src/slice-add-field.ts +106 -0
- package/src/slice-add-variation.ts +137 -0
- package/src/slice-create.ts +129 -0
- package/src/slice-list-variations.ts +67 -0
- package/src/slice-list.ts +88 -0
- package/src/slice-remove-field.ts +117 -0
- package/src/slice-remove-variation.ts +108 -0
- package/src/slice-remove.ts +81 -0
- package/src/slice-rename.ts +112 -0
- package/src/slice-view.ts +77 -0
- package/src/slice.ts +90 -0
- package/src/sync.ts +309 -0
- package/src/token-create.ts +185 -0
- package/src/token-delete.ts +161 -0
- package/src/token-list.ts +212 -0
- package/src/token-set-name.ts +165 -0
- package/src/token.ts +60 -0
- package/src/webhook-add-header.ts +118 -0
- package/src/webhook-create.ts +152 -0
- package/src/webhook-disable.ts +109 -0
- package/src/webhook-enable.ts +132 -0
- package/src/webhook-list.ts +93 -0
- package/src/webhook-remove-header.ts +117 -0
- package/src/webhook-remove.ts +106 -0
- package/src/webhook-set-triggers.ts +148 -0
- package/src/webhook-status.ts +90 -0
- package/src/webhook-test.ts +106 -0
- package/src/webhook-view.ts +147 -0
- package/src/webhook.ts +95 -0
- package/src/whoami.ts +62 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1996 @@
|
|
|
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 ee}var ee=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function te(e){return{kind:`validation`,type:`url`,reference:te,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 ne(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function re(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function x(e,t){return{kind:`schema`,type:`array`,reference:x,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 S(e){return{kind:`schema`,type:`boolean`,reference:S,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 ie(e,t){return{kind:`schema`,type:`literal`,reference:ie,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 C(e,t){return{kind:`schema`,type:`nullable`,reference:C,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=re(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function w(e){return{kind:`schema`,type:`number`,reference:w,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 T(e,t){return{kind:`schema`,type:`object`,reference:T,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]:re(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]=ne(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 E(e,t){return{kind:`schema`,type:`optional`,reference:E,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=re(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function D(e,t,n){return{kind:`schema`,type:`record`,reference:D,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 O(e){return{kind:`schema`,type:`string`,reference:O,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 k(){return{kind:`schema`,type:`unknown`,reference:k,expects:`unknown`,async:!1,get"~standard"(){return v(this)},"~run"(e){return e.typed=!0,e}}}function ae(e,t,n){let r=e[`~run`]({value:t},f(n));if(r.issues)throw new ee(r.issues);return r.value}function oe(...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 A(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 j=new URL(`.prismic`,I(c(l()))),se=`https://prismic.io`;async function ce(e,t){let n={token:e,host:t?.host};await s(j,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(j,`utf-8`);return JSON.parse(e)}catch{return}}async function ue(){try{await t(j)}catch{return!0}return await le()?(await o(j),!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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
4
|
+
USAGE
|
|
5
|
+
prismic custom-type add-field boolean <type-id> <field-id> [flags]
|
|
6
|
+
|
|
7
|
+
ARGUMENTS
|
|
8
|
+
type-id Custom type identifier (required)
|
|
9
|
+
field-id Field identifier (required)
|
|
10
|
+
|
|
11
|
+
FLAGS
|
|
12
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
13
|
+
-l, --label string Display label for the field
|
|
14
|
+
--default Set default value to true
|
|
15
|
+
--true-label string Label shown when toggle is on
|
|
16
|
+
--false-label string Label shown when toggle is off
|
|
17
|
+
-h, --help Show help for command
|
|
18
|
+
|
|
19
|
+
EXAMPLES
|
|
20
|
+
prismic custom-type add-field boolean homepage featured
|
|
21
|
+
prismic custom-type add-field boolean article published --default
|
|
22
|
+
prismic custom-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
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 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=A(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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
26
|
+
USAGE
|
|
27
|
+
prismic custom-type add-field color <type-id> <field-id> [flags]
|
|
28
|
+
|
|
29
|
+
ARGUMENTS
|
|
30
|
+
type-id Custom type identifier (required)
|
|
31
|
+
field-id Field identifier (required)
|
|
32
|
+
|
|
33
|
+
FLAGS
|
|
34
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
35
|
+
-l, --label string Display label for the field
|
|
36
|
+
-p, --placeholder string Placeholder text
|
|
37
|
+
-h, --help Show help for command
|
|
38
|
+
|
|
39
|
+
EXAMPLES
|
|
40
|
+
prismic custom-type add-field color homepage bg_color
|
|
41
|
+
prismic custom-type add-field color homepage accent --tab "Design"
|
|
42
|
+
prismic custom-type add-field color homepage text_color --label "Text Color"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
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 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=A(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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
46
|
+
USAGE
|
|
47
|
+
prismic custom-type add-field date <type-id> <field-id> [flags]
|
|
48
|
+
|
|
49
|
+
ARGUMENTS
|
|
50
|
+
type-id Custom type identifier (required)
|
|
51
|
+
field-id Field identifier (required)
|
|
52
|
+
|
|
53
|
+
FLAGS
|
|
54
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
55
|
+
-l, --label string Display label for the field
|
|
56
|
+
-p, --placeholder string Placeholder text
|
|
57
|
+
--default string Default date value (YYYY-MM-DD format)
|
|
58
|
+
-h, --help Show help for command
|
|
59
|
+
|
|
60
|
+
EXAMPLES
|
|
61
|
+
prismic custom-type add-field date homepage publish_date
|
|
62
|
+
prismic custom-type add-field date event start_date --tab "Schedule"
|
|
63
|
+
prismic custom-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
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 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=A(_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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
67
|
+
USAGE
|
|
68
|
+
prismic custom-type add-field embed <type-id> <field-id> [flags]
|
|
69
|
+
|
|
70
|
+
ARGUMENTS
|
|
71
|
+
type-id Custom type identifier (required)
|
|
72
|
+
field-id Field identifier (required)
|
|
73
|
+
|
|
74
|
+
FLAGS
|
|
75
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
76
|
+
-l, --label string Display label for the field
|
|
77
|
+
-p, --placeholder string Placeholder text
|
|
78
|
+
-h, --help Show help for command
|
|
79
|
+
|
|
80
|
+
EXAMPLES
|
|
81
|
+
prismic custom-type add-field embed homepage video
|
|
82
|
+
prismic custom-type add-field embed homepage youtube --tab "Media"
|
|
83
|
+
prismic custom-type add-field embed homepage media --label "Media Embed"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
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 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=A(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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
87
|
+
USAGE
|
|
88
|
+
prismic custom-type add-field geo-point <type-id> <field-id> [flags]
|
|
89
|
+
|
|
90
|
+
ARGUMENTS
|
|
91
|
+
type-id Custom type identifier (required)
|
|
92
|
+
field-id Field identifier (required)
|
|
93
|
+
|
|
94
|
+
FLAGS
|
|
95
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
96
|
+
-l, --label string Display label for the field
|
|
97
|
+
-h, --help Show help for command
|
|
98
|
+
|
|
99
|
+
EXAMPLES
|
|
100
|
+
prismic custom-type add-field geo-point homepage location
|
|
101
|
+
prismic custom-type add-field geo-point store address --tab "Details"
|
|
102
|
+
prismic custom-type add-field geo-point event venue --label "Event Venue"`);return}if(!a){console.error(`Missing required argument: type-id
|
|
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 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=A(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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
106
|
+
USAGE
|
|
107
|
+
prismic custom-type add-field image <type-id> <field-id> [flags]
|
|
108
|
+
|
|
109
|
+
ARGUMENTS
|
|
110
|
+
type-id Custom type identifier (required)
|
|
111
|
+
field-id Field identifier (required)
|
|
112
|
+
|
|
113
|
+
FLAGS
|
|
114
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
115
|
+
-l, --label string Display label for the field
|
|
116
|
+
-p, --placeholder string Placeholder text
|
|
117
|
+
-h, --help Show help for command
|
|
118
|
+
|
|
119
|
+
EXAMPLES
|
|
120
|
+
prismic custom-type add-field image homepage hero
|
|
121
|
+
prismic custom-type add-field image article thumbnail --tab "Media"
|
|
122
|
+
prismic custom-type add-field image product photo --label "Product Photo"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
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 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=A(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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
126
|
+
USAGE
|
|
127
|
+
prismic custom-type add-field key-text <type-id> <field-id> [flags]
|
|
128
|
+
|
|
129
|
+
ARGUMENTS
|
|
130
|
+
type-id Custom type identifier (required)
|
|
131
|
+
field-id Field identifier (required)
|
|
132
|
+
|
|
133
|
+
FLAGS
|
|
134
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
135
|
+
-l, --label string Display label for the field
|
|
136
|
+
-p, --placeholder string Placeholder text
|
|
137
|
+
-h, --help Show help for command
|
|
138
|
+
|
|
139
|
+
EXAMPLES
|
|
140
|
+
prismic custom-type add-field key-text homepage title
|
|
141
|
+
prismic custom-type add-field key-text homepage meta_title --tab "SEO"
|
|
142
|
+
prismic custom-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
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 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=A(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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
146
|
+
USAGE
|
|
147
|
+
prismic custom-type add-field link <type-id> <field-id> [flags]
|
|
148
|
+
|
|
149
|
+
ARGUMENTS
|
|
150
|
+
type-id Custom type identifier (required)
|
|
151
|
+
field-id Field identifier (required)
|
|
152
|
+
|
|
153
|
+
FLAGS
|
|
154
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
155
|
+
-l, --label string Display label for the field
|
|
156
|
+
-p, --placeholder string Placeholder text
|
|
157
|
+
--variation string Slice variations (can be used multiple times)
|
|
158
|
+
--allow-text Allow text with link
|
|
159
|
+
--allow-target-blank Allow opening link in new tab
|
|
160
|
+
--repeatable Allow multiple links
|
|
161
|
+
-h, --help Show help for command
|
|
162
|
+
|
|
163
|
+
EXAMPLES
|
|
164
|
+
prismic custom-type add-field link homepage button
|
|
165
|
+
prismic custom-type add-field link homepage cta --allow-text
|
|
166
|
+
prismic custom-type add-field link homepage cta --variation Primary --variation Secondary
|
|
167
|
+
prismic custom-type add-field link homepage links --repeatable`);return}if(!d){console.error(`Missing required argument: type-id
|
|
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 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=A(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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
171
|
+
USAGE
|
|
172
|
+
prismic custom-type add-field number <type-id> <field-id> [flags]
|
|
173
|
+
|
|
174
|
+
ARGUMENTS
|
|
175
|
+
type-id Custom type identifier (required)
|
|
176
|
+
field-id Field identifier (required)
|
|
177
|
+
|
|
178
|
+
FLAGS
|
|
179
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
180
|
+
-l, --label string Display label for the field
|
|
181
|
+
-p, --placeholder string Placeholder text
|
|
182
|
+
--min number Minimum value
|
|
183
|
+
--max number Maximum value
|
|
184
|
+
--step number Step increment
|
|
185
|
+
-h, --help Show help for command
|
|
186
|
+
|
|
187
|
+
EXAMPLES
|
|
188
|
+
prismic custom-type add-field number homepage price
|
|
189
|
+
prismic custom-type add-field number product quantity --min 0 --max 100
|
|
190
|
+
prismic custom-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!u){console.error(`Missing required argument: type-id
|
|
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 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=A(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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
194
|
+
USAGE
|
|
195
|
+
prismic custom-type add-field rich-text <type-id> <field-id> [flags]
|
|
196
|
+
|
|
197
|
+
ARGUMENTS
|
|
198
|
+
type-id Custom type identifier (required)
|
|
199
|
+
field-id Field identifier (required)
|
|
200
|
+
|
|
201
|
+
FLAGS
|
|
202
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
203
|
+
-l, --label string Display label for the field
|
|
204
|
+
-p, --placeholder string Placeholder text
|
|
205
|
+
--single string Allowed block types for single-line (comma-separated)
|
|
206
|
+
--multi string Allowed block types for multi-line (comma-separated)
|
|
207
|
+
--allow-target-blank Allow opening links in new tab
|
|
208
|
+
-h, --help Show help for command
|
|
209
|
+
|
|
210
|
+
BLOCK TYPES
|
|
211
|
+
heading1, heading2, heading3, heading4, heading5, heading6,
|
|
212
|
+
paragraph, strong, em, preformatted, hyperlink, image, embed,
|
|
213
|
+
list-item, o-list-item, rtl
|
|
214
|
+
|
|
215
|
+
EXAMPLES
|
|
216
|
+
prismic custom-type add-field rich-text homepage body
|
|
217
|
+
prismic custom-type add-field rich-text article content --multi "paragraph,heading2,heading3,strong,em,hyperlink"
|
|
218
|
+
prismic custom-type add-field rich-text page tagline --single "heading1"
|
|
219
|
+
prismic custom-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: type-id
|
|
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 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=A(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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
223
|
+
USAGE
|
|
224
|
+
prismic custom-type add-field select <type-id> <field-id> [flags]
|
|
225
|
+
|
|
226
|
+
ARGUMENTS
|
|
227
|
+
type-id Custom type identifier (required)
|
|
228
|
+
field-id Field identifier (required)
|
|
229
|
+
|
|
230
|
+
FLAGS
|
|
231
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
232
|
+
-l, --label string Display label for the field
|
|
233
|
+
-p, --placeholder string Placeholder text
|
|
234
|
+
--option string Add an option (can be used multiple times)
|
|
235
|
+
--default string Default selected value
|
|
236
|
+
-h, --help Show help for command
|
|
237
|
+
|
|
238
|
+
EXAMPLES
|
|
239
|
+
prismic custom-type add-field select homepage layout --option "full" --option "sidebar"
|
|
240
|
+
prismic custom-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
|
|
241
|
+
prismic custom-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
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 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=A(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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
245
|
+
USAGE
|
|
246
|
+
prismic custom-type add-field timestamp <type-id> <field-id> [flags]
|
|
247
|
+
|
|
248
|
+
ARGUMENTS
|
|
249
|
+
type-id Custom type identifier (required)
|
|
250
|
+
field-id Field identifier (required)
|
|
251
|
+
|
|
252
|
+
FLAGS
|
|
253
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
254
|
+
-l, --label string Display label for the field
|
|
255
|
+
-p, --placeholder string Placeholder text
|
|
256
|
+
--default string Default timestamp value (ISO 8601 format)
|
|
257
|
+
-h, --help Show help for command
|
|
258
|
+
|
|
259
|
+
EXAMPLES
|
|
260
|
+
prismic custom-type add-field timestamp homepage event_time
|
|
261
|
+
prismic custom-type add-field timestamp event start --tab "Schedule"
|
|
262
|
+
prismic custom-type add-field timestamp article published_at --label "Published At"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
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 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=A(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=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});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
|
+
|
|
266
|
+
USAGE
|
|
267
|
+
prismic custom-type add-field uid <type-id> <field-id> [flags]
|
|
268
|
+
|
|
269
|
+
ARGUMENTS
|
|
270
|
+
type-id Custom type identifier (required)
|
|
271
|
+
field-id Field identifier (required)
|
|
272
|
+
|
|
273
|
+
FLAGS
|
|
274
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
275
|
+
-l, --label string Display label for the field
|
|
276
|
+
-p, --placeholder string Placeholder text
|
|
277
|
+
-h, --help Show help for command
|
|
278
|
+
|
|
279
|
+
EXAMPLES
|
|
280
|
+
prismic custom-type add-field uid page uid
|
|
281
|
+
prismic custom-type add-field uid article slug --label "URL Slug"
|
|
282
|
+
prismic custom-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
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 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=A(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
|
+
|
|
286
|
+
USAGE
|
|
287
|
+
prismic custom-type add-field <field-type> <type-id> <field-id> [flags]
|
|
288
|
+
|
|
289
|
+
FIELD TYPES
|
|
290
|
+
boolean Boolean toggle
|
|
291
|
+
color Color picker
|
|
292
|
+
date Date picker
|
|
293
|
+
embed Embed (oEmbed)
|
|
294
|
+
geo-point Geographic coordinates
|
|
295
|
+
image Image
|
|
296
|
+
key-text Single-line text
|
|
297
|
+
link Any link type
|
|
298
|
+
number Number
|
|
299
|
+
rich-text Rich text editor
|
|
300
|
+
select Dropdown select
|
|
301
|
+
timestamp Date and time
|
|
302
|
+
uid Unique identifier
|
|
303
|
+
|
|
304
|
+
FLAGS
|
|
305
|
+
-h, --help Show help for command
|
|
306
|
+
|
|
307
|
+
LEARN MORE
|
|
308
|
+
Use \`prismic custom-type add-field <field-type> --help\` for more information.
|
|
309
|
+
|
|
310
|
+
EXAMPLES
|
|
311
|
+
prismic custom-type add-field key-text homepage meta_title --tab "SEO"
|
|
312
|
+
prismic custom-type add-field link homepage button --allow-text
|
|
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 Be=T({id:O(),type:ie(`SharedSlice`),name:O(),description:E(O()),variations:x(T({id:O(),name:O(),description:E(O()),docURL:E(O()),version:E(O()),imageUrl:E(O()),primary:E(D(O(),k())),items:E(D(O(),k()))}))});async function B(e){if(!await L(`package.json`))return{ok:!1,error:`Could not find project root (no package.json found)`};let t=await V(),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=A(Be,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 V(){let e=await He(),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 Ve=T({dependencies:E(D(O(),O()))});async function He(){let e=await L(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=ae(Ve,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function H(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Ue=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function We(){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
|
+
|
|
316
|
+
USAGE
|
|
317
|
+
prismic custom-type connect-slice <type-id> <slice-id> [flags]
|
|
318
|
+
|
|
319
|
+
ARGUMENTS
|
|
320
|
+
type-id Custom type identifier (required)
|
|
321
|
+
slice-id Slice identifier (required)
|
|
322
|
+
|
|
323
|
+
FLAGS
|
|
324
|
+
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
325
|
+
-h, --help Show help for command
|
|
326
|
+
|
|
327
|
+
EXAMPLES
|
|
328
|
+
prismic custom-type connect-slice homepage CallToAction
|
|
329
|
+
prismic custom-type connect-slice homepage CallToAction --slice-zone slices
|
|
330
|
+
prismic custom-type connect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
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 B(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=A(Ue,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 Ge(){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
|
+
|
|
334
|
+
USAGE
|
|
335
|
+
prismic custom-type create <id> [flags]
|
|
336
|
+
|
|
337
|
+
ARGUMENTS
|
|
338
|
+
id Custom type identifier (required)
|
|
339
|
+
|
|
340
|
+
FLAGS
|
|
341
|
+
-n, --name string Display name for the custom type
|
|
342
|
+
--single Create as a singleton (non-repeatable) type
|
|
343
|
+
-h, --help Show help for command
|
|
344
|
+
|
|
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??Ke(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 Ke(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const qe=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Je(){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
|
+
|
|
348
|
+
USAGE
|
|
349
|
+
prismic custom-type disconnect-slice <type-id> <slice-id> [flags]
|
|
350
|
+
|
|
351
|
+
ARGUMENTS
|
|
352
|
+
type-id Custom type identifier (required)
|
|
353
|
+
slice-id Slice identifier (required)
|
|
354
|
+
|
|
355
|
+
FLAGS
|
|
356
|
+
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
357
|
+
-h, --help Show help for command
|
|
358
|
+
|
|
359
|
+
EXAMPLES
|
|
360
|
+
prismic custom-type disconnect-slice homepage CallToAction
|
|
361
|
+
prismic custom-type disconnect-slice homepage CallToAction --slice-zone slices
|
|
362
|
+
prismic custom-type disconnect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
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 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=A(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}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 Ye=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function Xe(){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
|
+
|
|
366
|
+
USAGE
|
|
367
|
+
prismic custom-type list [flags]
|
|
368
|
+
|
|
369
|
+
FLAGS
|
|
370
|
+
--json Output as JSON
|
|
371
|
+
-h, --help Show help for command
|
|
372
|
+
|
|
373
|
+
EXAMPLES
|
|
374
|
+
prismic custom-type list
|
|
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=A(Ye,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 Ze=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function Qe(){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
|
+
|
|
377
|
+
USAGE
|
|
378
|
+
prismic custom-type remove <type-id> [flags]
|
|
379
|
+
|
|
380
|
+
ARGUMENTS
|
|
381
|
+
type-id Custom type identifier (required)
|
|
382
|
+
|
|
383
|
+
FLAGS
|
|
384
|
+
-y Confirm removal
|
|
385
|
+
-h, --help Show help for command
|
|
386
|
+
|
|
387
|
+
EXAMPLES
|
|
388
|
+
prismic custom-type remove settings
|
|
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 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=A(Ze,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 $e=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function et(){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
|
+
|
|
392
|
+
USAGE
|
|
393
|
+
prismic custom-type remove-field <type-id> <field-id> [flags]
|
|
394
|
+
|
|
395
|
+
ARGUMENTS
|
|
396
|
+
type-id Custom type identifier (required)
|
|
397
|
+
field-id Field identifier (required)
|
|
398
|
+
|
|
399
|
+
FLAGS
|
|
400
|
+
--tab string Specific tab (searches all tabs if not specified)
|
|
401
|
+
-h, --help Show help for command
|
|
402
|
+
|
|
403
|
+
EXAMPLES
|
|
404
|
+
prismic custom-type remove-field settings title
|
|
405
|
+
prismic custom-type remove-field settings description --tab "Content"`);return}if(!i){console.error(`Missing required argument: type-id
|
|
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 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=A($e,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 tt=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function nt(){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
|
+
|
|
409
|
+
USAGE
|
|
410
|
+
prismic custom-type set-name <type-id> <new-name> [flags]
|
|
411
|
+
|
|
412
|
+
ARGUMENTS
|
|
413
|
+
type-id Custom type identifier (required)
|
|
414
|
+
new-name New display name (required)
|
|
415
|
+
|
|
416
|
+
FLAGS
|
|
417
|
+
-h, --help Show help for command
|
|
418
|
+
|
|
419
|
+
EXAMPLES
|
|
420
|
+
prismic custom-type set-name settings "Site Settings"
|
|
421
|
+
prismic custom-type set-name menu "Navigation Menu"`);return}if(!n){console.error(`Missing required argument: type-id
|
|
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 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=A(tt,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 rt=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function it(){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
|
+
|
|
425
|
+
USAGE
|
|
426
|
+
prismic custom-type view <type-id> [flags]
|
|
427
|
+
|
|
428
|
+
ARGUMENTS
|
|
429
|
+
type-id Custom type identifier (required)
|
|
430
|
+
|
|
431
|
+
FLAGS
|
|
432
|
+
--json Output as JSON
|
|
433
|
+
-h, --help Show help for command
|
|
434
|
+
|
|
435
|
+
EXAMPLES
|
|
436
|
+
prismic custom-type view settings
|
|
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 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=A(rt,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 at(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Ge();break;case`list`:await Xe();break;case`view`:await it();break;case`remove`:await Qe();break;case`set-name`:await nt();break;case`add-field`:await ze();break;case`remove-field`:await et();break;case`connect-slice`:await We();break;case`disconnect-slice`:await Je();break;default:t&&(console.error(`Unknown custom-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage custom types in a Prismic repository.
|
|
439
|
+
|
|
440
|
+
USAGE
|
|
441
|
+
prismic custom-type <command> [flags]
|
|
442
|
+
|
|
443
|
+
COMMANDS
|
|
444
|
+
create Create a new custom type
|
|
445
|
+
list List all custom types
|
|
446
|
+
view View details of a custom type
|
|
447
|
+
remove Remove a custom type
|
|
448
|
+
set-name Change a custom type's display name
|
|
449
|
+
add-field Add a field to a custom type
|
|
450
|
+
remove-field Remove a field from a custom type
|
|
451
|
+
connect-slice Connect a shared slice to a custom type
|
|
452
|
+
disconnect-slice Disconnect a shared slice from a custom type
|
|
453
|
+
|
|
454
|
+
FLAGS
|
|
455
|
+
-h, --help Show help for command
|
|
456
|
+
|
|
457
|
+
LEARN MORE
|
|
458
|
+
Use \`prismic custom-type <command> --help\` for more information about a command.`)}}const ot=`prismic.config.json`,st=T({repositoryName:O(),apiEndpoint:E(oe(O(),te())),localSliceMachineSimulatorURL:E(oe(O(),te())),libraries:E(x(O())),adapter:E(O()),labs:E(T({legacySliceUpgrader:E(S())}))});async function ct(e,t=c(process.cwd())){let n=await ft(t);return n.ok?(await s(n.path,z(e)),{ok:!0,config:e}):n}async function U(e=c(process.cwd())){let t=await W(e);if(t.ok)return t.config.repositoryName}async function W(e=c(process.cwd())){let t=await dt(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=A(st,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new lt(n.issues)}}catch{return{ok:!1,error:new lt}}}var lt=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function ut(e,t=c(process.cwd())){let n=await dt(t);if(!n.ok)return n;let r=await W(t);if(!r.ok)return r;let i={...r.config,...e};return await s(n.path,z(i)),{ok:!0,config:i}}async function dt(e=c(process.cwd())){let t=await L(ot,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new pt}}async function ft(e=c(process.cwd())){let t=await L(`package.json`,{start:e});return t?{ok:!0,path:new URL(ot,t)}:{ok:!1,error:new mt}}var pt=class extends Error{message=`Could not find a prismic.config.json file.`},mt=class extends Error{message=`Could not find a package.json file.`};async function ht(){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
|
+
|
|
460
|
+
Use this command to connect an existing Prismic repository to your project.
|
|
461
|
+
To create a new repository, use \`prismic repo create\` instead.
|
|
462
|
+
|
|
463
|
+
USAGE
|
|
464
|
+
prismic init [flags]
|
|
465
|
+
|
|
466
|
+
FLAGS
|
|
467
|
+
-r, --repo Repository name (required)
|
|
468
|
+
-h, --help Show help for command
|
|
469
|
+
|
|
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 W()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await ct({repositoryName:t.repo});if(!n.ok){n.error instanceof mt?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 G(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:ae(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 q(a)};else if(a.status===403)return{ok:!1,value:o,error:new K(a)};else return{ok:!1,value:o,error:new gt(a)}}var gt=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}},K=class extends gt{},q=class extends gt{};async function _t(){let{values:{help:t,name:n,repo:r=await U()},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
|
+
|
|
473
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
474
|
+
project root.
|
|
475
|
+
|
|
476
|
+
USAGE
|
|
477
|
+
prismic locale add <code> [flags]
|
|
478
|
+
|
|
479
|
+
ARGUMENTS
|
|
480
|
+
<code> Locale code (e.g. fr-fr, es-es)
|
|
481
|
+
|
|
482
|
+
FLAGS
|
|
483
|
+
-n, --name string Custom display name (creates custom locale)
|
|
484
|
+
-r, --repo string Repository domain
|
|
485
|
+
-h, --help Show help for command
|
|
486
|
+
|
|
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 M()){bt();return}let a=n?await yt(r,i,n):await vt(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof K?bt():(console.error(`Failed to add locale: ${z(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function vt(e,t){return await G(new URL(`/app/settings/multilanguages`,await F(e)),{method:`POST`,body:{languages:[t]}})}async function yt(e,t,n){let[r,i]=t.split(`-`);return await G(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 bt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function xt(){let{values:{help:t,repo:n=await U(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all locales in a Prismic repository.
|
|
489
|
+
|
|
490
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
491
|
+
project root.
|
|
492
|
+
|
|
493
|
+
USAGE
|
|
494
|
+
prismic locale list [flags]
|
|
495
|
+
|
|
496
|
+
FLAGS
|
|
497
|
+
--json Output as JSON
|
|
498
|
+
-r, --repo string Repository domain
|
|
499
|
+
-h, --help Show help for command
|
|
500
|
+
|
|
501
|
+
LEARN MORE
|
|
502
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){wt();return}let i=await Ct(n);if(!i.ok){i.error instanceof K?wt():b(i.error)?(console.error(`Failed to list locales: Invalid response: ${z(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${z(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(z(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const St=T({results:x(T({id:O(),label:O(),customName:C(O()),isMaster:S()}))});async function Ct(e){let t=new URL(`/locale/repository/locales`,await de());return t.searchParams.set(`repository`,e),await G(t,{schema:St})}function wt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Tt(){let{values:{repo:t=await U(),help:n},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(`Remove a locale from a Prismic repository.
|
|
503
|
+
|
|
504
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
505
|
+
project root.
|
|
506
|
+
|
|
507
|
+
USAGE
|
|
508
|
+
prismic locale remove <code> [flags]
|
|
509
|
+
|
|
510
|
+
ARGUMENTS
|
|
511
|
+
<code> Locale code (e.g. en-us, fr-fr)
|
|
512
|
+
|
|
513
|
+
FLAGS
|
|
514
|
+
-r, --repo string Repository domain
|
|
515
|
+
-h, --help Show help for command
|
|
516
|
+
|
|
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 M()){Dt();return}let i=await Et(t,r);if(!i.ok){i.error instanceof K?Dt():(console.error(`Failed to remove locale: ${z(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function Et(e,t){let n=new URL(`/locale/repository/locales/${t}`,await de());return n.searchParams.set(`repository`,e),await G(n,{method:`DELETE`})}function Dt(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ot(){let{values:{help:t,repo:n=await U()},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
|
+
|
|
520
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
521
|
+
project root.
|
|
522
|
+
|
|
523
|
+
USAGE
|
|
524
|
+
prismic locale set-default <code> [flags]
|
|
525
|
+
|
|
526
|
+
ARGUMENTS
|
|
527
|
+
<code> Locale code (e.g. en-us, fr-fr)
|
|
528
|
+
|
|
529
|
+
FLAGS
|
|
530
|
+
-r, --repo string Repository domain
|
|
531
|
+
-h, --help Show help for command
|
|
532
|
+
|
|
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 M()){At();return}let i=await Ct(n);if(!i.ok){i.error instanceof K?At():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 kt(n,o);if(!s.ok){s.error instanceof K?At():(console.error(`Failed to set default locale: ${z(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function kt(e,t){let n=new URL(`/locale/repository/locales`,await de());return n.searchParams.set(`repository`,e),await G(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function At(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function jt(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await _t();break;case`list`:await xt();break;case`remove`:await Tt();break;case`set-default`:await Ot();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
|
|
535
|
+
|
|
536
|
+
USAGE
|
|
537
|
+
prismic locale <command> [flags]
|
|
538
|
+
|
|
539
|
+
COMMANDS
|
|
540
|
+
add Add a locale to a repository
|
|
541
|
+
list List locales in a repository
|
|
542
|
+
remove Remove a locale from a repository
|
|
543
|
+
set-default Set the default locale for a repository
|
|
544
|
+
|
|
545
|
+
FLAGS
|
|
546
|
+
-h, --help Show help for command
|
|
547
|
+
|
|
548
|
+
LEARN MORE
|
|
549
|
+
Use \`prismic locale <command> --help\` for more information about a command.`)}}async function Mt(){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
|
+
|
|
551
|
+
USAGE
|
|
552
|
+
prismic login [flags]
|
|
553
|
+
|
|
554
|
+
FLAGS
|
|
555
|
+
-h, --help Show help for command
|
|
556
|
+
|
|
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 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=Nt(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),Pt(a)}),n.on(`error`,e=>{clearTimeout(r),t(e)})})}function Nt(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 Pt(e){u(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function Ft(){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
|
+
|
|
560
|
+
USAGE
|
|
561
|
+
prismic logout [flags]
|
|
562
|
+
|
|
563
|
+
FLAGS
|
|
564
|
+
-h, --help Show help for command
|
|
565
|
+
|
|
566
|
+
LEARN MORE
|
|
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 It=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Lt(){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
|
+
|
|
569
|
+
USAGE
|
|
570
|
+
prismic page-type add-field boolean <type-id> <field-id> [flags]
|
|
571
|
+
|
|
572
|
+
ARGUMENTS
|
|
573
|
+
type-id Page type identifier (required)
|
|
574
|
+
field-id Field identifier (required)
|
|
575
|
+
|
|
576
|
+
FLAGS
|
|
577
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
578
|
+
-l, --label string Display label for the field
|
|
579
|
+
--default Set default value to true
|
|
580
|
+
--true-label string Label shown when toggle is on
|
|
581
|
+
--false-label string Label shown when toggle is off
|
|
582
|
+
-h, --help Show help for command
|
|
583
|
+
|
|
584
|
+
EXAMPLES
|
|
585
|
+
prismic page-type add-field boolean homepage featured
|
|
586
|
+
prismic page-type add-field boolean article published --default
|
|
587
|
+
prismic page-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
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 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=A(It,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 Rt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function zt(){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
|
+
|
|
591
|
+
USAGE
|
|
592
|
+
prismic page-type add-field color <type-id> <field-id> [flags]
|
|
593
|
+
|
|
594
|
+
ARGUMENTS
|
|
595
|
+
type-id Page type identifier (required)
|
|
596
|
+
field-id Field identifier (required)
|
|
597
|
+
|
|
598
|
+
FLAGS
|
|
599
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
600
|
+
-l, --label string Display label for the field
|
|
601
|
+
-p, --placeholder string Placeholder text
|
|
602
|
+
-h, --help Show help for command
|
|
603
|
+
|
|
604
|
+
EXAMPLES
|
|
605
|
+
prismic page-type add-field color homepage bg_color
|
|
606
|
+
prismic page-type add-field color homepage accent --tab "Design"
|
|
607
|
+
prismic page-type add-field color homepage text_color --label "Text Color"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
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 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=A(Rt,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 Bt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Vt(){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
|
+
|
|
611
|
+
USAGE
|
|
612
|
+
prismic page-type add-field date <type-id> <field-id> [flags]
|
|
613
|
+
|
|
614
|
+
ARGUMENTS
|
|
615
|
+
type-id Page type identifier (required)
|
|
616
|
+
field-id Field identifier (required)
|
|
617
|
+
|
|
618
|
+
FLAGS
|
|
619
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
620
|
+
-l, --label string Display label for the field
|
|
621
|
+
-p, --placeholder string Placeholder text
|
|
622
|
+
--default string Default date value (YYYY-MM-DD format)
|
|
623
|
+
-h, --help Show help for command
|
|
624
|
+
|
|
625
|
+
EXAMPLES
|
|
626
|
+
prismic page-type add-field date homepage publish_date
|
|
627
|
+
prismic page-type add-field date event start_date --tab "Schedule"
|
|
628
|
+
prismic page-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
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 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=A(Bt,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 Ht=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Ut(){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
|
+
|
|
632
|
+
USAGE
|
|
633
|
+
prismic page-type add-field embed <type-id> <field-id> [flags]
|
|
634
|
+
|
|
635
|
+
ARGUMENTS
|
|
636
|
+
type-id Page type identifier (required)
|
|
637
|
+
field-id Field identifier (required)
|
|
638
|
+
|
|
639
|
+
FLAGS
|
|
640
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
641
|
+
-l, --label string Display label for the field
|
|
642
|
+
-p, --placeholder string Placeholder text
|
|
643
|
+
-h, --help Show help for command
|
|
644
|
+
|
|
645
|
+
EXAMPLES
|
|
646
|
+
prismic page-type add-field embed homepage video
|
|
647
|
+
prismic page-type add-field embed homepage youtube --tab "Media"
|
|
648
|
+
prismic page-type add-field embed homepage media --label "Media Embed"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
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 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=A(Ht,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 Wt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Gt(){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
|
+
|
|
652
|
+
USAGE
|
|
653
|
+
prismic page-type add-field geo-point <type-id> <field-id> [flags]
|
|
654
|
+
|
|
655
|
+
ARGUMENTS
|
|
656
|
+
type-id Page type identifier (required)
|
|
657
|
+
field-id Field identifier (required)
|
|
658
|
+
|
|
659
|
+
FLAGS
|
|
660
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
661
|
+
-l, --label string Display label for the field
|
|
662
|
+
-h, --help Show help for command
|
|
663
|
+
|
|
664
|
+
EXAMPLES
|
|
665
|
+
prismic page-type add-field geo-point homepage location
|
|
666
|
+
prismic page-type add-field geo-point store address --tab "Details"
|
|
667
|
+
prismic page-type add-field geo-point event venue --label "Event Venue"`);return}if(!a){console.error(`Missing required argument: type-id
|
|
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 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=A(Wt,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 Kt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function qt(){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
|
+
|
|
671
|
+
USAGE
|
|
672
|
+
prismic page-type add-field image <type-id> <field-id> [flags]
|
|
673
|
+
|
|
674
|
+
ARGUMENTS
|
|
675
|
+
type-id Page type identifier (required)
|
|
676
|
+
field-id Field identifier (required)
|
|
677
|
+
|
|
678
|
+
FLAGS
|
|
679
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
680
|
+
-l, --label string Display label for the field
|
|
681
|
+
-p, --placeholder string Placeholder text
|
|
682
|
+
-h, --help Show help for command
|
|
683
|
+
|
|
684
|
+
EXAMPLES
|
|
685
|
+
prismic page-type add-field image homepage hero
|
|
686
|
+
prismic page-type add-field image article thumbnail --tab "Media"
|
|
687
|
+
prismic page-type add-field image product photo --label "Product Photo"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
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 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=A(Kt,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 Jt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Yt(){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
|
+
|
|
691
|
+
USAGE
|
|
692
|
+
prismic page-type add-field key-text <type-id> <field-id> [flags]
|
|
693
|
+
|
|
694
|
+
ARGUMENTS
|
|
695
|
+
type-id Page type identifier (required)
|
|
696
|
+
field-id Field identifier (required)
|
|
697
|
+
|
|
698
|
+
FLAGS
|
|
699
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
700
|
+
-l, --label string Display label for the field
|
|
701
|
+
-p, --placeholder string Placeholder text
|
|
702
|
+
-h, --help Show help for command
|
|
703
|
+
|
|
704
|
+
EXAMPLES
|
|
705
|
+
prismic page-type add-field key-text homepage title
|
|
706
|
+
prismic page-type add-field key-text homepage meta_title --tab "SEO"
|
|
707
|
+
prismic page-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
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 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=A(Jt,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 Xt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function Zt(){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
|
+
|
|
711
|
+
USAGE
|
|
712
|
+
prismic page-type add-field link <type-id> <field-id> [flags]
|
|
713
|
+
|
|
714
|
+
ARGUMENTS
|
|
715
|
+
type-id Page type identifier (required)
|
|
716
|
+
field-id Field identifier (required)
|
|
717
|
+
|
|
718
|
+
FLAGS
|
|
719
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
720
|
+
-l, --label string Display label for the field
|
|
721
|
+
-p, --placeholder string Placeholder text
|
|
722
|
+
--variation string Slice variations (can be used multiple times)
|
|
723
|
+
--allow-text Allow text with link
|
|
724
|
+
--allow-target-blank Allow opening link in new tab
|
|
725
|
+
--repeatable Allow multiple links
|
|
726
|
+
-h, --help Show help for command
|
|
727
|
+
|
|
728
|
+
EXAMPLES
|
|
729
|
+
prismic page-type add-field link homepage button
|
|
730
|
+
prismic page-type add-field link homepage cta --allow-text
|
|
731
|
+
prismic page-type add-field link homepage cta --variation Primary --variation Secondary
|
|
732
|
+
prismic page-type add-field link homepage links --repeatable`);return}if(!d){console.error(`Missing required argument: type-id
|
|
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 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=A(Xt,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 Qt=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function $t(){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
|
+
|
|
736
|
+
USAGE
|
|
737
|
+
prismic page-type add-field number <type-id> <field-id> [flags]
|
|
738
|
+
|
|
739
|
+
ARGUMENTS
|
|
740
|
+
type-id Page type identifier (required)
|
|
741
|
+
field-id Field identifier (required)
|
|
742
|
+
|
|
743
|
+
FLAGS
|
|
744
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
745
|
+
-l, --label string Display label for the field
|
|
746
|
+
-p, --placeholder string Placeholder text
|
|
747
|
+
--min number Minimum value
|
|
748
|
+
--max number Maximum value
|
|
749
|
+
--step number Step increment
|
|
750
|
+
-h, --help Show help for command
|
|
751
|
+
|
|
752
|
+
EXAMPLES
|
|
753
|
+
prismic page-type add-field number homepage price
|
|
754
|
+
prismic page-type add-field number product quantity --min 0 --max 100
|
|
755
|
+
prismic page-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!u){console.error(`Missing required argument: type-id
|
|
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 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=A(Qt,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 en=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function tn(){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
|
+
|
|
759
|
+
USAGE
|
|
760
|
+
prismic page-type add-field rich-text <type-id> <field-id> [flags]
|
|
761
|
+
|
|
762
|
+
ARGUMENTS
|
|
763
|
+
type-id Page type identifier (required)
|
|
764
|
+
field-id Field identifier (required)
|
|
765
|
+
|
|
766
|
+
FLAGS
|
|
767
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
768
|
+
-l, --label string Display label for the field
|
|
769
|
+
-p, --placeholder string Placeholder text
|
|
770
|
+
--single string Allowed block types for single-line (comma-separated)
|
|
771
|
+
--multi string Allowed block types for multi-line (comma-separated)
|
|
772
|
+
--allow-target-blank Allow opening links in new tab
|
|
773
|
+
-h, --help Show help for command
|
|
774
|
+
|
|
775
|
+
BLOCK TYPES
|
|
776
|
+
heading1, heading2, heading3, heading4, heading5, heading6,
|
|
777
|
+
paragraph, strong, em, preformatted, hyperlink, image, embed,
|
|
778
|
+
list-item, o-list-item, rtl
|
|
779
|
+
|
|
780
|
+
EXAMPLES
|
|
781
|
+
prismic page-type add-field rich-text homepage body
|
|
782
|
+
prismic page-type add-field rich-text article content --multi "paragraph,heading2,heading3,strong,em,hyperlink"
|
|
783
|
+
prismic page-type add-field rich-text page tagline --single "heading1"
|
|
784
|
+
prismic page-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: type-id
|
|
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 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=A(en,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 nn=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function rn(){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
|
+
|
|
788
|
+
USAGE
|
|
789
|
+
prismic page-type add-field select <type-id> <field-id> [flags]
|
|
790
|
+
|
|
791
|
+
ARGUMENTS
|
|
792
|
+
type-id Page type identifier (required)
|
|
793
|
+
field-id Field identifier (required)
|
|
794
|
+
|
|
795
|
+
FLAGS
|
|
796
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
797
|
+
-l, --label string Display label for the field
|
|
798
|
+
-p, --placeholder string Placeholder text
|
|
799
|
+
--option string Add an option (can be used multiple times)
|
|
800
|
+
--default string Default selected value
|
|
801
|
+
-h, --help Show help for command
|
|
802
|
+
|
|
803
|
+
EXAMPLES
|
|
804
|
+
prismic page-type add-field select homepage layout --option "full" --option "sidebar"
|
|
805
|
+
prismic page-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
|
|
806
|
+
prismic page-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!l){console.error(`Missing required argument: type-id
|
|
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 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=A(nn,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 an=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function on(){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
|
+
|
|
810
|
+
USAGE
|
|
811
|
+
prismic page-type add-field timestamp <type-id> <field-id> [flags]
|
|
812
|
+
|
|
813
|
+
ARGUMENTS
|
|
814
|
+
type-id Page type identifier (required)
|
|
815
|
+
field-id Field identifier (required)
|
|
816
|
+
|
|
817
|
+
FLAGS
|
|
818
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
819
|
+
-l, --label string Display label for the field
|
|
820
|
+
-p, --placeholder string Placeholder text
|
|
821
|
+
--default string Default timestamp value (ISO 8601 format)
|
|
822
|
+
-h, --help Show help for command
|
|
823
|
+
|
|
824
|
+
EXAMPLES
|
|
825
|
+
prismic page-type add-field timestamp homepage event_time
|
|
826
|
+
prismic page-type add-field timestamp event start --tab "Schedule"
|
|
827
|
+
prismic page-type add-field timestamp article published_at --label "Published At"`);return}if(!c){console.error(`Missing required argument: type-id
|
|
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 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=A(an,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 sn=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function cn(){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
|
+
|
|
831
|
+
USAGE
|
|
832
|
+
prismic page-type add-field uid <type-id> <field-id> [flags]
|
|
833
|
+
|
|
834
|
+
ARGUMENTS
|
|
835
|
+
type-id Page type identifier (required)
|
|
836
|
+
field-id Field identifier (required)
|
|
837
|
+
|
|
838
|
+
FLAGS
|
|
839
|
+
-t, --tab string Target tab (default: first existing tab, or "Main")
|
|
840
|
+
-l, --label string Display label for the field
|
|
841
|
+
-p, --placeholder string Placeholder text
|
|
842
|
+
-h, --help Show help for command
|
|
843
|
+
|
|
844
|
+
EXAMPLES
|
|
845
|
+
prismic page-type add-field uid page uid
|
|
846
|
+
prismic page-type add-field uid article slug --label "URL Slug"
|
|
847
|
+
prismic page-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!o){console.error(`Missing required argument: type-id
|
|
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 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=A(sn,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 ln(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await Lt();break;case`color`:await zt();break;case`date`:await Vt();break;case`embed`:await Ut();break;case`geo-point`:await Gt();break;case`image`:await qt();break;case`key-text`:await Yt();break;case`link`:await Zt();break;case`number`:await $t();break;case`rich-text`:await tn();break;case`select`:await rn();break;case`timestamp`:await on();break;case`uid`:await cn();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
|
|
850
|
+
|
|
851
|
+
USAGE
|
|
852
|
+
prismic page-type add-field <field-type> <type-id> <field-id> [flags]
|
|
853
|
+
|
|
854
|
+
FIELD TYPES
|
|
855
|
+
boolean Boolean toggle
|
|
856
|
+
color Color picker
|
|
857
|
+
date Date picker
|
|
858
|
+
embed Embed (oEmbed)
|
|
859
|
+
geo-point Geographic coordinates
|
|
860
|
+
image Image
|
|
861
|
+
key-text Single-line text
|
|
862
|
+
link Any link type
|
|
863
|
+
number Number
|
|
864
|
+
rich-text Rich text editor
|
|
865
|
+
select Dropdown select
|
|
866
|
+
timestamp Date and time
|
|
867
|
+
uid Unique identifier
|
|
868
|
+
|
|
869
|
+
FLAGS
|
|
870
|
+
-h, --help Show help for command
|
|
871
|
+
|
|
872
|
+
LEARN MORE
|
|
873
|
+
Use \`prismic page-type add-field <field-type> --help\` for more information.
|
|
874
|
+
|
|
875
|
+
EXAMPLES
|
|
876
|
+
prismic page-type add-field key-text homepage meta_title --tab "SEO"
|
|
877
|
+
prismic page-type add-field link homepage button --allow-text
|
|
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 un=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function dn(){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
|
+
|
|
881
|
+
USAGE
|
|
882
|
+
prismic page-type connect-slice <type-id> <slice-id> [flags]
|
|
883
|
+
|
|
884
|
+
ARGUMENTS
|
|
885
|
+
type-id Page type identifier (required)
|
|
886
|
+
slice-id Slice identifier (required)
|
|
887
|
+
|
|
888
|
+
FLAGS
|
|
889
|
+
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
890
|
+
-h, --help Show help for command
|
|
891
|
+
|
|
892
|
+
EXAMPLES
|
|
893
|
+
prismic page-type connect-slice homepage CallToAction
|
|
894
|
+
prismic page-type connect-slice homepage CallToAction --slice-zone slices
|
|
895
|
+
prismic page-type connect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
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 B(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=A(un,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 fn(){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
|
+
|
|
899
|
+
USAGE
|
|
900
|
+
prismic page-type create <id> [flags]
|
|
901
|
+
|
|
902
|
+
ARGUMENTS
|
|
903
|
+
id Page type identifier (required)
|
|
904
|
+
|
|
905
|
+
FLAGS
|
|
906
|
+
-n, --name string Display name for the page type
|
|
907
|
+
--single Create as a singleton (non-repeatable) type
|
|
908
|
+
-h, --help Show help for command
|
|
909
|
+
|
|
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??pn(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 pn(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const mn=T({id:O(),label:O(),repeatable:S(),status:S(),format:O(),json:D(O(),D(O(),k()))});async function hn(){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
|
+
|
|
913
|
+
USAGE
|
|
914
|
+
prismic page-type disconnect-slice <type-id> <slice-id> [flags]
|
|
915
|
+
|
|
916
|
+
ARGUMENTS
|
|
917
|
+
type-id Page type identifier (required)
|
|
918
|
+
slice-id Slice identifier (required)
|
|
919
|
+
|
|
920
|
+
FLAGS
|
|
921
|
+
-z, --slice-zone string Target slice zone field ID (default: "slices")
|
|
922
|
+
-h, --help Show help for command
|
|
923
|
+
|
|
924
|
+
EXAMPLES
|
|
925
|
+
prismic page-type disconnect-slice homepage CallToAction
|
|
926
|
+
prismic page-type disconnect-slice homepage CallToAction --slice-zone slices
|
|
927
|
+
prismic page-type disconnect-slice article HeroSection -z body`);return}if(!i){console.error(`Missing required argument: type-id
|
|
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 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=A(mn,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 gn=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function _n(){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
|
+
|
|
931
|
+
USAGE
|
|
932
|
+
prismic page-type list [flags]
|
|
933
|
+
|
|
934
|
+
FLAGS
|
|
935
|
+
--json Output as JSON
|
|
936
|
+
-h, --help Show help for command
|
|
937
|
+
|
|
938
|
+
EXAMPLES
|
|
939
|
+
prismic page-type list
|
|
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=A(gn,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 vn=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function yn(){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
|
+
|
|
942
|
+
USAGE
|
|
943
|
+
prismic page-type remove <type-id> [flags]
|
|
944
|
+
|
|
945
|
+
ARGUMENTS
|
|
946
|
+
type-id Page type identifier (required)
|
|
947
|
+
|
|
948
|
+
FLAGS
|
|
949
|
+
-y Confirm removal
|
|
950
|
+
-h, --help Show help for command
|
|
951
|
+
|
|
952
|
+
EXAMPLES
|
|
953
|
+
prismic page-type remove homepage
|
|
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 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=A(vn,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 bn=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function xn(){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
|
+
|
|
957
|
+
USAGE
|
|
958
|
+
prismic page-type remove-field <type-id> <field-id> [flags]
|
|
959
|
+
|
|
960
|
+
ARGUMENTS
|
|
961
|
+
type-id Page type identifier (required)
|
|
962
|
+
field-id Field identifier (required)
|
|
963
|
+
|
|
964
|
+
FLAGS
|
|
965
|
+
--tab string Specific tab (searches all tabs if not specified)
|
|
966
|
+
-h, --help Show help for command
|
|
967
|
+
|
|
968
|
+
EXAMPLES
|
|
969
|
+
prismic page-type remove-field homepage title
|
|
970
|
+
prismic page-type remove-field homepage meta_title --tab "SEO & Metadata"`);return}if(!i){console.error(`Missing required argument: type-id
|
|
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 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=A(bn,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 Sn=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function Cn(){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
|
+
|
|
974
|
+
USAGE
|
|
975
|
+
prismic page-type set-name <type-id> <new-name> [flags]
|
|
976
|
+
|
|
977
|
+
ARGUMENTS
|
|
978
|
+
type-id Page type identifier (required)
|
|
979
|
+
new-name New display name (required)
|
|
980
|
+
|
|
981
|
+
FLAGS
|
|
982
|
+
-h, --help Show help for command
|
|
983
|
+
|
|
984
|
+
EXAMPLES
|
|
985
|
+
prismic page-type set-name homepage "Home Page"
|
|
986
|
+
prismic page-type set-name blog_post "Blog Post"`);return}if(!n){console.error(`Missing required argument: type-id
|
|
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 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=A(Sn,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 wn=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function Tn(){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
|
+
|
|
990
|
+
USAGE
|
|
991
|
+
prismic page-type set-repeatable <type-id> <true|false> [flags]
|
|
992
|
+
|
|
993
|
+
ARGUMENTS
|
|
994
|
+
type-id Page type identifier (required)
|
|
995
|
+
true|false Repeatable value (required)
|
|
996
|
+
|
|
997
|
+
FLAGS
|
|
998
|
+
-h, --help Show help for command
|
|
999
|
+
|
|
1000
|
+
EXAMPLES
|
|
1001
|
+
prismic page-type set-repeatable homepage true
|
|
1002
|
+
prismic page-type set-repeatable settings false`);return}if(!n){console.error(`Missing required argument: type-id
|
|
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 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=A(wn,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 En=T({id:O(),label:O(),repeatable:S(),status:S(),format:E(O()),json:D(O(),D(O(),k()))});async function Dn(){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
|
+
|
|
1006
|
+
USAGE
|
|
1007
|
+
prismic page-type view <type-id> [flags]
|
|
1008
|
+
|
|
1009
|
+
ARGUMENTS
|
|
1010
|
+
type-id Page type identifier (required)
|
|
1011
|
+
|
|
1012
|
+
FLAGS
|
|
1013
|
+
--json Output as JSON
|
|
1014
|
+
-h, --help Show help for command
|
|
1015
|
+
|
|
1016
|
+
EXAMPLES
|
|
1017
|
+
prismic page-type view homepage
|
|
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 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=A(En,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 On(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await fn();break;case`list`:await _n();break;case`view`:await Dn();break;case`remove`:await yn();break;case`set-name`:await Cn();break;case`set-repeatable`:await Tn();break;case`add-field`:await ln();break;case`remove-field`:await xn();break;case`connect-slice`:await dn();break;case`disconnect-slice`:await hn();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
|
|
1020
|
+
|
|
1021
|
+
USAGE
|
|
1022
|
+
prismic page-type <command> [flags]
|
|
1023
|
+
|
|
1024
|
+
COMMANDS
|
|
1025
|
+
create Create a new page type
|
|
1026
|
+
list List all page types
|
|
1027
|
+
view View details of a page type
|
|
1028
|
+
remove Remove a page type
|
|
1029
|
+
set-name Change a page type's display name
|
|
1030
|
+
set-repeatable Set whether a page type is repeatable
|
|
1031
|
+
add-field Add a field to a page type
|
|
1032
|
+
remove-field Remove a field from a page type
|
|
1033
|
+
connect-slice Connect a shared slice to a page type
|
|
1034
|
+
disconnect-slice Disconnect a shared slice from a page type
|
|
1035
|
+
|
|
1036
|
+
FLAGS
|
|
1037
|
+
-h, --help Show help for command
|
|
1038
|
+
|
|
1039
|
+
LEARN MORE
|
|
1040
|
+
Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function kn(){let{values:{help:t,name:n,repo:r=await U()},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
|
+
|
|
1042
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1043
|
+
project root.
|
|
1044
|
+
|
|
1045
|
+
USAGE
|
|
1046
|
+
prismic preview add <url> [flags]
|
|
1047
|
+
|
|
1048
|
+
ARGUMENTS
|
|
1049
|
+
<url> Preview URL (e.g. https://example.com/api/preview)
|
|
1050
|
+
|
|
1051
|
+
FLAGS
|
|
1052
|
+
-n, --name string Display name (defaults to hostname)
|
|
1053
|
+
-r, --repo string Repository domain
|
|
1054
|
+
-h, --help Show help for command
|
|
1055
|
+
|
|
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 M()){Mn();return}let a=An(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await jn(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof K?Mn():(console.error(`Failed to add preview: ${z(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function An(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 jn(e,t){return await G(new URL(`/previews/new`,await F(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function Mn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Nn(){let{values:{help:t,repo:n=await U(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all preview configurations in a Prismic repository.
|
|
1058
|
+
|
|
1059
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1060
|
+
project root.
|
|
1061
|
+
|
|
1062
|
+
USAGE
|
|
1063
|
+
prismic preview list [flags]
|
|
1064
|
+
|
|
1065
|
+
FLAGS
|
|
1066
|
+
--json Output as JSON
|
|
1067
|
+
-r, --repo string Repository domain
|
|
1068
|
+
-h, --help Show help for command
|
|
1069
|
+
|
|
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 M()){In();return}let i=await Fn(n);if(!i.ok){i.error instanceof K?In():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 Pn=T({results:x(T({id:O(),label:O(),url:O()}))});async function Fn(e){return await G(new URL(`/core/repository/preview_configs`,await F(e)),{schema:Pn})}function In(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ln(){let{values:{help:t,repo:n=await U()},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
|
+
|
|
1073
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1074
|
+
project root.
|
|
1075
|
+
|
|
1076
|
+
USAGE
|
|
1077
|
+
prismic preview remove <url> [flags]
|
|
1078
|
+
|
|
1079
|
+
ARGUMENTS
|
|
1080
|
+
<url> Preview URL to remove
|
|
1081
|
+
|
|
1082
|
+
FLAGS
|
|
1083
|
+
-r, --repo string Repository domain
|
|
1084
|
+
-h, --help Show help for command
|
|
1085
|
+
|
|
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 M()){zn();return}let i=await Fn(n);if(!i.ok){i.error instanceof K?zn():(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 Rn(n,a.id);if(!o.ok){o.error instanceof K?zn():(console.error(`Failed to remove preview: ${z(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function Rn(e,t){return await G(new URL(`/previews/delete/${t}`,await F(e)),{method:`POST`,body:{}})}function zn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Bn(){let{values:{help:t,repo:n=await U()},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
|
+
|
|
1089
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1090
|
+
project root.
|
|
1091
|
+
|
|
1092
|
+
USAGE
|
|
1093
|
+
prismic preview set-name <url> <name> [flags]
|
|
1094
|
+
|
|
1095
|
+
ARGUMENTS
|
|
1096
|
+
<url> Preview URL to update
|
|
1097
|
+
<name> New display name
|
|
1098
|
+
|
|
1099
|
+
FLAGS
|
|
1100
|
+
-r, --repo string Repository domain
|
|
1101
|
+
-h, --help Show help for command
|
|
1102
|
+
|
|
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 M()){Hn();return}let a=An(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await Fn(n);if(!o.ok){o.error instanceof K?Hn():(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 Vn(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof K?Hn():(console.error(`Failed to update preview: ${z(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function Vn(e,t,n){return await G(new URL(`/previews/save/${t}`,await F(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function Hn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Un(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await kn();break;case`list`:await Nn();break;case`remove`:await Ln();break;case`set-name`:await Bn();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
|
|
1105
|
+
|
|
1106
|
+
USAGE
|
|
1107
|
+
prismic preview <command> [flags]
|
|
1108
|
+
|
|
1109
|
+
COMMANDS
|
|
1110
|
+
add Add a preview configuration
|
|
1111
|
+
list List preview configurations
|
|
1112
|
+
remove Remove a preview configuration
|
|
1113
|
+
set-name Update a preview's name
|
|
1114
|
+
|
|
1115
|
+
FLAGS
|
|
1116
|
+
-h, --help Show help for command
|
|
1117
|
+
|
|
1118
|
+
LEARN MORE
|
|
1119
|
+
Use \`prismic preview <command> --help\` for more information about a command.`)}}const Wn=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;async function Gn(){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
|
+
|
|
1121
|
+
Creates prismic.config.json in the current directory. If a config file already
|
|
1122
|
+
exists, use --replace to update it with the new repository.
|
|
1123
|
+
|
|
1124
|
+
USAGE
|
|
1125
|
+
prismic repo create <domain> [flags]
|
|
1126
|
+
|
|
1127
|
+
ARGUMENTS
|
|
1128
|
+
domain Repository domain (required). Must be at least 4 characters,
|
|
1129
|
+
start and end with alphanumeric, and contain only alphanumerics and hyphens.
|
|
1130
|
+
|
|
1131
|
+
FLAGS
|
|
1132
|
+
-n, --name string Display name for the repository (defaults to domain)
|
|
1133
|
+
--no-config Skip creating or updating prismic.config.json
|
|
1134
|
+
--replace Replace existing repositoryName in prismic.config.json
|
|
1135
|
+
-h, --help Show help for command
|
|
1136
|
+
|
|
1137
|
+
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(!Wn.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()){qn();return}let o=await W();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 Kn(a,n);if(!s.ok){s.error instanceof K?qn():(console.error(`Failed to create repository: ${z(s.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await ut({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 ct({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 Kn(e,t=e){return await G(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 qn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Jn=T({repositories:x(T({domain:O(),name:E(O()),role:O()}))});async function Yn(){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
|
+
|
|
1140
|
+
USAGE
|
|
1141
|
+
prismic repo list [flags]
|
|
1142
|
+
|
|
1143
|
+
FLAGS
|
|
1144
|
+
--json Output as JSON
|
|
1145
|
+
-h, --help Show help for command
|
|
1146
|
+
|
|
1147
|
+
LEARN MORE
|
|
1148
|
+
Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await M()){Zn();return}let r=await Xn();if(!r.ok){r.error instanceof K?Zn():(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 Xn(){return await G(new URL(`profile`,await fe()),{schema:Jn})}function Zn(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Qn(){let{values:{help:t,repo:n=await U()},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
|
+
|
|
1150
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1151
|
+
project root.
|
|
1152
|
+
|
|
1153
|
+
USAGE
|
|
1154
|
+
prismic repo set-name <name> [flags]
|
|
1155
|
+
|
|
1156
|
+
ARGUMENTS
|
|
1157
|
+
<name> The new display name for the repository
|
|
1158
|
+
|
|
1159
|
+
FLAGS
|
|
1160
|
+
-r, --repo string Repository domain
|
|
1161
|
+
-h, --help Show help for command
|
|
1162
|
+
|
|
1163
|
+
LEARN MORE
|
|
1164
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){er();return}let i=await $n(n,r);if(!i.ok){i.error instanceof K?er():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 $n(e,t){let n=await F(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await G(r,{method:`POST`,body:i,schema:T({repository:T({name:O()})})})}function er(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const tr=T({repositories:x(T({domain:O(),name:E(O())}))});async function nr(){let{values:{help:t,repo:n=await U(),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
|
+
|
|
1166
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1167
|
+
project root.
|
|
1168
|
+
|
|
1169
|
+
USAGE
|
|
1170
|
+
prismic repo view [flags]
|
|
1171
|
+
|
|
1172
|
+
FLAGS
|
|
1173
|
+
-w, --web Open repository in browser
|
|
1174
|
+
-r, --repo string Repository domain
|
|
1175
|
+
-h, --help Show help for command
|
|
1176
|
+
|
|
1177
|
+
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 F(n);if(r){ir(i.toString()),console.info(`Opening ${i}`);return}if(!await M()){ar();return}let a=await rr();if(!a.ok){a.error instanceof K?ar():(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 rr(){return await G(new URL(`profile`,await fe()),{schema:tr})}function ir(e){u(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function ar(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function or(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Gn();break;case`list`:await Yn();break;case`view`:await nr();break;case`set-name`:await Qn();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
|
|
1179
|
+
|
|
1180
|
+
USAGE
|
|
1181
|
+
prismic repo <command> [flags]
|
|
1182
|
+
|
|
1183
|
+
COMMANDS
|
|
1184
|
+
create Create a new Prismic repository
|
|
1185
|
+
list List all repositories
|
|
1186
|
+
view View repository details
|
|
1187
|
+
set-name Set repository display name
|
|
1188
|
+
|
|
1189
|
+
FLAGS
|
|
1190
|
+
-h, --help Show help for command
|
|
1191
|
+
|
|
1192
|
+
LEARN MORE
|
|
1193
|
+
Use \`prismic repo <command> --help\` for more information about a command.`)}}async function sr(){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
|
+
|
|
1195
|
+
USAGE
|
|
1196
|
+
prismic slice add-field boolean <slice-id> <field-id> [flags]
|
|
1197
|
+
|
|
1198
|
+
ARGUMENTS
|
|
1199
|
+
slice-id Slice identifier (required)
|
|
1200
|
+
field-id Field identifier (required)
|
|
1201
|
+
|
|
1202
|
+
FLAGS
|
|
1203
|
+
-v, --variation string Target variation (default: first variation)
|
|
1204
|
+
-l, --label string Display label for the field
|
|
1205
|
+
--default Set default value to true
|
|
1206
|
+
--true-label string Label shown when toggle is on
|
|
1207
|
+
--false-label string Label shown when toggle is off
|
|
1208
|
+
-h, --help Show help for command
|
|
1209
|
+
|
|
1210
|
+
EXAMPLES
|
|
1211
|
+
prismic slice add-field boolean my_slice featured
|
|
1212
|
+
prismic slice add-field boolean hero show_overlay --default
|
|
1213
|
+
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
|
+
`),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 B(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 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 color picker field to an existing slice.
|
|
1216
|
+
|
|
1217
|
+
USAGE
|
|
1218
|
+
prismic slice add-field color <slice-id> <field-id> [flags]
|
|
1219
|
+
|
|
1220
|
+
ARGUMENTS
|
|
1221
|
+
slice-id Slice identifier (required)
|
|
1222
|
+
field-id Field identifier (required)
|
|
1223
|
+
|
|
1224
|
+
FLAGS
|
|
1225
|
+
-v, --variation string Target variation (default: first variation)
|
|
1226
|
+
-l, --label string Display label for the field
|
|
1227
|
+
-p, --placeholder string Placeholder text
|
|
1228
|
+
-h, --help Show help for command
|
|
1229
|
+
|
|
1230
|
+
EXAMPLES
|
|
1231
|
+
prismic slice add-field color my_slice background_color
|
|
1232
|
+
prismic slice add-field color hero accent --label "Accent Color"
|
|
1233
|
+
prismic slice add-field color banner theme_color --variation "dark"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1234
|
+
`),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 B(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 lr(){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
|
+
|
|
1237
|
+
USAGE
|
|
1238
|
+
prismic slice add-field date <slice-id> <field-id> [flags]
|
|
1239
|
+
|
|
1240
|
+
ARGUMENTS
|
|
1241
|
+
slice-id Slice identifier (required)
|
|
1242
|
+
field-id Field identifier (required)
|
|
1243
|
+
|
|
1244
|
+
FLAGS
|
|
1245
|
+
-v, --variation string Target variation (default: first variation)
|
|
1246
|
+
-l, --label string Display label for the field
|
|
1247
|
+
-p, --placeholder string Placeholder text
|
|
1248
|
+
-h, --help Show help for command
|
|
1249
|
+
|
|
1250
|
+
EXAMPLES
|
|
1251
|
+
prismic slice add-field date my_slice publish_date
|
|
1252
|
+
prismic slice add-field date event start_date --label "Start Date"
|
|
1253
|
+
prismic slice add-field date promo end_date --variation "countdown"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1254
|
+
`),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 B(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 ur(){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
|
+
|
|
1257
|
+
USAGE
|
|
1258
|
+
prismic slice add-field embed <slice-id> <field-id> [flags]
|
|
1259
|
+
|
|
1260
|
+
ARGUMENTS
|
|
1261
|
+
slice-id Slice identifier (required)
|
|
1262
|
+
field-id Field identifier (required)
|
|
1263
|
+
|
|
1264
|
+
FLAGS
|
|
1265
|
+
-v, --variation string Target variation (default: first variation)
|
|
1266
|
+
-l, --label string Display label for the field
|
|
1267
|
+
-p, --placeholder string Placeholder text
|
|
1268
|
+
-h, --help Show help for command
|
|
1269
|
+
|
|
1270
|
+
EXAMPLES
|
|
1271
|
+
prismic slice add-field embed my_slice video
|
|
1272
|
+
prismic slice add-field embed gallery media --label "Media Embed"
|
|
1273
|
+
prismic slice add-field embed social tweet --variation "twitter"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1274
|
+
`),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 B(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 dr(){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
|
+
|
|
1277
|
+
USAGE
|
|
1278
|
+
prismic slice add-field geo-point <slice-id> <field-id> [flags]
|
|
1279
|
+
|
|
1280
|
+
ARGUMENTS
|
|
1281
|
+
slice-id Slice identifier (required)
|
|
1282
|
+
field-id Field identifier (required)
|
|
1283
|
+
|
|
1284
|
+
FLAGS
|
|
1285
|
+
-v, --variation string Target variation (default: first variation)
|
|
1286
|
+
-l, --label string Display label for the field
|
|
1287
|
+
-h, --help Show help for command
|
|
1288
|
+
|
|
1289
|
+
EXAMPLES
|
|
1290
|
+
prismic slice add-field geo-point my_slice location
|
|
1291
|
+
prismic slice add-field geo-point store coordinates --label "Store Location"
|
|
1292
|
+
prismic slice add-field geo-point map marker --variation "interactive"`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1293
|
+
`),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 B(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 fr(){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
|
+
|
|
1296
|
+
USAGE
|
|
1297
|
+
prismic slice add-field image <slice-id> <field-id> [flags]
|
|
1298
|
+
|
|
1299
|
+
ARGUMENTS
|
|
1300
|
+
slice-id Slice identifier (required)
|
|
1301
|
+
field-id Field identifier (required)
|
|
1302
|
+
|
|
1303
|
+
FLAGS
|
|
1304
|
+
-v, --variation string Target variation (default: first variation)
|
|
1305
|
+
-l, --label string Display label for the field
|
|
1306
|
+
-h, --help Show help for command
|
|
1307
|
+
|
|
1308
|
+
EXAMPLES
|
|
1309
|
+
prismic slice add-field image my_slice background
|
|
1310
|
+
prismic slice add-field image hero banner --label "Hero Banner"
|
|
1311
|
+
prismic slice add-field image gallery thumbnail --variation "grid"`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1312
|
+
`),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 B(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 pr(){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
|
+
|
|
1315
|
+
USAGE
|
|
1316
|
+
prismic slice add-field key-text <slice-id> <field-id> [flags]
|
|
1317
|
+
|
|
1318
|
+
ARGUMENTS
|
|
1319
|
+
slice-id Slice identifier (required)
|
|
1320
|
+
field-id Field identifier (required)
|
|
1321
|
+
|
|
1322
|
+
FLAGS
|
|
1323
|
+
-v, --variation string Target variation (default: first variation)
|
|
1324
|
+
-l, --label string Display label for the field
|
|
1325
|
+
-p, --placeholder string Placeholder text
|
|
1326
|
+
-h, --help Show help for command
|
|
1327
|
+
|
|
1328
|
+
EXAMPLES
|
|
1329
|
+
prismic slice add-field key-text my_slice title
|
|
1330
|
+
prismic slice add-field key-text hero heading --label "Heading"
|
|
1331
|
+
prismic slice add-field key-text cta button_text --placeholder "Enter button text"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1332
|
+
`),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 B(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 mr(){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
|
+
|
|
1335
|
+
USAGE
|
|
1336
|
+
prismic slice add-field link <slice-id> <field-id> [flags]
|
|
1337
|
+
|
|
1338
|
+
ARGUMENTS
|
|
1339
|
+
slice-id Slice identifier (required)
|
|
1340
|
+
field-id Field identifier (required)
|
|
1341
|
+
|
|
1342
|
+
FLAGS
|
|
1343
|
+
-v, --variation string Target variation (default: first variation)
|
|
1344
|
+
-l, --label string Display label for the field
|
|
1345
|
+
-p, --placeholder string Placeholder text
|
|
1346
|
+
--allow-text Allow text with link
|
|
1347
|
+
--allow-target-blank Allow opening link in new tab
|
|
1348
|
+
--repeatable Allow multiple links
|
|
1349
|
+
-h, --help Show help for command
|
|
1350
|
+
|
|
1351
|
+
EXAMPLES
|
|
1352
|
+
prismic slice add-field link my_slice button
|
|
1353
|
+
prismic slice add-field link cta primary_link --allow-text
|
|
1354
|
+
prismic slice add-field link navigation links --repeatable
|
|
1355
|
+
prismic slice add-field link hero cta --allow-text --allow-target-blank`);return}if(!l){console.error(`Missing required argument: slice-id
|
|
1356
|
+
`),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 B(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 hr(){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
|
+
|
|
1359
|
+
USAGE
|
|
1360
|
+
prismic slice add-field number <slice-id> <field-id> [flags]
|
|
1361
|
+
|
|
1362
|
+
ARGUMENTS
|
|
1363
|
+
slice-id Slice identifier (required)
|
|
1364
|
+
field-id Field identifier (required)
|
|
1365
|
+
|
|
1366
|
+
FLAGS
|
|
1367
|
+
-v, --variation string Target variation (default: first variation)
|
|
1368
|
+
-l, --label string Display label for the field
|
|
1369
|
+
-p, --placeholder string Placeholder text
|
|
1370
|
+
-h, --help Show help for command
|
|
1371
|
+
|
|
1372
|
+
EXAMPLES
|
|
1373
|
+
prismic slice add-field number my_slice price
|
|
1374
|
+
prismic slice add-field number product quantity --label "Quantity"
|
|
1375
|
+
prismic slice add-field number stats count --variation "detailed"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1376
|
+
`),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 B(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 gr(){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
|
+
|
|
1379
|
+
USAGE
|
|
1380
|
+
prismic slice add-field rich-text <slice-id> <field-id> [flags]
|
|
1381
|
+
|
|
1382
|
+
ARGUMENTS
|
|
1383
|
+
slice-id Slice identifier (required)
|
|
1384
|
+
field-id Field identifier (required)
|
|
1385
|
+
|
|
1386
|
+
FLAGS
|
|
1387
|
+
-v, --variation string Target variation (default: first variation)
|
|
1388
|
+
-l, --label string Display label for the field
|
|
1389
|
+
-p, --placeholder string Placeholder text
|
|
1390
|
+
--single string Allowed block types for single-line (comma-separated)
|
|
1391
|
+
--multi string Allowed block types for multi-line (comma-separated)
|
|
1392
|
+
--allow-target-blank Allow opening links in new tab
|
|
1393
|
+
-h, --help Show help for command
|
|
1394
|
+
|
|
1395
|
+
BLOCK TYPES
|
|
1396
|
+
heading1, heading2, heading3, heading4, heading5, heading6,
|
|
1397
|
+
paragraph, strong, em, preformatted, hyperlink, image, embed,
|
|
1398
|
+
list-item, o-list-item, rtl
|
|
1399
|
+
|
|
1400
|
+
EXAMPLES
|
|
1401
|
+
prismic slice add-field rich-text my_slice body
|
|
1402
|
+
prismic slice add-field rich-text article content --multi "paragraph,heading2,heading3,strong,em,hyperlink"
|
|
1403
|
+
prismic slice add-field rich-text hero tagline --single "heading1"
|
|
1404
|
+
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
|
+
`),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 B(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 _r(){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
|
+
|
|
1408
|
+
USAGE
|
|
1409
|
+
prismic slice add-field select <slice-id> <field-id> [flags]
|
|
1410
|
+
|
|
1411
|
+
ARGUMENTS
|
|
1412
|
+
slice-id Slice identifier (required)
|
|
1413
|
+
field-id Field identifier (required)
|
|
1414
|
+
|
|
1415
|
+
FLAGS
|
|
1416
|
+
-v, --variation string Target variation (default: first variation)
|
|
1417
|
+
-l, --label string Display label for the field
|
|
1418
|
+
-p, --placeholder string Placeholder text
|
|
1419
|
+
--option string Add an option (can be used multiple times)
|
|
1420
|
+
--default string Default selected value
|
|
1421
|
+
-h, --help Show help for command
|
|
1422
|
+
|
|
1423
|
+
EXAMPLES
|
|
1424
|
+
prismic slice add-field select my_slice layout --option "full" --option "sidebar"
|
|
1425
|
+
prismic slice add-field select hero style --option "light" --option "dark" --default "light"
|
|
1426
|
+
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
|
+
`),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 B(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 vr(){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
|
+
|
|
1430
|
+
USAGE
|
|
1431
|
+
prismic slice add-field timestamp <slice-id> <field-id> [flags]
|
|
1432
|
+
|
|
1433
|
+
ARGUMENTS
|
|
1434
|
+
slice-id Slice identifier (required)
|
|
1435
|
+
field-id Field identifier (required)
|
|
1436
|
+
|
|
1437
|
+
FLAGS
|
|
1438
|
+
-v, --variation string Target variation (default: first variation)
|
|
1439
|
+
-l, --label string Display label for the field
|
|
1440
|
+
-p, --placeholder string Placeholder text
|
|
1441
|
+
-h, --help Show help for command
|
|
1442
|
+
|
|
1443
|
+
EXAMPLES
|
|
1444
|
+
prismic slice add-field timestamp my_slice created_at
|
|
1445
|
+
prismic slice add-field timestamp event start_time --label "Event Start"
|
|
1446
|
+
prismic slice add-field timestamp schedule meeting_time --variation "detailed"`);return}if(!a){console.error(`Missing required argument: slice-id
|
|
1447
|
+
`),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 B(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 yr(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await sr();break;case`color`:await cr();break;case`date`:await lr();break;case`embed`:await ur();break;case`geo-point`:await dr();break;case`image`:await fr();break;case`key-text`:await pr();break;case`link`:await mr();break;case`number`:await hr();break;case`rich-text`:await gr();break;case`select`:await _r();break;case`timestamp`:await vr();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
|
|
1449
|
+
|
|
1450
|
+
USAGE
|
|
1451
|
+
prismic slice add-field <field-type> <slice-id> <field-id> [flags]
|
|
1452
|
+
|
|
1453
|
+
FIELD TYPES
|
|
1454
|
+
boolean Boolean toggle
|
|
1455
|
+
color Color picker
|
|
1456
|
+
date Date picker
|
|
1457
|
+
embed Embed (oEmbed)
|
|
1458
|
+
geo-point Geographic coordinates
|
|
1459
|
+
image Image
|
|
1460
|
+
key-text Single-line text
|
|
1461
|
+
link Any link type
|
|
1462
|
+
number Number
|
|
1463
|
+
rich-text Rich text editor
|
|
1464
|
+
select Dropdown select
|
|
1465
|
+
timestamp Date and time
|
|
1466
|
+
|
|
1467
|
+
FLAGS
|
|
1468
|
+
-h, --help Show help for command
|
|
1469
|
+
|
|
1470
|
+
LEARN MORE
|
|
1471
|
+
Use \`prismic slice add-field <field-type> --help\` for more information.
|
|
1472
|
+
|
|
1473
|
+
EXAMPLES
|
|
1474
|
+
prismic slice add-field key-text my_slice title --label "Title"
|
|
1475
|
+
prismic slice add-field link my_slice cta --allow-text
|
|
1476
|
+
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 br(){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
|
+
|
|
1479
|
+
USAGE
|
|
1480
|
+
prismic slice add-variation <slice-id> <variation-id> [flags]
|
|
1481
|
+
|
|
1482
|
+
ARGUMENTS
|
|
1483
|
+
slice-id Slice identifier (required)
|
|
1484
|
+
variation-id New variation identifier (required)
|
|
1485
|
+
|
|
1486
|
+
FLAGS
|
|
1487
|
+
--name string Display name for the variation
|
|
1488
|
+
--copy-from string Copy fields from an existing variation
|
|
1489
|
+
-h, --help Show help for command
|
|
1490
|
+
|
|
1491
|
+
EXAMPLES
|
|
1492
|
+
prismic slice add-variation MySlice withImage
|
|
1493
|
+
prismic slice add-variation MySlice withImage --name "With Image"
|
|
1494
|
+
prismic slice add-variation MySlice withImage --copy-from default`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1495
|
+
`),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 B(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??H(a)}}else u={id:a,name:n??H(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 xr(){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
|
+
|
|
1498
|
+
USAGE
|
|
1499
|
+
prismic slice create <id> [flags]
|
|
1500
|
+
|
|
1501
|
+
ARGUMENTS
|
|
1502
|
+
id Slice identifier (required)
|
|
1503
|
+
|
|
1504
|
+
FLAGS
|
|
1505
|
+
-n, --name string Display name for the slice
|
|
1506
|
+
-h, --help Show help for command
|
|
1507
|
+
|
|
1508
|
+
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??Tr(i),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}}]},o=await Sr(),c=new URL(Tr(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 Sr(){let e=await wr(),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 Cr=T({dependencies:E(D(O(),O()))});async function wr(){let e=await L(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=ae(Cr,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function Tr(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Er(){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
|
+
|
|
1511
|
+
USAGE
|
|
1512
|
+
prismic slice list [flags]
|
|
1513
|
+
|
|
1514
|
+
FLAGS
|
|
1515
|
+
--json Output as JSON
|
|
1516
|
+
-h, --help Show help for command
|
|
1517
|
+
|
|
1518
|
+
EXAMPLES
|
|
1519
|
+
prismic slice list
|
|
1520
|
+
prismic slice list --json`);return}let a=await V(),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=A(Be,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 Dr(){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
|
+
|
|
1522
|
+
USAGE
|
|
1523
|
+
prismic slice list-variations <slice-id> [flags]
|
|
1524
|
+
|
|
1525
|
+
ARGUMENTS
|
|
1526
|
+
slice-id Slice identifier (required)
|
|
1527
|
+
|
|
1528
|
+
FLAGS
|
|
1529
|
+
--json Output as JSON
|
|
1530
|
+
-h, --help Show help for command
|
|
1531
|
+
|
|
1532
|
+
EXAMPLES
|
|
1533
|
+
prismic slice list-variations MySlice
|
|
1534
|
+
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 B(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 Or(){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
|
+
|
|
1537
|
+
USAGE
|
|
1538
|
+
prismic slice remove <slice-id> [flags]
|
|
1539
|
+
|
|
1540
|
+
ARGUMENTS
|
|
1541
|
+
slice-id Slice identifier (required)
|
|
1542
|
+
|
|
1543
|
+
FLAGS
|
|
1544
|
+
-y Confirm removal
|
|
1545
|
+
-h, --help Show help for command
|
|
1546
|
+
|
|
1547
|
+
EXAMPLES
|
|
1548
|
+
prismic slice remove MySlice
|
|
1549
|
+
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 B(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 kr(){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
|
+
|
|
1552
|
+
USAGE
|
|
1553
|
+
prismic slice remove-field <slice-id> <field-id> [flags]
|
|
1554
|
+
|
|
1555
|
+
ARGUMENTS
|
|
1556
|
+
slice-id Slice identifier (required)
|
|
1557
|
+
field-id Field identifier (required)
|
|
1558
|
+
|
|
1559
|
+
FLAGS
|
|
1560
|
+
--variation string Target variation (default: "default")
|
|
1561
|
+
--zone string Field zone: "primary" or "items" (default: "primary")
|
|
1562
|
+
-h, --help Show help for command
|
|
1563
|
+
|
|
1564
|
+
EXAMPLES
|
|
1565
|
+
prismic slice remove-field MySlice title
|
|
1566
|
+
prismic slice remove-field MySlice title --variation withImage
|
|
1567
|
+
prismic slice remove-field MySlice item_title --zone items`);return}if(!i){console.error(`Missing required argument: slice-id
|
|
1568
|
+
`),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 B(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 Ar(){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
|
+
|
|
1571
|
+
USAGE
|
|
1572
|
+
prismic slice remove-variation <slice-id> <variation-id> [flags]
|
|
1573
|
+
|
|
1574
|
+
ARGUMENTS
|
|
1575
|
+
slice-id Slice identifier (required)
|
|
1576
|
+
variation-id Variation to remove (required)
|
|
1577
|
+
|
|
1578
|
+
FLAGS
|
|
1579
|
+
-h, --help Show help for command
|
|
1580
|
+
|
|
1581
|
+
EXAMPLES
|
|
1582
|
+
prismic slice remove-variation MySlice withImage`);return}if(!n){console.error(`Missing required argument: slice-id
|
|
1583
|
+
`),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 B(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 jr(){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
|
+
|
|
1586
|
+
USAGE
|
|
1587
|
+
prismic slice rename <slice-id> <new-name> [flags]
|
|
1588
|
+
|
|
1589
|
+
ARGUMENTS
|
|
1590
|
+
slice-id Current slice identifier (required)
|
|
1591
|
+
new-name New display name (required)
|
|
1592
|
+
|
|
1593
|
+
FLAGS
|
|
1594
|
+
--id string Also change the slice ID (renames directory)
|
|
1595
|
+
-h, --help Show help for command
|
|
1596
|
+
|
|
1597
|
+
EXAMPLES
|
|
1598
|
+
prismic slice rename MySlice "My New Name"
|
|
1599
|
+
prismic slice rename MySlice "My New Name" --id NewSliceId`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1600
|
+
`),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 B(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 V(),t=new URL(`.`,l),o=new URL(H(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 Mr(){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
|
+
|
|
1603
|
+
USAGE
|
|
1604
|
+
prismic slice view <slice-id> [flags]
|
|
1605
|
+
|
|
1606
|
+
ARGUMENTS
|
|
1607
|
+
slice-id Slice identifier (required)
|
|
1608
|
+
|
|
1609
|
+
FLAGS
|
|
1610
|
+
--json Output as JSON
|
|
1611
|
+
-h, --help Show help for command
|
|
1612
|
+
|
|
1613
|
+
EXAMPLES
|
|
1614
|
+
prismic slice view MySlice
|
|
1615
|
+
prismic slice view MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
|
|
1616
|
+
`),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await B(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 Nr(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await xr();break;case`list`:await Er();break;case`view`:await Mr();break;case`rename`:await jr();break;case`remove`:await Or();break;case`add-field`:await yr();break;case`remove-field`:await kr();break;case`add-variation`:await br();break;case`remove-variation`:await Ar();break;case`list-variations`:await Dr();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
|
|
1618
|
+
|
|
1619
|
+
USAGE
|
|
1620
|
+
prismic slice <command> [flags]
|
|
1621
|
+
|
|
1622
|
+
COMMANDS
|
|
1623
|
+
create Create a new slice
|
|
1624
|
+
list List all slices
|
|
1625
|
+
view View details of a slice
|
|
1626
|
+
rename Rename a slice
|
|
1627
|
+
remove Remove a slice
|
|
1628
|
+
add-field Add a field to a slice
|
|
1629
|
+
remove-field Remove a field from a slice
|
|
1630
|
+
add-variation Add a variation to a slice
|
|
1631
|
+
remove-variation Remove a variation from a slice
|
|
1632
|
+
list-variations List all variations of a slice
|
|
1633
|
+
|
|
1634
|
+
FLAGS
|
|
1635
|
+
-h, --help Show help for command
|
|
1636
|
+
|
|
1637
|
+
LEARN MORE
|
|
1638
|
+
Use \`prismic slice <command> --help\` for more information about a command.`)}}const Pr=T({id:O(),label:E(O()),repeatable:S(),status:S(),format:E(O()),json:D(O(),k())});async function Fr(){let{values:{help:t,repo:r=await U(),"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(`Sync custom types and slices from Prismic to local files.
|
|
1639
|
+
|
|
1640
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1641
|
+
project root.
|
|
1642
|
+
|
|
1643
|
+
USAGE
|
|
1644
|
+
prismic sync [flags]
|
|
1645
|
+
|
|
1646
|
+
FLAGS
|
|
1647
|
+
-r, --repo string Repository domain
|
|
1648
|
+
--dry-run Show what would be synced without writing files
|
|
1649
|
+
--types-only Only sync custom types
|
|
1650
|
+
--slices-only Only sync slices
|
|
1651
|
+
--json Output as JSON
|
|
1652
|
+
-h, --help Show help for command
|
|
1653
|
+
|
|
1654
|
+
EXAMPLES
|
|
1655
|
+
prismic sync
|
|
1656
|
+
prismic sync --repo my-repo
|
|
1657
|
+
prismic sync --dry-run
|
|
1658
|
+
prismic sync --types-only`);return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}c||console.info(`Syncing from repository: ${r}\n`);let l=!o,u=!a,[d,f]=await Promise.all([l?Lr(r):Promise.resolve({ok:!0,value:[]}),u?Rr(r):Promise.resolve({ok:!0,value:[]})]);if(!d.ok){console.error(`Failed to fetch custom types: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch slices: ${f.error}`),process.exitCode=1;return}let p=d.value,m=f.value;if(c||(l&&console.info(`Fetching custom types... ${p.length} types`),u&&console.info(`Fetching slices... ${m.length} slices`)),i){if(c)console.info(z({customTypes:p,slices:m}));else{if(console.info(``),l&&p.length>0){console.info(`Would write custom types:`);for(let e of p)console.info(` customtypes/${e.id}/index.json`)}if(u&&m.length>0){let e=zr(await V());console.info(`Would write slices:`);for(let t of m)console.info(` ${e}${H(t.name)}/model.json`)}console.info(`\nDry run complete: ${p.length} custom types, ${m.length} slices`)}return}let h=await L(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`.`,h),_=[],v=[];if(l&&p.length>0){c||console.info(`
|
|
1659
|
+
Writing custom types:`);let e=new URL(`customtypes/`,g);for(let t of p){let r=new URL(`${t.id}/`,e),i=new URL(`index.json`,r);try{await n(r,{recursive:!0}),await s(i,z(t));let e=`customtypes/${t.id}/index.json`;_.push(e),c||console.info(` ${e}`)}catch(e){console.error(`Failed to write custom type ${t.id}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(u&&m.length>0){c||console.info(`
|
|
1660
|
+
Writing slices:`);let e=await V();for(let t of m){let r=new URL(`${H(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await s(i,z(t));let a=`${zr(e)}${H(t.name)}/model.json`;v.push(a),c||console.info(` ${a}`)}catch(e){console.error(`Failed to write slice ${t.name}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}c?console.info(z({writtenTypes:_,writtenSlices:v})):console.info(`\nSync complete: ${_.length} custom types, ${v.length} slices`)}async function Ir(){let e=await P();return e.hostname=`customtypes.${e.hostname}`,e}async function Lr(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Ir(),r=new URL(`customtypes`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=A(x(Pr),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Rr(e){let t=await N();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Ir(),r=new URL(`slices`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=A(x(Be),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}function zr(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}async function Br(){let{values:{help:t,repo:n=await U(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all API tokens for a Prismic repository.
|
|
1661
|
+
|
|
1662
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1663
|
+
project root.
|
|
1664
|
+
|
|
1665
|
+
USAGE
|
|
1666
|
+
prismic token list [flags]
|
|
1667
|
+
|
|
1668
|
+
FLAGS
|
|
1669
|
+
--json Output as JSON
|
|
1670
|
+
-r, --repo string Repository domain
|
|
1671
|
+
-h, --help Show help for command
|
|
1672
|
+
|
|
1673
|
+
LEARN MORE
|
|
1674
|
+
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Xr();return}let[i,a]=await Promise.all([J(n),qr(n)]);if(!i.ok){i.error instanceof K||i.error instanceof q?Xr():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 K||a.error instanceof q?Xr():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=Jr(e.token),n=Yr(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=Jr(e.token),n=Yr(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const Vr=T({$date:w()}),Hr=T({id:O(),origin:O(),domain:O(),app:O(),scope:O(),expired_at:Vr,created_at:Vr,owner:C(O()),token:O()}),Ur=T({id:O(),secret:O(),name:O(),owner:O(),created_at:Vr,authorized_domains:x(O()),wroom_auths:x(Hr)}),Wr=T({app_name:O(),token:O(),timestamp:w()}),Gr=T({max_tokens:w(),tokens:x(Wr)}),Kr=x(Ur);async function J(e){return await G(new URL(`settings/security/contentapi`,await F(e)),{schema:Kr})}async function qr(e){return await G(new URL(`settings/security/customtypesapi`,await F(e)),{schema:Gr})}function Jr(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function Yr(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function Xr(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Zr(){let{values:{help:t,repo:n=await U(),json:r,write:i,name:a=`Prismic CLI`,"allow-releases":o}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`},write:{type:`boolean`,short:`w`},name:{type:`string`,short:`n`},"allow-releases":{type:`boolean`}},allowPositionals:!1});if(t){console.info(`Create a new API token for a Prismic repository.
|
|
1675
|
+
|
|
1676
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1677
|
+
project root.
|
|
1678
|
+
|
|
1679
|
+
USAGE
|
|
1680
|
+
prismic token create [flags]
|
|
1681
|
+
|
|
1682
|
+
FLAGS
|
|
1683
|
+
-w, --write Create a write token (Custom Types/Migration API)
|
|
1684
|
+
-n, --name string Token name (default: "Prismic CLI")
|
|
1685
|
+
--allow-releases Allow access to releases (access tokens only)
|
|
1686
|
+
--json Output as JSON
|
|
1687
|
+
-r, --repo string Repository domain
|
|
1688
|
+
-h, --help Show help for command
|
|
1689
|
+
|
|
1690
|
+
LEARN MORE
|
|
1691
|
+
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(i&&o){console.error(`--allow-releases is only valid for access tokens (not with --write)`),process.exitCode=1;return}if(!await M()){ei();return}if(i){let e=await Qr(n,a);if(!e.ok){e.error instanceof K||e.error instanceof q?ei():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 $r(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof K||e.error instanceof q?ei():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 Qr(e,t){return await G(new URL(`settings/security/token`,await F(e)),{method:`POST`,body:{app_name:t},schema:Wr})}async function $r(e,t,n){let r=await J(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await G(new URL(`settings/security/oauthapp`,await F(e)),{method:`POST`,body:{app_name:t},schema:Ur});if(!n.ok)return n;i=n.value}return await G(new URL(`settings/security/authorizations`,await F(e)),{method:`POST`,body:{app:i.id,scope:n},schema:Hr})}function ei(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ti(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a token from a Prismic repository.
|
|
1692
|
+
|
|
1693
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1694
|
+
project root.
|
|
1695
|
+
|
|
1696
|
+
USAGE
|
|
1697
|
+
prismic token delete <token> [flags]
|
|
1698
|
+
|
|
1699
|
+
ARGUMENTS
|
|
1700
|
+
token The token value (or partial match)
|
|
1701
|
+
|
|
1702
|
+
FLAGS
|
|
1703
|
+
-r, --repo string Repository domain
|
|
1704
|
+
-h, --help Show help for command
|
|
1705
|
+
|
|
1706
|
+
LEARN MORE
|
|
1707
|
+
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Y();return}let[i,a]=await Promise.all([J(n),qr(n)]);if(!i.ok){i.error instanceof K||i.error instanceof q?Y():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 K||a.error instanceof q?Y():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 G(new URL(`settings/security/authorizations/${o.id}`,await F(n)),{method:`DELETE`});if(!e.ok){e.error instanceof K||e.error instanceof q?Y():(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 G(new URL(`settings/security/token/${s.token}`,await F(n)),{method:`DELETE`});if(!e.ok){e.error instanceof K||e.error instanceof q?Y():(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 Y(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ni(){let{values:{help:t,repo:n=await U()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the name of a token in a Prismic repository.
|
|
1708
|
+
|
|
1709
|
+
Note: Only access tokens can be renamed. Write tokens cannot be renamed without
|
|
1710
|
+
changing the token value.
|
|
1711
|
+
|
|
1712
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1713
|
+
project root.
|
|
1714
|
+
|
|
1715
|
+
USAGE
|
|
1716
|
+
prismic token set-name <token> <name> [flags]
|
|
1717
|
+
|
|
1718
|
+
ARGUMENTS
|
|
1719
|
+
token The token value (or partial match)
|
|
1720
|
+
name New name for the token
|
|
1721
|
+
|
|
1722
|
+
FLAGS
|
|
1723
|
+
-r, --repo string Repository domain
|
|
1724
|
+
-h, --help Show help for command
|
|
1725
|
+
|
|
1726
|
+
LEARN MORE
|
|
1727
|
+
Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: name`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){X();return}let[a,o]=await Promise.all([J(n),qr(n)]);if(!a.ok){a.error instanceof K||a.error instanceof q?X():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 K||o.error instanceof q?X():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 G(new URL(`settings/security/oauthapp/${s.id}`,await F(n)),{method:`POST`,body:{name:i},schema:Ur});if(!e.ok){e.error instanceof K||e.error instanceof q?X():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 X(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ri(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Br();break;case`create`:await Zr();break;case`set-name`:await ni();break;case`delete`:await ti();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
|
|
1728
|
+
|
|
1729
|
+
USAGE
|
|
1730
|
+
prismic token <command> [flags]
|
|
1731
|
+
|
|
1732
|
+
COMMANDS
|
|
1733
|
+
list List all tokens
|
|
1734
|
+
create Create a new token
|
|
1735
|
+
set-name Set token name (access tokens only)
|
|
1736
|
+
delete Delete a token
|
|
1737
|
+
|
|
1738
|
+
FLAGS
|
|
1739
|
+
-h, --help Show help for command
|
|
1740
|
+
|
|
1741
|
+
LEARN MORE
|
|
1742
|
+
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 ii(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a webhook in a Prismic repository.
|
|
1743
|
+
|
|
1744
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1745
|
+
project root.
|
|
1746
|
+
|
|
1747
|
+
USAGE
|
|
1748
|
+
prismic webhook view <url> [flags]
|
|
1749
|
+
|
|
1750
|
+
ARGUMENTS
|
|
1751
|
+
<url> Webhook URL
|
|
1752
|
+
|
|
1753
|
+
FLAGS
|
|
1754
|
+
-r, --repo string Repository domain
|
|
1755
|
+
-h, --help Show help for command
|
|
1756
|
+
|
|
1757
|
+
LEARN MORE
|
|
1758
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ai();return}let i=await Q(n);if(!i.ok){i.error instanceof K?ai():(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 ai(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const oi=T({config:T({_id:O(),url:O(),active:S(),name:C(O()),secret:C(O()),headers:D(O(),O()),documentsPublished:S(),documentsUnpublished:S(),releasesCreated:S(),releasesUpdated:S(),tagsCreated:S(),tagsDeleted:S()})});async function Q(e){return await G(new URL(`/app/settings/webhooks`,await F(e)),{schema:x(oi)})}async function si(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Enable a webhook in a Prismic repository.
|
|
1759
|
+
|
|
1760
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1761
|
+
project root.
|
|
1762
|
+
|
|
1763
|
+
USAGE
|
|
1764
|
+
prismic webhook enable <url> [flags]
|
|
1765
|
+
|
|
1766
|
+
ARGUMENTS
|
|
1767
|
+
<url> Webhook URL
|
|
1768
|
+
|
|
1769
|
+
FLAGS
|
|
1770
|
+
-r, --repo string Repository domain
|
|
1771
|
+
-h, --help Show help for command
|
|
1772
|
+
|
|
1773
|
+
LEARN MORE
|
|
1774
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ci();return}let i=await Q(n);if(!i.ok){i.error instanceof K?ci():(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 K?ci():(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 G(r,{method:`POST`,body:i})}function ci(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function li(){let{values:{help:t,repo:n=await U()},positionals:[r,i,a]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a custom HTTP header to a webhook.
|
|
1775
|
+
|
|
1776
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1777
|
+
project root.
|
|
1778
|
+
|
|
1779
|
+
USAGE
|
|
1780
|
+
prismic webhook add-header <url> <key> <value> [flags]
|
|
1781
|
+
|
|
1782
|
+
ARGUMENTS
|
|
1783
|
+
<url> Webhook URL
|
|
1784
|
+
<key> Header name
|
|
1785
|
+
<value> Header value
|
|
1786
|
+
|
|
1787
|
+
FLAGS
|
|
1788
|
+
-r, --repo string Repository domain
|
|
1789
|
+
-h, --help Show help for command
|
|
1790
|
+
|
|
1791
|
+
LEARN MORE
|
|
1792
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: <value>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ui();return}let o=await Q(n);if(!o.ok){o.error instanceof K?ui():(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 K?ui():(console.error(`Failed to add header: ${z(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function ui(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const di=Object.values(Z);async function fi(){let{values:{help:t,repo:n=await U(),name:r,secret:i,trigger:a=[]},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},secret:{type:`string`,short:`s`},trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new webhook in a Prismic repository.
|
|
1793
|
+
|
|
1794
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1795
|
+
project root.
|
|
1796
|
+
|
|
1797
|
+
USAGE
|
|
1798
|
+
prismic webhook create <url> [flags]
|
|
1799
|
+
|
|
1800
|
+
ARGUMENTS
|
|
1801
|
+
<url> Webhook URL to receive events
|
|
1802
|
+
|
|
1803
|
+
FLAGS
|
|
1804
|
+
-n, --name string Webhook name
|
|
1805
|
+
-s, --secret string Secret for webhook signature
|
|
1806
|
+
-t, --trigger string Trigger events (can be repeated)
|
|
1807
|
+
-r, --repo string Repository domain
|
|
1808
|
+
-h, --help Show help for command
|
|
1809
|
+
|
|
1810
|
+
TRIGGERS
|
|
1811
|
+
document.published When documents are published
|
|
1812
|
+
document.unpublished When documents are unpublished
|
|
1813
|
+
release.created When a release is created
|
|
1814
|
+
release.updated When a release is edited or deleted
|
|
1815
|
+
tag.created When a tag is created
|
|
1816
|
+
tag.deleted When a tag is deleted
|
|
1817
|
+
|
|
1818
|
+
If no triggers specified, all are enabled.
|
|
1819
|
+
|
|
1820
|
+
LEARN MORE
|
|
1821
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}for(let e of a)if(!di.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${di.join(`, `)}`),process.exitCode=1;return}if(!await M()){mi();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 pi(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof K?mi():(console.error(`Failed to create webhook: ${z(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function pi(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 G(n,{method:`POST`,body:r})}function mi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function hi(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disable a webhook in a Prismic repository.
|
|
1822
|
+
|
|
1823
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1824
|
+
project root.
|
|
1825
|
+
|
|
1826
|
+
USAGE
|
|
1827
|
+
prismic webhook disable <url> [flags]
|
|
1828
|
+
|
|
1829
|
+
ARGUMENTS
|
|
1830
|
+
<url> Webhook URL
|
|
1831
|
+
|
|
1832
|
+
FLAGS
|
|
1833
|
+
-r, --repo string Repository domain
|
|
1834
|
+
-h, --help Show help for command
|
|
1835
|
+
|
|
1836
|
+
LEARN MORE
|
|
1837
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){gi();return}let i=await Q(n);if(!i.ok){i.error instanceof K?gi():(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 K?gi():(console.error(`Failed to disable webhook: ${z(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function gi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function _i(){let{values:{help:t,repo:n=await U(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all webhooks in a Prismic repository.
|
|
1838
|
+
|
|
1839
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1840
|
+
project root.
|
|
1841
|
+
|
|
1842
|
+
USAGE
|
|
1843
|
+
prismic webhook list [flags]
|
|
1844
|
+
|
|
1845
|
+
FLAGS
|
|
1846
|
+
--json Output as JSON
|
|
1847
|
+
-r, --repo string Repository domain
|
|
1848
|
+
-h, --help Show help for command
|
|
1849
|
+
|
|
1850
|
+
LEARN MORE
|
|
1851
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){vi();return}let i=await Q(n);if(!i.ok){i.error instanceof K?vi():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 vi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function yi(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a webhook from a Prismic repository.
|
|
1852
|
+
|
|
1853
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1854
|
+
project root.
|
|
1855
|
+
|
|
1856
|
+
USAGE
|
|
1857
|
+
prismic webhook remove <url> [flags]
|
|
1858
|
+
|
|
1859
|
+
ARGUMENTS
|
|
1860
|
+
<url> Webhook URL
|
|
1861
|
+
|
|
1862
|
+
FLAGS
|
|
1863
|
+
-r, --repo string Repository domain
|
|
1864
|
+
-h, --help Show help for command
|
|
1865
|
+
|
|
1866
|
+
LEARN MORE
|
|
1867
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){xi();return}let i=await Q(n);if(!i.ok){i.error instanceof K?xi():(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 bi(n,a.config._id);if(!o.ok){o.error instanceof K?xi():(console.error(`Failed to remove webhook: ${z(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function bi(e,t){return await G(new URL(`/app/settings/webhooks/${t}/delete`,await F(e)),{method:`POST`})}function xi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Si(){let{values:{help:t,repo:n=await U()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom HTTP header from a webhook.
|
|
1868
|
+
|
|
1869
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1870
|
+
project root.
|
|
1871
|
+
|
|
1872
|
+
USAGE
|
|
1873
|
+
prismic webhook remove-header <url> <key> [flags]
|
|
1874
|
+
|
|
1875
|
+
ARGUMENTS
|
|
1876
|
+
<url> Webhook URL
|
|
1877
|
+
<key> Header name
|
|
1878
|
+
|
|
1879
|
+
FLAGS
|
|
1880
|
+
-r, --repo string Repository domain
|
|
1881
|
+
-h, --help Show help for command
|
|
1882
|
+
|
|
1883
|
+
LEARN MORE
|
|
1884
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Ci();return}let a=await Q(n);if(!a.ok){a.error instanceof K?Ci():(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 K?Ci():(console.error(`Failed to remove header: ${z(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function Ci(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const wi=Object.values(Z);async function Ti(){let{values:{help:t,repo:n=await U(),trigger:r},positionals:[i]}=e({args:process.argv.slice(4),options:{trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update which events trigger a webhook.
|
|
1885
|
+
|
|
1886
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1887
|
+
project root.
|
|
1888
|
+
|
|
1889
|
+
USAGE
|
|
1890
|
+
prismic webhook set-triggers <url> [flags]
|
|
1891
|
+
|
|
1892
|
+
ARGUMENTS
|
|
1893
|
+
<url> Webhook URL
|
|
1894
|
+
|
|
1895
|
+
FLAGS
|
|
1896
|
+
-t, --trigger string Trigger events (can be repeated, at least one required)
|
|
1897
|
+
-r, --repo string Repository domain
|
|
1898
|
+
-h, --help Show help for command
|
|
1899
|
+
|
|
1900
|
+
TRIGGERS
|
|
1901
|
+
document.published When documents are published
|
|
1902
|
+
document.unpublished When documents are unpublished
|
|
1903
|
+
release.created When a release is created
|
|
1904
|
+
release.updated When a release is edited or deleted
|
|
1905
|
+
tag.created When a tag is created
|
|
1906
|
+
tag.deleted When a tag is deleted
|
|
1907
|
+
|
|
1908
|
+
LEARN MORE
|
|
1909
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!r||r.length===0){console.error(`Missing required option: --trigger`),process.exitCode=1;return}for(let e of r)if(!wi.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${wi.join(`, `)}`),process.exitCode=1;return}if(!await M()){Ei();return}let a=await Q(n);if(!a.ok){a.error instanceof K?Ei():(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 K?Ei():(console.error(`Failed to update webhook triggers: ${z(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function Ei(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Di(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Show the enabled/disabled status of a webhook.
|
|
1910
|
+
|
|
1911
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1912
|
+
project root.
|
|
1913
|
+
|
|
1914
|
+
USAGE
|
|
1915
|
+
prismic webhook status <url> [flags]
|
|
1916
|
+
|
|
1917
|
+
ARGUMENTS
|
|
1918
|
+
<url> Webhook URL
|
|
1919
|
+
|
|
1920
|
+
FLAGS
|
|
1921
|
+
-r, --repo string Repository domain
|
|
1922
|
+
-h, --help Show help for command
|
|
1923
|
+
|
|
1924
|
+
LEARN MORE
|
|
1925
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){Oi();return}let i=await Q(n);if(!i.ok){i.error instanceof K?Oi():(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 Oi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ki(){let{values:{help:t,repo:n=await U()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Trigger a test webhook in a Prismic repository.
|
|
1926
|
+
|
|
1927
|
+
By default, this command reads the repository from prismic.config.json at the
|
|
1928
|
+
project root.
|
|
1929
|
+
|
|
1930
|
+
USAGE
|
|
1931
|
+
prismic webhook test <url> [flags]
|
|
1932
|
+
|
|
1933
|
+
ARGUMENTS
|
|
1934
|
+
<url> Webhook URL
|
|
1935
|
+
|
|
1936
|
+
FLAGS
|
|
1937
|
+
-r, --repo string Repository domain
|
|
1938
|
+
-h, --help Show help for command
|
|
1939
|
+
|
|
1940
|
+
LEARN MORE
|
|
1941
|
+
Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await M()){ji();return}let i=await Q(n);if(!i.ok){i.error instanceof K?ji():(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 Ai(n,a.config._id);if(!o.ok){o.error instanceof K?ji():(console.error(`Failed to test webhook: ${z(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function Ai(e,t){return await G(new URL(`/app/settings/webhooks/${t}/trigger`,await F(e)),{method:`POST`})}function ji(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Mi(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await _i();break;case`create`:await fi();break;case`view`:await ii();break;case`remove`:await yi();break;case`test`:await ki();break;case`enable`:await si();break;case`disable`:await hi();break;case`status`:await Di();break;case`add-header`:await li();break;case`remove-header`:await Si();break;case`set-triggers`:await Ti();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
|
|
1942
|
+
|
|
1943
|
+
USAGE
|
|
1944
|
+
prismic webhook <command> [flags]
|
|
1945
|
+
|
|
1946
|
+
COMMANDS
|
|
1947
|
+
list List all webhooks
|
|
1948
|
+
create Create a new webhook
|
|
1949
|
+
view View webhook details
|
|
1950
|
+
remove Delete a webhook
|
|
1951
|
+
test Trigger a test webhook
|
|
1952
|
+
enable Enable a webhook
|
|
1953
|
+
disable Disable a webhook
|
|
1954
|
+
status Show webhook enabled/disabled status
|
|
1955
|
+
add-header Add a custom HTTP header
|
|
1956
|
+
remove-header Remove a custom HTTP header
|
|
1957
|
+
set-triggers Update webhook triggers
|
|
1958
|
+
|
|
1959
|
+
FLAGS
|
|
1960
|
+
-h, --help Show help for command
|
|
1961
|
+
|
|
1962
|
+
LEARN MORE
|
|
1963
|
+
Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function Ni(){let{values:{help:t}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t){console.info(`Show the currently logged in user.
|
|
1964
|
+
|
|
1965
|
+
USAGE
|
|
1966
|
+
prismic whoami [flags]
|
|
1967
|
+
|
|
1968
|
+
FLAGS
|
|
1969
|
+
-h, --help Show help for command
|
|
1970
|
+
|
|
1971
|
+
LEARN MORE
|
|
1972
|
+
Use \`prismic <command> --help\` for more information about a command.`);return}if(!await M()){Fi();return}let n=await Pi();if(!n.ok){n.error instanceof K?Fi():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function Pi(){return await G(new URL(`profile`,await fe()),{schema:T({email:O()})})}function Fi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:Ii}=e({options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(Ii[0]){case`init`:await ht();break;case`login`:await Mt();break;case`logout`:await Ft();break;case`whoami`:await Ni();break;case`repo`:await or();break;case`locale`:await jt();break;case`page-type`:await On();break;case`custom-type`:await at();break;case`slice`:await Nr();break;case`sync`:await Fr();break;case`preview`:await Un();break;case`token`:await ri();break;case`webhook`:await Mi();break;default:Ii[0]&&(console.error(`Unknown command: ${Ii[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
|
|
1973
|
+
|
|
1974
|
+
USAGE
|
|
1975
|
+
prismic <command> [flags]
|
|
1976
|
+
|
|
1977
|
+
COMMANDS
|
|
1978
|
+
init Initialize a Prismic project
|
|
1979
|
+
login Log in to Prismic
|
|
1980
|
+
logout Log out of Prismic
|
|
1981
|
+
whoami Show the currently logged in user
|
|
1982
|
+
repo Manage Prismic repositories
|
|
1983
|
+
locale Manage locales in a repository
|
|
1984
|
+
page-type Manage page types in a repository
|
|
1985
|
+
custom-type Manage custom types in a repository
|
|
1986
|
+
slice Manage slices in a project
|
|
1987
|
+
sync Sync types and slices from Prismic
|
|
1988
|
+
preview Manage preview configurations
|
|
1989
|
+
token Manage API tokens in a repository
|
|
1990
|
+
webhook Manage webhooks in a repository
|
|
1991
|
+
|
|
1992
|
+
FLAGS
|
|
1993
|
+
-h, --help Show help for command
|
|
1994
|
+
|
|
1995
|
+
LEARN MORE
|
|
1996
|
+
Use \`prismic <command> --help\` for more information about a command.`)}export{};
|