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

View file

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

View file

@ -1,8 +1,9 @@
// SPDX-FileCopyrightText: 2023 Pere Lev
// SPDX-FileCopyrightText: 2024 André Jaenisch
//
// 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';
/** @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_formatted is passed', () => {
describe('when no locale is passed', () => {
it('should be empty', () => {
// Arrange
// 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', () => {
// Arrange
const created_at_formatted = '2024-02-11';
const locale = 'he';
// Act
const { container } = render(Created, { created_at_formatted });
const { container } = render(Created, { locale });
// Assert
expect(container.textContent).toEqual('');
@ -56,8 +56,8 @@ describe('Created.svelte', () => {
});
describe('when created_at is passed', () => {
describe('when no created_at_formatted is passed', () => {
it('should be empty', () => {
describe('when no locale is passed', () => {
it('should render English formatted', () => {
// Arrange
const created_at = new Date();
@ -65,23 +65,23 @@ describe('Created.svelte', () => {
const { container } = render(Created, { created_at });
// Assert
expect(container.textContent).toEqual('');
expect(container.textContent).toContain('created');
});
});
describe('when created_at_formatted is passed', () => {
it('should be empty', () => {
describe('when locale is passed', () => {
it('should render formatted in that locale', () => {
// Arrange
const created_at = new Date().toISOString();
const created_at_formatted = created_at.toString();
const created_at = new Date();
const locale = 'de'
// Act
const { container } = render(Created, { created_at, created_at_formatted });
const { container } = render(Created, { created_at, locale });
// Assert
expect(container.textContent).not.toEqual('');
expect(screen.getByText(created_at_formatted)).toBeDefined();
expect(screen.getByText(created_at_formatted)).toHaveAttribute('datetime', created_at);
expect(screen.getByText(new RegExp(created_at.getFullYear()))).toBeDefined();
expect(screen.getByText(new RegExp(created_at.getFullYear()))).toHaveAttribute('datetime', created_at.toISOString());
});
});
});