Skip to content

Commit ca6c41c

Browse files
Merge branch 'master' of https://github.com/appwrite/sdk-generator into fix-js-bigint
2 parents 5c5e0fd + 0e8a69e commit ca6c41c

File tree

29 files changed

+163
-58
lines changed

29 files changed

+163
-58
lines changed

composer.lock

Lines changed: 26 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SDK/Language/CLI.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ public function getFiles()
158158
'template' => 'cli/lib/client.js.twig',
159159
'minify' => false,
160160
],
161+
[
162+
'scope' => 'default',
163+
'destination' => 'lib/utils.js',
164+
'template' => 'cli/lib/utils.js.twig',
165+
'minify' => false,
166+
],
161167
[
162168
'scope' => 'default',
163169
'destination' => 'lib/commands/init.js',

src/SDK/Language/Deno.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function getParamExample(array $param)
145145
$output .= '{}';
146146
break;
147147
case self::TYPE_FILE:
148-
$output .= "new File([fileBlob], 'file.png')";
148+
$output .= "'file.png'";
149149
break;
150150
}
151151
}
@@ -164,7 +164,7 @@ public function getParamExample(array $param)
164164
$output .= "'{$example}'";
165165
break;
166166
case self::TYPE_FILE:
167-
$output .= "new File([fileBlob], 'file.png')";
167+
$output .= "'file.png'";
168168
break;
169169
}
170170
}

src/SDK/Language/Kotlin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function getParamExample(array $param)
197197
if(empty($example) && $example !== 0 && $example !== false) {
198198
switch ($type) {
199199
case self::TYPE_FILE:
200-
$output .= 'File("./path-to-files/image.jpg")';
200+
$output .= 'File("file.png")';
201201
break;
202202
case self::TYPE_NUMBER:
203203
case self::TYPE_INTEGER:

src/SDK/Language/Node.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function getParamExample(array $param)
148148
$output .= '{}';
149149
break;
150150
case self::TYPE_FILE:
151-
$output .= "fs.createReadStream(__dirname + '/file.png')";
151+
$output .= "'file.png'";
152152
break;
153153
}
154154
}
@@ -167,11 +167,11 @@ public function getParamExample(array $param)
167167
$output .= "'{$example}'";
168168
break;
169169
case self::TYPE_FILE:
170-
$output .= "fs.createReadStream(__dirname + '/file.png')";
170+
$output .= "'file.png'";
171171
break;
172172
}
173173
}
174174

175175
return $output;
176176
}
177-
}
177+
}

src/SDK/Language/PHP.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public function getParamExample(array $param)
309309
$output .= '[]';
310310
break;
311311
case self::TYPE_FILE:
312-
$output .= "new \CURLFile('/path/to/file.png', 'image/png', 'file.png')";
312+
$output .= "'file.png'";
313313
break;
314314
}
315315
}
@@ -330,7 +330,7 @@ public function getParamExample(array $param)
330330
$output .= "'{$example}'";
331331
break;
332332
case self::TYPE_FILE:
333-
$output .= "new \CURLFile('/path/to/file.png', 'image/png', 'file.png')";
333+
$output .= "'file.png'";
334334
break;
335335
}
336336
}

src/SDK/Language/Python.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public function getParamExample(array $param)
302302
$output .= '{}';
303303
break;
304304
case self::TYPE_FILE:
305-
$output .= "open('/path/to/file.png', 'rb')"; //TODO add file class
305+
$output .= "'file.png'";
306306
break;
307307
}
308308
}
@@ -321,7 +321,7 @@ public function getParamExample(array $param)
321321
$output .= "'{$example}'";
322322
break;
323323
case self::TYPE_FILE:
324-
$output .= "open('/path/to/file.png', 'rb')"; //TODO add file class
324+
$output .= "'file.png'";
325325
break;
326326
}
327327
}

src/SDK/Language/Ruby.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public function getParamExample(array $param)
280280
$output .= '{}';
281281
break;
282282
case self::TYPE_FILE:
283-
$output .= "File.new()";
283+
$output .= "'dir/file.png'";
284284
break;
285285
}
286286
}
@@ -301,7 +301,7 @@ public function getParamExample(array $param)
301301
$output .= "'{$example}'";
302302
break;
303303
case self::TYPE_FILE:
304-
$output .= "File.new()";
304+
$output .= "'file.png'";
305305
break;
306306
}
307307
}

