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
@@ -0,0 +1,186 @@
1
+ import { z } from 'zod';
2
+ import { defineOption } from '../lib/define-option.js';
3
+ import { listAvailableAliases } from '../models/application.js';
4
+ import { listMetaEvents } from '../models/notification.js';
5
+ import { appIdOrName, date, orgaIdOrName } from '../parsers.js';
6
+
7
+ export const aliasOption = defineOption({
8
+ name: 'alias',
9
+ schema: z.string().optional(),
10
+ description: 'Short name for the application',
11
+ aliases: ['a'],
12
+ placeholder: 'alias',
13
+ complete: listAvailableAliases,
14
+ });
15
+
16
+ export const appIdOrNameOption = defineOption({
17
+ name: 'app',
18
+ schema: z.string().transform(appIdOrName).optional(),
19
+ description: 'Application to manage by its ID (or name, if unambiguous)',
20
+ placeholder: 'app-id|app-name',
21
+ });
22
+
23
+ export const logsFormatOption = defineOption({
24
+ name: 'format',
25
+ schema: z.enum(['human', 'json', 'json-stream']).default('human'),
26
+ description: 'Output format (human, json, json-stream)',
27
+ aliases: ['F'],
28
+ placeholder: 'format',
29
+ });
30
+
31
+ export const beforeOption = defineOption({
32
+ name: 'before',
33
+ schema: z.string().transform(date).optional(),
34
+ description: 'Fetch logs before this date/time (ISO8601 date, positive number in seconds or duration, e.g.: 1h)',
35
+ aliases: ['until'],
36
+ placeholder: 'before',
37
+ });
38
+
39
+ export const afterOption = defineOption({
40
+ name: 'after',
41
+ schema: z.string().transform(date).optional(),
42
+ description: 'Fetch logs after this date/time (ISO8601 date, positive number in seconds or duration, e.g.: 1h)',
43
+ aliases: ['since'],
44
+ placeholder: 'after',
45
+ });
46
+
47
+ export const addonIdOption = defineOption({
48
+ name: 'addon',
49
+ schema: z.string().optional(),
50
+ description: 'Add-on ID',
51
+ placeholder: 'addon-id',
52
+ });
53
+
54
+ export const orgaIdOrNameOption = defineOption({
55
+ name: 'org',
56
+ schema: z.string().transform(orgaIdOrName).optional(),
57
+ description: 'Organisation to target by its ID (or name, if unambiguous)',
58
+ aliases: ['o', 'owner'],
59
+ placeholder: 'org-id|org-name',
60
+ });
61
+
62
+ export const humanJsonOutputFormatOption = defineOption({
63
+ name: 'format',
64
+ schema: z.enum(['human', 'json']).default('human'),
65
+ description: 'Output format (human, json)',
66
+ aliases: ['F'],
67
+ placeholder: 'format',
68
+ });
69
+
70
+ export const confirmAddonDeletionOption = defineOption({
71
+ name: 'yes',
72
+ schema: z.boolean().default(false),
73
+ description: 'Skip confirmation and delete the add-on directly',
74
+ aliases: ['y'],
75
+ });
76
+
77
+ export const envFormatOption = defineOption({
78
+ name: 'format',
79
+ schema: z.enum(['human', 'json', 'shell']).default('human'),
80
+ description: 'Output format (human, json, shell)',
81
+ aliases: ['F'],
82
+ placeholder: 'format',
83
+ });
84
+
85
+ export const aliasCreationOption = defineOption({
86
+ name: 'alias',
87
+ schema: z.string().optional(),
88
+ description: 'Short name for the application',
89
+ aliases: ['a'],
90
+ placeholder: 'alias',
91
+ });
92
+
93
+ export const quietOption = defineOption({
94
+ name: 'quiet',
95
+ schema: z.boolean().default(false),
96
+ description: "Don't show logs during deployment",
97
+ aliases: ['q'],
98
+ });
99
+
100
+ export const followDeployLogsOption = defineOption({
101
+ name: 'follow',
102
+ schema: z.boolean().default(false),
103
+ description: 'Continue to follow logs after deployment has ended',
104
+ deprecated: 'use `--exit-on never` instead',
105
+ });
106
+
107
+ export const exitOnDeployOption = defineOption({
108
+ name: 'exit-on',
109
+ schema: z.enum(['deploy-start', 'deploy-end', 'never']).default('deploy-end'),
110
+ description: 'Step at which the logs streaming is ended, steps are: deploy-start, deploy-end, never',
111
+ aliases: ['e'],
112
+ placeholder: 'step',
113
+ });
114
+
115
+ export const importAsJsonOption = defineOption({
116
+ name: 'json',
117
+ schema: z.boolean().default(false),
118
+ description: 'Import variables as JSON (an array of { \"name\": \"THE_NAME\", \"value\": \"THE_VALUE\" } objects)',
119
+ });
120
+
121
+ export const targetVersionOption = defineOption({
122
+ name: 'target',
123
+ schema: z.string().optional(),
124
+ description: 'Target version to upgrade to (e.g.: 24, 2.4, 2.4.1)',
125
+ placeholder: 'version',
126
+ });
127
+
128
+ export const listAllNotificationsOption = defineOption({
129
+ name: 'list-all',
130
+ schema: z.boolean().default(false),
131
+ description: "List all notifications for your user or for an organisation with the '--org' option",
132
+ });
133
+
134
+ export const notificationEventTypeOption = defineOption({
135
+ name: 'event',
136
+ schema: z
137
+ .string()
138
+ .transform((v) => v.split(','))
139
+ .optional(),
140
+ description: 'Restrict notifications to specific event types',
141
+ placeholder: 'event-type',
142
+ complete: listMetaEvents,
143
+ });
144
+
145
+ export const notificationScopeOption = defineOption({
146
+ name: 'service',
147
+ schema: z
148
+ .string()
149
+ .transform((v) => v.split(','))
150
+ .optional(),
151
+ description: 'Restrict notifications to specific applications and add-ons',
152
+ placeholder: 'service-id',
153
+ });
154
+
155
+ export const helpOption = defineOption({
156
+ name: 'help',
157
+ schema: z.boolean().optional(),
158
+ description: 'Display help about this program',
159
+ aliases: ['?'],
160
+ });
161
+
162
+ export const versionOption = defineOption({
163
+ name: 'version',
164
+ schema: z.boolean().optional(),
165
+ description: 'Display the version of this program',
166
+ aliases: ['V'],
167
+ });
168
+
169
+ export const colorOption = defineOption({
170
+ name: 'color',
171
+ schema: z.boolean().default(true),
172
+ description: 'Choose whether to print colors or not. You can also use --no-color',
173
+ });
174
+
175
+ export const updateNotifierOption = defineOption({
176
+ name: 'update-notifier',
177
+ schema: z.boolean().default(true),
178
+ description: 'Choose whether to use update notifier or not. You can also use --no-update-notifier',
179
+ });
180
+
181
+ export const verboseOption = defineOption({
182
+ name: 'verbose',
183
+ schema: z.boolean().default(false),
184
+ description: 'Verbose output',
185
+ aliases: ['v'],
186
+ });
@@ -0,0 +1,9 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+
3
+ export const helpCommand = defineCommand({
4
+ description: 'Display help about the Clever Cloud CLI',
5
+ since: '0.1.0',
6
+ options: {},
7
+ args: [],
8
+ handler: null,
9
+ });
@@ -0,0 +1,9 @@
1
+ # 📖 `clever help` command reference
2
+
3
+ ## ➡️ `clever help` <kbd>Since 0.1.0</kbd>
4
+
5
+ Display help about the Clever Cloud CLI
6
+
7
+ ```bash
8
+ clever help
9
+ ```
@@ -0,0 +1,39 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { isK8sClusterActive, k8sAddPersistentStorage } from '../../lib/k8s.js';
3
+ import { styleText } from '../../lib/style-text.js';
4
+ import { Logger } from '../../logger.js';
5
+ import { orgaIdOrNameOption } from '../global.options.js';
6
+ import { k8sIdOrNameArg } from './k8s.args.js';
7
+
8
+ export const k8sAddPersistentStorageCommand = defineCommand({
9
+ description: 'Activate persistent storage to a deployed Kubernetes cluster',
10
+ since: '4.3.0',
11
+ options: {
12
+ org: orgaIdOrNameOption,
13
+ },
14
+ args: [k8sIdOrNameArg],
15
+ async handler(options, clusterIdOrName) {
16
+ const orgIdOrName = options.org;
17
+
18
+ if ((await isK8sClusterActive(orgIdOrName, clusterIdOrName)) === false) {
19
+ Logger.printInfo(
20
+ 'Persistent storage can only be added to deployed clusters, wait for the deployment to finish and try again',
21
+ );
22
+
23
+ const orgMessageComplement = orgIdOrName ? `--org "${orgIdOrName.orga_id || orgIdOrName.orga_name}"` : '';
24
+ Logger.println(
25
+ `Check with ${styleText('blue', `clever k8s get ${clusterIdOrName.addon_name || clusterIdOrName.operator_id} ${orgMessageComplement}`)}`,
26
+ );
27
+ return;
28
+ }
29
+
30
+ try {
31
+ await k8sAddPersistentStorage(orgIdOrName, clusterIdOrName);
32
+ Logger.printSuccess(
33
+ `Persistent storage successfully activated on cluster ${styleText('green', clusterIdOrName.addon_name || clusterIdOrName.operator_id)}`,
34
+ );
35
+ } catch (error) {
36
+ Logger.error("Failed to add persistent storage, check if it's not already activated");
37
+ }
38
+ },
39
+ });
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ import { defineArgument } from '../../lib/define-argument.js';
3
+ import { addonIdOrName } from '../../parsers.js';
4
+
5
+ export const k8sIdOrNameArg = defineArgument({
6
+ schema: z.string().transform(addonIdOrName),
7
+ description: 'Kubernetes cluster ID or name',
8
+ placeholder: 'cluster-id|cluster-name',
9
+ });
@@ -0,0 +1,12 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+
3
+ export const k8sCommand = defineCommand({
4
+ description: 'Manage Kubernetes clusters',
5
+ since: '4.3.0',
6
+ isExperimental: true,
7
+ featureFlag: 'k8s',
8
+ options: {},
9
+ args: [],
10
+ // Parent command - no handler, only contains subcommands
11
+ handler: null,
12
+ });
@@ -0,0 +1,86 @@
1
+ import { z } from 'zod';
2
+ import { typewriterLogo } from '../../lib/ascii.js';
3
+ import { defineArgument } from '../../lib/define-argument.js';
4
+ import { defineCommand } from '../../lib/define-command.js';
5
+ import { defineOption } from '../../lib/define-option.js';
6
+ import { getK8sCluster, k8sCreate } from '../../lib/k8s.js';
7
+ import { styleText } from '../../lib/style-text.js';
8
+ import { Logger } from '../../logger.js';
9
+ import { orgaIdOrNameOption } from '../global.options.js';
10
+
11
+ const DEPLOY_POLL_DELAY_MS = 10000;
12
+
13
+ export const k8sCreateCommand = defineCommand({
14
+ description: 'Create a Kubernetes cluster',
15
+ since: '4.3.0',
16
+ options: {
17
+ watch: defineOption({
18
+ name: 'watch',
19
+ schema: z.boolean().default(false),
20
+ description: 'Watch the deployment until the cluster is deployed',
21
+ aliases: ['w'],
22
+ }),
23
+ org: orgaIdOrNameOption,
24
+ },
25
+ args: [
26
+ defineArgument({
27
+ schema: z.string(),
28
+ description: 'Kubernetes cluster name',
29
+ placeholder: 'cluster-name',
30
+ }),
31
+ ],
32
+ async handler(options, ...args) {
33
+ const clusterName = args[0];
34
+ const orgIdOrName = options.org;
35
+
36
+ try {
37
+ const cluster = await k8sCreate(clusterName, orgIdOrName);
38
+
39
+ if (options.watch) {
40
+ await typewriterLogo();
41
+
42
+ let deployedCluster = cluster;
43
+ while (deployedCluster.status !== 'ACTIVE' && deployedCluster.status !== 'FAILED') {
44
+ Logger.println(
45
+ `⏳ Cluster status: ${styleText('yellow', deployedCluster.status)}. Waiting for ${DEPLOY_POLL_DELAY_MS / 1000}s before checking again...`,
46
+ );
47
+ await new Promise((resolve) => setTimeout(resolve, DEPLOY_POLL_DELAY_MS));
48
+
49
+ deployedCluster = await getK8sCluster(orgIdOrName, cluster.id);
50
+ }
51
+
52
+ Logger.println('');
53
+ switch (deployedCluster.status) {
54
+ case 'ACTIVE':
55
+ Logger.printSuccess(
56
+ `Cluster ${styleText('green', `${deployedCluster.name} (${deployedCluster.id})`)} deployed successfully`,
57
+ );
58
+ break;
59
+ case 'FAILED':
60
+ throw new Error(
61
+ `Cluster ${styleText('red', `${deployedCluster.name} (${deployedCluster.id})`)} deployment failed`,
62
+ );
63
+ default:
64
+ throw new Error(`Unexpected cluster status: ${deployedCluster.status}`);
65
+ }
66
+ } else {
67
+ Logger.println(`🚀 Cluster ${styleText('white', `${cluster.name} (${cluster.id})`)} is being deployed`);
68
+ }
69
+
70
+ const orgMessageComplement = orgIdOrName ? `--org "${orgIdOrName.orga_id || orgIdOrName.orga_name}"` : '';
71
+
72
+ Logger.println('');
73
+ Logger.println(
74
+ `You can get its information with ${styleText('blue', `clever k8s get ${cluster.id} ${orgMessageComplement}`)}`,
75
+ );
76
+ } catch (error) {
77
+ if (error.responseBody?.code === 'clever.core.quota-exceeded') {
78
+ throw new Error(
79
+ 'Failed to create Kubernetes cluster: your quota exceeded, contact support to increase your quota',
80
+ );
81
+ } else {
82
+ throw new Error(error.message);
83
+ }
84
+ }
85
+ },
86
+ });
@@ -0,0 +1,40 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { k8sDelete } from '../../lib/k8s.js';
3
+ import { confirm } from '../../lib/prompts.js';
4
+ import { styleText } from '../../lib/style-text.js';
5
+ import { Logger } from '../../logger.js';
6
+ import { confirmAddonDeletionOption, orgaIdOrNameOption } from '../global.options.js';
7
+ import { k8sIdOrNameArg } from './k8s.args.js';
8
+
9
+ export const k8sDeleteCommand = defineCommand({
10
+ description: 'Delete a Kubernetes cluster',
11
+ since: '4.3.0',
12
+ options: {
13
+ org: orgaIdOrNameOption,
14
+ yes: confirmAddonDeletionOption,
15
+ },
16
+ args: [k8sIdOrNameArg],
17
+ async handler(options, clusterIdOrName) {
18
+ const { org: orgIdOrName, yes: confirmDeletion } = options;
19
+
20
+ let proceedDeletion;
21
+ if (confirmDeletion) {
22
+ proceedDeletion = true;
23
+ } else {
24
+ proceedDeletion = await confirm(
25
+ `Are you sure you want to delete the Kubernetes cluster ${styleText(
26
+ 'blue',
27
+ clusterIdOrName.addon_name || clusterIdOrName.operator_id,
28
+ )}?`,
29
+ 'Kubernetes cluster deletion cancelled.',
30
+ );
31
+ }
32
+
33
+ if (proceedDeletion) {
34
+ await k8sDelete(orgIdOrName, clusterIdOrName);
35
+ Logger.printSuccess(
36
+ `Kubernetes cluster ${styleText('green', clusterIdOrName.addon_name || clusterIdOrName.operator_id)} successfully deleted`,
37
+ );
38
+ }
39
+ },
40
+ });
@@ -0,0 +1,131 @@
1
+ # 📖 `clever k8s` command reference
2
+
3
+ > [!NOTE]
4
+ > 🧪 **Experimental**: This command may change or be removed in future versions.
5
+ > Enable with: `clever features enable k8s`
6
+
7
+ ## ➡️ `clever k8s` <kbd>Since 4.3.0</kbd>
8
+
9
+ Manage Kubernetes clusters
10
+
11
+ ```bash
12
+ clever k8s
13
+ ```
14
+
15
+ ## ➡️ `clever k8s add-persistent-storage` <kbd>Since 4.3.0</kbd>
16
+
17
+ Activate persistent storage to a deployed Kubernetes cluster
18
+
19
+ ```bash
20
+ clever k8s add-persistent-storage <cluster-id|cluster-name> [options]
21
+ ```
22
+
23
+ ### 📥 Arguments
24
+
25
+ |Name|Description|
26
+ |---|---|
27
+ |`cluster-id|cluster-name`|Kubernetes cluster ID or name|
28
+
29
+ ### ⚙️ Options
30
+
31
+ |Name|Description|
32
+ |---|---|
33
+ |`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
34
+
35
+ ## ➡️ `clever k8s create` <kbd>Since 4.3.0</kbd>
36
+
37
+ Create a Kubernetes cluster
38
+
39
+ ```bash
40
+ clever k8s create <cluster-name> [options]
41
+ ```
42
+
43
+ ### 📥 Arguments
44
+
45
+ |Name|Description|
46
+ |---|---|
47
+ |`cluster-name`|Kubernetes cluster name|
48
+
49
+ ### ⚙️ Options
50
+
51
+ |Name|Description|
52
+ |---|---|
53
+ |`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
54
+ |`-w`, `--watch`|Watch the deployment until the cluster is deployed|
55
+
56
+ ## ➡️ `clever k8s delete` <kbd>Since 4.3.0</kbd>
57
+
58
+ Delete a Kubernetes cluster
59
+
60
+ ```bash
61
+ clever k8s delete <cluster-id|cluster-name> [options]
62
+ ```
63
+
64
+ ### 📥 Arguments
65
+
66
+ |Name|Description|
67
+ |---|---|
68
+ |`cluster-id|cluster-name`|Kubernetes cluster ID or name|
69
+
70
+ ### ⚙️ Options
71
+
72
+ |Name|Description|
73
+ |---|---|
74
+ |`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
75
+ |`-y`, `--yes`|Skip confirmation and delete the add-on directly|
76
+
77
+ ## ➡️ `clever k8s get` <kbd>Since 4.3.0</kbd>
78
+
79
+ Get information about a Kubernetes cluster
80
+
81
+ ```bash
82
+ clever k8s get <cluster-id|cluster-name> [options]
83
+ ```
84
+
85
+ ### 📥 Arguments
86
+
87
+ |Name|Description|
88
+ |---|---|
89
+ |`cluster-id|cluster-name`|Kubernetes cluster ID or name|
90
+
91
+ ### ⚙️ Options
92
+
93
+ |Name|Description|
94
+ |---|---|
95
+ |`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
96
+ |`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
97
+
98
+ ## ➡️ `clever k8s get-kubeconfig` <kbd>Since 4.3.0</kbd>
99
+
100
+ Get configuration of a Kubernetes cluster
101
+
102
+ ```bash
103
+ clever k8s get-kubeconfig <cluster-id|cluster-name> [options]
104
+ ```
105
+
106
+ ### 📥 Arguments
107
+
108
+ |Name|Description|
109
+ |---|---|
110
+ |`cluster-id|cluster-name`|Kubernetes cluster ID or name|
111
+
112
+ ### ⚙️ Options
113
+
114
+ |Name|Description|
115
+ |---|---|
116
+ |`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
117
+
118
+ ## ➡️ `clever k8s list` <kbd>Since 4.3.0</kbd>
119
+
120
+ List Kubernetes clusters
121
+
122
+ ```bash
123
+ clever k8s list [options]
124
+ ```
125
+
126
+ ### ⚙️ Options
127
+
128
+ |Name|Description|
129
+ |---|---|
130
+ |`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
131
+ |`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
@@ -0,0 +1,32 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { isK8sClusterActive, k8sGetConfig } from '../../lib/k8s.js';
3
+ import { styleText } from '../../lib/style-text.js';
4
+ import { Logger } from '../../logger.js';
5
+ import { orgaIdOrNameOption } from '../global.options.js';
6
+ import { k8sIdOrNameArg } from './k8s.args.js';
7
+
8
+ export const k8sGetKubeconfigCommand = defineCommand({
9
+ description: 'Get configuration of a Kubernetes cluster',
10
+ since: '4.3.0',
11
+ options: {
12
+ org: orgaIdOrNameOption,
13
+ },
14
+ args: [k8sIdOrNameArg],
15
+ async handler(options, clusterIdOrName) {
16
+ const orgIdOrName = options.org;
17
+
18
+ if ((await isK8sClusterActive(orgIdOrName, clusterIdOrName)) !== true) {
19
+ Logger.printInfo(
20
+ 'Kubeconfig can only be retrieved from deployed clusters, wait for the deployment to finish and try again',
21
+ );
22
+
23
+ const orgMessageComplement = orgIdOrName ? `--org "${orgIdOrName.orga_id || orgIdOrName.orga_name}"` : '';
24
+ Logger.println(
25
+ `Check with ${styleText('blue', `clever k8s get ${clusterIdOrName.addon_name || clusterIdOrName.operator_id} ${orgMessageComplement}`)}`,
26
+ );
27
+ return;
28
+ }
29
+
30
+ console.log(await k8sGetConfig(orgIdOrName, clusterIdOrName));
31
+ },
32
+ });
@@ -0,0 +1,43 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { getK8sCluster } from '../../lib/k8s.js';
3
+ import { styleText } from '../../lib/style-text.js';
4
+ import { Logger } from '../../logger.js';
5
+ import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
6
+ import { k8sIdOrNameArg } from './k8s.args.js';
7
+
8
+ export const k8sGetCommand = defineCommand({
9
+ description: 'Get information about a Kubernetes cluster',
10
+ since: '4.3.0',
11
+ options: {
12
+ org: orgaIdOrNameOption,
13
+ format: humanJsonOutputFormatOption,
14
+ },
15
+ args: [k8sIdOrNameArg],
16
+ async handler(options, clusterIdOrName) {
17
+ const { format, org: orgIdOrName } = options;
18
+
19
+ const k8sInfo = await getK8sCluster(orgIdOrName, clusterIdOrName);
20
+
21
+ switch (format) {
22
+ case 'json':
23
+ Logger.printJson(k8sInfo);
24
+ break;
25
+ case 'human':
26
+ default:
27
+ console.table({
28
+ Name: k8sInfo.name,
29
+ ID: k8sInfo.id,
30
+ Version: k8sInfo.version,
31
+ Status: k8sInfo.status,
32
+ });
33
+
34
+ Logger.println('');
35
+ const orgMessageComplement = orgIdOrName ? `--org "${orgIdOrName.orga_id || orgIdOrName.orga_name}"` : '';
36
+
37
+ Logger.println(
38
+ `Once ACTIVE, get the kubeconfig with ${styleText('blue', `clever k8s get-kubeconfig ${k8sInfo.id} ${orgMessageComplement}`)}`,
39
+ );
40
+ break;
41
+ }
42
+ },
43
+ });
@@ -0,0 +1,38 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { k8sList } from '../../lib/k8s.js';
3
+ import { styleText } from '../../lib/style-text.js';
4
+ import { Logger } from '../../logger.js';
5
+ import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
6
+
7
+ export const k8sListCommand = defineCommand({
8
+ description: 'List Kubernetes clusters',
9
+ since: '4.3.0',
10
+ options: {
11
+ org: orgaIdOrNameOption,
12
+ format: humanJsonOutputFormatOption,
13
+ },
14
+ args: [],
15
+ async handler(options) {
16
+ const { format, org: orgIdOrName } = options;
17
+ const clusters = await k8sList(orgIdOrName, format);
18
+
19
+ switch (format) {
20
+ case 'json':
21
+ Logger.printJson(clusters);
22
+ break;
23
+ case 'human':
24
+ default:
25
+ if (clusters.length === 0) {
26
+ Logger.println(`🔎 No cluster found, create one with ${styleText('blue', `clever k8s create`)} command`);
27
+ return;
28
+ }
29
+
30
+ Logger.println(`🔎 Found ${clusters.length} cluster${clusters.length > 1 ? 's' : ''}:`);
31
+
32
+ Object.values(clusters).forEach((c) => {
33
+ Logger.println(` • ${styleText('white', `${c.name} (${c.id})`)} - ${c.status}`);
34
+ });
35
+ break;
36
+ }
37
+ },
38
+ });
@@ -0,0 +1,17 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { operatorList } from '../../lib/operator-commands.js';
3
+ import { humanJsonOutputFormatOption } from '../global.options.js';
4
+
5
+ export const keycloakCommand = defineCommand({
6
+ description: 'Manage Clever Cloud Keycloak services',
7
+ since: '3.13.0',
8
+ isExperimental: true,
9
+ featureFlag: 'operators',
10
+ options: {
11
+ format: humanJsonOutputFormatOption,
12
+ },
13
+ args: [],
14
+ async handler(options) {
15
+ await operatorList('keycloak', options.format);
16
+ },
17
+ });
@@ -0,0 +1,13 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { operatorNgDisable } from '../../lib/operator-commands.js';
3
+ import { addonIdOrNameArg } from '../global.args.js';
4
+
5
+ export const keycloakDisableNgCommand = defineCommand({
6
+ description: 'Unlink Keycloak from its Network Group',
7
+ since: '3.13.0',
8
+ options: {},
9
+ args: [addonIdOrNameArg],
10
+ async handler(_options, addonIdOrName) {
11
+ await operatorNgDisable('keycloak', addonIdOrName);
12
+ },
13
+ });