mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-19 00:10:00 +00:00
Plugin API 1.4: grants for unencrypted HTTP, local sockets, IDE commands and owned database sources; window status items, output channels, content tabs, editor selections, decorations, search, Problems and VCS reads; runs, keyed terminals with exit events, plugin run targets, dynamic run configurations and test parsers; language features, injections, snippets and menu locations; plugin MCP tools on the built-in server; four official API examples. Released 1.3 plugins keep working.
25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
import type { RunConfig } from "@/bindings";
|
|
import { validateLanguages } from "./languageSettings";
|
|
import { useProject } from "./project";
|
|
import { workflowSettings } from "./workflowSettings";
|
|
|
|
/** Mirrors ide-sdk's interpreter target selection for guards before IPC launch. */
|
|
export function withRunTarget(config: RunConfig): RunConfig {
|
|
if (config.target !== undefined && config.target !== null) return config;
|
|
const languages = validateLanguages(useProject.getState().settings?.languages);
|
|
const name = config.command
|
|
.split(/[\\/]/)
|
|
.at(-1)
|
|
?.replace(/\.(exe|cmd|bat)$/i, "");
|
|
const selected =
|
|
["php", "composer", "phpunit", "pest"].includes(name ?? "") || ["php", "composer", "phpunit"].includes(config.kind)
|
|
? languages.php.runTarget
|
|
: ["node", "npm", "npx", "pnpm", "yarn", "bun"].includes(name ?? "") ||
|
|
["node", "npm", "vitest", "jest", "mocha"].includes(config.kind)
|
|
? languages.node.runTarget
|
|
: "";
|
|
if (selected === "local") return { ...config, target: "" };
|
|
const target = selected || workflowSettings().run.defaultTarget;
|
|
return target ? { ...config, target } : config;
|
|
}
|