Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update electron (major) #1968

Merged
merged 16 commits into from
Oct 30, 2024
Merged
22 changes: 0 additions & 22 deletions .eslintrc-hak.js

This file was deleted.

22 changes: 0 additions & 22 deletions .eslintrc-scripts.js

This file was deleted.

22 changes: 0 additions & 22 deletions .eslintrc-test.js

This file was deleted.

88 changes: 88 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
module.exports = {
plugins: ["matrix-org", "n"],
extends: ["plugin:matrix-org/javascript"],
parserOptions: {
ecmaVersion: 2021,
project: ["tsconfig.json"],
},
env: {
es6: true,
node: true,
// we also have some browser code (ie. the preload script)
browser: true,
},
// NOTE: These rules are frozen and new rules should not be added here.
// New changes belong in https://github.com/matrix-org/eslint-plugin-matrix-org/
rules: {
"quotes": "off",
"indent": "off",
"prefer-promise-reject-errors": "off",
"no-async-promise-executor": "off",

"n/file-extension-in-import": ["error", "always"],
"unicorn/prefer-node-protocol": ["error"],
},
overrides: [
{
files: ["src/**/*.ts"],
extends: ["plugin:matrix-org/typescript"],
rules: {
// Things we do that break the ideal style
"prefer-promise-reject-errors": "off",
"quotes": "off",

"@typescript-eslint/no-explicit-any": "off",
// We're okay with assertion errors when we ask for them
"@typescript-eslint/no-non-null-assertion": "off",
},
},
{
files: ["hak/**/*.ts"],
extends: ["plugin:matrix-org/typescript"],
parserOptions: {
project: ["hak/tsconfig.json"],
},
rules: {
// Things we do that break the ideal style
"prefer-promise-reject-errors": "off",
"quotes": "off",

"@typescript-eslint/no-explicit-any": "off",
// We're okay with assertion errors when we ask for them
"@typescript-eslint/no-non-null-assertion": "off",
},
},
{
files: ["scripts/**/*.ts"],
extends: ["plugin:matrix-org/typescript"],
parserOptions: {
project: ["scripts/tsconfig.json"],
},
rules: {
// Things we do that break the ideal style
"prefer-promise-reject-errors": "off",
"quotes": "off",

"@typescript-eslint/no-explicit-any": "off",
// We're okay with assertion errors when we ask for them
"@typescript-eslint/no-non-null-assertion": "off",
},
},
{
files: ["playwright/**/*.ts"],
extends: ["plugin:matrix-org/typescript"],
parserOptions: {
project: ["playwright/tsconfig.json"],
},
rules: {
// Things we do that break the ideal style
"prefer-promise-reject-errors": "off",
"quotes": "off",

"@typescript-eslint/no-explicit-any": "off",
// We're okay with assertion errors when we ask for them
"@typescript-eslint/no-non-null-assertion": "off",
},
},
],
};
37 changes: 0 additions & 37 deletions .eslintrc.js

This file was deleted.

File renamed without changes.
File renamed without changes.
36 changes: 11 additions & 25 deletions hak/keytar/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,21 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/

import path from "path";
import childProcess from "child_process";
import path from "node:path";

import HakEnv from "../../scripts/hak/hakEnv";
import { DependencyInfo } from "../../scripts/hak/dep";
import type HakEnv from "../../scripts/hak/hakEnv.js";
import type { DependencyInfo } from "../../scripts/hak/dep.js";

export default async function buildKeytar(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
const env = hakEnv.makeGypEnv();

console.log("Running yarn with env", env);
await new Promise<void>((resolve, reject) => {
const proc = childProcess.spawn(
path.join(moduleInfo.nodeModuleBinDir, "node-gyp" + (hakEnv.isWin() ? ".cmd" : "")),
["rebuild", "--arch", hakEnv.getTargetArch()],
{
cwd: moduleInfo.moduleBuildDir,
env,
stdio: "inherit",
// We need shell mode on Windows to be able to launch `.cmd` executables
// See https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2
shell: hakEnv.isWin(),
},
);
proc.on("exit", (code) => {
if (code) {
reject(code);
} else {
resolve();
}
});
});
await hakEnv.spawn(
path.join(moduleInfo.nodeModuleBinDir, "node-gyp"),
["rebuild", "--arch", hakEnv.getTargetArch()],
{
cwd: moduleInfo.moduleBuildDir,
env,
},
);
}
24 changes: 4 additions & 20 deletions hak/keytar/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,10 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/

