@budibase/cli 3.20.10 → 3.20.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1399,7 +1399,7 @@ $1`)};Fce.parseAttributes=s(function(t){return Object.keys(t).map(function(r){va
|
|
|
1399
1399
|
`}s(KUe,"frontendWrapJS");var g3i=at(S6t()),_3i=at(VW()),y3i=at(w6t()),b3i=at(C6t()),E3i=at(A6t()),v3i=at(r6t()),S3i=at(IUe()),w3i=at(T6t()),T3i=at(M6t());var uCu={math:g3i.default,array:_3i.default,number:y3i.default,url:b3i.default,string:E3i.default,comparison:v3i.default,object:S3i.default,regex:w3i.default,uuid:T3i.default},A3i=["sortBy"],lCu={date:zUe,duration:Jce},zR;function eue(){if(zR)return zR;zR={};for(let e of Object.values(uCu))for(let[t,r]of Object.entries(e))zR[t]=(...n)=>r(...n,{});zR={...zR,...lCu};for(let e of A3i)delete zR[e];return Object.freeze(zR),zR}s(eue,"getJsHelperList");var YUe=s(e=>`(function(){
|
|
1400
1400
|
${e}
|
|
1401
1401
|
})();`,"iifeWrapper");var JW=class e extends Error{constructor(){super(e.message);this.code=e.code}static{s(this,"JsTimeoutError")}static{this.message="Timed out while executing JS"}static{this.code="JS_TIMEOUT_ERROR"}},Nj=class e extends Error{constructor(r){super(`error while running user-supplied JavaScript: ${r.toString()}`);this.userScriptError=r;this.code=e.code}static{s(this,"UserScriptError")}static{this.code="USER_SCRIPT_ERROR"}};var x3i=at(Eke());var QUe,c$t=s(e=>QUe=e,"setJSRunner"),C3i=s(()=>{QUe=void 0},"removeJSRunner"),a$t,fCu=s(e=>a$t=e,"setOnErrorLog"),dCu=s(e=>{if(!e||typeof e!="string")return e;let t=/\[+(.+)]+/,r=e.match(t);return r&&r[1]?r[1]:e},"removeSquareBrackets"),pCu=s(e=>e==="snippets"||e==="helpers"||e.startsWith("snippets.")||e.startsWith("helpers."),"isReservedKey"),hCu=s((e,t)=>{if(pCu(e))return;let r=/^(["'`]).*\1$/,n=t;return r.test(e)?e.substring(1,e.length-1):(e.split(".").forEach(i=>{if(n==null||typeof n!="object")return null;n=n[dCu(i)]}),n)},"getContextValue");function O3i(handlebars,context){if(!d3i()||!QUe)throw new Error("JS disabled in environment.");try{let js=YUe(o$t(handlebars)),snippetMap={},snippetCache={};for(let e of context.snippets||[])snippetMap[e.name]=e.code;let clonedContext;Zce()?clonedContext=context:clonedContext=(0,x3i.default)(context);let sandboxContext={$:e=>hCu(e,clonedContext),helpers:eue(),snippets:new Proxy({},{get:function(_,name){return name in snippetCache||(snippetCache[name]=eval(YUe(snippetMap[name]))),snippetCache[name]}})},logs=[];if(!Zce()){let e=KUe(js).split(js)[0].split(`
|
|
1402
|
-
`).length,t=s(r=>(...n)=>{kj()||console[r](...n),n.forEach((o,a)=>{typeof o=="object"&&(n[a]=JSON.stringify(o))});let i=new Error().stack?.match(/<anonymous>:(\d+):\d+/)?.[1];logs.push({log:n,line:i?parseInt(i)-e:void 0,type:r})},"buildLogResponse");sandboxContext.console={log:t("log"),info:t("info"),debug:t("debug"),warn:t("warn"),error:t("error"),table:t("table")}}let res={data:QUe(js,sandboxContext),logs};return`{{${XW} js_result-${JSON.stringify(res)}}}`}catch(e){a$t&&a$t(e);let{noThrow:t=!0}=context.__opts||{};if(e.code==="ERR_SCRIPT_EXECUTION_TIMEOUT")return"Timed out while executing JS";if(e.code==="JS_REQUEST_TIMEOUT_ERROR")return e.message;if(e.code===JW.code)return JW.message;if(e.code===Nj.code){if(t)return e.userScriptError.toString();throw e}if(e.name==="SyntaxError"){if(t)return e.toString();throw e}return"Error while executing JS"}}s(O3i,"processJS");var mCu={"<":"<",">":">"};function gCu(e){return e==null||typeof e!="object"?!1:e.toString()==="[object Object]"||e.length>0&&typeof e[0]=="object"}s(gCu,"isObject");var _Cu=[new FR(Ij.OBJECT,e=>new XUe.default.SafeString(JSON.stringify(e))),new FR(Ij.JS,O3i,!1),new FR(Ij.DECODE_ID,e=>{if(!e)return[];let t=typeof e=="string"?e:e._id,r=decodeURIComponent(t).replace(/'/g,'"');try{let n=JSON.parse(r);return Array.isArray(n)?n:[n]}catch{return[e]}}),new FR(Ij.ALL,(e,t)=>{let{__opts:r}=t;if(gCu(e))return new XUe.default.SafeString(JSON.stringify(e));if(r&&r.onlyFound&&e==null)return r.input;if(e==null||typeof e!="string")return e??"";e&&e.string&&(e=e.string);let n=e;return r&&r.escapeNewlines&&(n=e.replace(/\n/g,"\\n")),n=new XUe.default.SafeString(n.replace(/&/g,"&")),n==null||typeof n!="string"?n:n.replace(/[<>]/g,i=>mCu[i]||i)}),new FR(Ij.LITERAL,e=>{if(e===void 0)return"";let t=typeof e,r=t==="object"?JSON.stringify(e):e;return`{{${XW} ${t}-${r}}}`})];function R3i(){return Object.values(Ij).concat(VUe,n$t)}s(R3i,"HelperNames");function u$t(e){for(let t of _Cu)t.register(e)}s(u$t,"registerMinimum");function I3i(e){u$t(e),l3i(e)}s(I3i,"registerAll");var k3i=["#","else","/"];var ZW=class{static{s(this,"Preprocessor")}constructor(t,r){this.name=t,this.fn=r}process(t,r,n){let i=this.fn(r,n),o=t.indexOf(r);return s$t(t,o,r.length,i)}},N3i=[new ZW("swap-to-dot-notation",e=>{let t=e.indexOf("["),r=0;for(;t!==-1;){h3i(e.charAt(t-1))&&(e=s$t(e,t+r,1,".[")),r=t+1;let n=e.substring(r+1).indexOf("[");t=n>0?r+1+n:-1}return e}),new ZW("fix-functions",e=>{for(let t of k3i){let r=`{ ${t}`,n=`{${t}`;e=e.replace(new RegExp(r,"g"),n)}return e}),new ZW("normalize-spaces",e=>e.replace(/{{(\s{2,})/g,"{{ ")),new ZW("finalise",(e,t)=>{let n=!t?.noHelpers,i=e.slice(2,e.length-2);i.charAt(0)===" "&&(i=i.slice(1)),i.charAt(i.length-1)===" "&&(i=i.slice(0,i.length-1));let o=i.split(" ")[0];for(let c of k3i)if(o.includes(c))return e;let a=o.trim().toLowerCase();return n&&!t?.disabledHelpers?.includes(a)&&R3i().some(c=>a===c.toLowerCase())&&(i=`(${i})`),`{{ all ${i} }}`})];var l$t=class{static{s(this,"Postprocessor")}constructor(t,r){this.name=t,this.fn=r}process(t){return this.fn(t)}},f$t=[new l$t("convert-literals",e=>{if(typeof e!="string"||!e.includes(XW))return{result:e};let t=e.indexOf("-"),r=e.substring(12,t),n=e.substring(t+1,e.length-2);switch(r){case"string":return{result:n};case"number":return{result:parseFloat(n)};case"boolean":return{result:n==="true"};case"object":return{result:JSON.parse(n)};case"js_result":{let i=JSON.parse(n);return{result:i.data,logs:i.logs}}}return{result:n}})];function d$t(e,t,r){let n=[];for(let i of t){if(typeof e!="string")break;let o=new RegExp(WUe),a=e.match(o);if(a!=null)for(let c of a){let u=i.process(e,c,r||{});typeof u=="object"?("logs"in u&&u.logs&&(n=n.concat(u.logs)),e=u.result):e=u}}return{result:e,logs:n}}s(d$t,"process");function P3i(e,t){let r=N3i;return t.noFinalise&&(r=r.filter(n=>n.name!=="finalise")),d$t(e,r,t).result}s(P3i,"preprocess");function D3i(e){return d$t(e,f$t).result}s(D3i,"postprocess");function M3i(e){return d$t(e,f$t)}s(M3i,"postprocessWithLogs");var m$t=(0,h$t.create)();I3i(m$t);var ECu=Object.keys(m$t.helpers),B3i=(0,h$t.create)();u$t(B3i);var vCu={noHelpers:!1,cacheTemplates:!1,noEscaping:!1,escapeNewlines:!1,noFinalise:!1};function SCu(e){return e?Object.keys(e).filter(r=>ECu.includes(r)):[]}s(SCu,"findOverlappingHelpers");var p$t={};function wCu(e,t,r){t={...vCu,...t};let n=!t?.noHelpers,i=`${e}-${JSON.stringify(t)}`;if(t.cacheTemplates&&p$t[i])return p$t[i];let o=n?SCu(r):[];if(e=P3i(e,{...t,disabledHelpers:o}),r&&n&&o.length>0)for(let u of F3i(e))e=e.replace(u,m3i(u,o,"./"));t.noEscaping&&(e=ACu(e));let c=(t.noHelpers?B3i:m$t).compile(e,{strict:!1});return p$t[i]=c,c}s(wCu,"createTemplate");function TCu(e,t,r){let n=e;if(typeof e!="string")throw new Error("Cannot process non-string types.");function i(o){let a=wCu(o,r,t),c=Math.floor(Date.now()/1e3)*1e3,u=a({now:new Date(c).toISOString(),__opts:{...r,input:o},...t});return r?.logging?M3i(u):D3i(u)}s(i,"process");try{if(r&&r.onlyFound){let o=[],a=F3i(e);for(let c of a){let u=i(c);typeof u=="object"&&"result"in u?(o=o.concat(u.logs||[]),e=e.replace(c,u.result)):e=e.replace(c,u)}return r?.logging?{result:e,logs:o}:e}else return i(e)}catch(o){let{noThrow:a=!0}=r||{};if(a)return n;throw o}}s(TCu,"processStringSyncInternal");function U3i(e,t,r){return TCu(e,t,{...r,logging:!1})}s(U3i,"processStringSync");function ACu(e){let t=p3i(e);if(t==null)return e;let r=[...new Set(t)];for(let n of r){let i=new RegExp(`${n}(?!})`,"g");e=e.replace(i,`{${n}}`)}return e}s(ACu,"disableEscaping");function F3i(e){if(!e||typeof e!="string")return[];let t=new RegExp(i$t),r=e.match(t);return r??[]}s(F3i,"findHBSBlocks");function xCu(){let e=kj()?q3i.default:L3i.default;c$t((t,r)=>{e.createContext(r);let n=KUe(t),i=e.runInNewContext(n,r);if(i.error)throw new Nj(i.error);return i.result})}s(xCu,"browserJSSetup");function CCu(){Zce()?C3i():xCu()}s(CCu,"defaultJSSetup");CCu();var OCu=require("download"),RCu=require("tar"),ICu=["package.json.hbs","schema.json.hbs","README.md.hbs"];async function kCu(e){let t=await(0,j3i.default)("https://api.github.com/repos/budibase/budibase-skeleton/releases/latest");if(t.status>=300)throw new Error("Failed to retrieve skeleton metadata");let r=await t.json();for(let n of r.assets)if(n.name&&n.name.includes(e))return n.browser_download_url;throw new Error("No skeleton found in latest release.")}s(kCu,"getSkeletonUrl");async function H3i(e,t){let r=await kCu(e),n=(0,JUe.join)($3i.default.tmpdir(),"skeleton.tar.gz");Pj.default.writeFileSync(n,await OCu(r)),Pj.default.mkdirSync(t),await RCu.extract({file:n,C:t}),Pj.default.rmSync(n)}s(H3i,"getSkeleton");async function G3i(e,t,r,n){for(let i of ICu){let o=(0,JUe.join)(t,i),a=(0,JUe.join)(t,i.substring(0,i.length-4)),c=Pj.default.readFileSync(o,"utf8");if(!c)continue;let u=U3i(c,{name:t,description:r,version:n});Pj.default.writeFileSync(a,u),Pj.default.rmSync(o)}}s(G3i,"fleshOutSkeleton");ZD();var Dj=at(require("fs"));Ir();var V3i=at(require("util")),W3i=at(require("child_process"));var NCu=V3i.default.promisify(W3i.default.exec);async function K3i(e,t="./"){let{stdout:r}=await NCu(e,{cwd:t});return r}s(K3i,"exec");async function z3i(e){try{return await K3i(`${e} --version`),!0}catch{return!1}}s(z3i,"utilityInstalled");async function ZUe(e,t="./"){let r=await z3i("yarn"),n=await z3i("npm");if(!r&&!n)throw new Error("Must have yarn or npm installed to run build.");let i=e==="install"?`npm ${e}`:`npm run ${e}`,o=r?`yarn ${e} --ignore-engines`:i;await K3i(o,t)}s(ZUe,"runPkgCommand");var eFe=require("path");ad();var PCu=require("find-free-port");function DCu(){if(!Dj.default.existsSync("package.json"))throw new Error("Please run in a plugin directory - must contain package.json");if(!Dj.default.existsSync("schema.json"))throw new Error("Please run in a plugin directory - must contain schema.json")}s(DCu,"checkInPlugin");async function MCu(e){return Dj.default.readdirSync(process.cwd()).find(r=>r===".git")?!1:(console.log(jc(`By default the plugin will be created in the directory "${e}"`)),console.log(jc("if you are already in an empty directory, such as a new Git repo, you can disable this functionality.")),sI("Create top level directory?"))}s(MCu,"askAboutTopLevel");async function LCu(e){let t=e.init||e;if(!t||!_Vt.includes(t)){console.log(ou("Please provide a type to init, either 'component', 'datasource' or 'automation'."));return}console.log(jc("Lets get some details about your new plugin:"));let r=await JD("Name",`budibase-${t}`);if(Dj.default.existsSync(r)){console.log(ou("Directory by plugin name already exists, pick a new name."));return}let n=await JD("Description",`An amazing Budibase ${t}!`),i=await JD("Version","1.0.0"),o=await MCu(r);console.log(jc("Retrieving project...")),await H3i(t,r),await G3i(t,r,n,i),console.log(jc("Installing dependencies...")),await ZUe("install",(0,eFe.join)(process.cwd(),r)),o?console.log(jc(`Plugin created in directory "${r}"`)):(nje(r,process.cwd()),console.log(jc("Plugin created in current directory."))),Gue(WA.PluginInit,{type:t,name:r,description:n,version:i})}s(LCu,"init");async function Y3i(){DCu(),console.log(jc("Verifying plugin..."));let e=Dj.default.readFileSync("schema.json","utf8"),t=Dj.default.readFileSync("package.json","utf8"),r,n;try{let i=JSON.parse(e),o=JSON.parse(t);if(!o.name||!o.version||!o.description)throw new Error("package.json is missing one of 'name', 'version' or 'description'.");return r=o.name,n=o.version,oPe.validate(i),{name:r,version:n}}catch(i){i&&i.message&&i.message.includes("not valid JSON")?console.log(ou(`schema.json is not valid JSON: ${i.message}`)):console.log(ou(`Invalid schema/package.json: ${i.message}`))}}s(Y3i,"verify");async function qCu(){let e=await Y3i();if(!e?.name)return;console.log(Fc("Verified!")),console.log(jc("Building plugin...")),await ZUe("build");let t=(0,eFe.join)("dist",`${e.name}-${e.version}.tar.gz`);console.log(Fc(`Build complete - output in: ${t}`))}s(qCu,"build");async function BCu(){let e=await Y3i();if(!e?.name)return;let t=(0,eFe.join)("dist",`${e.name}-${e.version}.tar.gz`);console.log(jc(`Watching - build in: ${t}`));try{await ZUe("watch")}catch{console.log(Fc("Watch exited."))}}s(BCu,"watch");async function UCu(){let e=await JD("Directory to watch","./"),[t]=await PCu(1e4),r="admin";await Yue({init:"quick",single:!0,watchPluginDir:e,genUser:r,port:t,silent:!0}),await Xj(),console.log(Fc("Configuration has been written to docker-compose.yaml")),console.log(Fc("Development environment started successfully - connect at: ")+jc(`http://localhost:${t}`)),console.log(Fc("Use the following credentials to login:")),console.log(Fc("Email: ")+jc(bje)),console.log(Fc("Password: ")+jc(r))}s(UCu,"dev");var Q3i=new NS("plugins").addHelp("Custom plugins for Budibase, init, build and verify your components and datasources with this tool.").addSubOption("--init [type]","Init a new plugin project, with a type of either component or datasource.",LCu).addSubOption("--build","Build your plugin, this will verify and produce a final tarball for your project.",qCu).addSubOption("--watch","Automatically build any changes to your plugin.",BCu).addSubOption("--dev","Run a development environment which automatically watches the current directory.",UCu);function X3i(){return[T9t,Z5t,y2i,Q3i]}s(X3i,"getCommands");var Z3i=require("commander");ad();var J3i="3.20.10";async function jCu(){let e=new Z3i.Command().addHelpCommand("help",gK("Help with Budibase commands.")).helpOption(!1).version(J3i);for(let t of X3i())t.configure(e);await e.parseAsync(process.argv)}s(jCu,"init");var $Cu=["exit","SIGINT","SIGUSR1","SIGUSR2","uncaughtException"];$Cu.forEach(e=>{process.on(e,t=>{t&&!isNaN(t)||t&&(console.error(ou("Failed to run CLI command - please report with the following message:")),console.error(ou(t)))})});jCu().catch(e=>{console.error("Unexpected error - ",e)});
|
|
1402
|
+
`).length,t=s(r=>(...n)=>{kj()||console[r](...n),n.forEach((o,a)=>{typeof o=="object"&&(n[a]=JSON.stringify(o))});let i=new Error().stack?.match(/<anonymous>:(\d+):\d+/)?.[1];logs.push({log:n,line:i?parseInt(i)-e:void 0,type:r})},"buildLogResponse");sandboxContext.console={log:t("log"),info:t("info"),debug:t("debug"),warn:t("warn"),error:t("error"),table:t("table")}}let res={data:QUe(js,sandboxContext),logs};return`{{${XW} js_result-${JSON.stringify(res)}}}`}catch(e){a$t&&a$t(e);let{noThrow:t=!0}=context.__opts||{};if(e.code==="ERR_SCRIPT_EXECUTION_TIMEOUT")return"Timed out while executing JS";if(e.code==="JS_REQUEST_TIMEOUT_ERROR")return e.message;if(e.code===JW.code)return JW.message;if(e.code===Nj.code){if(t)return e.userScriptError.toString();throw e}if(e.name==="SyntaxError"){if(t)return e.toString();throw e}return"Error while executing JS"}}s(O3i,"processJS");var mCu={"<":"<",">":">"};function gCu(e){return e==null||typeof e!="object"?!1:e.toString()==="[object Object]"||e.length>0&&typeof e[0]=="object"}s(gCu,"isObject");var _Cu=[new FR(Ij.OBJECT,e=>new XUe.default.SafeString(JSON.stringify(e))),new FR(Ij.JS,O3i,!1),new FR(Ij.DECODE_ID,e=>{if(!e)return[];let t=typeof e=="string"?e:e._id,r=decodeURIComponent(t).replace(/'/g,'"');try{let n=JSON.parse(r);return Array.isArray(n)?n:[n]}catch{return[e]}}),new FR(Ij.ALL,(e,t)=>{let{__opts:r}=t;if(gCu(e))return new XUe.default.SafeString(JSON.stringify(e));if(r&&r.onlyFound&&e==null)return r.input;if(e==null||typeof e!="string")return e??"";e&&e.string&&(e=e.string);let n=e;return r&&r.escapeNewlines&&(n=e.replace(/\n/g,"\\n")),n=new XUe.default.SafeString(n.replace(/&/g,"&")),n==null||typeof n!="string"?n:n.replace(/[<>]/g,i=>mCu[i]||i)}),new FR(Ij.LITERAL,e=>{if(e===void 0)return"";let t=typeof e,r=t==="object"?JSON.stringify(e):e;return`{{${XW} ${t}-${r}}}`})];function R3i(){return Object.values(Ij).concat(VUe,n$t)}s(R3i,"HelperNames");function u$t(e){for(let t of _Cu)t.register(e)}s(u$t,"registerMinimum");function I3i(e){u$t(e),l3i(e)}s(I3i,"registerAll");var k3i=["#","else","/"];var ZW=class{static{s(this,"Preprocessor")}constructor(t,r){this.name=t,this.fn=r}process(t,r,n){let i=this.fn(r,n),o=t.indexOf(r);return s$t(t,o,r.length,i)}},N3i=[new ZW("swap-to-dot-notation",e=>{let t=e.indexOf("["),r=0;for(;t!==-1;){h3i(e.charAt(t-1))&&(e=s$t(e,t+r,1,".[")),r=t+1;let n=e.substring(r+1).indexOf("[");t=n>0?r+1+n:-1}return e}),new ZW("fix-functions",e=>{for(let t of k3i){let r=`{ ${t}`,n=`{${t}`;e=e.replace(new RegExp(r,"g"),n)}return e}),new ZW("normalize-spaces",e=>e.replace(/{{(\s{2,})/g,"{{ ")),new ZW("finalise",(e,t)=>{let n=!t?.noHelpers,i=e.slice(2,e.length-2);i.charAt(0)===" "&&(i=i.slice(1)),i.charAt(i.length-1)===" "&&(i=i.slice(0,i.length-1));let o=i.split(" ")[0];for(let c of k3i)if(o.includes(c))return e;let a=o.trim().toLowerCase();return n&&!t?.disabledHelpers?.includes(a)&&R3i().some(c=>a===c.toLowerCase())&&(i=`(${i})`),`{{ all ${i} }}`})];var l$t=class{static{s(this,"Postprocessor")}constructor(t,r){this.name=t,this.fn=r}process(t){return this.fn(t)}},f$t=[new l$t("convert-literals",e=>{if(typeof e!="string"||!e.includes(XW))return{result:e};let t=e.indexOf("-"),r=e.substring(12,t),n=e.substring(t+1,e.length-2);switch(r){case"string":return{result:n};case"number":return{result:parseFloat(n)};case"boolean":return{result:n==="true"};case"object":return{result:JSON.parse(n)};case"js_result":{let i=JSON.parse(n);return{result:i.data,logs:i.logs}}}return{result:n}})];function d$t(e,t,r){let n=[];for(let i of t){if(typeof e!="string")break;let o=new RegExp(WUe),a=e.match(o);if(a!=null)for(let c of a){let u=i.process(e,c,r||{});typeof u=="object"?("logs"in u&&u.logs&&(n=n.concat(u.logs)),e=u.result):e=u}}return{result:e,logs:n}}s(d$t,"process");function P3i(e,t){let r=N3i;return t.noFinalise&&(r=r.filter(n=>n.name!=="finalise")),d$t(e,r,t).result}s(P3i,"preprocess");function D3i(e){return d$t(e,f$t).result}s(D3i,"postprocess");function M3i(e){return d$t(e,f$t)}s(M3i,"postprocessWithLogs");var m$t=(0,h$t.create)();I3i(m$t);var ECu=Object.keys(m$t.helpers),B3i=(0,h$t.create)();u$t(B3i);var vCu={noHelpers:!1,cacheTemplates:!1,noEscaping:!1,escapeNewlines:!1,noFinalise:!1};function SCu(e){return e?Object.keys(e).filter(r=>ECu.includes(r)):[]}s(SCu,"findOverlappingHelpers");var p$t={};function wCu(e,t,r){t={...vCu,...t};let n=!t?.noHelpers,i=`${e}-${JSON.stringify(t)}`;if(t.cacheTemplates&&p$t[i])return p$t[i];let o=n?SCu(r):[];if(e=P3i(e,{...t,disabledHelpers:o}),r&&n&&o.length>0)for(let u of F3i(e))e=e.replace(u,m3i(u,o,"./"));t.noEscaping&&(e=ACu(e));let c=(t.noHelpers?B3i:m$t).compile(e,{strict:!1});return p$t[i]=c,c}s(wCu,"createTemplate");function TCu(e,t,r){let n=e;if(typeof e!="string")throw new Error("Cannot process non-string types.");function i(o){let a=wCu(o,r,t),c=Math.floor(Date.now()/1e3)*1e3,u=a({now:new Date(c).toISOString(),__opts:{...r,input:o},...t});return r?.logging?M3i(u):D3i(u)}s(i,"process");try{if(r&&r.onlyFound){let o=[],a=F3i(e);for(let c of a){let u=i(c);typeof u=="object"&&"result"in u?(o=o.concat(u.logs||[]),e=e.replace(c,u.result)):e=e.replace(c,u)}return r?.logging?{result:e,logs:o}:e}else return i(e)}catch(o){let{noThrow:a=!0}=r||{};if(a)return n;throw o}}s(TCu,"processStringSyncInternal");function U3i(e,t,r){return TCu(e,t,{...r,logging:!1})}s(U3i,"processStringSync");function ACu(e){let t=p3i(e);if(t==null)return e;let r=[...new Set(t)];for(let n of r){let i=new RegExp(`${n}(?!})`,"g");e=e.replace(i,`{${n}}`)}return e}s(ACu,"disableEscaping");function F3i(e){if(!e||typeof e!="string")return[];let t=new RegExp(i$t),r=e.match(t);return r??[]}s(F3i,"findHBSBlocks");function xCu(){let e=kj()?q3i.default:L3i.default;c$t((t,r)=>{e.createContext(r);let n=KUe(t),i=e.runInNewContext(n,r);if(i.error)throw new Nj(i.error);return i.result})}s(xCu,"browserJSSetup");function CCu(){Zce()?C3i():xCu()}s(CCu,"defaultJSSetup");CCu();var OCu=require("download"),RCu=require("tar"),ICu=["package.json.hbs","schema.json.hbs","README.md.hbs"];async function kCu(e){let t=await(0,j3i.default)("https://api.github.com/repos/budibase/budibase-skeleton/releases/latest");if(t.status>=300)throw new Error("Failed to retrieve skeleton metadata");let r=await t.json();for(let n of r.assets)if(n.name&&n.name.includes(e))return n.browser_download_url;throw new Error("No skeleton found in latest release.")}s(kCu,"getSkeletonUrl");async function H3i(e,t){let r=await kCu(e),n=(0,JUe.join)($3i.default.tmpdir(),"skeleton.tar.gz");Pj.default.writeFileSync(n,await OCu(r)),Pj.default.mkdirSync(t),await RCu.extract({file:n,C:t}),Pj.default.rmSync(n)}s(H3i,"getSkeleton");async function G3i(e,t,r,n){for(let i of ICu){let o=(0,JUe.join)(t,i),a=(0,JUe.join)(t,i.substring(0,i.length-4)),c=Pj.default.readFileSync(o,"utf8");if(!c)continue;let u=U3i(c,{name:t,description:r,version:n});Pj.default.writeFileSync(a,u),Pj.default.rmSync(o)}}s(G3i,"fleshOutSkeleton");ZD();var Dj=at(require("fs"));Ir();var V3i=at(require("util")),W3i=at(require("child_process"));var NCu=V3i.default.promisify(W3i.default.exec);async function K3i(e,t="./"){let{stdout:r}=await NCu(e,{cwd:t});return r}s(K3i,"exec");async function z3i(e){try{return await K3i(`${e} --version`),!0}catch{return!1}}s(z3i,"utilityInstalled");async function ZUe(e,t="./"){let r=await z3i("yarn"),n=await z3i("npm");if(!r&&!n)throw new Error("Must have yarn or npm installed to run build.");let i=e==="install"?`npm ${e}`:`npm run ${e}`,o=r?`yarn ${e} --ignore-engines`:i;await K3i(o,t)}s(ZUe,"runPkgCommand");var eFe=require("path");ad();var PCu=require("find-free-port");function DCu(){if(!Dj.default.existsSync("package.json"))throw new Error("Please run in a plugin directory - must contain package.json");if(!Dj.default.existsSync("schema.json"))throw new Error("Please run in a plugin directory - must contain schema.json")}s(DCu,"checkInPlugin");async function MCu(e){return Dj.default.readdirSync(process.cwd()).find(r=>r===".git")?!1:(console.log(jc(`By default the plugin will be created in the directory "${e}"`)),console.log(jc("if you are already in an empty directory, such as a new Git repo, you can disable this functionality.")),sI("Create top level directory?"))}s(MCu,"askAboutTopLevel");async function LCu(e){let t=e.init||e;if(!t||!_Vt.includes(t)){console.log(ou("Please provide a type to init, either 'component', 'datasource' or 'automation'."));return}console.log(jc("Lets get some details about your new plugin:"));let r=await JD("Name",`budibase-${t}`);if(Dj.default.existsSync(r)){console.log(ou("Directory by plugin name already exists, pick a new name."));return}let n=await JD("Description",`An amazing Budibase ${t}!`),i=await JD("Version","1.0.0"),o=await MCu(r);console.log(jc("Retrieving project...")),await H3i(t,r),await G3i(t,r,n,i),console.log(jc("Installing dependencies...")),await ZUe("install",(0,eFe.join)(process.cwd(),r)),o?console.log(jc(`Plugin created in directory "${r}"`)):(nje(r,process.cwd()),console.log(jc("Plugin created in current directory."))),Gue(WA.PluginInit,{type:t,name:r,description:n,version:i})}s(LCu,"init");async function Y3i(){DCu(),console.log(jc("Verifying plugin..."));let e=Dj.default.readFileSync("schema.json","utf8"),t=Dj.default.readFileSync("package.json","utf8"),r,n;try{let i=JSON.parse(e),o=JSON.parse(t);if(!o.name||!o.version||!o.description)throw new Error("package.json is missing one of 'name', 'version' or 'description'.");return r=o.name,n=o.version,oPe.validate(i),{name:r,version:n}}catch(i){i&&i.message&&i.message.includes("not valid JSON")?console.log(ou(`schema.json is not valid JSON: ${i.message}`)):console.log(ou(`Invalid schema/package.json: ${i.message}`))}}s(Y3i,"verify");async function qCu(){let e=await Y3i();if(!e?.name)return;console.log(Fc("Verified!")),console.log(jc("Building plugin...")),await ZUe("build");let t=(0,eFe.join)("dist",`${e.name}-${e.version}.tar.gz`);console.log(Fc(`Build complete - output in: ${t}`))}s(qCu,"build");async function BCu(){let e=await Y3i();if(!e?.name)return;let t=(0,eFe.join)("dist",`${e.name}-${e.version}.tar.gz`);console.log(jc(`Watching - build in: ${t}`));try{await ZUe("watch")}catch{console.log(Fc("Watch exited."))}}s(BCu,"watch");async function UCu(){let e=await JD("Directory to watch","./"),[t]=await PCu(1e4),r="admin";await Yue({init:"quick",single:!0,watchPluginDir:e,genUser:r,port:t,silent:!0}),await Xj(),console.log(Fc("Configuration has been written to docker-compose.yaml")),console.log(Fc("Development environment started successfully - connect at: ")+jc(`http://localhost:${t}`)),console.log(Fc("Use the following credentials to login:")),console.log(Fc("Email: ")+jc(bje)),console.log(Fc("Password: ")+jc(r))}s(UCu,"dev");var Q3i=new NS("plugins").addHelp("Custom plugins for Budibase, init, build and verify your components and datasources with this tool.").addSubOption("--init [type]","Init a new plugin project, with a type of either component or datasource.",LCu).addSubOption("--build","Build your plugin, this will verify and produce a final tarball for your project.",qCu).addSubOption("--watch","Automatically build any changes to your plugin.",BCu).addSubOption("--dev","Run a development environment which automatically watches the current directory.",UCu);function X3i(){return[T9t,Z5t,y2i,Q3i]}s(X3i,"getCommands");var Z3i=require("commander");ad();var J3i="3.20.11";async function jCu(){let e=new Z3i.Command().addHelpCommand("help",gK("Help with Budibase commands.")).helpOption(!1).version(J3i);for(let t of X3i())t.configure(e);await e.parseAsync(process.argv)}s(jCu,"init");var $Cu=["exit","SIGINT","SIGUSR1","SIGUSR2","uncaughtException"];$Cu.forEach(e=>{process.on(e,t=>{t&&!isNaN(t)||t&&(console.error(ou("Failed to run CLI command - please report with the following message:")),console.error(ou(t)))})});jCu().catch(e=>{console.error("Unexpected error - ",e)});
|
|
1403
1403
|
/*! Bundled license information:
|
|
1404
1404
|
|
|
1405
1405
|
lodash/lodash.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/cli",
|
|
3
|
-
"version": "3.20.
|
|
3
|
+
"version": "3.20.11",
|
|
4
4
|
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"@types/pouchdb": "^6.4.0",
|
|
42
42
|
"ts-node": "10.8.1"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "80707b68f76ee020f52c3242e6d987bdfd1a19ff"
|
|
45
45
|
}
|