|
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 | +} |
2 | 20 |
|
3 | 21 | export async function installExtensions() { |
4 | 22 | const opts = { |
5 | 23 | forceDownload: !!process.env.UPGRADE_EXTENSIONS, |
6 | 24 | }; |
| 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 | + ); |
7 | 32 | 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 | + } |
9 | 42 | } catch (e) { |
10 | | - console.warn(`Error installing extension: ${e}`); // eslint-disable-line no-console |
| 43 | + logWithExtPrefix(`Error installing extensions: ${e.message}`); |
11 | 44 | } |
| 45 | + logEmptyLine(); |
12 | 46 | } |
0 commit comments