@budibase/cli 2.3.18-alpha.3 → 2.3.18-alpha.30

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.
Files changed (70) hide show
  1. package/dist/analytics/Client.js +32 -0
  2. package/dist/analytics/index.js +55 -0
  3. package/dist/backups/index.js +119 -0
  4. package/dist/backups/objectStore.js +82 -0
  5. package/dist/backups/utils.js +110 -0
  6. package/dist/constants.js +9 -0
  7. package/dist/core/db.js +55 -0
  8. package/dist/environment.js +4 -0
  9. package/dist/events.js +13 -0
  10. package/dist/exec.js +49 -0
  11. package/dist/hosting/genUser.js +32 -0
  12. package/dist/hosting/index.js +21 -0
  13. package/dist/hosting/init.js +117 -0
  14. package/dist/hosting/makeFiles.js +143 -0
  15. package/dist/hosting/start.js +63 -0
  16. package/dist/hosting/status.js +30 -0
  17. package/dist/hosting/stop.js +30 -0
  18. package/dist/hosting/types.js +2 -0
  19. package/dist/hosting/update.js +58 -0
  20. package/dist/hosting/utils.js +125 -0
  21. package/dist/hosting/watch.js +47 -0
  22. package/dist/index.js +36 -0
  23. package/dist/options.js +14 -0
  24. package/dist/plugins/index.js +199 -0
  25. package/dist/plugins/skeleton.js +75 -0
  26. package/dist/prebuilds.js +46 -0
  27. package/dist/questions.js +58 -0
  28. package/dist/structures/Command.js +75 -0
  29. package/dist/structures/ConfigManager.js +39 -0
  30. package/dist/tsconfig.build.tsbuildinfo +1 -0
  31. package/dist/utils.js +126 -0
  32. package/package.json +20 -11
  33. package/src/analytics/Client.ts +33 -0
  34. package/src/analytics/{index.js → index.ts} +7 -10
  35. package/src/backups/{index.js → index.ts} +19 -19
  36. package/src/backups/{objectStore.js → objectStore.ts} +9 -9
  37. package/src/backups/{utils.js → utils.ts} +24 -19
  38. package/src/constants.ts +4 -0
  39. package/src/core/{db.js → db.ts} +8 -7
  40. package/src/{environment.js → environment.ts} +1 -0
  41. package/src/events.ts +11 -0
  42. package/src/{exec.js → exec.ts} +7 -7
  43. package/src/hosting/{genUser.js → genUser.ts} +4 -3
  44. package/src/hosting/{index.js → index.ts} +10 -12
  45. package/src/hosting/{init.js → init.ts} +20 -19
  46. package/src/hosting/{makeFiles.js → makeFiles.ts} +23 -21
  47. package/src/hosting/{start.js → start.ts} +6 -10
  48. package/src/hosting/{status.js → status.ts} +4 -8
  49. package/src/hosting/{stop.js → stop.ts} +4 -8
  50. package/src/hosting/types.ts +4 -0
  51. package/src/hosting/{update.js → update.ts} +10 -10
  52. package/src/hosting/{utils.js → utils.ts} +26 -23
  53. package/src/hosting/{watch.js → watch.ts} +7 -6
  54. package/src/{index.js → index.ts} +5 -5
  55. package/src/options.ts +8 -0
  56. package/src/plugins/{index.js → index.ts} +27 -25
  57. package/src/plugins/{skeleton.js → skeleton.ts} +14 -9
  58. package/src/{prebuilds.js → prebuilds.ts} +7 -6
  59. package/src/{questions.js → questions.ts} +6 -6
  60. package/src/structures/{Command.js → Command.ts} +29 -14
  61. package/src/structures/{ConfigManager.js → ConfigManager.ts} +7 -7
  62. package/src/utils.ts +112 -0
  63. package/start.sh +3 -0
  64. package/tsconfig.build.json +24 -0
  65. package/tsconfig.json +30 -0
  66. package/src/analytics/Client.js +0 -32
  67. package/src/constants.js +0 -25
  68. package/src/events.js +0 -11
  69. package/src/options.js +0 -8
  70. package/src/utils.js +0 -106
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es6",
4
+ "module": "commonjs",
5
+ "lib": ["es2020"],
6
+ "strict": true,
7
+ "noImplicitAny": true,
8
+ "esModuleInterop": true,
9
+ "resolveJsonModule": true,
10
+ "incremental": true,
11
+ "types": [ "node", "jest" ],
12
+ "outDir": "dist",
13
+ "skipLibCheck": true
14
+ },
15
+ "include": [
16
+ "src/**/*"
17
+ ],
18
+ "exclude": [
19
+ "node_modules",
20
+ "dist",
21
+ "**/*.spec.ts",
22
+ "**/*.spec.js"
23
+ ]
24
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "extends": "./tsconfig.build.json",
3
+ "compilerOptions": {
4
+ "composite": true,
5
+ "declaration": true,
6
+ "sourceMap": true,
7
+ "baseUrl": ".",
8
+ "paths": {
9
+ "@budibase/types": ["../types/src"],
10
+ "@budibase/backend-core": ["../backend-core/src"],
11
+ "@budibase/backend-core/*": ["../backend-core/*"],
12
+ }
13
+ },
14
+ "ts-node": {
15
+ "require": ["tsconfig-paths/register"],
16
+ "swc": true
17
+ },
18
+ "references": [
19
+ { "path": "../types" },
20
+ { "path": "../backend-core" },
21
+ ],
22
+ "include": [
23
+ "src/**/*",
24
+ "package.json"
25
+ ],
26
+ "exclude": [
27
+ "node_modules",
28
+ "dist"
29
+ ]
30
+ }
@@ -1,32 +0,0 @@
1
- const PostHog = require("posthog-node")
2
- const { POSTHOG_TOKEN, AnalyticsEvents } = require("../constants")
3
- const ConfigManager = require("../structures/ConfigManager")
4
-
5
- class AnalyticsClient {
6
- constructor() {
7
- this.client = new PostHog(POSTHOG_TOKEN)
8
- this.configManager = new ConfigManager()
9
- }
10
-
11
- capture(event) {
12
- if (this.configManager.config.analyticsDisabled) return
13
-
14
- this.client.capture(event)
15
- }
16
-
17
- enable() {
18
- this.configManager.removeKey("analyticsDisabled")
19
- this.client.capture({ event: AnalyticsEvents.OptIn, distinctId: "cli" })
20
- }
21
-
22
- disable() {
23
- this.client.capture({ event: AnalyticsEvents.OptOut, distinctId: "cli" })
24
- this.configManager.setValue("analyticsDisabled", true)
25
- }
26
-
27
- status() {
28
- return this.configManager.config.analyticsDisabled ? "disabled" : "enabled"
29
- }
30
- }
31
-
32
- module.exports = AnalyticsClient
package/src/constants.js DELETED
@@ -1,25 +0,0 @@
1
- const { Event } = require("@budibase/types")
2
-
3
- exports.CommandWords = {
4
- BACKUPS: "backups",
5
- HOSTING: "hosting",
6
- ANALYTICS: "analytics",
7
- HELP: "help",
8
- PLUGIN: "plugins",
9
- }
10
-
11
- exports.InitTypes = {
12
- QUICK: "quick",
13
- DIGITAL_OCEAN: "do",
14
- }
15
-
16
- exports.AnalyticsEvents = {
17
- OptOut: "analytics:opt:out",
18
- OptIn: "analytics:opt:in",
19
- SelfHostInit: "hosting:init",
20
- PluginInit: Event.PLUGIN_INIT,
21
- }
22
-
23
- exports.POSTHOG_TOKEN = "phc_yGOn4i7jWKaCTapdGR6lfA4AvmuEQ2ijn5zAVSFYPlS"
24
-
25
- exports.GENERATED_USER_EMAIL = "admin@admin.com"
package/src/events.js DELETED
@@ -1,11 +0,0 @@
1
- const AnalyticsClient = require("./analytics/Client")
2
-
3
- const client = new AnalyticsClient()
4
-
5
- exports.captureEvent = (event, properties) => {
6
- client.capture({
7
- distinctId: "cli",
8
- event,
9
- properties,
10
- })
11
- }
package/src/options.js DELETED
@@ -1,8 +0,0 @@
1
- const analytics = require("./analytics")
2
- const hosting = require("./hosting")
3
- const backups = require("./backups")
4
- const plugins = require("./plugins")
5
-
6
- exports.getCommands = () => {
7
- return [hosting.command, analytics.command, backups.command, plugins.command]
8
- }
package/src/utils.js DELETED
@@ -1,106 +0,0 @@
1
- const chalk = require("chalk")
2
- const fs = require("fs")
3
- const axios = require("axios")
4
- const path = require("path")
5
- const progress = require("cli-progress")
6
- const { join } = require("path")
7
-
8
- exports.downloadFile = async (url, filePath) => {
9
- filePath = path.resolve(filePath)
10
- const writer = fs.createWriteStream(filePath)
11
-
12
- const response = await axios({
13
- url,
14
- method: "GET",
15
- responseType: "stream",
16
- })
17
-
18
- response.data.pipe(writer)
19
-
20
- return new Promise((resolve, reject) => {
21
- writer.on("finish", resolve)
22
- writer.on("error", reject)
23
- })
24
- }
25
-
26
- exports.httpCall = async (url, method) => {
27
- const response = await axios({
28
- url,
29
- method,
30
- })
31
- return response.data
32
- }
33
-
34
- exports.getHelpDescription = string => {
35
- return chalk.cyan(string)
36
- }
37
-
38
- exports.getSubHelpDescription = string => {
39
- return chalk.green(string)
40
- }
41
-
42
- exports.error = error => {
43
- return chalk.red(`Error - ${error}`)
44
- }
45
-
46
- exports.success = success => {
47
- return chalk.green(success)
48
- }
49
-
50
- exports.info = info => {
51
- return chalk.cyan(info)
52
- }
53
-
54
- exports.logErrorToFile = (file, error) => {
55
- fs.writeFileSync(path.resolve(`./${file}`), `Budibase Error\n${error}`)
56
- }
57
-
58
- exports.parseEnv = env => {
59
- const lines = env.toString().split("\n")
60
- let result = {}
61
- for (const line of lines) {
62
- const match = line.match(/^([^=:#]+?)[=:](.*)/)
63
- if (match) {
64
- result[match[1].trim()] = match[2].trim()
65
- }
66
- }
67
- return result
68
- }
69
-
70
- exports.progressBar = total => {
71
- const bar = new progress.SingleBar({}, progress.Presets.shades_classic)
72
- bar.start(total, 0)
73
- return bar
74
- }
75
-
76
- exports.checkSlashesInUrl = url => {
77
- return url.replace(/(https?:\/\/)|(\/)+/g, "$1$2")
78
- }
79
-
80
- exports.moveDirectory = (oldPath, newPath) => {
81
- const files = fs.readdirSync(oldPath)
82
- // check any file exists already
83
- for (let file of files) {
84
- if (fs.existsSync(join(newPath, file))) {
85
- throw new Error(
86
- "Unable to remove top level directory - some skeleton files already exist."
87
- )
88
- }
89
- }
90
- for (let file of files) {
91
- fs.renameSync(join(oldPath, file), join(newPath, file))
92
- }
93
- fs.rmdirSync(oldPath)
94
- }
95
-
96
- exports.capitaliseFirstLetter = str => {
97
- return str.charAt(0).toUpperCase() + str.slice(1)
98
- }
99
-
100
- exports.stringifyToDotEnv = json => {
101
- let str = ""
102
- for (let [key, value] of Object.entries(json)) {
103
- str += `${key}=${value}\n`
104
- }
105
- return str
106
- }