Skip to content

Commit 129436b

Browse files
author
Akos Kitta
committed
fix: missing binary in backend application
Signed-off-by: Akos Kitta <[email protected]>
1 parent 3529b14 commit 129436b

File tree

1 file changed

+72
-34
lines changed

1 file changed

+72
-34
lines changed

Diff for: electron-app/webpack.config.js

+72-34
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
const chmodr = require('chmodr');
22
const CopyWebpackPlugin = require('copy-webpack-plugin');
33
const path = require('node:path');
4+
const fs = require('node:fs/promises');
45
const resolvePackagePath = require('resolve-package-path');
56
const webpack = require('webpack');
67
const frontend = require('./gen-webpack.config');
78
const backend = require('./gen-webpack.node.config');
89

10+
const isWindows = process.platform === 'win32';
11+
const isMacOS = process.platform === 'darwin';
12+
913
// https://github.com/browserify/node-util/issues/57#issuecomment-764436352
1014
const mainWindowConfig = frontend[0];
1115
mainWindowConfig.resolve.extensions.push('.ts');
@@ -37,7 +41,19 @@ class PermissionsPlugin {
3741
*/
3842
apply(compiler) {
3943
compiler.hooks.afterEmit.tap('PermissionsPlugin', () => {
40-
return new Promise((resolve, reject) => {
44+
return new Promise(async (resolve, reject) => {
45+
let trashBinaryFilename = undefined;
46+
if (isWindows) {
47+
trashBinaryFilename = 'windows-trash.exe';
48+
} else if (isMacOS) {
49+
trashBinaryFilename = 'macos-trash';
50+
}
51+
if (trashBinaryFilename) {
52+
await fs.chmod(
53+
path.join(__dirname, 'lib', 'backend', trashBinaryFilename),
54+
0o755
55+
);
56+
}
4157
chmodr(
4258
path.join(__dirname, 'lib', 'backend', 'resources'),
4359
0o755,
@@ -48,42 +64,64 @@ class PermissionsPlugin {
4864
}
4965
}
5066

67+
const trashBinariesPath = path.join(
68+
resolvePackagePath('trash', __dirname),
69+
'..',
70+
'lib'
71+
);
72+
73+
const copyOptions = {
74+
patterns: [
75+
// binaries
76+
{
77+
from: path.join(
78+
resolvePackagePath('arduino-ide-extension', __dirname),
79+
'..',
80+
'src',
81+
'node',
82+
'resources'
83+
),
84+
to: path.resolve(__dirname, 'lib', 'backend', 'resources'),
85+
globOptions: {
86+
ignore: ['**/i18n/**'],
87+
},
88+
},
89+
// plotter app
90+
{
91+
from: path.join(
92+
resolvePackagePath('arduino-serial-plotter-webapp', __dirname),
93+
'..',
94+
'build'
95+
),
96+
to: path.resolve(
97+
__dirname,
98+
'lib',
99+
'backend',
100+
'resources',
101+
'arduino-serial-plotter-webapp'
102+
),
103+
},
104+
],
105+
};
106+
107+
// workaround for https://github.com/eclipse-theia/theia/issues/12780
108+
// copy the Windows (`windows-trash.exe`) and macOS (`macos-trash`) executables for `trash`
109+
if (isWindows) {
110+
copyOptions.patterns.push({
111+
from: path.join(trashBinariesPath, 'windows-trash.exe'),
112+
to: path.resolve(__dirname, 'lib', 'backend'),
113+
});
114+
} else if (isMacOS) {
115+
copyOptions.patterns.push({
116+
from: path.join(trashBinariesPath, 'macos-trash'),
117+
to: path.resolve(__dirname, 'lib', 'backend'),
118+
});
119+
}
120+
51121
// Copy all the IDE2 binaries and the plotter web app.
52122
// XXX: For whatever reason it is important to use `unshift` instead of `push`, and execute the additional webpack plugins before the Theia contributed ones kick in. Otherwise ours do not work.
53123
backend.config.plugins.unshift(
54-
new CopyWebpackPlugin({
55-
patterns: [
56-
// binaries
57-
{
58-
from: path.join(
59-
resolvePackagePath('arduino-ide-extension', __dirname),
60-
'..',
61-
'src',
62-
'node',
63-
'resources'
64-
),
65-
to: path.resolve(__dirname, 'lib', 'backend', 'resources'),
66-
globOptions: {
67-
ignore: ['**/i18n/**'],
68-
},
69-
},
70-
// plotter app
71-
{
72-
from: path.join(
73-
resolvePackagePath('arduino-serial-plotter-webapp', __dirname),
74-
'..',
75-
'build'
76-
),
77-
to: path.resolve(
78-
__dirname,
79-
'lib',
80-
'backend',
81-
'resources',
82-
'arduino-serial-plotter-webapp'
83-
),
84-
},
85-
],
86-
}),
124+
new CopyWebpackPlugin(copyOptions),
87125
new PermissionsPlugin()
88126
);
89127

0 commit comments

Comments
 (0)