@budibase/cli 2.0.12 → 2.0.14-alpha.0
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/constants.js +2 -0
- package/src/hosting/genUser.js +12 -7
- package/src/hosting/init.js +7 -5
- package/src/hosting/makeFiles.js +11 -9
- package/src/hosting/watch.js +6 -4
- package/src/plugins/index.js +12 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.14-alpha.0",
|
|
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": "
|
|
30
|
-
"@budibase/string-templates": "
|
|
31
|
-
"@budibase/types": "
|
|
29
|
+
"@budibase/backend-core": "2.0.14-alpha.0",
|
|
30
|
+
"@budibase/string-templates": "2.0.14-alpha.0",
|
|
31
|
+
"@budibase/types": "2.0.14-alpha.0",
|
|
32
32
|
"axios": "0.21.2",
|
|
33
33
|
"chalk": "4.1.0",
|
|
34
34
|
"cli-progress": "3.11.2",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"eslint": "^7.20.0",
|
|
55
55
|
"renamer": "^4.0.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "73138b4d579c7330ab0e9723eb61e4d1c37bfb01"
|
|
58
58
|
}
|
package/src/constants.js
CHANGED
package/src/hosting/genUser.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
const { success } = require("../utils")
|
|
2
2
|
const { updateDockerComposeService } = require("./utils")
|
|
3
3
|
const randomString = require("randomstring")
|
|
4
|
+
const { GENERATED_USER_EMAIL } = require("../constants")
|
|
4
5
|
|
|
5
|
-
exports.generateUser = async () => {
|
|
6
|
-
const email =
|
|
7
|
-
|
|
6
|
+
exports.generateUser = async (password, silent) => {
|
|
7
|
+
const email = GENERATED_USER_EMAIL
|
|
8
|
+
if (!password) {
|
|
9
|
+
password = randomString.generate({ length: 6 })
|
|
10
|
+
}
|
|
8
11
|
updateDockerComposeService(service => {
|
|
9
12
|
service.environment["BB_ADMIN_USER_EMAIL"] = email
|
|
10
13
|
service.environment["BB_ADMIN_USER_PASSWORD"] = password
|
|
11
14
|
})
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
if (!silent) {
|
|
16
|
+
console.log(
|
|
17
|
+
success(
|
|
18
|
+
`User admin credentials configured, access with email: ${email} - password: ${password}`
|
|
19
|
+
)
|
|
15
20
|
)
|
|
16
|
-
|
|
21
|
+
}
|
|
17
22
|
}
|
package/src/hosting/init.js
CHANGED
|
@@ -33,7 +33,7 @@ async function getInitConfig(type, isQuick, port) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
exports.init = async opts => {
|
|
36
|
-
let type, isSingle, watchDir, genUser, port
|
|
36
|
+
let type, isSingle, watchDir, genUser, port, silent
|
|
37
37
|
if (typeof opts === "string") {
|
|
38
38
|
type = opts
|
|
39
39
|
} else {
|
|
@@ -42,6 +42,7 @@ exports.init = async opts => {
|
|
|
42
42
|
watchDir = opts["watchPluginDir"]
|
|
43
43
|
genUser = opts["genUser"]
|
|
44
44
|
port = opts["port"]
|
|
45
|
+
silent = opts["silent"]
|
|
45
46
|
}
|
|
46
47
|
const isQuick = type === InitTypes.QUICK || type === InitTypes.DIGITAL_OCEAN
|
|
47
48
|
await checkDockerConfigured()
|
|
@@ -60,14 +61,15 @@ exports.init = async opts => {
|
|
|
60
61
|
const config = await getInitConfig(type, isQuick, port)
|
|
61
62
|
if (!isSingle) {
|
|
62
63
|
await downloadFiles()
|
|
63
|
-
await makeFiles.makeEnv(config)
|
|
64
|
+
await makeFiles.makeEnv(config, silent)
|
|
64
65
|
} else {
|
|
65
|
-
await makeFiles.makeSingleCompose(config)
|
|
66
|
+
await makeFiles.makeSingleCompose(config, silent)
|
|
66
67
|
}
|
|
67
68
|
if (watchDir) {
|
|
68
|
-
await watchPlugins(watchDir)
|
|
69
|
+
await watchPlugins(watchDir, silent)
|
|
69
70
|
}
|
|
70
71
|
if (genUser) {
|
|
71
|
-
|
|
72
|
+
const inputPassword = typeof genUser === "string" ? genUser : null
|
|
73
|
+
await generateUser(inputPassword, silent)
|
|
72
74
|
}
|
|
73
75
|
}
|
package/src/hosting/makeFiles.js
CHANGED
|
@@ -89,7 +89,7 @@ module.exports.QUICK_CONFIG = {
|
|
|
89
89
|
port: 10000,
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
async function make(path, contentsFn, inputs = {}) {
|
|
92
|
+
async function make(path, contentsFn, inputs = {}, silent) {
|
|
93
93
|
const port =
|
|
94
94
|
inputs.port ||
|
|
95
95
|
(await number(
|
|
@@ -98,19 +98,21 @@ async function make(path, contentsFn, inputs = {}) {
|
|
|
98
98
|
))
|
|
99
99
|
const fileContents = contentsFn(port)
|
|
100
100
|
fs.writeFileSync(path, fileContents)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
if (!silent) {
|
|
102
|
+
console.log(
|
|
103
|
+
success(
|
|
104
|
+
`Configuration has been written successfully - please check ${path} for more details.`
|
|
105
|
+
)
|
|
104
106
|
)
|
|
105
|
-
|
|
107
|
+
}
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
module.exports.makeEnv = async (inputs = {}) => {
|
|
109
|
-
return make(ENV_PATH, getEnv, inputs)
|
|
110
|
+
module.exports.makeEnv = async (inputs = {}, silent) => {
|
|
111
|
+
return make(ENV_PATH, getEnv, inputs, silent)
|
|
110
112
|
}
|
|
111
113
|
|
|
112
|
-
module.exports.makeSingleCompose = async (inputs = {}) => {
|
|
113
|
-
return make(COMPOSE_PATH, getSingleCompose, inputs)
|
|
114
|
+
module.exports.makeSingleCompose = async (inputs = {}, silent) => {
|
|
115
|
+
return make(COMPOSE_PATH, getSingleCompose, inputs, silent)
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
module.exports.getEnvProperty = property => {
|
package/src/hosting/watch.js
CHANGED
|
@@ -3,7 +3,7 @@ const fs = require("fs")
|
|
|
3
3
|
const { error, success } = require("../utils")
|
|
4
4
|
const { updateDockerComposeService } = require("./utils")
|
|
5
5
|
|
|
6
|
-
exports.watchPlugins = async pluginPath => {
|
|
6
|
+
exports.watchPlugins = async (pluginPath, silent) => {
|
|
7
7
|
const PLUGIN_PATH = "/plugins"
|
|
8
8
|
// get absolute path
|
|
9
9
|
pluginPath = resolve(pluginPath)
|
|
@@ -28,7 +28,9 @@ exports.watchPlugins = async pluginPath => {
|
|
|
28
28
|
}
|
|
29
29
|
service.volumes.push(`${pluginPath}:${PLUGIN_PATH}`)
|
|
30
30
|
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if (!silent) {
|
|
32
|
+
console.log(
|
|
33
|
+
success(`Docker compose configured to watch directory: ${pluginPath}`)
|
|
34
|
+
)
|
|
35
|
+
}
|
|
34
36
|
}
|
package/src/plugins/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const { join } = require("path")
|
|
|
10
10
|
const { success, error, info, moveDirectory } = require("../utils")
|
|
11
11
|
const { captureEvent } = require("../events")
|
|
12
12
|
const fp = require("find-free-port")
|
|
13
|
+
const { GENERATED_USER_EMAIL } = require("../constants")
|
|
13
14
|
const { init: hostingInit } = require("../hosting/init")
|
|
14
15
|
const { start: hostingStart } = require("../hosting/start")
|
|
15
16
|
|
|
@@ -147,14 +148,24 @@ async function watch() {
|
|
|
147
148
|
async function dev() {
|
|
148
149
|
const pluginDir = await questions.string("Directory to watch", "./")
|
|
149
150
|
const [port] = await fp(10000)
|
|
151
|
+
const password = "admin"
|
|
150
152
|
await hostingInit({
|
|
151
153
|
init: InitTypes.QUICK,
|
|
152
154
|
single: true,
|
|
153
155
|
watchPluginDir: pluginDir,
|
|
154
|
-
genUser:
|
|
156
|
+
genUser: password,
|
|
155
157
|
port,
|
|
158
|
+
silent: true,
|
|
156
159
|
})
|
|
157
160
|
await hostingStart()
|
|
161
|
+
console.log(success(`Configuration has been written to docker-compose.yaml`))
|
|
162
|
+
console.log(
|
|
163
|
+
success("Development environment started successfully - connect at: ") +
|
|
164
|
+
info(`http://localhost:${port}`)
|
|
165
|
+
)
|
|
166
|
+
console.log(success("Use the following credentials to login:"))
|
|
167
|
+
console.log(success("Email: ") + info(GENERATED_USER_EMAIL))
|
|
168
|
+
console.log(success("Password: ") + info(password))
|
|
158
169
|
}
|
|
159
170
|
|
|
160
171
|
const command = new Command(`${CommandWords.PLUGIN}`)
|