Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cake
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
cake
Commits
c349b15f
Commit
c349b15f
authored
3 years ago
by
李帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化完成
parent
05f8ab0c
master
v5
v4
v3
v2
v1
No related merge requests found
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1016 additions
and
2338 deletions
+1016
-2338
cake.meta
assets/cake.meta
+3
-3
cake.fire
assets/cake/scene/cake.fire
+432
-298
cake.ts
assets/cake/scene/cake.ts
+227
-154
cocos_generator.fire
assets/cake/scene/cocos_generator.fire
+0
-1303
cocos_generator.fire.meta
assets/cake/scene/cocos_generator.fire.meta
+0
-7
cocos_generator.ts
assets/cake/scene/cocos_generator.ts
+0
-195
cocos_generator.ts.meta
assets/cake/scene/cocos_generator.ts.meta
+0
-9
test_nice_try.png.meta
assets/cake/textures/切图/test_nice_try.png.meta
+2
-2
buildCocos.js
bin/buildCocos.js
+352
-367
No files found.
assets/cake.meta
View file @
c349b15f
{
{
"ver": "1.1.2",
"ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle":
tru
e,
"isBundle":
fals
e,
"bundleName": "",
"bundleName": "",
"priority": 1,
"priority": 1,
"compressionType": {},
"compressionType": {},
"optimizeHotUpdate": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"isRemoteBundle": {
"ios":
tru
e,
"ios":
fals
e,
"android":
tru
e
"android":
fals
e
},
},
"subMetas": {}
"subMetas": {}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
assets/cake/scene/cake.fire
View file @
c349b15f
This diff is collapsed.
Click to expand it.
assets/cake/scene/cake.ts
View file @
c349b15f
This diff is collapsed.
Click to expand it.
assets/cake/scene/cocos_generator.fire
deleted
100644 → 0
View file @
05f8ab0c
This diff is collapsed.
Click to expand it.
assets/cake/scene/cocos_generator.fire.meta
deleted
100644 → 0
View file @
05f8ab0c
{
"ver": "1.2.9",
"uuid": "0737ce42-24f0-45c6-8e1a-8bdab4f74ba3",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
assets/cake/scene/cocos_generator.ts
deleted
100644 → 0
View file @
05f8ab0c
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
SceneComponent
extends
MyCocosSceneComponent
{
addPreloadImage
()
{
// TODO 根据自己的配置预加载图片资源
this
.
_imageResList
.
push
({
url
:
this
.
data
.
pic_url
});
this
.
_imageResList
.
push
({
url
:
this
.
data
.
pic_url_2
});
}
addPreloadAudio
()
{
// TODO 根据自己的配置预加载音频资源
this
.
_audioResList
.
push
({
url
:
this
.
data
.
audio_url
});
}
addPreloadAnima
()
{
}
onLoadEnd
()
{
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this
.
initData
();
this
.
initView
();
this
.
initListener
();
}
_cantouch
=
null
;
initData
()
{
// 所有全局变量 默认都是null
this
.
_cantouch
=
true
;
}
initView
()
{
this
.
initBg
();
this
.
initPic
();
this
.
initBtn
();
this
.
initIcon
();
}
initBg
()
{
const
bgNode
=
cc
.
find
(
'
Canvas/bg
'
);
bgNode
.
scale
=
this
.
_mapScaleMax
;
}
pic1
=
null
;
pic2
=
null
;
initPic
()
{
const
canvas
=
cc
.
find
(
'
Canvas
'
);
const
maxW
=
canvas
.
width
*
0.7
;
this
.
getSprNodeByUrl
(
this
.
data
.
pic_url
,
(
sprNode
)
=>
{
const
picNode1
=
sprNode
;
picNode1
.
scale
=
maxW
/
picNode1
.
width
;
picNode1
.
baseX
=
picNode1
.
x
;
canvas
.
addChild
(
picNode1
);
this
.
pic1
=
picNode1
;
const
labelNode
=
new
cc
.
Node
();
labelNode
.
color
=
cc
.
Color
.
YELLOW
;
const
label
=
labelNode
.
addComponent
(
cc
.
Label
);
label
.
string
=
this
.
data
.
text
;
label
.
fontSize
=
60
;
label
.
lineHeight
=
60
;
label
.
font
=
cc
.
find
(
'
Canvas/res/font/BRLNSDB
'
).
getComponent
(
'
cc.Label
'
).
font
;
picNode1
.
addChild
(
labelNode
);
});
this
.
getSprNodeByUrl
(
this
.
data
.
pic_url_2
,
(
sprNode
)
=>
{
const
picNode2
=
sprNode
;
picNode2
.
scale
=
maxW
/
picNode2
.
width
;
canvas
.
addChild
(
picNode2
);
picNode2
.
x
=
canvas
.
width
;
picNode2
.
baseX
=
picNode2
.
x
;
this
.
pic2
=
picNode2
;
const
labelNode
=
new
cc
.
Node
();
const
label
=
labelNode
.
addComponent
(
cc
.
RichText
);
const
size
=
60
label
.
font
=
cc
.
find
(
'
Canvas/res/font/BRLNSDB
'
).
getComponent
(
cc
.
Label
).
font
;
label
.
string
=
`<outline color=#751e00 width=4><size=
${
size
}
><color=#ffffff>
${
this
.
data
.
text
}
</color></size></outline>`
label
.
lineHeight
=
size
;
picNode2
.
addChild
(
labelNode
);
});
}
initIcon
()
{
const
iconNode
=
this
.
getSprNode
(
'
icon
'
);
iconNode
.
zIndex
=
5
;
iconNode
.
anchorX
=
1
;
iconNode
.
anchorY
=
1
;
iconNode
.
parent
=
cc
.
find
(
'
Canvas
'
);
iconNode
.
x
=
iconNode
.
parent
.
width
/
2
-
10
;
iconNode
.
y
=
iconNode
.
parent
.
height
/
2
-
10
;
iconNode
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
()
=>
{
this
.
playAudioByUrl
(
this
.
data
.
audio_url
);
})
}
curPage
=
null
;
initBtn
()
{
this
.
curPage
=
0
;
const
bottomPart
=
cc
.
find
(
'
Canvas/bottomPart
'
);
bottomPart
.
zIndex
=
5
;
// 提高层级
bottomPart
.
x
=
bottomPart
.
parent
.
width
/
2
;
bottomPart
.
y
=
-
bottomPart
.
parent
.
height
/
2
;
const
leftBtnNode
=
bottomPart
.
getChildByName
(
'
btn_left
'
);
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode
.
on
(
'
click
'
,
()
=>
{
if
(
!
this
.
_cantouch
)
{
return
;
}
if
(
this
.
curPage
==
0
)
{
return
;
}
this
.
curPage
=
0
this
.
leftMove
();
this
.
playLocalAudio
(
'
btn
'
);
})
const
rightBtnNode
=
bottomPart
.
getChildByName
(
'
btn_right
'
);
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode
.
on
(
'
click
'
,
()
=>
{
if
(
!
this
.
_cantouch
)
{
return
;
}
if
(
this
.
curPage
==
1
)
{
return
;
}
this
.
curPage
=
1
this
.
rightMove
();
// 游戏结束时需要调用这个方法通知系统作业完成
onHomeworkFinish
();
this
.
playLocalAudio
(
'
btn
'
);
})
}
leftMove
()
{
this
.
_cantouch
=
false
;
const
len
=
this
.
pic1
.
parent
.
width
;
cc
.
tween
(
this
.
pic1
)
.
to
(
1
,
{
x
:
this
.
pic1
.
baseX
},
{
easing
:
'
cubicInOut
'
})
.
start
();
cc
.
tween
(
this
.
pic2
)
.
to
(
1
,
{
x
:
this
.
pic2
.
baseX
},
{
easing
:
'
cubicInOut
'
})
.
call
(()
=>
{
this
.
_cantouch
=
true
;
})
.
start
();
}
rightMove
()
{
this
.
_cantouch
=
false
;
const
len
=
this
.
pic1
.
parent
.
width
;
cc
.
tween
(
this
.
pic1
)
.
to
(
1
,
{
x
:
this
.
pic1
.
baseX
-
len
},
{
easing
:
'
cubicInOut
'
})
.
start
();
cc
.
tween
(
this
.
pic2
)
.
to
(
1
,
{
x
:
this
.
pic2
.
baseX
-
len
},
{
easing
:
'
cubicInOut
'
})
.
call
(()
=>
{
this
.
_cantouch
=
true
;
})
.
start
();
}
// update (dt) {},
initListener
()
{
}
playLocalAudio
(
audioName
)
{
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
return
new
Promise
((
resolve
,
reject
)
=>
{
const
id
=
cc
.
audioEngine
.
playEffect
(
audio
.
clip
,
false
);
cc
.
audioEngine
.
setFinishCallback
(
id
,
()
=>
{
resolve
(
id
);
});
})
}
}
This diff is collapsed.
Click to expand it.
assets/cake/scene/cocos_generator.ts.meta
deleted
100644 → 0
View file @
05f8ab0c
{
"ver": "1.0.8",
"uuid": "408a67f8-65fa-4cf1-8cf2-83e20e1a0fd5",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
assets/cake/textures/切图/test_nice_try.png.meta
View file @
c349b15f
...
@@ -4,9 +4,9 @@
...
@@ -4,9 +4,9 @@
"type": "sprite",
"type": "sprite",
"wrapMode": "clamp",
"wrapMode": "clamp",
"filterMode": "bilinear",
"filterMode": "bilinear",
"premultiplyAlpha":
fals
e,
"premultiplyAlpha":
tru
e,
"genMipmaps": false,
"genMipmaps": false,
"packable":
tru
e,
"packable":
fals
e,
"width": 378,
"width": 378,
"height": 192,
"height": 192,
"platformSettings": {},
"platformSettings": {},
...
...
This diff is collapsed.
Click to expand it.
bin/buildCocos.js
View file @
c349b15f
const
{
spawn
}
=
require
(
"
child_process
"
);
const
{
spawn
}
=
require
(
'
child_process
'
);
const
fs
=
require
(
"
fs
"
);
const
fs
=
require
(
'
fs
'
);
const
compressing
=
require
(
'
compressing
'
);
const
compressing
=
require
(
'
compressing
'
);
const
{
v4
,
parse
}
=
require
(
'
uuid
'
);
const
{
v4
,
parse
}
=
require
(
'
uuid
'
);
const
{
Base64
}
=
require
(
'
js-base64
'
);
const
{
Base64
}
=
require
(
'
js-base64
'
);
const
{
copyDir
,
removeDir
,
fix2
}
=
require
(
"
./utils
"
);
const
{
copyDir
,
removeDir
,
fix2
}
=
require
(
'
./utils
'
);
async
function
buildForm
()
{
async
function
buildForm
()
{
const
paths
=
fs
.
readdirSync
(
'
form
'
);
const
paths
=
fs
.
readdirSync
(
'
form
'
);
...
@@ -30,11 +30,7 @@ async function buildForm() {
...
@@ -30,11 +30,7 @@ async function buildForm() {
function
execCmd
(
cmd
,
params
,
path
)
{
function
execCmd
(
cmd
,
params
,
path
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
buffer
=
spawn
(
const
buffer
=
spawn
(
cmd
,
params
,
{
cwd
:
path
});
cmd
,
params
,
{
cwd
:
path
}
);
buffer
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
buffer
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`stdout:
${
data
}
`
);
console
.
log
(
`stdout:
${
data
}
`
);
...
@@ -51,18 +47,13 @@ function execCmd(cmd, params, path) {
...
@@ -51,18 +47,13 @@ function execCmd(cmd, params, path) {
});
});
}
}
let
creatorBasePath
=
'
D:/install/CocosDashboard_1.0.6/resources/.editors/Creator/2.4.5/CocosCreator.exe
'
;
let
creatorBasePath
=
'
CocosCreator
'
;
if
(
process
.
platform
!==
'
win32
'
)
{
if
(
process
.
platform
!==
'
win32
'
)
{
creatorBasePath
=
"
/Applications/CocosCreator/Creator/2.4.5/CocosCreator.app/Contents/MacOS/CocosCreator
"
;
creatorBasePath
=
'
/Applications/CocosCreator/Creator/2.4.5/CocosCreator.app/Contents/MacOS/CocosCreator
'
;
}
}
const
buildCocos
=
function
(
args
)
{
const
buildCocos
=
function
(
args
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
buffer
=
spawn
(
const
buffer
=
spawn
(
creatorBasePath
,
args
,
{
cwd
:
'
.
'
});
creatorBasePath
,
args
,
{
cwd
:
'
.
'
}
);
buffer
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
buffer
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`stdout:
${
data
}
`
);
console
.
log
(
`stdout:
${
data
}
`
);
...
@@ -88,7 +79,7 @@ function getReleaseFileName(projectName) {
...
@@ -88,7 +79,7 @@ function getReleaseFileName(projectName) {
function
getFolderName
(
path
)
{
function
getFolderName
(
path
)
{
let
folderName
=
''
;
let
folderName
=
''
;
fs
.
readdirSync
(
path
).
find
(
fileName
=>
{
fs
.
readdirSync
(
path
).
find
((
fileName
)
=>
{
const
st
=
fs
.
statSync
(
`
${
path
}
/
${
fileName
}
`
);
const
st
=
fs
.
statSync
(
`
${
path
}
/
${
fileName
}
`
);
if
(
st
.
isDirectory
())
{
if
(
st
.
isDirectory
())
{
folderName
=
fileName
;
folderName
=
fileName
;
...
@@ -103,7 +94,7 @@ function editFolderMeta(path, folderName, isBundle) {
...
@@ -103,7 +94,7 @@ function editFolderMeta(path, folderName, isBundle) {
metaData
.
isBundle
=
isBundle
;
metaData
.
isBundle
=
isBundle
;
metaData
.
isRemoteBundle
=
{
metaData
.
isRemoteBundle
=
{
ios
:
isBundle
,
ios
:
isBundle
,
android
:
isBundle
android
:
isBundle
,
};
};
fs
.
writeFileSync
(
metaPath
,
JSON
.
stringify
(
metaData
));
fs
.
writeFileSync
(
metaPath
,
JSON
.
stringify
(
metaData
));
}
}
...
@@ -119,52 +110,52 @@ async function buildAndroidBundle() {
...
@@ -119,52 +110,52 @@ async function buildAndroidBundle() {
}
}
async
function
buildIosBundle
()
{
async
function
buildIosBundle
()
{
const
args
=
[
'
--path
'
,
'
./
'
,
'
--build
'
,
"
platform=ios;debug=false;md5Cache=true;buildPath=build_ios;encryptJs=true;xxteaKey=6bbfce23-28b4-4a;zipCompressJs=true
"
,
'
--force
'
];
const
args
=
[
'
--path
'
,
'
./
'
,
'
--build
'
,
'
platform=ios;debug=false;md5Cache=true;buildPath=build_ios;encryptJs=true;xxteaKey=6bbfce23-28b4-4a;zipCompressJs=true
'
,
'
--force
'
];
await
buildCocos
(
args
);
await
buildCocos
(
args
);
}
}
async
function
buildWebBundle
()
{
async
function
buildWebBundle
()
{
const
args
=
[
'
--path
'
,
'
./
'
,
'
--build
'
,
"
platform=web-desktop;debug=false;buildPath=build_web_desktop
"
,
'
--force
'
];
const
args
=
[
'
--path
'
,
'
./
'
,
'
--build
'
,
'
platform=web-desktop;debug=false;buildPath=build_web_desktop
'
,
'
--force
'
];
await
buildCocos
(
args
);
await
buildCocos
(
args
);
}
}
function
createConfigFile
(
projectName
,
type
)
{
function
createConfigFile
(
projectName
,
type
)
{
let
iosVersion
=
""
;
let
iosVersion
=
''
;
let
androidVersion
=
""
;
let
androidVersion
=
''
;
if
(
!
type
)
{
if
(
!
type
)
{
const
androidPaths
=
fs
.
readdirSync
(
`dist/android/
${
projectName
}
`
);
const
androidPaths
=
fs
.
readdirSync
(
`dist/android/
${
projectName
}
`
);
const
androidConfigFileName
=
androidPaths
.
find
(
path
=>
path
.
indexOf
(
'
config
'
)
==
0
);
const
androidConfigFileName
=
androidPaths
.
find
((
path
)
=>
path
.
indexOf
(
'
config
'
)
==
0
);
androidVersion
=
androidConfigFileName
.
split
(
'
.
'
)[
1
];
androidVersion
=
androidConfigFileName
.
split
(
'
.
'
)[
1
];
const
iosPaths
=
fs
.
readdirSync
(
`dist/ios/
${
projectName
}
`
);
const
iosPaths
=
fs
.
readdirSync
(
`dist/ios/
${
projectName
}
`
);
const
iosConfigFileName
=
iosPaths
.
find
(
path
=>
path
.
indexOf
(
'
config
'
)
==
0
);
const
iosConfigFileName
=
iosPaths
.
find
((
path
)
=>
path
.
indexOf
(
'
config
'
)
==
0
);
iosVersion
=
iosConfigFileName
.
split
(
'
.
'
)[
1
];
iosVersion
=
iosConfigFileName
.
split
(
'
.
'
)[
1
];
}
else
{
}
else
{
if
(
type
==
"
android
"
)
{
if
(
type
==
'
android
'
)
{
const
androidPaths
=
fs
.
readdirSync
(
`dist/android/
${
projectName
}
`
);
const
androidPaths
=
fs
.
readdirSync
(
`dist/android/
${
projectName
}
`
);
const
androidConfigFileName
=
androidPaths
.
find
(
path
=>
path
.
indexOf
(
'
config
'
)
==
0
);
const
androidConfigFileName
=
androidPaths
.
find
((
path
)
=>
path
.
indexOf
(
'
config
'
)
==
0
);
androidVersion
=
androidConfigFileName
.
split
(
'
.
'
)[
1
];
androidVersion
=
androidConfigFileName
.
split
(
'
.
'
)[
1
];
}
else
{
}
else
{
const
iosPaths
=
fs
.
readdirSync
(
`dist/ios/
${
projectName
}
`
);
const
iosPaths
=
fs
.
readdirSync
(
`dist/ios/
${
projectName
}
`
);
const
iosConfigFileName
=
iosPaths
.
find
(
path
=>
path
.
indexOf
(
'
config
'
)
==
0
);
const
iosConfigFileName
=
iosPaths
.
find
((
path
)
=>
path
.
indexOf
(
'
config
'
)
==
0
);
iosVersion
=
iosConfigFileName
.
split
(
'
.
'
)[
1
];
iosVersion
=
iosConfigFileName
.
split
(
'
.
'
)[
1
];
}
}
}
}
const
config
=
{
const
config
=
{
"
ios
"
:
{
ios
:
{
"
sceneName
"
:
projectName
,
sceneName
:
projectName
,
"
version
"
:
iosVersion
version
:
iosVersion
,
},
},
"
android
"
:
{
android
:
{
"
sceneName
"
:
projectName
,
sceneName
:
projectName
,
"
version
"
:
androidVersion
version
:
androidVersion
,
}
},
}
};
fs
.
writeFileSync
(
'
dist/config.json
'
,
JSON
.
stringify
(
config
));
fs
.
writeFileSync
(
'
dist/config.json
'
,
JSON
.
stringify
(
config
));
}
}
function
compressAll
(
projectName
)
{
function
compressAll
(
projectName
)
{
const
tarStream
=
new
compressing
.
zip
.
Stream
();
const
tarStream
=
new
compressing
.
zip
.
Stream
();
tarStream
.
addEntry
(
'
dist/play
'
);
tarStream
.
addEntry
(
'
dist/play
'
);
tarStream
.
addEntry
(
'
dist/form
'
);
tarStream
.
addEntry
(
'
dist/form
'
);
...
@@ -176,12 +167,12 @@ function compressAll (projectName) {
...
@@ -176,12 +167,12 @@ function compressAll (projectName) {
tarStream
.
pipe
(
destStream
);
tarStream
.
pipe
(
destStream
);
}
}
function
build_check
()
{
function
build_check
()
{
const
dirNames
=
process
.
cwd
().
split
(
/
\/
|
\\
/
);
const
dirNames
=
process
.
cwd
().
split
(
/
\/
|
\\
/
);
const
projectName
=
dirNames
[
dirNames
.
length
-
1
];
const
projectName
=
dirNames
[
dirNames
.
length
-
1
];
const
path
=
'
assets
'
const
path
=
'
assets
'
;
let
folderName
=
''
;
let
folderName
=
''
;
fs
.
readdirSync
(
path
).
find
(
fileName
=>
{
fs
.
readdirSync
(
path
).
find
((
fileName
)
=>
{
const
st
=
fs
.
statSync
(
`
${
path
}
/
${
fileName
}
`
);
const
st
=
fs
.
statSync
(
`
${
path
}
/
${
fileName
}
`
);
if
(
st
.
isDirectory
())
{
if
(
st
.
isDirectory
())
{
folderName
=
fileName
;
folderName
=
fileName
;
...
@@ -189,11 +180,11 @@ function build_check () {
...
@@ -189,11 +180,11 @@ function build_check () {
});
});
if
(
projectName
!=
folderName
)
{
if
(
projectName
!=
folderName
)
{
throw
(
`项目名(
${
projectName
}
)与bundle文件夹名(
${
folderName
}
)不相同`
)
;
throw
`项目名(
${
projectName
}
)与bundle文件夹名(
${
folderName
}
)不相同`
;
}
}
let
same
=
false
;
let
same
=
false
;
const
files
=
fs
.
readdirSync
(
`
${
path
}
/
${
folderName
}
/scene`
);
const
files
=
fs
.
readdirSync
(
`
${
path
}
/
${
folderName
}
/scene`
);
files
.
forEach
(
fileName
=>
{
files
.
forEach
((
fileName
)
=>
{
fileName
.
split
(
'
.
'
).
forEach
((
str
,
idx
,
arr
)
=>
{
fileName
.
split
(
'
.
'
).
forEach
((
str
,
idx
,
arr
)
=>
{
if
(
str
==
'
fire
'
)
{
if
(
str
==
'
fire
'
)
{
const
sceneName
=
arr
[
idx
-
1
];
const
sceneName
=
arr
[
idx
-
1
];
...
@@ -201,36 +192,35 @@ function build_check () {
...
@@ -201,36 +192,35 @@ function build_check () {
same
=
true
;
same
=
true
;
}
}
}
}
})
});
});
});
if
(
!
same
)
{
if
(
!
same
)
{
throw
(
`bundle文件夹名称(
${
folderName
}
)与scene名称不相同`
)
;
throw
`bundle文件夹名称(
${
folderName
}
)与scene名称不相同`
;
}
}
return
projectName
;
return
projectName
;
}
}
function
changeSettingToWebDesktop
()
{
function
changeSettingToWebDesktop
()
{
const
path
=
'
assets
'
const
path
=
'
assets
'
;
const
folderName
=
getFolderName
(
path
);
const
folderName
=
getFolderName
(
path
);
editFolderMeta
(
path
,
folderName
,
false
);
editFolderMeta
(
path
,
folderName
,
false
);
}
}
function
changeSettingsToBundle
()
{
function
changeSettingsToBundle
()
{
const
path
=
'
assets
'
const
path
=
'
assets
'
;
const
folderName
=
getFolderName
(
path
);
const
folderName
=
getFolderName
(
path
);
editFolderMeta
(
path
,
folderName
,
true
);
editFolderMeta
(
path
,
folderName
,
true
);
}
}
function
replaceUuids
()
{
function
replaceUuids
()
{
console
.
log
(
'
build_step_0 开始~!
'
);
console
.
log
(
'
build_step_0 开始~!
'
);
const
path
=
'
assets
'
const
path
=
'
assets
'
;
function
getFolderName
(
path
)
{
function
getFolderName
(
path
)
{
let
folderName
=
''
;
let
folderName
=
''
;
fs
.
readdirSync
(
path
).
find
(
fileName
=>
{
fs
.
readdirSync
(
path
).
find
((
fileName
)
=>
{
const
st
=
fs
.
statSync
(
`
${
path
}
/
${
fileName
}
`
);
const
st
=
fs
.
statSync
(
`
${
path
}
/
${
fileName
}
`
);
if
(
st
.
isDirectory
())
{
if
(
st
.
isDirectory
())
{
folderName
=
fileName
;
folderName
=
fileName
;
...
@@ -276,7 +266,7 @@ function replaceUuids () {
...
@@ -276,7 +266,7 @@ function replaceUuids () {
}
}
const
fileStr
=
fs
.
readFileSync
(
path
);
const
fileStr
=
fs
.
readFileSync
(
path
);
const
newFileStr
=
fileStr
.
toString
().
replace
(
new
RegExp
(
replaceStr
.
replace
(
/
[
.*+?^${}()|[
\]\\]
/g
,
"
\\
$&
"
),
'
g
'
),
newStr
);
const
newFileStr
=
fileStr
.
toString
().
replace
(
new
RegExp
(
replaceStr
.
replace
(
/
[
.*+?^${}()|[
\]\\]
/g
,
'
\\
$&
'
),
'
g
'
),
newStr
);
fs
.
writeFileSync
(
path
,
newFileStr
);
fs
.
writeFileSync
(
path
,
newFileStr
);
}
}
function
getShortUuid
(
uuid
)
{
function
getShortUuid
(
uuid
)
{
...
@@ -303,15 +293,13 @@ function replaceUuids () {
...
@@ -303,15 +293,13 @@ function replaceUuids () {
console
.
log
(
'
build_step_0 完成~!
'
);
console
.
log
(
'
build_step_0 完成~!
'
);
}
}
function
replaceIndexHtml
()
{
function
replaceIndexHtml
()
{
const
data
=
fs
.
readFileSync
(
'
index.html
'
);
const
data
=
fs
.
readFileSync
(
'
index.html
'
);
fs
.
writeFileSync
(
'
dist/play/index.html
'
,
data
);
fs
.
writeFileSync
(
'
dist/play/index.html
'
,
data
);
}
}
module
.
exports
=
{
module
.
exports
=
{
build
:
async
function
()
{
build
:
async
function
()
{
const
startTime
=
new
Date
().
getTime
();
const
startTime
=
new
Date
().
getTime
();
// 构建前检查
// 构建前检查
...
@@ -373,7 +361,6 @@ module.exports = {
...
@@ -373,7 +361,6 @@ module.exports = {
},
},
buildAndroid
:
async
function
()
{
buildAndroid
:
async
function
()
{
// 构建前检查
// 构建前检查
const
projectName
=
build_check
();
const
projectName
=
build_check
();
// 替换uuid
// 替换uuid
...
@@ -387,13 +374,12 @@ module.exports = {
...
@@ -387,13 +374,12 @@ module.exports = {
// 改设置为非bundle
// 改设置为非bundle
changeSettingToWebDesktop
();
changeSettingToWebDesktop
();
createConfigFile
(
projectName
,
"
android
"
);
createConfigFile
(
projectName
,
'
android
'
);
await
removeDir
(
'
build_android
'
);
await
removeDir
(
'
build_android
'
);
console
.
log
(
'
构建 android bundle 成功!
'
);
console
.
log
(
'
构建 android bundle 成功!
'
);
},
},
buildIos
:
async
function
()
{
buildIos
:
async
function
()
{
// 构建前检查
// 构建前检查
const
projectName
=
build_check
();
const
projectName
=
build_check
();
// 替换uuid
// 替换uuid
...
@@ -407,9 +393,8 @@ module.exports = {
...
@@ -407,9 +393,8 @@ module.exports = {
// 改设置为非bundle
// 改设置为非bundle
changeSettingToWebDesktop
();
changeSettingToWebDesktop
();
createConfigFile
(
projectName
,
"
ios
"
);
createConfigFile
(
projectName
,
'
ios
'
);
await
removeDir
(
'
build_ios
'
);
await
removeDir
(
'
build_ios
'
);
console
.
log
(
'
构建 ios bundle 成功!
'
);
console
.
log
(
'
构建 ios bundle 成功!
'
);
}
},
};
};
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment