appwrite-cli 1.2.1 → 2.0.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 (57) hide show
  1. package/README.md +4 -4
  2. package/docs/examples/account/create.md +1 -1
  3. package/docs/examples/account/update-password.md +1 -1
  4. package/docs/examples/console/variables.md +1 -0
  5. package/docs/examples/databases/create-relationship-attribute.md +9 -0
  6. package/docs/examples/databases/get-document.md +2 -1
  7. package/docs/examples/databases/update-boolean-attribute.md +6 -0
  8. package/docs/examples/databases/update-datetime-attribute.md +6 -0
  9. package/docs/examples/databases/update-email-attribute.md +6 -0
  10. package/docs/examples/databases/update-enum-attribute.md +7 -0
  11. package/docs/examples/databases/update-float-attribute.md +8 -0
  12. package/docs/examples/databases/update-integer-attribute.md +8 -0
  13. package/docs/examples/databases/update-ip-attribute.md +6 -0
  14. package/docs/examples/databases/update-relationship-attribute.md +5 -0
  15. package/docs/examples/databases/update-string-attribute.md +6 -0
  16. package/docs/examples/databases/update-url-attribute.md +6 -0
  17. package/docs/examples/functions/create.md +1 -1
  18. package/docs/examples/functions/update.md +1 -1
  19. package/docs/examples/projects/update-auth-password-dictionary.md +3 -0
  20. package/docs/examples/projects/update-auth-password-history.md +3 -0
  21. package/docs/examples/teams/create-membership.md +3 -1
  22. package/docs/examples/teams/get-prefs.md +2 -0
  23. package/docs/examples/teams/{update.md → update-name.md} +1 -1
  24. package/docs/examples/teams/update-prefs.md +3 -0
  25. package/docs/examples/users/update-password.md +1 -1
  26. package/index.js +2 -0
  27. package/install.ps1 +2 -2
  28. package/install.sh +1 -1
  29. package/lib/client.js +7 -7
  30. package/lib/commands/account.js +40 -7
  31. package/lib/commands/console.js +44 -0
  32. package/lib/commands/databases.js +727 -103
  33. package/lib/commands/deploy.js +270 -146
  34. package/lib/commands/functions.js +35 -9
  35. package/lib/commands/generic.js +6 -3
  36. package/lib/commands/init.js +215 -179
  37. package/lib/commands/projects.js +139 -5
  38. package/lib/commands/storage.js +39 -11
  39. package/lib/commands/teams.js +102 -16
  40. package/lib/commands/users.js +51 -2
  41. package/lib/config.js +84 -6
  42. package/lib/parser.js +7 -2
  43. package/lib/questions.js +307 -280
  44. package/package.json +1 -1
  45. package/docs/examples/account/get-logs.md +0 -2
  46. package/docs/examples/account/get-sessions.md +0 -1
  47. package/docs/examples/functions/retry-build.md +0 -4
  48. package/docs/examples/locale/get-continents.md +0 -1
  49. package/docs/examples/locale/get-countries-e-u.md +0 -1
  50. package/docs/examples/locale/get-countries-phones.md +0 -1
  51. package/docs/examples/locale/get-countries.md +0 -1
  52. package/docs/examples/locale/get-currencies.md +0 -1
  53. package/docs/examples/locale/get-languages.md +0 -1
  54. package/docs/examples/teams/get-memberships.md +0 -4
  55. package/docs/examples/users/get-logs.md +0 -3
  56. package/docs/examples/users/get-memberships.md +0 -2
  57. package/docs/examples/users/get-sessions.md +0 -2
package/lib/config.js CHANGED
@@ -22,7 +22,7 @@ class Config {
22
22
 
23
23
  write() {
24
24
  let dir = _path.dirname(this.path)
25
- if (!fs.existsSync(dir)){
25
+ if (!fs.existsSync(dir)) {
26
26
  fs.mkdirSync(dir, { recursive: true });
27
27
  }
28
28
  fs.writeFileSync(this.path, JSONbig.stringify(this.data, null, 4));
@@ -135,7 +135,7 @@ class Local extends Config {
135
135
  }
136
136
 
137
137
  getCollection($id) {
138
- if (!this.has("collection")) {
138
+ if (!this.has("collections")) {
139
139
  return {};
140
140
  }
141
141
 
@@ -156,7 +156,7 @@ class Local extends Config {
156
156
 
157
157
  let collections = this.get("collections");
158
158
  for (let i = 0; i < collections.length; i++) {
159
- if (collections[i]['$id'] == props['$id']) {
159
+ if (collections[i]['$id'] == props['$id'] && collections[i]['databaseId'] == props['databaseId']) {
160
160
  collections[i] = props;
161
161
  this.set("collections", collections);
162
162
  return;
@@ -166,6 +166,84 @@ class Local extends Config {
166
166
  this.set("collections", collections);
167
167
  }
168
168
 
169
+ getBuckets() {
170
+ if (!this.has("buckets")) {
171
+ return [];
172
+ }
173
+ return this.get("buckets");
174
+ }
175
+
176
+ getBucket($id) {
177
+ if (!this.has("buckets")) {
178
+ return {};
179
+ }
180
+
181
+ let buckets = this.get("buckets");
182
+ for (let i = 0; i < buckets.length; i++) {
183
+ if (buckets[i]['$id'] == $id) {
184
+ return buckets[i];
185
+ }
186
+ }
187
+
188
+ return {};
189
+ }
190
+
191
+ addBucket(props) {
192
+ if (!this.has("buckets")) {
193
+ this.set("buckets", []);
194
+ }
195
+
196
+ let buckets = this.get("buckets");
197
+ for (let i = 0; i < buckets.length; i++) {
198
+ if (buckets[i]['$id'] == props['$id']) {
199
+ buckets[i] = props;
200
+ this.set("buckets", buckets);
201
+ return;
202
+ }
203
+ }
204
+ buckets.push(props);
205
+ this.set("buckets", buckets);
206
+ }
207
+
208
+ getDatabases() {
209
+ if (!this.has("databases")) {
210
+ return [];
211
+ }
212
+ return this.get("databases");
213
+ }
214
+
215
+ getDatabase($id) {
216
+ if (!this.has("databases")) {
217
+ return {};
218
+ }
219
+
220
+ let databases = this.get("databases");
221
+ for (let i = 0; i < databases.length; i++) {
222
+ if (databases[i]['$id'] == $id) {
223
+ return databases[i];
224
+ }
225
+ }
226
+
227
+ return {};
228
+ }
229
+
230
+ addDatabase(props) {
231
+ if (!this.has("databases")) {
232
+ this.set("databases", []);
233
+ }
234
+
235
+ let databases = this.get("databases");
236
+ for (let i = 0; i < databases.length; i++) {
237
+ if (databases[i]['$id'] == props['$id']) {
238
+ databases[i] = props;
239
+ this.set("databases", databases);
240
+ return;
241
+ }
242
+ }
243
+ databases.push(props);
244
+ this.set("databases", databases);
245
+ }
246
+
169
247
  getTeams() {
170
248
  if (!this.has("teams")) {
171
249
  return [];
@@ -187,7 +265,7 @@ class Local extends Config {
187
265
 
188
266
  return {};
189
267
  }
190
-
268
+
191
269
  addTeam(props) {
192
270
  if (!this.has("teams")) {
193
271
  this.set("teams", []);
@@ -300,6 +378,6 @@ class Global extends Config {
300
378
  }
301
379
 
302
380
  module.exports = {
303
- localConfig : new Local(),
304
- globalConfig : new Global(),
381
+ localConfig: new Local(),
382
+ globalConfig: new Global(),
305
383
  };
package/lib/parser.js CHANGED
@@ -23,8 +23,12 @@ const parse = (data) => {
23
23
  drawJSON(data[key]);
24
24
  }
25
25
  } else if (typeof data[key] === 'object') {
26
- console.log(`${chalk.yellow.bold.underline(key)}`)
27
- parse(data[key]);
26
+ if (data[key] && data[key].constructor.name === 'BigNumber') {
27
+ console.log(`${chalk.yellow.bold(key)} : ${data[key]}`);
28
+ } else {
29
+ console.log(`${chalk.yellow.bold.underline(key)}`)
30
+ parse(data[key]);
31
+ }
28
32
  } else {
29
33
  console.log(`${chalk.yellow.bold(key)} : ${data[key]}`);
30
34
  }
@@ -164,6 +168,7 @@ const commandDescriptions = {
164
168
  "client": `The client command allows you to configure your CLI`,
165
169
  "login": `The login command allows you to authenticate and manage a user account.`,
166
170
  "logout": `The logout command allows you to logout of your Appwrite account.`,
171
+ "console" : `The console command allows gives you access to the APIs used by the Appwrite console.`,
167
172
  "main": chalk.redBright(`${logo}${description}`),
168
173
  }
169
174