clever-tools 4.4.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/bin/clever.js +208 -2128
  2. package/package.json +33 -25
  3. package/src/clever-client/auth-bridge.js +0 -9
  4. package/src/clever-client/drains.js +0 -17
  5. package/src/clever-client/operators.js +1 -1
  6. package/src/commands/README.md +65 -0
  7. package/src/commands/accesslogs/accesslogs.command.js +158 -0
  8. package/src/commands/accesslogs/accesslogs.docs.md +20 -0
  9. package/src/commands/{activity.js → activity/activity.command.js} +74 -44
  10. package/src/commands/activity/activity.docs.md +19 -0
  11. package/src/commands/addon/addon.args.js +14 -0
  12. package/src/commands/addon/addon.command.js +7 -0
  13. package/src/commands/addon/addon.create.command.js +236 -0
  14. package/src/commands/addon/addon.delete.command.js +32 -0
  15. package/src/commands/addon/addon.docs.md +156 -0
  16. package/src/commands/addon/addon.env.command.js +50 -0
  17. package/src/commands/addon/addon.list.command.js +55 -0
  18. package/src/commands/addon/addon.providers.command.js +45 -0
  19. package/src/commands/addon/addon.providers.show.command.js +99 -0
  20. package/src/commands/addon/addon.rename.command.js +24 -0
  21. package/src/commands/applications/applications.command.js +59 -0
  22. package/src/commands/applications/applications.docs.md +31 -0
  23. package/src/commands/applications/applications.list.command.js +100 -0
  24. package/src/commands/cancel-deploy/cancel-deploy.command.js +30 -0
  25. package/src/commands/cancel-deploy/cancel-deploy.docs.md +16 -0
  26. package/src/commands/config/config.args.js +10 -0
  27. package/src/commands/config/config.command.js +20 -0
  28. package/src/commands/config/config.docs.md +86 -0
  29. package/src/commands/config/config.get.command.js +21 -0
  30. package/src/commands/config/config.set.command.js +38 -0
  31. package/src/commands/config/config.update.command.js +88 -0
  32. package/src/commands/console/console.command.js +31 -0
  33. package/src/commands/console/console.docs.md +16 -0
  34. package/src/commands/create/create.command.js +173 -0
  35. package/src/commands/create/create.docs.md +27 -0
  36. package/src/commands/{curl.js → curl/curl.command.js} +10 -3
  37. package/src/commands/curl/curl.docs.md +9 -0
  38. package/src/commands/database/database.args.js +8 -0
  39. package/src/commands/database/database.backups.command.js +60 -0
  40. package/src/commands/database/database.backups.download.command.js +55 -0
  41. package/src/commands/database/database.command.js +10 -0
  42. package/src/commands/database/database.docs.md +52 -0
  43. package/src/commands/delete/delete.command.js +43 -0
  44. package/src/commands/delete/delete.docs.md +17 -0
  45. package/src/commands/deploy/deploy.command.js +166 -0
  46. package/src/commands/deploy/deploy.docs.md +22 -0
  47. package/src/commands/diag/diag.command.js +136 -0
  48. package/src/commands/diag/diag.docs.md +15 -0
  49. package/src/commands/domain/domain.add.command.js +25 -0
  50. package/src/commands/domain/domain.args.js +8 -0
  51. package/src/commands/domain/domain.command.js +38 -0
  52. package/src/commands/domain/domain.diag.command.js +204 -0
  53. package/src/commands/domain/domain.docs.md +143 -0
  54. package/src/commands/domain/domain.favourite.command.js +35 -0
  55. package/src/commands/domain/domain.favourite.set.command.js +24 -0
  56. package/src/commands/domain/domain.favourite.unset.command.js +23 -0
  57. package/src/commands/domain/domain.overview.command.js +157 -0
  58. package/src/commands/domain/domain.rm.command.js +25 -0
  59. package/src/commands/drain/drain.args.js +8 -0
  60. package/src/commands/drain/drain.command.js +56 -0
  61. package/src/commands/drain/drain.create.command.js +128 -0
  62. package/src/commands/drain/drain.disable.command.js +27 -0
  63. package/src/commands/drain/drain.docs.md +129 -0
  64. package/src/commands/drain/drain.enable.command.js +27 -0
  65. package/src/commands/drain/drain.get.command.js +38 -0
  66. package/src/commands/drain/drain.remove.command.js +26 -0
  67. package/src/commands/emails/emails.add.command.js +32 -0
  68. package/src/commands/emails/emails.args.js +8 -0
  69. package/src/commands/emails/emails.command.js +35 -0
  70. package/src/commands/emails/emails.docs.md +79 -0
  71. package/src/commands/emails/emails.open.command.js +15 -0
  72. package/src/commands/emails/emails.primary.command.js +29 -0
  73. package/src/commands/emails/emails.remove-all.command.js +54 -0
  74. package/src/commands/emails/emails.remove.command.js +25 -0
  75. package/src/commands/env/env.command.js +77 -0
  76. package/src/commands/env/env.docs.md +99 -0
  77. package/src/commands/env/env.import-vars.command.js +45 -0
  78. package/src/commands/env/env.import.command.js +29 -0
  79. package/src/commands/env/env.rm.command.js +25 -0
  80. package/src/commands/env/env.set.command.js +32 -0
  81. package/src/commands/features/features.args.js +9 -0
  82. package/src/commands/features/features.command.js +7 -0
  83. package/src/commands/features/features.disable.command.js +25 -0
  84. package/src/commands/features/features.docs.md +71 -0
  85. package/src/commands/features/features.enable.command.js +32 -0
  86. package/src/commands/features/features.info.command.js +27 -0
  87. package/src/commands/features/features.list.command.js +49 -0
  88. package/src/commands/global.args.js +45 -0
  89. package/src/commands/global.commands.js +461 -0
  90. package/src/commands/global.options.js +186 -0
  91. package/src/commands/help/help.command.js +9 -0
  92. package/src/commands/help/help.docs.md +9 -0
  93. package/src/commands/k8s/k8s.add-persistent-storage.command.js +39 -0
  94. package/src/commands/k8s/k8s.args.js +9 -0
  95. package/src/commands/k8s/k8s.command.js +12 -0
  96. package/src/commands/k8s/k8s.create.command.js +86 -0
  97. package/src/commands/k8s/k8s.delete.command.js +40 -0
  98. package/src/commands/k8s/k8s.docs.md +131 -0
  99. package/src/commands/k8s/k8s.get-kubeconfig.command.js +32 -0
  100. package/src/commands/k8s/k8s.get.command.js +43 -0
  101. package/src/commands/k8s/k8s.list.command.js +38 -0
  102. package/src/commands/keycloak/keycloak.command.js +17 -0
  103. package/src/commands/keycloak/keycloak.disable-ng.command.js +13 -0
  104. package/src/commands/keycloak/keycloak.docs.md +197 -0
  105. package/src/commands/keycloak/keycloak.enable-ng.command.js +13 -0
  106. package/src/commands/keycloak/keycloak.get.command.js +17 -0
  107. package/src/commands/keycloak/keycloak.open.command.js +13 -0
  108. package/src/commands/keycloak/keycloak.open.logs.command.js +13 -0
  109. package/src/commands/keycloak/keycloak.open.webui.command.js +13 -0
  110. package/src/commands/keycloak/keycloak.rebuild.command.js +13 -0
  111. package/src/commands/keycloak/keycloak.restart.command.js +13 -0
  112. package/src/commands/keycloak/keycloak.version.check.command.js +17 -0
  113. package/src/commands/keycloak/keycloak.version.command.js +17 -0
  114. package/src/commands/keycloak/keycloak.version.update.command.js +17 -0
  115. package/src/commands/kv/kv.command.js +99 -0
  116. package/src/commands/kv/kv.docs.md +27 -0
  117. package/src/commands/link/link.command.js +31 -0
  118. package/src/commands/link/link.docs.md +22 -0
  119. package/src/commands/{login.js → login/login.command.js} +44 -22
  120. package/src/commands/login/login.docs.md +16 -0
  121. package/src/commands/logout/logout.command.js +15 -0
  122. package/src/commands/logout/logout.docs.md +9 -0
  123. package/src/commands/logs/logs.command.js +81 -0
  124. package/src/commands/logs/logs.docs.md +22 -0
  125. package/src/commands/make-default/make-default.command.js +17 -0
  126. package/src/commands/make-default/make-default.docs.md +15 -0
  127. package/src/commands/matomo/matomo.command.js +17 -0
  128. package/src/commands/matomo/matomo.docs.md +109 -0
  129. package/src/commands/matomo/matomo.get.command.js +17 -0
  130. package/src/commands/matomo/matomo.open.command.js +13 -0
  131. package/src/commands/matomo/matomo.open.logs.command.js +13 -0
  132. package/src/commands/matomo/matomo.open.webui.command.js +13 -0
  133. package/src/commands/matomo/matomo.rebuild.command.js +13 -0
  134. package/src/commands/matomo/matomo.restart.command.js +13 -0
  135. package/src/commands/metabase/metabase.command.js +17 -0
  136. package/src/commands/metabase/metabase.docs.md +169 -0
  137. package/src/commands/metabase/metabase.get.command.js +17 -0
  138. package/src/commands/metabase/metabase.open.command.js +13 -0
  139. package/src/commands/metabase/metabase.open.logs.command.js +13 -0
  140. package/src/commands/metabase/metabase.open.webui.command.js +13 -0
  141. package/src/commands/metabase/metabase.rebuild.command.js +13 -0
  142. package/src/commands/metabase/metabase.restart.command.js +13 -0
  143. package/src/commands/metabase/metabase.version.check.command.js +17 -0
  144. package/src/commands/metabase/metabase.version.command.js +17 -0
  145. package/src/commands/metabase/metabase.version.update.command.js +17 -0
  146. package/src/commands/ng/ng.args.js +27 -0
  147. package/src/commands/ng/ng.command.js +45 -0
  148. package/src/commands/ng/ng.create.command.js +60 -0
  149. package/src/commands/ng/ng.create.external.command.js +44 -0
  150. package/src/commands/ng/ng.delete.command.js +22 -0
  151. package/src/commands/ng/ng.delete.external.command.js +25 -0
  152. package/src/commands/ng/ng.docs.md +214 -0
  153. package/src/commands/ng/ng.get-config.command.js +32 -0
  154. package/src/commands/ng/ng.get.command.js +22 -0
  155. package/src/commands/ng/ng.link.command.js +25 -0
  156. package/src/commands/ng/ng.options.js +9 -0
  157. package/src/commands/ng/ng.search.command.js +22 -0
  158. package/src/commands/ng/ng.unlink.command.js +25 -0
  159. package/src/commands/notify-email/notify-email.add.command.js +65 -0
  160. package/src/commands/notify-email/notify-email.command.js +61 -0
  161. package/src/commands/notify-email/notify-email.docs.md +60 -0
  162. package/src/commands/notify-email/notify-email.remove.command.js +24 -0
  163. package/src/commands/open/open.command.js +24 -0
  164. package/src/commands/open/open.docs.md +16 -0
  165. package/src/commands/otoroshi/otoroshi.command.js +17 -0
  166. package/src/commands/otoroshi/otoroshi.disable-ng.command.js +13 -0
  167. package/src/commands/otoroshi/otoroshi.docs.md +211 -0
  168. package/src/commands/otoroshi/otoroshi.enable-ng.command.js +13 -0
  169. package/src/commands/otoroshi/otoroshi.get-config.command.js +13 -0
  170. package/src/commands/otoroshi/otoroshi.get.command.js +17 -0
  171. package/src/commands/otoroshi/otoroshi.open.command.js +13 -0
  172. package/src/commands/otoroshi/otoroshi.open.logs.command.js +13 -0
  173. package/src/commands/otoroshi/otoroshi.open.webui.command.js +13 -0
  174. package/src/commands/otoroshi/otoroshi.rebuild.command.js +13 -0
  175. package/src/commands/otoroshi/otoroshi.restart.command.js +13 -0
  176. package/src/commands/otoroshi/otoroshi.version.check.command.js +17 -0
  177. package/src/commands/otoroshi/otoroshi.version.command.js +17 -0
  178. package/src/commands/otoroshi/otoroshi.version.update.command.js +17 -0
  179. package/src/commands/profile/profile.command.js +60 -0
  180. package/src/commands/profile/profile.docs.md +23 -0
  181. package/src/commands/profile/profile.open.command.js +12 -0
  182. package/src/commands/published-config/published-config.command.js +40 -0
  183. package/src/commands/published-config/published-config.docs.md +77 -0
  184. package/src/commands/published-config/published-config.import.command.js +29 -0
  185. package/src/commands/published-config/published-config.rm.command.js +27 -0
  186. package/src/commands/published-config/published-config.set.command.js +34 -0
  187. package/src/commands/restart/restart.command.js +77 -0
  188. package/src/commands/restart/restart.docs.md +21 -0
  189. package/src/commands/scale/scale.command.js +121 -0
  190. package/src/commands/scale/scale.docs.md +23 -0
  191. package/src/commands/service/service.command.js +91 -0
  192. package/src/commands/service/service.docs.md +104 -0
  193. package/src/commands/service/service.link-addon.command.js +24 -0
  194. package/src/commands/service/service.link-app.command.js +23 -0
  195. package/src/commands/service/service.unlink-addon.command.js +24 -0
  196. package/src/commands/service/service.unlink-app.command.js +23 -0
  197. package/src/commands/ssh/ssh.command.js +40 -0
  198. package/src/commands/ssh/ssh.docs.md +17 -0
  199. package/src/commands/ssh-keys/ssh-keys.add.command.js +41 -0
  200. package/src/commands/ssh-keys/ssh-keys.args.js +8 -0
  201. package/src/commands/ssh-keys/ssh-keys.command.js +50 -0
  202. package/src/commands/ssh-keys/ssh-keys.docs.md +66 -0
  203. package/src/commands/ssh-keys/ssh-keys.open.command.js +12 -0
  204. package/src/commands/ssh-keys/ssh-keys.remove-all.command.js +54 -0
  205. package/src/commands/ssh-keys/ssh-keys.remove.command.js +26 -0
  206. package/src/commands/status/status.command.js +122 -0
  207. package/src/commands/status/status.docs.md +17 -0
  208. package/src/commands/stop/stop.command.js +23 -0
  209. package/src/commands/stop/stop.docs.md +16 -0
  210. package/src/commands/tcp-redirs/tcp-redirs.add.command.js +24 -0
  211. package/src/commands/tcp-redirs/tcp-redirs.command.js +41 -0
  212. package/src/commands/tcp-redirs/tcp-redirs.docs.md +71 -0
  213. package/src/commands/tcp-redirs/tcp-redirs.list-namespaces.command.js +48 -0
  214. package/src/commands/tcp-redirs/tcp-redirs.options.js +11 -0
  215. package/src/commands/tcp-redirs/tcp-redirs.remove.command.js +34 -0
  216. package/src/commands/tokens/tokens.command.js +43 -0
  217. package/src/commands/tokens/tokens.create.command.js +108 -0
  218. package/src/commands/tokens/tokens.docs.md +50 -0
  219. package/src/commands/tokens/tokens.revoke.command.js +25 -0
  220. package/src/commands/unlink/unlink.command.js +21 -0
  221. package/src/commands/unlink/unlink.docs.md +15 -0
  222. package/src/commands/version/version.command.js +13 -0
  223. package/src/commands/version/version.docs.md +9 -0
  224. package/src/commands/webhooks/webhooks.add.command.js +51 -0
  225. package/src/commands/webhooks/webhooks.command.js +57 -0
  226. package/src/commands/webhooks/webhooks.docs.md +61 -0
  227. package/src/commands/webhooks/webhooks.remove.command.js +24 -0
  228. package/src/lib/cliparse-patched.js +192 -0
  229. package/src/lib/define-argument.js +7 -0
  230. package/src/lib/define-argument.types.d.ts +23 -0
  231. package/src/lib/define-command.js +7 -0
  232. package/src/lib/define-command.types.d.ts +85 -0
  233. package/src/lib/define-common.types.d.ts +18 -0
  234. package/src/lib/define-option.js +7 -0
  235. package/src/lib/define-option.types.d.ts +29 -0
  236. package/src/lib/get-command-info.js +86 -0
  237. package/src/lib/get-command-info.types.d.ts +42 -0
  238. package/src/lib/k8s.js +1 -1
  239. package/src/lib/zod-utils.js +66 -0
  240. package/src/models/addon.js +2 -19
  241. package/src/models/app_configuration.js +0 -30
  242. package/src/models/application.js +4 -5
  243. package/src/models/application_configuration.js +5 -23
  244. package/src/models/domain.js +34 -2
  245. package/src/models/exit-strategy-option.js +0 -9
  246. package/src/models/git.js +1 -4
  247. package/src/models/log-v4.js +15 -4
  248. package/src/models/log.js +5 -0
  249. package/src/models/namespaces.js +1 -2
  250. package/src/models/notification.js +1 -7
  251. package/src/parsers.js +33 -111
  252. package/src/command-options.js +0 -55
  253. package/src/command-promise-handler.js +0 -16
  254. package/src/commands/accesslogs.js +0 -138
  255. package/src/commands/addon.js +0 -391
  256. package/src/commands/applications.js +0 -123
  257. package/src/commands/cancel-deploy.js +0 -19
  258. package/src/commands/config.js +0 -47
  259. package/src/commands/console.js +0 -20
  260. package/src/commands/create.js +0 -129
  261. package/src/commands/database.js +0 -73
  262. package/src/commands/delete.js +0 -24
  263. package/src/commands/deploy.js +0 -133
  264. package/src/commands/diag.js +0 -126
  265. package/src/commands/domain.js +0 -445
  266. package/src/commands/drain.js +0 -164
  267. package/src/commands/emails.js +0 -156
  268. package/src/commands/env.js +0 -124
  269. package/src/commands/features.js +0 -87
  270. package/src/commands/k8s.js +0 -193
  271. package/src/commands/keycloak.js +0 -138
  272. package/src/commands/kv.js +0 -93
  273. package/src/commands/link.js +0 -20
  274. package/src/commands/logout.js +0 -8
  275. package/src/commands/logs.js +0 -45
  276. package/src/commands/makeDefault.js +0 -11
  277. package/src/commands/matomo.js +0 -85
  278. package/src/commands/metabase.js +0 -112
  279. package/src/commands/ng.js +0 -202
  280. package/src/commands/notify-email.js +0 -99
  281. package/src/commands/open.js +0 -13
  282. package/src/commands/otoroshi.js +0 -150
  283. package/src/commands/profile.js +0 -55
  284. package/src/commands/published-config.js +0 -70
  285. package/src/commands/restart.js +0 -52
  286. package/src/commands/scale.js +0 -66
  287. package/src/commands/service.js +0 -105
  288. package/src/commands/ssh-keys.js +0 -144
  289. package/src/commands/ssh.js +0 -20
  290. package/src/commands/status.js +0 -115
  291. package/src/commands/stop.js +0 -12
  292. package/src/commands/tcp-redirs.js +0 -80
  293. package/src/commands/tokens.js +0 -144
  294. package/src/commands/unlink.js +0 -14
  295. package/src/commands/version.js +0 -6
  296. package/src/commands/webhooks.js +0 -74
