Skip to content

Commit

Permalink
fix #6055: tolerate missing internet access while deploying plugins
Browse files Browse the repository at this point in the history
- check whether a plugin is already to be deployed by an id
- fix to use canonical plugin ids to resolve and activate plugins
- make sure that dependencies only resolved after listed plugin entries
- don't fail the entire deployment if a resolution of a single plugin entry failed

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Aug 29, 2019
1 parent 30b340a commit 1a3048d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-ext-vscode/src/node/scanner-vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ export class VsCodePluginScanner extends TheiaPluginScanner implements PluginSca
* to an array of deployable extension dependencies
*/
private getDeployableDependencies(dependencies: string[]): string[] {
return dependencies.map(dep => this.VSCODE_PREFIX + dep);
return dependencies.map(dep => this.VSCODE_PREFIX + dep.toLowerCase());
}
}
4 changes: 4 additions & 0 deletions packages/plugin-ext/src/common/plugin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ export interface PluginModel {
backend?: string;
};
contributes?: PluginContribution;
/**
* The deployable form of extensionDependencies from package.json,
* i.e. not `publisher.name`, but `vscode:extension/publisher.name`.
*/
extensionDependencies?: string[];
}

Expand Down
53 changes: 33 additions & 20 deletions packages/plugin-ext/src/main/node/plugin-deployer-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,40 @@ export class PluginDeployerImpl implements PluginDeployer {

const queue = [...pluginEntries];
while (queue.length) {
const current = queue.shift()!;
if (visited.has(current)) {
continue;
const chunk = [];
while (queue.length) {
const current = queue.shift()!;
if (visited.has(current)) {
continue;
}
visited.add(current);
try {
const pluginDeployerEntries = await this.resolvePlugin(current);
await this.applyFileHandlers(pluginDeployerEntries);
await this.applyDirectoryFileHandlers(pluginDeployerEntries);
for (const deployerEntry of pluginDeployerEntries) {
const metadata = await this.pluginDeployerHandler.getPluginMetadata(deployerEntry);
if (metadata && !pluginsToDeploy.has(metadata.model.id)) {
pluginsToDeploy.set(metadata.model.id, deployerEntry);
chunk.push(metadata);
}
}
} catch (e) {
console.error(`Failed to resolve plugins from '${current}'`, e);
}
}
visited.add(current);

// resolve plugins
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);

for (const deployerEntry of pluginDeployerEntries) {
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);
for (const metadata of chunk) {
const extensionDependencies = metadata.source.extensionDependencies;
const deployableExtensionDependencies = metadata.model.extensionDependencies;
if (extensionDependencies && deployableExtensionDependencies) {
for (let dependencyIndex = 0; dependencyIndex < extensionDependencies.length; dependencyIndex++) {
const dependencyId = extensionDependencies[dependencyIndex].toLowerCase();
if (!pluginsToDeploy.has(dependencyId)) {
const deployableDependency = deployableExtensionDependencies[dependencyIndex];
if (deployableDependency) {
queue.push(deployableDependency);
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/plugin/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
loading = (async () => {
if (plugin.rawModel.extensionDependencies) {
for (const dependencyId of plugin.rawModel.extensionDependencies) {
const dependency = this.registry.get(dependencyId);
const dependency = this.registry.get(dependencyId.toLowerCase());
if (dependency) {
await this.loadPlugin(dependency, configStorage, visited);
} else {
Expand Down

0 comments on commit 1a3048d

Please sign in to comment.