feat: prepare for deployment

When trying to deploy the application to my own domain I noticed that
the adapter is wrong. Since I'm not hosting anything in „the Cloud” I
went with a plain Node.js server. Therefore I have to use a specific
adapter and also fix the type of the server response. This in turn
uncovered a bug in the Created component which I also fixed.

Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
This commit is contained in:
André Jaenisch 2024-04-12 15:53:14 +02:00
parent 08e739440e
commit 2252cf42fd
No known key found for this signature in database
GPG key ID: 5A668E771F1ED854
6 changed files with 1041 additions and 435 deletions

1398
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -19,42 +19,42 @@
"format": "prettier --write ." "format": "prettier --write ."
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "1.42.1", "@playwright/test": "1.43.0",
"@skeletonlabs/skeleton": "2.9.0", "@skeletonlabs/skeleton": "2.9.1",
"@skeletonlabs/tw-plugin": "0.3.1", "@skeletonlabs/tw-plugin": "0.4.0",
"@sveltejs/adapter-auto": "3.1.1", "@sveltejs/adapter-node": "5.0.1",
"@sveltejs/kit": "2.5.2", "@sveltejs/kit": "2.5.5",
"@sveltejs/vite-plugin-svelte": "3.0.2", "@sveltejs/vite-plugin-svelte": "3.1.0",
"@tailwindcss/forms": "0.5.7", "@tailwindcss/forms": "0.5.7",
"@tailwindcss/typography": "0.5.10", "@tailwindcss/typography": "0.5.12",
"@tauri-apps/cli": "1.5.11", "@tauri-apps/cli": "1.5.11",
"@testing-library/jest-dom": "6.4.2", "@testing-library/jest-dom": "6.4.2",
"@testing-library/svelte": "4.1.0", "@testing-library/svelte": "4.1.0",
"@types/node": "20.11.24", "@types/node": "20.12.7",
"@typescript-eslint/eslint-plugin": "7.1.1", "@typescript-eslint/eslint-plugin": "7.6.0",
"@typescript-eslint/parser": "7.1.1", "@typescript-eslint/parser": "7.6.0",
"@vitest/coverage-v8": "1.3.1", "@vitest/coverage-v8": "1.5.0",
"autoprefixer": "10.4.18", "autoprefixer": "10.4.19",
"eslint": "8.57.0", "eslint": "8.57.0",
"eslint-config-prettier": "9.1.0", "eslint-config-prettier": "9.1.0",
"eslint-plugin-svelte": "2.35.1", "eslint-plugin-svelte": "2.37.0",
"jsdom": "24.0.0", "jsdom": "24.0.0",
"postcss": "8.4.35", "postcss": "8.4.38",
"prettier": "3.2.5", "prettier": "3.2.5",
"prettier-plugin-svelte": "3.2.2", "prettier-plugin-svelte": "3.2.2",
"svelte": "4.2.12", "svelte": "4.2.13",
"svelte-check": "3.6.6", "svelte-check": "3.6.9",
"svelte-i18n": "4.0.0", "svelte-i18n": "4.0.0",
"svelte-octicons": "18.7.1", "svelte-octicons": "18.7.1",
"tailwindcss": "3.4.1", "tailwindcss": "3.4.3",
"tslib": "2.6.2", "tslib": "2.6.2",
"typescript": "5.3.3", "typescript": "5.4.5",
"vite": "5.1.5", "vite": "5.2.8",
"vitest": "1.3.1" "vitest": "1.5.0"
}, },
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"axios": "1.6.7", "axios": "1.6.8",
"cheerio": "1.0.0-rc.12" "cheerio": "1.0.0-rc.12"
} }
} }

View file

