2020-09-25 15:47:42 +02:00
|
|
|
#!/usr/bin/env node
|
2020-09-28 18:04:08 +02:00
|
|
|
const { exportTemplateFromApp } = require("../src/utilities/templates")
|
2020-09-29 11:32:42 +02:00
|
|
|
const yargs = require("yargs")
|
2020-09-25 15:47:42 +02:00
|
|
|
|
2020-09-28 18:04:08 +02:00
|
|
|
// Script to export a chosen budibase app into a package
|
2020-10-29 11:28:27 +01:00
|
|
|
// Usage: ./scripts/exportAppTemplate.js export --name=Funky --appId=someInstanceId --appId=appId
|
2020-09-25 15:47:42 +02:00
|
|
|
|
2020-09-29 11:32:42 +02:00
|
|
|
yargs
|
|
|
|
.command(
|
|
|
|
"export",
|
|
|
|
"Export an existing budibase application to the .budibase/templates directory",
|
|
|
|
{
|
|
|
|
name: {
|
|
|
|
description: "The name of the newly exported template",
|
|
|
|
alias: "n",
|
|
|
|
type: "string",
|
|
|
|
},
|
|
|
|
appId: {
|
|
|
|
description: "The appId of the application you want to export",
|
|
|
|
alias: "app",
|
|
|
|
type: "string",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
async args => {
|
|
|
|
console.log("Exporting app..")
|
2020-11-06 13:30:30 +01:00
|
|
|
if (args.name == null || args.appId == null) {
|
|
|
|
console.error(
|
|
|
|
"Unable to export without a name and app ID being specified, check help for more info."
|
|
|
|
)
|
|
|
|
return
|
|
|
|
}
|
2020-09-29 11:32:42 +02:00
|
|
|
const exportPath = await exportTemplateFromApp({
|
|
|
|
templateName: args.name,
|
|
|
|
appId: args.appId,
|
|
|
|
})
|
|
|
|
console.log(`Template ${args.name} exported to ${exportPath}`)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.help()
|
|
|
|
.alias("help", "h").argv
|