@budibase/cli 3.18.14 → 3.18.15
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`)};Uce.parseAttributes=s(function(t){return Object.keys(t).map(function(r){va
|
|
|
1399
1399
|
`}s(YUe,"frontendWrapJS");var l3i=at(E6t()),f3i=at(KW()),d3i=at(v6t()),p3i=at(A6t()),h3i=at(w6t()),m3i=at(e6t()),g3i=at(kUe()),_3i=at(S6t()),y3i=at(P6t());var Jxu={math:l3i.default,array:f3i.default,number:d3i.default,url:p3i.default,string:h3i.default,comparison:m3i.default,object:g3i.default,regex:_3i.default,uuid:y3i.default},b3i=["sortBy"],Zxu={date:VUe,duration:Xce},zR;function Zce(){if(zR)return zR;zR={};for(let e of Object.values(Jxu))for(let[t,r]of Object.entries(e))zR[t]=(...n)=>r(...n,{});zR={...zR,...Zxu};for(let e of b3i)delete zR[e];return Object.freeze(zR),zR}s(Zce,"getJsHelperList");var QUe=s(e=>`(function(){
|
|
1400
1400
|
${e}
|
|
1401
1401
|
})();`,"iifeWrapper");var eK=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"}},kj=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 E3i=at(Eke());var XUe,o$t=s(e=>XUe=e,"setJSRunner"),v3i=s(()=>{XUe=void 0},"removeJSRunner"),s$t,eCu=s(e=>s$t=e,"setOnErrorLog"),tCu=s(e=>{if(!e||typeof e!="string")return e;let t=/\[+(.+)]+/,r=e.match(t);return r&&r[1]?r[1]:e},"removeSquareBrackets"),rCu=s(e=>e==="snippets"||e==="helpers"||e.startsWith("snippets.")||e.startsWith("helpers."),"isReservedKey"),nCu=s((e,t)=>{if(rCu(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[tCu(i)]}),n)},"getContextValue");function S3i(handlebars,context){if(!o3i()||!XUe)throw new Error("JS disabled in environment.");try{let js=QUe(i$t(handlebars)),snippetMap={},snippetCache={};for(let e of context.snippets||[])snippetMap[e.name]=e.code;let clonedContext;Jce()?clonedContext=context:clonedContext=(0,E3i.default)(context);let sandboxContext={$:e=>nCu(e,clonedContext),helpers:Zce(),snippets:new Proxy({},{get:function(_,name){return name in snippetCache||(snippetCache[name]=eval(QUe(snippetMap[name]))),snippetCache[name]}})},logs=[];if(!Jce()){let e=YUe(js).split(js)[0].split(`
|
|
1402
|
-
`).length,t=s(r=>(...n)=>{Ij()||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:XUe(js,sandboxContext),logs};return`{{${ZW} js_result-${JSON.stringify(res)}}}`}catch(e){s$t&&s$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===eK.code)return eK.message;if(e.code===kj.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(S3i,"processJS");var iCu={"<":"<",">":">"};function sCu(e){return e==null||typeof e!="object"?!1:e.toString()==="[object Object]"||e.length>0&&typeof e[0]=="object"}s(sCu,"isObject");var oCu=[new FR(Rj.OBJECT,e=>new JUe.default.SafeString(JSON.stringify(e))),new FR(Rj.JS,S3i,!1),new FR(Rj.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(Rj.ALL,(e,t)=>{let{__opts:r}=t;if(sCu(e))return new JUe.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 JUe.default.SafeString(n.replace(/&/g,"&")),n==null||typeof n!="string"?n:n.replace(/[<>]/g,i=>iCu[i]||i)}),new FR(Rj.LITERAL,e=>{if(e===void 0)return"";let t=typeof e,r=t==="object"?JSON.stringify(e):e;return`{{${ZW} ${t}-${r}}}`})];function w3i(){return Object.values(Rj).concat(WUe,t$t)}s(w3i,"HelperNames");function a$t(e){for(let t of oCu)t.register(e)}s(a$t,"registerMinimum");function T3i(e){a$t(e),i3i(e)}s(T3i,"registerAll");var A3i=["#","else","/"];var tK=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 n$t(t,o,r.length,i)}},x3i=[new tK("swap-to-dot-notation",e=>{let t=e.indexOf("["),r=0;for(;t!==-1;){c3i(e.charAt(t-1))&&(e=n$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 tK("fix-functions",e=>{for(let t of A3i){let r=`{ ${t}`,n=`{${t}`;e=e.replace(new RegExp(r,"g"),n)}return e}),new tK("normalize-spaces",e=>e.replace(/{{(\s{2,})/g,"{{ ")),new tK("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 A3i)if(o.includes(c))return e;let a=o.trim().toLowerCase();return n&&!t?.disabledHelpers?.includes(a)&&w3i().some(c=>a===c.toLowerCase())&&(i=`(${i})`),`{{ all ${i} }}`})];var c$t=class{static{s(this,"Postprocessor")}constructor(t,r){this.name=t,this.fn=r}process(t){return this.fn(t)}},u$t=[new c$t("convert-literals",e=>{if(typeof e!="string"||!e.includes(ZW))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 l$t(e,t,r){let n=[];for(let i of t){if(typeof e!="string")break;let o=new RegExp(KUe),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(l$t,"process");function C3i(e,t){let r=x3i;return t.noFinalise&&(r=r.filter(n=>n.name!=="finalise")),l$t(e,r,t).result}s(C3i,"preprocess");function O3i(e){return l$t(e,u$t).result}s(O3i,"postprocess");function R3i(e){return l$t(e,u$t)}s(R3i,"postprocessWithLogs");var p$t=(0,d$t.create)();T3i(p$t);var uCu=Object.keys(p$t.helpers),N3i=(0,d$t.create)();a$t(N3i);var lCu={noHelpers:!1,cacheTemplates:!1,noEscaping:!1,escapeNewlines:!1,noFinalise:!1};function fCu(e){return e?Object.keys(e).filter(r=>uCu.includes(r)):[]}s(fCu,"findOverlappingHelpers");var f$t={};function dCu(e,t,r){t={...lCu,...t};let n=!t?.noHelpers,i=`${e}-${JSON.stringify(t)}`;if(t.cacheTemplates&&f$t[i])return f$t[i];let o=n?fCu(r):[];if(e=C3i(e,{...t,disabledHelpers:o}),r&&n&&o.length>0)for(let u of D3i(e))e=e.replace(u,u3i(u,o,"./"));t.noEscaping&&(e=hCu(e));let c=(t.noHelpers?N3i:p$t).compile(e,{strict:!1});return f$t[i]=c,c}s(dCu,"createTemplate");function pCu(e,t,r){let n=e;if(typeof e!="string")throw new Error("Cannot process non-string types.");function i(o){let a=dCu(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?R3i(u):O3i(u)}s(i,"process");try{if(r&&r.onlyFound){let o=[],a=D3i(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(pCu,"processStringSyncInternal");function P3i(e,t,r){return pCu(e,t,{...r,logging:!1})}s(P3i,"processStringSync");function hCu(e){let t=a3i(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(hCu,"disableEscaping");function D3i(e){if(!e||typeof e!="string")return[];let t=new RegExp(r$t),r=e.match(t);return r??[]}s(D3i,"findHBSBlocks");function mCu(){let e=Ij()?k3i.default:I3i.default;o$t((t,r)=>{e.createContext(r);let n=YUe(t),i=e.runInNewContext(n,r);if(i.error)throw new kj(i.error);return i.result})}s(mCu,"browserJSSetup");function gCu(){Jce()?v3i():mCu()}s(gCu,"defaultJSSetup");gCu();var _Cu=require("download"),yCu=require("tar"),bCu=["package.json.hbs","schema.json.hbs","README.md.hbs"];async function ECu(e){let t=await(0,M3i.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(ECu,"getSkeletonUrl");async function q3i(e,t){let r=await ECu(e),n=(0,ZUe.join)(L3i.default.tmpdir(),"skeleton.tar.gz");Nj.default.writeFileSync(n,await _Cu(r)),Nj.default.mkdirSync(t),await yCu.extract({file:n,C:t}),Nj.default.rmSync(n)}s(q3i,"getSkeleton");async function B3i(e,t,r,n){for(let i of bCu){let o=(0,ZUe.join)(t,i),a=(0,ZUe.join)(t,i.substring(0,i.length-4)),c=Nj.default.readFileSync(o,"utf8");if(!c)continue;let u=P3i(c,{name:t,description:r,version:n});Nj.default.writeFileSync(a,u),Nj.default.rmSync(o)}}s(B3i,"fleshOutSkeleton");ZD();var Pj=at(require("fs"));Nr();var F3i=at(require("util")),j3i=at(require("child_process"));var vCu=F3i.default.promisify(j3i.default.exec);async function $3i(e,t="./"){let{stdout:r}=await vCu(e,{cwd:t});return r}s($3i,"exec");async function U3i(e){try{return await $3i(`${e} --version`),!0}catch{return!1}}s(U3i,"utilityInstalled");async function eFe(e,t="./"){let r=await U3i("yarn"),n=await U3i("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 $3i(o,t)}s(eFe,"runPkgCommand");var tFe=require("path");od();var SCu=require("find-free-port");function wCu(){if(!Pj.default.existsSync("package.json"))throw new Error("Please run in a plugin directory - must contain package.json");if(!Pj.default.existsSync("schema.json"))throw new Error("Please run in a plugin directory - must contain schema.json")}s(wCu,"checkInPlugin");async function TCu(e){return Pj.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(TCu,"askAboutTopLevel");async function ACu(e){let t=e.init||e;if(!t||!VGt.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(Pj.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 TCu(r);console.log(jc("Retrieving project...")),await q3i(t,r),await B3i(t,r,n,i),console.log(jc("Installing dependencies...")),await eFe("install",(0,tFe.join)(process.cwd(),r)),o?console.log(jc(`Plugin created in directory "${r}"`)):(ije(r,process.cwd()),console.log(jc("Plugin created in current directory."))),Hue(WA.PluginInit,{type:t,name:r,description:n,version:i})}s(ACu,"init");async function H3i(){wCu(),console.log(jc("Verifying plugin..."));let e=Pj.default.readFileSync("schema.json","utf8"),t=Pj.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,aPe.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(H3i,"verify");async function xCu(){let e=await H3i();if(!e?.name)return;console.log(Fc("Verified!")),console.log(jc("Building plugin...")),await eFe("build");let t=(0,tFe.join)("dist",`${e.name}-${e.version}.tar.gz`);console.log(Fc(`Build complete - output in: ${t}`))}s(xCu,"build");async function CCu(){let e=await H3i();if(!e?.name)return;let t=(0,tFe.join)("dist",`${e.name}-${e.version}.tar.gz`);console.log(jc(`Watching - build in: ${t}`));try{await eFe("watch")}catch{console.log(Fc("Watch exited."))}}s(CCu,"watch");async function OCu(){let e=await JD("Directory to watch","./"),[t]=await SCu(1e4),r="admin";await Kue({init:"quick",single:!0,watchPluginDir:e,genUser:r,port:t,silent:!0}),await Qj(),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(Eje)),console.log(Fc("Password: ")+jc(r))}s(OCu,"dev");var G3i=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.",ACu).addSubOption("--build","Build your plugin, this will verify and produce a final tarball for your project.",xCu).addSubOption("--watch","Automatically build any changes to your plugin.",CCu).addSubOption("--dev","Run a development environment which automatically watches the current directory.",OCu);function z3i(){return[v9t,Q5t,d2i,G3i]}s(z3i,"getCommands");var W3i=require("commander");od();var V3i="3.18.14";async function ICu(){let e=new W3i.Command().addHelpCommand("help",yK("Help with Budibase commands.")).helpOption(!1).version(V3i);for(let t of z3i())t.configure(e);await e.parseAsync(process.argv)}s(ICu,"init");var kCu=["exit","SIGINT","SIGUSR1","SIGUSR2","uncaughtException"];kCu.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)))})});ICu().catch(e=>{console.error("Unexpected error - ",e)});
|
|
1402
|
+
`).length,t=s(r=>(...n)=>{Ij()||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:XUe(js,sandboxContext),logs};return`{{${ZW} js_result-${JSON.stringify(res)}}}`}catch(e){s$t&&s$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===eK.code)return eK.message;if(e.code===kj.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(S3i,"processJS");var iCu={"<":"<",">":">"};function sCu(e){return e==null||typeof e!="object"?!1:e.toString()==="[object Object]"||e.length>0&&typeof e[0]=="object"}s(sCu,"isObject");var oCu=[new FR(Rj.OBJECT,e=>new JUe.default.SafeString(JSON.stringify(e))),new FR(Rj.JS,S3i,!1),new FR(Rj.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(Rj.ALL,(e,t)=>{let{__opts:r}=t;if(sCu(e))return new JUe.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 JUe.default.SafeString(n.replace(/&/g,"&")),n==null||typeof n!="string"?n:n.replace(/[<>]/g,i=>iCu[i]||i)}),new FR(Rj.LITERAL,e=>{if(e===void 0)return"";let t=typeof e,r=t==="object"?JSON.stringify(e):e;return`{{${ZW} ${t}-${r}}}`})];function w3i(){return Object.values(Rj).concat(WUe,t$t)}s(w3i,"HelperNames");function a$t(e){for(let t of oCu)t.register(e)}s(a$t,"registerMinimum");function T3i(e){a$t(e),i3i(e)}s(T3i,"registerAll");var A3i=["#","else","/"];var tK=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 n$t(t,o,r.length,i)}},x3i=[new tK("swap-to-dot-notation",e=>{let t=e.indexOf("["),r=0;for(;t!==-1;){c3i(e.charAt(t-1))&&(e=n$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 tK("fix-functions",e=>{for(let t of A3i){let r=`{ ${t}`,n=`{${t}`;e=e.replace(new RegExp(r,"g"),n)}return e}),new tK("normalize-spaces",e=>e.replace(/{{(\s{2,})/g,"{{ ")),new tK("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 A3i)if(o.includes(c))return e;let a=o.trim().toLowerCase();return n&&!t?.disabledHelpers?.includes(a)&&w3i().some(c=>a===c.toLowerCase())&&(i=`(${i})`),`{{ all ${i} }}`})];var c$t=class{static{s(this,"Postprocessor")}constructor(t,r){this.name=t,this.fn=r}process(t){return this.fn(t)}},u$t=[new c$t("convert-literals",e=>{if(typeof e!="string"||!e.includes(ZW))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 l$t(e,t,r){let n=[];for(let i of t){if(typeof e!="string")break;let o=new RegExp(KUe),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(l$t,"process");function C3i(e,t){let r=x3i;return t.noFinalise&&(r=r.filter(n=>n.name!=="finalise")),l$t(e,r,t).result}s(C3i,"preprocess");function O3i(e){return l$t(e,u$t).result}s(O3i,"postprocess");function R3i(e){return l$t(e,u$t)}s(R3i,"postprocessWithLogs");var p$t=(0,d$t.create)();T3i(p$t);var uCu=Object.keys(p$t.helpers),N3i=(0,d$t.create)();a$t(N3i);var lCu={noHelpers:!1,cacheTemplates:!1,noEscaping:!1,escapeNewlines:!1,noFinalise:!1};function fCu(e){return e?Object.keys(e).filter(r=>uCu.includes(r)):[]}s(fCu,"findOverlappingHelpers");var f$t={};function dCu(e,t,r){t={...lCu,...t};let n=!t?.noHelpers,i=`${e}-${JSON.stringify(t)}`;if(t.cacheTemplates&&f$t[i])return f$t[i];let o=n?fCu(r):[];if(e=C3i(e,{...t,disabledHelpers:o}),r&&n&&o.length>0)for(let u of D3i(e))e=e.replace(u,u3i(u,o,"./"));t.noEscaping&&(e=hCu(e));let c=(t.noHelpers?N3i:p$t).compile(e,{strict:!1});return f$t[i]=c,c}s(dCu,"createTemplate");function pCu(e,t,r){let n=e;if(typeof e!="string")throw new Error("Cannot process non-string types.");function i(o){let a=dCu(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?R3i(u):O3i(u)}s(i,"process");try{if(r&&r.onlyFound){let o=[],a=D3i(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(pCu,"processStringSyncInternal");function P3i(e,t,r){return pCu(e,t,{...r,logging:!1})}s(P3i,"processStringSync");function hCu(e){let t=a3i(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(hCu,"disableEscaping");function D3i(e){if(!e||typeof e!="string")return[];let t=new RegExp(r$t),r=e.match(t);return r??[]}s(D3i,"findHBSBlocks");function mCu(){let e=Ij()?k3i.default:I3i.default;o$t((t,r)=>{e.createContext(r);let n=YUe(t),i=e.runInNewContext(n,r);if(i.error)throw new kj(i.error);return i.result})}s(mCu,"browserJSSetup");function gCu(){Jce()?v3i():mCu()}s(gCu,"defaultJSSetup");gCu();var _Cu=require("download"),yCu=require("tar"),bCu=["package.json.hbs","schema.json.hbs","README.md.hbs"];async function ECu(e){let t=await(0,M3i.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(ECu,"getSkeletonUrl");async function q3i(e,t){let r=await ECu(e),n=(0,ZUe.join)(L3i.default.tmpdir(),"skeleton.tar.gz");Nj.default.writeFileSync(n,await _Cu(r)),Nj.default.mkdirSync(t),await yCu.extract({file:n,C:t}),Nj.default.rmSync(n)}s(q3i,"getSkeleton");async function B3i(e,t,r,n){for(let i of bCu){let o=(0,ZUe.join)(t,i),a=(0,ZUe.join)(t,i.substring(0,i.length-4)),c=Nj.default.readFileSync(o,"utf8");if(!c)continue;let u=P3i(c,{name:t,description:r,version:n});Nj.default.writeFileSync(a,u),Nj.default.rmSync(o)}}s(B3i,"fleshOutSkeleton");ZD();var Pj=at(require("fs"));Nr();var F3i=at(require("util")),j3i=at(require("child_process"));var vCu=F3i.default.promisify(j3i.default.exec);async function $3i(e,t="./"){let{stdout:r}=await vCu(e,{cwd:t});return r}s($3i,"exec");async function U3i(e){try{return await $3i(`${e} --version`),!0}catch{return!1}}s(U3i,"utilityInstalled");async function eFe(e,t="./"){let r=await U3i("yarn"),n=await U3i("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 $3i(o,t)}s(eFe,"runPkgCommand");var tFe=require("path");od();var SCu=require("find-free-port");function wCu(){if(!Pj.default.existsSync("package.json"))throw new Error("Please run in a plugin directory - must contain package.json");if(!Pj.default.existsSync("schema.json"))throw new Error("Please run in a plugin directory - must contain schema.json")}s(wCu,"checkInPlugin");async function TCu(e){return Pj.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(TCu,"askAboutTopLevel");async function ACu(e){let t=e.init||e;if(!t||!VGt.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(Pj.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 TCu(r);console.log(jc("Retrieving project...")),await q3i(t,r),await B3i(t,r,n,i),console.log(jc("Installing dependencies...")),await eFe("install",(0,tFe.join)(process.cwd(),r)),o?console.log(jc(`Plugin created in directory "${r}"`)):(ije(r,process.cwd()),console.log(jc("Plugin created in current directory."))),Hue(WA.PluginInit,{type:t,name:r,description:n,version:i})}s(ACu,"init");async function H3i(){wCu(),console.log(jc("Verifying plugin..."));let e=Pj.default.readFileSync("schema.json","utf8"),t=Pj.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,aPe.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(H3i,"verify");async function xCu(){let e=await H3i();if(!e?.name)return;console.log(Fc("Verified!")),console.log(jc("Building plugin...")),await eFe("build");let t=(0,tFe.join)("dist",`${e.name}-${e.version}.tar.gz`);console.log(Fc(`Build complete - output in: ${t}`))}s(xCu,"build");async function CCu(){let e=await H3i();if(!e?.name)return;let t=(0,tFe.join)("dist",`${e.name}-${e.version}.tar.gz`);console.log(jc(`Watching - build in: ${t}`));try{await eFe("watch")}catch{console.log(Fc("Watch exited."))}}s(CCu,"watch");async function OCu(){let e=await JD("Directory to watch","./"),[t]=await SCu(1e4),r="admin";await Kue({init:"quick",single:!0,watchPluginDir:e,genUser:r,port:t,silent:!0}),await Qj(),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(Eje)),console.log(Fc("Password: ")+jc(r))}s(OCu,"dev");var G3i=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.",ACu).addSubOption("--build","Build your plugin, this will verify and produce a final tarball for your project.",xCu).addSubOption("--watch","Automatically build any changes to your plugin.",CCu).addSubOption("--dev","Run a development environment which automatically watches the current directory.",OCu);function z3i(){return[v9t,Q5t,d2i,G3i]}s(z3i,"getCommands");var W3i=require("commander");od();var V3i="3.18.15";async function ICu(){let e=new W3i.Command().addHelpCommand("help",yK("Help with Budibase commands.")).helpOption(!1).version(V3i);for(let t of z3i())t.configure(e);await e.parseAsync(process.argv)}s(ICu,"init");var kCu=["exit","SIGINT","SIGUSR1","SIGUSR2","uncaughtException"];kCu.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)))})});ICu().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.18.
|
|
3
|
+
"version": "3.18.15",
|
|
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": "95620e87e1a4f31518d8577e659c8fc4420b60d8"
|
|
45
45
|
}
|