clever-tools 3.13.1 → 4.0.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/README.md +130 -37
- package/bin/clever.js +1427 -718
- package/package.json +62 -77
- package/src/clever-client/auth-bridge.js +9 -12
- package/src/clever-client/ng.js +1 -1
- package/src/clever-client/operators.js +7 -7
- package/src/command-options.js +6 -6
- package/src/command-promise-handler.js +6 -6
- package/src/commands/accesslogs.js +38 -29
- package/src/commands/activity.js +62 -40
- package/src/commands/addon.js +65 -69
- package/src/commands/applications.js +33 -31
- package/src/commands/cancel-deploy.js +7 -7
- package/src/commands/config.js +9 -7
- package/src/commands/console.js +3 -3
- package/src/commands/create.js +33 -32
- package/src/commands/curl.js +14 -36
- package/src/commands/database.js +10 -30
- package/src/commands/delete.js +8 -8
- package/src/commands/deploy.js +60 -46
- package/src/commands/diag.js +27 -25
- package/src/commands/domain.js +89 -91
- package/src/commands/drain.js +26 -14
- package/src/commands/emails.js +24 -28
- package/src/commands/env.js +18 -18
- package/src/commands/features.js +12 -18
- package/src/commands/keycloak.js +11 -11
- package/src/commands/kv.js +13 -13
- package/src/commands/link.js +9 -8
- package/src/commands/login.js +19 -27
- package/src/commands/logout.js +1 -1
- package/src/commands/logs.js +20 -12
- package/src/commands/makeDefault.js +5 -5
- package/src/commands/matomo.js +7 -7
- package/src/commands/metabase.js +9 -9
- package/src/commands/ng.js +32 -32
- package/src/commands/notify-email.js +11 -15
- package/src/commands/open.js +1 -1
- package/src/commands/otoroshi.js +11 -11
- package/src/commands/profile.js +8 -8
- package/src/commands/published-config.js +11 -11
- package/src/commands/restart.js +15 -8
- package/src/commands/scale.js +25 -16
- package/src/commands/service.js +28 -11
- package/src/commands/ssh-keys.js +25 -29
- package/src/commands/ssh.js +1 -2
- package/src/commands/status.js +31 -22
- package/src/commands/stop.js +3 -3
- package/src/commands/tcp-redirs.js +27 -26
- package/src/commands/tokens.js +44 -43
- package/src/commands/unlink.js +7 -5
- package/src/commands/version.js +2 -4
- package/src/commands/webhooks.js +8 -10
- package/src/experimental-features.js +7 -5
- package/src/format-table.js +46 -15
- package/src/initial-setup.js +2 -32
- package/src/initial-update-notifier.js +18 -0
- package/src/lib/has-param.js +16 -0
- package/src/lib/ng-print.js +21 -24
- package/src/lib/operator-commands.js +58 -53
- package/src/lib/prompts.js +5 -5
- package/src/lib/slugify.js +1 -1
- package/src/logger.js +26 -21
- package/src/models/activity.js +3 -3
- package/src/models/addon.js +54 -56
- package/src/models/app_configuration.js +34 -32
- package/src/models/application.js +90 -77
- package/src/models/application_configuration.js +19 -27
- package/src/models/configuration.js +30 -32
- package/src/models/deployments.js +9 -19
- package/src/models/domain.js +10 -9
- package/src/models/drain.js +16 -15
- package/src/models/exit-strategy-option.js +15 -5
- package/src/models/fs-utils.js +4 -3
- package/src/models/git.js +26 -32
- package/src/models/ids-resolver.js +37 -41
- package/src/models/isomorphic-http-with-agent.js +3 -3
- package/src/models/json-array.js +5 -6
- package/src/models/log-v4.js +44 -52
- package/src/models/log.js +40 -45
- package/src/models/namespaces.js +4 -4
- package/src/models/ng-resources.js +49 -39
- package/src/models/ng.js +41 -40
- package/src/models/node-dns-resolver.js +3 -3
- package/src/models/notification.js +7 -10
- package/src/models/operator.js +8 -10
- package/src/models/organisation.js +5 -8
- package/src/models/send-to-api.js +18 -11
- package/src/models/user.js +6 -5
- package/src/models/utils.js +5 -8
- package/src/models/variables.js +18 -20
- package/src/parsers.js +34 -34
- package/src/load-package-json.cjs +0 -5
package/src/commands/matomo.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
* @param {string} params.options.format The output format
|
|
16
16
|
* @returns {Promise<void>}
|
|
17
17
|
*/
|
|
18
|
-
export async function get
|
|
18
|
+
export async function get(params) {
|
|
19
19
|
const [addonIdOrName] = params.args;
|
|
20
20
|
const { format } = params.options;
|
|
21
21
|
await operatorPrint('matomo', addonIdOrName, format);
|
|
@@ -25,7 +25,7 @@ export async function get (params) {
|
|
|
25
25
|
* List all Matomo operators
|
|
26
26
|
* @returns {Promise<void>}
|
|
27
27
|
*/
|
|
28
|
-
export async function list
|
|
28
|
+
export async function list(params) {
|
|
29
29
|
await operatorList('addon-matomo', params.options.format);
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -35,7 +35,7 @@ export async function list (params) {
|
|
|
35
35
|
* @param {string} params.args[0] The operator's name or ID
|
|
36
36
|
* @returns {Promise<void>}
|
|
37
37
|
*/
|
|
38
|
-
export async function open
|
|
38
|
+
export async function open(params) {
|
|
39
39
|
const [addonIdOrName] = params.args;
|
|
40
40
|
await operatorOpen('matomo', addonIdOrName);
|
|
41
41
|
}
|
|
@@ -46,7 +46,7 @@ export async function open (params) {
|
|
|
46
46
|
* @param {string} params.args[0] The operator's name or ID
|
|
47
47
|
* @returns {Promise<void>}
|
|
48
48
|
*/
|
|
49
|
-
export async function openLogs
|
|
49
|
+
export async function openLogs(params) {
|
|
50
50
|
const [addonIdOrName] = params.args;
|
|
51
51
|
await operatorOpenLogs('matomo', addonIdOrName);
|
|
52
52
|
}
|
|
@@ -57,7 +57,7 @@ export async function openLogs (params) {
|
|
|
57
57
|
* @param {string} params.args[0] The operator's name or ID
|
|
58
58
|
* @returns {Promise<void>}
|
|
59
59
|
*/
|
|
60
|
-
export async function openWebUi
|
|
60
|
+
export async function openWebUi(params) {
|
|
61
61
|
const [addonIdOrName] = params.args;
|
|
62
62
|
await operatorOpenWebUi('matomo', addonIdOrName);
|
|
63
63
|
}
|
|
@@ -68,7 +68,7 @@ export async function openWebUi (params) {
|
|
|
68
68
|
* @param {string} params.args[0] The operator's name or ID
|
|
69
69
|
* @returns {Promise<void>}
|
|
70
70
|
*/
|
|
71
|
-
export async function reboot
|
|
71
|
+
export async function reboot(params) {
|
|
72
72
|
const [addonIdOrName] = params.args;
|
|
73
73
|
await operatorReboot('matomo', addonIdOrName);
|
|
74
74
|
}
|
|
@@ -79,7 +79,7 @@ export async function reboot (params) {
|
|
|
79
79
|
* @param {string} params.args[0] The operator's name or ID
|
|
80
80
|
* @returns {Promise<void>}
|
|
81
81
|
*/
|
|
82
|
-
export async function rebuild
|
|
82
|
+
export async function rebuild(params) {
|
|
83
83
|
const [addonIdOrName] = params.args;
|
|
84
84
|
await operatorRebuild('matomo', addonIdOrName);
|
|
85
85
|
}
|
package/src/commands/metabase.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
* @param {string} params.options.format The output format
|
|
18
18
|
* @returns {Promise<void>}
|
|
19
19
|
*/
|
|
20
|
-
export async function checkVersion
|
|
20
|
+
export async function checkVersion(params) {
|
|
21
21
|
const [addonIdOrName] = params.args;
|
|
22
22
|
const { format } = params.options;
|
|
23
23
|
await operatorCheckVersion('metabase', addonIdOrName, format);
|
|
@@ -29,7 +29,7 @@ export async function checkVersion (params) {
|
|
|
29
29
|
* @param {string} params.args[0] The operator's name or ID
|
|
30
30
|
* @returns {Promise<void>}
|
|
31
31
|
*/
|
|
32
|
-
export async function updateVersion
|
|
32
|
+
export async function updateVersion(params) {
|
|
33
33
|
const [addonIdOrName] = params.args;
|
|
34
34
|
const { target } = params.options;
|
|
35
35
|
await operatorUpdateVersion('metabase', target, addonIdOrName);
|
|
@@ -42,7 +42,7 @@ export async function updateVersion (params) {
|
|
|
42
42
|
* @param {string} params.options.format The output format
|
|
43
43
|
* @returns {Promise<void>}
|
|
44
44
|
*/
|
|
45
|
-
export async function get
|
|
45
|
+
export async function get(params) {
|
|
46
46
|
const [addonIdOrName] = params.args;
|
|
47
47
|
const { format } = params.options;
|
|
48
48
|
await operatorPrint('metabase', addonIdOrName, format);
|
|
@@ -52,7 +52,7 @@ export async function get (params) {
|
|
|
52
52
|
* List all Metabase operators
|
|
53
53
|
* @returns {Promise<void>}
|
|
54
54
|
*/
|
|
55
|
-
export async function list
|
|
55
|
+
export async function list(params) {
|
|
56
56
|
await operatorList('metabase', params.options.format);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -62,7 +62,7 @@ export async function list (params) {
|
|
|
62
62
|
* @param {string} params.args[0] The operator's name or ID
|
|
63
63
|
* @returns {Promise<void>}
|
|
64
64
|
*/
|
|
65
|
-
export async function open
|
|
65
|
+
export async function open(params) {
|
|
66
66
|
const [addonIdOrName] = params.args;
|
|
67
67
|
await operatorOpen('metabase', addonIdOrName);
|
|
68
68
|
}
|
|
@@ -73,7 +73,7 @@ export async function open (params) {
|
|
|
73
73
|
* @param {string} params.args[0] The operator's name or ID
|
|
74
74
|
* @returns {Promise<void>}
|
|
75
75
|
*/
|
|
76
|
-
export async function openLogs
|
|
76
|
+
export async function openLogs(params) {
|
|
77
77
|
const [addonIdOrName] = params.args;
|
|
78
78
|
await operatorOpenLogs('metabase', addonIdOrName);
|
|
79
79
|
}
|
|
@@ -84,7 +84,7 @@ export async function openLogs (params) {
|
|
|
84
84
|
* @param {string} params.args[0] The operator's name or ID
|
|
85
85
|
* @returns {Promise<void>}
|
|
86
86
|
*/
|
|
87
|
-
export async function openWebUi
|
|
87
|
+
export async function openWebUi(params) {
|
|
88
88
|
const [addonIdOrName] = params.args;
|
|
89
89
|
await operatorOpenWebUi('metabase', addonIdOrName);
|
|
90
90
|
}
|
|
@@ -95,7 +95,7 @@ export async function openWebUi (params) {
|
|
|
95
95
|
* @param {string} params.args[0] The operator's name or ID
|
|
96
96
|
* @returns {Promise<void>}
|
|
97
97
|
*/
|
|
98
|
-
export async function reboot
|
|
98
|
+
export async function reboot(params) {
|
|
99
99
|
const [addonIdOrName] = params.args;
|
|
100
100
|
await operatorReboot('metabase', addonIdOrName);
|
|
101
101
|
}
|
|
@@ -106,7 +106,7 @@ export async function reboot (params) {
|
|
|
106
106
|
* @param {string} params.args[0] The operator's name or ID
|
|
107
107
|
* @returns {Promise<void>}
|
|
108
108
|
*/
|
|
109
|
-
export async function rebuild
|
|
109
|
+
export async function rebuild(params) {
|
|
110
110
|
const [addonIdOrName] = params.args;
|
|
111
111
|
await operatorRebuild('metabase', addonIdOrName);
|
|
112
112
|
}
|
package/src/commands/ng.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as networkGroup from '../models/ng.js';
|
|
3
|
-
import * as networkGroupResources from '../models/ng-resources.js';
|
|
4
|
-
|
|
5
|
-
import { Logger } from '../logger.js';
|
|
1
|
+
import { styleText } from 'node:util';
|
|
6
2
|
import { printResults } from '../lib/ng-print.js';
|
|
3
|
+
import { Logger } from '../logger.js';
|
|
4
|
+
import * as networkGroupResources from '../models/ng-resources.js';
|
|
5
|
+
import * as networkGroup from '../models/ng.js';
|
|
7
6
|
|
|
8
7
|
/** Create a Network Group
|
|
9
8
|
* @param {Object} params
|
|
@@ -14,20 +13,19 @@ import { printResults } from '../lib/ng-print.js';
|
|
|
14
13
|
* @param {Object} params.options.org Organisation ID or name
|
|
15
14
|
* @param {string} params.options.tags Comma-separated list of tags
|
|
16
15
|
*/
|
|
17
|
-
export async function createNg
|
|
16
|
+
export async function createNg(params) {
|
|
18
17
|
const [ngLabel] = params.args;
|
|
19
18
|
const label = ngLabel.ngResourceLabel;
|
|
20
19
|
const { description, link: membersIds, org, tags } = params.options;
|
|
21
20
|
|
|
22
21
|
await networkGroup.create(label, description, tags, membersIds, org);
|
|
23
22
|
|
|
24
|
-
const successMessage = `Network Group ${
|
|
23
|
+
const successMessage = `Network Group ${styleText('green', label)} successfully created`;
|
|
25
24
|
if (membersIds == null) {
|
|
26
25
|
Logger.printSuccess(`${successMessage}!`);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
26
|
+
} else {
|
|
29
27
|
Logger.printSuccess(`${successMessage} with member(s):`);
|
|
30
|
-
Logger.println(membersIds.map((id) =>
|
|
28
|
+
Logger.println(membersIds.map((id) => styleText('grey', ` - ${id}`)).join('\n'));
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
|
|
@@ -36,13 +34,13 @@ export async function createNg (params) {
|
|
|
36
34
|
* @param {Object} params.args[0] Network Group ID or label
|
|
37
35
|
* @param {Object} params.options.org Organisation ID or name
|
|
38
36
|
*/
|
|
39
|
-
export async function deleteNg
|
|
37
|
+
export async function deleteNg(params) {
|
|
40
38
|
const [ngIdOrLabel] = params.args;
|
|
41
39
|
const { org } = params.options;
|
|
42
40
|
|
|
43
41
|
await networkGroup.destroy(ngIdOrLabel, org);
|
|
44
42
|
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
45
|
-
Logger.printSuccess(`Network Group ${
|
|
43
|
+
Logger.printSuccess(`Network Group ${styleText('green', ngText)} successfully deleted!`);
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
/** Create an external peer in a Network Group
|
|
@@ -52,13 +50,15 @@ export async function deleteNg (params) {
|
|
|
52
50
|
* @param {string} params.args[2] Wireguard public key
|
|
53
51
|
* @param {Object} params.options.org Organisation ID or name
|
|
54
52
|
*/
|
|
55
|
-
export async function createExternalPeer
|
|
53
|
+
export async function createExternalPeer(params) {
|
|
56
54
|
const [peerIdOrLabel, ngIdOrLabel, publicKey] = params.args;
|
|
57
55
|
const { org } = params.options;
|
|
58
56
|
|
|
59
57
|
await networkGroupResources.createExternalPeerWithParent(ngIdOrLabel, peerIdOrLabel.ngResourceLabel, publicKey, org);
|
|
60
58
|
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
61
|
-
Logger.printSuccess(
|
|
59
|
+
Logger.printSuccess(
|
|
60
|
+
`External peer ${styleText('green', peerIdOrLabel.ngResourceLabel)} successfully created in Network Group ${styleText('green', ngText)}`,
|
|
61
|
+
);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/** Delete an external peer from a Network Group
|
|
@@ -67,14 +67,16 @@ export async function createExternalPeer (params) {
|
|
|
67
67
|
* @param {Object} params.args[1] Network Group ID or label
|
|
68
68
|
* @param {Object} params.options.org Organisation ID or name
|
|
69
69
|
*/
|
|
70
|
-
export async function deleteExternalPeer
|
|
70
|
+
export async function deleteExternalPeer(params) {
|
|
71
71
|
const [peerIdOrLabel, ngIdOrLabel] = params.args;
|
|
72
72
|
const { org } = params.options;
|
|
73
73
|
|
|
74
74
|
const peerText = peerIdOrLabel.ngResourceLabel ?? peerIdOrLabel.memberId;
|
|
75
75
|
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
76
76
|
await networkGroupResources.deleteExternalPeerWithParent(ngIdOrLabel, peerText, org);
|
|
77
|
-
Logger.printSuccess(
|
|
77
|
+
Logger.printSuccess(
|
|
78
|
+
`External peer ${styleText('green', peerText)} successfully deleted from Network Group ${styleText('green', ngText)}`,
|
|
79
|
+
);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
/** Link a member to a Network Group
|
|
@@ -83,13 +85,15 @@ export async function deleteExternalPeer (params) {
|
|
|
83
85
|
* @param {Object} params.args[1] Network Group ID or label
|
|
84
86
|
* @param {Object} params.options.org Organisation ID or name
|
|
85
87
|
*/
|
|
86
|
-
export async function linkToNg
|
|
88
|
+
export async function linkToNg(params) {
|
|
87
89
|
const [resourceId, ngIdOrLabel] = params.args;
|
|
88
90
|
const { org } = params.options;
|
|
89
91
|
|
|
90
92
|
await networkGroupResources.linkMember(ngIdOrLabel, resourceId.memberId, org);
|
|
91
93
|
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
92
|
-
Logger.printSuccess(
|
|
94
|
+
Logger.printSuccess(
|
|
95
|
+
`Member ${styleText('green', resourceId.memberId)} successfully linked to Network Group ${styleText('green', ngText)}`,
|
|
96
|
+
);
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
/** Unlink a member from a Network Group
|
|
@@ -98,13 +102,15 @@ export async function linkToNg (params) {
|
|
|
98
102
|
* @param {Object} params.args[1] Network Group ID or label
|
|
99
103
|
* @param {Object} params.options.org Organisation ID or name
|
|
100
104
|
*/
|
|
101
|
-
export async function unlinkFromNg
|
|
105
|
+
export async function unlinkFromNg(params) {
|
|
102
106
|
const [resourceId, ngIdOrLabel] = params.args;
|
|
103
107
|
const { org } = params.options;
|
|
104
108
|
|
|
105
109
|
await networkGroupResources.unlinkMember(ngIdOrLabel, resourceId.memberId, org);
|
|
106
110
|
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
107
|
-
Logger.printSuccess(
|
|
111
|
+
Logger.printSuccess(
|
|
112
|
+
`Member ${styleText('green', resourceId.memberId)} successfully unlinked from Network Group ${styleText('green', ngText)}`,
|
|
113
|
+
);
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
/** Print the configuration of a Network Group's peer
|
|
@@ -114,7 +120,7 @@ export async function unlinkFromNg (params) {
|
|
|
114
120
|
* @param {Object} params.options.org Organisation ID or name
|
|
115
121
|
* @param {string} params.options.format Output format
|
|
116
122
|
*/
|
|
117
|
-
export async function getPeerConfig
|
|
123
|
+
export async function getPeerConfig(params) {
|
|
118
124
|
const [peerIdOrLabel, ngIdOrLabel] = params.args;
|
|
119
125
|
const { org, format } = params.options;
|
|
120
126
|
|
|
@@ -138,7 +144,7 @@ export async function getPeerConfig (params) {
|
|
|
138
144
|
* @param {Object} params.options.orgaIdOrName Organisation ID or name
|
|
139
145
|
* @param {string} params.options.format Output format
|
|
140
146
|
*/
|
|
141
|
-
export async function listNg
|
|
147
|
+
export async function listNg(params) {
|
|
142
148
|
const { org, format } = params.options;
|
|
143
149
|
|
|
144
150
|
const ngs = await networkGroup.getAllNGs(org);
|
|
@@ -151,16 +157,10 @@ export async function listNg (params) {
|
|
|
151
157
|
case 'human':
|
|
152
158
|
default: {
|
|
153
159
|
if (!ngs.length) {
|
|
154
|
-
Logger.println(`ℹ️ No Network Group found, create one with ${
|
|
160
|
+
Logger.println(`ℹ️ No Network Group found, create one with ${styleText('blue', 'clever ng create')} command`);
|
|
155
161
|
return;
|
|
156
162
|
}
|
|
157
|
-
const ngList = ngs.map(({
|
|
158
|
-
id,
|
|
159
|
-
label,
|
|
160
|
-
networkIp,
|
|
161
|
-
members,
|
|
162
|
-
peers,
|
|
163
|
-
}) => ({
|
|
163
|
+
const ngList = ngs.map(({ id, label, networkIp, members, peers }) => ({
|
|
164
164
|
ID: id,
|
|
165
165
|
Label: label,
|
|
166
166
|
'Network CIDR': networkIp,
|
|
@@ -179,7 +179,7 @@ export async function listNg (params) {
|
|
|
179
179
|
* @param {Object} params.options.org Organisation ID or name
|
|
180
180
|
* @param {string} params.options.format Output format
|
|
181
181
|
*/
|
|
182
|
-
export async function get
|
|
182
|
+
export async function get(params) {
|
|
183
183
|
const [idOrLabel] = params.args;
|
|
184
184
|
const { org, format } = params.options;
|
|
185
185
|
const type = params.options.type ?? 'single';
|
|
@@ -193,7 +193,7 @@ export async function get (params) {
|
|
|
193
193
|
* @param {Object} params.options.org Organisation ID or name
|
|
194
194
|
* @param {string} params.options.format Output format
|
|
195
195
|
*/
|
|
196
|
-
export async function search
|
|
196
|
+
export async function search(params) {
|
|
197
197
|
const [idOrLabel] = params.args;
|
|
198
198
|
const { org, format } = params.options;
|
|
199
199
|
const type = params.options.type;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { createEmailhook, deleteEmailhook, getEmailhooks } from '@clevercloud/client/esm/api/v2/notification.js';
|
|
2
|
+
import { styleText } from 'node:util';
|
|
3
3
|
import { Logger } from '../logger.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { getEmailhooks, createEmailhook, deleteEmailhook } from '@clevercloud/client/esm/api/v2/notification.js';
|
|
4
|
+
import { getOrgaIdOrUserId, getOwnerAndApp } from '../models/notification.js';
|
|
7
5
|
import { sendToApi } from '../models/send-to-api.js';
|
|
8
6
|
|
|
9
|
-
export async function list
|
|
7
|
+
export async function list(params) {
|
|
10
8
|
const { org, 'list-all': listAll, format } = params.options;
|
|
11
9
|
|
|
12
10
|
// TODO: fix alias option
|
|
@@ -34,16 +32,15 @@ export async function list (params) {
|
|
|
34
32
|
}
|
|
35
33
|
case 'human':
|
|
36
34
|
default: {
|
|
37
|
-
formattedHooks.forEach((hook
|
|
38
|
-
Logger.println(
|
|
35
|
+
formattedHooks.forEach((hook) => {
|
|
36
|
+
Logger.println(styleText('bold', hook.name ?? hook.id));
|
|
39
37
|
Logger.println(` id: ${hook.id}`);
|
|
40
38
|
Logger.println(` services: ${hook.services.join(', ')}`);
|
|
41
39
|
Logger.println(` events: ${hook.events.join(', ')}`);
|
|
42
40
|
if (hook.notified.length > 1) {
|
|
43
41
|
Logger.println(' to:');
|
|
44
42
|
hook.notified.forEach((target) => Logger.println(` ${target}`));
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
43
|
+
} else {
|
|
47
44
|
Logger.println(` to: ${hook.notified[0]}`);
|
|
48
45
|
}
|
|
49
46
|
});
|
|
@@ -51,8 +48,7 @@ export async function list (params) {
|
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
50
|
|
|
54
|
-
export function getEmailNotificationTargets
|
|
55
|
-
|
|
51
|
+
export function getEmailNotificationTargets(notifTargets) {
|
|
56
52
|
if (notifTargets == null) {
|
|
57
53
|
return [];
|
|
58
54
|
}
|
|
@@ -73,7 +69,7 @@ export function getEmailNotificationTargets (notifTargets) {
|
|
|
73
69
|
.filter((e) => e != null);
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
export async function add
|
|
72
|
+
export async function add(params) {
|
|
77
73
|
const { org, event: events, service, notify: notifTargets } = params.options;
|
|
78
74
|
const [name] = params.args;
|
|
79
75
|
|
|
@@ -83,7 +79,7 @@ export async function add (params) {
|
|
|
83
79
|
const body = {
|
|
84
80
|
name,
|
|
85
81
|
notified: getEmailNotificationTargets(notifTargets),
|
|
86
|
-
scope:
|
|
82
|
+
scope: appId != null && service == null ? [appId] : service,
|
|
87
83
|
events,
|
|
88
84
|
};
|
|
89
85
|
|
|
@@ -92,7 +88,7 @@ export async function add (params) {
|
|
|
92
88
|
Logger.println('The webhook has been added');
|
|
93
89
|
}
|
|
94
90
|
|
|
95
|
-
export async function remove
|
|
91
|
+
export async function remove(params) {
|
|
96
92
|
const { org } = params.options;
|
|
97
93
|
const [notificationId] = params.args;
|
|
98
94
|
|
package/src/commands/open.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as Application from '../models/application.js';
|
|
|
2
2
|
import * as Domain from '../models/domain.js';
|
|
3
3
|
import { openBrowser } from '../models/utils.js';
|
|
4
4
|
|
|
5
|
-
export async function open
|
|
5
|
+
export async function open(params) {
|
|
6
6
|
const { alias, app: appIdOrName } = params.options;
|
|
7
7
|
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
8
8
|
|
package/src/commands/otoroshi.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
* @param {string} params.options.format The output format
|
|
20
20
|
* @returns {Promise<void>}
|
|
21
21
|
*/
|
|
22
|
-
export async function checkVersion
|
|
22
|
+
export async function checkVersion(params) {
|
|
23
23
|
const [addonIdOrName] = params.args;
|
|
24
24
|
const { format } = params.options;
|
|
25
25
|
await operatorCheckVersion('otoroshi', addonIdOrName, format);
|
|
@@ -31,7 +31,7 @@ export async function checkVersion (params) {
|
|
|
31
31
|
* @param {string} params.args[0] The operator's name or ID
|
|
32
32
|
* @returns {Promise<void>}
|
|
33
33
|
*/
|
|
34
|
-
export async function updateVersion
|
|
34
|
+
export async function updateVersion(params) {
|
|
35
35
|
const [addonIdOrName] = params.args;
|
|
36
36
|
const { target } = params.options;
|
|
37
37
|
await operatorUpdateVersion('otoroshi', target, addonIdOrName);
|
|
@@ -44,7 +44,7 @@ export async function updateVersion (params) {
|
|
|
44
44
|
* @param {string} params.options.format The output format
|
|
45
45
|
* @returns {Promise<void>}
|
|
46
46
|
*/
|
|
47
|
-
export async function get
|
|
47
|
+
export async function get(params) {
|
|
48
48
|
const [addonIdOrName] = params.args;
|
|
49
49
|
const { format } = params.options;
|
|
50
50
|
await operatorPrint('otoroshi', addonIdOrName, format);
|
|
@@ -54,7 +54,7 @@ export async function get (params) {
|
|
|
54
54
|
* List all Otoroshi operators
|
|
55
55
|
* @returns {Promise<void>}
|
|
56
56
|
*/
|
|
57
|
-
export async function list
|
|
57
|
+
export async function list(params) {
|
|
58
58
|
await operatorList('otoroshi', params.options.format);
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -65,7 +65,7 @@ export async function list (params) {
|
|
|
65
65
|
* @returns {Promise<void>}
|
|
66
66
|
* @throws {Error} If the Network Group feature is already disabled
|
|
67
67
|
*/
|
|
68
|
-
export async function ngDisable
|
|
68
|
+
export async function ngDisable(params) {
|
|
69
69
|
const [addonIdOrName] = params.args;
|
|
70
70
|
await operatorNgDisable('otoroshi', addonIdOrName);
|
|
71
71
|
}
|
|
@@ -77,7 +77,7 @@ export async function ngDisable (params) {
|
|
|
77
77
|
* @returns {Promise<void>}
|
|
78
78
|
* @throws {Error} If the Network Group feature is already enabled
|
|
79
79
|
*/
|
|
80
|
-
export async function ngEnable
|
|
80
|
+
export async function ngEnable(params) {
|
|
81
81
|
const [addonIdOrName] = params.args;
|
|
82
82
|
await operatorNgEnable('otoroshi', addonIdOrName);
|
|
83
83
|
}
|
|
@@ -88,7 +88,7 @@ export async function ngEnable (params) {
|
|
|
88
88
|
* @param {string} params.args[0] The operator's name or ID
|
|
89
89
|
* @returns {Promise<void>}
|
|
90
90
|
*/
|
|
91
|
-
export async function open
|
|
91
|
+
export async function open(params) {
|
|
92
92
|
const [addonIdOrName] = params.args;
|
|
93
93
|
await operatorOpen('otoroshi', addonIdOrName);
|
|
94
94
|
}
|
|
@@ -99,7 +99,7 @@ export async function open (params) {
|
|
|
99
99
|
* @param {string} params.args[0] The operator's name or ID
|
|
100
100
|
* @returns {Promise<void>}
|
|
101
101
|
*/
|
|
102
|
-
export async function openLogs
|
|
102
|
+
export async function openLogs(params) {
|
|
103
103
|
const [addonIdOrName] = params.args;
|
|
104
104
|
await operatorOpenLogs('otoroshi', addonIdOrName);
|
|
105
105
|
}
|
|
@@ -110,7 +110,7 @@ export async function openLogs (params) {
|
|
|
110
110
|
* @param {string} params.args[0] The operator's name or ID
|
|
111
111
|
* @returns {Promise<void>}
|
|
112
112
|
*/
|
|
113
|
-
export async function openWebUi
|
|
113
|
+
export async function openWebUi(params) {
|
|
114
114
|
const [addonIdOrName] = params.args;
|
|
115
115
|
await operatorOpenWebUi('otoroshi', addonIdOrName);
|
|
116
116
|
}
|
|
@@ -121,7 +121,7 @@ export async function openWebUi (params) {
|
|
|
121
121
|
* @param {string} params.args[0] The operator's name or ID
|
|
122
122
|
* @returns {Promise<void>}
|
|
123
123
|
*/
|
|
124
|
-
export async function reboot
|
|
124
|
+
export async function reboot(params) {
|
|
125
125
|
const [addonIdOrName] = params.args;
|
|
126
126
|
await operatorReboot('otoroshi', addonIdOrName);
|
|
127
127
|
}
|
|
@@ -132,7 +132,7 @@ export async function reboot (params) {
|
|
|
132
132
|
* @param {string} params.args[0] The operator's name or ID
|
|
133
133
|
* @returns {Promise<void>}
|
|
134
134
|
*/
|
|
135
|
-
export async function rebuild
|
|
135
|
+
export async function rebuild(params) {
|
|
136
136
|
const [addonIdOrName] = params.args;
|
|
137
137
|
await operatorRebuild('otoroshi', addonIdOrName);
|
|
138
138
|
}
|
package/src/commands/profile.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import dedent from 'dedent';
|
|
2
|
+
import { styleText } from 'node:util';
|
|
3
3
|
import { Logger } from '../logger.js';
|
|
4
4
|
import * as User from '../models/user.js';
|
|
5
|
-
import
|
|
5
|
+
import { openBrowser } from '../models/utils.js';
|
|
6
6
|
|
|
7
|
-
export async function profile
|
|
7
|
+
export async function profile(params) {
|
|
8
8
|
const { format } = params.options;
|
|
9
9
|
|
|
10
10
|
const user = await User.getCurrent();
|
|
@@ -28,7 +28,7 @@ export async function profile (params) {
|
|
|
28
28
|
creationDate: new Date(user.creationDate),
|
|
29
29
|
tokenExpiration: new Date(currentToken.expirationDate).toISOString(),
|
|
30
30
|
lang: user.lang,
|
|
31
|
-
has2FA:
|
|
31
|
+
has2FA: user.preferredMFA != null && user.preferredMFA !== 'NONE',
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
switch (format) {
|
|
@@ -41,15 +41,15 @@ export async function profile (params) {
|
|
|
41
41
|
Logger.println(dedent`
|
|
42
42
|
You're currently logged in as:
|
|
43
43
|
User id ${formattedUser.id}
|
|
44
|
-
Name ${formattedUser.name ??
|
|
44
|
+
Name ${formattedUser.name ?? styleText(['red', 'bold'], '[not specified]')}
|
|
45
45
|
Email ${formattedUser.email}
|
|
46
46
|
Token expiration ${tokenExpiration}
|
|
47
47
|
Two factor auth ${formattedUser.has2FA ? 'yes' : 'no'}
|
|
48
48
|
`);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|
|
52
52
|
|
|
53
|
-
export async function openProfile
|
|
53
|
+
export async function openProfile() {
|
|
54
54
|
await openBrowser('/users/me/information', 'Opening the profile page in your browser');
|
|
55
55
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { getAllExposedEnvVars, updateAllExposedEnvVars } from '@clevercloud/client/esm/api/v2/application.js';
|
|
2
|
+
import { toNameEqualsValueString, validateName } from '@clevercloud/client/esm/utils/env-vars.js';
|
|
2
3
|
import { Logger } from '../logger.js';
|
|
3
|
-
import * as
|
|
4
|
+
import * as Application from '../models/application.js';
|
|
4
5
|
import { sendToApi } from '../models/send-to-api.js';
|
|
5
|
-
import
|
|
6
|
-
import { getAllExposedEnvVars, updateAllExposedEnvVars } from '@clevercloud/client/esm/api/v2/application.js';
|
|
6
|
+
import * as variables from '../models/variables.js';
|
|
7
7
|
|
|
8
|
-
export async function list
|
|
8
|
+
export async function list(params) {
|
|
9
9
|
const { alias, app: appIdOrName, format } = params.options;
|
|
10
10
|
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
11
11
|
|
|
@@ -28,7 +28,7 @@ export async function list (params) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export async function set
|
|
31
|
+
export async function set(params) {
|
|
32
32
|
const [varName, varValue] = params.args;
|
|
33
33
|
const { alias, app: appIdOrName } = params.options;
|
|
34
34
|
|
|
@@ -44,9 +44,9 @@ export async function set (params) {
|
|
|
44
44
|
await updateAllExposedEnvVars({ id: ownerId, appId }, publishedConfigs).then(sendToApi);
|
|
45
45
|
|
|
46
46
|
Logger.println('Your published config item has been successfully saved');
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
export async function rm
|
|
49
|
+
export async function rm(params) {
|
|
50
50
|
const [varName] = params.args;
|
|
51
51
|
const { alias, app: appIdOrName } = params.options;
|
|
52
52
|
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
@@ -56,9 +56,9 @@ export async function rm (params) {
|
|
|
56
56
|
await updateAllExposedEnvVars({ id: ownerId, appId }, publishedConfigs).then(sendToApi);
|
|
57
57
|
|
|
58
58
|
Logger.println('Your published config item has been successfully removed');
|
|
59
|
-
}
|
|
59
|
+
}
|
|
60
60
|
|
|
61
|
-
export async function importEnv
|
|
61
|
+
export async function importEnv(params) {
|
|
62
62
|
const { alias, app: appIdOrName, json } = params.options;
|
|
63
63
|
const format = json ? 'json' : 'name-equals-value';
|
|
64
64
|
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
@@ -67,4 +67,4 @@ export async function importEnv (params) {
|
|
|
67
67
|
await updateAllExposedEnvVars({ id: ownerId, appId }, publishedConfigs).then(sendToApi);
|
|
68
68
|
|
|
69
69
|
Logger.println('Your published configs have been set');
|
|
70
|
-
}
|
|
70
|
+
}
|
package/src/commands/restart.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { styleText } from 'node:util';
|
|
2
|
+
import { Logger } from '../logger.js';
|
|
3
3
|
import * as Application from '../models/application.js';
|
|
4
|
+
import * as ExitStrategy from '../models/exit-strategy-option.js';
|
|
4
5
|
import * as git from '../models/git.js';
|
|
5
6
|
import * as Log from '../models/log-v4.js';
|
|
6
|
-
import { Logger } from '../logger.js';
|
|
7
|
-
import * as ExitStrategy from '../models/exit-strategy-option.js';
|
|
8
7
|
|
|
9
8
|
// Once the API call to redeploy() has been triggerred successfully,
|
|
10
9
|
// the rest (waiting for deployment state to evolve and displaying logs) is done with auto retry (resilient to network pb)
|
|
11
|
-
export async function restart
|
|
12
|
-
const {
|
|
10
|
+
export async function restart(params) {
|
|
11
|
+
const {
|
|
12
|
+
alias,
|
|
13
|
+
app: appIdOrName,
|
|
14
|
+
quiet,
|
|
15
|
+
commit,
|
|
16
|
+
'without-cache': withoutCache,
|
|
17
|
+
follow,
|
|
18
|
+
'exit-on': exitOnDeploy,
|
|
19
|
+
} = params.options;
|
|
13
20
|
|
|
14
21
|
const exitStrategy = ExitStrategy.get(follow, exitOnDeploy);
|
|
15
22
|
|
|
@@ -18,7 +25,7 @@ export async function restart (params) {
|
|
|
18
25
|
const app = await Application.get(ownerId, appId);
|
|
19
26
|
|
|
20
27
|
if (app == null) {
|
|
21
|
-
throw new Error(
|
|
28
|
+
throw new Error("The application doesn't exist");
|
|
22
29
|
}
|
|
23
30
|
|
|
24
31
|
const remoteCommitId = app.commitId;
|
|
@@ -26,7 +33,7 @@ export async function restart (params) {
|
|
|
26
33
|
const commitId = fullCommitId || remoteCommitId;
|
|
27
34
|
if (commitId != null) {
|
|
28
35
|
const cacheSuffix = withoutCache ? ' without using cache' : '';
|
|
29
|
-
Logger.println(`🔄 Restarting ${
|
|
36
|
+
Logger.println(`🔄 Restarting ${styleText('bold', app.name)}${cacheSuffix} ${styleText('grey', `(${commitId})`)}`);
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
// This should be handled by the API when a deployment ID is set but we'll do this for now
|