Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一把秋刀鱼
uni-app
提交
39b5f12a
U
uni-app
项目概览
一把秋刀鱼
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
39b5f12a
编写于
4月 08, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(cli): add invoke
上级
8e55ca87
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
86 addition
and
43 deletion
+86
-43
packages/vue-cli-plugin-uni/bin/uniapp-cli.js
packages/vue-cli-plugin-uni/bin/uniapp-cli.js
+7
-43
packages/vue-cli-plugin-uni/lib/commands/custom.js
packages/vue-cli-plugin-uni/lib/commands/custom.js
+38
-0
packages/vue-cli-plugin-uni/lib/commands/invoke.js
packages/vue-cli-plugin-uni/lib/commands/invoke.js
+41
-0
未找到文件。
packages/vue-cli-plugin-uni/bin/uniapp-cli.js
浏览文件 @
39b5f12a
#!/usr/bin/env node
const
path
=
require
(
'
path
'
)
const
{
error
}
=
require
(
'
@vue/cli-shared-utils
'
)
const
{
initCustomScript
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/package
'
)
const
Service
=
require
(
'
@vue/cli-service
'
)
#!/usr/bin/env node
const
yargsParser
=
require
(
'
yargs-parser
'
)
const
argv
=
yargsParser
(
process
.
argv
.
slice
(
2
))
if
(
argv
.
_
[
0
]
===
'
custom
'
)
{
const
script
=
argv
.
_
[
1
]
if
(
!
script
)
{
console
.
error
(
`请指定 package.json->uni-app->scripts 下的 script 名称`
)
process
.
exit
(
0
)
}
const
scriptOptions
=
initCustomScript
(
script
,
path
.
resolve
(
process
.
cwd
(),
'
package.json
'
))
if
(
scriptOptions
&&
scriptOptions
.
title
)
{
// console.log('>' + scriptOptions.title)
}
const
action
=
argv
.
_
[
0
]
if
(
action
===
'
custom
'
)
{
require
(
'
../lib/commands/custom
'
)(
argv
)
}
else
if
(
action
===
'
invoke
'
)
{
require
(
'
../lib/commands/invoke
'
)(
argv
)
}
else
{
console
.
error
(
`uniapp-cli custom script`
)
process
.
exit
(
0
)
}
// @vue/cli-service/lib/Service.js
const
service
=
new
Service
(
process
.
env
.
VUE_CLI_CONTEXT
||
process
.
cwd
())
const
command
=
(
process
.
env
.
NODE_ENV
===
'
development
'
&&
process
.
env
.
UNI_PLATFORM
===
'
h5
'
)
?
'
uni-serve
'
:
'
uni-build
'
service
.
run
(
command
,
{
watch
:
process
.
env
.
NODE_ENV
===
'
development
'
,
minimize
:
process
.
env
.
UNI_MINIMIZE
===
'
true
'
,
clean
:
false
}).
catch
(
err
=>
{
error
(
err
)
process
.
exit
(
1
)
})
}
packages/vue-cli-plugin-uni/lib/commands/custom.js
0 → 100644
浏览文件 @
39b5f12a
const
path
=
require
(
'
path
'
)
const
Service
=
require
(
'
@vue/cli-service
'
)
const
{
initCustomScript
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/package
'
)
module
.
exports
=
function
custom
(
argv
)
{
const
script
=
argv
.
_
[
1
]
if
(
!
script
)
{
console
.
error
(
`请指定 package.json->uni-app->scripts 下的 script 名称`
)
process
.
exit
(
0
)
}
const
scriptOptions
=
initCustomScript
(
script
,
path
.
resolve
(
process
.
cwd
(),
'
package.json
'
))
if
(
scriptOptions
&&
scriptOptions
.
title
)
{
// console.log('>' + scriptOptions.title)
}
// @vue/cli-service/lib/Service.js
const
service
=
new
Service
(
process
.
env
.
VUE_CLI_CONTEXT
||
process
.
cwd
())
const
command
=
(
process
.
env
.
NODE_ENV
===
'
development
'
&&
process
.
env
.
UNI_PLATFORM
===
'
h5
'
)
?
'
uni-serve
'
:
'
uni-build
'
service
.
run
(
command
,
{
watch
:
process
.
env
.
NODE_ENV
===
'
development
'
,
minimize
:
process
.
env
.
UNI_MINIMIZE
===
'
true
'
,
clean
:
false
}).
catch
(
err
=>
{
console
.
error
(
err
)
process
.
exit
(
1
)
})
}
packages/vue-cli-plugin-uni/lib/commands/invoke.js
0 → 100644
浏览文件 @
39b5f12a
const
fs
=
require
(
'
fs
'
)
const
path
=
require
(
'
path
'
)
module
.
exports
=
async
function
add
(
argv
)
{
const
pluginName
=
argv
.
_
[
1
]
if
(
!
pluginName
)
{
console
.
error
(
`请指定插件名称`
)
process
.
exit
(
0
)
}
const
pluginPkg
=
require
(
pluginName
+
'
/package.json
'
)
const
options
=
pluginPkg
[
'
uni-app
'
]
if
(
!
options
)
{
console
.
error
(
`插件不合法`
)
process
.
exit
(
0
)
}
const
name
=
options
.
name
if
(
!
name
)
{
console
.
error
(
`插件名称不存在`
)
process
.
exit
(
0
)
}
const
scripts
=
options
.
scripts
||
{
[
'
dev:
'
+
name
]:
`cross-env NODE_ENV=development UNI_PLATFORM=
${
name
}
vue-cli-service uni-build --watch`
,
[
'
build:
'
+
name
]:
`cross-env NODE_ENV=production UNI_PLATFORM=
${
name
}
vue-cli-service uni-build`
}
const
pkgPath
=
path
.
resolve
(
process
.
cwd
(),
'
package.json
'
)
const
pkg
=
require
(
pkgPath
)
if
(
!
pkg
.
scripts
)
{
pkg
.
scripts
=
{}
}
let
changed
=
false
Object
.
keys
(
scripts
).
forEach
(
script
=>
{
if
(
!
pkg
.
scripts
[
script
])
{
changed
=
true
pkg
.
scripts
[
script
]
=
scripts
[
script
]
}
})
if
(
changed
)
{
fs
.
writeFileSync
(
pkgPath
,
JSON
.
stringify
(
pkg
,
null
,
2
))
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录