From 77713756a7316c2e96b1b87e3e6640a3f329edc8 Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Fri, 12 Jul 2024 13:36:20 +0530 Subject: [PATCH 1/5] make init samples cloud first. --- .../overview/platforms/wizard/android/step3.svelte | 7 ++----- .../overview/platforms/wizard/apple/step3.svelte | 7 ++----- .../overview/platforms/wizard/flutter/step3.svelte | 7 ++----- .../overview/platforms/wizard/web/step3.svelte | 6 ++---- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte index 9b47253d1..f4039bd65 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte @@ -4,14 +4,11 @@ import { WizardStep } from '$lib/layout'; import { sdk } from '$lib/stores/sdk'; - const { endpoint, project } = sdk.forProject.client.config; + const { project } = sdk.forProject.client.config; const code = `import io.appwrite.Client import io.appwrite.services.Account -val client = Client(context) - .setEndpoint("${endpoint}") - .setProject("${project}") - .setSelfSigned(status: true) // For self signed certificates, only use for development`; +val client = Client(context).setProject("${project}")`; diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte index 6ff63e373..9b65f09dc 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte @@ -5,13 +5,10 @@ import { sdk } from '$lib/stores/sdk'; import Id from '$lib/components/id.svelte'; - const { endpoint, project } = sdk.forProject.client.config; + const { project } = sdk.forProject.client.config; const code = `import Appwrite -let client = Client() - .setEndpoint("${endpoint}") - .setProject("${project}") - .setSelfSigned(true) // For self signed certificates, only use for development`; +let client = Client().setProject("${project}")`; let showAlert = true; diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte index 3211a6796..89fb868bf 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte @@ -5,14 +5,11 @@ import { sdk } from '$lib/stores/sdk'; import Id from '$lib/components/id.svelte'; - const { endpoint, project } = sdk.forProject.client.config; + const { project } = sdk.forProject.client.config; const code = `import 'package:appwrite/appwrite.dart'; Client client = Client(); -client - .setEndpoint('${endpoint}') - .setProject('${project}') - .setSelfSigned(status: true); // For self signed certificates, only use for development`; +client.setProject('${project}')`; let showAlert = true; diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/web/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/web/step3.svelte index c259253dd..3990040d2 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/web/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/web/step3.svelte @@ -4,12 +4,10 @@ import { WizardStep } from '$lib/layout'; import { sdk } from '$lib/stores/sdk'; - const { endpoint, project } = sdk.forProject.client.config; + const { project } = sdk.forProject.client.config; const code = `const client = new Client(); -client - .setEndpoint('${endpoint}') - .setProject('${project}');`; +client.setProject('${project}');`; From b08dab3e719b96f0d809325b3a533dc723bd028e Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Fri, 12 Jul 2024 14:05:36 +0530 Subject: [PATCH 2/5] update: show `setSelfSigned` if self-hosted. --- .../overview/platforms/wizard/android/step3.svelte | 7 ++++++- .../overview/platforms/wizard/apple/step3.svelte | 6 +++++- .../overview/platforms/wizard/flutter/step3.svelte | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte index f4039bd65..c3bb1ef2f 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte @@ -3,12 +3,17 @@ import Id from '$lib/components/id.svelte'; import { WizardStep } from '$lib/layout'; import { sdk } from '$lib/stores/sdk'; + import { isSelfHosted } from '$lib/system'; const { project } = sdk.forProject.client.config; const code = `import io.appwrite.Client import io.appwrite.services.Account -val client = Client(context).setProject("${project}")`; +val client = Client(context) + .setProject("${project}")${ + isSelfHosted ? ` + .setSelfSigned(status: true) // For self signed certificates, only use for development` : '' + }`; diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte index 9b65f09dc..136718c15 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte @@ -8,7 +8,11 @@ const { project } = sdk.forProject.client.config; const code = `import Appwrite -let client = Client().setProject("${project}")`; +let client = Client() + .setProject("${project}")${ + isSelfHosted ? ` + .setSelfSigned(true) // For self signed certificates, only use for development` : '' + }`; let showAlert = true; diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte index 89fb868bf..28fbcbce9 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte @@ -9,7 +9,11 @@ const code = `import 'package:appwrite/appwrite.dart'; Client client = Client(); -client.setProject('${project}')`; +client + .setProject('${project}')${ + isSelfHosted ? ` + .setSelfSigned(status: true); // For self signed certificates, only use for development` : ';' + }`; let showAlert = true; From d55e9bcebaf9133eca371226509980ef8013b107 Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Fri, 12 Jul 2024 14:14:54 +0530 Subject: [PATCH 3/5] update: fix formatting. --- .../overview/platforms/wizard/android/step3.svelte | 6 ++++-- .../overview/platforms/wizard/apple/step3.svelte | 6 ++++-- .../overview/platforms/wizard/flutter/step3.svelte | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte index c3bb1ef2f..3c1792794 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte @@ -11,8 +11,10 @@ import io.appwrite.services.Account val client = Client(context) .setProject("${project}")${ - isSelfHosted ? ` - .setSelfSigned(status: true) // For self signed certificates, only use for development` : '' + isSelfHosted + ? ` + .setSelfSigned(status: true) // For self signed certificates, only use for development` + : '' }`; diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte index 136718c15..ad34f3045 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte @@ -10,8 +10,10 @@ let client = Client() .setProject("${project}")${ - isSelfHosted ? ` - .setSelfSigned(true) // For self signed certificates, only use for development` : '' + isSelfHosted + ? ` + .setSelfSigned(true) // For self signed certificates, only use for development` + : '' }`; let showAlert = true; diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte index 28fbcbce9..8214e87fd 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte @@ -11,8 +11,10 @@ Client client = Client(); client .setProject('${project}')${ - isSelfHosted ? ` - .setSelfSigned(status: true); // For self signed certificates, only use for development` : ';' + isSelfHosted + ? ` + .setSelfSigned(status: true); // For self signed certificates, only use for development` + : ';' }`; let showAlert = true; From 2fdae271d387f8b0de9a8e10cd1d6e0020a73208 Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Fri, 12 Jul 2024 17:44:03 +0530 Subject: [PATCH 4/5] update: show sdk init examples based on env. --- .../platforms/wizard/android/step3.svelte | 15 ++++++------- .../platforms/wizard/apple/step3.svelte | 21 ++++++++++--------- .../platforms/wizard/flutter/step3.svelte | 21 ++++++++++--------- .../platforms/wizard/web/step3.svelte | 11 ++++++++-- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte index 3c1792794..8ee923f7a 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/android/step3.svelte @@ -5,17 +5,18 @@ import { sdk } from '$lib/stores/sdk'; import { isSelfHosted } from '$lib/system'; - const { project } = sdk.forProject.client.config; + const { endpoint, project } = sdk.forProject.client.config; const code = `import io.appwrite.Client import io.appwrite.services.Account -val client = Client(context) - .setProject("${project}")${ - isSelfHosted - ? ` +${ + !isSelfHosted + ? `val client = Client(context).setProject("${project}")` + : `val client = Client(context) + .setEndpoint("${endpoint}") + .setProject("${project}") .setSelfSigned(status: true) // For self signed certificates, only use for development` - : '' - }`; +}`; diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte index ad34f3045..00274d637 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/apple/step3.svelte @@ -5,16 +5,17 @@ import { sdk } from '$lib/stores/sdk'; import Id from '$lib/components/id.svelte'; - const { project } = sdk.forProject.client.config; + const { endpoint, project } = sdk.forProject.client.config; const code = `import Appwrite -let client = Client() - .setProject("${project}")${ - isSelfHosted - ? ` +${ + !isSelfHosted + ? `let client = Client().setProject("${project}")` + : `let client = Client() + .setEndpoint("${endpoint}") + .setProject("${project}") .setSelfSigned(true) // For self signed certificates, only use for development` - : '' - }`; +}`; let showAlert = true; @@ -24,9 +25,9 @@ let client = Client()

