diff --git a/.gitignore b/.gitignore index 005352d31..dbf8dad1c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ node_modules/ *.log out/ .DS_Store -bin \ No newline at end of file +bin +*.pw \ No newline at end of file diff --git a/forge.config.js b/forge.config.js index 2adc3c7b9..ec2275b60 100644 --- a/forge.config.js +++ b/forge.config.js @@ -7,9 +7,9 @@ var AllowedFirstParts = { }; var AllowedNodeModules = { - "lzma-native": true, - "fs-ext": true, - "fsevents": true, + // "lzma-native": true, + // "fs-ext": true, + // "fsevents": true, }; var modCache = {}; @@ -27,6 +27,11 @@ function ignoreFn(path) { if (parts.length <= 2) { return false; } + if (parts.length > 3) { + if (parts[3] == "build") { + return true; + } + } let nodeModule = parts[2]; if (!modCache[nodeModule]) { modCache[nodeModule] = true; @@ -34,6 +39,7 @@ function ignoreFn(path) { if (!AllowedNodeModules[nodeModule]) { return true; } + } return false; } @@ -50,24 +56,39 @@ module.exports = { "node_modules/fsevents/**", ], icon: "static/PromptIcon.icns", + osxNotarize: { + tool: "notarytool", + keychainProfile: "notarytool-creds", + }, + osxSign: { + "hardened-runtime": true, + binaries: [ + "Contents/Resources/app/bin/prompt-local-server", + "Contents/Resources/app/bin/mshell/mshell-v0.2-linux.amd64", + "Contents/Resources/app/bin/mshell/mshell-v0.2-linux.arm64", + "Contents/Resources/app/bin/mshell/mshell-v0.2-darwin.amd64", + "Contents/Resources/app/bin/mshell/mshell-v0.2-darwin.arm64", + ], + identity: "VYQ48YC2N2", + }, }, - rebuildConfig: {}, - makers: [ - { - name: '@electron-forge/maker-squirrel', - config: {}, - }, - { - name: '@electron-forge/maker-zip', - platforms: ['darwin'], - }, - { - name: '@electron-forge/maker-deb', - config: {}, - }, - { - name: '@electron-forge/maker-rpm', - config: {}, - }, - ], + rebuildConfig: {}, + makers: [ + { + name: '@electron-forge/maker-squirrel', + config: {}, + }, + { + name: '@electron-forge/maker-zip', + platforms: ['darwin'], + }, + { + name: '@electron-forge/maker-deb', + config: {}, + }, + { + name: '@electron-forge/maker-rpm', + config: {}, + }, + ], }; diff --git a/package.json b/package.json index 3dd3d08e9..e276ecb34 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "classnames": "^2.3.1", "dayjs": "^1.11.3", "electron-squirrel-startup": "^1.0.0", - "fs-ext": "^2.0.0", "mobx": "^6.6.0", "mobx-react": "^7.5.0", "node-fetch": "^3.2.10", diff --git a/src/base.ts b/src/base.ts index df445f2dd..7eb11b4fa 100644 --- a/src/base.ts +++ b/src/base.ts @@ -1,6 +1,5 @@ import * as path from "path"; import * as fs from "fs"; -import {flockSync} from "fs-ext"; const HomeVarName = "HOME"; const PromptHomeVarName = "PROMPT_HOME"; @@ -26,12 +25,4 @@ function getDBName() : string { return path.join(promptHome, DBFileName); } -function acquirePromptElectronLock() : File { - let promptHome = getPromptHomeDir(); - let lockFileName = path.join(promptHome, PromptLockFile); - let fd = fs.openSync(lockFileName, "w", 0o600); - flockSync(fd, "exnb"); - return fd; -} - -export {getPromptHomeDir, getDBName, acquirePromptElectronLock}; +export {getPromptHomeDir, getDBName}; diff --git a/src/emain.ts b/src/emain.ts index 7cab14abe..3b451bf44 100644 --- a/src/emain.ts +++ b/src/emain.ts @@ -4,7 +4,6 @@ import * as fs from "fs"; import fetch from "node-fetch"; import * as child_process from "node:child_process"; import {debounce} from "throttle-debounce"; -import {acquirePromptElectronLock} from "./base"; import {handleJsonFetchResponse} from "./util"; import * as winston from "winston"; import * as util from "util"; @@ -18,6 +17,7 @@ let scHome = getPromptHomeDir(); ensureDir(scHome); let DistDir = (isDev ? "dist-dev" : "dist"); let GlobalAuthKey = ""; +let instanceId = uuidv4(); // these are either "darwin/amd64" or "darwin/arm64" // normalize darwin/x64 to darwin/amd64 for GOARCH compatibility @@ -26,7 +26,6 @@ let unameArch = process.arch; if (unameArch == "x64") { unameArch = "amd64" } - let logger; let loggerConfig = { level: "info", @@ -50,7 +49,8 @@ console.log(sprintf("prompt-app starting, PROMPT_HOME=%s, apppath=%s arch=%s/%s" if (isDev) { console.log("prompt-app PROMPT_DEV set"); } - +let app = electron.app; +app.setName("Prompt"); const DevLocalServerPath = "/Users/mike/prompt/local-server"; let localServerProc = null; let localServerShouldRestart = false; @@ -113,17 +113,6 @@ function readAuthKey() { return authKeyStr.trim(); } -let app = electron.app; -app.setName("Prompt"); - -let lock : File; -try { - lock = acquirePromptElectronLock(); -} -catch (e) { - app.exit(0); -} - let menuTemplate = [ { role: "appMenu", @@ -318,7 +307,7 @@ app.on('window-all-closed', () => { }); electron.ipcMain.on("get-id", (event) => { - event.returnValue = event.processId; + event.returnValue = instanceId + ":" + event.processId; return; }); @@ -454,6 +443,12 @@ async function sleep(ms) { // ====== MAIN ====== // (async () => { + let instanceLock = app.requestSingleInstanceLock(); + if (!instanceLock) { + console.log("prompt-app could not get single-instance-lock, shutting down"); + app.quit(); + return; + } GlobalAuthKey = readAuthKey(); try { await runLocalServer(); diff --git a/src/main.tsx b/src/main.tsx index 17d30f0d5..796a4e4c3 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -507,7 +507,7 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width class Line extends React.Component<{sw : ScreenWindow, line : LineType, width : number, staticRender : boolean, visible : OV, onHeightChange : HeightChangeCallbackType}, {}> { render() { let line = this.props.line; - if (line.hidden) { + if (line.archived) { return null; } if (line.linetype == "text") { diff --git a/src/types.ts b/src/types.ts index 0950abe4a..c394ac352 100644 --- a/src/types.ts +++ b/src/types.ts @@ -29,7 +29,7 @@ type LineType = { cmdid? : string, contentheight? : number, star? : number, - hidden? : boolean, + archived? : boolean, ephemeral? : boolean, remove? : boolean, }; diff --git a/yarn.lock b/yarn.lock index efbde79bf..59ad6dd1e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3529,13 +3529,6 @@ fresh@0.5.2: resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== -fs-ext@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fs-ext/-/fs-ext-2.0.0.tgz#e58168fcc37506a9358e0928f4aae60912af7caa" - integrity sha512-aK8NlpSO5LUdSoWeshpnkgtptbua1rGo58Wc+mHQ2+JnoBlubMTsnV56Swl4bA0msrgAhG8TDu1aGS8deJwzBQ== - dependencies: - nan "^2.14.0" - fs-extra@^10.0.0, fs-extra@^10.1.0: version "10.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" @@ -4868,11 +4861,6 @@ mute-stream@0.0.8: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== -nan@^2.14.0: - version "2.16.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.16.0.tgz#664f43e45460fb98faf00edca0bb0d7b8dce7916" - integrity sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA== - nanoid@^3.3.4: version "3.3.4" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"