Skip to content

Commit d0f9cb5

Browse files
authored
chore: improve logging when installing dev extensions (#2649)
* chore: improve logging when installing dev extensions * prevent error if no extensions are installed (not actually possible) * use node:path to get extensions directory * log message in case of error
1 parent b505628 commit d0f9cb5

File tree

3 files changed

+68
-47
lines changed

3 files changed

+68
-47
lines changed

app/electron/main/debug.js

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,46 @@
1-
import {installExtension, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS} from 'electron-devtools-installer';
1+
import {join} from 'node:path';
2+
3+
import {
4+
installExtension,
5+
REACT_DEVELOPER_TOOLS,
6+
REDUX_DEVTOOLS,
7+
} from '@tomjs/electron-devtools-installer';
8+
9+
const EXTENSIONS_TO_INSTALL = [REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS];
10+
11+
// These console.log wrappers are used for better visual separation from other logs
12+
13+
function logEmptyLine() {
14+
console.log(''); // eslint-disable-line no-console
15+
}
16+
17+
function logWithExtPrefix(textString) {
18+
console.log(`[🧩 Extensions 🧩] ${textString}`); // eslint-disable-line no-console
19+
}
220

321
export async function installExtensions() {
422
const opts = {
523
forceDownload: !!process.env.UPGRADE_EXTENSIONS,
624
};
25+
logEmptyLine();
26+
logWithExtPrefix('Installing development extensions...');
27+
logWithExtPrefix(
28+
opts.forceDownload
29+
? 'Explicitly re-downloading all extensions'
30+
: 'Set UPGRADE_EXTENSIONS=1 to force re-download',
31+
);
732
try {
8-
await installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS], opts);
33+
const installedExts = await installExtension(EXTENSIONS_TO_INSTALL, opts);
34+
if (installedExts.length === 0) {
35+
logWithExtPrefix('No extensions were installed');
36+
} else {
37+
logWithExtPrefix(`Installed extensions at ${join(installedExts[0].path, '..')}:`);
38+
for (const ext of installedExts) {
39+
logWithExtPrefix(`* ${ext.name} v${ext.version} (ID: ${ext.id})`);
40+
}
41+
}
942
} catch (e) {
10-
console.warn(`Error installing extension: ${e}`); // eslint-disable-line no-console
43+
logWithExtPrefix(`Error installing extensions: ${e.message}`);
1144
}
45+
logEmptyLine();
1246
}

package-lock.json

Lines changed: 30 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
"@appium/fake-driver": "6.0.2",
100100
"@appium/support": "7.0.5",
101101
"@eslint-react/eslint-plugin": "2.12.4",
102+
"@tomjs/electron-devtools-installer": "4.0.1",
102103
"@types/lodash": "4.17.23",
103104
"@types/react": "19.2.13",
104105
"@types/react-dom": "19.2.3",
@@ -107,7 +108,6 @@
107108
"babel-plugin-react-compiler": "1.0.0",
108109
"electron": "40.2.1",
109110
"electron-builder": "26.7.0",
110-
"electron-devtools-installer": "4.0.0",
111111
"electron-vite": "5.0.0",
112112
"eslint": "9.39.2",
113113
"eslint-plugin-react-hooks": "7.0.1",

0 commit comments

Comments
 (0)