@ -27,5 +27,5 @@ You should have received a copy of the GNU Affero General Public License along w
</script> </script>
{#if created_at && created_at_formatted} {#if created_at && created_at_formatted}
<span>created <date datetime={created_at}>{@html created_at_formatted}</date></span> <span>created <time datetime={created_at?.toISOString()}>{@html created_at_formatted}</time></span>
{/if} {/if}

View file

@ -14,7 +14,6 @@ import { requests } from '$lib/server/ap.js';
/** @type {import('./$types').PageServerLoad} */ /** @type {import('./$types').PageServerLoad} */
export async function load({ params }) { export async function load({ params }) {
const locale = 'en-US';
const profile = await requests.get('/profile'); const profile = await requests.get('/profile');
return { return {
@ -23,7 +22,7 @@ export async function load({ params }) {
}, },
user: { user: {
...profile, ...profile,
created_at_formatted: new Intl.DateTimeFormat(locale).format(new Date(profile.created_at)), created_at: new Date(profile.created_at),
created_with: 'Anvil', created_with: 'Anvil',
instance: 'example.com' instance: 'example.com'
} }

View file

@ -1,8 +1,9 @@
// SPDX-FileCopyrightText: 2023 Pere Lev // SPDX-FileCopyrightText: 2023 Pere Lev
// SPDX-FileCopyrightText: 2024 André Jaenisch
// //
// SPDX-License-Identifier: AGPL-3.0-or-later // SPDX-License-Identifier: AGPL-3.0-or-later
import adapter from '@sveltejs/adapter-auto'; import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */ /** @type {import('@sveltejs/kit').Config} */

View file

@ -28,7 +28,7 @@ describe('Created.svelte', () => {
}); });
describe('when no created_at is passed', () => { describe('when no created_at is passed', () => {
describe('when no created_at_formatted is passed', () => { describe('when no locale is passed', () => {
it('should be empty', () => { it('should be empty', () => {
// Arrange // Arrange
// Nothing to prepare // Nothing to prepare
@ -41,13 +41,13 @@ describe('Created.svelte', () => {
}); });
}); });
describe('when created_at_formatted is passed', () => { describe('when locale is passed', () => {
it('should be empty', () => { it('should be empty', () => {
// Arrange // Arrange
const created_at_formatted = '2024-02-11'; const locale = 'he';
// Act // Act
const { container } = render(Created, { created_at_formatted }); const { container } = render(Created, { locale });
// Assert // Assert
expect(container.textContent).toEqual(''); expect(container.textContent).toEqual('');
@ -56,8 +56,8 @@ describe('Created.svelte', () => {
}); });
describe('when created_at is passed', () => { describe('when created_at is passed', () => {
describe('when no created_at_formatted is passed', () => { describe('when no locale is passed', () => {
it('should be empty', () => { it('should render English formatted', () => {
// Arrange // Arrange
const created_at = new Date(); const created_at = new Date();
@ -65,23 +65,23 @@ describe('Created.svelte', () => {
const { container } = render(Created, { created_at }); const { container } = render(Created, { created_at });
// Assert // Assert
expect(container.textContent).toEqual(''); expect(container.textContent).toContain('created');
}); });
}); });
describe('when created_at_formatted is passed', () => { describe('when locale is passed', () => {
it('should be empty', () => { it('should render formatted in that locale', () => {
// Arrange // Arrange
const created_at = new Date().toISOString(); const created_at = new Date();
const created_at_formatted = created_at.toString(); const locale = 'de'
// Act // Act
const { container } = render(Created, { created_at, created_at_formatted }); const { container } = render(Created, { created_at, locale });
// Assert // Assert
expect(container.textContent).not.toEqual(''); expect(container.textContent).not.toEqual('');
expect(screen.getByText(created_at_formatted)).toBeDefined(); expect(screen.getByText(new RegExp(created_at.getFullYear()))).toBeDefined();
expect(screen.getByText(created_at_formatted)).toHaveAttribute('datetime', created_at); expect(screen.getByText(new RegExp(created_at.getFullYear()))).toHaveAttribute('datetime', created_at.toISOString());
}); });
}); });
}); });