Skip to content

Commit 75480bd

Browse files
author
Akos Kitta
committed
fix: extra metadata is unavailable at webpack time
merge in the frontend config and any other metadata from the final app's package.json, as those are not available at theia build time. Signed-off-by: Akos Kitta <[email protected]>
1 parent 28bc470 commit 75480bd

File tree

12 files changed

+149
-58
lines changed

12 files changed

+149
-58
lines changed

Diff for: .vscode/launch.json

+19-26
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
"type": "node",
66
"request": "launch",
77
"name": "App",
8-
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
8+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
99
"windows": {
10-
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd",
10+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd",
1111
},
1212
"cwd": "${workspaceFolder}/electron-app",
1313
"args": [
1414
".",
1515
"--log-level=debug",
1616
"--hostname=localhost",
17-
"--app-project-path=${workspaceRoot}/electron-app",
17+
"--app-project-path=${workspaceFolder}/electron-app",
1818
"--remote-debugging-port=9222",
1919
"--no-app-auto-install",
2020
"--plugins=local-dir:./plugins",
@@ -26,11 +26,11 @@
2626
},
2727
"sourceMaps": true,
2828
"outFiles": [
29-
"${workspaceRoot}/electron-app/src-gen/backend/*.js",
30-
"${workspaceRoot}/electron-app/src-gen/frontend/*.js",
31-
"${workspaceRoot}/electron-app/lib/**/*.js",
32-
"${workspaceRoot}/arduino-ide-extension/lib/**/*.js",
33-
"${workspaceRoot}/node_modules/@theia/**/*.js"
29+
"${workspaceFolder}/electron-app/lib/backend/electron-main.js",
30+
"${workspaceFolder}/electron-app/lib/backend/main.js",
31+
"${workspaceFolder}/electron-app/lib/**/*.js",
32+
"${workspaceFolder}/arduino-ide-extension/lib/**/*.js",
33+
"${workspaceFolder}/node_modules/@theia/**/*.js"
3434
],
3535
"smartStep": true,
3636
"internalConsoleOptions": "openOnSessionStart",
@@ -40,16 +40,16 @@
4040
"type": "node",
4141
"request": "launch",
4242
"name": "App [Dev]",
43-
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
43+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
4444
"windows": {
45-
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd",
45+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd",
4646
},
4747
"cwd": "${workspaceFolder}/electron-app",
4848
"args": [
4949
".",
5050
"--log-level=debug",
5151
"--hostname=localhost",
52-
"--app-project-path=${workspaceRoot}/electron-app",
52+
"--app-project-path=${workspaceFolder}/electron-app",
5353
"--remote-debugging-port=9222",
5454
"--no-app-auto-install",
5555
"--plugins=local-dir:./plugins",
@@ -63,11 +63,11 @@
6363
},
6464
"sourceMaps": true,
6565
"outFiles": [
66-
"${workspaceRoot}/electron-app/src-gen/backend/*.js",
67-
"${workspaceRoot}/electron-app/src-gen/frontend/*.js",
68-
"${workspaceRoot}/electron-app/lib/**/*.js",
69-
"${workspaceRoot}/arduino-ide-extension/lib/**/*.js",
70-
"${workspaceRoot}/node_modules/@theia/**/*.js"
66+
"${workspaceFolder}/electron-app/lib/backend/electron-main.js",
67+
"${workspaceFolder}/electron-app/lib/backend/main.js",
68+
"${workspaceFolder}/electron-app/lib/**/*.js",
69+
"${workspaceFolder}/arduino-ide-extension/lib/**/*.js",
70+
"${workspaceFolder}/node_modules/@theia/**/*.js"
7171
],
7272
"smartStep": true,
7373
"internalConsoleOptions": "openOnSessionStart",
@@ -84,7 +84,7 @@
8484
"type": "node",
8585
"request": "launch",
8686
"name": "Run Test [current]",
87-
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
87+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
8888
"args": [
8989
"--require",
9090
"reflect-metadata/Reflect",
@@ -95,7 +95,7 @@
9595
"**/${fileBasenameNoExtension}.js"
9696
],
9797
"env": {
98-
"TS_NODE_PROJECT": "${workspaceRoot}/tsconfig.json",
98+
"TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json",
9999
"IDE2_TEST": "true"
100100
},
101101
"sourceMaps": true,
@@ -109,19 +109,12 @@
109109
"name": "Attach by Process ID",
110110
"processId": "${command:PickProcess}"
111111
},
112-
{
113-
"type": "node",
114-
"request": "launch",
115-
"name": "Electron Packager",
116-
"program": "${workspaceRoot}/electron/packager/index.js",
117-
"cwd": "${workspaceFolder}/electron/packager"
118-
}
119112
],
120113
"compounds": [
121114
{
122115
"name": "Launch Electron Backend & Frontend",
123116
"configurations": [
124-
"App (Electron)",
117+
"App",
125118
"Attach to Electron Frontend"
126119
]
127120
}

Diff for: arduino-ide-extension/src/browser/app-service.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import type { Disposable } from '@theia/core/lib/common/disposable';
2+
import type { AppInfo } from '../electron-common/electron-arduino';
23
import type { StartupTasks } from '../electron-common/startup-task';
34
import type { Sketch } from './contributions/contribution';
45

6+
export type { AppInfo };
7+
58
export const AppService = Symbol('AppService');
69
export interface AppService {
710
quit(): void;
8-
version(): Promise<string>;
11+
info(): Promise<AppInfo>;
912
registerStartupTasksHandler(
1013
handler: (tasks: StartupTasks) => void
1114
): Disposable;

Diff for: arduino-ide-extension/src/browser/contributions/about.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { nls } from '@theia/core/lib/common/nls';
44
import { isOSX, isWindows } from '@theia/core/lib/common/os';
55
import { inject, injectable } from '@theia/core/shared/inversify';
66
import moment from 'moment';
7-
import { ConfigService } from '../../common/protocol';
87
import { AppService } from '../app-service';
98
import { ArduinoMenus } from '../menu/arduino-menus';
109
import {
@@ -18,8 +17,6 @@ import {
1817
export class About extends Contribution {
1918
@inject(ClipboardService)
2019
private readonly clipboardService: ClipboardService;
21-
@inject(ConfigService)
22-
private readonly configService: ConfigService;
2320
@inject(AppService)
2421
private readonly appService: AppService;
2522

@@ -42,11 +39,9 @@ export class About extends Contribution {
4239
}
4340

4441
private async showAbout(): Promise<void> {
45-
const [appVersion, cliVersion] = await Promise.all([
46-
this.appService.version(),
47-
this.configService.getVersion(),
48-
]);
49-
const buildDate = this.buildDate;
42+
const appInfo = await this.appService.info();
43+
const { appVersion, cliVersion, buildDate } = appInfo;
44+
5045
const detail = (showAll: boolean) =>
5146
nls.localize(
5247
'arduino/about/detail',
@@ -84,10 +79,6 @@ export class About extends Contribution {
8479
return FrontendApplicationConfigProvider.get().applicationName;
8580
}
8681

87-
private get buildDate(): string | undefined {
88-
return FrontendApplicationConfigProvider.get().buildDate;
89-
}
90-
9182
private ago(isoTime: string): string {
9283
const now = moment(Date.now());
9384
const other = moment(isoTime);

Diff for: arduino-ide-extension/src/common/protocol/config-service.ts

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { RecursivePartial } from '@theia/core/lib/common/types';
33
export const ConfigServicePath = '/services/config-service';
44
export const ConfigService = Symbol('ConfigService');
55
export interface ConfigService {
6-
getVersion(): Promise<Readonly<string>>;
76
getConfiguration(): Promise<ConfigState>;
87
setConfiguration(config: Config): Promise<void>;
98
}

Diff for: arduino-ide-extension/src/electron-browser/electron-app-service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Disposable } from '@theia/core/lib/common/disposable';
22
import { injectable } from '@theia/core/shared/inversify';
3-
import type { AppService } from '../browser/app-service';
3+
import type { AppInfo, AppService } from '../browser/app-service';
44
import type { Sketch } from '../common/protocol/sketches-service';
55
import type { StartupTasks } from '../electron-common/startup-task';
66

@@ -10,8 +10,8 @@ export class ElectronAppService implements AppService {
1010
window.electronArduino.quitApp();
1111
}
1212

13-
version(): Promise<string> {
14-
return window.electronArduino.appVersion();
13+
info(): Promise<AppInfo> {
14+
return window.electronArduino.appInfo();
1515
}
1616

1717
registerStartupTasksHandler(

Diff for: arduino-ide-extension/src/electron-browser/preload.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { v4 } from 'uuid';
1111
import type { Sketch } from '../common/protocol/sketches-service';
1212
import {
13-
CHANNEL_APP_VERSION,
13+
CHANNEL_APP_INFO,
1414
CHANNEL_IS_FIRST_WINDOW,
1515
CHANNEL_MAIN_MENU_ITEM_DID_CLICK,
1616
CHANNEL_OPEN_PATH,
@@ -76,7 +76,7 @@ const api: ElectronArduino = {
7676
ipcRenderer.invoke(CHANNEL_SHOW_OPEN_DIALOG, options),
7777
showSaveDialog: (options: SaveDialogOptions) =>
7878
ipcRenderer.invoke(CHANNEL_SHOW_SAVE_DIALOG, options),
79-
appVersion: () => ipcRenderer.invoke(CHANNEL_APP_VERSION),
79+
appInfo: () => ipcRenderer.invoke(CHANNEL_APP_INFO),
8080
quitApp: () => ipcRenderer.send(CHANNEL_QUIT_APP),
8181
isFirstWindow: () => ipcRenderer.invoke(CHANNEL_IS_FIRST_WINDOW),
8282
requestReload: (options: StartupTasks) =>

Diff for: arduino-ide-extension/src/electron-common/electron-arduino.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ import type {
1111
InternalMenuDto as TheiaInternalMenuDto,
1212
MenuDto,
1313
} from '@theia/core/lib/electron-common/electron-api';
14+
15+
export const appInfoPropertyLiterals = [
16+
'appVersion',
17+
'cliVersion',
18+
'buildDate',
19+
] as const;
20+
export type AppInfoProperty = (typeof appInfoPropertyLiterals)[number];
21+
export type AppInfo = {
22+
readonly [P in AppInfoProperty]: string;
23+
};
24+
1425
import type { Sketch } from '../common/protocol/sketches-service';
1526
import type { StartupTasks } from './startup-task';
1627

@@ -50,7 +61,7 @@ export interface ElectronArduino {
5061
showMessageBox(options: MessageBoxOptions): Promise<MessageBoxReturnValue>;
5162
showOpenDialog(options: OpenDialogOptions): Promise<OpenDialogReturnValue>;
5263
showSaveDialog(options: SaveDialogOptions): Promise<SaveDialogReturnValue>;
53-
appVersion(): Promise<string>;
64+
appInfo(): Promise<AppInfo>;
5465
quitApp(): void;
5566
isFirstWindow(): Promise<boolean>;
5667
requestReload(tasks: StartupTasks): void;
@@ -77,7 +88,7 @@ declare global {
7788
export const CHANNEL_SHOW_MESSAGE_BOX = 'Arduino:ShowMessageBox';
7889
export const CHANNEL_SHOW_OPEN_DIALOG = 'Arduino:ShowOpenDialog';
7990
export const CHANNEL_SHOW_SAVE_DIALOG = 'Arduino:ShowSaveDialog';
80-
export const CHANNEL_APP_VERSION = 'Arduino:AppVersion';
91+
export const CHANNEL_APP_INFO = 'Arduino:AppInfo';
8192
export const CHANNEL_QUIT_APP = 'Arduino:QuitApp';
8293
export const CHANNEL_IS_FIRST_WINDOW = 'Arduino:IsFirstWindow';
8394
export const CHANNEL_SCHEDULE_DELETION = 'Arduino:ScheduleDeletion';

Diff for: arduino-ide-extension/src/electron-main/electron-arduino.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import { createDisposableListener } from '@theia/core/lib/electron-main/event-ut
1818
import { injectable } from '@theia/core/shared/inversify';
1919
import { WebContents } from '@theia/electron/shared/electron';
2020
import {
21-
CHANNEL_APP_VERSION,
21+
AppInfo,
22+
CHANNEL_APP_INFO,
2223
CHANNEL_IS_FIRST_WINDOW,
2324
CHANNEL_MAIN_MENU_ITEM_DID_CLICK,
2425
CHANNEL_OPEN_PATH,
@@ -85,8 +86,8 @@ export class ElectronArduino implements ElectronMainApplicationContribution {
8586
return result;
8687
}
8788
);
88-
ipcMain.handle(CHANNEL_APP_VERSION, async () => {
89-
return app.appVersion;
89+
ipcMain.handle(CHANNEL_APP_INFO, async (): Promise<AppInfo> => {
90+
return app.appInfo;
9091
});
9192
ipcMain.on(CHANNEL_QUIT_APP, () => app.requestStop());
9293
ipcMain.handle(CHANNEL_IS_FIRST_WINDOW, async (event) => {

0 commit comments

Comments
 (0)