Skip to content

Commit ba59b6b

Browse files
committed
Merge remote-tracking branch 'origin/feat-cli-g2' into fix-cli-aliases
2 parents 2ac1569 + 2014675 commit ba59b6b

File tree

76 files changed

+2621
-979
lines changed

Some content is hidden

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

76 files changed

+2621
-979
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CLI beta Publish
2+
on:
3+
pull_request:
4+
paths:
5+
- 'templates/cli/**.twig'
6+
- 'src/SDK/Language/CLI.php'
7+
8+
env:
9+
PACKAGE_NAME: "${{ vars.PACKAGE_NAME }}@0.16.0${{ github.event.pull_request.head.sha }}"
10+
11+
jobs:
12+
publish:
13+
environment: cli-testing
14+
permissions:
15+
contents: write
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repo
19+
uses: actions/checkout@v3
20+
- name: Setup Composer dependencies
21+
run: docker run --rm --volume "$(pwd)":/app composer install --ignore-platform-reqs
22+
- name: Generate SDKS
23+
run: docker run --rm -v "$(pwd)":/app -w /app php:8.1-cli php example.php
24+
- name: Fix permission
25+
run: sudo chown -R 1001:1001 examples
26+
- name: Setup Node
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 'latest'
30+
registry-url: 'https://registry.npmjs.org'
31+
- name: Setup
32+
working-directory: ./examples/cli/
33+
run: npm install
34+
- name: Set version
35+
working-directory: ./examples/cli/
36+
run: |
37+
sed -i "s#appwrite-cli#${{ vars.PACKAGE_NAME }}#g" package.json
38+
sed -i "s#0.16.0#0.16.0${{ github.event.pull_request.head.sha }}#g" package.json
39+
- name: Publish
40+
working-directory: examples/cli/
41+
run: npm publish --access public
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
- name: Instruction
45+
run: |
46+
echo "Install it by running npm install ${{ env.PACKAGE_NAME }}"
47+
echo "Run it using npx ${{ env.PACKAGE_NAME }}"

.github/workflows/tests.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,40 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
php-version: ['8.2']
16-
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]
16+
sdk: [
17+
Android5Java17,
18+
Android14Java17,
19+
CLINode16,
20+
CLINode18,
21+
DartBeta,
22+
DartStable,
23+
Deno1193,
24+
Deno1303,
25+
DotNet60,
26+
DotNet80,
27+
FlutterStable,
28+
FlutterBeta,
29+
Go112,
30+
Go118,
31+
KotlinJava8,
32+
KotlinJava11,
33+
KotlinJava17,
34+
Node16,
35+
Node18,
36+
Node20,
37+
PHP74,
38+
PHP80,
39+
Python38,
40+
Python39,
41+
Python310,
42+
Ruby27,
43+
Ruby30,
44+
Ruby31,
45+
AppleSwift56,
46+
Swift56,
47+
WebChromium,
48+
WebNode
49+
]
1750

1851
steps:
1952
- name: Checkout repository

