Skip to content

Commit

Permalink
Merge pull request #11 from appwrite/dev
Browse files Browse the repository at this point in the history
feat: update version
  • Loading branch information
christyjacob4 authored Jul 7, 2021
2 parents 03de4d4 + 90efaa0 commit f9eb3ae
Show file tree
Hide file tree
Showing 34 changed files with 132 additions and 75 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Appwrite Command Line SDK

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

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

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)
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)

![Appwrite](https://appwrite.io/images/github.png)

Expand Down
17 changes: 17 additions & 0 deletions app/Appwrite/services/account.php → app/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,22 @@
$parser->parseResponse($response);
});

$cli
->task('getSession')
->label('description', "Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used.\n\n")
->param('sessionId', '' , new Wildcard() , 'Session unique ID. Use the string 'current' to get the current device session.', false)
->action(function ( $sessionId ) use ($parser) {
/** @var string $sessionId */

$client = new Client();
$path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}');
$params = [];
$response = $client->call(Client::METHOD_GET, $path, [
'content-type' => 'application/json',
], $params);
$parser->parseResponse($response);
});

$cli
->task('deleteSession')
->label('description', "Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the option id argument, only the session unique ID provider will be deleted.\n\n")
Expand Down Expand Up @@ -343,6 +359,7 @@
Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.",
"getSessions" => "Get currently logged in user list of active sessions across different devices.",
"deleteSessions" => "Delete all sessions from the user account and remove any sessions cookies from the end client.",
"getSession" => "Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used.",
"deleteSession" => "Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the option id argument, only the session unique ID provider will be deleted.",
"createVerification" => "Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](/docs/client/account#accountUpdateVerification). The verification link sent to the user's email address is valid for 7 days.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions app/Appwrite/services/client.php → app/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@
$cli
->task('version')
->action(function() {
Console::log('CLI Version : 0.10.0');
Console::log('Server Version : 0.8.0');
Console::log('CLI Version : 0.11.0');
Console::log('Server Version : 0.9.0');
});


