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
@@ -0,0 +1,35 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { styleText } from '../../lib/style-text.js';
3
+ import { Logger } from '../../logger.js';
4
+ import { getUserEmailAddresses } from '../../models/emails.js';
5
+ import { humanJsonOutputFormatOption } from '../global.options.js';
6
+
7
+ export const emailsCommand = defineCommand({
8
+ description: 'Manage email addresses of the current user',
9
+ since: '3.13.0',
10
+ options: {
11
+ format: humanJsonOutputFormatOption,
12
+ },
13
+ args: [],
14
+ async handler(options) {
15
+ const { format } = options;
16
+ const addresses = await getUserEmailAddresses();
17
+
18
+ switch (format) {
19
+ case 'json': {
20
+ Logger.printJson(addresses);
21
+ break;
22
+ }
23
+ case 'human':
24
+ default: {
25
+ Logger.println('✉️ Primary email address:');
26
+ Logger.println(` • ${styleText('green', addresses.primary)}`);
27
+ if (addresses.secondary.length > 0) {
28
+ Logger.println();
29
+ Logger.println(`✉️ ${addresses.secondary.length} secondary email address(es):`);
30
+ addresses.secondary.forEach((address) => Logger.println(` • ${styleText('blue', address)}`));
31
+ }
32
+ }
33
+ }
34
+ },
35
+ });
@@ -0,0 +1,79 @@
1
+ # 📖 `clever emails` command reference
2
+
3
+ ## ➡️ `clever emails` <kbd>Since 3.13.0</kbd>
4
+
5
+ Manage email addresses of the current user
6
+
7
+ ```bash
8
+ clever emails [options]
9
+ ```
10
+
11
+ ### ⚙️ Options
12
+
13
+ |Name|Description|
14
+ |---|---|
15
+ |`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
16
+
17
+ ## ➡️ `clever emails add` <kbd>Since 3.13.0</kbd>
18
+
19
+ Add a new secondary email address to the current user
20
+
21
+ ```bash
22
+ clever emails add <email>
23
+ ```
24
+
25
+ ### 📥 Arguments
26
+
27
+ |Name|Description|
28
+ |---|---|
29
+ |`email`|Email address|
30
+
31
+ ## ➡️ `clever emails open` <kbd>Since 3.13.0</kbd>
32
+
33
+ Open the email addresses management page in the Console
34
+
35
+ ```bash
36
+ clever emails open
37
+ ```
38
+
39
+ ## ➡️ `clever emails primary` <kbd>Since 3.13.0</kbd>
40
+
41
+ Set the primary email address of the current user
42
+
43
+ ```bash
44
+ clever emails primary <email>
45
+ ```
46
+
47
+ ### 📥 Arguments
48
+
49
+ |Name|Description|
50
+ |---|---|
51
+ |`email`|Email address|
52
+
53
+ ## ➡️ `clever emails remove` <kbd>Since 3.13.0</kbd>
54
+
55
+ Remove a secondary email address from the current user
56
+
57
+ ```bash
58
+ clever emails remove <email>
59
+ ```
60
+
61
+ ### 📥 Arguments
62
+
63
+ |Name|Description|
64
+ |---|---|
65
+ |`email`|Email address|
66
+
67
+ ## ➡️ `clever emails remove-all` <kbd>Since 3.13.0</kbd>
68
+
69
+ Remove all secondary email addresses from the current user
70
+
71
+ ```bash
72
+ clever emails remove-all [options]
73
+ ```
74
+
75
+ ### ⚙️ Options
76
+
77
+ |Name|Description|
78
+ |---|---|
79
+ |`-y`, `--yes`|Skip confirmation|
@@ -0,0 +1,15 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { openBrowser } from '../../models/utils.js';
3
+
4
+ export const emailsOpenCommand = defineCommand({
5
+ description: 'Open the email addresses management page in the Console',
6
+ since: '3.13.0',
7
+ options: {},
8
+ args: [],
9
+ handler() {
10
+ return openBrowser(
11
+ '/users/me/emails',
12
+ 'Opening the email addresses management page of the Console in your browser',
13
+ );
14
+ },
15
+ });
@@ -0,0 +1,29 @@
1
+ import { todo_addEmailAddress as addEmailAddress } from '@clevercloud/client/esm/api/v2/user.js';
2
+ import { defineCommand } from '../../lib/define-command.js';
3
+ import { Logger } from '../../logger.js';
4
+ import { getUserEmailAddresses } from '../../models/emails.js';
5
+ import { sendToApi } from '../../models/send-to-api.js';
6
+ import { emailArg } from './emails.args.js';
7
+
8
+ export const emailsPrimaryCommand = defineCommand({
9
+ description: 'Set the primary email address of the current user',
10
+ since: '3.13.0',
11
+ options: {},
12
+ args: [emailArg],
13
+ async handler(_options, newPrimaryAddress) {
14
+ const addresses = await getUserEmailAddresses();
15
+
16
+ if (addresses.primary === newPrimaryAddress) {
17
+ throw new Error('This address is already the primary one');
18
+ }
19
+
20
+ if (!addresses.secondary.includes(newPrimaryAddress)) {
21
+ throw new Error('This address must be added as a secondary address before marking it as primary');
22
+ }
23
+
24
+ const newPrimaryEmailEncoded = encodeURIComponent(newPrimaryAddress);
25
+ await addEmailAddress({ email: newPrimaryEmailEncoded }, { make_primary: true }).then(sendToApi);
26
+
27
+ Logger.printSuccess(`Primary address updated to ${newPrimaryAddress} successfully`);
28
+ },
29
+ });
@@ -0,0 +1,54 @@
1
+ import { todo_removeEmailAddress as removeEmailAddress } from '@clevercloud/client/esm/api/v2/user.js';
2
+ import { z } from 'zod';
3
+ import { defineCommand } from '../../lib/define-command.js';
4
+ import { defineOption } from '../../lib/define-option.js';
5
+ import { confirm } from '../../lib/prompts.js';
6
+ import { Logger } from '../../logger.js';
7
+ import { getUserEmailAddresses } from '../../models/emails.js';
8
+ import { sendToApi } from '../../models/send-to-api.js';
9
+
10
+ export const emailsRemoveAllCommand = defineCommand({
11
+ description: 'Remove all secondary email addresses from the current user',
12
+ since: '3.13.0',
13
+ options: {
14
+ yes: defineOption({
15
+ name: 'yes',
16
+ schema: z.boolean().default(false),
17
+ description: 'Skip confirmation',
18
+ aliases: ['y'],
19
+ }),
20
+ },
21
+ args: [],
22
+ async handler(options) {
23
+ if (!options.yes) {
24
+ await confirm('Are you sure you want to remove all your secondary addresses?', 'No secondary addresses removed');
25
+ }
26
+
27
+ const addresses = await getUserEmailAddresses();
28
+
29
+ if (addresses.secondary.length === 0) {
30
+ Logger.println('No secondary address to remove');
31
+ return;
32
+ }
33
+
34
+ const results = await Promise.all(
35
+ addresses.secondary.map((addressToRemove) => {
36
+ const addressToRemoveEncoded = encodeURIComponent(addressToRemove);
37
+ return removeEmailAddress({ email: addressToRemoveEncoded })
38
+ .then(sendToApi)
39
+ .then(() => [true, addressToRemove])
40
+ .catch(() => [false, addressToRemove]);
41
+ }),
42
+ );
43
+
44
+ if (results.every(([isRemoved]) => isRemoved)) {
45
+ Logger.printSuccess('All secondary addresses were removed successfully');
46
+ } else {
47
+ const addressesWithErrors = results
48
+ .filter(([isRemoved]) => !isRemoved)
49
+ .map(([_, address]) => address)
50
+ .join(', ');
51
+ throw new Error(`Some errors occured while removing these addresses: ${addressesWithErrors}`);
52
+ }
53
+ },
54
+ });
@@ -0,0 +1,25 @@
1
+ import { todo_removeEmailAddress as removeEmailAddress } from '@clevercloud/client/esm/api/v2/user.js';
2
+ import { defineCommand } from '../../lib/define-command.js';
3
+ import { Logger } from '../../logger.js';
4
+ import { getUserEmailAddresses } from '../../models/emails.js';
5
+ import { sendToApi } from '../../models/send-to-api.js';
6
+ import { emailArg } from './emails.args.js';
7
+
8
+ export const emailsRemoveCommand = defineCommand({
9
+ description: 'Remove a secondary email address from the current user',
10
+ since: '3.13.0',
11
+ options: {},
12
+ args: [emailArg],
13
+ async handler(_options, addressToRemove) {
14
+ const addresses = await getUserEmailAddresses();
15
+
16
+ if (!addresses.secondary.includes(addressToRemove)) {
17
+ throw new Error("This address is not part of the secondary addresses of the current user, it can't be removed");
18
+ }
19
+
20
+ const addressToRemoveEncoded = encodeURIComponent(addressToRemove);
21
+ await removeEmailAddress({ email: addressToRemoveEncoded }).then(sendToApi);
22
+
23
+ Logger.printSuccess(`Secondary address ${addressToRemove} removed successfully`);
24
+ },
25
+ });
@@ -0,0 +1,77 @@
1
+ import {
2
+ getAllEnvVars,
3
+ getAllEnvVarsForAddons,
4
+ getAllEnvVarsForDependencies,
5
+ } from '@clevercloud/client/esm/api/v2/application.js';
6
+ import { toNameEqualsValueString } from '@clevercloud/client/esm/utils/env-vars.js';
7
+ import { z } from 'zod';
8
+ import { defineCommand } from '../../lib/define-command.js';
9
+ import { defineOption } from '../../lib/define-option.js';
10
+ import { Logger } from '../../logger.js';
11
+ import * as Application from '../../models/application.js';
12
+ import { sendToApi } from '../../models/send-to-api.js';
13
+ import { aliasOption, appIdOrNameOption, envFormatOption } from '../global.options.js';
14
+
15
+ export const envCommand = defineCommand({
16
+ description: 'Manage environment variables of an application',
17
+ since: '0.2.0',
18
+ options: {
19
+ addExportsOption: defineOption({
20
+ name: 'add-export',
21
+ schema: z.boolean().default(false),
22
+ description: 'Display sourceable env variables setting',
23
+ deprecated: 'use `--format shell` instead',
24
+ }),
25
+ alias: aliasOption,
26
+ app: appIdOrNameOption,
27
+ format: envFormatOption,
28
+ },
29
+ args: [],
30
+ async handler(options) {
31
+ const { alias, app: appIdOrName, addExportsOption, format } = options;
32
+ const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
33
+
34
+ const [envFromApp, envFromAddons, envFromDeps] = await Promise.all([
35
+ getAllEnvVars({ id: ownerId, appId }).then(sendToApi),
36
+ getAllEnvVarsForAddons({ id: ownerId, appId }).then(sendToApi),
37
+ getAllEnvVarsForDependencies({ id: ownerId, appId }).then(sendToApi),
38
+ ]);
39
+
40
+ switch (format) {
41
+ case 'json': {
42
+ Logger.printJson({
43
+ env: envFromApp,
44
+ fromAddons: envFromAddons.map((addon) => ({
45
+ addonId: addon.addon_id,
46
+ addonName: addon.addon_name,
47
+ env: addon.env,
48
+ })),
49
+ fromDependencies: envFromDeps.map((dep) => ({
50
+ addonId: dep.app_id,
51
+ addonName: dep.app_name,
52
+ env: dep.env,
53
+ })),
54
+ });
55
+ break;
56
+ }
57
+ case 'shell':
58
+ case 'human':
59
+ default: {
60
+ const addExports = addExportsOption || format === 'shell';
61
+
62
+ Logger.println('# Manually set env variables');
63
+ Logger.println(toNameEqualsValueString(envFromApp, { addExports }));
64
+
65
+ envFromAddons.forEach((addon) => {
66
+ Logger.println('# Addon ' + addon.addon_name);
67
+ Logger.println(toNameEqualsValueString(addon.env, { addExports }));
68
+ });
69
+
70
+ envFromDeps.forEach((dep) => {
71
+ Logger.println('# Dependency ' + dep.app_name);
72
+ Logger.println(toNameEqualsValueString(dep.env, { addExports }));
73
+ });
74
+ }
75
+ }
76
+ },
77
+ });
@@ -0,0 +1,99 @@
1
+ # 📖 `clever env` command reference
2
+
3
+ ## ➡️ `clever env` <kbd>Since 0.2.0</kbd>
4
+
5
+ Manage environment variables of an application
6
+
7
+ ```bash
8
+ clever env [options]
9
+ ```
10
+
11
+ ### ⚙️ Options
12
+
13
+ |Name|Description|
14
+ |---|---|
15
+ |`--add-export`|Display sourceable env variables setting *(deprecated, use `--format shell` instead)*|
16
+ |`-a`, `--alias` `<alias>`|Short name for the application|
17
+ |`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
18
+ |`-F`, `--format` `<format>`|Output format (human, json, shell) (default: human)|
19
+
20
+ ## ➡️ `clever env import` <kbd>Since 0.3.0</kbd>
21
+
22
+ Load environment variables from STDIN
23
+ (WARNING: this deletes all current variables and replace them with the new list loaded from STDIN)
24
+
25
+ ```bash
26
+ clever env import [options]
27
+ ```
28
+
29
+ ### ⚙️ Options
30
+
31
+ |Name|Description|
32
+ |---|---|
33
+ |`-a`, `--alias` `<alias>`|Short name for the application|
34
+ |`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
35
+ |`--json`|Import variables as JSON (an array of { "name": "THE_NAME", "value": "THE_VALUE" } objects)|
36
+
37
+ ## ➡️ `clever env import-vars` <kbd>Since 2.0.0</kbd>
38
+
39
+ Add or update environment variables named <variable-names> (comma-separated), taking their values from the current environment
40
+
41
+ ```bash
42
+ clever env import-vars <variable-names> [options]
43
+ ```
44
+
45
+ ### 📥 Arguments
46
+
47
+ |Name|Description|
48
+ |---|---|
49
+ |`variable-names`|Comma separated list of names of the environment variables|
50
+
51
+ ### ⚙️ Options
52
+
53
+ |Name|Description|
54
+ |---|---|
55
+ |`-a`, `--alias` `<alias>`|Short name for the application|
56
+ |`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
57
+
58
+ ## ➡️ `clever env rm` <kbd>Since 0.3.0</kbd>
59
+
60
+ Remove an environment variable from an application
61
+
62
+ ```bash
63
+ clever env rm <variable-name> [options]
64
+ ```
65
+
66
+ ### 📥 Arguments
67
+
68
+ |Name|Description|
69
+ |---|---|
70
+ |`variable-name`|Name of the environment variable|
71
+
72
+ ### ⚙️ Options
73
+
74
+ |Name|Description|
75
+ |---|---|
76
+ |`-a`, `--alias` `<alias>`|Short name for the application|
77
+ |`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
78
+
79
+ ## ➡️ `clever env set` <kbd>Since 0.3.0</kbd>
80
+
81
+ Add or update an environment variable named <variable-name> with the value <variable-value>
82
+
83
+ ```bash
84
+ clever env set <variable-name> <variable-value> [options]
85
+ ```
86
+
87
+ ### 📥 Arguments
88
+
89
+ |Name|Description|
90
+ |---|---|
91
+ |`variable-name`|Name of the environment variable|
92
+ |`variable-value`|Value of the environment variable|
93
+
94
+ ### ⚙️ Options
95
+
96
+ |Name|Description|
97
+ |---|---|
98
+ |`-a`, `--alias` `<alias>`|Short name for the application|
99
+ |`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
@@ -0,0 +1,45 @@
1
+ import { updateEnvVar } from '@clevercloud/client/esm/api/v2/application.js';
2
+ import { validateName } from '@clevercloud/client/esm/utils/env-vars.js';
3
+ import { z } from 'zod';
4
+ import { defineArgument } from '../../lib/define-argument.js';
5
+ import { defineCommand } from '../../lib/define-command.js';
6
+ import { Logger } from '../../logger.js';
7
+ import * as Application from '../../models/application.js';
8
+ import { sendToApi } from '../../models/send-to-api.js';
9
+ import { aliasOption, appIdOrNameOption } from '../global.options.js';
10
+
11
+ export const envImportVarsCommand = defineCommand({
12
+ description:
13
+ 'Add or update environment variables named <variable-names> (comma-separated), taking their values from the current environment',
14
+ since: '2.0.0',
15
+ options: {
16
+ alias: aliasOption,
17
+ app: appIdOrNameOption,
18
+ },
19
+ args: [
20
+ defineArgument({
21
+ schema: z.string(),
22
+ description: 'Comma separated list of names of the environment variables',
23
+ placeholder: 'variable-names',
24
+ }),
25
+ ],
26
+ async handler(options, envNames) {
27
+ const { alias, app: appIdOrName } = options;
28
+
29
+ for (const envName of envNames) {
30
+ const nameIsValid = validateName(envName);
31
+ if (!nameIsValid) {
32
+ throw new Error(`Environment variable name ${envName} is invalid`);
33
+ }
34
+ }
35
+
36
+ const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
37
+
38
+ for (const envName of envNames) {
39
+ const value = process.env[envName] || '';
40
+ await updateEnvVar({ id: ownerId, appId, envName }, { value }).then(sendToApi);
41
+ }
42
+
43
+ Logger.println('Your environment variables have been successfully saved');
44
+ },
45
+ });
@@ -0,0 +1,29 @@
1
+ import { updateAllEnvVars } from '@clevercloud/client/esm/api/v2/application.js';
2
+ import { defineCommand } from '../../lib/define-command.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
+ import { aliasOption, appIdOrNameOption, importAsJsonOption } from '../global.options.js';
8
+
9
+ export const envImportCommand = defineCommand({
10
+ description:
11
+ 'Load environment variables from STDIN\n(WARNING: this deletes all current variables and replace them with the new list loaded from STDIN)',
12
+ since: '0.3.0',
13
+ options: {
14
+ alias: aliasOption,
15
+ app: appIdOrNameOption,
16
+ json: importAsJsonOption,
17
+ },
18
+ args: [],
19
+ async handler(options) {
20
+ const { alias, app: appIdOrName, json } = options;
21
+ const format = json ? 'json' : 'name-equals-value';
22
+ const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
23
+
24
+ const envVars = await variables.readVariablesFromStdin(format);
25
+ await updateAllEnvVars({ id: ownerId, appId }, envVars).then(sendToApi);
26
+
27
+ Logger.println('Environment variables have been set');
28
+ },
29
+ });
@@ -0,0 +1,25 @@
1
+ import { removeEnvVar } from '@clevercloud/client/esm/api/v2/application.js';
2
+ import { defineCommand } from '../../lib/define-command.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 { envVariableNameArg } from '../global.args.js';
7
+ import { aliasOption, appIdOrNameOption } from '../global.options.js';
8
+
9
+ export const envRmCommand = defineCommand({
10
+ description: 'Remove an environment variable from an application',
11
+ since: '0.3.0',
12
+ options: {
13
+ alias: aliasOption,
14
+ app: appIdOrNameOption,
15
+ },
16
+ args: [envVariableNameArg],
17
+ async handler(options, envName) {
18
+ const { alias, app: appIdOrName } = options;
19
+ const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
20
+
21
+ await removeEnvVar({ id: ownerId, appId, envName }).then(sendToApi);
22
+
23
+ Logger.println('Your environment variable has been successfully removed');
24
+ },
25
+ });
@@ -0,0 +1,32 @@
1
+ import { updateEnvVar } from '@clevercloud/client/esm/api/v2/application.js';
2
+ import { validateName } from '@clevercloud/client/esm/utils/env-vars.js';
3
+ import { defineCommand } from '../../lib/define-command.js';
4
+ import { Logger } from '../../logger.js';
5
+ import * as Application from '../../models/application.js';
6
+ import { sendToApi } from '../../models/send-to-api.js';
7
+ import { envVariableNameArg, envVariableValueArg } from '../global.args.js';
8
+ import { aliasOption, appIdOrNameOption } from '../global.options.js';
9
+
10
+ export const envSetCommand = defineCommand({
11
+ description: 'Add or update an environment variable named <variable-name> with the value <variable-value>',
12
+ since: '0.3.0',
13
+ options: {
14
+ alias: aliasOption,
15
+ app: appIdOrNameOption,
16
+ },
17
+ args: [envVariableNameArg, envVariableValueArg],
18
+ async handler(options, envName, value) {
19
+ const { alias, app: appIdOrName } = options;
20
+
21
+ const nameIsValid = validateName(envName);
22
+ if (!nameIsValid) {
23
+ throw new Error(`Environment variable name ${envName} is invalid`);
24
+ }
25
+
26
+ const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
27
+
28
+ await updateEnvVar({ id: ownerId, appId, envName }, { value }).then(sendToApi);
29
+
30
+ Logger.println('Your environment variable has been successfully saved');
31
+ },
32
+ });
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ import { defineArgument } from '../../lib/define-argument.js';
3
+ import { commaSeparated } from '../../parsers.js';
4
+
5
+ export const featuresArg = defineArgument({
6
+ schema: z.string().transform(commaSeparated),
7
+ description: 'Comma-separated list of experimental features to manage',
8
+ placeholder: 'features',
9
+ });
@@ -0,0 +1,7 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { featuresListCommand } from './features.list.command.js';
3
+
4
+ export const featuresCommand = defineCommand({
5
+ ...featuresListCommand,
6
+ description: 'Manage Clever Tools experimental features',
7
+ });
@@ -0,0 +1,25 @@
1
+ import { EXPERIMENTAL_FEATURES } from '../../experimental-features.js';
2
+ import { defineCommand } from '../../lib/define-command.js';
3
+ import { Logger } from '../../logger.js';
4
+ import { setFeature } from '../../models/configuration.js';
5
+ import { featuresArg } from './features.args.js';
6
+
7
+ export const featuresDisableCommand = defineCommand({
8
+ description: 'Disable experimental features',
9
+ since: '3.11.0',
10
+ options: {},
11
+ args: [featuresArg],
12
+ async handler(_options, features) {
13
+ const availableFeatures = Object.keys(EXPERIMENTAL_FEATURES);
14
+
15
+ const unknownFeatures = features.filter((feature) => !availableFeatures.includes(feature));
16
+ if (unknownFeatures.length > 0) {
17
+ throw new Error(`Unavailable feature(s): ${unknownFeatures.join(', ')}`);
18
+ }
19
+
20
+ for (const featureName of features) {
21
+ await setFeature(featureName, false);
22
+ Logger.println(`Experimental feature '${featureName}' disabled`);
23
+ }
24
+ },
25
+ });
@@ -0,0 +1,71 @@
1
+ # 📖 `clever features` command reference
2
+
3
+ ## ➡️ `clever features` <kbd>Since 3.11.0</kbd>
4
+
5
+ Manage Clever Tools experimental features
6
+
7
+ ```bash
8
+ clever features [options]
9
+ ```
10
+
11
+ ### ⚙️ Options
12
+
13
+ |Name|Description|
14
+ |---|---|
15
+ |`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
16
+
17
+ ## ➡️ `clever features disable` <kbd>Since 3.11.0</kbd>
18
+
19
+ Disable experimental features
20
+
21
+ ```bash
22
+ clever features disable <features>
23
+ ```
24
+
25
+ ### 📥 Arguments
26
+
27
+ |Name|Description|
28
+ |---|---|
29
+ |`features`|Comma-separated list of experimental features to manage|
30
+
31
+ ## ➡️ `clever features enable` <kbd>Since 3.11.0</kbd>
32
+
33
+ Enable experimental features
34
+
35
+ ```bash
36
+ clever features enable <features>
37
+ ```
38
+
39
+ ### 📥 Arguments
40
+
41
+ |Name|Description|
42
+ |---|---|
43
+ |`features`|Comma-separated list of experimental features to manage|
44
+
45
+ ## ➡️ `clever features info` <kbd>Since 3.11.0</kbd>
46
+
47
+ Display info about an experimental feature
48
+
49
+ ```bash
50
+ clever features info <feature>
51
+ ```
52
+
53
+ ### 📥 Arguments
54
+
55
+ |Name|Description|
56
+ |---|---|
57
+ |`feature`|Experimental feature to manage|
58
+
59
+ ## ➡️ `clever features list` <kbd>Since 3.11.0</kbd>
60
+
61
+ List available experimental features
62
+
63
+ ```bash
64
+ clever features list [options]
65
+ ```
66
+
67
+ ### ⚙️ Options
68
+
69
+ |Name|Description|
70
+ |---|---|
71
+ |`-F`, `--format` `<format>`|Output format (human, json) (default: human)|