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,23 @@
1
+ import { undeploy as stopApplication } 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 { aliasOption, appIdOrNameOption } from '../global.options.js';
7
+
8
+ export const stopCommand = defineCommand({
9
+ description: 'Stop a running application',
10
+ since: '0.2.0',
11
+ options: {
12
+ alias: aliasOption,
13
+ app: appIdOrNameOption,
14
+ },
15
+ args: [],
16
+ async handler(options) {
17
+ const { alias, app: appIdOrName } = options;
18
+ const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
19
+
20
+ await stopApplication({ id: ownerId, appId }).then(sendToApi);
21
+ Logger.printSuccess('Application successfully stopped!');
22
+ },
23
+ });
@@ -0,0 +1,16 @@
1
+ # 📖 `clever stop` command reference
2
+
3
+ ## ➡️ `clever stop` <kbd>Since 0.2.0</kbd>
4
+
5
+ Stop a running application
6
+
7
+ ```bash
8
+ clever stop [options]
9
+ ```
10
+
11
+ ### ⚙️ Options
12
+
13
+ |Name|Description|
14
+ |---|---|
15
+ |`-a`, `--alias` `<alias>`|Short name for the application|
16
+ |`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
@@ -0,0 +1,24 @@
1
+ import { addTcpRedir } 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 { aliasOption, appIdOrNameOption } from '../global.options.js';
7
+ import { namespaceOption } from './tcp-redirs.options.js';
8
+
9
+ export const tcpRedirsAddCommand = defineCommand({
10
+ description: 'Add a new TCP redirection to the application',
11
+ since: '2.3.0',
12
+ options: {
13
+ namespace: namespaceOption,
14
+ alias: aliasOption,
15
+ app: appIdOrNameOption,
16
+ },
17
+ args: [],
18
+ async handler(options) {
19
+ const { alias, app: appIdOrName, namespace } = options;
20
+ const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
21
+ const { port } = await addTcpRedir({ id: ownerId, appId }, { namespace }).then(sendToApi);
22
+ Logger.println('Successfully added tcp redirection on port: ' + port);
23
+ },
24
+ });
@@ -0,0 +1,41 @@
1
+ import { getTcpRedirs } 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 { aliasOption, appIdOrNameOption, humanJsonOutputFormatOption } from '../global.options.js';
7
+
8
+ export const tcpRedirsCommand = defineCommand({
9
+ description: 'Control the TCP redirections from reverse proxies to your application',
10
+ since: '2.3.0',
11
+ options: {
12
+ alias: aliasOption,
13
+ app: appIdOrNameOption,
14
+ format: humanJsonOutputFormatOption,
15
+ },
16
+ args: [],
17
+ async handler(options) {
18
+ const { alias, app: appIdOrName, format } = options;
19
+ const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
20
+
21
+ const redirs = await getTcpRedirs({ id: ownerId, appId }).then(sendToApi);
22
+
23
+ switch (format) {
24
+ case 'json': {
25
+ Logger.printJson(redirs);
26
+ break;
27
+ }
28
+ case 'human':
29
+ default: {
30
+ if (redirs.length === 0) {
31
+ Logger.println('No active TCP redirection for this application');
32
+ } else {
33
+ Logger.println('Enabled TCP redirections:');
34
+ for (const { namespace, port } of redirs) {
35
+ Logger.println(port + ' on ' + namespace);
36
+ }
37
+ }
38
+ }
39
+ }
40
+ },
41
+ });
@@ -0,0 +1,71 @@
1
+ # 📖 `clever tcp-redirs` command reference
2
+
3
+ ## ➡️ `clever tcp-redirs` <kbd>Since 2.3.0</kbd>
4
+
5
+ Control the TCP redirections from reverse proxies to your application
6
+
7
+ ```bash
8
+ clever tcp-redirs [options]
9
+ ```
10
+
11
+ ### ⚙️ Options
12
+
13
+ |Name|Description|
14
+ |---|---|
15
+ |`-a`, `--alias` `<alias>`|Short name for the application|
16
+ |`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
17
+ |`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
18
+
19
+ ## ➡️ `clever tcp-redirs add` <kbd>Since 2.3.0</kbd>
20
+
21
+ Add a new TCP redirection to the application
22
+
23
+ ```bash
24
+ clever tcp-redirs add --namespace <namespace> [options]
25
+ ```
26
+
27
+ ### ⚙️ Options
28
+
29
+ |Name|Description|
30
+ |---|---|
31
+ |`--namespace` `<namespace>`|Namespace in which the TCP redirection should be **(required)**|
32
+ |`-a`, `--alias` `<alias>`|Short name for the application|
33
+ |`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
34
+
35
+ ## ➡️ `clever tcp-redirs list-namespaces` <kbd>Since 2.3.0</kbd>
36
+
37
+ List the namespaces in which you can create new TCP redirections
38
+
39
+ ```bash
40
+ clever tcp-redirs list-namespaces [options]
41
+ ```
42
+
43
+ ### ⚙️ Options
44
+
45
+ |Name|Description|
46
+ |---|---|
47
+ |`-a`, `--alias` `<alias>`|Short name for the application|
48
+ |`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
49
+ |`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
50
+
51
+ ## ➡️ `clever tcp-redirs remove` <kbd>Since 2.3.0</kbd>
52
+
53
+ Remove a TCP redirection from the application
54
+
55
+ ```bash
56
+ clever tcp-redirs remove --namespace <namespace> <port> [options]
57
+ ```
58
+
59
+ ### 📥 Arguments
60
+
61
+ |Name|Description|
62
+ |---|---|
63
+ |`port`|port identifying the TCP redirection|
64
+
65
+ ### ⚙️ Options
66
+
67
+ |Name|Description|
68
+ |---|---|
69
+ |`--namespace` `<namespace>`|Namespace in which the TCP redirection should be **(required)**|
70
+ |`-a`, `--alias` `<alias>`|Short name for the application|
71
+ |`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
@@ -0,0 +1,48 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { Logger } from '../../logger.js';
3
+ import * as Application from '../../models/application.js';
4
+ import * as Namespaces from '../../models/namespaces.js';
5
+ import { aliasOption, appIdOrNameOption, humanJsonOutputFormatOption } from '../global.options.js';
6
+
7
+ export const tcpRedirsListNamespacesCommand = defineCommand({
8
+ description: 'List the namespaces in which you can create new TCP redirections',
9
+ since: '2.3.0',
10
+ options: {
11
+ alias: aliasOption,
12
+ app: appIdOrNameOption,
13
+ format: humanJsonOutputFormatOption,
14
+ },
15
+ args: [],
16
+ async handler(options) {
17
+ const { alias, app: appIdOrName, format } = options;
18
+ const { ownerId } = await Application.resolveId(appIdOrName, alias);
19
+
20
+ const namespaces = await Namespaces.getNamespaces(ownerId);
21
+
22
+ namespaces.sort((a, b) => a.namespace.localeCompare(b.namespace));
23
+
24
+ switch (format) {
25
+ case 'json': {
26
+ Logger.printJson(namespaces);
27
+ break;
28
+ }
29
+ case 'human':
30
+ default: {
31
+ Logger.println('Available namespaces:');
32
+ namespaces.forEach(({ namespace }) => {
33
+ switch (namespace) {
34
+ case 'cleverapps':
35
+ Logger.println(`- ${namespace}: for redirections used with 'cleverapps.io' domain`);
36
+ break;
37
+ case 'default':
38
+ Logger.println(`- ${namespace}: for redirections used with custom domains`);
39
+ break;
40
+ default:
41
+ Logger.println(`- ${namespace}`);
42
+ }
43
+ });
44
+ break;
45
+ }
46
+ }
47
+ },
48
+ });
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ import { defineOption } from '../../lib/define-option.js';
3
+ import { completeNamespaces } from '../../models/namespaces.js';
4
+
5
+ export const namespaceOption = defineOption({
6
+ name: 'namespace',
7
+ schema: z.string(),
8
+ description: 'Namespace in which the TCP redirection should be',
9
+ placeholder: 'namespace',
10
+ complete: completeNamespaces,
11
+ });
@@ -0,0 +1,34 @@
1
+ import { removeTcpRedir } from '@clevercloud/client/esm/api/v2/application.js';
2
+ import { z } from 'zod';
3
+ import { defineArgument } from '../../lib/define-argument.js';
4
+ import { defineCommand } from '../../lib/define-command.js';
5
+ import { Logger } from '../../logger.js';
6
+ import * as Application from '../../models/application.js';
7
+ import { sendToApi } from '../../models/send-to-api.js';
8
+ import { aliasOption, appIdOrNameOption } from '../global.options.js';
9
+ import { namespaceOption } from './tcp-redirs.options.js';
10
+
11
+ export const tcpRedirsRemoveCommand = defineCommand({
12
+ description: 'Remove a TCP redirection from the application',
13
+ since: '2.3.0',
14
+ options: {
15
+ namespace: namespaceOption,
16
+ alias: aliasOption,
17
+ app: appIdOrNameOption,
18
+ },
19
+ args: [
20
+ defineArgument({
21
+ schema: z.coerce.number().int().min(1025, 65535),
22
+ description: 'port identifying the TCP redirection',
23
+ placeholder: 'port',
24
+ }),
25
+ ],
26
+ async handler(options, port) {
27
+ const { alias, app: appIdOrName, namespace } = options;
28
+ const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
29
+
30
+ await removeTcpRedir({ id: ownerId, appId, sourcePort: port, namespace }).then(sendToApi);
31
+
32
+ Logger.println('Successfully removed tcp redirection.');
33
+ },
34
+ });
@@ -0,0 +1,43 @@
1
+ import { listApiTokens } from '../../clever-client/auth-bridge.js';
2
+ import { defineCommand } from '../../lib/define-command.js';
3
+ import { formatDate } from '../../lib/format-date.js';
4
+ import { styleText } from '../../lib/style-text.js';
5
+ import { Logger } from '../../logger.js';
6
+ import { conf } from '../../models/configuration.js';
7
+ import { sendToAuthBridge } from '../../models/send-to-api.js';
8
+ import { humanJsonOutputFormatOption } from '../global.options.js';
9
+
10
+ export const tokensCommand = defineCommand({
11
+ description: `Manage API tokens to query Clever Cloud API from ${conf.AUTH_BRIDGE_HOST}`,
12
+ since: '3.12.0',
13
+ options: {
14
+ format: humanJsonOutputFormatOption,
15
+ },
16
+ args: [],
17
+ async handler(options) {
18
+ const { format } = options;
19
+
20
+ const tokens = await listApiTokens().then(sendToAuthBridge);
21
+
22
+ if (format === 'json') {
23
+ Logger.printJson(tokens);
24
+ } else {
25
+ if (tokens.length === 0) {
26
+ Logger.println(`ℹ️ No API token found, create one with ${styleText('blue', 'clever tokens create')} command`);
27
+ } else {
28
+ console.table(
29
+ tokens.map((token) => {
30
+ return {
31
+ 'API token ID': token.apiTokenId,
32
+ Name: token.name,
33
+ 'Creation IP address': token.ip,
34
+ Creation: formatDate(token.creationDate),
35
+ Expiration: formatDate(token.expirationDate),
36
+ State: token.state,
37
+ };
38
+ }),
39
+ );
40
+ }
41
+ }
42
+ },
43
+ });
@@ -0,0 +1,108 @@
1
+ import dedent from 'dedent';
2
+ import { z } from 'zod';
3
+ import { createApiToken } from '../../clever-client/auth-bridge.js';
4
+ import { defineArgument } from '../../lib/define-argument.js';
5
+ import { defineCommand } from '../../lib/define-command.js';
6
+ import { defineOption } from '../../lib/define-option.js';
7
+ import { formatDate } from '../../lib/format-date.js';
8
+ import { promptSecret } from '../../lib/prompts.js';
9
+ import { styleText } from '../../lib/style-text.js';
10
+ import { Logger } from '../../logger.js';
11
+ import { conf } from '../../models/configuration.js';
12
+ import { sendToAuthBridge } from '../../models/send-to-api.js';
13
+ import { getCurrent as getCurrentUser } from '../../models/user.js';
14
+ import { futureDateOrDuration } from '../../parsers.js';
15
+ import { humanJsonOutputFormatOption } from '../global.options.js';
16
+
17
+ export const tokensCreateCommand = defineCommand({
18
+ description: 'Create an API token',
19
+ since: '3.12.0',
20
+ options: {
21
+ expiration: defineOption({
22
+ name: 'expiration',
23
+ schema: z.string().default('1y').transform(futureDateOrDuration),
24
+ description: 'Duration until API token expiration (e.g.: 1h, 4d, 2w, 6M)',
25
+ aliases: ['e'],
26
+ placeholder: 'expiration',
27
+ }),
28
+ format: humanJsonOutputFormatOption,
29
+ },
30
+ args: [
31
+ defineArgument({
32
+ schema: z.string(),
33
+ description: 'API token name',
34
+ placeholder: 'api-token-name',
35
+ }),
36
+ ],
37
+ async handler(options, apiTokenName) {
38
+ const { expiration, format } = options;
39
+ const user = await getCurrentUser();
40
+
41
+ if (!user.hasPassword) {
42
+ const apiTokenListHref = new URL('/users/me/api-tokens', conf.CONSOLE_URL).href;
43
+ throw new Error(dedent`
44
+ ${styleText('yellow', '!')} Your Clever Cloud account is linked via GitHub and has no password. Setting one is required to create API tokens.
45
+ ${styleText('blue', '→')} To do so, go to the following URL: ${styleText('blue', apiTokenListHref)}
46
+ `);
47
+ }
48
+
49
+ // Max expiration is 1 year from now
50
+ const maxExpirationDate = new Date();
51
+ maxExpirationDate.setFullYear(maxExpirationDate.getFullYear() + 1);
52
+
53
+ if (expiration > maxExpirationDate) {
54
+ throw new Error('You cannot set an expiration date greater than 1 year');
55
+ }
56
+ const expirationDate = expiration;
57
+
58
+ const password = await promptSecret('Enter your password:');
59
+
60
+ let mfaCode;
61
+ if (user.preferredMFA === 'TOTP') {
62
+ mfaCode = await promptSecret('Enter your 2FA code:');
63
+ }
64
+
65
+ const tokenData = {
66
+ email: user.email,
67
+ password,
68
+ mfaCode,
69
+ name: apiTokenName,
70
+ expirationDate: expirationDate.toISOString(),
71
+ };
72
+ const createdToken = await createApiToken(tokenData)
73
+ .then(sendToAuthBridge)
74
+ .catch((error) => {
75
+ const errorCode = error?.cause?.responseBody?.code;
76
+ if (errorCode === 'invalid-credential') {
77
+ throw new Error('Invalid credentials, check your password');
78
+ }
79
+ if (errorCode === 'invalid-mfa-code') {
80
+ throw new Error('Invalid credentials, check your 2FA code');
81
+ }
82
+ throw error;
83
+ });
84
+
85
+ switch (format) {
86
+ case 'json':
87
+ Logger.printJson(createdToken);
88
+ break;
89
+ case 'human':
90
+ default:
91
+ Logger.println(dedent`
92
+ ${styleText('green', '✔')} API token successfully created! Store it securely, you won't able to print it again.
93
+
94
+ - API token ID : ${styleText('grey', createdToken.apiTokenId)}
95
+ - API token : ${styleText('grey', createdToken.apiToken)}
96
+ - Expiration : ${styleText('grey', formatDate(createdToken.expirationDate))}
97
+
98
+ Export this token and use it to make authenticated requests to the Clever Cloud API through the Auth Bridge:
99
+
100
+ export CC_API_TOKEN=${createdToken.apiToken}
101
+ curl -H "Authorization: Bearer $CC_API_TOKEN" ${conf.AUTH_BRIDGE_HOST}/v2/self
102
+
103
+ Then, to revoke this token, run:
104
+ clever tokens revoke ${createdToken.apiTokenId}
105
+ `);
106
+ }
107
+ },
108
+ });
@@ -0,0 +1,50 @@
1
+ # 📖 `clever tokens` command reference
2
+
3
+ ## ➡️ `clever tokens` <kbd>Since 3.12.0</kbd>
4
+
5
+ Manage API tokens to query Clever Cloud API from https://api-bridge.clever-cloud.com
6
+
7
+ ```bash
8
+ clever tokens [options]
9
+ ```
10
+
11
+ ### ⚙️ Options
12
+
13
+ |Name|Description|
14
+ |---|---|
15
+ |`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
16
+
17
+ ## ➡️ `clever tokens create` <kbd>Since 3.12.0</kbd>
18
+
19
+ Create an API token
20
+
21
+ ```bash
22
+ clever tokens create <api-token-name> [options]
23
+ ```
24
+
25
+ ### 📥 Arguments
26
+
27
+ |Name|Description|
28
+ |---|---|
29
+ |`api-token-name`|API token name|
30
+
31
+ ### ⚙️ Options
32
+
33
+ |Name|Description|
34
+ |---|---|
35
+ |`-e`, `--expiration` `<expiration>`|Duration until API token expiration (e.g.: 1h, 4d, 2w, 6M) (default: 1y)|
36
+ |`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
37
+
38
+ ## ➡️ `clever tokens revoke` <kbd>Since 3.12.0</kbd>
39
+
40
+ Revoke an API token
41
+
42
+ ```bash
43
+ clever tokens revoke <api-token-id>
44
+ ```
45
+
46
+ ### 📥 Arguments
47
+
48
+ |Name|Description|
49
+ |---|---|
50
+ |`api-token-id`|API token ID|
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ import { deleteApiToken } from '../../clever-client/auth-bridge.js';
3
+ import { defineArgument } from '../../lib/define-argument.js';
4
+ import { defineCommand } from '../../lib/define-command.js';
5
+ import { styleText } from '../../lib/style-text.js';
6
+ import { Logger } from '../../logger.js';
7
+ import { sendToAuthBridge } from '../../models/send-to-api.js';
8
+
9
+ export const tokensRevokeCommand = defineCommand({
10
+ description: 'Revoke an API token',
11
+ since: '3.12.0',
12
+ options: {},
13
+ args: [
14
+ defineArgument({
15
+ schema: z.string(),
16
+ description: 'API token ID',
17
+ placeholder: 'api-token-id',
18
+ }),
19
+ ],
20
+ async handler(_options, apiTokenId) {
21
+ await deleteApiToken(apiTokenId).then(sendToAuthBridge);
22
+
23
+ Logger.println(styleText('green', '✔'), 'API token successfully revoked!');
24
+ },
25
+ });
@@ -0,0 +1,21 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { styleText } from '../../lib/style-text.js';
3
+ import { Logger } from '../../logger.js';
4
+ import * as AppConfig from '../../models/app_configuration.js';
5
+ import * as Application from '../../models/application.js';
6
+ import { aliasArg } from '../global.args.js';
7
+
8
+ export const unlinkCommand = defineCommand({
9
+ description: 'Unlink this repo from an existing application',
10
+ since: '0.2.0',
11
+ options: {},
12
+ args: [aliasArg],
13
+ async handler(_options, alias) {
14
+ const app = await AppConfig.getAppDetails({ alias });
15
+
16
+ await Application.unlinkRepo(app.alias);
17
+ Logger.printSuccess(
18
+ `Application ${styleText('green', app.appId)} has been successfully unlinked from local alias ${styleText('green', app.alias)}!`,
19
+ );
20
+ },
21
+ });
@@ -0,0 +1,15 @@
1
+ # 📖 `clever unlink` command reference
2
+
3
+ ## ➡️ `clever unlink` <kbd>Since 0.2.0</kbd>
4
+
5
+ Unlink this repo from an existing application
6
+
7
+ ```bash
8
+ clever unlink <app-alias>
9
+ ```
10
+
11
+ ### 📥 Arguments
12
+
13
+ |Name|Description|
14
+ |---|---|
15
+ |`app-alias`|Application alias|
@@ -0,0 +1,13 @@
1
+ import pkg from '../../../package.json' with { type: 'json' };
2
+ import { defineCommand } from '../../lib/define-command.js';
3
+ import { Logger } from '../../logger.js';
4
+
5
+ export const versionCommand = defineCommand({
6
+ description: 'Display the clever-tools version',
7
+ since: '1.0.0',
8
+ options: {},
9
+ args: [],
10
+ async handler() {
11
+ Logger.println(pkg.version);
12
+ },
13
+ });
@@ -0,0 +1,9 @@
1
+ # 📖 `clever version` command reference
2
+
3
+ ## ➡️ `clever version` <kbd>Since 1.0.0</kbd>
4
+
5
+ Display the clever-tools version
6
+
7
+ ```bash
8
+ clever version
9
+ ```
@@ -0,0 +1,51 @@
1
+ import { createWebhook } from '@clevercloud/client/esm/api/v2/notification.js';
2
+ import { z } from 'zod';
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 { Logger } from '../../logger.js';
7
+ import { getOwnerAndApp } from '../../models/notification.js';
8
+ import { sendToApi } from '../../models/send-to-api.js';
9
+ import { notificationNameArg } from '../global.args.js';
10
+ import { notificationEventTypeOption, notificationScopeOption, orgaIdOrNameOption } from '../global.options.js';
11
+
12
+ export const webhooksAddCommand = defineCommand({
13
+ description: 'Register webhook to be called when events happen',
14
+ since: '0.6.0',
15
+ options: {
16
+ format: defineOption({
17
+ name: 'format',
18
+ schema: z.string().default('raw'),
19
+ description: "Format of the body sent to the webhook ('raw', 'slack', 'gitter', or 'flowdock')",
20
+ placeholder: 'format',
21
+ }),
22
+ org: orgaIdOrNameOption,
23
+ event: notificationEventTypeOption,
24
+ service: notificationScopeOption,
25
+ },
26
+ args: [
27
+ notificationNameArg,
28
+ defineArgument({
29
+ schema: z.string(),
30
+ description: 'Webhook URL',
31
+ placeholder: 'url',
32
+ }),
33
+ ],
34
+ async handler(options, name, hookUrl) {
35
+ const { org, format, event: events, service } = options;
36
+
37
+ // TODO: fix alias option
38
+ const { ownerId, appId } = await getOwnerAndApp(null, org, !org && !service);
39
+
40
+ const body = {
41
+ name,
42
+ urls: [{ format, url: hookUrl }],
43
+ scope: appId != null && service == null ? [appId] : service,
44
+ events,
45
+ };
46
+
47
+ await createWebhook({ ownerId }, body).then(sendToApi);
48
+
49
+ Logger.println('The webhook has been added');
50
+ },
51
+ });
@@ -0,0 +1,57 @@
1
+ import { getWebhooks } from '@clevercloud/client/esm/api/v2/notification.js';
2
+ import { defineCommand } from '../../lib/define-command.js';
3
+ import { styleText } from '../../lib/style-text.js';
4
+ import { Logger } from '../../logger.js';
5
+ import { getOwnerAndApp } from '../../models/notification.js';
6
+ import { sendToApi } from '../../models/send-to-api.js';
7
+ import { humanJsonOutputFormatOption, listAllNotificationsOption, orgaIdOrNameOption } from '../global.options.js';
8
+
9
+ export const webhooksCommand = defineCommand({
10
+ description: 'Manage webhooks',
11
+ since: '0.6.0',
12
+ options: {
13
+ org: orgaIdOrNameOption,
14
+ listAll: listAllNotificationsOption,
15
+ format: humanJsonOutputFormatOption,
16
+ },
17
+ args: [],
18
+ async handler(options) {
19
+ const { org, listAll, format } = options;
20
+
21
+ // TODO: fix alias option
22
+ const { ownerId, appId } = await getOwnerAndApp(null, org, !listAll);
23
+ const hooks = await getWebhooks({ ownerId }).then(sendToApi);
24
+
25
+ const formattedHooks = hooks
26
+ .filter((hook) => {
27
+ const emptyScope = !hook.scope || hook.scope.length === 0;
28
+ return !appId || emptyScope || hook.scope.includes(appId);
29
+ })
30
+ .map((hook) => ({
31
+ id: hook.id,
32
+ name: hook.name,
33
+ ownerId: hook.ownerId,
34
+ services: hook.scope ?? [hook.ownerId],
35
+ events: hook.events ?? ['ALL'],
36
+ urls: hook.urls,
37
+ }));
38
+
39
+ switch (format) {
40
+ case 'json': {
41
+ Logger.printJson(formattedHooks);
42
+ break;
43
+ }
44
+ case 'human':
45
+ default: {
46
+ formattedHooks.forEach((hook) => {
47
+ Logger.println(hook.name ? styleText('bold', hook.name) : hook.id);
48
+ Logger.println(` id: ${hook.id}`);
49
+ Logger.println(` services: ${hook.services.join(', ')}`);
50
+ Logger.println(` events: ${hook.events.join(', ')}`);
51
+ Logger.println(' hooks:');
52
+ hook.urls.forEach((url) => Logger.println(` ${url.url} (${url.format})`));
53
+ });
54
+ }
55
+ }
56
+ },
57
+ });