@@ -1,150 +0,0 @@
1
- import {
2
- operatorCheckVersion,
3
- operatorList,
4
- operatorNgDisable,
5
- operatorNgEnable,
6
- operatorOpen,
7
- operatorOpenLogs,
8
- operatorOpenWebUi,
9
- operatorPrint,
10
- operatorReboot,
11
- operatorRebuild,
12
- operatorUpdateVersion,
13
- } from '../lib/operator-commands.js';
14
-
15
- /**
16
- * Check the version of an Otoroshi operator
17
- * @param {object} params The command's parameters
18
- * @param {string} params.args[0] The operator's name or ID
19
- * @param {string} params.options.format The output format
20
- * @returns {Promise<void>}
21
- */
22
- export async function checkVersion(params) {
23
- const [addonIdOrName] = params.args;
24
- const { format } = params.options;
25
- await operatorCheckVersion('otoroshi', addonIdOrName, format);
26
- }
27
-
28
- /**
29
- * Update the version of an Otoroshi operator
30
- * @param {object} params The command's parameters
31
- * @param {string} params.args[0] The operator's name or ID
32
- * @returns {Promise<void>}
33
- */
34
- export async function updateVersion(params) {
35
- const [addonIdOrName] = params.args;
36
- const { target } = params.options;
37
- await operatorUpdateVersion('otoroshi', target, addonIdOrName);
38
- }
39
-
40
- /**
41
- * Get the details of an Otoroshi operator
42
- * @param {object} params The command's parameters
43
- * @param {string} params.args[0] The operator's name or ID
44
- * @param {string} params.options.format The output format
45
- * @returns {Promise<void>}
46
- */
47
- export async function get(params) {
48
- const [addonIdOrName] = params.args;
49
- const { format } = params.options;
50
- await operatorPrint('otoroshi', addonIdOrName, format);
51
- }
52
-
53
- /**
54
- * Print the configuration of an Otoroshi operator in otoroshictl format
55
- * @param {object} params The command's parameters
56
- * @param {string} params.args[0] The operator's name or ID
57
- * @returns {Promise<void>}
58
- */
59
- export async function getConfig(params) {
60
- const [addonIdOrName] = params.args;
61
- const { format } = params.options;
62
- await operatorPrint('otoroshi', addonIdOrName, 'otoroshictl');
63
- }
64
-
65
- /**
66
- * List all Otoroshi operators
67
- * @returns {Promise<void>}
68
- */
69
- export async function list(params) {
70
- await operatorList('otoroshi', params.options.format);
71
- }
72
-
73
- /**
74
- * Unlink a Operator from a Network Group
75
- * @param {object} params The command's parameters
76
- * @param {string} params.args[0] The operator's name or ID
77
- * @returns {Promise<void>}
78
- * @throws {Error} If the Network Group feature is already disabled
79
- */
80
- export async function ngDisable(params) {
81
- const [addonIdOrName] = params.args;
82
- await operatorNgDisable('otoroshi', addonIdOrName);
83
- }
84
-
85
- /**
86
- * Link a Operator to a Network Group
87
- * @param {object} params The command's parameters
88
- * @param {string} params.args[0] The operator's name or ID
89
- * @returns {Promise<void>}
90
- * @throws {Error} If the Network Group feature is already enabled
91
- */
92
- export async function ngEnable(params) {
93
- const [addonIdOrName] = params.args;
94
- await operatorNgEnable('otoroshi', addonIdOrName);
95
- }
96
-
97
- /**
98
- * Open an Otoroshi operator dashboard in the Clever Cloud Console
99
- * @param {object} params The command's parameters
100
- * @param {string} params.args[0] The operator's name or ID
101
- * @returns {Promise<void>}
102
- */
103
- export async function open(params) {
104
- const [addonIdOrName] = params.args;
105
- await operatorOpen('otoroshi', addonIdOrName);
106
- }
107
-
108
- /**
109
- * Open the Logs section of an Otoroshi Operator application in the Clever Cloud Console
110
- * @param {object} params The command's parameters
111
- * @param {string} params.args[0] The operator's name or ID
112
- * @returns {Promise<void>}
113
- */
114
- export async function openLogs(params) {
115
- const [addonIdOrName] = params.args;
116
- await operatorOpenLogs('otoroshi', addonIdOrName);
117
- }
118
-
119
- /**
120
- * Open the Web UI of an Otoroshi Operator application in the Clever Cloud Console
121
- * @param {object} params The command's parameters
122
- * @param {string} params.args[0] The operator's name or ID
123
- * @returns {Promise<void>}
124
- */
125
- export async function openWebUi(params) {
126
- const [addonIdOrName] = params.args;
127
- await operatorOpenWebUi('otoroshi', addonIdOrName);
128
- }
129
-
130
- /**
131
- * Reboot an Otoroshi operator
132
- * @param {object} params The command's parameters
133
- * @param {string} params.args[0] The operator's name or ID
134
- * @returns {Promise<void>}
135
- */
136
- export async function reboot(params) {
137
- const [addonIdOrName] = params.args;
138
- await operatorReboot('otoroshi', addonIdOrName);
139
- }
140
-
141
- /**
142
- * Rebuild an Otoroshi operator
143
- * @param {object} params The command's parameters
144
- * @param {string} params.args[0] The operator's name or ID
145
- * @returns {Promise<void>}
146
- */
147
- export async function rebuild(params) {
148
- const [addonIdOrName] = params.args;
149
- await operatorRebuild('otoroshi', addonIdOrName);
150
- }
@@ -1,55 +0,0 @@
1
- import dedent from 'dedent';
2
- import { styleText } from '../lib/style-text.js';
3
- import { Logger } from '../logger.js';
4
- import * as User from '../models/user.js';
5
- import { openBrowser } from '../models/utils.js';
6
-
7
- export async function profile(params) {
8
- const { format } = params.options;
9
-
10
- const user = await User.getCurrent();
11
- const currentToken = await User.getCurrentToken();
12
- const tokenExpiration = new Date(currentToken.expirationDate).toLocaleString('en-US', {
13
- year: 'numeric',
14
- month: 'short',
15
- day: 'numeric',
16
- hour: 'numeric',
17
- minute: 'numeric',
18
- hour12: false,
19
- timeZone: 'UTC',
20
- timeZoneName: 'short',
21
- });
22
-
23
- const formattedUser = {
24
- id: user.id,
25
- email: user.email,
26
- name: user.name,
27
- avatar: user.avatar,
28
- creationDate: new Date(user.creationDate),
29
- tokenExpiration: new Date(currentToken.expirationDate).toISOString(),
30
- lang: user.lang,
31
- has2FA: user.preferredMFA != null && user.preferredMFA !== 'NONE',
32
- };
33
-
34
- switch (format) {
35
- case 'json': {
36
- Logger.printJson(formattedUser);
37
- break;
38
- }
39
- case 'human':
40
- default: {
41
- Logger.println(dedent`
42
- You're currently logged in as:
43
- User id ${formattedUser.id}
44
- Name ${formattedUser.name ?? styleText(['red', 'bold'], '[not specified]')}
45
- Email ${formattedUser.email}
46
- Token expiration ${tokenExpiration}
47
- Two factor auth ${formattedUser.has2FA ? 'yes' : 'no'}
48
- `);
49
- }
50
- }
51
- }
52
-
53
- export async function openProfile() {
54
- await openBrowser('/users/me/information', 'Opening the profile page in your browser');
55
- }
@@ -1,70 +0,0 @@
1
- import { getAllExposedEnvVars, updateAllExposedEnvVars } from '@clevercloud/client/esm/api/v2/application.js';
2
- import { toNameEqualsValueString, validateName } from '@clevercloud/client/esm/utils/env-vars.js';
3
- import { Logger } from '../logger.js';
4
- import * as Application from '../models/application.js';
5
- import { sendToApi } from '../models/send-to-api.js';
6
- import * as variables from '../models/variables.js';
7
-
8
- export async function list(params) {
9
- const { alias, app: appIdOrName, format } = params.options;
10
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
11
-
12
- const publishedConfigs = await getAllExposedEnvVars({ id: ownerId, appId }).then(sendToApi);
13
- const pairs = Object.entries(publishedConfigs).map(([name, value]) => ({ name, value }));
14
-
15
- switch (format) {
16
- case 'json': {
17
- Logger.printJson(pairs);
18
- break;
19
- }
20
- case 'shell':
21
- Logger.println(toNameEqualsValueString(pairs, { addExports: true }));
22
- break;
23
- case 'human':
24
- default: {
25
- Logger.println('# Published configs');
26
- Logger.println(toNameEqualsValueString(pairs, { addExports: false }));
27
- }
28
- }
29
- }
30
-
31
- export async function set(params) {
32
- const [varName, varValue] = params.args;
33
- const { alias, app: appIdOrName } = params.options;
34
-
35
- const nameIsValid = validateName(varName);
36
- if (!nameIsValid) {
37
- throw new Error(`Published config name ${varName} is invalid`);
38
- }
39
-
40
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
41
-
42
- const publishedConfigs = await getAllExposedEnvVars({ id: ownerId, appId }).then(sendToApi);
43
- publishedConfigs[varName] = varValue;
44
- await updateAllExposedEnvVars({ id: ownerId, appId }, publishedConfigs).then(sendToApi);
45
-
46
- Logger.println('Your published config item has been successfully saved');
47
- }
48
-
49
- export async function rm(params) {
50
- const [varName] = params.args;
51
- const { alias, app: appIdOrName } = params.options;
52
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
53
-
54
- const publishedConfigs = await getAllExposedEnvVars({ id: ownerId, appId }).then(sendToApi);
55
- delete publishedConfigs[varName];
56
- await updateAllExposedEnvVars({ id: ownerId, appId }, publishedConfigs).then(sendToApi);
57
-
58
- Logger.println('Your published config item has been successfully removed');
59
- }
60
-
61
- export async function importEnv(params) {
62
- const { alias, app: appIdOrName, json } = params.options;
63
- const format = json ? 'json' : 'name-equals-value';
64
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
65
-
66
- const publishedConfigs = await variables.readVariablesFromStdin(format);
67
- await updateAllExposedEnvVars({ id: ownerId, appId }, publishedConfigs).then(sendToApi);
68
-
69
- Logger.println('Your published configs have been set');
70
- }
@@ -1,52 +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 * as ExitStrategy from '../models/exit-strategy-option.js';
5
- import * as git from '../models/git.js';
6
- import * as Log from '../models/log-v4.js';
7
-
8
- // Once the API call to redeploy() has been triggerred successfully,
9
- // the rest (waiting for deployment state to evolve and displaying logs) is done with auto retry (resilient to network pb)
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;
20
-
21
- const exitStrategy = ExitStrategy.get(follow, exitOnDeploy);
22
-
23
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
24
- const fullCommitId = await git.resolveFullCommitId(commit);
25
- const app = await Application.get(ownerId, appId);
26
-
27
- if (app == null) {
28
- throw new Error("The application doesn't exist");
29
- }
30
-
31
- const remoteCommitId = app.commitId;
32
-
33
- const commitId = fullCommitId || remoteCommitId;
34
- if (commitId != null) {
35
- const cacheSuffix = withoutCache ? ' without using cache' : '';
36
- Logger.println(`🔄 Restarting ${styleText('bold', app.name)}${cacheSuffix} ${styleText('grey', `(${commitId})`)}`);
37
- }
38
-
39
- // This should be handled by the API when a deployment ID is set but we'll do this for now
40
- const redeployDate = new Date();
41
-
42
- const redeploy = await Application.redeploy(ownerId, appId, fullCommitId, withoutCache);
43
-
44
- return Log.watchDeploymentAndDisplayLogs({
45
- ownerId,
46
- appId,
47
- deploymentId: redeploy.deploymentId,
48
- quiet,
49
- redeployDate,
50
- exitStrategy,
51
- });
52
- }
@@ -1,66 +0,0 @@
1
- import { Logger } from '../logger.js';
2
- import * as Application from '../models/application.js';
3
-
4
- function validateOptions(options) {
5
- let { flavor, 'min-flavor': minFlavor, 'max-flavor': maxFlavor } = options;
6
- let {
7
- instances,
8
- 'min-instances': minInstances,
9
- 'max-instances': maxInstances,
10
- 'build-flavor': buildFlavor,
11
- } = options;
12
-
13
- if ([flavor, minFlavor, maxFlavor, instances, minInstances, maxInstances, buildFlavor].every((v) => v == null)) {
14
- throw new Error('You should provide at least 1 option');
15
- }
16
-
17
- if (flavor != null) {
18
- if (minFlavor != null || maxFlavor != null) {
19
- throw new Error("You can't use --flavor and --min-flavor or --max-flavor at the same time");
20
- }
21
- minFlavor = flavor;
22
- maxFlavor = flavor;
23
- }
24
-
25
- if (instances != null) {
26
- if (minInstances != null || maxInstances != null) {
27
- throw new Error("You can't use --instances and --min-instances or --max-instances at the same time");
28
- }
29
- minInstances = instances;
30
- maxInstances = instances;
31
- }
32
-
33
- if (minInstances != null && maxInstances != null && minInstances > maxInstances) {
34
- throw new Error("min-instances can't be greater than max-instances");
35
- }
36
-
37
- if (minFlavor != null && maxFlavor != null) {
38
- const minFlavorIndex = Application.listAvailableFlavors().indexOf(minFlavor);
39
- const maxFlavorIndex = Application.listAvailableFlavors().indexOf(maxFlavor);
40
- if (minFlavorIndex > maxFlavorIndex) {
41
- throw new Error("min-flavor can't be a greater flavor than max-flavor");
42
- }
43
- }
44
-
45
- return { minFlavor, maxFlavor, minInstances, maxInstances, buildFlavor };
46
- }
47
-
48
- export async function scale(params) {
49
- const { alias, app: appIdOrName } = params.options;
50
- const { minFlavor, maxFlavor, minInstances, maxInstances, buildFlavor } = validateOptions(params.options);
51
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
52
-
53
- await Application.setScalability(
54
- appId,
55
- ownerId,
56
- {
57
- minFlavor,
58
- maxFlavor,
59
- minInstances,
60
- maxInstances,
61
- },
62
- buildFlavor,
63
- );
64
-
65
- Logger.println('App rescaled successfully');
66
- }
@@ -1,105 +0,0 @@
1
- import { styleText } from '../lib/style-text.js';
2
- import { Logger } from '../logger.js';
3
- import * as Addon from '../models/addon.js';
4
- import * as Application from '../models/application.js';
5
-
6
- export async function list(params) {
7
- const {
8
- alias,
9
- app: appIdOrName,
10
- 'show-all': showAll,
11
- 'only-apps': onlyApps,
12
- 'only-addons': onlyAddons,
13
- format,
14
- } = params.options;
15
- if (onlyApps && onlyAddons) {
16
- throw new Error('--only-apps and --only-addons are mutually exclusive');
17
- }
18
-
19
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
20
-
21
- const formattedServices = {};
22
-
23
- if (!onlyAddons) {
24
- const apps = await Application.listDependencies(ownerId, appId, showAll);
25
- formattedServices.applications = apps.map((app) => ({
26
- id: app.id,
27
- name: app.name,
28
- isLinked: app.isLinked,
29
- }));
30
- }
31
-
32
- if (!onlyApps) {
33
- const addons = await Addon.list(ownerId, appId, showAll);
34
- formattedServices.addons = addons.map((addon) => ({
35
- id: addon.id,
36
- realId: addon.realId,
37
- name: addon.name,
38
- isLinked: addon.isLinked,
39
- }));
40
- }
41
-
42
- switch (format) {
43
- case 'json': {
44
- Logger.printJson(formattedServices);
45
- break;
46
- }
47
- case 'human':
48
- default: {
49
- const { applications = [], addons = [] } = formattedServices;
50
-
51
- if (applications.length === 0 && addons.length === 0) {
52
- Logger.printInfo(
53
- `No linked services found, use ${styleText('blue', 'clever service link-app')} or ${styleText('blue', 'clever service link-addon')} to link services to an application`,
54
- );
55
- return;
56
- }
57
-
58
- if (applications.length > 0) {
59
- Logger.println('Applications:');
60
- applications.forEach(({ isLinked, name }) => Logger.println(`${isLinked ? '*' : ' '} ${name}`));
61
- }
62
-
63
- if (addons.length > 0) {
64
- Logger.println('Addons:');
65
- addons.forEach(({ isLinked, name, realId }) => Logger.println(`${isLinked ? '*' : ' '} ${name} (${realId})`));
66
- }
67
- }
68
- }
69
- }
70
-
71
- export async function linkApp(params) {
72
- const { alias, app: appIdOrName } = params.options;
73
- const [dependency] = params.args;
74
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
75
-
76
- await Application.link(ownerId, appId, dependency);
77
- Logger.println(`App ${dependency.app_id || dependency.app_name} successfully linked`);
78
- }
79
-
80
- export async function unlinkApp(params) {
81
- const { alias, app: appIdOrName } = params.options;
82
- const [dependency] = params.args;
83
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
84
-
85
- await Application.unlink(ownerId, appId, dependency);
86
- Logger.println(`App ${dependency.app_id || dependency.app_name} successfully unlinked`);
87
- }
88
-
89
- export async function linkAddon(params) {
90
- const { alias, app: appIdOrName } = params.options;
91
- const [addon] = params.args;
92
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
93
-
94
- await Addon.link(ownerId, appId, addon);
95
- Logger.println(`Addon ${addon.addon_id || addon.addon_name} successfully linked`);
96
- }
97
-
98
- export async function unlinkAddon(params) {
99
- const { alias, app: appIdOrName } = params.options;
100
- const [addon] = params.args;
101
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
102
-
103
- await Addon.unlink(ownerId, appId, addon);
104
- Logger.println(`Addon ${addon.addon_id || addon.addon_name} successfully unlinked`);
105
- }
@@ -1,144 +0,0 @@
1
- import { todo_addSshKey as addSshKey, todo_removeSshKey as removeSshKey } from '@clevercloud/client/esm/api/v2/user.js';
2
- import dedent from 'dedent';
3
- import fs from 'node:fs';
4
- import { confirm } from '../lib/prompts.js';
5
- import { styleText } from '../lib/style-text.js';
6
- import { Logger } from '../logger.js';
7
- import { sendToApi } from '../models/send-to-api.js';
8
- import { getUserSshKeys } from '../models/ssh-keys.js';
9
- import { openBrowser } from '../models/utils.js';
10
-
11
- /**
12
- * List SSH keys of the current user
13
- * @param {object} params The command parameters
14
- * @param {string} params.options.format The output format
15
- */
16
- export async function list(params) {
17
- const { format } = params.options;
18
-
19
- const keys = await getUserSshKeys();
20
-
21
- switch (format) {
22
- case 'json': {
23
- Logger.printJson(keys);
24
- break;
25
- }
26
- case 'human':
27
- default: {
28
- if (keys.length === 0) {
29
- Logger.println(dedent`
30
- ${styleText('blue', '🔐 No SSH keys')}
31
-
32
- To list the SSH keys on your local system, use the following command:
33
- ${styleText('grey', 'ssh-add -l -E sha256')}
34
-
35
- To create a new key pair, use the following command:
36
- ${styleText('grey', 'ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_clever -C "An optional comment"')}
37
-
38
- Then add the public key to your Clever Cloud account:
39
- ${styleText('grey', 'clever ssh-keys add myNewKey ~/.ssh/id_ed25519_clever.pub')}
40
- `);
41
- return;
42
- }
43
-
44
- Logger.println(`🔐 ${keys.length} SSH key(s):`);
45
- keys.forEach((key) => {
46
- Logger.println(` • ${styleText('blue', key.name)}`, styleText('grey', `(${key.fingerprint})`));
47
- });
48
- }
49
- }
50
- }
51
-
52
- /**
53
- * Add a SSH key to the current user
54
- * @param {object} params The command parameters
55
- * @param {Array<string>} params.args
56
- */
57
- export async function add(params) {
58
- const [keyName, filePath] = params.args;
59
-
60
- if (!fs.existsSync(filePath)) {
61
- throw new Error(`File ${filePath} does not exist`);
62
- }
63
-
64
- const pubKeyContent = fs.readFileSync(filePath, 'utf8').trim();
65
- Logger.debug(`SSH key file content: ${pubKeyContent}`);
66
-
67
- try {
68
- await addSshKey({ key: encodeURIComponent(keyName) }, JSON.stringify(pubKeyContent)).then(sendToApi);
69
- } catch (e) {
70
- console.log(e?.responseBody?.id);
71
- if (e?.responseBody?.id === 505) {
72
- throw new Error("This SSH key is not valid, please make sure you're pointing to the public key file");
73
- }
74
- }
75
-
76
- Logger.printSuccess(`SSH key ${keyName} added successfully`);
77
- }
78
-
79
- /**
80
- * Remove a SSH key from the current user
81
- * @param {object} params The command parameters
82
- * @param {Array<string>} params.args
83
- */
84
- export async function remove(params) {
85
- const [keyName] = params.args;
86
-
87
- const keys = await getUserSshKeys();
88
-
89
- if (keys.find((key) => key.name === keyName) == null) {
90
- throw new Error(`SSH key ${styleText('red', keyName)} not found`);
91
- }
92
-
93
- const keyNameEncoded = encodeURIComponent(keyName);
94
- await removeSshKey({ key: keyNameEncoded }).then(sendToApi);
95
-
96
- Logger.printSuccess(`SSH key ${keyName} removed successfully`);
97
- }
98
-
99
- /**
100
- * Remove all SSH keys from the current user
101
- * @param {object} params The command parameters
102
- * @param {object} params.options The command options
103
- * @param {boolean} params.options.yes The user confirmation
104
- */
105
- export async function removeAll(params) {
106
- if (!params.options.yes) {
107
- await confirm('Are you sure you want to remove all your SSH keys?', 'No SSH keys removed');
108
- }
109
-
110
- const keys = await getUserSshKeys();
111
-
112
- if (keys.length === 0) {
113
- Logger.println('No SSH keys to remove');
114
- return;
115
- }
116
-
117
- const results = await Promise.all(
118
- keys.map((key) => {
119
- const keyNameEncoded = encodeURIComponent(key.name);
120
- return removeSshKey({ key: keyNameEncoded })
121
- .then(sendToApi)
122
- .then(() => [true, key.name])
123
- .catch(() => [false, key.name]);
124
- }),
125
- );
126
-
127
- if (results.every(([isRemoved]) => isRemoved)) {
128
- Logger.printSuccess('All SSH keys were removed successfully');
129
- } else {
130
- const keyNamesWithErrors = results
131
- .filter(([isRemoved]) => !isRemoved)
132
- .map(([_, keyName]) => keyName)
133
- .join(', ');
134
- throw new Error(`Some errors occured while removing these SSH keys: ${keyNamesWithErrors}`);
135
- }
136
- }
137
-
138
- /**
139
- * Open the SSH keys management page of the Console in your browser
140
- * @returns {Promise<void>} A promise that resolves when the page is opened
141
- */
142
- export function openConsole() {
143
- return openBrowser('/users/me/ssh-keys', 'Opening the SSH keys management page of the Console in your browser');
144
- }
@@ -1,20 +0,0 @@
1
- import { spawn } from 'node:child_process';
2
- import * as Application from '../models/application.js';
3
- import { conf } from '../models/configuration.js';
4
-
5
- export async function ssh(params) {
6
- const { alias, app: appIdOrName, 'identity-file': identityFile } = params.options;
7
-
8
- const { appId } = await Application.resolveId(appIdOrName, alias);
9
- const sshParams = ['-t', conf.SSH_GATEWAY, appId];
10
- if (identityFile != null) {
11
- sshParams.push('-i', identityFile);
12
- }
13
-
14
- await new Promise((resolve, reject) => {
15
- // TODO: we should catch errors
16
- const sshProcess = spawn('ssh', sshParams, { stdio: 'inherit' });
17
- sshProcess.on('exit', resolve);
18
- sshProcess.on('error', reject);
19
- });
20
- }