Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
1a29ff49
U
uni-app
项目概览
DCloud
/
uni-app
4 个月 前同步成功
通知
726
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1a29ff49
编写于
4月 29, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://github.com/dcloudio/uni-app
into alpha
上级
ab3b4a57
bb7070ba
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
packages/uni-app-plus/lib/uni.automator.js
packages/uni-app-plus/lib/uni.automator.js
+1
-1
未找到文件。
packages/uni-app-plus/lib/uni.automator.js
浏览文件 @
1a29ff49
"
use strict
"
;
function
t
(
t
){
return
t
&&
"
object
"
==
typeof
t
&&
"
default
"
in
t
?
t
.
default
:
t
}
var
e
=
t
(
require
(
"
fs
"
)),
s
=
t
(
require
(
"
debug
"
)),
i
=
t
(
require
(
"
postcss-selector-parser
"
)),
a
=
t
(
require
(
"
fs-extra
"
)),
r
=
t
(
require
(
"
licia/dateFormat
"
)),
n
=
require
(
"
path
"
),
o
=
require
(
"
util
"
);
function
c
(
t
){
t
.
walk
(
t
=>
{
if
(
"
tag
"
===
t
.
type
){
const
e
=
t
.
value
;
t
.
value
=
"
page
"
===
e
?
"
body
"
:
"
uni-
"
+
e
}})}
const
l
=
[
"
Page.getElement
"
,
"
Page.getElements
"
,
"
Element.getElement
"
,
"
Element.getElements
"
];
const
h
=
s
(
"
automator:launcher
"
),
u
=
o
.
promisify
(
e
.
readdir
),
p
=
o
.
promisify
(
e
.
stat
);
class
d
{
constructor
(
t
){
this
.
id
=
t
.
id
,
this
.
app
=
t
.
executablePath
,
this
.
appid
=
t
.
appid
||
"
HBuilder
"
,
this
.
package
=
t
.
package
||
"
io.dcloud.HBuilder
"
}
shouldPush
(){
return
this
.
exists
(
this
.
FILE_APP_SERVICE
).
then
(()
=>
(
h
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
${
this
.
FILE_APP_SERVICE
}
exists`
),
!
1
)).
catch
(()
=>
(
h
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
${
this
.
FILE_APP_SERVICE
}
not exists`
),
!
0
))}
push
(
t
){
return
async
function
t
(
e
){
const
s
=
await
u
(
e
);
return
(
await
Promise
.
all
(
s
.
map
(
async
s
=>
{
const
i
=
n
.
resolve
(
e
,
s
);
return
(
await
p
(
i
)).
isDirectory
()?
t
(
i
):
i
}))).
reduce
((
t
,
e
)
=>
t
.
concat
(
e
),[])}(
t
).
then
(
e
=>
{
const
s
=
e
.
map
(
e
=>
{
const
s
=
n
.
join
(
this
.
DIR_WWW
,
n
.
relative
(
t
,
e
));
return
h
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
push
${
e
}
${
s
}
`
),
this
.
pushFile
(
e
,
s
)});
return
Promise
.
all
(
s
)}).
then
(
t
=>!
0
)}
get
FILE_APP_SERVICE
(){
return
this
.
DIR_WWW
+
"
/app-service.js
"
}}
const
m
=
s
(
"
automator:simctl
"
);
class
y
extends
d
{
async
init
(){
const
t
=
require
(
"
node-simctl
"
).
Simctl
;
this
.
tool
=
new
t
({
udid
:
this
.
id
});
try
{
await
this
.
tool
.
bootDevice
()}
catch
(
t
){}
await
this
.
initSDCard
(),
m
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
init
${
this
.
id
}
`
)}
async
initSDCard
(){
const
t
=
(
await
this
.
tool
.
appInfo
(
this
.
package
)).
match
(
/DataContainer
\s
+=
\s
+"
(
.*
)
"/
);
if
(
!
t
)
return
Promise
.
resolve
(
""
);
this
.
sdcard
=
t
[
1
].
replace
(
"
file:
"
,
""
),
m
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
sdcard
}
`
)}
async
version
(){
return
Promise
.
resolve
(
this
.
sdcard
?
"
9.6.96
"
:
""
)}
async
install
(){
return
m
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
app
}
`
),
await
this
.
tool
.
installApp
(
this
.
app
),
await
this
.
initSDCard
(),
Promise
.
resolve
(
!
0
)}
async
start
(){
try
{
await
this
.
tool
.
terminateApp
(
this
.
package
),
await
this
.
tool
.
launchApp
(
this
.
package
)}
catch
(
t
){
console
.
log
(
"
start.......
"
,
t
)}
return
Promise
.
resolve
(
!
0
)}
async
exit
(){
return
await
this
.
tool
.
terminateApp
(
this
.
package
),
await
this
.
tool
.
shutdownDevice
(),
Promise
.
resolve
(
!
0
)}
async
captureScreenshot
(){
return
Promise
.
resolve
(
await
this
.
tool
.
getScreenshot
())}
exists
(
t
){
return
a
.
existsSync
(
t
)?
Promise
.
resolve
(
!
0
):
Promise
.
reject
(
Error
(
t
+
"
not exists
"
))}
pushFile
(
t
,
e
){
return
Promise
.
resolve
(
a
.
copySync
(
t
,
e
))}
get
DIR_WWW
(){
return
`
${
this
.
sdcard
}
/Documents/Pandora/apps/
${
this
.
appid
}
/www/`
}}
const
f
=
require
(
"
adbkit
"
),
w
=
s
(
"
automator:adb
"
);
class
M
extends
d
{
async
init
(){
if
(
this
.
tool
=
f
.
createClient
(),
!
this
.
id
){
const
t
=
await
this
.
tool
.
listDevices
();
if
(
!
t
.
length
)
throw
Error
(
"
Device not found
"
);
this
.
id
=
t
[
0
].
id
}
this
.
sdcard
=
(
await
this
.
shell
(
this
.
COMMAND_EXTERNAL
)).
trim
(),
w
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
init
${
this
.
id
}
${
this
.
sdcard
}
`
)}
version
(){
return
this
.
shell
(
this
.
COMMAND_VERSION
).
then
(
t
=>
{
const
e
=
t
.
match
(
/versionName=
(
.*
)
/
);
return
e
&&
e
.
length
>
1
?
e
[
1
]:
""
})}
install
(){
return
w
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
app
}
`
),
this
.
tool
.
install
(
this
.
id
,
this
.
app
).
then
(()
=>
this
.
init
())}
start
(){
return
this
.
exit
().
then
(()
=>
this
.
shell
(
this
.
COMMAND_START
))}
exit
(){
return
this
.
shell
(
this
.
COMMAND_STOP
)}
captureScreenshot
(){
return
this
.
tool
.
screencap
(
this
.
id
).
then
(
t
=>
new
Promise
(
e
=>
{
const
s
=
[];
t
.
on
(
"
data
"
,(
function
(
t
){
s
.
push
(
t
)})),
t
.
on
(
"
end
"
,(
function
(){
e
(
Buffer
.
concat
(
s
).
toString
(
"
base64
"
))}))}))}
exists
(
t
){
return
this
.
tool
.
stat
(
this
.
id
,
t
).
then
(()
=>!
1
).
catch
(()
=>!
0
)}
pushFile
(
t
,
e
){
return
this
.
tool
.
push
(
this
.
id
,
t
,
e
)}
shell
(
t
){
return
w
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
SEND ►
${
t
}
`
),
this
.
tool
.
shell
(
this
.
id
,
t
).
then
(
f
.
util
.
readAll
).
then
(
t
=>
{
const
e
=
t
.
toString
();
return
w
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
◀ RECV
${
e
}
`
),
e
})}
get
DIR_WWW
(){
return
`
${
this
.
sdcard
}
/Android/data/
${
this
.
package
}
/apps/
${
this
.
appid
}
/www`
}
get
COMMAND_EXTERNAL
(){
return
"
echo $EXTERNAL_STORAGE
"
}
get
COMMAND_VERSION
(){
return
"
dumpsys package
"
+
this
.
package
}
get
COMMAND_STOP
(){
return
"
am force-stop
"
+
this
.
package
}
get
COMMAND_START
(){
return
`am start -n
${
this
.
package
}
/io.dcloud.PandoraEntry --es
${
this
.
appid
}
--ez needUpdateApp false --ez reload true`
}}
const
g
=
s
(
"
automator:devtool
"
);
let
E
,
P
=!
1
;
const
A
=
{
"
Tool.close
"
:{
reflect
:
async
()
=>
{}},
"
App.exit
"
:{
reflect
:
async
()
=>
E
.
exit
()},
"
App.enableLog
"
:{
reflect
:()
=>
Promise
.
resolve
()},
"
App.captureScreenshot
"
:{
reflect
:
async
(
t
,
e
)
=>
{
const
s
=
await
E
.
captureScreenshot
(
e
);
return
g
(
"
App.captureScreenshot
"
+
s
.
length
),{
data
:
s
}}}};
!
function
(
t
){
l
.
forEach
(
e
=>
{
t
[
e
]
=
function
(
t
){
return
{
reflect
:
async
(
e
,
s
)
=>
e
(
t
,
s
,
!
1
),
params
:
t
=>
(
t
.
selector
&&
(
t
.
selector
=
i
(
c
).
processSync
(
t
.
selector
)),
t
)}}(
e
)})}(
A
);
const
$
=
{
devtools
:{
name
:
"
App
"
,
paths
:[],
required
:[
"
manifest.json
"
,
"
app-service.js
"
],
validate
:
async
function
(
t
,
s
){
if
(
t
.
platform
=
(
t
.
platform
||
process
.
env
.
UNI_OS_NAME
).
toLocaleLowerCase
(),
Object
.
assign
(
t
,
t
[
t
.
platform
]),
E
=
function
(
t
,
e
){
return
"
ios
"
===
t
?
new
y
(
e
):
new
M
(
e
)}(
t
.
platform
,
t
),
await
E
.
init
(),
!
await
E
.
version
()){
if
(
!
t
.
executablePath
)
throw
Error
(
`app-plus->
${
t
.
platform
}
->executablePath is not provided`
);
if
(
!
e
.
existsSync
(
t
.
executablePath
))
throw
Error
(
t
.
executablePath
+
"
not exists
"
);
P
=!
0
}
return
t
},
create
:
async
function
(
t
,
e
,
s
){
P
&&
await
E
.
install
(),(
s
.
compiled
||
await
E
.
shouldPush
())
&&
await
E
.
push
(
t
),
await
E
.
start
()}},
adapter
:
A
};
module
.
exports
=
$
;
"
use strict
"
;
function
t
(
t
){
return
t
&&
"
object
"
==
typeof
t
&&
"
default
"
in
t
?
t
.
default
:
t
}
var
e
=
t
(
require
(
"
fs
"
)),
s
=
t
(
require
(
"
debug
"
)),
i
=
t
(
require
(
"
postcss-selector-parser
"
)),
a
=
t
(
require
(
"
fs-extra
"
)),
r
=
t
(
require
(
"
licia/dateFormat
"
)),
n
=
require
(
"
path
"
),
o
=
require
(
"
util
"
);
function
c
(
t
){
t
.
walk
(
t
=>
{
if
(
"
tag
"
===
t
.
type
){
const
e
=
t
.
value
;
t
.
value
=
"
page
"
===
e
?
"
body
"
:
"
uni-
"
+
e
}})}
const
l
=
[
"
Page.getElement
"
,
"
Page.getElements
"
,
"
Element.getElement
"
,
"
Element.getElements
"
];
const
h
=
s
(
"
automator:launcher
"
),
u
=
o
.
promisify
(
e
.
readdir
),
p
=
o
.
promisify
(
e
.
stat
);
class
d
{
constructor
(
t
){
this
.
id
=
t
.
id
,
this
.
app
=
t
.
executablePath
,
this
.
appid
=
t
.
appid
||
"
HBuilder
"
,
this
.
package
=
t
.
package
||
"
io.dcloud.HBuilder
"
}
shouldPush
(){
return
this
.
exists
(
this
.
FILE_APP_SERVICE
).
then
(()
=>
(
h
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
${
this
.
FILE_APP_SERVICE
}
exists`
),
!
1
)).
catch
(()
=>
(
h
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
${
this
.
FILE_APP_SERVICE
}
not exists`
),
!
0
))}
push
(
t
){
return
async
function
t
(
e
){
const
s
=
await
u
(
e
);
return
(
await
Promise
.
all
(
s
.
map
(
async
s
=>
{
const
i
=
n
.
resolve
(
e
,
s
);
return
(
await
p
(
i
)).
isDirectory
()?
t
(
i
):
i
}))).
reduce
((
t
,
e
)
=>
t
.
concat
(
e
),[])}(
t
).
then
(
e
=>
{
const
s
=
e
.
map
(
e
=>
{
const
s
=
n
.
join
(
this
.
DIR_WWW
,
n
.
relative
(
t
,
e
));
return
h
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
push
${
e
}
${
s
}
`
),
this
.
pushFile
(
e
,
s
)});
return
Promise
.
all
(
s
)}).
then
(
t
=>!
0
)}
get
FILE_APP_SERVICE
(){
return
this
.
DIR_WWW
+
"
/app-service.js
"
}}
const
m
=
s
(
"
automator:simctl
"
);
class
y
extends
d
{
async
init
(){
const
t
=
require
(
"
node-simctl
"
).
Simctl
;
this
.
tool
=
new
t
({
udid
:
this
.
id
});
try
{
await
this
.
tool
.
bootDevice
()}
catch
(
t
){}
await
this
.
initSDCard
(),
m
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
init
${
this
.
id
}
`
)}
async
initSDCard
(){
const
t
=
(
await
this
.
tool
.
appInfo
(
this
.
package
)).
match
(
/DataContainer
\s
+=
\s
+"
(
.*
)
"/
);
if
(
!
t
)
return
Promise
.
resolve
(
""
);
this
.
sdcard
=
t
[
1
].
replace
(
"
file:
"
,
""
),
m
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
sdcard
}
`
)}
async
version
(){
return
Promise
.
resolve
(
this
.
sdcard
?
"
9.6.96
"
:
""
)}
async
install
(){
return
m
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
app
}
`
),
await
this
.
tool
.
installApp
(
this
.
app
),
await
this
.
initSDCard
(),
Promise
.
resolve
(
!
0
)}
async
start
(){
try
{
await
this
.
tool
.
terminateApp
(
this
.
package
),
await
this
.
tool
.
launchApp
(
this
.
package
)}
catch
(
t
){
}
return
Promise
.
resolve
(
!
0
)}
async
exit
(){
return
await
this
.
tool
.
terminateApp
(
this
.
package
),
await
this
.
tool
.
shutdownDevice
(),
Promise
.
resolve
(
!
0
)}
async
captureScreenshot
(){
return
Promise
.
resolve
(
await
this
.
tool
.
getScreenshot
())}
exists
(
t
){
return
a
.
existsSync
(
t
)?
Promise
.
resolve
(
!
0
):
Promise
.
reject
(
Error
(
t
+
"
not exists
"
))}
pushFile
(
t
,
e
){
return
Promise
.
resolve
(
a
.
copySync
(
t
,
e
))}
get
DIR_WWW
(){
return
`
${
this
.
sdcard
}
/Documents/Pandora/apps/
${
this
.
appid
}
/www/`
}}
const
f
=
require
(
"
adbkit
"
),
w
=
s
(
"
automator:adb
"
);
class
M
extends
d
{
async
init
(){
if
(
this
.
tool
=
f
.
createClient
(),
!
this
.
id
){
const
t
=
await
this
.
tool
.
listDevices
();
if
(
!
t
.
length
)
throw
Error
(
"
Device not found
"
);
this
.
id
=
t
[
0
].
id
}
this
.
sdcard
=
(
await
this
.
shell
(
this
.
COMMAND_EXTERNAL
)).
trim
(),
w
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
init
${
this
.
id
}
${
this
.
sdcard
}
`
)}
version
(){
return
this
.
shell
(
this
.
COMMAND_VERSION
).
then
(
t
=>
{
const
e
=
t
.
match
(
/versionName=
(
.*
)
/
);
return
e
&&
e
.
length
>
1
?
e
[
1
]:
""
})}
install
(){
return
w
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
app
}
`
),
this
.
tool
.
install
(
this
.
id
,
this
.
app
).
then
(()
=>
this
.
init
())}
start
(){
return
this
.
exit
().
then
(()
=>
this
.
shell
(
this
.
COMMAND_START
))}
exit
(){
return
this
.
shell
(
this
.
COMMAND_STOP
)}
captureScreenshot
(){
return
this
.
tool
.
screencap
(
this
.
id
).
then
(
t
=>
new
Promise
(
e
=>
{
const
s
=
[];
t
.
on
(
"
data
"
,(
function
(
t
){
s
.
push
(
t
)})),
t
.
on
(
"
end
"
,(
function
(){
e
(
Buffer
.
concat
(
s
).
toString
(
"
base64
"
))}))}))}
exists
(
t
){
return
this
.
tool
.
stat
(
this
.
id
,
t
).
then
(()
=>!
1
).
catch
(()
=>!
0
)}
pushFile
(
t
,
e
){
return
this
.
tool
.
push
(
this
.
id
,
t
,
e
)}
shell
(
t
){
return
w
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
SEND ►
${
t
}
`
),
this
.
tool
.
shell
(
this
.
id
,
t
).
then
(
f
.
util
.
readAll
).
then
(
t
=>
{
const
e
=
t
.
toString
();
return
w
(
`
${
r
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
◀ RECV
${
e
}
`
),
e
})}
get
DIR_WWW
(){
return
`
${
this
.
sdcard
}
/Android/data/
${
this
.
package
}
/apps/
${
this
.
appid
}
/www`
}
get
COMMAND_EXTERNAL
(){
return
"
echo $EXTERNAL_STORAGE
"
}
get
COMMAND_VERSION
(){
return
"
dumpsys package
"
+
this
.
package
}
get
COMMAND_STOP
(){
return
"
am force-stop
"
+
this
.
package
}
get
COMMAND_START
(){
return
`am start -n
${
this
.
package
}
/io.dcloud.PandoraEntry --es
${
this
.
appid
}
--ez needUpdateApp false --ez reload true`
}}
const
E
=
s
(
"
automator:devtool
"
);
let
g
,
P
=!
1
;
const
A
=
{
"
Tool.close
"
:{
reflect
:
async
()
=>
{}},
"
App.exit
"
:{
reflect
:
async
()
=>
g
.
exit
()},
"
App.enableLog
"
:{
reflect
:()
=>
Promise
.
resolve
()},
"
App.captureScreenshot
"
:{
reflect
:
async
(
t
,
e
)
=>
{
const
s
=
await
g
.
captureScreenshot
(
e
);
return
E
(
"
App.captureScreenshot
"
+
s
.
length
),{
data
:
s
}}}};
!
function
(
t
){
l
.
forEach
(
e
=>
{
t
[
e
]
=
function
(
t
){
return
{
reflect
:
async
(
e
,
s
)
=>
e
(
t
,
s
,
!
1
),
params
:
t
=>
(
t
.
selector
&&
(
t
.
selector
=
i
(
c
).
processSync
(
t
.
selector
)),
t
)}}(
e
)})}(
A
);
const
$
=
{
devtools
:{
name
:
"
App
"
,
paths
:[],
required
:[
"
manifest.json
"
,
"
app-service.js
"
],
validate
:
async
function
(
t
,
s
){
if
(
t
.
platform
=
(
t
.
platform
||
process
.
env
.
UNI_OS_NAME
).
toLocaleLowerCase
(),
Object
.
assign
(
t
,
t
[
t
.
platform
]),
g
=
function
(
t
,
e
){
return
"
ios
"
===
t
?
new
y
(
e
):
new
M
(
e
)}(
t
.
platform
,
t
),
await
g
.
init
(),
!
await
g
.
version
()){
if
(
!
t
.
executablePath
)
throw
Error
(
`app-plus->
${
t
.
platform
}
->executablePath is not provided`
);
if
(
!
e
.
existsSync
(
t
.
executablePath
))
throw
Error
(
t
.
executablePath
+
"
not exists
"
);
P
=!
0
}
return
t
},
create
:
async
function
(
t
,
e
,
s
){
P
&&
await
g
.
install
(),(
s
.
compiled
||
await
g
.
shouldPush
())
&&
await
g
.
push
(
t
),
await
g
.
start
()}},
adapter
:
A
};
module
.
exports
=
$
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录