Updates to scripts (#180)

This commit is contained in:
Philip Peterson 2025-08-30 22:52:25 -07:00 committed by GitHub
parent 47ff892422
commit 40cece79ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 10 deletions

13
bin/cp-snapshot.js vendored
View file

@ -1,3 +1,4 @@
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const fsPromises = require('fs/promises'); const fsPromises = require('fs/promises');
@ -10,24 +11,30 @@ function copySnapshot(pathToElectron, archToCopy) {
const pathToBlobV8 = path.resolve(__dirname, '..', 'cache', archToCopy, v8ContextFileName); const pathToBlobV8 = path.resolve(__dirname, '..', 'cache', archToCopy, v8ContextFileName);
console.log('Copying v8 snapshots from', pathToBlob, 'to', pathToElectron); console.log('Copying v8 snapshots from', pathToBlob, 'to', pathToElectron);
fs.mkdirSync(pathToElectron, { recursive: true });
fs.copyFileSync(pathToBlob, path.join(pathToElectron, snapshotFileName)); fs.copyFileSync(pathToBlob, path.join(pathToElectron, snapshotFileName));
fs.copyFileSync(pathToBlobV8, path.join(pathToElectron, v8ContextFileName)); fs.copyFileSync(pathToBlobV8, path.join(pathToElectron, v8ContextFileName));
} }
function getPathToElectron() { function getPathToElectron() {
const electronPath = require.resolve('electron');
switch (process.platform) { switch (process.platform) {
case 'darwin': case 'darwin':
return path.resolve( return path.resolve(
__dirname, electronPath,
'..', '..',
'node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources' '..',
'..',
'dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources'
); );
case 'win32': case 'win32':
case 'linux': case 'linux':
return path.resolve(__dirname, '..', 'node_modules', 'electron', 'dist'); return path.resolve(electronPath, '..', '..', '..', 'dist');
} }
} }
function getV8ContextFileName(archToCopy) { function getV8ContextFileName(archToCopy) {
return `snapshot_blob.bin`; return `snapshot_blob.bin`;
} }

28
bin/mk-snapshot.js vendored
View file

@ -15,6 +15,12 @@ const archMap = {
}; };
async function main() { async function main() {
const npmConfigArch = process.env.npm_config_arch;
if (!npmConfigArch) {
throw new Error('env var npm_config_arch is not specified')
}
const baseDirPath = path.resolve(__dirname, '..'); const baseDirPath = path.resolve(__dirname, '..');
console.log('Creating a linked script..'); console.log('Creating a linked script..');
@ -32,11 +38,25 @@ async function main() {
// Verify if we will be able to use this in `mksnapshot` // Verify if we will be able to use this in `mksnapshot`
vm.runInNewContext(result.snapshotScript, undefined, {filename: snapshotScriptPath, displayErrors: true}); vm.runInNewContext(result.snapshotScript, undefined, {filename: snapshotScriptPath, displayErrors: true});
const outputBlobPath = `${baseDirPath}/cache/${process.env.npm_config_arch}`; const outputBlobPath = `${baseDirPath}/cache/${npmConfigArch}`;
await mkdirp(outputBlobPath); await mkdirp(outputBlobPath);
let mksnapshotBinPath
if (process.platform === 'win32') {
mksnapshotBinPath =
require.resolve(
path.join("electron-mksnapshot", "bin", "mksnapshot.exe")
);
} else {
mksnapshotBinPath =
require.resolve(
path.join("electron-mksnapshot", "bin", "mksnapshot")
);
}
mksnapshotBinPath = path.dirname(mksnapshotBinPath);
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
const mksnapshotBinPath = `${baseDirPath}/node_modules/electron-mksnapshot/bin`;
const matchingDirs = crossArchDirs.map((dir) => `${mksnapshotBinPath}/${dir}`).filter((dir) => fs.existsSync(dir)); const matchingDirs = crossArchDirs.map((dir) => `${mksnapshotBinPath}/${dir}`).filter((dir) => fs.existsSync(dir));
for (const dir of matchingDirs) { for (const dir of matchingDirs) {
if (fs.existsSync(`${mksnapshotBinPath}/gen/v8/embedded.S`)) { if (fs.existsSync(`${mksnapshotBinPath}/gen/v8/embedded.S`)) {
@ -45,12 +65,12 @@ async function main() {
} }
} }
} }
const startupBlobPath = path.join(outputBlobPath, 'snapshot_blob.bin'); const startupBlobPath = path.join(outputBlobPath, 'snapshot_blob.bin');
console.log(`Generating startup blob in "${outputBlobPath}"`); console.log(`Generating startup blob in "${outputBlobPath}"`);
const res = childProcess.execFileSync( const res = childProcess.execFileSync(
path.resolve(__dirname, '..', 'node_modules', 'electron-mksnapshot', 'bin', 'mksnapshot' + (process.platform === 'win32' ? '.exe' : '')), require.resolve(`electron-mksnapshot/bin/mksnapshot${process.platform === 'win32' ? '.exe' : ''}`),
[ [
'--startup-src=' + snapshotScriptPath, '--startup-src=' + snapshotScriptPath,
'--startup-blob=' + startupBlobPath, '--startup-blob=' + startupBlobPath,

5
bin/notarize.js vendored
View file

@ -1,11 +1,12 @@
const { notarize } = require("@electron/notarize");
exports.default = async function notarizing(context) { exports.default = async function notarizing(context) {
const { electronPlatformName, appOutDir } = context; const { electronPlatformName, appOutDir } = context;
if (electronPlatformName !== "darwin" || !process.env.APPLE_ID || !process.env.APPLE_PASSWORD) { if (electronPlatformName !== "darwin" || !process.env.APPLE_ID || !process.env.APPLE_PASSWORD) {
return; return;
} }
const { notarize } = await import('@electron/notarize');
const appName = context.packager.appInfo.productFilename; const appName = context.packager.appInfo.productFilename;
return await notarize({ return await notarize({
appBundleId: "com.quineglobal.hyper", appBundleId: "com.quineglobal.hyper",

View file

@ -1,5 +1,5 @@
{ {
"name": "hyper", "name": "hyper-root",
"version": "4.0.0-q-canary.8", "version": "4.0.0-q-canary.8",
"repository": "quine-global/hyper", "repository": "quine-global/hyper",
"engines": { "engines": {