kourou 0.24.2 → 0.25.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/README.md +98 -12
- package/lib/commands/api-key/check.d.ts +3 -3
- package/lib/commands/api-key/check.js +5 -7
- package/lib/commands/api-key/create.d.ts +3 -3
- package/lib/commands/api-key/create.js +8 -10
- package/lib/commands/api-key/delete.d.ts +3 -3
- package/lib/commands/api-key/delete.js +4 -6
- package/lib/commands/api-key/search.d.ts +3 -3
- package/lib/commands/api-key/search.js +5 -7
- package/lib/commands/app/debug-proxy.d.ts +3 -3
- package/lib/commands/app/debug-proxy.js +57 -55
- package/lib/commands/app/doctor.d.ts +24 -0
- package/lib/commands/app/doctor.js +201 -0
- package/lib/commands/app/scaffold.d.ts +2 -2
- package/lib/commands/app/scaffold.js +20 -15
- package/lib/commands/app/start-services.d.ts +1 -1
- package/lib/commands/app/start-services.js +26 -26
- package/lib/commands/collection/create.d.ts +3 -3
- package/lib/commands/collection/create.js +9 -6
- package/lib/commands/collection/export.d.ts +5 -5
- package/lib/commands/collection/export.js +25 -26
- package/lib/commands/collection/import.d.ts +5 -5
- package/lib/commands/collection/import.js +17 -17
- package/lib/commands/collection/migrate.d.ts +27 -0
- package/lib/commands/collection/migrate.js +43 -0
- package/lib/commands/config/diff.d.ts +1 -1
- package/lib/commands/config/diff.js +27 -21
- package/lib/commands/document/search.d.ts +3 -3
- package/lib/commands/document/search.js +20 -20
- package/lib/commands/es/aliases/cat.d.ts +12 -0
- package/lib/commands/es/aliases/cat.js +36 -0
- package/lib/commands/es/indices/cat.d.ts +2 -2
- package/lib/commands/es/indices/cat.js +8 -8
- package/lib/commands/es/indices/get.d.ts +2 -2
- package/lib/commands/es/indices/get.js +7 -7
- package/lib/commands/es/indices/insert.d.ts +2 -2
- package/lib/commands/es/indices/insert.js +9 -9
- package/lib/commands/es/migrate.d.ts +10 -8
- package/lib/commands/es/migrate.js +86 -82
- package/lib/commands/es/snapshot/create-repository.d.ts +2 -2
- package/lib/commands/es/snapshot/create-repository.js +16 -12
- package/lib/commands/es/snapshot/create.d.ts +2 -2
- package/lib/commands/es/snapshot/create.js +7 -7
- package/lib/commands/es/snapshot/list.d.ts +2 -2
- package/lib/commands/es/snapshot/list.js +12 -8
- package/lib/commands/file/decrypt.d.ts +4 -4
- package/lib/commands/file/decrypt.js +21 -21
- package/lib/commands/file/encrypt.d.ts +4 -4
- package/lib/commands/file/encrypt.js +20 -22
- package/lib/commands/file/test.d.ts +3 -3
- package/lib/commands/file/test.js +13 -13
- package/lib/commands/import.d.ts +5 -5
- package/lib/commands/import.js +39 -28
- package/lib/commands/index/export.d.ts +5 -4
- package/lib/commands/index/export.js +21 -19
- package/lib/commands/index/import.d.ts +5 -5
- package/lib/commands/index/import.js +21 -19
- package/lib/commands/instance/kill.d.ts +2 -2
- package/lib/commands/instance/kill.js +34 -34
- package/lib/commands/instance/list.d.ts +1 -1
- package/lib/commands/instance/list.js +33 -30
- package/lib/commands/instance/logs.d.ts +2 -2
- package/lib/commands/instance/logs.js +26 -22
- package/lib/commands/instance/spawn.d.ts +2 -2
- package/lib/commands/instance/spawn.js +46 -40
- package/lib/commands/paas/deploy.d.ts +2 -2
- package/lib/commands/paas/deploy.js +33 -21
- package/lib/commands/paas/init.d.ts +1 -1
- package/lib/commands/paas/init.js +10 -6
- package/lib/commands/paas/login.d.ts +3 -3
- package/lib/commands/paas/login.js +30 -19
- package/lib/commands/paas/logs.d.ts +27 -0
- package/lib/commands/paas/logs.js +137 -18
- package/lib/commands/profile/export.d.ts +3 -3
- package/lib/commands/profile/export.js +12 -12
- package/lib/commands/profile/import.d.ts +3 -3
- package/lib/commands/profile/import.js +6 -8
- package/lib/commands/realtime/subscribe.d.ts +3 -3
- package/lib/commands/realtime/subscribe.js +25 -25
- package/lib/commands/redis/list-keys.d.ts +3 -3
- package/lib/commands/redis/list-keys.js +15 -11
- package/lib/commands/role/export.d.ts +3 -3
- package/lib/commands/role/export.js +11 -11
- package/lib/commands/role/import.d.ts +4 -4
- package/lib/commands/role/import.js +10 -12
- package/lib/commands/sdk/execute.d.ts +5 -5
- package/lib/commands/sdk/execute.js +23 -19
- package/lib/commands/sdk/query.d.ts +5 -4
- package/lib/commands/sdk/query.js +30 -24
- package/lib/commands/user/export-mappings.d.ts +3 -3
- package/lib/commands/user/export-mappings.js +11 -11
- package/lib/commands/user/export.d.ts +6 -6
- package/lib/commands/user/export.js +34 -33
- package/lib/commands/user/import-mappings.d.ts +3 -3
- package/lib/commands/user/import-mappings.js +7 -7
- package/lib/commands/user/import.d.ts +3 -3
- package/lib/commands/user/import.js +6 -8
- package/lib/commands/vault/add.d.ts +3 -3
- package/lib/commands/vault/add.js +27 -19
- package/lib/commands/vault/decrypt.d.ts +4 -4
- package/lib/commands/vault/decrypt.js +24 -20
- package/lib/commands/vault/encrypt.d.ts +4 -4
- package/lib/commands/vault/encrypt.js +24 -20
- package/lib/commands/vault/show.d.ts +3 -3
- package/lib/commands/vault/show.js +24 -20
- package/lib/commands/vault/test.d.ts +3 -3
- package/lib/commands/vault/test.js +16 -12
- package/lib/common.d.ts +3 -3
- package/lib/common.js +28 -29
- package/lib/hooks/command_not_found/api-action.d.ts +2 -2
- package/lib/hooks/command_not_found/api-action.js +20 -22
- package/lib/index.d.ts +1 -1
- package/lib/support/PaasKommand.d.ts +2 -2
- package/lib/support/PaasKommand.js +9 -9
- package/lib/support/dump-collection.js +50 -41
- package/lib/support/editor.js +12 -10
- package/lib/support/execute.d.ts +6 -1
- package/lib/support/execute.js +9 -8
- package/lib/support/kuzzle.d.ts +12 -4
- package/lib/support/kuzzle.js +65 -31
- package/lib/support/migrate/providers/elasticsearch.d.ts +16 -0
- package/lib/support/migrate/providers/elasticsearch.js +74 -0
- package/lib/support/migrate/providers/file.d.ts +15 -0
- package/lib/support/migrate/providers/file.js +74 -0
- package/lib/support/migrate/providers/index.d.ts +12 -0
- package/lib/support/migrate/providers/index.js +16 -0
- package/lib/support/migrate/types.d.ts +8 -0
- package/lib/support/migrate/types.js +2 -0
- package/lib/support/restore-collection.d.ts +2 -1
- package/lib/support/restore-collection.js +37 -26
- package/lib/support/restore-securities.js +22 -19
- package/package.json +16 -15
|
@@ -8,60 +8,63 @@ class InstanceList extends common_1.Kommand {
|
|
|
8
8
|
const instancesList = await this.getInstancesList();
|
|
9
9
|
// eslint-disable-next-line no-console
|
|
10
10
|
console.table(instancesList, [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
"name",
|
|
12
|
+
"status",
|
|
13
|
+
"kuzzleVersion",
|
|
14
|
+
"kuzzlePort",
|
|
15
|
+
"esVersion",
|
|
16
|
+
"esPort",
|
|
17
|
+
"redisVersion",
|
|
18
|
+
"redisPort",
|
|
19
19
|
]);
|
|
20
20
|
}
|
|
21
21
|
async getInstancesList() {
|
|
22
22
|
let containersListProcess;
|
|
23
23
|
try {
|
|
24
|
-
containersListProcess = await (0, execute_1.execute)(
|
|
24
|
+
containersListProcess = await (0, execute_1.execute)("docker", "ps", "--format", '"{{.Names}}%{{.Image}}%{{.Status}}%{{.Ports}}"');
|
|
25
25
|
}
|
|
26
26
|
catch (_a) {
|
|
27
|
-
this.warn(
|
|
27
|
+
this.warn("Something went wrong while getting kuzzle running instances list");
|
|
28
28
|
return [];
|
|
29
29
|
}
|
|
30
|
-
let containersList = containersListProcess.stdout
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.
|
|
36
|
-
const
|
|
30
|
+
let containersList = containersListProcess.stdout
|
|
31
|
+
.replace(/"/g, "")
|
|
32
|
+
.split("\n");
|
|
33
|
+
containersList = containersList.filter((c) => c.match(/stack-\d{0,3}_kuzzle_1/) ||
|
|
34
|
+
c.match(/stack-\d{0,3}_elasticsearch_1/) ||
|
|
35
|
+
c.match(/stack-\d{0,3}_redis_1/));
|
|
36
|
+
const stacks = [
|
|
37
|
+
...new Set(containersList.map((container) => container.split("_")[0])),
|
|
38
|
+
].sort((stackA, stackB) => stackA > stackB ? 1 : stackA < stackB ? -1 : 0);
|
|
39
|
+
const formatedStacks = stacks.map((stack) => ({
|
|
37
40
|
name: stack,
|
|
38
|
-
status:
|
|
41
|
+
status: "",
|
|
39
42
|
kuzzleVersion: 0,
|
|
40
43
|
kuzzlePort: 0,
|
|
41
44
|
redisVersion: 0,
|
|
42
45
|
redisPort: 0,
|
|
43
46
|
esVersion: 0,
|
|
44
|
-
esPort: 0
|
|
47
|
+
esPort: 0,
|
|
45
48
|
}));
|
|
46
49
|
for (const container of containersList) {
|
|
47
|
-
const splitted = container.split(
|
|
48
|
-
const stackNumber = parseInt(splitted[0].split(
|
|
49
|
-
const type = splitted[0].split(
|
|
50
|
-
const version = parseInt(splitted[1].split(
|
|
50
|
+
const splitted = container.split("%");
|
|
51
|
+
const stackNumber = parseInt(splitted[0].split("_")[0].split("-")[1], 10);
|
|
52
|
+
const type = splitted[0].split("_")[1];
|
|
53
|
+
const version = parseInt(splitted[1].split(":")[1], 10);
|
|
51
54
|
const port = splitted[3];
|
|
52
55
|
switch (type) {
|
|
53
|
-
case
|
|
56
|
+
case "kuzzle":
|
|
54
57
|
formatedStacks[stackNumber].status = splitted[2];
|
|
55
58
|
formatedStacks[stackNumber].kuzzleVersion = version;
|
|
56
|
-
formatedStacks[stackNumber].kuzzlePort = parseInt(port.substring(port.indexOf(
|
|
59
|
+
formatedStacks[stackNumber].kuzzlePort = parseInt(port.substring(port.indexOf("->7512/tcp") - 4, port.indexOf("->7512/tcp")), 10);
|
|
57
60
|
break;
|
|
58
|
-
case
|
|
61
|
+
case "redis":
|
|
59
62
|
formatedStacks[stackNumber].redisVersion = version;
|
|
60
|
-
formatedStacks[stackNumber].redisPort = parseInt(port.replace(
|
|
63
|
+
formatedStacks[stackNumber].redisPort = parseInt(port.replace("/tcp", ""), 10);
|
|
61
64
|
break;
|
|
62
|
-
case
|
|
65
|
+
case "elasticsearch":
|
|
63
66
|
formatedStacks[stackNumber].esVersion = version;
|
|
64
|
-
formatedStacks[stackNumber].esPort = parseInt(port.substring(port.indexOf(
|
|
67
|
+
formatedStacks[stackNumber].esPort = parseInt(port.substring(port.indexOf("->9200/tcp") - 4, port.indexOf("->9200/tcp")), 10);
|
|
65
68
|
break;
|
|
66
69
|
}
|
|
67
70
|
}
|
|
@@ -70,4 +73,4 @@ class InstanceList extends common_1.Kommand {
|
|
|
70
73
|
}
|
|
71
74
|
exports.InstanceList = InstanceList;
|
|
72
75
|
InstanceList.initSdk = false;
|
|
73
|
-
InstanceList.description =
|
|
76
|
+
InstanceList.description = "Lists the Kuzzle running instances";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { flags } from
|
|
2
|
-
import { Kommand } from
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { Kommand } from "../../common";
|
|
3
3
|
export declare class InstanceLogs extends Kommand {
|
|
4
4
|
static initSdk: boolean;
|
|
5
5
|
static description: string;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InstanceLogs = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
|
-
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
|
+
const inquirer_1 = (0, tslib_1.__importDefault)(require("inquirer"));
|
|
7
7
|
const common_1 = require("../../common");
|
|
8
8
|
const execute_1 = require("../../support/execute");
|
|
9
9
|
class InstanceLogs extends common_1.Kommand {
|
|
@@ -13,16 +13,18 @@ class InstanceLogs extends common_1.Kommand {
|
|
|
13
13
|
if (!instance) {
|
|
14
14
|
const instancesList = await this.getInstancesList();
|
|
15
15
|
if (instancesList.length === 0) {
|
|
16
|
-
throw new Error(
|
|
16
|
+
throw new Error("There are no Kuzzle running instances");
|
|
17
17
|
}
|
|
18
|
-
const responses = await inquirer_1.default.prompt([
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const responses = await inquirer_1.default.prompt([
|
|
19
|
+
{
|
|
20
|
+
name: "instance",
|
|
21
|
+
message: "On which kuzzle instance do you want to see the logs",
|
|
22
|
+
type: "list",
|
|
22
23
|
choices: instancesList,
|
|
23
|
-
}
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
24
26
|
if (!responses.instance) {
|
|
25
|
-
throw new Error(
|
|
27
|
+
throw new Error("A running Kuzzle instance must be selected.");
|
|
26
28
|
}
|
|
27
29
|
instance = responses.instance;
|
|
28
30
|
}
|
|
@@ -30,11 +32,11 @@ class InstanceLogs extends common_1.Kommand {
|
|
|
30
32
|
}
|
|
31
33
|
async showInstanceLogs(instanceName, followOption) {
|
|
32
34
|
var _a, _b;
|
|
33
|
-
const args = [
|
|
35
|
+
const args = ["logs", instanceName];
|
|
34
36
|
if (followOption) {
|
|
35
|
-
args.push(
|
|
37
|
+
args.push("-f");
|
|
36
38
|
}
|
|
37
|
-
const instanceLogs = (0, execute_1.execute)(
|
|
39
|
+
const instanceLogs = (0, execute_1.execute)("docker", ...args);
|
|
38
40
|
(_a = instanceLogs.process.stdout) === null || _a === void 0 ? void 0 : _a.pipe(process.stdout);
|
|
39
41
|
(_b = instanceLogs.process.stderr) === null || _b === void 0 ? void 0 : _b.pipe(process.stderr);
|
|
40
42
|
await instanceLogs;
|
|
@@ -42,28 +44,30 @@ class InstanceLogs extends common_1.Kommand {
|
|
|
42
44
|
async getInstancesList() {
|
|
43
45
|
let containersListProcess;
|
|
44
46
|
try {
|
|
45
|
-
containersListProcess = await (0, execute_1.execute)(
|
|
47
|
+
containersListProcess = await (0, execute_1.execute)("docker", "ps", "--format", '"{{.Names}}"');
|
|
46
48
|
}
|
|
47
49
|
catch (_a) {
|
|
48
|
-
this.warn(
|
|
50
|
+
this.warn("Something went wrong while getting kuzzle running instances list");
|
|
49
51
|
return [];
|
|
50
52
|
}
|
|
51
|
-
const containersList = containersListProcess.stdout
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const containersList = containersListProcess.stdout
|
|
54
|
+
.replace(/"/g, "")
|
|
55
|
+
.split("\n");
|
|
56
|
+
return containersList.filter((containerName) => containerName.includes("kuzzle") &&
|
|
57
|
+
!containerName.includes("redis") &&
|
|
58
|
+
!containerName.includes("elasticsearch"));
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
exports.InstanceLogs = InstanceLogs;
|
|
58
62
|
InstanceLogs.initSdk = false;
|
|
59
|
-
InstanceLogs.description =
|
|
63
|
+
InstanceLogs.description = "Displays the logs of a running Kuzzle";
|
|
60
64
|
InstanceLogs.flags = {
|
|
61
65
|
instance: command_1.flags.string({
|
|
62
|
-
char:
|
|
63
|
-
description:
|
|
66
|
+
char: "i",
|
|
67
|
+
description: "Kuzzle instance name",
|
|
64
68
|
}),
|
|
65
69
|
follow: command_1.flags.boolean({
|
|
66
|
-
char:
|
|
67
|
-
description:
|
|
70
|
+
char: "f",
|
|
71
|
+
description: "Follow log output",
|
|
68
72
|
}),
|
|
69
73
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { flags } from
|
|
2
|
-
import { Kommand } from
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { Kommand } from "../../common";
|
|
3
3
|
export default class InstanceSpawn extends Kommand {
|
|
4
4
|
static initSdk: boolean;
|
|
5
5
|
static description: string;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
4
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
const net_1 = tslib_1.__importDefault(require("net"));
|
|
6
|
+
const net_1 = (0, tslib_1.__importDefault)(require("net"));
|
|
7
7
|
const command_1 = require("@oclif/command");
|
|
8
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
|
-
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
11
|
-
const listr_1 = tslib_1.__importDefault(require("listr"));
|
|
12
|
-
const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
|
|
10
|
+
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
11
|
+
const listr_1 = (0, tslib_1.__importDefault)(require("listr"));
|
|
12
|
+
const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
|
|
13
13
|
const common_1 = require("../../common");
|
|
14
14
|
const execute_1 = require("../../support/execute");
|
|
15
15
|
const MIN_MAX_MAP_COUNT = 262144;
|
|
16
|
-
const MIN_DOCO_VERSION =
|
|
16
|
+
const MIN_DOCO_VERSION = "1.12.0";
|
|
17
17
|
const kuzzleStackV1 = (increment) => `
|
|
18
18
|
version: '3'
|
|
19
19
|
|
|
@@ -88,28 +88,35 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
88
88
|
async runSafe() {
|
|
89
89
|
const portIndex = await this.findAvailablePort();
|
|
90
90
|
const docoFilename = path_1.default.join(this.kourouDir, `kuzzle-stack-${portIndex}.yml`);
|
|
91
|
-
const successfullCheck = this.flags.check
|
|
92
|
-
await this.checkPrerequisites()
|
|
93
|
-
true;
|
|
91
|
+
const successfullCheck = this.flags.check
|
|
92
|
+
? await this.checkPrerequisites()
|
|
93
|
+
: true;
|
|
94
94
|
if (this.flags.check && successfullCheck) {
|
|
95
|
-
this.log(`\n${node_emoji_1.default.get(
|
|
95
|
+
this.log(`\n${node_emoji_1.default.get("ok_hand")} Prerequisites are ${chalk_1.default.green.bold("OK")}!`);
|
|
96
96
|
}
|
|
97
97
|
else if (this.flags.check && !successfullCheck) {
|
|
98
|
-
throw new Error(`${node_emoji_1.default.get(
|
|
98
|
+
throw new Error(`${node_emoji_1.default.get("shrug")} Your system doesn't satisfy all the prerequisites. Cannot run Kuzzle.`);
|
|
99
99
|
}
|
|
100
100
|
this.log(chalk_1.default.grey(`\nWriting docker-compose file to ${docoFilename}...`));
|
|
101
101
|
(0, fs_1.writeFileSync)(docoFilename, this.generateDocoFile(this.flags.version, portIndex));
|
|
102
102
|
// clean up
|
|
103
|
-
await (0, execute_1.execute)(
|
|
104
|
-
const doco = (0, child_process_1.spawn)(
|
|
105
|
-
|
|
103
|
+
await (0, execute_1.execute)("docker-compose", "-f", docoFilename, "-p", `stack-${portIndex}`, "down");
|
|
104
|
+
const doco = (0, child_process_1.spawn)("docker-compose", [
|
|
105
|
+
"-f",
|
|
106
|
+
docoFilename,
|
|
107
|
+
"-p",
|
|
108
|
+
`stack-${portIndex}`,
|
|
109
|
+
"up",
|
|
110
|
+
"-d",
|
|
111
|
+
]);
|
|
112
|
+
cli_ux_1.default.action.start(` ${node_emoji_1.default.get("rocket")} Kuzzle version ${this.flags.version} is launching`, undefined, {
|
|
106
113
|
stdout: true,
|
|
107
114
|
});
|
|
108
|
-
doco.on(
|
|
115
|
+
doco.on("close", (docoCode) => {
|
|
109
116
|
if (docoCode === 0) {
|
|
110
|
-
cli_ux_1.default.action.stop(
|
|
111
|
-
this.log(`\n${node_emoji_1.default.get(
|
|
112
|
-
this.log(chalk_1.default.grey(
|
|
117
|
+
cli_ux_1.default.action.stop("done");
|
|
118
|
+
this.log(`\n${node_emoji_1.default.get("thumbsup")} ${chalk_1.default.bold("Kuzzle is booting")} in the background right now.`);
|
|
119
|
+
this.log(chalk_1.default.grey("To watch the logs, run"));
|
|
113
120
|
this.log(chalk_1.default.grey(` docker-compose -f ${docoFilename} -p stack-${portIndex} logs -f\n`));
|
|
114
121
|
this.log(` Kuzzle port: ${7512 + portIndex}`);
|
|
115
122
|
this.log(` MQTT port: ${1883 + portIndex}`);
|
|
@@ -118,27 +125,27 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
118
125
|
}
|
|
119
126
|
else {
|
|
120
127
|
cli_ux_1.default.action.stop(chalk_1.default.red(` Something went wrong: docker-compose exited with ${docoCode}`));
|
|
121
|
-
this.log(chalk_1.default.grey(
|
|
128
|
+
this.log(chalk_1.default.grey("If you want to investigate the problem, try running"));
|
|
122
129
|
this.log(chalk_1.default.grey(` docker-compose -f ${docoFilename} -p stack-${portIndex} up\n`));
|
|
123
|
-
throw new Error(
|
|
130
|
+
throw new Error("docker-compose exited witn non-zero status");
|
|
124
131
|
}
|
|
125
132
|
});
|
|
126
133
|
}
|
|
127
134
|
async checkPrerequisites() {
|
|
128
|
-
this.log(chalk_1.default.grey(
|
|
135
|
+
this.log(chalk_1.default.grey("Checking prerequisites..."));
|
|
129
136
|
const checks = new listr_1.default([
|
|
130
137
|
{
|
|
131
138
|
title: `docker-compose exists and the version is at least ${MIN_DOCO_VERSION}`,
|
|
132
139
|
task: async () => {
|
|
133
140
|
try {
|
|
134
|
-
const docov = await (0, execute_1.execute)(
|
|
141
|
+
const docov = await (0, execute_1.execute)("docker-compose", "-v");
|
|
135
142
|
const matches = docov.stdout.match(/[^0-9.]*([0-9.]*).*/);
|
|
136
143
|
if (matches === null) {
|
|
137
|
-
throw new Error(
|
|
144
|
+
throw new Error("Unable to read docker-compose verson. This is weird.");
|
|
138
145
|
}
|
|
139
146
|
const docoVersion = matches.length > 0 ? matches[1] : null;
|
|
140
147
|
if (docoVersion === null) {
|
|
141
|
-
throw new Error(
|
|
148
|
+
throw new Error("Unable to read docker-compose version. This is weird.");
|
|
142
149
|
}
|
|
143
150
|
try {
|
|
144
151
|
if (docoVersion < MIN_DOCO_VERSION) {
|
|
@@ -150,7 +157,7 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
150
157
|
}
|
|
151
158
|
}
|
|
152
159
|
catch (error) {
|
|
153
|
-
throw new Error(
|
|
160
|
+
throw new Error("No docker-compose found. Are you sure docker-compose is installed?");
|
|
154
161
|
}
|
|
155
162
|
},
|
|
156
163
|
},
|
|
@@ -158,9 +165,9 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
158
165
|
title: `vm.max_map_count is greater than ${MIN_MAX_MAP_COUNT}`,
|
|
159
166
|
task: async () => {
|
|
160
167
|
try {
|
|
161
|
-
const sysctl = await (0, execute_1.execute)(
|
|
168
|
+
const sysctl = await (0, execute_1.execute)("/sbin/sysctl", "-n", "vm.max_map_count");
|
|
162
169
|
if (sysctl.exitCode !== 0) {
|
|
163
|
-
throw new Error(
|
|
170
|
+
throw new Error("Something went wrong checking vm.max_map_count");
|
|
164
171
|
}
|
|
165
172
|
const value = parseInt(sysctl.stdout, 10);
|
|
166
173
|
if (value < MIN_MAX_MAP_COUNT) {
|
|
@@ -183,24 +190,23 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
183
190
|
}
|
|
184
191
|
}
|
|
185
192
|
generateDocoFile(kuzzleMajor, portIndex) {
|
|
186
|
-
if (kuzzleMajor ===
|
|
193
|
+
if (kuzzleMajor === "1") {
|
|
187
194
|
return kuzzleStackV1(portIndex);
|
|
188
195
|
}
|
|
189
196
|
return kuzzleStackV2(portIndex);
|
|
190
197
|
}
|
|
191
198
|
isPortAvailable(port) {
|
|
192
199
|
return new Promise((resolve, reject) => {
|
|
193
|
-
const tester = net_1.default
|
|
194
|
-
.
|
|
200
|
+
const tester = net_1.default
|
|
201
|
+
.createServer()
|
|
202
|
+
.once("error", (error) => {
|
|
195
203
|
if (!error.message.match(/EADDRINUSE/)) {
|
|
196
204
|
reject(error);
|
|
197
205
|
}
|
|
198
206
|
resolve(false);
|
|
199
207
|
})
|
|
200
|
-
.once(
|
|
201
|
-
tester
|
|
202
|
-
.once('close', () => resolve(true))
|
|
203
|
-
.close();
|
|
208
|
+
.once("listening", () => {
|
|
209
|
+
tester.once("close", () => resolve(true)).close();
|
|
204
210
|
})
|
|
205
211
|
.listen(port);
|
|
206
212
|
});
|
|
@@ -218,16 +224,16 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
218
224
|
}
|
|
219
225
|
exports.default = InstanceSpawn;
|
|
220
226
|
InstanceSpawn.initSdk = false;
|
|
221
|
-
InstanceSpawn.description =
|
|
227
|
+
InstanceSpawn.description = "Spawn a new Kuzzle instance";
|
|
222
228
|
InstanceSpawn.flags = {
|
|
223
229
|
help: command_1.flags.help(),
|
|
224
230
|
check: command_1.flags.boolean({
|
|
225
|
-
description:
|
|
231
|
+
description: "Check prerequisite before running Kuzzle",
|
|
226
232
|
default: false,
|
|
227
233
|
}),
|
|
228
234
|
version: command_1.flags.string({
|
|
229
|
-
char:
|
|
230
|
-
description:
|
|
231
|
-
default:
|
|
235
|
+
char: "v",
|
|
236
|
+
description: "Core-version of the instance to spawn",
|
|
237
|
+
default: "2",
|
|
232
238
|
}),
|
|
233
239
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { flags } from
|
|
2
|
-
import { PaasKommand } from
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { PaasKommand } from "../../support/PaasKommand";
|
|
3
3
|
declare class PaasDeploy extends PaasKommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static flags: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
4
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
|
-
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
7
|
-
const login_1 = tslib_1.__importDefault(require("./login"));
|
|
6
|
+
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
7
|
+
const login_1 = (0, tslib_1.__importDefault)(require("./login"));
|
|
8
8
|
const PaasKommand_1 = require("../../support/PaasKommand");
|
|
9
9
|
class PaasDeploy extends PaasKommand_1.PaasKommand {
|
|
10
10
|
async runSafe() {
|
|
@@ -12,11 +12,11 @@ class PaasDeploy extends PaasKommand_1.PaasKommand {
|
|
|
12
12
|
await this.initPaasClient({ apiKey });
|
|
13
13
|
const user = await this.paas.auth.getCurrentUser();
|
|
14
14
|
this.logInfo(`Logged as "${user._id}" for project "${this.flags.project || this.getProject()}"`);
|
|
15
|
-
const [image, tag] = this.args.image.split(
|
|
15
|
+
const [image, tag] = this.args.image.split(":");
|
|
16
16
|
this.logInfo(`Deploy application with image "${image}:${tag}"`);
|
|
17
17
|
await this.paas.query({
|
|
18
|
-
controller:
|
|
19
|
-
action:
|
|
18
|
+
controller: "application",
|
|
19
|
+
action: "deploy",
|
|
20
20
|
environmentId: this.args.environment,
|
|
21
21
|
projectId: this.flags.project || this.getProject(),
|
|
22
22
|
applicationId: this.args.applicationId,
|
|
@@ -25,43 +25,55 @@ class PaasDeploy extends PaasKommand_1.PaasKommand {
|
|
|
25
25
|
name: image,
|
|
26
26
|
tag,
|
|
27
27
|
},
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
29
|
});
|
|
30
|
-
this.logOk(
|
|
30
|
+
this.logOk("Deployment in progress");
|
|
31
31
|
}
|
|
32
32
|
async getCredentials() {
|
|
33
33
|
const project = this.getProject();
|
|
34
34
|
const projectFile = this.fileProjectCredentials(project);
|
|
35
35
|
if (!fs_1.default.existsSync(projectFile)) {
|
|
36
|
-
this.log(
|
|
37
|
-
const nextStep = await cli_ux_1.default.prompt(
|
|
38
|
-
this.log(
|
|
39
|
-
if (nextStep.toLowerCase().startsWith(
|
|
40
|
-
await login_1.default.run([
|
|
36
|
+
this.log("");
|
|
37
|
+
const nextStep = await cli_ux_1.default.prompt("Cannot find credentials for this project. Do you want to login first? [Y/N]", { type: "single" });
|
|
38
|
+
this.log("");
|
|
39
|
+
if (nextStep.toLowerCase().startsWith("y")) {
|
|
40
|
+
await login_1.default.run(["--project", project]);
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
|
-
this.logKo(
|
|
43
|
+
this.logKo("Aborting.");
|
|
44
44
|
process.exit(1);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
const credentials = JSON.parse(fs_1.default.readFileSync(projectFile,
|
|
47
|
+
const credentials = JSON.parse(fs_1.default.readFileSync(projectFile, "utf8"));
|
|
48
48
|
return credentials.apiKey;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
PaasDeploy.description =
|
|
51
|
+
PaasDeploy.description = "Deploy a new version of the application in the PaaS";
|
|
52
52
|
PaasDeploy.flags = {
|
|
53
53
|
help: command_1.flags.help(),
|
|
54
54
|
token: command_1.flags.string({
|
|
55
55
|
default: process.env.KUZZLE_PAAS_TOKEN,
|
|
56
|
-
description:
|
|
56
|
+
description: "Authentication token",
|
|
57
57
|
}),
|
|
58
58
|
project: command_1.flags.string({
|
|
59
|
-
description:
|
|
59
|
+
description: "Current PaaS project",
|
|
60
60
|
}),
|
|
61
61
|
};
|
|
62
62
|
PaasDeploy.args = [
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
{
|
|
64
|
+
name: "environment",
|
|
65
|
+
description: "Project environment name",
|
|
66
|
+
required: true,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "applicationId",
|
|
70
|
+
description: "Application Identifier",
|
|
71
|
+
required: true,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "image",
|
|
75
|
+
description: "Image name and hash as myimage:mytag",
|
|
76
|
+
required: true,
|
|
77
|
+
},
|
|
66
78
|
];
|
|
67
79
|
exports.default = PaasDeploy;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
4
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
7
|
const PaasKommand_1 = require("../../support/PaasKommand");
|
|
8
8
|
class PaasInit extends PaasKommand_1.PaasKommand {
|
|
9
9
|
async runSafe() {
|
|
10
|
-
const packageJsonPath = path_1.default.join(process.cwd(),
|
|
10
|
+
const packageJsonPath = path_1.default.join(process.cwd(), "package.json");
|
|
11
11
|
if (!fs_1.default.existsSync(packageJsonPath)) {
|
|
12
12
|
throw new Error(`Cannot find package json in current directory. (${packageJsonPath})`);
|
|
13
13
|
}
|
|
14
|
-
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath,
|
|
14
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf8"));
|
|
15
15
|
this.logInfo('Add the "kuzzle" property inside project package.json.');
|
|
16
16
|
packageJson.kuzzle = {
|
|
17
17
|
paas: {
|
|
@@ -21,11 +21,15 @@ class PaasInit extends PaasKommand_1.PaasKommand {
|
|
|
21
21
|
fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
PaasInit.description =
|
|
24
|
+
PaasInit.description = "Initialize a PaaS project in current directory";
|
|
25
25
|
PaasInit.flags = {
|
|
26
26
|
help: command_1.flags.help(),
|
|
27
27
|
};
|
|
28
28
|
PaasInit.args = [
|
|
29
|
-
{
|
|
29
|
+
{
|
|
30
|
+
name: "project",
|
|
31
|
+
description: "Kuzzle PaaS project name",
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
30
34
|
];
|
|
31
35
|
exports.default = PaasInit;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { flags } from
|
|
2
|
-
import { ApiKey } from
|
|
3
|
-
import { PaasKommand } from
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { ApiKey } from "kuzzle-sdk";
|
|
3
|
+
import { PaasKommand } from "../../support/PaasKommand";
|
|
4
4
|
declare class PaasLogin extends PaasKommand {
|
|
5
5
|
static description: string;
|
|
6
6
|
static flags: {
|