Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
AK09
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
AK09
Commits
7847f83a
Commit
7847f83a
authored
May 26, 2021
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 打包
parent
72501a45
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
46 deletions
+76
-46
build.sh
publish/build.sh
+12
-0
build_step_3.js
publish/build_step_3.js
+0
-45
build_step_4.js
publish/build_step_4.js
+63
-0
.DS_Store
publish/publish/.DS_Store
+0
-0
config.json
publish/publish/config.json
+1
-1
No files found.
publish/build.sh
View file @
7847f83a
...
...
@@ -53,3 +53,15 @@ cd ../publish
node build_step_3.js
echo
"build_step_3 完成~!"
cd
../play
/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/MacOS/CocosCreator
--path
"./"
--build
"platform=web-desktop;debug=false;buildPath=build_web_desktop"
--force
echo
"生成 web-desktop 完成~!"
cd
../publish
node build_step_4.js
echo
"build_step_4 完成~!"
\ No newline at end of file
publish/build_step_3.js
View file @
7847f83a
...
...
@@ -6,51 +6,6 @@ async function main() {
await
removeDir
(
'
./publish/android
'
);
await
copyDir
(
'
../play/build_android/jsb-link/remote
'
,
'
./publish/android
'
);
await
removeDir
(
'
../play/build_android/jsb-link
'
);
const
bundleData
=
{
ios
:
await
getBundleData
(
'
./publish/ios
'
),
android
:
await
getBundleData
(
'
./publish/android
'
),
}
fs
.
writeFileSync
(
'
./publish/config.json
'
,
JSON
.
stringify
(
bundleData
));
const
tarStream
=
new
compressing
.
zip
.
Stream
();
tarStream
.
addEntry
(
'
./publish/play
'
);
tarStream
.
addEntry
(
'
./publish/form
'
);
tarStream
.
addEntry
(
'
./publish/ios
'
);
tarStream
.
addEntry
(
'
./publish/android
'
);
tarStream
.
addEntry
(
'
./publish/config.json
'
);
const
destStream
=
fs
.
createWriteStream
(
`publish/
${
getReleaseFileName
()}
.zip`
);
tarStream
.
pipe
(
destStream
);
console
.
log
(
'
打包完成!
'
);
}
async
function
getBundleData
(
path
)
{
const
bundleData
=
{
sceneName
:
''
,
version
:
''
,
}
const
paths
=
fs
.
readdirSync
(
path
);
bundleData
.
sceneName
=
paths
[
0
];
const
files
=
fs
.
readdirSync
(
path
+
'
/
'
+
bundleData
.
sceneName
);
files
.
forEach
(
fileName
=>
{
fileName
.
split
(
'
.
'
).
forEach
((
str
,
idx
,
arr
)
=>
{
if
(
str
==
'
config
'
)
{
bundleData
.
version
=
arr
[
idx
+
1
];
}
})
});
return
bundleData
;
}
function
getReleaseFileName
()
{
let
date
=
new
Date
();
let
fileName
=
`Release_
${
date
.
getFullYear
()}${
fix2
(
date
.
getMonth
()
+
1
)}${
fix2
(
date
.
getDate
())}
`
;
fileName
+=
`
${
fix2
(
date
.
getHours
())}
-
${
fix2
(
date
.
getMinutes
())}
-
${
fix2
(
date
.
getSeconds
())}
`
;
return
fileName
;
}
main
();
\ No newline at end of file
publish/build_step_4.js
0 → 100644
View file @
7847f83a
const
{
removeDir
,
copyDir
,
fix2
}
=
require
(
'
./utils
'
);
const
compressing
=
require
(
'
compressing
'
);
let
fs
=
require
(
'
fs
'
);
async
function
main
()
{
await
removeDir
(
'
./publish/web_desktop
'
);
const
projectName
=
await
getBundleName
(
'
../play/build_web_desktop/web-desktop/assets
'
);
await
copyDir
(
`../play/build_web_desktop/web-desktop/assets/
${
projectName
}
`
,
'
./publish/web_desktop
'
);
await
removeDir
(
'
../play/build_web_desktop
'
);
const
bundleData
=
{
ios
:
await
getBundleData
(
'
./publish/ios
'
),
android
:
await
getBundleData
(
'
./publish/android
'
),
}
fs
.
writeFileSync
(
'
./publish/config.json
'
,
JSON
.
stringify
(
bundleData
));
const
tarStream
=
new
compressing
.
zip
.
Stream
();
tarStream
.
addEntry
(
'
./publish/play
'
);
tarStream
.
addEntry
(
'
./publish/form
'
);
tarStream
.
addEntry
(
'
./publish/ios
'
);
tarStream
.
addEntry
(
'
./publish/android
'
);
tarStream
.
addEntry
(
'
./publish/web_desktop
'
);
tarStream
.
addEntry
(
'
./publish/config.json
'
);
const
destStream
=
fs
.
createWriteStream
(
`publish/
${
getReleaseFileName
()}
.zip`
);
tarStream
.
pipe
(
destStream
);
console
.
log
(
'
打包完成!
'
);
}
async
function
getBundleName
(
path
)
{
const
paths
=
fs
.
readdirSync
(
path
);
return
paths
.
find
(
path
=>
path
!=
'
internal
'
&&
path
!=
'
main
'
);
}
async
function
getBundleData
(
path
)
{
const
bundleData
=
{
sceneName
:
''
,
version
:
''
,
}
const
paths
=
fs
.
readdirSync
(
path
);
bundleData
.
sceneName
=
paths
[
0
];
const
files
=
fs
.
readdirSync
(
path
+
'
/
'
+
bundleData
.
sceneName
);
files
.
forEach
(
fileName
=>
{
fileName
.
split
(
'
.
'
).
forEach
((
str
,
idx
,
arr
)
=>
{
if
(
str
==
'
config
'
)
{
bundleData
.
version
=
arr
[
idx
+
1
];
}
})
});
return
bundleData
;
}
function
getReleaseFileName
()
{
let
date
=
new
Date
();
let
fileName
=
`Release_
${
date
.
getFullYear
()}${
fix2
(
date
.
getMonth
()
+
1
)}${
fix2
(
date
.
getDate
())}
`
;
fileName
+=
`
${
fix2
(
date
.
getHours
())}
-
${
fix2
(
date
.
getMinutes
())}
-
${
fix2
(
date
.
getSeconds
())}
`
;
return
fileName
;
}
main
();
\ No newline at end of file
publish/publish/.DS_Store
View file @
7847f83a
No preview for this file type
publish/publish/config.json
View file @
7847f83a
{
"ios"
:{
"sceneName"
:
"AK09"
,
"version"
:
"
"
},
"android"
:{
"sceneName"
:
"AK09"
,
"version"
:
"
"
}}
{
"ios"
:{
"sceneName"
:
"AK09"
,
"version"
:
"
11da0"
},
"android"
:{
"sceneName"
:
"AK09"
,
"version"
:
"11da0
"
}}
\ No newline at end of file
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