Merge pull request #733 from benmccann/sveltekit2

upgrade to SvelteKit 2
This commit is contained in:
Torsten Dittmann authored and GitHub committed 2024-01-30 15:45:42 +01:00
commit e11d9858ad
31 files changed
+1252 -934

No files matched your search

+1206 -871
View File
File diff suppressed because it is too large. Load diff
+7 -7
View File
@@ -44,9 +44,9 @@
"@melt-ui/pp": "^0.1.4",
"@melt-ui/svelte": "^0.61.2",
"@playwright/test": "^1.37.1",
"@sveltejs/adapter-static": "^2.0.3",
"@sveltejs/kit": "^1.24.0",
"@sveltejs/vite-plugin-svelte": "^2.4.5",
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/kit": "^2.3.4",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@testing-library/dom": "^9.0.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/svelte": "^4.0.3",
@@ -55,7 +55,7 @@
"@types/prismjs": "^1.26.0",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"@vitest/ui": "^0.29.7",
"@vitest/ui": "^1.2.1",
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-svelte": "^2.33.0",
@@ -64,15 +64,15 @@
"prettier": "^3.2.2",
"prettier-plugin-svelte": "^3.1.2",
"sass": "^1.66.1",
"svelte": "^4.2.0",
"svelte": "^4.2.9",
"svelte-check": "^3.5.1",
"svelte-jester": "^2.3.2",
"svelte-preprocess": "^5.0.4",
"svelte-sequential-preprocessor": "^2.0.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vitest": "^0.29.7"
"vite": "^5.0.11",
"vitest": "^1.2.1"
},
"type": "module"
}
+2 -2
View File
@@ -22,7 +22,7 @@ export const load: LayoutLoad = async ({ depends, url }) => {
return {
account,
organizations: sdk.forConsole.teams.list()
organizations: await sdk.forConsole.teams.list()
};
} catch (error) {
const acceptedRoutes = [
@@ -41,7 +41,7 @@ export const load: LayoutLoad = async ({ depends, url }) => {
const redirectUrl =
url.pathname && url.pathname !== '/' ? `redirect=${url.pathname}` : '';
const path = url.search ? `${url.search}&${redirectUrl}` : `?${redirectUrl}`;
throw redirect(303, `/login${path}`);
redirect(303, `/login${path}`);
}
}
};
+2 -4
View File
@@ -4,9 +4,7 @@ import type { PageLoad } from './$types';
import { user } from '$lib/stores/user';
export const load: PageLoad = async () => {
if (user) {
return;
} else {
throw redirect(302, `${base}/login`);
if (!user) {
redirect(302, `${base}/login`);
}
};
+1 -2
View File
@@ -1,5 +1,4 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { Heading } from '$lib/components';
import { Account, Client } from '@appwrite.io/console';
@@ -18,7 +17,7 @@
const secret = $page.url.searchParams.get('secret');
await account.updateMagicURLSession(userId, secret);
await goto(`appwrite-callback-${projectId}://${$page.url.search}`);
window.location.href = `appwrite-callback-${projectId}://${$page.url.search}`;
});
</script>
+2 -7
View File
@@ -1,20 +1,15 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { Heading } from '$lib/components';
const project = $page.url.searchParams.get('project');
const link = `appwrite-callback-${project}://${$page.url.search}`;
const redirect = new Promise((resolve, reject) => {
const redirect = new Promise((_resolve, reject) => {
if (!project) {
reject('no-project');
}
// this timeout is needed because goto does not
// throw an exception if the redirect does not work
setTimeout(() => reject('timeout'), 500);
// goto will resolve on successful redirect
goto(link).then(resolve);
window.location.href = link;
});
</script>
+2 -7
View File
@@ -1,20 +1,15 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { Heading } from '$lib/components';
const project = $page.url.searchParams.get('project');
const link = `appwrite-callback-${project}://${$page.url.search}`;
const redirect = new Promise((resolve, reject) => {
const redirect = new Promise((_resolve, reject) => {
if (!project) {
reject('no-project');
}
// this timeout is needed because goto does not
// throw an exception if the redirect does not work
setTimeout(() => reject('timeout'), 500);
// goto will resolve on successful redirect
goto(link).then(resolve);
window.location.href = link;
});
</script>
+3 -3
View File
@@ -2,9 +2,9 @@ import { isCloud } from '$lib/system';
import { redirect } from '@sveltejs/kit';
export async function load({ parent }) {
if (!isCloud) throw redirect(303, '/');
if (!isCloud) redirect(303, '/');
const { account } = await parent();
if (!account) throw redirect(303, '/login');
if (!account) redirect(303, '/login');
throw redirect(303, `/card/${account.$id}`);
redirect(303, `/card/${account.$id}`);
}
+2 -2
View File
@@ -36,7 +36,7 @@ export async function load({ params, url, parent }) {
const res = await fetch(frontImg);
if (!res.ok) {
throw redirect(303, '/');
redirect(303, '/');
}
return {
@@ -53,6 +53,6 @@ export async function load({ params, url, parent }) {
};
} catch (e) {
console.error(e);
throw redirect(303, '/');
redirect(303, '/');
}
}
+3 -3
View File
@@ -8,9 +8,9 @@ export const load: PageLoad = async ({ parent, url }) => {
if (organizations.total) {
const teamId = account.prefs.organization ?? organizations.teams[0].$id;
if (!teamId) {
throw redirect(303, `${base}/console/account/organizations${url.search ?? ''}`);
} else throw redirect(303, `${base}/console/organization-${teamId}${url.search ?? ''}`);
redirect(303, `${base}/console/account/organizations${url.search ?? ''}`);
} else redirect(303, `${base}/console/organization-${teamId}${url.search ?? ''}`);
} else {
throw redirect(303, `${base}/console/onboarding${url.search ?? ''}`);
redirect(303, `${base}/console/onboarding${url.search ?? ''}`);
}
};
@@ -45,6 +45,6 @@ export const load: LayoutLoad = async ({ params, depends }) => {
const newPrefs = { ...prefs, organization: null };
sdk.forConsole.account.updatePrefs(newPrefs);
localStorage.removeItem('organization');
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -25,6 +25,6 @@ export const load: LayoutLoad = async ({ params, depends }) => {
organization: await sdk.forConsole.teams.get(project.teamId)
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -3,5 +3,5 @@ import { base } from '$app/paths';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params }) => {
throw redirect(302, `${base}/console/project-${params.project}/overview`);
redirect(302, `${base}/console/project-${params.project}/overview`);
};
@@ -14,6 +14,6 @@ export const load: LayoutLoad = async ({ params, depends }) => {
team: await sdk.forProject.teams.get(params.team)
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -14,6 +14,6 @@ export const load: PageLoad = async ({ params }) => {
users: response.users as Metric[]
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -15,6 +15,6 @@ export const load: LayoutLoad = async ({ params, depends }) => {
user: await sdk.forProject.users.get(params.user)
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -15,6 +15,6 @@ export const load: LayoutLoad = async ({ params, depends }) => {
database: await sdk.forProject.databases.get(params.database)
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -23,6 +23,6 @@ export const load: LayoutLoad = async ({ params, depends }) => {
])
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -46,6 +46,6 @@ export const load: LayoutLoad = async ({ params, parent, depends }) => {
document
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -14,6 +14,6 @@ export const load: PageLoad = async ({ params }) => {
databases: response.databases as Metric[]
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -22,6 +22,6 @@ export const load: LayoutLoad = async ({ params, depends }) => {
])
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -15,6 +15,6 @@ export const load: PageLoad = async ({ params }) => {
executions: response.executions as Metric[]
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -6,8 +6,8 @@ import { selectedTab } from './store';
export const load: PageLoad = async ({ params }) => {
if (get(selectedTab) === 'keys') {
throw redirect(302, `${base}/console/project-${params.project}/overview/keys`);
redirect(302, `${base}/console/project-${params.project}/overview/keys`);
} else {
throw redirect(302, `${base}/console/project-${params.project}/overview/platforms`);
redirect(302, `${base}/console/project-${params.project}/overview/platforms`);
}
};
@@ -15,6 +15,6 @@ export const load: LayoutLoad = async ({ params, depends }) => {
webhook: await sdk.forConsole.projects.getWebhook(params.project, params.webhook)
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -15,6 +15,6 @@ export const load: LayoutLoad = async ({ params, depends }) => {
bucket: await sdk.forProject.storage.getBucket(params.bucket)
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -15,6 +15,6 @@ export const load: LayoutLoad = async ({ params, depends }) => {
file: await sdk.forProject.storage.getFile(params.bucket, params.file)
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
@@ -14,6 +14,6 @@ export const load: PageLoad = async ({ params }) => {
buckets: response.buckets as Metric[]
};
} catch (e) {
throw error(e.code, e.message);
error(e.code, e.message);
}
};
+2 -2
View File
@@ -2,7 +2,7 @@ import { isCloud } from '$lib/system';
import { redirect } from '@sveltejs/kit';
export async function load({ parent }) {
if (!isCloud) throw redirect(303, '/');
if (!isCloud) redirect(303, '/');
const { account } = await parent();
if (!account) throw redirect(303, '/login');
if (!account) redirect(303, '/login');
}
+1 -1
View File
@@ -4,6 +4,6 @@ import type { LayoutLoad } from './$types';
export const load: LayoutLoad = async () => {
if (isSelfHosted) {
throw error(501, 'Not available in self hosted.');
error(501, 'Not available in self hosted.');
}
};
-1
View File
@@ -5,7 +5,6 @@
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "Node",
"importsNotUsedAsValues": "error",
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
+1 -4
View File
@@ -19,9 +19,6 @@ const config = defineConfig({
define: {
'import.meta.env.VERCEL_ANALYTICS_ID': JSON.stringify(process.env.VERCEL_ANALYTICS_ID)
},
legacy: {
buildSsrCjsExternalHeuristics: true
},
server: {
port: 3000
}
@@ -36,7 +33,7 @@ const testConfig = defineConfig({
include: ['tests/unit/**/*.test.ts'],
environment: 'jsdom',
globals: true,
threads: true,
pool: 'threads',
setupFiles: ['./tests/unit/setup.ts'],
deps: {
inline: ['@analytics/type-utils']