Commit Graph
100 Commits
Author SHA1 Message Date
wancat 3b8264e39e refactor: refactor commandHandler to class 2023-08-29 12:08:36 +08:00
wancat c3683ddaea feat: import file-graph package
* Update Dockerfile structure, copy quests, packages to sub folder
2023-08-29 11:58:14 +08:00
wancat 6c70a6eaea feat: add box shadow to pwd node 2023-08-28 19:36:38 +08:00
wancat 54592831ee feat: accept graph sent from server 2023-08-28 19:36:38 +08:00
wancat 45813ebbc0 feat: display tree by data
+ show discovered as highlight
+ BREAKING: cannot hightlight lines
2023-08-28 19:36:38 +08:00
Lin, Hung-Shin 9da4d4edaa Merge pull request #19 from lancatlin/file-graph-algorithm
feat: Add file-graph-algorithm
2023-08-28 19:33:59 +08:00
wancat 1b51346eb9 feat: merge middle part 2023-08-28 14:39:52 +08:00
wancat a66de4dfe1 feat: add merge function
Able to deal with:
1.  merge a subtree
2023-08-28 14:39:52 +08:00
wancat 1778780364 feat: add makeParent options to addChild 2023-08-28 14:39:52 +08:00
wancat 781e01d43a draft: add fileGraph handler draft 2023-08-28 14:39:52 +08:00
wancat 569016077e feat: add error handling for duplicate or not exists 2023-08-28 14:39:52 +08:00
wancat fa496ceae7 feat: create FileNode class, addChild method 2023-08-28 14:39:52 +08:00
Lin, Hung-Shin 10d1a728c6 Merge pull request #21 from lancatlin/fix-zsh-prompt
Fix zsh prompt
2023-08-26 12:42:15 +08:00
wancat b0cc7bb3fb feat: update prompt color 2023-08-26 12:34:36 +08:00
wancat 791a450fdc fix: remove the trailing '%' before prompt
https://github.com/xtermjs/xterm.js/issues/2564
https://unix.stackexchange.com/questions/167582/why-zsh-ends-a-line-with-a-highlighted-percent-symbol
https://zsh.sourceforge.io/Doc/Release/Options.html
2023-08-26 12:14:47 +08:00
Lin, Hung-Shin 0cc2618b8b Merge pull request #20 from lancatlin/fix-mount-at-production
fix: remove mounting at production error
2023-08-26 11:12:58 +08:00
wancat 54e0689d30 fix: remove mounting at production error 2023-08-26 11:11:13 +08:00
Lin, Hung-Shin 98e7f6a9f7 Merge pull request #18 from lancatlin/app-cjk-input
fix: Unicode input in container
2023-08-26 09:31:38 +08:00
wancat 7d594e62db fix: set locale to zh_TW.UTF8 in quest image 2023-08-25 12:07:57 +08:00
Lin, Hung-Shin 5da311d9a4 Merge pull request #14 from lancatlin/server-session-manage
* add `status` and `lastActivityAt` field to session
* automatically delete expiry container, mark session as inactive
* default retrieving only active session on `GET /sessions`
* create container on session creation, start container on socket connection
2023-08-24 11:38:02 +08:00
wancat 4e03be9408 fix: disable restart in dev docker compose 2023-08-24 11:36:36 +08:00
wancat 3f50b99d1a fix: not to use 'force' in container deletion 2023-08-24 11:36:24 +08:00
wancat 27f8525585 fix: add missing "error" field in command 2023-08-24 11:35:43 +08:00
Lin, Hung-Shin e5e6d58a6e Merge pull request #16 from lancatlin/fix-dev-dockerfile
fix: dockerfile node access
2023-08-23 23:06:07 +08:00
Lin, Hung-Shin e417d442e7 Merge pull request #15 from lancatlin/fix-api-url
fix: update dev server api link
2023-08-23 20:37:21 +08:00
wancat 12f73d370e fix: update dev server api link 2023-08-23 20:36:32 +08:00
wancat ad3dd2fb18 fix: default retrieve active session
+ typo 'deactive' -> 'inactive',
2023-08-23 12:27:20 +08:00
wancat 22060070b9 feat: add session expiry deletion script and scheduler 2023-08-23 12:22:15 +08:00
wancat 8e63284211 feat: seperate container creation and get 2023-08-23 11:51:16 +08:00
wancat 2c866d2e83 feat: add status, lastActivityAt column to session 2023-08-23 11:50:49 +08:00
Lin, Hung-Shin bdb979e608 Merge pull request #12 from lancatlin/deployment
Deployment frontend
2023-08-23 10:58:59 +08:00
wancat 268f9fe4b1 feat: add eslint workflow 2023-08-23 10:56:21 +08:00
wancat 280e246430 feat: build backend, frontend, and quest images in workflow 2023-08-23 10:50:31 +08:00
Lin, Hung-Shin abaae9ab6a Merge pull request #13 from lancatlin/app-neil
Add tree chart and drag to scroll function in visualisation section
2023-08-23 07:54:53 +08:00
wancat e644920593 fix: error handling for quest title 2023-08-22 20:51:33 +08:00
wancat 4b3a80608c fix: remove hard coded project path
+ pass host_pwd using docker compose
+ mount it only when provided
2023-08-22 16:05:06 +08:00
wancat cf5b761f3f feat: collect docker scripts into one file 2023-08-22 15:49:21 +08:00
Lin, Hung-Shin eeb30d1f7a fix: Update README.md typo 2023-08-22 12:17:47 +08:00
wancat d8f8605df9 fix: deployment
+ include api-docs in nginx
+ include quests in docker compose
+ update README
2023-08-22 12:11:58 +08:00
wancat 9aa9367f9e refactor: move quests out of server
+ move quests from server/quests to ./quests
+ add frontend image in docker compose development
2023-08-22 11:48:44 +08:00
wancat e54ae32960 feat: add frontend nginx image 2023-08-22 11:16:37 +08:00
wancat 4255eb5910 feat: merge middle part 2023-08-21 22:22:01 +08:00
wancat 7405f786a0 feat: add merge function
Able to deal with:
1.  merge a subtree
2023-08-21 22:22:01 +08:00
wancat fd26be5e64 feat: add makeParent options to addChild 2023-08-21 22:22:01 +08:00
wancat ba610a3fc5 draft: add fileGraph handler draft 2023-08-21 22:22:01 +08:00
wancat 5a1fc6499a feat: add error handling for duplicate or not exists 2023-08-21 22:22:01 +08:00
wancat 9b78f0d41c feat: create FileNode class, addChild method 2023-08-21 22:22:01 +08:00
Lin, Hung-Shin fcaa088a31 Merge pull request #11 from lancatlin/server-socket-graph
New features:
1. collect 2 levels file list when user type 'ls' in container
2. send the file graph event via socket

