@budibase/cli 3.39.27 → 3.39.29

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 CHANGED
@@ -4466,7 +4466,7 @@ ${t}
4466
4466
  </style>
4467
4467
  `,a=!1,u,c,l=[];if(i){let d=`${t}.pre-svelte5`;Rs.default.writeFileSync(d,e),Rs.default.writeFileSync(t,o),a=!0,u=e,c=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=rh.default.join(rh.default.dirname(t),"Boundary.js");if(Rs.default.existsSync(f))try{Rs.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:u,after:c,message:l.join(" ")}}s(Nqa,"migrateWrapper");function Oqa(){let t=rh.default.join(process.cwd(),"package.json");if(!Rs.default.existsSync(t))return{changed:!1,message:"package.json not found"};let e=Rs.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=_Xn(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 u=JSON.stringify(r,null,2);if(n===u)return{changed:!1,message:"package.json already appears Svelte 5 ready. Skipping."};Rs.default.writeFileSync(`${t}.pre-svelte5`,e),Rs.default.writeFileSync(t,`${u}
4468
4468
  `);let c=i&&o?` (version ${i} -> ${o})`:"",l=o?`Updated package.json for Svelte 5, Rollup 4, scripts, and version bump${c}.`:"Updated package.json for Svelte 5, Rollup 4, and scripts.";return{changed:!0,before:n,after:u,message:l}}s(Oqa,"migratePackageJson");function IXn(){let t=rh.default.join(process.cwd(),".github","workflows");return Rs.default.existsSync(t)?Rs.default.readdirSync(t).filter(r=>r.endsWith(".yml")||r.endsWith(".yaml")).map(r=>rh.default.join(".github","workflows",r)):[]}s(IXn,"findWorkflowFiles");function xqa(){let t=IXn();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=rh.default.join(process.cwd(),n),o=Rs.default.readFileSync(i,"utf8");if(!/node-version:\s*['"]?16['"]?/g.test(o))continue;let u=o.replace(/node-version:\s*['"]?16['"]?/g,"node-version: 18");if(u!==o){let c=`${i}.pre-svelte5`;Rs.default.writeFileSync(c,o),Rs.default.writeFileSync(i,u),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(xqa,"migrateNodeVersion");function vqa(){let t=rh.default.join(process.cwd(),"schema.json");if(!Rs.default.existsSync(t))return{changed:!1,message:"schema.json not found - skipping schema metadata migration."};let e=Rs.default.readFileSync(t,"utf8"),r;try{r=JSON.parse(e)}catch(c){return{changed:!1,message:`Invalid schema.json: ${c?.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 u=JSON.stringify(r,null,2);return Rs.default.writeFileSync(`${t}.pre-svelte5`,e),Rs.default.writeFileSync(t,`${u}
4469
- `),{changed:!0,before:o,after:u,message:"Updated schema.json metadata to include svelteMajor: 5."}}s(vqa,"migrateSchemaJson");async function RXn(){let t=[],e=Rs.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=_Xn(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=EXn(),u="unknown";if(a){let T=Rs.default.readFileSync(a,"utf8");yXn(T)?(u="looks-new",t.push(`Rollup config ${a} already looks Svelte 5-ready.`)):(u="needs-migration",t.push("Will write Rollup 4 / Svelte 5 config and rename to rollup.config.mjs."))}else u="unknown",t.push("No rollup config found - will create rollup.config.mjs.");let c=SXn(),l="not-found";c?Rs.default.readFileSync(c,"utf8").includes("<svelte:boundary>")?(l="looks-new",t.push(`${c} already uses <svelte:boundary>.`)):(l="needs-migration",t.push(`Will update ${c} to use <svelte:boundary>, $$restProps, and error UI.`)):t.push("No wrapper.svelte found - skipping wrapper migration.");let f="unknown";if(Rs.default.existsSync("schema.json"))try{let T=Rs.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",m="not-found",A=IXn();if(A.length>0){let T=!1,S=!1;for(let b of A){let C=rh.default.join(process.cwd(),b),B=Rs.default.readFileSync(C,"utf8");/node-version:\s*['"]?16['"]?/.test(B)&&(T=!0),/node-version:\s*['"]?(18|20|22)['"]?/.test(B)&&(S=!0)}T?(m="needs-migration",t.push("Will update GitHub workflow files: node-version 16 -> 18.")):S?(m="looks-new",t.push("GitHub workflow files already use node-version 18 or higher.")):(m="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:u,packageJson:d,wrapper:l,schema:f,nodeVersion:m,canBuildAfter:!0,rollupFile:a,wrapperFile:c,pkg:r}}s(RXn,"analysePluginForSvelte5");async function CXn(){let t=await wqa();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=Nqa(),r=vqa(),n=Oqa(),i=xqa();return{pkgRes:n,schemaRes:r,rollupRes:t,wrapperRes:e,nodeVersionRes:i}}s(CXn,"runSvelte5Migration");var bXn=require("child_process");var Dqa=require("find-free-port");function Bqa(t){let e=[],r=[];for(let n of new Set(t.filter(Boolean)))if(rx.default.existsSync(n))try{rx.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(Bqa,"cleanupPreSvelte5Backups");function wXn(){if(!rx.default.existsSync("package.json"))throw new Error("Please run in a plugin directory - must contain package.json");if(!rx.default.existsSync("schema.json"))throw new Error("Please run in a plugin directory - must contain schema.json")}s(wXn,"checkInPlugin");async function kqa(t){return rx.default.readdirSync(process.cwd()).find(r=>r===".git")?!1:(console.log(Qi(`By default the plugin will be created in the directory "${t}"`)),console.log(Qi("if you are already in an empty directory, such as a new Git repo, you can disable this functionality.")),OI("Create top level directory?"))}s(kqa,"askAboutTopLevel");async function Pqa(t){let e=t.init||t;if(!e||!$Ft.includes(e)){console.log(Fa("Please provide a type to init, either 'component', 'datasource' or 'automation'."));return}console.log(Qi("Lets get some details about your new plugin:"));let r=await pP("Name",`budibase-${e}`);if(rx.default.existsSync(r)){console.log(Fa("Directory by plugin name already exists, pick a new name."));return}let n=await pP("Description",`An amazing Budibase ${e}!`),i=await pP("Version","1.0.0"),o=await kqa(r);console.log(Qi("Retrieving project...")),await QMe(e,r),await pXn(e,r,n,i),console.log(Qi("Installing dependencies...")),await S5("install",(0,qMe.join)(process.cwd(),r)),o?console.log(Qi(`Plugin created in directory "${r}"`)):(Rqe(r,process.cwd()),console.log(Qi("Plugin created in current directory."))),Wue(Pb.PluginInit,{type:e,name:r,description:n,version:i})}s(Pqa,"init");async function yLt(){wXn(),console.log(Qi("Verifying plugin..."));let t=rx.default.readFileSync("schema.json","utf8"),e=rx.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,CNe.validate(i),{name:r,version:n}}catch(i){i&&i.message&&i.message.includes("not valid JSON")?console.log(Fa(`schema.json is not valid JSON: ${i.message}`)):console.log(Fa(`Invalid schema/package.json: ${i.message}`))}}s(yLt,"verify");async function Lqa(){let t=await yLt();if(!t?.name)return;console.log(pu("Verified!")),console.log(Qi("Building plugin...")),await S5("build");let e=(0,qMe.join)("dist",`${t.name}-${t.version}.tar.gz`);console.log(pu(`Build complete - output in: ${e}`))}s(Lqa,"build");async function Mqa(){let t=await yLt();if(!t?.name)return;let e=(0,qMe.join)("dist",`${t.name}-${t.version}.tar.gz`);console.log(Qi(`Watching - build in: ${e}`));try{await S5("watch")}catch{console.log(pu("Watch exited."))}}s(Mqa,"watch");async function Uqa(){let t=await pP("Directory to watch","./"),[e]=await Dqa(1e4),r="admin";await Xue({init:"quick",single:!0,watchPluginDir:t,genUser:r,port:e,silent:!0}),await Fq(),console.log(pu("Configuration has been written to docker-compose.yaml")),console.log(pu("Development environment started successfully - connect at: ")+Qi(`http://localhost:${e}`)),console.log(pu("Use the following credentials to login:")),console.log(pu("Email: ")+Qi(Qqe)),console.log(pu("Password: ")+Qi(r))}s(Uqa,"dev");async function Fqa(t){wXn();let e=!!t?.yes,r=!!t?.force,n=!1;try{n=!!(0,bXn.execSync)("git status --porcelain",{encoding:"utf8"}).trim()}catch{}if(n&&!r&&(console.log(Qi("Your git working directory is not clean. Commit or stash changes, or re-run with --force.")),!await OI("Proceed with migration anyway?"))){console.log(Qi("Migration aborted."));return}console.log(Qi("Analyzing plugin for Svelte 5 migration..."));let i=await RXn();console.log(Qi("Proposed changes:"));for(let c of i.report)console.log(Qi(" - "+c));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 OI("Apply these changes now?")){console.log(Qi("Migration aborted by user."));return}console.log(Qi("Applying migrations..."));let a=await CXn();if(a.rollupRes?.message?.includes("Failed to retrieve canonical rollup.config.mjs from skeleton")){console.log(Fa(a.rollupRes.message));return}if(a.pkgRes?.message&&console.log(Qi(a.pkgRes.message)),a.schemaRes?.message&&console.log(Qi(a.schemaRes.message)),a.rollupRes?.message&&console.log(Qi(a.rollupRes.message)),a.wrapperRes?.message&&console.log(Qi(a.wrapperRes.message)),console.log(Qi("Installing updated dependencies...")),await S5("install"),console.log(Qi("Re-verifying plugin...")),!(await yLt())?.name){console.log(Fa("Verification failed after migration."));return}console.log(Qi("Attempting build..."));try{await S5("build");let c=Bqa(o.filter(l=>!!l));console.log(pu("Migration completed. Your plugin was migrated to Svelte 5 and built successfully.")),c.deleted.length&&console.log(Qi(`Removed ${c.deleted.length} pre-svelte5 backup file(s): ${c.deleted.join(", ")}`)),c.failed.length&&console.log(Qi(`Failed to remove ${c.failed.length} pre-svelte5 backup file(s): ${c.failed.map(l=>`${l.path} (${l.error})`).join(", ")}`))}catch(c){console.log(Fa(`Build failed after migration. Please review the errors above. ${c?.message||""}`))}}s(Fqa,"migrateSvelte5");var NXn=new NI("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.",Pqa).addSubOption("--build","Build your plugin, this will verify and produce a final tarball for your project.",Lqa).addSubOption("--watch","Automatically build any changes to your plugin.",Mqa).addSubOption("--dev","Run a development environment which automatically watches the current directory.",Uqa).addSubOption("--migrate-svelte5","Migrate this plugin to the Svelte 5-compatible Budibase plugin format.",Fqa,[{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 OXn(){return[Eqt,YQt,lWn,NXn]}s(OXn,"getCommands");var vXn=require("commander");hd();var xXn="3.39.27";async function qqa(){let t=new vXn.Command().addHelpCommand("help",Q9("Help with Budibase commands.")).helpOption(!1).version(xXn);for(let e of OXn())e.configure(t);await t.parseAsync(process.argv)}s(qqa,"init");var Gqa=["exit","SIGINT","SIGUSR1","SIGUSR2","uncaughtException"];Gqa.forEach(t=>{process.on(t,e=>{e&&!isNaN(e)||e&&(console.error(Fa("Failed to run CLI command - please report with the following message:")),console.error(Fa(e)))})});qqa().catch(t=>{console.error("Unexpected error - ",t)});
4469
+ `),{changed:!0,before:o,after:u,message:"Updated schema.json metadata to include svelteMajor: 5."}}s(vqa,"migrateSchemaJson");async function RXn(){let t=[],e=Rs.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=_Xn(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=EXn(),u="unknown";if(a){let T=Rs.default.readFileSync(a,"utf8");yXn(T)?(u="looks-new",t.push(`Rollup config ${a} already looks Svelte 5-ready.`)):(u="needs-migration",t.push("Will write Rollup 4 / Svelte 5 config and rename to rollup.config.mjs."))}else u="unknown",t.push("No rollup config found - will create rollup.config.mjs.");let c=SXn(),l="not-found";c?Rs.default.readFileSync(c,"utf8").includes("<svelte:boundary>")?(l="looks-new",t.push(`${c} already uses <svelte:boundary>.`)):(l="needs-migration",t.push(`Will update ${c} to use <svelte:boundary>, $$restProps, and error UI.`)):t.push("No wrapper.svelte found - skipping wrapper migration.");let f="unknown";if(Rs.default.existsSync("schema.json"))try{let T=Rs.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",m="not-found",A=IXn();if(A.length>0){let T=!1,S=!1;for(let b of A){let C=rh.default.join(process.cwd(),b),B=Rs.default.readFileSync(C,"utf8");/node-version:\s*['"]?16['"]?/.test(B)&&(T=!0),/node-version:\s*['"]?(18|20|22)['"]?/.test(B)&&(S=!0)}T?(m="needs-migration",t.push("Will update GitHub workflow files: node-version 16 -> 18.")):S?(m="looks-new",t.push("GitHub workflow files already use node-version 18 or higher.")):(m="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:u,packageJson:d,wrapper:l,schema:f,nodeVersion:m,canBuildAfter:!0,rollupFile:a,wrapperFile:c,pkg:r}}s(RXn,"analysePluginForSvelte5");async function CXn(){let t=await wqa();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=Nqa(),r=vqa(),n=Oqa(),i=xqa();return{pkgRes:n,schemaRes:r,rollupRes:t,wrapperRes:e,nodeVersionRes:i}}s(CXn,"runSvelte5Migration");var bXn=require("child_process");var Dqa=require("find-free-port");function Bqa(t){let e=[],r=[];for(let n of new Set(t.filter(Boolean)))if(rx.default.existsSync(n))try{rx.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(Bqa,"cleanupPreSvelte5Backups");function wXn(){if(!rx.default.existsSync("package.json"))throw new Error("Please run in a plugin directory - must contain package.json");if(!rx.default.existsSync("schema.json"))throw new Error("Please run in a plugin directory - must contain schema.json")}s(wXn,"checkInPlugin");async function kqa(t){return rx.default.readdirSync(process.cwd()).find(r=>r===".git")?!1:(console.log(Qi(`By default the plugin will be created in the directory "${t}"`)),console.log(Qi("if you are already in an empty directory, such as a new Git repo, you can disable this functionality.")),OI("Create top level directory?"))}s(kqa,"askAboutTopLevel");async function Pqa(t){let e=t.init||t;if(!e||!$Ft.includes(e)){console.log(Fa("Please provide a type to init, either 'component', 'datasource' or 'automation'."));return}console.log(Qi("Lets get some details about your new plugin:"));let r=await pP("Name",`budibase-${e}`);if(rx.default.existsSync(r)){console.log(Fa("Directory by plugin name already exists, pick a new name."));return}let n=await pP("Description",`An amazing Budibase ${e}!`),i=await pP("Version","1.0.0"),o=await kqa(r);console.log(Qi("Retrieving project...")),await QMe(e,r),await pXn(e,r,n,i),console.log(Qi("Installing dependencies...")),await S5("install",(0,qMe.join)(process.cwd(),r)),o?console.log(Qi(`Plugin created in directory "${r}"`)):(Rqe(r,process.cwd()),console.log(Qi("Plugin created in current directory."))),Wue(Pb.PluginInit,{type:e,name:r,description:n,version:i})}s(Pqa,"init");async function yLt(){wXn(),console.log(Qi("Verifying plugin..."));let t=rx.default.readFileSync("schema.json","utf8"),e=rx.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,CNe.validate(i),{name:r,version:n}}catch(i){i&&i.message&&i.message.includes("not valid JSON")?console.log(Fa(`schema.json is not valid JSON: ${i.message}`)):console.log(Fa(`Invalid schema/package.json: ${i.message}`))}}s(yLt,"verify");async function Lqa(){let t=await yLt();if(!t?.name)return;console.log(pu("Verified!")),console.log(Qi("Building plugin...")),await S5("build");let e=(0,qMe.join)("dist",`${t.name}-${t.version}.tar.gz`);console.log(pu(`Build complete - output in: ${e}`))}s(Lqa,"build");async function Mqa(){let t=await yLt();if(!t?.name)return;let e=(0,qMe.join)("dist",`${t.name}-${t.version}.tar.gz`);console.log(Qi(`Watching - build in: ${e}`));try{await S5("watch")}catch{console.log(pu("Watch exited."))}}s(Mqa,"watch");async function Uqa(){let t=await pP("Directory to watch","./"),[e]=await Dqa(1e4),r="admin";await Xue({init:"quick",single:!0,watchPluginDir:t,genUser:r,port:e,silent:!0}),await Fq(),console.log(pu("Configuration has been written to docker-compose.yaml")),console.log(pu("Development environment started successfully - connect at: ")+Qi(`http://localhost:${e}`)),console.log(pu("Use the following credentials to login:")),console.log(pu("Email: ")+Qi(Qqe)),console.log(pu("Password: ")+Qi(r))}s(Uqa,"dev");async function Fqa(t){wXn();let e=!!t?.yes,r=!!t?.force,n=!1;try{n=!!(0,bXn.execSync)("git status --porcelain",{encoding:"utf8"}).trim()}catch{}if(n&&!r&&(console.log(Qi("Your git working directory is not clean. Commit or stash changes, or re-run with --force.")),!await OI("Proceed with migration anyway?"))){console.log(Qi("Migration aborted."));return}console.log(Qi("Analyzing plugin for Svelte 5 migration..."));let i=await RXn();console.log(Qi("Proposed changes:"));for(let c of i.report)console.log(Qi(" - "+c));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 OI("Apply these changes now?")){console.log(Qi("Migration aborted by user."));return}console.log(Qi("Applying migrations..."));let a=await CXn();if(a.rollupRes?.message?.includes("Failed to retrieve canonical rollup.config.mjs from skeleton")){console.log(Fa(a.rollupRes.message));return}if(a.pkgRes?.message&&console.log(Qi(a.pkgRes.message)),a.schemaRes?.message&&console.log(Qi(a.schemaRes.message)),a.rollupRes?.message&&console.log(Qi(a.rollupRes.message)),a.wrapperRes?.message&&console.log(Qi(a.wrapperRes.message)),console.log(Qi("Installing updated dependencies...")),await S5("install"),console.log(Qi("Re-verifying plugin...")),!(await yLt())?.name){console.log(Fa("Verification failed after migration."));return}console.log(Qi("Attempting build..."));try{await S5("build");let c=Bqa(o.filter(l=>!!l));console.log(pu("Migration completed. Your plugin was migrated to Svelte 5 and built successfully.")),c.deleted.length&&console.log(Qi(`Removed ${c.deleted.length} pre-svelte5 backup file(s): ${c.deleted.join(", ")}`)),c.failed.length&&console.log(Qi(`Failed to remove ${c.failed.length} pre-svelte5 backup file(s): ${c.failed.map(l=>`${l.path} (${l.error})`).join(", ")}`))}catch(c){console.log(Fa(`Build failed after migration. Please review the errors above. ${c?.message||""}`))}}s(Fqa,"migrateSvelte5");var NXn=new NI("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.",Pqa).addSubOption("--build","Build your plugin, this will verify and produce a final tarball for your project.",Lqa).addSubOption("--watch","Automatically build any changes to your plugin.",Mqa).addSubOption("--dev","Run a development environment which automatically watches the current directory.",Uqa).addSubOption("--migrate-svelte5","Migrate this plugin to the Svelte 5-compatible Budibase plugin format.",Fqa,[{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 OXn(){return[Eqt,YQt,lWn,NXn]}s(OXn,"getCommands");var vXn=require("commander");hd();var xXn="3.39.29";async function qqa(){let t=new vXn.Command().addHelpCommand("help",Q9("Help with Budibase commands.")).helpOption(!1).version(xXn);for(let e of OXn())e.configure(t);await t.parseAsync(process.argv)}s(qqa,"init");var Gqa=["exit","SIGINT","SIGUSR1","SIGUSR2","uncaughtException"];Gqa.forEach(t=>{process.on(t,e=>{e&&!isNaN(e)||e&&(console.error(Fa("Failed to run CLI command - please report with the following message:")),console.error(Fa(e)))})});qqa().catch(t=>{console.error("Unexpected error - ",t)});
4470
4470
  /*! Bundled license information:
4471
4471
 
4472
4472
  lodash/lodash.js: