appwrite-cli 1.2.1 → 2.0.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 (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 +37 -9
  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 +6 -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/questions.js CHANGED
@@ -5,334 +5,361 @@ const { databasesList } = require('./commands/databases');
5
5
  const JSONbig = require("json-bigint")({ storeAsString: false });
6
6
 
7
7
  const getIgnores = (runtime) => {
8
- const languge = runtime.split('-')[0];
8
+ const languge = runtime.split('-')[0];
9
9
 
10
- switch (languge) {
11
- case 'cpp':
12
- return ['build', 'CMakeFiles', 'CMakeCaches.txt'];
13
- case 'dart':
14
- return ['.packages', '.dart_tool'];
15
- case 'deno':
16
- return [];
17
- case 'dotnet':
18
- return ['bin', 'obj', '.nuget'];
19
- case 'java':
20
- case 'kotlin':
21
- return ['build'];
22
- case 'node':
23
- return ['node_modules', '.npm'];
24
- case 'php':
25
- return ['vendor'];
26
- case 'python':
27
- return ['__pypackages__'];
28
- case 'ruby':
29
- return ['vendor'];
30
- case 'rust':
31
- return ['target', 'debug', '*.rs.bk', '*.pdb'];
32
- case 'swift':
33
- return ['.build', '.swiftpm'];
34
- }
10
+ switch (languge) {
11
+ case 'cpp':
12
+ return ['build', 'CMakeFiles', 'CMakeCaches.txt'];
13
+ case 'dart':
14
+ return ['.packages', '.dart_tool'];
15
+ case 'deno':
16
+ return [];
17
+ case 'dotnet':
18
+ return ['bin', 'obj', '.nuget'];
19
+ case 'java':
20
+ case 'kotlin':
21
+ return ['build'];
22
+ case 'node':
23
+ return ['node_modules', '.npm'];
24
+ case 'php':
25
+ return ['vendor'];
26
+ case 'python':
27
+ return ['__pypackages__'];
28
+ case 'ruby':
29
+ return ['vendor'];
30
+ case 'rust':
31
+ return ['target', 'debug', '*.rs.bk', '*.pdb'];
32
+ case 'swift':
33
+ return ['.build', '.swiftpm'];
34
+ }
35
35
 
36
- return undefined;
36
+ return undefined;
37
37
  };
38
38
 
39
39
  const getEntrypoint = (runtime) => {
40
- const languge = runtime.split('-')[0];
40
+ const languge = runtime.split('-')[0];
41
41
 
42
- switch (languge) {
43
- case 'dart':
44
- return 'lib/main.dart';
45
- case 'deno':
46
- return 'src/mod.ts';
47
- case 'node':
48
- return 'src/index.js';
49
- case 'php':
50
- return 'src/index.php';
51
- case 'python':
52
- return 'src/index.py';
53
- case 'ruby':
54
- return 'src/index.rb';
55
- case 'rust':
56
- return 'main.rs';
57
- case 'swift':
58
- return 'Sources/swift-5.5/main.swift';
59
- case 'cpp':
60
- return 'src/index.cc';
61
- case 'dotnet':
62
- return 'src/Index.cs';
63
- case 'java':
64
- return 'src/Index.java';
65
- case 'kotlin':
66
- return 'src/Index.kt';
67
- }
42
+ switch (languge) {
43
+ case 'dart':
44
+ return 'lib/main.dart';
45
+ case 'deno':
46
+ return 'src/mod.ts';
47
+ case 'node':
48
+ return 'src/index.js';
49
+ case 'php':
50
+ return 'src/index.php';
51
+ case 'python':
52
+ return 'src/index.py';
53
+ case 'ruby':
54
+ return 'src/index.rb';
55
+ case 'rust':
56
+ return 'main.rs';
57
+ case 'swift':
58
+ return 'Sources/swift-5.5/main.swift';
59
+ case 'cpp':
60
+ return 'src/index.cc';
61
+ case 'dotnet':
62
+ return 'src/Index.cs';
63
+ case 'java':
64
+ return 'src/Index.java';
65
+ case 'kotlin':
66
+ return 'src/Index.kt';
67
+ }
68
68
 
69
- return undefined;
69
+ return undefined;
70
70
  };
71
71
 
72
72
  const questionsInitProject = [
73
- {
74
- type: "confirm",
75
- name: "override",
76
- message:
77
- `An Appwrite project ( ${localConfig.getProject()['projectName']} ) is already associated with the current directory. Would you like to override`,
78
- when() {
79
- return Object.keys(localConfig.getProject()).length !== 0;
80
- }
81
- },
82
- {
83
- type: "list",
84
- name: "start",
85
- when(answers) {
86
- if (answers.override == undefined) {
87
- return true
88
- }
89
- return answers.override;
73
+ {
74
+ type: "confirm",
75
+ name: "override",
76
+ message:
77
+ `An Appwrite project ( ${localConfig.getProject()['projectName']} ) is already associated with the current directory. Would you like to override`,
78
+ when() {
79
+ return Object.keys(localConfig.getProject()).length !== 0;
80
+ }
90
81
  },
91
- message: "How would you like to start?",
92
- choices: [
93
- {
94
- name: "Create a new Appwrite project",
95
- value: "new",
96
- },
97
- {
98
- name: "Link this directory to an existing Appwrite project",
99
- value: "existing",
100
- },
101
- ],
102
- },
103
- {
104
- type: "input",
105
- name: "project",
106
- message: "What would you like to name your project?",
107
- default: "My Awesome Project",
108
- when(answers) {
109
- return answers.start == "new";
82
+ {
83
+ type: "list",
84
+ name: "start",
85
+ when(answers) {
86
+ if (answers.override == undefined) {
87
+ return true
88
+ }
89
+ return answers.override;
90
+ },
91
+ message: "How would you like to start?",
92
+ choices: [
93
+ {
94
+ name: "Create a new Appwrite project",
95
+ value: "new",
96
+ },
97
+ {
98
+ name: "Link this directory to an existing Appwrite project",
99
+ value: "existing",
100
+ },
101
+ ],
110
102
  },
111
- },
112
- {
113
- type: "input",
114
- name: "id",
115
- message: "What ID would you like to have for your project?",
116
- default: "unique()",
117
- when(answers) {
118
- return answers.start == "new";
103
+ {
104
+ type: "input",
105
+ name: "project",
106
+ message: "What would you like to name your project?",
107
+ default: "My Awesome Project",
108
+ when(answers) {
109
+ return answers.start == "new";
110
+ },
119
111
  },
120
- },
121
- {
122
- type: "list",
123
- name: "project",
124
- message: "Choose your Appwrite project.",
125
- when(answers) {
126
- return answers.start == "existing";
112
+ {
113
+ type: "input",
114
+ name: "id",
115
+ message: "What ID would you like to have for your project?",
116
+ default: "unique()",
117
+ when(answers) {
118
+ return answers.start == "new";
119
+ },
127
120
  },
128
- choices: async () => {
129
- let response = await projectsList({
130
- parseOutput: false
131
- })
132
- let projects = response["projects"]
133
- let choices = projects.map((project, idx) => {
134
- return {
135
- name: `${project.name} (${project['$id']})`,
136
- value: {
137
- name: project.name,
138
- id: project['$id']
139
- }
140
- }
141
- })
121
+ {
122
+ type: "list",
123
+ name: "project",
124
+ message: "Choose your Appwrite project.",
125
+ when(answers) {
126
+ return answers.start == "existing";
127
+ },
128
+ choices: async () => {
129
+ let response = await projectsList({
130
+ parseOutput: false
131
+ })
132
+ let projects = response["projects"]
133
+ let choices = projects.map((project, idx) => {
134
+ return {
135
+ name: `${project.name} (${project['$id']})`,
136
+ value: {
137
+ name: project.name,
138
+ id: project['$id']
139
+ }
140
+ }
141
+ })
142
142
 
143
- if (choices.length == 0) {
144
- throw new Error("No projects found. Please create a new project.")
145
- }
143
+ if (choices.length == 0) {
144
+ throw new Error("No projects found. Please create a new project.")
145
+ }
146
146
 
147
- return choices;
147
+ return choices;
148
+ }
148
149
  }
149
- }
150
150
  ];
151
151
 
152
152
  const questionsInitFunction = [
153
- {
154
- type: "input",
155
- name: "name",
156
- message: "What would you like to name your function?",
157
- default: "My Awesome Function"
158
- },
159
- {
160
- type: "input",
161
- name: "id",
162
- message: "What ID would you like to have for your function?",
163
- default: "unique()"
164
- },
165
- {
166
- type: "list",
167
- name: "runtime",
168
- message: "What runtime would you like to use?",
169
- choices: async () => {
170
- let response = await functionsListRuntimes({
171
- parseOutput: false
172
- })
173
- let runtimes = response["runtimes"]
174
- let choices = runtimes.map((runtime, idx) => {
175
- return {
176
- name: `${runtime.name} (${runtime['$id']})`,
177
- value: { id: runtime['$id'], entrypoint: getEntrypoint(runtime['$id']), ignore: getIgnores(runtime['$id'])},
153
+ {
154
+ type: "input",
155
+ name: "name",
156
+ message: "What would you like to name your function?",
157
+ default: "My Awesome Function"
158
+ },
159
+ {
160
+ type: "input",
161
+ name: "id",
162
+ message: "What ID would you like to have for your function?",
163
+ default: "unique()"
164
+ },
165
+ {
166
+ type: "list",
167
+ name: "runtime",
168
+ message: "What runtime would you like to use?",
169
+ choices: async () => {
170
+ let response = await functionsListRuntimes({
171
+ parseOutput: false
172
+ })
173
+ let runtimes = response["runtimes"]
174
+ let choices = runtimes.map((runtime, idx) => {
175
+ return {
176
+ name: `${runtime.name} (${runtime['$id']})`,
177
+ value: { id: runtime['$id'], entrypoint: getEntrypoint(runtime['$id']), ignore: getIgnores(runtime['$id']) },
178
+ }
179
+ })
180
+ return choices;
178
181
  }
179
- })
180
- return choices;
181
182
  }
182
- }
183
183
  ];
184
184
 
185
185
  const questionsInitCollection = [
186
- {
187
- type: "checkbox",
188
- name: "databases",
189
- message: "From which database would you like to init collections?",
190
- choices: async () => {
191
- let response = await databasesList({
192
- parseOutput: false
193
- })
194
- let databases = response["databases"]
186
+ {
187
+ type: "checkbox",
188
+ name: "databases",
189
+ message: "From which database would you like to init collections?",
190
+ choices: async () => {
191
+ let response = await databasesList({
192
+ parseOutput: false
193
+ })
194
+ let databases = response["databases"]
195
195
 
196
- if(databases.length <= 0) {
197
- throw new Error("No databases found. Please create one in project console.")
198
- }
199
- let choices = databases.map((database, idx) => {
200
- return {
201
- name: `${database.name} (${database.$id})`,
202
- value: database.$id
196
+ if (databases.length <= 0) {
197
+ throw new Error("No databases found. Please create one in project console.")
198
+ }
199
+ let choices = databases.map((database, idx) => {
200
+ return {
201
+ name: `${database.name} (${database.$id})`,
202
+ value: database.$id
203
+ }
204
+ })
205
+ return choices;
203
206
  }
204
- })
205
- return choices;
206
207
  }
207
- }
208
208
  ];
209
209
 
210
210
  const questionsLogin = [
211
- {
212
- type: "input",
213
- name: "email",
214
- message: "Enter your email",
215
- validate(value) {
216
- if (!value) {
217
- return "Please enter your email";
218
- }
219
- return true;
211
+ {
212
+ type: "input",
213
+ name: "email",
214
+ message: "Enter your email",
215
+ validate(value) {
216
+ if (!value) {
217
+ return "Please enter your email";
218
+ }
219
+ return true;
220
+ },
221
+ },
222
+ {
223
+ type: "password",
224
+ name: "password",
225
+ message: "Enter your password",
226
+ mask: "*",
227
+ validate(value) {
228
+ if (!value) {
229
+ return "Please enter your password";
230
+ }
231
+ return true;
232
+ }
220
233
  },
221
- },
222
- {
223
- type: "password",
224
- name: "password",
225
- message: "Enter your password",
226
- mask: "*",
227
- validate(value) {
228
- if (!value) {
229
- return "Please enter your password";
230
- }
231
- return true;
232
- }
233
- },
234
234
  ];
235
235
 
236
236
  const questionsDeployFunctions = [
237
- {
238
- type: "checkbox",
239
- name: "functions",
240
- message: "Which functions would you like to deploy?",
241
- choices: () => {
242
- let functions = localConfig.getFunctions();
243
- if (functions.length === 0) {
244
- throw new Error("No functions found in the current directory.");
245
- }
246
- let choices = functions.map((func, idx) => {
247
- return {
248
- name: `${func.name} (${func.$id})`,
249
- value: func.$id
237
+ {
238
+ type: "checkbox",
239
+ name: "functions",
240
+ message: "Which functions would you like to deploy?",
241
+ choices: () => {
242
+ let functions = localConfig.getFunctions();
243
+ if (functions.length === 0) {
244
+ throw new Error("No functions found in the current directory.");
245
+ }
246
+ let choices = functions.map((func, idx) => {
247
+ return {
248
+ name: `${func.name} (${func.$id})`,
249
+ value: func.$id
250
+ }
251
+ })
252
+ return choices;
250
253
  }
251
- })
252
- return choices;
253
- }
254
- },
255
- {
256
- type: "input",
257
- name: "override",
258
- message: 'Are you sure you want to override this function\'s variables? This can lead to loss of secrets! Type "YES" to confirm.'
259
- },
254
+ },
255
+ {
256
+ type: "input",
257
+ name: "override",
258
+ message: 'Are you sure you want to override this function\'s variables? This can lead to loss of secrets! Type "YES" to confirm.'
259
+ },
260
260
  ]
261
261
 
262
262
  const questionsDeployCollections = [
263
- {
264
- type: "checkbox",
265
- name: "collections",
266
- message: "Which collections would you like to deploy?",
267
- choices: () => {
268
- let collections = localConfig.getCollections();
269
- if (collections.length === 0) {
270
- throw new Error("No collections found in the current directory. Run `appwrite init collection` to fetch all your collections.");
271
- }
272
- let choices = collections.map((collection, idx) => {
273
- return {
274
- name: `${collection.name} (${collection['$id']})`,
275
- value: collection.$id
263
+ {
264
+ type: "checkbox",
265
+ name: "collections",
266
+ message: "Which collections would you like to deploy?",
267
+ choices: () => {
268
+ let collections = localConfig.getCollections();
269
+ if (collections.length === 0) {
270
+ throw new Error("No collections found in the current directory. Run `appwrite init collection` to fetch all your collections.");
271
+ }
272
+ let choices = collections.map((collection, idx) => {
273
+ return {
274
+ name: `${collection.name} (${collection['databaseId']} - ${collection['$id']})`,
275
+ value: `${collection['databaseId']}|${collection['$id']}`
276
+ }
277
+ })
278
+ return choices;
276
279
  }
277
- })
278
- return choices;
279
- }
280
- },
281
- {
282
- type: "input",
283
- name: "override",
284
- message: 'Are you sure you want to override this collection? This can lead to loss of data! Type "YES" to confirm.'
285
- },
280
+ },
281
+ {
282
+ type: "input",
283
+ name: "override",
284
+ message: 'Are you sure you want to override this collection? This can lead to loss of data! Type "YES" to confirm.'
285
+ },
286
+ ]
287
+
288
+ const questionsDeployBuckets = [
289
+ {
290
+ type: "checkbox",
291
+ name: "buckets",
292
+ message: "Which buckets would you like to deploy?",
293
+ choices: () => {
294
+ let buckets = localConfig.getBuckets();
295
+ if (buckets.length === 0) {
296
+ throw new Error("No buckets found in the current directory. Run `appwrite init bucket` to fetch all your buckets.");
297
+ }
298
+ let choices = buckets.map((bucket, idx) => {
299
+ return {
300
+ name: `${bucket.name} (${bucket['$id']})`,
301
+ value: bucket.$id
302
+ }
303
+ })
304
+ return choices;
305
+ }
306
+ },
307
+ {
308
+ type: "input",
309
+ name: "override",
310
+ message: 'Are you sure you want to override this bucket? This can lead to loss of data! Type "YES" to confirm.'
311
+ },
286
312
  ]
287
313
 
288
314
  const questionsGetEntrypoint = [
289
- {
290
- type: "input",
291
- name: "entrypoint",
292
- message: "Enter the entrypoint",
293
- default: null,
294
- validate(value) {
295
- if (!value) {
296
- return "Please enter your enrtypoint";
297
- }
298
- return true;
299
- }
300
- },
315
+ {
316
+ type: "input",
317
+ name: "entrypoint",
318
+ message: "Enter the entrypoint",
319
+ default: null,
320
+ validate(value) {
321
+ if (!value) {
322
+ return "Please enter your enrtypoint";
323
+ }
324
+ return true;
325
+ }
326
+ },
301
327
  ]
302
328
 
303
329
  const questionsDeployTeams = [
304
- {
305
- type: "checkbox",
306
- name: "teams",
307
- message: "Which teams would you like to deploy?",
308
- choices: () => {
309
- let teams = localConfig.getTeams();
310
- if (teams.length === 0) {
311
- throw new Error("No teams found in the current directory. Run `appwrite init team` to fetch all your teams.");
312
- }
313
- let choices = teams.map((team, idx) => {
314
- return {
315
- name: `${team.name} (${team['$id']})`,
316
- value: team.$id
330
+ {
331
+ type: "checkbox",
332
+ name: "teams",
333
+ message: "Which teams would you like to deploy?",
334
+ choices: () => {
335
+ let teams = localConfig.getTeams();
336
+ if (teams.length === 0) {
337
+ throw new Error("No teams found in the current directory. Run `appwrite init team` to fetch all your teams.");
338
+ }
339
+ let choices = teams.map((team, idx) => {
340
+ return {
341
+ name: `${team.name} (${team['$id']})`,
342
+ value: team.$id
343
+ }
344
+ })
345
+ return choices;
317
346
  }
318
- })
319
- return choices;
320
- }
321
- },
322
- {
323
- type: "input",
324
- name: "override",
325
- message: 'Are you sure you want to override this team? This can lead to loss of data! Type "YES" to confirm.'
326
- },
347
+ },
348
+ {
349
+ type: "input",
350
+ name: "override",
351
+ message: 'Are you sure you want to override this team? This can lead to loss of data! Type "YES" to confirm.'
352
+ },
327
353
  ]
328
354
 
329
355
  module.exports = {
330
- questionsInitProject,
331
- questionsLogin,
332
- questionsInitFunction,
333
- questionsInitCollection,
334
- questionsDeployFunctions,
335
- questionsDeployCollections,
336
- questionsDeployTeams,
337
- questionsGetEntrypoint
356
+ questionsInitProject,
357
+ questionsLogin,
358
+ questionsInitFunction,
359
+ questionsInitCollection,
360
+ questionsDeployFunctions,
361
+ questionsDeployCollections,
362
+ questionsDeployBuckets,
363
+ questionsDeployTeams,
364
+ questionsGetEntrypoint
338
365
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "appwrite-cli",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "1.2.1",
5
+ "version": "2.0.0",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "index.js",
8
8
  "bin": {
@@ -1,2 +0,0 @@
1
- appwrite account getLogs \
2
-
@@ -1 +0,0 @@
1
- appwrite account getSessions
@@ -1,4 +0,0 @@
1
- appwrite functions retryBuild \
2
- --functionId [FUNCTION_ID] \
3
- --deploymentId [DEPLOYMENT_ID] \
4
- --buildId [BUILD_ID]
@@ -1 +0,0 @@
1
- appwrite locale getContinents