@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budibase/cli",
3
- "version": "1.3.15-alpha.6",
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.6",
30
- "@budibase/string-templates": "1.3.15-alpha.6",
31
- "@budibase/types": "1.3.15-alpha.6",
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": "d511cc183ee3c3e6d084d7b4e121156c74ff03d8"
55
+ "gitHead": "d410b9a47c5f1b630d8e189b348cf048b17b06b6"
56
56
  }
@@ -1 +1,2 @@
1
1
  process.env.NO_JS = "1"
2
+ process.env.JS_BCRYPT = "1"
@@ -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
- console.log(info(`Plugin created in directory "${name}"`))
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
@@ -27,7 +27,10 @@ function checkForBinaries() {
27
27
  }
28
28
 
29
29
  function cleanup(evt) {
30
- if (evt && evt.errno) {
30
+ if (!isNaN(evt)) {
31
+ return
32
+ }
33
+ if (evt) {
31
34
  console.error(
32
35
  error(
33
36
  "Failed to run CLI command - please report with the following message:"
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
+ }