提交 b3cc1654 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat(cli): run method (question/165071)

上级 605d50f8
......@@ -34,4 +34,17 @@ export default {
'When running on Windows to iOS mobile phone, the modification of the uts plugin code needs to be submitted to the cloud to package the custom playground to take effect.',
'uts.ios.standard.tips':
'When the standard playground runs to an IOS phone, the uts plugin is temporarily not supported. If you need to call the uts plugin, please use a custom playground',
'prompt.run.message': 'Run method: open {devtools}, import {outputDir} run.',
'prompt.run.devtools.app': 'HBuilderX',
'prompt.run.devtools.mp-alipay': 'Alipay Mini Program Devtools',
'prompt.run.devtools.mp-baidu': 'Baidu Mini Program Devtools',
'prompt.run.devtools.mp--kuaishou': 'Kuaishou Mini Program Devtools',
'prompt.run.devtools.mp-lark': 'Lark Mini Program Devtools',
'prompt.run.devtools.mp-qq': 'QQ Mini Program Devtools',
'prompt.run.devtools.mp-toutiao': 'ByteDance Mini Program Devtools',
'prompt.run.devtools.mp-weixin': 'Weixin Mini Program Devtools',
'prompt.run.devtools.quickapp-webview':
'Quick App Alliance Devtools | Huawei Quick App Devtools',
'prompt.run.devtools.quickapp-webview-huawei': 'Huawei Quick App Devtools',
'prompt.run.devtools.quickapp-webview-union': 'Quick App Alliance Devtools',
} as const
......@@ -34,4 +34,17 @@ export default {
'iOS手机在windows上使用标准基座真机运行无法使用uts插件,如需使用uts插件请提交云端打包自定义基座',
'uts.ios.standard.tips':
'iOS手机在标准基座真机运行暂不支持uts插件,如需调用uts插件请使用自定义基座',
'prompt.run.message': '运行方式:打开 {devtools}, 导入 {outputDir} 运行。',
'prompt.run.devtools.app': 'HBuilderX',
'prompt.run.devtools.mp-alipay': '支付宝小程序开发者工具',
'prompt.run.devtools.mp-baidu': '百度开发者工具',
'prompt.run.devtools.mp--kuaishou': '快手开发者工具',
'prompt.run.devtools.mp-lark': '飞书开发者工具',
'prompt.run.devtools.mp-qq': 'QQ小程序开发者工具',
'prompt.run.devtools.mp-toutiao': '字节跳动开发者工具',
'prompt.run.devtools.mp-weixin': '微信开发者工具',
'prompt.run.devtools.quickapp-webview':
'快应用联盟开发者工具 | 华为快应用开发者工具',
'prompt.run.devtools.quickapp-webview-huawei': '华为快应用开发者工具',
'prompt.run.devtools.quickapp-webview-union': '快应用联盟开发者工具',
} as const
......@@ -10,7 +10,12 @@ import {
import { CliOptions } from '.'
import { build, buildSSR } from './build'
import { createServer, createSSRServer } from './server'
import { initEnv, printStartupDuration } from './utils'
import {
type PLATFORM,
initEnv,
printStartupDuration,
showRunPrompt,
} from './utils'
import { initEasycom } from '../utils/easycom'
export async function runDev(options: CliOptions & ServerOptions) {
......@@ -53,6 +58,7 @@ export async function runDev(options: CliOptions & ServerOptions) {
}
isFirstEnd = false
output('log', M['dev.watching.end'])
showRunPrompt(options.platform as PLATFORM)
printStartupDuration(createLogger(options.logLevel), false)
if (process.env.UNI_UTS_ERRORS) {
console.error(process.env.UNI_UTS_ERRORS)
......@@ -116,6 +122,9 @@ export async function runBuild(options: CliOptions & BuildOptions) {
? buildSSR(options)
: build(options))
console.log(M['build.done'])
if (options.platform !== 'h5') {
showRunPrompt(options.platform as PLATFORM)
}
} catch (e: any) {
console.error(`Build failed with errors.`)
process.exit(1)
......
......@@ -11,6 +11,7 @@ import {
initModulePaths,
parseScripts,
getPlatformDir,
output,
} from '@dcloudio/uni-cli-shared'
import { CliOptions } from '.'
......@@ -30,6 +31,19 @@ export const PLATFORMS = [
'quickapp-webview-union',
]
export type PLATFORM =
| 'app'
| 'mp-alipay'
| 'mp-baidu'
| 'mp-kuaishou'
| 'mp-lark'
| 'mp-qq'
| 'mp-toutiao'
| 'mp-weixin'
| 'quickapp-webview'
| 'quickapp-webview-huawei'
| 'quickapp-webview-union'
function resolveConfigFile() {
const viteConfigJs = path.resolve(process.env.UNI_INPUT_DIR, 'vite.config.js')
const viteConfigTs = path.resolve(process.env.UNI_INPUT_DIR, 'vite.config.ts')
......@@ -301,3 +315,30 @@ function initCustomScripts(options: CliOptions) {
process.env.UNI_CUSTOM_DEFINE = JSON.stringify(custom.define)
process.env.UNI_CUSTOM_CONTEXT = JSON.stringify(custom.context)
}
export function showRunPrompt(platform: PLATFORM) {
if (!isInHBuilderX()) {
const devtools = getPlatformDevtools(getOriginalPlatform(platform))
const outputDir = path.relative(
process.env.UNI_CLI_CONTEXT,
process.env.UNI_OUTPUT_DIR
)
output(
'log',
`${M['prompt.run.message']
.replace('{devtools}', M[devtools])
.replace('{outputDir}', colors.cyan(outputDir))}`
)
}
}
function getOriginalPlatform(platform: PLATFORM) {
if (platform.startsWith('quickapp-webview') && process.env.UNI_SUB_PLATFORM) {
return process.env.UNI_SUB_PLATFORM
}
return platform
}
function getPlatformDevtools(platform: PLATFORM) {
return `prompt.run.devtools.${platform}` as keyof typeof M
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册