clever-tools 4.4.1 → 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.
Files changed (291) hide show
  1. package/bin/clever.js +208 -2125
  2. package/package.json +33 -25
  3. package/src/commands/README.md +65 -0
  4. package/src/commands/accesslogs/accesslogs.command.js +158 -0
  5. package/src/commands/accesslogs/accesslogs.docs.md +20 -0
  6. package/src/commands/{activity.js → activity/activity.command.js} +74 -44
  7. package/src/commands/activity/activity.docs.md +19 -0
  8. package/src/commands/addon/addon.args.js +14 -0
  9. package/src/commands/addon/addon.command.js +7 -0
  10. package/src/commands/addon/addon.create.command.js +236 -0
  11. package/src/commands/addon/addon.delete.command.js +32 -0
  12. package/src/commands/addon/addon.docs.md +156 -0
  13. package/src/commands/addon/addon.env.command.js +50 -0
  14. package/src/commands/addon/addon.list.command.js +55 -0
  15. package/src/commands/addon/addon.providers.command.js +45 -0
  16. package/src/commands/addon/addon.providers.show.command.js +99 -0
  17. package/src/commands/addon/addon.rename.command.js +24 -0
  18. package/src/commands/applications/applications.command.js +59 -0
  19. package/src/commands/applications/applications.docs.md +31 -0
  20. package/src/commands/applications/applications.list.command.js +100 -0
  21. package/src/commands/cancel-deploy/cancel-deploy.command.js +30 -0
  22. package/src/commands/cancel-deploy/cancel-deploy.docs.md +16 -0
  23. package/src/commands/config/config.args.js +10 -0
  24. package/src/commands/config/config.command.js +20 -0
  25. package/src/commands/config/config.docs.md +86 -0
  26. package/src/commands/config/config.get.command.js +21 -0
  27. package/src/commands/config/config.set.command.js +38 -0
  28. package/src/commands/config/config.update.command.js +88 -0
  29. package/src/commands/console/console.command.js +31 -0
  30. package/src/commands/console/console.docs.md +16 -0
  31. package/src/commands/create/create.command.js +173 -0
  32. package/src/commands/create/create.docs.md +27 -0
  33. package/src/commands/{curl.js → curl/curl.command.js} +10 -3
  34. package/src/commands/curl/curl.docs.md +9 -0
  35. package/src/commands/database/database.args.js +8 -0
  36. package/src/commands/database/database.backups.command.js +60 -0
  37. package/src/commands/database/database.backups.download.command.js +55 -0
  38. package/src/commands/database/database.command.js +10 -0
  39. package/src/commands/database/database.docs.md +52 -0
  40. package/src/commands/delete/delete.command.js +43 -0
  41. package/src/commands/delete/delete.docs.md +17 -0
  42. package/src/commands/deploy/deploy.command.js +166 -0
  43. package/src/commands/deploy/deploy.docs.md +22 -0
  44. package/src/commands/diag/diag.command.js +136 -0
  45. package/src/commands/diag/diag.docs.md +15 -0
  46. package/src/commands/domain/domain.add.command.js +25 -0
  47. package/src/commands/domain/domain.args.js +8 -0
  48. package/src/commands/domain/domain.command.js +38 -0
  49. package/src/commands/domain/domain.diag.command.js +204 -0
  50. package/src/commands/domain/domain.docs.md +143 -0
  51. package/src/commands/domain/domain.favourite.command.js +35 -0
  52. package/src/commands/domain/domain.favourite.set.command.js +24 -0
  53. package/src/commands/domain/domain.favourite.unset.command.js +23 -0
  54. package/src/commands/domain/domain.overview.command.js +157 -0
  55. package/src/commands/domain/domain.rm.command.js +25 -0
  56. package/src/commands/drain/drain.args.js +8 -0
  57. package/src/commands/drain/drain.command.js +56 -0
  58. package/src/commands/drain/drain.create.command.js +128 -0
  59. package/src/commands/drain/drain.disable.command.js +27 -0
  60. package/src/commands/drain/drain.docs.md +129 -0
  61. package/src/commands/drain/drain.enable.command.js +27 -0
  62. package/src/commands/drain/drain.get.command.js +38 -0
  63. package/src/commands/drain/drain.remove.command.js +26 -0
  64. package/src/commands/emails/emails.add.command.js +32 -0
  65. package/src/commands/emails/emails.args.js +8 -0
  66. package/src/commands/emails/emails.command.js +35 -0
  67. package/src/commands/emails/emails.docs.md +79 -0
  68. package/src/commands/emails/emails.open.command.js +15 -0
  69. package/src/commands/emails/emails.primary.command.js +29 -0
  70. package/src/commands/emails/emails.remove-all.command.js +54 -0
  71. package/src/commands/emails/emails.remove.command.js +25 -0
  72. package/src/commands/env/env.command.js +77 -0
  73. package/src/commands/env/env.docs.md +99 -0
  74. package/src/commands/env/env.import-vars.command.js +45 -0
  75. package/src/commands/env/env.import.command.js +29 -0
  76. package/src/commands/env/env.rm.command.js +25 -0
  77. package/src/commands/env/env.set.command.js +32 -0
  78. package/src/commands/features/features.args.js +9 -0
  79. package/src/commands/features/features.command.js +7 -0
  80. package/src/commands/features/features.disable.command.js +25 -0
  81. package/src/commands/features/features.docs.md +71 -0
  82. package/src/commands/features/features.enable.command.js +32 -0
  83. package/src/commands/features/features.info.command.js +27 -0
  84. package/src/commands/features/features.list.command.js +49 -0
  85. package/src/commands/global.args.js +45 -0
  86. package/src/commands/global.commands.js +461 -0
  87. package/src/commands/global.options.js +186 -0
  88. package/src/commands/help/help.command.js +9 -0
  89. package/src/commands/help/help.docs.md +9 -0
  90. package/src/commands/k8s/k8s.add-persistent-storage.command.js +39 -0
  91. package/src/commands/k8s/k8s.args.js +9 -0
  92. package/src/commands/k8s/k8s.command.js +12 -0
  93. package/src/commands/k8s/k8s.create.command.js +86 -0
  94. package/src/commands/k8s/k8s.delete.command.js +40 -0
  95. package/src/commands/k8s/k8s.docs.md +131 -0
  96. package/src/commands/k8s/k8s.get-kubeconfig.command.js +32 -0
  97. package/src/commands/k8s/k8s.get.command.js +43 -0
  98. package/src/commands/k8s/k8s.list.command.js +38 -0
  99. package/src/commands/keycloak/keycloak.command.js +17 -0
  100. package/src/commands/keycloak/keycloak.disable-ng.command.js +13 -0
  101. package/src/commands/keycloak/keycloak.docs.md +197 -0
  102. package/src/commands/keycloak/keycloak.enable-ng.command.js +13 -0
  103. package/src/commands/keycloak/keycloak.get.command.js +17 -0
  104. package/src/commands/keycloak/keycloak.open.command.js +13 -0
  105. package/src/commands/keycloak/keycloak.open.logs.command.js +13 -0
  106. package/src/commands/keycloak/keycloak.open.webui.command.js +13 -0
  107. package/src/commands/keycloak/keycloak.rebuild.command.js +13 -0
  108. package/src/commands/keycloak/keycloak.restart.command.js +13 -0
  109. package/src/commands/keycloak/keycloak.version.check.command.js +17 -0
  110. package/src/commands/keycloak/keycloak.version.command.js +17 -0
  111. package/src/commands/keycloak/keycloak.version.update.command.js +17 -0
  112. package/src/commands/kv/kv.command.js +99 -0
  113. package/src/commands/kv/kv.docs.md +27 -0
  114. package/src/commands/link/link.command.js +31 -0
  115. package/src/commands/link/link.docs.md +22 -0
  116. package/src/commands/{login.js → login/login.command.js} +44 -22
  117. package/src/commands/login/login.docs.md +16 -0
  118. package/src/commands/logout/logout.command.js +15 -0
  119. package/src/commands/logout/logout.docs.md +9 -0
  120. package/src/commands/logs/logs.command.js +81 -0
  121. package/src/commands/logs/logs.docs.md +22 -0
  122. package/src/commands/make-default/make-default.command.js +17 -0
  123. package/src/commands/make-default/make-default.docs.md +15 -0
  124. package/src/commands/matomo/matomo.command.js +17 -0
  125. package/src/commands/matomo/matomo.docs.md +109 -0
  126. package/src/commands/matomo/matomo.get.command.js +17 -0
  127. package/src/commands/matomo/matomo.open.command.js +13 -0
  128. package/src/commands/matomo/matomo.open.logs.command.js +13 -0
  129. package/src/commands/matomo/matomo.open.webui.command.js +13 -0
  130. package/src/commands/matomo/matomo.rebuild.command.js +13 -0
  131. package/src/commands/matomo/matomo.restart.command.js +13 -0
  132. package/src/commands/metabase/metabase.command.js +17 -0
  133. package/src/commands/metabase/metabase.docs.md +169 -0
  134. package/src/commands/metabase/metabase.get.command.js +17 -0
  135. package/src/commands/metabase/metabase.open.command.js +13 -0
  136. package/src/commands/metabase/metabase.open.logs.command.js +13 -0
  137. package/src/commands/metabase/metabase.open.webui.command.js +13 -0
  138. package/src/commands/metabase/metabase.rebuild.command.js +13 -0
  139. package/src/commands/metabase/metabase.restart.command.js +13 -0
  140. package/src/commands/metabase/metabase.version.check.command.js +17 -0
  141. package/src/commands/metabase/metabase.version.command.js +17 -0
  142. package/src/commands/metabase/metabase.version.update.command.js +17 -0
  143. package/src/commands/ng/ng.args.js +27 -0
  144. package/src/commands/ng/ng.command.js +45 -0
  145. package/src/commands/ng/ng.create.command.js +60 -0
  146. package/src/commands/ng/ng.create.external.command.js +44 -0
  147. package/src/commands/ng/ng.delete.command.js +22 -0
  148. package/src/commands/ng/ng.delete.external.command.js +25 -0
  149. package/src/commands/ng/ng.docs.md +214 -0
  150. package/src/commands/ng/ng.get-config.command.js +32 -0
  151. package/src/commands/ng/ng.get.command.js +22 -0
  152. package/src/commands/ng/ng.link.command.js +25 -0
  153. package/src/commands/ng/ng.options.js +9 -0
  154. package/src/commands/ng/ng.search.command.js +22 -0
  155. package/src/commands/ng/ng.unlink.command.js +25 -0
  156. package/src/commands/notify-email/notify-email.add.command.js +65 -0
  157. package/src/commands/notify-email/notify-email.command.js +61 -0
  158. package/src/commands/notify-email/notify-email.docs.md +60 -0
  159. package/src/commands/notify-email/notify-email.remove.command.js +24 -0
  160. package/src/commands/open/open.command.js +24 -0
  161. package/src/commands/open/open.docs.md +16 -0
  162. package/src/commands/otoroshi/otoroshi.command.js +17 -0
  163. package/src/commands/otoroshi/otoroshi.disable-ng.command.js +13 -0
  164. package/src/commands/otoroshi/otoroshi.docs.md +211 -0
  165. package/src/commands/otoroshi/otoroshi.enable-ng.command.js +13 -0
  166. package/src/commands/otoroshi/otoroshi.get-config.command.js +13 -0
  167. package/src/commands/otoroshi/otoroshi.get.command.js +17 -0
  168. package/src/commands/otoroshi/otoroshi.open.command.js +13 -0
  169. package/src/commands/otoroshi/otoroshi.open.logs.command.js +13 -0
  170. package/src/commands/otoroshi/otoroshi.open.webui.command.js +13 -0
  171. package/src/commands/otoroshi/otoroshi.rebuild.command.js +13 -0
  172. package/src/commands/otoroshi/otoroshi.restart.command.js +13 -0
  173. package/src/commands/otoroshi/otoroshi.version.check.command.js +17 -0
  174. package/src/commands/otoroshi/otoroshi.version.command.js +17 -0
  175. package/src/commands/otoroshi/otoroshi.version.update.command.js +17 -0
  176. package/src/commands/profile/profile.command.js +60 -0
  177. package/src/commands/profile/profile.docs.md +23 -0
  178. package/src/commands/profile/profile.open.command.js +12 -0
  179. package/src/commands/published-config/published-config.command.js +40 -0
  180. package/src/commands/published-config/published-config.docs.md +77 -0
  181. package/src/commands/published-config/published-config.import.command.js +29 -0
  182. package/src/commands/published-config/published-config.rm.command.js +27 -0
  183. package/src/commands/published-config/published-config.set.command.js +34 -0
  184. package/src/commands/restart/restart.command.js +77 -0
  185. package/src/commands/restart/restart.docs.md +21 -0
  186. package/src/commands/scale/scale.command.js +121 -0
  187. package/src/commands/scale/scale.docs.md +23 -0
  188. package/src/commands/service/service.command.js +91 -0
  189. package/src/commands/service/service.docs.md +104 -0
  190. package/src/commands/service/service.link-addon.command.js +24 -0
  191. package/src/commands/service/service.link-app.command.js +23 -0
  192. package/src/commands/service/service.unlink-addon.command.js +24 -0
  193. package/src/commands/service/service.unlink-app.command.js +23 -0
  194. package/src/commands/ssh/ssh.command.js +40 -0
  195. package/src/commands/ssh/ssh.docs.md +17 -0
  196. package/src/commands/ssh-keys/ssh-keys.add.command.js +41 -0
  197. package/src/commands/ssh-keys/ssh-keys.args.js +8 -0
  198. package/src/commands/ssh-keys/ssh-keys.command.js +50 -0
  199. package/src/commands/ssh-keys/ssh-keys.docs.md +66 -0
  200. package/src/commands/ssh-keys/ssh-keys.open.command.js +12 -0
  201. package/src/commands/ssh-keys/ssh-keys.remove-all.command.js +54 -0
  202. package/src/commands/ssh-keys/ssh-keys.remove.command.js +26 -0
  203. package/src/commands/status/status.command.js +122 -0
  204. package/src/commands/status/status.docs.md +17 -0
  205. package/src/commands/stop/stop.command.js +23 -0
  206. package/src/commands/stop/stop.docs.md +16 -0
  207. package/src/commands/tcp-redirs/tcp-redirs.add.command.js +24 -0
  208. package/src/commands/tcp-redirs/tcp-redirs.command.js +41 -0
  209. package/src/commands/tcp-redirs/tcp-redirs.docs.md +71 -0
  210. package/src/commands/tcp-redirs/tcp-redirs.list-namespaces.command.js +48 -0
  211. package/src/commands/tcp-redirs/tcp-redirs.options.js +11 -0
  212. package/src/commands/tcp-redirs/tcp-redirs.remove.command.js +34 -0
  213. package/src/commands/tokens/tokens.command.js +43 -0
  214. package/src/commands/tokens/tokens.create.command.js +108 -0
  215. package/src/commands/tokens/tokens.docs.md +50 -0
  216. package/src/commands/tokens/tokens.revoke.command.js +25 -0
  217. package/src/commands/unlink/unlink.command.js +21 -0
  218. package/src/commands/unlink/unlink.docs.md +15 -0
  219. package/src/commands/version/version.command.js +13 -0
  220. package/src/commands/version/version.docs.md +9 -0
  221. package/src/commands/webhooks/webhooks.add.command.js +51 -0
  222. package/src/commands/webhooks/webhooks.command.js +57 -0
  223. package/src/commands/webhooks/webhooks.docs.md +61 -0
  224. package/src/commands/webhooks/webhooks.remove.command.js +24 -0
  225. package/src/lib/cliparse-patched.js +192 -0
  226. package/src/lib/define-argument.js +7 -0
  227. package/src/lib/define-argument.types.d.ts +23 -0
  228. package/src/lib/define-command.js +7 -0
  229. package/src/lib/define-command.types.d.ts +85 -0
  230. package/src/lib/define-common.types.d.ts +18 -0
  231. package/src/lib/define-option.js +7 -0
  232. package/src/lib/define-option.types.d.ts +29 -0
  233. package/src/lib/get-command-info.js +86 -0
  234. package/src/lib/get-command-info.types.d.ts +42 -0
  235. package/src/lib/zod-utils.js +66 -0
  236. package/src/models/addon.js +2 -3
  237. package/src/models/application.js +4 -5
  238. package/src/models/application_configuration.js +5 -23
  239. package/src/models/domain.js +34 -2
  240. package/src/models/exit-strategy-option.js +0 -9
  241. package/src/models/git.js +1 -4
  242. package/src/models/log-v4.js +5 -0
  243. package/src/models/log.js +5 -0
  244. package/src/models/namespaces.js +1 -2
  245. package/src/models/notification.js +1 -7
  246. package/src/parsers.js +33 -92
  247. package/src/command-options.js +0 -55
  248. package/src/command-promise-handler.js +0 -16
  249. package/src/commands/accesslogs.js +0 -138
  250. package/src/commands/addon.js +0 -391
  251. package/src/commands/applications.js +0 -123
  252. package/src/commands/cancel-deploy.js +0 -19
  253. package/src/commands/config.js +0 -47
  254. package/src/commands/console.js +0 -20
  255. package/src/commands/create.js +0 -129
  256. package/src/commands/database.js +0 -73
  257. package/src/commands/delete.js +0 -24
  258. package/src/commands/deploy.js +0 -133
  259. package/src/commands/diag.js +0 -126
  260. package/src/commands/domain.js +0 -445
  261. package/src/commands/drain.js +0 -164
  262. package/src/commands/emails.js +0 -156
  263. package/src/commands/env.js +0 -124
  264. package/src/commands/features.js +0 -87
  265. package/src/commands/k8s.js +0 -193
  266. package/src/commands/keycloak.js +0 -138
  267. package/src/commands/kv.js +0 -93
  268. package/src/commands/link.js +0 -20
  269. package/src/commands/logout.js +0 -8
  270. package/src/commands/logs.js +0 -45
  271. package/src/commands/makeDefault.js +0 -11
  272. package/src/commands/matomo.js +0 -85
  273. package/src/commands/metabase.js +0 -112
  274. package/src/commands/ng.js +0 -202
  275. package/src/commands/notify-email.js +0 -99
  276. package/src/commands/open.js +0 -13
  277. package/src/commands/otoroshi.js +0 -149
  278. package/src/commands/profile.js +0 -55
  279. package/src/commands/published-config.js +0 -70
  280. package/src/commands/restart.js +0 -52
  281. package/src/commands/scale.js +0 -66
  282. package/src/commands/service.js +0 -105
  283. package/src/commands/ssh-keys.js +0 -144
  284. package/src/commands/ssh.js +0 -20
  285. package/src/commands/status.js +0 -115
  286. package/src/commands/stop.js +0 -12
  287. package/src/commands/tcp-redirs.js +0 -80
  288. package/src/commands/tokens.js +0 -144
  289. package/src/commands/unlink.js +0 -14
  290. package/src/commands/version.js +0 -6
  291. package/src/commands/webhooks.js +0 -74
