Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions templates/cli/app/services/help.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

namespace {{ spec.title | caseUcfirst }}\Services;

printf("
echo "\e[0;31;m
_ _ _
/_\ _ __ _ ____ ___ __(_) |_ ___
//_\\| '_ \| '_ \ \ /\ / / '__| | __/ _ \
/ _ \ |_) | |_) \ V V /| | | | || __/
\_/ \_/ .__/| .__/ \_/\_/ |_| |_|\__\___|
|_| |_|

");
\e[0m" ;

printf("\nUsage : appwrite [SERVICE] [COMMAND] --[OPTION]\n\n");
printf("Services :\n");
$mask = "\t%-20.20s %-125.125s\n";
Expand Down
31 changes: 20 additions & 11 deletions templates/cli/app/services/service.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,31 @@ $cli

{% for parameter in method.parameters.body %}

{% if parameter.type == 'file' %}
{% if parameter.type == 'file' and method.packaging %}
$cloudFunctionPath = realpath(__DIR__.'/../../../files/'.${{ parameter.name | caseCamel }});
$cloudFunctionParentDir = dirname($cloudFunctionPath, 1);
$cloudFunctionDirName = basename(${{ parameter.name | caseCamel }});
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/');
exec("tar -zcvf $archiveName -C ${cloudFunctionParentDir} $cloudFunctionDirName && mv ${archiveName} ${volumeMountPoint}");
$archivePath = realpath($volumeMountPoint."/$archiveName");$archivePath = realpath($volumeMountPoint."/$archiveName");
$cFile = new \CURLFile($archivePath, 'application/x-gzip' , basename($archivePath));

$params['{{ parameter.name }}'] = $cFile;

{% elseif parameter.type == 'file' %}

${{ parameter.name | caseCamel }} = realpath(__DIR__.'/../../../files/'.${{ parameter.name | caseCamel }});
if (file_exists(${{ parameter.name | caseCamel }}) === false ) {
throw new Exception("Path doesn't exist. Please ensure that the path is within the current directory. ");
}
{% if method.packaging %}
$archive_file_name = '{{ parameter.name | caseCamel }}.tar';
$archive_file_path = dirname(${{ parameter.name | caseCamel }}, 1)."/${archive_file_name}";
$archive = new PharData($archive_file_path);
$archive->buildFromDirectory(${{ parameter.name | caseCamel }});
$archive->compress(Phar::GZ);
${{ parameter.name | caseCamel }} = $archive_file_path.'.gz';
{% endif %}

$cFile = new \CURLFile(${{ parameter.name | caseCamel }}, {% if method.packaging %} 'application/x-gzip' {% else %} 'image/png' {% endif %}, basename(${{ parameter.name | caseCamel }}));
$params['{{ parameter.name }}'] = $cFile;

{% else %}
$params['{{ parameter.name }}'] = ${{ parameter.name | caseCamel }};
{% endif %}
Expand Down Expand Up @@ -117,8 +127,7 @@ $cli
{% endif %}

{% if method.packaging %}
unlink($archive_file_path); // as we already obtained a tar.gz
unlink($archive_file_path.'.gz');
unlink($archivePath);
{% endif %}
});

Expand Down