mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 09:23:51 +00:00
1849b4d39f
* chore: migrate eslint to oxlint * chore: migrate prettier to oxfmt * chore: migrate typescript * chore: toThrow should have a expected value * chore: cast test value as Day * chore: small title fix * chore: mocks should be hoisted * chore: incorrect async useage * chore: test should be inside description * chore: test sohuld include an expeced * chore: oxfmt --------- Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/**
|
|
* This file contains a list of constants that may need to be resolved at runtime
|
|
*/
|
|
|
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
|
|
import { isOntimeCloud } from './setup/environment.js';
|
|
import { srcFiles } from './setup/index.js';
|
|
|
|
// =================================================
|
|
export const password = process.env.SESSION_PASSWORD;
|
|
export const routerPrefix = process.env.ROUTER_PREFIX;
|
|
|
|
/**
|
|
* Updates the router prefix in the index.html file
|
|
* This is only needed in the cloud environment where the client is not at the root segment
|
|
* ie: https://cloud.getontime.com/client-hash/timer
|
|
*/
|
|
export function updateRouterPrefix(prefix: string | undefined = routerPrefix): string {
|
|
if (!prefix) {
|
|
return '';
|
|
}
|
|
|
|
try {
|
|
const data = readFileSync(srcFiles.clientIndexHtml, { encoding: 'utf-8', flag: 'r' }).replace(
|
|
'<base href="/" />',
|
|
`<base href="/${prefix}/" ${isOntimeCloud ? 'data-is-cloud' : ''}/>`,
|
|
);
|
|
writeFileSync(srcFiles.clientIndexHtml, data, { encoding: 'utf-8', flag: 'w' });
|
|
} catch (_error) {
|
|
/** unhandled */
|
|
}
|
|
|
|
return `/${prefix}`;
|
|
}
|