diff --git a/bin/cp-snapshot.js b/bin/cp-snapshot.js index fe30e52c..a9d437e3 100644 --- a/bin/cp-snapshot.js +++ b/bin/cp-snapshot.js @@ -1,3 +1,4 @@ + const path = require('path'); const fs = require('fs'); const fsPromises = require('fs/promises'); @@ -10,24 +11,30 @@ function copySnapshot(pathToElectron, archToCopy) { const pathToBlobV8 = path.resolve(__dirname, '..', 'cache', archToCopy, v8ContextFileName); console.log('Copying v8 snapshots from', pathToBlob, 'to', pathToElectron); + fs.mkdirSync(pathToElectron, { recursive: true }); fs.copyFileSync(pathToBlob, path.join(pathToElectron, snapshotFileName)); fs.copyFileSync(pathToBlobV8, path.join(pathToElectron, v8ContextFileName)); } function getPathToElectron() { + const electronPath = require.resolve('electron'); + switch (process.platform) { case 'darwin': 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 'linux': - return path.resolve(__dirname, '..', 'node_modules', 'electron', 'dist'); + return path.resolve(electronPath, '..', '..', '..', 'dist'); } } + function getV8ContextFileName(archToCopy) { return `snapshot_blob.bin`; } diff --git a/bin/mk-snapshot.js b/bin/mk-snapshot.js index 3829139c..6ed78db4 100644 --- a/bin/mk-snapshot.js +++ b/bin/mk-snapshot.js @@ -15,6 +15,12 @@ const archMap = { }; 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, '..'); console.log('Creating a linked script..'); @@ -32,11 +38,25 @@ async function main() { // Verify if we will be able to use this in `mksnapshot` 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); + 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') { - const mksnapshotBinPath = `${baseDirPath}/node_modules/electron-mksnapshot/bin`; const matchingDirs = crossArchDirs.map((dir) => `${mksnapshotBinPath}/${dir}`).filter((dir) => fs.existsSync(dir)); for (const dir of matchingDirs) { if (fs.existsSync(`${mksnapshotBinPath}/gen/v8/embedded.S`)) { @@ -45,12 +65,12 @@ async function main() { } } } - + const startupBlobPath = path.join(outputBlobPath, 'snapshot_blob.bin'); console.log(`Generating startup blob in "${outputBlobPath}"`); 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-blob=' + startupBlobPath, diff --git a/bin/notarize.js b/bin/notarize.js index d4ce1ef4..3031fcbc 100644 --- a/bin/notarize.js +++ b/bin/notarize.js @@ -1,11 +1,12 @@ -const { notarize } = require("@electron/notarize"); - exports.default = async function notarizing(context) { + const { electronPlatformName, appOutDir } = context; if (electronPlatformName !== "darwin" || !process.env.APPLE_ID || !process.env.APPLE_PASSWORD) { return; } + const { notarize } = await import('@electron/notarize'); + const appName = context.packager.appInfo.productFilename; return await notarize({ appBundleId: "com.quineglobal.hyper", diff --git a/package.json b/package.json index 6201f044..83fdb8d1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "hyper", + "name": "hyper-root", "version": "4.0.0-q-canary.8", "repository": "quine-global/hyper", "engines": {