[WIP] v2 #11

Draft
ashpie wants to merge 5 commits from v2 into develop
88 changed files with 9877 additions and 7485 deletions

13
.eslintignore Normal file
View File

@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

View File

@ -1,135 +1,30 @@
module.exports = { module.exports = {
root: true, root: true,
parser: '@typescript-eslint/parser',
plugins: [
'svelte3',
'@typescript-eslint',
'import',
'simple-import-sort',
],
parserOptions: {
tsconfigRootDir: __dirname,
project: [
'./tsconfig.test.json',
'./src/tsconfig.json',
'./src/common/tsconfig.json',
'./src/assets/ts/tsconfig.eslint.json',
'./src/assets/views/tsconfig.json',
]
},
extends: [ extends: [
'eslint:recommended', 'eslint:recommended',
'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
], ],
rules: { parser: '@typescript-eslint/parser',
indent: [ plugins: ['@typescript-eslint'],
'error', parserOptions: {
4, sourceType: 'module',
{ ecmaVersion: 2020,
SwitchCase: 1 extraFileExtensions: ['.svelte']
} },
], env: {
'no-trailing-spaces': 'error', browser: true,
'max-len': [ es2017: true,
'error', node: true
{
code: 120,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true
}
],
semi: 'off',
'@typescript-eslint/semi': [
'error'
],
'no-extra-semi': 'error',
'eol-last': 'error',
'comma-dangle': 'off',
'simple-import-sort/imports': 'error',
'no-extra-parens': 'off',
'no-nested-ternary': 'error',
'no-return-await': 'off',
'no-useless-return': 'error',
'no-useless-constructor': 'off',
'import/extensions': ['error', 'ignorePackages'],
'@typescript-eslint/comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
enums: 'always-multiline',
generics: 'always-multiline',
tuples: 'always-multiline'
}
],
'@typescript-eslint/no-extra-parens': [
'error'
],
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_'
}
],
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-useless-constructor': [
'error'
],
'@typescript-eslint/return-await': [
'error',
'always'
],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'explicit'
}
],
'@typescript-eslint/no-floating-promises': 'error',
}, },
ignorePatterns: [
'.eslintrc.js',
'rollup.config.js',
'jest.config.js',
'dist/**/*',
'config/**/*',
'intermediates/**/*',
'public/**/*',
'scripts/**/*',
'src/frontend/register_svelte/register_svelte.js',
],
overrides: [ overrides: [
{ {
files: [ files: ['*.svelte'],
'test/**/*' parser: 'svelte-eslint-parser',
], parserOptions: {
rules: { parser: '@typescript-eslint/parser'
'max-len': [ }
'error',
{
code: 120,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
ignoreStrings: true
} }
] ]
} };
},
{
files: ['*.svelte'],
processor: 'svelte3/svelte3'
}
],
settings: {
'svelte3/typescript': require('typescript'),
'svelte3/ignore-styles': function (attributes) {
return !!(attributes['lang'] && attributes['lang'] !== 'css');
}
},
}

21
.gitignore vendored
View File

@ -1,13 +1,12 @@
.DS_Store
node_modules node_modules
.idea /build
public /.svelte-kit
dist /package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
yarn-error.log yarn-error.log
storage/tmp /.idea
storage/uploads
config/local.*
src/package.json
intermediates/
dist/

2
.npmrc Normal file
View File

@ -0,0 +1,2 @@
engine-strict=true
resolution-mode=highest

13
.prettierignore Normal file
View File

@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

9
.prettierrc Normal file
View File

@ -0,0 +1,9 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}

View File

