Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
52796372
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
720
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,发现更多精彩内容 >>
提交
52796372
编写于
9月 24, 2021
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
de9eb8cc
faef944f
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
11 addition
and
8 deletion
+11
-8
lib/h5/uni.automator.js
lib/h5/uni.automator.js
+1
-1
packages/uni-app-plus/dist/automator.view.js
packages/uni-app-plus/dist/automator.view.js
+1
-1
packages/uni-app-plus/lib/uni.automator.js
packages/uni-app-plus/lib/uni.automator.js
+1
-1
packages/uni-automator/dist/index.js
packages/uni-automator/dist/index.js
+1
-1
packages/uni-automator/dist/teardown.js
packages/uni-automator/dist/teardown.js
+1
-1
packages/uni-h5/dist/automator.js
packages/uni-h5/dist/automator.js
+1
-1
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+2
-1
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
+3
-1
未找到文件。
lib/h5/uni.automator.js
浏览文件 @
52796372
"
use strict
"
;
function
e
(
e
){
return
e
&&
"
object
"
==
typeof
e
&&
"
default
"
in
e
?
e
.
default
:
e
}
var
t
=
e
(
require
(
"
debug
"
)),
o
=
e
(
require
(
"
p
uppeteer
"
)),
a
=
e
(
require
(
"
postcss-selector-parser
"
));
function
n
(
e
){
e
.
walk
(
e
=>
{
if
(
"
tag
"
===
e
.
type
){
const
t
=
e
.
value
;
e
.
value
=
"
page
"
===
t
?
"
uni-page-body
"
:
"
uni-
"
+
t
}})}
const
s
=
[
"
Page.getElement
"
,
"
Page.getElements
"
,
"
Element.getElement
"
,
"
Element.getElements
"
];
const
c
=
t
(
"
automator:devtool
"
);
let
r
,
l
;
const
i
=
{
"
Tool.close
"
:{
reflect
:
async
()
=>
{
await
r
.
close
()}},
"
App.exit
"
:{
reflect
:
async
()
=>
{}},
"
App.enableLog
"
:{
reflect
:()
=>
Promise
.
resolve
()},
"
App.captureScreenshot
"
:{
reflect
:
async
(
e
,
t
)
=>
{
const
o
=
await
l
.
screenshot
({
encoding
:
"
base64
"
,
fullPage
:
!!
t
.
fullPage
});
return
c
(
"
App.captureScreenshot
"
+
o
.
length
),{
data
:
o
}}}};
!
function
(
e
){
s
.
forEach
(
t
=>
{
e
[
t
]
=
function
(
e
){
return
{
reflect
:
async
(
t
,
o
)
=>
t
(
e
,
o
,
!
1
),
params
:
e
=>
(
e
.
selector
&&
(
e
.
selector
=
a
(
n
).
processSync
(
e
.
selector
)),
e
)}}(
t
)})}(
i
);
const
p
=
{
devtools
:{
name
:
"
google chrome
"
,
paths
:[],
validate
:
async
function
(
e
){
return
e
.
options
=
e
.
options
||
{},
e
.
executablePath
&&!
e
.
options
.
executablePath
&&
(
e
.
options
.
executablePath
=
e
.
executablePath
),
e
.
options
.
defaultViewport
=
Object
.
assign
({
width
:
375
,
height
:
667
,
deviceScaleFactor
:
2
,
hasTouch
:
!
0
,
isMobile
:
!
0
},
e
.
options
.
defaultViewport
||
{}),
e
.
teardown
||
(
e
.
teardown
=!
1
===
e
.
options
.
headless
?
"
disconnect
"
:
"
close
"
),
e
},
create
:
async
function
(
e
,
t
,
a
){
r
=
await
o
.
launch
(
t
.
options
);
const
n
=
r
.
process
();
n
?
c
(
"
%s %o
"
,
n
.
spawnfile
,
t
.
options
):
c
(
"
%o
"
,
t
.
options
),
l
=
await
r
.
newPage
(),
l
.
on
(
"
console
"
,
e
=>
{
a
.
emit
(
"
App.logAdded
"
,{
type
:
e
.
type
(),
args
:[
e
.
text
()]})}),
l
.
on
(
"
pageerror
"
,
e
=>
{
a
.
emit
(
"
App.exceptionThrown
"
,
e
)}),
await
l
.
goto
(
t
.
url
||
e
),
await
l
.
waitFor
(
1
e3
)}},
shouldCompile
:(
e
,
t
)
=>!
t
.
url
,
adapter
:
i
};
module
.
exports
=
p
;
"
use strict
"
;
function
e
(
e
){
return
e
&&
"
object
"
==
typeof
e
&&
"
default
"
in
e
?
e
.
default
:
e
}
var
t
=
e
(
require
(
"
debug
"
)),
o
=
e
(
require
(
"
p
ostcss-selector-parser
"
));
const
n
=
t
(
"
automator:devtool
"
);
function
r
(
e
){
e
.
walk
(
e
=>
{
if
(
"
tag
"
===
e
.
type
){
const
t
=
e
.
value
;
e
.
value
=
"
page
"
===
t
?
"
uni-page-body
"
:
"
uni-
"
+
t
}})}
const
s
=
[
"
Page.getElement
"
,
"
Page.getElements
"
,
"
Element.getElement
"
,
"
Element.getElements
"
];
const
i
=
[
"
chromium
"
,
"
firefox
"
,
"
webkit
"
];
let
a
=!
1
;
try
{
a
=!!
require
(
"
playwright
"
)}
catch
(
e
){}
const
c
=
new
Map
;
function
p
(
e
=
"
chromium
"
){
const
t
=
e
&&
i
.
includes
(
e
)?
e
:
i
[
0
];
let
o
=
c
.
get
(
t
);
return
o
||
(
o
=
function
(
e
){
if
(
"
webkit
"
===
e
)
return
l
(
"
webkit
"
);
if
(
"
firefox
"
===
e
)
return
l
(
"
firefox
"
);
return
a
?
l
(
"
chromium
"
):
function
(){
const
e
=
require
(
"
puppeteer
"
);
let
t
,
o
;
return
{
type
:
"
chromium
"
,
provider
:
"
puppeteer
"
,
async
open
(
r
,
s
,
i
){
t
=
await
e
.
launch
(
s
.
options
);
const
a
=
t
.
process
();
a
?
n
(
"
%s %o
"
,
a
.
spawnfile
,
s
.
options
):
n
(
"
%o
"
,
s
.
options
),
o
=
await
t
.
newPage
(),
o
.
on
(
"
console
"
,
e
=>
{
i
.
emit
(
"
App.logAdded
"
,{
type
:
e
.
type
(),
args
:[
e
.
text
()]})}),
o
.
on
(
"
pageerror
"
,
e
=>
{
i
.
emit
(
"
App.exceptionThrown
"
,
e
)}),
await
o
.
goto
(
s
.
url
||
r
),
await
o
.
waitFor
(
1
e3
)},
close
:()
=>
t
.
close
(),
screenshot
:(
e
=!
1
)
=>
o
.
screenshot
({
encoding
:
"
base64
"
,
fullPage
:
e
})}}()}(
t
),
c
.
set
(
t
,
o
)),
o
}
function
l
(
e
){
const
t
=
require
(
"
playwright
"
);
let
o
,
r
;
return
{
type
:
e
,
provider
:
"
playwright
"
,
async
open
(
s
,
i
,
a
){
o
=
await
t
[
e
].
launch
(
i
.
options
),
"
firefox
"
===
e
&&
(
i
.
contextOptions
.
isMobile
=!
1
),
n
(
"
browser.newContext
"
+
JSON
.
stringify
(
i
.
contextOptions
));
const
c
=
await
o
.
newContext
(
i
.
contextOptions
);
r
=
await
c
.
newPage
(),
r
.
on
(
"
console
"
,
e
=>
{
a
.
emit
(
"
App.logAdded
"
,{
type
:
e
.
type
(),
args
:[
e
.
text
()]})}),
r
.
on
(
"
pageerror
"
,
e
=>
{
a
.
emit
(
"
App.exceptionThrown
"
,
e
)}),
await
r
.
goto
(
i
.
url
||
s
),
await
r
.
waitForTimeout
(
1
e3
)},
close
:()
=>
o
.
close
(),
screenshot
:(
e
=!
1
)
=>
r
.
screenshot
({
fullPage
:
e
}).
then
(
e
=>
e
.
toString
(
"
base64
"
))}}
let
u
;
const
f
=
{
"
Tool.close
"
:{
reflect
:
async
()
=>
{
await
u
.
close
()}},
"
App.exit
"
:{
reflect
:
async
()
=>
{}},
"
App.enableLog
"
:{
reflect
:()
=>
Promise
.
resolve
()},
"
App.captureScreenshot
"
:{
reflect
:
async
(
e
,
t
)
=>
{
const
o
=
await
u
.
screenshot
(
!!
t
.
fullPage
);
return
n
(
"
App.captureScreenshot
"
+
o
.
length
),{
data
:
o
}}}};
!
function
(
e
){
s
.
forEach
(
t
=>
{
e
[
t
]
=
function
(
e
){
return
{
reflect
:
async
(
t
,
o
)
=>
t
(
e
,
o
,
!
1
),
params
:
e
=>
(
e
.
selector
&&
(
e
.
selector
=
o
(
r
).
processSync
(
e
.
selector
)),
e
)}}(
t
)})}(
f
);
const
h
=
{
devtools
:{
name
:
"
browser
"
,
paths
:[],
validate
:
async
function
(
e
){
return
e
.
options
=
e
.
options
||
{},
e
.
executablePath
&&!
e
.
options
.
executablePath
&&
(
e
.
options
.
executablePath
=
e
.
executablePath
),
e
.
contextOptions
=
{
viewport
:
Object
.
assign
({
width
:
375
,
height
:
667
},
e
.
options
.
defaultViewport
||
{}),
hasTouch
:
!
0
,
isMobile
:
!
0
,
deviceScaleFactor
:
2
},
e
.
options
.
defaultViewport
=
Object
.
assign
({
width
:
375
,
height
:
667
,
deviceScaleFactor
:
2
,
hasTouch
:
!
0
,
isMobile
:
!
0
},
e
.
options
.
defaultViewport
||
{}),
e
.
teardown
||
(
e
.
teardown
=!
1
===
e
.
options
.
headless
?
"
disconnect
"
:
"
close
"
),
e
},
create
:
async
function
(
e
,
t
,
o
){
u
=
p
(
process
.
env
.
BROWSER
),
n
(
"
createDevtools
"
+
(
u
.
provider
+
"
"
+
u
.
type
+
"
"
+
JSON
.
stringify
(
t
))),
await
u
.
open
(
e
,
t
,
o
)}},
shouldCompile
:(
e
,
t
)
=>!
t
.
url
,
adapter
:
f
};
module
.
exports
=
h
;
packages/uni-app-plus/dist/automator.view.js
浏览文件 @
52796372
此差异已折叠。
点击以展开。
packages/uni-app-plus/lib/uni.automator.js
浏览文件 @
52796372
"
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
"
)),
r
=
t
(
require
(
"
fs-extra
"
)),
a
=
t
(
require
(
"
licia/dateFormat
"
)),
n
=
require
(
"
path
"
),
o
=
require
(
"
util
"
);
function
l
(
t
){
t
.
walk
(
t
=>
{
if
(
"
tag
"
===
t
.
type
){
const
e
=
t
.
value
;
t
.
value
=
"
page
"
===
e
?
"
body
"
:
"
uni-
"
+
e
}})}
require
(
"
address
"
),
require
(
"
default-gateway
"
),
require
(
"
licia/isStr
"
),
require
(
"
licia/getPort
"
);
const
c
=
[
"
Page.getElement
"
,
"
Page.getElements
"
,
"
Element.getElement
"
,
"
Element.getElements
"
];
require
(
"
qrcode-terminal
"
),
require
(
"
qrcode-reader
"
);
const
h
=
/^win/
.
test
(
process
.
platform
),
u
=
s
(
"
automator:launcher
"
),
p
=
o
.
promisify
(
e
.
readdir
),
d
=
o
.
promisify
(
e
.
stat
);
class
m
{
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
(()
=>
(
u
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
${
this
.
FILE_APP_SERVICE
}
exists`
),
!
1
)).
catch
(()
=>
(
u
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
${
this
.
FILE_APP_SERVICE
}
not exists`
),
!
0
))}
push
(
t
){
return
async
function
t
(
e
){
const
s
=
await
p
(
e
);
return
(
await
Promise
.
all
(
s
.
map
(
async
s
=>
{
const
i
=
n
.
resolve
(
e
,
s
);
return
(
await
d
(
i
)).
isDirectory
()?
t
(
i
):
i
}))).
reduce
((
t
,
e
)
=>
t
.
concat
(
e
),[])}(
t
).
then
(
e
=>
{
const
s
=
e
.
map
(
e
=>
{
const
s
=
(
t
=>
h
?
t
.
replace
(
/
\\
/g
,
"
/
"
):
t
)(
n
.
join
(
this
.
DIR_WWW
,
n
.
relative
(
t
,
e
)));
return
u
(
`
${
a
(
"
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
y
=
s
(
"
automator:simctl
"
);
function
f
(
t
){
const
e
=
parseInt
(
t
);
return
e
>
9
?
String
(
e
):
"
0
"
+
e
}
class
g
extends
m
{
constructor
(){
super
(...
arguments
),
this
.
bundleVersion
=
""
}
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
(),
y
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
init
${
this
.
id
}
`
)}
async
initSDCard
(){
const
t
=
await
this
.
tool
.
appInfo
(
this
.
package
);
y
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
appInfo
${
t
}
`
);
const
e
=
t
.
match
(
/DataContainer
\s
+=
\s
+"
(
.*
)
"/
);
if
(
!
e
)
return
Promise
.
resolve
(
""
);
const
s
=
t
.
match
(
/CFBundleVersion
\s
+=
\s
+
(
.*
)
;/
);
if
(
!
s
)
return
Promise
.
resolve
(
""
);
this
.
sdcard
=
e
[
1
].
replace
(
"
file:
"
,
""
),
this
.
bundleVersion
=
s
[
1
],
y
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
sdcard
}
`
)}
async
version
(){
return
Promise
.
resolve
(
this
.
bundleVersion
)}
formatVersion
(
t
){
const
e
=
t
.
split
(
"
.
"
);
return
3
!==
e
.
length
?
t
:
e
[
0
]
+
f
(
e
[
1
])
+
f
(
e
[
2
])}
async
install
(){
return
y
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
app
}
`
),
await
this
.
tool
.
installApp
(
this
.
app
),
await
this
.
tool
.
grantPermission
(
this
.
package
,
"
all
"
),
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
r
.
existsSync
(
t
)?
Promise
.
resolve
(
!
0
):
Promise
.
reject
(
Error
(
t
+
"
not exists
"
))}
pushFile
(
t
,
e
){
return
Promise
.
resolve
(
r
.
copySync
(
t
,
e
))}
get
DIR_WWW
(){
return
`
${
this
.
sdcard
}
/Documents/Pandora/apps/
${
this
.
appid
}
/www/`
}}
const
w
=
require
(
"
adbkit
"
),
M
=
s
(
"
automator:adb
"
);
class
P
extends
m
{
async
init
(){
if
(
this
.
tool
=
w
.
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
(),
M
(
`
${
a
(
"
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
]:
""
})}
formatVersion
(
t
){
return
t
}
async
install
(){
let
t
=!
0
;
try
{
const
e
=
(
await
this
.
tool
.
getProperties
(
this
.
id
))[
"
ro.build.version.release
"
].
split
(
"
.
"
)[
0
];
parseInt
(
e
)
<
6
&&
(
t
=!
1
)}
catch
(
t
){}
if
(
M
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
app
}
permission=
${
t
}
`
),
t
){
const
t
=
require
(
"
adbkit/lib/adb/command.js
"
),
e
=
t
.
prototype
.
_send
;
t
.
prototype
.
_send
=
function
(
t
){
return
0
===
t
.
indexOf
(
"
shell:pm install -r
"
)
&&
(
t
=
t
.
replace
(
"
shell:pm install -r
"
,
"
shell:pm install -r -g
"
),
M
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
${
t
}
`
)),
e
.
call
(
this
,
t
)}}
return
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
)}
pushFile
(
t
,
e
){
return
this
.
tool
.
push
(
this
.
id
,
t
,
e
)}
shell
(
t
){
return
M
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
SEND ►
${
t
}
`
),
this
.
tool
.
shell
(
this
.
id
,
t
).
then
(
w
.
util
.
readAll
).
then
(
t
=>
{
const
e
=
t
.
toString
();
return
M
(
`
${
a
(
"
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
v
=
s
(
"
automator:devtool
"
);
let
E
,
$
=!
1
;
const
S
=
{
android
:
/android_version=
(
.*
)
/
,
ios
:
/iphone_version=
(
.*
)
/
};
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
v
(
"
App.captureScreenshot
"
+
s
.
length
),{
data
:
s
}}}};
!
function
(
t
){
c
.
forEach
(
e
=>
{
t
[
e
]
=
function
(
t
){
return
{
reflect
:
async
(
e
,
s
)
=>
e
(
t
,
s
,
!
1
),
params
:
t
=>
(
t
.
selector
&&
(
t
.
selector
=
i
(
l
).
processSync
(
t
.
selector
)),
t
)}}(
e
)})}(
A
);
const
_
=
{
devtools
:{
name
:
"
App
"
,
paths
:[],
required
:[
"
manifest.json
"
,
"
app-service.js
"
],
validate
:
async
function
(
t
,
s
){
t
.
platform
=
(
t
.
platform
||
process
.
env
.
UNI_OS_NAME
).
toLocaleLowerCase
(),
Object
.
assign
(
t
,
t
[
t
.
platform
]),
E
=
function
(
t
,
e
){
return
"
ios
"
===
t
?
new
g
(
e
):
new
P
(
e
)}(
t
.
platform
,
t
),
await
E
.
init
();
const
i
=
await
E
.
version
();
if
(
i
){
if
(
t
.
version
){
const
s
=
E
.
formatVersion
(
function
(
t
,
s
){
if
(
t
.
endsWith
(
"
.txt
"
))
try
{
const
i
=
e
.
readFileSync
(
t
).
toString
().
match
(
S
[
s
]);
if
(
i
)
return
i
[
1
]}
catch
(
t
){
console
.
error
(
t
)}
return
t
}(
t
.
version
,
t
.
platform
));
v
(
"
version:
"
+
i
),
v
(
"
newVersion:
"
+
s
),
s
!==
i
&&
(
$
=!
0
)}}
else
$
=!
0
;
if
(
$
){
if
(
!
t
.
executablePath
)
throw
Error
(
`app-plus->
${
t
.
platform
}
->executablePath is not provided`
);
if
(
!
e
.
existsSync
(
t
.
executablePath
))
throw
Error
(
t
.
executablePath
+
"
not exists
"
)}
return
t
},
create
:
async
function
(
t
,
e
,
s
){
$
&&
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
"
)),
r
=
t
(
require
(
"
fs-extra
"
)),
a
=
t
(
require
(
"
licia/dateFormat
"
)),
n
=
require
(
"
path
"
),
o
=
require
(
"
util
"
);
require
(
"
address
"
),
require
(
"
default-gateway
"
),
require
(
"
licia/isStr
"
),
require
(
"
licia/getPort
"
);
s
(
"
automator:devtool
"
);
function
l
(
t
){
t
.
walk
(
t
=>
{
if
(
"
tag
"
===
t
.
type
){
const
e
=
t
.
value
;
t
.
value
=
"
page
"
===
e
?
"
body
"
:
"
uni-
"
+
e
}})}
const
c
=
[
"
Page.getElement
"
,
"
Page.getElements
"
,
"
Element.getElement
"
,
"
Element.getElements
"
];
require
(
"
qrcode-terminal
"
),
require
(
"
qrcode-reader
"
);
const
h
=
/^win/
.
test
(
process
.
platform
),
u
=
s
(
"
automator:launcher
"
),
d
=
o
.
promisify
(
e
.
readdir
),
p
=
o
.
promisify
(
e
.
stat
);
class
m
{
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
(()
=>
(
u
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
${
this
.
FILE_APP_SERVICE
}
exists`
),
!
1
)).
catch
(()
=>
(
u
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
${
this
.
FILE_APP_SERVICE
}
not exists`
),
!
0
))}
push
(
t
){
return
async
function
t
(
e
){
const
s
=
await
d
(
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
=
(
t
=>
h
?
t
.
replace
(
/
\\
/g
,
"
/
"
):
t
)(
n
.
join
(
this
.
DIR_WWW
,
n
.
relative
(
t
,
e
)));
return
u
(
`
${
a
(
"
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
y
=
s
(
"
automator:simctl
"
);
function
f
(
t
){
const
e
=
parseInt
(
t
);
return
e
>
9
?
String
(
e
):
"
0
"
+
e
}
class
g
extends
m
{
constructor
(){
super
(...
arguments
),
this
.
bundleVersion
=
""
}
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
(),
y
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
init
${
this
.
id
}
`
)}
async
initSDCard
(){
const
t
=
await
this
.
tool
.
appInfo
(
this
.
package
);
y
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
appInfo
${
t
}
`
);
const
e
=
t
.
match
(
/DataContainer
\s
+=
\s
+"
(
.*
)
"/
);
if
(
!
e
)
return
Promise
.
resolve
(
""
);
const
s
=
t
.
match
(
/CFBundleVersion
\s
+=
\s
+
(
.*
)
;/
);
if
(
!
s
)
return
Promise
.
resolve
(
""
);
this
.
sdcard
=
e
[
1
].
replace
(
"
file:
"
,
""
),
this
.
bundleVersion
=
s
[
1
],
y
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
sdcard
}
`
)}
async
version
(){
return
Promise
.
resolve
(
this
.
bundleVersion
)}
formatVersion
(
t
){
const
e
=
t
.
split
(
"
.
"
);
return
3
!==
e
.
length
?
t
:
e
[
0
]
+
f
(
e
[
1
])
+
f
(
e
[
2
])}
async
install
(){
return
y
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
app
}
`
),
await
this
.
tool
.
installApp
(
this
.
app
),
await
this
.
tool
.
grantPermission
(
this
.
package
,
"
all
"
),
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
r
.
existsSync
(
t
)?
Promise
.
resolve
(
!
0
):
Promise
.
reject
(
Error
(
t
+
"
not exists
"
))}
pushFile
(
t
,
e
){
return
Promise
.
resolve
(
r
.
copySync
(
t
,
e
))}
get
DIR_WWW
(){
return
`
${
this
.
sdcard
}
/Documents/Pandora/apps/
${
this
.
appid
}
/www/`
}}
const
w
=
require
(
"
adbkit
"
),
M
=
s
(
"
automator:adb
"
);
class
P
extends
m
{
async
init
(){
if
(
this
.
tool
=
w
.
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
(),
M
(
`
${
a
(
"
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
]:
""
})}
formatVersion
(
t
){
return
t
}
async
install
(){
let
t
=!
0
;
try
{
const
e
=
(
await
this
.
tool
.
getProperties
(
this
.
id
))[
"
ro.build.version.release
"
].
split
(
"
.
"
)[
0
];
parseInt
(
e
)
<
6
&&
(
t
=!
1
)}
catch
(
t
){}
if
(
M
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
install
${
this
.
app
}
permission=
${
t
}
`
),
t
){
const
t
=
require
(
"
adbkit/lib/adb/command.js
"
),
e
=
t
.
prototype
.
_send
;
t
.
prototype
.
_send
=
function
(
t
){
return
0
===
t
.
indexOf
(
"
shell:pm install -r
"
)
&&
(
t
=
t
.
replace
(
"
shell:pm install -r
"
,
"
shell:pm install -r -g
"
),
M
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
${
t
}
`
)),
e
.
call
(
this
,
t
)}}
return
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
)}
pushFile
(
t
,
e
){
return
this
.
tool
.
push
(
this
.
id
,
t
,
e
)}
shell
(
t
){
return
M
(
`
${
a
(
"
yyyy-mm-dd HH:MM:ss:l
"
)}
SEND ►
${
t
}
`
),
this
.
tool
.
shell
(
this
.
id
,
t
).
then
(
w
.
util
.
readAll
).
then
(
t
=>
{
const
e
=
t
.
toString
();
return
M
(
`
${
a
(
"
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
v
=
s
(
"
automator:devtool
"
);
let
E
,
$
=!
1
;
const
S
=
{
android
:
/android_version=
(
.*
)
/
,
ios
:
/iphone_version=
(
.*
)
/
};
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
v
(
"
App.captureScreenshot
"
+
s
.
length
),{
data
:
s
}}}};
!
function
(
t
){
c
.
forEach
(
e
=>
{
t
[
e
]
=
function
(
t
){
return
{
reflect
:
async
(
e
,
s
)
=>
e
(
t
,
s
,
!
1
),
params
:
t
=>
(
t
.
selector
&&
(
t
.
selector
=
i
(
l
).
processSync
(
t
.
selector
)),
t
)}}(
e
)})}(
A
);
const
_
=
{
devtools
:{
name
:
"
App
"
,
paths
:[],
required
:[
"
manifest.json
"
,
"
app-service.js
"
],
validate
:
async
function
(
t
,
s
){
t
.
platform
=
(
t
.
platform
||
process
.
env
.
UNI_OS_NAME
).
toLocaleLowerCase
(),
Object
.
assign
(
t
,
t
[
t
.
platform
]),
E
=
function
(
t
,
e
){
return
"
ios
"
===
t
?
new
g
(
e
):
new
P
(
e
)}(
t
.
platform
,
t
),
await
E
.
init
();
const
i
=
await
E
.
version
();
if
(
i
){
if
(
t
.
version
){
const
s
=
E
.
formatVersion
(
function
(
t
,
s
){
if
(
t
.
endsWith
(
"
.txt
"
))
try
{
const
i
=
e
.
readFileSync
(
t
).
toString
().
match
(
S
[
s
]);
if
(
i
)
return
i
[
1
]}
catch
(
t
){
console
.
error
(
t
)}
return
t
}(
t
.
version
,
t
.
platform
));
v
(
"
version:
"
+
i
),
v
(
"
newVersion:
"
+
s
),
s
!==
i
&&
(
$
=!
0
)}}
else
$
=!
0
;
if
(
$
){
if
(
!
t
.
executablePath
)
throw
Error
(
`app-plus->
${
t
.
platform
}
->executablePath is not provided`
);
if
(
!
e
.
existsSync
(
t
.
executablePath
))
throw
Error
(
t
.
executablePath
+
"
not exists
"
)}
return
t
},
create
:
async
function
(
t
,
e
,
s
){
$
&&
await
E
.
install
(),(
$
||
s
.
compiled
||
await
E
.
shouldPush
())
&&
await
E
.
push
(
t
),
await
E
.
start
()}},
adapter
:
A
};
module
.
exports
=
_
;
packages/uni-automator/dist/index.js
浏览文件 @
52796372
此差异已折叠。
点击以展开。
packages/uni-automator/dist/teardown.js
浏览文件 @
52796372
"
use strict
"
;
module
.
exports
=
async
function
(){
const
e
=
global
.
program
;
e
&&
e
.
teardown
(),
await
new
Promise
(
e
=>
{
setTimeout
(()
=>
{
e
(
)},
3
e3
)})};
"
use strict
"
;
module
.
exports
=
async
function
(){
const
o
=
global
.
program
;
o
&&
o
.
teardown
(),
await
new
Promise
(
o
=>
{
setTimeout
(()
=>
{
o
(
void
0
)},
3
e3
)})};
packages/uni-h5/dist/automator.js
浏览文件 @
52796372
此差异已折叠。
点击以展开。
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
52796372
...
...
@@ -23,6 +23,7 @@ const manifestJsonObj = require('@dcloudio/uni-cli-shared/lib/manifest').getMani
process
.
env
.
UNI_APP_ID
=
manifestJsonObj
.
appid
||
''
process
.
env
.
UNI_APP_NAME
=
manifestJsonObj
.
name
||
''
process
.
env
.
UNI_PLATFORM
=
process
.
env
.
UNI_PLATFORM
||
'
h5
'
// 小程序 vue3 标记
if
(
process
.
env
.
UNI_PLATFORM
.
indexOf
(
'
mp-
'
)
===
0
)
{
...
...
@@ -497,4 +498,4 @@ runByHBuilderX && console.log(uniI18n.__('compiling'))
module
.
exports
=
{
manifestPlatformOptions
:
platformOptions
}
}
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
浏览文件 @
52796372
...
...
@@ -95,6 +95,8 @@ function analyzeUsingComponents () {
// }, {})
}
const
parseRequirePath
=
path
=>
/^
[
A-z
]
/
.
test
(
path
)
?
`./
${
path
}
`
:
path
function
normalizeUsingComponents
(
file
,
usingComponents
)
{
const
names
=
Object
.
keys
(
usingComponents
)
if
(
!
names
.
length
)
{
...
...
@@ -102,7 +104,7 @@ function normalizeUsingComponents (file, usingComponents) {
}
file
=
path
.
dirname
(
'
/
'
+
file
)
names
.
forEach
(
name
=>
{
usingComponents
[
name
]
=
normalizePath
(
pa
th
.
relative
(
file
,
usingComponents
[
name
]
))
usingComponents
[
name
]
=
normalizePath
(
pa
rseRequirePath
(
path
.
relative
(
file
,
usingComponents
[
name
])
))
})
return
usingComponents
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录