grimmer0125 / switchv

1. build app yarn make_mas, sh ./sign.sh 2. https://apps.apple.com/us/app/switchv/id1663612397 3. extension: https://marketplace.visualstudio.com/items?itemName=grimmer.SwitchV

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SwitchV

Use this to quickly open and switch VSCode projects.

Features

  • use command line shortcut/tray menu to quickly launch a UI listing recent opened window with different project paths, then select one to open it in VSCode.

Dev and package Note

  • extension
    • yarn install
    • either
      • F5 debug for debugging or
      • built it and install it. Firstly
        • install vsce
        • yarn make vsce package,
        • yarn load (first time) & yarn reload then code --install-extension SwitchV-0.0.1.vsix to install.
  • server
    • yarn install
    • For the first time or every time db scheme changes, execute yarn db:migrate to generate SQLite DB file (./prisma/dev.db) and generate TypeScript interface. yarn db:view can be used to view DB data.
      • To generate TypeScript DB interface via yarn db:type (db:migrate will also automatically do this part, yarn install will also include generated types in node_modules/.prisma/index.d.ts)
    • F5 debug or yarn start:debug
    • build: yarn make.
  • desktop/electron
    • yarn install
    • yarn start (not set VSCode debugging yet)
    • package as mac app: yarn make. It (Electron part) is about 196MB. Server vercel/pkg build is 119MB. Total it is 316MB. Try Tauri to reduce electron part?
    • build mas build: yarn make_mas. Then execute sh ./sign.sh.

pnpm tips:

  • pnpm install vs npm install
  • pnpm dlx vs npx

ref: https://pnpm.io/pnpm-cli

issues/todos

  1. [fixed] after click one window item, show VSCode, first time "cmd+ctrl+j" trigger does not effect and always need the second time.

  2. [fixed] after using ctrl+w to close SwitchV, the window object will be destroyed and can not be used anymore (will throw exception)

  3. [fixed] (packaged app) Frontend usually fails to fetch data from server since the server is starting firstly. Need refresh. Add some waiting time.

  4. [system limitation, wll not fix] handle minimizing electron app case and make it hidden. ref: electron/electron#29860 (comment)

  5. Sometimes tray menu will not show. It seems to be because too many menu apps? Yes. It is all about macbook notch. We can not solve it

  6. React App is called twice initially (this is due to <React.StrictMode>). ref: facebook/react#12856 (comment)

debugger issue

To debug main process

Below is a workaround way to debug main process: Its reference is electron/forge#1369 (comment)

{
  "type": "node",
  "request": "launch",
  "name": "Electron Main",
  "runtimeExecutable": "npm",
  "runtimeArgs": [
      "run",
      "start",
  ],
  "cwd": "${workspaceFolder}"
}

electron-forge official site only mention how to debug main process but it has a bug electron/forge#1369

{
  "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-nix",
}

Error: Cannot find module '/Users/liamdawson/w/@electron-forge/cli/dist/electron-forge-start'

To debug render process (workaround way)

electron site and ms github site both mention below setting to debug main proces

{
  "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
}

and ms github site has a extra setting for debugging render process. But the above setting to trigger main process has a bug that it does not trigger the webpack server customized by electron forge. To workaround this for mainly debugging render process, the steps are

  1. yarn start (to start webpack server part)
  2. launch compound "Electron: All" launch setting (from ms github site) to debug main & render processes.

The drawback is you will see two copy of SwitchV. And attaching render process takes a little time (e.g. only stop at some breakpoints after a while/refresh).

notes about packaging a macOS app

steps:

  1. bundle server
  2. in server, execute yarn build to generate dist folder
  3. (first time) yarn global add pkg
  4. add "version": "0.0.1" field in generated server/node_modules/.prisma/client/package.json
  5. in server, pkg --debug -t node16-macos-arm64 -o SwitchV-server-macos .
  6. yarn make
  7. [optional] DEBUG_PKG=1 ./SwitchV-server-macos for debugging
  8. in electron, yarn make to generate out folder

two issues

  1. x TODO: how to use vercel/pkg bundle deb.db in nestjs, instead of manual copy???? (use macOS application folder to store db file)
  2. x TODO: close the packaged app via cmd+q seems not close SwitchV-server-macos process? check by command: lsof -i:55688. Use ctrl+c to stop development (running via yarn start) is OK. (add close button on tray to help? I guess it is not helping). Solved by electron send kill server process in the before-quick event handler. Another person suggests to add one more step to handle SIGINT signal on server side, ref https://stackoverflow.com/questions/71523442/child-process-doesnt-exit.

server notes

ref:

  1. prisma/prisma#8449
  2. vercel/pkg#1508

About

1. build app yarn make_mas, sh ./sign.sh 2. https://apps.apple.com/us/app/switchv/id1663612397 3. extension: https://marketplace.visualstudio.com/items?itemName=grimmer.SwitchV


Languages

Language:TypeScript 90.6%Language:Shell 7.8%Language:JavaScript 0.7%Language:CSS 0.5%Language:HTML 0.4%