Skip to content

Commit 403f3e4

Browse files
committed
feat(shell-electron): add cli usage without electron
1 parent 122207d commit 403f3e4

File tree

18 files changed

+16693
-11720
lines changed

18 files changed

+16693
-11720
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ TODOs.md
1010
.idea
1111
.web-extension-id
1212
yarn-error.log
13+
.yarn/*
1314

1415
/packages/*/lib
1516
.amo.env.json

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@
8080
"engines": {
8181
"node": ">=8.10"
8282
}
83-
}
83+
}

packages/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434
"@types/webpack-env": "^1.15.1",
3535
"typescript": "^4.5.2"
3636
}
37-
}
37+
}

packages/app-backend-api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"ts": "tsc -d -outDir lib"
1111
},
1212
"dependencies": {
13-
"@vue/devtools-api": "^6.0.0-beta.1",
14-
"@vue-devtools/shared-utils": "^0.0.0"
13+
"@vue-devtools/shared-utils": "^0.0.0",
14+
"@vue/devtools-api": "^6.0.0-beta.1"
1515
},
1616
"devDependencies": {
1717
"@types/node": "^13.9.1",

packages/app-backend-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
"ts": "tsc -d -outDir lib"
1111
},
1212
"dependencies": {
13-
"@vue/devtools-api": "^6.0.0-beta.1",
1413
"@vue-devtools/app-backend-api": "^0.0.0",
1514
"@vue-devtools/app-backend-vue1": "^0.0.0",
1615
"@vue-devtools/app-backend-vue2": "^0.0.0",
1716
"@vue-devtools/app-backend-vue3": "^0.0.0",
1817
"@vue-devtools/shared-utils": "^0.0.0",
18+
"@vue/devtools-api": "^6.0.0-beta.1",
1919
"lodash": "^4.17.21",
2020
"speakingurl": "^14.0.1"
2121
},

packages/app-backend-vue3/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"ts": "tsc -d -outDir lib"
1111
},
1212
"dependencies": {
13-
"@vue/devtools-api": "^6.0.0-beta.1",
1413
"@vue-devtools/app-backend-api": "^0.0.0",
15-
"@vue-devtools/shared-utils": "^0.0.0"
14+
"@vue-devtools/shared-utils": "^0.0.0",
15+
"@vue/devtools-api": "^6.0.0-beta.1"
1616
},
1717
"devDependencies": {
1818
"@types/node": "^13.9.1",

packages/build-tools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
"monaco-editor-webpack-plugin": "^3.1.0",
1717
"path-browserify": "^1.0.1",
1818
"postcss-loader": "^5.2.0",
19+
"style-resources-loader": "^1.2.1",
1920
"stylus": "^0.54.5",
2021
"stylus-loader": "^5.0.0",
21-
"style-resources-loader": "^1.2.1",
2222
"terser-webpack-plugin": "^5.1.1",
2323
"vue-loader": "^15.7.1",
2424
"vue-template-compiler": "^2.7.10",

packages/docs/src/guide/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ npm install --save-dev @vue/devtools
127127

128128
Once you installed the package globally, run:
129129
```bash
130-
vue-devtools
130+
vue-devtools # or use vue-devtools-cli without electron
131131
```
132132

133133
Then add this code to the `<head>` section of your application HTML file:

packages/shell-electron/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ npm install --save-dev @vue/devtools
2020

2121
Once you installed the package globally, run:
2222
```bash
23-
vue-devtools
23+
vue-devtools # or use vue-devtools-cli without electron
2424
```
2525

2626
Then add:

packages/shell-electron/app.html

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5+
<meta http-equiv="Cache-Control" content="no-cache, no-store, max-age=0" />
6+
<meta http-equiv="Pragma" content="no-cache" />
7+
<meta http-equiv="expires" content="Fri, 18 Jue 2023 17:00:00 GMT" />
58
<title>Vue Developer Tools</title>
9+
<script src="/local_ip"></script>
610
<style>
711
#app,
812
#intro {
@@ -41,7 +45,7 @@
4145
}
4246

4347
#intro .content {
44-
width: 395px;
48+
width: 500px;
4549
font-size: 18px;
4650
line-height: 45px;
4751
text-align: center;
@@ -64,9 +68,18 @@
6468
margin-left: 10px;
6569
border: 1px solid #cacaca;
6670
border-radius: 2px;
67-
text-align: center;
6871
font-size: 14px;
6972
}
73+
74+
#intro textarea {
75+
flex: 1;
76+
padding: 0 10px;
77+
margin-left: 10px;
78+
border: 1px solid #cacaca;
79+
border-radius: 2px;
80+
font-size: 14px;
81+
width: 100%;
82+
}
7083
</style>
7184
</head>
7285
<body>
@@ -82,23 +95,27 @@ <h2 class="title">
8295
</div>
8396
<div class="content-row">
8497
<label for="script-byip">Or</label>
85-
<input type="text" id="script-byip">
98+
<textarea id="script-byip" rows="5" ></textarea>
8699
</div>
87100
to the top of the page you want to debug.
88101
</div>
89102
</div>
90103
<div id="app">
91104
</div>
92105
<script>
93-
const port = process.env.PORT || 8098
94-
const localIp = require('ip').address();
106+
const port = process.env.PORT
107+
const localIp = process.env.HOST
95108
const $ = document.querySelector.bind(document)
96109

