Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/src/database/entities/plugin.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class Plugin {
hooks?: string[];
permissions?: string[];
dependencies?: Record<string, string>;
peerDependencies?: Record<string, string>;
settings?: Record<string, any>;
entryPoint?: string;
};
Expand Down
27 changes: 25 additions & 2 deletions packages/core/src/modules/plugins/installed-plugins.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class InstalledPluginsService {
applicationId: string,
pluginId: string,
ownerId: string,
): Promise<InstalledPlugin> {
): Promise<InstalledPlugin & { peerWarnings: string[] }> {
// Verify app ownership
const app = await this.appRepo.findOne({
where: { id: applicationId, ownerId },
Expand Down Expand Up @@ -97,8 +97,31 @@ export class InstalledPluginsService {
pluginId,
});

// Peer dependency check (warning-only, never throws or blocks)
const peerDeps = plugin.manifest?.peerDependencies ?? {};
const peerWarnings: string[] = [];
if (Object.keys(peerDeps).length > 0) {
const activeInstalled = await this.installedRepo.find({
where: { applicationId, status: InstalledPluginStatus.ACTIVE },
relations: ["plugin"],
});
const activeSlugs = new Set(
activeInstalled.map((i) => i.plugin?.slug).filter(Boolean),
);
for (const peerSlug of Object.keys(peerDeps)) {
if (!activeSlugs.has(peerSlug)) {
peerWarnings.push(peerSlug);
}
}
if (peerWarnings.length > 0) {
this.logger.warn(
`Plugin "${plugin.name}" installed on app "${app.name}" with missing peer plugins: ${peerWarnings.join(", ")}`,
);
}
}

this.logger.log(`Plugin ${plugin.name} installed on app ${app.name}`);
return result;
return { ...result, peerWarnings };
}

async uninstall(
Expand Down
2 changes: 2 additions & 0 deletions packages/plugins/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export interface PluginManifest {
author?: string;
permissions?: string[];
dependencies?: Record<string, string>;
/** Slugs of plugins this plugin works best alongside. Missing peers trigger a warning but never block install. */
peerDependencies?: Record<string, string>;
}

export interface PluginContext {
Expand Down
Loading