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
f0cb3ba6
Commit
f0cb3ba6
authored
Sep 27, 2021
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 解决脚手架中的scene与js文件的uuid相同的问题
parent
a6251a04
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
14 deletions
+71
-14
build_step_0.js
publish/build_step_0.js
+52
-13
package-lock.json
publish/package-lock.json
+15
-0
package.json
publish/package.json
+4
-1
No files found.
publish/build_step_0.js
View file @
f0cb3ba6
let
fs
=
require
(
'
fs
'
);
const
fs
=
require
(
'
fs
'
);
const
{
v4
,
parse
}
=
require
(
'
uuid
'
);
const
{
Base64
}
=
require
(
'
js-base64
'
);
function
getFolderName
(
path
)
{
let
folderName
=
''
;
fs
.
readdirSync
(
path
).
find
(
fileName
=>
{
const
st
=
fs
.
statSync
(
`
${
path
}
/
${
fileName
}
`
);
if
(
st
.
isDirectory
())
{
folderName
=
fileName
;
}
});
return
folderName
;
}
function
editFolderMeta
(
path
,
folderName
)
{
const
metaPath
=
`
${
path
}
/
${
folderName
}
.meta`
;
const
metaDataStr
=
fs
.
readFileSync
(
metaPath
);
const
metaData
=
JSON
.
parse
(
metaDataStr
);
metaData
.
isBundle
=
false
;
fs
.
writeFileSync
(
metaPath
,
JSON
.
stringify
(
metaData
));
}
function
fileReplace
(
path
,
replaceStr
,
newStr
)
{
const
fileStr
=
fs
.
readFileSync
(
path
);
const
newFileStr
=
fileStr
.
toString
().
replace
(
replaceStr
,
newStr
);
fs
.
writeFileSync
(
path
,
newFileStr
);
}
const
path
=
'
../play/assets
'
const
folderName
=
getFolderName
(
path
);
editFolderMeta
(
path
,
folderName
);
const
oldFireUuid
=
'
57ea7c61-9b8b-498a-b024-c98ee9124beb
'
;
const
newFireUuid
=
v4
();
fileReplace
(
`../play/assets/
${
folderName
}
/scene/
${
folderName
}
.fire.meta`
,
oldFireUuid
,
newFireUuid
);
fileReplace
(
`../play/assets/
${
folderName
}
/scene/
${
folderName
}
.fire`
,
oldFireUuid
,
newFireUuid
);
fileReplace
(
'
../play/settings/builder.json
'
,
oldFireUuid
,
newFireUuid
);
function
getShortUuid
(
uuid
)
{
const
bytes
=
parse
(
uuid
).
subarray
(
1
);
return
uuid
.
substring
(
0
,
5
)
+
Base64
.
fromUint8Array
(
bytes
).
substring
(
2
);
}
let
folderName
=
''
;
fs
.
readdirSync
(
path
).
find
(
fileName
=>
{
const
st
=
fs
.
statSync
(
`
${
path
}
/
${
fileName
}
`
);
if
(
st
.
isDirectory
())
{
folderName
=
fileName
;
}
});
const
metaPath
=
`
${
path
}
/
${
folderName
}
.meta`
;
const
metaDataStr
=
fs
.
readFileSync
(
metaPath
);
const
metaData
=
JSON
.
parse
(
metaDataStr
);
metaData
.
isBundle
=
false
;
fs
.
writeFileSync
(
metaPath
,
JSON
.
stringify
(
metaData
));
const
oldJsUuid
=
'
f4ede462-f8d7-4069-ba80-915611c058ca
'
;
const
oldJsShortUuid
=
'
f4edeRi+NdAabqAkVYRwFjK
'
;
const
oldJsId
=
'
e687yyoRBIzZAOVRL8Sseh
'
;
const
newJsUuid
=
v4
();
const
newJsShortUuid
=
getShortUuid
(
newJsUuid
);
const
newJsId
=
v4
().
replace
(
/-/g
,
''
).
substring
(
0
,
oldJsId
.
length
);
fileReplace
(
`../play/assets/
${
folderName
}
/scene/
${
folderName
}
.js.meta`
,
oldJsUuid
,
newJsUuid
);
fileReplace
(
`../play/assets/
${
folderName
}
/scene/
${
folderName
}
.fire`
,
oldFireUuid
,
newFireUuid
);
fileReplace
(
`../play/assets/
${
folderName
}
/scene/
${
folderName
}
.fire`
,
oldJsShortUuid
,
newJsShortUuid
);
fileReplace
(
`../play/assets/
${
folderName
}
/scene/
${
folderName
}
.fire`
,
oldJsId
,
newJsId
);
publish/package-lock.json
View file @
f0cb3ba6
...
...
@@ -4,6 +4,11 @@
"lockfileVersion"
:
1
,
"requires"
:
true
,
"dependencies"
:
{
"base-64"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npmjs.org/base-64/-/base-64-1.0.0.tgz"
,
"integrity"
:
"sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg=="
},
"bl"
:
{
"version"
:
"1.2.3"
,
"resolved"
:
"https://registry.npmjs.org/bl/-/bl-1.2.3.tgz"
,
...
...
@@ -107,6 +112,11 @@
"resolved"
:
"https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
,
"integrity"
:
"sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"js-base64"
:
{
"version"
:
"3.7.2"
,
"resolved"
:
"https://registry.npmjs.org/js-base64/-/js-base64-3.7.2.tgz"
,
"integrity"
:
"sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ=="
},
"minimist"
:
{
"version"
:
"1.2.5"
,
"resolved"
:
"https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz"
,
...
...
@@ -222,6 +232,11 @@
"resolved"
:
"https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
,
"integrity"
:
"sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"uuid"
:
{
"version"
:
"8.3.2"
,
"resolved"
:
"https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz"
,
"integrity"
:
"sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
},
"wrappy"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz"
,
...
...
publish/package.json
View file @
f0cb3ba6
...
...
@@ -9,6 +9,9 @@
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"compressing"
:
"^1.5.1"
"base-64"
:
"^1.0.0"
,
"compressing"
:
"^1.5.1"
,
"js-base64"
:
"^3.7.2"
,
"uuid"
:
"^8.3.2"
}
}
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