kourou 0.19.2 → 0.20.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 +148 -108
- package/lib/commands/app/scaffold.d.ts +2 -0
- package/lib/commands/app/scaffold.js +30 -7
- package/lib/commands/app/start-services.js +7 -7
- package/lib/commands/collection/export.d.ts +1 -0
- package/lib/commands/collection/export.js +24 -7
- package/lib/commands/collection/import.js +4 -4
- package/lib/commands/config/diff.js +5 -5
- package/lib/commands/document/search.js +1 -1
- package/lib/commands/es/migrate.js +3 -3
- package/lib/commands/file/decrypt.js +2 -2
- package/lib/commands/file/encrypt.js +2 -2
- package/lib/commands/file/test.js +2 -2
- package/lib/commands/import.js +7 -7
- package/lib/commands/index/export.d.ts +2 -0
- package/lib/commands/index/export.js +13 -5
- package/lib/commands/index/import.js +4 -4
- package/lib/commands/instance/kill.js +6 -6
- package/lib/commands/instance/list.js +1 -1
- package/lib/commands/instance/logs.js +3 -3
- package/lib/commands/instance/spawn.js +10 -10
- package/lib/commands/profile/export.js +2 -2
- package/lib/commands/profile/import.js +2 -2
- package/lib/commands/realtime/subscribe.js +1 -1
- package/lib/commands/role/export.js +2 -3
- package/lib/commands/role/import.js +2 -2
- package/lib/commands/sdk/execute.js +2 -2
- package/lib/commands/sdk/query.js +1 -1
- package/lib/commands/user/export-mappings.js +2 -2
- package/lib/commands/user/export.js +4 -4
- package/lib/commands/user/import-mappings.js +1 -1
- package/lib/commands/user/import.js +2 -2
- package/lib/commands/vault/add.js +2 -2
- package/lib/commands/vault/decrypt.js +2 -2
- package/lib/commands/vault/encrypt.js +2 -2
- package/lib/commands/vault/show.js +3 -3
- package/lib/commands/vault/test.js +1 -1
- package/lib/common.d.ts +17 -0
- package/lib/common.js +35 -4
- package/lib/hooks/command_not_found/api-action.js +2 -2
- package/lib/support/dump-collection.d.ts +1 -1
- package/lib/support/dump-collection.js +211 -61
- package/lib/support/editor.js +3 -3
- package/lib/support/execute.js +1 -1
- package/lib/support/kuzzle.d.ts +1 -1
- package/lib/support/kuzzle.js +1 -0
- package/lib/support/restore-collection.js +5 -5
- package/lib/support/restore-securities.js +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +21 -19
- package/templates.tgz +0 -0
- package/lib/commands/es/snapshot/restore.d.ts +0 -18
- package/lib/commands/es/snapshot/restore.js +0 -52
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const command_1 = require("@oclif/command");
|
|
5
5
|
const elasticsearch_1 = require("@elastic/elasticsearch");
|
|
6
|
-
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
7
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
-
const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
|
|
6
|
+
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
7
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
8
|
+
const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
|
|
9
9
|
const common_1 = require("../../common");
|
|
10
10
|
class EsMigrate extends common_1.Kommand {
|
|
11
11
|
async migrateMappings(index) {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FileDecrypt = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
7
7
|
const command_1 = require("@oclif/command");
|
|
8
8
|
const kuzzle_vault_1 = require("kuzzle-vault");
|
|
9
9
|
const common_1 = require("../../common");
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VaultEncrypt = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
7
7
|
const command_1 = require("@oclif/command");
|
|
8
8
|
const kuzzle_vault_1 = require("kuzzle-vault");
|
|
9
9
|
const common_1 = require("../../common");
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FileTest = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
7
7
|
const command_1 = require("@oclif/command");
|
|
8
8
|
const kuzzle_vault_1 = require("kuzzle-vault");
|
|
9
9
|
const common_1 = require("../../common");
|
package/lib/commands/import.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const command_1 = require("@oclif/command");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
7
7
|
const common_1 = require("../common");
|
|
8
8
|
const kuzzle_1 = require("../support/kuzzle");
|
|
9
9
|
const restore_collection_1 = require("../support/restore-collection");
|
|
@@ -15,7 +15,7 @@ class Import extends common_1.Kommand {
|
|
|
15
15
|
try {
|
|
16
16
|
this.logInfo(`[collection] Start importing mappings in ${file}`);
|
|
17
17
|
const dump = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
|
|
18
|
-
const { index, collection } = await restore_collection_1.restoreCollectionMappings(this.sdk, dump);
|
|
18
|
+
const { index, collection } = await (0, restore_collection_1.restoreCollectionMappings)(this.sdk, dump);
|
|
19
19
|
this.logOk(`[collection] Imported mappings for "${index}":"${collection}"`);
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
@@ -25,7 +25,7 @@ class Import extends common_1.Kommand {
|
|
|
25
25
|
for (const file of files.documents) {
|
|
26
26
|
try {
|
|
27
27
|
this.logInfo(`[collection] Start importing documents in ${file}`);
|
|
28
|
-
const { total, index, collection } = await restore_collection_1.restoreCollectionData(this.sdk, this.log.bind(this), Number(this.flags['batch-size']), file);
|
|
28
|
+
const { total, index, collection } = await (0, restore_collection_1.restoreCollectionData)(this.sdk, this.log.bind(this), Number(this.flags['batch-size']), file);
|
|
29
29
|
this.logOk(`[collection] Imported ${total} documents in "${index}":"${collection}"`);
|
|
30
30
|
}
|
|
31
31
|
catch (error) {
|
|
@@ -36,7 +36,7 @@ class Import extends common_1.Kommand {
|
|
|
36
36
|
try {
|
|
37
37
|
this.logInfo(`[roles] Start importing roles in ${file}`);
|
|
38
38
|
const dump = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
|
|
39
|
-
const total = await restore_securities_1.restoreRoles(this, dump, this.flags['preserve-anonymous']);
|
|
39
|
+
const total = await (0, restore_securities_1.restoreRoles)(this, dump, this.flags['preserve-anonymous']);
|
|
40
40
|
this.logOk(`[roles] Imported ${total} roles`);
|
|
41
41
|
}
|
|
42
42
|
catch (error) {
|
|
@@ -47,7 +47,7 @@ class Import extends common_1.Kommand {
|
|
|
47
47
|
try {
|
|
48
48
|
this.logInfo(`[profiles] Start importing profiles in ${file}`);
|
|
49
49
|
const dump = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
|
|
50
|
-
const total = await restore_securities_1.restoreProfiles(this, dump);
|
|
50
|
+
const total = await (0, restore_securities_1.restoreProfiles)(this, dump);
|
|
51
51
|
this.logOk(`[profiles] Imported ${total} profiles`);
|
|
52
52
|
}
|
|
53
53
|
catch (error) {
|
|
@@ -70,7 +70,7 @@ class Import extends common_1.Kommand {
|
|
|
70
70
|
try {
|
|
71
71
|
this.logInfo(`[users] Start importing users in ${file}`);
|
|
72
72
|
const dump = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
|
|
73
|
-
const total = await restore_securities_1.restoreUsers(this, dump);
|
|
73
|
+
const total = await (0, restore_securities_1.restoreUsers)(this, dump);
|
|
74
74
|
this.logOk(`[users] Imported ${total} users`);
|
|
75
75
|
}
|
|
76
76
|
catch (error) {
|
|
@@ -14,6 +14,7 @@ export default class IndexExport extends Kommand {
|
|
|
14
14
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
15
15
|
path: flags.IOptionFlag<string | undefined>;
|
|
16
16
|
'batch-size': flags.IOptionFlag<string>;
|
|
17
|
+
query: flags.IOptionFlag<string>;
|
|
17
18
|
format: flags.IOptionFlag<string>;
|
|
18
19
|
};
|
|
19
20
|
static args: {
|
|
@@ -21,5 +22,6 @@ export default class IndexExport extends Kommand {
|
|
|
21
22
|
description: string;
|
|
22
23
|
required: boolean;
|
|
23
24
|
}[];
|
|
25
|
+
static examples: string[];
|
|
24
26
|
runSafe(): Promise<void>;
|
|
25
27
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const command_1 = require("@oclif/command");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
7
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
|
+
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
7
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
8
8
|
const common_1 = require("../../common");
|
|
9
9
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
10
10
|
const dump_collection_1 = require("../../support/dump-collection");
|
|
@@ -13,14 +13,15 @@ class IndexExport extends common_1.Kommand {
|
|
|
13
13
|
const exportPath = this.flags.path
|
|
14
14
|
? path_1.default.join(this.flags.path, this.args.index)
|
|
15
15
|
: this.args.index;
|
|
16
|
+
const query = this.parseJs(this.flags.query);
|
|
16
17
|
this.logInfo(`Dumping index "${this.args.index}" in ${exportPath}${path_1.default.sep} ...`);
|
|
17
18
|
fs_1.default.mkdirSync(exportPath, { recursive: true });
|
|
18
19
|
const { collections } = await this.sdk.collection.list(this.args.index);
|
|
19
20
|
for (const collection of collections) {
|
|
20
21
|
try {
|
|
21
22
|
if (collection.type !== 'realtime') {
|
|
22
|
-
await dump_collection_1.dumpCollectionMappings(this.sdk, this.args.index, collection.name, exportPath, this.flags.format);
|
|
23
|
-
await dump_collection_1.dumpCollectionData(this.sdk, this.args.index, collection.name, Number(this.flags['batch-size']), exportPath,
|
|
23
|
+
await (0, dump_collection_1.dumpCollectionMappings)(this.sdk, this.args.index, collection.name, exportPath, this.flags.format);
|
|
24
|
+
await (0, dump_collection_1.dumpCollectionData)(this.sdk, this.args.index, collection.name, Number(this.flags['batch-size']), exportPath, query, this.flags.format);
|
|
24
25
|
cli_ux_1.default.action.stop();
|
|
25
26
|
}
|
|
26
27
|
}
|
|
@@ -38,6 +39,9 @@ IndexExport.flags = Object.assign(Object.assign({ help: command_1.flags.help({})
|
|
|
38
39
|
}), 'batch-size': command_1.flags.string({
|
|
39
40
|
description: 'Maximum batch size (see limits.documentsFetchCount config)',
|
|
40
41
|
default: '2000'
|
|
42
|
+
}), query: command_1.flags.string({
|
|
43
|
+
description: 'Only dump documents in collections matching the query (JS or JSON format)',
|
|
44
|
+
default: '{}'
|
|
41
45
|
}), format: command_1.flags.string({
|
|
42
46
|
description: '"jsonl or kuzzle - kuzzle will export in Kuzzle format usable for internal fixtures and jsonl allows to import that data back with kourou',
|
|
43
47
|
default: 'jsonl'
|
|
@@ -48,3 +52,7 @@ IndexExport.flags = Object.assign(Object.assign({ help: command_1.flags.help({})
|
|
|
48
52
|
IndexExport.args = [
|
|
49
53
|
{ name: 'index', description: 'Index name', required: true },
|
|
50
54
|
];
|
|
55
|
+
IndexExport.examples = [
|
|
56
|
+
'kourou index:export nyc-open-data',
|
|
57
|
+
'kourou index:export nyc-open-data --query \'{"range":{"_kuzzle_info.createdAt":{"gt":1632935638866}}}\'',
|
|
58
|
+
];
|
|
@@ -1,8 +1,8 @@
|
|
|
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 common_1 = require("../../common");
|
|
8
8
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
@@ -21,9 +21,9 @@ class IndexImport extends common_1.Kommand {
|
|
|
21
21
|
if (!this.flags['no-mappings']) {
|
|
22
22
|
const mappingsPath = path_1.default.join(dumpDir, 'mappings.json');
|
|
23
23
|
const dump = JSON.parse(fs_1.default.readFileSync(mappingsPath, 'utf8'));
|
|
24
|
-
await restore_collection_1.restoreCollectionMappings(this.sdk, dump, this.flags.index);
|
|
24
|
+
await (0, restore_collection_1.restoreCollectionMappings)(this.sdk, dump, this.flags.index);
|
|
25
25
|
}
|
|
26
|
-
const { total, collection, index: dstIndex } = await restore_collection_1.restoreCollectionData(this.sdk, this.log.bind(this), Number(this.flags['batch-size']), path_1.default.join(dumpDir, 'documents.jsonl'), this.flags.index);
|
|
26
|
+
const { total, collection, index: dstIndex } = await (0, restore_collection_1.restoreCollectionData)(this.sdk, this.log.bind(this), Number(this.flags['batch-size']), path_1.default.join(dumpDir, 'documents.jsonl'), this.flags.index);
|
|
27
27
|
this.logOk(`Successfully imported ${total} documents in "${dstIndex}:${collection}"`);
|
|
28
28
|
}
|
|
29
29
|
catch (error) {
|
|
@@ -3,11 +3,11 @@ 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"));
|
|
7
|
-
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
6
|
+
const inquirer_1 = (0, tslib_1.__importDefault)(require("inquirer"));
|
|
7
|
+
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
8
8
|
const child_process_1 = require("child_process");
|
|
9
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
10
|
-
const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
|
|
9
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
10
|
+
const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
|
|
11
11
|
const common_1 = require("../../common");
|
|
12
12
|
const execute_1 = require("../../support/execute");
|
|
13
13
|
class InstanceLogs extends common_1.Kommand {
|
|
@@ -48,7 +48,7 @@ class InstanceLogs extends common_1.Kommand {
|
|
|
48
48
|
cli_ux_1.default.action.start(`${node_emoji_1.default.get('boom')} Killing Kuzzle instance ${instanceName}`, undefined, {
|
|
49
49
|
stdout: true
|
|
50
50
|
});
|
|
51
|
-
const instanceKill = child_process_1.spawn('docker-compose', [
|
|
51
|
+
const instanceKill = (0, child_process_1.spawn)('docker-compose', [
|
|
52
52
|
'-f',
|
|
53
53
|
docoFilename,
|
|
54
54
|
'-p',
|
|
@@ -68,7 +68,7 @@ class InstanceLogs extends common_1.Kommand {
|
|
|
68
68
|
async getInstancesList() {
|
|
69
69
|
let containersListProcess;
|
|
70
70
|
try {
|
|
71
|
-
containersListProcess = await execute_1.execute('docker', 'ps', '--format', '"{{.Names}}"');
|
|
71
|
+
containersListProcess = await (0, execute_1.execute)('docker', 'ps', '--format', '"{{.Names}}"');
|
|
72
72
|
}
|
|
73
73
|
catch (error) {
|
|
74
74
|
this.warn(`Something went wrong while getting kuzzle running instances list: ${error.message}`);
|
|
@@ -21,7 +21,7 @@ class InstanceList extends common_1.Kommand {
|
|
|
21
21
|
async getInstancesList() {
|
|
22
22
|
let containersListProcess;
|
|
23
23
|
try {
|
|
24
|
-
containersListProcess = await execute_1.execute('docker', 'ps', '--format', '"{{.Names}}%{{.Image}}%{{.Status}}%{{.Ports}}"');
|
|
24
|
+
containersListProcess = await (0, execute_1.execute)('docker', 'ps', '--format', '"{{.Names}}%{{.Image}}%{{.Status}}%{{.Ports}}"');
|
|
25
25
|
}
|
|
26
26
|
catch (_a) {
|
|
27
27
|
this.warn('Something went wrong while getting kuzzle running instances list');
|
|
@@ -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 {
|
|
@@ -34,7 +34,7 @@ class InstanceLogs extends common_1.Kommand {
|
|
|
34
34
|
if (followOption) {
|
|
35
35
|
args.push('-f');
|
|
36
36
|
}
|
|
37
|
-
const instanceLogs = execute_1.execute('docker', ...args);
|
|
37
|
+
const instanceLogs = (0, execute_1.execute)('docker', ...args);
|
|
38
38
|
(_a = instanceLogs.process.stdout) === null || _a === void 0 ? void 0 : _a.pipe(process.stdout);
|
|
39
39
|
(_b = instanceLogs.process.stderr) === null || _b === void 0 ? void 0 : _b.pipe(process.stderr);
|
|
40
40
|
await instanceLogs;
|
|
@@ -42,7 +42,7 @@ class InstanceLogs extends common_1.Kommand {
|
|
|
42
42
|
async getInstancesList() {
|
|
43
43
|
let containersListProcess;
|
|
44
44
|
try {
|
|
45
|
-
containersListProcess = await execute_1.execute('docker', 'ps', '--format', '"{{.Names}}"');
|
|
45
|
+
containersListProcess = await (0, execute_1.execute)('docker', 'ps', '--format', '"{{.Names}}"');
|
|
46
46
|
}
|
|
47
47
|
catch (_a) {
|
|
48
48
|
this.warn('Something went wrong while getting kuzzle running instances list');
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const command_1 = require("@oclif/command");
|
|
5
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
5
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
6
6
|
const child_process_1 = require("child_process");
|
|
7
|
-
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
7
|
+
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
|
-
const listr_1 = tslib_1.__importDefault(require("listr"));
|
|
10
|
-
const net_1 = tslib_1.__importDefault(require("net"));
|
|
11
|
-
const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
|
|
9
|
+
const listr_1 = (0, tslib_1.__importDefault)(require("listr"));
|
|
10
|
+
const net_1 = (0, tslib_1.__importDefault)(require("net"));
|
|
11
|
+
const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
|
|
12
12
|
const common_1 = require("../../common");
|
|
13
13
|
const execute_1 = require("../../support/execute");
|
|
14
14
|
const MIN_MAX_MAP_COUNT = 262144;
|
|
@@ -97,10 +97,10 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
97
97
|
throw new Error(`${node_emoji_1.default.get('shrug')} Your system doesn't satisfy all the prerequisites. Cannot run Kuzzle.`);
|
|
98
98
|
}
|
|
99
99
|
this.log(chalk_1.default.grey(`\nWriting docker-compose file to ${docoFilename}...`));
|
|
100
|
-
fs_1.writeFileSync(docoFilename, this.generateDocoFile(this.flags.version, portIndex));
|
|
100
|
+
(0, fs_1.writeFileSync)(docoFilename, this.generateDocoFile(this.flags.version, portIndex));
|
|
101
101
|
// clean up
|
|
102
|
-
await execute_1.execute('docker-compose', '-f', docoFilename, '-p', `stack-${portIndex}`, 'down');
|
|
103
|
-
const doco = child_process_1.spawn('docker-compose', ['-f', docoFilename, '-p', `stack-${portIndex}`, 'up', '-d']);
|
|
102
|
+
await (0, execute_1.execute)('docker-compose', '-f', docoFilename, '-p', `stack-${portIndex}`, 'down');
|
|
103
|
+
const doco = (0, child_process_1.spawn)('docker-compose', ['-f', docoFilename, '-p', `stack-${portIndex}`, 'up', '-d']);
|
|
104
104
|
cli_ux_1.default.action.start(` ${node_emoji_1.default.get('rocket')} Kuzzle version ${this.flags.version} is launching`, undefined, {
|
|
105
105
|
stdout: true,
|
|
106
106
|
});
|
|
@@ -130,7 +130,7 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
130
130
|
title: `docker-compose exists and the version is at least ${MIN_DOCO_VERSION}`,
|
|
131
131
|
task: async () => {
|
|
132
132
|
try {
|
|
133
|
-
const docov = await execute_1.execute('docker-compose', '-v');
|
|
133
|
+
const docov = await (0, execute_1.execute)('docker-compose', '-v');
|
|
134
134
|
const matches = docov.stdout.match(/[^0-9.]*([0-9.]*).*/);
|
|
135
135
|
if (matches === null) {
|
|
136
136
|
throw new Error('Unable to read docker-compose verson. This is weird.');
|
|
@@ -157,7 +157,7 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
157
157
|
title: `vm.max_map_count is greater than ${MIN_MAX_MAP_COUNT}`,
|
|
158
158
|
task: async () => {
|
|
159
159
|
try {
|
|
160
|
-
const sysctl = await execute_1.execute('/sbin/sysctl', '-n', 'vm.max_map_count');
|
|
160
|
+
const sysctl = await (0, execute_1.execute)('/sbin/sysctl', '-n', 'vm.max_map_count');
|
|
161
161
|
if (sysctl.exitCode !== 0) {
|
|
162
162
|
throw new Error('Something went wrong checking vm.max_map_count');
|
|
163
163
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
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"));
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
4
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
5
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
7
|
const common_1 = require("../../common");
|
|
8
8
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const command_1 = require("@oclif/command");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
6
|
const common_1 = require("../../common");
|
|
7
7
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
8
8
|
const restore_securities_1 = require("../../support/restore-securities");
|
|
@@ -10,7 +10,7 @@ class ProfileImport extends common_1.Kommand {
|
|
|
10
10
|
async runSafe() {
|
|
11
11
|
this.logInfo(`Importing profiles from ${this.args.path} ...`);
|
|
12
12
|
const dump = JSON.parse(fs_1.default.readFileSync(this.args.path, 'utf-8'));
|
|
13
|
-
const count = await restore_securities_1.restoreProfiles(this, dump);
|
|
13
|
+
const count = await (0, restore_securities_1.restoreProfiles)(this, dump);
|
|
14
14
|
this.logOk(`${count} profiles restored`);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const command_1 = require("@oclif/command");
|
|
5
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
5
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
6
6
|
const common_1 = require("../../common");
|
|
7
7
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
8
8
|
class RealtimeSubscribe extends common_1.Kommand {
|
|
@@ -1,8 +1,8 @@
|
|
|
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"));
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
4
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
5
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
7
|
const common_1 = require("../../common");
|
|
8
8
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
@@ -21,7 +21,6 @@ class RoleDump extends common_1.Kommand {
|
|
|
21
21
|
}
|
|
22
22
|
async _dumpRoles() {
|
|
23
23
|
const options = {
|
|
24
|
-
scroll: '3s',
|
|
25
24
|
size: 100
|
|
26
25
|
};
|
|
27
26
|
let result = await this.sdk.security.searchRoles({}, options);
|
|
@@ -1,7 +1,7 @@
|
|
|
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
6
|
const common_1 = require("../../common");
|
|
7
7
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
@@ -10,7 +10,7 @@ class RoleImport extends common_1.Kommand {
|
|
|
10
10
|
async runSafe() {
|
|
11
11
|
this.logInfo(`Importing roles from ${this.args.path} ...`);
|
|
12
12
|
const dump = JSON.parse(fs_1.default.readFileSync(this.args.path, 'utf-8'));
|
|
13
|
-
const count = await restore_securities_1.restoreRoles(this, dump, this.flags['preserve-anonymous']);
|
|
13
|
+
const count = await (0, restore_securities_1.restoreRoles)(this, dump, this.flags['preserve-anonymous']);
|
|
14
14
|
this.logOk(`${count} roles restored`);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -17,7 +17,7 @@ class SdkExecute extends common_1.Kommand {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
async runSafe() {
|
|
20
|
-
if (lodash_1.isEmpty(this.code)) {
|
|
20
|
+
if ((0, lodash_1.isEmpty)(this.code)) {
|
|
21
21
|
throw new Error('No code provided.');
|
|
22
22
|
}
|
|
23
23
|
let userError = null;
|
|
@@ -56,7 +56,7 @@ ${variables}
|
|
|
56
56
|
}
|
|
57
57
|
if (userError) {
|
|
58
58
|
this.logKo(`Error when executing SDK code: ${userError}`);
|
|
59
|
-
this.log(
|
|
59
|
+
this.log(userError.stack);
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
62
|
this.logOk('Successfully executed SDK code');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const command_1 = require("@oclif/command");
|
|
5
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
5
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
6
6
|
const common_1 = require("../../common");
|
|
7
7
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
8
8
|
class SdkQuery extends common_1.Kommand {
|
|
@@ -1,8 +1,8 @@
|
|
|
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"));
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
4
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
5
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
7
|
const common_1 = require("../../common");
|
|
8
8
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
@@ -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"));
|
|
5
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
6
|
-
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
7
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
4
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
5
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
6
|
+
const crypto_1 = (0, tslib_1.__importDefault)(require("crypto"));
|
|
7
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
8
8
|
const command_1 = require("@oclif/command");
|
|
9
9
|
const common_1 = require("../../common");
|
|
10
10
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const command_1 = require("@oclif/command");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
6
|
const common_1 = require("../../common");
|
|
7
7
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
8
8
|
class UserImportMappings extends common_1.Kommand {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const command_1 = require("@oclif/command");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
6
|
const common_1 = require("../../common");
|
|
7
7
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
8
8
|
const restore_securities_1 = require("../../support/restore-securities");
|
|
@@ -10,7 +10,7 @@ class UserImport extends common_1.Kommand {
|
|
|
10
10
|
async runSafe() {
|
|
11
11
|
this.logInfo(`Importing users from ${this.args.path} ...`);
|
|
12
12
|
const dump = JSON.parse(fs_1.default.readFileSync(this.args.path, 'utf-8'));
|
|
13
|
-
const count = await restore_securities_1.restoreUsers(this, dump);
|
|
13
|
+
const count = await (0, restore_securities_1.restoreUsers)(this, dump);
|
|
14
14
|
this.logOk(`${count} users restored`);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VaultAdd = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
8
8
|
const kuzzle_vault_1 = require("kuzzle-vault");
|
|
9
9
|
const common_1 = require("../../common");
|
|
10
10
|
class VaultAdd extends common_1.Kommand {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VaultDecrypt = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
7
7
|
const command_1 = require("@oclif/command");
|
|
8
8
|
const kuzzle_vault_1 = require("kuzzle-vault");
|
|
9
9
|
const common_1 = require("../../common");
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VaultEncrypt = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
7
7
|
const command_1 = require("@oclif/command");
|
|
8
8
|
const kuzzle_vault_1 = require("kuzzle-vault");
|
|
9
9
|
const common_1 = require("../../common");
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VaultShow = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
7
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
8
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
9
9
|
const kuzzle_vault_1 = require("kuzzle-vault");
|
|
10
10
|
const common_1 = require("../../common");
|
|
11
11
|
class VaultShow extends common_1.Kommand {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VaultTest = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
6
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
7
7
|
const kuzzle_vault_1 = require("kuzzle-vault");
|
|
8
8
|
const common_1 = require("../../common");
|
|
9
9
|
class VaultTest extends common_1.Kommand {
|
package/lib/common.d.ts
CHANGED
|
@@ -27,3 +27,20 @@ export declare abstract class Kommand extends Command {
|
|
|
27
27
|
fromEditor(defaultContent: Record<string, unknown> | string, options?: EditorParams): Record<string, unknown>;
|
|
28
28
|
parseJs(input?: string): any;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* An iteration-order-safe version of lodash.values
|
|
32
|
+
*
|
|
33
|
+
* @param object The object containing the values
|
|
34
|
+
* @param fields The field names to pick in the right order
|
|
35
|
+
* @returns The values in the same order as the fields
|
|
36
|
+
* @see https://lodash.com/docs/4.17.15#values
|
|
37
|
+
*/
|
|
38
|
+
export declare function pickValues(object: any, fields: string[]): any[];
|
|
39
|
+
/**
|
|
40
|
+
* Formats the value for correct CSV output, avoiding to return
|
|
41
|
+
* values that would badly serialize in CSV.
|
|
42
|
+
*
|
|
43
|
+
* @param value The value to format
|
|
44
|
+
* @returns The value or a string telling the value is not scalar
|
|
45
|
+
*/
|
|
46
|
+
export declare function formatValueForCSV(value: any): any;
|
package/lib/common.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Kommand = void 0;
|
|
3
|
+
exports.formatValueForCSV = exports.pickValues = exports.Kommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
|
|
8
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
7
|
+
const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
|
|
8
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
9
|
+
const get_1 = (0, tslib_1.__importDefault)(require("lodash/get"));
|
|
10
|
+
const isObject_1 = (0, tslib_1.__importDefault)(require("lodash/isObject"));
|
|
9
11
|
const kuzzle_1 = require("./support/kuzzle");
|
|
10
12
|
const editor_1 = require("./support/editor");
|
|
11
13
|
class Kommand extends command_1.Command {
|
|
@@ -86,6 +88,9 @@ class Kommand extends command_1.Command {
|
|
|
86
88
|
? ` (https://docs.kuzzle.io/core/2/api/errors/error-codes/${error.id.split('.')[0]})`
|
|
87
89
|
: '';
|
|
88
90
|
this.logKo(`Error stack: \n${stack || error.message}\n\nError status: ${error.status}\n\nError id: ${error.id}${errorLink}`);
|
|
91
|
+
for (const err of error.errors) {
|
|
92
|
+
this.logKo(err);
|
|
93
|
+
}
|
|
89
94
|
}
|
|
90
95
|
finally {
|
|
91
96
|
this.sdk.disconnect();
|
|
@@ -131,3 +136,29 @@ class Kommand extends command_1.Command {
|
|
|
131
136
|
exports.Kommand = Kommand;
|
|
132
137
|
Kommand.initSdk = true;
|
|
133
138
|
Kommand.readStdin = false;
|
|
139
|
+
/**
|
|
140
|
+
* An iteration-order-safe version of lodash.values
|
|
141
|
+
*
|
|
142
|
+
* @param object The object containing the values
|
|
143
|
+
* @param fields The field names to pick in the right order
|
|
144
|
+
* @returns The values in the same order as the fields
|
|
145
|
+
* @see https://lodash.com/docs/4.17.15#values
|
|
146
|
+
*/
|
|
147
|
+
function pickValues(object, fields) {
|
|
148
|
+
return fields.map(f => formatValueForCSV((0, get_1.default)(object, f)));
|
|
149
|
+
}
|
|
150
|
+
exports.pickValues = pickValues;
|
|
151
|
+
/**
|
|
152
|
+
* Formats the value for correct CSV output, avoiding to return
|
|
153
|
+
* values that would badly serialize in CSV.
|
|
154
|
+
*
|
|
155
|
+
* @param value The value to format
|
|
156
|
+
* @returns The value or a string telling the value is not scalar
|
|
157
|
+
*/
|
|
158
|
+
function formatValueForCSV(value) {
|
|
159
|
+
if ((0, isObject_1.default)(value)) {
|
|
160
|
+
return '[NOT_SCALAR]';
|
|
161
|
+
}
|
|
162
|
+
return value;
|
|
163
|
+
}
|
|
164
|
+
exports.formatValueForCSV = formatValueForCSV;
|