import childProcess from "child_process";

import HakEnv from "../../scripts/hak/hakEnv";
import { DependencyInfo } from "../../scripts/hak/dep";
import type HakEnv from "../../scripts/hak/hakEnv.js";
import type { DependencyInfo } from "../../scripts/hak/dep.js";

export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
const tools = [["python", "--version"]]; // node-gyp uses python for reasons beyond comprehension

for (const tool of tools) {
await new Promise<void>((resolve, reject) => {
const proc = childProcess.spawn(tool[0], tool.slice(1), {
stdio: ["ignore"],
});
proc.on("exit", (code) => {
if (code !== 0) {
reject("Can't find " + tool);
} else {
resolve();
}
});
});
}
// node-gyp uses python for reasons beyond comprehension
await hakEnv.checkTools([["python", "--version"]]);
}
42 changes: 10 additions & 32 deletions hak/matrix-seshat/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/

import childProcess from "child_process";

import HakEnv from "../../scripts/hak/hakEnv";
import { DependencyInfo } from "../../scripts/hak/dep";
import type HakEnv from "../../scripts/hak/hakEnv.js";
import type { DependencyInfo } from "../../scripts/hak/dep.js";

export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
const env = hakEnv.makeGypEnv();
Expand All @@ -19,38 +17,18 @@ export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Prom
}

console.log("Running yarn install");
await new Promise<void>((resolve, reject) => {
const proc = childProcess.spawn("yarn" + (hakEnv.isWin() ? ".cmd" : ""), ["install"], {
cwd: moduleInfo.moduleBuildDir,
env,
shell: true,
stdio: "inherit",
});
proc.on("exit", (code) => {
if (code) {
reject(code);
} else {
resolve();
}
});
await hakEnv.spawn("yarn", ["install"], {
cwd: moduleInfo.moduleBuildDir,
env,
shell: true,
});

const buildTarget = hakEnv.wantsStaticSqlCipher() ? "build-bundled" : "build";

console.log("Running yarn build");
await new Promise<void>((resolve, reject) => {
const proc = childProcess.spawn("yarn" + (hakEnv.isWin() ? ".cmd" : ""), ["run", buildTarget], {
cwd: moduleInfo.moduleBuildDir,
env,
shell: true,
stdio: "inherit",
});
proc.on("exit", (code) => {
if (code) {
reject(code);
} else {
resolve();
}
});
await hakEnv.spawn("yarn", ["run", buildTarget], {
cwd: moduleInfo.moduleBuildDir,
env,
shell: true,
});
}
27 changes: 7 additions & 20 deletions hak/matrix-seshat/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/

import childProcess from "child_process";
import fsProm from "fs/promises";
import childProcess from "node:child_process";
import fsProm from "node:fs/promises";

import HakEnv from "../../scripts/hak/hakEnv";
import { DependencyInfo } from "../../scripts/hak/dep";
import type HakEnv from "../../scripts/hak/hakEnv.js";
import type { Tool } from "../../scripts/hak/hakEnv.js";
import type { DependencyInfo } from "../../scripts/hak/dep.js";

export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
const tools = [
const tools: Tool[] = [
["rustc", "--version"],
["python", "--version"], // node-gyp uses python for reasons beyond comprehension
];
Expand All @@ -25,21 +26,7 @@ export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Prom
} else {
tools.push(["make", "--version"]);
}

for (const tool of tools) {
await new Promise<void>((resolve, reject) => {
const proc = childProcess.spawn(tool[0], tool.slice(1), {
stdio: ["ignore"],
});
proc.on("exit", (code) => {
if (code !== 0) {
reject("Can't find " + tool);
} else {
resolve();
}
});
});
}
await hakEnv.checkTools(tools);

// Ensure Rust target exists (nb. we avoid depending on rustup)
await new Promise((resolve, reject) => {
Expand Down
5 changes: 1 addition & 4 deletions hak/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@
"strict": true,
"lib": ["es2022"]
},
"include": ["../scripts/@types/*.d.ts", "./**/*.ts"],
"ts-node": {
"transpileOnly": true
}
"include": ["../scripts/@types/*.d.ts", "./**/*.ts"]
}
Loading
Loading