kourou 0.26.1 → 0.26.2

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 CHANGED
@@ -27,7 +27,7 @@ $ npm install -g kourou
27
27
  $ kourou COMMAND
28
28
  running command...
29
29
  $ kourou (-v|--version|version)
30
- kourou/0.26.1 darwin-arm64 node-v18.17.1
30
+ kourou/0.26.2 darwin-arm64 node-v18.17.1
31
31
  $ kourou --help [COMMAND]
32
32
  USAGE
33
33
  $ kourou COMMAND
@@ -7,6 +7,7 @@ const kuzzle_1 = require("../../support/kuzzle");
7
7
  const elasticsearch_1 = require("@elastic/elasticsearch");
8
8
  const execute_1 = require("../../support/execute");
9
9
  const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
10
+ const checkPrerequisites_1 = require("../../support/docker/checkPrerequisites");
10
11
  class AppDoctor extends common_1.Kommand {
11
12
  constructor() {
12
13
  super(...arguments);
@@ -169,21 +170,11 @@ class AppDoctor extends common_1.Kommand {
169
170
  suggestions.push(`Install missing libraries: sudo apt-get install ${notInstalled.join(" ")}`);
170
171
  }
171
172
  this.log("Docker checks");
172
- try {
173
- const docov = await (0, execute_1.execute)("docker-compose", "-v");
174
- const matches = docov.stdout.match(/[^0-9.]*([0-9.]*).*/);
175
- if (matches === null || matches.length === 0) {
176
- this.logKo("Docker Version cannot be found");
177
- }
178
- else {
179
- this.logOk(`Docker Compose Version: ${matches[1]}`);
180
- }
181
- }
182
- catch (error) {
183
- this.logKo("Docker Compose cannot be found");
184
- suggestions.push("Install Docker Compose with 'npm run install:docker'");
173
+ const result = await (0, checkPrerequisites_1.checkPrerequisites)(this);
174
+ if (!result) {
175
+ suggestions.push("Install Docker and the Compose plugin");
185
176
  }
186
- this.log(`----------------- DoKtor finish his job ! -----------------`);
177
+ this.log(`----------------- DoKtor finished its job ! -----------------`);
187
178
  this.log(`He suggest you to check the following points:`);
188
179
  for (const suggestion of suggestions) {
189
180
  this.logInfo(" => " + suggestion);
@@ -7,5 +7,4 @@ export default class AppStartServices extends Kommand {
7
7
  check: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
8
8
  };
9
9
  runSafe(): Promise<void>;
10
- checkPrerequisites(): Promise<boolean>;
11
10
  }
@@ -5,11 +5,10 @@ const fs_1 = require("fs");
5
5
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
6
6
  const command_1 = require("@oclif/command");
7
7
  const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
8
- const listr_1 = (0, tslib_1.__importDefault)(require("listr"));
9
8
  const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
10
9
  const common_1 = require("../../common");
11
10
  const execute_1 = require("../../support/execute");
12
- const MIN_DOCO_VERSION = "1.12.0";
11
+ const checkPrerequisites_1 = require("../../support/docker/checkPrerequisites");
13
12
  const kuzzleServicesFile = `
14
13
  version: '3'
15
14
 
@@ -31,7 +30,7 @@ class AppStartServices extends common_1.Kommand {
31
30
  this.createKourouDir();
32
31
  const docoFilename = path_1.default.join(this.kourouDir, "kuzzle-services.yml");
33
32
  const successfullCheck = this.flags.check
34
- ? await this.checkPrerequisites()
33
+ ? await (0, checkPrerequisites_1.checkPrerequisites)(this)
35
34
  : true;
36
35
  if (this.flags.check && successfullCheck) {
37
36
  this.log(`\n${node_emoji_1.default.get("ok_hand")} Prerequisites are ${chalk_1.default.green.bold("OK")}!`);
@@ -39,62 +38,22 @@ class AppStartServices extends common_1.Kommand {
39
38
  else if (this.flags.check && !successfullCheck) {
40
39
  throw new Error(`${node_emoji_1.default.get("shrug")} Your system doesn't satisfy all the prerequisites. Cannot run Kuzzle services.`);
41
40
  }
42
- this.log(chalk_1.default.grey(`\nWriting docker-compose file to ${docoFilename}...\n`));
41
+ this.log(chalk_1.default.grey(`\nWriting the Docker Compose file to ${docoFilename}...\n`));
43
42
  (0, fs_1.writeFileSync)(docoFilename, kuzzleServicesFile);
44
43
  // clean up
45
- await (0, execute_1.execute)("docker-compose", "-f", docoFilename, "down");
44
+ await (0, execute_1.execute)("docker", "compose", "-f", docoFilename, "down");
46
45
  try {
47
- await (0, execute_1.execute)("docker-compose", "-f", docoFilename, "up", "-d");
46
+ await (0, execute_1.execute)("docker", "compose", "-f", docoFilename, "up", "-d");
48
47
  this.logOk("Elasticsearch and Redis are booting in the background right now.");
49
48
  this.log(chalk_1.default.grey("\nTo watch the logs, run"));
50
- this.log(chalk_1.default.blue.bold(` docker-compose -f ${docoFilename} logs -f\n`));
49
+ this.log(chalk_1.default.blue.bold(` docker compose -f ${docoFilename} logs -f\n`));
51
50
  this.log(` Elasticsearch port: ${chalk_1.default.bold("9200")}`);
52
51
  this.log(` Redis port: ${chalk_1.default.bold("6379")}`);
53
52
  }
54
53
  catch (error) {
55
54
  this.logKo(` Something went wrong: ${error.message}`);
56
55
  this.log(chalk_1.default.grey("If you want to investigate the problem, try running"));
57
- this.log(chalk_1.default.grey(` docker-compose -f ${docoFilename} up\n`));
58
- }
59
- }
60
- async checkPrerequisites() {
61
- this.log(chalk_1.default.grey("Checking prerequisites..."));
62
- const checks = new listr_1.default([
63
- {
64
- title: `docker-compose exists and the version is at least ${MIN_DOCO_VERSION}`,
65
- task: async () => {
66
- try {
67
- const docov = await (0, execute_1.execute)("docker-compose", "-v");
68
- const matches = docov.stdout.match(/[^0-9.]*([0-9.]*).*/);
69
- if (matches === null) {
70
- throw new Error("Unable to read docker-compose verson. This is weird.");
71
- }
72
- const docoVersion = matches.length > 0 ? matches[1] : null;
73
- if (docoVersion === null) {
74
- throw new Error("Unable to read docker-compose version. This is weird.");
75
- }
76
- try {
77
- if (docoVersion < MIN_DOCO_VERSION) {
78
- throw new Error(`The detected version of docker-compose (${docoVersion}) is not recent enough (${MIN_DOCO_VERSION})`);
79
- }
80
- }
81
- catch (error) {
82
- throw new Error(error);
83
- }
84
- }
85
- catch (error) {
86
- throw new Error("No docker-compose found. Are you sure docker-compose is installed?");
87
- }
88
- },
89
- },
90
- ]);
91
- try {
92
- await checks.run();
93
- return true;
94
- }
95
- catch (error) {
96
- this.logKo(error.message);
97
- return false;
56
+ this.log(chalk_1.default.grey(` docker compose -f ${docoFilename} up\n`));
98
57
  }
99
58
  }
100
59
  }
