-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vscode): add support for "workbench.extensions.installExtension"…
… command Signed-off-by: Florian Greinacher <[email protected]>
- Loading branch information
1 parent
e209832
commit c372d16
Showing
8 changed files
with
154 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/plugin-ext/src/main/node/resolvers/local-directory-plugin-deployer-resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2018 Red Hat, Inc. and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
import { PluginDeployerResolverContext } from '../../../common/plugin-protocol'; | ||
import { injectable } from 'inversify'; | ||
import * as fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
import { LocalPluginDeployerResolver } from './local-plugin-deployer-resolver'; | ||
|
||
@injectable() | ||
export class LocalDirectoryPluginDeployerResolver extends LocalPluginDeployerResolver { | ||
static LOCAL_DIR = 'local-dir'; | ||
|
||
constructor() { | ||
super(LocalDirectoryPluginDeployerResolver.LOCAL_DIR); | ||
} | ||
|
||
protected async resolveFromLocalPath(pluginResolverContext: PluginDeployerResolverContext, localPath: string): Promise<void> { | ||
const files = await fs.readdir(localPath); | ||
files.forEach(file => | ||
pluginResolverContext.addPlugin(file, path.resolve(localPath, file)) | ||
); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
packages/plugin-ext/src/main/node/resolvers/local-file-plugin-deployer-resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2018 Red Hat, Inc. and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
import { PluginDeployerResolverContext } from '../../../common/plugin-protocol'; | ||
import { injectable } from 'inversify'; | ||
import * as path from 'path'; | ||
import { LocalPluginDeployerResolver } from './local-plugin-deployer-resolver'; | ||
|
||
@injectable() | ||
export class LocalFilePluginDeployerResolver extends LocalPluginDeployerResolver { | ||
static LOCAL_FILE = 'local-file'; | ||
|
||
constructor() { | ||
super(LocalFilePluginDeployerResolver.LOCAL_FILE); | ||
} | ||
|
||
async resolveFromLocalPath(pluginResolverContext: PluginDeployerResolverContext, localPath: string): Promise<void> { | ||
const fileName = path.basename(localPath); | ||
pluginResolverContext.addPlugin(fileName, localPath); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
packages/plugin-ext/src/main/node/resolvers/local-plugin-deployer-resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2020 Red Hat, Inc. and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { PluginDeployerResolver, PluginDeployerResolverContext } from '../../../common/plugin-protocol'; | ||
import * as fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
import { FileUri } from '@theia/core/lib/node'; | ||
import URI from '@theia/core/lib/common/uri'; | ||
|
||
export abstract class LocalPluginDeployerResolver implements PluginDeployerResolver { | ||
constructor(private readonly scheme: string) { } | ||
|
||
public async resolve(pluginResolverContext: PluginDeployerResolverContext): Promise<void> { | ||
const localPath = await this.resolveLocalPluginPath( | ||
pluginResolverContext, | ||
this.scheme); | ||
if (localPath) { | ||
await this.resolveFromLocalPath(pluginResolverContext, localPath); | ||
} | ||
} | ||
|
||
public accept(pluginId: string): boolean { | ||
return pluginId.startsWith(this.scheme); | ||
} | ||
|
||
protected abstract resolveFromLocalPath(pluginResolverContext: PluginDeployerResolverContext, localPath: string): Promise<void>; | ||
|
||
private async resolveLocalPluginPath( | ||
pluginResolverContext: PluginDeployerResolverContext, | ||
expectedScheme: string): Promise<string | null> { | ||
const localUri = new URI(pluginResolverContext.getOriginId()); | ||
if (localUri.scheme !== expectedScheme) { | ||
return null; | ||
} | ||
let fsPath = FileUri.fsPath(localUri); | ||
if (!path.isAbsolute(fsPath)) { | ||
fsPath = path.resolve(process.cwd(), fsPath); | ||
} | ||
if (!await fs.pathExists(fsPath)) { | ||
console.warn(`The local plugin referenced by ${pluginResolverContext.getOriginId()} does not exist.`); | ||
return null; | ||
} | ||
return fsPath; | ||
} | ||
|
||
} |
63 changes: 0 additions & 63 deletions
63
packages/plugin-ext/src/main/node/resolvers/plugin-local-dir-resolver.ts
This file was deleted.
Oops, something went wrong.