Initialize your SDK

- Initialize your SDK by pointing the client to your Appwrite project using your Project ID. + Initialize your SDK by pointing the client to your Appwrite project using your + Project ID + .

diff --git a/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte b/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte index 8214e87fd..9b186e5cb 100644 --- a/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte +++ b/src/routes/console/project-[project]/overview/platforms/wizard/flutter/step3.svelte @@ -5,17 +5,18 @@ import { sdk } from '$lib/stores/sdk'; import Id from '$lib/components/id.svelte'; - const { project } = sdk.forProject.client.config; + const { endpoint, project } = sdk.forProject.client.config; const code = `import 'package:appwrite/appwrite.dart'; Client client = Client(); -client - .setProject('${project}')${ - isSelfHosted - ? ` - .setSelfSigned(status: true); // For self signed certificates, only use for development` - : ';' - }`; +${ + !isSelfHosted + ? `client.setProject('${project}');` + : `client + .setEndpoint('${endpoint}') + .setProject('${project}') + .setSelfSigned(status: true); // For self signed certificates, only use for development;` +}`; let showAlert = true; @@ -25,8 +26,8 @@ client

Initialize your SDK

- Initialize your SDK by pointing the client to your Appwrite project using your Project ID + Initialize your SDK by pointing the client to your Appwrite project using your + Project ID