example.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function getSSLPage($url) {
186186
->setTwitter('appwrite_io')
187187
->setDiscord('564160730845151244', 'https://appwrite.io/discord')
188188
->setDefaultHeaders([
189-
'X-Appwrite-Response-Format' => '0.15.0',
189+
'X-Appwrite-Response-Format' => '1.5.0',
190190
])
191191
;
192192

@@ -393,7 +393,7 @@ function getSSLPage($url) {
393393
;
394394

395395
$sdk->generate(__DIR__ . '/examples/apple');
396-
396+
397397
// DotNet
398398
$sdk = new SDK(new DotNet(), new Swagger2($spec));
399399

@@ -442,7 +442,7 @@ function getSSLPage($url) {
442442
// Android
443443

444444
$sdk = new SDK(new Android(), new Swagger2($spec));
445-
445+
446446
$sdk
447447
->setName('Android')
448448
->setNamespace('io appwrite')
@@ -466,7 +466,7 @@ function getSSLPage($url) {
466466

467467
// Kotlin
468468
$sdk = new SDK(new Kotlin(), new Swagger2($spec));
469-
469+
470470
$sdk
471471
->setName('Kotlin')
472472
->setNamespace('io appwrite')

mock-server/docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3'
2-
31
services:
42
mockapi:
53
container_name: mockapi

src/SDK/Language.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ public function getFilters(): array
8484
return [];
8585
}
8686

87+
/**
88+
* Language specific functions.
89+
* @return array
90+
*/
91+
public function getFunctions(): array
92+
{
93+
return [];
94+
}
95+
8796
protected function toPascalCase(string $value): string
8897
{
8998
return \ucfirst($this->toCamelCase($value));

src/SDK/Language/CLI.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,66 @@
22

33
namespace Appwrite\SDK\Language;
44

5+
use Twig\TwigFunction;
6+
57
class CLI extends Node
68
{
9+
/**
10+
* List of functions to ignore for console preview.
11+
* @var array
12+
*/
13+
private $consoleIgnoreFunctions = [
14+
'listidentities',
15+
'listmfafactors',
16+
'getprefs',
17+
'getsession',
18+
'getattribute',
19+
'listdocumentlogs',
20+
'getindex',
21+
'listcollectionlogs',
22+
'getcollectionusage',
23+
'listlogs',
24+
'listruntimes',
25+
'getusage',
26+
'getusage',
27+
'listvariables',
28+
'getvariable',
29+
'listproviderlogs',
30+
'listsubscriberlogs',
31+
'getsubscriber',
32+
'listtopiclogs',
33+
'getemailtemplate',
34+
'getsmstemplate',
35+
'getfiledownload',
36+
'getfilepreview',
37+
'getfileview',
38+
'getusage',
39+
'listlogs',
40+
'getprefs',
41+
'getusage',
42+
'listlogs',
43+
'getmembership',
44+
'listmemberships',
45+
'listmfafactors',
46+
'getmfarecoverycodes',
47+
'getprefs',
48+
'listtargets',
49+
'gettarget',
50+
];
51+
52+
/**
53+
* List of SDK services to ignore for console preview.
54+
* @var array
55+
*/
56+
private $consoleIgnoreServices = [
57+
'health',
58+
'migrations',
59+
'locale',
60+
'avatars',
61+
'project',
62+
'proxy',
63+
'vcs'
64+
];
765
/**
866
* @var array
967
*/
@@ -172,6 +230,11 @@ public function getFiles(): array
172230
'destination' => 'lib/utils.js',
173231
'template' => 'cli/lib/utils.js.twig',
174232
],
233+
[
234+
'scope' => 'default',
235+
'destination' => 'lib/commands/init.js',
236+
'template' => 'cli/lib/commands/init.js.twig',
237+
],
175238
[
176239
'scope' => 'default',
177240
'destination' => 'lib/commands/pull.js',
@@ -285,4 +348,18 @@ public function getParamExample(array $param): string
285348

286349
return $output;
287350
}
351+
352+
/**
353+
* Language specific filters.
354+
* @return array
355+
*/
356+
public function getFunctions(): array
357+
{
358+
return [
359+
/** Return true if the entered service->method is enabled for a console preview link */
360+
new TwigFunction('hasConsolePreview', fn($method, $service) => preg_match('/^([Gg]et|[Ll]ist)/', $method)
361+
&& !in_array(strtolower($method), $this->consoleIgnoreFunctions)
362+
&& !in_array($service, $this->consoleIgnoreServices)),
363+
];
364+
}
288365
}

src/SDK/Language/Dart.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,13 @@ public function getFiles(): array
475475
],
476476
[
477477
'scope' => 'default',
478-
'destination' => '.travis.yml',
479-
'template' => 'dart/.travis.yml.twig',
478+
'destination' => '.github/workflows/publish.yml',
479+
'template' => 'dart/.github/workflows/publish.yml.twig',
480+
],
481+
[
482+
'scope' => 'default',
483+
'destination' => '.github/workflows/format.yml',
484+
'template' => 'dart/.github/workflows/format.yml.twig',
480485
],
481486
[
482487
'scope' => 'default',

0 commit comments

Comments
 (0)