Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat-multiple-accounts-and-insta…
Browse files Browse the repository at this point in the history
…nces' into feat-cli-local-development
  • Loading branch information
Meldiron committed Jun 4, 2024
2 parents 93ea80a + 3621c3c commit 7583db3
Show file tree
Hide file tree
Showing 72 changed files with 2,514 additions and 978 deletions.
35 changes: 34 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,40 @@ jobs:
fail-fast: false
matrix:
php-version: ['8.2']
sdk: [Android5Java17, Android14Java17, CLINode16, CLINode18, DartBeta, DartStable, Deno1193, Deno1303, DotNet60, DotNet70, FlutterStable, FlutterBeta, Go112, Go118, KotlinJava8, KotlinJava11, KotlinJava17, Node16, Node18, Node20, PHP74, PHP80, Python38, Python39, Python310, Ruby27, Ruby30, Ruby31, AppleSwift56, Swift56, WebChromium, WebNode]
sdk: [
Android5Java17,
Android14Java17,
CLINode16,
CLINode18,
DartBeta,
DartStable,
Deno1193,
Deno1303,
DotNet60,
DotNet80,
FlutterStable,
FlutterBeta,
Go112,
Go118,
KotlinJava8,
KotlinJava11,
KotlinJava17,
Node16,
Node18,
Node20,
PHP74,
PHP80,
Python38,
Python39,
Python310,
Ruby27,
Ruby30,
Ruby31,
AppleSwift56,
Swift56,
WebChromium,
WebNode
]

steps:
- name: Checkout repository
Expand Down
2 changes: 0 additions & 2 deletions mock-server/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
mockapi:
container_name: mockapi
Expand Down
9 changes: 9 additions & 0 deletions src/SDK/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ public function getFilters(): array
return [];
}

/**
* Language specific functions.
* @return array
*/
public function getFunctions(): array
{
return [];
}

