Skip to content

Commit

Permalink
Merge pull request #185 from kuzzleio/0.26.0-proposal
Browse files Browse the repository at this point in the history
Release 0.26.0
  • Loading branch information
Shiranuit authored Mar 6, 2023
2 parents f2e0644 + 1789f78 commit 76d75f6
Show file tree
Hide file tree
Showing 13 changed files with 326 additions and 152 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-shadow": "error",
Expand Down
187 changes: 117 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $ npm install -g kourou
$ kourou COMMAND
running command...
$ 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]
USAGE
$ kourou COMMAND
Expand Down Expand Up @@ -126,61 +126,72 @@ All other arguments and options will be passed as-is to the `sdk:query` method.
# 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: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)

## `kourou api-key:check TOKEN`

Expand Down Expand Up @@ -410,7 +421,7 @@ EXAMPLES
$ kourou autocomplete --refresh-cache
```

_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)_

## `kourou collection:create INDEX COLLECTION [BODY]`

Expand Down Expand Up @@ -874,7 +885,7 @@ OPTIONS
--all see all commands in CLI
```

_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)_

## `kourou import PATH`

Expand Down Expand Up @@ -1097,30 +1108,66 @@ OPTIONS

_See code: [src/commands/paas/login.ts](src/commands/paas/login.ts)_

## `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
--help show CLI help
--project=project Current PaaS project
--token=token Authentication token
```

_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
-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/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/logs.ts](src/commands/paas/logs.ts)_
_See code: [src/commands/paas/snapshots/restore.ts](src/commands/paas/snapshots/restore.ts)_

## `kourou profile:export`

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"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>",
"bin": {
"kourou": "./bin/run"
Expand Down
3 changes: 3 additions & 0 deletions src/commands/app/debug-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export default class DebugProxy extends Kommand {
};

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({
controller: "debug",
action: "nodeVersion",
Expand Down
29 changes: 0 additions & 29 deletions src/commands/paas/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import fs from "fs";

import { flags } from "@oclif/command";
import cli from "cli-ux";

import PaasLogin from "./login";
import { PaasKommand } from "../../support/PaasKommand";

class PaasDeploy extends PaasKommand {
Expand Down Expand Up @@ -70,31 +66,6 @@ class PaasDeploy extends PaasKommand {

this.logOk("Deployment in progress");
}

async getCredentials() {
const project = this.getProject();
const projectFile = this.fileProjectCredentials(project);

if (!fs.existsSync(projectFile)) {
this.log("");
const nextStep = await 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 PaasLogin.run(["--project", project]);
} else {
this.logKo("Aborting.");
process.exit(1);
}
}

const credentials = JSON.parse(fs.readFileSync(projectFile, "utf8"));

return credentials.apiKey;
}
}

export default PaasDeploy;
9 changes: 4 additions & 5 deletions src/commands/paas/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ class PaasLogin extends PaasKommand {

await this.initPaasClient({ username, password });

await this.authenticateNPM(username, password);

const apiKey: 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.`
Expand Down Expand Up @@ -89,10 +90,8 @@ class PaasLogin extends PaasKommand {
}),
};

const response = await fetch(
`https://${this.packagesHost}/-/user/org.couchdb.user:${username}`,
options
);
const targetUrl = `https://${this.packagesHost}/-/user/org.couchdb.user:${username}`;
const response = await fetch(targetUrl, options);
const json = await response.json();

if (response.status !== 201) {
Expand Down
Loading

0 comments on commit 76d75f6

Please sign in to comment.