@budibase/cli 2.0.34-alpha.5 → 2.0.34-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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budibase/cli",
3
- "version": "2.0.34-alpha.5",
3
+ "version": "2.0.34-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": "2.0.34-alpha.5",
30
- "@budibase/string-templates": "2.0.34-alpha.5",
31
- "@budibase/types": "2.0.34-alpha.5",
29
+ "@budibase/backend-core": "2.0.34-alpha.7",
30
+ "@budibase/string-templates": "2.0.34-alpha.7",
31
+ "@budibase/types": "2.0.34-alpha.7",
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": "cdfa70192e35b47e129974b03dc703ee4005c86d"
57
+ "gitHead": "899da8117bff87550e52d246e54c00bfe88bd56e"
58
58
  }
@@ -4,7 +4,7 @@ const fs = require("fs")
4
4
  const { join } = require("path")
5
5
  const { getAllDbs } = require("../core/db")
6
6
  const tar = require("tar")
7
- const { progressBar } = require("../utils")
7
+ const { progressBar, httpCall } = require("../utils")
8
8
  const {
9
9
  TEMP_DIR,
10
10
  COUCH_DIR,
@@ -86,6 +86,15 @@ async function importBackup(opts) {
86
86
  bar.stop()
87
87
  console.log("MinIO Import")
88
88
  await importObjects()
89
+ // finish by letting the system know that a restore has occurred
90
+ try {
91
+ await httpCall(
92
+ `http://localhost:${config.MAIN_PORT}/api/system/restored`,
93
+ "POST"
94
+ )
95
+ } catch (err) {
96
+ // ignore error - it will be an older system
97
+ }
89
98
  console.log("Import complete")
90
99
  fs.rmSync(TEMP_DIR, { recursive: true })
91
100
  }
@@ -16,16 +16,21 @@ exports.exportObjects = async () => {
16
16
  const path = join(TEMP_DIR, MINIO_DIR)
17
17
  fs.mkdirSync(path)
18
18
  let fullList = []
19
+ let errorCount = 0
19
20
  for (let bucket of bucketList) {
20
21
  const client = ObjectStore(bucket)
21
22
  try {
22
23
  await client.headBucket().promise()
23
24
  } catch (err) {
25
+ errorCount++
24
26
  continue
25
27
  }
26
28
  const list = await client.listObjectsV2().promise()
27
29
  fullList = fullList.concat(list.Contents.map(el => ({ ...el, bucket })))
28
30
  }
31
+ if (errorCount === bucketList.length) {
32
+ throw new Error("Unable to access MinIO/S3 - check environment config.")
33
+ }
29
34
  const bar = progressBar(fullList.length)
30
35
  let count = 0
31
36
  for (let object of fullList) {
@@ -2,17 +2,19 @@ const dotenv = require("dotenv")
2
2
  const fs = require("fs")
3
3
  const { string } = require("../questions")
4
4
  const { getPouch } = require("../core/db")
5
+ const { env: environment } = require("@budibase/backend-core")
5
6
 
6
- exports.DEFAULT_COUCH = "http://budibase:budibase@localhost:10000/db/"
7
- exports.DEFAULT_MINIO = "http://localhost:10000/"
8
7
  exports.TEMP_DIR = ".temp"
9
8
  exports.COUCH_DIR = "couchdb"
10
9
  exports.MINIO_DIR = "minio"
11
10
 
12
11
  const REQUIRED = [
13
12
  { value: "MAIN_PORT", default: "10000" },
14
- { value: "COUCH_DB_URL", default: exports.DEFAULT_COUCH },
15
- { value: "MINIO_URL", default: exports.DEFAULT_MINIO },
13
+ {
14
+ value: "COUCH_DB_URL",
15
+ default: "http://budibase:budibase@localhost:10000/db/",
16
+ },
17
+ { value: "MINIO_URL", default: "http://localhost:10000" },
16
18
  { value: "MINIO_ACCESS_KEY" },
17
19
  { value: "MINIO_SECRET_KEY" },
18
20
  ]
@@ -27,7 +29,7 @@ exports.checkURLs = config => {
27
29
  ] = `http://${username}:${password}@localhost:${mainPort}/db/`
28
30
  }
29
31
  if (!config["MINIO_URL"]) {
30
- config["MINIO_URL"] = exports.DEFAULT_MINIO
32
+ config["MINIO_URL"] = `http://localhost:${mainPort}/`
31
33
  }
32
34
  return config
33
35
  }
@@ -65,6 +67,10 @@ exports.getConfig = async (envFile = true) => {
65
67
  } else {
66
68
  config = await exports.askQuestions()
67
69
  }
70
+ // fill out environment
71
+ for (let key of Object.keys(config)) {
72
+ environment._set(key, config[key])
73
+ }
68
74
  return config
69
75
  }
70
76
 
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  require("./prebuilds")
3
3
  require("./environment")
4
+ const json = require("../package.json")
4
5
  const { getCommands } = require("./options")
5
6
  const { Command } = require("commander")
6
7
  const { getHelpDescription } = require("./utils")
@@ -10,7 +11,7 @@ async function init() {
10
11
  const program = new Command()
11
12
  .addHelpCommand("help", getHelpDescription("Help with Budibase commands."))
12
13
  .helpOption(false)
13
- program.helpOption()
14
+ .version(json.version)
14
15
  // add commands
15
16
  for (let command of getCommands()) {
16
17
  command.configure(program)
package/src/utils.js CHANGED
@@ -23,6 +23,14 @@ exports.downloadFile = async (url, filePath) => {
23
23
  })
24
24
  }
25
25
 
26
+ exports.httpCall = async (url, method) => {
27
+ const response = await axios({
28
+ url,
29
+ method,
30
+ })
31
+ return response.data
32
+ }
33
+
26
34
  exports.getHelpDescription = string => {
27
35
  return chalk.cyan(string)
28
36
  }