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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clever-tools",
3
- "version": "4.4.1",
3
+ "version": "4.5.0",
4
4
  "description": "Command Line Interface for Clever Cloud.",
5
5
  "keywords": [
6
6
  "cli",
@@ -37,54 +37,62 @@
37
37
  "scripts/*.sh"
38
38
  ],
39
39
  "scripts": {
40
- "fix-all": "npm run lint:fix && npm run format",
40
+ "docs": "node scripts/generate-docs.js",
41
+ "docs:check": "node scripts/generate-docs.js --check",
42
+ "fix-all": "npm run lint:fix && npm run docs && npm run format",
41
43
  "format": "prettier . --write",
42
44
  "format:check": "prettier . --check",
43
45
  "install-local:cliparse": "(cd ../cliparse-node && npm pack) && mv ../cliparse-node/cliparse-*.tgz . && npm i -f ./cliparse-*.tgz",
44
46
  "lint": "eslint",
45
47
  "lint:fix": "eslint --fix",
46
- "validate": "npm run lint && npm run format:check && npm run typecheck",
48
+ "validate": "npm run lint && npm run format:check && npm run typecheck && npm run docs:check",
47
49
  "typecheck": "tsc -p tsconfig.json"
48
50
  },
49
51
  "dependencies": {
50
- "@clevercloud/client": "11.2.0",
52
+ "@babel/traverse": "7.28.5",
53
+ "@clevercloud/client": "11.3.0",
51
54
  "@inquirer/prompts": "7.8.4",
52
55
  "char-regex": "2.0.2",
53
56
  "cliparse": "0.5.0",
54
- "dedent": "1.6.0",
55
- "eventsource": "4.0.0",
56
- "ioredis": "5.7.0",
57
- "iso8601-duration": "2.1.2",
58
- "isomorphic-git": "1.33.1",
57
+ "dedent": "1.7.0",
58
+ "eventsource": "4.1.0",
59
+ "ioredis": "5.8.2",
60
+ "iso8601-duration": "2.1.3",
61
+ "isomorphic-git": "1.35.1",
59
62
  "linux-release-info": "3.0.0",
60
63
  "lodash": "4.17.21",
61
64
  "open": "10.2.0",
62
- "semver": "7.7.2",
65
+ "semver": "7.7.3",
63
66
  "slugify": "1.6.6",
64
- "tldts": "7.0.12",
67
+ "tldts": "7.0.19",
65
68
  "update-notifier": "7.3.1",
66
- "xdg": "0.1.1"
69
+ "xdg": "0.1.1",
70
+ "zod": "4.1.13"
67
71
  },
68
72
  "devDependencies": {
69
- "@aws-sdk/client-s3": "3.876.0",
70
- "@clevercloud/eslint-config": "1.0.1",
73
+ "@aws-sdk/client-s3": "3.940.0",
74
+ "@clevercloud/eslint-config": "1.1.0",
71
75
  "@commitlint/cli": "19.8.1",
72
76
  "@commitlint/config-conventional": "19.8.1",
73
77
  "@eslint/compat": "1.3.2",
74
78
  "@rollup/plugin-commonjs": "28.0.6",
75
79
  "@rollup/plugin-json": "6.1.0",
76
- "@rollup/plugin-node-resolve": "16.0.1",
80
+ "@rollup/plugin-node-resolve": "16.0.3",
77
81
  "@types/mime-types": "3.0.1",
78
- "@yao-pkg/pkg": "6.6.0",
79
- "eslint": "9.34.0",
80
- "globals": "16.3.0",
81
- "mime-types": "3.0.1",
82
- "prettier": "3.6.2",
83
- "prettier-plugin-organize-imports": "4.2.0",
84
- "rollup": "4.49.0",
85
- "simple-git": "3.28.0",
86
- "tinyglobby": "0.2.14",
87
- "typescript": "5.9.2"
82
+ "@types/picomatch": "4.0.2",
83
+ "@yao-pkg/pkg": "6.10.1",
84
+ "eslint": "9.39.1",
85
+ "globals": "16.5.0",
86
+ "mime-types": "3.0.2",
87
+ "prettier": "3.7.3",
88
+ "prettier-plugin-organize-imports": "4.3.0",
89
+ "remark-parse": "11.0.0",
90
+ "remark-stringify": "11.0.0",
91
+ "rollup": "4.53.3",
92
+ "simple-git": "3.30.0",
93
+ "tinyglobby": "0.2.15",
94
+ "typescript": "5.9.3",
95
+ "unified": "11.0.5"
88
96
  },
