diff --git a/bin/buildCocos.js b/bin/buildCocos.js index 990bf8a227f4b5078a10e3a2c170c661ce718076..def408487f423cdd73d4cadf48bf895c2e97cce4 100644 --- a/bin/buildCocos.js +++ b/bin/buildCocos.js @@ -227,6 +227,7 @@ function changeSettingsToBundle () { function replaceUuids () { console.log('build_step_0 开始~ï¼'); + const path = 'assets' function getFolderName(path) { let folderName = ''; fs.readdirSync(path).find(fileName => { @@ -237,6 +238,31 @@ function replaceUuids () { }); return folderName; } + const folderName = getFolderName(path); + + let oldFireUuid = ''; + let oldJsUuid = ''; + let oldJsShortUuid = ''; + let oldJsId = ''; + const fireMetaStr = fs.readFileSync(`assets/${folderName}/scene/${folderName}.fire.meta`); + if (fireMetaStr.indexOf('57ea7c61-9b8b-498a-b024-c98ee9124beb') > 0) { + // è€Cocos脚手架 + oldFireUuid = '57ea7c61-9b8b-498a-b024-c98ee9124beb'; + oldJsUuid = 'f4ede462-f8d7-4069-ba80-915611c058ca'; + oldJsShortUuid = 'f4edeRi+NdAabqAkVYRwFjK'; + oldJsId = 'e687yyoRBIzZAOVRL8Sseh'; + } + if (fireMetaStr.indexOf('0737ce42-24f0-45c6-8e1a-8bdab4f74ba3') > 0) { + // æ–°Cocos脚手架 + oldFireUuid = '0737ce42-24f0-45c6-8e1a-8bdab4f74ba3'; + oldJsUuid = '408a67f8-65fa-4cf1-8cf2-83e20e1a0fd5'; + oldJsShortUuid = '408a6f4ZfpM8Yzyg+IOGg/V'; + oldJsId = 'eaTVUpqahPfZeO9+sUI7RP'; + } + if (oldFireUuid === '') { + return; + } + function editFolderMeta(path, folderName) { const metaPath = `${path}/${folderName}.meta`; const metaDataStr = fs.readFileSync(metaPath); @@ -258,19 +284,13 @@ function replaceUuids () { return uuid.substring(0, 5) + Base64.fromUint8Array(bytes).substring(2); } - const path = 'assets' - const folderName = getFolderName(path); editFolderMeta(path, folderName); - 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); - 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);