Skip to content
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

Feat/debug-tools #7

Merged
merged 16 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
♻️ refactor: debug -> intergrate with debug-tools and use openBrowser…
… from react-dev-utils
  • Loading branch information
KusStar committed Oct 26, 2021
commit ab9b44363a6fd5e6c01e022eeb281629e3a6a998
2 changes: 1 addition & 1 deletion packages/debug/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $ npx mincud -h
$ mincud 'npm run dev'
```

## Attribute
## Thanks

- [react-native/cli](https://github.com/react-native-community/cli), [metro](https://github.com/facebook/metro)
- [expo/expo-cli](https://github.com/expo/expo-cli)
2 changes: 2 additions & 0 deletions packages/debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
"isomorphic-ws": "^4.0.1",
"lodash.debounce": "^4.0.8",
"meow": "9.0.0",
"mincu-debug-tools": "^2.1.1",
"mincu-lib": "^2.1.1",
"open": "^8.2.1",
"react-dev-utils": "^11.0.4",
"strip-ansi": "6.0.0",
"terminate": "^2.2.2",
"ws": "^8.0.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/debug/src/mincud/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import open from 'open'
import internalIp from 'internal-ip'
import execa from 'execa'
import stripAnsi from 'strip-ansi'
Expand All @@ -10,6 +9,8 @@ import terminate from 'terminate'
import { startServer } from './server'
import { StringMatcher } from './StringMatcher'
import { REGEXP_NETWORK_HOST, REGEXP_LOCAL_HOST, CMD_RELOAD, CMD_DEV_TOOL } from './shared'
import { DEV_TOOL_PORT } from 'mincu-debug-tools/server';
import openBrowser from 'react-dev-utils/openBrowser'

const TAG = chalk.inverse.green.bold(' Server ')
let childPid = -1
Expand Down Expand Up @@ -106,9 +107,8 @@ const openQRCode = (text: string) => {
}
const url = new URL(origin)
url.searchParams.set('devSecret', 'iNCUDeveloper++')
const subtitle = "请打开 「南大家园」 - 「生活板块」 - 右上角「扫一扫」,扫描以上二维码,开始调试"

open(`https://qrcode-function.vercel.app/api?text=${encodeURIComponent(url.toString())}&title=${origin}&subtitle=${subtitle}&type=html`)
openBrowser(`http://localhost:${DEV_TOOL_PORT}/?url=${encodeURIComponent(url.toString())}&origin=${origin}`)
}

export const startCli = () => {
Expand Down
9 changes: 8 additions & 1 deletion packages/debug/src/mincud/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import chalk from 'chalk'
import { DEBUG_PORT, LogLevel } from './shared'
import { logToConsole } from './logToConsole';
import { Decode } from 'console-feed-node-transform';
import { startDevTool } from 'mincu-debug-tools/server';

type RecvType = 'log'

Expand All @@ -17,7 +18,7 @@ const formatMessage = (message: Data) => {
return JSON.parse(str) as Received
}

export const startServer = () => {
const startWebSocketServer = () => {

const wss = new WebSocket.Server({ port: DEBUG_PORT });

Expand Down Expand Up @@ -55,4 +56,10 @@ export const startServer = () => {
`)

return wss
}

export const startServer = () => {
startDevTool()

return startWebSocketServer()
}