89
97
  "engines": {
90
98
  "node": ">=22"
@@ -0,0 +1,65 @@
1
+ # clever-tools reference
2
+
3
+ This directory contains the documentation for all `clever` CLI commands.
4
+
5
+ ## ⚙️ Global options
6
+
7
+ These options are available for all commands:
8
+
9
+ |Name|Description|
10
+ |---|---|
11
+ |`--color`|Choose whether to print colors or not. You can also use --no-color|
12
+ |`-v`, `--verbose`|Verbose output|
13
+ |`--update-notifier`|Choose whether to use update notifier or not. You can also use --no-update-notifier|
14
+
15
+ ## ➡️ Commands
16
+
17
+ |Command|Description|
18
+ |---|---|
19
+ |[`clever accesslogs`](./accesslogs/accesslogs.docs.md)|Fetch access logs|
20
+ |[`clever activity`](./activity/activity.docs.md)|Show last deployments of an application|
21
+ |[`clever addon`](./addon/addon.docs.md)|Manage add-ons|
22
+ |[`clever applications`](./applications/applications.docs.md)|List linked applications|
23
+ |[`clever cancel-deploy`](./cancel-deploy/cancel-deploy.docs.md)|Cancel an ongoing deployment|
24
+ |[`clever config`](./config/config.docs.md)|Display or edit the configuration of your application|
25
+ |[`clever console`](./console/console.docs.md)|Open an application in the Console|
26
+ |[`clever create`](./create/create.docs.md)|Create an application|
27
+ |[`clever curl`](./curl/curl.docs.md)|Query Clever Cloud's API using Clever Tools credentials|
28
+ |[`clever database`](./database/database.docs.md)|Manage databases and backups|
29
+ |[`clever delete`](./delete/delete.docs.md)|Delete an application|
30
+ |[`clever deploy`](./deploy/deploy.docs.md)|Deploy an application|
31
+ |[`clever diag`](./diag/diag.docs.md)|Diagnose the current installation (prints various informations for support)|
32
+ |[`clever domain`](./domain/domain.docs.md)|Manage domain names for an application|
33
+ |[`clever drain`](./drain/drain.docs.md)|Manage drains|
34
+ |[`clever emails`](./emails/emails.docs.md)|Manage email addresses of the current user|
35
+ |[`clever env`](./env/env.docs.md)|Manage environment variables of an application|
36
+ |[`clever features`](./features/features.docs.md)|Manage Clever Tools experimental features|
37
+ |[`clever help`](./help/help.docs.md)|Display help about the Clever Cloud CLI|
38
+ |[`clever k8s`](./k8s/k8s.docs.md)|Manage Kubernetes clusters|
39
+ |[`clever keycloak`](./keycloak/keycloak.docs.md)|Manage Clever Cloud Keycloak services|
40
+ |[`clever kv`](./kv/kv.docs.md)|Send a raw command to a Materia KV or Redis® add-on|
41
+ |[`clever link`](./link/link.docs.md)|Link this repo to an existing application|
42
+ |[`clever login`](./login/login.docs.md)|Login to Clever Cloud|
43
+ |[`clever logout`](./logout/logout.docs.md)|Logout from Clever Cloud|
44
+ |[`clever logs`](./logs/logs.docs.md)|Fetch application logs, continuously|
45
+ |[`clever make-default`](./make-default/make-default.docs.md)|Make a linked application the default one|
46
+ |[`clever matomo`](./matomo/matomo.docs.md)|Manage Clever Cloud Matomo services|
47
+ |[`clever metabase`](./metabase/metabase.docs.md)|Manage Clever Cloud Metabase services|
48
+ |[`clever ng`](./ng/ng.docs.md)|List Network Groups|
49
+ |[`clever notify-email`](./notify-email/notify-email.docs.md)|Manage email notifications|
50
+ |[`clever open`](./open/open.docs.md)|Open an application in the Console|
51
+ |[`clever otoroshi`](./otoroshi/otoroshi.docs.md)|Manage Clever Cloud Otoroshi services|
52
+ |[`clever profile`](./profile/profile.docs.md)|Display the profile of the current user|
53
+ |[`clever published-config`](./published-config/published-config.docs.md)|Manage the configuration made available to other applications by this application|
54
+ |[`clever restart`](./restart/restart.docs.md)|Start or restart an application|
55
+ |[`clever scale`](./scale/scale.docs.md)|Change scalability of an application|
56
+ |[`clever service`](./service/service.docs.md)|Manage service dependencies|
57
+ |[`clever ssh`](./ssh/ssh.docs.md)|Connect to running instances through SSH|
58
+ |[`clever ssh-keys`](./ssh-keys/ssh-keys.docs.md)|Manage SSH keys of the current user|
59
+ |[`clever status`](./status/status.docs.md)|See the status of an application|
60
+ |[`clever stop`](./stop/stop.docs.md)|Stop a running application|
61
+ |[`clever tcp-redirs`](./tcp-redirs/tcp-redirs.docs.md)|Control the TCP redirections from reverse proxies to your application|
62
+ |[`clever tokens`](./tokens/tokens.docs.md)|Manage API tokens to query Clever Cloud API from https://api-bridge.clever-cloud.com|
63
+ |[`clever unlink`](./unlink/unlink.docs.md)|Unlink this repo from an existing application|
64
+ |[`clever version`](./version/version.docs.md)|Display the clever-tools version|
65
+ |[`clever webhooks`](./webhooks/webhooks.docs.md)|Manage webhooks|
@@ -0,0 +1,158 @@
1
+ import { ApplicationAccessLogStream } from '@clevercloud/client/esm/streams/access-logs.js';
2
+ import { formatTable } from '../../format-table.js';
3
+ import { defineCommand } from '../../lib/define-command.js';
4
+ import { styleText } from '../../lib/style-text.js';
5
+ import { Logger } from '../../logger.js';
6
+ import * as Application from '../../models/application.js';
7
+ import { JsonArray } from '../../models/json-array.js';
8
+ import { getHostAndTokens } from '../../models/send-to-api.js';
9
+ import { truncateWithEllipsis } from '../../models/utils.js';
10
+ import {
11
+ addonIdOption,
12
+ afterOption,
13
+ aliasOption,
14
+ appIdOrNameOption,
15
+ beforeOption,
16
+ logsFormatOption,
17
+ } from '../global.options.js';
18
+
19
+ const THROTTLE_ELEMENTS = 2000;
20
+
21
+ const THROTTLE_PER_IN_MILLISECONDS = 100;
22
+
23
+ const CITY_MAX_LENGTH = 20;
24
+
25
+ function formatHuman(log) {
26
+ const { date, http, source } = log;
27
+ const country = source.countryCode ?? '(unknown)';
28
+ const hasSourceCity = source.city ?? '';
29
+
30
+ return formatTable(
31
+ [
32
+ [
33
+ styleText('grey', date.toISOString(date)),
34
+ source.ip,
35
+ `${country}${hasSourceCity ? '/' + truncateWithEllipsis(CITY_MAX_LENGTH, source.city) : ''}`,
36
+ colorStatusCode(http.response.statusCode),
37
+ http.request.method.toString().padEnd(4, ' ') + ' ' + http.request.path,
38
+ ],
39
+ ],
40
+
41
+ ACCESSLOG_COLUMN_WIDTHS,
42
+ );
43
+ }
44
+
45
+ const ACCESSLOG_COLUMN_WIDTHS = [
46
+ '2024-06-24T08:05:43.880Z',
47
+ '255.255.255.255',
48
+ // country / city
49
+ 2 + 1 + CITY_MAX_LENGTH,
50
+ 'XXX',
51
+ // longest method name
52
+ 'OPTIONS',
53
+ // path
54
+ ];
55
+
56
+ function colorStatusCode(code) {
57
+ const codeString = code.toString();
58
+ if (code >= 500) {
59
+ return styleText('red', codeString);
60
+ }
61
+ if (code >= 400) {
62
+ return styleText('yellow', codeString);
63
+ }
64
+ if (code >= 300) {
65
+ return styleText('blue', codeString);
66
+ }
67
+ if (code >= 200) {
68
+ return styleText('green', codeString);
69
+ }
70
+ return codeString;
71
+ }
72
+
73
+ export const accesslogsCommand = defineCommand({
74
+ description: 'Fetch access logs',
75
+ since: '2.1.0',
76
+ options: {
77
+ alias: aliasOption,
78
+ app: appIdOrNameOption,
79
+ format: logsFormatOption,
80
+ before: beforeOption,
81
+ after: afterOption,
82
+ addon: addonIdOption,
83
+ },
84
+ args: [],
85
+ async handler(options) {
86
+ // TODO: drop when add-ons are supported in API
87
+ if (options.addon) {
88
+ throw new Error('Access Logs are not available for add-ons yet');
89
+ }
90
+
91
+ const { apiHost, tokens } = await getHostAndTokens();
92
+ const { alias, app: appIdOrName, format, before: until, after: since } = options;
93
+ const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
94
+
95
+ const stream = new ApplicationAccessLogStream({
96
+ apiHost,
97
+ tokens,
98
+ ownerId,
99
+ appId,
100
+ since,
101
+ until,
102
+ throttleElements: THROTTLE_ELEMENTS,
103
+ throttlePerInMilliseconds: THROTTLE_PER_IN_MILLISECONDS,
104
+ });
105
+
106
+ if (format === 'human') {
107
+ Logger.println(styleText('yellow', '/!\\ This feature is in Beta testing phase'));
108
+ }
109
+
110
+ if (format === 'json' && !until) {
111
+ throw new Error('JSON format only works with a limiting parameter such as `before`');
112
+ }
113
+
114
+ // used for 'json' format
115
+ const jsonArray = new JsonArray();
116
+
117
+ stream
118
+ .on('open', () => {
119
+ Logger.debug(styleText('blue', `Logs stream (open) ${JSON.stringify({ appId })}`));
120
+ if (format === 'json') {
121
+ jsonArray.open();
122
+ }
123
+ })
124
+ .on('error', (event) => {
125
+ Logger.debug(styleText('red', `Logs stream (error) ${event.error.message}`));
126
+ })
127
+ .onLog((log) => {
128
+ switch (format) {
129
+ case 'json':
130
+ jsonArray.push(log);
131
+ break;
132
+ case 'json-stream':
133
+ Logger.printJson(log);
134
+ break;
135
+ case 'human':
136
+ default:
137
+ // when the connection is cut too early, or for TCP redirections, we don't have HTTP section
138
+ if (log.http == null) {
139
+ break;
140
+ }
141
+
142
+ Logger.println(formatHuman(log));
143
+ break;
144
+ }
145
+ });
146
+
147
+ // Properly close the stream
148
+ process.once('SIGINT', (signal) => stream.close(signal));
149
+
150
+ const closeReason = await stream.start();
151
+
152
+ if (format === 'json') {
153
+ jsonArray.close();
154
+ }
155
+
156
+ Logger.debug(`stream closed: ${closeReason?.type}`);
157
+ },
158
+ });
@@ -0,0 +1,20 @@
1
+ # 📖 `clever accesslogs` command reference
2
+
3
+ ## ➡️ `clever accesslogs` <kbd>Since 2.1.0</kbd>
4
+
5
+ Fetch access logs
6
+
7
+ ```bash
8
+ clever accesslogs [options]
9
+ ```
10
+
11
+ ### ⚙️ Options
12
+
13
+ |Name|Description|
14
+ |---|---|
15
+ |`--addon` `<addon-id>`|Add-on ID|
16
+ |`--after`, `--since` `<after>`|Fetch logs after this date/time (ISO8601 date, positive number in seconds or duration, e.g.: 1h)|
17
+ |`-a`, `--alias` `<alias>`|Short name for the application|
18
+ |`--app` `<app-id\|app-name>`|Application to manage by its ID (or name, if unambiguous)|
19
+ |`--before`, `--until` `<before>`|Fetch logs before this date/time (ISO8601 date, positive number in seconds or duration, e.g.: 1h)|
20
+ |`-F`, `--format` `<format>`|Output format (human, json, json-stream) (default: human)|
@@ -1,12 +1,15 @@
1
- import { styleText } from '../lib/style-text.js';
2
-
3
1
  import { EventsStream } from '@clevercloud/client/esm/streams/events.js';
4
- import { formatTable } from '../format-table.js';
5
- import { Logger } from '../logger.js';
6
- import * as Activity from '../models/activity.js';
7
- import * as Application from '../models/application.js';
8
- import { getHostAndTokens } from '../models/send-to-api.js';
9
- import { Deferred } from '../models/utils.js';
2
+ import { z } from 'zod';
3
+ import { formatTable } from '../../format-table.js';
4
+ import { defineCommand } from '../../lib/define-command.js';
5
+ import { defineOption } from '../../lib/define-option.js';
6
+ import { styleText } from '../../lib/style-text.js';
7
+ import { Logger } from '../../logger.js';
8
+ import * as Activity from '../../models/activity.js';
9
+ import * as Application from '../../models/application.js';
10
+ import { getHostAndTokens } from '../../models/send-to-api.js';
11
+ import { Deferred } from '../../models/utils.js';
12
+ import { aliasOption, appIdOrNameOption } from '../global.options.js';
10
13
 
11
14
  const dtf = new Intl.DateTimeFormat('en', {
12
15
  year: 'numeric',
@@ -41,7 +44,6 @@ function getColoredState(state, isLast) {
41
44
  return 'UNKNOWN';
42
45
  }
43
46
 
44
- // We use examples of maximum width text to have a clean display
45
47
  const ACTIVITY_TABLE_COLUMN_WIDTHS = [
46
48
  formatDate(Date.now()),
47
49
  47,
@@ -75,6 +77,7 @@ function formatActivityLine(event) {
75
77
  event.cause,
76
78
  ],
77
79
  ],
80
+
78
81
  ACTIVITY_TABLE_COLUMN_WIDTHS,
79
82
  );
80
83
  }
@@ -153,43 +156,70 @@ function getEventHandler(format, follow) {
153
156
  }
154
157
  }
