From ed432a09bca1d8ccf9f007dfac8c958c2578b451 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 1 Jan 2026 15:58:48 +0800 Subject: [PATCH] Refactor repo type handling in download-deps.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor getGitUrl and getNormalizedOrigin functions to handle different repo types more clearly. 目前的版本只支持 git 或者 url+'.git' 不够通用. 不支持 纯https 的 url 形式. 本修改解决了这个问题. 现在可以用下面这种格式的 配置了: ```json { "from": { "type": "https", "url": "https://aaa.bbb/cccc/dddd/eeee/my-external", "checkout": "branch-test" } } ``` ``` --- native/utils/download-deps.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/native/utils/download-deps.js b/native/utils/download-deps.js index d2a1c68a05..d261f3ceef 100644 --- a/native/utils/download-deps.js +++ b/native/utils/download-deps.js @@ -27,7 +27,7 @@ function getCliArgs() { } /** - * + * * @param {string} configPath * @param {string} targetDir */ @@ -78,6 +78,9 @@ async function downloadDepsThroughGit( function getGitUrl(repo) { const origin = getNormalizedOrigin(repo); switch (repo.type) { + case 'ftp': return `${repo.url}`; + case 'http': return `${repo.url}`; + case 'https': return `${repo.url}`; case 'github': return `${origin}${repo.owner}/${repo.name}.git`; case 'gitlab': return `${origin}publics/${repo.name}.git`; default: throwUnknownExternType(); @@ -88,6 +91,9 @@ function getNormalizedOrigin(repo) { let origin = repo.origin; if (origin === undefined) { switch (repo.type) { + case 'ftp': return undefined; + case 'http': return undefined; + case 'https': return undefined; case 'github': origin = 'github.com'; break; case 'gitlab': origin = 'gitlab.cocos.net'; break; default: throwUnknownExternType();