@@ -50,7 +50,8 @@ class InstanceLogs extends common_1.Kommand {
50
50
  cli_ux_1.default.action.start(`${node_emoji_1.default.get("boom")} Killing Kuzzle instance ${instanceName}`, undefined, {
51
51
  stdout: true,
52
52
  });
53
- const instanceKill = (0, child_process_1.spawn)("docker-compose", [
53
+ const instanceKill = (0, child_process_1.spawn)("docker", [
54
+ "compose",
54
55
  "-f",
55
56
  docoFilename,
56
57
  "-p",
@@ -9,7 +9,6 @@ export default class InstanceSpawn extends Kommand {
9
9
  version: flags.IOptionFlag<string>;
10
10
  };
11
11
  runSafe(): Promise<void>;
12
- checkPrerequisites(): Promise<boolean>;
13
12
  private generateDocoFile;
14
13
  private isPortAvailable;
15
14
  private findAvailablePort;
@@ -8,12 +8,12 @@ const command_1 = require("@oclif/command");
8
8
  const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
9
9
  const child_process_1 = require("child_process");
10
10
  const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
11
- const listr_1 = (0, tslib_1.__importDefault)(require("listr"));
12
11
  const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
13
12
  const common_1 = require("../../common");
14
13
  const execute_1 = require("../../support/execute");
14
+ const checkPrerequisites_1 = require("../../support/docker/checkPrerequisites");
15
15
  const MIN_MAX_MAP_COUNT = 262144;
16
- const MIN_DOCO_VERSION = "1.12.0";
16
+ const MIN_DOCO_VERSION = "2.0.0";
17
17
  const kuzzleStackV1 = (increment) => `
18
18
  version: '3'
19
19
 
@@ -89,7 +89,7 @@ class InstanceSpawn extends common_1.Kommand {
89
89
  const portIndex = await this.findAvailablePort();
90
90
  const docoFilename = path_1.default.join(this.kourouDir, `kuzzle-stack-${portIndex}.yml`);
91
91
  const successfullCheck = this.flags.check
92
- ? await this.checkPrerequisites()
92
+ ? await (0, checkPrerequisites_1.checkPrerequisites)(this)
93
93
  : true;
94
94
  if (this.flags.check && successfullCheck) {
95
95
  this.log(`\n${node_emoji_1.default.get("ok_hand")} Prerequisites are ${chalk_1.default.green.bold("OK")}!`);
@@ -97,11 +97,12 @@ class InstanceSpawn extends common_1.Kommand {
97
97
  else if (this.flags.check && !successfullCheck) {
98
98
  throw new Error(`${node_emoji_1.default.get("shrug")} Your system doesn't satisfy all the prerequisites. Cannot run Kuzzle.`);
99
99
  }
100
- this.log(chalk_1.default.grey(`\nWriting docker-compose file to ${docoFilename}...`));
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)("docker-compose", "-f", docoFilename, "-p", `stack-${portIndex}`, "down");
104
- const doco = (0, child_process_1.spawn)("docker-compose", [
103
+ await (0, execute_1.execute)("docker", "compose", "-f", docoFilename, "-p", `stack-${portIndex}`, "down");
104
+ const doco = (0, child_process_1.spawn)("docker", [
105
+ "compose",
105
106
  "-f",
106
107
  docoFilename,
107
108
  "-p",
@@ -117,78 +118,20 @@ class InstanceSpawn extends common_1.Kommand {
117
118
  cli_ux_1.default.action.stop("done");
118
119
  this.log(`\n${node_emoji_1.default.get("thumbsup")} ${chalk_1.default.bold("Kuzzle is booting")} in the background right now.`);
119
120
  this.log(chalk_1.default.grey("To watch the logs, run"));
120
- this.log(chalk_1.default.grey(` docker-compose -f ${docoFilename} -p stack-${portIndex} logs -f\n`));
121
+ this.log(chalk_1.default.grey(` docker compose -f ${docoFilename} -p stack-${portIndex} logs -f\n`));
121
122
  this.log(` Kuzzle port: ${7512 + portIndex}`);
122
123
  this.log(` MQTT port: ${1883 + portIndex}`);
123
124
  this.log(` Node.js debugger port: ${9229 + portIndex}`);
124
125
  this.log(` Elasticsearch port: ${9200 + portIndex}`);
125
126
  }
126
127
  else {
127
- cli_ux_1.default.action.stop(chalk_1.default.red(` Something went wrong: docker-compose exited with ${docoCode}`));
128
+ cli_ux_1.default.action.stop(chalk_1.default.red(` Something went wrong: docker compose exited with ${docoCode}`));
128
129
  this.log(chalk_1.default.grey("If you want to investigate the problem, try running"));
129
- this.log(chalk_1.default.grey(` docker-compose -f ${docoFilename} -p stack-${portIndex} up\n`));
130
- throw new Error("docker-compose exited witn non-zero status");
130
+ this.log(chalk_1.default.grey(` docker compose -f ${docoFilename} -p stack-${portIndex} up\n`));
131
+ throw new Error("docker compose exited with a non-zero status");
131
132
  }
132
133
  });
133
134
  }
134
- async checkPrerequisites() {
135
- this.log(chalk_1.default.grey("Checking prerequisites..."));
136
- const checks = new listr_1.default([
137
- {
138
- title: `docker-compose exists and the version is at least ${MIN_DOCO_VERSION}`,
139
- task: async () => {
140
- try {
141
- const docov = await (0, execute_1.execute)("docker-compose", "-v");
142
- const matches = docov.stdout.match(/[^0-9.]*([0-9.]*).*/);
143
- if (matches === null) {
144
- throw new Error("Unable to read docker-compose verson. This is weird.");
145
- }
146
- const docoVersion = matches.length > 0 ? matches[1] : null;
147
- if (docoVersion === null) {
148
- throw new Error("Unable to read docker-compose version. This is weird.");
149
- }
150
- try {
151
- if (docoVersion < MIN_DOCO_VERSION) {
152
- throw new Error(`The detected version of docker-compose (${docoVersion}) is not recent enough (${MIN_DOCO_VERSION})`);
153
- }
154
- }
155
- catch (error) {
156
- throw new Error(error);
157
- }
158
- }
159
- catch (error) {
160
- throw new Error("No docker-compose found. Are you sure docker-compose is installed?");
161
- }
162
- },
163
- },
164
- {
165
- title: `vm.max_map_count is greater than ${MIN_MAX_MAP_COUNT}`,
166
- task: async () => {
167
- try {
168
- const sysctl = await (0, execute_1.execute)("/sbin/sysctl", "-n", "vm.max_map_count");
169
- if (sysctl.exitCode !== 0) {
170
- throw new Error("Something went wrong checking vm.max_map_count");
171
- }
172
- const value = parseInt(sysctl.stdout, 10);
173
- if (value < MIN_MAX_MAP_COUNT) {
174
- throw new Error(`vm.max_map_count must be at least ${MIN_MAX_MAP_COUNT} (found ${value})`);
175
- }
176
- }
177
- catch (error) {
178
- throw new Error(`Something went wrong checking vm.max_map_count: ${error.message}`);
179
- }
180
- },
181
- },
182
- ]);
183
- try {
184
- await checks.run();
185
- return true;
186
- }
187
- catch (error) {
188
- this.logKo(error.message);
189
- return false;
190
- }
191
- }
192
135
  generateDocoFile(kuzzleMajor, portIndex) {
193
136
  if (kuzzleMajor === "1") {
194
137
  return kuzzleStackV1(portIndex);
@@ -0,0 +1,2 @@
1
+ import { Kommand } from "../../common";
2
+ export declare function checkPrerequisites(ctx: Kommand): Promise<boolean>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkPrerequisites = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const listr_1 = (0, tslib_1.__importDefault)(require("listr"));
6
+ const execute_1 = require("../execute");
7
+ const MIN_DOCO_VERSION = "2.0.0";
8
+ async function checkPrerequisites(ctx) {
9
+ const checks = new listr_1.default([
10
+ {
11
+ title: `docker compose exists and the version is at least ${MIN_DOCO_VERSION}`,
12
+ task: async () => {
13
+ const docov = await (0, execute_1.execute)("docker", "compose", "version");
14
+ const matches = docov.stdout.match(/[^0-9.]*([0-9.]*).*/);
15
+ const docoVersion = matches ? matches[1] : null;
16
+ ctx.logInfo(`Found Docker Compose version: ${docoVersion}`);
17
+ if (!docoVersion) {
18
+ throw new Error("Unable to read the version of Docker Compose. Are you sure Docker and the Compose plugin are installed?");
19
+ }
20
+ if (docoVersion < MIN_DOCO_VERSION) {
21
+ throw new Error(`Your version of Docker Compose (${docoVersion}) is below the required version (${MIN_DOCO_VERSION}).`);
22
+ }
23
+ },
24
+ },
25
+ ]);
26
+ try {
27
+ await checks.run();
28
+ return true;
29
+ }
30
+ catch (error) {
31
+ ctx.logKo(error.message);
32
+ return false;
33
+ }
34
+ }
35
+ exports.checkPrerequisites = checkPrerequisites;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kourou",
3
3
  "description": "The CLI that helps you manage your Kuzzle instances",
4
- "version": "0.26.1",
4
+ "version": "0.26.2",
5
5
  "author": "The Kuzzle Team <support@kuzzle.io>",
6
6
  "bin": {
7
7
  "kourou": "./bin/run"