mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
Enhance application controller and runtime provisioner with loading window visibility and improved file handling
This commit is contained in:
@@ -23,11 +23,13 @@ type RuntimeProvisionerDeps = {
|
||||
recursive: true;
|
||||
force: true;
|
||||
dereference: true;
|
||||
filter: (sourcePath: string) => boolean;
|
||||
filter?: (sourcePath: string) => boolean;
|
||||
},
|
||||
) => unknown;
|
||||
readFileSync: (filePath: string) => string | Buffer;
|
||||
writeFileSync: (filePath: string, content: string) => unknown;
|
||||
statSync: (filePath: string) => { isDirectory: () => boolean };
|
||||
symlinkSync: (target: string, path: string, type: "junction") => unknown;
|
||||
};
|
||||
|
||||
export type PreparedNodecgRuntime = {
|
||||
@@ -84,6 +86,8 @@ function resolveDeps(deps?: Partial<RuntimeProvisionerDeps>): RuntimeProvisioner
|
||||
cpSync: deps?.cpSync ?? fs.cpSync,
|
||||
readFileSync: deps?.readFileSync ?? fs.readFileSync,
|
||||
writeFileSync: deps?.writeFileSync ?? fs.writeFileSync,
|
||||
statSync: deps?.statSync ?? fs.statSync,
|
||||
symlinkSync: deps?.symlinkSync ?? fs.symlinkSync,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -150,16 +154,20 @@ function installManagedRuntime(
|
||||
deps.rmSync(path.join(targetRuntimePath, entry), { recursive: true, force: true });
|
||||
}
|
||||
|
||||
deps.cpSync(sourceRuntimePath, targetRuntimePath, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
dereference: true,
|
||||
filter: (sourcePath) => {
|
||||
const relativePath = path.relative(sourceRuntimePath, sourcePath);
|
||||
const firstSegment = relativePath.split(path.sep)[0];
|
||||
return !WRITABLE_NODECG_DIRS.includes(firstSegment as (typeof WRITABLE_NODECG_DIRS)[number]);
|
||||
},
|
||||
});
|
||||
for (const entry of MANAGED_RUNTIME_ENTRIES) {
|
||||
const sourcePath = path.join(sourceRuntimePath, entry);
|
||||
const targetPath = path.join(targetRuntimePath, entry);
|
||||
|
||||
if (!deps.existsSync(sourcePath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (deps.statSync(sourcePath).isDirectory()) {
|
||||
deps.symlinkSync(sourcePath, targetPath, "junction");
|
||||
} else {
|
||||
deps.cpSync(sourcePath, targetPath, { recursive: true, force: true, dereference: true });
|
||||
}
|
||||
}
|
||||
|
||||
const sourceRuntime = readJson(path.join(sourceRuntimePath, ".scoreko-runtime.json"), deps);
|
||||
deps.writeFileSync(
|
||||
|
||||
Reference in New Issue
Block a user