@@ -1,93 +0,0 @@
1
- import { getAllEnvVars } from '@clevercloud/client/esm/api/v2/addon.js';
2
- import Redis from 'ioredis';
3
- import { styleText } from '../lib/style-text.js';
4
- import { Logger } from '../logger.js';
5
- import { findAddonsByNameOrId } from '../models/ids-resolver.js';
6
- import { sendToApi } from '../models/send-to-api.js';
7
-
8
- const URL_ENV_KEY = 'REDIS_URL';
9
- const MAX_RETRIES_PER_REQUEST = 1;
10
-
11
- /**
12
- * Send a raw command to a compatible KV database
13
- * @param {Object} params
14
- * @param {Array<string>} params.args
15
- * @param {Object} params.options
16
- * @param {string} params.options.format
17
- * @returns {Promise<void>}
18
- */
19
- export async function sendRawCommand(params) {
20
- const [addonIdOrRealIdOrName] = params.args;
21
- const { org, format } = params.options;
22
-
23
- const addons = await findAddonsByNameOrId(addonIdOrRealIdOrName, org);
24
-
25
- if (addons.length === 0) {
26
- throw new Error(`Add-on ${addonIdOrRealIdOrName} not found`);
27
- }
28
-
29
- if (addons.length > 1) {
30
- const formattedAddons = addons
31
- .map(({ addonId, ownerId }) => `\n${styleText('grey', `- ${addonId} (${ownerId})`)}`)
32
- .join('');
33
- throw new Error(`Several add-ons found for '${addonIdOrRealIdOrName}', use ID instead:${formattedAddons}`);
34
- }
35
-
36
- const { addonId, ownerId } = addons[0];
37
-
38
- const url = await getAddonUrl(ownerId, addonId);
39
-
40
- Logger.debug(`Extracted command: ${params.args.join(' ')}`);
41
- const command = params.args.slice(1);
42
-
43
- const result = await sendCommand(url, command);
44
-
45
- switch (format) {
46
- case 'json': {
47
- Logger.printJson(result);
48
- break;
49
- }
50
- case 'human':
51
- default: {
52
- Logger.println(result);
53
- }
54
- }
55
- }
56
-
57
- /**
58
- * Get the URL of the compatible KV database
59
- * @param {string} ownerId
60
- * @param {string} addonId
61
- * @returns {Promise<string>} the URL of the compatible KV database
62
- */
63
- async function getAddonUrl(ownerId, addonId) {
64
- const envVars = await getAllEnvVars({ id: ownerId, addonId }).then(sendToApi);
65
- const redisUrl = envVars.find((env) => env.name === URL_ENV_KEY)?.value;
66
-
67
- if (!redisUrl) {
68
- throw new Error(
69
- `Environment variable ${styleText('red', URL_ENV_KEY)} not found, is it a Materia KV or Redis® add-on?`,
70
- );
71
- }
72
-
73
- return redisUrl;
74
- }
75
-
76
- /**
77
- * Send a command to a compatible KV database
78
- * @param {string} url
79
- * @param {Array<string>} command
80
- * @returns {Promise<string>} the command result
81
- */
82
- async function sendCommand(url, command) {
83
- Logger.debug(`Sending command '${command.join(' ')}' to ${url}`);
84
- const client = new Redis(url, { maxRetriesPerRequest: MAX_RETRIES_PER_REQUEST });
85
- try {
86
- const result = await client.call(...command);
87
- Logger.debug(`Command result: ${result}`);
88
- return result;
89
- } finally {
90
- await client.disconnect();
91
- Logger.debug('Disconnected from server');
92
- }
93
- }
@@ -1,20 +0,0 @@
1
- import { styleText } from '../lib/style-text.js';
2
- import { Logger } from '../logger.js';
3
- import * as Application from '../models/application.js';
4
-
5
- export async function link(params) {
6
- const [app] = params.args;
7
- const { org: orgaIdOrName, alias } = params.options;
8
-
9
- let appConfigEntry;
10
- if (app.app_id != null && orgaIdOrName != null) {
11
- Logger.warn("You've specified a unique application ID, organisation option will be ignored");
12
- appConfigEntry = await Application.linkRepo(app, null, alias);
13
- } else {
14
- appConfigEntry = await Application.linkRepo(app, orgaIdOrName, alias);
15
- }
16
-
17
- Logger.printSuccess(
18
- `Application ${styleText('green', appConfigEntry.app_id)} has been successfully linked to local alias ${styleText('green', appConfigEntry.alias)}!`,
19
- );
20
- }
@@ -1,8 +0,0 @@
1
- import { Logger } from '../logger.js';
2
- import { conf, writeOAuthConf } from '../models/configuration.js';
3
-
4
- export async function logout() {
5
- // write empty object
6
- await writeOAuthConf({});
7
- Logger.println(`${conf.CONFIGURATION_FILE} has been updated.`);
8
- }
@@ -1,45 +0,0 @@
1
- import { styleText } from '../lib/style-text.js';
2
- import { Logger } from '../logger.js';
3
- import * as Application from '../models/application.js';
4
- import { resolveAddonId } from '../models/ids-resolver.js';
5
- import * as Log from '../models/log-v4.js';
6
- import * as LogV2 from '../models/log.js';
7
- import { Deferred } from '../models/utils.js';
8
-
9
- export async function appLogs(params) {
10
- const {
11
- alias,
12
- app: appIdOrName,
13
- addon: addonIdOrRealId,
14
- after: since,
15
- before: until,
16
- search,
17
- 'deployment-id': deploymentId,
18
- format,
19
- } = params.options;
20
-
21
- // ignore --search ""
22
- const filter = search !== '' ? search : null;
23
- const isForHuman = format === 'human';
24
-
25
- // TODO: drop when addons are migrated to the v4 API
26
- if (addonIdOrRealId != null) {
27
- const addonId = await resolveAddonId(addonIdOrRealId);
28
- if (isForHuman) {
29
- Logger.println(styleText('blue', 'Waiting for addon logs…'));
30
- } else {
31
- throw new Error(`"${format}" format is not yet available for add-on logs`);
32
- }
33
- return LogV2.displayLogs({ appAddonId: addonId, since, until, filter, deploymentId });
34
- }
35
-
36
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
37
-
38
- if (isForHuman) {
39
- Logger.println(styleText('blue', 'Waiting for application logs…'));
40
- }
41
-
42
- const deferred = new Deferred();
43
- await Log.displayLogs({ ownerId, appId, since, until, filter, deploymentId, format, deferred });
44
- return deferred.promise;
45
- }
@@ -1,11 +0,0 @@
1
- import { styleText } from '../lib/style-text.js';
2
- import { Logger } from '../logger.js';
3
- import * as AppConfig from '../models/app_configuration.js';
4
-
5
- export async function makeDefault(params) {
6
- const [alias] = params.args;
7
-
8
- await AppConfig.setDefault(alias);
9
-
10
- Logger.printSuccess(`The application ${styleText('green', alias)} has been set as default`);
11
- }
@@ -1,85 +0,0 @@
1
- import {
2
- operatorList,
3
- operatorOpen,
4
- operatorOpenLogs,
5
- operatorOpenWebUi,
6
- operatorPrint,
7
- operatorReboot,
8
- operatorRebuild,
9
- } from '../lib/operator-commands.js';
10
-
11
- /**
12
- * Get the details of a Matomo operator
13
- * @param {object} params The command's parameters
14
- * @param {string} params.args[0] The operator's name or ID
15
- * @param {string} params.options.format The output format
16
- * @returns {Promise<void>}
17
- */
18
- export async function get(params) {
19
- const [addonIdOrName] = params.args;
20
- const { format } = params.options;
21
- await operatorPrint('matomo', addonIdOrName, format);
22
- }
23
-
24
- /**
25
- * List all Matomo operators
26
- * @returns {Promise<void>}
27
- */
28
- export async function list(params) {
29
- await operatorList('addon-matomo', params.options.format);
30
- }
31
-
32
- /**
33
- * Open a Matomo operator dashboard in the Clever Cloud Console
34
- * @param {object} params The command's parameters
35
- * @param {string} params.args[0] The operator's name or ID
36
- * @returns {Promise<void>}
37
- */
38
- export async function open(params) {
39
- const [addonIdOrName] = params.args;
40
- await operatorOpen('matomo', addonIdOrName);
41
- }
42
-
43
- /**
44
- * Open the Logs section of a Matomo Operator application in the Clever Cloud Console
45
- * @param {object} params The command's parameters
46
- * @param {string} params.args[0] The operator's name or ID
47
- * @returns {Promise<void>}
48
- */
49
- export async function openLogs(params) {
50
- const [addonIdOrName] = params.args;
51
- await operatorOpenLogs('matomo', addonIdOrName);
52
- }
53
-
54
- /**
55
- * Open the Web UI of a Matomo Operator application in the Clever Cloud Console
56
- * @param {object} params The command's parameters
57
- * @param {string} params.args[0] The operator's name or ID
58
- * @returns {Promise<void>}
59
- */
60
- export async function openWebUi(params) {
61
- const [addonIdOrName] = params.args;
62
- await operatorOpenWebUi('matomo', addonIdOrName);
63
- }
64
-
65
- /**
66
- * Reboot a Matomo operator
67
- * @param {object} params The command's parameters
68
- * @param {string} params.args[0] The operator's name or ID
69
- * @returns {Promise<void>}
70
- */
71
- export async function reboot(params) {
72
- const [addonIdOrName] = params.args;
73
- await operatorReboot('matomo', addonIdOrName);
74
- }
75
-
76
- /**
77
- * Rebuild a Matomo operator
78
- * @param {object} params The command's parameters
79
- * @param {string} params.args[0] The operator's name or ID
80
- * @returns {Promise<void>}
81
- */
82
- export async function rebuild(params) {
83
- const [addonIdOrName] = params.args;
84
- await operatorRebuild('matomo', addonIdOrName);
85
- }
@@ -1,112 +0,0 @@
1
- import {
2
- operatorCheckVersion,
3
- operatorList,
4
- operatorOpen,
5
- operatorOpenLogs,
6
- operatorOpenWebUi,
7
- operatorPrint,
8
- operatorReboot,
9
- operatorRebuild,
10
- operatorUpdateVersion,
11
- } from '../lib/operator-commands.js';
12
-
13
- /**
14
- * Check the version of a Metabase operator
15
- * @param {object} params The command's parameters
16
- * @param {string} params.args[0] The operator's name or ID
17
- * @param {string} params.options.format The output format
18
- * @returns {Promise<void>}
19
- */
20
- export async function checkVersion(params) {
21
- const [addonIdOrName] = params.args;
22
- const { format } = params.options;
23
- await operatorCheckVersion('metabase', addonIdOrName, format);
24
- }
25
-
26
- /**
27
- * Update the version of a Metabase operator
28
- * @param {object} params The command's parameters
29
- * @param {string} params.args[0] The operator's name or ID
30
- * @returns {Promise<void>}
31
- */
32
- export async function updateVersion(params) {
33
- const [addonIdOrName] = params.args;
34
- const { target } = params.options;
35
- await operatorUpdateVersion('metabase', target, addonIdOrName);
36
- }
37
-
38
- /**
39
- * Get the details of a Metabase operator
40
- * @param {object} params The command's parameters
41
- * @param {string} params.args[0] The operator's name or ID
42
- * @param {string} params.options.format The output format
43
- * @returns {Promise<void>}
44
- */
45
- export async function get(params) {
46
- const [addonIdOrName] = params.args;
47
- const { format } = params.options;
48
- await operatorPrint('metabase', addonIdOrName, format);
49
- }
50
-
51
- /**
52
- * List all Metabase operators
53
- * @returns {Promise<void>}
54
- */
55
- export async function list(params) {
56
- await operatorList('metabase', params.options.format);
57
- }
58
-
59
- /**
60
- * Open a Metabase operator dashboard in the Clever Cloud Console
61
- * @param {object} params The command's parameters
62
- * @param {string} params.args[0] The operator's name or ID
63
- * @returns {Promise<void>}
64
- */
65
- export async function open(params) {
66
- const [addonIdOrName] = params.args;
67
- await operatorOpen('metabase', addonIdOrName);
68
- }
69
-
70
- /**
71
- * Open the Logs section of a Metabase Operator application in the Clever Cloud Console
72
- * @param {object} params The command's parameters
73
- * @param {string} params.args[0] The operator's name or ID
74
- * @returns {Promise<void>}
75
- */
76
- export async function openLogs(params) {
77
- const [addonIdOrName] = params.args;
78
- await operatorOpenLogs('metabase', addonIdOrName);
79
- }
80
-
81
- /**
82
- * Open the Web UI of a Metabase Operator application in the Clever Cloud Console
83
- * @param {object} params The command's parameters
84
- * @param {string} params.args[0] The operator's name or ID
85
- * @returns {Promise<void>}
86
- */
87
- export async function openWebUi(params) {
88
- const [addonIdOrName] = params.args;
89
- await operatorOpenWebUi('metabase', addonIdOrName);
90
- }
91
-
92
- /**
93
- * Reboot a Metabase operator
94
- * @param {object} params The command's parameters
95
- * @param {string} params.args[0] The operator's name or ID
96
- * @returns {Promise<void>}
97
- */
98
- export async function reboot(params) {
99
- const [addonIdOrName] = params.args;
100
- await operatorReboot('metabase', addonIdOrName);
101
- }
102
-
103
- /**
104
- * Rebuild a Metabase operator
105
- * @param {object} params The command's parameters
106
- * @param {string} params.args[0] The operator's name or ID
107
- * @returns {Promise<void>}
108
- */
109
- export async function rebuild(params) {
110
- const [addonIdOrName] = params.args;
111
- await operatorRebuild('metabase', addonIdOrName);
112
- }
@@ -1,202 +0,0 @@
1
- import { printResults } from '../lib/ng-print.js';
2
- import { styleText } from '../lib/style-text.js';
3
- import { Logger } from '../logger.js';
4
- import * as networkGroupResources from '../models/ng-resources.js';
5
- import * as networkGroup from '../models/ng.js';
6
-
7
- /** Create a Network Group
8
- * @param {Object} params
9
- * @param {Array<Object>} params.args
10
- * @param {Object} params.args[0] Network Group label
11
- * @param {string} params.options.description Network Group description
12
- * @param {Array<string>} params.options.link Array of member IDs or labels to link to the Network Group
13
- * @param {Object} params.options.org Organisation ID or name
14
- * @param {string} params.options.tags Comma-separated list of tags
15
- */
16
- export async function createNg(params) {
17
- const [ngLabel] = params.args;
18
- const label = ngLabel.ngResourceLabel;
19
- const { description, link: membersIds, org, tags } = params.options;
20
-
21
- await networkGroup.create(label, description, tags, membersIds, org);
22
-
23
- const successMessage = `Network Group ${styleText('green', label)} successfully created`;
24
- if (membersIds == null) {
25
- Logger.printSuccess(`${successMessage}!`);
26
- } else {
27
- Logger.printSuccess(`${successMessage} with member(s):`);
28
- Logger.println(membersIds.map((id) => styleText('grey', ` - ${id}`)).join('\n'));
29
- }
30
- }
31
-
32
- /** Delete a Network Group
33
- * @param {Object} params
34
- * @param {Object} params.args[0] Network Group ID or label
35
- * @param {Object} params.options.org Organisation ID or name
36
- */
37
- export async function deleteNg(params) {
38
- const [ngIdOrLabel] = params.args;
39
- const { org } = params.options;
40
-
41
- await networkGroup.destroy(ngIdOrLabel, org);
42
- const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
43
- Logger.printSuccess(`Network Group ${styleText('green', ngText)} successfully deleted!`);
44
- }
45
-
46
- /** Create an external peer in a Network Group
47
- * @param {Object} params
48
- * @param {Object} params.args[0] External peer ID or label
49
- * @param {Object} params.args[1] Network Group ID or label
50
- * @param {string} params.args[2] WireGuard public key
51
- * @param {Object} params.options.org Organisation ID or name
52
- */
53
- export async function createExternalPeer(params) {
54
- const [peerIdOrLabel, ngIdOrLabel, publicKey] = params.args;
55
- const { org } = params.options;
56
-
57
- await networkGroupResources.createExternalPeerWithParent(ngIdOrLabel, peerIdOrLabel.ngResourceLabel, publicKey, org);
58
- const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
59
- Logger.printSuccess(
60
- `External peer ${styleText('green', peerIdOrLabel.ngResourceLabel)} successfully created in Network Group ${styleText('green', ngText)}`,
61
- );
62
- }
63
-
64
- /** Delete an external peer from a Network Group
65
- * @param {Object} params
66
- * @param {Object} params.args[0] External peer ID or label
67
- * @param {Object} params.args[1] Network Group ID or label
68
- * @param {Object} params.options.org Organisation ID or name
69
- */
70
- export async function deleteExternalPeer(params) {
71
- const [peerIdOrLabel, ngIdOrLabel] = params.args;
72
- const { org } = params.options;
73
-
74
- const peerText = peerIdOrLabel.ngResourceLabel ?? peerIdOrLabel.memberId;
75
- const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
76
- await networkGroupResources.deleteExternalPeerWithParent(ngIdOrLabel, peerText, org);
77
- Logger.printSuccess(
78
- `External peer ${styleText('green', peerText)} successfully deleted from Network Group ${styleText('green', ngText)}`,
79
- );
80
- }
81
-
82
- /** Link a member to a Network Group
83
- * @param {Object} params
84
- * @param {string} params.args[0] Member ID
85
- * @param {Object} params.args[1] Network Group ID or label
86
- * @param {Object} params.options.org Organisation ID or name
87
- */
88
- export async function linkToNg(params) {
89
- const [resourceId, ngIdOrLabel] = params.args;
90
- const { org } = params.options;
91
-
92
- await networkGroupResources.linkMember(ngIdOrLabel, resourceId.memberId, org);
93
- const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
94
- Logger.printSuccess(
95
- `Member ${styleText('green', resourceId.memberId)} successfully linked to Network Group ${styleText('green', ngText)}`,
96
- );
97
- }
98
-
99
- /** Unlink a member from a Network Group
100
- * @param {Object} params
101
- * @param {string} params.args[0] Member ID
102
- * @param {Object} params.args[1] Network Group ID or label
103
- * @param {Object} params.options.org Organisation ID or name
104
- */
105
- export async function unlinkFromNg(params) {
106
- const [resourceId, ngIdOrLabel] = params.args;
107
- const { org } = params.options;
108
-
109
- await networkGroupResources.unlinkMember(ngIdOrLabel, resourceId.memberId, org);
110
- const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
111
- Logger.printSuccess(
112
- `Member ${styleText('green', resourceId.memberId)} successfully unlinked from Network Group ${styleText('green', ngText)}`,
113
- );
114
- }
115
-
116
- /** Print the configuration of a Network Group's peer
117
- * @param {Object} params
118
- * @param {Object} params.args[0] Peer ID or label
119
- * @param {Object} params.args[1] Network Group ID or label
120
- * @param {Object} params.options.org Organisation ID or name
121
- * @param {string} params.options.format Output format
122
- */
123
- export async function getPeerConfig(params) {
124
- const [peerIdOrLabel, ngIdOrLabel] = params.args;
125
- const { org, format } = params.options;
126
-
127
- const config = await networkGroup.getPeerConfig(peerIdOrLabel, ngIdOrLabel, org);
128
-
129
- switch (format) {
130
- case 'json': {
131
- Logger.printJson(config);
132
- break;
133
- }
134
- case 'human':
135
- default: {
136
- const decodedConfiguration = Buffer.from(config.configuration, 'base64').toString('utf8');
137
- Logger.println(decodedConfiguration);
138
- }
139
- }
140
- }
141
-
142
- /** List Network Groups, their members and peers
143
- * @param {Object} params
144
- * @param {Object} params.options.orgaIdOrName Organisation ID or name
145
- * @param {string} params.options.format Output format
146
- */
147
- export async function listNg(params) {
148
- const { org, format } = params.options;
149
-
150
- const ngs = await networkGroup.getAllNGs(org);
151
-
152
- switch (format) {
153
- case 'json': {
154
- Logger.printJson(ngs);
155
- break;
156
- }
157
- case 'human':
158
- default: {
159
- if (!ngs.length) {
160
- Logger.println(`ℹ️ No Network Group found, create one with ${styleText('blue', 'clever ng create')} command`);
161
- return;
162
- }
163
- const ngList = ngs.map(({ id, label, networkIp, members, peers }) => ({
164
- ID: id,
165
- Label: label,
166
- 'Network CIDR': networkIp,
167
- Members: Object.keys(members).length,
168
- Peers: Object.keys(peers).length,
169
- }));
170
-
171
- console.table(ngList);
172
- }
173
- }
174
- }
175
-
176
- /** Show information about a Network Group, a member or a peer
177
- * @param {Object} params
178
- * @param {Object} params.args[0] ID or label of the Network Group, a member or a peer
179
- * @param {Object} params.options.org Organisation ID or name
180
- * @param {string} params.options.format Output format
181
- */
182
- export async function get(params) {
183
- const [idOrLabel] = params.args;
184
- const { org, format } = params.options;
185
- const type = params.options.type ?? 'single';
186
-
187
- await printResults(idOrLabel, org, format, 'get', type);
188
- }
189
-
190
- /** Show information about a Network Group, a member or a peer
191
- * @param {Object} params
192
- * @param {Object} params.args[0] ID or label of the Network Group, a member or a peer
193
- * @param {Object} params.options.org Organisation ID or name
194
- * @param {string} params.options.format Output format
195
- */
196
- export async function search(params) {
197
- const [idOrLabel] = params.args;
198
- const { org, format } = params.options;
199
- const type = params.options.type;
200
-
201
- await printResults(idOrLabel, org, format, 'search', type);
202
- }
@@ -1,99 +0,0 @@
1
- import { createEmailhook, deleteEmailhook, getEmailhooks } from '@clevercloud/client/esm/api/v2/notification.js';
2
- import { styleText } from '../lib/style-text.js';
3
- import { Logger } from '../logger.js';
4
- import { getOrgaIdOrUserId, getOwnerAndApp } from '../models/notification.js';
5
- import { sendToApi } from '../models/send-to-api.js';
6
-
7
- export async function list(params) {
8
- const { org, 'list-all': listAll, format } = params.options;
9
-
10
- // TODO: fix alias option
11
- const { ownerId, appId } = await getOwnerAndApp(null, org, !listAll);
12
- const hooks = await getEmailhooks({ ownerId }).then(sendToApi);
13
-
14
- const formattedHooks = hooks
15
- .filter((hook) => {
16
- const emptyScope = !hook.scope || hook.scope.length === 0;
17
- return !appId || emptyScope || hook.scope.includes(appId);
18
- })
19
- .map((hook) => ({
20
- id: hook.id,
21
- name: hook.name,
22
- ownerId: hook.ownerId,
23
- services: hook.scope ?? [hook.ownerId],
24
- events: hook.events ?? ['ALL'],
25
- notified: hook.notified ? hook.notified.map(({ target }) => target ?? 'whole team') : ['whole team'],
26
- }));
27
-
28
- switch (format) {
29
- case 'json': {
30
- Logger.printJson(formattedHooks);
31
- break;
32
- }
33
- case 'human':
34
- default: {
35
- formattedHooks.forEach((hook) => {
36
- Logger.println(styleText('bold', hook.name ?? hook.id));
37
- Logger.println(` id: ${hook.id}`);
38
- Logger.println(` services: ${hook.services.join(', ')}`);
39
- Logger.println(` events: ${hook.events.join(', ')}`);
40
- if (hook.notified.length > 1) {
41
- Logger.println(' to:');
42
- hook.notified.forEach((target) => Logger.println(` ${target}`));
43
- } else {
44
- Logger.println(` to: ${hook.notified[0]}`);
45
- }
46
- });
47
- }
48
- }
49
- }
50
-
51
- export function getEmailNotificationTargets(notifTargets) {
52
- if (notifTargets == null) {
53
- return [];
54
- }
55
-
56
- return notifTargets
57
- .map((el) => {
58
- if (el.includes('@')) {
59
- return { type: 'email', target: el };
60
- }
61
- if (el.startsWith('user_')) {
62
- return { type: 'userid', target: el };
63
- }
64
- if (el.toLowerCase() === 'organisation') {
65
- return { type: 'organisation' };
66
- }
67
- return null;
68
- })
69
- .filter((e) => e != null);
70
- }
71
-
72
- export async function add(params) {
73
- const { org, event: events, service, notify: notifTargets } = params.options;
74
- const [name] = params.args;
75
-
76
- // TODO: fix alias option
77
- const { ownerId, appId } = await getOwnerAndApp(null, org, !org && !service);
78
-
79
- const body = {
80
- name,
81
- notified: getEmailNotificationTargets(notifTargets),
82
- scope: appId != null && service == null ? [appId] : service,
83
- events,
84
- };
85
-
86
- await createEmailhook({ ownerId }, body).then(sendToApi);
87
-
88
- Logger.println('The webhook has been added');
89
- }
90
-
91
- export async function remove(params) {
92
- const { org } = params.options;
93
- const [notificationId] = params.args;
94
-
95
- const ownerId = await getOrgaIdOrUserId(org);
96
- await deleteEmailhook({ ownerId, id: notificationId }).then(sendToApi);
97
-
98
- Logger.println('The notification has been successfully removed');
99
- }
@@ -1,13 +0,0 @@
1
- import * as Application from '../models/application.js';
2
- import * as Domain from '../models/domain.js';
3
- import { openBrowser } from '../models/utils.js';
4
-
5
- export async function open(params) {
6
- const { alias, app: appIdOrName } = params.options;
7
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
8
-
9
- const vhost = await Domain.getBest(appId, ownerId);
10
- const url = 'https://' + vhost.fqdn;
11
-
12
- await openBrowser(url, 'Opening the application in your browser');
13
- }