@budibase/cli 3.36.1 → 3.36.2

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -4358,7 +4358,7 @@ ${t}
4358
4358
  </style>
4359
4359
  `,a=!1,c,u,l=[];if(i){let d=`${t}.pre-svelte5`;Cs.default.writeFileSync(d,e),Cs.default.writeFileSync(t,o),a=!0,c=e,u=o,l.push(`Updated ${t} to use <svelte:boundary>, $$restProps, and error UI.`)}else l.push(`${t} already looks Svelte 5 compatible (uses <svelte:boundary> with no legacy Boundary.js wrapper).`);let f=bh.default.join(bh.default.dirname(t),"Boundary.js");if(Cs.default.existsSync(f))try{Cs.default.unlinkSync(f),a=!0,l.push("Removed legacy lib/Boundary.js (incompatible with Svelte 5).")}catch(d){console.log("Failed to delete legacy Boundary.js:",d instanceof Error?d.message:d)}return{changed:a,before:c,after:u,message:l.join(" ")}}s(Wnc,"migrateWrapper");function znc(){let t=bh.default.join(process.cwd(),"package.json");if(!Cs.default.existsSync(t))return{changed:!1,message:"package.json not found"};let e=Cs.default.readFileSync(t,"utf8"),r;try{r=JSON.parse(e)}catch(f){return{changed:!1,message:`Invalid package.json: ${f?.message||"parse error"}`}}let n=JSON.stringify(r,null,2),i=typeof r.version=="string"?r.version.trim():void 0,o=Dsi(i);r.dependencies||(r.dependencies={}),r.dependencies.svelte="^5.0.0",r.peerDependencies={...r.peerDependencies||{},svelte:"^5.0.0"};let a=r.devDependencies||{};a.rollup="^4.21.0",a["@rollup/plugin-commonjs"]="^25.0.7",a["@rollup/plugin-node-resolve"]="^15.2.3",a["rollup-plugin-svelte"]="^7.2.3",a["@budibase/backend-core"]&&(a["@budibase/backend-core"]="^2.8.0"),a["npm-run-all"]&&delete a["npm-run-all"],r.devDependencies=a,r.dependencies?.["@crownframework/svelte-error-boundary"]&&delete r.dependencies["@crownframework/svelte-error-boundary"],r.scripts||(r.scripts={}),r.scripts.build="rollup -c rollup.config.mjs",r.scripts.watch="rollup -cw rollup.config.mjs",o&&(r.version=o);let c=JSON.stringify(r,null,2);if(n===c)return{changed:!1,message:"package.json already appears Svelte 5 ready. Skipping."};Cs.default.writeFileSync(`${t}.pre-svelte5`,e),Cs.default.writeFileSync(t,`${c}
4360
4360
  `);let u=i&&o?` (version ${i} -> ${o})`:"",l=o?`Updated package.json for Svelte 5, Rollup 4, scripts, and version bump${u}.`:"Updated package.json for Svelte 5, Rollup 4, and scripts.";return{changed:!0,before:n,after:c,message:l}}s(znc,"migratePackageJson");function Msi(){let t=bh.default.join(process.cwd(),".github","workflows");return Cs.default.existsSync(t)?Cs.default.readdirSync(t).filter(r=>r.endsWith(".yml")||r.endsWith(".yaml")).map(r=>bh.default.join(".github","workflows",r)):[]}s(Msi,"findWorkflowFiles");function Knc(){let t=Msi();if(t.length===0)return{changed:!1,message:"No GitHub workflow files found in .github/workflows/ - skipping node version migration."};let e=[],r=!1;for(let n of t){let i=bh.default.join(process.cwd(),n),o=Cs.default.readFileSync(i,"utf8");if(!/node-version:\s*['"]?16['"]?/g.test(o))continue;let c=o.replace(/node-version:\s*['"]?16['"]?/g,"node-version: 18");if(c!==o){let u=`${i}.pre-svelte5`;Cs.default.writeFileSync(u,o),Cs.default.writeFileSync(i,c),r=!0,e.push(`Updated ${n}: node-version 16 -> 18`)}}return r?{changed:!0,message:e.join("; ")}:{changed:!1,message:"No workflow files with node-version: 16 found - skipping node version migration."}}s(Knc,"migrateNodeVersion");function $nc(){let t=bh.default.join(process.cwd(),"schema.json");if(!Cs.default.existsSync(t))return{changed:!1,message:"schema.json not found - skipping schema metadata migration."};let e=Cs.default.readFileSync(t,"utf8"),r;try{r=JSON.parse(e)}catch(u){return{changed:!1,message:`Invalid schema.json: ${u?.message||"parse error"}`}}let n=r&&typeof r.metadata=="object"&&!Array.isArray(r.metadata)?r.metadata:{};if(!(n?.svelteMajor!==5))return{changed:!1,message:"schema.json metadata already includes svelteMajor: 5. Skipping."};let o=JSON.stringify(r,null,2),a={...n,svelteMajor:5};r.metadata=a;let c=JSON.stringify(r,null,2);return Cs.default.writeFileSync(`${t}.pre-svelte5`,e),Cs.default.writeFileSync(t,`${c}
