clever-tools 4.4.0 → 4.5.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/bin/clever.js +208 -2128
- package/package.json +33 -25
- package/src/clever-client/auth-bridge.js +0 -9
- package/src/clever-client/drains.js +0 -17
- package/src/clever-client/operators.js +1 -1
- package/src/commands/README.md +65 -0
- package/src/commands/accesslogs/accesslogs.command.js +158 -0
- package/src/commands/accesslogs/accesslogs.docs.md +20 -0
- package/src/commands/{activity.js → activity/activity.command.js} +74 -44
- package/src/commands/activity/activity.docs.md +19 -0
- package/src/commands/addon/addon.args.js +14 -0
- package/src/commands/addon/addon.command.js +7 -0
- package/src/commands/addon/addon.create.command.js +236 -0
- package/src/commands/addon/addon.delete.command.js +32 -0
- package/src/commands/addon/addon.docs.md +156 -0
- package/src/commands/addon/addon.env.command.js +50 -0
- package/src/commands/addon/addon.list.command.js +55 -0
- package/src/commands/addon/addon.providers.command.js +45 -0
- package/src/commands/addon/addon.providers.show.command.js +99 -0
- package/src/commands/addon/addon.rename.command.js +24 -0
- package/src/commands/applications/applications.command.js +59 -0
- package/src/commands/applications/applications.docs.md +31 -0
- package/src/commands/applications/applications.list.command.js +100 -0
- package/src/commands/cancel-deploy/cancel-deploy.command.js +30 -0
- package/src/commands/cancel-deploy/cancel-deploy.docs.md +16 -0
- package/src/commands/config/config.args.js +10 -0
- package/src/commands/config/config.command.js +20 -0
- package/src/commands/config/config.docs.md +86 -0
- package/src/commands/config/config.get.command.js +21 -0
- package/src/commands/config/config.set.command.js +38 -0
- package/src/commands/config/config.update.command.js +88 -0
- package/src/commands/console/console.command.js +31 -0
- package/src/commands/console/console.docs.md +16 -0
- package/src/commands/create/create.command.js +173 -0
- package/src/commands/create/create.docs.md +27 -0
- package/src/commands/{curl.js → curl/curl.command.js} +10 -3
- package/src/commands/curl/curl.docs.md +9 -0
- package/src/commands/database/database.args.js +8 -0
- package/src/commands/database/database.backups.command.js +60 -0
- package/src/commands/database/database.backups.download.command.js +55 -0
- package/src/commands/database/database.command.js +10 -0
- package/src/commands/database/database.docs.md +52 -0
- package/src/commands/delete/delete.command.js +43 -0
- package/src/commands/delete/delete.docs.md +17 -0
- package/src/commands/deploy/deploy.command.js +166 -0
- package/src/commands/deploy/deploy.docs.md +22 -0
- package/src/commands/diag/diag.command.js +136 -0
- package/src/commands/diag/diag.docs.md +15 -0
- package/src/commands/domain/domain.add.command.js +25 -0
- package/src/commands/domain/domain.args.js +8 -0
- package/src/commands/domain/domain.command.js +38 -0
- package/src/commands/domain/domain.diag.command.js +204 -0
- package/src/commands/domain/domain.docs.md +143 -0
- package/src/commands/domain/domain.favourite.command.js +35 -0
- package/src/commands/domain/domain.favourite.set.command.js +24 -0
- package/src/commands/domain/domain.favourite.unset.command.js +23 -0
- package/src/commands/domain/domain.overview.command.js +157 -0
- package/src/commands/domain/domain.rm.command.js +25 -0
- package/src/commands/drain/drain.args.js +8 -0
- package/src/commands/drain/drain.command.js +56 -0
- package/src/commands/drain/drain.create.command.js +128 -0
- package/src/commands/drain/drain.disable.command.js +27 -0
- package/src/commands/drain/drain.docs.md +129 -0
- package/src/commands/drain/drain.enable.command.js +27 -0
- package/src/commands/drain/drain.get.command.js +38 -0
- package/src/commands/drain/drain.remove.command.js +26 -0
- package/src/commands/emails/emails.add.command.js +32 -0
- package/src/commands/emails/emails.args.js +8 -0
- package/src/commands/emails/emails.command.js +35 -0
- package/src/commands/emails/emails.docs.md +79 -0
- package/src/commands/emails/emails.open.command.js +15 -0
- package/src/commands/emails/emails.primary.command.js +29 -0
- package/src/commands/emails/emails.remove-all.command.js +54 -0
- package/src/commands/emails/emails.remove.command.js +25 -0
- package/src/commands/env/env.command.js +77 -0
- package/src/commands/env/env.docs.md +99 -0
- package/src/commands/env/env.import-vars.command.js +45 -0
- package/src/commands/env/env.import.command.js +29 -0
- package/src/commands/env/env.rm.command.js +25 -0
- package/src/commands/env/env.set.command.js +32 -0
- package/src/commands/features/features.args.js +9 -0
- package/src/commands/features/features.command.js +7 -0
- package/src/commands/features/features.disable.command.js +25 -0
- package/src/commands/features/features.docs.md +71 -0
- package/src/commands/features/features.enable.command.js +32 -0
- package/src/commands/features/features.info.command.js +27 -0
- package/src/commands/features/features.list.command.js +49 -0
- package/src/commands/global.args.js +45 -0
- package/src/commands/global.commands.js +461 -0
- package/src/commands/global.options.js +186 -0
- package/src/commands/help/help.command.js +9 -0
- package/src/commands/help/help.docs.md +9 -0
- package/src/commands/k8s/k8s.add-persistent-storage.command.js +39 -0
- package/src/commands/k8s/k8s.args.js +9 -0
- package/src/commands/k8s/k8s.command.js +12 -0
- package/src/commands/k8s/k8s.create.command.js +86 -0
- package/src/commands/k8s/k8s.delete.command.js +40 -0
- package/src/commands/k8s/k8s.docs.md +131 -0
- package/src/commands/k8s/k8s.get-kubeconfig.command.js +32 -0
- package/src/commands/k8s/k8s.get.command.js +43 -0
- package/src/commands/k8s/k8s.list.command.js +38 -0
- package/src/commands/keycloak/keycloak.command.js +17 -0
- package/src/commands/keycloak/keycloak.disable-ng.command.js +13 -0
- package/src/commands/keycloak/keycloak.docs.md +197 -0
- package/src/commands/keycloak/keycloak.enable-ng.command.js +13 -0
- package/src/commands/keycloak/keycloak.get.command.js +17 -0
- package/src/commands/keycloak/keycloak.open.command.js +13 -0
- package/src/commands/keycloak/keycloak.open.logs.command.js +13 -0
- package/src/commands/keycloak/keycloak.open.webui.command.js +13 -0
- package/src/commands/keycloak/keycloak.rebuild.command.js +13 -0
- package/src/commands/keycloak/keycloak.restart.command.js +13 -0
- package/src/commands/keycloak/keycloak.version.check.command.js +17 -0
- package/src/commands/keycloak/keycloak.version.command.js +17 -0
- package/src/commands/keycloak/keycloak.version.update.command.js +17 -0
- package/src/commands/kv/kv.command.js +99 -0
- package/src/commands/kv/kv.docs.md +27 -0
- package/src/commands/link/link.command.js +31 -0
- package/src/commands/link/link.docs.md +22 -0
- package/src/commands/{login.js → login/login.command.js} +44 -22
- package/src/commands/login/login.docs.md +16 -0
- package/src/commands/logout/logout.command.js +15 -0
- package/src/commands/logout/logout.docs.md +9 -0
- package/src/commands/logs/logs.command.js +81 -0
- package/src/commands/logs/logs.docs.md +22 -0
- package/src/commands/make-default/make-default.command.js +17 -0
- package/src/commands/make-default/make-default.docs.md +15 -0
- package/src/commands/matomo/matomo.command.js +17 -0
- package/src/commands/matomo/matomo.docs.md +109 -0
- package/src/commands/matomo/matomo.get.command.js +17 -0
- package/src/commands/matomo/matomo.open.command.js +13 -0
- package/src/commands/matomo/matomo.open.logs.command.js +13 -0
- package/src/commands/matomo/matomo.open.webui.command.js +13 -0
- package/src/commands/matomo/matomo.rebuild.command.js +13 -0
- package/src/commands/matomo/matomo.restart.command.js +13 -0
- package/src/commands/metabase/metabase.command.js +17 -0
- package/src/commands/metabase/metabase.docs.md +169 -0
- package/src/commands/metabase/metabase.get.command.js +17 -0
- package/src/commands/metabase/metabase.open.command.js +13 -0
- package/src/commands/metabase/metabase.open.logs.command.js +13 -0
- package/src/commands/metabase/metabase.open.webui.command.js +13 -0
- package/src/commands/metabase/metabase.rebuild.command.js +13 -0
- package/src/commands/metabase/metabase.restart.command.js +13 -0
- package/src/commands/metabase/metabase.version.check.command.js +17 -0
- package/src/commands/metabase/metabase.version.command.js +17 -0
- package/src/commands/metabase/metabase.version.update.command.js +17 -0
- package/src/commands/ng/ng.args.js +27 -0
- package/src/commands/ng/ng.command.js +45 -0
- package/src/commands/ng/ng.create.command.js +60 -0
- package/src/commands/ng/ng.create.external.command.js +44 -0
- package/src/commands/ng/ng.delete.command.js +22 -0
- package/src/commands/ng/ng.delete.external.command.js +25 -0
- package/src/commands/ng/ng.docs.md +214 -0
- package/src/commands/ng/ng.get-config.command.js +32 -0
- package/src/commands/ng/ng.get.command.js +22 -0
- package/src/commands/ng/ng.link.command.js +25 -0
- package/src/commands/ng/ng.options.js +9 -0
- package/src/commands/ng/ng.search.command.js +22 -0
- package/src/commands/ng/ng.unlink.command.js +25 -0
- package/src/commands/notify-email/notify-email.add.command.js +65 -0
- package/src/commands/notify-email/notify-email.command.js +61 -0
- package/src/commands/notify-email/notify-email.docs.md +60 -0
- package/src/commands/notify-email/notify-email.remove.command.js +24 -0
- package/src/commands/open/open.command.js +24 -0
- package/src/commands/open/open.docs.md +16 -0
- package/src/commands/otoroshi/otoroshi.command.js +17 -0
- package/src/commands/otoroshi/otoroshi.disable-ng.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.docs.md +211 -0
- package/src/commands/otoroshi/otoroshi.enable-ng.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.get-config.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.get.command.js +17 -0
- package/src/commands/otoroshi/otoroshi.open.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.open.logs.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.open.webui.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.rebuild.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.restart.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.version.check.command.js +17 -0
- package/src/commands/otoroshi/otoroshi.version.command.js +17 -0
- package/src/commands/otoroshi/otoroshi.version.update.command.js +17 -0
- package/src/commands/profile/profile.command.js +60 -0
- package/src/commands/profile/profile.docs.md +23 -0
- package/src/commands/profile/profile.open.command.js +12 -0
- package/src/commands/published-config/published-config.command.js +40 -0
- package/src/commands/published-config/published-config.docs.md +77 -0
- package/src/commands/published-config/published-config.import.command.js +29 -0
- package/src/commands/published-config/published-config.rm.command.js +27 -0
- package/src/commands/published-config/published-config.set.command.js +34 -0
- package/src/commands/restart/restart.command.js +77 -0
- package/src/commands/restart/restart.docs.md +21 -0
- package/src/commands/scale/scale.command.js +121 -0
- package/src/commands/scale/scale.docs.md +23 -0
- package/src/commands/service/service.command.js +91 -0
- package/src/commands/service/service.docs.md +104 -0
- package/src/commands/service/service.link-addon.command.js +24 -0
- package/src/commands/service/service.link-app.command.js +23 -0
- package/src/commands/service/service.unlink-addon.command.js +24 -0
- package/src/commands/service/service.unlink-app.command.js +23 -0
- package/src/commands/ssh/ssh.command.js +40 -0
- package/src/commands/ssh/ssh.docs.md +17 -0
- package/src/commands/ssh-keys/ssh-keys.add.command.js +41 -0
- package/src/commands/ssh-keys/ssh-keys.args.js +8 -0
- package/src/commands/ssh-keys/ssh-keys.command.js +50 -0
- package/src/commands/ssh-keys/ssh-keys.docs.md +66 -0
- package/src/commands/ssh-keys/ssh-keys.open.command.js +12 -0
- package/src/commands/ssh-keys/ssh-keys.remove-all.command.js +54 -0
- package/src/commands/ssh-keys/ssh-keys.remove.command.js +26 -0
- package/src/commands/status/status.command.js +122 -0
- package/src/commands/status/status.docs.md +17 -0
- package/src/commands/stop/stop.command.js +23 -0
- package/src/commands/stop/stop.docs.md +16 -0
- package/src/commands/tcp-redirs/tcp-redirs.add.command.js +24 -0
- package/src/commands/tcp-redirs/tcp-redirs.command.js +41 -0
- package/src/commands/tcp-redirs/tcp-redirs.docs.md +71 -0
- package/src/commands/tcp-redirs/tcp-redirs.list-namespaces.command.js +48 -0
- package/src/commands/tcp-redirs/tcp-redirs.options.js +11 -0
- package/src/commands/tcp-redirs/tcp-redirs.remove.command.js +34 -0
- package/src/commands/tokens/tokens.command.js +43 -0
- package/src/commands/tokens/tokens.create.command.js +108 -0
- package/src/commands/tokens/tokens.docs.md +50 -0
- package/src/commands/tokens/tokens.revoke.command.js +25 -0
- package/src/commands/unlink/unlink.command.js +21 -0
- package/src/commands/unlink/unlink.docs.md +15 -0
- package/src/commands/version/version.command.js +13 -0
- package/src/commands/version/version.docs.md +9 -0
- package/src/commands/webhooks/webhooks.add.command.js +51 -0
- package/src/commands/webhooks/webhooks.command.js +57 -0
- package/src/commands/webhooks/webhooks.docs.md +61 -0
- package/src/commands/webhooks/webhooks.remove.command.js +24 -0
- package/src/lib/cliparse-patched.js +192 -0
- package/src/lib/define-argument.js +7 -0
- package/src/lib/define-argument.types.d.ts +23 -0
- package/src/lib/define-command.js +7 -0
- package/src/lib/define-command.types.d.ts +85 -0
- package/src/lib/define-common.types.d.ts +18 -0
- package/src/lib/define-option.js +7 -0
- package/src/lib/define-option.types.d.ts +29 -0
- package/src/lib/get-command-info.js +86 -0
- package/src/lib/get-command-info.types.d.ts +42 -0
- package/src/lib/k8s.js +1 -1
- package/src/lib/zod-utils.js +66 -0
- package/src/models/addon.js +2 -19
- package/src/models/app_configuration.js +0 -30
- package/src/models/application.js +4 -5
- package/src/models/application_configuration.js +5 -23
- package/src/models/domain.js +34 -2
- package/src/models/exit-strategy-option.js +0 -9
- package/src/models/git.js +1 -4
- package/src/models/log-v4.js +15 -4
- package/src/models/log.js +5 -0
- package/src/models/namespaces.js +1 -2
- package/src/models/notification.js +1 -7
- package/src/parsers.js +33 -111
- package/src/command-options.js +0 -55
- package/src/command-promise-handler.js +0 -16
- package/src/commands/accesslogs.js +0 -138
- package/src/commands/addon.js +0 -391
- package/src/commands/applications.js +0 -123
- package/src/commands/cancel-deploy.js +0 -19
- package/src/commands/config.js +0 -47
- package/src/commands/console.js +0 -20
- package/src/commands/create.js +0 -129
- package/src/commands/database.js +0 -73
- package/src/commands/delete.js +0 -24
- package/src/commands/deploy.js +0 -133
- package/src/commands/diag.js +0 -126
- package/src/commands/domain.js +0 -445
- package/src/commands/drain.js +0 -164
- package/src/commands/emails.js +0 -156
- package/src/commands/env.js +0 -124
- package/src/commands/features.js +0 -87
- package/src/commands/k8s.js +0 -193
- package/src/commands/keycloak.js +0 -138
- package/src/commands/kv.js +0 -93
- package/src/commands/link.js +0 -20
- package/src/commands/logout.js +0 -8
- package/src/commands/logs.js +0 -45
- package/src/commands/makeDefault.js +0 -11
- package/src/commands/matomo.js +0 -85
- package/src/commands/metabase.js +0 -112
- package/src/commands/ng.js +0 -202
- package/src/commands/notify-email.js +0 -99
- package/src/commands/open.js +0 -13
- package/src/commands/otoroshi.js +0 -150
- package/src/commands/profile.js +0 -55
- package/src/commands/published-config.js +0 -70
- package/src/commands/restart.js +0 -52
- package/src/commands/scale.js +0 -66
- package/src/commands/service.js +0 -105
- package/src/commands/ssh-keys.js +0 -144
- package/src/commands/ssh.js +0 -20
- package/src/commands/status.js +0 -115
- package/src/commands/stop.js +0 -12
- package/src/commands/tcp-redirs.js +0 -80
- package/src/commands/tokens.js +0 -144
- package/src/commands/unlink.js +0 -14
- package/src/commands/version.js +0 -6
- package/src/commands/webhooks.js +0 -74
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
3
|
+
import { defineOption } from '../../lib/define-option.js';
|
|
4
|
+
import { styleText } from '../../lib/style-text.js';
|
|
5
|
+
import { Logger } from '../../logger.js';
|
|
6
|
+
import * as AppConfig from '../../models/app_configuration.js';
|
|
7
|
+
|
|
8
|
+
function formatApps(apps, onlyAliases, json) {
|
|
9
|
+
if (json) {
|
|
10
|
+
if (onlyAliases) {
|
|
11
|
+
apps = apps.map((a) => a.alias);
|
|
12
|
+
}
|
|
13
|
+
return JSON.stringify(apps, null, 2);
|
|
14
|
+
} else {
|
|
15
|
+
if (onlyAliases) {
|
|
16
|
+
return apps.map((a) => a.alias).join('\n');
|
|
17
|
+
} else {
|
|
18
|
+
return apps
|
|
19
|
+
.map((app) => {
|
|
20
|
+
const sshUrl = app.git_ssh_url ?? app.deploy_url.replace('https://', 'git+ssh://git@');
|
|
21
|
+
return [
|
|
22
|
+
`Application ${app.name}`,
|
|
23
|
+
` alias: ${styleText('bold', app.alias)}`,
|
|
24
|
+
` ID: ${app.app_id}`,
|
|
25
|
+
` deployment URL: ${app.deploy_url}`,
|
|
26
|
+
` git+ssh URL: ${sshUrl}`,
|
|
27
|
+
].join('\n');
|
|
28
|
+
})
|
|
29
|
+
.join('\n\n');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const applicationsCommand = defineCommand({
|
|
35
|
+
description: 'List linked applications',
|
|
36
|
+
since: '0.3.0',
|
|
37
|
+
options: {
|
|
38
|
+
onlyAliases: defineOption({
|
|
39
|
+
name: 'only-aliases',
|
|
40
|
+
schema: z.boolean().default(false),
|
|
41
|
+
description: 'List only application aliases',
|
|
42
|
+
}),
|
|
43
|
+
json: defineOption({
|
|
44
|
+
name: 'json',
|
|
45
|
+
schema: z.boolean().default(false),
|
|
46
|
+
description: 'Show result in JSON format',
|
|
47
|
+
aliases: ['j'],
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
args: [],
|
|
51
|
+
async handler(options) {
|
|
52
|
+
const { onlyAliases, json } = options;
|
|
53
|
+
|
|
54
|
+
const { apps } = await AppConfig.loadApplicationConf();
|
|
55
|
+
|
|
56
|
+
const formattedApps = formatApps(apps, onlyAliases, json);
|
|
57
|
+
Logger.println(formattedApps);
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# 📖 `clever applications` command reference
|
|
2
|
+
|
|
3
|
+
## ➡️ `clever applications` <kbd>Since 0.3.0</kbd>
|
|
4
|
+
|
|
5
|
+
List linked applications
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
clever applications [options]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### ⚙️ Options
|
|
12
|
+
|
|
13
|
+
|Name|Description|
|
|
14
|
+
|---|---|
|
|
15
|
+
|`-j`, `--json`|Show result in JSON format|
|
|
16
|
+
|`--only-aliases`|List only application aliases|
|
|
17
|
+
|
|
18
|
+
## ➡️ `clever applications list` <kbd>Since 3.8.0</kbd>
|
|
19
|
+
|
|
20
|
+
List all applications
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
clever applications list [options]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### ⚙️ Options
|
|
27
|
+
|
|
28
|
+
|Name|Description|
|
|
29
|
+
|---|---|
|
|
30
|
+
|`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
|
|
31
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { formatTable } from '../../format-table.js';
|
|
2
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
3
|
+
import { styleText } from '../../lib/style-text.js';
|
|
4
|
+
import { Logger } from '../../logger.js';
|
|
5
|
+
import * as AppConfig from '../../models/app_configuration.js';
|
|
6
|
+
import * as Application from '../../models/application.js';
|
|
7
|
+
import * as Organisation from '../../models/organisation.js';
|
|
8
|
+
import { truncateWithEllipsis } from '../../models/utils.js';
|
|
9
|
+
import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
|
|
10
|
+
|
|
11
|
+
function getPropertyMaxWidth(array, propertyName) {
|
|
12
|
+
return Math.max(...array.map((o) => o[propertyName].length));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const applicationsListCommand = defineCommand({
|
|
16
|
+
description: 'List all applications',
|
|
17
|
+
since: '3.8.0',
|
|
18
|
+
options: {
|
|
19
|
+
org: orgaIdOrNameOption,
|
|
20
|
+
format: humanJsonOutputFormatOption,
|
|
21
|
+
},
|
|
22
|
+
args: [],
|
|
23
|
+
async handler(options) {
|
|
24
|
+
const { org: orgaIdOrName, format } = options;
|
|
25
|
+
|
|
26
|
+
const linkedApps = await AppConfig.loadApplicationConf().then((conf) => conf.apps);
|
|
27
|
+
|
|
28
|
+
const ownerId =
|
|
29
|
+
orgaIdOrName != null && orgaIdOrName.orga_name !== '' ? await Organisation.getId(orgaIdOrName) : null;
|
|
30
|
+
|
|
31
|
+
const allAppsPerOrg = await Application.getAllApps(ownerId);
|
|
32
|
+
|
|
33
|
+
// For each app, we try to find a corresponding local alias in the configuration file
|
|
34
|
+
const allAppsWithAliasPerOrg = allAppsPerOrg.map((org) => {
|
|
35
|
+
const applicationsWithAlias = org.applications.map((app) => {
|
|
36
|
+
const foundAlias = linkedApps.find((a) => a.app_id === app.app_id)?.alias;
|
|
37
|
+
return { ...app, alias: foundAlias ?? '' };
|
|
38
|
+
});
|
|
39
|
+
return { ...org, applications: applicationsWithAlias };
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
switch (format) {
|
|
43
|
+
case 'json': {
|
|
44
|
+
Logger.printJson(allAppsWithAliasPerOrg);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case 'human':
|
|
48
|
+
default: {
|
|
49
|
+
const headers = ['APPLICATION ID', 'NAME', 'TYPE', 'ZONE', 'LOCAL ALIAS'];
|
|
50
|
+
const appNameWidth = 42;
|
|
51
|
+
|
|
52
|
+
// We calculate the maximum width of each column to format the table
|
|
53
|
+
const allApps = allAppsWithAliasPerOrg.flatMap((org) => org.applications);
|
|
54
|
+
const columnWidths = [
|
|
55
|
+
getPropertyMaxWidth(allApps, 'app_id'),
|
|
56
|
+
appNameWidth,
|
|
57
|
+
getPropertyMaxWidth(allApps, 'type'),
|
|
58
|
+
getPropertyMaxWidth(allApps, 'zone'),
|
|
59
|
+
getPropertyMaxWidth(allApps, 'alias'),
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
allAppsWithAliasPerOrg.forEach((org) => {
|
|
63
|
+
Logger.println();
|
|
64
|
+
|
|
65
|
+
const applicationsPlural = org.applications.length !== 1 ? 'applications' : 'application';
|
|
66
|
+
const punctuation = org.applications.length > 0 ? ':' : '';
|
|
67
|
+
|
|
68
|
+
Logger.println(
|
|
69
|
+
styleText(
|
|
70
|
+
'blue',
|
|
71
|
+
`• Organization '${org.name}' (${org.id}) with ${org.applications.length} ${applicationsPlural}${punctuation}`,
|
|
72
|
+
),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (org.applications.length > 0) {
|
|
76
|
+
Logger.println();
|
|
77
|
+
Logger.println(
|
|
78
|
+
formatTable(
|
|
79
|
+
[
|
|
80
|
+
headers,
|
|
81
|
+
...org.applications.map((app) => [
|
|
82
|
+
app.app_id,
|
|
83
|
+
truncateWithEllipsis(appNameWidth, app.name),
|
|
84
|
+
app.type,
|
|
85
|
+
app.zone,
|
|
86
|
+
app.alias,
|
|
87
|
+
]),
|
|
88
|
+
],
|
|
89
|
+
|
|
90
|
+
columnWidths,
|
|
91
|
+
),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cancelDeployment, getAllDeployments } from '@clevercloud/client/esm/api/v2/application.js';
|
|
2
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
3
|
+
import { styleText } from '../../lib/style-text.js';
|
|
4
|
+
import { Logger } from '../../logger.js';
|
|
5
|
+
import * as Application from '../../models/application.js';
|
|
6
|
+
import { sendToApi } from '../../models/send-to-api.js';
|
|
7
|
+
import { aliasOption, appIdOrNameOption } from '../global.options.js';
|
|
8
|
+
|
|
9
|
+
export const cancelDeployCommand = defineCommand({
|
|
10
|
+
description: 'Cancel an ongoing deployment',
|
|
11
|
+
since: '0.2.0',
|
|
12
|
+
options: {
|
|
13
|
+
alias: aliasOption,
|
|
14
|
+
app: appIdOrNameOption,
|
|
15
|
+
},
|
|
16
|
+
args: [],
|
|
17
|
+
async handler(options) {
|
|
18
|
+
const { alias, app: appIdOrName } = options;
|
|
19
|
+
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
20
|
+
|
|
21
|
+
const deployments = await getAllDeployments({ id: ownerId, appId, limit: 1 }).then(sendToApi);
|
|
22
|
+
|
|
23
|
+
if (deployments.length === 0 || deployments[0].action !== 'DEPLOY' || deployments[0].state !== 'WIP') {
|
|
24
|
+
throw new Error('There is no ongoing deployment for this application');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
await cancelDeployment({ id: ownerId, appId, deploymentId: deployments[0].id }).then(sendToApi);
|
|
28
|
+
Logger.printSuccess(`Deployment ${styleText(['bold', 'green'], deployments[0].uuid)} successfully cancelled!`);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# 📖 `clever cancel-deploy` command reference
|
|
2
|
+
|
|
3
|
+
## ➡️ `clever cancel-deploy` <kbd>Since 0.2.0</kbd>
|
|
4
|
+
|
|
5
|
+
Cancel an ongoing deployment
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
clever cancel-deploy [options]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### ⚙️ Options
|
|
12
|
+
|
|
13
|
+
|Name|Description|
|
|
14
|
+
|---|---|
|
|
15
|
+
|`-a`, `--alias` `<alias>`|Short name for the application|
|
|
16
|
+
|`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineArgument } from '../../lib/define-argument.js';
|
|
3
|
+
import { listAvailableIds } from '../../models/application_configuration.js';
|
|
4
|
+
|
|
5
|
+
export const configurationNameArg = defineArgument({
|
|
6
|
+
schema: z.string(),
|
|
7
|
+
description: `Configuration to manage: ${listAvailableIds(true)}`,
|
|
8
|
+
placeholder: 'configuration-name',
|
|
9
|
+
complete: listAvailableIds,
|
|
10
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import * as Application from '../../models/application.js';
|
|
3
|
+
import * as ApplicationConfiguration from '../../models/application_configuration.js';
|
|
4
|
+
import { aliasOption, appIdOrNameOption } from '../global.options.js';
|
|
5
|
+
|
|
6
|
+
export const configCommand = defineCommand({
|
|
7
|
+
description: 'Display or edit the configuration of your application',
|
|
8
|
+
since: '2.5.0',
|
|
9
|
+
options: {
|
|
10
|
+
alias: aliasOption,
|
|
11
|
+
app: appIdOrNameOption,
|
|
12
|
+
},
|
|
13
|
+
args: [],
|
|
14
|
+
async handler(options) {
|
|
15
|
+
const { alias, app: appIdOrName } = options;
|
|
16
|
+
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
17
|
+
const app = await Application.get(ownerId, appId);
|
|
18
|
+
ApplicationConfiguration.printAllValues(app);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# 📖 `clever config` command reference
|
|
2
|
+
|
|
3
|
+
## ➡️ `clever config` <kbd>Since 2.5.0</kbd>
|
|
4
|
+
|
|
5
|
+
Display or edit the configuration of your application
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
clever config [options]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### ⚙️ Options
|
|
12
|
+
|
|
13
|
+
|Name|Description|
|
|
14
|
+
|---|---|
|
|
15
|
+
|`-a`, `--alias` `<alias>`|Short name for the application|
|
|
16
|
+
|`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
|
|
17
|
+
|
|
18
|
+
## ➡️ `clever config get` <kbd>Since 2.5.0</kbd>
|
|
19
|
+
|
|
20
|
+
Display the current configuration
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
clever config get <configuration-name> [options]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 📥 Arguments
|
|
27
|
+
|
|
28
|
+
|Name|Description|
|
|
29
|
+
|---|---|
|
|
30
|
+
|`configuration-name`|Configuration to manage: name, description, zero-downtime, sticky-sessions, cancel-on-push, force-https, or task|
|
|
31
|
+
|
|
32
|
+
### ⚙️ Options
|
|
33
|
+
|
|
34
|
+
|Name|Description|
|
|
35
|
+
|---|---|
|
|
36
|
+
|`-a`, `--alias` `<alias>`|Short name for the application|
|
|
37
|
+
|`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
|
|
38
|
+
|
|
39
|
+
## ➡️ `clever config set` <kbd>Since 2.5.0</kbd>
|
|
40
|
+
|
|
41
|
+
Edit one configuration setting
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
clever config set <configuration-name> <configuration-value> [options]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 📥 Arguments
|
|
48
|
+
|
|
49
|
+
|Name|Description|
|
|
50
|
+
|---|---|
|
|
51
|
+
|`configuration-name`|Configuration to manage: name, description, zero-downtime, sticky-sessions, cancel-on-push, force-https, or task|
|
|
52
|
+
|`configuration-value`|The new value of the configuration|
|
|
53
|
+
|
|
54
|
+
### ⚙️ Options
|
|
55
|
+
|
|
56
|
+
|Name|Description|
|
|
57
|
+
|---|---|
|
|
58
|
+
|`-a`, `--alias` `<alias>`|Short name for the application|
|
|
59
|
+
|`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
|
|
60
|
+
|
|
61
|
+
## ➡️ `clever config update` <kbd>Since 2.5.0</kbd>
|
|
62
|
+
|
|
63
|
+
Edit multiple configuration settings at once
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
clever config update [options]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### ⚙️ Options
|
|
70
|
+
|
|
71
|
+
|Name|Description|
|
|
72
|
+
|---|---|
|
|
73
|
+
|`-a`, `--alias` `<alias>`|Short name for the application|
|
|
74
|
+
|`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
|
|
75
|
+
|`--description` `<description>`|Set application description|
|
|
76
|
+
|`--disable-cancel-on-push`|Disable cancel on push|
|
|
77
|
+
|`--disable-force-https`|Disable force HTTPS redirection|
|
|
78
|
+
|`--disable-sticky-sessions`|Disable sticky sessions|
|
|
79
|
+
|`--disable-task`|Disable application as Clever Task|
|
|
80
|
+
|`--disable-zero-downtime`|Disable zero-downtime deployment|
|
|
81
|
+
|`--enable-cancel-on-push`|Enable cancel on push|
|
|
82
|
+
|`--enable-force-https`|Enable force HTTPS redirection|
|
|
83
|
+
|`--enable-sticky-sessions`|Enable sticky sessions|
|
|
84
|
+
|`--enable-task`|Enable application as Clever Task|
|
|
85
|
+
|`--enable-zero-downtime`|Enable zero-downtime deployment|
|
|
86
|
+
|`--name` `<name>`|Set application name|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import * as Application from '../../models/application.js';
|
|
3
|
+
import * as ApplicationConfiguration from '../../models/application_configuration.js';
|
|
4
|
+
import { aliasOption, appIdOrNameOption } from '../global.options.js';
|
|
5
|
+
import { configurationNameArg } from './config.args.js';
|
|
6
|
+
|
|
7
|
+
export const configGetCommand = defineCommand({
|
|
8
|
+
description: 'Display the current configuration',
|
|
9
|
+
since: '2.5.0',
|
|
10
|
+
options: {
|
|
11
|
+
alias: aliasOption,
|
|
12
|
+
app: appIdOrNameOption,
|
|
13
|
+
},
|
|
14
|
+
args: [configurationNameArg],
|
|
15
|
+
async handler(options, configurationName) {
|
|
16
|
+
const { alias, app: appIdOrName } = options;
|
|
17
|
+
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
18
|
+
const app = await Application.get(ownerId, appId);
|
|
19
|
+
ApplicationConfiguration.printValue(app, configurationName);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineArgument } from '../../lib/define-argument.js';
|
|
3
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
4
|
+
import { styleText } from '../../lib/style-text.js';
|
|
5
|
+
import { Logger } from '../../logger.js';
|
|
6
|
+
import * as Application from '../../models/application.js';
|
|
7
|
+
import * as ApplicationConfiguration from '../../models/application_configuration.js';
|
|
8
|
+
import { aliasOption, appIdOrNameOption } from '../global.options.js';
|
|
9
|
+
import { configurationNameArg } from './config.args.js';
|
|
10
|
+
|
|
11
|
+
export const configSetCommand = defineCommand({
|
|
12
|
+
description: 'Edit one configuration setting',
|
|
13
|
+
since: '2.5.0',
|
|
14
|
+
options: {
|
|
15
|
+
alias: aliasOption,
|
|
16
|
+
app: appIdOrNameOption,
|
|
17
|
+
},
|
|
18
|
+
args: [
|
|
19
|
+
configurationNameArg,
|
|
20
|
+
defineArgument({
|
|
21
|
+
schema: z.string(),
|
|
22
|
+
description: 'The new value of the configuration',
|
|
23
|
+
placeholder: 'configuration-value',
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
async handler(options, configurationName, configurationValue) {
|
|
27
|
+
const { alias, app: appIdOrName } = options;
|
|
28
|
+
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
29
|
+
const config = ApplicationConfiguration.getById(configurationName);
|
|
30
|
+
const newOptions = {
|
|
31
|
+
[config.name]: ApplicationConfiguration.parse(config, configurationValue),
|
|
32
|
+
};
|
|
33
|
+
const app = await Application.updateOptions(ownerId, appId, newOptions);
|
|
34
|
+
Logger.printSuccess(
|
|
35
|
+
`Config ${styleText('green', config.id)} successfully updated to ${styleText('green', ApplicationConfiguration.formatValue(config, app[config.name]).toString())}!`,
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
3
|
+
import { defineOption } from '../../lib/define-option.js';
|
|
4
|
+
import * as Application from '../../models/application.js';
|
|
5
|
+
import * as ApplicationConfiguration from '../../models/application_configuration.js';
|
|
6
|
+
import { aliasOption, appIdOrNameOption } from '../global.options.js';
|
|
7
|
+
|
|
8
|
+
export const configUpdateCommand = defineCommand({
|
|
9
|
+
description: 'Edit multiple configuration settings at once',
|
|
10
|
+
since: '2.5.0',
|
|
11
|
+
options: {
|
|
12
|
+
alias: aliasOption,
|
|
13
|
+
appIdOrName: appIdOrNameOption,
|
|
14
|
+
name: defineOption({
|
|
15
|
+
name: 'name',
|
|
16
|
+
schema: z.string().optional(),
|
|
17
|
+
description: 'Set application name',
|
|
18
|
+
}),
|
|
19
|
+
description: defineOption({
|
|
20
|
+
name: 'description',
|
|
21
|
+
schema: z.string().optional(),
|
|
22
|
+
description: 'Set application description',
|
|
23
|
+
}),
|
|
24
|
+
enableZeroDowntime: defineOption({
|
|
25
|
+
name: 'enable-zero-downtime',
|
|
26
|
+
schema: z.boolean().default(false),
|
|
27
|
+
description: 'Enable zero-downtime deployment',
|
|
28
|
+
}),
|
|
29
|
+
disableZeroDowntime: defineOption({
|
|
30
|
+
name: 'disable-zero-downtime',
|
|
31
|
+
schema: z.boolean().default(false),
|
|
32
|
+
description: 'Disable zero-downtime deployment',
|
|
33
|
+
}),
|
|
34
|
+
enableStickySessions: defineOption({
|
|
35
|
+
name: 'enable-sticky-sessions',
|
|
36
|
+
schema: z.boolean().default(false),
|
|
37
|
+
description: 'Enable sticky sessions',
|
|
38
|
+
}),
|
|
39
|
+
disableStickySessions: defineOption({
|
|
40
|
+
name: 'disable-sticky-sessions',
|
|
41
|
+
schema: z.boolean().default(false),
|
|
42
|
+
description: 'Disable sticky sessions',
|
|
43
|
+
}),
|
|
44
|
+
enableCancelOnPush: defineOption({
|
|
45
|
+
name: 'enable-cancel-on-push',
|
|
46
|
+
schema: z.boolean().default(false),
|
|
47
|
+
description: 'Enable cancel on push',
|
|
48
|
+
}),
|
|
49
|
+
disableCancelOnPush: defineOption({
|
|
50
|
+
name: 'disable-cancel-on-push',
|
|
51
|
+
schema: z.boolean().default(false),
|
|
52
|
+
description: 'Disable cancel on push',
|
|
53
|
+
}),
|
|
54
|
+
enableForceHttps: defineOption({
|
|
55
|
+
name: 'enable-force-https',
|
|
56
|
+
schema: z.boolean().default(false),
|
|
57
|
+
description: 'Enable force HTTPS redirection',
|
|
58
|
+
}),
|
|
59
|
+
disableForceHttps: defineOption({
|
|
60
|
+
name: 'disable-force-https',
|
|
61
|
+
schema: z.boolean().default(false),
|
|
62
|
+
description: 'Disable force HTTPS redirection',
|
|
63
|
+
}),
|
|
64
|
+
enableTask: defineOption({
|
|
65
|
+
name: 'enable-task',
|
|
66
|
+
schema: z.boolean().default(false),
|
|
67
|
+
description: 'Enable application as Clever Task',
|
|
68
|
+
}),
|
|
69
|
+
disableTask: defineOption({
|
|
70
|
+
name: 'disable-task',
|
|
71
|
+
schema: z.boolean().default(false),
|
|
72
|
+
description: 'Disable application as Clever Task',
|
|
73
|
+
}),
|
|
74
|
+
},
|
|
75
|
+
async handler(options) {
|
|
76
|
+
const { alias, appIdOrName, ...rawOptions } = options;
|
|
77
|
+
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
78
|
+
const newOptions = ApplicationConfiguration.parseOptions(rawOptions);
|
|
79
|
+
|
|
80
|
+
if (Object.keys(newOptions).length === 0) {
|
|
81
|
+
throw new Error('No configuration to update');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const app = await Application.updateOptions(ownerId, appId, newOptions);
|
|
85
|
+
|
|
86
|
+
ApplicationConfiguration.printAllValues(app);
|
|
87
|
+
},
|
|
88
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import * as AppConfig from '../../models/app_configuration.js';
|
|
3
|
+
import * as Application from '../../models/application.js';
|
|
4
|
+
import { openBrowser } from '../../models/utils.js';
|
|
5
|
+
import { aliasOption, appIdOrNameOption } from '../global.options.js';
|
|
6
|
+
|
|
7
|
+
export const consoleCommand = defineCommand({
|
|
8
|
+
description: 'Open an application in the Console',
|
|
9
|
+
since: '1.0.0',
|
|
10
|
+
options: {
|
|
11
|
+
alias: aliasOption,
|
|
12
|
+
app: appIdOrNameOption,
|
|
13
|
+
},
|
|
14
|
+
args: [],
|
|
15
|
+
async handler(options) {
|
|
16
|
+
const { alias, app: appIdOrName } = options;
|
|
17
|
+
|
|
18
|
+
const { apps } = await AppConfig.loadApplicationConf();
|
|
19
|
+
// If no app is linked or asked, open the Console without any context
|
|
20
|
+
if (apps.length === 0 && !appIdOrName) {
|
|
21
|
+
await openBrowser('/', 'Opening the Console in your browser');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
26
|
+
const prefixPath = ownerId.startsWith('user_') ? 'users/me' : `organisations/${ownerId}`;
|
|
27
|
+
const consolePath = `/${prefixPath}/applications/${appId}`;
|
|
28
|
+
|
|
29
|
+
await openBrowser(consolePath, `Opening the Console in your browser for application ${appId}`);
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# 📖 `clever console` command reference
|
|
2
|
+
|
|
3
|
+
## ➡️ `clever console` <kbd>Since 1.0.0</kbd>
|
|
4
|
+
|
|
5
|
+
Open an application in the Console
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
clever console [options]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### ⚙️ Options
|
|
12
|
+
|
|
13
|
+
|Name|Description|
|
|
14
|
+
|---|---|
|
|
15
|
+
|`-a`, `--alias` `<alias>`|Short name for the application|
|
|
16
|
+
|`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
|