Skip to content

Commit 0f47ae2

Browse files
committed
Merge branch 'master' into feat-node-sdk-custom-exception
2 parents 05bd062 + d875e69 commit 0f47ae2

40 files changed

+660
-216
lines changed

.travis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2+
dist: xenial
3+
4+
arch:
5+
- amd64
6+
7+
os: linux
8+
19
language: php
210

311
php:
@@ -24,4 +32,4 @@ install:
2432
- composer install
2533

2634
script:
27-
- vendor/bin/phpunit
35+
- vendor/bin/phpunit

example.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ function getSSLPage($url) {
4545
}
4646

4747
// PHP
48-
$sdk = new SDK(new PHP(), new Swagger2($spec));
48+
$php = new PHP();
49+
$php
50+
->setComposerVendor('appwrite')
51+
->setComposerPackage('appwrite');
52+
$sdk = new SDK($php, new Swagger2($spec));
4953

5054
$sdk
5155
->setName('NAME')

src/SDK/Language/CLI.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ public function getFiles()
226226
'template' => '/cli/app/services/init.php.twig',
227227
'minify' => false,
228228
],
229+
[
230+
'scope' => 'default',
231+
'destination' => '.travis.yml',
232+
'template' => '/cli/.travis.yml.twig',
233+
'minify' => false,
234+
],
229235
];
230236
}
231237

