appwrite-cli 5.0.2 → 5.0.3
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 +2 -2
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +2 -2
- package/lib/commands/generic.js +40 -3
- package/lib/commands/messaging.js +19 -19
- package/lib/questions.js +57 -2
- package/package.json +1 -1
- package/scoop/appwrite.json +3 -3
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
|
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
31
|
$ appwrite -v
|
|
32
|
-
5.0.
|
|
32
|
+
5.0.3
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Install using prebuilt binaries
|
|
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
|
|
|
60
60
|
Once the installation completes, you can verify your install using
|
|
61
61
|
```
|
|
62
62
|
$ appwrite -v
|
|
63
|
-
5.0.
|
|
63
|
+
5.0.3
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
## Getting Started
|
package/install.ps1
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
# You can use "View source" of this page to see the full script.
|
|
14
14
|
|
|
15
15
|
# REPO
|
|
16
|
-
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.
|
|
17
|
-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.
|
|
16
|
+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.3/appwrite-cli-win-x64.exe"
|
|
17
|
+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.3/appwrite-cli-win-arm64.exe"
|
|
18
18
|
|
|
19
19
|
$APPWRITE_BINARY_NAME = "appwrite.exe"
|
|
20
20
|
|
package/install.sh
CHANGED
|
@@ -97,7 +97,7 @@ printSuccess() {
|
|
|
97
97
|
downloadBinary() {
|
|
98
98
|
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
|
|
99
99
|
|
|
100
|
-
GITHUB_LATEST_VERSION="5.0.
|
|
100
|
+
GITHUB_LATEST_VERSION="5.0.3"
|
|
101
101
|
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
|
|
102
102
|
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
|
|
103
103
|
|
package/lib/client.js
CHANGED
|
@@ -15,8 +15,8 @@ class Client {
|
|
|
15
15
|
'x-sdk-name': 'Command Line',
|
|
16
16
|
'x-sdk-platform': 'console',
|
|
17
17
|
'x-sdk-language': 'cli',
|
|
18
|
-
'x-sdk-version': '5.0.
|
|
19
|
-
'user-agent' : `AppwriteCLI/5.0.
|
|
18
|
+
'x-sdk-version': '5.0.3',
|
|
19
|
+
'user-agent' : `AppwriteCLI/5.0.3 (${os.type()} ${os.version()}; ${os.arch()})`,
|
|
20
20
|
'X-Appwrite-Response-Format' : '1.5.0',
|
|
21
21
|
};
|
|
22
22
|
}
|
package/lib/commands/generic.js
CHANGED
|
@@ -4,8 +4,8 @@ const Client = require("../client");
|
|
|
4
4
|
const { sdkForConsole } = require("../sdks");
|
|
5
5
|
const { globalConfig, localConfig } = require("../config");
|
|
6
6
|
const { actionRunner, success, parseBool, commandDescriptions, log, parse } = require("../parser");
|
|
7
|
-
const { questionsLogin } = require("../questions");
|
|
8
|
-
const { accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
|
|
7
|
+
const { questionsLogin, questionsListFactors, questionsMfaChallenge } = require("../questions");
|
|
8
|
+
const { accountUpdateMfaChallenge, accountCreateMfaChallenge, accountGet, accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
|
|
9
9
|
|
|
10
10
|
const login = new Command("login")
|
|
11
11
|
.description(commandDescriptions['login'])
|
|
@@ -24,7 +24,44 @@ const login = new Command("login")
|
|
|
24
24
|
sdk: client
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
client.setCookie(globalConfig.getCookie());
|
|
28
|
+
|
|
29
|
+
let account;
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
account = await accountGet({
|
|
33
|
+
sdk: client,
|
|
34
|
+
parseOutput: false
|
|
35
|
+
});
|
|
36
|
+
} catch(error) {
|
|
37
|
+
if (error.response === 'user_more_factors_required') {
|
|
38
|
+
const { factor } = await inquirer.prompt(questionsListFactors);
|
|
39
|
+
|
|
40
|
+
const challenge = await accountCreateMfaChallenge({
|
|
41
|
+
factor,
|
|
42
|
+
parseOutput: false,
|
|
43
|
+
sdk: client
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const { otp } = await inquirer.prompt(questionsMfaChallenge);
|
|
47
|
+
|
|
48
|
+
await accountUpdateMfaChallenge({
|
|
49
|
+
challengeId: challenge.$id,
|
|
50
|
+
otp,
|
|
51
|
+
parseOutput: false,
|
|
52
|
+
sdk: client
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
account = await accountGet({
|
|
56
|
+
sdk: client,
|
|
57
|
+
parseOutput: false
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
success("Signed in as user with ID: " + account.$id);
|
|
28
65
|
}));
|
|
29
66
|
|
|
30
67
|
const logout = new Command("logout")
|
|
@@ -1032,9 +1032,9 @@ const messagingUpdateMailgunProvider = async ({ providerId, name, apiKey, domain
|
|
|
1032
1032
|
* @typedef {Object} MessagingCreateMsg91ProviderRequestParams
|
|
1033
1033
|
* @property {string} providerId Provider ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
1034
1034
|
* @property {string} name Provider name.
|
|
1035
|
-
* @property {string}
|
|
1036
|
-
* @property {string} senderId Msg91
|
|
1037
|
-
* @property {string} authKey Msg91
|
|
1035
|
+
* @property {string} from Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
|
|
1036
|
+
* @property {string} senderId Msg91 Sender ID.
|
|
1037
|
+
* @property {string} authKey Msg91 Auth Key.
|
|
1038
1038
|
* @property {boolean} enabled Set as enabled.
|
|
1039
1039
|
* @property {boolean} parseOutput
|
|
1040
1040
|
* @property {libClient | undefined} sdk
|
|
@@ -1043,7 +1043,7 @@ const messagingUpdateMailgunProvider = async ({ providerId, name, apiKey, domain
|
|
|
1043
1043
|
/**
|
|
1044
1044
|
* @param {MessagingCreateMsg91ProviderRequestParams} params
|
|
1045
1045
|
*/
|
|
1046
|
-
const messagingCreateMsg91Provider = async ({ providerId, name,
|
|
1046
|
+
const messagingCreateMsg91Provider = async ({ providerId, name, from, senderId, authKey, enabled, parseOutput = true, sdk = undefined}) => {
|
|
1047
1047
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
1048
1048
|
let apiPath = '/messaging/providers/msg91';
|
|
1049
1049
|
let payload = {};
|
|
@@ -1053,8 +1053,8 @@ const messagingCreateMsg91Provider = async ({ providerId, name, templateId, send
|
|
|
1053
1053
|
if (typeof name !== 'undefined') {
|
|
1054
1054
|
payload['name'] = name;
|
|
1055
1055
|
}
|
|
1056
|
-
if (typeof
|
|
1057
|
-
payload['
|
|
1056
|
+
if (typeof from !== 'undefined') {
|
|
1057
|
+
payload['from'] = from;
|
|
1058
1058
|
}
|
|
1059
1059
|
if (typeof senderId !== 'undefined') {
|
|
1060
1060
|
payload['senderId'] = senderId;
|
|
@@ -1085,9 +1085,9 @@ const messagingCreateMsg91Provider = async ({ providerId, name, templateId, send
|
|
|
1085
1085
|
* @property {string} providerId Provider ID.
|
|
1086
1086
|
* @property {string} name Provider name.
|
|
1087
1087
|
* @property {boolean} enabled Set as enabled.
|
|
1088
|
-
* @property {string}
|
|
1089
|
-
* @property {string}
|
|
1090
|
-
* @property {string}
|
|
1088
|
+
* @property {string} senderId Msg91 Sender ID.
|
|
1089
|
+
* @property {string} authKey Msg91 Auth Key.
|
|
1090
|
+
* @property {string} from Sender number.
|
|
1091
1091
|
* @property {boolean} parseOutput
|
|
1092
1092
|
* @property {libClient | undefined} sdk
|
|
1093
1093
|
*/
|
|
@@ -1095,7 +1095,7 @@ const messagingCreateMsg91Provider = async ({ providerId, name, templateId, send
|
|
|
1095
1095
|
/**
|
|
1096
1096
|
* @param {MessagingUpdateMsg91ProviderRequestParams} params
|
|
1097
1097
|
*/
|
|
1098
|
-
const messagingUpdateMsg91Provider = async ({ providerId, name, enabled,
|
|
1098
|
+
const messagingUpdateMsg91Provider = async ({ providerId, name, enabled, senderId, authKey, from, parseOutput = true, sdk = undefined}) => {
|
|
1099
1099
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
1100
1100
|
let apiPath = '/messaging/providers/msg91/{providerId}'.replace('{providerId}', providerId);
|
|
1101
1101
|
let payload = {};
|
|
@@ -1105,15 +1105,15 @@ const messagingUpdateMsg91Provider = async ({ providerId, name, enabled, templat
|
|
|
1105
1105
|
if (typeof enabled !== 'undefined') {
|
|
1106
1106
|
payload['enabled'] = enabled;
|
|
1107
1107
|
}
|
|
1108
|
-
if (typeof templateId !== 'undefined') {
|
|
1109
|
-
payload['templateId'] = templateId;
|
|
1110
|
-
}
|
|
1111
1108
|
if (typeof senderId !== 'undefined') {
|
|
1112
1109
|
payload['senderId'] = senderId;
|
|
1113
1110
|
}
|
|
1114
1111
|
if (typeof authKey !== 'undefined') {
|
|
1115
1112
|
payload['authKey'] = authKey;
|
|
1116
1113
|
}
|
|
1114
|
+
if (typeof from !== 'undefined') {
|
|
1115
|
+
payload['from'] = from;
|
|
1116
|
+
}
|
|
1117
1117
|
|
|
1118
1118
|
let response = undefined;
|
|
1119
1119
|
|
|
@@ -2497,9 +2497,9 @@ messaging
|
|
|
2497
2497
|
.description(`Create a new MSG91 provider.`)
|
|
2498
2498
|
.requiredOption(`--providerId <providerId>`, `Provider ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
2499
2499
|
.requiredOption(`--name <name>`, `Provider name.`)
|
|
2500
|
-
.option(`--
|
|
2501
|
-
.option(`--senderId <senderId>`, `Msg91
|
|
2502
|
-
.option(`--authKey <authKey>`, `Msg91
|
|
2500
|
+
.option(`--from <from>`, `Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
|
|
2501
|
+
.option(`--senderId <senderId>`, `Msg91 Sender ID.`)
|
|
2502
|
+
.option(`--authKey <authKey>`, `Msg91 Auth Key.`)
|
|
2503
2503
|
.option(`--enabled <enabled>`, `Set as enabled.`, parseBool)
|
|
2504
2504
|
.action(actionRunner(messagingCreateMsg91Provider))
|
|
2505
2505
|
|
|
@@ -2509,9 +2509,9 @@ messaging
|
|
|
2509
2509
|
.requiredOption(`--providerId <providerId>`, `Provider ID.`)
|
|
2510
2510
|
.option(`--name <name>`, `Provider name.`)
|
|
2511
2511
|
.option(`--enabled <enabled>`, `Set as enabled.`, parseBool)
|
|
2512
|
-
.option(`--
|
|
2513
|
-
.option(`--
|
|
2514
|
-
.option(`--
|
|
2512
|
+
.option(`--senderId <senderId>`, `Msg91 Sender ID.`)
|
|
2513
|
+
.option(`--authKey <authKey>`, `Msg91 Auth Key.`)
|
|
2514
|
+
.option(`--from <from>`, `Sender number.`)
|
|
2515
2515
|
.action(actionRunner(messagingUpdateMsg91Provider))
|
|
2516
2516
|
|
|
2517
2517
|
messaging
|
package/lib/questions.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const { localConfig } = require('./config');
|
|
2
2
|
const { projectsList } = require('./commands/projects');
|
|
3
3
|
const { functionsListRuntimes } = require('./commands/functions');
|
|
4
|
+
const { accountListMfaFactors } = require("./commands/account");
|
|
5
|
+
const { sdkForConsole } = require("./sdks");
|
|
6
|
+
|
|
4
7
|
const { databasesList } = require('./commands/databases');
|
|
5
8
|
const JSONbig = require("json-bigint")({ storeAsString: false });
|
|
6
9
|
|
|
@@ -387,7 +390,57 @@ const questionsDeployTeams = [
|
|
|
387
390
|
name: "override",
|
|
388
391
|
message: 'Are you sure you want to override this team? This can lead to loss of data! Type "YES" to confirm.'
|
|
389
392
|
},
|
|
390
|
-
]
|
|
393
|
+
];
|
|
394
|
+
|
|
395
|
+
const questionsListFactors = [
|
|
396
|
+
{
|
|
397
|
+
type: "list",
|
|
398
|
+
name: "factor",
|
|
399
|
+
message: "Your account is protected by multiple factors. Which factor would you like to use to authenticate?",
|
|
400
|
+
choices: async () => {
|
|
401
|
+
let client = await sdkForConsole(false);
|
|
402
|
+
const factors = await accountListMfaFactors({
|
|
403
|
+
sdk: client,
|
|
404
|
+
parseOutput: false
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
const choices = [
|
|
408
|
+
{
|
|
409
|
+
name: `TOTP (Time-based One-time Password)`,
|
|
410
|
+
value: 'totp'
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
name: `E-mail`,
|
|
414
|
+
value: 'email'
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
name: `Phone (SMS)`,
|
|
418
|
+
value: 'phone'
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
name: `Recovery code`,
|
|
422
|
+
value: 'recoveryCode'
|
|
423
|
+
}
|
|
424
|
+
].filter((ch) => factors[ch.value] === true);
|
|
425
|
+
|
|
426
|
+
return choices;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
];
|
|
430
|
+
|
|
431
|
+
const questionsMfaChallenge = [
|
|
432
|
+
{
|
|
433
|
+
type: "input",
|
|
434
|
+
name: "otp",
|
|
435
|
+
message: "Enter OTP",
|
|
436
|
+
validate(value) {
|
|
437
|
+
if (!value) {
|
|
438
|
+
return "Please enter OTP";
|
|
439
|
+
}
|
|
440
|
+
return true;
|
|
441
|
+
},
|
|
442
|
+
}
|
|
443
|
+
];
|
|
391
444
|
|
|
392
445
|
module.exports = {
|
|
393
446
|
questionsInitProject,
|
|
@@ -398,5 +451,7 @@ module.exports = {
|
|
|
398
451
|
questionsDeployCollections,
|
|
399
452
|
questionsDeployBuckets,
|
|
400
453
|
questionsDeployTeams,
|
|
401
|
-
questionsGetEntrypoint
|
|
454
|
+
questionsGetEntrypoint,
|
|
455
|
+
questionsListFactors,
|
|
456
|
+
questionsMfaChallenge
|
|
402
457
|
};
|
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": "5.0.
|
|
5
|
+
"version": "5.0.3",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|
package/scoop/appwrite.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
|
|
5
5
|
"homepage": "https://github.com/appwrite/sdk-for-cli",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"architecture": {
|
|
8
8
|
"64bit": {
|
|
9
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.
|
|
9
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.3/appwrite-cli-win-x64.exe",
|
|
10
10
|
"bin": [
|
|
11
11
|
[
|
|
12
12
|
"appwrite-cli-win-x64.exe",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"arm64": {
|
|
18
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.
|
|
18
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.3/appwrite-cli-win-arm64.exe",
|
|
19
19
|
"bin": [
|
|
20
20
|
[
|
|
21
21
|
"appwrite-cli-win-arm64.exe",
|