mirror of
https://github.com/vector-im/element-desktop.git
synced 2024-09-10 06:15:17 +00:00
* Update dependency glob to v9 * Adjust copy.ts to promisifed glob * Switch asar -> @electron/asar * Update rimraf for glob v9 compatibility * Iterate * Iterate * Patch @electron/asar * Fix another way --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Janne Mareike Koschinski <jannemk@element.io> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
64 lines
1.7 KiB
TypeScript
Executable file
64 lines
1.7 KiB
TypeScript
Executable file
#!/usr/bin/env -S npx ts-node
|
|
|
|
/*
|
|
* 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 * as asar from "@electron/asar";
|
|
import * as childProcess from "child_process";
|
|
|
|
export async function versionFromAsar(): Promise<string> {
|
|
try {
|
|
await fs.stat("webapp.asar");
|
|
} catch (e) {
|
|
throw new Error("No 'webapp.asar' found. Run 'yarn run fetch'");
|
|
}
|
|
|
|
return asar.extractFile("webapp.asar", "version").toString().trim();
|
|
}
|
|
|
|
export async function setPackageVersion(ver: string): Promise<void> {
|
|
// set version in package.json: electron-builder will use this to populate
|
|
// all the various version fields
|
|
await new Promise<void>((resolve, reject) => {
|
|
childProcess.execFile(
|
|
process.platform === "win32" ? "yarn.cmd" : "yarn",
|
|
[
|
|
"version",
|
|
"-s",
|
|
"--no-git-tag-version", // This also means "don't commit to git" as it turns out
|
|
"--new-version",
|
|
ver,
|
|
],
|
|
(err) => {
|
|
if (err) {
|
|
reject(err);
|
|
} else {
|
|
resolve();
|
|
}
|
|
},
|
|
);
|
|
});
|
|
}
|
|
|
|
async function main(args: string[]): Promise<number> {
|
|
let version = args[0];
|
|
|
|
if (version === undefined) version = await versionFromAsar();
|
|
|
|
await setPackageVersion(version);
|
|
return 0;
|
|
}
|
|
|
|
if (require.main === module) {
|
|
main(process.argv.slice(2))
|
|
.then((ret) => {
|
|
process.exit(ret);
|
|
})
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
});
|
|
}
|