@ -1,3 +1,38 @@
# ily.li is a simple file self-hosting solution # create-svelte
Boilerplate for a quickstart with [swaf](https://eternae.ink/arisu/swaf) Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
## Creating a project
If you're seeing this, you've probably already done this step. Congrats!
```bash
# create a new project in the current directory
npm create svelte@latest
# create a new project in my-app
npm create svelte@latest my-app
```
## Developing
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
```bash
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
```
## Building
To create a production version of your app:
```bash
npm run build
```
You can preview the production build with `npm run preview`.
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.

135
oldsrc/.eslintrc.cjs Normal file
View File

@ -0,0 +1,135 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'svelte3',
'@typescript-eslint',
'import',
'simple-import-sort',
],
parserOptions: {
tsconfigRootDir: __dirname,
project: [
'./tsconfig.test.json',
'./src/tsconfig.json',
'./src/common/tsconfig.json',
'./src/assets/ts/tsconfig.eslint.json',
'./src/assets/views/tsconfig.json',
]
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
indent: [
'error',
4,
{
SwitchCase: 1
}
],
'no-trailing-spaces': 'error',
'max-len': [
'error',
{
code: 120,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true
}
],
semi: 'off',
'@typescript-eslint/semi': [
'error'
],
'no-extra-semi': 'error',
'eol-last': 'error',
'comma-dangle': 'off',
'simple-import-sort/imports': 'error',
'no-extra-parens': 'off',
'no-nested-ternary': 'error',
'no-return-await': 'off',
'no-useless-return': 'error',
'no-useless-constructor': 'off',
'import/extensions': ['error', 'ignorePackages'],
'@typescript-eslint/comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
enums: 'always-multiline',
generics: 'always-multiline',
tuples: 'always-multiline'
}
],
'@typescript-eslint/no-extra-parens': [
'error'
],
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_'
}
],
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-useless-constructor': [
'error'
],
'@typescript-eslint/return-await': [
'error',
'always'
],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'explicit'
}
],
'@typescript-eslint/no-floating-promises': 'error',
},
ignorePatterns: [
'.eslintrc.js',
'rollup.config.js',
'jest.config.js',
'dist/**/*',
'config/**/*',
'intermediates/**/*',
'public/**/*',
'scripts/**/*',
'src/frontend/register_svelte/register_svelte.js',
],
overrides: [
{
files: [
'test/**/*'
],
rules: {
'max-len': [
'error',
{
code: 120,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
ignoreStrings: true
}
]
}
},
{
files: ['*.svelte'],
processor: 'svelte3/svelte3'
}
],
settings: {
'svelte3/typescript': require('typescript'),
'svelte3/ignore-styles': function (attributes) {
return !!(attributes['lang'] && attributes['lang'] !== 'css');
}
},
}

13
oldsrc/.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
node_modules
.idea
public
dist
yarn-error.log
storage/tmp
storage/uploads
config/local.*
src/package.json
intermediates/
dist/

3
oldsrc/README.md Normal file
View File

@ -0,0 +1,3 @@
# ily.li is a simple file self-hosting solution
Boilerplate for a quickstart with [swaf](https://eternae.ink/arisu/swaf)

59
oldsrc/package.json Normal file
View File

@ -0,0 +1,59 @@
{
"name": "ily.li",
"version": "1.1.0",
"description": "Self-hosted file pusher",
"repository": "https://eternae.ink/ashpie/ily.li",
"author": "Alice Gaudon <alice@gaudon.pro>",
"license": "GPL-3.0-only",
"main": "dist/main.js",
"scripts": {
"test": "jest --verbose --runInBand",
"clean": "node scripts/clean.js",
"prepare-sources": "node scripts/prepare-sources.js",
"compile": "yarn clean && yarn prepare-sources && tsc --build",
"build": "yarn compile && node . pre-compile-views && node scripts/dist.js",
"build-production": "NODE_ENV=production yarn build",
"dev": "yarn compile && concurrently -k -n \"Maildev,Typescript,ViewPreCompile,Node\" -p \"[{name}]\" -c \"yellow,blue,red,green\" \"maildev\" \"tsc --build --watch --preserveWatchOutput\" \"nodemon -i public -i intermediates -- pre-compile-views --watch\" \"nodemon -i public -i intermediates\"",
"lint": "eslint .",
"start": "yarn build-production && node ."
},
"devDependencies": {
"@tsconfig/svelte": "^3.0.0",
"@types/config": "^0.0.41",
"@types/express": "^4.17.6",
"@types/express-session": "^1.17.0",
"@types/formidable": "^2.0.0",
"@types/jest": "^27.0.3",
"@types/mysql": "^2.15.15",
"@types/node": "^17.0.4",
"@types/nodemailer": "^6.4.0",
"@types/nunjucks": "^3.1.3",
"@types/ws": "^8.2.0",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"concurrently": "^7.0.0",
"eslint": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-svelte3": "^3.2.1",
"imagemin-gifsicle": "^7.0.0",
"imagemin-mozjpeg": "^10.0.0",
"imagemin-pngquant": "^9.0.2",
"imagemin-svgo": "^10.0.0",
"imagemin-webp": "^7.0.0",
"jest": "^27.0.4",
"maildev": "^1.1.0",
"nodemon": "^2.0.3",
"sass": "^1.32.12",
"svelte": "^3.44.2",
"svgo": "^2.3.0",
"ts-jest": "^27.0.3",
"typescript": "^4.0.2"
},
"dependencies": {
"config": "^3.3.1",
"express": "^4.17.1",
"formidable": "^2.0.1",
"swaf": "^0.25.1"
}
}

43
oldsrc/tsconfig.json Normal file
View File

@ -0,0 +1,43 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"declaration": true,
"stripInternal": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"strictNullChecks": true,
"moduleResolution": "Node",
"esModuleInterop": true,
"baseUrl": "dist",
"inlineSourceMap": true,
"inlineSources": true,
"outDir": "dist",
"typeRoots": [
"node_modules/@types",
"src/types"
],
"lib": [
"es2020",
"dom"
],
"resolveJsonModule": true,
"skipLibCheck": true,
"allowJs": true
},
"include": [],
"references": [
{
"path": "src",
},
{
"path": "src/assets/ts",
},
{
"path": "src/assets/views",
}
]
}