protected function toPascalCase(string $value): string
{
return \ucfirst($this->toCamelCase($value));
Expand Down
77 changes: 77 additions & 0 deletions src/SDK/Language/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,66 @@

namespace Appwrite\SDK\Language;

use Twig\TwigFunction;

class CLI extends Node
{
/**
* List of functions to ignore for console preview.
* @var array
*/
private $consoleIgnoreFunctions = [
'listidentities',
'listmfafactors',
'getprefs',
'getsession',
'getattribute',
'listdocumentlogs',
'getindex',
'listcollectionlogs',
'getcollectionusage',
'listlogs',
'listruntimes',
'getusage',
'getusage',
'listvariables',
'getvariable',
'listproviderlogs',
'listsubscriberlogs',
'getsubscriber',
'listtopiclogs',
'getemailtemplate',
'getsmstemplate',
'getfiledownload',
'getfilepreview',
'getfileview',
'getusage',
'listlogs',
'getprefs',
'getusage',
'listlogs',
'getmembership',
'listmemberships',
'listmfafactors',
'getmfarecoverycodes',
'getprefs',
'listtargets',
'gettarget',
];

/**
* List of SDK services to ignore for console preview.
* @var array
*/
private $consoleIgnoreServices = [
'health',
'migrations',
'locale',
'avatars',
'project',
'proxy',
'vcs'
];
/**
* @var array
*/
Expand Down Expand Up @@ -172,6 +230,11 @@ public function getFiles(): array
'destination' => 'lib/utils.js',
'template' => 'cli/lib/utils.js.twig',
],
[
'scope' => 'default',
'destination' => 'lib/commands/init.js',
'template' => 'cli/lib/commands/init.js.twig',
],
[
'scope' => 'default',
'destination' => 'lib/commands/pull.js',
Expand Down Expand Up @@ -290,4 +353,18 @@ public function getParamExample(array $param): string

return $output;
}

/**
* Language specific filters.
* @return array
*/
public function getFunctions(): array
{
return [
/** Return true if the entered service->method is enabled for a console preview link */
new TwigFunction('methodHaveConsolePreview', fn($method, $service) => preg_match('/^([Gg]et|[Ll]ist)/', $method)
&& !in_array(strtolower($method), $this->consoleIgnoreFunctions)
&& !in_array($service, $this->consoleIgnoreServices)),
];
}
}
9 changes: 7 additions & 2 deletions src/SDK/Language/Dart.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,13 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'dart/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'dart/.github/workflows/publish.yml.twig',
],
[
'scope' => 'default',
'destination' => '.github/workflows/format.yml',
'template' => 'dart/.github/workflows/format.yml.twig',
],
[
'scope' => 'default',
Expand Down
76 changes: 38 additions & 38 deletions src/SDK/Language/DotNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ public function getFiles(): array
return [
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'dotnet/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'dotnet/.github/workflows/publish.yml.twig',
],
[
'scope' => 'default',
Expand Down Expand Up @@ -333,93 +333,93 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}.sln',
'template' => 'dotnet/src/Appwrite.sln',
'destination' => '{{ spec.title | caseUcfirst }}.sln',
'template' => 'dotnet/Package.sln',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/{{ spec.title | caseUcfirst }}.csproj',
'template' => 'dotnet/src/Appwrite/Appwrite.csproj.twig',
'destination' => '{{ spec.title | caseUcfirst }}/{{ spec.title | caseUcfirst }}.csproj',
'template' => 'dotnet/Package/Package.csproj.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Client.cs',
'template' => 'dotnet/src/Appwrite/Client.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Client.cs',
'template' => 'dotnet/Package/Client.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/{{ spec.title | caseUcfirst }}Exception.cs',
'template' => 'dotnet/src/Appwrite/Exception.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/{{ spec.title | caseUcfirst }}Exception.cs',
'template' => 'dotnet/Package/Exception.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/ID.cs',
'template' => 'dotnet/src/Appwrite/ID.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/ID.cs',
'template' => 'dotnet/Package/ID.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Permission.cs',
'template' => 'dotnet/src/Appwrite/Permission.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Permission.cs',
'template' => 'dotnet/Package/Permission.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Query.cs',
'template' => 'dotnet/src/Appwrite/Query.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Query.cs',
'template' => 'dotnet/Package/Query.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Role.cs',
'template' => 'dotnet/src/Appwrite/Role.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Role.cs',
'template' => 'dotnet/Package/Role.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Converters/ValueClassConverter.cs',
'template' => 'dotnet/src/Appwrite/Converters/ValueClassConverter.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Converters/ValueClassConverter.cs',
'template' => 'dotnet/Package/Converters/ValueClassConverter.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Extensions/Extensions.cs',
'template' => 'dotnet/src/Appwrite/Extensions/Extensions.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Extensions/Extensions.cs',
'template' => 'dotnet/Package/Extensions/Extensions.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Models/OrderType.cs',
'template' => 'dotnet/src/Appwrite/Models/OrderType.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Models/OrderType.cs',
'template' => 'dotnet/Package/Models/OrderType.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Models/UploadProgress.cs',
'template' => 'dotnet/src/Appwrite/Models/UploadProgress.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Models/UploadProgress.cs',
'template' => 'dotnet/Package/Models/UploadProgress.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Models/InputFile.cs',
'template' => 'dotnet/src/Appwrite/Models/InputFile.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Models/InputFile.cs',
'template' => 'dotnet/Package/Models/InputFile.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Services/Service.cs',
'template' => 'dotnet/src/Appwrite/Services/Service.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Services/Service.cs',
'template' => 'dotnet/Package/Services/Service.cs.twig',
],
[
'scope' => 'service',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Services/{{service.name | caseUcfirst}}.cs',
'template' => 'dotnet/src/Appwrite/Services/ServiceTemplate.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Services/{{service.name | caseUcfirst}}.cs',
'template' => 'dotnet/Package/Services/ServiceTemplate.cs.twig',
],
[
'scope' => 'definition',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Models/{{ definition.name | caseUcfirst | overrideIdentifier }}.cs',
'template' => 'dotnet/src/Appwrite/Models/Model.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Models/{{ definition.name | caseUcfirst | overrideIdentifier }}.cs',
'template' => 'dotnet/Package/Models/Model.cs.twig',
],
[
'scope' => 'enum',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Enums/{{ enum.name | caseUcfirst | overrideIdentifier }}.cs',
'template' => 'dotnet/src/Appwrite/Enums/Enum.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Enums/{{ enum.name | caseUcfirst | overrideIdentifier }}.cs',
'template' => 'dotnet/Package/Enums/Enum.cs.twig',
],
[
'scope' => 'default',
'destination' => '/src/{{ spec.title | caseUcfirst }}/Enums/IEnum.cs',
'template' => 'dotnet/src/Appwrite/Enums/IEnum.cs.twig',
'destination' => '{{ spec.title | caseUcfirst }}/Enums/IEnum.cs',
'template' => 'dotnet/Package/Enums/IEnum.cs.twig',
]
];
}
Expand Down
9 changes: 7 additions & 2 deletions src/SDK/Language/Flutter.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,13 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'flutter/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'flutter/.github/workflows/publish.yml.twig',
],
[
'scope' => 'default',
'destination' => '.github/workflows/format.yml',
'template' => 'flutter/.github/workflows/format.yml.twig',
],
[
'scope' => 'enum',
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'node/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'node/.github/workflows/publish.yml.twig',
],
[
'scope' => 'enum',
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Python.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'python/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'python/.github/workflows/publish.yml.twig',
],
[
'scope' => 'enum',
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Ruby.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'ruby/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'ruby/.github/workflows/publish.yml.twig',
],
[
'scope' => 'definition',
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Language/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public function getFiles(): array
],
[
'scope' => 'default',
'destination' => '.travis.yml',
'template' => 'web/.travis.yml.twig',
'destination' => '.github/workflows/publish.yml',
'template' => 'web/.github/workflows/publish.yml.twig',
],
[
'scope' => 'enum',
Expand Down
7 changes: 7 additions & 0 deletions src/SDK/SDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ public function __construct(Language $language, Spec $spec)
'debug' => true
]);

/**
* Add language-specific functions
*/
foreach ($this->language->getFunctions() as $function) {
$this->twig->addFunction($function);
}

/**
* Add language specific filters
*/
Expand Down
Loading

0 comments on commit 7583db3

Please sign in to comment.