Update electron (major) (#1968)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
renovate[bot]
2024-10-30 18:06:03 +00:00
committed by GitHub
parent 91233f283d
commit cecea312c6
53 changed files with 651 additions and 619 deletions

View File

@@ -1,11 +1,11 @@
#!/usr/bin/env -S npx ts-node
#!/usr/bin/env -S npx tsx
// copies resources into the lib directory.
import parseArgs from "minimist";
import * as chokidar from "chokidar";
import * as path from "path";
import * as fs from "fs";
import * as path from "node:path";
import * as fs from "node:fs";
const argv = parseArgs(process.argv.slice(2), {});

View File

@@ -1,15 +1,15 @@
#!/usr/bin/env -S npx ts-node --resolveJsonModule
#!/usr/bin/env -S npx tsx --resolveJsonModule
import * as path from "path";
import { createWriteStream, promises as fs } from "fs";
import * as childProcess from "child_process";
import * as path from "node:path";
import { createWriteStream, promises as fs } from "node:fs";
import * as childProcess from "node:child_process";
import * as tar from "tar";
import * as asar from "@electron/asar";
import fetch from "node-fetch";
import { promises as stream } from "stream";
import { promises as stream } from "node:stream";
import riotDesktopPackageJson from "../package.json";
import { setPackageVersion } from "./set-version";
import { setPackageVersion } from "./set-version.js";
const PUB_KEY_URL = "https://packages.riot.im/element-release-key.asc";
const PACKAGE_URL_PREFIX = "https://github.com/element-hq/element-web/releases/download/";

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env -S npx ts-node
#!/usr/bin/env -S npx tsx
/**
* Script to generate incremental Nightly build versions, based on the latest Nightly build version of that kind.

View File

@@ -1,10 +1,10 @@
#!/usr/bin/env -S npx ts-node
#!/usr/bin/env -S npx tsx
/*
* Checks for the presence of a webapp, inspects its version and prints it
*/
import { versionFromAsar } from "./set-version";
import { versionFromAsar } from "./set-version.js";
async function main(): Promise<number> {
const version = await versionFromAsar();

View File

@@ -6,8 +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 { DependencyInfo } from "./dep";
import HakEnv from "./hakEnv";
import type { DependencyInfo } from "./dep.js";
import type HakEnv from "./hakEnv.js";
export default async function build(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
await moduleInfo.scripts.build(hakEnv, moduleInfo);

View File

@@ -6,8 +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 { DependencyInfo } from "./dep";
import HakEnv from "./hakEnv";
import type { DependencyInfo } from "./dep.js";
import type HakEnv from "./hakEnv.js";
export default async function check(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
if (moduleInfo.scripts.check) {

View File

@@ -6,11 +6,11 @@ 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 path from "node:path";
import { rimraf } from "rimraf";
import { DependencyInfo } from "./dep";
import HakEnv from "./hakEnv";
import type { DependencyInfo } from "./dep.js";
import type HakEnv from "./hakEnv.js";
export default async function clean(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
await rimraf(moduleInfo.moduleDotHakDir);

View File

@@ -6,15 +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 path from "path";
import fsProm from "fs/promises";
import childProcess from "child_process";
import path from "node:path";
import fsProm from "node:fs/promises";
import childProcess from "node:child_process";
import { rimraf } from "rimraf";
import { glob } from "glob";
import { mkdirp } from "mkdirp";
import HakEnv from "./hakEnv";
import { DependencyInfo } from "./dep";
import type HakEnv from "./hakEnv.js";
import type { DependencyInfo } from "./dep.js";
export default async function copy(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
if (moduleInfo.cfg.prune) {

View File

@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/
import HakEnv from "./hakEnv";
import type HakEnv from "./hakEnv.js";
export interface DependencyInfo {
name: string;

View File

@@ -6,12 +6,11 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/
import fsProm from "fs/promises";
import childProcess from "child_process";
import fsProm from "node:fs/promises";
import pacote from "pacote";
import HakEnv from "./hakEnv";
import { DependencyInfo } from "./dep";
import type HakEnv from "./hakEnv.js";
import type { DependencyInfo } from "./dep.js";
export default async function fetch(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
let haveModuleBuildDir;
@@ -32,21 +31,8 @@ export default async function fetch(hakEnv: HakEnv, moduleInfo: DependencyInfo):
});
console.log("Running yarn install in " + moduleInfo.moduleBuildDir);
await new Promise<void>((resolve, reject) => {
const proc = childProcess.spawn(hakEnv.isWin() ? "yarn.cmd" : "yarn", ["install", "--ignore-scripts"], {
stdio: "inherit",
cwd: moduleInfo.moduleBuildDir,
// 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("yarn", ["install", "--ignore-scripts"], {
cwd: moduleInfo.moduleBuildDir,
});
// also extract another copy to the output directory at this point

View File

@@ -8,8 +8,8 @@ Please see LICENSE files in the repository root for full details.
import { mkdirp } from "mkdirp";
import { DependencyInfo } from "./dep";
import HakEnv from "./hakEnv";
import type { DependencyInfo } from "./dep.js";
import type HakEnv from "./hakEnv.js";
export default async function fetchDeps(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
await mkdirp(moduleInfo.moduleDotHakDir);

View File

@@ -6,12 +6,13 @@ 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 os from "os";
import path from "node:path";
import os from "node:os";
import nodePreGypVersioning from "@mapbox/node-pre-gyp/lib/util/versioning";
import { getElectronVersionFromInstalled } from "app-builder-lib/out/electron/electronVersion";
import { getElectronVersionFromInstalled } from "app-builder-lib/out/electron/electronVersion.js";
import childProcess, { SpawnOptions } from "node:child_process";
import { Arch, Target, TARGETS, getHost, isHostId, TargetId } from "./target";
import { Arch, Target, TARGETS, getHost, isHostId, TargetId } from "./target.js";
async function getRuntime(projectRoot: string): Promise<string> {
const electronVersion = await getElectronVersionFromInstalled(projectRoot);
@@ -27,6 +28,8 @@ async function getRuntimeVersion(projectRoot: string): Promise<string> {
}
}
export type Tool = [cmd: string, ...args: string[]];
export default class HakEnv {
public readonly target: Target;
public runtime?: string;
@@ -104,4 +107,41 @@ export default class HakEnv {
public wantsStaticSqlCipher(): boolean {
return !(this.isLinux() || this.isFreeBSD()) || process.env.SQLCIPHER_BUNDLED == "1";
}
public spawn(
cmd: string,
args: string[],
{ ignoreWinCmdlet, ...options }: SpawnOptions & { ignoreWinCmdlet?: boolean } = {},
): Promise<void> {
return new Promise((resolve, reject) => {
const proc = childProcess.spawn(cmd + (!ignoreWinCmdlet && this.isWin() ? ".cmd" : ""), args, {
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: this.isWin(),
...options,
});
proc.on("exit", (code) => {
if (code) {
reject(code);
} else {
resolve();
}
});
});
}
public async checkTools(tools: Tool[]): Promise<void> {
for (const [tool, ...args] of tools) {
try {
await this.spawn(tool, args, {
ignoreWinCmdlet: true,
stdio: ["ignore"],
shell: false,
});
} catch {
throw new Error(`Can't find ${tool}`);
}
}
}
}

View File

@@ -6,11 +6,14 @@ 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 path, { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import HakEnv from "./hakEnv";
import { TargetId } from "./target";
import { DependencyInfo } from "./dep";
import HakEnv from "./hakEnv.js";
import type { TargetId } from "./target.js";
import type { DependencyInfo } from "./dep.js";
import { loadJsonFile } from "../../src/utils.js";
import packageJson from "../../package.json";
const GENERALCOMMANDS = ["target"];
@@ -27,21 +30,15 @@ const METACOMMANDS: Record<string, string[]> = {
// Scripts valid in a hak.json 'scripts' section
const HAKSCRIPTS = ["check", "fetch", "build"];
const __dirname = dirname(fileURLToPath(import.meta.url));
async function main(): Promise<void> {
const prefix = path.join(__dirname, "..", "..");
let packageJson;
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
packageJson = require(path.join(prefix, "package.json"));
} catch {
console.error("Can't find a package.json!");
process.exit(1);
}
const targetIds: TargetId[] = [];
// Apply `--target <target>` option if specified
// Can be specified multiple times for the copy command to bundle
// multiple archs into a single universal output module)
// multiple arches into a single universal output module)
for (;;) {
// eslint-disable-line no-constant-condition
const targetIndex = process.argv.indexOf("--target");
@@ -66,12 +63,11 @@ async function main(): Promise<void> {
const hakDepsCfg = packageJson.hakDependencies || {};
for (const dep of Object.keys(hakDepsCfg)) {
for (const dep in hakDepsCfg) {
const hakJsonPath = path.join(prefix, "hak", dep, "hak.json");
let hakJson: Record<string, any>;
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
hakJson = await require(hakJsonPath);
hakJson = loadJsonFile(hakJsonPath);
} catch {
console.error("No hak.json found for " + dep + ".");
console.log("Expecting " + hakJsonPath);
@@ -79,7 +75,7 @@ async function main(): Promise<void> {
}
deps[dep] = {
name: dep,
version: hakDepsCfg[dep],
version: hakDepsCfg[dep as keyof typeof hakDepsCfg],
cfg: hakJson,
moduleHakDir: path.join(prefix, "hak", dep),
moduleDotHakDir: path.join(hakEnv.dotHakDir, dep),
@@ -93,9 +89,9 @@ async function main(): Promise<void> {
};
for (const s of HAKSCRIPTS) {
if (hakJson.scripts && hakJson.scripts[s]) {
const scriptModule = await import(path.join(prefix, "hak", dep, hakJson.scripts[s]));
if (scriptModule.__esModule) {
if (hakJson.scripts?.[s]) {
const scriptModule = await import(path.join("file://", prefix, "hak", dep, hakJson.scripts[s]));
if (scriptModule.default) {
deps[dep].scripts[s] = scriptModule.default;
} else {
deps[dep].scripts[s] = scriptModule;

View File

@@ -6,13 +6,12 @@ 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 os from "os";
import fsProm from "fs/promises";
import childProcess from "child_process";
import path from "node:path";
import os from "node:os";
import fsProm from "node:fs/promises";
import HakEnv from "./hakEnv";
import { DependencyInfo } from "./dep";
import HakEnv from "./hakEnv.js";
import { DependencyInfo } from "./dep.js";
export default async function link(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
const yarnrc = path.join(hakEnv.projectRoot, ".yarnrc");
@@ -39,39 +38,10 @@ export default async function link(hakEnv: HakEnv, moduleInfo: DependencyInfo):
);
}
const yarnCmd = "yarn" + (hakEnv.isWin() ? ".cmd" : "");
await new Promise<void>((resolve, reject) => {
const proc = childProcess.spawn(yarnCmd, ["link"], {
cwd: moduleInfo.moduleOutDir,
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("yarn", ["link"], {
cwd: moduleInfo.moduleOutDir,
});
await new Promise<void>((resolve, reject) => {
const proc = childProcess.spawn(yarnCmd, ["link", moduleInfo.name], {
cwd: hakEnv.projectRoot,
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("yarn", ["link", moduleInfo.name], {
cwd: hakEnv.projectRoot,
});
}

View File

@@ -1,13 +1,14 @@
#!/usr/bin/env -S npx ts-node
#!/usr/bin/env -S npx tsx
/*
* Checks for the presence of a webapp, inspects its version and sets the
* version metadata of the package to match.
*/
import { promises as fs } from "fs";
import { promises as fs } from "node:fs";
import * as asar from "@electron/asar";
import * as childProcess from "child_process";
import * as childProcess from "node:child_process";
import * as url from "node:url";
export async function versionFromAsar(): Promise<string> {
try {
@@ -57,13 +58,16 @@ async function main(args: string[]): Promise<number> {
return 0;
}
if (require.main === module) {
main(process.argv.slice(2))
.then((ret) => {
process.exit(ret);
})
.catch((e) => {
console.error(e);
process.exit(1);
});
if (import.meta.url.startsWith("file:")) {
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
main(process.argv.slice(2))
.then((ret) => {
process.exit(ret);
})
.catch((e) => {
console.error(e);
process.exit(1);
});
}
}

View File

@@ -1,16 +1,13 @@
{
"compilerOptions": {
"resolveJsonModule": true,
"moduleResolution": "node",
"moduleResolution": "node16",
"esModuleInterop": true,
"target": "es2017",
"module": "commonjs",
"target": "es2022",
"module": "node16",
"sourceMap": false,
"strict": true,
"lib": ["es2020", "dom"]
},
"include": ["../src/@types", "./**/*.ts"],
"ts-node": {
"transpileOnly": true
}
"include": ["../src/@types", "./**/*.ts"]
}