Skip to content

Commit 21743f4

Browse files
Merge pull request #747 from appwrite/fix-cli
fix: cli
2 parents c7405b6 + 5e0f726 commit 21743f4

File tree

4 files changed

+97
-46
lines changed

4 files changed

+97
-46
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
php-version: ['8.1']
16-
sdk: [Android11Java8, Android11Java11, Android12Java8, Android12Java11, CLINode14, CLINode16, DartBeta, DartStable, Deno1193, Deno1303, DotNet60, DotNet70, FlutterStable, FlutterBeta, Go112, Go118, KotlinJava8, KotlinJava11, KotlinJava17, Node12, Node14, Node16, PHP74, PHP80, Python38, Python39, Python310, Ruby27, Ruby30, Ruby31, AppleSwift55, Swift55, WebChromium, WebNode]
16+
sdk: [Android11Java8, Android11Java11, Android12Java8, Android12Java11, CLINode16, CLINode18, DartBeta, DartStable, Deno1193, Deno1303, DotNet60, DotNet70, FlutterStable, FlutterBeta, Go112, Go118, KotlinJava8, KotlinJava11, KotlinJava17, Node12, Node14, Node16, PHP74, PHP80, Python38, Python39, Python310, Ruby27, Ruby30, Ruby31, AppleSwift55, Swift55, WebChromium, WebNode]
1717

1818
steps:
1919
- name: Checkout repository

mock-server/app/http.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@
7272
->action(function ($x, $y, $z) {
7373
});
7474

75+
// Version Route for CLI
76+
App::get('/v1/health/version')
77+
->desc('Get version')
78+
->groups(['api', 'health'])
79+
->label('scope', 'public')
80+
->label('sdk.response.code', Response::STATUS_CODE_OK)
81+
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
82+
->inject('response')
83+
->action(function (UtopiaSwooleResponse $response) {
84+
$response->json([ 'version' => '1.0.0' ]);
85+
});
86+
7587
App::post('/v1/mock/tests/foo')
7688
->desc('Post Foo')
7789
->groups(['mock'])

tests/CLINode14Test.php renamed to tests/CLINode18Test.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Appwrite\SDK\Language;
66
use Appwrite\SDK\Language\CLI;
77

