@budibase/cli 2.3.20 → 2.3.21-alpha.1
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/dist/analytics/Client.js +32 -0
- package/dist/analytics/index.js +55 -0
- package/dist/backups/index.js +119 -0
- package/dist/backups/objectStore.js +82 -0
- package/dist/backups/utils.js +110 -0
- package/dist/constants.js +9 -0
- package/dist/core/db.js +55 -0
- package/dist/environment.js +4 -0
- package/dist/events.js +13 -0
- package/dist/exec.js +49 -0
- package/dist/hosting/genUser.js +32 -0
- package/dist/hosting/index.js +21 -0
- package/dist/hosting/init.js +117 -0
- package/dist/hosting/makeFiles.js +143 -0
- package/dist/hosting/start.js +63 -0
- package/dist/hosting/status.js +30 -0
- package/dist/hosting/stop.js +30 -0
- package/dist/hosting/types.js +2 -0
- package/dist/hosting/update.js +58 -0
- package/dist/hosting/utils.js +125 -0
- package/dist/hosting/watch.js +47 -0
- package/dist/index.js +36 -0
- package/dist/options.js +14 -0
- package/dist/plugins/index.js +199 -0
- package/dist/plugins/skeleton.js +75 -0
- package/dist/prebuilds.js +46 -0
- package/dist/questions.js +58 -0
- package/dist/structures/Command.js +75 -0
- package/dist/structures/ConfigManager.js +39 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/utils.js +126 -0
- package/package.json +20 -10
- package/src/analytics/Client.ts +33 -0
- package/src/analytics/{index.js → index.ts} +7 -10
- package/src/backups/{index.js → index.ts} +19 -19
- package/src/backups/{objectStore.js → objectStore.ts} +9 -9
- package/src/backups/{utils.js → utils.ts} +33 -28
- package/src/constants.ts +4 -0
- package/src/core/{db.js → db.ts} +8 -7
- package/src/{environment.js → environment.ts} +1 -0
- package/src/events.ts +11 -0
- package/src/{exec.js → exec.ts} +7 -7
- package/src/hosting/{genUser.js → genUser.ts} +4 -3
- package/src/hosting/{index.js → index.ts} +10 -12
- package/src/hosting/{init.js → init.ts} +20 -19
- package/src/hosting/{makeFiles.js → makeFiles.ts} +23 -21
- package/src/hosting/{start.js → start.ts} +6 -10
- package/src/hosting/{status.js → status.ts} +4 -8
- package/src/hosting/{stop.js → stop.ts} +4 -8
- package/src/hosting/types.ts +4 -0
- package/src/hosting/{update.js → update.ts} +10 -10
- package/src/hosting/{utils.js → utils.ts} +26 -23
- package/src/hosting/{watch.js → watch.ts} +7 -6
- package/src/{index.js → index.ts} +5 -5
- package/src/options.ts +8 -0
- package/src/plugins/{index.js → index.ts} +27 -25
- package/src/plugins/{skeleton.js → skeleton.ts} +14 -9
- package/src/{prebuilds.js → prebuilds.ts} +7 -6
- package/src/{questions.js → questions.ts} +6 -6
- package/src/structures/{Command.js → Command.ts} +29 -14
- package/src/structures/{ConfigManager.js → ConfigManager.ts} +7 -7
- package/src/utils.ts +112 -0
- package/start.sh +3 -0
- package/tsconfig.build.json +24 -0
- package/tsconfig.json +30 -0
- package/src/analytics/Client.js +0 -32
- package/src/constants.js +0 -25
- package/src/events.js +0 -11
- package/src/options.js +0 -8
- package/src/utils.js +0 -106
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.init = void 0;
|
|
39
|
+
const constants_1 = require("../constants");
|
|
40
|
+
const questions_1 = require("../questions");
|
|
41
|
+
const events_1 = require("../events");
|
|
42
|
+
const makeFiles = __importStar(require("./makeFiles"));
|
|
43
|
+
const utils_1 = require("../utils");
|
|
44
|
+
const utils_2 = require("./utils");
|
|
45
|
+
const watch_1 = require("./watch");
|
|
46
|
+
const genUser_1 = require("./genUser");
|
|
47
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
48
|
+
const DO_USER_DATA_URL = "http://169.254.169.254/metadata/v1/user-data";
|
|
49
|
+
function getInitConfig(type, isQuick, port) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const config = isQuick ? makeFiles.QUICK_CONFIG : {};
|
|
52
|
+
if (type === constants_1.InitType.DIGITAL_OCEAN) {
|
|
53
|
+
try {
|
|
54
|
+
const output = yield (0, node_fetch_1.default)(DO_USER_DATA_URL);
|
|
55
|
+
const data = yield output.text();
|
|
56
|
+
const response = (0, utils_1.parseEnv)(data);
|
|
57
|
+
for (let [key, value] of Object.entries(makeFiles.ConfigMap)) {
|
|
58
|
+
if (response[key]) {
|
|
59
|
+
config[value] = response[key];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
// don't need to handle error, just don't do anything
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// override port
|
|
68
|
+
if (port) {
|
|
69
|
+
config[makeFiles.ConfigMap.MAIN_PORT] = port;
|
|
70
|
+
}
|
|
71
|
+
return config;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function init(opts) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
let type, isSingle, watchDir, genUser, port, silent;
|
|
77
|
+
if (typeof opts === "string") {
|
|
78
|
+
type = opts;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
type = opts["init"];
|
|
82
|
+
isSingle = opts["single"];
|
|
83
|
+
watchDir = opts["watchPluginDir"];
|
|
84
|
+
genUser = opts["genUser"];
|
|
85
|
+
port = opts["port"];
|
|
86
|
+
silent = opts["silent"];
|
|
87
|
+
}
|
|
88
|
+
const isQuick = type === constants_1.InitType.QUICK || type === constants_1.InitType.DIGITAL_OCEAN;
|
|
89
|
+
yield (0, utils_2.checkDockerConfigured)();
|
|
90
|
+
if (!isQuick) {
|
|
91
|
+
const shouldContinue = yield (0, questions_1.confirmation)("This will create multiple files in current directory, should continue?");
|
|
92
|
+
if (!shouldContinue) {
|
|
93
|
+
console.log("Stopping.");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
(0, events_1.captureEvent)(constants_1.AnalyticsEvent.SelfHostInit, {
|
|
98
|
+
type,
|
|
99
|
+
});
|
|
100
|
+
const config = yield getInitConfig(type, isQuick, port);
|
|
101
|
+
if (!isSingle) {
|
|
102
|
+
yield (0, utils_2.downloadDockerCompose)();
|
|
103
|
+
yield makeFiles.makeEnv(config, silent);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
yield makeFiles.makeSingleCompose(config, silent);
|
|
107
|
+
}
|
|
108
|
+
if (watchDir) {
|
|
109
|
+
yield (0, watch_1.watchPlugins)(watchDir, silent);
|
|
110
|
+
}
|
|
111
|
+
if (genUser) {
|
|
112
|
+
const inputPassword = typeof genUser === "string" ? genUser : null;
|
|
113
|
+
yield (0, genUser_1.generateUser)(inputPassword, silent);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
exports.init = init;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getComposeProperty = exports.getEnvProperty = exports.makeSingleCompose = exports.makeEnv = exports.QUICK_CONFIG = exports.ConfigMap = exports.ENV_PATH = exports.COMPOSE_PATH = void 0;
|
|
16
|
+
const questions_1 = require("../questions");
|
|
17
|
+
const utils_1 = require("../utils");
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
21
|
+
const utils_2 = require("./utils");
|
|
22
|
+
const randomString = require("randomstring");
|
|
23
|
+
const SINGLE_IMAGE = "budibase/budibase:latest";
|
|
24
|
+
const VOL_NAME = "budibase_data";
|
|
25
|
+
exports.COMPOSE_PATH = path_1.default.resolve("./docker-compose.yaml");
|
|
26
|
+
exports.ENV_PATH = path_1.default.resolve("./.env");
|
|
27
|
+
function getSecrets(opts = { single: false }) {
|
|
28
|
+
const secrets = [
|
|
29
|
+
"JWT_SECRET",
|
|
30
|
+
"MINIO_ACCESS_KEY",
|
|
31
|
+
"MINIO_SECRET_KEY",
|
|
32
|
+
"REDIS_PASSWORD",
|
|
33
|
+
"INTERNAL_API_KEY",
|
|
34
|
+
];
|
|
35
|
+
const obj = {};
|
|
36
|
+
secrets.forEach(secret => (obj[secret] = randomString.generate()));
|
|
37
|
+
// setup couch creds separately
|
|
38
|
+
if (opts && opts.single) {
|
|
39
|
+
obj["COUCHDB_USER"] = "admin";
|
|
40
|
+
obj["COUCHDB_PASSWORD"] = randomString.generate();
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
obj["COUCH_DB_USER"] = "admin";
|
|
44
|
+
obj["COUCH_DB_PASSWORD"] = randomString.generate();
|
|
45
|
+
}
|
|
46
|
+
return obj;
|
|
47
|
+
}
|
|
48
|
+
function getSingleCompose(port) {
|
|
49
|
+
const singleComposeObj = {
|
|
50
|
+
version: "3",
|
|
51
|
+
services: {
|
|
52
|
+
budibase: {
|
|
53
|
+
restart: "unless-stopped",
|
|
54
|
+
image: SINGLE_IMAGE,
|
|
55
|
+
ports: [`${port}:80`],
|
|
56
|
+
environment: getSecrets({ single: true }),
|
|
57
|
+
volumes: [`${VOL_NAME}:/data`],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
volumes: {
|
|
61
|
+
[VOL_NAME]: {
|
|
62
|
+
driver: "local",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
return yaml_1.default.stringify(singleComposeObj);
|
|
67
|
+
}
|
|
68
|
+
function getEnv(port) {
|
|
69
|
+
const partOne = (0, utils_1.stringifyToDotEnv)({
|
|
70
|
+
MAIN_PORT: port,
|
|
71
|
+
});
|
|
72
|
+
const partTwo = (0, utils_1.stringifyToDotEnv)(getSecrets());
|
|
73
|
+
const partThree = (0, utils_1.stringifyToDotEnv)({
|
|
74
|
+
APP_PORT: 4002,
|
|
75
|
+
WORKER_PORT: 4003,
|
|
76
|
+
MINIO_PORT: 4004,
|
|
77
|
+
COUCH_DB_PORT: 4005,
|
|
78
|
+
REDIS_PORT: 6379,
|
|
79
|
+
WATCHTOWER_PORT: 6161,
|
|
80
|
+
BUDIBASE_ENVIRONMENT: "PRODUCTION",
|
|
81
|
+
});
|
|
82
|
+
return [
|
|
83
|
+
"# Use the main port in the builder for your self hosting URL, e.g. localhost:10000",
|
|
84
|
+
partOne,
|
|
85
|
+
"# This section contains all secrets pertaining to the system",
|
|
86
|
+
partTwo,
|
|
87
|
+
"# This section contains variables that do not need to be altered under normal circumstances",
|
|
88
|
+
partThree,
|
|
89
|
+
].join("\n");
|
|
90
|
+
}
|
|
91
|
+
exports.ConfigMap = {
|
|
92
|
+
MAIN_PORT: "port",
|
|
93
|
+
};
|
|
94
|
+
exports.QUICK_CONFIG = {
|
|
95
|
+
key: "budibase",
|
|
96
|
+
port: 10000,
|
|
97
|
+
};
|
|
98
|
+
function make(path, contentsFn, inputs = {}, silent) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const port = inputs.port ||
|
|
101
|
+
(yield (0, questions_1.number)("Please enter the port on which you want your installation to run: ", 10000));
|
|
102
|
+
const fileContents = contentsFn(port);
|
|
103
|
+
fs_1.default.writeFileSync(path, fileContents);
|
|
104
|
+
if (!silent) {
|
|
105
|
+
console.log((0, utils_1.success)(`Configuration has been written successfully - please check ${path} for more details.`));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function makeEnv(inputs = {}, silent) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
return make(exports.ENV_PATH, getEnv, inputs, silent);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
exports.makeEnv = makeEnv;
|
|
115
|
+
function makeSingleCompose(inputs = {}, silent) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
return make(exports.COMPOSE_PATH, getSingleCompose, inputs, silent);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
exports.makeSingleCompose = makeSingleCompose;
|
|
121
|
+
function getEnvProperty(property) {
|
|
122
|
+
const props = fs_1.default.readFileSync(exports.ENV_PATH, "utf8").split(property);
|
|
123
|
+
if (props[0].charAt(0) === "=") {
|
|
124
|
+
property = props[0];
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
property = props[1];
|
|
128
|
+
}
|
|
129
|
+
return property.split("=")[1].split("\n")[0];
|
|
130
|
+
}
|
|
131
|
+
exports.getEnvProperty = getEnvProperty;
|
|
132
|
+
function getComposeProperty(property) {
|
|
133
|
+
const { service } = (0, utils_2.getAppService)(exports.COMPOSE_PATH);
|
|
134
|
+
if (property === "port" && Array.isArray(service.ports)) {
|
|
135
|
+
const port = service.ports[0];
|
|
136
|
+
return port.split(":")[0];
|
|
137
|
+
}
|
|
138
|
+
else if (service.environment) {
|
|
139
|
+
return service.environment[property];
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
exports.getComposeProperty = getComposeProperty;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.start = void 0;
|
|
39
|
+
const utils_1 = require("./utils");
|
|
40
|
+
const utils_2 = require("../utils");
|
|
41
|
+
const makeFiles = __importStar(require("./makeFiles"));
|
|
42
|
+
const docker_compose_1 = __importDefault(require("docker-compose"));
|
|
43
|
+
const fs_1 = __importDefault(require("fs"));
|
|
44
|
+
function start() {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
yield (0, utils_1.checkDockerConfigured)();
|
|
47
|
+
(0, utils_1.checkInitComplete)();
|
|
48
|
+
console.log((0, utils_2.info)("Starting services, this may take a moment - first time this may take a few minutes to download images."));
|
|
49
|
+
let port;
|
|
50
|
+
if (fs_1.default.existsSync(makeFiles.ENV_PATH)) {
|
|
51
|
+
port = makeFiles.getEnvProperty("MAIN_PORT");
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
port = makeFiles.getComposeProperty("port");
|
|
55
|
+
}
|
|
56
|
+
yield (0, utils_1.handleError)(() => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
// need to log as it makes it more clear
|
|
58
|
+
yield docker_compose_1.default.upAll({ cwd: "./", log: true });
|
|
59
|
+
}));
|
|
60
|
+
console.log((0, utils_2.success)(`Services started, please go to http://localhost:${port} for next steps.`));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.start = start;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.status = void 0;
|
|
16
|
+
const utils_1 = require("./utils");
|
|
17
|
+
const utils_2 = require("../utils");
|
|
18
|
+
const docker_compose_1 = __importDefault(require("docker-compose"));
|
|
19
|
+
function status() {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
yield (0, utils_1.checkDockerConfigured)();
|
|
22
|
+
(0, utils_1.checkInitComplete)();
|
|
23
|
+
console.log((0, utils_2.info)("Budibase status"));
|
|
24
|
+
yield (0, utils_1.handleError)(() => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const response = yield docker_compose_1.default.ps();
|
|
26
|
+
console.log(response.out);
|
|
27
|
+
}));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.status = status;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.stop = void 0;
|
|
16
|
+
const utils_1 = require("./utils");
|
|
17
|
+
const utils_2 = require("../utils");
|
|
18
|
+
const docker_compose_1 = __importDefault(require("docker-compose"));
|
|
19
|
+
function stop() {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
yield (0, utils_1.checkDockerConfigured)();
|
|
22
|
+
(0, utils_1.checkInitComplete)();
|
|
23
|
+
console.log((0, utils_2.info)("Stopping services, this may take a moment."));
|
|
24
|
+
yield (0, utils_1.handleError)(() => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
yield docker_compose_1.default.stop();
|
|
26
|
+
}));
|
|
27
|
+
console.log((0, utils_2.success)("Services have been stopped successfully."));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.stop = stop;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.update = void 0;
|
|
16
|
+
const utils_1 = require("./utils");
|
|
17
|
+
const questions_1 = require("../questions");
|
|
18
|
+
const docker_compose_1 = __importDefault(require("docker-compose"));
|
|
19
|
+
const makeFiles_1 = require("./makeFiles");
|
|
20
|
+
const utils_2 = require("../utils");
|
|
21
|
+
const start_1 = require("./start");
|
|
22
|
+
const BB_COMPOSE_SERVICES = ["app-service", "worker-service", "proxy-service"];
|
|
23
|
+
const BB_SINGLE_SERVICE = ["budibase"];
|
|
24
|
+
function update() {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const { services } = (0, utils_1.getServices)(makeFiles_1.COMPOSE_PATH);
|
|
27
|
+
const isSingle = Object.keys(services).length === 1;
|
|
28
|
+
yield (0, utils_1.checkDockerConfigured)();
|
|
29
|
+
(0, utils_1.checkInitComplete)();
|
|
30
|
+
if (!isSingle &&
|
|
31
|
+
(yield (0, questions_1.confirmation)("Do you wish to update you docker-compose.yaml?"))) {
|
|
32
|
+
yield (0, utils_1.downloadDockerCompose)();
|
|
33
|
+
}
|
|
34
|
+
yield (0, utils_1.handleError)(() => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const status = yield docker_compose_1.default.ps();
|
|
36
|
+
const parts = status.out.split("\n");
|
|
37
|
+
const isUp = parts[2] && parts[2].indexOf("Up") !== -1;
|
|
38
|
+
if (isUp) {
|
|
39
|
+
console.log((0, utils_2.info)("Stopping services, this may take a moment."));
|
|
40
|
+
yield docker_compose_1.default.stop();
|
|
41
|
+
}
|
|
42
|
+
console.log((0, utils_2.info)("Beginning update, this may take a few minutes."));
|
|
43
|
+
let services;
|
|
44
|
+
if (isSingle) {
|
|
45
|
+
services = BB_SINGLE_SERVICE;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
services = BB_COMPOSE_SERVICES;
|
|
49
|
+
}
|
|
50
|
+
yield docker_compose_1.default.pullMany(services, { log: true });
|
|
51
|
+
if (isUp) {
|
|
52
|
+
console.log((0, utils_2.success)("Update complete, restarting services..."));
|
|
53
|
+
yield (0, start_1.start)();
|
|
54
|
+
}
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.update = update;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.updateDockerComposeService = exports.getAppService = exports.getServices = exports.handleError = exports.checkInitComplete = exports.checkDockerConfigured = exports.downloadDockerCompose = void 0;
|
|
39
|
+
const lookpath_1 = require("lookpath");
|
|
40
|
+
const fs_1 = __importDefault(require("fs"));
|
|
41
|
+
const makeFiles = __importStar(require("./makeFiles"));
|
|
42
|
+
const utils_1 = require("../utils");
|
|
43
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
44
|
+
const ERROR_FILE = "docker-error.log";
|
|
45
|
+
const COMPOSE_URL = "https://raw.githubusercontent.com/Budibase/budibase/master/hosting/docker-compose.yaml";
|
|
46
|
+
function downloadDockerCompose() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const fileName = COMPOSE_URL.split("/").slice(-1)[0];
|
|
49
|
+
try {
|
|
50
|
+
yield (0, utils_1.downloadFile)(COMPOSE_URL, `./${fileName}`);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
console.error((0, utils_1.error)(`Failed to retrieve compose file - ${err}`));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.downloadDockerCompose = downloadDockerCompose;
|
|
58
|
+
function checkDockerConfigured() {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const error = "docker/docker-compose has not been installed, please follow instructions at: https://docs.budibase.com/docs/docker-compose";
|
|
61
|
+
const docker = yield (0, lookpath_1.lookpath)("docker");
|
|
62
|
+
const compose = yield (0, lookpath_1.lookpath)("docker-compose");
|
|
63
|
+
if (!docker || !compose) {
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
exports.checkDockerConfigured = checkDockerConfigured;
|
|
69
|
+
function checkInitComplete() {
|
|
70
|
+
if (!fs_1.default.existsSync(makeFiles.ENV_PATH) &&
|
|
71
|
+
!fs_1.default.existsSync(makeFiles.COMPOSE_PATH)) {
|
|
72
|
+
throw "Please run the hosting --init command before any other hosting command.";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.checkInitComplete = checkInitComplete;
|
|
76
|
+
function handleError(func) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
try {
|
|
79
|
+
yield func();
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
if (err && err.err) {
|
|
83
|
+
(0, utils_1.logErrorToFile)(ERROR_FILE, err.err);
|
|
84
|
+
}
|
|
85
|
+
throw `Failed to start - logs written to file: ${ERROR_FILE}`;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
exports.handleError = handleError;
|
|
90
|
+
function getServices(path) {
|
|
91
|
+
const dockerYaml = fs_1.default.readFileSync(path, "utf8");
|
|
92
|
+
const parsedYaml = yaml_1.default.parse(dockerYaml);
|
|
93
|
+
return { yaml: parsedYaml, services: parsedYaml.services };
|
|
94
|
+
}
|
|
95
|
+
exports.getServices = getServices;
|
|
96
|
+
function getAppService(path) {
|
|
97
|
+
const { yaml, services } = getServices(path), serviceList = Object.keys(services);
|
|
98
|
+
let service;
|
|
99
|
+
if (services["app-service"]) {
|
|
100
|
+
service = services["app-service"];
|
|
101
|
+
}
|
|
102
|
+
else if (serviceList.length === 1) {
|
|
103
|
+
service = services[serviceList[0]];
|
|
104
|
+
}
|
|
105
|
+
return { yaml, service };
|
|
106
|
+
}
|
|
107
|
+
exports.getAppService = getAppService;
|
|
108
|
+
function updateDockerComposeService(
|
|
109
|
+
// eslint-disable-next-line no-unused-vars
|
|
110
|
+
updateFn) {
|
|
111
|
+
const opts = ["docker-compose.yaml", "docker-compose.yml"];
|
|
112
|
+
const dockerFilePath = opts.find(name => fs_1.default.existsSync(name));
|
|
113
|
+
if (!dockerFilePath) {
|
|
114
|
+
console.log((0, utils_1.error)("Unable to locate docker-compose YAML."));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const { yaml: parsedYaml, service } = getAppService(dockerFilePath);
|
|
118
|
+
if (!service) {
|
|
119
|
+
console.log((0, utils_1.error)("Unable to locate service within compose file, is it a valid Budibase configuration?"));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
updateFn(service);
|
|
123
|
+
fs_1.default.writeFileSync(dockerFilePath, yaml_1.default.stringify(parsedYaml));
|
|
124
|
+
}
|
|
125
|
+
exports.updateDockerComposeService = updateDockerComposeService;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.watchPlugins = void 0;
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const fs_1 = __importDefault(require("fs"));
|
|
18
|
+
const utils_1 = require("../utils");
|
|
19
|
+
const utils_2 = require("./utils");
|
|
20
|
+
function watchPlugins(pluginPath, silent) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const PLUGIN_PATH = "/plugins";
|
|
23
|
+
// get absolute path
|
|
24
|
+
pluginPath = (0, path_1.resolve)(pluginPath);
|
|
25
|
+
if (!fs_1.default.existsSync(pluginPath)) {
|
|
26
|
+
console.log((0, utils_1.error)(`The directory "${pluginPath}" does not exist, please create and then try again.`));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
(0, utils_2.updateDockerComposeService)((service) => {
|
|
30
|
+
// set environment variable
|
|
31
|
+
service.environment["PLUGINS_DIR"] = PLUGIN_PATH;
|
|
32
|
+
// add volumes to parsed yaml
|
|
33
|
+
if (!service.volumes) {
|
|
34
|
+
service.volumes = [];
|
|
35
|
+
}
|
|
36
|
+
const found = service.volumes.find(vol => vol.includes(PLUGIN_PATH));
|
|
37
|
+
if (found) {
|
|
38
|
+
service.volumes.splice(service.volumes.indexOf(found), 1);
|
|
39
|
+
}
|
|
40
|
+
service.volumes.push(`${pluginPath}:${PLUGIN_PATH}`);
|
|
41
|
+
});
|
|
42
|
+
if (!silent) {
|
|
43
|
+
console.log((0, utils_1.success)(`Docker compose configured to watch directory: ${pluginPath}`));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.watchPlugins = watchPlugins;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
require("./prebuilds");
|
|
14
|
+
require("./environment");
|
|
15
|
+
const options_1 = require("./options");
|
|
16
|
+
const commander_1 = require("commander");
|
|
17
|
+
const utils_1 = require("./utils");
|
|
18
|
+
const json = require("../package.json");
|
|
19
|
+
// add hosting config
|
|
20
|
+
function init() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const program = new commander_1.Command()
|
|
23
|
+
.addHelpCommand("help", (0, utils_1.getHelpDescription)("Help with Budibase commands."))
|
|
24
|
+
.helpOption(false)
|
|
25
|
+
.version(json.version);
|
|
26
|
+
// add commands
|
|
27
|
+
for (let command of (0, options_1.getCommands)()) {
|
|
28
|
+
command.configure(program);
|
|
29
|
+
}
|
|
30
|
+
// this will stop the program if no command found
|
|
31
|
+
yield program.parseAsync(process.argv);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
init().catch(err => {
|
|
35
|
+
console.error(`Unexpected error - `, err);
|
|
36
|
+
});
|
package/dist/options.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getCommands = void 0;
|
|
7
|
+
const analytics_1 = __importDefault(require("./analytics"));
|
|
8
|
+
const hosting_1 = __importDefault(require("./hosting"));
|
|
9
|
+
const backups_1 = __importDefault(require("./backups"));
|
|
10
|
+
const plugins_1 = __importDefault(require("./plugins"));
|
|
11
|
+
function getCommands() {
|
|
12
|
+
return [hosting_1.default, analytics_1.default, backups_1.default, plugins_1.default];
|
|
13
|
+
}
|
|
14
|
+
exports.getCommands = getCommands;
|