diff --git a/apps/web/src/projectScripts.ts b/apps/web/src/projectScripts.ts index c09a801237fc3c813fc636f2bf027f6ae1591e1b..4084df8456b9ce3e706e76f1a0ebb63491a516f7 100644 --- a/apps/web/src/projectScripts.ts +++ b/apps/web/src/projectScripts.ts @@ -1,10 +1,7 @@ import type { ProjectScript } from "@t3tools/contracts"; -import { isWindowsPlatform } from "./lib/utils"; - const SCRIPT_RUN_COMMAND_PATTERN = /^script\.([a-z0-9][a-z0-9-]*)\.run$/; const MAX_SCRIPT_ID_LENGTH = 64; -const ENV_KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/; function normalizeScriptId(value: string): string { const cleaned = value @@ -52,37 +49,6 @@ export function nextProjectScriptId(name: string, existingIds: Iterable) return `${baseId}-${Date.now()}`.slice(0, MAX_SCRIPT_ID_LENGTH); } -function shellEscapePosix(value: string): string { - return `'${value.replace(/'/g, `'\\''`)}'`; -} - -function shellEscapeWindowsSetValue(value: string): string { - return value.replace(/\^/g, "^^").replace(/%/g, "^%").replace(/"/g, '""'); -} - -function injectEnvIntoShellCommand( - command: string, - env: Record, - platform = typeof navigator === "undefined" ? "" : navigator.platform, -): string { - const entries = Object.entries(env).filter( - ([key, value]) => ENV_KEY_PATTERN.test(key) && value.length > 0, - ); - if (entries.length === 0) { - return command; - } - - if (isWindowsPlatform(platform)) { - const prefixes = entries.map( - ([key, value]) => `set "${key}=${shellEscapeWindowsSetValue(value)}"`, - ); - return `${prefixes.join(" && ")} && ${command}`; - } - - const assignments = entries.map(([key, value]) => `${key}=${shellEscapePosix(value)}`).join(" "); - return `env ${assignments} ${command}`; -} - interface ProjectScriptRuntimeEnvInput { project: { cwd: string;