Compare commits
7 Commits
93efc326ab
...
8c465e8b7d
Author | SHA1 | Date | |
---|---|---|---|
8c465e8b7d | |||
936f023886 | |||
bce4b4e2b6 | |||
eb04446a43 | |||
ffcacd32f6 | |||
e8e462e264 | |||
f40e638583 |
1
.husky/.gitignore
vendored
Normal file
1
.husky/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
_
|
4
.husky/pre-commit
Normal file
4
.husky/pre-commit
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
yarn format
|
@ -3,7 +3,7 @@
|
|||||||
## ✒️ Overview
|
## ✒️ Overview
|
||||||
This is an API client for @lfk/backend
|
This is an API client for @lfk/backend
|
||||||
- WebApp built with [Svelte](https://svelte.dev), [WindiCSS](https://windicss.org/) (to compile [TailwindCSS](https://tailwindcss.com/)) and [Vite](https://vitejs.dev).
|
- WebApp built with [Svelte](https://svelte.dev), [WindiCSS](https://windicss.org/) (to compile [TailwindCSS](https://tailwindcss.com/)) and [Vite](https://vitejs.dev).
|
||||||
- Served to clients via by `electron`.
|
- Served to clients via by [Electron](https://electronjs.org/).
|
||||||
|
|
||||||
## 🚀 Getting Started
|
## 🚀 Getting Started
|
||||||
```
|
```
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"format": "prettier --write --plugin-search-dir=. ./**/*.html ./**/*.svelte"
|
"format": "prettier --write --plugin-search-dir=. ./**/*.html ./**/*.svelte",
|
||||||
|
"prepare": "husky install"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@svitejs/vite-plugin-svelte": "^0.11.0",
|
"@svitejs/vite-plugin-svelte": "^0.11.0",
|
||||||
@ -13,6 +14,7 @@
|
|||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"html-minifier": "^4.0.0",
|
"html-minifier": "^4.0.0",
|
||||||
|
"husky": "^5.1.3",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^2.2.1",
|
||||||
"prettier-plugin-svelte": "^2.2.0",
|
"prettier-plugin-svelte": "^2.2.0",
|
||||||
"svelte": "^3.35.0",
|
"svelte": "^3.35.0",
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
<script>
|
<script>
|
||||||
import Scanner from "./Scanner.svelte";
|
import Scanner from "./Scanner.svelte";
|
||||||
import Login from "./Login.svelte";
|
import Login from "./Login.svelte";
|
||||||
import Settings from "./Settings.svelte";
|
import Settings from "./Settings.svelte";
|
||||||
import { apikey, lang, page } from "./store.js";
|
import { apikey, lang, page } from "./store.js";
|
||||||
$: is_configured = $apikey !== "null" && $apikey !== "";
|
$: is_configured = $apikey && $apikey !== "null" && $apikey !== "";
|
||||||
$: settings_open = $page === "settings";
|
$: settings_open = $page === "settings";
|
||||||
console.log($page);
|
console.log($page);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if settings_open && is_configured}
|
{#if settings_open && is_configured}
|
||||||
<Settings />
|
<Settings />
|
||||||
{:else if is_configured}
|
{:else if is_configured}
|
||||||
<Scanner />
|
<Scanner />
|
||||||
{:else}
|
{:else}
|
||||||
<Login />
|
<Login />
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -25,9 +25,7 @@
|
|||||||
{hours}:{minutes}:{seconds}
|
{hours}:{minutes}:{seconds}
|
||||||
</h1>
|
</h1>
|
||||||
<section class="px-4 py-24 mx-auto max-w-7xl">
|
<section class="px-4 py-24 mx-auto max-w-7xl">
|
||||||
<div
|
<div class="w-full mx-auto space-y-5 sm:w-8/12 md:w-12 lg:w-12 xl:w-12">
|
||||||
class="w-full mx-auto space-y-5 sm:w-8/12 md:w-6/12 lg:w-4/12 xl:w-3/12"
|
|
||||||
>
|
|
||||||
<form
|
<form
|
||||||
class="space-y-4"
|
class="space-y-4"
|
||||||
onsubmit="event.preventDefault();"
|
onsubmit="event.preventDefault();"
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "cd app && yarn dev",
|
"dev": "cd app && yarn dev",
|
||||||
"electron:start": "cd app && yarn build && cd .. && electron-forge start",
|
"electron:start": "cd app && yarn build && cd .. && electron-forge start",
|
||||||
"electron:package": "cd app && yarn build && cd .. && electron-forge package"
|
"electron:package": "cd app && yarn build && cd .. && electron-forge package",
|
||||||
|
"prepare": "husky install",
|
||||||
|
"format": "cd app && yarn format"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@electron-forge/cli": "^6.0.0-beta.54",
|
"@electron-forge/cli": "^6.0.0-beta.54",
|
||||||
@ -14,7 +16,8 @@
|
|||||||
"@electron-forge/maker-rpm": "^6.0.0-beta.54",
|
"@electron-forge/maker-rpm": "^6.0.0-beta.54",
|
||||||
"@electron-forge/maker-squirrel": "^6.0.0-beta.54",
|
"@electron-forge/maker-squirrel": "^6.0.0-beta.54",
|
||||||
"@electron-forge/maker-zip": "^6.0.0-beta.54",
|
"@electron-forge/maker-zip": "^6.0.0-beta.54",
|
||||||
"electron-nightly": "14.0.0-nightly.20210311"
|
"electron-nightly": "14.0.0-nightly.20210311",
|
||||||
|
"husky": "^5.1.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"electron-squirrel-startup": "^1.0.0"
|
"electron-squirrel-startup": "^1.0.0"
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 70 KiB |
File diff suppressed because one or more lines are too long
@ -1,20 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
||||||
|
|
||||||
<title>LfK!Scan</title>
|
|
||||||
|
|
||||||
<link rel="icon" type="image/png" href="/favicon.png">
|
|
||||||
<link rel="stylesheet" href="/global.css">
|
|
||||||
<link rel="stylesheet" href="/build/bundle.css">
|
|
||||||
|
|
||||||
<script defer src="/build/bundle.js"></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
Binary file not shown.
Before Width: | Height: | Size: 21 KiB |
@ -1,75 +0,0 @@
|
|||||||
import svelte from 'rollup-plugin-svelte';
|
|
||||||
import resolve from '@rollup/plugin-node-resolve';
|
|
||||||
import commonjs from '@rollup/plugin-commonjs';
|
|
||||||
import livereload from 'rollup-plugin-livereload';
|
|
||||||
import { terser } from 'rollup-plugin-terser';
|
|
||||||
|
|
||||||
const production = !process.env.ROLLUP_WATCH;
|
|
||||||
|
|
||||||
function serve() {
|
|
||||||
let server;
|
|
||||||
|
|
||||||
function toExit() {
|
|
||||||
if (server) server.kill(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
writeBundle() {
|
|
||||||
if (server) return;
|
|
||||||
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
|
|
||||||
stdio: ['ignore', 'inherit', 'inherit'],
|
|
||||||
shell: true
|
|
||||||
});
|
|
||||||
|
|
||||||
process.on('SIGTERM', toExit);
|
|
||||||
process.on('exit', toExit);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
input: 'src/main.js',
|
|
||||||
output: {
|
|
||||||
sourcemap: true,
|
|
||||||
format: 'iife',
|
|
||||||
name: 'app',
|
|
||||||
file: 'public/build/bundle.js'
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
svelte({
|
|
||||||
// enable run-time checks when not in production
|
|
||||||
dev: !production,
|
|
||||||
// we'll extract any component CSS out into
|
|
||||||
// a separate file - better for performance
|
|
||||||
css: css => {
|
|
||||||
css.write('public/build/bundle.css');
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
// If you have external dependencies installed from
|
|
||||||
// npm, you'll most likely need these plugins. In
|
|
||||||
// some cases you'll need additional configuration -
|
|
||||||
// consult the documentation for details:
|
|
||||||
// https://github.com/rollup/plugins/tree/master/packages/commonjs
|
|
||||||
resolve({
|
|
||||||
browser: true,
|
|
||||||
dedupe: ['svelte']
|
|
||||||
}),
|
|
||||||
commonjs(),
|
|
||||||
|
|
||||||
// In dev mode, call `npm run start` once
|
|
||||||
// the bundle has been generated
|
|
||||||
!production && serve(),
|
|
||||||
|
|
||||||
// Watch the `public` directory and refresh the
|
|
||||||
// browser on changes when not in production
|
|
||||||
!production && livereload('public'),
|
|
||||||
|
|
||||||
// If we're building for production (npm run build
|
|
||||||
// instead of npm run dev), minify
|
|
||||||
production && terser()
|
|
||||||
],
|
|
||||||
watch: {
|
|
||||||
clearScreen: false
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,125 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/** This script modifies the project to support TS code in .svelte files like:
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
export let name: string;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
As well as validating the code for CI.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** To work on this script:
|
|
||||||
rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
|
|
||||||
*/
|
|
||||||
|
|
||||||
const fs = require("fs")
|
|
||||||
const path = require("path")
|
|
||||||
const { argv } = require("process")
|
|
||||||
|
|
||||||
const projectRoot = argv[2] || path.join(__dirname, "..")
|
|
||||||
|
|
||||||
// Add deps to pkg.json
|
|
||||||
const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8"))
|
|
||||||
packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
|
|
||||||
"svelte-check": "^1.0.0",
|
|
||||||
"svelte-preprocess": "^4.0.0",
|
|
||||||
"@rollup/plugin-typescript": "^4.0.0",
|
|
||||||
"typescript": "^3.9.3",
|
|
||||||
"tslib": "^2.0.0",
|
|
||||||
"@tsconfig/svelte": "^1.0.0"
|
|
||||||
})
|
|
||||||
|
|
||||||
// Add script for checking
|
|
||||||
packageJSON.scripts = Object.assign(packageJSON.scripts, {
|
|
||||||
"validate": "svelte-check"
|
|
||||||
})
|
|
||||||
|
|
||||||
// Write the package JSON
|
|
||||||
fs.writeFileSync(path.join(projectRoot, "package.json"), JSON.stringify(packageJSON, null, " "))
|
|
||||||
|
|
||||||
// mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
|
|
||||||
const beforeMainJSPath = path.join(projectRoot, "src", "main.js")
|
|
||||||
const afterMainTSPath = path.join(projectRoot, "src", "main.ts")
|
|
||||||
fs.renameSync(beforeMainJSPath, afterMainTSPath)
|
|
||||||
|
|
||||||
// Switch the app.svelte file to use TS
|
|
||||||
const appSveltePath = path.join(projectRoot, "src", "App.svelte")
|
|
||||||
let appFile = fs.readFileSync(appSveltePath, "utf8")
|
|
||||||
appFile = appFile.replace("<script>", '<script lang="ts">')
|
|
||||||
appFile = appFile.replace("export let name;", 'export let name: string;')
|
|
||||||
fs.writeFileSync(appSveltePath, appFile)
|
|
||||||
|
|
||||||
// Edit rollup config
|
|
||||||
const rollupConfigPath = path.join(projectRoot, "rollup.config.js")
|
|
||||||
let rollupConfig = fs.readFileSync(rollupConfigPath, "utf8")
|
|
||||||
|
|
||||||
// Edit imports
|
|
||||||
rollupConfig = rollupConfig.replace(`'rollup-plugin-terser';`, `'rollup-plugin-terser';
|
|
||||||
import sveltePreprocess from 'svelte-preprocess';
|
|
||||||
import typescript from '@rollup/plugin-typescript';`)
|
|
||||||
|
|
||||||
// Replace name of entry point
|
|
||||||
rollupConfig = rollupConfig.replace(`'src/main.js'`, `'src/main.ts'`)
|
|
||||||
|
|
||||||
// Add preprocess to the svelte config, this is tricky because there's no easy signifier.
|
|
||||||
// Instead we look for `css:` then the next `}` and add the preprocessor to that
|
|
||||||
let foundCSS = false
|
|
||||||
let match
|
|
||||||
|
|
||||||
// https://regex101.com/r/OtNjwo/1
|
|
||||||
const configEditor = new RegExp(/css:.|\n*}/gmi)
|
|
||||||
while (( match = configEditor.exec(rollupConfig)) != null) {
|
|
||||||
if (foundCSS) {
|
|
||||||
const endOfCSSIndex = match.index + 1
|
|
||||||
rollupConfig = rollupConfig.slice(0, endOfCSSIndex) + ",\n preprocess: sveltePreprocess()," + rollupConfig.slice(endOfCSSIndex);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if (match[0].includes("css:")) foundCSS = true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Add TypeScript
|
|
||||||
rollupConfig = rollupConfig.replace("commonjs(),", 'commonjs(),\n\t\ttypescript({ sourceMap: !production }),')
|
|
||||||
fs.writeFileSync(rollupConfigPath, rollupConfig)
|
|
||||||
|
|
||||||
// Add TSConfig
|
|
||||||
const tsconfig = `{
|
|
||||||
"extends": "@tsconfig/svelte/tsconfig.json",
|
|
||||||
|
|
||||||
"include": ["src/**/*"],
|
|
||||||
"exclude": ["node_modules/*", "__sapper__/*", "public/*"],
|
|
||||||
}`
|
|
||||||
const tsconfigPath = path.join(projectRoot, "tsconfig.json")
|
|
||||||
fs.writeFileSync(tsconfigPath, tsconfig)
|
|
||||||
|
|
||||||
// Delete this script, but not during testing
|
|
||||||
if (!argv[2]) {
|
|
||||||
// Remove the script
|
|
||||||
fs.unlinkSync(path.join(__filename))
|
|
||||||
|
|
||||||
// Check for Mac's DS_store file, and if it's the only one left remove it
|
|
||||||
const remainingFiles = fs.readdirSync(path.join(__dirname))
|
|
||||||
if (remainingFiles.length === 1 && remainingFiles[0] === '.DS_store') {
|
|
||||||
fs.unlinkSync(path.join(__dirname, '.DS_store'))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the scripts folder is empty
|
|
||||||
if (fs.readdirSync(path.join(__dirname)).length === 0) {
|
|
||||||
// Remove the scripts folder
|
|
||||||
fs.rmdirSync(path.join(__dirname))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds the extension recommendation
|
|
||||||
fs.mkdirSync(path.join(projectRoot, ".vscode"))
|
|
||||||
fs.writeFileSync(path.join(projectRoot, ".vscode", "extensions.json"), `{
|
|
||||||
"recommendations": ["svelte.svelte-vscode"]
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
|
|
||||||
console.log("Converted to TypeScript.")
|
|
||||||
|
|
||||||
if (fs.existsSync(path.join(projectRoot, "node_modules"))) {
|
|
||||||
console.log("\nYou will need to re-run your dependency manager to get started.")
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
<header class="navbar">
|
|
||||||
<section class="navbar-section">
|
|
||||||
<a href="#" class="btn btn-link">Docs</a>
|
|
||||||
<a href="#" class="btn btn-link">Examples</a>
|
|
||||||
</section>
|
|
||||||
<div class="navbar-center"><img src="/favicon.png" style="height:4rem;" alt="Spectre.css"></div>
|
|
||||||
<section class="navbar-section">
|
|
||||||
<a href="#" class="btn btn-link">Twitter</a>
|
|
||||||
<a href="#" class="btn btn-link">GitHub</a>
|
|
||||||
</section>
|
|
||||||
</header>
|
|
||||||
<main>
|
|
||||||
<div class="hero hero-sm bg-dark">
|
|
||||||
<div class="hero-body">
|
|
||||||
<h1><img src="/favicon.png" alt="Logo" style="height: 5rem;vertical-align: middle;"><span style="vertical-align: middle;">LfK!Scan</span></h1>
|
|
||||||
<p>Lauf für Kaya! Scanstation</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="padding:1rem;">
|
|
||||||
<div class="column col-12">
|
|
||||||
<h3>Configure Scanstation <a target="_blank" href="https://docs.lauf-fuer-kaya.de/"><small class="label">📃 take a look at the configuration guide</small></a></h3>
|
|
||||||
</div>
|
|
||||||
<div class="column col-6 col-xs-12">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label" for="input-example-1">Token</label>
|
|
||||||
<input class="form-input" id="input-example-1" type="text" placeholder="Token">
|
|
||||||
</div>
|
|
||||||
<button class="btn btn-primary input-group-btn btn-lg">Submit</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
10
src/main.js
10
src/main.js
@ -1,10 +0,0 @@
|
|||||||
import App from './App.svelte';
|
|
||||||
|
|
||||||
const app = new App({
|
|
||||||
target: document.body,
|
|
||||||
props: {
|
|
||||||
appName: 'Electron-Svelte'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default app;
|
|
Loading…
x
Reference in New Issue
Block a user