kourou 0.20.7 → 0.22.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 +92 -10
- package/lib/commands/app/scaffold.d.ts +3 -3
- package/lib/commands/app/scaffold.js +16 -69
- package/lib/commands/app/start-services.js +6 -4
- package/lib/commands/collection/export.d.ts +1 -0
- package/lib/commands/collection/export.js +3 -2
- package/lib/commands/collection/import.d.ts +1 -0
- package/lib/commands/collection/import.js +3 -2
- package/lib/commands/config/diff.js +3 -3
- package/lib/commands/es/migrate.d.ts +5 -2
- package/lib/commands/es/migrate.js +51 -30
- 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.d.ts +1 -0
- package/lib/commands/import.js +3 -2
- package/lib/commands/index/export.d.ts +1 -0
- package/lib/commands/index/export.js +4 -3
- package/lib/commands/index/import.d.ts +1 -0
- package/lib/commands/index/import.js +3 -2
- package/lib/commands/instance/kill.js +7 -5
- package/lib/commands/instance/logs.js +1 -1
- package/lib/commands/instance/spawn.js +8 -7
- package/lib/commands/paas/deploy.d.ts +18 -0
- package/lib/commands/paas/deploy.js +66 -0
- package/lib/commands/paas/init.d.ts +14 -0
- package/lib/commands/paas/init.js +31 -0
- package/lib/commands/paas/login.d.ts +15 -0
- package/lib/commands/paas/login.js +64 -0
- package/lib/commands/paas/logs.d.ts +17 -0
- package/lib/commands/paas/logs.js +54 -0
- package/lib/commands/profile/export.js +2 -2
- package/lib/commands/profile/import.js +1 -1
- package/lib/commands/realtime/subscribe.js +1 -1
- package/lib/commands/role/export.js +2 -2
- package/lib/commands/role/import.js +1 -1
- 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 +1 -1
- 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 +6 -1
- package/lib/common.js +32 -15
- package/lib/hooks/command_not_found/api-action.js +10 -6
- package/lib/support/PaasKommand.d.ts +22 -0
- package/lib/support/PaasKommand.js +58 -0
- package/lib/support/dump-collection.js +4 -4
- package/lib/support/editor.js +2 -2
- package/lib/support/kuzzle.d.ts +3 -1
- package/lib/support/kuzzle.js +14 -10
- package/lib/support/restore-collection.js +3 -3
- package/lib/support/restore-securities.js +2 -2
- package/package.json +10 -11
- package/oclif.manifest.json +0 -1
- package/scripts/postinstall.sh +0 -10
- package/templates.tgz +0 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ The CLI that helps you manage your Kuzzle instances.
|
|
|
13
13
|
* [Commands](#commands)
|
|
14
14
|
* [Where does this weird name come from?](#where-does-this-weird-name-come-from)
|
|
15
15
|
* [Have fun with a quine](#have-fun-with-a-quine)
|
|
16
|
-
* [
|
|
16
|
+
* [Telemetry](#telemetry)
|
|
17
17
|
<!-- tocstop -->
|
|
18
18
|
|
|
19
19
|
:warning: This project is currently in beta and breaking changes may occur until the 1.0.0
|
|
@@ -26,7 +26,7 @@ $ npm install -g kourou
|
|
|
26
26
|
$ kourou COMMAND
|
|
27
27
|
running command...
|
|
28
28
|
$ kourou (-v|--version|version)
|
|
29
|
-
kourou/0.
|
|
29
|
+
kourou/0.22.0 linux-x64 node-v16.15.0
|
|
30
30
|
$ kourou --help [COMMAND]
|
|
31
31
|
USAGE
|
|
32
32
|
$ kourou COMMAND
|
|
@@ -129,7 +129,7 @@ All other arguments and options will be passed as-is to the `sdk:query` method.
|
|
|
129
129
|
* [`kourou api-key:create USER`](#kourou-api-keycreate-user)
|
|
130
130
|
* [`kourou api-key:delete USER ID`](#kourou-api-keydelete-user-id)
|
|
131
131
|
* [`kourou api-key:search USER`](#kourou-api-keysearch-user)
|
|
132
|
-
* [`kourou app:scaffold
|
|
132
|
+
* [`kourou app:scaffold DESTINATION`](#kourou-appscaffold-destination)
|
|
133
133
|
* [`kourou app:start-services`](#kourou-appstart-services)
|
|
134
134
|
* [`kourou autocomplete [SHELL]`](#kourou-autocomplete-shell)
|
|
135
135
|
* [`kourou collection:create INDEX COLLECTION [BODY]`](#kourou-collectioncreate-index-collection-body)
|
|
@@ -155,6 +155,10 @@ All other arguments and options will be passed as-is to the `sdk:query` method.
|
|
|
155
155
|
* [`kourou instance:list`](#kourou-instancelist)
|
|
156
156
|
* [`kourou instance:logs`](#kourou-instancelogs)
|
|
157
157
|
* [`kourou instance:spawn`](#kourou-instancespawn)
|
|
158
|
+
* [`kourou paas:deploy ENVIRONMENT IMAGE`](#kourou-paasdeploy-environment-image)
|
|
159
|
+
* [`kourou paas:init PROJECT`](#kourou-paasinit-project)
|
|
160
|
+
* [`kourou paas:login`](#kourou-paaslogin)
|
|
161
|
+
* [`kourou paas:logs ENVIRONMENT APPLICATION`](#kourou-paaslogs-environment-application)
|
|
158
162
|
* [`kourou profile:export`](#kourou-profileexport)
|
|
159
163
|
* [`kourou profile:import PATH`](#kourou-profileimport-path)
|
|
160
164
|
* [`kourou realtime:subscribe INDEX COLLECTION [FILTERS]`](#kourou-realtimesubscribe-index-collection-filters)
|
|
@@ -284,19 +288,20 @@ OPTIONS
|
|
|
284
288
|
|
|
285
289
|
_See code: [src/commands/api-key/search.ts](src/commands/api-key/search.ts)_
|
|
286
290
|
|
|
287
|
-
## `kourou app:scaffold
|
|
291
|
+
## `kourou app:scaffold DESTINATION`
|
|
288
292
|
|
|
289
293
|
Scaffolds a new Kuzzle application
|
|
290
294
|
|
|
291
295
|
```
|
|
292
296
|
USAGE
|
|
293
|
-
$ kourou app:scaffold
|
|
297
|
+
$ kourou app:scaffold DESTINATION
|
|
294
298
|
|
|
295
299
|
ARGUMENTS
|
|
296
|
-
|
|
300
|
+
DESTINATION Directory to scaffold the app
|
|
297
301
|
|
|
298
302
|
OPTIONS
|
|
299
|
-
--
|
|
303
|
+
--flavor=flavor [default: generic] Template flavor ("generic", "iot-platform")
|
|
304
|
+
--help show CLI help
|
|
300
305
|
```
|
|
301
306
|
|
|
302
307
|
_See code: [src/commands/app/scaffold.ts](src/commands/app/scaffold.ts)_
|
|
@@ -337,7 +342,7 @@ EXAMPLES
|
|
|
337
342
|
$ kourou autocomplete --refresh-cache
|
|
338
343
|
```
|
|
339
344
|
|
|
340
|
-
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/
|
|
345
|
+
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v1.2.0/src/commands/autocomplete/index.ts)_
|
|
341
346
|
|
|
342
347
|
## `kourou collection:create INDEX COLLECTION [BODY]`
|
|
343
348
|
|
|
@@ -598,9 +603,12 @@ USAGE
|
|
|
598
603
|
OPTIONS
|
|
599
604
|
--batch-size=batch-size [default: 1000] How many documents to move in batch per operation
|
|
600
605
|
--dest=dest (required) Destination Elasticsearch server URL
|
|
606
|
+
--dry-run Print witch collections will be migrated
|
|
601
607
|
--help show CLI help
|
|
602
608
|
--no-interactive Skip confirmation interactive prompts (perfect for scripting)
|
|
609
|
+
--pattern=pattern Pattern to match indices to migrate
|
|
603
610
|
--reset Reset destination Elasticsearch server
|
|
611
|
+
--scroll=scroll [default: 30s] Scroll duration for Elasticsearch scrolling
|
|
604
612
|
--src=src (required) Source Elasticsearch server URL
|
|
605
613
|
|
|
606
614
|
EXAMPLES
|
|
@@ -911,6 +919,78 @@ OPTIONS
|
|
|
911
919
|
|
|
912
920
|
_See code: [src/commands/instance/spawn.ts](src/commands/instance/spawn.ts)_
|
|
913
921
|
|
|
922
|
+
## `kourou paas:deploy ENVIRONMENT IMAGE`
|
|
923
|
+
|
|
924
|
+
Deploy a new version of the application in the PaaS
|
|
925
|
+
|
|
926
|
+
```
|
|
927
|
+
USAGE
|
|
928
|
+
$ kourou paas:deploy ENVIRONMENT IMAGE
|
|
929
|
+
|
|
930
|
+
ARGUMENTS
|
|
931
|
+
ENVIRONMENT Project environment name
|
|
932
|
+
IMAGE Image name and hash as myimage:mytag
|
|
933
|
+
|
|
934
|
+
OPTIONS
|
|
935
|
+
--help show CLI help
|
|
936
|
+
--project=project Current PaaS project
|
|
937
|
+
--token=token Authentication token
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
_See code: [src/commands/paas/deploy.ts](src/commands/paas/deploy.ts)_
|
|
941
|
+
|
|
942
|
+
## `kourou paas:init PROJECT`
|
|
943
|
+
|
|
944
|
+
Initialize a PaaS project in current directory
|
|
945
|
+
|
|
946
|
+
```
|
|
947
|
+
USAGE
|
|
948
|
+
$ kourou paas:init PROJECT
|
|
949
|
+
|
|
950
|
+
ARGUMENTS
|
|
951
|
+
PROJECT Kuzzle PaaS project name
|
|
952
|
+
|
|
953
|
+
OPTIONS
|
|
954
|
+
--help show CLI help
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
_See code: [src/commands/paas/init.ts](src/commands/paas/init.ts)_
|
|
958
|
+
|
|
959
|
+
## `kourou paas:login`
|
|
960
|
+
|
|
961
|
+
Login for a PaaS project
|
|
962
|
+
|
|
963
|
+
```
|
|
964
|
+
USAGE
|
|
965
|
+
$ kourou paas:login
|
|
966
|
+
|
|
967
|
+
OPTIONS
|
|
968
|
+
--help show CLI help
|
|
969
|
+
--project=project Current PaaS project
|
|
970
|
+
--username=username PaaS username
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
_See code: [src/commands/paas/login.ts](src/commands/paas/login.ts)_
|
|
974
|
+
|
|
975
|
+
## `kourou paas:logs ENVIRONMENT APPLICATION`
|
|
976
|
+
|
|
977
|
+
Show logs of the targeted application
|
|
978
|
+
|
|
979
|
+
```
|
|
980
|
+
USAGE
|
|
981
|
+
$ kourou paas:logs ENVIRONMENT APPLICATION
|
|
982
|
+
|
|
983
|
+
ARGUMENTS
|
|
984
|
+
ENVIRONMENT Kuzzle PaaS environment
|
|
985
|
+
APPLICATION Kuzzle PaaS application
|
|
986
|
+
|
|
987
|
+
OPTIONS
|
|
988
|
+
--help show CLI help
|
|
989
|
+
--project=project Current PaaS project
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
_See code: [src/commands/paas/logs.ts](src/commands/paas/logs.ts)_
|
|
993
|
+
|
|
914
994
|
## `kourou profile:export`
|
|
915
995
|
|
|
916
996
|
Exports profiles
|
|
@@ -1555,8 +1635,10 @@ $ kourou sdk:execute --print-raw '(
|
|
|
1555
1635
|
|
|
1556
1636
|
(Kuzzle must be accessible and running in local)
|
|
1557
1637
|
|
|
1558
|
-
#
|
|
1638
|
+
# Telemetry
|
|
1639
|
+
|
|
1640
|
+
We use a custom Open Source analytics backend (you can check the code [here](https://gihtub.com/kuzzleio/kepler)) to record the use of Kourou by users.
|
|
1559
1641
|
|
|
1560
|
-
We use a custom Open Source analytics backend (you can check the code [here](https://gihtub.com/kuzzleio/kepler)) to record the use of Kourou by users.
|
|
1561
1642
|
Collected metrics will allow us to study the use of our products in order to improve them. We do not collect any personal data about users.
|
|
1643
|
+
|
|
1562
1644
|
You can disable usage metrics collection by setting the `KOUROU_USAGE` environment variable to `false`.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
1
2
|
import { Kommand } from '../../common';
|
|
2
3
|
export default class AppScaffold extends Kommand {
|
|
3
4
|
static initSdk: boolean;
|
|
4
5
|
static description: string;
|
|
5
6
|
static flags: {
|
|
6
7
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
8
|
+
flavor: flags.IOptionFlag<string>;
|
|
7
9
|
};
|
|
8
10
|
static args: {
|
|
9
11
|
name: string;
|
|
10
12
|
description: string;
|
|
11
13
|
required: boolean;
|
|
12
14
|
}[];
|
|
13
|
-
checkKebabCase(name: string): boolean;
|
|
14
|
-
convertToKebabCase(name: string): string;
|
|
15
15
|
runSafe(): Promise<void>;
|
|
16
|
-
|
|
16
|
+
cloneTemplate(flavor: string, destination: string): Promise<void>;
|
|
17
17
|
}
|
|
@@ -1,86 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
5
|
-
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
4
|
const command_1 = require("@oclif/command");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const listr_1 = (0, tslib_1.__importDefault)(require("listr"));
|
|
10
|
-
const inquirer_1 = (0, tslib_1.__importDefault)(require("inquirer"));
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const listr_1 = tslib_1.__importDefault(require("listr"));
|
|
11
7
|
const common_1 = require("../../common");
|
|
12
8
|
const execute_1 = require("../../support/execute");
|
|
13
|
-
const templatesDir = path_1.default.join(__dirname, '..', '..', '..', 'templates');
|
|
14
|
-
const TEMPLATED_ENTRIES = [
|
|
15
|
-
'package.json',
|
|
16
|
-
'app.ts',
|
|
17
|
-
'README.md'
|
|
18
|
-
];
|
|
19
|
-
const KEBAB_CASE_REGEX = /^[a-z-\d]+$/;
|
|
20
9
|
class AppScaffold extends common_1.Kommand {
|
|
21
|
-
checkKebabCase(name) {
|
|
22
|
-
return KEBAB_CASE_REGEX.test(name);
|
|
23
|
-
}
|
|
24
|
-
convertToKebabCase(name) {
|
|
25
|
-
return name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
26
|
-
}
|
|
27
10
|
async runSafe() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const kebabCasedName = this.convertToKebabCase(this.args.name);
|
|
31
|
-
const response = await inquirer_1.default.prompt([
|
|
32
|
-
{
|
|
33
|
-
name: 'kebabCaseConversion',
|
|
34
|
-
type: 'confirm',
|
|
35
|
-
message: `Would you like to convert "${this.args.name}" to "${kebabCasedName}"`
|
|
36
|
-
}
|
|
37
|
-
]);
|
|
38
|
-
if (!response.kebabCaseConversion) {
|
|
39
|
-
process.exit(0);
|
|
40
|
-
}
|
|
41
|
-
this.args.name = kebabCasedName;
|
|
42
|
-
}
|
|
43
|
-
const templatePath = path_1.default.join(templatesDir, 'app-scaffold', 'ts');
|
|
11
|
+
const destination = this.args.destination;
|
|
12
|
+
const flavor = this.flags.flavor;
|
|
44
13
|
const tasks = new listr_1.default([
|
|
45
|
-
{
|
|
46
|
-
title: `Creating directory: ${chalk_1.default.gray(this.args.name + path_1.default.sep)}`,
|
|
47
|
-
task: () => (0, execute_1.execute)('mkdir', this.args.name)
|
|
48
|
-
},
|
|
49
14
|
{
|
|
50
15
|
title: 'Creating and rendering application files',
|
|
51
|
-
task: () => this.
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
title: 'Installing dependencies (this can take some time)',
|
|
55
|
-
task: () => (0, execute_1.execute)('npm', 'run', 'install:docker', { cwd: this.args.name })
|
|
16
|
+
task: async () => this.cloneTemplate(flavor, destination)
|
|
56
17
|
},
|
|
57
18
|
]);
|
|
58
19
|
await tasks.run();
|
|
59
|
-
this.
|
|
20
|
+
this.log('');
|
|
21
|
+
this.logOk(`Scaffolding complete! Use ${chalk_1.default.grey(`cd ${destination} && npm run docker npm install`)} install dependencies and then ${chalk_1.default.grey(`npm run docker:dev`)} to run your application!`);
|
|
60
22
|
}
|
|
61
|
-
async
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const entryDir = path_1.default.dirname(path_1.default.join(this.args.name, entryPath));
|
|
66
|
-
const entryInfo = fs_1.default.statSync(entryPath);
|
|
67
|
-
if (entryInfo.isDirectory()) {
|
|
68
|
-
fs_1.default.mkdirSync(entryDir.replace(templatePath, ''), { recursive: true });
|
|
69
|
-
await this.renderTemplates(entryPath, templatePath);
|
|
70
|
-
}
|
|
71
|
-
else if (entryInfo.isFile() || entryInfo.isSymbolicLink()) {
|
|
72
|
-
const content = fs_1.default.readFileSync(entryPath, 'utf8');
|
|
73
|
-
// Only render a whitelist a files who need it
|
|
74
|
-
const rendered = TEMPLATED_ENTRIES.includes(entry)
|
|
75
|
-
? lodash_1.default.template(content)({ appName: this.args.name })
|
|
76
|
-
: content;
|
|
77
|
-
fs_1.default.mkdirSync(entryDir.replace(templatePath, ''), { recursive: true });
|
|
78
|
-
fs_1.default.writeFileSync(path_1.default.join(this.args.name, entryPath.replace(templatePath, '')), rendered);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
this.logInfo(`Skipped ${entryPath} because it's not a regular file`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
23
|
+
async cloneTemplate(flavor, destination) {
|
|
24
|
+
await (0, execute_1.execute)('git', 'clone', '--depth=1', 'https://github.com/kuzzleio/project-templates', '--branch', flavor, '--single-branch');
|
|
25
|
+
await (0, execute_1.execute)('mv', `project-templates/${flavor}`, `${destination}/`);
|
|
26
|
+
await (0, execute_1.execute)('rm', '-rf', 'project-templates/');
|
|
84
27
|
}
|
|
85
28
|
}
|
|
86
29
|
exports.default = AppScaffold;
|
|
@@ -88,7 +31,11 @@ AppScaffold.initSdk = false;
|
|
|
88
31
|
AppScaffold.description = 'Scaffolds a new Kuzzle application';
|
|
89
32
|
AppScaffold.flags = {
|
|
90
33
|
help: command_1.flags.help(),
|
|
34
|
+
flavor: command_1.flags.string({
|
|
35
|
+
default: 'generic',
|
|
36
|
+
description: 'Template flavor ("generic", "iot-platform")'
|
|
37
|
+
})
|
|
91
38
|
};
|
|
92
39
|
AppScaffold.args = [
|
|
93
|
-
{ name: '
|
|
40
|
+
{ name: 'destination', description: 'Directory to scaffold the app', required: true },
|
|
94
41
|
];
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
6
|
const command_1 = require("@oclif/command");
|
|
6
|
-
const chalk_1 =
|
|
7
|
-
const listr_1 =
|
|
8
|
-
const node_emoji_1 =
|
|
7
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
+
const listr_1 = tslib_1.__importDefault(require("listr"));
|
|
9
|
+
const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
|
|
9
10
|
const common_1 = require("../../common");
|
|
10
11
|
const execute_1 = require("../../support/execute");
|
|
11
12
|
const MIN_DOCO_VERSION = '1.12.0';
|
|
@@ -27,7 +28,8 @@ services:
|
|
|
27
28
|
`;
|
|
28
29
|
class AppStartServices extends common_1.Kommand {
|
|
29
30
|
async runSafe() {
|
|
30
|
-
|
|
31
|
+
this.createKourouDir();
|
|
32
|
+
const docoFilename = path_1.default.join(this.kourouDir, 'kuzzle-services.yml');
|
|
31
33
|
const successfullCheck = this.flags.check ?
|
|
32
34
|
await this.checkPrerequisites() :
|
|
33
35
|
true;
|
|
@@ -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 =
|
|
6
|
-
const path_1 =
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
7
|
const common_1 = require("../../common");
|
|
8
8
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
9
9
|
const dump_collection_1 = require("../../support/dump-collection");
|
|
@@ -32,6 +32,7 @@ class CollectionExport extends common_1.Kommand {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
exports.default = CollectionExport;
|
|
35
|
+
CollectionExport.keepAuth = true;
|
|
35
36
|
CollectionExport.description = 'Exports a collection (JSONL format)';
|
|
36
37
|
CollectionExport.flags = Object.assign(Object.assign({ help: command_1.flags.help({}), path: command_1.flags.string({
|
|
37
38
|
description: 'Dump root directory',
|
|
@@ -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 =
|
|
5
|
-
const fs_1 =
|
|
4
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
|
+
const fs_1 = 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");
|
|
@@ -20,6 +20,7 @@ class CollectionImport extends common_1.Kommand {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
exports.default = CollectionImport;
|
|
23
|
+
CollectionImport.keepAuth = true;
|
|
23
24
|
CollectionImport.description = 'Imports a collection';
|
|
24
25
|
CollectionImport.flags = Object.assign(Object.assign({ help: command_1.flags.help({}), 'batch-size': command_1.flags.string({
|
|
25
26
|
description: 'Maximum batch size (see limits.documentsWriteCount config)',
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ConfigKeyDiff = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
|
-
const lodash_1 =
|
|
7
|
-
const fs_1 =
|
|
8
|
-
const strip_json_comments_1 =
|
|
6
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
|
+
const strip_json_comments_1 = tslib_1.__importDefault(require("strip-json-comments"));
|
|
9
9
|
const common_1 = require("../../common");
|
|
10
10
|
class ConfigKeyDiff extends common_1.Kommand {
|
|
11
11
|
async runSafe() {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { flags } from '@oclif/command';
|
|
2
|
+
import { Client } from '@elastic/elasticsearch';
|
|
2
3
|
import { Kommand } from '../../common';
|
|
3
4
|
export default class EsMigrate extends Kommand {
|
|
4
5
|
static initSdk: boolean;
|
|
@@ -10,11 +11,13 @@ export default class EsMigrate extends Kommand {
|
|
|
10
11
|
reset: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
11
12
|
'batch-size': import("@oclif/parser/lib/flags").IOptionFlag<number>;
|
|
12
13
|
'no-interactive': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
14
|
+
'dry-run': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
15
|
+
pattern: flags.IOptionFlag<string | undefined>;
|
|
16
|
+
scroll: flags.IOptionFlag<string>;
|
|
13
17
|
};
|
|
14
18
|
static examples: string[];
|
|
15
|
-
private src;
|
|
16
|
-
private dest;
|
|
17
19
|
private migrateMappings;
|
|
18
20
|
private migrateData;
|
|
21
|
+
runMigrate(index: string, src: Client, dest: Client): Promise<void>;
|
|
19
22
|
runSafe(): Promise<void>;
|
|
20
23
|
}
|
|
@@ -3,21 +3,21 @@ 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 =
|
|
7
|
-
const chalk_1 =
|
|
8
|
-
const node_emoji_1 =
|
|
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"));
|
|
9
9
|
const common_1 = require("../../common");
|
|
10
10
|
class EsMigrate extends common_1.Kommand {
|
|
11
|
-
async migrateMappings(index) {
|
|
12
|
-
const { body } = await
|
|
11
|
+
async migrateMappings(index, src, dest) {
|
|
12
|
+
const { body } = await src.indices.getMapping({ index });
|
|
13
13
|
const mappings = body[index];
|
|
14
|
-
await
|
|
14
|
+
await dest.indices.create({ index, body: { mappings: mappings.mappings } });
|
|
15
15
|
}
|
|
16
|
-
async migrateData(index, batch_size) {
|
|
16
|
+
async migrateData(index, batch_size, src, dest) {
|
|
17
17
|
const queue = [];
|
|
18
|
-
const { body } = await
|
|
18
|
+
const { body } = await src.search({
|
|
19
19
|
index,
|
|
20
|
-
scroll:
|
|
20
|
+
scroll: this.flags.scroll,
|
|
21
21
|
size: batch_size,
|
|
22
22
|
body: {
|
|
23
23
|
query: {
|
|
@@ -42,42 +42,52 @@ class EsMigrate extends common_1.Kommand {
|
|
|
42
42
|
bulk.push(doc._source);
|
|
43
43
|
count++;
|
|
44
44
|
}
|
|
45
|
-
await
|
|
45
|
+
await dest.bulk({ body: bulk });
|
|
46
46
|
progressBar.update(count);
|
|
47
|
-
const { body: { hits } } = await
|
|
48
|
-
scrollId,
|
|
49
|
-
scroll:
|
|
47
|
+
const { body: { hits } } = await src.scroll({
|
|
48
|
+
scroll_id: scrollId,
|
|
49
|
+
scroll: this.flags.scroll
|
|
50
50
|
});
|
|
51
51
|
queue.push(hits);
|
|
52
52
|
}
|
|
53
53
|
progressBar.stop();
|
|
54
54
|
return total;
|
|
55
55
|
}
|
|
56
|
+
async runMigrate(index, src, dest) {
|
|
57
|
+
this.logInfo(`Importing ${chalk_1.default.bold(index)} to ${chalk_1.default.bold(this.flags.dest)}`);
|
|
58
|
+
await this.migrateMappings(index, src, dest);
|
|
59
|
+
this.logOk('Mappings successfully imported!');
|
|
60
|
+
const count = await this.migrateData(index, this.flags['batch-size'], src, dest);
|
|
61
|
+
if (count === 0) {
|
|
62
|
+
this.logInfo('No documents to import\n');
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.logOk(`${chalk_1.default.bold(count)} document(s) imported!\n`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
56
68
|
async runSafe() {
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
const src = new elasticsearch_1.Client({ node: this.flags.src });
|
|
70
|
+
const dest = new elasticsearch_1.Client({ node: this.flags.dest });
|
|
59
71
|
if (this.flags.reset && !this.flags['no-interactive']) {
|
|
60
72
|
this.log(chalk_1.default.red(`${node_emoji_1.default.get('fire')} Are you sure you want to reset ${chalk_1.default.bold(this.flags.dest)}?`));
|
|
61
73
|
await cli_ux_1.default.confirm(chalk_1.default.redBright(` ${node_emoji_1.default.get('fire')} You will lose all the data stored in it (Type "yes" to confirm)`));
|
|
62
|
-
await
|
|
74
|
+
await dest.indices.delete({ index: '_all' });
|
|
63
75
|
}
|
|
64
76
|
this.logInfo(`Fetching indices list from ${chalk_1.default.bold(this.flags.src)}`);
|
|
65
|
-
const
|
|
66
|
-
const
|
|
77
|
+
const srcBody = await src.cat.indices({ format: 'json' });
|
|
78
|
+
const srcIndices = srcBody.body
|
|
67
79
|
.map(({ index }) => index)
|
|
80
|
+
.filter((index) => index.match(this.flags.pattern))
|
|
68
81
|
.sort();
|
|
69
|
-
this.logOk(`Found ${chalk_1.default.bold(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.logInfo(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
this.logOk(`${chalk_1.default.bold(count)} document(s) imported!\n`);
|
|
82
|
+
this.logOk(`Found ${chalk_1.default.bold(srcIndices.length)} indices in the source Elasticsearch server\n`);
|
|
83
|
+
if (this.flags['dry-run']) {
|
|
84
|
+
this.log(`${chalk_1.default.bold(srcIndices)}`);
|
|
85
|
+
this.logInfo(`${chalk_1.default.bold(srcIndices.length)} indices will be migrated`);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.logInfo(`Starting indices migration from ${chalk_1.default.bold(this.flags.src)} to ${chalk_1.default.bold(this.flags.dest)}`);
|
|
89
|
+
for (const index of srcIndices) {
|
|
90
|
+
await this.runMigrate(index, src, dest);
|
|
81
91
|
}
|
|
82
92
|
}
|
|
83
93
|
}
|
|
@@ -109,6 +119,17 @@ EsMigrate.flags = {
|
|
|
109
119
|
description: 'Skip confirmation interactive prompts (perfect for scripting)',
|
|
110
120
|
default: false,
|
|
111
121
|
}),
|
|
122
|
+
'dry-run': command_1.flags.boolean({
|
|
123
|
+
description: 'Print witch collections will be migrated',
|
|
124
|
+
default: false,
|
|
125
|
+
}),
|
|
126
|
+
'pattern': command_1.flags.string({
|
|
127
|
+
description: 'Pattern to match indices to migrate'
|
|
128
|
+
}),
|
|
129
|
+
'scroll': command_1.flags.string({
|
|
130
|
+
description: 'Scroll duration for Elasticsearch scrolling',
|
|
131
|
+
default: '30s'
|
|
132
|
+
}),
|
|
112
133
|
};
|
|
113
134
|
EsMigrate.examples = [
|
|
114
135
|
'kourou es:migrate --src http://elasticsearch:9200 --dest http://otherElasticsearch:9200 --reset --batch-size 2000',
|
|
@@ -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 =
|
|
6
|
-
const lodash_1 =
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
const lodash_1 = 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 =
|
|
6
|
-
const lodash_1 =
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
const lodash_1 = 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 =
|
|
6
|
-
const lodash_1 =
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
const lodash_1 = 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.d.ts
CHANGED
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 =
|
|
6
|
-
const path_1 =
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
const path_1 = 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");
|
|
@@ -116,6 +116,7 @@ class Import extends common_1.Kommand {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
exports.default = Import;
|
|
119
|
+
Import.keepAuth = true;
|
|
119
120
|
Import.description = 'Recursively imports dump files from a root directory';
|
|
120
121
|
Import.flags = Object.assign(Object.assign({ 'preserve-anonymous': command_1.flags.boolean({
|
|
121
122
|
description: 'Preserve anonymous rights',
|
|
@@ -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 =
|
|
6
|
-
const cli_ux_1 =
|
|
7
|
-
const path_1 =
|
|
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"));
|
|
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");
|
|
@@ -33,6 +33,7 @@ class IndexExport extends common_1.Kommand {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
exports.default = IndexExport;
|
|
36
|
+
IndexExport.keepAuth = true;
|
|
36
37
|
IndexExport.description = 'Exports an index (JSONL or Kuzzle format)';
|
|
37
38
|
IndexExport.flags = Object.assign(Object.assign({ help: command_1.flags.help({}), path: command_1.flags.string({
|
|
38
39
|
description: 'Dump root directory',
|