Remove serverport from project file (#1957)

* feat: get server port from app satate or env

optional startup port from env will always override

function for parsing port from env

populate default port in app state

add test for migration

* bump version
This commit is contained in:
Alex Christoffer Rasmussen
2026-03-02 06:02:29 -08:00
committed by GitHub
parent 1fe58e21be
commit c1fcdf7065
38 changed files with 593 additions and 193 deletions
@@ -10,6 +10,7 @@ interface AppState {
projectName?: string;
rundownId?: string;
showWelcomeDialog?: boolean;
serverPort?: number;
}
const adapter = new JSONFile<AppState>(publicFiles.appState);
@@ -61,3 +62,13 @@ export async function setShowWelcomeDialog(show: boolean): Promise<boolean> {
await config.write();
return show;
}
export async function getServerPort(): Promise<number | undefined> {
await config.read();
return config.data.serverPort;
}
export async function setServerPort(port: number): Promise<void> {
config.data.serverPort = port;
await config.write();
}
@@ -183,7 +183,10 @@ export async function initialiseProject(): Promise<string> {
}
try {
const projectName = await loadProjectFile(lastLoaded.projectName, lastLoaded.rundownId);
const projectName = await loadProjectFile(lastLoaded.projectName, {
rundownId: lastLoaded.rundownId,
initialLoad: true,
});
return projectName;
} catch (error) {
// if we are here, most likely the json parsing failed and the file is corrupt
@@ -207,7 +210,10 @@ export async function initialiseProject(): Promise<string> {
* @throws
* @param fileName file name of the project including the extension
*/
export async function loadProjectFile(fileName: string, rundownId?: string): Promise<string> {
export async function loadProjectFile(
fileName: string,
options?: { rundownId?: string; initialLoad?: boolean },
): Promise<string> {
const filePath = doesProjectExist(fileName);
if (filePath === null) {
throw new Error('Project file not found');
@@ -215,7 +221,7 @@ export async function loadProjectFile(fileName: string, rundownId?: string): Pro
// when loading a project file, we allow parsing to fail and interrupt the process
const fileData = await parseJsonFile(filePath);
const result = parseDatabaseModel(fileData);
const result = parseDatabaseModel(fileData, options?.initialLoad);
let parsedFileName = fileName;
if (result.migrated) {
@@ -226,7 +232,7 @@ export async function loadProjectFile(fileName: string, rundownId?: string): Pro
parsedFileName = await handleCorruptedFile(filePath, parsedFileName);
}
const projectName = await loadProject(result.data, parsedFileName, rundownId);
const projectName = await loadProject(result.data, parsedFileName, options?.rundownId);
return projectName;
}