From 15d6932a4c986fa0a1a739b61f6385220b87a42b Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 3 Jan 2022 00:40:42 +0400 Subject: [PATCH 1/7] feat: update cli docs --- app/views/docs/command-line.phtml | 138 ++++++++++++++++++++++++------ 1 file changed, 113 insertions(+), 25 deletions(-) diff --git a/app/views/docs/command-line.phtml b/app/views/docs/command-line.phtml index 85b24828c..a2902eb2b 100644 --- a/app/views/docs/command-line.phtml +++ b/app/views/docs/command-line.phtml @@ -1,67 +1,148 @@ -

The Appwrite CLI is a command-line application that allows you to interact with the Appwrite server-side APIs and perform server-side tasks quickly using your terminal. A few examples of these tasks including managing resources (documents, files, users), executing and packaging Cloud Functions, and any other operation available through the Appwrite API.

+

The Appwrite CLI is a command-line application that allows you to interact with the Appwrite server and perform server-side tasks quickly using your terminal. This includes creating and managing projects, managing resources (documents, files, users), creating and deploying Cloud Functions, and other operations available through Appwrite's API.

-

Getting started

+

Installation

-

The Appwrite CLI installation is extremely easy and fast. The CLI is packaged as a Docker container, which makes it secure by default, requires no dependencies but Docker, and truly platform and language agnostic.

+

The Appwrite CLI installation is extremely easy and fast. The CLI is packaged both as an npm module as well as a standalone binary for your operating system, making it completely dependency free, platform independent and language agnostic.

-

The next step is to have your Appwrite server running. You can grab our simple installation command and execute it.

+

The next step is to have your Appwrite server running. You can grab our simple installation command and execute it. Now, we're all set to play around with the CLI.

-

Next, head over to http://localhost and create a project in the Appwrite Console, create an API key, and we're good to play around with the CLI.

+

Install with npm

-

Installation

+

If you have npm set up, installing the CLI is as simple as running

-

To install the CLI, we recommend running the installation script for your operating system.

+
+
+        
+            npm install -g appwrite-cli
+        
+    
+
+ + +

Install with script

+ +

For a completely dependency-free installation, the CLI also ships with a convenient installation script for your operating system

-

Once the setup is complete, you can validate your installation using:

+

Once the installation is complete, you can verify the install using

+ +
+
appwrite -v
+
+ +

Getting Started

+ +

Before you can use the CLI, you need to login to your Appwrite account using

+ +
+
appwrite login
+
+ +

Initialising your project

+ +

Once logged in, the CLI needs to be initialised before you can use it with your Appwrite project. You can do this with the `appwrite init project` command.

+ +
+
appwrite init project
+
+ +

The following prompt will guide you through the setup process. The init command also creates an appwrite.json file representing your Appwrite project. The `appwrite.json` file does a lot of things.

+ + + +

You can also fetch all the collections in your current project using

+ +
+
appwrite init collection
+
+ +

The CLI also comes with a convenient `--all` flag to perform both these steps at once using

+ +
+
appwrite init --all
+
+ +

Deploying cloud functions

+ +

The CLI makes it extremely easy to create and deploy Appwrite's cloud functions. Initialise your new function using

+ +
+

+appwrite init function
+? What would you like to name your function? My Awesome Function
+? What runtime would you like to use? Node.js (node-15.5)
+✓ Success
+
+ +

This will create a new function `My Awesome Function` in your current Appwrite project and also create a template function for you to get started. You can now deploy this function using

+ +
+
appwrite deploy function
+
+ +

Deploying collections

+ +

The Appwrite CLI also makes it extremely easy to migrate your project from a development server to a production server using the CLI. You can deploy all the collections in your appwrite.json file using

-
appwrite version
+
appwrite deploy collections
-

To start using the CLI with your project, you will first need to initialize the CLI with:

+

The `deploy` command also comes with a convenient `--all` flag to deploy all your functions and collections at once.

-
appwrite init
+
appwrite deploy --all
-

Great! Now you're all set to use the Appwrite CLI. You can access your CLI using the following general syntax:

+
+

Self Signed Certificates

+

By default, requests to domains with self signed SSL certificates (or no certificates) are disabled. If you trust the domain, you can bypass the certificate validation using

+
+
appwrite client --selfSigned true
+
+
+ +

Usage Examples

+ +

The Appwrite CLI follows the following general syntax.

appwrite [SERVICE] [COMMAND] --[OPTIONS]
-

Examples

+

Here are a few sample commands to get you started

Create User

To create a new user in your project, you can use the `create` command. To successfully create a user, make sure your API key is granted with the scope "users.write".

-
appwrite users create --email="hello@appwrite.io" --password="my-secret"
+
appwrite users create --userId "unique()" --email hello@appwrite.io --password very_strong_password
@@ -88,20 +169,27 @@

To get more information on a particular collection, you can make use of the `getCollection` command and pass in the `collectionId`. To successfully fetch the collection, make sure your API key is granted with the scope "collections.read".

-
appwrite database getCollection --collectionId=5ff468cfa32a0
+
appwrite database getCollection --collectionId 5ff468cfa32a0
+
+ +

Create Document

+ +

To create a new document in an existing collection, you can use the `createDocument` command.

+ +
+
appwrite database createDocument --collectionId  --documentId 'unique()' --data '{ "Name": "Iron Man" }' --read role:all team:abc
-

Configuration

-