155
158
 
156
- export async function activity(params) {
157
- const { alias, app: appIdOrName, 'show-all': showAll, follow, format } = params.options;
158
- const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
159
- const events = await Activity.list(ownerId, appId, showAll);
160
- const reversedArrayWithIndex = events.reverse().map((event, index, all) => {
161
- const isLast = index === all.length - 1;
162
- return { ...event, isLast };
163
- });
164
-
165
- const handler = getEventHandler(format, follow);
166
-
167
- let lastEvent = reversedArrayWithIndex.reduce(
168
- (previousEvent, newEvent) => handleEvent(previousEvent, newEvent, handler),
169
- {},
170
- );
171
-
172
- if (!follow) {
173
- handler.end();
174
- return lastEvent;
175
- }
159
+ export const activityCommand = defineCommand({
160
+ description: 'Show last deployments of an application',
161
+ since: '0.2.3',
162
+ options: {
163
+ follow: defineOption({
164
+ name: 'follow',
165
+ schema: z.boolean().default(false),
166
+ description: 'Track new deployments in activity list',
167
+ aliases: ['f'],
168
+ }),
169
+ showAll: defineOption({
170
+ name: 'show-all',
171
+ schema: z.boolean().default(false),
172
+ description: 'Show all activity',
173
+ }),
174
+ format: defineOption({
175
+ name: 'format',
176
+ schema: z.enum(['human', 'json', 'json-stream']).default('human'),
177
+ description: 'Output format (human, json, json-stream)',
178
+ aliases: ['F'],
179
+ placeholder: 'format',
180
+ }),
181
+ alias: aliasOption,
182
+ app: appIdOrNameOption,
183
+ },
184
+ args: [],
185
+ async handler(options) {
186
+ const { alias, app: appIdOrName, showAll, follow, format } = options;
187
+ const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
188
+ const events = await Activity.list(ownerId, appId, showAll);
189
+ const reversedArrayWithIndex = events.reverse().map((event, index, all) => {
190
+ const isLast = index === all.length - 1;
191
+ return { ...event, isLast };
192
+ });
193
+
194
+ const handler = getEventHandler(format, follow);
195
+
196
+ let lastEvent = reversedArrayWithIndex.reduce(
197
+ (previousEvent, newEvent) => handleEvent(previousEvent, newEvent, handler),
198
+ {},
199
+ );
200
+
201
+ if (!follow) {
202
+ handler.end();
203
+ return lastEvent;
204
+ }
176
205
 
177
- const { apiHost, tokens } = await getHostAndTokens();
178
- const eventsStream = new EventsStream({ apiHost, tokens, appId });
206
+ const { apiHost, tokens } = await getHostAndTokens();
207
+ const eventsStream = new EventsStream({ apiHost, tokens, appId });
179
208
 
180
- const deferred = new Deferred();
209
+ const deferred = new Deferred();
181
210
 
182
- eventsStream
183
- .on('open', () => Logger.debug('WS for events (open) ' + JSON.stringify({ appId })))
184
- .on('event', (event) => {
185
- lastEvent = onEvent(lastEvent, event, handler);
186
- return lastEvent;
187
- })
188
- .on('ping', () => Logger.debug('WS for events (ping)'))
189
- .on('close', ({ reason }) => Logger.debug('WS for events (close) ' + reason))
190
- .on('error', deferred.reject);
211
+ eventsStream
212
+ .on('open', () => Logger.debug('WS for events (open) ' + JSON.stringify({ appId })))
213
+ .on('event', (event) => {
214
+ lastEvent = onEvent(lastEvent, event, handler);
215
+ return lastEvent;
216
+ })
217
+ .on('ping', () => Logger.debug('WS for events (ping)'))
218
+ .on('close', ({ reason }) => Logger.debug('WS for events (close) ' + reason))
219
+ .on('error', deferred.reject);
191
220
 
192
- eventsStream.open({ autoRetry: true, maxRetryCount: 6 });
221
+ eventsStream.open({ autoRetry: true, maxRetryCount: 6 });
193
222
 
194
- return deferred.promise;
195
- }
223
+ return deferred.promise;
224
+ },
225
+ });
@@ -0,0 +1,19 @@
1
+ # 📖 `clever activity` command reference
2
+
3
+ ## ➡️ `clever activity` <kbd>Since 0.2.3</kbd>
4
+
5
+ Show last deployments of an application
6
+
7
+ ```bash
8
+ clever activity [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`, `--follow`|Track new deployments in activity list|
18
+ |`-F`, `--format` `<format>`|Output format (human, json, json-stream) (default: human)|
19
+ |`--show-all`|Show all activity|
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { defineArgument } from '../../lib/define-argument.js';
3
+
4
+ export const addonProviderArg = defineArgument({
5
+ schema: z.string(),
6
+ description: 'Add-on provider',
7
+ placeholder: 'addon-provider',
8
+ });
9
+
10
+ export const addonNameArg = defineArgument({
11
+ schema: z.string(),
12
+ description: 'Add-on name',
13
+ placeholder: 'addon-name',
14
+ });
@@ -0,0 +1,7 @@
1
+ import { defineCommand } from '../../lib/define-command.js';
2
+ import { addonListCommand } from './addon.list.command.js';
3
+
4
+ export const addonCommand = defineCommand({
5
+ ...addonListCommand,
6
+ description: 'Manage add-ons',
7
+ });