Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xy_camera
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
xy_camera
Commits
37620075
Commit
37620075
authored
Dec 01, 2021
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 替换的文件名
parent
ab89e285
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
13 deletions
+15
-13
buildCocos.js
bin/buildCocos.js
+15
-13
No files found.
bin/buildCocos.js
View file @
37620075
...
...
@@ -223,6 +223,7 @@ function changeSettingsToBundle () {
editFolderMeta
(
path
,
folderName
,
true
);
}
function
replaceUuids
()
{
console
.
log
(
'
build_step_0 开始~!
'
);
...
...
@@ -243,8 +244,6 @@ function replaceUuids () {
metaData
.
isBundle
=
false
;
fs
.
writeFileSync
(
metaPath
,
JSON
.
stringify
(
metaData
));
}
function
fileReplace
(
path
,
replaceStr
,
newStr
)
{
if
(
!
fs
.
existsSync
(
path
))
{
return
;
...
...
@@ -254,26 +253,24 @@ function replaceUuids () {
const
newFileStr
=
fileStr
.
toString
().
replace
(
new
RegExp
(
replaceStr
.
replace
(
/
[
.*+?^${}()|[
\]\\]
/g
,
"
\\
$&
"
),
'
g
'
),
newStr
);
fs
.
writeFileSync
(
path
,
newFileStr
);
}
function
getShortUuid
(
uuid
)
{
const
bytes
=
parse
(
uuid
).
subarray
(
1
);
return
uuid
.
substring
(
0
,
5
)
+
Base64
.
fromUint8Array
(
bytes
).
substring
(
2
);
}
const
path
=
'
assets
'
const
folderName
=
getFolderName
(
path
);
editFolderMeta
(
path
,
folderName
);
const
oldFireUuid
=
'
57ea7c61-9b8b-498a-b024-c98ee9124beb
'
;
const
oldFireUuid
=
'
0737ce42-24f0-45c6-8e1a-8bdab4f74ba3
'
;
const
newFireUuid
=
v4
();
fileReplace
(
`assets/
${
folderName
}
/scene/
${
folderName
}
.fire.meta`
,
oldFireUuid
,
newFireUuid
);
fileReplace
(
`assets/
${
folderName
}
/scene/
${
folderName
}
.fire`
,
oldFireUuid
,
newFireUuid
);
fileReplace
(
'
settings/builder.json
'
,
oldFireUuid
,
newFireUuid
);
function
getShortUuid
(
uuid
)
{
const
bytes
=
parse
(
uuid
).
subarray
(
1
);
return
uuid
.
substring
(
0
,
5
)
+
Base64
.
fromUint8Array
(
bytes
).
substring
(
2
);
}
const
oldJsUuid
=
'
f4ede462-f8d7-4069-ba80-915611c058ca
'
;
const
oldJsShortUuid
=
'
f4edeRi+NdAabqAkVYRwFjK
'
;
const
oldJsId
=
'
e687yyoRBIzZAOVRL8Sseh
'
;
const
oldJsUuid
=
'
408a67f8-65fa-4cf1-8cf2-83e20e1a0fd5
'
;
const
oldJsShortUuid
=
'
408a6f4ZfpM8Yzyg+IOGg/V
'
;
const
oldJsId
=
'
eaTVUpqahPfZeO9+sUI7RP
'
;
const
newJsUuid
=
v4
();
const
newJsShortUuid
=
getShortUuid
(
newJsUuid
);
const
newJsId
=
v4
().
replace
(
/-/g
,
''
).
substring
(
0
,
oldJsId
.
length
);
...
...
@@ -355,9 +352,11 @@ module.exports = {
},
buildAndroid
:
async
function
()
{
// 构建前检查
const
projectName
=
build_check
();
// 替换uuid
replaceUuids
();
// 改设置为bundle
changeSettingsToBundle
();
...
...
@@ -373,8 +372,11 @@ module.exports = {
},
buildIos
:
async
function
()
{
// 构建前检查
const
projectName
=
build_check
();
// 替换uuid
replaceUuids
();
// 改设置为bundle
changeSettingsToBundle
();
...
...
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