10 Commits

Author SHA1 Message Date
ba07f7b55f Merge branch 'main' of https://git.odit.services/lfk/scanclient into main
# Conflicts:
#	.gitignore
#	README.md
#	main.js
#	package.json
2021-03-15 13:36:54 +01:00
a2ec9d0cb3 👷‍♂️ CI - move to main tags event + disable rpm build for now 2021-03-15 13:33:22 +01:00
3e533f5c6d CI - fixed rpm build
Some checks failed
continuous-integration/drone/push Build was killed
continuous-integration/drone/tag Build was killed
2021-03-14 22:03:04 +01:00
8f907ba597 CI - rpm release building
Some checks failed
continuous-integration/drone/push Build was killed
continuous-integration/drone/tag Build is failing
2021-03-14 21:59:41 +01:00
e85a639e96 CI - only build @lfk-scanclient-linux-x64
Some checks failed
continuous-integration/drone/push Build was killed
continuous-integration/drone/tag Build was killed
2021-03-14 21:52:41 +01:00
b1c9cc7652 CI - testing full artifact zipping
Some checks failed
continuous-integration/drone/push Build was killed
continuous-integration/drone/tag Build is passing
2021-03-14 21:47:50 +01:00
ab7ba528ee removed "@" from dist package
Some checks failed
continuous-integration/drone/push Build was killed
continuous-integration/drone/tag Build is failing
2021-03-14 21:35:41 +01:00
bfff17c465 🚚 move to apk zip
Some checks failed
continuous-integration/drone/push Build was killed
continuous-integration/drone/tag Build is failing
2021-03-14 21:28:40 +01:00
de92402a3c CI - 📁 create zip for release
Some checks failed
continuous-integration/drone/push Build was killed
continuous-integration/drone/tag Build is failing
2021-03-14 21:17:05 +01:00
913b1ef047 initial commit 🎉 2021-03-10 21:29:07 +01:00
10 changed files with 272 additions and 12 deletions

View File

@@ -15,9 +15,11 @@ steps:
depends_on: ["clone"]
image: node:15.11.0-alpine3.13
commands:
- apk add git -f
- apk add git zip -f
- yarn && cd app && yarn && cd ..
- yarn electron:package
- mkdir dist
- zip -r dist/@lfk-scanclient-linux-x64.zip out/@lfk-scanclient-linux-x64
- name: gitea_release
depends_on: ["run electron packager"]
image: plugins/gitea-release
@@ -25,7 +27,7 @@ steps:
api_key:
from_secret: gitea_token
base_url: https://git.odit.services
files: out/*
files: dist/*
checksum:
- md5
- sha1
@@ -37,8 +39,7 @@ steps:
event: tag
trigger:
# branch:
# - dev
branch:
- main
event:
- push
- tag

View File

@@ -23,15 +23,12 @@
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "@electron-forge/maker-squirrel",
"config": {
"name": "@lfk/scanclient"
}
},
{
"name": "@electron-forge/maker-zip",
"platforms": [ "darwin" ]
"platforms": [ "darwin" ],
"config": {
"name": "lfk__scanclient"
}
},
{
"name": "@electron-forge/maker-deb",

BIN
public/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

1
public/global.css Normal file

File diff suppressed because one or more lines are too long

20
public/index.html Normal file
View File

@@ -0,0 +1,20 @@
<!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>

BIN
public/svelte.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

75
rollup.config.js Normal file
View File

@@ -0,0 +1,75 @@
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
}
};

125
scripts/setupTypeScript.js Normal file
View File

@@ -0,0 +1,125 @@
// @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.")
}

31
src/App.svelte Normal file
View File

@@ -0,0 +1,31 @@
<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 Normal file
View File

@@ -0,0 +1,10 @@
import App from './App.svelte';
const app = new App({
target: document.body,
props: {
appName: 'Electron-Svelte'
}
});
export default app;