@budibase/cli 1.3.15-alpha.6 → 1.3.15-alpha.7
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/environment.js +1 -0
- package/src/plugins/index.js +27 -2
- package/src/prebuilds.js +4 -1
- package/src/utils.js +17 -0
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.7",
|
|
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.7",
|
|
30
|
+
"@budibase/string-templates": "1.3.15-alpha.7",
|
|
31
|
+
"@budibase/types": "1.3.15-alpha.7",
|
|
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": "d410b9a47c5f1b630d8e189b348cf048b17b06b6"
|
|
56
56
|
}
|
package/src/environment.js
CHANGED
package/src/plugins/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const { PLUGIN_TYPE_ARR } = require("@budibase/types")
|
|
|
7
7
|
const { validate } = require("@budibase/backend-core/plugins")
|
|
8
8
|
const { runPkgCommand } = require("../exec")
|
|
9
9
|
const { join } = require("path")
|
|
10
|
-
const { success, error, info } = require("../utils")
|
|
10
|
+
const { success, error, info, moveDirectory } = require("../utils")
|
|
11
11
|
|
|
12
12
|
function checkInPlugin() {
|
|
13
13
|
if (!fs.existsSync("package.json")) {
|
|
@@ -22,6 +22,24 @@ function checkInPlugin() {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
async function askAboutTopLevel(name) {
|
|
26
|
+
const files = fs.readdirSync(process.cwd())
|
|
27
|
+
// we are in an empty git repo, don't ask
|
|
28
|
+
if (files.find(file => file === ".git")) {
|
|
29
|
+
return false
|
|
30
|
+
} else {
|
|
31
|
+
console.log(
|
|
32
|
+
info(`By default the plugin will be created in the directory "${name}"`)
|
|
33
|
+
)
|
|
34
|
+
console.log(
|
|
35
|
+
info(
|
|
36
|
+
"if you are already in an empty directory, such as a new Git repo, you can disable this functionality."
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
return questions.confirmation("Create top level directory?")
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
25
43
|
async function init(opts) {
|
|
26
44
|
const type = opts["init"] || opts
|
|
27
45
|
if (!type || !PLUGIN_TYPE_ARR.includes(type)) {
|
|
@@ -45,13 +63,20 @@ async function init(opts) {
|
|
|
45
63
|
`An amazing Budibase ${type}!`
|
|
46
64
|
)
|
|
47
65
|
const version = await questions.string("Version", "1.0.0")
|
|
66
|
+
const topLevel = await askAboutTopLevel(name)
|
|
48
67
|
// get the skeleton
|
|
49
68
|
console.log(info("Retrieving project..."))
|
|
50
69
|
await getSkeleton(type, name)
|
|
51
70
|
await fleshOutSkeleton(type, name, desc, version)
|
|
52
71
|
console.log(info("Installing dependencies..."))
|
|
53
72
|
await runPkgCommand("install", join(process.cwd(), name))
|
|
54
|
-
|
|
73
|
+
// if no parent directory desired move to cwd
|
|
74
|
+
if (!topLevel) {
|
|
75
|
+
moveDirectory(name, process.cwd())
|
|
76
|
+
console.log(info(`Plugin created in current directory.`))
|
|
77
|
+
} else {
|
|
78
|
+
console.log(info(`Plugin created in directory "${name}"`))
|
|
79
|
+
}
|
|
55
80
|
}
|
|
56
81
|
|
|
57
82
|
async function verify() {
|
package/src/prebuilds.js
CHANGED
package/src/utils.js
CHANGED
|
@@ -3,6 +3,7 @@ const fs = require("fs")
|
|
|
3
3
|
const axios = require("axios")
|
|
4
4
|
const path = require("path")
|
|
5
5
|
const progress = require("cli-progress")
|
|
6
|
+
const { join } = require("path")
|
|
6
7
|
|
|
7
8
|
exports.downloadFile = async (url, filePath) => {
|
|
8
9
|
filePath = path.resolve(filePath)
|
|
@@ -67,3 +68,19 @@ exports.progressBar = total => {
|
|
|
67
68
|
exports.checkSlashesInUrl = url => {
|
|
68
69
|
return url.replace(/(https?:\/\/)|(\/)+/g, "$1$2")
|
|
69
70
|
}
|
|
71
|
+
|
|
72
|
+
exports.moveDirectory = (oldPath, newPath) => {
|
|
73
|
+
const files = fs.readdirSync(oldPath)
|
|
74
|
+
// check any file exists already
|
|
75
|
+
for (let file of files) {
|
|
76
|
+
if (fs.existsSync(join(newPath, file))) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
"Unable to remove top level directory - some skeleton files already exist."
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for (let file of files) {
|
|
83
|
+
fs.renameSync(join(oldPath, file), join(newPath, file))
|
|
84
|
+
}
|
|
85
|
+
fs.rmdirSync(oldPath)
|
|
86
|
+
}
|