Skip to content

Commit 8b25d4f

Browse files
fetch latest releases from github api
1 parent 8a708ce commit 8b25d4f

File tree

3 files changed

+43
-19
lines changed

3 files changed

+43
-19
lines changed

src/routes/(console)/project-[region]-[project]/overview/platforms/createApple.svelte

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,27 @@
4040
const projectId = page.params.project;
4141
4242
const alreadyExistsInstructions = `
43-
Install the Appwrite iOS SDK using the following package URL:
43+
Install the Appwrite iOS SDK using the following package URL:
4444
45-
\`\`\`
46-
https://github.com/appwrite/sdk-for-apple
47-
\`\`\`
45+
\`\`\`
46+
https://github.com/appwrite/sdk-for-apple
47+
\`\`\`
4848
49-
From a suitable lib directory, export the Appwrite client as a global variable:
49+
From a suitable lib directory, export the Appwrite client as a global variable:
5050
51-
\`\`\`
52-
let client = Client()
53-
.setEndpoint("${sdk.forProject(page.params.region, page.params.project).client.config.endpoint}")
54-
.setProject("${projectId}")
51+
\`\`\`
52+
let client = Client()
53+
.setEndpoint("${sdk.forProject(page.params.region, page.params.project).client.config.endpoint}")
54+
.setProject("${projectId}")
5555
56-
let account = Account(client)
57-
\`\`\`
56+
let account = Account(client)
57+
\`\`\`
5858
59-
On the homepage of the app, create a button that says "Send a ping" and when clicked, it should call the following function:
59+
On the homepage of the app, create a button that says "Send a ping" and when clicked, it should call the following function:
6060
61-
\`\`\`
62-
client.ping()
63-
\`\`\`
61+
\`\`\`
62+
client.ping()
63+
\`\`\`
6464
`;
6565
6666
const gitCloneCode =

src/routes/(console)/project-[region]-[project]/overview/platforms/createFlutter.svelte

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@
3838
let isPlatformCreated = $state(isConnectPlatform);
3939
4040
const projectId = page.params.project;
41+
const FLUTTER_RELEASES_ENDPOINT =
42+
'https://api.github.com/repos/appwrite/sdk-for-flutter/releases';
43+
let flutterSdkVersion = $state('20.3.0');
4144
42-
const alreadyExistsInstructions = `
45+
function buildFlutterInstructions(version: string) {
46+
return `
4347
Install the Appwrite Flutter SDK using the following command:
4448
4549
\`\`\`
46-
flutter pub add appwrite:20.3.0
50+
flutter pub add appwrite:${version}
4751
\`\`\`
4852
4953
From a suitable lib directory, export the Appwrite client as a global variable, hardcode the project details too:
@@ -59,7 +63,10 @@ On the homepage of the app, create a button that says "Send a ping" and when cli
5963
\`\`\`
6064
client.ping();
6165
\`\`\`
62-
`;
66+
`;
67+
}
68+
69+
const alreadyExistsInstructions = $derived(buildFlutterInstructions(flutterSdkVersion));
6370
6471
const gitCloneCode =
6572
'\ngit clone https://github.com/appwrite/starter-for-flutter\ncd starter-for-flutter\n';
@@ -134,6 +141,22 @@ client.ping();
134141
[PlatformType.Flutterwindows]: 'Package name'
135142
};
136143
144+
async function fetchFlutterSdkVersion() {
145+
try {
146+
const response = await fetch(FLUTTER_RELEASES_ENDPOINT);
147+
if (!response.ok) {
148+
throw new Error(`Failed to fetch Flutter releases: ${response.status}`);
149+
}
150+
const data = await response.json();
151+
const latestTag = data?.[0]?.tag_name;
152+
if (latestTag) {
153+
flutterSdkVersion = latestTag;
154+
}
155+
} catch (error) {
156+
console.error('Unable to fetch latest Flutter SDK version', error);
157+
}
158+
}
159+
137160
async function createFlutterPlatform() {
138161
try {
139162
isCreatingPlatform = true;
@@ -181,6 +204,7 @@ client.ping();
181204
}
182205
183206
onMount(() => {
207+
fetchFlutterSdkVersion();
184208
const unsubscribe = realtime.forConsole(page.params.region, 'console', (response) => {
185209
if (response.events.includes(`projects.${projectId}.ping`)) {
186210
connectionSuccessful = true;

src/routes/(console)/project-[region]-[project]/overview/platforms/llmBanner.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { Click, trackEvent } from '$lib/actions/analytics';
99
import IconAINotification from '../../databases/database-[database]/(suggestions)/icon/aiNotification.svelte';
1010
import Avatar from '$lib/components/avatar.svelte';
11-
import CursorIcon from '../components/CursorIconLarge.svelte';
11+
import CursorIcon from '$routes/(console)/project-[region]-[project]/overview/components/CursorIconLarge.svelte';
1212
import type { ComponentType } from 'svelte';
1313
1414
let {

0 commit comments

Comments
 (0)