diff --git a/src/server/api/routers/scripts.ts b/src/server/api/routers/scripts.ts index d8b3d07..d0ac7e6 100644 --- a/src/server/api/routers/scripts.ts +++ b/src/server/api/routers/scripts.ts @@ -41,6 +41,7 @@ function pbToScript(pb: PBScript): Script { script: m.script, resources: m.resources, config_path: m.config_path, + script: scriptDownloaderService.deriveScriptPath(pb.type, m.type, pb.slug) ?? undefined, })), default_credentials: { username: pb.default_user, diff --git a/src/server/services/autoSyncService.js b/src/server/services/autoSyncService.js index 0d94ba4..b995f46 100644 --- a/src/server/services/autoSyncService.js +++ b/src/server/services/autoSyncService.js @@ -392,6 +392,7 @@ export class AutoSyncService { type: m.type, resources: m.resources, config_path: m.config_path, + script: sds.deriveScriptPath(pb.type, m.type, pb.slug) ?? undefined, })), default_credentials: { username: pb.default_user, password: pb.default_passwd }, notes: pb.notes_json, diff --git a/src/server/services/localScripts.ts b/src/server/services/localScripts.ts index 237b45f..fe733e6 100644 --- a/src/server/services/localScripts.ts +++ b/src/server/services/localScripts.ts @@ -1,6 +1,7 @@ import { readFile, readdir, writeFile, mkdir } from 'fs/promises'; import { join } from 'path'; import type { Script, ScriptCard } from '~/types/script'; +import { scriptDownloaderService } from './scriptDownloader.js'; export class LocalScriptsService { private scriptsDirectory: string; @@ -58,6 +59,7 @@ export class LocalScriptsService { type: m.type, resources: m.resources, config_path: m.config_path, + script: scriptDownloaderService.deriveScriptPath(pb.type, m.type, pb.slug) ?? undefined, })), notes: pb.notes_json.map(n => ({ text: n.text, type: n.type })), })); @@ -135,6 +137,7 @@ export class LocalScriptsService { type: m.type, resources: m.resources, config_path: m.config_path, + script: scriptDownloaderService.deriveScriptPath(pb.type, m.type, pb.slug) ?? undefined, })), notes: pb.notes_json.map(n => ({ text: n.text, type: n.type })), }; diff --git a/src/types/script.ts b/src/types/script.ts index 984e479..7939158 100644 --- a/src/types/script.ts +++ b/src/types/script.ts @@ -12,10 +12,8 @@ export interface ScriptInstallMethod { resources: ScriptResources; config_path?: string; /** - * Optional install script file path (e.g. "ct/adguard.sh"). - * Present in user-defined local JSON scripts. - * For PocketBase-sourced scripts this field is absent; the downloader derives - * the path from the script type and slug via `deriveScriptPath()`. + * Install script file path (e.g. "ct/adguard.sh"). + * For PocketBase-sourced scripts, this is derived by the backend. */ script?: string; }