From cd0f99d12488997a57021aaa10b77ecdc212d073 Mon Sep 17 00:00:00 2001 From: ItzNotABug Date: Tue, 8 Oct 2024 13:23:47 +0530 Subject: [PATCH 5/5] fix: syntaxes. --- .../platforms/wizard/android/step3.svelte | 4 ++-- .../overview/platforms/wizard/apple/step3.svelte | 6 +++--- .../platforms/wizard/flutter/step3.svelte | 6 +++--- .../platforms/wizard/react-native/step3.svelte | 16 ++++++++++------ .../overview/platforms/wizard/web/step3.svelte | 5 ++--- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/routes/(console)/project-[project]/overview/platforms/wizard/android/step3.svelte b/src/routes/(console)/project-[project]/overview/platforms/wizard/android/step3.svelte index 8ee923f7a..e2c956664 100644 --- a/src/routes/(console)/project-[project]/overview/platforms/wizard/android/step3.svelte +++ b/src/routes/(console)/project-[project]/overview/platforms/wizard/android/step3.svelte @@ -3,14 +3,14 @@ import Id from '$lib/components/id.svelte'; import { WizardStep } from '$lib/layout'; import { sdk } from '$lib/stores/sdk'; - import { isSelfHosted } from '$lib/system'; + import { isCloud } from '$lib/system'; const { endpoint, project } = sdk.forProject.client.config; const code = `import io.appwrite.Client import io.appwrite.services.Account ${ - !isSelfHosted + isCloud ? `val client = Client(context).setProject("${project}")` : `val client = Client(context) .setEndpoint("${endpoint}") diff --git a/src/routes/(console)/project-[project]/overview/platforms/wizard/apple/step3.svelte b/src/routes/(console)/project-[project]/overview/platforms/wizard/apple/step3.svelte index 00274d637..8ae1e3d86 100644 --- a/src/routes/(console)/project-[project]/overview/platforms/wizard/apple/step3.svelte +++ b/src/routes/(console)/project-[project]/overview/platforms/wizard/apple/step3.svelte @@ -1,7 +1,7 @@ @@ -40,7 +44,7 @@ const client Before sending any API calls to your new Appwrite project, make sure your device or emulator has network access to your Appwrite project's hostname or IP address.

- {#if showAlert && isSelfHosted} + {#if showAlert && !isCloud}
(showAlert = false)}> For self-hosted solutions diff --git a/src/routes/(console)/project-[project]/overview/platforms/wizard/web/step3.svelte b/src/routes/(console)/project-[project]/overview/platforms/wizard/web/step3.svelte index d764b94a2..e9b820208 100644 --- a/src/routes/(console)/project-[project]/overview/platforms/wizard/web/step3.svelte +++ b/src/routes/(console)/project-[project]/overview/platforms/wizard/web/step3.svelte @@ -3,13 +3,12 @@ import Id from '$lib/components/id.svelte'; import { WizardStep } from '$lib/layout'; import { sdk } from '$lib/stores/sdk'; - import { isSelfHosted } from '$lib/system'; + import { isCloud } from '$lib/system'; const { endpoint, project } = sdk.forProject.client.config; const code = `const client = new Client(); - ${ - !isSelfHosted + isCloud ? `client.setProject('${project}');` : `client .setEndpoint('${endpoint}')