Expand Down
File renamed without changes.
17 changes: 9 additions & 8 deletions app/Appwrite/services/functions.php → app/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
->label('description', "Create a new function. You can pass a list of [permissions](/docs/permissions) to allow different project users or team with access to execute the function using the client API.\n\n")
->param('name', '' , new Wildcard() , 'Function name. Max length: 128 chars.', false)
->param('execute', '' , new Wildcard() , 'An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', false)
->param('env', '' , new Wildcard() , 'Execution enviornment.', false)
->param('runtime', '' , new Wildcard() , 'Execution runtime.', false)
->param('vars', [] , new Wildcard() , 'Key-value JSON object.', true)
->param('events', [] , new Wildcard() , 'Events list.', true)
->param('schedule', '' , new Wildcard() , 'Schedule CRON syntax.', true)
->param('timeout', 15 , new Wildcard() , 'Function maximum execution time in seconds.', true)
->action(function ( $name, $execute, $env, $vars, $events, $schedule, $timeout ) use ($parser) {
->action(function ( $name, $execute, $runtime, $vars, $events, $schedule, $timeout ) use ($parser) {
/** @var string $name */
/** @var array $execute */
/** @var string $env */
/** @var string $runtime */
/** @var object $vars */
/** @var array $events */
/** @var string $schedule */
Expand All @@ -94,7 +94,7 @@
/** Body Params */
$params['name'] = $name;
$params['execute'] = !is_array($execute) ? array($execute) : $execute;
$params['env'] = $env;
$params['runtime'] = $runtime;
$params['vars'] = $vars;
$params['events'] = !is_array($events) ? array($events) : $events;
$params['schedule'] = $schedule;
Expand Down Expand Up @@ -308,14 +308,15 @@
$params = [];
/** Body Params */
$params['command'] = $command;
$cloudFunctionPath = realpath(__DIR__.'/../../../files/'.$code);
$cloudFunctionParentDir = dirname($cloudFunctionPath, 1);
$cloudFunctionDirName = basename($cloudFunctionPath);
$code = \urldecode($code);
$cloudFunctionPath = realpath(__DIR__.'/../files/'.$code);
$cloudFunctionParentDir = escapeshellarg(dirname($cloudFunctionPath, 1));
$cloudFunctionDirName = escapeshellarg(basename($cloudFunctionPath));
if (file_exists($cloudFunctionPath) === false ) {
throw new Exception("Path doesn't exist. Please ensure that the path is within the current directory. ");
}
$archiveName = 'code.tar.gz';
$volumeMountPoint = realpath(__DIR__.'/../../../files/');
$volumeMountPoint = realpath(__DIR__.'/../files/');
exec("tar -zcvf $archiveName -C $cloudFunctionParentDir $cloudFunctionDirName && mv $archiveName $volumeMountPoint");
$archivePath = realpath($volumeMountPoint."/$archiveName");
$cFile = new \CURLFile($archivePath, 'application/x-gzip' , basename($archivePath));
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/Appwrite/services/init.php → app/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Utopia\CLI\Console;
use Appwrite\Parser;

const USER_PREFERENCES_FILE = __DIR__."/../../.preferences/.prefs.json";
const USER_PREFERENCES_FILE = __DIR__."/.preferences/.prefs.json";
const PREFERENCE_ENDPOINT = "endpoint";

/**
Expand Down
File renamed without changes.
7 changes: 5 additions & 2 deletions app/Appwrite/services/storage.php → app/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
$path = str_replace([], [], '/storage/files');
$params = [];
/** Body Params */
$file = realpath(__DIR__.'/../../../files/'.$file);
$file = realpath(__DIR__.'/../files/'.\urldecode($file));
if (file_exists($file) === false ) {
throw new Exception("Path doesn't exist. Please ensure that the path is within the current directory. ");
}
Expand Down Expand Up @@ -175,6 +175,7 @@
->param('fileId', '' , new Wildcard() , 'File unique ID', false)
->param('width', 0 , new Wildcard() , 'Resize preview image width, Pass an integer between 0 to 4000.', true)
->param('height', 0 , new Wildcard() , 'Resize preview image height, Pass an integer between 0 to 4000.', true)
->param('gravity', 'center' , new Wildcard() , 'Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right', true)
->param('quality', 100 , new Wildcard() , 'Preview image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
->param('borderWidth', 0 , new Wildcard() , 'Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.', true)
->param('borderColor', '' , new Wildcard() , 'Preview image border color. Use a valid HEX color, no # is needed for prefix.', true)
Expand All @@ -183,10 +184,11 @@
->param('rotation', 0 , new Wildcard() , 'Preview image rotation in degrees. Pass an integer between 0 and 360.', true)
->param('background', '' , new Wildcard() , 'Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.', true)
->param('output', '' , new Wildcard() , 'Output format type (jpeg, jpg, png, gif and webp).', true)
->action(function ( $fileId, $width, $height, $quality, $borderWidth, $borderColor, $borderRadius, $opacity, $rotation, $background, $output ) use ($parser) {
->action(function ( $fileId, $width, $height, $gravity, $quality, $borderWidth, $borderColor, $borderRadius, $opacity, $rotation, $background, $output ) use ($parser) {
/** @var string $fileId */
/** @var integer $width */
/** @var integer $height */
/** @var string $gravity */
/** @var integer $quality */
/** @var integer $borderWidth */
/** @var string $borderColor */
Expand All @@ -202,6 +204,7 @@
/** Query Params */
$params['width'] = $width;
$params['height'] = $height;
$params['gravity'] = $gravity;
$params['quality'] = $quality;
$params['borderWidth'] = $borderWidth;
$params['borderColor'] = $borderColor;
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions app/Appwrite/services/users.php → app/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,26 @@
$parser->parseResponse($response);
});

$cli
->task('updateVerification')
->label('description', "Update the user email verification status by its unique ID.\n\n")
->param('userId', '' , new Wildcard() , 'User unique ID.', false)
->param('emailVerification', '' , new Wildcard() , 'User Email Verification Status.', false)
->action(function ( $userId, $emailVerification ) use ($parser) {
/** @var string $userId */
/** @var boolean $emailVerification */

$client = new Client();
$path = str_replace(['{userId}'], [$userId], '/users/{userId}/verification');
$params = [];
/** Body Params */
$params['emailVerification'] = $emailVerification;
$response = $client->call(Client::METHOD_PATCH, $path, [
'content-type' => 'application/json',
], $params);
$parser->parseResponse($response);
});


$cli
->task('help')
Expand All @@ -273,6 +293,7 @@
"deleteSessions" => "Delete all user's sessions by using the user's unique ID.",
"deleteSession" => "Delete a user sessions by its unique ID.",
"updateStatus" => "Update the user status by its unique ID.",
"updateVerification" => "Update the user email verification status by its unique ID.",
];
$parser->formatArray($commands);
Console::log("\nRun 'appwrite users COMMAND --help' for more information on a command.");
Expand Down
4 changes: 2 additions & 2 deletions bin/account
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [[ $# -eq 0 ]]; then
php /usr/local/code/app/Appwrite/services/account.php help
php /usr/local/code/app/account.php help
else
php /usr/local/code/app/Appwrite/services/account.php $@
php /usr/local/code/app/account.php $@
fi
4 changes: 2 additions & 2 deletions bin/avatars
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [[ $# -eq 0 ]]; then
php /usr/local/code/app/Appwrite/services/avatars.php help
php /usr/local/code/app/avatars.php help
else
php /usr/local/code/app/Appwrite/services/avatars.php $@
php /usr/local/code/app/avatars.php $@
fi
4 changes: 2 additions & 2 deletions bin/client
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [[ $# -eq 0 ]]; then
php /usr/local/code/app/Appwrite/services/client.php help
php /usr/local/code/app/client.php help
else
php /usr/local/code/app/Appwrite/services/client.php $@
php /usr/local/code/app/client.php $@
fi
4 changes: 2 additions & 2 deletions bin/database
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [[ $# -eq 0 ]]; then
php /usr/local/code/app/Appwrite/services/database.php help
php /usr/local/code/app/database.php help
else
php /usr/local/code/app/Appwrite/services/database.php $@
php /usr/local/code/app/database.php $@
fi
4 changes: 2 additions & 2 deletions bin/functions
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [[ $# -eq 0 ]]; then
php /usr/local/code/app/Appwrite/services/functions.php help
php /usr/local/code/app/functions.php help
else
php /usr/local/code/app/Appwrite/services/functions.php $@
php /usr/local/code/app/functions.php $@
fi
4 changes: 2 additions & 2 deletions bin/health
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [[ $# -eq 0 ]]; then
php /usr/local/code/app/Appwrite/services/health.php help
php /usr/local/code/app/health.php help
else
php /usr/local/code/app/Appwrite/services/health.php $@
php /usr/local/code/app/health.php $@
fi
2 changes: 1 addition & 1 deletion bin/help
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

php /usr/local/code/app/Appwrite/services/help.php $@
php /usr/local/code/app/help.php $@
2 changes: 1 addition & 1 deletion bin/init
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

php /usr/local/code/app/Appwrite/services/init.php init $@
php /usr/local/code/app/init.php init $@
4 changes: 2 additions & 2 deletions bin/locale
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [[ $# -eq 0 ]]; then
php /usr/local/code/app/Appwrite/services/locale.php help
php /usr/local/code/app/locale.php help
else
php /usr/local/code/app/Appwrite/services/locale.php $@
php /usr/local/code/app/locale.php $@
fi
4 changes: 2 additions & 2 deletions bin/storage
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [[ $# -eq 0 ]]; then
php /usr/local/code/app/Appwrite/services/storage.php help
php /usr/local/code/app/storage.php help
else
php /usr/local/code/app/Appwrite/services/storage.php $@
php /usr/local/code/app/storage.php $@
fi
4 changes: 2 additions & 2 deletions bin/teams
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [[ $# -eq 0 ]]; then
php /usr/local/code/app/Appwrite/services/teams.php help
php /usr/local/code/app/teams.php help
else
php /usr/local/code/app/Appwrite/services/teams.php $@
php /usr/local/code/app/teams.php $@
fi
4 changes: 2 additions & 2 deletions bin/users
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [[ $# -eq 0 ]]; then
php /usr/local/code/app/Appwrite/services/users.php help
php /usr/local/code/app/users.php help
else
php /usr/local/code/app/Appwrite/services/users.php $@
php /usr/local/code/app/users.php $@
fi
2 changes: 1 addition & 1 deletion bin/version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

php /usr/local/code/app/Appwrite/services/client.php version
php /usr/local/code/app/client.php version
1 change: 1 addition & 0 deletions docs/examples/account/get-session.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
appwrite account getSession --sessionId="[SESSION_ID]"
2 changes: 1 addition & 1 deletion docs/examples/functions/create.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
appwrite functions create --name="[NAME]" --execute="" --env="dotnet-3.1" --vars="{}" --events="" --schedule="" --timeout="1"
appwrite functions create --name="[NAME]" --execute="" --runtime="java-11.0" --vars="{}" --events="" --schedule="" --timeout="1"
2 changes: 1 addition & 1 deletion docs/examples/storage/get-file-preview.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
appwrite storage getFilePreview --fileId="[FILE_ID]" --width="0" --height="0" --quality="0" --borderWidth="0" --borderColor="" --borderRadius="0" --opacity="0" --rotation="0" --background="" --output="jpg"
appwrite storage getFilePreview --fileId="[FILE_ID]" --width="0" --height="0" --gravity="center" --quality="0" --borderWidth="0" --borderColor="" --borderRadius="0" --opacity="0" --rotation="0" --background="" --output="jpg"
1 change: 1 addition & 0 deletions docs/examples/users/update-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
appwrite users updateVerification --userId="[USER_ID]" --emailVerification=""
2 changes: 1 addition & 1 deletion install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $APPWRITE_EXECUTABLE_FILEPATH = Join-Path -Path $APPWRITE_INSTALL_DIR -ChildPath
$APPWRITE_CLI_IMAGE_NAME = "appwrite/cli"

# Appwrite CLI image version
$APPWRITE_CLI_IMAGE_VERSION = "0.10.0"
$APPWRITE_CLI_IMAGE_VERSION = "0.11.0"

$APPWRITE_EXECUTABLE_CONTENT = @"
`$allowList = 'version', 'help', 'init', 'client' , 'account', 'avatars', 'database', 'functions', 'health', 'locale', 'storage', 'teams', 'users'
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ APPWRITE_TEMP_NAME=temp
APPWRITE_CLI_IMAGE_NAME=appwrite/cli

# Appwrite CLI image version
APPWRITE_CLI_IMAGE_VERSION=0.10.0
APPWRITE_CLI_IMAGE_VERSION=0.11.0

# sudo is required to copy executable to APPWRITE_INSTALL_DIR for linux
USE_SUDO="false"
Expand Down Expand Up @@ -147,7 +147,7 @@ for x in "${@}" ; do
_args=$_args" "$x
done
bash -c "docker run -i --rm --volume appwrite-cli:/usr/local/code/app/.preferences/ --volume $(pwd):/usr/local/code/files:rw --network host '$APPWRITE_CLI_IMAGE_NAME:$APPWRITE_CLI_IMAGE_VERSION' $_args" ' > $APPWRITE_TEMP_NAME
bash -c "docker run -i --rm --volume appwrite-cli:/usr/local/code/app/.preferences/ --volume \"$PWD\":/usr/local/code/files:rw --network host '$APPWRITE_CLI_IMAGE_NAME:$APPWRITE_CLI_IMAGE_VERSION' $_args" ' > $APPWRITE_TEMP_NAME

printf "${GREEN}🚧 Setting Permissions ${NC}\n"
chmod +x $APPWRITE_TEMP_NAME
Expand Down
Loading

0 comments on commit f9eb3ae

Please sign in to comment.