MCPcopy Create free account
hub / github.com/Crain99/cc-reverse / detectProjectVersion

Function detectProjectVersion

src/core/reverseEngine.js:148–336  ·  view source on GitHub ↗

* 检测Cocos Creator项目版本并返回相应的文件路径 * @param {string} sourcePath 源项目路径 * @param {string} versionHint 版本提示 * @returns {Object} 包含版本信息和文件路径的对象

(sourcePath, versionHint)

Source from the content-addressed store, hash-verified

146 ctx.applyGlobals();
147
148 if (!assetsOnly) {
149 logger.info('开始分析代码...');
150 const scriptResult = await codeAnalyzer.analyze(code, {
151 forceFormat: scriptFormat || undefined,
152 noAstFallback,
153 verbose,
154 outputPath,
155 });
156 summary.scripts = {
157 total: scriptResult?.written ?? 0,
158 modules: scriptResult?.modules ?? 0,
159 written: scriptResult?.written ?? 0,
160 failed: scriptResult?.failed ?? 0,
161 format: scriptResult?.format,
162 extractor: scriptResult?.extractor,
163 };
164 } else {
165 summary.scripts = { total: 0, skipped: true };
166 }
167
168 if (!scriptsOnly) {
169 logger.info('开始处理资源...');
170 await resourceProcessor.processResources();
171 summary.assets = {
172 scenes: resourceProcessor.sceneAssets.length,
173 prefabs: resourceProcessor.prefabs.length,
174 sprites: Object.keys(resourceProcessor.spriteFrames).length,
175 audio: resourceProcessor.audio.length,
176 animations: resourceProcessor.animation.length,
177 copies: resourceProcessor.cacheReadList.length,
178 labelAtlas: (resourceProcessor._labelAtlasCount || 0),
179 };
180 } else {
181 summary.assets = { skipped: true };
182 }
183
184 logger.info('生成项目文件...');
185 await projectGenerator.generateProject();
186
187 summary.reportPath = await writeRecoveryReport(outputPath, summary, sourcePath);
188
189 if (!verbose) {
190 await fileManager.cleanDirectory(tempPath);
191 }
192
193 return summary;
194 } catch (err) {
195 logger.error('处理项目文件时出错:', err);
196 throw err;
197 }
198}
199
200/**
201 * 检测Cocos Creator项目版本并返回相应的文件路径
202 * @param {string} sourcePath 源项目路径
203 * @param {string} versionHint 版本提示
204 * @returns {Object}
205 */

Calls 3

buildPathsFunction · 0.85
is3xRootFunction · 0.85
findExistingPathFunction · 0.85

Tested by

no test coverage detected