Breaking changes:
1. change the channel of terminal connection from 'message' to 'terminal'
3. move client.js to standalone package packages/client
4. change frontend api to call the same origin instead, setup vite proxy for developement. (Now it's localhost on default cuz the server updates includes in this PR as well)
2023-08-21 22:14:06 +08:00
wancat 9facfa31d0 fix: remove unused experiment file 2023-08-21 22:11:38 +08:00
wancat aba582a737 doc: update README to add app and app:local instruction 2023-08-21 21:01:18 +08:00
wancat d86aa5bcc1 fix: use environment to select API_ENDPOINT 2023-08-21 20:59:35 +08:00
wancat c248004484 feat: add Vite proxy, change terminal to other channel 2023-08-21 20:40:05 +08:00
wancat c3e735b627 fix: unset variable after execution 2023-08-21 20:40:05 +08:00
wancat f08ee333a7 feat: push new pwd when 'cd' 2023-08-21 20:40:05 +08:00
wancat 096b7a7714 feat: push discover event to frontend 2023-08-21 20:40:05 +08:00
wancat c0186c6a30 feat: show hiddenFiles 2023-08-21 20:40:05 +08:00
wancat f43fa1b5ef fix: limit 2 level to only 5 children 2023-08-21 20:40:05 +08:00
wancat 34d5ace664 feat: use minimist to refactor cli 2023-08-21 20:40:05 +08:00
wancat 6ace18475b refactor: move client to sperate packages, rename cli to container 2023-08-21 20:40:05 +08:00
wancat 41a12c9aa8 feat: collect 2 level files info when ls
* change cli dir to /usr/local/lib/cli
* refactor cli to multiple files
* add handleCommand and listeners pattern
2023-08-21 20:40:05 +08:00
Lin, Hung-Shin e6d6036cd0 Merge pull request #10 from lancatlin/app-terminal
Connect web terminal to server
2023-08-21 20:38:00 +08:00
wancat ed9b584093 fix: rename "reconnect" to "bindListeners" 2023-08-21 20:34:41 +08:00
wancat 4efce2c6b8 fix: remove cors 2023-08-21 20:27:44 +08:00
wancat 5d9951a3a2 refactor: use SocketWrapper to wrap the instance 2023-08-18 21:19:11 +08:00
wancat 313d30edda feat: add reset function 2023-08-17 21:17:48 +08:00
wancat e122800c81 feat: add sessionManagerto connect session 2023-08-17 20:21:32 +08:00
wancat 7fa5ab5bc6 Create a pty cli, not useful 2023-08-17 19:45:18 +08:00
wancat a74233d7f9 feat: connect to localhost 2023-08-17 19:43:55 +08:00
Lin, Hung-Shin d2daa5193a Merge pull request #7 from lancatlin/server-quest-helloworld
Game architecture design
2023-08-11 16:35:52 +08:00
wancat 0ba823b432 feat: print hints 2023-08-09 21:16:43 +08:00
wancat a151d2d667 feat: add type and color to response 2023-08-09 21:14:57 +08:00
wancat 5cad3ecc12 fix: mark progress to stage.next directly 2023-08-08 20:38:27 +08:00
wancat a73aa8b461 fix: prevent execute command twice 2023-08-08 20:38:27 +08:00
wancat 41a090ce73 doc: update README 2023-08-08 20:38:27 +08:00
wancat 6f368f761e feat: add hints to session, update API 2023-08-08 20:38:27 +08:00
wancat ae61bfc768 Update eslint rule 2023-08-08 20:38:27 +08:00
wancat 094332da53 feat: add commandHandler 2023-08-08 20:38:27 +08:00
wancat 0de4b6ac9d feat: design game file and parse it to mongo
* 取消用 README 來寫關卡說明
2023-08-08 20:38:27 +08:00
wancat 6204bd0b17 feat: change to use Zsh
* show message from server response
* send output and error to server
2023-08-08 20:38:27 +08:00
wancat 0153eae673 feat: new cli client to send and receive msg from api 2023-08-08 20:38:27 +08:00
wancat e2e585329f Create a pty cli, not useful 2023-08-08 20:38:27 +08:00
wancat 12a42d117c feat: write story of the game 2023-08-08 20:38:27 +08:00
Lin, Hung-Shin edfe197e51 Merge pull request #8 from lancatlin/hot-fix-server-socket
fix: send string
2023-08-08 20:37:08 +08:00
wancat 06ee53f194 fix: send string 2023-08-08 20:36:49 +08:00
Lin, Hung-Shin fb826c2f0e Merge pull request #6 from lancatlin/app-neil
Front-end update
2023-08-01 20:56:20 +08:00
wancat d26e68098a fix: use PascalCase 2023-08-01 20:54:49 +08:00
wancat 66cc1036b4 feat: use axios, extract api to another file 2023-08-01 20:54:49 +08:00
Lin, Hung-Shin b729e30e0b Merge pull request #5 from lancatlin/server-commands-api
Server commands api
2023-07-31 17:22:36 +08:00
wancat c3030b22be feat: add mongo init script, use root in app image 2023-07-31 17:19:03 +08:00
wancat ec90c484b4 feat: add parameters and subcommand to client.js
- Added `"commander": "^11.0.0"` as a dependency in the `package.json` file
- Added an `import { program } from 'commander'` statement in the `client.js` file
- Modified the `createdSession` function in the `client.js` file to use `program.opts().host` instead of `API_ENDPOINT`
- Added a `getSessionList` function in the `client.js` file to fetch the list of sessions
- Added a `lastSession` function in the `client.js` file to get the last session from the session list
- Added a `connect` function in the `client.js` file to establish a socket connection
- Modified the `main` function in the `client.js` file to use `program.opts().session` instead of `process.argv[2]` to get the session ID
- Modified the `main` function in the `client.js` file to use `program.opts().host` instead of `API_ENDPOINT` to initialize the socket connection
- Added a `program` object with options and actions in the `client.js` file
- Added `.bash_history` to the `.gitignore` file
- Added `.viminfo` to the `.gitignore` file
- Added `*.swp` to the `.gitignore` file

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-31 15:42:58 +08:00
wancat b9643e7d5c feat: capture output and exit code of commands
+ ignore interactive commands like vim, top or nano
2023-07-27 17:56:32 +08:00
wancat d997a061a9 feat: send command typed in container to API
- Modify the Dockerfile in the `server/quests/helloworld` directory to add a user and change the working directory
- Rename the file `server/quests/helloworld/entrypoint.sh` to `server/quests/helloworld/home/.bashrc`
- Modify the `server/src/config.js` file to add the `isProduction` flag
- Modify the `server/src/utils/docker.js` file to add a `HostConfig` option and bind a directory if not in production mode
- Modify the Dockerfile to add an argument `DOCKER_GID` and create a group and user with the specified `DOCKER_GID`
- Add a new Dockerfile.dev file with the same modifications as the Dockerfile
- Add a new file `inspect.sh`
- Modify the `server/src/client.js` file to use the `API_ENDPOINT` variable instead of a hardcoded URL

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-26 20:54:01 +08:00
wancat 9376e16f72 Success to send command to api
+ require sourcing entrypoint.sh manually
2023-07-26 00:12:10 +08:00
wancat 9f74a80551 feat: refactor session management and API usage
- Add an import statement for the `get` function from `./utils/env.js`
- Add a constant for `API_ENDPOINT` using the `get` function
- Remove the `sessionId` constant declaration
- Add an `async` function `getSessionId` for fetching session ID
- Add an `async` function `main` for the main program logic
- Initialize `sessionId` using the command line argument or by calling `getSessionId`
- Add a console log statement for the session ID
- Remove the `if` statement for checking `sessionId` existence
- Update the socket URL to use `API_ENDPOINT`
- Add a `socket.on` event listener for the `close` event
- Update the condition for checking the `key` value in `stdin.on` event listener
- Call the `main` function at the end of the file

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-25 15:56:51 +08:00
wancat 88ed447573 fix: error handling
- Remove unnecessary try-catch block in createSession function
- Add error handling for missing session ID in socket.js
- Improve error handling in connectDB function
- Add error handling middleware for server errors
- Add default export for get function in env.js

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-25 15:46:59 +08:00
wancat 943c11714c feat: connect containers to custom network
- Export the `get` function in `utils/env.js`
- Change the Docker image in `docker.js` from `ubuntu` to `lancatlin/quest-helloworld`
- Remove the `createContainer` and `getContainer` functions from `docker.js`
- Add a `network` constant in `docker.js` that gets the Docker network from the config
- Connect the container to the network in `getOrCreateContainer` function in `docker.js`
- Add `API_ENDPOINT` environment variable in the `attachContainer` function in `docker.js`

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-25 15:42:07 +08:00
wancat 189c87df5a build: setup Docker dev configuration
- Add `.dockerignore` file
- Add `Dockerfile.dev`
- Modify `docker-compose.yml`:
  - Add `restart: on-failure` to `app` service
  - Modify `build` section of `app` service
  - Remove `links` section from `app` service
  - Add `networks` section to `app` and `db` services
  - Add `networks` section to the end of the file

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-25 15:37:05 +08:00
wancat 3cea54ce71 feat: add new API for recording executed commands
- Add the `jsonwebtoken` dependency to the server's `package.json`
- Add a new file `commandController.js` to the server's API controllers
- Add a new route `/commands` to the server's API routes
- Add a new file `commands.js` to the server's API routes
- Modify the `index.js` file in the server's API routes to import and use the `commands.js` route
- Add a `newCommand` function to the `commandController.js` file
- Add a `Command` model to the `command.js` file in the server's models
- Add the `genSessionJWT` and `verifySessionJWT` functions to the `auth.js` file in the server's utils
- Modify the `attachContainer` function in the `docker.js` file in the server's utils to include a `token` parameter
- Modify the `swagger.yaml` file to include a new route `/commands` for recording executed commands in a session

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-24 16:39:04 +08:00
wancat fe3f4ddc73 fix: docker image name update 2023-07-24 16:39:04 +08:00
Lin, Hung-Shin 9ee9a8586f Merge pull request #3 from lancatlin/server-terminal-api
Server terminal api
2023-07-24 15:09:02 +08:00