kourou 0.28.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -160
- package/lib/commands/app/scaffold.d.ts +1 -1
- package/lib/commands/app/scaffold.js +3 -3
- package/lib/commands/app/start-services.js +0 -2
- package/lib/commands/instance/spawn.js +0 -4
- package/lib/common.d.ts +2 -2
- package/lib/common.js +1 -2
- package/lib/support/PaasKommand.d.ts +0 -1
- package/lib/support/PaasKommand.js +0 -10
- package/lib/support/dump-collection.js +6 -1
- package/lib/support/kuzzle.d.ts +1 -1
- package/lib/support/kuzzle.js +1 -1
- package/package.json +57 -51
- package/lib/commands/paas/deploy.d.ts +0 -17
- package/lib/commands/paas/deploy.js +0 -57
- package/lib/commands/paas/elasticsearch/dump.d.ts +0 -35
- package/lib/commands/paas/elasticsearch/dump.js +0 -172
- package/lib/commands/paas/init.d.ts +0 -14
- package/lib/commands/paas/init.js +0 -35
- package/lib/commands/paas/logs.d.ts +0 -42
- package/lib/commands/paas/logs.js +0 -181
- package/lib/commands/paas/snapshots/cat.d.ts +0 -18
- package/lib/commands/paas/snapshots/cat.js +0 -46
- package/lib/commands/paas/snapshots/dump.d.ts +0 -18
- package/lib/commands/paas/snapshots/dump.js +0 -46
- package/lib/commands/paas/snapshots/restore.d.ts +0 -18
- package/lib/commands/paas/snapshots/restore.js +0 -51
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.
|
|
30
|
+
kourou/1.0.1 linux-x64 node-v22.12.0
|
|
31
31
|
$ kourou --help [COMMAND]
|
|
32
32
|
USAGE
|
|
33
33
|
$ kourou COMMAND
|
|
@@ -161,14 +161,7 @@ All other arguments and options will be passed as-is to the `sdk:query` method.
|
|
|
161
161
|
* [`kourou instance:list`](#kourou-instancelist)
|
|
162
162
|
* [`kourou instance:logs`](#kourou-instancelogs)
|
|
163
163
|
* [`kourou instance:spawn`](#kourou-instancespawn)
|
|
164
|
-
* [`kourou paas:deploy ENVIRONMENT APPLICATIONID IMAGE`](#kourou-paasdeploy-environment-applicationid-image)
|
|
165
|
-
* [`kourou paas:elasticsearch:dump ENVIRONMENT APPLICATIONID DUMPDIRECTORY`](#kourou-paaselasticsearchdump-environment-applicationid-dumpdirectory)
|
|
166
|
-
* [`kourou paas:init PROJECT`](#kourou-paasinit-project)
|
|
167
164
|
* [`kourou paas:login`](#kourou-paaslogin)
|
|
168
|
-
* [`kourou paas:logs ENVIRONMENT APPLICATION`](#kourou-paaslogs-environment-application)
|
|
169
|
-
* [`kourou paas:snapshots:cat ENVIRONMENT APPLICATIONID`](#kourou-paassnapshotscat-environment-applicationid)
|
|
170
|
-
* [`kourou paas:snapshots:dump ENVIRONMENT APPLICATIONID`](#kourou-paassnapshotsdump-environment-applicationid)
|
|
171
|
-
* [`kourou paas:snapshots:restore ENVIRONMENT APPLICATIONID SNAPSHOTID`](#kourou-paassnapshotsrestore-environment-applicationid-snapshotid)
|
|
172
165
|
* [`kourou profile:export`](#kourou-profileexport)
|
|
173
166
|
* [`kourou profile:import PATH`](#kourou-profileimport-path)
|
|
174
167
|
* [`kourou realtime:subscribe INDEX COLLECTION [FILTERS]`](#kourou-realtimesubscribe-index-collection-filters)
|
|
@@ -813,6 +806,8 @@ OPTIONS
|
|
|
813
806
|
--help show CLI help
|
|
814
807
|
```
|
|
815
808
|
|
|
809
|
+
_See code: [lib/commands/es/snapshot/restore.js](lib/commands/es/snapshot/restore.js)_
|
|
810
|
+
|
|
816
811
|
## `kourou file:decrypt FILE`
|
|
817
812
|
|
|
818
813
|
Decrypts an encrypted file.
|
|
@@ -1062,63 +1057,6 @@ OPTIONS
|
|
|
1062
1057
|
|
|
1063
1058
|
_See code: [lib/commands/instance/spawn.js](lib/commands/instance/spawn.js)_
|
|
1064
1059
|
|
|
1065
|
-
## `kourou paas:deploy ENVIRONMENT APPLICATIONID IMAGE`
|
|
1066
|
-
|
|
1067
|
-
Deploy a new version of the application in the PaaS
|
|
1068
|
-
|
|
1069
|
-
```
|
|
1070
|
-
USAGE
|
|
1071
|
-
$ kourou paas:deploy ENVIRONMENT APPLICATIONID IMAGE
|
|
1072
|
-
|
|
1073
|
-
ARGUMENTS
|
|
1074
|
-
ENVIRONMENT Project environment name
|
|
1075
|
-
APPLICATIONID Application Identifier
|
|
1076
|
-
IMAGE Image name and hash as myimage:mytag
|
|
1077
|
-
|
|
1078
|
-
OPTIONS
|
|
1079
|
-
--help show CLI help
|
|
1080
|
-
--project=project Current PaaS project
|
|
1081
|
-
--token=token Authentication token
|
|
1082
|
-
```
|
|
1083
|
-
|
|
1084
|
-
_See code: [lib/commands/paas/deploy.js](lib/commands/paas/deploy.js)_
|
|
1085
|
-
|
|
1086
|
-
## `kourou paas:elasticsearch:dump ENVIRONMENT APPLICATIONID DUMPDIRECTORY`
|
|
1087
|
-
|
|
1088
|
-
Dump data from the Elasticsearch of a PaaS application
|
|
1089
|
-
|
|
1090
|
-
```
|
|
1091
|
-
USAGE
|
|
1092
|
-
$ kourou paas:elasticsearch:dump ENVIRONMENT APPLICATIONID DUMPDIRECTORY
|
|
1093
|
-
|
|
1094
|
-
ARGUMENTS
|
|
1095
|
-
ENVIRONMENT Project environment name
|
|
1096
|
-
APPLICATIONID Application Identifier
|
|
1097
|
-
DUMPDIRECTORY Directory where to store dump files
|
|
1098
|
-
|
|
1099
|
-
OPTIONS
|
|
1100
|
-
--batch-size=batch-size [default: 2000] Maximum batch size
|
|
1101
|
-
--help show CLI help
|
|
1102
|
-
--project=project Current PaaS project
|
|
1103
|
-
```
|
|
1104
|
-
|
|
1105
|
-
## `kourou paas:init PROJECT`
|
|
1106
|
-
|
|
1107
|
-
Initialize a PaaS project in current directory
|
|
1108
|
-
|
|
1109
|
-
```
|
|
1110
|
-
USAGE
|
|
1111
|
-
$ kourou paas:init PROJECT
|
|
1112
|
-
|
|
1113
|
-
ARGUMENTS
|
|
1114
|
-
PROJECT Kuzzle PaaS project name
|
|
1115
|
-
|
|
1116
|
-
OPTIONS
|
|
1117
|
-
--help show CLI help
|
|
1118
|
-
```
|
|
1119
|
-
|
|
1120
|
-
_See code: [lib/commands/paas/init.js](lib/commands/paas/init.js)_
|
|
1121
|
-
|
|
1122
1060
|
## `kourou paas:login`
|
|
1123
1061
|
|
|
1124
1062
|
Login for a PaaS project
|
|
@@ -1136,101 +1074,6 @@ OPTIONS
|
|
|
1136
1074
|
|
|
1137
1075
|
_See code: [lib/commands/paas/login.js](lib/commands/paas/login.js)_
|
|
1138
1076
|
|
|
1139
|
-
## `kourou paas:logs ENVIRONMENT APPLICATION`
|
|
1140
|
-
|
|
1141
|
-
Show logs of the targeted application
|
|
1142
|
-
|
|
1143
|
-
```
|
|
1144
|
-
USAGE
|
|
1145
|
-
$ kourou paas:logs ENVIRONMENT APPLICATION
|
|
1146
|
-
|
|
1147
|
-
ARGUMENTS
|
|
1148
|
-
ENVIRONMENT Kuzzle PaaS environment
|
|
1149
|
-
APPLICATION Kuzzle PaaS application
|
|
1150
|
-
|
|
1151
|
-
OPTIONS
|
|
1152
|
-
-f, --follow Follow log output
|
|
1153
|
-
-n, --tail=tail Number of lines to show from the end of the logs
|
|
1154
|
-
-t, --timestamp Show timestamp
|
|
1155
|
-
--help show CLI help
|
|
1156
|
-
--podName=podName Name of the pod to show logs from
|
|
1157
|
-
--project=project Current PaaS project
|
|
1158
|
-
--since=since Display logs from a specific absolute (e.g. 2022/12/02 09:41) or relative (e.g. a minute ago) time
|
|
1159
|
-
--until=until Display logs until a specific absolute (e.g. 2022/12/02 09:41) or relative (e.g. a minute ago) time
|
|
1160
|
-
```
|
|
1161
|
-
|
|
1162
|
-
_See code: [lib/commands/paas/logs.js](lib/commands/paas/logs.js)_
|
|
1163
|
-
|
|
1164
|
-
## `kourou paas:snapshots:cat ENVIRONMENT APPLICATIONID`
|
|
1165
|
-
|
|
1166
|
-
List all snapshots for a given kuzzle application in a environment
|
|
1167
|
-
|
|
1168
|
-
```
|
|
1169
|
-
USAGE
|
|
1170
|
-
$ kourou paas:snapshots:cat ENVIRONMENT APPLICATIONID
|
|
1171
|
-
|
|
1172
|
-
ARGUMENTS
|
|
1173
|
-
ENVIRONMENT Project environment name
|
|
1174
|
-
APPLICATIONID Application Identifier
|
|
1175
|
-
|
|
1176
|
-
OPTIONS
|
|
1177
|
-
--help show CLI help
|
|
1178
|
-
--project=project Current PaaS project
|
|
1179
|
-
--token=token Authentication token
|
|
1180
|
-
|
|
1181
|
-
EXAMPLE
|
|
1182
|
-
kourou paas:snapshots:cat --project paas-project-myproject api main
|
|
1183
|
-
```
|
|
1184
|
-
|
|
1185
|
-
_See code: [lib/commands/paas/snapshots/cat.js](lib/commands/paas/snapshots/cat.js)_
|
|
1186
|
-
|
|
1187
|
-
## `kourou paas:snapshots:dump ENVIRONMENT APPLICATIONID`
|
|
1188
|
-
|
|
1189
|
-
Create a new snapshot of the current application state
|
|
1190
|
-
|
|
1191
|
-
```
|
|
1192
|
-
USAGE
|
|
1193
|
-
$ kourou paas:snapshots:dump ENVIRONMENT APPLICATIONID
|
|
1194
|
-
|
|
1195
|
-
ARGUMENTS
|
|
1196
|
-
ENVIRONMENT Project environment name
|
|
1197
|
-
APPLICATIONID Application Identifier
|
|
1198
|
-
|
|
1199
|
-
OPTIONS
|
|
1200
|
-
--help show CLI help
|
|
1201
|
-
--project=project Current PaaS project
|
|
1202
|
-
--token=token Authentication token
|
|
1203
|
-
|
|
1204
|
-
EXAMPLE
|
|
1205
|
-
kourou paas:snapshots:dump --project paas-project-myproject api main
|
|
1206
|
-
```
|
|
1207
|
-
|
|
1208
|
-
_See code: [lib/commands/paas/snapshots/dump.js](lib/commands/paas/snapshots/dump.js)_
|
|
1209
|
-
|
|
1210
|
-
## `kourou paas:snapshots:restore ENVIRONMENT APPLICATIONID SNAPSHOTID`
|
|
1211
|
-
|
|
1212
|
-
Restore a snapshot of the current application state
|
|
1213
|
-
|
|
1214
|
-
```
|
|
1215
|
-
USAGE
|
|
1216
|
-
$ kourou paas:snapshots:restore ENVIRONMENT APPLICATIONID SNAPSHOTID
|
|
1217
|
-
|
|
1218
|
-
ARGUMENTS
|
|
1219
|
-
ENVIRONMENT Project environment name
|
|
1220
|
-
APPLICATIONID Application Identifier
|
|
1221
|
-
SNAPSHOTID Snapshot Identifier
|
|
1222
|
-
|
|
1223
|
-
OPTIONS
|
|
1224
|
-
--help show CLI help
|
|
1225
|
-
--project=project Current PaaS project
|
|
1226
|
-
--token=token Authentication token
|
|
1227
|
-
|
|
1228
|
-
EXAMPLE
|
|
1229
|
-
kourou paas:snapshots:restore --project paas-project-myproject api main snapshot-id
|
|
1230
|
-
```
|
|
1231
|
-
|
|
1232
|
-
_See code: [lib/commands/paas/snapshots/restore.js](lib/commands/paas/snapshots/restore.js)_
|
|
1233
|
-
|
|
1234
1077
|
## `kourou profile:export`
|
|
1235
1078
|
|
|
1236
1079
|
Exports profiles
|
|
@@ -19,5 +19,5 @@ export default class AppScaffold extends Kommand {
|
|
|
19
19
|
prepareTemplate(): Promise<void>;
|
|
20
20
|
cloneTemplate(flavor: string): Promise<void>;
|
|
21
21
|
copyTemplate(destination: string): Promise<void>;
|
|
22
|
-
cleanup(): Promise<void>;
|
|
22
|
+
cleanup(destination: string): Promise<void>;
|
|
23
23
|
}
|
|
@@ -32,7 +32,7 @@ class AppScaffold extends common_1.Kommand {
|
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
title: "Cleaning up",
|
|
35
|
-
task: async () => this.cleanup()
|
|
35
|
+
task: async () => this.cleanup(destination)
|
|
36
36
|
}
|
|
37
37
|
]);
|
|
38
38
|
await tasks.run();
|
|
@@ -41,7 +41,6 @@ class AppScaffold extends common_1.Kommand {
|
|
|
41
41
|
this.logOk(`Use ${chalk_1.default.blue.bold(`cd ${destination} && docker compose up -d`)} to start your Kuzzle stack.`);
|
|
42
42
|
}
|
|
43
43
|
getRepo(flavor) {
|
|
44
|
-
console.log(flavor);
|
|
45
44
|
switch (flavor) {
|
|
46
45
|
case "generic":
|
|
47
46
|
return "template-kuzzle-project";
|
|
@@ -76,8 +75,9 @@ class AppScaffold extends common_1.Kommand {
|
|
|
76
75
|
async copyTemplate(destination) {
|
|
77
76
|
await (0, execute_1.execute)("cp", "-r", `${this.templatesDir}/`, `${destination}/`);
|
|
78
77
|
}
|
|
79
|
-
async cleanup() {
|
|
78
|
+
async cleanup(destination) {
|
|
80
79
|
await (0, execute_1.execute)("rm", "-rf", this.templatesDir);
|
|
80
|
+
await (0, execute_1.execute)("rm", "-rf", `${destination}/.git`);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
exports.default = AppScaffold;
|
|
@@ -10,8 +10,6 @@ const common_1 = require("../../common");
|
|
|
10
10
|
const execute_1 = require("../../support/execute");
|
|
11
11
|
const checkPrerequisites_1 = require("../../support/docker/checkPrerequisites");
|
|
12
12
|
const kuzzleServicesFile = `
|
|
13
|
-
version: '3'
|
|
14
|
-
|
|
15
13
|
services:
|
|
16
14
|
redis:
|
|
17
15
|
image: redis:5
|
|
@@ -15,8 +15,6 @@ const checkPrerequisites_1 = require("../../support/docker/checkPrerequisites");
|
|
|
15
15
|
const MIN_MAX_MAP_COUNT = 262144;
|
|
16
16
|
const MIN_DOCO_VERSION = "2.0.0";
|
|
17
17
|
const kuzzleStackV1 = (increment) => `
|
|
18
|
-
version: '3'
|
|
19
|
-
|
|
20
18
|
services:
|
|
21
19
|
kuzzle:
|
|
22
20
|
image: kuzzleio/kuzzle:1
|
|
@@ -50,8 +48,6 @@ services:
|
|
|
50
48
|
- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
|
|
51
49
|
`;
|
|
52
50
|
const kuzzleStackV2 = (increment) => `
|
|
53
|
-
version: '3'
|
|
54
|
-
|
|
55
51
|
services:
|
|
56
52
|
kuzzle:
|
|
57
53
|
image: kuzzleio/kuzzle:2
|
package/lib/common.d.ts
CHANGED
|
@@ -22,8 +22,8 @@ export declare abstract class Kommand extends Command {
|
|
|
22
22
|
logOk(message: string): void;
|
|
23
23
|
logInfo(message: string): void;
|
|
24
24
|
logKo(message?: string): void;
|
|
25
|
-
run(): Promise<
|
|
26
|
-
beforeConnect(): void
|
|
25
|
+
run(): Promise<void>;
|
|
26
|
+
beforeConnect(): Promise<void>;
|
|
27
27
|
runSafe(): Promise<void>;
|
|
28
28
|
/**
|
|
29
29
|
* Reads a value from STDIN.
|
package/lib/common.js
CHANGED
|
@@ -129,9 +129,8 @@ class Kommand extends command_1.Command {
|
|
|
129
129
|
this.sdk.disconnect();
|
|
130
130
|
process.exit(this.exitCode);
|
|
131
131
|
}
|
|
132
|
-
return this.exitCode;
|
|
133
132
|
}
|
|
134
|
-
beforeConnect() {
|
|
133
|
+
async beforeConnect() {
|
|
135
134
|
// will be called before connecting to Kuzzle
|
|
136
135
|
}
|
|
137
136
|
async runSafe() {
|
|
@@ -56,16 +56,6 @@ class PaasKommand extends common_1.Kommand {
|
|
|
56
56
|
}
|
|
57
57
|
return this.flags.project;
|
|
58
58
|
}
|
|
59
|
-
async getCredentials() {
|
|
60
|
-
const project = this.getProject();
|
|
61
|
-
const projectFile = this.fileProjectCredentials(project);
|
|
62
|
-
if (!fs_1.default.existsSync(projectFile)) {
|
|
63
|
-
this.logKo("You are not logged in. You should run paas:login first. Aborting.");
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
const credentials = JSON.parse(fs_1.default.readFileSync(projectFile, "utf8"));
|
|
67
|
-
return credentials.apiKey;
|
|
68
|
-
}
|
|
69
59
|
}
|
|
70
60
|
exports.PaasKommand = PaasKommand;
|
|
71
61
|
PaasKommand.initSdk = false;
|
|
@@ -245,7 +245,12 @@ async function dumpCollectionMappings(sdk, index, collection, destPath, format =
|
|
|
245
245
|
type: "mappings",
|
|
246
246
|
content: {
|
|
247
247
|
[index]: {
|
|
248
|
-
[collection]:
|
|
248
|
+
[collection]: {
|
|
249
|
+
mappings
|
|
250
|
+
// For later use, we could add the settings here
|
|
251
|
+
// eg: "settings": { "index.mapping.total_fields.limit": 10000 }
|
|
252
|
+
// This can be added after the dump and it will work with kourou:import command
|
|
253
|
+
},
|
|
249
254
|
},
|
|
250
255
|
},
|
|
251
256
|
};
|
package/lib/support/kuzzle.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare class KuzzleSDK {
|
|
|
40
40
|
(): Promise<void>;
|
|
41
41
|
}): Promise<void>;
|
|
42
42
|
disconnect(): void;
|
|
43
|
-
query(request: any): Promise<import("kuzzle-sdk").ResponsePayload<
|
|
43
|
+
query(request: any): Promise<import("kuzzle-sdk").ResponsePayload<JSONObject>>;
|
|
44
44
|
/**
|
|
45
45
|
* Query the Kuzzle API and return a streamed response.
|
|
46
46
|
* @param request The request to send to Kuzzle
|
package/lib/support/kuzzle.js
CHANGED
|
@@ -116,7 +116,7 @@ class KuzzleSDK {
|
|
|
116
116
|
const currentToken = this.sdk.jwt;
|
|
117
117
|
let apiKey;
|
|
118
118
|
try {
|
|
119
|
-
apiKey = await this.security.createApiKey(userKuid, "Kourou impersonation token", { expiresIn: "2h", refresh:
|
|
119
|
+
apiKey = await this.security.createApiKey(userKuid, "Kourou impersonation token", { expiresIn: "2h", refresh: "wait_for" });
|
|
120
120
|
this.sdk.jwt = apiKey._source.token;
|
|
121
121
|
await callback();
|
|
122
122
|
}
|
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.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
6
6
|
"bin": {
|
|
7
7
|
"kourou": "./bin/run"
|
|
@@ -19,64 +19,70 @@
|
|
|
19
19
|
"test:functional:cucumber": "./node_modules/.bin/cucumber-js --fail-fast"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@elastic/elasticsearch": "
|
|
22
|
+
"@elastic/elasticsearch": "7.12.0",
|
|
23
23
|
"@oclif/command": "1.8.*",
|
|
24
24
|
"@oclif/config": "1.18.*",
|
|
25
25
|
"@oclif/plugin-autocomplete": "1.3.*",
|
|
26
26
|
"@oclif/plugin-help": "3.2.2",
|
|
27
|
-
"bluebird": "
|
|
28
|
-
"chalk": "
|
|
29
|
-
"chrono-node": "
|
|
30
|
-
"cli-ux": "
|
|
31
|
-
"inquirer": "
|
|
32
|
-
"kepler-companion": "
|
|
33
|
-
"kuzzle-sdk": "
|
|
34
|
-
"kuzzle-vault": "
|
|
35
|
-
"listr": "
|
|
36
|
-
"lodash": "
|
|
37
|
-
"ndjson": "
|
|
38
|
-
"node-emoji": "
|
|
39
|
-
"node-fetch": "
|
|
40
|
-
"production": "
|
|
41
|
-
"strip-json-comments": "
|
|
42
|
-
"tar": "
|
|
43
|
-
"tmp": "
|
|
44
|
-
"tslib": "
|
|
45
|
-
"
|
|
46
|
-
"
|
|
27
|
+
"bluebird": "3.7.2",
|
|
28
|
+
"chalk": "4.1.0",
|
|
29
|
+
"chrono-node": "2.4.2",
|
|
30
|
+
"cli-ux": "5.5.1",
|
|
31
|
+
"inquirer": "8.0.0",
|
|
32
|
+
"kepler-companion": "1.1.3",
|
|
33
|
+
"kuzzle-sdk": "7.14.0",
|
|
34
|
+
"kuzzle-vault": "2.0.4",
|
|
35
|
+
"listr": "0.14.3",
|
|
36
|
+
"lodash": "4.17.21",
|
|
37
|
+
"ndjson": "2.0.0",
|
|
38
|
+
"node-emoji": "1.10.0",
|
|
39
|
+
"node-fetch": "2.6.7",
|
|
40
|
+
"production": "0.0.2",
|
|
41
|
+
"strip-json-comments": "3.1.1",
|
|
42
|
+
"tar": "6.1.11",
|
|
43
|
+
"tmp": "0.2.1",
|
|
44
|
+
"tslib": "2.3.1",
|
|
45
|
+
"ws": "8.8.0",
|
|
46
|
+
"typescript": "4.4.*"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@istanbuljs/nyc-config-typescript": "
|
|
50
|
-
"@oclif/dev-cli": "
|
|
51
|
-
"@oclif/test": "
|
|
52
|
-
"@types/bluebird": "
|
|
53
|
-
"@types/chai": "
|
|
54
|
-
"@types/compare-version": "
|
|
55
|
-
"@types/inquirer": "
|
|
56
|
-
"@types/listr": "
|
|
57
|
-
"@types/mocha": "
|
|
58
|
-
"@types/ndjson": "
|
|
59
|
-
"@types/node": "
|
|
60
|
-
"@types/node-emoji": "
|
|
61
|
-
"@types/node-fetch": "
|
|
62
|
-
"@types/tar": "
|
|
63
|
-
"@types/tmp": "
|
|
64
|
-
"@types/ws": "
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "
|
|
66
|
-
"@typescript-eslint/parser": "
|
|
67
|
-
"chai": "
|
|
68
|
-
"cucumber": "
|
|
69
|
-
"eslint": "
|
|
70
|
-
"globby": "
|
|
71
|
-
"mocha": "
|
|
72
|
-
"nyc": "
|
|
73
|
-
"prettier-eslint": "
|
|
74
|
-
"should": "
|
|
75
|
-
"source-map-support": "
|
|
76
|
-
"ts-node": "10.9.*"
|
|
49
|
+
"@istanbuljs/nyc-config-typescript": "1.0.1",
|
|
50
|
+
"@oclif/dev-cli": "1.26.0",
|
|
51
|
+
"@oclif/test": "1.2.8",
|
|
52
|
+
"@types/bluebird": "3.5.33",
|
|
53
|
+
"@types/chai": "4.2.16",
|
|
54
|
+
"@types/compare-version": "0.1.31",
|
|
55
|
+
"@types/inquirer": "7.3.3",
|
|
56
|
+
"@types/listr": "0.14.2",
|
|
57
|
+
"@types/mocha": "8.2.2",
|
|
58
|
+
"@types/ndjson": "2.0.0",
|
|
59
|
+
"@types/node": "18.19.0",
|
|
60
|
+
"@types/node-emoji": "1.8.1",
|
|
61
|
+
"@types/node-fetch": "2.6.1",
|
|
62
|
+
"@types/tar": "6.1.3",
|
|
63
|
+
"@types/tmp": "0.2.0",
|
|
64
|
+
"@types/ws": "8.5.3",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "4.22.0",
|
|
66
|
+
"@typescript-eslint/parser": "4.22.0",
|
|
67
|
+
"chai": "4.3.4",
|
|
68
|
+
"cucumber": "6.0.7",
|
|
69
|
+
"eslint": "7.24.0",
|
|
70
|
+
"globby": "11.0.3",
|
|
71
|
+
"mocha": "8.3.2",
|
|
72
|
+
"nyc": "15.1.0",
|
|
73
|
+
"prettier-eslint": "12.0.0",
|
|
74
|
+
"should": "13.2.3",
|
|
75
|
+
"source-map-support": "0.5.19",
|
|
76
|
+
"ts-node": "10.9.*",
|
|
77
|
+
"semantic-release-config-kuzzle": "1.0.0",
|
|
78
|
+
"semantic-release-slack-bot": "4.0.2",
|
|
79
|
+
"@semantic-release/changelog": "6.0.3",
|
|
80
|
+
"@semantic-release/commit-analyzer": "13.0.0",
|
|
81
|
+
"@semantic-release/git": "10.0.1",
|
|
82
|
+
"@semantic-release/release-notes-generator": "14.0.1"
|
|
77
83
|
},
|
|
78
84
|
"engines": {
|
|
79
|
-
"node": ">=
|
|
85
|
+
"node": ">=18.0.0"
|
|
80
86
|
},
|
|
81
87
|
"files": [
|
|
82
88
|
"/bin",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { flags } from "@oclif/command";
|
|
2
|
-
import { PaasKommand } from "../../support/PaasKommand";
|
|
3
|
-
declare class PaasDeploy extends PaasKommand {
|
|
4
|
-
static description: string;
|
|
5
|
-
static flags: {
|
|
6
|
-
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
|
-
token: flags.IOptionFlag<string | undefined>;
|
|
8
|
-
project: flags.IOptionFlag<string | undefined>;
|
|
9
|
-
};
|
|
10
|
-
static args: {
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
required: boolean;
|
|
14
|
-
}[];
|
|
15
|
-
runSafe(): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export default PaasDeploy;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const command_1 = require("@oclif/command");
|
|
4
|
-
const PaasKommand_1 = require("../../support/PaasKommand");
|
|
5
|
-
class PaasDeploy extends PaasKommand_1.PaasKommand {
|
|
6
|
-
async runSafe() {
|
|
7
|
-
const apiKey = await this.getCredentials();
|
|
8
|
-
await this.initPaasClient({ apiKey });
|
|
9
|
-
const user = await this.paas.auth.getCurrentUser();
|
|
10
|
-
this.logInfo(`Logged as "${user._id}" for project "${this.flags.project || this.getProject()}"`);
|
|
11
|
-
const [image, tag] = this.args.image.split(":");
|
|
12
|
-
this.logInfo(`Deploy application with image "${image}:${tag}"`);
|
|
13
|
-
await this.paas.query({
|
|
14
|
-
controller: "application",
|
|
15
|
-
action: "deploy",
|
|
16
|
-
environmentId: this.args.environment,
|
|
17
|
-
projectId: this.flags.project || this.getProject(),
|
|
18
|
-
applicationId: this.args.applicationId,
|
|
19
|
-
body: {
|
|
20
|
-
image: {
|
|
21
|
-
name: image,
|
|
22
|
-
tag,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
this.logOk("Deployment in progress");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
PaasDeploy.description = "Deploy a new version of the application in the PaaS";
|
|
30
|
-
PaasDeploy.flags = {
|
|
31
|
-
help: command_1.flags.help(),
|
|
32
|
-
token: command_1.flags.string({
|
|
33
|
-
default: process.env.KUZZLE_PAAS_TOKEN,
|
|
34
|
-
description: "Authentication token",
|
|
35
|
-
}),
|
|
36
|
-
project: command_1.flags.string({
|
|
37
|
-
description: "Current PaaS project",
|
|
38
|
-
}),
|
|
39
|
-
};
|
|
40
|
-
PaasDeploy.args = [
|
|
41
|
-
{
|
|
42
|
-
name: "environment",
|
|
43
|
-
description: "Project environment name",
|
|
44
|
-
required: true,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: "applicationId",
|
|
48
|
-
description: "Application Identifier",
|
|
49
|
-
required: true,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "image",
|
|
53
|
-
description: "Image name and hash as myimage:mytag",
|
|
54
|
-
required: true,
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
exports.default = PaasDeploy;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { flags } from "@oclif/command";
|
|
2
|
-
import { PaasKommand } from "../../../support/PaasKommand";
|
|
3
|
-
declare class PaasEsDump extends PaasKommand {
|
|
4
|
-
static description: string;
|
|
5
|
-
static flags: {
|
|
6
|
-
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
|
-
project: flags.IOptionFlag<string | undefined>;
|
|
8
|
-
"batch-size": import("@oclif/parser/lib/flags").IOptionFlag<number>;
|
|
9
|
-
};
|
|
10
|
-
static args: {
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
required: boolean;
|
|
14
|
-
}[];
|
|
15
|
-
runSafe(): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* @description Get all indexes from the Elasticsearch of the PaaS application.
|
|
18
|
-
* @returns The indexes.
|
|
19
|
-
*/
|
|
20
|
-
private getAllIndexes;
|
|
21
|
-
/**
|
|
22
|
-
* @description Dump documents from the Elasticsearch of the PaaS application.
|
|
23
|
-
* @param pitId ID of the PIT opened on Elasticsearch.
|
|
24
|
-
* @param searchAfter Cursor for dumping documents after a certain one.
|
|
25
|
-
* @returns The dumped documents.
|
|
26
|
-
*/
|
|
27
|
-
private dumpDocuments;
|
|
28
|
-
private dumpAllDocuments;
|
|
29
|
-
/**
|
|
30
|
-
* @description Finish the document dumping session.
|
|
31
|
-
* @param pitId ID of the PIT opened on Elasticsearch.
|
|
32
|
-
*/
|
|
33
|
-
private finishDump;
|
|
34
|
-
}
|
|
35
|
-
export default PaasEsDump;
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
5
|
-
const promises_1 = (0, tslib_1.__importDefault)(require("node:fs/promises"));
|
|
6
|
-
const ndjson_1 = (0, tslib_1.__importDefault)(require("ndjson"));
|
|
7
|
-
const command_1 = require("@oclif/command");
|
|
8
|
-
const PaasKommand_1 = require("../../../support/PaasKommand");
|
|
9
|
-
class PaasEsDump extends PaasKommand_1.PaasKommand {
|
|
10
|
-
async runSafe() {
|
|
11
|
-
// Check that the batch size is positive
|
|
12
|
-
if (this.flags["batch-size"] <= 0) {
|
|
13
|
-
this.logKo(`The batch size must be greater than zero. (Specified batch size: ${this.flags["batch-size"]})`);
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
// Log in to the PaaS
|
|
17
|
-
const apiKey = await this.getCredentials();
|
|
18
|
-
await this.initPaasClient({ apiKey });
|
|
19
|
-
const user = await this.paas.auth.getCurrentUser();
|
|
20
|
-
this.logInfo(`Logged as "${user._id}" for project "${this.flags.project || this.getProject()}"`);
|
|
21
|
-
// Create the dump directory
|
|
22
|
-
await promises_1.default.mkdir(this.args.dumpDirectory, { recursive: true });
|
|
23
|
-
// Dump the indexes
|
|
24
|
-
this.logInfo("Dumping Elasticsearch indexes...");
|
|
25
|
-
const indexesResult = await this.getAllIndexes();
|
|
26
|
-
await promises_1.default.writeFile(path_1.default.join(this.args.dumpDirectory, "indexes.json"), JSON.stringify(indexesResult));
|
|
27
|
-
this.logOk("Elasticsearch indexes dumped!");
|
|
28
|
-
// Dump all the documents
|
|
29
|
-
this.logInfo("Dumping Elasticsearch documents...");
|
|
30
|
-
await this.dumpAllDocuments();
|
|
31
|
-
this.logOk("Elasticsearch documents dumped!");
|
|
32
|
-
this.logOk(`The dumped files are available under "${path_1.default.resolve(this.args.dumpDirectory)}"`);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @description Get all indexes from the Elasticsearch of the PaaS application.
|
|
36
|
-
* @returns The indexes.
|
|
37
|
-
*/
|
|
38
|
-
async getAllIndexes() {
|
|
39
|
-
const { result } = await this.paas.query({
|
|
40
|
-
controller: "application/storage",
|
|
41
|
-
action: "getIndexes",
|
|
42
|
-
environmentId: this.args.environment,
|
|
43
|
-
projectId: this.flags.project || this.getProject(),
|
|
44
|
-
applicationId: this.args.applicationId,
|
|
45
|
-
body: {},
|
|
46
|
-
});
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* @description Dump documents from the Elasticsearch of the PaaS application.
|
|
51
|
-
* @param pitId ID of the PIT opened on Elasticsearch.
|
|
52
|
-
* @param searchAfter Cursor for dumping documents after a certain one.
|
|
53
|
-
* @returns The dumped documents.
|
|
54
|
-
*/
|
|
55
|
-
async dumpDocuments(pitId, searchAfter) {
|
|
56
|
-
const { result } = await this.paas.query({
|
|
57
|
-
controller: "application/storage",
|
|
58
|
-
action: "dumpDocuments",
|
|
59
|
-
environmentId: this.args.environment,
|
|
60
|
-
projectId: this.flags.project || this.getProject(),
|
|
61
|
-
applicationId: this.args.applicationId,
|
|
62
|
-
body: {
|
|
63
|
-
pitId,
|
|
64
|
-
searchAfter: JSON.stringify(searchAfter),
|
|
65
|
-
size: this.flags["batch-size"],
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
async dumpAllDocuments() {
|
|
71
|
-
// Prepare dumping all documents
|
|
72
|
-
let pitId = "";
|
|
73
|
-
let searchAfter = [];
|
|
74
|
-
let dumpedDocuments = 0;
|
|
75
|
-
let totalDocuments = 0;
|
|
76
|
-
const fd = await promises_1.default.open(path_1.default.join(this.args.dumpDirectory, "documents.jsonl"), "w");
|
|
77
|
-
const writeStream = fd.createWriteStream();
|
|
78
|
-
const ndjsonStream = ndjson_1.default.stringify();
|
|
79
|
-
writeStream.on("error", (error) => {
|
|
80
|
-
throw error;
|
|
81
|
-
});
|
|
82
|
-
ndjsonStream.on("data", (line) => {
|
|
83
|
-
writeStream.write(line);
|
|
84
|
-
});
|
|
85
|
-
const teardown = async () => {
|
|
86
|
-
// Finish the dump session if a PIT ID is set
|
|
87
|
-
if (pitId.length > 0) {
|
|
88
|
-
await this.finishDump(pitId);
|
|
89
|
-
}
|
|
90
|
-
// Close the open streams/file
|
|
91
|
-
writeStream.close();
|
|
92
|
-
await fd.close();
|
|
93
|
-
};
|
|
94
|
-
try {
|
|
95
|
-
// Dump the first batch
|
|
96
|
-
let result = await this.dumpDocuments(pitId, searchAfter);
|
|
97
|
-
let hits = result.hits.hits;
|
|
98
|
-
while (hits.length > 0) {
|
|
99
|
-
// Update the PIT ID and the cursor for the next dump
|
|
100
|
-
pitId = result.pit_id;
|
|
101
|
-
searchAfter = hits[hits.length - 1].sort;
|
|
102
|
-
// Save the documents
|
|
103
|
-
for (let i = 0; i < hits.length; ++i) {
|
|
104
|
-
ndjsonStream.write(hits[i]);
|
|
105
|
-
}
|
|
106
|
-
dumpedDocuments += hits.length;
|
|
107
|
-
totalDocuments = result.hits.total.value;
|
|
108
|
-
this.logInfo(`Dumping Elasticsearch documents: ${Math.floor(dumpedDocuments / totalDocuments * 100)}% (${dumpedDocuments}/${totalDocuments})`);
|
|
109
|
-
// Dump the next batch
|
|
110
|
-
result = await this.dumpDocuments(pitId, searchAfter);
|
|
111
|
-
hits = result.hits.hits;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
teardown();
|
|
116
|
-
this.logKo(`Error while dumping the documents: ${error}`);
|
|
117
|
-
process.exit(1);
|
|
118
|
-
}
|
|
119
|
-
// Finish the dump
|
|
120
|
-
teardown();
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* @description Finish the document dumping session.
|
|
124
|
-
* @param pitId ID of the PIT opened on Elasticsearch.
|
|
125
|
-
*/
|
|
126
|
-
async finishDump(pitId) {
|
|
127
|
-
try {
|
|
128
|
-
await this.paas.query({
|
|
129
|
-
controller: "application/storage",
|
|
130
|
-
action: "finishDumpDocuments",
|
|
131
|
-
environmentId: this.args.environment,
|
|
132
|
-
projectId: this.flags.project || this.getProject(),
|
|
133
|
-
applicationId: this.args.applicationId,
|
|
134
|
-
body: {
|
|
135
|
-
pitId,
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
this.logInfo(`Unable to cleanly finish the dump session: ${error}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
PaasEsDump.description = "Dump data from the Elasticsearch of a PaaS application";
|
|
145
|
-
PaasEsDump.flags = {
|
|
146
|
-
help: command_1.flags.help(),
|
|
147
|
-
project: command_1.flags.string({
|
|
148
|
-
description: "Current PaaS project",
|
|
149
|
-
}),
|
|
150
|
-
"batch-size": command_1.flags.integer({
|
|
151
|
-
description: "Maximum batch size",
|
|
152
|
-
default: 2000,
|
|
153
|
-
}),
|
|
154
|
-
};
|
|
155
|
-
PaasEsDump.args = [
|
|
156
|
-
{
|
|
157
|
-
name: "environment",
|
|
158
|
-
description: "Project environment name",
|
|
159
|
-
required: true,
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: "applicationId",
|
|
163
|
-
description: "Application Identifier",
|
|
164
|
-
required: true,
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
name: "dumpDirectory",
|
|
168
|
-
description: "Directory where to store dump files",
|
|
169
|
-
required: true,
|
|
170
|
-
}
|
|
171
|
-
];
|
|
172
|
-
exports.default = PaasEsDump;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PaasKommand } from "../../support/PaasKommand";
|
|
2
|
-
declare class PaasInit extends PaasKommand {
|
|
3
|
-
static description: string;
|
|
4
|
-
static flags: {
|
|
5
|
-
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
6
|
-
};
|
|
7
|
-
static args: {
|
|
8
|
-
name: string;
|
|
9
|
-
description: string;
|
|
10
|
-
required: boolean;
|
|
11
|
-
}[];
|
|
12
|
-
runSafe(): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
export default PaasInit;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
-
const command_1 = require("@oclif/command");
|
|
7
|
-
const PaasKommand_1 = require("../../support/PaasKommand");
|
|
8
|
-
class PaasInit extends PaasKommand_1.PaasKommand {
|
|
9
|
-
async runSafe() {
|
|
10
|
-
const packageJsonPath = path_1.default.join(process.cwd(), "package.json");
|
|
11
|
-
if (!fs_1.default.existsSync(packageJsonPath)) {
|
|
12
|
-
throw new Error(`Cannot find package json in current directory. (${packageJsonPath})`);
|
|
13
|
-
}
|
|
14
|
-
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf8"));
|
|
15
|
-
this.logInfo('Add the "kuzzle" property inside project package.json.');
|
|
16
|
-
packageJson.kuzzle = {
|
|
17
|
-
paas: {
|
|
18
|
-
project: this.args.project,
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
PaasInit.description = "Initialize a PaaS project in current directory";
|
|
25
|
-
PaasInit.flags = {
|
|
26
|
-
help: command_1.flags.help(),
|
|
27
|
-
};
|
|
28
|
-
PaasInit.args = [
|
|
29
|
-
{
|
|
30
|
-
name: "project",
|
|
31
|
-
description: "Kuzzle PaaS project name",
|
|
32
|
-
required: true,
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
exports.default = PaasInit;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { flags } from "@oclif/command";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { PaasKommand } from "../../support/PaasKommand";
|
|
4
|
-
declare class PaasLogs extends PaasKommand {
|
|
5
|
-
static description: string;
|
|
6
|
-
static flags: {
|
|
7
|
-
follow: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
8
|
-
timestamp: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
9
|
-
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
10
|
-
project: flags.IOptionFlag<string | undefined>;
|
|
11
|
-
tail: import("@oclif/parser/lib/flags").IOptionFlag<number | undefined>;
|
|
12
|
-
podName: flags.IOptionFlag<string | undefined>;
|
|
13
|
-
since: flags.IOptionFlag<string | undefined>;
|
|
14
|
-
until: flags.IOptionFlag<string | undefined>;
|
|
15
|
-
};
|
|
16
|
-
static args: {
|
|
17
|
-
name: string;
|
|
18
|
-
description: string;
|
|
19
|
-
required: boolean;
|
|
20
|
-
}[];
|
|
21
|
-
/**
|
|
22
|
-
* Allowed colors for pod names.
|
|
23
|
-
*/
|
|
24
|
-
private readonly allColors;
|
|
25
|
-
/**
|
|
26
|
-
* Available colors for pod names.
|
|
27
|
-
*/
|
|
28
|
-
private availableColors;
|
|
29
|
-
/**
|
|
30
|
-
* The color to use for pod names.
|
|
31
|
-
* @private
|
|
32
|
-
*/
|
|
33
|
-
private podsColor;
|
|
34
|
-
runSafe(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Returns the color to use for a pod name.
|
|
37
|
-
* @param podName Name of the pod.
|
|
38
|
-
* @returns The color to use.
|
|
39
|
-
*/
|
|
40
|
-
getPodColor(podName: string): chalk.Chalk;
|
|
41
|
-
}
|
|
42
|
-
export default PaasLogs;
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const readline = (0, tslib_1.__importStar)(require("readline"));
|
|
5
|
-
const command_1 = require("@oclif/command");
|
|
6
|
-
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
7
|
-
const chrono = (0, tslib_1.__importStar)(require("chrono-node"));
|
|
8
|
-
const PaasKommand_1 = require("../../support/PaasKommand");
|
|
9
|
-
class PaasLogs extends PaasKommand_1.PaasKommand {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments);
|
|
12
|
-
/**
|
|
13
|
-
* Allowed colors for pod names.
|
|
14
|
-
*/
|
|
15
|
-
this.allColors = [
|
|
16
|
-
chalk_1.default.red,
|
|
17
|
-
chalk_1.default.green,
|
|
18
|
-
chalk_1.default.yellow,
|
|
19
|
-
chalk_1.default.blue,
|
|
20
|
-
chalk_1.default.magenta,
|
|
21
|
-
chalk_1.default.cyan,
|
|
22
|
-
chalk_1.default.gray,
|
|
23
|
-
];
|
|
24
|
-
/**
|
|
25
|
-
* Available colors for pod names.
|
|
26
|
-
*/
|
|
27
|
-
this.availableColors = [...this.allColors];
|
|
28
|
-
/**
|
|
29
|
-
* The color to use for pod names.
|
|
30
|
-
* @private
|
|
31
|
-
*/
|
|
32
|
-
this.podsColor = new Map();
|
|
33
|
-
}
|
|
34
|
-
async runSafe() {
|
|
35
|
-
var e_1, _a;
|
|
36
|
-
const apiKey = await this.getCredentials();
|
|
37
|
-
await this.initPaasClient({ apiKey });
|
|
38
|
-
const user = await this.paas.auth.getCurrentUser();
|
|
39
|
-
this.logInfo(`Logged as "${user._id}" for project "${this.flags.project || this.getProject()}"`);
|
|
40
|
-
const separator = "\t";
|
|
41
|
-
// Parse the time arguments
|
|
42
|
-
const since = this.flags.since
|
|
43
|
-
? chrono.parseDate(this.flags.since).toISOString()
|
|
44
|
-
: undefined;
|
|
45
|
-
const until = this.flags.until
|
|
46
|
-
? chrono.parseDate(this.flags.until).toISOString()
|
|
47
|
-
: undefined;
|
|
48
|
-
// Perform the streamed request
|
|
49
|
-
const incomingMessage = await this.paas.queryHttpStream({
|
|
50
|
-
controller: "application",
|
|
51
|
-
action: "logs",
|
|
52
|
-
environmentId: this.args.environment,
|
|
53
|
-
projectId: this.flags.project || this.getProject(),
|
|
54
|
-
applicationId: this.args.application,
|
|
55
|
-
follow: this.flags.follow,
|
|
56
|
-
tailLines: this.flags.tail,
|
|
57
|
-
podName: this.flags.podName,
|
|
58
|
-
since,
|
|
59
|
-
until,
|
|
60
|
-
});
|
|
61
|
-
// Don't continue if an error occurred
|
|
62
|
-
if (incomingMessage.statusCode !== 200) {
|
|
63
|
-
return new Promise((_, reject) => {
|
|
64
|
-
// Collect the whole response body
|
|
65
|
-
let responseBody = "";
|
|
66
|
-
incomingMessage.on("data", (buffer) => {
|
|
67
|
-
responseBody += buffer.toString();
|
|
68
|
-
});
|
|
69
|
-
incomingMessage.on("end", () => {
|
|
70
|
-
let response;
|
|
71
|
-
try {
|
|
72
|
-
response = JSON.parse(responseBody);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
reject(new Error("An error occurred while parsing the error response body from Kuzzle"));
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
reject(response.error);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
// Read the response line by line
|
|
83
|
-
const lineStream = readline.createInterface({
|
|
84
|
-
input: incomingMessage,
|
|
85
|
-
crlfDelay: Infinity,
|
|
86
|
-
terminal: false,
|
|
87
|
-
});
|
|
88
|
-
try {
|
|
89
|
-
// Display the response
|
|
90
|
-
for (var lineStream_1 = (0, tslib_1.__asyncValues)(lineStream), lineStream_1_1; lineStream_1_1 = await lineStream_1.next(), !lineStream_1_1.done;) {
|
|
91
|
-
const line = lineStream_1_1.value;
|
|
92
|
-
try {
|
|
93
|
-
const data = JSON.parse(line);
|
|
94
|
-
// Exclude logs that are empty or that are not from a pod
|
|
95
|
-
if (!data.content || !data.podName) {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
// Get the pod color
|
|
99
|
-
const podColor = this.getPodColor(data.podName);
|
|
100
|
-
// Display the log
|
|
101
|
-
const timestamp = this.flags.timestamp
|
|
102
|
-
? `[${new Date(data.timeStamp).toLocaleString()}] `
|
|
103
|
-
: "";
|
|
104
|
-
const name = podColor(`${data.podName}${separator}`);
|
|
105
|
-
this.log(`${timestamp}${name}| ${data.content}`);
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
this.logKo(`Error while parsing log: ${error} (Received: "${line}")`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
113
|
-
finally {
|
|
114
|
-
try {
|
|
115
|
-
if (lineStream_1_1 && !lineStream_1_1.done && (_a = lineStream_1.return)) await _a.call(lineStream_1);
|
|
116
|
-
}
|
|
117
|
-
finally { if (e_1) throw e_1.error; }
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Returns the color to use for a pod name.
|
|
122
|
-
* @param podName Name of the pod.
|
|
123
|
-
* @returns The color to use.
|
|
124
|
-
*/
|
|
125
|
-
getPodColor(podName) {
|
|
126
|
-
// Attempt to get the color from the list
|
|
127
|
-
let podColor = this.podsColor.get(podName);
|
|
128
|
-
if (!podColor) {
|
|
129
|
-
// Get a random color
|
|
130
|
-
const index = Math.floor(Math.random() * this.availableColors.length);
|
|
131
|
-
[podColor] = this.availableColors.splice(index, 1);
|
|
132
|
-
this.podsColor.set(podName, podColor);
|
|
133
|
-
// If all colors are used, reset the available colors
|
|
134
|
-
if (this.availableColors.length === 0) {
|
|
135
|
-
this.availableColors = [...this.allColors];
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return podColor;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
PaasLogs.description = "Show logs of the targeted application";
|
|
142
|
-
PaasLogs.flags = {
|
|
143
|
-
follow: command_1.flags.boolean({
|
|
144
|
-
char: "f",
|
|
145
|
-
description: "Follow log output",
|
|
146
|
-
}),
|
|
147
|
-
timestamp: command_1.flags.boolean({
|
|
148
|
-
char: "t",
|
|
149
|
-
description: "Show timestamp",
|
|
150
|
-
}),
|
|
151
|
-
help: command_1.flags.help(),
|
|
152
|
-
project: command_1.flags.string({
|
|
153
|
-
description: "Current PaaS project",
|
|
154
|
-
}),
|
|
155
|
-
tail: command_1.flags.integer({
|
|
156
|
-
char: "n",
|
|
157
|
-
description: "Number of lines to show from the end of the logs",
|
|
158
|
-
}),
|
|
159
|
-
podName: command_1.flags.string({
|
|
160
|
-
description: "Name of the pod to show logs from",
|
|
161
|
-
}),
|
|
162
|
-
since: command_1.flags.string({
|
|
163
|
-
description: "Display logs from a specific absolute (e.g. 2022/12/02 09:41) or relative (e.g. a minute ago) time",
|
|
164
|
-
}),
|
|
165
|
-
until: command_1.flags.string({
|
|
166
|
-
description: "Display logs until a specific absolute (e.g. 2022/12/02 09:41) or relative (e.g. a minute ago) time",
|
|
167
|
-
}),
|
|
168
|
-
};
|
|
169
|
-
PaasLogs.args = [
|
|
170
|
-
{
|
|
171
|
-
name: "environment",
|
|
172
|
-
description: "Kuzzle PaaS environment",
|
|
173
|
-
required: true,
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
name: "application",
|
|
177
|
-
description: "Kuzzle PaaS application",
|
|
178
|
-
required: true,
|
|
179
|
-
},
|
|
180
|
-
];
|
|
181
|
-
exports.default = PaasLogs;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { flags } from "@oclif/command";
|
|
2
|
-
import { PaasKommand } from "../../../support/PaasKommand";
|
|
3
|
-
declare class PaasSnapshotsCat extends PaasKommand {
|
|
4
|
-
static description: string;
|
|
5
|
-
static flags: {
|
|
6
|
-
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
|
-
token: flags.IOptionFlag<string | undefined>;
|
|
8
|
-
project: flags.IOptionFlag<string | undefined>;
|
|
9
|
-
};
|
|
10
|
-
static args: {
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
required: boolean;
|
|
14
|
-
}[];
|
|
15
|
-
static examples: string[];
|
|
16
|
-
runSafe(): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export default PaasSnapshotsCat;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const command_1 = require("@oclif/command");
|
|
4
|
-
const PaasKommand_1 = require("../../../support/PaasKommand");
|
|
5
|
-
class PaasSnapshotsCat extends PaasKommand_1.PaasKommand {
|
|
6
|
-
async runSafe() {
|
|
7
|
-
const apiKey = await this.getCredentials();
|
|
8
|
-
await this.initPaasClient({ apiKey });
|
|
9
|
-
const user = await this.paas.auth.getCurrentUser();
|
|
10
|
-
this.logInfo(`Logged as "${user._id}" for project "${this.flags.project || this.getProject()}"`);
|
|
11
|
-
const { result } = await this.paas.query({
|
|
12
|
-
controller: "application",
|
|
13
|
-
action: "snapshots",
|
|
14
|
-
environmentId: this.args.environment,
|
|
15
|
-
projectId: this.flags.project || this.getProject(),
|
|
16
|
-
applicationId: this.args.applicationId,
|
|
17
|
-
body: {},
|
|
18
|
-
});
|
|
19
|
-
this.logInfo(JSON.stringify(result, null, 2));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
PaasSnapshotsCat.description = "List all snapshots for a given kuzzle application in a environment";
|
|
23
|
-
PaasSnapshotsCat.flags = {
|
|
24
|
-
help: command_1.flags.help(),
|
|
25
|
-
token: command_1.flags.string({
|
|
26
|
-
default: process.env.KUZZLE_PAAS_TOKEN,
|
|
27
|
-
description: "Authentication token",
|
|
28
|
-
}),
|
|
29
|
-
project: command_1.flags.string({
|
|
30
|
-
description: "Current PaaS project",
|
|
31
|
-
}),
|
|
32
|
-
};
|
|
33
|
-
PaasSnapshotsCat.args = [
|
|
34
|
-
{
|
|
35
|
-
name: "environment",
|
|
36
|
-
description: "Project environment name",
|
|
37
|
-
required: true,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "applicationId",
|
|
41
|
-
description: "Application Identifier",
|
|
42
|
-
required: true,
|
|
43
|
-
}
|
|
44
|
-
];
|
|
45
|
-
PaasSnapshotsCat.examples = ["kourou paas:snapshots:cat --project paas-project-myproject api main"];
|
|
46
|
-
exports.default = PaasSnapshotsCat;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { flags } from "@oclif/command";
|
|
2
|
-
import { PaasKommand } from "../../../support/PaasKommand";
|
|
3
|
-
declare class PaasSnapshotsDump extends PaasKommand {
|
|
4
|
-
static description: string;
|
|
5
|
-
static flags: {
|
|
6
|
-
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
|
-
token: flags.IOptionFlag<string | undefined>;
|
|
8
|
-
project: flags.IOptionFlag<string | undefined>;
|
|
9
|
-
};
|
|
10
|
-
static args: {
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
required: boolean;
|
|
14
|
-
}[];
|
|
15
|
-
static examples: string[];
|
|
16
|
-
runSafe(): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export default PaasSnapshotsDump;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const command_1 = require("@oclif/command");
|
|
4
|
-
const PaasKommand_1 = require("../../../support/PaasKommand");
|
|
5
|
-
class PaasSnapshotsDump extends PaasKommand_1.PaasKommand {
|
|
6
|
-
async runSafe() {
|
|
7
|
-
const apiKey = await this.getCredentials();
|
|
8
|
-
await this.initPaasClient({ apiKey });
|
|
9
|
-
const user = await this.paas.auth.getCurrentUser();
|
|
10
|
-
this.logInfo(`Logged as "${user._id}" for project "${this.flags.project || this.getProject()}"`);
|
|
11
|
-
const { result } = await this.paas.query({
|
|
12
|
-
controller: "application",
|
|
13
|
-
action: "dump",
|
|
14
|
-
environmentId: this.args.environment,
|
|
15
|
-
projectId: this.flags.project || this.getProject(),
|
|
16
|
-
applicationId: this.args.applicationId,
|
|
17
|
-
body: {},
|
|
18
|
-
});
|
|
19
|
-
this.logOk(result.body);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
PaasSnapshotsDump.description = "Create a new snapshot of the current application state";
|
|
23
|
-
PaasSnapshotsDump.flags = {
|
|
24
|
-
help: command_1.flags.help(),
|
|
25
|
-
token: command_1.flags.string({
|
|
26
|
-
default: process.env.KUZZLE_PAAS_TOKEN,
|
|
27
|
-
description: "Authentication token",
|
|
28
|
-
}),
|
|
29
|
-
project: command_1.flags.string({
|
|
30
|
-
description: "Current PaaS project",
|
|
31
|
-
}),
|
|
32
|
-
};
|
|
33
|
-
PaasSnapshotsDump.args = [
|
|
34
|
-
{
|
|
35
|
-
name: "environment",
|
|
36
|
-
description: "Project environment name",
|
|
37
|
-
required: true,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "applicationId",
|
|
41
|
-
description: "Application Identifier",
|
|
42
|
-
required: true,
|
|
43
|
-
}
|
|
44
|
-
];
|
|
45
|
-
PaasSnapshotsDump.examples = ["kourou paas:snapshots:dump --project paas-project-myproject api main"];
|
|
46
|
-
exports.default = PaasSnapshotsDump;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { flags } from "@oclif/command";
|
|
2
|
-
import { PaasKommand } from "../../../support/PaasKommand";
|
|
3
|
-
declare class PaasSnapshotsRestore extends PaasKommand {
|
|
4
|
-
static description: string;
|
|
5
|
-
static flags: {
|
|
6
|
-
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
|
-
token: flags.IOptionFlag<string | undefined>;
|
|
8
|
-
project: flags.IOptionFlag<string | undefined>;
|
|
9
|
-
};
|
|
10
|
-
static args: {
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
required: boolean;
|
|
14
|
-
}[];
|
|
15
|
-
static examples: string[];
|
|
16
|
-
runSafe(): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export default PaasSnapshotsRestore;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const command_1 = require("@oclif/command");
|
|
4
|
-
const PaasKommand_1 = require("../../../support/PaasKommand");
|
|
5
|
-
class PaasSnapshotsRestore extends PaasKommand_1.PaasKommand {
|
|
6
|
-
async runSafe() {
|
|
7
|
-
const apiKey = await this.getCredentials();
|
|
8
|
-
await this.initPaasClient({ apiKey });
|
|
9
|
-
const user = await this.paas.auth.getCurrentUser();
|
|
10
|
-
this.logInfo(`Logged as "${user._id}" for project "${this.flags.project || this.getProject()}"`);
|
|
11
|
-
await this.paas.query({
|
|
12
|
-
controller: "application",
|
|
13
|
-
action: "restore",
|
|
14
|
-
environmentId: this.args.environment,
|
|
15
|
-
projectId: this.flags.project || this.getProject(),
|
|
16
|
-
applicationId: this.args.applicationId,
|
|
17
|
-
snapshotId: this.args.snapshotId
|
|
18
|
-
});
|
|
19
|
-
this.logInfo("Ok");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
PaasSnapshotsRestore.description = "Restore a snapshot of the current application state";
|
|
23
|
-
PaasSnapshotsRestore.flags = {
|
|
24
|
-
help: command_1.flags.help(),
|
|
25
|
-
token: command_1.flags.string({
|
|
26
|
-
default: process.env.KUZZLE_PAAS_TOKEN,
|
|
27
|
-
description: "Authentication token",
|
|
28
|
-
}),
|
|
29
|
-
project: command_1.flags.string({
|
|
30
|
-
description: "Current PaaS project",
|
|
31
|
-
}),
|
|
32
|
-
};
|
|
33
|
-
PaasSnapshotsRestore.args = [
|
|
34
|
-
{
|
|
35
|
-
name: "environment",
|
|
36
|
-
description: "Project environment name",
|
|
37
|
-
required: true,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "applicationId",
|
|
41
|
-
description: "Application Identifier",
|
|
42
|
-
required: true,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "snapshotId",
|
|
46
|
-
description: "Snapshot Identifier",
|
|
47
|
-
required: true,
|
|
48
|
-
}
|
|
49
|
-
];
|
|
50
|
-
PaasSnapshotsRestore.examples = ["kourou paas:snapshots:restore --project paas-project-myproject api main snapshot-id"];
|
|
51
|
-
exports.default = PaasSnapshotsRestore;
|