kourou 0.25.0 → 0.25.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 -3
- package/lib/commands/app/scaffold.js +1 -1
- package/lib/commands/collection/migrate.js +1 -1
- package/lib/commands/paas/login.js +8 -8
- package/lib/commands/paas/logs.js +16 -11
- package/lib/support/PaasKommand.d.ts +1 -0
- package/lib/support/PaasKommand.js +3 -0
- package/lib/support/kuzzle.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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.25.
|
|
29
|
+
kourou/0.25.1 linux-x64 node-v16.15.0
|
|
30
30
|
$ kourou --help [COMMAND]
|
|
31
31
|
USAGE
|
|
32
32
|
$ kourou COMMAND
|
|
@@ -365,7 +365,7 @@ ARGUMENTS
|
|
|
365
365
|
DESTINATION Directory to scaffold the app
|
|
366
366
|
|
|
367
367
|
OPTIONS
|
|
368
|
-
--flavor=flavor [default: generic] Template flavor ("generic", "iot-
|
|
368
|
+
--flavor=flavor [default: generic] Template flavor ("generic", "iot-backend", "iot-console").
|
|
369
369
|
Those can be found here: https://github.com/kuzzleio/project-templates
|
|
370
370
|
|
|
371
371
|
--help show CLI help
|
|
@@ -547,7 +547,7 @@ _See code: [src/commands/collection/import.ts](src/commands/collection/import.ts
|
|
|
547
547
|
|
|
548
548
|
## `kourou collection:migrate SCRIPT PATH`
|
|
549
549
|
|
|
550
|
-
Migrate a collection
|
|
550
|
+
Migrate a collection by transforming documents from a dump file and importing them into Kuzzle
|
|
551
551
|
|
|
552
552
|
```
|
|
553
553
|
USAGE
|
|
@@ -35,7 +35,7 @@ AppScaffold.flags = {
|
|
|
35
35
|
help: command_1.flags.help(),
|
|
36
36
|
flavor: command_1.flags.string({
|
|
37
37
|
default: "generic",
|
|
38
|
-
description: `Template flavor ("generic", "iot-
|
|
38
|
+
description: `Template flavor ("generic", "iot-backend", "iot-console").
|
|
39
39
|
Those can be found here: https://github.com/kuzzleio/project-templates`,
|
|
40
40
|
}),
|
|
41
41
|
};
|
|
@@ -25,7 +25,7 @@ class CollectionMigrate extends common_1.Kommand {
|
|
|
25
25
|
}
|
|
26
26
|
exports.default = CollectionMigrate;
|
|
27
27
|
CollectionMigrate.keepAuth = true;
|
|
28
|
-
CollectionMigrate.description = "Migrate a collection";
|
|
28
|
+
CollectionMigrate.description = "Migrate a collection by transforming documents from a dump file and importing them into Kuzzle";
|
|
29
29
|
CollectionMigrate.flags = Object.assign(Object.assign({ help: command_1.flags.help({}), "batch-size": command_1.flags.string({
|
|
30
30
|
description: "Maximum batch size (see limits.documentsWriteCount config)",
|
|
31
31
|
default: "200",
|
|
@@ -20,10 +20,6 @@ class PaasLogin extends PaasKommand_1.PaasKommand {
|
|
|
20
20
|
await this.authenticateNPM(username, password);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
if (this.flags.only_npm) {
|
|
24
|
-
await this.authenticateNPM(username, password);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
23
|
await this.initPaasClient({ username, password });
|
|
28
24
|
const apiKey = await this.paas.auth.createApiKey("Kourou PaaS API Key");
|
|
29
25
|
this.createProjectCredentials(apiKey);
|
|
@@ -53,15 +49,19 @@ class PaasLogin extends PaasKommand_1.PaasKommand {
|
|
|
53
49
|
password,
|
|
54
50
|
}),
|
|
55
51
|
};
|
|
56
|
-
const response = await (0, node_fetch_1.default)(`https
|
|
57
|
-
const
|
|
52
|
+
const response = await (0, node_fetch_1.default)(`https://${this.packagesHost}/-/user/org.couchdb.user:${username}`, options);
|
|
53
|
+
const json = await response.json();
|
|
54
|
+
if (response.status !== 201) {
|
|
55
|
+
throw new Error(json.error);
|
|
56
|
+
}
|
|
57
|
+
const { token } = json;
|
|
58
58
|
(0, child_process_1.spawnSync)("npm", [
|
|
59
59
|
"config",
|
|
60
60
|
"set",
|
|
61
61
|
"@kuzzleio:registry",
|
|
62
|
-
|
|
62
|
+
`https://${this.packagesHost}`,
|
|
63
63
|
], { stdio: "inherit" });
|
|
64
|
-
(0, child_process_1.spawnSync)("npm", ["set",
|
|
64
|
+
(0, child_process_1.spawnSync)("npm", ["set", `//${this.packagesHost}/:_authToken`, token], {
|
|
65
65
|
stdio: "inherit",
|
|
66
66
|
});
|
|
67
67
|
}
|
|
@@ -59,18 +59,23 @@ class PaasLogs extends PaasKommand_1.PaasKommand {
|
|
|
59
59
|
// Display the response
|
|
60
60
|
for (var lineStream_1 = (0, tslib_1.__asyncValues)(lineStream), lineStream_1_1; lineStream_1_1 = await lineStream_1.next(), !lineStream_1_1.done;) {
|
|
61
61
|
const line = lineStream_1_1.value;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
try {
|
|
63
|
+
const data = JSON.parse(line);
|
|
64
|
+
// Exclude logs that are empty or that are not from a pod
|
|
65
|
+
if (!data.content || !data.podName) {
|
|
66
|
+
this.logKo(line);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
// Get the pod color
|
|
70
|
+
const podColor = this.getPodColor(data.podName);
|
|
71
|
+
// Display the log
|
|
72
|
+
const timestamp = this.flags.timestamp ? `[${new Date(data.timeStamp).toLocaleString()}] ` : "";
|
|
73
|
+
const name = podColor(`${data.podName}${separator}`);
|
|
74
|
+
this.log(`${timestamp}${name}| ${data.content}`);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
this.logKo(`Unable to parse the following line: ${line}`);
|
|
67
78
|
}
|
|
68
|
-
// Get the pod color
|
|
69
|
-
const podColor = this.getPodColor(data.podName);
|
|
70
|
-
// Display the log
|
|
71
|
-
const timestamp = this.flags.timestamp ? `[${new Date(data.timeStamp).toLocaleString()}] ` : "";
|
|
72
|
-
const name = podColor(`${data.podName}${separator}`);
|
|
73
|
-
this.log(`${timestamp}${name}| ${data.content}`);
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -11,6 +11,7 @@ export declare class PaasKommand extends Kommand {
|
|
|
11
11
|
protected host: string;
|
|
12
12
|
protected port: number;
|
|
13
13
|
protected ssl: any;
|
|
14
|
+
protected packagesHost: string;
|
|
14
15
|
protected paas: KuzzleSDK;
|
|
15
16
|
initPaasClient(credentials: PaaSClientCredentials): Promise<void>;
|
|
16
17
|
fileProjectCredentials(project: string): string;
|
|
@@ -18,6 +18,9 @@ class PaasKommand extends common_1.Kommand {
|
|
|
18
18
|
this.ssl = process.env.KUZZLE_PAAS_SSL
|
|
19
19
|
? JSON.parse(process.env.KUZZLE_PAAS_SSL)
|
|
20
20
|
: true;
|
|
21
|
+
this.packagesHost = process.env.KUZZLE_PAAS_PACKAGES_HOST
|
|
22
|
+
? process.env.KUZZLE_PAAS_PACKAGES_HOST
|
|
23
|
+
: "packages.paas.kuzzle.io";
|
|
21
24
|
// Instantiate a dummy SDK to avoid the this.paas? notation everywhere -_-
|
|
22
25
|
this.paas = new kuzzle_1.KuzzleSDK({});
|
|
23
26
|
}
|
package/lib/support/kuzzle.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.KuzzleSDK = exports.kuzzleFlags = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const http_1 = (0, tslib_1.__importDefault)(require("http"));
|
|
6
|
+
const https_1 = (0, tslib_1.__importDefault)(require("https"));
|
|
6
7
|
const command_1 = require("@oclif/command");
|
|
7
8
|
const kuzzle_sdk_1 = require("kuzzle-sdk");
|
|
8
9
|
const SECOND = 1000;
|
|
@@ -170,7 +171,8 @@ class KuzzleSDK {
|
|
|
170
171
|
};
|
|
171
172
|
// Send the request
|
|
172
173
|
return new Promise((resolve, reject) => {
|
|
173
|
-
const
|
|
174
|
+
const httpModule = this.ssl ? https_1.default : http_1.default;
|
|
175
|
+
const req = httpModule.request(url, options, (res) => {
|
|
174
176
|
resolve(res);
|
|
175
177
|
});
|
|
176
178
|
req.on("error", reject);
|