At any point, if you would like to change your project endpoint, project ID, project Key, selfSigned certificate acceptance or locale configuration you set during the CLI init, you can make use of the `client` service.

+

At any point, if you would like to change your server endpoint, project key or selfSigned certificate acceptance, you can use of the `client` service.

-
appwrite client setEndpoint --endpoint="http://192.168.1.6/v1"
-appwrite client setProject --project="5ff450422d42f"
-appwrite client setKey --key="23f24gwrhSDgefaY"
-appwrite client setSelfSigned --value=true
-appwrite client setLocale --locale="en-US"
+

+appwrite client --endpoint http://192.168.1.6/v1
+appwrite client --key 23f24gwrhSDgefaY
+appwrite client --selfSigned true
+

Help

From 139ba647d8a7a0ae2426e07276ff269664530349 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 30 Jan 2022 02:46:40 +0400 Subject: [PATCH 2/7] feat: add error codes --- app/views/docs/error-codes.phtml | 39 +++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/app/views/docs/error-codes.phtml b/app/views/docs/error-codes.phtml index 95f6f712e..fc475e22a 100644 --- a/app/views/docs/error-codes.phtml +++ b/app/views/docs/error-codes.phtml @@ -1,3 +1,7 @@ +getParam('errorCodes', []); +?> +

Appwrite uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, invalid input, etc.). Codes in the 5xx range indicate an error with the Appwrite server, but these are rare.

@@ -15,6 +19,12 @@ + + + + + + @@ -106,4 +116,31 @@ "code": 400 } - \ No newline at end of file + + +

Error Codes

+ +

Appwrite also passes convennient error codes in addition to the http status code to help you get more fine grained control over what went wrong and allowing you to display relevant error messages.

+ +
Success!
201CreatedThe requested resource has been created successfully.
204 No Content
+ + + + + + + + + + + + + + + + + + +
Error CodeDescription
+ APPWRITE_FUNCTION_ID + Your function's unique ID.
\ No newline at end of file From 90a101234a269190c92b3a2d15b7ad1315e9d3ac Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 30 Jan 2022 03:03:59 +0400 Subject: [PATCH 3/7] fix: add status code --- app/views/docs/error-codes.phtml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/views/docs/error-codes.phtml b/app/views/docs/error-codes.phtml index fc475e22a..7e5a06b74 100644 --- a/app/views/docs/error-codes.phtml +++ b/app/views/docs/error-codes.phtml @@ -125,20 +125,16 @@ $errorCodes = $this->getParam('errorCodes', []); - + + - - - - + From fc6c4ae832b458ab0314530c66fedaf534cb2e48 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 30 Jan 2022 03:07:42 +0400 Subject: [PATCH 4/7] fix: adjust column widths --- app/views/docs/error-codes.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/docs/error-codes.phtml b/app/views/docs/error-codes.phtml index 7e5a06b74..5c3a79187 100644 --- a/app/views/docs/error-codes.phtml +++ b/app/views/docs/error-codes.phtml @@ -125,8 +125,8 @@ $errorCodes = $this->getParam('errorCodes', []);
Error CodeCodeHTTP Status Code Description
- APPWRITE_FUNCTION_ID - Your function's unique ID.
- - + + From bbb609e4913ec007aa0355628979ffd51abc273a Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 30 Jan 2022 03:09:15 +0400 Subject: [PATCH 5/7] feat: spelling errors --- app/views/docs/error-codes.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/docs/error-codes.phtml b/app/views/docs/error-codes.phtml index 5c3a79187..aa0860bd4 100644 --- a/app/views/docs/error-codes.phtml +++ b/app/views/docs/error-codes.phtml @@ -120,7 +120,7 @@ $errorCodes = $this->getParam('errorCodes', []);

Error Codes

-

Appwrite also passes convennient error codes in addition to the http status code to help you get more fine grained control over what went wrong and allowing you to display relevant error messages.

+

Appwrite also passes convenient error codes in addition to the http status code to help you get more fine grained control over what went wrong and allowing you to display relevant error messages.

CodeHTTP Status CodeCodeHTTP Status Description
From 69a1d38168e0610599bc5fe214152b6999fb5a9c Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 7 Feb 2022 02:57:41 +0400 Subject: [PATCH 6/7] feat: update code --- app/views/docs/error-codes.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/docs/error-codes.phtml b/app/views/docs/error-codes.phtml index aa0860bd4..8bbf8dd4c 100644 --- a/app/views/docs/error-codes.phtml +++ b/app/views/docs/error-codes.phtml @@ -134,7 +134,7 @@ $errorCodes = $this->getParam('errorCodes', []); - + From ae2f7943da5d9b07712f880e7828fba6ac7ef671 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 7 Feb 2022 02:58:18 +0400 Subject: [PATCH 7/7] feat: update code --- app/views/docs/error-codes.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/docs/error-codes.phtml b/app/views/docs/error-codes.phtml index 8bbf8dd4c..511532923 100644 --- a/app/views/docs/error-codes.phtml +++ b/app/views/docs/error-codes.phtml @@ -120,7 +120,7 @@ $errorCodes = $this->getParam('errorCodes', []);

Error Codes

-

Appwrite also passes convenient error codes in addition to the http status code to help you get more fine grained control over what went wrong and allowing you to display relevant error messages.

+

Appwrite also passes convenient error codes in addition to the http status codes to help you get more fine grained control over what went wrong and allowing you to display relevant error messages.