Skip to content

Commit 60b7f96

Browse files
committed
refactor ruby files
1 parent 479acf1 commit 60b7f96

3 files changed

Lines changed: 26 additions & 50 deletions

File tree

packages/react-native/scripts/cocoapods/rncore.rb

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ def add_rncore_dependency(s)
4444
## - RCT_SYMBOLICATE_PREBUILT_FRAMEWORKS: If set to 1, it will download the dSYMs for the prebuilt RNCore frameworks and install these in the framework folders
4545

4646
class ReactNativeCoreUtils
47-
MAVEN_CENTRAL_REPOSITORY = "https://repo1.maven.org/maven2"
48-
REACT_NATIVE_MAVEN_CACHE_REPOSITORY = "https://rnmaven.swmtest.xyz"
49-
5047
@@build_from_source = true
5148
@@react_native_path = ""
5249
@@react_native_version = ""
@@ -373,34 +370,13 @@ def self.stable_tarball_url(version, build_type, dsyms = false)
373370

374371
def self.stable_tarball_urls(version, build_type, dsyms = false)
375372
group = "com/facebook/react"
376-
return maven_repository_urls().map { |maven_repo_url|
373+
return ReactNativePodsUtils.maven_repository_urls().map { |maven_repo_url|
377374
# Sample url from Maven:
378375
# https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.81.0/react-native-artifacts-0.81.0-reactnative-core-debug.tar.gz
379376
"#{maven_repo_url}/#{group}/react-native-artifacts/#{version}/react-native-artifacts-#{version}-reactnative-core-#{dsyms ? "dSYM-" : ""}#{build_type.to_s}.tar.gz"
380377
}
381378
end
382379

383-
def self.maven_repository_urls()
384-
## You can use the `ENTERPRISE_REPOSITORY` variable to customise the base url from which artifacts will be downloaded.
385-
## The mirror's structure must be the same of the Maven repo the react-native core team publishes on Maven Central.
386-
if ENV['ENTERPRISE_REPOSITORY'] != nil && ENV['ENTERPRISE_REPOSITORY'] != ""
387-
return [ENV['ENTERPRISE_REPOSITORY'].delete_suffix("/")]
388-
end
389-
390-
# Keep the React Native Maven cache before Maven Central so cached artifacts are tried first
391-
# and Maven Central remains the fallback.
392-
return react_native_maven_cache_enabled? ?
393-
[REACT_NATIVE_MAVEN_CACHE_REPOSITORY, MAVEN_CENTRAL_REPOSITORY] :
394-
[MAVEN_CENTRAL_REPOSITORY]
395-
end
396-
397-
def self.react_native_maven_cache_enabled?()
398-
value = ENV['RCT_REACT_NATIVE_MAVEN_CACHE_ENABLED']
399-
return true if value == nil || value == ""
400-
401-
value.downcase != "false" && value != "0"
402-
end
403-
404380
def self.nightly_tarball_url(version, configuration, dsyms = false)
405381
artefact_coordinate = "react-native-artifacts"
406382
artefact_name = "reactnative-core-#{dsyms ? "dSYM-" : ""}#{configuration ? configuration : "debug"}.tar.gz"

packages/react-native/scripts/cocoapods/rndependencies.rb

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ def add_rn_third_party_dependencies(s)
5757
end
5858

5959
class ReactNativeDependenciesUtils
60-
MAVEN_CENTRAL_REPOSITORY = "https://repo1.maven.org/maven2"
61-
REACT_NATIVE_MAVEN_CACHE_REPOSITORY = "https://rnmaven.swmtest.xyz"
62-
6360
@@build_from_source = true
6461
@@react_native_path = ""
6562
@@react_native_version = ""
@@ -174,32 +171,11 @@ def self.release_tarball_url(version, build_type)
174171

175172
def self.release_tarball_urls(version, build_type)
176173
group = "com/facebook/react"
177-
return maven_repository_urls().map { |maven_repo_url|
174+
return ReactNativePodsUtils.maven_repository_urls().map { |maven_repo_url|
178175
"#{maven_repo_url}/#{group}/react-native-artifacts/#{version}/react-native-artifacts-#{version}-reactnative-dependencies-#{build_type.to_s}.tar.gz"
179176
}
180177
end
181178

182-
def self.maven_repository_urls()
183-
## You can use the `ENTERPRISE_REPOSITORY` variable to customise the base url from which artifacts will be downloaded.
184-
## The mirror's structure must be the same of the Maven repo the react-native core team publishes on Maven Central.
185-
if ENV['ENTERPRISE_REPOSITORY'] != nil && ENV['ENTERPRISE_REPOSITORY'] != ""
186-
return [ENV['ENTERPRISE_REPOSITORY'].delete_suffix("/")]
187-
end
188-
189-
# Keep the React Native Maven cache before Maven Central so cached artifacts are tried first
190-
# and Maven Central remains the fallback.
191-
return react_native_maven_cache_enabled? ?
192-
[REACT_NATIVE_MAVEN_CACHE_REPOSITORY, MAVEN_CENTRAL_REPOSITORY] :
193-
[MAVEN_CENTRAL_REPOSITORY]
194-
end
195-
196-
def self.react_native_maven_cache_enabled?()
197-
value = ENV['RCT_REACT_NATIVE_MAVEN_CACHE_ENABLED']
198-
return true if value == nil || value == ""
199-
200-
value.downcase != "false" && value != "0"
201-
end
202-
203179
def self.nightly_tarball_url(version, build_type)
204180
artifact_coordinate = "react-native-artifacts"
205181
artifact_name = "reactnative-dependencies-#{build_type.to_s}.tar.gz"

packages/react-native/scripts/cocoapods/utils.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,35 @@
1212

1313
# Utilities class for React Native Cocoapods
1414
class ReactNativePodsUtils
15+
MAVEN_CENTRAL_REPOSITORY = "https://repo1.maven.org/maven2"
16+
REACT_NATIVE_MAVEN_CACHE_REPOSITORY = "https://rnmaven.swmtest.xyz"
17+
1518
# URI::File.build validates path components as ASCII, so escape the filesystem path first.
1619
def self.local_file_uri(path)
1720
URI::File.build(path: URI::DEFAULT_PARSER.escape(path)).to_s
1821
end
1922

23+
def self.maven_repository_urls()
24+
## You can use the `ENTERPRISE_REPOSITORY` variable to customise the base url from which artifacts will be downloaded.
25+
## The mirror's structure must be the same of the Maven repo the react-native core team publishes on Maven Central.
26+
if ENV['ENTERPRISE_REPOSITORY'] != nil && ENV['ENTERPRISE_REPOSITORY'] != ""
27+
return [ENV['ENTERPRISE_REPOSITORY'].delete_suffix("/")]
28+
end
29+
30+
# Keep the React Native Maven cache before Maven Central so cached artifacts are tried first
31+
# and Maven Central remains the fallback.
32+
return react_native_maven_cache_enabled? ?
33+
[REACT_NATIVE_MAVEN_CACHE_REPOSITORY, MAVEN_CENTRAL_REPOSITORY] :
34+
[MAVEN_CENTRAL_REPOSITORY]
35+
end
36+
37+
def self.react_native_maven_cache_enabled?()
38+
value = ENV['RCT_REACT_NATIVE_MAVEN_CACHE_ENABLED']
39+
return true if value == nil || value == ""
40+
41+
value.downcase != "false" && value != "0"
42+
end
43+
2044
def self.warn_if_not_on_arm64
2145
if SysctlChecker.new().call_sysctl_arm64() == 1 && !Environment.new().ruby_platform().include?('arm64')
2246
Pod::UI.warn 'Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64).'

0 commit comments

Comments
 (0)