@caiquecamargo/vite-plugin-netlify-cms 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/config.yml +65 -5
- package/dist/index.es.js +2 -2
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/package.json +5 -6
package/dist/index.umd.js
CHANGED
|
@@ -131,5 +131,5 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
|
|
|
131
131
|
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
132
132
|
`,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){const n="end"in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){const i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const n=!this.onKeyLine&&this.indent===e.indent&&t.sep;let i=[];if(n&&t.sep&&!t.value){const r=[];for(let o=0;o<t.sep.length;++o){const l=t.sep[o];switch(l.type){case"newline":r.push(o);break;case"space":break;case"comment":l.indent>e.indent&&(r.length=0);break;default:r.length=0}}r.length>=2&&(i=t.sep.splice(r[1]))}switch(this.type){case"anchor":case"tag":n||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!K(t.start,"explicit-key-ind")?t.start.push(this.sourceToken):n||t.value?(i.push(this.sourceToken),e.items.push({start:i})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]}),this.onKeyLine=!0;return;case"map-value-ind":if(K(t.start,"explicit-key-ind"))if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(K(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Is(t.key)&&!K(t.sep,"newline")){const r=pe(t.start),o=t.key,l=t.sep;l.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:o,sep:l}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else if(K(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const r=pe(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||n?e.items.push({start:i,key:null,sep:[this.sourceToken]}):K(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const r=this.flowScalar(this.type);n||t.value?(e.items.push({start:i,key:r,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(r):(Object.assign(t,{key:r,sep:[]}),this.onKeyLine=!0);return}default:{const r=this.startBlockValue(e);if(r){n&&r.type!=="block-seq"&&K(t.start,"explicit-key-ind")&&e.items.push({start:i}),this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){const n="end"in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){const i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||K(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){const n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n&&n.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const i=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:i,sep:[]}):t.sep?this.stack.push(i):Object.assign(t,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}const n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{const n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){const i=Ze(n),r=pe(i);Ts(e);const o=e.end.splice(1,e.end.length);o.push(this.sourceToken);const l={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=l}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
|
133
133
|
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
134
|
-
`,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const t=Ze(e),n=pe(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n}]}}case"map-value-ind":{this.onKeyLine=!0;const t=Ze(e),n=pe(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function Ls(s){const e=s.prettyErrors!==!1;return{lineCounter:s.lineCounter||e&&new As||null,prettyErrors:e}}function Rn(s,e={}){const{lineCounter:t,prettyErrors:n}=Ls(e),i=new It(t?.addNewLine),r=new kt(e),o=Array.from(r.compose(i.parse(s)));if(n&&t)for(const l of o)l.errors.forEach(Ge(s,t)),l.warnings.forEach(Ge(s,t));return o.length>0?o:Object.assign([],{empty:!0},r.streamInfo())}function $s(s,e={}){const{lineCounter:t,prettyErrors:n}=Ls(e),i=new It(t?.addNewLine),r=new kt(e);let o=null;for(const l of r.compose(i.parse(s),!0,s.length))if(!o)o=l;else if(o.options.logLevel!=="silent"){o.errors.push(new Z(l.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&t&&(o.errors.forEach(Ge(s,t)),o.warnings.forEach(Ge(s,t))),o}function Wn(s,e,t){let n;typeof e=="function"?n=e:t===void 0&&e&&typeof e=="object"&&(t=e);const i=$s(s,t);if(!i)return null;if(i.warnings.forEach(r=>qt(i.options.logLevel,r)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:n},t))}function Vn(s,e,t){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:t===void 0&&e&&(t=e),typeof t=="string"&&(t=t.length),typeof t=="number"){const i=Math.round(t);t=i<1?void 0:i>8?{indent:8}:{indent:i}}if(s===void 0){const{keepUndefined:i}=t??e??{};if(!i)return}return new ue(s,n,t).toString(t)}const Jn=Object.freeze(Object.defineProperty({__proto__:null,Alias:$e,CST:Fn,Composer:kt,Document:ue,Lexer:Os,LineCounter:As,Pair:C,Parser:It,Scalar:N,Schema:Ye,YAMLError:gt,YAMLMap:j,YAMLParseError:Z,YAMLSeq:x,YAMLWarning:cs,isAlias:Q,isCollection:L,isDocument:ge,isMap:H,isNode:$,isPair:I,isScalar:E,isSeq:ne,parse:Wn,parseAllDocuments:Rn,parseDocument:$s,stringify:Vn,visit:Y,visitAsync:Le},Symbol.toStringTag,{value:"Module"})),Yn=s=>s,Gn=s=>s,Qn=s=>s,Hn=s=>s,Xn=s=>({widget:"boolean",...s}),zn=s=>({widget:"code",...s}),xn=s=>({widget:"color",...s}),Zn=s=>({widget:"datetime",...s}),ei=s=>({widget:"hidden",...s}),ti=s=>({widget:"file",...s}),si=s=>({widget:"image",...s}),ni=s=>({widget:"list",...s}),ii=s=>({widget:"map",...s}),ri=s=>({widget:"number",...s}),oi=s=>({widget:"object",...s}),li=s=>({widget:"relation",...s}),ai=s=>({widget:"select",...s}),ci=s=>({widget:"string",...s}),fi=s=>({widget:"text",...s}),ui=s=>({widget:"markdown",...s}),hi=async s=>{try{await V.readdir(s)}catch{await V.mkdir(s,{recursive:!0})}},di=async(s,e)=>{await V.writeFile(e,s)},pi=s=>{const e=s.startsWith(".")?s.slice(2):s;return e?["ts","js","cjs","mjs"].some(t=>e.includes(t))?e.split(".").slice(0,-1).join("."):e:s},Cs=async(s,e)=>{try{const t=await V.readdir(s),n=pi(e);if(n.includes("/")){const[o,l]=n.split("/");return await Cs(Te.join(s,o),l)}const i=t.find(o=>o.startsWith(n));if(!i)throw new Error("Config file not found");const{config:r}=await _s.loadConfigFromFile({command:"build",mode:""},Te.join(s,i))??{};if(!r)throw new Error("Config file not found");return r}catch{throw new Error("Config file not found")}},Tt=async(s,e)=>{const{configFile:t="./netlify.config.ts",config:n,saveFolder:i="./public/admin"}=e??{},r=n??await Cs(s,t);await hi(Te.join(s,i));const o=Jn.stringify(r);await di(o,Te.join(s,i,"config.yml"))};async function mi(s){let e="";return{name:"vite-plugin-netlify-cms",configResolved:t=>{e=t.root},buildStart:async()=>{await Tt(e,s)},handleHotUpdate:async({file:t})=>{t.endsWith("netlify.config.ts")&&await Tt(e,s)}}}A.createConfig=Tt,A.default=mi,A.defineBooleanWidget=Xn,A.defineCodeWidget=zn,A.defineColorWidget=xn,A.defineConfig=Yn,A.defineDateTimeWidget=Zn,A.defineFileCollection=Qn,A.defineFileCollectionEntry=Hn,A.defineFileWidget=ti,A.defineFolderCollection=Gn,A.defineHiddenWidget=ei,A.defineImageWidget=si,A.defineListWidget=ni,A.defineMapWidget=ii,A.defineMarkdownWidget=ui,A.defineNumberWidget=ri,A.defineObjectWidget=oi,A.defineRelationWidget=li,A.defineSelectWidget=ai,A.defineStringWidget=ci,A.defineTextWidget=fi,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
134
|
+
`,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const t=Ze(e),n=pe(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n}]}}case"map-value-ind":{this.onKeyLine=!0;const t=Ze(e),n=pe(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function Ls(s){const e=s.prettyErrors!==!1;return{lineCounter:s.lineCounter||e&&new As||null,prettyErrors:e}}function Rn(s,e={}){const{lineCounter:t,prettyErrors:n}=Ls(e),i=new It(t?.addNewLine),r=new kt(e),o=Array.from(r.compose(i.parse(s)));if(n&&t)for(const l of o)l.errors.forEach(Ge(s,t)),l.warnings.forEach(Ge(s,t));return o.length>0?o:Object.assign([],{empty:!0},r.streamInfo())}function $s(s,e={}){const{lineCounter:t,prettyErrors:n}=Ls(e),i=new It(t?.addNewLine),r=new kt(e);let o=null;for(const l of r.compose(i.parse(s),!0,s.length))if(!o)o=l;else if(o.options.logLevel!=="silent"){o.errors.push(new Z(l.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&t&&(o.errors.forEach(Ge(s,t)),o.warnings.forEach(Ge(s,t))),o}function Wn(s,e,t){let n;typeof e=="function"?n=e:t===void 0&&e&&typeof e=="object"&&(t=e);const i=$s(s,t);if(!i)return null;if(i.warnings.forEach(r=>qt(i.options.logLevel,r)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:n},t))}function Vn(s,e,t){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:t===void 0&&e&&(t=e),typeof t=="string"&&(t=t.length),typeof t=="number"){const i=Math.round(t);t=i<1?void 0:i>8?{indent:8}:{indent:i}}if(s===void 0){const{keepUndefined:i}=t??e??{};if(!i)return}return new ue(s,n,t).toString(t)}const Jn=Object.freeze(Object.defineProperty({__proto__:null,Alias:$e,CST:Fn,Composer:kt,Document:ue,Lexer:Os,LineCounter:As,Pair:C,Parser:It,Scalar:N,Schema:Ye,YAMLError:gt,YAMLMap:j,YAMLParseError:Z,YAMLSeq:x,YAMLWarning:cs,isAlias:Q,isCollection:L,isDocument:ge,isMap:H,isNode:$,isPair:I,isScalar:E,isSeq:ne,parse:Wn,parseAllDocuments:Rn,parseDocument:$s,stringify:Vn,visit:Y,visitAsync:Le},Symbol.toStringTag,{value:"Module"})),Yn=s=>s,Gn=s=>s,Qn=s=>s,Hn=s=>s,Xn=s=>({widget:"boolean",...s}),zn=s=>({widget:"code",...s}),xn=s=>({widget:"color",...s}),Zn=s=>({widget:"datetime",...s}),ei=s=>({widget:"hidden",...s}),ti=s=>({widget:"file",...s}),si=s=>({widget:"image",...s}),ni=s=>({widget:"list",...s}),ii=s=>({widget:"map",...s}),ri=s=>({widget:"number",...s}),oi=s=>({widget:"object",...s}),li=s=>({widget:"relation",...s}),ai=s=>({widget:"select",...s}),ci=s=>({widget:"string",...s}),fi=s=>({widget:"text",...s}),ui=s=>({widget:"markdown",...s}),hi=async s=>{try{await V.readdir(s)}catch{await V.mkdir(s,{recursive:!0})}},di=async(s,e)=>{await V.writeFile(e,s)},pi=s=>{const e=s.startsWith(".")?s.slice(2):s;return e?["ts","js","cjs","mjs"].some(t=>e.includes(t))?e.split(".").slice(0,-1).join("."):e:s},Cs=async(s,e)=>{try{const t=await V.readdir(s),n=pi(e);if(n.includes("/")){const[o,l]=n.split("/");return await Cs(Te.join(s,o),l)}const i=t.find(o=>o.startsWith(n));if(!i)throw new Error("Config file not found");const{config:r}=await _s.loadConfigFromFile({command:"build",mode:""},Te.join(s,i))??{};if(!r)throw new Error("Config file not found");return r}catch(t){throw console.log(t),new Error("Config file not found")}},Tt=async(s,e)=>{const{configFile:t="./netlify.config.ts",config:n,saveFolder:i="./public/admin"}=e??{},r=n??await Cs(s,t);await hi(Te.join(s,i));const o=Jn.stringify(r);await di(o,Te.join(s,i,"config.yml"))};async function mi(s){let e="";return{name:"vite-plugin-netlify-cms",configResolved:t=>{e=t.root},buildStart:async()=>{await Tt(e,s)},handleHotUpdate:async({file:t})=>{t.endsWith("netlify.config.ts")&&await Tt(e,s)}}}A.createConfig=Tt,A.default=mi,A.defineBooleanWidget=Xn,A.defineCodeWidget=zn,A.defineColorWidget=xn,A.defineConfig=Yn,A.defineDateTimeWidget=Zn,A.defineFileCollection=Qn,A.defineFileCollectionEntry=Hn,A.defineFileWidget=ti,A.defineFolderCollection=Gn,A.defineHiddenWidget=ei,A.defineImageWidget=si,A.defineListWidget=ni,A.defineMapWidget=ii,A.defineMarkdownWidget=ui,A.defineNumberWidget=ri,A.defineObjectWidget=oi,A.defineRelationWidget=li,A.defineSelectWidget=ai,A.defineStringWidget=ci,A.defineTextWidget=fi,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
135
135
|
//# sourceMappingURL=index.umd.js.map
|