feat: add ability to pass pkg version easily

pull/243/head
Josh Moore 1 year ago
parent 37c5836ec6
commit e8e29d2a73

@ -9,6 +9,13 @@ import { UserConfig } from './UserConfig';
import { ServerConfiguration } from 'ass';
import { MySql } from './sql/mysql';
/**
* Top-level metadata exports
*/
export const App = {
pkgVersion: ''
}
/**
* Custom middleware to attach the ass object (and construct the `host` property)
*/
@ -29,6 +36,8 @@ async function main() {
const pkg = await fs.readJson(path.join('package.json')) as { name: string, version: string };
log.blank().info(pkg.name, pkg.version).blank();
App.pkgVersion = pkg.version;
// Ensure data files exist
await ensureFiles();

@ -9,6 +9,7 @@ import { BusBoyFile, AssFile } from 'ass';
import { getFileS3, uploadFileS3 } from '../s3';
import { Readable } from 'stream';
import * as data from '../data';
import { App } from '../app';
const router = Router({ caseSensitive: true });
@ -23,7 +24,7 @@ bb.extend(router, {
});
// Render or redirect
router.get('/', (req, res) => UserConfig.ready ? res.render('index') : res.redirect('/setup'));
router.get('/', (req, res) => UserConfig.ready ? res.render('index', { version: App.pkgVersion }) : res.redirect('/setup'));
// Upload flow
router.post('/', async (req, res) => {

@ -4,11 +4,12 @@ import { log } from '../log';
import { UserConfig } from '../UserConfig';
import { setDataModeToSql } from '../data';
import { MySql } from '../sql/mysql';
import { App } from '../app';
const router = Router({ caseSensitive: true });
// Static routes
router.get('/', (req, res) => UserConfig.ready ? res.redirect('/') : res.render('setup'));
router.get('/', (req, res) => UserConfig.ready ? res.redirect('/') : res.render('setup', { version: App.pkgVersion }));
router.get('/ui.js', (req, res) => UserConfig.ready ? res.send('') : res.type('text/javascript').sendFile(path.join('dist-frontend/setup.mjs')));
// Setup route

@ -2,4 +2,4 @@ extends _base_
block section
span ass
block content
h1.text-3xl Welcome to ass, a ShareX server.
h1.text-3xl Welcome to ass #{version}, a ShareX server.

Loading…
Cancel
Save