97110
const $localhost = $('#script-localhost')
98111
const $byIp = $('#script-byip')
99112

100113
$localhost.value = '<' + 'script src="http://localhost:' + port + '"><' + '/script>'
101-
$byIp.value = '<' + 'script src="http://' + localIp + ':' + port + '"><' + '/script>'
114+
$byIp.innerHTML = `&lt;script&gt;
115+
window.__VUE_DEVTOOLS_HOST__ = 'http://${localIp}'
116+
window.__VUE_DEVTOOLS_PORT__ = ${port}
117+
&lt;/script&gt;
118+
&lt;script src="http://${localIp}:${port}" &gt;&lt;/script&gt;`
102119

103120
function selectAll () {
104121
this.selectionStart = 0

packages/shell-electron/app.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ require('./server')
33

44
const { app, BrowserWindow } = require('electron')
55
const path = require('path')
6-
const url = require('url')
76

87
let mainWindow = null
98

@@ -18,11 +17,7 @@ function createWindow () {
1817
},
1918
})
2019

21-
mainWindow.loadURL(url.format({
22-
pathname: path.join(__dirname, 'app.html'),
23-
protocol: 'file:',
24-
slashes: true,
25-
}))
20+
mainWindow.loadURL(`http://localhost:${process.env.PORT || 8098}/app.html`)
2621

2722
mainWindow.on('closed', () => {
2823
mainWindow = null

packages/shell-electron/cli.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('./server.js')

packages/shell-electron/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
"directory": "packages/shell-electron"
99
},
1010
"bin": {
11-
"vue-devtools": "./bin.js"
11+
"vue-devtools": "./bin.js",
12+
"vue-devtools-cli": "./cli.js"
1213
},
1314
"main": "index.js",
1415
"types": "types/index.d.ts",
1516
"sideEffects": false,
1617
"scripts": {
1718
"start": "node bin.js",
19+
"dev": "node cli.js",
1820
"dev:client": "webpack --watch",
1921
"dev:node": "webpack --watch --config webpack.node.config.js",
2022
"build": "npm run build:client && npm run build:node",
@@ -56,4 +58,4 @@
5658
"README.md",
5759
"server.js"
5860
]
59-
}
61+
}

packages/shell-electron/server.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const path = require('path')
22
const fs = require('fs')
3-
const app = require('express')()
3+
const express = require('express')
4+
const app = express()
45
const { createServer } = require('http')
56
const { Server } = require('socket.io')
67

78
const port = process.env.PORT || 8098
9+
const localIp = require('ip').address()
810

911
const httpServer = createServer(app)
1012
const io = new Server(httpServer, {
@@ -13,6 +15,16 @@ const io = new Server(httpServer, {
1315
},
1416
})
1517

18+
app.use(express.static(path.join(__dirname, './')))
19+
app.get('/local_ip', function (req, res) {
20+
res.header('Content-Type', 'application/javascript')
21+
res.send(`window.process = {
22+
env: {
23+
PORT: ${port},
24+
HOST: '${localIp}'
25+
}
26+
}`)
27+
})
1628
app.get('/', function (req, res) {
1729
const hookContent = fs.readFileSync(path.join(__dirname, '/build/hook.js'), 'utf8')
1830
const backendContent = fs.readFileSync(path.join(__dirname, '/build/backend.js'), 'utf8')
@@ -41,5 +53,6 @@ io.on('connection', function (socket) {
4153

4254
httpServer.listen(port, '0.0.0.0', () => {
4355
// eslint-disable-next-line no-console
44-
console.log('listening on 0.0.0.0:' + port)
56+
console.log(`listening on 0.0.0.0:${port}
57+
open this link http://${localIp}:${port}/app.html when you need remote vue-devtools.`)
4558
})

packages/shell-electron/src/devtools.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { initDevTools } from '@front'
33
import { Bridge } from '@vue-devtools/shared-utils'
44

55
const port = window.process.env.PORT || 8098
6-
const socket = io('http://localhost:' + port)
6+
const host = window.process.env.HOST || 'localhost'
7+
const socket = io(`http://${host}:${port}`)
78
const $ = document.querySelector.bind(document)
89
const $intro = $('#intro')
910

packages/shell-host/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"dev": "cross-env TAILWIND_MODE=watch webpack serve"
77
},
88
"dependencies": {
9-
"@vue/ui": "^0.12.5",
109
"@vue-devtools/app-backend-core": "^0.0.0",
1110
"@vue-devtools/app-frontend": "^0.0.0",
1211
"@vue-devtools/shared-utils": "^0.0.0",
12+
"@vue/ui": "^0.12.5",
1313
"vue": "^2.7.10"
1414
},
1515
"devDependencies": {

0 commit comments

Comments
 (0)