8-
class CLINode14Test extends Base
8+
class CLINode18Test extends Base
99
{
1010
protected string $sdkName = 'cli';
1111
protected string $sdkPlatform = 'server';
@@ -15,11 +15,11 @@ class CLINode14Test extends Base
1515
protected string $language = 'cli';
1616
protected string $class = 'Appwrite\SDK\Language\CLI';
1717
protected array $build = [
18-
'docker run --rm -v $(pwd):/app -w /app/tests/sdks/cli node:16-alpine npm install',
18+
'docker run --rm -v $(pwd):/app -w /app/tests/sdks/cli node:18-alpine npm install',
1919
'cp tests/languages/cli/test.js tests/sdks/cli/test.js'
2020
];
2121
protected string $command =
22-
'docker run --network="mockapi" --rm -v $(pwd):/app -w /app/tests/sdks/cli node:14-alpine node test.js';
22+
'docker run --network="mockapi" --rm -v $(pwd):/app -w /app/tests/sdks/cli node:18-alpine node test.js';
2323

2424
protected array $expectedOutput = [
2525
...Base::FOO_RESPONSES,

tests/languages/cli/test.js

Lines changed: 81 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,96 @@
1-
const { exec, execSync } = require('child_process');
1+
const { exec, execSync } = require("child_process");
22

3-
execSync("node index client --endpoint 'https://qa.appwrite.org/v1' --projectId console --key=35y3h5h345 --selfSigned true", { stdio: 'inherit' });
3+
execSync(
4+
"node index client --endpoint 'http://mockapi/v1' --projectId console --key=35y3h5h345 --selfSigned true",
5+
{ stdio: "inherit" }
6+
);
47

58
var output;
6-
console.log('\nTest Started');
9+
console.log("\nTest Started");
710

811
// Foo
9-
output = execSync("node index foo get --x string --y 123 --z string in array", { stdio: 'pipe'}).toString();
10-
console.log(output.split('\n')[0].split(" : ")[1]);
11-
12-
output = execSync("node index foo post --x string --y 123 --z string in array", { stdio: 'pipe'}).toString();
13-
console.log(output.split('\n')[0].split(" : ")[1]);
14-
15-
output = execSync("node index foo put --x string --y 123 --z string in array", { stdio: 'pipe'}).toString();
16-
console.log(output.split('\n')[0].split(" : ")[1]);
17-
18-
output = execSync("node index foo patch --x string --y 123 --z string in array", { stdio: 'pipe'}).toString();
19-
console.log(output.split('\n')[0].split(" : ")[1]);
20-
21-
output = execSync("node index foo delete --x string --y 123 --z string in array", { stdio: 'pipe'}).toString();
22-
console.log(output.split('\n')[0].split(" : ")[1]);
12+
output = execSync(
13+
"node index foo get --x string --y 123 --z string in array",
14+
{ stdio: "pipe" }
15+
).toString();
16+
console.log(output.split("\n")[0].split(" : ")[1]);
17+
18+
output = execSync(
19+
"node index foo post --x string --y 123 --z string in array",
20+
{ stdio: "pipe" }
21+
).toString();
22+
console.log(output.split("\n")[0].split(" : ")[1]);
23+
24+
output = execSync(
25+
"node index foo put --x string --y 123 --z string in array",
26+
{ stdio: "pipe" }
27+
).toString();
28+
console.log(output.split("\n")[0].split(" : ")[1]);
29+
30+
output = execSync(
31+
"node index foo patch --x string --y 123 --z string in array",
32+
{ stdio: "pipe" }
33+
).toString();
34+
console.log(output.split("\n")[0].split(" : ")[1]);
35+
36+
output = execSync(
37+
"node index foo delete --x string --y 123 --z string in array",
38+
{ stdio: "pipe" }
39+
).toString();
40+
console.log(output.split("\n")[0].split(" : ")[1]);
2341

2442
// Bar
25-
output = execSync("node index bar get --required string --xdefault 123 --z string in array", { stdio: 'pipe'}).toString();
26-
console.log(output.split('\n')[0].split(" : ")[1]);
27-
28-
output = execSync("node index bar post --required string --xdefault 123 --z string in array", { stdio: 'pipe'}).toString();
29-
console.log(output.split('\n')[0].split(" : ")[1]);
30-
31-
output = execSync("node index bar put --required string --xdefault 123 --z string in array", { stdio: 'pipe'}).toString();
32-
console.log(output.split('\n')[0].split(" : ")[1]);
33-
34-
output = execSync("node index bar patch --required string --xdefault 123 --z string in array", { stdio: 'pipe'}).toString();
35-
console.log(output.split('\n')[0].split(" : ")[1]);
36-
37-
output = execSync("node index bar delete --required string --xdefault 123 --z string in array", { stdio: 'pipe'}).toString();
38-
console.log(output.split('\n')[0].split(" : ")[1]);
43+
output = execSync(
44+
"node index bar get --required string --xdefault 123 --z string in array",
45+
{ stdio: "pipe" }
46+
).toString();
47+
console.log(output.split("\n")[0].split(" : ")[1]);
48+
49+
output = execSync(
50+
"node index bar post --required string --xdefault 123 --z string in array",
51+
{ stdio: "pipe" }
52+
).toString();
53+
console.log(output.split("\n")[0].split(" : ")[1]);
54+
55+
output = execSync(
56+
"node index bar put --required string --xdefault 123 --z string in array",
57+
{ stdio: "pipe" }
58+
).toString();
59+
console.log(output.split("\n")[0].split(" : ")[1]);
60+
61+
output = execSync(
62+
"node index bar patch --required string --xdefault 123 --z string in array",
63+
{ stdio: "pipe" }
64+
).toString();
65+
console.log(output.split("\n")[0].split(" : ")[1]);
66+
67+
output = execSync(
68+
"node index bar delete --required string --xdefault 123 --z string in array",
69+
{ stdio: "pipe" }
70+
).toString();
71+
console.log(output.split("\n")[0].split(" : ")[1]);
3972

4073
// General
41-
output = execSync("node index general redirect", { stdio: 'pipe'}).toString();
42-
console.log(output.split('\n')[0].split(" : ")[1]);
74+
output = execSync("node index general redirect", { stdio: "pipe" }).toString();
75+
console.log(output.split("\n")[0].split(" : ")[1]);
4376

44-
output = execSync("node index general upload --x string --y 123 --z string in array --file ../../resources/file.png", { stdio: 'pipe'}).toString();
45-
console.log(output.split('\n')[0].split(" : ")[1]);
77+
output = execSync(
78+
"node index general upload --x string --y 123 --z string in array --file ../../resources/file.png",
79+
{ stdio: "pipe" }
80+
).toString();
81+
console.log(output.split("\n")[0].split(" : ")[1]);
4682

47-
output = execSync("node index general upload --x string --y 123 --z string in array --file ../../resources/large_file.mp4", { stdio: 'pipe'}).toString();
48-
console.log(output.split('\n')[0].split(" : ")[1]);
83+
output = execSync(
84+
"node index general upload --x string --y 123 --z string in array --file ../../resources/large_file.mp4",
85+
{ stdio: "pipe" }
86+
).toString();
87+
console.log(output.split("\n")[0].split(" : ")[1]);
4988

5089
// Skip extra tests for CLI
51-
console.log('POST:/v1/mock/tests/general/upload:passed')
52-
console.log('POST:/v1/mock/tests/general/upload:passed')
90+
console.log("POST:/v1/mock/tests/general/upload:passed");
91+
console.log("POST:/v1/mock/tests/general/upload:passed");
5392

54-
execSync("node index general empty", { stdio: 'pipe'});
93+
execSync("node index general empty", { stdio: "pipe" });
5594

56-
output = execSync("node index general headers", { stdio: 'pipe'}).toString();
57-
console.log(output.split('\n')[0].split(" : ")[1]);
95+
output = execSync("node index general headers", { stdio: "pipe" }).toString();
96+
console.log(output.split("\n")[0].split(" : ")[1]);

0 commit comments

Comments
 (0)