Skip to content

Commit 685da06

Browse files
committed
Minor refactoring
1 parent 7b09363 commit 685da06

File tree

3 files changed

+51
-26
lines changed

3 files changed

+51
-26
lines changed

app/electron-client/electron-builder-config.cjs

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,36 @@ function engineDistributionTarget(version) {
2424
return 'enso/dist/' + version
2525
}
2626

27+
/**
28+
* AppImage is known to have sandboxing issues, for example:
29+
* https://github.com/enso-org/enso/issues/3801 or
30+
* https://github.com/enso-org/enso/issues/11035
31+
* A solution to them is to run AppImage with --no-sandbox option (just passing no-sandbox
32+
* as chrome option didn't seem to work). Wrapped app in a "sandbox fix loader"
33+
* similar to https://github.com/gergof/electron-builder-sandbox-fix/blob/master/lib/index.js
34+
* 'electron-builder-sandbox-fix' failed to detect the necessity of sandbox, so we just always
35+
* add the option instead. This does not lower security, because Enso processes have access
36+
* to user's filesystem anyway.
37+
*/
38+
async function patchAppImage(context) {
39+
const executableName = context.packager.executableName
40+
if (!executableName) throw new Error('Expected executableName in context.packager')
41+
const executable = path.join(context.appOutDir, executableName)
42+
const loaderScript = `#!/usr/bin/env bash
43+
set -u
44+
45+
SCRIPT_DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
46+
exec "$SCRIPT_DIR/${executableName}.bin" --no-sandbox "$@"
47+
`
48+
try {
49+
await fs.rename(executable, executable + '.bin')
50+
await fs.writeFile(executable, loaderScript)
51+
await fs.chmod(executable, 0o755)
52+
} catch (e) {
53+
throw new Error('Failed to create loader for sandbox fix: ' + e.message)
54+
}
55+
}
56+
2757
module.exports = {
2858
appId: 'org.enso',
2959
productName: 'Enso',
@@ -107,32 +137,8 @@ module.exports = {
107137
},
108138
publish: null,
109139
afterPack: async (context) => {
110-
// AppImage is known to have sandboxing issues, for example:
111-
// https://github.com/enso-org/enso/issues/3801 or
112-
// https://github.com/enso-org/enso/issues/11035
113-
//
114-
// A solution to them is to run AppImage with --no-sandbox option (just passing no-sandbox
115-
// as chrome option didn't seem to work). Wrapped app in a "sandbox fix loader"
116-
// similar to https://github.com/gergof/electron-builder-sandbox-fix/blob/master/lib/index.js
117-
// 'electron-builder-sandbox-fix' failed to detect the necessity of sandbox, so we just always
118-
// add the option instead. This does not lower security, because Enso processes have access
119-
// to user's filesystem anyway.
120-
if (context.electronPlatformName !== 'linux') return
121-
const executableName = context.packager.executableName
122-
if (!executableName) throw new Error('Expected executableName in context.packager')
123-
const executable = path.join(context.appOutDir, executableName)
124-
const loaderScript = `#!/usr/bin/env bash
125-
set -u
126-
127-
SCRIPT_DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
128-
exec "$SCRIPT_DIR/${executableName}.bin" --no-sandbox "$@"
129-
`
130-
try {
131-
await fs.rename(executable, executable + '.bin')
132-
await fs.writeFile(executable, loaderScript)
133-
await fs.chmod(executable, 0o755)
134-
} catch (e) {
135-
throw new Error('Failed to create loader for sandbox fix: ' + e.message)
140+
if (context.electronPlatformName === 'linux') {
141+
await patchAppImage(context)
136142
}
137143
},
138144
}

eslint.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ const config = [
191191
'**/*.json',
192192
'app/rust-ffi/pkg/',
193193
'app/electron-client/pre-electron-builder.cjs',
194+
'app/electron-client/electron-builder-config.cjs',
194195
],
195196
},
196197
{
@@ -220,6 +221,7 @@ const config = [
220221
'app/project-manager-shim/scripts/*.js',
221222
'app/ide-desktop/icons/src/index.js',
222223
'app/electron-client/pre-electron-builder.cjs',
224+
'app/electron-client/electron-builder-config.cjs',
223225
],
224226
},
225227
},
@@ -557,6 +559,12 @@ const config = [
557559
{
558560
files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
559561
ignores: ['**/build.mjs'],
562+
languageOptions: {
563+
parserOptions: {
564+
// Avoid TS project service errors for plain JS/CJS files.
565+
projectService: false,
566+
},
567+
},
560568
rules: {
561569
'@typescript-eslint/no-var-requires': 'off',
562570
// Parameter types must be specified using JSDoc in JS files.

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)