Skip to content

Commit

Permalink
fix #6036: prefer listed plugins to dependencies
Browse files Browse the repository at this point in the history
otherwise the wrong version gets installed from a marketplace instead of from local vsix file for example

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Aug 25, 2019
1 parent e697863 commit 8bba433
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 34 deletions.
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
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

0 comments on commit 8bba433

Please sign in to comment.