fix(huawei-push): simplify Jiguang Maven repository injection
Some checks failed
Frontend CI / ota (android) (push) Successful in 1m41s
Frontend CI / ota (ios) (push) Successful in 1m36s
Frontend CI / build-and-push-web (push) Successful in 10m38s
Frontend CI / build-android-apk (push) Failing after 16m7s

Clean up duplicate and malformed Jiguang repo addition code in the Huawei push plugin. The previous implementation had redundant logic for injecting the repository into dependencyResolutionManagement, resulting in duplicate entries and syntax errors. Simplified to directly append the maven URL using the `$&` backreference pattern for cleaner, more maintainable code.
This commit is contained in:
lafay
2026-06-15 23:05:55 +08:00
parent 1012337e57
commit edde8f1c30

View File

@@ -43,31 +43,14 @@ const withHuaweiPush = (config, options = {}) => {
}
}
// Add Jiguang Maven repo for dependency resolution (jcore/jpush SDK)
// Add Jiguang Maven repo to dependencyResolutionManagement (for jcore/jpush SDK)
if (!contents.includes('developer.jiguang.cn/maven')) {
const depMgmtPattern = /dependencyResolutionManagement\s*\{[\s\S]*?repositories\s*\{/;
if (depMgmtPattern.test(config.modResults.contents)) {
config.modResults.contents = config.modResults.contents.replace(
depMgmtPattern,
` if (!contents.includes('developer.huawei.com/repo')) {
const repoLine = ` maven { url 'https://developer.huawei.com/repo/' }`;
const hasPluginManagement = contents.includes('pluginManagement');
const hasRepositoriesInPM = /pluginManagement\s*\{[\s\S]*?repositories\s*\{/.test(contents);
if (hasRepositoriesInPM) {
config.modResults.contents = contents.replace(
/(pluginManagement\s*\{[\s\S]*?repositories\s*\{)/,
`$1\n ${repoLine}`
`$&\n maven { url 'https://developer.jiguang.cn/maven' }`
);
} else if (hasPluginManagement) {
config.modResults.contents = contents.replace(
/(pluginManagement\s*\{)/,
`$1\n repositories {\n gradlePluginPortal()\n google()\n mavenCentral()\n ${repoLine}\n }`
);
} else {
config.modResults.contents =
`pluginManagement {\n repositories {\n ${repoLine}\n }\n}\n\n` +
config.modResults.contents;
}
}
@@ -80,9 +63,6 @@ const withHuaweiPush = (config, options = {}) => {
`$&\n maven { url 'https://developer.huawei.com/repo/' }`
);
}
}\n maven { url 'https://developer.jiguang.cn/maven' }`
);
}
}
return config;