4361
- `),{changed:!0,before:o,after:c,message:"Updated schema.json metadata to include svelteMajor: 5."}}s($nc,"migrateSchemaJson");async function Usi(){let t=[],e=Cs.default.readFileSync("package.json","utf8"),r=JSON.parse(e),n=r?.dependencies?.svelte?.startsWith("^5")||r?.peerDependencies?.svelte?.startsWith("^5"),i=typeof r?.version=="string"?r.version.trim():void 0,o=Dsi(i);n?t.push("package.json appears to already depend on Svelte 5."):t.push("Will bump svelte to ^5.0.0 and align dev/peer dependencies."),r?.dependencies?.["@crownframework/svelte-error-boundary"]&&t.push("Detected @crownframework/svelte-error-boundary; migration will replace it with <svelte:boundary> in lib/Wrapper.svelte."),o&&i&&o!==i&&t.push(`Will bump package.json version from ${i} to ${o}.`);let a=Bsi(),c="unknown";if(a){let T=Cs.default.readFileSync(a,"utf8");Psi(T)?(c="looks-new",t.push(`Rollup config ${a} already looks Svelte 5-ready.`)):(c="needs-migration",t.push("Will write Rollup 4 / Svelte 5 config and rename to rollup.config.mjs."))}else c="unknown",t.push("No rollup config found - will create rollup.config.mjs.");let u=Lsi(),l="not-found";u?Cs.default.readFileSync(u,"utf8").includes("<svelte:boundary>")?(l="looks-new",t.push(`${u} already uses <svelte:boundary>.`)):(l="needs-migration",t.push(`Will update ${u} to use <svelte:boundary>, $$restProps, and error UI.`)):t.push("No wrapper.svelte found - skipping wrapper migration.");let f="unknown";if(Cs.default.existsSync("schema.json"))try{let T=Cs.default.readFileSync("schema.json","utf8"),S=JSON.parse(T);(S&&typeof S.metadata=="object"&&!Array.isArray(S.metadata)?S.metadata:{}).svelteMajor===5?(f="looks-new",t.push("schema.json metadata already declares svelteMajor: 5.")):(f="needs-migration",t.push("Will update schema.json metadata to set svelteMajor: 5."))}catch(T){f="unknown",t.push(`schema.json could not be parsed - please fix JSON before migration (${T?.message||"parse error"}).`)}else f="not-found",t.push("schema.json not found - cannot update metadata.");let d=n?"looks-new":"needs-migration",g="not-found",A=Msi();if(A.length>0){let T=!1,S=!1;for(let v of A){let b=bh.default.join(process.cwd(),v),B=Cs.default.readFileSync(b,"utf8");/node-version:\s*['"]?16['"]?/.test(B)&&(T=!0),/node-version:\s*['"]?(18|20|22)['"]?/.test(B)&&(S=!0)}T?(g="needs-migration",t.push("Will update GitHub workflow files: node-version 16 -> 18.")):S?(g="looks-new",t.push("GitHub workflow files already use node-version 18 or higher.")):(g="looks-new",t.push("GitHub workflow files found but no node-version: 16 detected."))}else t.push("No GitHub workflow files found in .github/workflows/ - skipping node version check.");return{report:t,rollup:c,packageJson:d,wrapper:l,schema:f,nodeVersion:g,canBuildAfter:!0,rollupFile:a,wrapperFile:u,pkg:r}}s(Usi,"analysePluginForSvelte5");async function Fsi(){let t=await Ync();if(t.message.includes("Failed to retrieve canonical rollup.config.mjs from skeleton"))return{pkgRes:{changed:!1,message:"Skipped package.json migration due to Rollup template failure."},schemaRes:{changed:!1,message:"Skipped schema.json migration due to Rollup template failure."},rollupRes:t,wrapperRes:{changed:!1,message:"Skipped wrapper migration due to Rollup template failure."},nodeVersionRes:{changed:!1,message:"Skipped node version migration due to Rollup template failure."}};let e=Wnc(),r=$nc(),n=znc(),i=Knc();return{pkgRes:n,schemaRes:r,rollupRes:t,wrapperRes:e,nodeVersionRes:i}}s(Fsi,"runSvelte5Migration");var Qsi=require("child_process");var Jnc=require("find-free-port");function Xnc(t){let e=[],r=[];for(let n of new Set(t.filter(Boolean)))if(SO.default.existsSync(n))try{SO.default.unlinkSync(n),e.push(n)}catch(i){r.push({path:n,error:i instanceof Error?i.message:String(i)})}return{deleted:e,failed:r}}s(Xnc,"cleanupPreSvelte5Backups");function qsi(){if(!SO.default.existsSync("package.json"))throw new Error("Please run in a plugin directory - must contain package.json");if(!SO.default.existsSync("schema.json"))throw new Error("Please run in a plugin directory - must contain schema.json")}s(qsi,"checkInPlugin");async function Znc(t){return SO.default.readdirSync(process.cwd()).find(r=>r===".git")?!1:(console.log(Ui(`By default the plugin will be created in the directory "${t}"`)),console.log(Ui("if you are already in an empty directory, such as a new Git repo, you can disable this functionality.")),eC("Create top level directory?"))}s(Znc,"askAboutTopLevel");async function eic(t){let e=t.init||t;if(!e||!vMt.includes(e)){console.log(Qa("Please provide a type to init, either 'component', 'datasource' or 'automation'."));return}console.log(Ui("Lets get some details about your new plugin:"));let r=await gk("Name",`budibase-${e}`);if(SO.default.existsSync(r)){console.log(Qa("Directory by plugin name already exists, pick a new name."));return}let n=await gk("Description",`An amazing Budibase ${e}!`),i=await gk("Version","1.0.0"),o=await Znc(r);console.log(Ui("Retrieving project...")),await FLe(e,r),await vsi(e,r,n,i),console.log(Ui("Installing dependencies...")),await g5("install",(0,QLe.join)(process.cwd(),r)),o?console.log(Ui(`Plugin created in directory "${r}"`)):(IQe(r,process.cwd()),console.log(Ui("Plugin created in current directory."))),Yce(nw.PluginInit,{type:e,name:r,description:n,version:i})}s(eic,"init");async function nPt(){qsi(),console.log(Ui("Verifying plugin..."));let t=SO.default.readFileSync("schema.json","utf8"),e=SO.default.readFileSync("package.json","utf8"),r,n;try{let i=JSON.parse(t),o=JSON.parse(e);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,kwe.validate(i),{name:r,version:n}}catch(i){i&&i.message&&i.message.includes("not valid JSON")?console.log(Qa(`schema.json is not valid JSON: ${i.message}`)):console.log(Qa(`Invalid schema/package.json: ${i.message}`))}}s(nPt,"verify");async function tic(){let t=await nPt();if(!t?.name)return;console.log(Ic("Verified!")),console.log(Ui("Building plugin...")),await g5("build");let e=(0,QLe.join)("dist",`${t.name}-${t.version}.tar.gz`);console.log(Ic(`Build complete - output in: ${e}`))}s(tic,"build");async function ric(){let t=await nPt();if(!t?.name)return;let e=(0,QLe.join)("dist",`${t.name}-${t.version}.tar.gz`);console.log(Ui(`Watching - build in: ${e}`));try{await g5("watch")}catch{console.log(Ic("Watch exited."))}}s(ric,"watch");async function nic(){let t=await gk("Directory to watch","./"),[e]=await Jnc(1e4),r="admin";await Jce({init:"quick",single:!0,watchPluginDir:t,genUser:r,port:e,silent:!0}),await uG(),console.log(Ic("Configuration has been written to docker-compose.yaml")),console.log(Ic("Development environment started successfully - connect at: ")+Ui(`http://localhost:${e}`)),console.log(Ic("Use the following credentials to login:")),console.log(Ic("Email: ")+Ui(FQe)),console.log(Ic("Password: ")+Ui(r))}s(nic,"dev");async function iic(t){qsi();let e=!!t?.yes,r=!!t?.force,n=!1;try{n=!!(0,Qsi.execSync)("git status --porcelain",{encoding:"utf8"}).trim()}catch{}if(n&&!r&&(console.log(Ui("Your git working directory is not clean. Commit or stash changes, or re-run with --force.")),!await eC("Proceed with migration anyway?"))){console.log(Ui("Migration aborted."));return}console.log(Ui("Analyzing plugin for Svelte 5 migration..."));let i=await Usi();console.log(Ui("Proposed changes:"));for(let u of i.report)console.log(Ui(" - "+u));let o=["package.json.pre-svelte5","schema.json.pre-svelte5",i.rollupFile?`${i.rollupFile}.pre-svelte5`:void 0,i.wrapperFile?`${i.wrapperFile}.pre-svelte5`:void 0];if(!e&&!await eC("Apply these changes now?")){console.log(Ui("Migration aborted by user."));return}console.log(Ui("Applying migrations..."));let a=await Fsi();if(a.rollupRes?.message?.includes("Failed to retrieve canonical rollup.config.mjs from skeleton")){console.log(Qa(a.rollupRes.message));return}if(a.pkgRes?.message&&console.log(Ui(a.pkgRes.message)),a.schemaRes?.message&&console.log(Ui(a.schemaRes.message)),a.rollupRes?.message&&console.log(Ui(a.rollupRes.message)),a.wrapperRes?.message&&console.log(Ui(a.wrapperRes.message)),console.log(Ui("Installing updated dependencies...")),await g5("install"),console.log(Ui("Re-verifying plugin...")),!(await nPt())?.name){console.log(Qa("Verification failed after migration."));return}console.log(Ui("Attempting build..."));try{await g5("build");let u=Xnc(o.filter(l=>!!l));console.log(Ic("Migration completed. Your plugin was migrated to Svelte 5 and built successfully.")),u.deleted.length&&console.log(Ui(`Removed ${u.deleted.length} pre-svelte5 backup file(s): ${u.deleted.join(", ")}`)),u.failed.length&&console.log(Ui(`Failed to remove ${u.failed.length} pre-svelte5 backup file(s): ${u.failed.map(l=>`${l.path} (${l.error})`).join(", ")}`))}catch(u){console.log(Qa(`Build failed after migration. Please review the errors above. ${u?.message||""}`))}}s(iic,"migrateSvelte5");var Gsi=new ZI("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.",eic).addSubOption("--build","Build your plugin, this will verify and produce a final tarball for your project.",tic).addSubOption("--watch","Automatically build any changes to your plugin.",ric).addSubOption("--dev","Run a development environment which automatically watches the current directory.",nic).addSubOption("--migrate-svelte5","Migrate this plugin to the Svelte 5-compatible Budibase plugin format.",iic,[{command:"--yes",help:"Skip confirmation prompts during migration."},{command:"--force",help:"Proceed even if the git working directory is not clean (creates .pre-svelte5 backups during migration, removed on success)."}]);function jsi(){return[zFt,TFt,CJn,Gsi]}s(jsi,"getCommands");var Hsi=require("commander");Od();var Vsi="3.36.1";async function oic(){let t=new Hsi.Command().addHelpCommand("help",P9("Help with Budibase commands.")).helpOption(!1).version(Vsi);for(let e of jsi())e.configure(t);await t.parseAsync(process.argv)}s(oic,"init");var aic=["exit","SIGINT","SIGUSR1","SIGUSR2","uncaughtException"];aic.forEach(t=>{process.on(t,e=>{e&&!isNaN(e)||e&&(console.error(Qa("Failed to run CLI command - please report with the following message:")),console.error(Qa(e)))})});oic().catch(t=>{console.error("Unexpected error - ",t)});
4361
+ `),{changed:!0,before:o,after:c,message:"Updated schema.json metadata to include svelteMajor: 5."}}s($nc,"migrateSchemaJson");async function Usi(){let t=[],e=Cs.default.readFileSync("package.json","utf8"),r=JSON.parse(e),n=r?.dependencies?.svelte?.startsWith("^5")||r?.peerDependencies?.svelte?.startsWith("^5"),i=typeof r?.version=="string"?r.version.trim():void 0,o=Dsi(i);n?t.push("package.json appears to already depend on Svelte 5."):t.push("Will bump svelte to ^5.0.0 and align dev/peer dependencies."),r?.dependencies?.["@crownframework/svelte-error-boundary"]&&t.push("Detected @crownframework/svelte-error-boundary; migration will replace it with <svelte:boundary> in lib/Wrapper.svelte."),o&&i&&o!==i&&t.push(`Will bump package.json version from ${i} to ${o}.`);let a=Bsi(),c="unknown";if(a){let T=Cs.default.readFileSync(a,"utf8");Psi(T)?(c="looks-new",t.push(`Rollup config ${a} already looks Svelte 5-ready.`)):(c="needs-migration",t.push("Will write Rollup 4 / Svelte 5 config and rename to rollup.config.mjs."))}else c="unknown",t.push("No rollup config found - will create rollup.config.mjs.");let u=Lsi(),l="not-found";u?Cs.default.readFileSync(u,"utf8").includes("<svelte:boundary>")?(l="looks-new",t.push(`${u} already uses <svelte:boundary>.`)):(l="needs-migration",t.push(`Will update ${u} to use <svelte:boundary>, $$restProps, and error UI.`)):t.push("No wrapper.svelte found - skipping wrapper migration.");let f="unknown";if(Cs.default.existsSync("schema.json"))try{let T=Cs.default.readFileSync("schema.json","utf8"),S=JSON.parse(T);(S&&typeof S.metadata=="object"&&!Array.isArray(S.metadata)?S.metadata:{}).svelteMajor===5?(f="looks-new",t.push("schema.json metadata already declares svelteMajor: 5.")):(f="needs-migration",t.push("Will update schema.json metadata to set svelteMajor: 5."))}catch(T){f="unknown",t.push(`schema.json could not be parsed - please fix JSON before migration (${T?.message||"parse error"}).`)}else f="not-found",t.push("schema.json not found - cannot update metadata.");let d=n?"looks-new":"needs-migration",g="not-found",A=Msi();if(A.length>0){let T=!1,S=!1;for(let v of A){let b=bh.default.join(process.cwd(),v),B=Cs.default.readFileSync(b,"utf8");/node-version:\s*['"]?16['"]?/.test(B)&&(T=!0),/node-version:\s*['"]?(18|20|22)['"]?/.test(B)&&(S=!0)}T?(g="needs-migration",t.push("Will update GitHub workflow files: node-version 16 -> 18.")):S?(g="looks-new",t.push("GitHub workflow files already use node-version 18 or higher.")):(g="looks-new",t.push("GitHub workflow files found but no node-version: 16 detected."))}else t.push("No GitHub workflow files found in .github/workflows/ - skipping node version check.");return{report:t,rollup:c,packageJson:d,wrapper:l,schema:f,nodeVersion:g,canBuildAfter:!0,rollupFile:a,wrapperFile:u,pkg:r}}s(Usi,"analysePluginForSvelte5");async function Fsi(){let t=await Ync();if(t.message.includes("Failed to retrieve canonical rollup.config.mjs from skeleton"))return{pkgRes:{changed:!1,message:"Skipped package.json migration due to Rollup template failure."},schemaRes:{changed:!1,message:"Skipped schema.json migration due to Rollup template failure."},rollupRes:t,wrapperRes:{changed:!1,message:"Skipped wrapper migration due to Rollup template failure."},nodeVersionRes:{changed:!1,message:"Skipped node version migration due to Rollup template failure."}};let e=Wnc(),r=$nc(),n=znc(),i=Knc();return{pkgRes:n,schemaRes:r,rollupRes:t,wrapperRes:e,nodeVersionRes:i}}s(Fsi,"runSvelte5Migration");var Qsi=require("child_process");var Jnc=require("find-free-port");function Xnc(t){let e=[],r=[];for(let n of new Set(t.filter(Boolean)))if(SO.default.existsSync(n))try{SO.default.unlinkSync(n),e.push(n)}catch(i){r.push({path:n,error:i instanceof Error?i.message:String(i)})}return{deleted:e,failed:r}}s(Xnc,"cleanupPreSvelte5Backups");function qsi(){if(!SO.default.existsSync("package.json"))throw new Error("Please run in a plugin directory - must contain package.json");if(!SO.default.existsSync("schema.json"))throw new Error("Please run in a plugin directory - must contain schema.json")}s(qsi,"checkInPlugin");async function Znc(t){return SO.default.readdirSync(process.cwd()).find(r=>r===".git")?!1:(console.log(Ui(`By default the plugin will be created in the directory "${t}"`)),console.log(Ui("if you are already in an empty directory, such as a new Git repo, you can disable this functionality.")),eC("Create top level directory?"))}s(Znc,"askAboutTopLevel");async function eic(t){let e=t.init||t;if(!e||!vMt.includes(e)){console.log(Qa("Please provide a type to init, either 'component', 'datasource' or 'automation'."));return}console.log(Ui("Lets get some details about your new plugin:"));let r=await gk("Name",`budibase-${e}`);if(SO.default.existsSync(r)){console.log(Qa("Directory by plugin name already exists, pick a new name."));return}let n=await gk("Description",`An amazing Budibase ${e}!`),i=await gk("Version","1.0.0"),o=await Znc(r);console.log(Ui("Retrieving project...")),await FLe(e,r),await vsi(e,r,n,i),console.log(Ui("Installing dependencies...")),await g5("install",(0,QLe.join)(process.cwd(),r)),o?console.log(Ui(`Plugin created in directory "${r}"`)):(IQe(r,process.cwd()),console.log(Ui("Plugin created in current directory."))),Yce(nw.PluginInit,{type:e,name:r,description:n,version:i})}s(eic,"init");async function nPt(){qsi(),console.log(Ui("Verifying plugin..."));let t=SO.default.readFileSync("schema.json","utf8"),e=SO.default.readFileSync("package.json","utf8"),r,n;try{let i=JSON.parse(t),o=JSON.parse(e);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,kwe.validate(i),{name:r,version:n}}catch(i){i&&i.message&&i.message.includes("not valid JSON")?console.log(Qa(`schema.json is not valid JSON: ${i.message}`)):console.log(Qa(`Invalid schema/package.json: ${i.message}`))}}s(nPt,"verify");async function tic(){let t=await nPt();if(!t?.name)return;console.log(Ic("Verified!")),console.log(Ui("Building plugin...")),await g5("build");let e=(0,QLe.join)("dist",`${t.name}-${t.version}.tar.gz`);console.log(Ic(`Build complete - output in: ${e}`))}s(tic,"build");async function ric(){let t=await nPt();if(!t?.name)return;let e=(0,QLe.join)("dist",`${t.name}-${t.version}.tar.gz`);console.log(Ui(`Watching - build in: ${e}`));try{await g5("watch")}catch{console.log(Ic("Watch exited."))}}s(ric,"watch");async function nic(){let t=await gk("Directory to watch","./"),[e]=await Jnc(1e4),r="admin";await Jce({init:"quick",single:!0,watchPluginDir:t,genUser:r,port:e,silent:!0}),await uG(),console.log(Ic("Configuration has been written to docker-compose.yaml")),console.log(Ic("Development environment started successfully - connect at: ")+Ui(`http://localhost:${e}`)),console.log(Ic("Use the following credentials to login:")),console.log(Ic("Email: ")+Ui(FQe)),console.log(Ic("Password: ")+Ui(r))}s(nic,"dev");async function iic(t){qsi();let e=!!t?.yes,r=!!t?.force,n=!1;try{n=!!(0,Qsi.execSync)("git status --porcelain",{encoding:"utf8"}).trim()}catch{}if(n&&!r&&(console.log(Ui("Your git working directory is not clean. Commit or stash changes, or re-run with --force.")),!await eC("Proceed with migration anyway?"))){console.log(Ui("Migration aborted."));return}console.log(Ui("Analyzing plugin for Svelte 5 migration..."));let i=await Usi();console.log(Ui("Proposed changes:"));for(let u of i.report)console.log(Ui(" - "+u));let o=["package.json.pre-svelte5","schema.json.pre-svelte5",i.rollupFile?`${i.rollupFile}.pre-svelte5`:void 0,i.wrapperFile?`${i.wrapperFile}.pre-svelte5`:void 0];if(!e&&!await eC("Apply these changes now?")){console.log(Ui("Migration aborted by user."));return}console.log(Ui("Applying migrations..."));let a=await Fsi();if(a.rollupRes?.message?.includes("Failed to retrieve canonical rollup.config.mjs from skeleton")){console.log(Qa(a.rollupRes.message));return}if(a.pkgRes?.message&&console.log(Ui(a.pkgRes.message)),a.schemaRes?.message&&console.log(Ui(a.schemaRes.message)),a.rollupRes?.message&&console.log(Ui(a.rollupRes.message)),a.wrapperRes?.message&&console.log(Ui(a.wrapperRes.message)),console.log(Ui("Installing updated dependencies...")),await g5("install"),console.log(Ui("Re-verifying plugin...")),!(await nPt())?.name){console.log(Qa("Verification failed after migration."));return}console.log(Ui("Attempting build..."));try{await g5("build");let u=Xnc(o.filter(l=>!!l));console.log(Ic("Migration completed. Your plugin was migrated to Svelte 5 and built successfully.")),u.deleted.length&&console.log(Ui(`Removed ${u.deleted.length} pre-svelte5 backup file(s): ${u.deleted.join(", ")}`)),u.failed.length&&console.log(Ui(`Failed to remove ${u.failed.length} pre-svelte5 backup file(s): ${u.failed.map(l=>`${l.path} (${l.error})`).join(", ")}`))}catch(u){console.log(Qa(`Build failed after migration. Please review the errors above. ${u?.message||""}`))}}s(iic,"migrateSvelte5");var Gsi=new ZI("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.",eic).addSubOption("--build","Build your plugin, this will verify and produce a final tarball for your project.",tic).addSubOption("--watch","Automatically build any changes to your plugin.",ric).addSubOption("--dev","Run a development environment which automatically watches the current directory.",nic).addSubOption("--migrate-svelte5","Migrate this plugin to the Svelte 5-compatible Budibase plugin format.",iic,[{command:"--yes",help:"Skip confirmation prompts during migration."},{command:"--force",help:"Proceed even if the git working directory is not clean (creates .pre-svelte5 backups during migration, removed on success)."}]);function jsi(){return[zFt,TFt,CJn,Gsi]}s(jsi,"getCommands");var Hsi=require("commander");Od();var Vsi="3.36.2";async function oic(){let t=new Hsi.Command().addHelpCommand("help",P9("Help with Budibase commands.")).helpOption(!1).version(Vsi);for(let e of jsi())e.configure(t);await t.parseAsync(process.argv)}s(oic,"init");var aic=["exit","SIGINT","SIGUSR1","SIGUSR2","uncaughtException"];aic.forEach(t=>{process.on(t,e=>{e&&!isNaN(e)||e&&(console.error(Qa("Failed to run CLI command - please report with the following message:")),console.error(Qa(e)))})});oic().catch(t=>{console.error("Unexpected error - ",t)});
4362
4362
  /*! Bundled license information:
4363
4363
 
4364
4364
  lodash/lodash.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budibase/cli",
3
- "version": "3.36.1",
3
+ "version": "3.36.2",
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": "7a83e0e9dc810a0a6e41b006b8a6f26c749c75c0"
44
+ "gitHead": "af5c4987e639f4c3f801e5baa9570277080cef14"
45
45
  }