templates/cli/install.ps1.twig

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
$GITHUB_x64_URL = "https://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName | caseDash }}/releases/download/{{ sdk.version }}/{{ language.params.executableName }}-cli-win-x64.exe"
1717
$GITHUB_arm64_URL = "https://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName | caseDash }}/releases/download/{{ sdk.version }}/{{ language.params.executableName }}-cli-win-arm64.exe"
1818

19+
${{ spec.title | upper }}_BINARY_NAME = "{{ language.params.executableName }}.exe"
20+
1921
# {{ spec.title | caseUcfirst }} download directory
20-
${{ spec.title | upper }}_DOWNLOAD_DIR = Join-Path -Path $env:TEMP -ChildPath "{{ language.params.executableName }}.exe"
22+
${{ spec.title | upper }}_DOWNLOAD_DIR = Join-Path -Path $env:TEMP -ChildPath ${{ spec.title | upper }}_BINARY_NAME
2123

2224
# {{ spec.title | caseUcfirst }} CLI location
2325
${{ spec.title | upper }}_INSTALL_DIR = Join-Path -Path $env:LOCALAPPDATA -ChildPath "{{ spec.title | caseUcfirst }}"
24-
${{ spec.title | upper }}_INSTALL_FILE = Join-Path -Path ${{ spec.title | upper }}_INSTALL_DIR -ChildPath "{{ language.params.executableName }}.exe"
26+
${{ spec.title | upper }}_INSTALL_PATH = Join-Path -Path "${{ spec.title | upper }}_INSTALL_DIR" -ChildPath "${{ spec.title | upper }}_BINARY_NAME"
2527

2628
$USER_PATH_ENV_VAR = [Environment]::GetEnvironmentVariable("PATH", "User")
2729

@@ -53,9 +55,9 @@ function DownloadBinary {
5355
} else {
5456
Invoke-WebRequest -Uri $GITHUB_x64_URL -OutFile ${{ spec.title | upper }}_DOWNLOAD_DIR
5557
}
56-
57-
New-Item -ItemType Directory -Force -Path ${{ spec.title | upper }}_INSTALL_DIR | Out-Null
58-
Move-Item ${{ spec.title | upper }}_DOWNLOAD_DIR ${{ spec.title | upper }}_INSTALL_FILE
58+
59+
New-Item -ItemType Directory -Path ${{ spec.title | upper }}_INSTALL_DIR
60+
Move-Item ${{ spec.title | upper }}_DOWNLOAD_DIR ${{ spec.title | upper }}_INSTALL_PATH
5961
}
6062

6163

templates/cli/lib/commands/command.js.twig

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
const fs = require('fs');
2+
const pathLib = require('path');
23
const tar = require("tar");
4+
const ignore = require("ignore");
35
const { promisify } = require('util');
46
const libClient = require('../client.js');
7+
const { getAllFiles } = require('../utils.js');
58
const { Command } = require('commander');
69
const { sdkForProject, sdkForConsole } = require('../sdks')
710
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
@@ -37,13 +40,27 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ {
3740
if (!fs.lstatSync(folderPath).isDirectory())
3841
throw new Error('The path is not a directory.');
3942

43+
const ignorer = ignore();
44+
45+
const func = localConfig.getFunction(functionId);
46+
47+
if(func.ignore) {
48+
ignorer.add(func.ignore);
49+
log('Ignoring files using configuration from appwrite.json');
50+
} else if(fs.existsSync(pathLib.join({{ parameter.name | caseCamel | escapeKeyword }}, '.gitignore'))) {
51+
ignorer.add(fs.readFileSync(pathLib.join({{ parameter.name | caseCamel | escapeKeyword }}, '.gitignore')).toString());
52+
log('Ignoring files in .gitignore');
53+
}
54+
55+
const files = getAllFiles({{ parameter.name | caseCamel | escapeKeyword }}).map((file) => pathLib.relative({{ parameter.name | caseCamel | escapeKeyword }}, file)).filter((file) => !ignorer.ignores(file));
56+
4057
await tar
4158
.create({
4259
gzip: true,
4360
sync: true,
4461
cwd: folderPath,
4562
file: 'code.tar.gz'
46-
}, ['./'])
63+
}, files);
4764
let archivePath = fs.realpathSync('code.tar.gz')
4865
if (typeof archivePath !== 'undefined') {
4966
payload['{{ parameter.name }}'] = archivePath;

0 commit comments

Comments
 (0)