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

Fix vscode.env.appRoot path #13285

Merged
merged 2 commits into from
Jan 24, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const frontendOnlyApplicationModule = new ContainerModule((bind, unbind,
const mockedApplicationServer: ApplicationServer = {
getExtensionsInfos: async (): Promise<ExtensionInfo[]> => [],
getApplicationInfo: async (): Promise<ApplicationInfo | undefined> => undefined,
getApplicationRoot: async (): Promise<string> => '',
getBackendOS: async (): Promise<OS.Type> => OS.Type.Linux
};
if (isBound(ApplicationServer)) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/common/application-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const ApplicationServer = Symbol('ApplicationServer');
export interface ApplicationServer {
getExtensionsInfos(): Promise<ExtensionInfo[]>;
getApplicationInfo(): Promise<ApplicationInfo | undefined>;
getApplicationRoot(): Promise<string>;
/**
* @deprecated since 1.25.0. Use `OS.backend.type()` instead.
*/
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/node/application-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@ export class ApplicationServerImpl implements ApplicationServer {
const name = pck.name;
const version = pck.version;

return Promise.resolve({ name, version });
return Promise.resolve({
name,
version
});
}
return Promise.resolve(undefined);
}

getApplicationRoot(): Promise<string> {
return Promise.resolve(this.applicationPackage.projectPath);
}

async getBackendOS(): Promise<OS.Type> {
return OS.type();
}
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ export interface EnvInit {
queryParams: QueryParameters;
language: string;
shell: string;
uiKind: UIKind,
uiKind: UIKind;
appName: string;
appHost: string;
appRoot: string;
}

export interface PluginAPI {
Expand Down
12 changes: 10 additions & 2 deletions packages/plugin-ext/src/hosted/browser/hosted-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import { LanguageService } from '@theia/monaco-editor-core/esm/vs/editor/common/
import { Uint8ArrayReadBuffer, Uint8ArrayWriteBuffer } from '@theia/core/lib/common/message-rpc/uint8-array-message-buffer';
import { BasicChannel } from '@theia/core/lib/common/message-rpc/channel';
import { NotebookTypeRegistry, NotebookService, NotebookRendererMessagingService } from '@theia/notebook/lib/browser';
import { ApplicationServer } from '@theia/core/lib/common/application-protocol';
import {
AbstractHostedPluginSupport, PluginContributions, PluginHost,
ALL_ACTIVATION_EVENT, isConnectionScopedBackendPlugin
Expand Down Expand Up @@ -174,6 +175,9 @@ export class HostedPluginSupport extends AbstractHostedPluginSupport<PluginManag
@inject(PluginCustomEditorRegistry)
protected readonly customEditorRegistry: PluginCustomEditorRegistry;

@inject(ApplicationServer)
protected readonly applicationServer: ApplicationServer;

constructor() {
super(generateUuid());
}
Expand Down Expand Up @@ -302,7 +306,10 @@ export class HostedPluginSupport extends AbstractHostedPluginSupport<PluginManag
const isElectron = environment.electron.is();

const supportedActivationEvents = [...HostedPluginSupport.BUILTIN_ACTIVATION_EVENTS];
const additionalActivationEvents = await this.envServer.getValue(HostedPluginSupport.ADDITIONAL_ACTIVATION_EVENTS_ENV);
const [additionalActivationEvents, appRoot] = await Promise.all([
this.envServer.getValue(HostedPluginSupport.ADDITIONAL_ACTIVATION_EVENTS_ENV),
this.applicationServer.getApplicationRoot()
]);
if (additionalActivationEvents && additionalActivationEvents.value) {
additionalActivationEvents.value.split(',').forEach(event => supportedActivationEvents.push(event));
}
Expand All @@ -317,7 +324,8 @@ export class HostedPluginSupport extends AbstractHostedPluginSupport<PluginManag
shell: defaultShell,
uiKind: isElectron ? UIKind.Desktop : UIKind.Web,
appName: FrontendApplicationConfigProvider.get().applicationName,
appHost: isElectron ? 'desktop' : 'web' // TODO: 'web' could be the embedder's name, e.g. 'github.dev'
appHost: isElectron ? 'desktop' : 'web', // TODO: 'web' could be the embedder's name, e.g. 'github.dev'
appRoot
},
extApi,
webview: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class WorkerEnvExtImpl extends EnvExtImpl {
/**
* Throw error for app-root as there is no filesystem in worker context
*/
get appRoot(): string {
override get appRoot(): string {
throw new Error('There is no app root in worker context');
}

Expand Down
9 changes: 8 additions & 1 deletion packages/plugin-ext/src/plugin/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export abstract class EnvExtImpl {
private envMachineId: string;
private envSessionId: string;
private host: string;
private applicationRoot: string;
private _remoteName: string | undefined;

constructor() {
Expand Down Expand Up @@ -84,6 +85,10 @@ export abstract class EnvExtImpl {
this.host = appHost;
}

setAppRoot(appRoot: string): void {
this.applicationRoot = appRoot;
}

getClientOperatingSystem(): Promise<theia.OperatingSystem> {
return this.proxy.$getClientOperatingSystem();
}
Expand All @@ -92,7 +97,9 @@ export abstract class EnvExtImpl {
return this.applicationName;
}

abstract get appRoot(): string;
get appRoot(): string {
return this.applicationRoot;
}

abstract get isNewAppInstall(): boolean;

Expand Down
7 changes: 0 additions & 7 deletions packages/plugin-ext/src/plugin/node/env-node-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ export class EnvNodeExtImpl extends EnvExtImpl {
return this.macMachineId;
}

/**
* Provides application root.
*/
get appRoot(): string {
return __dirname;
}

get isNewAppInstall(): boolean {
return this._isNewAppInstall;
}
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-ext/src/plugin/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ export class PluginManagerExtImpl extends AbstractPluginManagerExtImpl<PluginMan
this.terminalService.$setShell(params.env.shell);
this.envExt.setApplicationName(params.env.appName);
this.envExt.setAppHost(params.env.appHost);
this.envExt.setAppRoot(params.env.appRoot);

this.preferencesManager.init(params.preferences);

Expand Down
Loading