8150
oldsrc/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,59 +1,41 @@
{ {
"name": "ily.li", "name": "ily.li",
"version": "1.1.0", "version": "2.0.0",
"description": "Self-hosted file pusher", "private": true,
"repository": "https://eternae.ink/ashpie/ily.li",
"author": "Alice Gaudon <alice@gaudon.pro>",
"license": "GPL-3.0-only",
"main": "dist/main.js",
"scripts": { "scripts": {
"test": "jest --verbose --runInBand", "dev": "vite dev",
"clean": "node scripts/clean.js", "build": "vite build",
"prepare-sources": "node scripts/prepare-sources.js", "preview": "vite preview",
"compile": "yarn clean && yarn prepare-sources && tsc --build", "test": "npm run test:integration && npm run test:unit",
"build": "yarn compile && node . pre-compile-views && node scripts/dist.js", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"build-production": "NODE_ENV=production yarn build", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"dev": "yarn compile && concurrently -k -n \"Maildev,Typescript,ViewPreCompile,Node\" -p \"[{name}]\" -c \"yellow,blue,red,green\" \"maildev\" \"tsc --build --watch --preserveWatchOutput\" \"nodemon -i public -i intermediates -- pre-compile-views --watch\" \"nodemon -i public -i intermediates\"", "lint": "prettier --plugin-search-dir . --check . && eslint .",
"lint": "eslint .", "format": "prettier --plugin-search-dir . --write .",
"start": "yarn build-production && node ." "test:integration": "playwright test",
"test:unit": "vitest"
}, },
"devDependencies": { "devDependencies": {
"@tsconfig/svelte": "^3.0.0", "@playwright/test": "^1.28.1",
"@types/config": "^0.0.41", "@sveltejs/adapter-auto": "^2.0.0",
"@types/express": "^4.17.6", "@sveltejs/adapter-node": "^1.3.1",
"@types/express-session": "^1.17.0", "@sveltejs/kit": "^1.20.4",
"@types/formidable": "^2.0.0", "@typescript-eslint/eslint-plugin": "^5.45.0",
"@types/jest": "^27.0.3", "@typescript-eslint/parser": "^5.45.0",
"@types/mysql": "^2.15.15", "eslint": "^8.28.0",
"@types/node": "^17.0.4", "eslint-config-prettier": "^8.5.0",
"@types/nodemailer": "^6.4.0", "eslint-plugin-svelte": "^2.30.0",
"@types/nunjucks": "^3.1.3", "lucide-svelte": "^0.354.0",
"@types/ws": "^8.2.0", "piekit-front": "../piekit-front",
"@typescript-eslint/eslint-plugin": "^5.4.0", "prettier": "^2.8.0",
"@typescript-eslint/parser": "^5.4.0", "prettier-plugin-svelte": "^2.10.1",
"concurrently": "^7.0.0", "sass": "^1.64.2",
"eslint": "^8.3.0", "svelte": "^4.0.5",
"eslint-plugin-import": "^2.25.3", "svelte-check": "^3.4.3",
"eslint-plugin-simple-import-sort": "^7.0.0", "tslib": "^2.4.1",
"eslint-plugin-svelte3": "^3.2.1", "typescript": "^5.0.0",
"imagemin-gifsicle": "^7.0.0", "vite": "^4.4.2",
"imagemin-mozjpeg": "^10.0.0", "vitest": "^0.32.2"
"imagemin-pngquant": "^9.0.2",
"imagemin-svgo": "^10.0.0",
"imagemin-webp": "^7.0.0",
"jest": "^27.0.4",
"maildev": "^1.1.0",
"nodemon": "^2.0.3",
"sass": "^1.32.12",
"svelte": "^3.44.2",
"svgo": "^2.3.0",
"ts-jest": "^27.0.3",
"typescript": "^4.0.2"
}, },
"dependencies": { "type": "module",
"config": "^3.3.1", "dependencies": {}
"express": "^4.17.1",
"formidable": "^2.0.1",
"swaf": "^0.25.1"
}
} }

12
playwright.config.ts Normal file
View File

@ -0,0 +1,12 @@
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173
},
testDir: 'tests',
testMatch: /(.+\.)?(test|spec)\.[jt]s/
};
export default config;

12
src/app.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
}
export {};

