@theia/plugin-ext-vscode 1.53.0-next.55 → 1.53.0-next.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -32
- package/package.json +15 -15
- package/src/browser/plugin-vscode-commands-contribution.ts +987 -987
- package/src/browser/plugin-vscode-contribution.ts +47 -47
- package/src/browser/plugin-vscode-frontend-module.ts +30 -30
- package/src/common/plugin-vscode-environment.ts +59 -59
- package/src/common/plugin-vscode-types.ts +20 -20
- package/src/common/plugin-vscode-uri.ts +45 -45
- package/src/node/context/plugin-vscode-init-fe.ts +43 -43
- package/src/node/local-vsix-file-plugin-deployer-resolver.ts +51 -51
- package/src/node/package.spec.ts +28 -28
- package/src/node/plugin-vscode-backend-module.ts +46 -46
- package/src/node/plugin-vscode-cli-contribution.ts +64 -64
- package/src/node/plugin-vscode-deployer-participant.ts +48 -48
- package/src/node/plugin-vscode-directory-handler.ts +123 -123
- package/src/node/plugin-vscode-file-handler.ts +62 -62
- package/src/node/plugin-vscode-init.ts +80 -80
- package/src/node/plugin-vscode-utils.ts +101 -101
- package/src/node/scanner-vscode.ts +113 -113
package/src/node/package.spec.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
/* note: this bogus test file is required so that
|
|
18
|
-
we are able to run mocha unit tests on this
|
|
19
|
-
package, without having any actual unit tests in it.
|
|
20
|
-
This way a coverage report will be generated,
|
|
21
|
-
showing 0% coverage, instead of no report.
|
|
22
|
-
This file can be removed once we have real unit
|
|
23
|
-
tests in place. */
|
|
24
|
-
|
|
25
|
-
describe('plugin-ext-vscode package', () => {
|
|
26
|
-
|
|
27
|
-
it('support code coverage statistics', () => true);
|
|
28
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/* note: this bogus test file is required so that
|
|
18
|
+
we are able to run mocha unit tests on this
|
|
19
|
+
package, without having any actual unit tests in it.
|
|
20
|
+
This way a coverage report will be generated,
|
|
21
|
+
showing 0% coverage, instead of no report.
|
|
22
|
+
This file can be removed once we have real unit
|
|
23
|
+
tests in place. */
|
|
24
|
+
|
|
25
|
+
describe('plugin-ext-vscode package', () => {
|
|
26
|
+
|
|
27
|
+
it('support code coverage statistics', () => true);
|
|
28
|
+
});
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
-
import {
|
|
19
|
-
PluginDeployerFileHandler, PluginDeployerDirectoryHandler, PluginScanner, PluginDeployerParticipant, PluginDeployerResolver
|
|
20
|
-
} from '@theia/plugin-ext';
|
|
21
|
-
import { PluginVsCodeFileHandler } from './plugin-vscode-file-handler';
|
|
22
|
-
import { PluginVsCodeDirectoryHandler } from './plugin-vscode-directory-handler';
|
|
23
|
-
import { VsCodePluginScanner } from './scanner-vscode';
|
|
24
|
-
import { PluginVsCodeCliContribution } from './plugin-vscode-cli-contribution';
|
|
25
|
-
import { CliContribution } from '@theia/core/lib/node';
|
|
26
|
-
import { PluginHostEnvironmentVariable } from '@theia/plugin-ext/lib/common';
|
|
27
|
-
import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
|
|
28
|
-
import { PluginVSCodeDeployerParticipant } from './plugin-vscode-deployer-participant';
|
|
29
|
-
import { LocalVSIXFilePluginDeployerResolver } from './local-vsix-file-plugin-deployer-resolver';
|
|
30
|
-
|
|
31
|
-
export default new ContainerModule(bind => {
|
|
32
|
-
bind(PluginVSCodeEnvironment).toSelf().inSingletonScope();
|
|
33
|
-
|
|
34
|
-
bind(PluginVSCodeDeployerParticipant).toSelf().inSingletonScope();
|
|
35
|
-
bind(PluginDeployerParticipant).toService(PluginVSCodeDeployerParticipant);
|
|
36
|
-
|
|
37
|
-
bind(PluginDeployerFileHandler).to(PluginVsCodeFileHandler).inSingletonScope();
|
|
38
|
-
bind(PluginDeployerDirectoryHandler).to(PluginVsCodeDirectoryHandler).inSingletonScope();
|
|
39
|
-
bind(PluginScanner).to(VsCodePluginScanner).inSingletonScope();
|
|
40
|
-
|
|
41
|
-
bind(PluginVsCodeCliContribution).toSelf().inSingletonScope();
|
|
42
|
-
bind(CliContribution).toService(PluginVsCodeCliContribution);
|
|
43
|
-
bind(PluginHostEnvironmentVariable).toService(PluginVsCodeCliContribution);
|
|
44
|
-
|
|
45
|
-
bind(PluginDeployerResolver).to(LocalVSIXFilePluginDeployerResolver).inSingletonScope();
|
|
46
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
+
import {
|
|
19
|
+
PluginDeployerFileHandler, PluginDeployerDirectoryHandler, PluginScanner, PluginDeployerParticipant, PluginDeployerResolver
|
|
20
|
+
} from '@theia/plugin-ext';
|
|
21
|
+
import { PluginVsCodeFileHandler } from './plugin-vscode-file-handler';
|
|
22
|
+
import { PluginVsCodeDirectoryHandler } from './plugin-vscode-directory-handler';
|
|
23
|
+
import { VsCodePluginScanner } from './scanner-vscode';
|
|
24
|
+
import { PluginVsCodeCliContribution } from './plugin-vscode-cli-contribution';
|
|
25
|
+
import { CliContribution } from '@theia/core/lib/node';
|
|
26
|
+
import { PluginHostEnvironmentVariable } from '@theia/plugin-ext/lib/common';
|
|
27
|
+
import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
|
|
28
|
+
import { PluginVSCodeDeployerParticipant } from './plugin-vscode-deployer-participant';
|
|
29
|
+
import { LocalVSIXFilePluginDeployerResolver } from './local-vsix-file-plugin-deployer-resolver';
|
|
30
|
+
|
|
31
|
+
export default new ContainerModule(bind => {
|
|
32
|
+
bind(PluginVSCodeEnvironment).toSelf().inSingletonScope();
|
|
33
|
+
|
|
34
|
+
bind(PluginVSCodeDeployerParticipant).toSelf().inSingletonScope();
|
|
35
|
+
bind(PluginDeployerParticipant).toService(PluginVSCodeDeployerParticipant);
|
|
36
|
+
|
|
37
|
+
bind(PluginDeployerFileHandler).to(PluginVsCodeFileHandler).inSingletonScope();
|
|
38
|
+
bind(PluginDeployerDirectoryHandler).to(PluginVsCodeDirectoryHandler).inSingletonScope();
|
|
39
|
+
bind(PluginScanner).to(VsCodePluginScanner).inSingletonScope();
|
|
40
|
+
|
|
41
|
+
bind(PluginVsCodeCliContribution).toSelf().inSingletonScope();
|
|
42
|
+
bind(CliContribution).toService(PluginVsCodeCliContribution);
|
|
43
|
+
bind(PluginHostEnvironmentVariable).toService(PluginVsCodeCliContribution);
|
|
44
|
+
|
|
45
|
+
bind(PluginDeployerResolver).to(LocalVSIXFilePluginDeployerResolver).inSingletonScope();
|
|
46
|
+
});
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { Argv, Arguments } from '@theia/core/shared/yargs';
|
|
19
|
-
import { CliContribution } from '@theia/core/lib/node/cli';
|
|
20
|
-
import { PluginHostEnvironmentVariable } from '@theia/plugin-ext/lib/common';
|
|
21
|
-
import { VSCODE_DEFAULT_API_VERSION } from '../common/plugin-vscode-types';
|
|
22
|
-
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* CLI Contribution allowing to override the VS Code API version which is returned by `vscode.version` API call.
|
|
26
|
-
*/
|
|
27
|
-
@injectable()
|
|
28
|
-
export class PluginVsCodeCliContribution implements CliContribution, PluginHostEnvironmentVariable {
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* CLI argument name to define the supported VS Code API version.
|
|
32
|
-
*/
|
|
33
|
-
static VSCODE_API_VERSION = 'vscode-api-version';
|
|
34
|
-
|
|
35
|
-
protected vsCodeApiVersion?: string;
|
|
36
|
-
protected vsCodeApiVersionDeferred = new Deferred<string>();
|
|
37
|
-
|
|
38
|
-
get vsCodeApiVersionPromise(): Promise<string> {
|
|
39
|
-
return this.vsCodeApiVersionDeferred.promise;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
configure(conf: Argv): void {
|
|
43
|
-
conf.option(PluginVsCodeCliContribution.VSCODE_API_VERSION, {
|
|
44
|
-
// eslint-disable-next-line max-len
|
|
45
|
-
description: `Overrides the version returned by VSCode API 'vscode.version'. Example: --${PluginVsCodeCliContribution.VSCODE_API_VERSION}=<Wanted Version>. Default [${VSCODE_DEFAULT_API_VERSION}]`,
|
|
46
|
-
type: 'string',
|
|
47
|
-
nargs: 1
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
setArguments(args: Arguments): void {
|
|
52
|
-
const arg = args[PluginVsCodeCliContribution.VSCODE_API_VERSION] as string | undefined;
|
|
53
|
-
this.vsCodeApiVersion = arg?.trim() || process.env['VSCODE_API_VERSION']?.trim() || VSCODE_DEFAULT_API_VERSION;
|
|
54
|
-
process.env['VSCODE_API_VERSION'] = this.vsCodeApiVersion;
|
|
55
|
-
this.vsCodeApiVersionDeferred.resolve(this.vsCodeApiVersion);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
process(env: NodeJS.ProcessEnv): void {
|
|
59
|
-
if (this.vsCodeApiVersion) {
|
|
60
|
-
env['VSCODE_API_VERSION'] = this.vsCodeApiVersion;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { Argv, Arguments } from '@theia/core/shared/yargs';
|
|
19
|
+
import { CliContribution } from '@theia/core/lib/node/cli';
|
|
20
|
+
import { PluginHostEnvironmentVariable } from '@theia/plugin-ext/lib/common';
|
|
21
|
+
import { VSCODE_DEFAULT_API_VERSION } from '../common/plugin-vscode-types';
|
|
22
|
+
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* CLI Contribution allowing to override the VS Code API version which is returned by `vscode.version` API call.
|
|
26
|
+
*/
|
|
27
|
+
@injectable()
|
|
28
|
+
export class PluginVsCodeCliContribution implements CliContribution, PluginHostEnvironmentVariable {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* CLI argument name to define the supported VS Code API version.
|
|
32
|
+
*/
|
|
33
|
+
static VSCODE_API_VERSION = 'vscode-api-version';
|
|
34
|
+
|
|
35
|
+
protected vsCodeApiVersion?: string;
|
|
36
|
+
protected vsCodeApiVersionDeferred = new Deferred<string>();
|
|
37
|
+
|
|
38
|
+
get vsCodeApiVersionPromise(): Promise<string> {
|
|
39
|
+
return this.vsCodeApiVersionDeferred.promise;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
configure(conf: Argv): void {
|
|
43
|
+
conf.option(PluginVsCodeCliContribution.VSCODE_API_VERSION, {
|
|
44
|
+
// eslint-disable-next-line max-len
|
|
45
|
+
description: `Overrides the version returned by VSCode API 'vscode.version'. Example: --${PluginVsCodeCliContribution.VSCODE_API_VERSION}=<Wanted Version>. Default [${VSCODE_DEFAULT_API_VERSION}]`,
|
|
46
|
+
type: 'string',
|
|
47
|
+
nargs: 1
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setArguments(args: Arguments): void {
|
|
52
|
+
const arg = args[PluginVsCodeCliContribution.VSCODE_API_VERSION] as string | undefined;
|
|
53
|
+
this.vsCodeApiVersion = arg?.trim() || process.env['VSCODE_API_VERSION']?.trim() || VSCODE_DEFAULT_API_VERSION;
|
|
54
|
+
process.env['VSCODE_API_VERSION'] = this.vsCodeApiVersion;
|
|
55
|
+
this.vsCodeApiVersionDeferred.resolve(this.vsCodeApiVersion);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
process(env: NodeJS.ProcessEnv): void {
|
|
59
|
+
if (this.vsCodeApiVersion) {
|
|
60
|
+
env['VSCODE_API_VERSION'] = this.vsCodeApiVersion;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2020 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import * as fs from '@theia/core/shared/fs-extra';
|
|
19
|
-
import { FileUri } from '@theia/core/lib/node';
|
|
20
|
-
import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
|
|
21
|
-
import { PluginDeployerParticipant, PluginDeployerStartContext } from '@theia/plugin-ext/lib/common/plugin-protocol';
|
|
22
|
-
import { LocalVSIXFilePluginDeployerResolver } from './local-vsix-file-plugin-deployer-resolver';
|
|
23
|
-
|
|
24
|
-
@injectable()
|
|
25
|
-
export class PluginVSCodeDeployerParticipant implements PluginDeployerParticipant {
|
|
26
|
-
|
|
27
|
-
@inject(PluginVSCodeEnvironment)
|
|
28
|
-
protected readonly environments: PluginVSCodeEnvironment;
|
|
29
|
-
|
|
30
|
-
async onWillStart(context: PluginDeployerStartContext): Promise<void> {
|
|
31
|
-
const extensionDeploymentDirUri = await this.environments.getDeploymentDirUri();
|
|
32
|
-
context.userEntries.push(extensionDeploymentDirUri.withScheme('local-dir').toString());
|
|
33
|
-
|
|
34
|
-
const userExtensionDirUri = await this.environments.getUserExtensionsDirUri();
|
|
35
|
-
const userExtensionDirPath = FileUri.fsPath(userExtensionDirUri);
|
|
36
|
-
|
|
37
|
-
if (await fs.pathExists(userExtensionDirPath)) {
|
|
38
|
-
const files = await fs.readdir(userExtensionDirPath);
|
|
39
|
-
for (const file of files) {
|
|
40
|
-
if (file.endsWith(LocalVSIXFilePluginDeployerResolver.FILE_EXTENSION)) {
|
|
41
|
-
const extensionUri = userExtensionDirUri.resolve(file).withScheme('local-file').toString();
|
|
42
|
-
console.log(`found drop-in extension "${extensionUri}"`);
|
|
43
|
-
context.userEntries.push(extensionUri);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2020 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
+
import * as fs from '@theia/core/shared/fs-extra';
|
|
19
|
+
import { FileUri } from '@theia/core/lib/node';
|
|
20
|
+
import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
|
|
21
|
+
import { PluginDeployerParticipant, PluginDeployerStartContext } from '@theia/plugin-ext/lib/common/plugin-protocol';
|
|
22
|
+
import { LocalVSIXFilePluginDeployerResolver } from './local-vsix-file-plugin-deployer-resolver';
|
|
23
|
+
|
|
24
|
+
@injectable()
|
|
25
|
+
export class PluginVSCodeDeployerParticipant implements PluginDeployerParticipant {
|
|
26
|
+
|
|
27
|
+
@inject(PluginVSCodeEnvironment)
|
|
28
|
+
protected readonly environments: PluginVSCodeEnvironment;
|
|
29
|
+
|
|
30
|
+
async onWillStart(context: PluginDeployerStartContext): Promise<void> {
|
|
31
|
+
const extensionDeploymentDirUri = await this.environments.getDeploymentDirUri();
|
|
32
|
+
context.userEntries.push(extensionDeploymentDirUri.withScheme('local-dir').toString());
|
|
33
|
+
|
|
34
|
+
const userExtensionDirUri = await this.environments.getUserExtensionsDirUri();
|
|
35
|
+
const userExtensionDirPath = FileUri.fsPath(userExtensionDirUri);
|
|
36
|
+
|
|
37
|
+
if (await fs.pathExists(userExtensionDirPath)) {
|
|
38
|
+
const files = await fs.readdir(userExtensionDirPath);
|
|
39
|
+
for (const file of files) {
|
|
40
|
+
if (file.endsWith(LocalVSIXFilePluginDeployerResolver.FILE_EXTENSION)) {
|
|
41
|
+
const extensionUri = userExtensionDirUri.resolve(file).withScheme('local-file').toString();
|
|
42
|
+
console.log(`found drop-in extension "${extensionUri}"`);
|
|
43
|
+
context.userEntries.push(extensionUri);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import * as path from 'path';
|
|
18
|
-
import * as fs from '@theia/core/shared/fs-extra';
|
|
19
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
20
|
-
import type { RecursivePartial, URI } from '@theia/core';
|
|
21
|
-
import { Deferred, firstTrue } from '@theia/core/lib/common/promise-util';
|
|
22
|
-
import {
|
|
23
|
-
PluginDeployerDirectoryHandler, PluginDeployerEntry, PluginDeployerDirectoryHandlerContext,
|
|
24
|
-
PluginDeployerEntryType, PluginPackage, PluginIdentifiers
|
|
25
|
-
} from '@theia/plugin-ext';
|
|
26
|
-
import { PluginCliContribution } from '@theia/plugin-ext/lib/main/node/plugin-cli-contribution';
|
|
27
|
-
import { TMP_DIR_PREFIX } from './plugin-vscode-utils';
|
|
28
|
-
|
|
29
|
-
@injectable()
|
|
30
|
-
export class PluginVsCodeDirectoryHandler implements PluginDeployerDirectoryHandler {
|
|
31
|
-
|
|
32
|
-
protected readonly deploymentDirectory: Deferred<URI>;
|
|
33
|
-
|
|
34
|
-
@inject(PluginCliContribution) protected readonly pluginCli: PluginCliContribution;
|
|
35
|
-
|
|
36
|
-
async accept(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
37
|
-
console.debug(`Resolving "${plugin.id()}" as a VS Code extension...`);
|
|
38
|
-
if (plugin.path().startsWith(TMP_DIR_PREFIX)) {
|
|
39
|
-
// avoid adding corrupted plugins from temporary directories
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return this.attemptResolution(plugin);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
protected async attemptResolution(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
46
|
-
if (this.resolvePackage(plugin)) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
return this.deriveMetadata(plugin);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected async deriveMetadata(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
53
|
-
return firstTrue(
|
|
54
|
-
this.resolveFromSources(plugin),
|
|
55
|
-
this.resolveFromVSIX(plugin),
|
|
56
|
-
this.resolveFromNpmTarball(plugin)
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async handle(context: PluginDeployerDirectoryHandlerContext): Promise<void> {
|
|
61
|
-
const types: PluginDeployerEntryType[] = [];
|
|
62
|
-
const packageJson: PluginPackage = context.pluginEntry().getValue('package.json');
|
|
63
|
-
if (packageJson.browser) {
|
|
64
|
-
types.push(PluginDeployerEntryType.FRONTEND);
|
|
65
|
-
}
|
|
66
|
-
if (packageJson.main || !packageJson.browser) {
|
|
67
|
-
types.push(PluginDeployerEntryType.BACKEND);
|
|
68
|
-
}
|
|
69
|
-
context.pluginEntry().accept(...types);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
protected async resolveFromSources(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
73
|
-
const pluginPath = plugin.path();
|
|
74
|
-
const pck = await this.requirePackage(pluginPath);
|
|
75
|
-
return this.resolvePackage(plugin, { pluginPath, pck });
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
protected async resolveFromVSIX(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
79
|
-
if (!(await fs.pathExists(path.join(plugin.path(), 'extension.vsixmanifest')))) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
const pluginPath = path.join(plugin.path(), 'extension');
|
|
83
|
-
const pck = await this.requirePackage(pluginPath);
|
|
84
|
-
return this.resolvePackage(plugin, { pluginPath, pck });
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
protected async resolveFromNpmTarball(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
88
|
-
const pluginPath = path.join(plugin.path(), 'package');
|
|
89
|
-
const pck = await this.requirePackage(pluginPath);
|
|
90
|
-
return this.resolvePackage(plugin, { pluginPath, pck });
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
protected resolvePackage(plugin: PluginDeployerEntry, options?: {
|
|
94
|
-
pluginPath: string
|
|
95
|
-
pck?: RecursivePartial<PluginPackage>
|
|
96
|
-
}): boolean {
|
|
97
|
-
const { pluginPath, pck } = options || {
|
|
98
|
-
pluginPath: plugin.path(),
|
|
99
|
-
pck: plugin.getValue('package.json')
|
|
100
|
-
};
|
|
101
|
-
if (!pck || !pck.name || !pck.version || !pck.engines || !pck.engines.vscode) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
pck.publisher ??= PluginIdentifiers.UNPUBLISHED;
|
|
105
|
-
if (options) {
|
|
106
|
-
plugin.storeValue('package.json', pck);
|
|
107
|
-
plugin.rootPath = plugin.path();
|
|
108
|
-
plugin.updatePath(pluginPath);
|
|
109
|
-
}
|
|
110
|
-
console.debug(`Resolved "${plugin.id()}" to a VS Code extension "${pck.name}@${pck.version}" with engines:`, pck.engines);
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
protected async requirePackage(pluginPath: string): Promise<PluginPackage | undefined> {
|
|
115
|
-
try {
|
|
116
|
-
const plugin: PluginPackage = await fs.readJSON(path.join(pluginPath, 'package.json'));
|
|
117
|
-
plugin.publisher ??= PluginIdentifiers.UNPUBLISHED;
|
|
118
|
-
return plugin;
|
|
119
|
-
} catch {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import * as path from 'path';
|
|
18
|
+
import * as fs from '@theia/core/shared/fs-extra';
|
|
19
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
20
|
+
import type { RecursivePartial, URI } from '@theia/core';
|
|
21
|
+
import { Deferred, firstTrue } from '@theia/core/lib/common/promise-util';
|
|
22
|
+
import {
|
|
23
|
+
PluginDeployerDirectoryHandler, PluginDeployerEntry, PluginDeployerDirectoryHandlerContext,
|
|
24
|
+
PluginDeployerEntryType, PluginPackage, PluginIdentifiers
|
|
25
|
+
} from '@theia/plugin-ext';
|
|
26
|
+
import { PluginCliContribution } from '@theia/plugin-ext/lib/main/node/plugin-cli-contribution';
|
|
27
|
+
import { TMP_DIR_PREFIX } from './plugin-vscode-utils';
|
|
28
|
+
|
|
29
|
+
@injectable()
|
|
30
|
+
export class PluginVsCodeDirectoryHandler implements PluginDeployerDirectoryHandler {
|
|
31
|
+
|
|
32
|
+
protected readonly deploymentDirectory: Deferred<URI>;
|
|
33
|
+
|
|
34
|
+
@inject(PluginCliContribution) protected readonly pluginCli: PluginCliContribution;
|
|
35
|
+
|
|
36
|
+
async accept(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
37
|
+
console.debug(`Resolving "${plugin.id()}" as a VS Code extension...`);
|
|
38
|
+
if (plugin.path().startsWith(TMP_DIR_PREFIX)) {
|
|
39
|
+
// avoid adding corrupted plugins from temporary directories
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return this.attemptResolution(plugin);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected async attemptResolution(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
46
|
+
if (this.resolvePackage(plugin)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return this.deriveMetadata(plugin);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected async deriveMetadata(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
53
|
+
return firstTrue(
|
|
54
|
+
this.resolveFromSources(plugin),
|
|
55
|
+
this.resolveFromVSIX(plugin),
|
|
56
|
+
this.resolveFromNpmTarball(plugin)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async handle(context: PluginDeployerDirectoryHandlerContext): Promise<void> {
|
|
61
|
+
const types: PluginDeployerEntryType[] = [];
|
|
62
|
+
const packageJson: PluginPackage = context.pluginEntry().getValue('package.json');
|
|
63
|
+
if (packageJson.browser) {
|
|
64
|
+
types.push(PluginDeployerEntryType.FRONTEND);
|
|
65
|
+
}
|
|
66
|
+
if (packageJson.main || !packageJson.browser) {
|
|
67
|
+
types.push(PluginDeployerEntryType.BACKEND);
|
|
68
|
+
}
|
|
69
|
+
context.pluginEntry().accept(...types);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
protected async resolveFromSources(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
73
|
+
const pluginPath = plugin.path();
|
|
74
|
+
const pck = await this.requirePackage(pluginPath);
|
|
75
|
+
return this.resolvePackage(plugin, { pluginPath, pck });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected async resolveFromVSIX(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
79
|
+
if (!(await fs.pathExists(path.join(plugin.path(), 'extension.vsixmanifest')))) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const pluginPath = path.join(plugin.path(), 'extension');
|
|
83
|
+
const pck = await this.requirePackage(pluginPath);
|
|
84
|
+
return this.resolvePackage(plugin, { pluginPath, pck });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
protected async resolveFromNpmTarball(plugin: PluginDeployerEntry): Promise<boolean> {
|
|
88
|
+
const pluginPath = path.join(plugin.path(), 'package');
|
|
89
|
+
const pck = await this.requirePackage(pluginPath);
|
|
90
|
+
return this.resolvePackage(plugin, { pluginPath, pck });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected resolvePackage(plugin: PluginDeployerEntry, options?: {
|
|
94
|
+
pluginPath: string
|
|
95
|
+
pck?: RecursivePartial<PluginPackage>
|
|
96
|
+
}): boolean {
|
|
97
|
+
const { pluginPath, pck } = options || {
|
|
98
|
+
pluginPath: plugin.path(),
|
|
99
|
+
pck: plugin.getValue('package.json')
|
|
100
|
+
};
|
|
101
|
+
if (!pck || !pck.name || !pck.version || !pck.engines || !pck.engines.vscode) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
pck.publisher ??= PluginIdentifiers.UNPUBLISHED;
|
|
105
|
+
if (options) {
|
|
106
|
+
plugin.storeValue('package.json', pck);
|
|
107
|
+
plugin.rootPath = plugin.path();
|
|
108
|
+
plugin.updatePath(pluginPath);
|
|
109
|
+
}
|
|
110
|
+
console.debug(`Resolved "${plugin.id()}" to a VS Code extension "${pck.name}@${pck.version}" with engines:`, pck.engines);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
protected async requirePackage(pluginPath: string): Promise<PluginPackage | undefined> {
|
|
115
|
+
try {
|
|
116
|
+
const plugin: PluginPackage = await fs.readJSON(path.join(pluginPath, 'package.json'));
|
|
117
|
+
plugin.publisher ??= PluginIdentifiers.UNPUBLISHED;
|
|
118
|
+
return plugin;
|
|
119
|
+
} catch {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|