appwrite-cli 0.16.0 → 0.18.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.
- package/README.md +4 -16
- package/docs/examples/account/{create-session.md → create-email-session.md} +1 -1
- package/docs/examples/account/create-phone-session.md +3 -0
- package/docs/examples/account/create-phone-verification.md +1 -0
- package/docs/examples/account/update-phone-session.md +3 -0
- package/docs/examples/account/update-phone-verification.md +3 -0
- package/docs/examples/account/update-phone.md +3 -0
- package/docs/examples/account/update-status.md +1 -0
- package/docs/examples/{database → databases}/create-boolean-attribute.md +2 -1
- package/docs/examples/{database → databases}/create-collection.md +2 -1
- package/docs/examples/{database → databases}/create-document.md +2 -1
- package/docs/examples/{database → databases}/create-email-attribute.md +2 -1
- package/docs/examples/{database → databases}/create-enum-attribute.md +2 -1
- package/docs/examples/{database → databases}/create-float-attribute.md +2 -1
- package/docs/examples/{database → databases}/create-index.md +2 -1
- package/docs/examples/{database → databases}/create-integer-attribute.md +2 -1
- package/docs/examples/{database → databases}/create-ip-attribute.md +2 -1
- package/docs/examples/{database → databases}/create-string-attribute.md +2 -1
- package/docs/examples/{database → databases}/create-url-attribute.md +2 -1
- package/docs/examples/databases/create.md +3 -0
- package/docs/examples/databases/delete-attribute.md +4 -0
- package/docs/examples/databases/delete-collection.md +3 -0
- package/docs/examples/{database → databases}/delete-document.md +2 -1
- package/docs/examples/databases/delete-index.md +4 -0
- package/docs/examples/databases/delete.md +2 -0
- package/docs/examples/databases/get-attribute.md +4 -0
- package/docs/examples/databases/get-collection-usage.md +4 -0
- package/docs/examples/databases/get-collection.md +3 -0
- package/docs/examples/databases/get-database-usage.md +3 -0
- package/docs/examples/{database → databases}/get-document.md +2 -1
- package/docs/examples/databases/get-index.md +4 -0
- package/docs/examples/databases/get-usage.md +2 -0
- package/docs/examples/databases/get.md +2 -0
- package/docs/examples/databases/list-attributes.md +3 -0
- package/docs/examples/databases/list-collection-logs.md +5 -0
- package/docs/examples/databases/list-collections.md +8 -0
- package/docs/examples/{database → databases}/list-document-logs.md +2 -1
- package/docs/examples/databases/list-documents.md +10 -0
- package/docs/examples/databases/list-indexes.md +3 -0
- package/docs/examples/databases/list-logs.md +4 -0
- package/docs/examples/databases/list.md +7 -0
- package/docs/examples/{database → databases}/update-collection.md +2 -1
- package/docs/examples/{database → databases}/update-document.md +3 -2
- package/docs/examples/databases/update.md +3 -0
- package/docs/examples/projects/create-key.md +2 -1
- package/docs/examples/projects/update-key.md +2 -1
- package/docs/examples/projects/update-webhook-signature.md +3 -0
- package/docs/examples/teams/list-logs.md +4 -0
- package/docs/examples/users/get-memberships.md +2 -0
- package/docs/examples/users/{update-verification.md → update-email-verification.md} +1 -1
- package/docs/examples/users/update-phone-verification.md +3 -0
- package/docs/examples/users/update-phone.md +3 -0
- package/index.js +2 -2
- package/install.ps1 +9 -5
- package/install.sh +1 -1
- package/lib/client.js +6 -7
- package/lib/commands/account.js +230 -56
- package/lib/commands/avatars.js +12 -9
- package/lib/commands/{database.js → databases.js} +484 -181
- package/lib/commands/deploy.js +156 -73
- package/lib/commands/functions.js +26 -9
- package/lib/commands/generic.js +13 -6
- package/lib/commands/health.js +3 -23
- package/lib/commands/init.js +43 -24
- package/lib/commands/locale.js +3 -0
- package/lib/commands/projects.js +50 -8
- package/lib/commands/storage.js +8 -5
- package/lib/commands/teams.js +45 -5
- package/lib/commands/users.js +101 -7
- package/lib/config.js +6 -4
- package/lib/parser.js +1 -1
- package/lib/questions.js +87 -4
- package/lib/sdks.js +17 -1
- package/lib/utils.js +19 -0
- package/package.json +8 -6
- package/docs/examples/account/delete.md +0 -1
- package/docs/examples/database/delete-attribute.md +0 -3
- package/docs/examples/database/delete-collection.md +0 -2
- package/docs/examples/database/delete-index.md +0 -3
- package/docs/examples/database/get-attribute.md +0 -3
- package/docs/examples/database/get-collection-usage.md +0 -3
- package/docs/examples/database/get-collection.md +0 -2
- package/docs/examples/database/get-index.md +0 -3
- package/docs/examples/database/get-usage.md +0 -2
- package/docs/examples/database/list-attributes.md +0 -2
- package/docs/examples/database/list-collection-logs.md +0 -4
- package/docs/examples/database/list-collections.md +0 -7
- package/docs/examples/database/list-documents.md +0 -9
- package/docs/examples/database/list-indexes.md +0 -2
- package/docs/examples/health/get-queue-usage.md +0 -1
package/lib/commands/users.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const pathLib = require('path');
|
|
2
3
|
const tar = require("tar");
|
|
4
|
+
const ignore = require("ignore");
|
|
3
5
|
const { promisify } = require('util');
|
|
4
6
|
const libClient = require('../client.js');
|
|
7
|
+
const { getAllFiles } = require('../utils.js');
|
|
5
8
|
const { Command } = require('commander');
|
|
6
9
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
@@ -207,6 +210,24 @@ const usersGetLogs = async ({ userId, limit, offset, parseOutput = true, sdk = u
|
|
|
207
210
|
return response;
|
|
208
211
|
}
|
|
209
212
|
|
|
213
|
+
const usersGetMemberships = async ({ userId, parseOutput = true, sdk = undefined}) => {
|
|
214
|
+
/* @param {string} userId */
|
|
215
|
+
|
|
216
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
217
|
+
let path = '/users/{userId}/memberships'.replace('{userId}', userId);
|
|
218
|
+
let payload = {};
|
|
219
|
+
let response = undefined;
|
|
220
|
+
response = await client.call('get', path, {
|
|
221
|
+
'content-type': 'application/json',
|
|
222
|
+
}, payload);
|
|
223
|
+
|
|
224
|
+
if (parseOutput) {
|
|
225
|
+
parse(response)
|
|
226
|
+
success()
|
|
227
|
+
}
|
|
228
|
+
return response;
|
|
229
|
+
}
|
|
230
|
+
|
|
210
231
|
const usersUpdateName = async ({ userId, name, parseOutput = true, sdk = undefined}) => {
|
|
211
232
|
/* @param {string} userId */
|
|
212
233
|
/* @param {string} name */
|
|
@@ -257,6 +278,31 @@ const usersUpdatePassword = async ({ userId, password, parseOutput = true, sdk =
|
|
|
257
278
|
return response;
|
|
258
279
|
}
|
|
259
280
|
|
|
281
|
+
const usersUpdatePhone = async ({ userId, number, parseOutput = true, sdk = undefined}) => {
|
|
282
|
+
/* @param {string} userId */
|
|
283
|
+
/* @param {string} number */
|
|
284
|
+
|
|
285
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
286
|
+
let path = '/users/{userId}/phone'.replace('{userId}', userId);
|
|
287
|
+
let payload = {};
|
|
288
|
+
|
|
289
|
+
/** Body Params */
|
|
290
|
+
if (typeof number !== 'undefined') {
|
|
291
|
+
payload['number'] = number;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
let response = undefined;
|
|
295
|
+
response = await client.call('patch', path, {
|
|
296
|
+
'content-type': 'application/json',
|
|
297
|
+
}, payload);
|
|
298
|
+
|
|
299
|
+
if (parseOutput) {
|
|
300
|
+
parse(response)
|
|
301
|
+
success()
|
|
302
|
+
}
|
|
303
|
+
return response;
|
|
304
|
+
}
|
|
305
|
+
|
|
260
306
|
const usersGetPrefs = async ({ userId, parseOutput = true, sdk = undefined}) => {
|
|
261
307
|
/* @param {string} userId */
|
|
262
308
|
|
|
@@ -380,7 +426,7 @@ const usersUpdateStatus = async ({ userId, status, parseOutput = true, sdk = und
|
|
|
380
426
|
return response;
|
|
381
427
|
}
|
|
382
428
|
|
|
383
|
-
const
|
|
429
|
+
const usersUpdateEmailVerification = async ({ userId, emailVerification, parseOutput = true, sdk = undefined}) => {
|
|
384
430
|
/* @param {string} userId */
|
|
385
431
|
/* @param {boolean} emailVerification */
|
|
386
432
|
|
|
@@ -405,6 +451,31 @@ const usersUpdateVerification = async ({ userId, emailVerification, parseOutput
|
|
|
405
451
|
return response;
|
|
406
452
|
}
|
|
407
453
|
|
|
454
|
+
const usersUpdatePhoneVerification = async ({ userId, phoneVerification, parseOutput = true, sdk = undefined}) => {
|
|
455
|
+
/* @param {string} userId */
|
|
456
|
+
/* @param {boolean} phoneVerification */
|
|
457
|
+
|
|
458
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
459
|
+
let path = '/users/{userId}/verification/phone'.replace('{userId}', userId);
|
|
460
|
+
let payload = {};
|
|
461
|
+
|
|
462
|
+
/** Body Params */
|
|
463
|
+
if (typeof phoneVerification !== 'undefined') {
|
|
464
|
+
payload['phoneVerification'] = phoneVerification;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
let response = undefined;
|
|
468
|
+
response = await client.call('patch', path, {
|
|
469
|
+
'content-type': 'application/json',
|
|
470
|
+
}, payload);
|
|
471
|
+
|
|
472
|
+
if (parseOutput) {
|
|
473
|
+
parse(response)
|
|
474
|
+
success()
|
|
475
|
+
}
|
|
476
|
+
return response;
|
|
477
|
+
}
|
|
478
|
+
|
|
408
479
|
|
|
409
480
|
users
|
|
410
481
|
.command(`list`)
|
|
@@ -413,7 +484,7 @@ users
|
|
|
413
484
|
.option(`--limit <limit>`, `Maximum number of users to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.`, parseInteger)
|
|
414
485
|
.option(`--offset <offset>`, `Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)`, parseInteger)
|
|
415
486
|
.option(`--cursor <cursor>`, `ID of the user used as the starting point for the query, excluding the user itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)`)
|
|
416
|
-
.option(`--cursorDirection <cursorDirection>`, `Direction of the cursor.`)
|
|
487
|
+
.option(`--cursorDirection <cursorDirection>`, `Direction of the cursor, can be either 'before' or 'after'.`)
|
|
417
488
|
.option(`--orderType <orderType>`, `Order result by ASC or DESC order.`)
|
|
418
489
|
.action(actionRunner(usersList))
|
|
419
490
|
|
|
@@ -441,7 +512,7 @@ users
|
|
|
441
512
|
|
|
442
513
|
users
|
|
443
514
|
.command(`delete`)
|
|
444
|
-
.description(`Delete a user by its unique ID.`)
|
|
515
|
+
.description(`Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus) endpoint instead.`)
|
|
445
516
|
.requiredOption(`--userId <userId>`, `User ID.`)
|
|
446
517
|
.action(actionRunner(usersDelete))
|
|
447
518
|
|
|
@@ -460,6 +531,12 @@ users
|
|
|
460
531
|
.option(`--offset <offset>`, `Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)`, parseInteger)
|
|
461
532
|
.action(actionRunner(usersGetLogs))
|
|
462
533
|
|
|
534
|
+
users
|
|
535
|
+
.command(`getMemberships`)
|
|
536
|
+
.description(`Get the user membership list by its unique ID.`)
|
|
537
|
+
.requiredOption(`--userId <userId>`, `User ID.`)
|
|
538
|
+
.action(actionRunner(usersGetMemberships))
|
|
539
|
+
|
|
463
540
|
users
|
|
464
541
|
.command(`updateName`)
|
|
465
542
|
.description(`Update the user name by its unique ID.`)
|
|
@@ -474,6 +551,13 @@ users
|
|
|
474
551
|
.requiredOption(`--password <password>`, `New user password. Must be at least 8 chars.`)
|
|
475
552
|
.action(actionRunner(usersUpdatePassword))
|
|
476
553
|
|
|
554
|
+
users
|
|
555
|
+
.command(`updatePhone`)
|
|
556
|
+
.description(`Update the user phone by its unique ID.`)
|
|
557
|
+
.requiredOption(`--userId <userId>`, `User ID.`)
|
|
558
|
+
.requiredOption(`--number <number>`, `User phone number.`)
|
|
559
|
+
.action(actionRunner(usersUpdatePhone))
|
|
560
|
+
|
|
477
561
|
users
|
|
478
562
|
.command(`getPrefs`)
|
|
479
563
|
.description(`Get the user preferences by its unique ID.`)
|
|
@@ -508,17 +592,24 @@ users
|
|
|
508
592
|
|
|
509
593
|
users
|
|
510
594
|
.command(`updateStatus`)
|
|
511
|
-
.description(`Update the user status by its unique ID.`)
|
|
595
|
+
.description(`Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved.`)
|
|
512
596
|
.requiredOption(`--userId <userId>`, `User ID.`)
|
|
513
597
|
.requiredOption(`--status <status>`, `User Status. To activate the user pass 'true' and to block the user pass 'false'.`, parseBool)
|
|
514
598
|
.action(actionRunner(usersUpdateStatus))
|
|
515
599
|
|
|
516
600
|
users
|
|
517
|
-
.command(`
|
|
601
|
+
.command(`updateEmailVerification`)
|
|
518
602
|
.description(`Update the user email verification status by its unique ID.`)
|
|
519
603
|
.requiredOption(`--userId <userId>`, `User ID.`)
|
|
520
604
|
.requiredOption(`--emailVerification <emailVerification>`, `User email verification status.`, parseBool)
|
|
521
|
-
.action(actionRunner(
|
|
605
|
+
.action(actionRunner(usersUpdateEmailVerification))
|
|
606
|
+
|
|
607
|
+
users
|
|
608
|
+
.command(`updatePhoneVerification`)
|
|
609
|
+
.description(`Update the user phone verification status by its unique ID.`)
|
|
610
|
+
.requiredOption(`--userId <userId>`, `User ID.`)
|
|
611
|
+
.requiredOption(`--phoneVerification <phoneVerification>`, `User phone verification status.`, parseBool)
|
|
612
|
+
.action(actionRunner(usersUpdatePhoneVerification))
|
|
522
613
|
|
|
523
614
|
|
|
524
615
|
module.exports = {
|
|
@@ -530,13 +621,16 @@ module.exports = {
|
|
|
530
621
|
usersDelete,
|
|
531
622
|
usersUpdateEmail,
|
|
532
623
|
usersGetLogs,
|
|
624
|
+
usersGetMemberships,
|
|
533
625
|
usersUpdateName,
|
|
534
626
|
usersUpdatePassword,
|
|
627
|
+
usersUpdatePhone,
|
|
535
628
|
usersGetPrefs,
|
|
536
629
|
usersUpdatePrefs,
|
|
537
630
|
usersGetSessions,
|
|
538
631
|
usersDeleteSessions,
|
|
539
632
|
usersDeleteSession,
|
|
540
633
|
usersUpdateStatus,
|
|
541
|
-
|
|
634
|
+
usersUpdateEmailVerification,
|
|
635
|
+
usersUpdatePhoneVerification
|
|
542
636
|
};
|
package/lib/config.js
CHANGED
|
@@ -2,6 +2,7 @@ const os = require('os');
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const _path = require("path");
|
|
4
4
|
const process = require("process");
|
|
5
|
+
const JSONbig = require("json-bigint")({ storeAsString: false });
|
|
5
6
|
|
|
6
7
|
class Config {
|
|
7
8
|
constructor(path) {
|
|
@@ -11,7 +12,8 @@ class Config {
|
|
|
11
12
|
|
|
12
13
|
read() {
|
|
13
14
|
try {
|
|
14
|
-
|
|
15
|
+
const file = fs.readFileSync(this.path).toString();
|
|
16
|
+
this.data = JSONbig.parse(file);
|
|
15
17
|
} catch (e) {
|
|
16
18
|
// console.log(`${this.path} not found. Empty data`);
|
|
17
19
|
this.data = {};
|
|
@@ -23,7 +25,7 @@ class Config {
|
|
|
23
25
|
if (!fs.existsSync(dir)){
|
|
24
26
|
fs.mkdirSync(dir, { recursive: true });
|
|
25
27
|
}
|
|
26
|
-
fs.writeFileSync(this.path,
|
|
28
|
+
fs.writeFileSync(this.path, JSONbig.stringify(this.data, null, 4));
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
get(key) {
|
|
@@ -46,7 +48,7 @@ class Config {
|
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
has(key) {
|
|
49
|
-
return this.data
|
|
51
|
+
return this.data[key] !== undefined;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
keys() {
|
|
@@ -58,7 +60,7 @@ class Config {
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
toString() {
|
|
61
|
-
return
|
|
63
|
+
return JSONbig.stringify(this.data, null, 4);
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
|
package/lib/parser.js
CHANGED
|
@@ -150,7 +150,7 @@ const logo = "\n _ _ _ ___ __ _____
|
|
|
150
150
|
const commandDescriptions = {
|
|
151
151
|
"account": `The account command allows you to authenticate and manage a user account.`,
|
|
152
152
|
"avatars": `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`,
|
|
153
|
-
"
|
|
153
|
+
"databases": `The databases command allows you to create structured collections of documents, query and filter lists of documents.`,
|
|
154
154
|
"deploy": `The deploy command provides a convenient wrapper for deploying your functions and collections.`,
|
|
155
155
|
"functions": `The functions command allows you view, create and manage your Cloud Functions.`,
|
|
156
156
|
"health": `The health command allows you to both validate and monitor your Appwrite server's health.`,
|
package/lib/questions.js
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
const { localConfig } = require('./config');
|
|
2
2
|
const { projectsList } = require('./commands/projects');
|
|
3
3
|
const { functionsListRuntimes } = require('./commands/functions');
|
|
4
|
+
const { databasesList } = require('./commands/databases');
|
|
5
|
+
const JSONbig = require("json-bigint")({ storeAsString: false });
|
|
6
|
+
|
|
7
|
+
const getIgnores = (runtime) => {
|
|
8
|
+
const languge = runtime.split('-')[0];
|
|
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
|
+
}
|
|
35
|
+
|
|
36
|
+
return undefined;
|
|
37
|
+
};
|
|
4
38
|
|
|
5
39
|
const getEntrypoint = (runtime) => {
|
|
6
40
|
const languge = runtime.split('-')[0];
|
|
@@ -22,6 +56,14 @@ const getEntrypoint = (runtime) => {
|
|
|
22
56
|
return 'main.rs';
|
|
23
57
|
case 'swift':
|
|
24
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';
|
|
25
67
|
}
|
|
26
68
|
|
|
27
69
|
return undefined;
|
|
@@ -67,6 +109,15 @@ const questionsInitProject = [
|
|
|
67
109
|
return answers.start == "new";
|
|
68
110
|
},
|
|
69
111
|
},
|
|
112
|
+
{
|
|
113
|
+
type: "input",
|
|
114
|
+
name: "id",
|
|
115
|
+
message: "What ID would you like to have for your project?",
|
|
116
|
+
default: "myAwesomeProject",
|
|
117
|
+
when(answers) {
|
|
118
|
+
return answers.start == "new";
|
|
119
|
+
},
|
|
120
|
+
},
|
|
70
121
|
{
|
|
71
122
|
type: "list",
|
|
72
123
|
name: "project",
|
|
@@ -105,6 +156,12 @@ const questionsInitFunction = [
|
|
|
105
156
|
message: "What would you like to name your function?",
|
|
106
157
|
default: "My Awesome Function"
|
|
107
158
|
},
|
|
159
|
+
{
|
|
160
|
+
type: "input",
|
|
161
|
+
name: "id",
|
|
162
|
+
message: "What ID would you like to have for your function?",
|
|
163
|
+
default: "myAwesomeFunction"
|
|
164
|
+
},
|
|
108
165
|
{
|
|
109
166
|
type: "list",
|
|
110
167
|
name: "runtime",
|
|
@@ -117,7 +174,32 @@ const questionsInitFunction = [
|
|
|
117
174
|
let choices = runtimes.map((runtime, idx) => {
|
|
118
175
|
return {
|
|
119
176
|
name: `${runtime.name} (${runtime['$id']})`,
|
|
120
|
-
value: { id: runtime['$id'], entrypoint: getEntrypoint(runtime['$id'])}
|
|
177
|
+
value: { id: runtime['$id'], entrypoint: getEntrypoint(runtime['$id']), ignore: getIgnores(runtime['$id'])},
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
return choices;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
];
|
|
184
|
+
|
|
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"]
|
|
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
|
|
121
203
|
}
|
|
122
204
|
})
|
|
123
205
|
return choices;
|
|
@@ -163,8 +245,8 @@ const questionsDeployFunctions = [
|
|
|
163
245
|
}
|
|
164
246
|
let choices = functions.map((func, idx) => {
|
|
165
247
|
return {
|
|
166
|
-
name: `${func.name} (${func
|
|
167
|
-
value: func
|
|
248
|
+
name: `${func.name} (${func.$id})`,
|
|
249
|
+
value: func.$id
|
|
168
250
|
}
|
|
169
251
|
})
|
|
170
252
|
return choices;
|
|
@@ -185,7 +267,7 @@ const questionsDeployCollections = [
|
|
|
185
267
|
let choices = collections.map((collection, idx) => {
|
|
186
268
|
return {
|
|
187
269
|
name: `${collection.name} (${collection['$id']})`,
|
|
188
|
-
value: collection
|
|
270
|
+
value: collection.$id
|
|
189
271
|
}
|
|
190
272
|
})
|
|
191
273
|
return choices;
|
|
@@ -217,6 +299,7 @@ module.exports = {
|
|
|
217
299
|
questionsInitProject,
|
|
218
300
|
questionsLogin,
|
|
219
301
|
questionsInitFunction,
|
|
302
|
+
questionsInitCollection,
|
|
220
303
|
questionsDeployFunctions,
|
|
221
304
|
questionsDeployCollections,
|
|
222
305
|
questionsGetEntrypoint
|
package/lib/sdks.js
CHANGED
|
@@ -7,7 +7,23 @@ const questionGetEndpoint = [
|
|
|
7
7
|
type: "input",
|
|
8
8
|
name: "endpoint",
|
|
9
9
|
message: "Enter the endpoint of your Appwrite server",
|
|
10
|
-
default: "http://localhost/v1"
|
|
10
|
+
default: "http://localhost/v1",
|
|
11
|
+
async validate(value) {
|
|
12
|
+
if (!value) {
|
|
13
|
+
return "Please enter a valid endpoint.";
|
|
14
|
+
}
|
|
15
|
+
let client = new Client().setEndpoint(value);
|
|
16
|
+
try {
|
|
17
|
+
let response = await client.call('get', '/health/version');
|
|
18
|
+
if (response.version) {
|
|
19
|
+
return true;
|
|
20
|
+
} else {
|
|
21
|
+
throw new Error();
|
|
22
|
+
}
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return "Invalid endpoint or your Appwrite server is not running as expected.";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
11
27
|
}
|
|
12
28
|
]
|
|
13
29
|
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
function getAllFiles(folder) {
|
|
5
|
+
const files = [];
|
|
6
|
+
for(const pathDir of fs.readdirSync(folder)) {
|
|
7
|
+
const pathAbsolute = path.join(folder, pathDir);
|
|
8
|
+
if (fs.statSync(pathAbsolute).isDirectory()) {
|
|
9
|
+
files.push(...getAllFiles(pathAbsolute));
|
|
10
|
+
} else {
|
|
11
|
+
files.push(pathAbsolute);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return files;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
getAllFiles
|
|
19
|
+
};
|
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": "0.
|
|
5
|
+
"version": "0.18.1",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|
|
@@ -22,13 +22,15 @@
|
|
|
22
22
|
"windows-arm64": "pkg -t node16-win-arm64 -o build/appwrite-cli-win-arm64.exe package.json"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"axios": "^0.
|
|
25
|
+
"axios": "^0.27.2",
|
|
26
26
|
"chalk": "4.1.2",
|
|
27
|
-
"cli-table3": "^0.6.
|
|
28
|
-
"commander": "^9.
|
|
27
|
+
"cli-table3": "^0.6.2",
|
|
28
|
+
"commander": "^9.2.0",
|
|
29
29
|
"form-data": "^4.0.0",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"json-bigint": "^1.0.0",
|
|
31
|
+
"inquirer": "^8.2.4",
|
|
32
|
+
"tar": "^6.1.11",
|
|
33
|
+
"ignore": "^5.2.0"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"pkg": "5.5.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
appwrite account delete
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
appwrite health getQueueUsage
|