12
src/app.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>

View File

@ -1,25 +0,0 @@
<script>
import BaseTemplate from "./templates/BaseTemplate.svelte";
import {locals} from "../ts/stores";
import Icon from "./utils/Icon.svelte";
</script>
<BaseTemplate title="{$locals.app.name} - About us"
description="Simple, self-hosted file hosting and link shrinking solution. Power lies in simplicity."
noH1>
<h1>Self-hosting files</h1>
<div class="container">
<section class="panel">
<h2>What is ily.li?</h2>
<p>ily.li is a simple, self-hosted file sharing/hosting and link shrinking platform. It is based on <a href="https://eternae.ink/ashpie/swaf" target="_blank">swaf</a>.</p>
<nav>
<ul>
<li>
<a href="https://eternae.ink/ashpie/ily.li" target="_blank"><Icon name="code"/> Repository</a>
</li>
</ul>
</nav>
</section>
</div>
</BaseTemplate>

7
src/index.test.ts Normal file
View File

@ -0,0 +1,7 @@
import { describe, it, expect } from 'vitest';
describe('sum test', () => {
it('adds 1 + 2 to equal 3', () => {
expect(1 + 2).toBe(3);
});
});

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

1
src/lib/index.ts Normal file
View File

@ -0,0 +1 @@
// place files you want to import through the `$lib` alias in this folder.

View File

@ -0,0 +1,8 @@
<script>
import {page} from "$app/stores";
import {BaseLayout} from "piekit-front";
import logo from "../lib/img/logo.svg";
</script>
<BaseLayout title={$page.data.title} h1={$page.data.h1} description={$page.data.description} logo={logo}>
<slot/>
</BaseLayout>

5
src/routes/+page.svelte Normal file
View File

@ -0,0 +1,5 @@
<script>
import {page} from "$app/stores";
</script>
<p>{$page.data.description}</p>

9
src/routes/+page.ts Normal file
View File

@ -0,0 +1,9 @@
import type {PageLoad} from './$types';
export const load: PageLoad = () => {
return {
title: ' - Home Page',
description: 'Simple, self-hosted file hosting and link shrinking solution. Power lies in simplicity.',
h1: 'Self-hosting files',
};
};

View File

@ -0,0 +1,17 @@
<script>
import {Icon} from "piekit-front";
</script>
<div class="container">
<section class="panel">
<h2>What is ily.li?</h2>
<p>ily.li is a simple, self-hosted file sharing/hosting and link shrinking platform. It is based on <a href="https://git.kma.sh/ashpie/piekit-front" target="_blank">piekit-front</a>.</p>
<nav>
<ul>
<li>
<a href="https://git.kma.sh/ashpie/ily.li" target="_blank"><Icon name="code"/> Repository</a>
</li>
</ul>
</nav>
</section>
</div>

View File

@ -0,0 +1,9 @@
import type {PageLoad} from './$types';
export const load: PageLoad = () => {
return {
title: ' - About us',
description: 'Simple, self-hosted file hosting and link shrinking solution. Power lies in simplicity.',
h1: 'Self-hosting files',
};
};

BIN
static/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1 +0,0 @@
/*

18
svelte.config.js Normal file
View File

@ -0,0 +1,18 @@
import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/kit/vite';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: {
adapter: adapter(),
version: {
name: process.env.npm_package_version
}
}
};
export default config;

6
tests/test.ts Normal file
View File

@ -0,0 +1,6 @@
import { expect, test } from '@playwright/test';
test('index page has expected h1', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('heading', { name: 'Welcome to SvelteKit' })).toBeVisible();
});

View File

@ -1,43 +1,17 @@
{ {
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": { "compilerOptions": {
"target": "ESNext", "allowJs": true,
"module": "ESNext", "checkJs": true,
"declaration": true,
"stripInternal": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"strictNullChecks": true,
"moduleResolution": "Node",
"esModuleInterop": true, "esModuleInterop": true,
"baseUrl": "dist", "forceConsistentCasingInFileNames": true,
"inlineSourceMap": true,
"inlineSources": true,
"outDir": "dist",
"typeRoots": [
"node_modules/@types",
"src/types"
],
"lib": [
"es2020",
"dom"
],
"resolveJsonModule": true, "resolveJsonModule": true,
"skipLibCheck": true, "skipLibCheck": true,
"allowJs": true "sourceMap": true,
}, "strict": true
"include": [],
"references": [
{
"path": "src",
},
{
"path": "src/assets/ts",
},
{
"path": "src/assets/views",
} }
] // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
} }

9
vite.config.ts Normal file
View File

@ -0,0 +1,9 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
export default defineConfig({
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
}
});

8396
yarn.lock

File diff suppressed because it is too large Load Diff