src/SDK/Language/Dart.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ public function getFiles()
281281
'template' => '/dart/lib/client.dart.twig',
282282
'minify' => false,
283283
],
284+
[
285+
'scope' => 'default',
286+
'destination' => '/lib/exception.dart',
287+
'template' => '/dart/lib/exception.dart.twig',
288+
'minify' => false,
289+
],
284290
[
285291
'scope' => 'default',
286292
'destination' => '/lib/{{ language.params.packageName }}.dart',

src/SDK/Language/Flutter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ public function getFiles()
7979
'template' => '/flutter/lib/enums.dart.twig',
8080
'minify' => false,
8181
],
82+
[
83+
'scope' => 'default',
84+
'destination' => '/lib/exception.dart',
85+
'template' => '/flutter/lib/exception.dart.twig',
86+
'minify' => false,
87+
],
8288
[
8389
'scope' => 'service',
8490
'destination' => '/lib/services/{{service.name | caseDash}}.dart',

src/SDK/Language/PHP.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ public function getFiles()
169169
'template' => '/php/src/Client.php.twig',
170170
'minify' => false,
171171
],
172+
[
173+
'scope' => 'default',
174+
'destination' => 'src/{{ spec.title | caseUcfirst}}/{{ spec.title | caseUcfirst}}Exception.php',
175+
'template' => '/php/src/Exception.php.twig',
176+
'minify' => false,
177+
],
172178
[
173179
'scope' => 'default',
174180
'destination' => '/src/{{ spec.title | caseUcfirst}}/Service.php',

src/SDK/SDK.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class SDK
5454
'shareVia' => '',
5555
'shareTags' => '',
5656
'warning' => '',
57+
'gettingStarted' => '',
5758
'readme' => '',
5859
'changelog' => '',
5960
'examples' => '',
@@ -186,6 +187,8 @@ public function __construct(Language $language, Spec $spec)
186187
*/
187188
public function setDefaultHeaders($headers) {
188189
$this->defaultHeaders = $headers;
190+
191+
return $this;
189192
}
190193

191194
/**
@@ -386,6 +389,17 @@ public function setWarning($message)
386389
return $this;
387390
}
388391

392+
/**
393+
* @param $message string
394+
* @return $this
395+
*/
396+
public function setGettingStarted($message)
397+
{
398+
$this->setParam('gettingStarted', $message);
399+
400+
return $this;
401+
}
402+
389403
/**
390404
* @param $text string
391405
* @return $this

templates/cli/.travis.yml.twig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
os: linux
2+
dist: xenial
3+
4+
language: shell
5+
6+
services:
7+
- docker
8+
9+
before_install:
10+
- curl -fsSL https://get.docker.com | sh
11+
- echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json
12+
- mkdir -p $HOME/.docker
13+
- echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json
14+
- sudo service docker start
15+
- >
16+
if [ ! -z "${DOCKERHUB_PULL_USERNAME:-}" ]; then
17+
echo "${DOCKERHUB_PULL_PASSWORD}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin
18+
fi
19+
- docker --version
20+
- docker run --rm --privileged linuxkit/binfmt:v0.8
21+
- docker buildx create --use
22+
23+
script:
24+
- docker ps; docker buildx ls
25+
26+
deploy:
27+
- provider: script
28+
edge: true
29+
script: docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x -t appwrite/cli:$TRAVIS_TAG ./ --push
30+
on:
31+
tags: true

templates/cli/install.ps1.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ${{ spec.title | upper }}_EXECUTABLE_FILEPATH = Join-Path -Path ${{ spec.title |
2525
${{ spec.title | upper }}_CLI_IMAGE_NAME = "{{ spec.title | lower }}/cli"
2626

2727
# {{ spec.title | caseUcfirst }} CLI image version
28-
${{ spec.title | upper }}_CLI_IMAGE_VERSION = "{{ spec.version }}"
28+
${{ spec.title | upper }}_CLI_IMAGE_VERSION = "{{ sdk.version }}"
2929

3030
${{ spec.title | upper }}_EXECUTABLE_CONTENT = @"
3131
$allowList = 'help', 'init', 'client' {% for service in spec.services %}, '{{ service.name }}'{% endfor %}

templates/cli/install.sh.twig

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323
# {{ spec.title | caseUcfirst }} executable file path
2424
{{ spec.title | upper }}_EXECUTABLE_FILEPATH="${{ spec.title | upper }}_INSTALL_DIR/${{ spec.title | upper }}_EXECUTABLE_NAME"
2525

26+
# {{ spec.title | caseUcfirst }} CLI temp name
27+
{{ spec.title | upper }}_TEMP_NAME=temp
28+
2629
# {{ spec.title | caseUcfirst }} CLI image name
2730
{{ spec.title | upper }}_CLI_IMAGE_NAME={{ spec.title | lower }}/cli
2831

2932
# {{ spec.title | caseUcfirst }} CLI image version
30-
{{ spec.title | upper }}_CLI_IMAGE_VERSION={{ spec.version }}
33+
{{ spec.title | upper }}_CLI_IMAGE_VERSION={{ sdk.version }}
3134

3235
# sudo is required to copy executable to {{ spec.title | upper }}_INSTALL_DIR for linux
3336
USE_SUDO="false"
@@ -124,7 +127,7 @@ fi
124127
125128
# Check if the command is in the whitelist
126129
if [[ ! " ${allowList[@]} " =~ " ${1} " ]]; then
127-
echo "\nLooks like a crazy hamster 🐹 flipped a bit.\n\nUse {{ language.params.executableName }} help for a list of supported commands."
130+
printf "\nLooks like a crazy hamster 🐹 flipped a bit.\n\nUse {{ language.params.executableName }} help for a list of supported commands.\n"
128131
exit 1
129132
fi
130133
@@ -138,30 +141,30 @@ for x in "${@}" ; do
138141
_args=$_args" "$x
139142
done
140143
141-
bash -c "docker run -i --rm --volume {{ spec.title | lower }}-cli:/usr/local/code/app/.preferences/ --volume $(pwd):/usr/local/code/files:rw --network host '${{ spec.title | upper }}_CLI_IMAGE_NAME:${{ spec.title | upper }}_CLI_IMAGE_VERSION' $_args" ' > ${{ spec.title | upper }}_EXECUTABLE_NAME
144+
bash -c "docker run -i --rm --volume {{ spec.title | lower }}-cli:/usr/local/code/app/.preferences/ --volume $(pwd):/usr/local/code/files:rw --network host '${{ spec.title | upper }}_CLI_IMAGE_NAME:${{ spec.title | upper }}_CLI_IMAGE_VERSION' $_args" ' > ${{ spec.title | upper }}_TEMP_NAME
142145

143146
printf "${GREEN}🚧 Setting Permissions ${NC}\n"
144-
chmod +x ${{ spec.title | upper }}_EXECUTABLE_NAME
147+
chmod +x ${{ spec.title | upper }}_TEMP_NAME
145148
if [ $? -ne 0 ]; then
146149
printf "${RED}❌ Failed to set permissions ... ${NC}\n"
147150
exit 1
148151
fi
149152
printSuccess
150153

151-
printf "${GREEN}📝 Copying file to ${{ spec.title | upper }}_EXECUTABLE_FILEPATH ... ${NC}\n"
152-
runAsRoot cp ${{ spec.title | upper }}_EXECUTABLE_NAME ${{ spec.title | upper }}_EXECUTABLE_FILEPATH
154+
printf "${GREEN}📝 Copying temporary file to ${{ spec.title | upper }}_EXECUTABLE_FILEPATH ... ${NC}\n"
155+
runAsRoot cp ${{ spec.title | upper }}_TEMP_NAME ${{ spec.title | upper }}_EXECUTABLE_FILEPATH
153156
if [ $? -ne 0 ]; then
154-
printf "${RED}❌ Failed to copy file to ${{ spec.title | upper }}_EXECUTABLE_FILEPATH ... ${NC}\n"
157+
printf "${RED}❌ Failed to copy temporary file to ${{ spec.title | upper }}_EXECUTABLE_FILEPATH ... ${NC}\n"
155158
exit 1
156159
fi
157160
printSuccess
158161
}
159162

160163
cleanup() {
161164
echo "🧹 Cleaning up mess ... "
162-
rm ${{ spec.title | upper }}_EXECUTABLE_NAME
165+
rm ${{ spec.title | upper }}_TEMP_NAME
163166
if [ $? -ne 0 ]; then
164-
printf "${RED}❌ Failed to remove ${{ spec.title | upper }}_EXECUTABLE_NAME ... ${NC}\n"
167+
printf "${RED}❌ Failed to remove temporary file ... ${NC}\n"
165168
exit 1
166169
fi
167170
printSuccess

0 commit comments

Comments
 (0)