Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer listed plugins to dependencies #6038

Merged
merged 1 commit into from
Aug 26, 2019
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
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/common/plugin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ export interface PluginDeployerHandler {
deployFrontendPlugins(frontendPlugins: PluginDeployerEntry[]): Promise<void>;
deployBackendPlugins(backendPlugins: PluginDeployerEntry[]): Promise<void>;

getPluginDependencies(pluginToBeInstalled: PluginDeployerEntry): Promise<string[]>
getPluginMetadata(pluginToBeInstalled: PluginDeployerEntry): Promise<PluginMetadata | undefined>
}

export const HostedPluginServer = Symbol('HostedPluginServer');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,8 @@ export class HostedPluginDeployerHandler implements PluginDeployerHandler {
return this.currentBackendPluginsMetadata;
}

async getPluginDependencies(plugin: PluginDeployerEntry): Promise<string[]> {
const metadata = await this.reader.getPluginMetadata(plugin.path());
if (metadata) {
if (metadata.model.extensionDependencies) {
return metadata.model.extensionDependencies;
}
}
return [];
getPluginMetadata(plugin: PluginDeployerEntry): Promise<PluginMetadata | undefined> {
return this.reader.getPluginMetadata(plugin.path());
}

async deployFrontendPlugins(frontendPlugins: PluginDeployerEntry[]): Promise<void> {
Expand Down
44 changes: 18 additions & 26 deletions packages/plugin-ext/src/main/node/plugin-deployer-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,47 +108,39 @@ export class PluginDeployerImpl implements PluginDeployer {
await this.deployMultipleEntries([pluginEntry]);
}

protected async deployMultipleEntries(pluginEntries: string[]): Promise<void> {

const deployedPlugins = new Set<string>();

/**
* Iterate over all the plugins, resolving them one at a time and adding
* in extension dependencies
*/
const futurePlugins = [];
while (pluginEntries.length !== 0) {
const currentPlugin = pluginEntries.pop() as string;
if (deployedPlugins.has(currentPlugin)) {
protected async deployMultipleEntries(pluginEntries: ReadonlyArray<string>): Promise<void> {
const visited = new Set<string>();
const pluginsToDeploy = new Map<string, PluginDeployerEntry>();

const queue = [...pluginEntries];
while (queue.length) {
const current = queue.shift()!;
if (visited.has(current)) {
continue;
}
visited.add(current);

// resolve plugins
const pluginDeployerEntries = await this.resolvePlugin(currentPlugin);
const pluginDeployerEntries = await this.resolvePlugin(current);

// now that we have plugins check if we have File Handler for them
await this.applyFileHandlers(pluginDeployerEntries);

// ok now ask for directory handlers
await this.applyDirectoryFileHandlers(pluginDeployerEntries);

// add current plugin deployer entries first because dependencies to be installed first
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JPinkney It does not matter in which order plugins are deployed. They are only loaded when a frontend is connected by then all plugins should be already on the disk.

futurePlugins.unshift(...pluginDeployerEntries);

deployedPlugins.add(currentPlugin);

// gather all dependencies needed for current plugin
for (const deployerEntry of pluginDeployerEntries) {
const deployDependencies = await this.pluginDeployerHandler.getPluginDependencies(deployerEntry);
pluginEntries.push(...deployDependencies);
const metadata = await this.pluginDeployerHandler.getPluginMetadata(deployerEntry);
if (metadata && !pluginsToDeploy.has(metadata.model.id)) {
pluginsToDeploy.set(metadata.model.id, deployerEntry);
if (metadata.model.extensionDependencies) {
queue.push(...metadata.model.extensionDependencies);
}
}
}

}

await this.deployPlugins(futurePlugins);

return Promise.resolve();

await this.deployPlugins([...pluginsToDeploy.values()]);
}

/**
Expand Down