Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OP08_1
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
OP08_1
Commits
47d35bfa
Commit
47d35bfa
authored
May 26, 2021
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 打包同时打包web_bondle
parent
cf19db04
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
51 deletions
+79
-51
build.sh
publish/build.sh
+12
-2
build_step_3.js
publish/build_step_3.js
+0
-45
build_step_4.js
publish/build_step_4.js
+63
-0
index.html
publish/index.html
+1
-1
package-lock.json
publish/package-lock.json
+3
-3
No files found.
publish/build.sh
View file @
47d35bfa
...
...
@@ -8,8 +8,6 @@ node build_check.js
set
+e
npm
install
cd
../form
npm
install
...
...
@@ -55,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 @
47d35bfa
...
...
@@ -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 @
47d35bfa
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/index.html
View file @
47d35bfa
...
...
@@ -35,7 +35,7 @@
<script
src=
"src/settings.js"
charset=
"utf-8"
></script>
<script
src=
"main.js"
charset=
"utf-8"
></script>
<script
type=
"text/javascript"
src=
"
https:
//staging-teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"
></script>
<script
type=
"text/javascript"
src=
"//staging-teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"
></script>
<script
type=
"text/javascript"
>
...
...
publish/package-lock.json
View file @
47d35bfa
...
...
@@ -5,9 +5,9 @@
"requires"
:
true
,
"dependencies"
:
{
"bl"
:
{
"version"
:
"1.2.
2
"
,
"resolved"
:
"https://registry.npmjs.org/bl/-/bl-1.2.
2
.tgz"
,
"integrity"
:
"sha512-
e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA
=="
,
"version"
:
"1.2.
3
"
,
"resolved"
:
"https://registry.npmjs.org/bl/-/bl-1.2.
3
.tgz"
,
"integrity"
:
"sha512-
pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww
=="
,
"requires"
:
{
"readable-stream"
:
"^2.3.5"
,
"safe-buffer"
:
"^5.1.1"
...
...
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