Skip to content

Refactor2 #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
desktop/electron/out

electron/embedded.provisionprofile
57 changes: 31 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# SwitchV

Use this to quickly open and switch VSCode projects.
Use this to quickly open and switch VS Code 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.
- 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 VS Code.

## Dev and package Note

Expand All @@ -16,16 +16,16 @@ Use this to quickly open and switch VSCode projects.
- install [vsce](https://code.visualstudio.com/api/working-with-extensions/publishing-extension)
- `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
- ~~server(moved into electron)~~
- ~~`yarn install`~~
- electron (desktop app)
- `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?
- DB setup
- 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)
- `yarn start` (not set VS Code debugging yet)
- ~~F5 debug or `yarn start:debug`~~ (need fix since we have embed the server into electron)
- 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`.


Expand All @@ -38,7 +38,7 @@ Use this to quickly open and switch VSCode projects.

## 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.
1. [fixed] after click one window item, show VS Code, 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)

Expand All @@ -50,6 +50,13 @@ Use this to quickly open and switch VSCode projects.

6. ~~React App is called twice initially~~ (this is due to <React.StrictMode>). ref: https://github.com/facebook/react/issues/12856#issuecomment-390206425


7. [solved] how to use vercel/pkg bundle deb.db in nestjs, instead of manual copy????
1. Solved by using macOS application folder to store db file.
2. Eventually, using `vercel/pkg` was also gave up and server is embedded into electron to make the final packaging working.
8. [fixed] 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).
1. Solved by electron sending 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.

### debugger issue

**To debug main process**
Expand Down Expand Up @@ -105,20 +112,18 @@ The drawback is you will see two copy of SwitchV. And attaching render process t
## notes about packaging a macOS app

steps:
1. bundle server
1. in server, execute `yarn build` to generate dist folder
2. (first time) `yarn global add pkg`
3. ~~add `"version": "0.0.1"` field in `generated server/node_modules/.prisma/client/package.json`~~
4. ~~in server, `pkg --debug -t node16-macos-arm64 -o SwitchV-server-macos .`~~
5. `yarn make`
6. [optional] `DEBUG_PKG=1 ./SwitchV-server-macos` for debugging
2. 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
1. ~~bundle server~~
1. ~~in server, execute `yarn build` to generate dist folder~~
2. ~~(first time) `yarn global add pkg`~~
3. ~~add `"version": "0.0.1"` field in `generated server/node_modules/.prisma/client/package.json`~~
4. ~~in server, `pkg --debug -t node16-macos-arm64 -o SwitchV-server-macos .`~~
5. ~~`yarn make`~~
6. ~~[optional] `DEBUG_PKG=1 ./SwitchV-server-macos` for debugging~~
2. Follow [Prepare provisioning profile](https://www.electronjs.org/) section on https://www.electronjs.org/ to get `yourapp.provisionprofile` and download it as `electron/embedded.provisionprofile`.
3. in electron, `yarn make` to generate out folder


### server packaging notes (we had use vercel/pkg to package server but we have decided to embed server to electron)
ref:
1. https://github.com/prisma/prisma/issues/8449
2. https://github.com/vercel/pkg/issues/1508
Expand Down
7 changes: 0 additions & 7 deletions server/.env

This file was deleted.

25 changes: 0 additions & 25 deletions server/.eslintrc.js

This file was deleted.

35 changes: 0 additions & 35 deletions server/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions server/.prettierrc

This file was deleted.

20 changes: 0 additions & 20 deletions server/.vscode/launch.json

This file was deleted.

33 changes: 0 additions & 33 deletions server/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions server/build.sh

This file was deleted.

5 changes: 0 additions & 5 deletions server/nest-cli.json

This file was deleted.

87 changes: 0 additions & 87 deletions server/package.json

This file was deleted.

39 changes: 0 additions & 39 deletions server/prisma/schema.prisma

This file was deleted.

22 changes: 0 additions & 22 deletions server/src/app.controller.spec.ts

This file was deleted.

Loading