@budibase/cli 1.3.15-alpha.0 → 1.3.15-alpha.3
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/package.json +5 -5
- package/src/plugins/index.js +3 -3
- package/src/plugins/constants.js +0 -6
- package/src/plugins/validate.js +0 -91
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/cli",
|
|
3
|
-
"version": "1.3.15-alpha.
|
|
3
|
+
"version": "1.3.15-alpha.3",
|
|
4
4
|
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"outputPath": "build"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@budibase/backend-core": "1.3.15-alpha.
|
|
30
|
-
"@budibase/string-templates": "1.3.15-alpha.
|
|
31
|
-
"@budibase/types": "1.3.15-alpha.
|
|
29
|
+
"@budibase/backend-core": "1.3.15-alpha.3",
|
|
30
|
+
"@budibase/string-templates": "1.3.15-alpha.3",
|
|
31
|
+
"@budibase/types": "1.3.15-alpha.3",
|
|
32
32
|
"axios": "0.21.2",
|
|
33
33
|
"chalk": "4.1.0",
|
|
34
34
|
"cli-progress": "3.11.2",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"eslint": "^7.20.0",
|
|
53
53
|
"renamer": "^4.0.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "a1eafcef980f6ed36933a6d2953e35b0de82be51"
|
|
56
56
|
}
|
package/src/plugins/index.js
CHANGED
|
@@ -3,8 +3,8 @@ const { CommandWords } = require("../constants")
|
|
|
3
3
|
const { getSkeleton, fleshOutSkeleton } = require("./skeleton")
|
|
4
4
|
const questions = require("../questions")
|
|
5
5
|
const fs = require("fs")
|
|
6
|
-
const {
|
|
7
|
-
const { validate } = require("
|
|
6
|
+
const { PLUGIN_TYPE_ARR } = require("@budibase/types")
|
|
7
|
+
const { validate } = require("@budibase/backend-core/plugins")
|
|
8
8
|
const { runPkgCommand } = require("../exec")
|
|
9
9
|
const { join } = require("path")
|
|
10
10
|
const { success, error, info } = require("../utils")
|
|
@@ -24,7 +24,7 @@ function checkInPlugin() {
|
|
|
24
24
|
|
|
25
25
|
async function init(opts) {
|
|
26
26
|
const type = opts["init"] || opts
|
|
27
|
-
if (!type || !
|
|
27
|
+
if (!type || !PLUGIN_TYPE_ARR.includes(type)) {
|
|
28
28
|
console.log(
|
|
29
29
|
error(
|
|
30
30
|
"Please provide a type to init, either 'component' or 'datasource'."
|
package/src/plugins/constants.js
DELETED
package/src/plugins/validate.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
const { PluginTypes } = require("./constants")
|
|
2
|
-
const { DatasourceFieldType, QueryType } = require("@budibase/types")
|
|
3
|
-
const joi = require("joi")
|
|
4
|
-
|
|
5
|
-
const DATASOURCE_TYPES = [
|
|
6
|
-
"Relational",
|
|
7
|
-
"Non-relational",
|
|
8
|
-
"Spreadsheet",
|
|
9
|
-
"Object store",
|
|
10
|
-
"Graph",
|
|
11
|
-
"API",
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
function runJoi(validator, schema) {
|
|
15
|
-
const { error } = validator.validate(schema)
|
|
16
|
-
if (error) {
|
|
17
|
-
throw error
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function validateComponent(schema) {
|
|
22
|
-
const validator = joi.object({
|
|
23
|
-
type: joi.string().allow("component").required(),
|
|
24
|
-
metadata: joi.object().unknown(true).required(),
|
|
25
|
-
hash: joi.string().optional(),
|
|
26
|
-
version: joi.string().optional(),
|
|
27
|
-
schema: joi
|
|
28
|
-
.object({
|
|
29
|
-
name: joi.string().required(),
|
|
30
|
-
settings: joi.array().items(joi.object().unknown(true)).required(),
|
|
31
|
-
})
|
|
32
|
-
.unknown(true),
|
|
33
|
-
})
|
|
34
|
-
runJoi(validator, schema)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function validateDatasource(schema) {
|
|
38
|
-
const fieldValidator = joi.object({
|
|
39
|
-
type: joi
|
|
40
|
-
.string()
|
|
41
|
-
.allow(...Object.values(DatasourceFieldType))
|
|
42
|
-
.required(),
|
|
43
|
-
required: joi.boolean().required(),
|
|
44
|
-
default: joi.any(),
|
|
45
|
-
display: joi.string(),
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const queryValidator = joi
|
|
49
|
-
.object({
|
|
50
|
-
type: joi.string().allow(...Object.values(QueryType)),
|
|
51
|
-
fields: joi.object().pattern(joi.string(), fieldValidator),
|
|
52
|
-
})
|
|
53
|
-
.required()
|
|
54
|
-
|
|
55
|
-
const validator = joi.object({
|
|
56
|
-
type: joi.string().allow("datasource").required(),
|
|
57
|
-
metadata: joi.object().unknown(true).required(),
|
|
58
|
-
hash: joi.string().optional(),
|
|
59
|
-
version: joi.string().optional(),
|
|
60
|
-
schema: joi.object({
|
|
61
|
-
docs: joi.string(),
|
|
62
|
-
friendlyName: joi.string().required(),
|
|
63
|
-
type: joi.string().allow(...DATASOURCE_TYPES),
|
|
64
|
-
description: joi.string().required(),
|
|
65
|
-
datasource: joi.object().pattern(joi.string(), fieldValidator).required(),
|
|
66
|
-
query: joi
|
|
67
|
-
.object({
|
|
68
|
-
create: queryValidator,
|
|
69
|
-
read: queryValidator,
|
|
70
|
-
update: queryValidator,
|
|
71
|
-
delete: queryValidator,
|
|
72
|
-
})
|
|
73
|
-
.unknown(true)
|
|
74
|
-
.required(),
|
|
75
|
-
}),
|
|
76
|
-
})
|
|
77
|
-
runJoi(validator, schema)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
exports.validate = schema => {
|
|
81
|
-
switch (schema.type) {
|
|
82
|
-
case PluginTypes.COMPONENT:
|
|
83
|
-
validateComponent(schema)
|
|
84
|
-
break
|
|
85
|
-
case PluginTypes.DATASOURCE:
|
|
86
|
-
validateDatasource(schema)
|
|
87
|
-
break
|
|
88
|
-
default:
|
|
89
|
-
throw new Error(`Unknown plugin type - check schema.json: ${schema.type}`)
|
|
90
|
-
}
|
|
91
|
-
}
|