Skip to content

Commit 8922e7c

Browse files
Merge branch 'master' into big-int
2 parents 3dc620a + b7109e1 commit 8922e7c

76 files changed

Lines changed: 4825 additions & 1300 deletions

Some content is hidden

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

.github/workflows/sdk-build-validation.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ jobs:
144144
if: matrix.sdk == 'go'
145145
uses: actions/setup-go@v5
146146
with:
147-
go-version: '1.21'
147+
go-version: '1.22.5'
148148

149149
- name: Setup .NET
150150
if: matrix.sdk == 'dotnet'
@@ -179,7 +179,7 @@ jobs:
179179
;;
180180
react-native)
181181
npm ci
182-
npm run build || echo "No build script, checking syntax only"
182+
npm run build
183183
;;
184184
flutter)
185185
flutter pub get
@@ -219,6 +219,7 @@ jobs:
219219
go)
220220
go mod tidy || true
221221
go build ./...
222+
go test ./...
222223
;;
223224
dotnet)
224225
dotnet build

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
Node16,
3535
Node18,
3636
Node20,
37-
PHP80,
37+
PHP82,
3838
PHP83,
3939
Python39,
4040
Python310,
@@ -116,4 +116,4 @@ jobs:
116116
run: chmod +x ./.github/scripts/max-line-length.sh
117117

118118
- name: Check max lines
119-
run: ./.github/scripts/max-line-length.sh . 1200 "*.twig"
119+
run: ./.github/scripts/max-line-length.sh . 1200 "*.twig"

example.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,20 @@ function configureSDK($sdk, $overrides = []) {
175175
/ _ \ |_) | |_) \ V V /| | | | || __/ / /___/ /___/\/ /_
176176
\_/ \_/ .__/| .__/ \_/\_/ |_| |_|\__\___| \____/\____/\____/
177177
|_| |_| ");
178+
// Generated formulas start with placeholder checksums. The generated CLI
179+
// publish workflow rewrites them after the native release binaries exist.
180+
foreach ([
181+
'APPWRITE_CLI_HOMEBREW_MAC_ARM64_SHA256' => 'homebrewMacArm64Sha256',
182+
'APPWRITE_CLI_HOMEBREW_MAC_X64_SHA256' => 'homebrewMacX64Sha256',
183+
'APPWRITE_CLI_HOMEBREW_LINUX_ARM64_SHA256' => 'homebrewLinuxArm64Sha256',
184+
'APPWRITE_CLI_HOMEBREW_LINUX_X64_SHA256' => 'homebrewLinuxX64Sha256',
185+
] as $envKey => $paramKey) {
186+
$sha256 = getenv($envKey);
187+
188+
if ($sha256 !== false && $sha256 !== '') {
189+
$language->setHomebrewSha256($paramKey, $sha256);
190+
}
191+
}
178192

179193
$sdk = new SDK($language, new Swagger2($spec));
180194
$sdk->setTest(false);

src/SDK/Language/CLI.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class CLI extends Node
7070
'executableName' => 'executable',
7171
'logo' => '',
7272
'logoUnescaped' => '',
73+
'homebrewMacArm64Sha256' => '0000000000000000000000000000000000000000000000000000000000000000',
74+
'homebrewMacX64Sha256' => '0000000000000000000000000000000000000000000000000000000000000000',
75+
'homebrewLinuxArm64Sha256' => '0000000000000000000000000000000000000000000000000000000000000000',
76+
'homebrewLinuxX64Sha256' => '0000000000000000000000000000000000000000000000000000000000000000',
7377
];
7478

7579
/**
@@ -150,6 +154,21 @@ public function setLogoUnescaped(string $logo): self
150154
return $this;
151155
}
152156

157+
/**
158+
* Override a generated Homebrew formula checksum placeholder when a release
159+
* build already knows the target binary SHA256.
160+
*
161+
* @param string $key
162+
* @param string $sha256
163+
* @return $this
164+
*/
165+
public function setHomebrewSha256(string $key, string $sha256): self
166+
{
167+
$this->setParam($key, $sha256);
168+
169+
return $this;
170+
}
171+
153172
/**
154173
* Convert string to kebab-case.
155174
* @param string $value
@@ -333,6 +352,11 @@ public function getFiles(): array
333352
'destination' => 'lib/parser.ts',
334353
'template' => 'cli/lib/parser.ts',
335354
],
355+
[
356+
'scope' => 'copy',
357+
'destination' => 'lib/response-config.ts',
358+
'template' => 'cli/lib/response-config.ts',
359+
],
336360
[
337361
'scope' => 'copy',
338362
'destination' => 'lib/questions.ts',

src/SDK/Language/Go.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,36 @@ public function getFilters(): array
384384
new TwigFilter('caseEnumKey', function (string $value) {
385385
return $this->toUpperSnakeCase($value);
386386
}),
387+
new TwigFilter('goPackagePath', function (array $sdk) {
388+
return $this->getPackagePath($sdk);
389+
}),
387390
];
388391
}
389392

393+
protected function getPackagePath(array $sdk): string
394+
{
395+
$user = $sdk['gitUserName'] ?? '';
396+
$repo = $sdk['gitRepoName'] ?? 'sdk-for-go';
397+
$suffix = $this->getMajorVersionSuffix($sdk['version'] ?? '');
398+
399+
if ($user === '') {
400+
return $repo . $suffix;
401+
}
402+
403+
return 'github.com/' . $user . '/' . $repo . $suffix;
404+
}
405+
406+
protected function getMajorVersionSuffix(string $version): string
407+
{
408+
if (!\preg_match('/^v?(?<major>\d+)/', $version, $matches)) {
409+
return '';
410+
}
411+
412+
$major = (int) ($matches['major'] ?? 0);
413+
414+
return $major >= 2 ? '/v' . $major : '';
415+
}
416+
390417
protected function getPropertyType(array $property, array $spec, string $generic = 'map[string]interface{}'): string
391418
{
392419
if (\array_key_exists('sub_schema', $property)) {

0 commit comments

Comments
 (0)