mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-06 14:51:08 +00:00
Plugins: add install force flag
This commit is contained in:
@@ -38,6 +38,10 @@ import {
|
||||
} from "./plugins-command-helpers.js";
|
||||
import { persistHookPackInstall, persistPluginInstall } from "./plugins-install-persist.js";
|
||||
|
||||
function resolveInstallMode(force?: boolean): "install" | "update" {
|
||||
return force ? "update" : "install";
|
||||
}
|
||||
|
||||
async function installBundledPluginSource(params: {
|
||||
config: OpenClawConfig;
|
||||
rawSpec: string;
|
||||
@@ -71,6 +75,7 @@ async function installBundledPluginSource(params: {
|
||||
async function tryInstallHookPackFromLocalPath(params: {
|
||||
config: OpenClawConfig;
|
||||
resolvedPath: string;
|
||||
installMode: "install" | "update";
|
||||
link?: boolean;
|
||||
}): Promise<{ ok: true } | { ok: false; error: string }> {
|
||||
if (params.link) {
|
||||
@@ -122,6 +127,7 @@ async function tryInstallHookPackFromLocalPath(params: {
|
||||
|
||||
const result = await installHooksFromPath({
|
||||
path: params.resolvedPath,
|
||||
mode: params.installMode,
|
||||
logger: createHookPackInstallLogger(),
|
||||
});
|
||||
if (!result.ok) {
|
||||
@@ -145,11 +151,13 @@ async function tryInstallHookPackFromLocalPath(params: {
|
||||
|
||||
async function tryInstallHookPackFromNpmSpec(params: {
|
||||
config: OpenClawConfig;
|
||||
installMode: "install" | "update";
|
||||
spec: string;
|
||||
pin?: boolean;
|
||||
}): Promise<{ ok: true } | { ok: false; error: string }> {
|
||||
const result = await installHooksFromNpmSpec({
|
||||
spec: params.spec,
|
||||
mode: params.installMode,
|
||||
logger: createHookPackInstallLogger(),
|
||||
});
|
||||
if (!result.ok) {
|
||||
@@ -245,6 +253,7 @@ export async function loadConfigForInstall(
|
||||
export async function runPluginInstallCommand(params: {
|
||||
raw: string;
|
||||
opts: InstallSafetyOverrides & {
|
||||
force?: boolean;
|
||||
link?: boolean;
|
||||
pin?: boolean;
|
||||
marketplace?: string;
|
||||
@@ -290,11 +299,13 @@ export async function runPluginInstallCommand(params: {
|
||||
if (!cfg) {
|
||||
return defaultRuntime.exit(1);
|
||||
}
|
||||
const installMode = resolveInstallMode(opts.force);
|
||||
|
||||
if (opts.marketplace) {
|
||||
const result = await installPluginFromMarketplace({
|
||||
dangerouslyForceUnsafeInstall: opts.dangerouslyForceUnsafeInstall,
|
||||
marketplace: opts.marketplace,
|
||||
mode: installMode,
|
||||
plugin: raw,
|
||||
logger: createPluginInstallLogger(),
|
||||
});
|
||||
@@ -329,6 +340,7 @@ export async function runPluginInstallCommand(params: {
|
||||
if (!probe.ok) {
|
||||
const hookFallback = await tryInstallHookPackFromLocalPath({
|
||||
config: cfg,
|
||||
installMode,
|
||||
resolvedPath: resolved,
|
||||
link: true,
|
||||
});
|
||||
@@ -366,12 +378,14 @@ export async function runPluginInstallCommand(params: {
|
||||
|
||||
const result = await installPluginFromPath({
|
||||
dangerouslyForceUnsafeInstall: opts.dangerouslyForceUnsafeInstall,
|
||||
mode: installMode,
|
||||
path: resolved,
|
||||
logger: createPluginInstallLogger(),
|
||||
});
|
||||
if (!result.ok) {
|
||||
const hookFallback = await tryInstallHookPackFromLocalPath({
|
||||
config: cfg,
|
||||
installMode,
|
||||
resolvedPath: resolved,
|
||||
});
|
||||
if (hookFallback.ok) {
|
||||
@@ -437,6 +451,7 @@ export async function runPluginInstallCommand(params: {
|
||||
if (clawhubSpec) {
|
||||
const result = await installPluginFromClawHub({
|
||||
dangerouslyForceUnsafeInstall: opts.dangerouslyForceUnsafeInstall,
|
||||
mode: installMode,
|
||||
spec: raw,
|
||||
logger: createPluginInstallLogger(),
|
||||
});
|
||||
@@ -472,6 +487,7 @@ export async function runPluginInstallCommand(params: {
|
||||
if (preferredClawHubSpec) {
|
||||
const clawhubResult = await installPluginFromClawHub({
|
||||
dangerouslyForceUnsafeInstall: opts.dangerouslyForceUnsafeInstall,
|
||||
mode: installMode,
|
||||
spec: preferredClawHubSpec,
|
||||
logger: createPluginInstallLogger(),
|
||||
});
|
||||
@@ -506,6 +522,7 @@ export async function runPluginInstallCommand(params: {
|
||||
|
||||
const result = await installPluginFromNpmSpec({
|
||||
dangerouslyForceUnsafeInstall: opts.dangerouslyForceUnsafeInstall,
|
||||
mode: installMode,
|
||||
spec: raw,
|
||||
logger: createPluginInstallLogger(),
|
||||
});
|
||||
@@ -518,6 +535,7 @@ export async function runPluginInstallCommand(params: {
|
||||
if (!bundledFallbackPlan) {
|
||||
const hookFallback = await tryInstallHookPackFromNpmSpec({
|
||||
config: cfg,
|
||||
installMode,
|
||||
spec: raw,
|
||||
pin: opts.pin,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user