appwrite-cli 12.0.0 → 13.0.0-rc.1

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 (283) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -2
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +145 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/client.d.ts +89 -0
  8. package/dist/lib/client.d.ts.map +1 -0
  9. package/dist/lib/client.js +227 -0
  10. package/dist/lib/client.js.map +1 -0
  11. package/dist/lib/commands/account.d.ts +379 -0
  12. package/dist/lib/commands/account.d.ts.map +1 -0
  13. package/dist/lib/commands/account.js +1228 -0
  14. package/dist/lib/commands/account.js.map +1 -0
  15. package/dist/lib/commands/console.d.ts +20 -0
  16. package/dist/lib/commands/console.d.ts.map +1 -0
  17. package/dist/lib/commands/console.js +78 -0
  18. package/dist/lib/commands/console.js.map +1 -0
  19. package/dist/lib/commands/databases.d.ts +732 -0
  20. package/dist/lib/commands/databases.d.ts.map +1 -0
  21. package/dist/lib/commands/databases.js +2196 -0
  22. package/dist/lib/commands/databases.js.map +1 -0
  23. package/dist/lib/commands/functions.d.ts +310 -0
  24. package/dist/lib/commands/functions.d.ts.map +1 -0
  25. package/dist/lib/commands/functions.js +1100 -0
  26. package/dist/lib/commands/functions.js.map +1 -0
  27. package/dist/lib/commands/generic.d.ts +17 -0
  28. package/dist/lib/commands/generic.d.ts.map +1 -0
  29. package/dist/lib/commands/generic.js +279 -0
  30. package/dist/lib/commands/generic.js.map +1 -0
  31. package/dist/lib/commands/graphql.d.ts +19 -0
  32. package/dist/lib/commands/graphql.d.ts.map +1 -0
  33. package/dist/lib/commands/graphql.js +77 -0
  34. package/dist/lib/commands/graphql.js.map +1 -0
  35. package/dist/lib/commands/health.d.ts +153 -0
  36. package/dist/lib/commands/health.d.ts.map +1 -0
  37. package/dist/lib/commands/health.js +464 -0
  38. package/dist/lib/commands/health.js.map +1 -0
  39. package/dist/lib/commands/init.d.ts +3 -0
  40. package/dist/lib/commands/init.d.ts.map +1 -0
  41. package/dist/lib/commands/init.js +518 -0
  42. package/dist/lib/commands/init.js.map +1 -0
  43. package/dist/lib/commands/locale.d.ts +53 -0
  44. package/dist/lib/commands/locale.d.ts.map +1 -0
  45. package/dist/lib/commands/locale.js +165 -0
  46. package/dist/lib/commands/locale.js.map +1 -0
  47. package/dist/lib/commands/messaging.d.ts +588 -0
  48. package/dist/lib/commands/messaging.d.ts.map +1 -0
  49. package/dist/lib/commands/messaging.js +2042 -0
  50. package/dist/lib/commands/messaging.js.map +1 -0
  51. package/dist/lib/commands/migrations.d.ts +150 -0
  52. package/dist/lib/commands/migrations.d.ts.map +1 -0
  53. package/dist/lib/commands/migrations.js +524 -0
  54. package/dist/lib/commands/migrations.js.map +1 -0
  55. package/dist/lib/commands/organizations.d.ts +11 -0
  56. package/dist/lib/commands/organizations.d.ts.map +1 -0
  57. package/dist/lib/commands/organizations.js +31 -0
  58. package/dist/lib/commands/organizations.js.map +1 -0
  59. package/dist/lib/commands/project.d.ts +53 -0
  60. package/dist/lib/commands/project.d.ts.map +1 -0
  61. package/dist/lib/commands/project.js +176 -0
  62. package/dist/lib/commands/project.js.map +1 -0
  63. package/dist/lib/commands/projects.d.ts +516 -0
  64. package/dist/lib/commands/projects.d.ts.map +1 -0
  65. package/dist/lib/commands/projects.js +1590 -0
  66. package/dist/lib/commands/projects.js.map +1 -0
  67. package/dist/lib/commands/proxy.d.ts +71 -0
  68. package/dist/lib/commands/proxy.d.ts.map +1 -0
  69. package/dist/lib/commands/proxy.js +240 -0
  70. package/dist/lib/commands/proxy.js.map +1 -0
  71. package/dist/lib/commands/pull.d.ts +8 -0
  72. package/dist/lib/commands/pull.d.ts.map +1 -0
  73. package/dist/lib/commands/pull.js +455 -0
  74. package/dist/lib/commands/pull.js.map +1 -0
  75. package/dist/lib/commands/push.d.ts +4 -0
  76. package/dist/lib/commands/push.d.ts.map +1 -0
  77. package/dist/lib/commands/push.js +2154 -0
  78. package/dist/lib/commands/push.js.map +1 -0
  79. package/dist/lib/commands/run.d.ts +3 -0
  80. package/dist/lib/commands/run.d.ts.map +1 -0
  81. package/dist/lib/commands/run.js +287 -0
  82. package/dist/lib/commands/run.js.map +1 -0
  83. package/dist/lib/commands/sites.d.ts +296 -0
  84. package/dist/lib/commands/sites.d.ts.map +1 -0
  85. package/dist/lib/commands/sites.js +1046 -0
  86. package/dist/lib/commands/sites.js.map +1 -0
  87. package/dist/lib/commands/storage.d.ts +170 -0
  88. package/dist/lib/commands/storage.d.ts.map +1 -0
  89. package/dist/lib/commands/storage.js +651 -0
  90. package/dist/lib/commands/storage.js.map +1 -0
  91. package/dist/lib/commands/tables-db.d.ts +728 -0
  92. package/dist/lib/commands/tables-db.d.ts.map +1 -0
  93. package/dist/lib/commands/tables-db.js +2198 -0
  94. package/dist/lib/commands/tables-db.js.map +1 -0
  95. package/dist/lib/commands/teams.d.ts +129 -0
  96. package/dist/lib/commands/teams.d.ts.map +1 -0
  97. package/dist/lib/commands/teams.js +403 -0
  98. package/dist/lib/commands/teams.js.map +1 -0
  99. package/dist/lib/commands/tokens.d.ts +48 -0
  100. package/dist/lib/commands/tokens.d.ts.map +1 -0
  101. package/dist/lib/commands/tokens.js +156 -0
  102. package/dist/lib/commands/tokens.js.map +1 -0
  103. package/dist/lib/commands/types.d.ts +3 -0
  104. package/dist/lib/commands/types.d.ts.map +1 -0
  105. package/dist/lib/commands/types.js +155 -0
  106. package/dist/lib/commands/types.js.map +1 -0
  107. package/dist/lib/commands/update.d.ts +3 -0
  108. package/dist/lib/commands/update.d.ts.map +1 -0
  109. package/dist/lib/commands/update.js +202 -0
  110. package/dist/lib/commands/update.js.map +1 -0
  111. package/dist/lib/commands/users.d.ts +382 -0
  112. package/dist/lib/commands/users.d.ts.map +1 -0
  113. package/dist/lib/commands/users.js +1195 -0
  114. package/dist/lib/commands/users.js.map +1 -0
  115. package/dist/lib/commands/vcs.d.ts +92 -0
  116. package/dist/lib/commands/vcs.d.ts.map +1 -0
  117. package/dist/lib/commands/vcs.js +276 -0
  118. package/dist/lib/commands/vcs.js.map +1 -0
  119. package/dist/lib/config.d.ts +118 -0
  120. package/dist/lib/config.d.ts.map +1 -0
  121. package/{lib → dist/lib}/config.js +204 -325
  122. package/dist/lib/config.js.map +1 -0
  123. package/dist/lib/emulation/docker.d.ts +15 -0
  124. package/dist/lib/emulation/docker.d.ts.map +1 -0
  125. package/dist/lib/emulation/docker.js +220 -0
  126. package/dist/lib/emulation/docker.js.map +1 -0
  127. package/dist/lib/emulation/utils.d.ts +29 -0
  128. package/dist/lib/emulation/utils.d.ts.map +1 -0
  129. package/dist/lib/emulation/utils.js +168 -0
  130. package/dist/lib/emulation/utils.js.map +1 -0
  131. package/dist/lib/exception.d.ts +8 -0
  132. package/dist/lib/exception.d.ts.map +1 -0
  133. package/dist/lib/exception.js +16 -0
  134. package/dist/lib/exception.js.map +1 -0
  135. package/dist/lib/id.d.ts +7 -0
  136. package/dist/lib/id.d.ts.map +1 -0
  137. package/dist/lib/id.js +32 -0
  138. package/dist/lib/id.js.map +1 -0
  139. package/dist/lib/paginate.d.ts +10 -0
  140. package/dist/lib/paginate.d.ts.map +1 -0
  141. package/{lib → dist/lib}/paginate.js +9 -15
  142. package/dist/lib/paginate.js.map +1 -0
  143. package/dist/lib/parser.d.ts +18 -0
  144. package/dist/lib/parser.d.ts.map +1 -0
  145. package/dist/lib/parser.js +237 -0
  146. package/dist/lib/parser.js.map +1 -0
  147. package/dist/lib/questions.d.ts +59 -0
  148. package/dist/lib/questions.d.ts.map +1 -0
  149. package/dist/lib/questions.js +995 -0
  150. package/dist/lib/questions.js.map +1 -0
  151. package/dist/lib/sdks.d.ts +4 -0
  152. package/dist/lib/sdks.d.ts.map +1 -0
  153. package/dist/lib/sdks.js +51 -0
  154. package/dist/lib/sdks.js.map +1 -0
  155. package/dist/lib/spinner.d.ts +28 -0
  156. package/dist/lib/spinner.d.ts.map +1 -0
  157. package/{lib → dist/lib}/spinner.js +34 -45
  158. package/dist/lib/spinner.js.map +1 -0
  159. package/dist/lib/type-generation/attribute.d.ts +17 -0
  160. package/dist/lib/type-generation/attribute.d.ts.map +1 -0
  161. package/dist/lib/type-generation/attribute.js +19 -0
  162. package/dist/lib/type-generation/attribute.js.map +1 -0
  163. package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
  164. package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
  165. package/dist/lib/type-generation/languages/csharp.js +180 -0
  166. package/dist/lib/type-generation/languages/csharp.js.map +1 -0
  167. package/dist/lib/type-generation/languages/dart.d.ts +8 -0
  168. package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
  169. package/dist/lib/type-generation/languages/dart.js +197 -0
  170. package/dist/lib/type-generation/languages/dart.js.map +1 -0
  171. package/dist/lib/type-generation/languages/java.d.ts +7 -0
  172. package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
  173. package/dist/lib/type-generation/languages/java.js +140 -0
  174. package/dist/lib/type-generation/languages/java.js.map +1 -0
  175. package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
  176. package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
  177. package/dist/lib/type-generation/languages/javascript.js +108 -0
  178. package/dist/lib/type-generation/languages/javascript.js.map +1 -0
  179. package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
  180. package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
  181. package/dist/lib/type-generation/languages/kotlin.js +95 -0
  182. package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
  183. package/dist/lib/type-generation/languages/language.d.ts +43 -0
  184. package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
  185. package/dist/lib/type-generation/languages/language.js +82 -0
  186. package/dist/lib/type-generation/languages/language.js.map +1 -0
  187. package/dist/lib/type-generation/languages/php.d.ts +7 -0
  188. package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
  189. package/dist/lib/type-generation/languages/php.js +116 -0
  190. package/dist/lib/type-generation/languages/php.js.map +1 -0
  191. package/dist/lib/type-generation/languages/swift.d.ts +7 -0
  192. package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
  193. package/dist/lib/type-generation/languages/swift.js +179 -0
  194. package/dist/lib/type-generation/languages/swift.js.map +1 -0
  195. package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
  196. package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
  197. package/dist/lib/type-generation/languages/typescript.js +112 -0
  198. package/dist/lib/type-generation/languages/typescript.js.map +1 -0
  199. package/dist/lib/types.d.ts +133 -0
  200. package/dist/lib/types.d.ts.map +1 -0
  201. package/dist/lib/types.js +3 -0
  202. package/dist/lib/types.js.map +1 -0
  203. package/dist/lib/utils.d.ts +15 -0
  204. package/dist/lib/utils.d.ts.map +1 -0
  205. package/{lib → dist/lib}/utils.js +74 -120
  206. package/dist/lib/utils.js.map +1 -0
  207. package/dist/lib/validations.d.ts +2 -0
  208. package/dist/lib/validations.d.ts.map +1 -0
  209. package/dist/lib/validations.js +20 -0
  210. package/dist/lib/validations.js.map +1 -0
  211. package/docs/examples/databases/upsert-document.md +1 -2
  212. package/index.ts +152 -0
  213. package/install.ps1 +2 -5
  214. package/install.sh +1 -2
  215. package/lib/client.ts +259 -0
  216. package/lib/commands/{account.js → account.ts} +410 -664
  217. package/lib/commands/console.ts +112 -0
  218. package/lib/commands/{databases.js → databases.ts} +818 -1136
  219. package/lib/commands/{functions.js → functions.ts} +381 -526
  220. package/lib/commands/{generic.js → generic.ts} +47 -39
  221. package/lib/commands/graphql.ts +110 -0
  222. package/lib/commands/{health.js → health.ts} +168 -284
  223. package/lib/commands/{init.js → init.ts} +68 -66
  224. package/lib/commands/{locale.js → locale.ts} +75 -121
  225. package/lib/commands/{messaging.js → messaging.ts} +699 -937
  226. package/lib/commands/{migrations.js → migrations.ts} +182 -258
  227. package/lib/commands/organizations.ts +46 -0
  228. package/lib/commands/{project.js → project.ts} +75 -111
  229. package/lib/commands/{projects.js → projects.ts} +587 -843
  230. package/lib/commands/{proxy.js → proxy.ts} +94 -140
  231. package/lib/commands/{pull.js → pull.ts} +54 -44
  232. package/lib/commands/{push.js → push.ts} +235 -191
  233. package/lib/commands/{run.js → run.ts} +61 -55
  234. package/lib/commands/{sites.js → sites.ts} +364 -504
  235. package/lib/commands/{storage.js → storage.ts} +216 -292
  236. package/lib/commands/{tables-db.js → tables-db.ts} +817 -1126
  237. package/lib/commands/{teams.js → teams.ts} +162 -236
  238. package/lib/commands/{tokens.js → tokens.ts} +70 -99
  239. package/lib/commands/{types.js → types.ts} +37 -35
  240. package/lib/commands/{update.js → update.ts} +25 -27
  241. package/lib/commands/{users.js → users.ts} +426 -644
  242. package/lib/commands/{vcs.js → vcs.ts} +122 -173
  243. package/lib/config.ts +854 -0
  244. package/lib/emulation/{docker.js → docker.ts} +39 -38
  245. package/lib/emulation/utils.ts +193 -0
  246. package/lib/exception.ts +20 -0
  247. package/lib/{id.js → id.ts} +5 -5
  248. package/lib/paginate.ts +63 -0
  249. package/lib/parser.ts +238 -0
  250. package/lib/{questions.js → questions.ts} +148 -156
  251. package/lib/sdks.ts +55 -0
  252. package/lib/spinner.ts +118 -0
  253. package/lib/type-generation/attribute.ts +17 -0
  254. package/lib/type-generation/languages/{csharp.js → csharp.ts} +59 -48
  255. package/lib/type-generation/languages/{dart.js → dart.ts} +91 -80
  256. package/lib/type-generation/languages/{java.js → java.ts} +58 -47
  257. package/lib/type-generation/languages/javascript.ts +111 -0
  258. package/lib/type-generation/languages/kotlin.ts +96 -0
  259. package/lib/type-generation/languages/language.ts +119 -0
  260. package/lib/type-generation/languages/{php.js → php.ts} +55 -48
  261. package/lib/type-generation/languages/{swift.js → swift.ts} +59 -48
  262. package/lib/type-generation/languages/typescript.ts +116 -0
  263. package/lib/types.ts +150 -0
  264. package/lib/utils.ts +322 -0
  265. package/lib/validations.ts +17 -0
  266. package/package.json +21 -12
  267. package/scoop/appwrite.config.json +3 -3
  268. package/tsconfig.json +30 -0
  269. package/index.js +0 -147
  270. package/lib/client.js +0 -254
  271. package/lib/commands/console.js +0 -127
  272. package/lib/commands/graphql.js +0 -126
  273. package/lib/commands/organizations.js +0 -48
  274. package/lib/emulation/utils.js +0 -186
  275. package/lib/exception.js +0 -9
  276. package/lib/parser.js +0 -250
  277. package/lib/sdks.js +0 -60
  278. package/lib/type-generation/attribute.js +0 -16
  279. package/lib/type-generation/languages/javascript.js +0 -102
  280. package/lib/type-generation/languages/kotlin.js +0 -85
  281. package/lib/type-generation/languages/language.js +0 -125
  282. package/lib/type-generation/languages/typescript.js +0 -107
  283. package/lib/validations.js +0 -17
