Skip to content

Commit

Permalink
Added check for peerDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligu committed Sep 28, 2024
1 parent 5b7e0d1 commit d898c6e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/pluginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ export class PluginManager {
this.log.error(`Please open an issue on the plugin repository to remove them.`);
return null;
}
const projectChipPeerDependencies = checkForProjectChipPackages(packageJson.peerDependencies || {});
if (projectChipPeerDependencies.length > 0) {
this.log.error(`Found @project-chip packages "${projectChipPeerDependencies.join(', ')}" in plugin peerDependencies.`);
this.log.error(`Please open an issue on the plugin repository to remove them.`);
return null;
}

// Check for matterbridge package in dependencies and devDependencies
const checkForMatterbridgePackage = (dependencies: Record<string, string>) => {
Expand All @@ -208,6 +214,12 @@ export class PluginManager {
this.log.error(`Please open an issue on the plugin repository to remove them.`);
return null;
}
const matterbridgePeerDependencies = checkForMatterbridgePackage(packageJson.peerDependencies || {});
if (matterbridgePeerDependencies.length > 0) {
this.log.error(`Found matterbridge package in the plugin peerDependencies.`);
this.log.error(`Please open an issue on the plugin repository to remove them.`);
return null;
}

this.log.debug(`Resolved plugin path ${plg}${pluginPath}${db}: ${packageJsonPath}`);
return packageJsonPath;
Expand Down Expand Up @@ -257,6 +269,12 @@ export class PluginManager {
this.log.error(`Please open an issue on the plugin repository to remove them.`);
this.log.error(`In the next release this plugin will not be loaded cause it doesn't meet the requirements.`);
}
const projectChipPeerDependencies = checkForProjectChipPackages(packageJson.peerDependencies || {});
if (projectChipPeerDependencies.length > 0) {
this.log.error(`Found @project-chip packages "${projectChipPeerDependencies.join(', ')}" in plugin ${plg}${plugin.name}${er} peerDependencies.`);
this.log.error(`Please open an issue on the plugin repository to remove them.`);
this.log.error(`In the next release this plugin will not be loaded cause it doesn't meet the requirements.`);
}

// Check for matterbridge package in dependencies and devDependencies
const checkForMatterbridgePackage = (dependencies: Record<string, string>) => {
Expand All @@ -274,6 +292,12 @@ export class PluginManager {
this.log.error(`Please open an issue on the plugin repository to remove them.`);
this.log.error(`In the next release this plugin will not be loaded cause it doesn't meet the requirements.`);
}
const matterbridgePeerDependencies = checkForMatterbridgePackage(packageJson.peerDependencies || {});
if (matterbridgePeerDependencies.length > 0) {
this.log.error(`Found matterbridge package in the plugin ${plg}${plugin.name}${er} peerDependencies.`);
this.log.error(`Please open an issue on the plugin repository to remove them.`);
this.log.error(`In the next release this plugin will not be loaded cause it doesn't meet the requirements.`);
}

// await this.saveToStorage(); // No need to save the plugin to storage
return packageJson;
Expand Down

0 comments on commit d898c6e

Please sign in to comment.