chore(deps): update to theia@1.41.0 (#2211)

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta
2023-09-29 18:40:13 +02:00
committed by GitHub
parent ce02e263ec
commit 8f4bcc83ec
12 changed files with 1431 additions and 1331 deletions

View File

@@ -4,11 +4,10 @@
const chmodr = require('chmodr');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('node:path');
const fs = require('node:fs/promises');
const isWindows = process.platform === 'win32';
const isMacOS = process.platform === 'darwin';
/**
* @param {string} target the name of the `npm` package to resolve.
*/
function resolvePackagePath(target, baseDir = __dirname) {
const resolvePackageJsonPath = require('resolve-package-path');
const packageJsonPath = resolvePackageJsonPath(target, baseDir);
@@ -23,9 +22,11 @@ function resolvePackagePath(target, baseDir = __dirname) {
// restore file permissions after webpack copy
// https://github.com/webpack-contrib/copy-webpack-plugin/issues/35#issuecomment-1407280257
class PermissionsPlugin {
constructor(targetPath, patchTheia12780 = false) {
/**
* @param {string} targetPath
*/
constructor(targetPath) {
this.targetPath = targetPath;
this.patchTheia12780 = patchTheia12780;
}
/**
@@ -34,20 +35,6 @@ class PermissionsPlugin {
apply(compiler) {
compiler.hooks.afterEmit.tap('PermissionsPlugin', () => {
return new Promise(async (resolve, reject) => {
if (this.patchTheia12780) {
let trashBinaryFilename = undefined;
if (isWindows) {
trashBinaryFilename = 'windows-trash.exe';
} else if (isMacOS) {
trashBinaryFilename = 'macos-trash';
}
if (trashBinaryFilename) {
await fs.chmod(
path.join(__dirname, 'lib', 'backend', trashBinaryFilename),
0o755
);
}
}
chmodr(this.targetPath, 0o755, (err) =>
err ? reject(err) : resolve(undefined)
);
@@ -59,18 +46,9 @@ class PermissionsPlugin {
/**
* Creates webpack plugins to copy all required resources (binaries, plotter app, translation files, etc.) to the appropriate location.
* @param {string} targetPath where to copy the resources
* @param {boolean|undefined} [patchTheia12780=true] to apply patch for https://github.com/eclipse-theia/theia/issues/12780. Only required in the production app.
* @param {string|undefined} [baseDir=__dirname] to calculate the modules from. Defaults to `__dirname`
*/
function createCopyArduinoResourcesPlugins(
targetPath,
patchTheia12780 = false,
baseDir = __dirname
) {
const trashBinariesPath = path.join(
resolvePackagePath('trash', baseDir),
'lib'
);
function createCopyArduinoResourcesPlugins(targetPath, baseDir = __dirname) {
const copyOptions = {
patterns: [
// binaries
@@ -96,25 +74,9 @@ function createCopyArduinoResourcesPlugins(
},
],
};
if (patchTheia12780) {
// workaround for https://github.com/eclipse-theia/theia/issues/12780
// copy the Windows (`windows-trash.exe`) and macOS (`macos-trash`) executables for `trash`
if (isWindows) {
copyOptions.patterns.push({
from: path.join(trashBinariesPath, 'windows-trash.exe'),
to: path.resolve(__dirname, 'lib', 'backend'),
});
} else if (isMacOS) {
copyOptions.patterns.push({
from: path.join(trashBinariesPath, 'macos-trash'),
to: path.resolve(__dirname, 'lib', 'backend'),
});
}
}
return [
new CopyWebpackPlugin(copyOptions),
new PermissionsPlugin(targetPath, patchTheia12780),
new PermissionsPlugin(targetPath),
];
}