clever-tools 4.7.1 → 4.8.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 +11 -1
- package/package.json +2 -2
- package/src/clever-client/drains.js +18 -18
- package/src/commands/README.md +1 -0
- package/src/commands/accesslogs/accesslogs.command.js +2 -2
- package/src/commands/activity/activity.command.js +1 -1
- package/src/commands/addon/addon.create.command.js +2 -3
- package/src/commands/addon/addon.delete.command.js +2 -2
- package/src/commands/addon/addon.docs.md +2 -2
- package/src/commands/addon/addon.env.command.js +4 -6
- package/src/commands/config-provider/config-provider.command.js +0 -4
- package/src/commands/config-provider/config-provider.import.command.js +1 -1
- package/src/commands/config-provider/config-provider.list.command.js +8 -19
- package/src/commands/config-provider/config-provider.open.command.js +1 -1
- package/src/commands/console/console.command.js +3 -2
- package/src/commands/curl/curl.command.js +0 -1
- package/src/commands/database/database.backups.command.js +4 -7
- package/src/commands/database/database.backups.download.command.js +5 -7
- package/src/commands/database/database.command.js +0 -4
- package/src/commands/database/database.docs.md +2 -2
- package/src/commands/deploy/deploy.command.js +1 -1
- package/src/commands/deploy/deploy.docs.md +1 -1
- package/src/commands/drain/drain.command.js +14 -9
- package/src/commands/drain/drain.create.command.js +9 -13
- package/src/commands/drain/drain.disable.command.js +7 -7
- package/src/commands/drain/drain.docs.md +6 -0
- package/src/commands/drain/drain.enable.command.js +7 -7
- package/src/commands/drain/drain.get.command.js +12 -8
- package/src/commands/drain/drain.remove.command.js +7 -7
- package/src/commands/emails/emails.open.command.js +1 -4
- package/src/commands/global.commands.js +18 -0
- package/src/commands/global.options.js +7 -7
- package/src/commands/help/help.command.js +0 -3
- package/src/commands/k8s/k8s.command.js +0 -4
- package/src/commands/k8s/k8s.delete.command.js +2 -2
- package/src/commands/k8s/k8s.docs.md +1 -1
- package/src/commands/logs/logs.command.js +4 -5
- package/src/commands/ng/ng.docs.md +0 -1
- package/src/commands/ng/ng.get-config.command.js +3 -14
- package/src/commands/ng/ng.options.js +1 -1
- package/src/commands/notify-email/notify-email.remove.command.js +2 -2
- package/src/commands/oauth-consumers/oauth-consumers.args.js +8 -0
- package/src/commands/oauth-consumers/oauth-consumers.command.js +6 -0
- package/src/commands/oauth-consumers/oauth-consumers.create.command.js +64 -0
- package/src/commands/oauth-consumers/oauth-consumers.delete.command.js +33 -0
- package/src/commands/oauth-consumers/oauth-consumers.docs.md +130 -0
- package/src/commands/oauth-consumers/oauth-consumers.get.command.js +67 -0
- package/src/commands/oauth-consumers/oauth-consumers.list.command.js +34 -0
- package/src/commands/oauth-consumers/oauth-consumers.open.command.js +18 -0
- package/src/commands/oauth-consumers/oauth-consumers.options.js +48 -0
- package/src/commands/oauth-consumers/oauth-consumers.update.command.js +83 -0
- package/src/commands/open/open.command.js +1 -1
- package/src/commands/profile/profile.open.command.js +1 -1
- package/src/commands/restart/restart.docs.md +1 -1
- package/src/commands/ssh-keys/ssh-keys.open.command.js +1 -1
- package/src/commands/webhooks/webhooks.remove.command.js +2 -2
- package/src/lib/cliparse-patched.js +2 -0
- package/src/lib/get-command-info.js +3 -1
- package/src/lib/get-command-info.types.d.ts +4 -0
- package/src/lib/operator-commands.js +11 -25
- package/src/lib/print-items-by-owner.js +38 -0
- package/src/lib/prompts.js +23 -1
- package/src/lib/zod-utils.js +51 -0
- package/src/models/drain.js +17 -0
- package/src/models/ids-resolver.js +38 -20
- package/src/models/ng.js +2 -2
- package/src/models/notification.js +0 -4
- package/src/models/oauth-consumer.js +77 -0
- package/src/models/utils.js +1 -1
package/bin/clever.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { EXPERIMENTAL_FEATURES, getFeatures } from '../src/config/features.js';
|
|
18
18
|
import { cliparse } from '../src/lib/cliparse-patched.js';
|
|
19
19
|
import { styleText } from '../src/lib/style-text.js';
|
|
20
|
-
import { getDefault, isBoolean, isRequired } from '../src/lib/zod-utils.js';
|
|
20
|
+
import { getDefault, getEnumValues, isBoolean, isRequired } from '../src/lib/zod-utils.js';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @typedef {import('../src/lib/define-command.types.js').CommandDefinition} CommandDefinition
|
|
@@ -199,6 +199,11 @@ function convertOption(option) {
|
|
|
199
199
|
}
|
|
200
200
|
if (option.complete != null) {
|
|
201
201
|
cliparseConfig.complete = option.complete;
|
|
202
|
+
} else {
|
|
203
|
+
const enumValues = getEnumValues(option.schema);
|
|
204
|
+
if (enumValues != null) {
|
|
205
|
+
cliparseConfig.complete = enumValues;
|
|
206
|
+
}
|
|
202
207
|
}
|
|
203
208
|
|
|
204
209
|
// Use Zod's safeParse for validation (handles coercion, enums, refinements, etc.)
|
|
@@ -242,6 +247,11 @@ function convertArgument(arg) {
|
|
|
242
247
|
|
|
243
248
|
if (arg.complete) {
|
|
244
249
|
cliparseConfig.complete = arg.complete;
|
|
250
|
+
} else {
|
|
251
|
+
const enumValues = getEnumValues(arg.schema);
|
|
252
|
+
if (enumValues != null) {
|
|
253
|
+
cliparseConfig.complete = enumValues;
|
|
254
|
+
}
|
|
245
255
|
}
|
|
246
256
|
|
|
247
257
|
// Use Zod's safeParse for validation (handles coercion, enums, refinements, etc.)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clever-tools",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"description": "Command Line Interface for Clever Cloud.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@babel/traverse": "7.28.5",
|
|
53
|
-
"@clevercloud/client": "
|
|
53
|
+
"@clevercloud/client": "12.0.0",
|
|
54
54
|
"@inquirer/prompts": "7.8.4",
|
|
55
55
|
"char-regex": "2.0.2",
|
|
56
56
|
"cliparse": "0.5.0",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// TODO: Move this to the Clever Cloud JS Client
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* GET /v4/drains/organisations/{ownerId}/
|
|
4
|
+
* GET /v4/drains/organisations/{ownerId}/resources/{resourceId}/drains?status={status}&executionStatus={executionStatus}&executionStatusNotIn={executionStatusNotIn}
|
|
5
5
|
* @param {Object} params
|
|
6
6
|
* @param {String} params.ownerId
|
|
7
|
-
* @param {String} params.
|
|
7
|
+
* @param {String} params.resourceId
|
|
8
8
|
* @param {String} params.status
|
|
9
9
|
* @param {String} params.executionStatus
|
|
10
10
|
* @param {String} params.executionStatusNotIn
|
|
@@ -13,7 +13,7 @@ export function getDrains(params) {
|
|
|
13
13
|
// no multipath for /self or /organisations/{id}
|
|
14
14
|
return Promise.resolve({
|
|
15
15
|
method: 'get',
|
|
16
|
-
url: `/v4/drains/organisations/${params.ownerId}/
|
|
16
|
+
url: `/v4/drains/organisations/${params.ownerId}/resources/${params.resourceId}/drains`,
|
|
17
17
|
headers: { Accept: 'application/json' },
|
|
18
18
|
queryParams: {
|
|
19
19
|
status: params.status,
|
|
@@ -25,85 +25,85 @@ export function getDrains(params) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* POST /v4/drains/organisations/{ownerId}/
|
|
28
|
+
* POST /v4/drains/organisations/{ownerId}/resources/{resourceId}/drains
|
|
29
29
|
* @param {Object} params
|
|
30
30
|
* @param {String} params.ownerId
|
|
31
|
-
* @param {String} params.
|
|
31
|
+
* @param {String} params.resourceId
|
|
32
32
|
* @param {Object} params.body
|
|
33
33
|
*/
|
|
34
34
|
export function createDrain(params) {
|
|
35
35
|
// no multipath for /self or /organisations/{id}
|
|
36
36
|
return Promise.resolve({
|
|
37
37
|
method: 'post',
|
|
38
|
-
url: `/v4/drains/organisations/${params.ownerId}/
|
|
38
|
+
url: `/v4/drains/organisations/${params.ownerId}/resources/${params.resourceId}/drains`,
|
|
39
39
|
headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
|
|
40
40
|
body: params.body,
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* DELETE /v4/drains/organisations/{ownerId}/
|
|
45
|
+
* DELETE /v4/drains/organisations/{ownerId}/resources/{resourceId}/drains/{drainId}
|
|
46
46
|
* @param {Object} params
|
|
47
47
|
* @param {String} params.ownerId
|
|
48
|
-
* @param {String} params.
|
|
48
|
+
* @param {String} params.resourceId
|
|
49
49
|
* @param {String} params.drainId
|
|
50
50
|
*/
|
|
51
51
|
export function deleteDrain(params) {
|
|
52
52
|
// no multipath for /self or /organisations/{id}
|
|
53
53
|
return Promise.resolve({
|
|
54
54
|
method: 'delete',
|
|
55
|
-
url: `/v4/drains/organisations/${params.ownerId}/
|
|
55
|
+
url: `/v4/drains/organisations/${params.ownerId}/resources/${params.resourceId}/drains/${params.drainId}`,
|
|
56
56
|
headers: { Accept: 'application/json' },
|
|
57
57
|
// no body
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* GET /v4/drains/organisations/{ownerId}/
|
|
62
|
+
* GET /v4/drains/organisations/{ownerId}/resources/{resourceId}/drains/{drainId}
|
|
63
63
|
* @param {Object} params
|
|
64
64
|
* @param {String} params.ownerId
|
|
65
|
-
* @param {String} params.
|
|
65
|
+
* @param {String} params.resourceId
|
|
66
66
|
* @param {String} params.drainId
|
|
67
67
|
*/
|
|
68
68
|
export function getDrain(params) {
|
|
69
69
|
// no multipath for /self or /organisations/{id}
|
|
70
70
|
return Promise.resolve({
|
|
71
71
|
method: 'get',
|
|
72
|
-
url: `/v4/drains/organisations/${params.ownerId}/
|
|
72
|
+
url: `/v4/drains/organisations/${params.ownerId}/resources/${params.resourceId}/drains/${params.drainId}`,
|
|
73
73
|
headers: { Accept: 'application/json' },
|
|
74
74
|
// no body
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
* PUT /v4/drains/organisations/{ownerId}/
|
|
79
|
+
* PUT /v4/drains/organisations/{ownerId}/resources/{resourceId}/drains/{drainId}/disable
|
|
80
80
|
* @param {Object} params
|
|
81
81
|
* @param {String} params.ownerId
|
|
82
|
-
* @param {String} params.
|
|
82
|
+
* @param {String} params.resourceId
|
|
83
83
|
* @param {String} params.drainId
|
|
84
84
|
*/
|
|
85
85
|
export function disableDrain(params) {
|
|
86
86
|
// no multipath for /self or /organisations/{id}
|
|
87
87
|
return Promise.resolve({
|
|
88
88
|
method: 'put',
|
|
89
|
-
url: `/v4/drains/organisations/${params.ownerId}/
|
|
89
|
+
url: `/v4/drains/organisations/${params.ownerId}/resources/${params.resourceId}/drains/${params.drainId}/disable`,
|
|
90
90
|
headers: { Accept: 'application/json' },
|
|
91
91
|
// no body
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
* PUT /v4/drains/organisations/{ownerId}/
|
|
96
|
+
* PUT /v4/drains/organisations/{ownerId}/resources/{resourceId}/drains/{drainId}/enable
|
|
97
97
|
* @param {Object} params
|
|
98
98
|
* @param {String} params.ownerId
|
|
99
|
-
* @param {String} params.
|
|
99
|
+
* @param {String} params.resourceId
|
|
100
100
|
* @param {String} params.drainId
|
|
101
101
|
*/
|
|
102
102
|
export function enableDrain(params) {
|
|
103
103
|
// no multipath for /self or /organisations/{id}
|
|
104
104
|
return Promise.resolve({
|
|
105
105
|
method: 'put',
|
|
106
|
-
url: `/v4/drains/organisations/${params.ownerId}/
|
|
106
|
+
url: `/v4/drains/organisations/${params.ownerId}/resources/${params.resourceId}/drains/${params.drainId}/enable`,
|
|
107
107
|
headers: { Accept: 'application/json' },
|
|
108
108
|
// no body
|
|
109
109
|
});
|
package/src/commands/README.md
CHANGED
|
@@ -47,6 +47,7 @@ These options are available for all commands:
|
|
|
47
47
|
|[`clever matomo`](./matomo/matomo.docs.md)|Manage Clever Cloud Matomo services|
|
|
48
48
|
|[`clever metabase`](./metabase/metabase.docs.md)|Manage Clever Cloud Metabase services|
|
|
49
49
|
|[`clever ng`](./ng/ng.docs.md)|List Network Groups|
|
|
50
|
+
|[`clever oauth-consumers`](./oauth-consumers/oauth-consumers.docs.md)|Manage OAuth consumers used with a Clever Cloud login|
|
|
50
51
|
|[`clever notify-email`](./notify-email/notify-email.docs.md)|Manage email notifications|
|
|
51
52
|
|[`clever open`](./open/open.docs.md)|Open an application in the Console|
|
|
52
53
|
|[`clever otoroshi`](./otoroshi/otoroshi.docs.md)|Manage Clever Cloud Otoroshi services|
|
|
@@ -8,7 +8,7 @@ import { JsonArray } from '../../models/json-array.js';
|
|
|
8
8
|
import { getHostAndTokens } from '../../models/send-to-api.js';
|
|
9
9
|
import { truncateWithEllipsis } from '../../models/utils.js';
|
|
10
10
|
import {
|
|
11
|
-
|
|
11
|
+
addonIdOrRealIdOption,
|
|
12
12
|
afterOption,
|
|
13
13
|
aliasOption,
|
|
14
14
|
appIdOrNameOption,
|
|
@@ -79,7 +79,7 @@ export const accesslogsCommand = defineCommand({
|
|
|
79
79
|
format: logsFormatOption,
|
|
80
80
|
before: beforeOption,
|
|
81
81
|
after: afterOption,
|
|
82
|
-
addon:
|
|
82
|
+
addon: addonIdOrRealIdOption,
|
|
83
83
|
},
|
|
84
84
|
args: [],
|
|
85
85
|
async handler(options) {
|
|
@@ -174,7 +174,7 @@ export const activityCommand = defineCommand({
|
|
|
174
174
|
format: defineOption({
|
|
175
175
|
name: 'format',
|
|
176
176
|
schema: z.enum(['human', 'json', 'json-stream']).default('human'),
|
|
177
|
-
description: 'Output format
|
|
177
|
+
description: 'Output format',
|
|
178
178
|
aliases: ['F'],
|
|
179
179
|
placeholder: 'format',
|
|
180
180
|
}),
|
|
@@ -10,9 +10,8 @@ import * as Addon from '../../models/addon.js';
|
|
|
10
10
|
import { completePlan, completeRegion, parseAddonOptions } from '../../models/addon.js';
|
|
11
11
|
import * as AppConfig from '../../models/app_configuration.js';
|
|
12
12
|
import { listAvailableAliases } from '../../models/application.js';
|
|
13
|
-
import
|
|
13
|
+
import { getOwnerIdFromOrgIdOrName } from '../../models/ids-resolver.js';
|
|
14
14
|
import { sendToApi } from '../../models/send-to-api.js';
|
|
15
|
-
import * as User from '../../models/user.js';
|
|
16
15
|
import { addonOptions } from '../../parsers.js';
|
|
17
16
|
import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
|
|
18
17
|
import { addonNameArg, addonProviderArg } from './addon.args.js';
|
|
@@ -130,7 +129,7 @@ export const addonCreateCommand = defineCommand({
|
|
|
130
129
|
addonOptions: parseAddonOptions(addonOptions),
|
|
131
130
|
};
|
|
132
131
|
|
|
133
|
-
const ownerId =
|
|
132
|
+
const ownerId = await getOwnerIdFromOrgIdOrName(orgaIdOrName);
|
|
134
133
|
if (linkedAppAlias != null) {
|
|
135
134
|
const linkedAppData = await AppConfig.getAppDetails({ alias: linkedAppAlias });
|
|
136
135
|
if (orgaIdOrName != null && linkedAppData.ownerId !== ownerId && format === 'human') {
|
|
@@ -3,14 +3,14 @@ import { Logger } from '../../logger.js';
|
|
|
3
3
|
import * as Addon from '../../models/addon.js';
|
|
4
4
|
import * as Organisation from '../../models/organisation.js';
|
|
5
5
|
import { addonIdOrNameArg } from '../global.args.js';
|
|
6
|
-
import {
|
|
6
|
+
import { orgaIdOrNameOption, skipConfirmationOption } from '../global.options.js';
|
|
7
7
|
|
|
8
8
|
export const addonDeleteCommand = defineCommand({
|
|
9
9
|
description: 'Delete an add-on',
|
|
10
10
|
since: '0.2.3',
|
|
11
11
|
options: {
|
|
12
12
|
org: orgaIdOrNameOption,
|
|
13
|
-
yes:
|
|
13
|
+
yes: skipConfirmationOption,
|
|
14
14
|
},
|
|
15
15
|
args: [addonIdOrNameArg],
|
|
16
16
|
async handler(options, addon) {
|
|
@@ -62,7 +62,7 @@ clever addon delete <addon-id|addon-name> [options]
|
|
|
62
62
|
|Name|Description|
|
|
63
63
|
|---|---|
|
|
64
64
|
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
65
|
-
|`-y`, `--yes`|Skip confirmation and
|
|
65
|
+
|`-y`, `--yes`|Skip confirmation and proceed with deletion directly|
|
|
66
66
|
|
|
67
67
|
## ➡️ `clever addon env` <kbd>Since 2.11.0</kbd>
|
|
68
68
|
|
|
@@ -83,7 +83,7 @@ clever addon env <addon-id> [options]
|
|
|
83
83
|
|Name|Description|
|
|
84
84
|
|---|---|
|
|
85
85
|
|`-F`, `--format` `<format>`|Output format (human, json, shell) (default: human)|
|
|
86
|
-
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)
|
|
86
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous) *(deprecated, organisation is now resolved automatically)*|
|
|
87
87
|
|
|
88
88
|
## ➡️ `clever addon list` <kbd>Since 0.2.3</kbd>
|
|
89
89
|
|
|
@@ -4,8 +4,7 @@ import { z } from 'zod';
|
|
|
4
4
|
import { defineArgument } from '../../lib/define-argument.js';
|
|
5
5
|
import { defineCommand } from '../../lib/define-command.js';
|
|
6
6
|
import { Logger } from '../../logger.js';
|
|
7
|
-
import {
|
|
8
|
-
import { resolveAddonId } from '../../models/ids-resolver.js';
|
|
7
|
+
import { resolveAddon } from '../../models/ids-resolver.js';
|
|
9
8
|
import { sendToApi } from '../../models/send-to-api.js';
|
|
10
9
|
import { envFormatOption, orgaIdOrNameOption } from '../global.options.js';
|
|
11
10
|
|
|
@@ -13,7 +12,7 @@ export const addonEnvCommand = defineCommand({
|
|
|
13
12
|
description: 'List environment variables for an add-on',
|
|
14
13
|
since: '2.11.0',
|
|
15
14
|
options: {
|
|
16
|
-
org: orgaIdOrNameOption,
|
|
15
|
+
org: { ...orgaIdOrNameOption, deprecated: 'organisation is now resolved automatically' },
|
|
17
16
|
format: envFormatOption,
|
|
18
17
|
},
|
|
19
18
|
args: [
|
|
@@ -24,10 +23,9 @@ export const addonEnvCommand = defineCommand({
|
|
|
24
23
|
}),
|
|
25
24
|
],
|
|
26
25
|
async handler(options, addonIdOrRealId) {
|
|
27
|
-
const {
|
|
26
|
+
const { format } = options;
|
|
28
27
|
|
|
29
|
-
const addonId = await
|
|
30
|
-
const ownerId = await findOwnerId(org, addonId);
|
|
28
|
+
const { ownerId, addonId } = await resolveAddon(addonIdOrRealId);
|
|
31
29
|
|
|
32
30
|
const envFromAddon = await getAllEnvVars({ id: ownerId, addonId }).then(sendToApi);
|
|
33
31
|
|
|
@@ -3,8 +3,4 @@ import { defineCommand } from '../../lib/define-command.js';
|
|
|
3
3
|
export const configProviderCommand = defineCommand({
|
|
4
4
|
description: 'Manage configuration providers',
|
|
5
5
|
since: '4.6.0',
|
|
6
|
-
options: {},
|
|
7
|
-
args: [],
|
|
8
|
-
// Parent command - no handler, only contains subcommands
|
|
9
|
-
handler: null,
|
|
10
6
|
});
|
|
@@ -11,7 +11,7 @@ import { configProviderIdOrNameArg } from './config-provider.args.js';
|
|
|
11
11
|
const importFormatOption = defineOption({
|
|
12
12
|
name: 'format',
|
|
13
13
|
schema: z.enum(['name-equals-value', 'json']).default('name-equals-value'),
|
|
14
|
-
description: 'Input format
|
|
14
|
+
description: 'Input format',
|
|
15
15
|
aliases: ['F'],
|
|
16
16
|
placeholder: 'format',
|
|
17
17
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
-
import {
|
|
2
|
+
import { printItemsByOwner } from '../../lib/print-items-by-owner.js';
|
|
3
3
|
import { Logger } from '../../logger.js';
|
|
4
4
|
import { findAddonsByAddonProvider } from '../../models/ids-resolver.js';
|
|
5
5
|
import { humanJsonOutputFormatOption } from '../global.options.js';
|
|
@@ -14,30 +14,19 @@ export const configProviderListCommand = defineCommand({
|
|
|
14
14
|
async handler(options) {
|
|
15
15
|
const { format } = options;
|
|
16
16
|
const deployed = await findAddonsByAddonProvider('config-provider');
|
|
17
|
-
const providersPerOwner = Object.groupBy(deployed, (provider) => provider.ownerId);
|
|
18
17
|
|
|
19
18
|
switch (format) {
|
|
20
|
-
case 'json':
|
|
19
|
+
case 'json': {
|
|
20
|
+
const providersPerOwner = Object.groupBy(deployed, (p) => p.ownerId);
|
|
21
21
|
Logger.printJson(providersPerOwner);
|
|
22
22
|
break;
|
|
23
|
+
}
|
|
23
24
|
case 'human':
|
|
24
25
|
default:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
)
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Logger.println(`Found ${deployed.length} configuration provider${deployed.length > 1 ? 's' : ''}:`);
|
|
33
|
-
Logger.println();
|
|
34
|
-
|
|
35
|
-
Object.values(providersPerOwner).forEach((providers) => {
|
|
36
|
-
Logger.println(`${styleText('bold', `${providers[0].ownerId} (${providers[0].ownerName})`)}`);
|
|
37
|
-
providers.forEach((provider) => {
|
|
38
|
-
Logger.println(` ${provider.name} ${styleText('grey', `(${provider.realId})`)}`);
|
|
39
|
-
});
|
|
40
|
-
Logger.println();
|
|
26
|
+
printItemsByOwner(deployed, {
|
|
27
|
+
itemName: 'configuration provider',
|
|
28
|
+
emptyCommand: 'clever addon create config-provider',
|
|
29
|
+
getItemId: (p) => p.realId,
|
|
41
30
|
});
|
|
42
31
|
break;
|
|
43
32
|
}
|
|
@@ -12,6 +12,6 @@ export const configProviderOpenCommand = defineCommand({
|
|
|
12
12
|
args: [configProviderIdOrNameArg],
|
|
13
13
|
async handler(_options, addonIdOrRealIdOrName) {
|
|
14
14
|
const { addonId } = await resolveConfigProviderId(addonIdOrRealIdOrName);
|
|
15
|
-
await openBrowser(`${config.GOTO_URL}/${addonId}`, `Opening ${styleText('blue', addonId)} in the browser
|
|
15
|
+
await openBrowser(`${config.GOTO_URL}/${addonId}`, `Opening ${styleText('blue', addonId)} in the browser…`);
|
|
16
16
|
},
|
|
17
17
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import { styleText } from '../../lib/style-text.js';
|
|
2
3
|
import * as AppConfig from '../../models/app_configuration.js';
|
|
3
4
|
import * as Application from '../../models/application.js';
|
|
4
5
|
import { openBrowser } from '../../models/utils.js';
|
|
@@ -18,7 +19,7 @@ export const consoleCommand = defineCommand({
|
|
|
18
19
|
const { apps } = await AppConfig.loadApplicationConf();
|
|
19
20
|
// If no app is linked or asked, open the Console without any context
|
|
20
21
|
if (apps.length === 0 && !appIdOrName) {
|
|
21
|
-
await openBrowser('/', 'Opening the Console in
|
|
22
|
+
await openBrowser('/', 'Opening the Console in the browser…');
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -26,6 +27,6 @@ export const consoleCommand = defineCommand({
|
|
|
26
27
|
const prefixPath = ownerId.startsWith('user_') ? 'users/me' : `organisations/${ownerId}`;
|
|
27
28
|
const consolePath = `/${prefixPath}/applications/${appId}`;
|
|
28
29
|
|
|
29
|
-
await openBrowser(consolePath, `Opening
|
|
30
|
+
await openBrowser(consolePath, `Opening ${styleText('blue', appId)} in the browser…`);
|
|
30
31
|
},
|
|
31
32
|
});
|
|
@@ -2,8 +2,7 @@ import { getBackups } from '@clevercloud/client/esm/api/v2/backups.js';
|
|
|
2
2
|
import { formatTable } from '../../format-table.js';
|
|
3
3
|
import { defineCommand } from '../../lib/define-command.js';
|
|
4
4
|
import { Logger } from '../../logger.js';
|
|
5
|
-
import {
|
|
6
|
-
import { resolveAddonId, resolveRealId } from '../../models/ids-resolver.js';
|
|
5
|
+
import { resolveAddon } from '../../models/ids-resolver.js';
|
|
7
6
|
import { sendToApi } from '../../models/send-to-api.js';
|
|
8
7
|
import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
|
|
9
8
|
import { databaseIdArg } from './database.args.js';
|
|
@@ -12,16 +11,14 @@ export const databaseBackupsCommand = defineCommand({
|
|
|
12
11
|
description: 'List available database backups',
|
|
13
12
|
since: '2.10.0',
|
|
14
13
|
options: {
|
|
15
|
-
org: orgaIdOrNameOption,
|
|
14
|
+
org: { ...orgaIdOrNameOption, deprecated: 'organisation is now resolved automatically' },
|
|
16
15
|
format: humanJsonOutputFormatOption,
|
|
17
16
|
},
|
|
18
17
|
args: [databaseIdArg],
|
|
19
18
|
async handler(options, addonIdOrRealId) {
|
|
20
|
-
const {
|
|
19
|
+
const { format } = options;
|
|
21
20
|
|
|
22
|
-
const realId = await
|
|
23
|
-
const addonId = await resolveAddonId(addonIdOrRealId);
|
|
24
|
-
const ownerId = await findOwnerId(org, realId);
|
|
21
|
+
const { ownerId, addonId, realId } = await resolveAddon(addonIdOrRealId);
|
|
25
22
|
|
|
26
23
|
const backups = await getBackups({ ownerId, ref: realId }).then(sendToApi);
|
|
27
24
|
|
|
@@ -6,8 +6,7 @@ import { z } from 'zod';
|
|
|
6
6
|
import { defineArgument } from '../../lib/define-argument.js';
|
|
7
7
|
import { defineCommand } from '../../lib/define-command.js';
|
|
8
8
|
import { defineOption } from '../../lib/define-option.js';
|
|
9
|
-
import {
|
|
10
|
-
import { resolveRealId } from '../../models/ids-resolver.js';
|
|
9
|
+
import { resolveAddon } from '../../models/ids-resolver.js';
|
|
11
10
|
import { sendToApi } from '../../models/send-to-api.js';
|
|
12
11
|
import { orgaIdOrNameOption } from '../global.options.js';
|
|
13
12
|
import { databaseIdArg } from './database.args.js';
|
|
@@ -23,7 +22,7 @@ export const databaseBackupsDownloadCommand = defineCommand({
|
|
|
23
22
|
aliases: ['out'],
|
|
24
23
|
placeholder: 'file-path',
|
|
25
24
|
}),
|
|
26
|
-
org: orgaIdOrNameOption,
|
|
25
|
+
org: { ...orgaIdOrNameOption, deprecated: 'organisation is now resolved automatically' },
|
|
27
26
|
},
|
|
28
27
|
args: [
|
|
29
28
|
databaseIdArg,
|
|
@@ -34,12 +33,11 @@ export const databaseBackupsDownloadCommand = defineCommand({
|
|
|
34
33
|
}),
|
|
35
34
|
],
|
|
36
35
|
async handler(options, addonIdOrRealId, backupId) {
|
|
37
|
-
const {
|
|
36
|
+
const { output } = options;
|
|
38
37
|
|
|
39
|
-
const
|
|
40
|
-
const ownerId = await findOwnerId(org, addonId);
|
|
38
|
+
const { ownerId, realId } = await resolveAddon(addonIdOrRealId);
|
|
41
39
|
|
|
42
|
-
const backups = await getBackups({ ownerId, ref:
|
|
40
|
+
const backups = await getBackups({ ownerId, ref: realId }).then(sendToApi);
|
|
43
41
|
const backup = backups.find((backup) => backup.backup_id === backupId);
|
|
44
42
|
|
|
45
43
|
if (backup == null) {
|
|
@@ -3,8 +3,4 @@ import { defineCommand } from '../../lib/define-command.js';
|
|
|
3
3
|
export const databaseCommand = defineCommand({
|
|
4
4
|
description: 'Manage databases and backups',
|
|
5
5
|
since: '2.10.0',
|
|
6
|
-
options: {},
|
|
7
|
-
args: [],
|
|
8
|
-
// Parent command - no handler, only contains subcommands
|
|
9
|
-
handler: null,
|
|
10
6
|
});
|
|
@@ -27,7 +27,7 @@ clever database backups <database-id|addon-id> [options]
|
|
|
27
27
|
|Name|Description|
|
|
28
28
|
|---|---|
|
|
29
29
|
|`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
|
|
30
|
-
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)
|
|
30
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous) *(deprecated, organisation is now resolved automatically)*|
|
|
31
31
|
|
|
32
32
|
## ➡️ `clever database backups download` <kbd>Since 2.10.0</kbd>
|
|
33
33
|
|
|
@@ -48,5 +48,5 @@ clever database backups download <database-id|addon-id> <backup-id> [options]
|
|
|
48
48
|
|
|
49
49
|
|Name|Description|
|
|
50
50
|
|---|---|
|
|
51
|
-
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)
|
|
51
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous) *(deprecated, organisation is now resolved automatically)*|
|
|
52
52
|
|`--output`, `--out` `<file-path>`|Redirect the output of the command in a file|
|
|
@@ -67,7 +67,7 @@ export const deployCommand = defineCommand({
|
|
|
67
67
|
sameCommitPolicy: defineOption({
|
|
68
68
|
name: 'same-commit-policy',
|
|
69
69
|
schema: z.enum(['error', 'ignore', 'restart', 'rebuild']).default('error'),
|
|
70
|
-
description: 'What to do when local and remote commit are identical
|
|
70
|
+
description: 'What to do when local and remote commit are identical',
|
|
71
71
|
aliases: ['p'],
|
|
72
72
|
placeholder: 'policy',
|
|
73
73
|
}),
|
|
@@ -14,7 +14,7 @@ clever deploy [options]
|
|
|
14
14
|
|---|---|
|
|
15
15
|
|`-a`, `--alias` `<alias>`|Short name for the application|
|
|
16
16
|
|`-b`, `--branch` `<branch>`|Branch to push (current branch by default)|
|
|
17
|
-
|`-e`, `--exit-on` `<step>`|Step at which the logs streaming is ended
|
|
17
|
+
|`-e`, `--exit-on` `<step>`|Step at which the logs streaming is ended (deploy-start, deploy-end, never) (default: deploy-end)|
|
|
18
18
|
|`--follow`|Continue to follow logs after deployment has ended *(deprecated, use `--exit-on never` instead)*|
|
|
19
19
|
|`-f`, `--force`|Force deploy even if it's not fast-forwardable|
|
|
20
20
|
|`-q`, `--quiet`|Don't show logs during deployment|
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { getDrains } from '../../clever-client/drains.js';
|
|
2
2
|
import { defineCommand } from '../../lib/define-command.js';
|
|
3
3
|
import { Logger } from '../../logger.js';
|
|
4
|
-
import
|
|
5
|
-
import { formatDrain } from '../../models/drain.js';
|
|
4
|
+
import { formatDrain, resolveDrainResource } from '../../models/drain.js';
|
|
6
5
|
import { sendToApi } from '../../models/send-to-api.js';
|
|
7
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
addonIdOrRealIdOption,
|
|
8
|
+
aliasOption,
|
|
9
|
+
appIdOrNameOption,
|
|
10
|
+
humanJsonOutputFormatOption,
|
|
11
|
+
} from '../global.options.js';
|
|
8
12
|
|
|
9
13
|
export const drainCommand = defineCommand({
|
|
10
14
|
description: 'Manage drains',
|
|
11
15
|
since: '0.9.0',
|
|
12
16
|
options: {
|
|
13
17
|
alias: aliasOption,
|
|
14
|
-
|
|
18
|
+
appIdOrName: appIdOrNameOption,
|
|
19
|
+
addonIdOrRealId: addonIdOrRealIdOption,
|
|
15
20
|
format: humanJsonOutputFormatOption,
|
|
16
21
|
},
|
|
17
22
|
args: [],
|
|
18
23
|
async handler(options) {
|
|
19
|
-
const { alias,
|
|
24
|
+
const { alias, appIdOrName, addonIdOrRealId, format } = options;
|
|
25
|
+
const { ownerId, resourceId } = await resolveDrainResource(alias, appIdOrName, addonIdOrRealId);
|
|
20
26
|
|
|
21
|
-
const { ownerId,
|
|
22
|
-
|
|
23
|
-
const drains = await getDrains({ ownerId, applicationId }).then(sendToApi);
|
|
27
|
+
const drains = await getDrains({ ownerId, resourceId }).then(sendToApi);
|
|
24
28
|
|
|
25
29
|
switch (format) {
|
|
26
30
|
case 'json': {
|
|
@@ -30,7 +34,8 @@ export const drainCommand = defineCommand({
|
|
|
30
34
|
case 'human':
|
|
31
35
|
default: {
|
|
32
36
|
if (drains.length === 0) {
|
|
33
|
-
|
|
37
|
+
const resourceLabel = addonIdOrRealId ?? appIdOrName ?? resourceId;
|
|
38
|
+
Logger.println(`There are no drains for ${resourceLabel}`);
|
|
34
39
|
return;
|
|
35
40
|
}
|
|
36
41
|
|
|
@@ -5,10 +5,9 @@ import { defineCommand } from '../../lib/define-command.js';
|
|
|
5
5
|
import { defineOption } from '../../lib/define-option.js';
|
|
6
6
|
import { styleText } from '../../lib/style-text.js';
|
|
7
7
|
import { Logger } from '../../logger.js';
|
|
8
|
-
import
|
|
9
|
-
import { DRAIN_TYPE_CLI_CODES, DRAIN_TYPES } from '../../models/drain.js';
|
|
8
|
+
import { DRAIN_TYPE_CLI_CODES, DRAIN_TYPES, resolveDrainResource } from '../../models/drain.js';
|
|
10
9
|
import { sendToApi } from '../../models/send-to-api.js';
|
|
11
|
-
import { aliasOption, appIdOrNameOption } from '../global.options.js';
|
|
10
|
+
import { addonIdOrRealIdOption, aliasOption, appIdOrNameOption } from '../global.options.js';
|
|
12
11
|
|
|
13
12
|
export const drainCreateCommand = defineCommand({
|
|
14
13
|
description: 'Create a drain',
|
|
@@ -50,14 +49,14 @@ export const drainCreateCommand = defineCommand({
|
|
|
50
49
|
placeholder: 'sd-params',
|
|
51
50
|
}),
|
|
52
51
|
alias: aliasOption,
|
|
53
|
-
|
|
52
|
+
appIdOrName: appIdOrNameOption,
|
|
53
|
+
addonIdOrRealId: addonIdOrRealIdOption,
|
|
54
54
|
},
|
|
55
55
|
args: [
|
|
56
56
|
defineArgument({
|
|
57
|
-
schema: z.
|
|
58
|
-
description:
|
|
57
|
+
schema: z.enum(DRAIN_TYPE_CLI_CODES),
|
|
58
|
+
description: 'Drain type',
|
|
59
59
|
placeholder: 'drain-type',
|
|
60
|
-
complete: DRAIN_TYPE_CLI_CODES,
|
|
61
60
|
}),
|
|
62
61
|
defineArgument({
|
|
63
62
|
schema: z.string(),
|
|
@@ -66,15 +65,12 @@ export const drainCreateCommand = defineCommand({
|
|
|
66
65
|
}),
|
|
67
66
|
],
|
|
68
67
|
async handler(options, drainTypeCliCode, url) {
|
|
69
|
-
const { alias,
|
|
68
|
+
const { alias, appIdOrName, addonIdOrRealId } = options;
|
|
70
69
|
const { username, password, apiKey, indexPrefix, rfc5424StructuredDataParameters } = options;
|
|
71
70
|
|
|
72
71
|
const drainType = Object.values(DRAIN_TYPES).find((drainType) => drainType.cliCode === drainTypeCliCode);
|
|
73
|
-
if (!drainType) {
|
|
74
|
-
throw new Error(`Invalid drain type. Supported types are: ${DRAIN_TYPE_CLI_CODES.join(', ')}`);
|
|
75
|
-
}
|
|
76
72
|
|
|
77
|
-
const { ownerId,
|
|
73
|
+
const { ownerId, resourceId } = await resolveDrainResource(alias, appIdOrName, addonIdOrRealId);
|
|
78
74
|
|
|
79
75
|
const body = {
|
|
80
76
|
kind: 'LOG',
|
|
@@ -122,7 +118,7 @@ export const drainCreateCommand = defineCommand({
|
|
|
122
118
|
}
|
|
123
119
|
}
|
|
124
120
|
|
|
125
|
-
const drain = await createDrain({ ownerId,
|
|
121
|
+
const drain = await createDrain({ ownerId, resourceId, body }).then(sendToApi);
|
|
126
122
|
Logger.printSuccess(`Drain ${styleText(['bold', 'green'], drain.id)} has been successfully created and enabled!`);
|
|
127
123
|
},
|
|
128
124
|
});
|