mirror of
https://github.com/aljazceru/pear-docs.git
synced 2025-12-17 14:34:19 +01:00
Add guide on terminal debugging (#43)
* Add guides on how to debug mobile/terminal apps * Rename to Pear Desktop * Cleanup * Clean Pear.config.args explanation * Fix incorrect renaming * Remove mobile debugging guide * Rename fix * Rename back to Pear Runtime
This commit is contained in:
committed by
GitHub
parent
9fa999e0c8
commit
af9d543015
@@ -17,6 +17,7 @@
|
||||
* [Making a Pear Terminal Application](./guide/making-a-pear-terminal-app.md)
|
||||
* [Sharing a Pear Application](./guide/sharing-a-pear-app.md)
|
||||
* [Marking a Release](./guide/releasing-a-pear-app.md)
|
||||
* [Debugging a Pear Terminal Application](./guide/debugging-a-pear-terminal-app.md)
|
||||
|
||||
### How-tos
|
||||
|
||||
|
||||
50
guide/debugging-a-pear-terminal-app.md
Normal file
50
guide/debugging-a-pear-terminal-app.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Debugging A Pear Terminal Application
|
||||
|
||||
Debugging Pear Terminal Applications is different than debugging Desktop Applications because they do not come with a UI. Instead a few steps are needed.
|
||||
|
||||
Use [Pear Inspect](https://github.com/holepunchto/pear-inspect) together with the Pear Runtime Desktop and use any tool that supports DevTools like Chrome.
|
||||
|
||||
## Step 1. Install pear-inspect
|
||||
|
||||
First install `pear-inspect`:
|
||||
|
||||
```
|
||||
npm install pear-inspect
|
||||
```
|
||||
|
||||
## Step 2. Add Code
|
||||
|
||||
This code should run as the first thing in the application:
|
||||
|
||||
``` js
|
||||
if (Pear.config.dev) {
|
||||
const { Inspector } = await import('pear-inspect')
|
||||
const inpector = await new Inspector()
|
||||
const key = await inpector.enable()
|
||||
console.log(`Debug with pear://runtime/devtools/${key.toString('hex')}`)
|
||||
}
|
||||
```
|
||||
|
||||
## Step 3. Run In Dev Mode
|
||||
|
||||
As the code specifies, `pear-inspect` is only running when in dev mode, so start the app:
|
||||
|
||||
```
|
||||
pear dev .
|
||||
```
|
||||
|
||||
The application will output something similar to:
|
||||
|
||||
```
|
||||
Debug with pear://runtime/devtools/a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2
|
||||
```
|
||||
|
||||
## Step 4. Add to Pear Runtime Desktop
|
||||
|
||||
In Pear Desktop go to `Developer Tooling` and paste in the key.
|
||||
|
||||
Note that the key can also be sent to someone else and they can debug the app remotely.
|
||||
|
||||
## Step 5. Open in Chrome
|
||||
|
||||
Click on `Open in Chrome` or copy the link into a tool that support DevTools.
|
||||
@@ -32,7 +32,6 @@ const { teardown, config } = Pear
|
||||
const key = config.args.pop()
|
||||
const shouldCreateSwarm = !key
|
||||
const swarm = new Hyperswarm()
|
||||
const log = console.log
|
||||
const rl = readline.createInterface({
|
||||
input: new tty.ReadStream(0),
|
||||
output: new tty.WriteStream(1)
|
||||
|
||||
@@ -83,7 +83,7 @@ Application storage path.
|
||||
|
||||
### `Pear.config.args <Array>`
|
||||
|
||||
Command-line application arguments passed after double dash `--`.
|
||||
Command-line application arguments passed like `pear dev . --some arg`.
|
||||
|
||||
### `Pear.config.release <Number>`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user