{error.stack}+ {/if} +
diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..fba3861 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,20 @@ +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], + plugins: ['svelte3', '@typescript-eslint'], + ignorePatterns: ['*.cjs'], + overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }], + settings: { + 'svelte3/typescript': () => require('typescript') + }, + parserOptions: { + sourceType: 'module', + ecmaVersion: 2019 + }, + env: { + browser: true, + es2017: true, + node: true + } +}; diff --git a/.gitignore b/.gitignore index f220e37..e700210 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .DS_Store -/node_modules/ -/src/node_modules/@sapper/ -yarn-error.log -/__sapper__/ +node_modules +/.svelte +/build +/functions diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..b6f27f1 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +engine-strict=true diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..844cfd1 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +.svelte/** +static/** +build/** +node_modules/** diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..ff2677e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "useTabs": true, + "singleQuote": true, + "trailingComma": "none", + "printWidth": 100 +} diff --git a/package.json b/package.json index 1d0e82a..4dcb44c 100644 --- a/package.json +++ b/package.json @@ -1,45 +1,34 @@ { - "name": "@damillora/rinze", - "description": "nanao.moe website, now in Svelte", - "version": "0.1.0", + "name": "~TODO~", + "version": "0.0.1", "scripts": { - "dev": "sapper dev", - "build": "sapper build --legacy", - "export": "sapper export --legacy", - "start": "node __sapper__/build" - }, - "dependencies": { - "@damillora/shian": "^2.0.0", - "compression": "^1.7.1", - "dayjs": "^1.10.4", - "howler": "^2.2.1", - "node-fetch": "^2.6.1", - "polka": "^1.0.0-next.14", - "sirv": "^1.0.0" + "dev": "svelte-kit dev", + "build": "svelte-kit build", + "preview": "svelte-kit preview", + "lint": "prettier --check . && eslint --ignore-path .gitignore .", + "format": "prettier --write ." }, "devDependencies": { - "@babel/core": "^7.0.0", - "@babel/plugin-syntax-dynamic-import": "^7.0.0", - "@babel/plugin-transform-runtime": "^7.0.0", - "@babel/preset-env": "^7.0.0", - "@babel/runtime": "^7.0.0", - "@rollup/plugin-alias": "^3.1.1", - "@rollup/plugin-babel": "^5.0.0", - "@rollup/plugin-commonjs": "^14.0.0", - "@rollup/plugin-node-resolve": "^8.0.0", - "@rollup/plugin-replace": "^2.2.0", - "@rollup/plugin-url": "^5.0.0", - "autoprefixer": "^10.2.3", - "clipboard": "^2.0.6", - "modern-normalize": "^1.0.0", - "node-sass": "^5.0.0", - "postcss": "^8.2.4", - "rollup": "^2.3.4", - "rollup-plugin-svelte": "^7.0.0", - "rollup-plugin-terser": "^7.0.0", - "sapper": "^0.28.0", - "svelte": "^3.17.3", - "svelte-preprocess": "^4.6.3" + "@sveltejs/kit": "next", + "@typescript-eslint/eslint-plugin": "^4.19.0", + "@typescript-eslint/parser": "^4.19.0", + "eslint": "^7.22.0", + "eslint-config-prettier": "^8.1.0", + "eslint-plugin-svelte3": "^3.2.0", + "prettier": "~2.2.1", + "prettier-plugin-svelte": "^2.2.0", + "svelte": "^3.29.0", + "svelte-preprocess": "^4.0.0", + "tslib": "^2.0.0", + "typescript": "^4.0.0", + "vite": "^2.2.3" }, - "license": "MIT" + "type": "module", + "dependencies": { + "@damillora/shian": "^2.0.1", + "@sveltejs/adapter-node": "^1.0.0-next.17", + "dayjs": "^1.10.4", + "howler": "^2.2.1", + "node-sass": "^5.0.0" + } } diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index 10a3a97..0000000 --- a/rollup.config.js +++ /dev/null @@ -1,139 +0,0 @@ -import path from 'path'; -import resolve from '@rollup/plugin-node-resolve'; -import replace from '@rollup/plugin-replace'; -import commonjs from '@rollup/plugin-commonjs'; -import url from '@rollup/plugin-url'; -import svelte from 'rollup-plugin-svelte'; -import babel from '@rollup/plugin-babel'; -import alias from '@rollup/plugin-alias'; -import { terser } from 'rollup-plugin-terser'; -import config from 'sapper/config/rollup.js'; -import pkg from './package.json'; -import sveltePreprocess from 'svelte-preprocess'; - -const mode = process.env.NODE_ENV; -const dev = mode === 'development'; -const legacy = !!process.env.SAPPER_LEGACY_BUILD; - -const onwarn = (warning, onwarn) => - (warning.code === 'MISSING_EXPORT' && /'preload'/.test(warning.message)) || - (warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) || - onwarn(warning); - -const preprocess = sveltePreprocess({ - scss: { - includePaths: ['src'], - }, - postcss: { - plugins: [require('autoprefixer')], - }, -}); - -export default { - client: { - input: config.client.input(), - output: config.client.output(), - plugins: [ - alias({ - resolve: ['.jpg', '.js', '.svelte','.scss'], // optional, by default this will just look for .js files or folders - entries: [ - { find: '@', replacement: path.resolve(__dirname, 'src') }, - ] - }), - replace({ - 'process.browser': true, - 'process.env.NODE_ENV': JSON.stringify(mode) - }), - svelte({ - compilerOptions: { - dev, - hydratable: true, - }, - preprocess, - }), - url({ - sourceDir: path.resolve(__dirname, 'src/node_modules/images'), - publicPath: '/client/' - }), - resolve({ - browser: true, - dedupe: ['svelte'] - }), - commonjs(), - - legacy && babel({ - extensions: ['.js', '.mjs', '.html', '.svelte'], - babelHelpers: 'runtime', - exclude: ['node_modules/@babel/**'], - presets: [ - ['@babel/preset-env', { - targets: '> 0.25%, not dead' - }] - ], - plugins: [ - '@babel/plugin-syntax-dynamic-import', - ['@babel/plugin-transform-runtime', { - useESModules: true - }] - ] - }), - - !dev && terser({ - module: true - }) - ], - - preserveEntrySignatures: false, - onwarn, - }, - - server: { - input: config.server.input(), - output: config.server.output(), - plugins: [ - replace({ - 'process.browser': false, - 'process.env.NODE_ENV': JSON.stringify(mode) - }), - svelte({ - compilerOptions: { - dev, - generate: 'ssr', - hydratable: true - }, - emitCss: false, - preprocess, - }), - url({ - sourceDir: path.resolve(__dirname, 'src/node_modules/images'), - publicPath: '/client/', - emitFiles: false // already emitted by client build - }), - resolve({ - dedupe: ['svelte'] - }), - commonjs() - ], - external: Object.keys(pkg.dependencies).concat(require('module').builtinModules), - - preserveEntrySignatures: 'strict', - onwarn, - }, - - serviceworker: { - input: config.serviceworker.input(), - output: config.serviceworker.output(), - plugins: [ - resolve(), - replace({ - 'process.browser': true, - 'process.env.NODE_ENV': JSON.stringify(mode) - }), - commonjs(), - !dev && terser() - ], - - preserveEntrySignatures: false, - onwarn, - } -}; diff --git a/scripts/setupTypeScript.js b/scripts/setupTypeScript.js deleted file mode 100644 index 45fb596..0000000 --- a/scripts/setupTypeScript.js +++ /dev/null @@ -1,306 +0,0 @@ -/** - * Run this script to convert the project to TypeScript. This is only guaranteed to work - * on the unmodified default template; if you have done code changes you are likely need - * to touch up the generated project manually. - */ - -// @ts-check -const fs = require('fs'); -const path = require('path'); -const { argv } = require('process'); - -const projectRoot = argv[2] || path.join(__dirname, '..'); - -const isRollup = fs.existsSync(path.join(projectRoot, "rollup.config.js")); - -function warn(message) { - console.warn('Warning: ' + message); -} - -function replaceInFile(fileName, replacements) { - if (fs.existsSync(fileName)) { - let contents = fs.readFileSync(fileName, 'utf8'); - let hadUpdates = false; - - replacements.forEach(([from, to]) => { - const newContents = contents.replace(from, to); - - const isAlreadyApplied = typeof to !== 'string' || contents.includes(to); - - if (newContents !== contents) { - contents = newContents; - hadUpdates = true; - } else if (!isAlreadyApplied) { - warn(`Wanted to update "${from}" in ${fileName}, but did not find it.`); - } - }); - - if (hadUpdates) { - fs.writeFileSync(fileName, contents); - } else { - console.log(`${fileName} had already been updated.`); - } - } else { - warn(`Wanted to update ${fileName} but the file did not exist.`); - } -} - -function createFile(fileName, contents) { - if (fs.existsSync(fileName)) { - warn(`Wanted to create ${fileName}, but it already existed. Leaving existing file.`); - } else { - fs.writeFileSync(fileName, contents); - } -} - -function addDepsToPackageJson() { - const pkgJSONPath = path.join(projectRoot, 'package.json'); - const packageJSON = JSON.parse(fs.readFileSync(pkgJSONPath, 'utf8')); - packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, { - ...(isRollup ? { '@rollup/plugin-typescript': '^6.0.0' } : { 'ts-loader': '^8.0.4' }), - '@tsconfig/svelte': '^1.0.10', - '@types/compression': '^1.7.0', - '@types/node': '^14.11.1', - '@types/polka': '^0.5.1', - 'svelte-check': '^1.0.46', - 'svelte-preprocess': '^4.3.0', - tslib: '^2.0.1', - typescript: '^4.0.3' - }); - - // Add script for checking - packageJSON.scripts = Object.assign(packageJSON.scripts, { - validate: 'svelte-check --ignore src/node_modules/@sapper' - }); - - // Write the package JSON - fs.writeFileSync(pkgJSONPath, JSON.stringify(packageJSON, null, ' ')); -} - -function changeJsExtensionToTs(dir) { - const elements = fs.readdirSync(dir, { withFileTypes: true }); - - for (let i = 0; i < elements.length; i++) { - if (elements[i].isDirectory()) { - changeJsExtensionToTs(path.join(dir, elements[i].name)); - } else if (elements[i].name.match(/^[^_]((?!json).)*js$/)) { - fs.renameSync(path.join(dir, elements[i].name), path.join(dir, elements[i].name).replace('.js', '.ts')); - } - } -} - -function updateSingleSvelteFile({ view, vars, contextModule }) { - replaceInFile(path.join(projectRoot, 'src', `${view}.svelte`), [ - [/(?: - - - ``` - */ -declare module "*.gif" { - const value: string; - export = value; -} - -declare module "*.jpg" { - const value: string; - export = value; -} - -declare module "*.jpeg" { - const value: string; - export = value; -} - -declare module "*.png" { - const value: string; - export = value; -} - -declare module "*.svg" { - const value: string; - export = value; -} - -declare module "*.webp" { - const value: string; - export = value; -} diff --git a/src/app.html b/src/app.html new file mode 100644 index 0000000..40b53a1 --- /dev/null +++ b/src/app.html @@ -0,0 +1,31 @@ + + +
+ + + + + + + + + + + %svelte.head% + + +{text}
diff --git a/src/node_modules/components/NavSeparator.svelte b/src/lib/components/NavSeparator.svelte similarity index 100% rename from src/node_modules/components/NavSeparator.svelte rename to src/lib/components/NavSeparator.svelte diff --git a/src/node_modules/components/PageHeader.svelte b/src/lib/components/PageHeader.svelte similarity index 85% rename from src/node_modules/components/PageHeader.svelte rename to src/lib/components/PageHeader.svelte index 8a12369..b613182 100644 --- a/src/node_modules/components/PageHeader.svelte +++ b/src/lib/components/PageHeader.svelte @@ -1,5 +1,5 @@{error.message}
+{error.stack}+ {/if} +
{error.message}
-{error.stack}- {/if} -