mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 13:23:35 +00:00
refactor: simplify setup of asset paths
This commit is contained in:
committed by
Carlos Valente
parent
e46948772e
commit
5950551da2
@@ -5,7 +5,7 @@ import { copyFile, rename } from 'fs/promises';
|
||||
|
||||
import { logger } from '../../classes/Logger.js';
|
||||
import { getNetworkInterfaces } from '../../utils/networkInterfaces.js';
|
||||
import { resolveCorruptDirectory, resolveProjectsDirectory, resolveStylesPath } from '../../setup/index.js';
|
||||
import { publicDir, publicFiles } from '../../setup/index.js';
|
||||
import {
|
||||
appendToName,
|
||||
ensureDirectory,
|
||||
@@ -47,8 +47,8 @@ init();
|
||||
* Ensure services has its dependencies initialized
|
||||
*/
|
||||
function init() {
|
||||
ensureDirectory(resolveProjectsDirectory);
|
||||
ensureDirectory(resolveCorruptDirectory);
|
||||
ensureDirectory(publicDir.projectsDir);
|
||||
ensureDirectory(publicDir.corruptDir);
|
||||
}
|
||||
|
||||
export async function getCurrentProject() {
|
||||
@@ -63,7 +63,7 @@ export async function getCurrentProject() {
|
||||
* to be composed in the loading functions
|
||||
*/
|
||||
async function loadDemoProject(): Promise<string> {
|
||||
const pathToNewFile = generateUniqueFileName(resolveProjectsDirectory, config.demoProject);
|
||||
const pathToNewFile = generateUniqueFileName(publicDir.projectsDir, config.demoProject);
|
||||
await initPersistence(getPathToProject(pathToNewFile), demoDb);
|
||||
const newName = getFileNameFromPath(pathToNewFile);
|
||||
await setLastLoadedProject(newName);
|
||||
@@ -75,7 +75,7 @@ async function loadDemoProject(): Promise<string> {
|
||||
* to be composed in the loading functions
|
||||
*/
|
||||
async function loadNewProject(): Promise<string> {
|
||||
const pathToNewFile = generateUniqueFileName(resolveProjectsDirectory, config.newProject);
|
||||
const pathToNewFile = generateUniqueFileName(publicDir.projectsDir, config.newProject);
|
||||
await initPersistence(getPathToProject(pathToNewFile), dbModel);
|
||||
const newName = getFileNameFromPath(pathToNewFile);
|
||||
await setLastLoadedProject(newName);
|
||||
@@ -273,7 +273,7 @@ export async function createProject(filename: string, projectData: ProjectData)
|
||||
},
|
||||
};
|
||||
|
||||
const uniqueFileName = generateUniqueFileName(resolveProjectsDirectory, filename);
|
||||
const uniqueFileName = generateUniqueFileName(publicDir.projectsDir, filename);
|
||||
const newFile = getPathToProject(uniqueFileName);
|
||||
|
||||
// change LowDB to point to new file
|
||||
@@ -316,14 +316,13 @@ export async function getInfo(): Promise<GetInfo> {
|
||||
// get nif and inject localhost
|
||||
const ni = getNetworkInterfaces();
|
||||
ni.unshift({ name: 'localhost', address: '127.0.0.1' });
|
||||
const cssOverride = resolveStylesPath;
|
||||
|
||||
return {
|
||||
networkInterfaces: ni,
|
||||
version,
|
||||
serverPort,
|
||||
osc,
|
||||
cssOverride,
|
||||
cssOverride: publicFiles.cssOverride,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user