Skip to content

Commit aa69621

Browse files
Merge pull request #138 from appwrite/1.6.x
1.6.x
2 parents 4c38539 + dab9986 commit aa69621

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+8624
-3831
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Appwrite Command Line SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-cli.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-1.5.6-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.6.0-blue.svg?style=flat-square)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
88

9-
**This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
9+
**This SDK is compatible with Appwrite server version 1.6.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
1010

1111
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Command Line SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1212

@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
2929

3030
```sh
3131
$ appwrite -v
32-
5.0.5
32+
6.0.0
3333
```
3434

3535
### Install using prebuilt binaries
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
6060
Once the installation completes, you can verify your install using
6161
```
6262
$ appwrite -v
63-
5.0.5
63+
6.0.0
6464
```
6565

6666
## Getting Started
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
appwrite account deleteMfaAuthenticator \
2-
--type totp \
3-
--otp <OTP>
2+
--type totp
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
appwrite functions createBuild \
22
--functionId <FUNCTION_ID> \
33
--deploymentId <DEPLOYMENT_ID> \
4-
--buildId <BUILD_ID>
4+

docs/examples/functions/create-execution.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ appwrite functions createExecution \
55

66

77

8+

docs/examples/functions/create.md

+2
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ appwrite functions create \
1919

2020

2121

22+
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
appwrite functions deleteExecution \
2+
--functionId <FUNCTION_ID> \
3+
--executionId <EXECUTION_ID>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
appwrite functions downloadDeployment \
1+
appwrite functions getDeploymentDownload \
22
--functionId <FUNCTION_ID> \
33
--deploymentId <DEPLOYMENT_ID>
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
appwrite functions getTemplate \
2+
--templateId <TEMPLATE_ID>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
appwrite functions listSpecifications
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
appwrite functions listTemplates \
2+
3+
4+
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
appwrite functions updateDeploymentBuild \
2+
--functionId <FUNCTION_ID> \
3+
--deploymentId <DEPLOYMENT_ID>

docs/examples/functions/update.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ appwrite functions update \
1515

1616

1717

18+
19+
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
appwrite projects createJWT \
2+
--projectId <PROJECT_ID> \
3+
--scopes one two three \
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
appwrite projects updateMockNumbers \
2+
--projectId <PROJECT_ID> \
3+
--numbers one two three
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
appwrite projects updateSessionAlerts \
2+
--projectId <PROJECT_ID> \
3+
--alerts false

docs/examples/users/create-j-w-t.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
appwrite users createJWT \
2+
--userId <USER_ID> \
3+
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
appwrite vcs getRepositoryContents \
2+
--installationId <INSTALLATION_ID> \
3+
--providerRepositoryId <PROVIDER_REPOSITORY_ID> \
4+

index.js

+37-8
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ const chalk = require("chalk");
1010
const { version } = require("./package.json");
1111
const { commandDescriptions, cliConfig } = require("./lib/parser");
1212
const { client } = require("./lib/commands/generic");
13-
const { login, logout } = require("./lib/commands/generic");
13+
const inquirer = require("inquirer");
14+
const { login, logout, whoami, migrate, register } = require("./lib/commands/generic");
1415
const { init } = require("./lib/commands/init");
15-
const { deploy } = require("./lib/commands/deploy");
16+
const { pull } = require("./lib/commands/pull");
17+
const { run } = require("./lib/commands/run");
18+
const { push, deploy } = require("./lib/commands/push");
1619
const { account } = require("./lib/commands/account");
1720
const { avatars } = require("./lib/commands/avatars");
1821
const { assistant } = require("./lib/commands/assistant");
@@ -32,25 +35,51 @@ const { teams } = require("./lib/commands/teams");
3235
const { users } = require("./lib/commands/users");
3336
const { vcs } = require("./lib/commands/vcs");
3437

38+
inquirer.registerPrompt('search-list', require('inquirer-search-list'));
39+
3540
program
3641
.description(commandDescriptions['main'])
3742
.configureHelp({
3843
helpWidth: process.stdout.columns || 80,
39-
sortSubcommands: true
44+
sortSubcommands: true,
4045
})
41-
.version(version, "-v, --version")
42-
.option("--verbose", "Show complete error log")
43-
.option("--json", "Output in JSON format")
46+
.helpOption('-h, --help', "Display help for command")
47+
.version(version, "-v, --version", "Output the version number")
48+
.option("-V, --verbose", "Show complete error log")
49+
.option("-j, --json", "Output in JSON format")
50+
.hook('preAction', migrate)
51+
.option("-f,--force", "Flag to confirm all warnings")
52+
.option("-a,--all", "Flag to push all resources")
53+
.option("--id [id...]", "Flag to pass a list of ids for a given action")
54+
.option("--report", "Enable reporting in case of CLI errors")
4455
.on("option:json", () => {
4556
cliConfig.json = true;
4657
})
4758
.on("option:verbose", () => {
4859
cliConfig.verbose = true;
4960
})
61+
.on("option:report", function() {
62+
cliConfig.report = true;
63+
cliConfig.reportData = { data: this };
64+
})
65+
.on("option:force", () => {
66+
cliConfig.force = true;
67+
})
68+
.on("option:all", () => {
69+
cliConfig.all = true;
70+
})
71+
.on("option:id", function() {
72+
cliConfig.ids = this.opts().id;
73+
})
5074
.showSuggestionAfterError()
75+
.addCommand(whoami)
76+
.addCommand(register)
5177
.addCommand(login)
5278
.addCommand(init)
79+
.addCommand(pull)
80+
.addCommand(push)
5381
.addCommand(deploy)
82+
.addCommand(run)
5483
.addCommand(logout)
5584
.addCommand(account)
5685
.addCommand(avatars)
@@ -72,5 +101,5 @@ program
72101
.addCommand(vcs)
73102
.addCommand(client)
74103
.parse(process.argv);
75-
76-
process.stdout.columns = oldWidth;
104+
105+
process.stdout.columns = oldWidth;

