File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /**
2+ * 厂商通道配置工具
3+ */
4+ import { VendorChannelConfig } from '../types' ;
5+
6+ declare global {
7+ var __JPUSH_VENDOR_CHANNELS__ : VendorChannelConfig | undefined ;
8+ }
9+
10+ /**
11+ * 获取当前配置的厂商通道列表
12+ */
13+ export function getVendorChannels ( ) : VendorChannelConfig | undefined {
14+ return globalThis . __JPUSH_VENDOR_CHANNELS__ ;
15+ }
16+
17+ /**
18+ * 获取厂商通道开启状态标记
19+ */
20+ export function getProjectVendorFlags ( ) : Record < string , boolean > {
21+ const channels = getVendorChannels ( ) ;
22+ if ( ! channels ) return { } ;
23+ return Object . fromEntries (
24+ Object . entries ( channels ) . map ( ( [ key , value ] ) => [ key , Boolean ( value ?. enabled ) ] )
25+ ) ;
26+ }
27+
28+ /**
29+ * 旧版本生成标签列表,用于清理旧配置
30+ */
31+ export const LEGACY_PROJECT_BUILD_TAGS = [
32+ 'jpush-buildscript-repositories' ,
33+ 'jpush-buildscript-classpaths' ,
34+ 'jpush-allprojects-repositories' ,
35+ ] ;
36+
37+ /**
38+ * 获取buildscript需要添加的maven仓库配置
39+ */
40+ export function getBuildscriptRepositories ( ) : string {
41+ const flags = getProjectVendorFlags ( ) ;
42+ const repos : string [ ] = [ ] ;
43+ if ( flags . huawei ) {
44+ repos . push ( `maven { url 'https://developer.huawei.com/repo/' }` ) ;
45+ }
46+ if ( flags . honor ) {
47+ repos . push ( `maven { url 'https://developer.hihonor.com/repo' }` ) ;
48+ }
49+ return repos . join ( '\n ' ) ;
50+ }
You can’t perform that action at this time.
0 commit comments