@quicktvui/web-cli 1.0.0-beta.15 → 1.0.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/qt-web-cli.js +29 -17
- package/lib/webpack.config.js +14 -0
- package/package.json +1 -1
package/bin/qt-web-cli.js
CHANGED
|
@@ -76,23 +76,35 @@ async function main() {
|
|
|
76
76
|
let mainEntry
|
|
77
77
|
let entryType
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
79
|
+
// 入口候选列表
|
|
80
|
+
const entryCandidates = [
|
|
81
|
+
{ name: 'webMain', path: pkg.webMain, type: 'webmain' },
|
|
82
|
+
{ name: 'src/main.ts', path: './src/main.ts', type: 'package' },
|
|
83
|
+
{ name: 'src/main.js', path: './src/main.js', type: 'package' },
|
|
84
|
+
{ name: 'main (package.json)', path: pkg.main, type: 'package' },
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
// 检查 src/web 本地渲染器
|
|
88
|
+
const hasLocalWebRenderer = fs.existsSync(path.join(projectRoot, 'src/web/index.js'))
|
|
89
|
+
|
|
90
|
+
for (const candidate of entryCandidates) {
|
|
91
|
+
if (!candidate.path) continue
|
|
92
|
+
const entryFullPath = path.resolve(projectRoot, candidate.path)
|
|
93
|
+
if (fs.existsSync(entryFullPath)) {
|
|
94
|
+
mainEntry = candidate.path
|
|
95
|
+
entryType = hasLocalWebRenderer ? 'local' : candidate.type
|
|
96
|
+
signale.info(`主入口: ${mainEntry}`)
|
|
97
|
+
signale.info(`Web 渲染器: ${hasLocalWebRenderer ? 'src/web (本地)' : '@quicktvui/web-renderer (包)'}`)
|
|
98
|
+
break
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!mainEntry) {
|
|
103
|
+
signale.error('无法找到有效的入口文件,请检查以下路径:')
|
|
104
|
+
signale.error(' - package.json 中的 webMain 字段')
|
|
105
|
+
signale.error(' - src/main.ts 或 src/main.js')
|
|
106
|
+
signale.error(' - package.json 中的 main 字段')
|
|
107
|
+
process.exit(1)
|
|
96
108
|
}
|
|
97
109
|
|
|
98
110
|
const mainEntryPath = path.resolve(projectRoot, mainEntry)
|
package/lib/webpack.config.js
CHANGED
|
@@ -66,6 +66,20 @@ function detectModules() {
|
|
|
66
66
|
if (fs.existsSync(cwdNodeModules) && !modules.includes(cwdNodeModules)) {
|
|
67
67
|
modules.push(cwdNodeModules)
|
|
68
68
|
}
|
|
69
|
+
// 添加 web-cli 自身的 node_modules 路径(支持全局安装)
|
|
70
|
+
const cliNodeModules = path.resolve(__dirname, '../node_modules')
|
|
71
|
+
if (fs.existsSync(cliNodeModules) && !modules.includes(cliNodeModules)) {
|
|
72
|
+
modules.push(cliNodeModules)
|
|
73
|
+
}
|
|
74
|
+
// 添加全局 node_modules 路径
|
|
75
|
+
try {
|
|
76
|
+
const globalNodeModules = require('child_process')
|
|
77
|
+
.execSync('npm root -g', { encoding: 'utf-8' })
|
|
78
|
+
.trim()
|
|
79
|
+
if (fs.existsSync(globalNodeModules) && !modules.includes(globalNodeModules)) {
|
|
80
|
+
modules.push(globalNodeModules)
|
|
81
|
+
}
|
|
82
|
+
} catch (e) {}
|
|
69
83
|
return modules
|
|
70
84
|
}
|
|
71
85
|
|