install.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# You can use "View source" of this page to see the full script.
1414

1515
# REPO
16-
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.5/appwrite-cli-win-x64.exe"
17-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/5.0.5/appwrite-cli-win-arm64.exe"
16+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0/appwrite-cli-win-x64.exe"
17+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0/appwrite-cli-win-arm64.exe"
1818

1919
$APPWRITE_BINARY_NAME = "appwrite.exe"
2020

@@ -85,8 +85,8 @@ function CleanUp {
8585
function InstallCompleted {
8686
Write-Host "[4/4] Finishing Installation ... "
8787
cleanup
88-
Write-Host "🤘 May the force be with you."
8988
Write-Host "To get started with Appwrite CLI, please visit https://appwrite.io/docs/command-line"
89+
Write-Host "As first step, you can login to your Appwrite account using 'appwrite login'"
9090
}
9191

9292

install.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ printSuccess() {
9797
downloadBinary() {
9898
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
9999

100-
GITHUB_LATEST_VERSION="5.0.5"
100+
GITHUB_LATEST_VERSION="6.0.0"
101101
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
102102
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
103103

@@ -145,8 +145,8 @@ cleanup() {
145145
installCompleted() {
146146
echo "[4/4] Wrapping up installation ... "
147147
cleanup
148-
printf "🤘 May the force be with you. \n"
149148
echo "🚀 To get started with Appwrite CLI, please visit https://appwrite.io/docs/command-line"
149+
echo "As first step, you can login to your Appwrite account using 'appwrite login'"
150150
}
151151

152152
# Installation Starts here

lib/client.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ const { fetch, FormData, Agent } = require("undici");
44
const JSONbig = require("json-bigint")({ storeAsString: false });
55
const AppwriteException = require("./exception.js");
66
const { globalConfig } = require("./config.js");
7+
const chalk = require("chalk");
78

89
class Client {
910
CHUNK_SIZE = 5*1024*1024; // 5MB
10-
11+
1112
constructor() {
1213
this.endpoint = 'https://cloud.appwrite.io/v1';
1314
this.headers = {
1415
'content-type': '',
1516
'x-sdk-name': 'Command Line',
1617
'x-sdk-platform': 'console',
1718
'x-sdk-language': 'cli',
18-
'x-sdk-version': '5.0.5',
19-
'user-agent' : `AppwriteCLI/5.0.5 (${os.type()} ${os.version()}; ${os.arch()})`,
20-
'X-Appwrite-Response-Format' : '1.5.0',
19+
'x-sdk-version': '6.0.0',
20+
'user-agent' : `AppwriteCLI/6.0.0 (${os.type()} ${os.version()}; ${os.arch()})`,
21+
'X-Appwrite-Response-Format' : '1.6.0',
2122
};
2223
}
2324

@@ -167,7 +168,7 @@ class Client {
167168

168169
body = formData;
169170
} else {
170-
body = JSON.stringify(params);
171+
body = JSONbig.stringify(params);
171172
}
172173

173174
let response = undefined;
@@ -182,6 +183,11 @@ class Client {
182183
},
183184
}),
184185
});
186+
187+
const warnings = response.headers.get('x-appwrite-warning');
188+
if (warnings) {
189+
warnings.split(';').forEach((warning) => console.warn(warning));
190+
}
185191
} catch (error) {
186192
throw new AppwriteException(error.message);
187193
}
@@ -194,6 +200,14 @@ class Client {
194200
} catch (error) {
195201
throw new AppwriteException(text, response.status, "", text);
196202
}
203+
204+
if (path !== '/account' && json.code === 401 && json.type === 'user_more_factors_required') {
205+
console.log(`${chalk.cyan.bold("ℹ Info")} ${chalk.cyan("Unusable account found, removing...")}`);
206+
207+
const current = globalConfig.getCurrentSession();
208+
globalConfig.setCurrentSession('');
209+
globalConfig.removeSession(current);
210+
}
197211
throw new AppwriteException(json.message, json.code, json.type, json);
198212
}
199213

@@ -210,7 +224,7 @@ class Client {
210224
const text = await response.text();
211225
let json = undefined;
212226
try {
213-
json = JSON.parse(text);
227+
json = JSONbig.parse(text);
214228
} catch (error) {
215229
return text;
216230
}

0 commit comments

Comments
 (0)