kourou
Advanced tools
Comparing version 0.25.2 to 0.26.0
@@ -20,2 +20,4 @@ "use strict"; | ||
async runSafe() { | ||
// @ts-ignore Disable ping pong since when debugging Kuzzle might not be responding | ||
clearInterval(this.sdk.sdk.protocol.pingIntervalId); | ||
const nodeVersionResponse = (await this.sdk.query({ | ||
@@ -22,0 +24,0 @@ controller: "debug", |
@@ -16,4 +16,3 @@ import { flags } from "@oclif/command"; | ||
runSafe(): Promise<void>; | ||
getCredentials(): Promise<any>; | ||
} | ||
export default PaasDeploy; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const fs_1 = (0, tslib_1.__importDefault)(require("fs")); | ||
const command_1 = require("@oclif/command"); | ||
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux")); | ||
const login_1 = (0, tslib_1.__importDefault)(require("./login")); | ||
const PaasKommand_1 = require("../../support/PaasKommand"); | ||
@@ -32,20 +28,2 @@ class PaasDeploy extends PaasKommand_1.PaasKommand { | ||
} | ||
async getCredentials() { | ||
const project = this.getProject(); | ||
const projectFile = this.fileProjectCredentials(project); | ||
if (!fs_1.default.existsSync(projectFile)) { | ||
this.log(""); | ||
const nextStep = await cli_ux_1.default.prompt("Cannot find credentials for this project. Do you want to login first? [Y/N]", { type: "single" }); | ||
this.log(""); | ||
if (nextStep.toLowerCase().startsWith("y")) { | ||
await login_1.default.run(["--project", project]); | ||
} | ||
else { | ||
this.logKo("Aborting."); | ||
process.exit(1); | ||
} | ||
} | ||
const credentials = JSON.parse(fs_1.default.readFileSync(projectFile, "utf8")); | ||
return credentials.apiKey; | ||
} | ||
} | ||
@@ -52,0 +30,0 @@ PaasDeploy.description = "Deploy a new version of the application in the PaaS"; |
@@ -24,5 +24,5 @@ "use strict"; | ||
await this.initPaasClient({ username, password }); | ||
await this.authenticateNPM(username, password); | ||
const apiKey = await this.paas.auth.createApiKey("Kourou PaaS API Key"); | ||
this.createProjectCredentials(apiKey); | ||
await this.authenticateNPM(username, password); | ||
this.logOk(`Successfully logged in as ${username}. Your Kuzzle Enterprise license is now enabled on this host.`); | ||
@@ -53,3 +53,4 @@ } | ||
}; | ||
const response = await (0, node_fetch_1.default)(`https://${this.packagesHost}/-/user/org.couchdb.user:${username}`, options); | ||
const targetUrl = `https://${this.packagesHost}/-/user/org.couchdb.user:${username}`; | ||
const response = await (0, node_fetch_1.default)(targetUrl, options); | ||
const json = await response.json(); | ||
@@ -56,0 +57,0 @@ if (response.status !== 201) { |
@@ -35,4 +35,2 @@ import { flags } from "@oclif/command"; | ||
runSafe(): Promise<void>; | ||
getCredentials(): Promise<any>; | ||
getNumberOfSpaces(names: string[], currentName: string): number; | ||
/** | ||
@@ -39,0 +37,0 @@ * Returns the color to use for a pod name. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const fs_1 = (0, tslib_1.__importDefault)(require("fs")); | ||
const readline = (0, tslib_1.__importStar)(require("readline")); | ||
@@ -9,4 +8,2 @@ const command_1 = require("@oclif/command"); | ||
const chrono = (0, tslib_1.__importStar)(require("chrono-node")); | ||
const cli_ux_1 = require("cli-ux"); | ||
const login_1 = (0, tslib_1.__importDefault)(require("./login")); | ||
const PaasKommand_1 = require("../../support/PaasKommand"); | ||
@@ -103,32 +100,2 @@ class PaasLogs extends PaasKommand_1.PaasKommand { | ||
} | ||
async getCredentials() { | ||
const project = this.getProject(); | ||
const projectFile = this.fileProjectCredentials(project); | ||
if (!fs_1.default.existsSync(projectFile)) { | ||
this.log(""); | ||
const nextStep = await cli_ux_1.cli.prompt("Cannot find credentials for this project. Do you want to login first? [Y/N]", { type: "single" }); | ||
this.log(""); | ||
if (nextStep.toLowerCase().startsWith("y")) { | ||
await login_1.default.run(["--project", project]); | ||
} | ||
else { | ||
this.logKo("Aborting."); | ||
process.exit(1); | ||
} | ||
} | ||
const credentials = JSON.parse(fs_1.default.readFileSync(projectFile, "utf8")); | ||
return credentials.apiKey; | ||
} | ||
getNumberOfSpaces(names, currentName) { | ||
const end = 10; | ||
let max = { name: "", length: 0 }; | ||
for (const name of names) { | ||
if (max.length < name.length) { | ||
max = { name: name, length: name.length }; | ||
} | ||
} | ||
return currentName === max.name | ||
? end | ||
: end + (max.length - currentName.length); | ||
} | ||
/** | ||
@@ -135,0 +102,0 @@ * Returns the color to use for a pod name. |
@@ -27,2 +27,3 @@ "use strict"; | ||
delete specifications.settings.index.routing; | ||
delete specifications.settings.index.history; | ||
return specifications; | ||
@@ -29,0 +30,0 @@ } |
@@ -22,3 +22,4 @@ import { Kommand } from "../common"; | ||
getProject(): any; | ||
getCredentials(): Promise<any>; | ||
} | ||
export {}; |
@@ -59,4 +59,14 @@ "use strict"; | ||
} | ||
async getCredentials() { | ||
const project = this.getProject(); | ||
const projectFile = this.fileProjectCredentials(project); | ||
if (!fs_1.default.existsSync(projectFile)) { | ||
this.logKo("You are not logged in. You should run paas:login first. Aborting."); | ||
process.exit(1); | ||
} | ||
const credentials = JSON.parse(fs_1.default.readFileSync(projectFile, "utf8")); | ||
return credentials.apiKey; | ||
} | ||
} | ||
exports.PaasKommand = PaasKommand; | ||
PaasKommand.initSdk = false; |
{ | ||
"name": "kourou", | ||
"description": "The CLI that helps you manage your Kuzzle instances", | ||
"version": "0.25.2", | ||
"version": "0.26.0", | ||
"author": "The Kuzzle Team <support@kuzzle.io>", | ||
@@ -6,0 +6,0 @@ "bin": { |
188
README.md
@@ -5,2 +5,3 @@ # kourou | ||
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io) | ||
@@ -30,3 +31,3 @@ [![Version](https://img.shields.io/npm/v/kourou.svg)](https://npmjs.org/package/kourou) | ||
$ kourou (-v|--version|version) | ||
kourou/0.25.2 linux-x64 node-v14.20.0 | ||
kourou/0.26.0 linux-x64 node-v14.21.2 | ||
$ kourou --help [COMMAND] | ||
@@ -130,57 +131,68 @@ USAGE | ||
<!-- commands --> | ||
* [`kourou api-key:check TOKEN`](#kourou-api-keycheck-token) | ||
* [`kourou api-key:create USER`](#kourou-api-keycreate-user) | ||
* [`kourou api-key:delete USER ID`](#kourou-api-keydelete-user-id) | ||
* [`kourou api-key:search USER`](#kourou-api-keysearch-user) | ||
* [`kourou app:debug-proxy`](#kourou-appdebug-proxy) | ||
* [`kourou app:doctor`](#kourou-appdoctor) | ||
* [`kourou app:scaffold DESTINATION`](#kourou-appscaffold-destination) | ||
* [`kourou app:start-services`](#kourou-appstart-services) | ||
* [`kourou autocomplete [SHELL]`](#kourou-autocomplete-shell) | ||
* [`kourou collection:create INDEX COLLECTION [BODY]`](#kourou-collectioncreate-index-collection-body) | ||
* [`kourou collection:export INDEX COLLECTION`](#kourou-collectionexport-index-collection) | ||
* [`kourou collection:import PATH`](#kourou-collectionimport-path) | ||
* [`kourou collection:migrate SCRIPT PATH`](#kourou-collectionmigrate-script-path) | ||
* [`kourou config:diff FIRST SECOND`](#kourou-configdiff-first-second) | ||
* [`kourou document:search INDEX COLLECTION [QUERY]`](#kourou-documentsearch-index-collection-query) | ||
* [`kourou es:aliases:cat`](#kourou-esaliasescat) | ||
* [`kourou es:indices:cat`](#kourou-esindicescat) | ||
* [`kourou es:indices:get INDEX ID`](#kourou-esindicesget-index-id) | ||
* [`kourou es:indices:insert INDEX`](#kourou-esindicesinsert-index) | ||
* [`kourou es:migrate`](#kourou-esmigrate) | ||
* [`kourou es:snapshot:create REPOSITORY NAME`](#kourou-essnapshotcreate-repository-name) | ||
* [`kourou es:snapshot:create-repository REPOSITORY LOCATION`](#kourou-essnapshotcreate-repository-repository-location) | ||
* [`kourou es:snapshot:list REPOSITORY`](#kourou-essnapshotlist-repository) | ||
* [`kourou file:decrypt FILE`](#kourou-filedecrypt-file) | ||
* [`kourou file:encrypt FILE`](#kourou-fileencrypt-file) | ||
* [`kourou file:test FILE`](#kourou-filetest-file) | ||
* [`kourou help [COMMAND]`](#kourou-help-command) | ||
* [`kourou import PATH`](#kourou-import-path) | ||
* [`kourou index:export INDEX`](#kourou-indexexport-index) | ||
* [`kourou index:import PATH`](#kourou-indeximport-path) | ||
* [`kourou instance:kill`](#kourou-instancekill) | ||
* [`kourou instance:list`](#kourou-instancelist) | ||
* [`kourou instance:logs`](#kourou-instancelogs) | ||
* [`kourou instance:spawn`](#kourou-instancespawn) | ||
* [`kourou paas:deploy ENVIRONMENT APPLICATIONID IMAGE`](#kourou-paasdeploy-environment-applicationid-image) | ||
* [`kourou paas:init PROJECT`](#kourou-paasinit-project) | ||
* [`kourou paas:login`](#kourou-paaslogin) | ||
* [`kourou paas:logs ENVIRONMENT APPLICATION`](#kourou-paaslogs-environment-application) | ||
* [`kourou profile:export`](#kourou-profileexport) | ||
* [`kourou profile:import PATH`](#kourou-profileimport-path) | ||
* [`kourou realtime:subscribe INDEX COLLECTION [FILTERS]`](#kourou-realtimesubscribe-index-collection-filters) | ||
* [`kourou redis:list-keys [MATCH]`](#kourou-redislist-keys-match) | ||
* [`kourou role:export`](#kourou-roleexport) | ||
* [`kourou role:import PATH`](#kourou-roleimport-path) | ||
* [`kourou sdk:execute [CODE]`](#kourou-sdkexecute-code) | ||
* [`kourou sdk:query CONTROLLER:ACTION`](#kourou-sdkquery-controlleraction) | ||
* [`kourou user:export`](#kourou-userexport) | ||
* [`kourou user:export-mappings`](#kourou-userexport-mappings) | ||
* [`kourou user:import PATH`](#kourou-userimport-path) | ||
* [`kourou user:import-mappings PATH`](#kourou-userimport-mappings-path) | ||
* [`kourou vault:add SECRETS-FILE KEY VALUE`](#kourou-vaultadd-secrets-file-key-value) | ||
* [`kourou vault:decrypt FILE`](#kourou-vaultdecrypt-file) | ||
* [`kourou vault:encrypt FILE`](#kourou-vaultencrypt-file) | ||
* [`kourou vault:show SECRETS-FILE [KEY]`](#kourou-vaultshow-secrets-file-key) | ||
* [`kourou vault:test SECRETS-FILE`](#kourou-vaulttest-secrets-file) | ||
- [kourou](#kourou) | ||
- [Usage](#usage) | ||
- [Connect and authenticate to Kuzzle API](#connect-and-authenticate-to-kuzzle-api) | ||
- [User impersonation](#user-impersonation) | ||
- [Automatic command infering for API actions](#automatic-command-infering-for-api-actions) | ||
- [Commands](#commands) | ||
- [`kourou api-key:check TOKEN`](#kourou-api-keycheck-token) | ||
- [`kourou api-key:create USER`](#kourou-api-keycreate-user) | ||
- [`kourou api-key:delete USER ID`](#kourou-api-keydelete-user-id) | ||
- [`kourou api-key:search USER`](#kourou-api-keysearch-user) | ||
- [`kourou app:debug-proxy`](#kourou-appdebug-proxy) | ||
- [`kourou app:doctor`](#kourou-appdoctor) | ||
- [`kourou app:scaffold DESTINATION`](#kourou-appscaffold-destination) | ||
- [`kourou app:start-services`](#kourou-appstart-services) | ||
- [`kourou autocomplete [SHELL]`](#kourou-autocomplete-shell) | ||
- [`kourou collection:create INDEX COLLECTION [BODY]`](#kourou-collectioncreate-index-collection-body) | ||
- [`kourou collection:export INDEX COLLECTION`](#kourou-collectionexport-index-collection) | ||
- [`kourou collection:import PATH`](#kourou-collectionimport-path) | ||
- [`kourou collection:migrate SCRIPT PATH`](#kourou-collectionmigrate-script-path) | ||
- [`kourou config:diff FIRST SECOND`](#kourou-configdiff-first-second) | ||
- [`kourou document:search INDEX COLLECTION [QUERY]`](#kourou-documentsearch-index-collection-query) | ||
- [`kourou es:aliases:cat`](#kourou-esaliasescat) | ||
- [`kourou es:indices:cat`](#kourou-esindicescat) | ||
- [`kourou es:indices:get INDEX ID`](#kourou-esindicesget-index-id) | ||
- [`kourou es:indices:insert INDEX`](#kourou-esindicesinsert-index) | ||
- [`kourou es:migrate`](#kourou-esmigrate) | ||
- [`kourou es:snapshot:create REPOSITORY NAME`](#kourou-essnapshotcreate-repository-name) | ||
- [`kourou es:snapshot:create-repository REPOSITORY LOCATION`](#kourou-essnapshotcreate-repository-repository-location) | ||
- [`kourou es:snapshot:list REPOSITORY`](#kourou-essnapshotlist-repository) | ||
- [`kourou file:decrypt FILE`](#kourou-filedecrypt-file) | ||
- [`kourou file:encrypt FILE`](#kourou-fileencrypt-file) | ||
- [`kourou file:test FILE`](#kourou-filetest-file) | ||
- [`kourou help [COMMAND]`](#kourou-help-command) | ||
- [`kourou import PATH`](#kourou-import-path) | ||
- [`kourou index:export INDEX`](#kourou-indexexport-index) | ||
- [`kourou index:import PATH`](#kourou-indeximport-path) | ||
- [`kourou instance:kill`](#kourou-instancekill) | ||
- [`kourou instance:list`](#kourou-instancelist) | ||
- [`kourou instance:logs`](#kourou-instancelogs) | ||
- [`kourou instance:spawn`](#kourou-instancespawn) | ||
- [`kourou paas:deploy ENVIRONMENT APPLICATIONID IMAGE`](#kourou-paasdeploy-environment-applicationid-image) | ||
- [`kourou paas:init PROJECT`](#kourou-paasinit-project) | ||
- [`kourou paas:login`](#kourou-paaslogin) | ||
- [`kourou paas:snapshots:cat ENVIRONMENT APPLICATIONID`](#kourou-paassnapshotscat-environment-applicationid) | ||
- [`kourou paas:snapshots:dump ENVIRONMENT APPLICATIONID`](#kourou-paassnapshotsdump-environment-applicationid) | ||
- [`kourou paas:snapshots:restore ENVIRONMENT APPLICATIONID SNAPSHOTID`](#kourou-paassnapshotsrestore-environment-applicationid-snapshotid) | ||
- [`kourou profile:export`](#kourou-profileexport) | ||
- [`kourou profile:import PATH`](#kourou-profileimport-path) | ||
- [`kourou realtime:subscribe INDEX COLLECTION [FILTERS]`](#kourou-realtimesubscribe-index-collection-filters) | ||
- [`kourou redis:list-keys [MATCH]`](#kourou-redislist-keys-match) | ||
- [`kourou role:export`](#kourou-roleexport) | ||
- [`kourou role:import PATH`](#kourou-roleimport-path) | ||
- [`kourou sdk:execute [CODE]`](#kourou-sdkexecute-code) | ||
- [`kourou sdk:query CONTROLLER:ACTION`](#kourou-sdkquery-controlleraction) | ||
- [`kourou user:export`](#kourou-userexport) | ||
- [`kourou user:export-mappings`](#kourou-userexport-mappings) | ||
- [`kourou user:import PATH`](#kourou-userimport-path) | ||
- [`kourou user:import-mappings PATH`](#kourou-userimport-mappings-path) | ||
- [`kourou vault:add SECRETS-FILE KEY VALUE`](#kourou-vaultadd-secrets-file-key-value) | ||
- [`kourou vault:decrypt FILE`](#kourou-vaultdecrypt-file) | ||
- [`kourou vault:encrypt FILE`](#kourou-vaultencrypt-file) | ||
- [`kourou vault:show SECRETS-FILE [KEY]`](#kourou-vaultshow-secrets-file-key) | ||
- [`kourou vault:test SECRETS-FILE`](#kourou-vaulttest-secrets-file) | ||
- [Where does this weird name come from?](#where-does-this-weird-name-come-from) | ||
- [Have fun with a quine](#have-fun-with-a-quine) | ||
- [Telemetry](#telemetry) | ||
@@ -415,3 +427,3 @@ ## `kourou api-key:check TOKEN` | ||
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v1.3.10/src/commands/autocomplete/index.ts)_ | ||
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v1.3.0/src/commands/autocomplete/index.ts)_ | ||
@@ -880,3 +892,3 @@ ## `kourou collection:create INDEX COLLECTION [BODY]` | ||
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.18/src/commands/help.ts)_ | ||
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.2/src/commands/help.ts)_ | ||
@@ -1104,27 +1116,63 @@ ## `kourou import PATH` | ||
## `kourou paas:logs ENVIRONMENT APPLICATION` | ||
## `kourou paas:snapshots:cat ENVIRONMENT APPLICATIONID` | ||
Show logs of the targeted application | ||
List all snapshots for a given kuzzle application in a environment | ||
``` | ||
USAGE | ||
$ kourou paas:logs ENVIRONMENT APPLICATION | ||
$ kourou paas:snapshots:cat ENVIRONMENT APPLICATIONID | ||
ARGUMENTS | ||
ENVIRONMENT Kuzzle PaaS environment | ||
APPLICATION Kuzzle PaaS application | ||
ENVIRONMENT Project environment name | ||
APPLICATIONID Application Identifier | ||
OPTIONS | ||
-f, --follow Follow log output | ||
-n, --tail=tail Number of lines to show from the end of the logs | ||
-t, --timestamp Show timestamp | ||
--help show CLI help | ||
--podName=podName Name of the pod to show logs from | ||
--project=project Current PaaS project | ||
--since=since Display logs from a specific absolute (e.g. 2022/12/02 09:41) or relative (e.g. a minute ago) time | ||
--until=until Display logs until a specific absolute (e.g. 2022/12/02 09:41) or relative (e.g. a minute ago) time | ||
--token=token Authentication token | ||
``` | ||
_See code: [src/commands/paas/logs.ts](src/commands/paas/logs.ts)_ | ||
_See code: [src/commands/paas/snapshots/cat.ts](src/commands/paas/snapshots/cat.ts)_ | ||
## `kourou paas:snapshots:dump ENVIRONMENT APPLICATIONID` | ||
List all snapshots for a given kuzzle application in a environment | ||
``` | ||
USAGE | ||
$ kourou paas:snapshots:dump ENVIRONMENT APPLICATIONID | ||
ARGUMENTS | ||
ENVIRONMENT Project environment name | ||
APPLICATIONID Application Identifier | ||
OPTIONS | ||
--help show CLI help | ||
--project=project Current PaaS project | ||
--token=token Authentication token | ||
``` | ||
_See code: [src/commands/paas/snapshots/dump.ts](src/commands/paas/snapshots/dump.ts)_ | ||
## `kourou paas:snapshots:restore ENVIRONMENT APPLICATIONID SNAPSHOTID` | ||
List all snapshots for a given kuzzle application in a environment | ||
``` | ||
USAGE | ||
$ kourou paas:snapshots:restore ENVIRONMENT APPLICATIONID SNAPSHOTID | ||
ARGUMENTS | ||
ENVIRONMENT Project environment name | ||
APPLICATIONID Application Identifier | ||
SNAPSHOTID Snapshot Identifier | ||
OPTIONS | ||
--help show CLI help | ||
--project=project Current PaaS project | ||
--token=token Authentication token | ||
``` | ||
_See code: [src/commands/paas/snapshots/restore.ts](src/commands/paas/snapshots/restore.ts)_ | ||
## `kourou profile:export` | ||
@@ -1131,0 +1179,0 @@ |
324766
144
6622
1825
71