package/lib/parser.ts ADDED
@@ -0,0 +1,238 @@
1
+ import chalk = require('chalk');
2
+ import commander = require('commander');
3
+ import Table = require('cli-table3');
4
+ const { description } = require('../../package.json');
5
+ import { globalConfig } from './config';
6
+ import os = require('os');
7
+ import Client = require('./client');
8
+ import { isCloud } from './utils';
9
+ import type { CliConfig } from './types';
10
+
11
+ const cliConfig: CliConfig = {
12
+ verbose: false,
13
+ json: false,
14
+ force: false,
15
+ all: false,
16
+ ids: [],
17
+ report: false,
18
+ reportData: {},
19
+ };
20
+
21
+ export const parse = (data: Record<string, any>): void => {
22
+ if (cliConfig.json) {
23
+ drawJSON(data);
24
+ return;
25
+ }
26
+
27
+ for (const key in data) {
28
+ if (data[key] === null) {
29
+ console.log(`${chalk.yellow.bold(key)} : null`);
30
+ } else if (Array.isArray(data[key])) {
31
+ console.log(`${chalk.yellow.bold.underline(key)}`);
32
+ if (typeof data[key][0] === 'object') {
33
+ drawTable(data[key]);
34
+ } else {
35
+ drawJSON(data[key]);
36
+ }
37
+ } else if (typeof data[key] === 'object') {
38
+ if (data[key]?.constructor?.name === 'BigNumber') {
39
+ console.log(`${chalk.yellow.bold(key)} : ${data[key]}`);
40
+ } else {
41
+ console.log(`${chalk.yellow.bold.underline(key)}`);
42
+ drawTable([data[key]]);
43
+ }
44
+ } else {
45
+ console.log(`${chalk.yellow.bold(key)} : ${data[key]}`);
46
+ }
47
+ }
48
+ };
49
+
50
+ export const drawTable = (data: Array<Record<string, any>>): void => {
51
+ if (data.length == 0) {
52
+ console.log('[]');
53
+ return;
54
+ }
55
+
56
+ // Create an object with all the keys in it
57
+ const obj = data.reduce((res, item) => ({ ...res, ...item }), {});
58
+ // Get those keys as an array
59
+ const keys = Object.keys(obj);
60
+ // Create an object with all keys set to the default value ''
61
+ const def = keys.reduce((result: Record<string, string>, key) => {
62
+ result[key] = '-';
63
+ return result;
64
+ }, {});
65
+ // Use object destructuring to replace all default values with the ones we have
66
+ data = data.map((item) => ({ ...def, ...item }));
67
+
68
+ const columns = Object.keys(data[0]);
69
+
70
+ const table = new Table({
71
+ head: columns.map((c) => chalk.cyan.italic.bold(c)),
72
+ chars: {
73
+ top: ' ',
74
+ 'top-mid': ' ',
75
+ 'top-left': ' ',
76
+ 'top-right': ' ',
77
+ bottom: ' ',
78
+ 'bottom-mid': ' ',
79
+ 'bottom-left': ' ',
80
+ 'bottom-right': ' ',
81
+ left: ' ',
82
+ 'left-mid': ' ',
83
+ mid: chalk.cyan('─'),
84
+ 'mid-mid': chalk.cyan('┼'),
85
+ right: ' ',
86
+ 'right-mid': ' ',
87
+ middle: chalk.cyan('│'),
88
+ },
89
+ });
90
+
91
+ data.forEach((row) => {
92
+ const rowValues: any[] = [];
93
+ for (const key in row) {
94
+ if (row[key] === null) {
95
+ rowValues.push('-');
96
+ } else if (Array.isArray(row[key])) {
97
+ rowValues.push(JSON.stringify(row[key]));
98
+ } else if (typeof row[key] === 'object') {
99
+ rowValues.push(JSON.stringify(row[key]));
100
+ } else {
101
+ rowValues.push(row[key]);
102
+ }
103
+ }
104
+ table.push(rowValues);
105
+ });
106
+ console.log(table.toString());
107
+ };
108
+
109
+ export const drawJSON = (data: any): void => {
110
+ console.log(JSON.stringify(data, null, 2));
111
+ };
112
+
113
+ export const parseError = (err: Error): void => {
114
+ if (cliConfig.report) {
115
+ (async () => {
116
+ let appwriteVersion = 'unknown';
117
+ const endpoint = globalConfig.getEndpoint();
118
+
119
+ try {
120
+ const client = new Client().setEndpoint(endpoint);
121
+ const res = await client.call<{ version: string }>('get', '/health/version');
122
+ appwriteVersion = res.version;
123
+ } catch {
124
+ // Silently fail
125
+ }
126
+
127
+ const version = '13.0.0-rc.1';
128
+ const stepsToReproduce = `Running \`appwrite ${(cliConfig.reportData as any).data.args.join(' ')}\``;
129
+ const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud()}`;
130
+
131
+ const stack = '```\n' + (err.stack || err.message) + '\n```';
132
+
133
+ const githubIssueUrl = new URL('https://github.com/appwrite/appwrite/issues/new');
134
+ githubIssueUrl.searchParams.append('labels', 'bug');
135
+ githubIssueUrl.searchParams.append('template', 'bug.yaml');
136
+ githubIssueUrl.searchParams.append('title', `🐛 Bug Report: ${err.message}`);
137
+ githubIssueUrl.searchParams.append('actual-behavior', `CLI Error:\n${stack}`);
138
+ githubIssueUrl.searchParams.append('steps-to-reproduce', stepsToReproduce);
139
+ githubIssueUrl.searchParams.append('environment', yourEnvironment);
140
+
141
+ log(
142
+ `To report this error you can:\n - Create a support ticket in our Discord server https://appwrite.io/discord \n - Create an issue in our Github\n ${githubIssueUrl.href}\n`
143
+ );
144
+
145
+ error('\n Stack Trace: \n');
146
+ console.error(err);
147
+ process.exit(1);
148
+ })();
149
+ } else {
150
+ if (cliConfig.verbose) {
151
+ console.error(err);
152
+ } else {
153
+ log('For detailed error pass the --verbose or --report flag');
154
+ error(err.message);
155
+ }
156
+ process.exit(1);
157
+ }
158
+ };
159
+
160
+ export const actionRunner = <T extends (...args: any[]) => Promise<any>>(fn: T): ((...args: Parameters<T>) => Promise<void>) => {
161
+ return (...args: Parameters<T>) => {
162
+ if (cliConfig.all && Array.isArray(cliConfig.ids) && cliConfig.ids.length !== 0) {
163
+ error(`The '--all' and '--id' flags cannot be used together.`);
164
+ process.exit(1);
165
+ }
166
+ return fn(...args).catch(parseError);
167
+ };
168
+ };
169
+
170
+ export const parseInteger = (value: string): number => {
171
+ const parsedValue = parseInt(value, 10);
172
+ if (isNaN(parsedValue)) {
173
+ throw new commander.InvalidArgumentError('Not a number.');
174
+ }
175
+ return parsedValue;
176
+ };
177
+
178
+ export const parseBool = (value: string): boolean => {
179
+ if (value === 'true') return true;
180
+ if (value === 'false') return false;
181
+ throw new commander.InvalidArgumentError('Not a boolean.');
182
+ };
183
+
184
+ export const log = (message?: string): void => {
185
+ console.log(`${chalk.cyan.bold('ℹ Info:')} ${chalk.cyan(message ?? '')}`);
186
+ };
187
+
188
+ export const warn = (message?: string): void => {
189
+ console.log(`${chalk.yellow.bold('ℹ Warning:')} ${chalk.yellow(message ?? '')}`);
190
+ };
191
+
192
+ export const hint = (message?: string): void => {
193
+ console.log(`${chalk.cyan.bold('♥ Hint:')} ${chalk.cyan(message ?? '')}`);
194
+ };
195
+
196
+ export const success = (message?: string): void => {
197
+ console.log(`${chalk.green.bold('✓ Success:')} ${chalk.green(message ?? '')}`);
198
+ };
199
+
200
+ export const error = (message?: string): void => {
201
+ console.error(`${chalk.red.bold('✗ Error:')} ${chalk.red(message ?? '')}`);
202
+ };
203
+
204
+ export const logo = "\n _ _ _ ___ __ _____\n \/_\\ _ __ _ ____ ___ __(_) |_ ___ \/ __\\ \/ \/ \\_ \\\n \/\/_\\\\| '_ \\| '_ \\ \\ \/\\ \/ \/ '__| | __\/ _ \\ \/ \/ \/ \/ \/ \/\\\/\n \/ _ \\ |_) | |_) \\ V V \/| | | | || __\/ \/ \/___\/ \/___\/\\\/ \/_\n \\_\/ \\_\/ .__\/| .__\/ \\_\/\\_\/ |_| |_|\\__\\___| \\____\/\\____\/\\____\/\n |_| |_|\n\n";
205
+
206
+ export const commandDescriptions: Record<string, string> = {
207
+ account: `The account command allows you to authenticate and manage a user account.`,
208
+ graphql: `The graphql command allows you to query and mutate any resource type on your Appwrite server.`,
209
+ avatars: `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`,
210
+ databases: `(Legacy) The databases command allows you to create structured collections of documents and query and filter lists of documents.`,
211
+ 'tables-db': `The tables-db command allows you to create structured tables of columns and query and filter lists of rows.`,
212
+ init: `The init command provides a convenient wrapper for creating and initializing projects, functions, collections, buckets, teams, and messaging-topics in Appwrite.`,
213
+ push: `The push command provides a convenient wrapper for pushing your functions, collections, buckets, teams, and messaging-topics.`,
214
+ run: `The run command allows you to run the project locally to allow easy development and quick debugging.`,
215
+ functions: `The functions command allows you to view, create, and manage your Cloud Functions.`,
216
+ health: `The health command allows you to both validate and monitor your Appwrite server's health.`,
217
+ pull: `The pull command helps you pull your Appwrite project, functions, collections, buckets, teams, and messaging-topics`,
218
+ locale: `The locale command allows you to customize your app based on your users' location.`,
219
+ sites: `The sites command allows you to view, create and manage your Appwrite Sites.`,
220
+ storage: `The storage command allows you to manage your project files.`,
221
+ teams: `The teams command allows you to group users of your project to enable them to share read and write access to your project resources.`,
222
+ update: `The update command allows you to update the Appwrite CLI to the latest version.`,
223
+ users: `The users command allows you to manage your project users.`,
224
+ projects: `The projects command allows you to manage your projects, add platforms, manage API keys, Dev Keys etc.`,
225
+ project: `The project command allows you to manage project related resources like usage, variables, etc.`,
226
+ client: `The client command allows you to configure your CLI`,
227
+ login: `The login command allows you to authenticate and manage a user account.`,
228
+ logout: `The logout command allows you to log out of your Appwrite account.`,
229
+ whoami: `The whomai command gives information about the currently logged-in user.`,
230
+ register: `Outputs the link to create an Appwrite account.`,
231
+ console: `The console command gives you access to the APIs used by the Appwrite Console.`,
232
+ messaging: `The messaging command allows you to manage topics and targets and send messages.`,
233
+ migrations: `The migrations command allows you to migrate data between services.`,
234
+ vcs: `The vcs command allows you to interact with VCS providers and manage your code repositories.`,
235
+ main: chalk.redBright(`${logo}${description}`),
236
+ };
237
+
238
+ export { cliConfig };