Adding watch command to CLI.
This commit is contained in:
parent
a19790e93e
commit
63742ec7f0
|
@ -15,8 +15,8 @@ export default defineConfig(({ mode }) => {
|
|||
hmr: {
|
||||
protocol: "wss",
|
||||
clientPort: env.VITE_HMR_CLIENT_PORT || 3000,
|
||||
path: env.VITE_HMR_PATH || "/"
|
||||
}
|
||||
path: env.VITE_HMR_PATH || "/",
|
||||
},
|
||||
},
|
||||
base: "/builder/",
|
||||
build: {
|
||||
|
|
|
@ -41,7 +41,7 @@ async function init(opts) {
|
|||
console.log(info(`Plugin created in directory "${name}"`))
|
||||
}
|
||||
|
||||
async function build() {
|
||||
async function verify() {
|
||||
console.log(info("Verifying plugin..."))
|
||||
const schema = fs.readFileSync("schema.json", "utf8")
|
||||
const pkg = fs.readFileSync("package.json", "utf8")
|
||||
|
@ -57,21 +57,43 @@ async function build() {
|
|||
name = pkgJson.name
|
||||
version = pkgJson.version
|
||||
validate(schemaJson)
|
||||
return { name, version }
|
||||
} catch (err) {
|
||||
if (err && err.message && err.message.includes("not valid JSON")) {
|
||||
console.log(error(`schema.json is not valid JSON: ${err.message}`))
|
||||
} else {
|
||||
console.log(error(`Invalid schema/package.json: ${err.message}`))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function build() {
|
||||
const verified = await verify()
|
||||
if (!verified.name) {
|
||||
return
|
||||
}
|
||||
console.log(success("Verified!"))
|
||||
console.log(info("Building plugin..."))
|
||||
await runPkgCommand("build")
|
||||
const output = join("dist", `${name}-${version}.tar.gz`)
|
||||
const output = join("dist", `${verified.name}-${verified.version}.tar.gz`)
|
||||
console.log(success(`Build complete - output in: ${output}`))
|
||||
}
|
||||
|
||||
async function watch() {
|
||||
const verified = await verify()
|
||||
if (!verified.name) {
|
||||
return
|
||||
}
|
||||
const output = join("dist", `${verified.name}-${verified.version}.tar.gz`)
|
||||
console.log(info(`Watching - build in: ${output}`))
|
||||
try {
|
||||
await runPkgCommand("watch")
|
||||
} catch (err) {
|
||||
// always errors when user escapes
|
||||
console.log(success("Watch exited."))
|
||||
}
|
||||
}
|
||||
|
||||
const command = new Command(`${CommandWords.PLUGIN}`)
|
||||
.addHelp(
|
||||
"Custom plugins for Budibase, init, build and verify your components and datasources with this tool."
|
||||
|
@ -86,5 +108,10 @@ const command = new Command(`${CommandWords.PLUGIN}`)
|
|||
"Build your plugin, this will verify and produce a final tarball for your project.",
|
||||
build
|
||||
)
|
||||
.addSubOption(
|
||||
"--watch",
|
||||
"Automatically build any changes to your plugin.",
|
||||
watch
|
||||
)
|
||||
|
||||
exports.command = command
|
||||
|
|
|
@ -5,7 +5,10 @@ const PREBUILDS = "prebuilds"
|
|||
const ARCH = `${os.platform()}-${os.arch()}`
|
||||
const PREBUILD_DIR = join(process.execPath, "..", PREBUILDS, ARCH)
|
||||
|
||||
checkForBinaries()
|
||||
// running as built CLI pkg bundle
|
||||
if (!process.argv[0].includes("node")) {
|
||||
checkForBinaries()
|
||||
}
|
||||
|
||||
function checkForBinaries() {
|
||||
const readDir = join(__filename, "..", "..", PREBUILDS, ARCH)
|
||||
|
|
|
@ -43,12 +43,12 @@
|
|||
"@babel/helper-validator-identifier" "^7.16.7"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@budibase/backend-core@^1.2.38":
|
||||
version "1.2.38"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.38.tgz#9451ae72f6af8cff3aa0a57dc61fc8d3505a77a0"
|
||||
integrity sha512-g7m4fHG1tLqNsSvdSltqRHLASOH5n3QBbN5DD7cmSBIVpUtDCA0EMx/L0vkDDhTmbOQApXAW3cyJs6H3QiWtOw==
|
||||
"@budibase/backend-core@1.2.40":
|
||||
version "1.2.40"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.40.tgz#692062478f310eaee780adbc55e266fc3b6649b6"
|
||||
integrity sha512-HUw6IQgKkP345vnQcTok6X+inqYe0WpUL7uFJnm3XERvsAWX4FYWbgDoGJGS0+jZjdPjvARkt4+uZuTAEUFLiQ==
|
||||
dependencies:
|
||||
"@budibase/types" "^1.2.38"
|
||||
"@budibase/types" "^1.2.40"
|
||||
"@techpass/passport-openidconnect" "0.3.2"
|
||||
aws-sdk "2.1030.0"
|
||||
bcrypt "5.0.1"
|
||||
|
@ -101,10 +101,10 @@
|
|||
to-gfm-code-block "^0.1.1"
|
||||
year "^0.2.1"
|
||||
|
||||
"@budibase/string-templates@^1.2.38":
|
||||
version "1.2.38"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.2.38.tgz#404804df516fb981b4f073f09bab64c9111cecb0"
|
||||
integrity sha512-JRIAZVuuBECxDBcbx5FOYRRKi1ZyW7//LwKL5U1r9sIVCIxCW1t5b175oTnR9/bkktNs7X2ziynH/tsT5GVC0g==
|
||||
"@budibase/string-templates@1.2.40":
|
||||
version "1.2.40"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.2.40.tgz#d7012b415a51e0119ac098e77d052f96bc04e742"
|
||||
integrity sha512-Vc/DrmJ//kpT+QoIGqloVnomBJgHVPNIiCOXc+2XSsN5HyR18S8uO7lc77cpln3dTlvNcd7bQqXO1UIx8oebUQ==
|
||||
dependencies:
|
||||
"@budibase/handlebars-helpers" "^0.11.8"
|
||||
dayjs "^1.10.4"
|
||||
|
@ -113,10 +113,10 @@
|
|||
lodash "^4.17.20"
|
||||
vm2 "^3.9.4"
|
||||
|
||||
"@budibase/types@^1.2.38":
|
||||
version "1.2.38"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.38.tgz#472f4ec891242488561a8cfc175961664bc7ac88"
|
||||
integrity sha512-pMKh4FKhPoa1pge4FKqPi3gbzZp3HJ1RuhM5naKFqC1yompIn/Es+YNft39VC2bTW5tiGbucMcjWzdpMwTSTVw==
|
||||
"@budibase/types@1.2.40", "@budibase/types@^1.2.40":
|
||||
version "1.2.40"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.40.tgz#c1456728b61966cab7fe3689bd044bf415faa138"
|
||||
integrity sha512-eNZFG0C/GBog87y6StKBjdF/aDJJtUHbAM8NWLUNNqTAiMxO2s3XhDN1dE6t74NBCRFzJo2sAD+34pJHhKFanQ==
|
||||
|
||||
"@eslint/eslintrc@^0.4.3":
|
||||
version "0.4.3"
|
||||
|
|
|
@ -138,7 +138,12 @@ module.exports = server.listen(env.PORT || 0, async () => {
|
|||
}
|
||||
|
||||
// monitor plugin directory if required
|
||||
if (env.SELF_HOSTED && !env.MULTI_TENANCY && env.PLUGINS_DIR && fs.existsSync(env.PLUGINS_DIR)) {
|
||||
if (
|
||||
env.SELF_HOSTED &&
|
||||
!env.MULTI_TENANCY &&
|
||||
env.PLUGINS_DIR &&
|
||||
fs.existsSync(env.PLUGINS_DIR)
|
||||
) {
|
||||
const watchPath = path.join(env.PLUGINS_DIR, "./**/dist/*.tar.gz")
|
||||
chokidar
|
||||
.watch(watchPath, {
|
||||
|
|
|
@ -1094,19 +1094,18 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@budibase/backend-core@1.2.39-alpha.8":
|
||||
version "1.2.39-alpha.8"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.39-alpha.8.tgz#70c4d3de7c68feaa3d7b183e4c9cfb1baf3d3d47"
|
||||
integrity sha512-vBGPIei1qVPmbrHKGD4Swf7ECOWGXV+2buRIOkr0gRawK8oLOXc2xYV1zsDM7jd7rTMwtyF86fL/lhaSkXWwKA==
|
||||
"@budibase/backend-core@1.2.40":
|
||||
version "1.2.40"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.40.tgz#692062478f310eaee780adbc55e266fc3b6649b6"
|
||||
integrity sha512-HUw6IQgKkP345vnQcTok6X+inqYe0WpUL7uFJnm3XERvsAWX4FYWbgDoGJGS0+jZjdPjvARkt4+uZuTAEUFLiQ==
|
||||
dependencies:
|
||||
"@budibase/types" "1.2.39-alpha.8"
|
||||
"@budibase/types" "^1.2.40"
|
||||
"@techpass/passport-openidconnect" "0.3.2"
|
||||
aws-sdk "2.1030.0"
|
||||
bcrypt "5.0.1"
|
||||
dotenv "16.0.1"
|
||||
emitter-listener "1.1.2"
|
||||
ioredis "4.28.0"
|
||||
joi "17.6.0"
|
||||
jsonwebtoken "8.5.1"
|
||||
koa-passport "4.1.4"
|
||||
lodash "4.17.21"
|
||||
|
@ -1178,13 +1177,13 @@
|
|||
svelte-flatpickr "^3.2.3"
|
||||
svelte-portal "^1.0.0"
|
||||
|
||||
"@budibase/pro@1.2.39-alpha.8":
|
||||
version "1.2.39-alpha.8"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.39-alpha.8.tgz#11433da0dba0e6c81ad93d6cabc5ce165db94e0f"
|
||||
integrity sha512-1N3FnVPhUwh2KR0IGiN+EjbY3LpF563Ac2FyT/JgyS9wG6NTP0hV/ugA7TZIvkv2XaYroYMYSPBa/wYtWh4xBQ==
|
||||
"@budibase/pro@1.2.40":
|
||||
version "1.2.40"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.40.tgz#007cad4d8341698104498ae7d1578a7e26760dd7"
|
||||
integrity sha512-lGB0/O8l63FtpP1dOzxowFUjgj7SrRSVsODygPB7oScfUBtbqHyZKC4EafrVpJT4A8hbdh1ijQZ8PLJE/YdRkQ==
|
||||
dependencies:
|
||||
"@budibase/backend-core" "1.2.39-alpha.8"
|
||||
"@budibase/types" "1.2.39-alpha.8"
|
||||
"@budibase/backend-core" "1.2.40"
|
||||
"@budibase/types" "1.2.40"
|
||||
"@koa/router" "8.0.8"
|
||||
joi "17.6.0"
|
||||
node-fetch "^2.6.1"
|
||||
|
@ -1207,10 +1206,10 @@
|
|||
svelte-apexcharts "^1.0.2"
|
||||
svelte-flatpickr "^3.1.0"
|
||||
|
||||
"@budibase/types@1.2.39-alpha.8":
|
||||
version "1.2.39-alpha.8"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.39-alpha.8.tgz#2999dac33da64b41f222d0fe73cfd387957952d9"
|
||||
integrity sha512-UbknZ3Pnl8tdCPy5XKkuW3OQb1T/L+n1slY8/orm8KpR/TOEhK4Q20JRxENqQo5f9Za8bX4COesLjwAmae426Q==
|
||||
"@budibase/types@1.2.40", "@budibase/types@^1.2.40":
|
||||
version "1.2.40"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.40.tgz#c1456728b61966cab7fe3689bd044bf415faa138"
|
||||
integrity sha512-eNZFG0C/GBog87y6StKBjdF/aDJJtUHbAM8NWLUNNqTAiMxO2s3XhDN1dE6t74NBCRFzJo2sAD+34pJHhKFanQ==
|
||||
|
||||
"@bull-board/api@3.7.0":
|
||||
version "3.7.0"
|
||||
|
|
|
@ -291,19 +291,18 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@budibase/backend-core@1.2.39-alpha.8":
|
||||
version "1.2.39-alpha.8"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.39-alpha.8.tgz#70c4d3de7c68feaa3d7b183e4c9cfb1baf3d3d47"
|
||||
integrity sha512-vBGPIei1qVPmbrHKGD4Swf7ECOWGXV+2buRIOkr0gRawK8oLOXc2xYV1zsDM7jd7rTMwtyF86fL/lhaSkXWwKA==
|
||||
"@budibase/backend-core@1.2.40":
|
||||
version "1.2.40"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.40.tgz#692062478f310eaee780adbc55e266fc3b6649b6"
|
||||
integrity sha512-HUw6IQgKkP345vnQcTok6X+inqYe0WpUL7uFJnm3XERvsAWX4FYWbgDoGJGS0+jZjdPjvARkt4+uZuTAEUFLiQ==
|
||||
dependencies:
|
||||
"@budibase/types" "1.2.39-alpha.8"
|
||||
"@budibase/types" "^1.2.40"
|
||||
"@techpass/passport-openidconnect" "0.3.2"
|
||||
aws-sdk "2.1030.0"
|
||||
bcrypt "5.0.1"
|
||||
dotenv "16.0.1"
|
||||
emitter-listener "1.1.2"
|
||||
ioredis "4.28.0"
|
||||
joi "17.6.0"
|
||||
jsonwebtoken "8.5.1"
|
||||
koa-passport "4.1.4"
|
||||
lodash "4.17.21"
|
||||
|
@ -325,21 +324,21 @@
|
|||
uuid "8.3.2"
|
||||
zlib "1.0.5"
|
||||
|
||||
"@budibase/pro@1.2.39-alpha.8":
|
||||
version "1.2.39-alpha.8"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.39-alpha.8.tgz#11433da0dba0e6c81ad93d6cabc5ce165db94e0f"
|
||||
integrity sha512-1N3FnVPhUwh2KR0IGiN+EjbY3LpF563Ac2FyT/JgyS9wG6NTP0hV/ugA7TZIvkv2XaYroYMYSPBa/wYtWh4xBQ==
|
||||
"@budibase/pro@1.2.40":
|
||||
version "1.2.40"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.40.tgz#007cad4d8341698104498ae7d1578a7e26760dd7"
|
||||
integrity sha512-lGB0/O8l63FtpP1dOzxowFUjgj7SrRSVsODygPB7oScfUBtbqHyZKC4EafrVpJT4A8hbdh1ijQZ8PLJE/YdRkQ==
|
||||
dependencies:
|
||||
"@budibase/backend-core" "1.2.39-alpha.8"
|
||||
"@budibase/types" "1.2.39-alpha.8"
|
||||
"@budibase/backend-core" "1.2.40"
|
||||
"@budibase/types" "1.2.40"
|
||||
"@koa/router" "8.0.8"
|
||||
joi "17.6.0"
|
||||
node-fetch "^2.6.1"
|
||||
|
||||
"@budibase/types@1.2.39-alpha.8":
|
||||
version "1.2.39-alpha.8"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.39-alpha.8.tgz#2999dac33da64b41f222d0fe73cfd387957952d9"
|
||||
integrity sha512-UbknZ3Pnl8tdCPy5XKkuW3OQb1T/L+n1slY8/orm8KpR/TOEhK4Q20JRxENqQo5f9Za8bX4COesLjwAmae426Q==
|
||||
"@budibase/types@1.2.40", "@budibase/types@^1.2.40":
|
||||
version "1.2.40"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.40.tgz#c1456728b61966cab7fe3689bd044bf415faa138"
|
||||
integrity sha512-eNZFG0C/GBog87y6StKBjdF/aDJJtUHbAM8NWLUNNqTAiMxO2s3XhDN1dE6t74NBCRFzJo2sAD+34pJHhKFanQ==
|
||||
|
||||
"@cspotcode/source-map-consumer@0.8.0":
|
||||
version "0.8.0"
|
||||
|
|
Loading…
Reference in New Issue