mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2025-12-23 22:18:36 -05:00
Added Rubocop; try to bump iOS version number correctly on build
This commit is contained in:
91
.rubocop.yml
Normal file
91
.rubocop.yml
Normal file
@@ -0,0 +1,91 @@
|
||||
AllCops:
|
||||
NewCops: enable
|
||||
|
||||
Layout/ArgumentAlignment:
|
||||
EnforcedStyle: with_fixed_indentation
|
||||
IndentationWidth: 2
|
||||
|
||||
Layout/CaseIndentation:
|
||||
EnforcedStyle: end
|
||||
|
||||
Layout/EndAlignment:
|
||||
EnforcedStyleAlignWith: start_of_line
|
||||
|
||||
Layout/DotPosition:
|
||||
EnforcedStyle: trailing
|
||||
|
||||
Layout/LineEndStringConcatenationIndentation:
|
||||
EnforcedStyle: indented
|
||||
|
||||
Layout/MultilineAssignmentLayout:
|
||||
EnforcedStyle: same_line
|
||||
|
||||
Layout/MultilineMethodCallIndentation:
|
||||
EnforcedStyle: indented
|
||||
|
||||
Layout/MultilineOperationIndentation:
|
||||
EnforcedStyle: indented
|
||||
|
||||
Layout/SpaceInsideBlockBraces:
|
||||
SpaceBeforeBlockParameters: false
|
||||
|
||||
Layout/SpaceAroundBlockParameters:
|
||||
# This is weird, but without it you get a conflict / infinite loop with
|
||||
# SpaceInsideParens
|
||||
EnforcedStyleInsidePipes: space
|
||||
|
||||
Layout/SpaceInsideParens:
|
||||
EnforcedStyle: space
|
||||
|
||||
Lint/NoReturnInBeginEndBlocks:
|
||||
Enabled: false
|
||||
|
||||
Metrics/AbcSize:
|
||||
Enabled: false
|
||||
|
||||
Metrics/BlockLength:
|
||||
Enabled: false
|
||||
|
||||
Metrics/ClassLength:
|
||||
Enabled: false
|
||||
|
||||
Metrics/CyclomaticComplexity:
|
||||
Enabled: false
|
||||
|
||||
Metrics/MethodLength:
|
||||
Enabled: false
|
||||
|
||||
Metrics/ModuleLength:
|
||||
Enabled: false
|
||||
|
||||
Metrics/PerceivedComplexity:
|
||||
Enabled: false
|
||||
|
||||
Naming/AccessorMethodName:
|
||||
Enabled: false
|
||||
|
||||
Naming/VariableNumber:
|
||||
Enabled: false
|
||||
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
Style/IfUnlessModifier:
|
||||
Enabled: false
|
||||
|
||||
Style/PercentLiteralDelimiters:
|
||||
PreferredDelimiters:
|
||||
"%w": "()"
|
||||
|
||||
# Not sure why but this causes some weird failures
|
||||
Style/RedundantSort:
|
||||
Enabled: false
|
||||
|
||||
Style/SymbolArray:
|
||||
Enabled: false
|
||||
|
||||
Style/StringLiterals:
|
||||
EnforcedStyle: double_quotes
|
||||
|
||||
Style/WordArray:
|
||||
Enabled: false
|
||||
10
Gemfile
10
Gemfile
@@ -1,8 +1,10 @@
|
||||
source 'https://rubygems.org'
|
||||
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
|
||||
ruby '>= 2.6.10'
|
||||
# frozen_string_literal: true
|
||||
|
||||
gem 'cocoapods', '>= 1.11.3'
|
||||
source "https://rubygems.org"
|
||||
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
|
||||
ruby ">= 2.6.10"
|
||||
|
||||
gem "cocoapods", ">= 1.11.3"
|
||||
|
||||
gem "fastlane"
|
||||
gem "nokogiri"
|
||||
|
||||
16
Gemfile.lock
16
Gemfile.lock
@@ -9,7 +9,7 @@ GEM
|
||||
minitest (>= 5.1)
|
||||
tzinfo (~> 2.0)
|
||||
zeitwerk (~> 2.3)
|
||||
addressable (2.8.2)
|
||||
addressable (2.8.4)
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
algoliasearch (1.27.5)
|
||||
httpclient (~> 2.8, >= 2.8.3)
|
||||
@@ -17,16 +17,16 @@ GEM
|
||||
artifactory (3.0.15)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.2.0)
|
||||
aws-partitions (1.740.0)
|
||||
aws-partitions (1.759.0)
|
||||
aws-sdk-core (3.171.0)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
aws-partitions (~> 1, >= 1.651.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
aws-sdk-kms (1.63.0)
|
||||
aws-sdk-kms (1.64.0)
|
||||
aws-sdk-core (~> 3, >= 3.165.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sdk-s3 (1.120.0)
|
||||
aws-sdk-s3 (1.121.0)
|
||||
aws-sdk-core (~> 3, >= 3.165.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.4)
|
||||
@@ -116,7 +116,7 @@ GEM
|
||||
faraday_middleware (1.2.0)
|
||||
faraday (~> 1.0)
|
||||
fastimage (2.2.6)
|
||||
fastlane (2.212.1)
|
||||
fastlane (2.212.2)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
addressable (>= 2.8, < 3.0.0)
|
||||
artifactory (~> 3.0)
|
||||
@@ -159,7 +159,7 @@ GEM
|
||||
fourflusher (2.3.1)
|
||||
fuzzy_match (2.0.4)
|
||||
gh_inspector (1.1.3)
|
||||
google-apis-androidpublisher_v3 (0.38.0)
|
||||
google-apis-androidpublisher_v3 (0.41.0)
|
||||
google-apis-core (>= 0.11.0, < 2.a)
|
||||
google-apis-core (0.11.0)
|
||||
addressable (~> 2.5, >= 2.5.1)
|
||||
@@ -190,7 +190,7 @@ GEM
|
||||
google-cloud-core (~> 1.6)
|
||||
googleauth (>= 0.16.2, < 2.a)
|
||||
mini_mime (~> 1.0)
|
||||
googleauth (1.5.0)
|
||||
googleauth (1.5.2)
|
||||
faraday (>= 0.17.3, < 3.a)
|
||||
jwt (>= 1.4, < 3.0)
|
||||
memoist (~> 0.16)
|
||||
@@ -290,4 +290,4 @@ RUBY VERSION
|
||||
ruby 2.7.5p203
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.27
|
||||
2.3.9
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "fileutils"
|
||||
|
||||
appfile_path = File.join( File.expand_path( File.dirname( __FILE__ ) ), "Appfile" )
|
||||
appfile_path = File.join( __dir__, "Appfile" )
|
||||
unless File.exist?( appfile_path )
|
||||
UI.abort_with_message! <<~NO_APPFILE_ERROR.gsub( /\s+/, " " ).strip
|
||||
Could not find #{appfile_path}. Copy the example file in that directory to
|
||||
@@ -8,12 +10,12 @@ unless File.exist?( appfile_path )
|
||||
NO_APPFILE_ERROR
|
||||
end
|
||||
|
||||
VERSION = File.open( "../package.json" ) { | f | JSON.parse( f.read )["version"] }
|
||||
VERSION = File.open( "../package.json" ) {| f | JSON.parse( f.read )["version"] }
|
||||
editor_cmd = [
|
||||
ENV["EDITOR"],
|
||||
`git config core.editor`,
|
||||
`which vi`
|
||||
].map{| e | e.to_s.strip }.detect {| e | !e.empty? }
|
||||
].map {| e | e.to_s.strip }.detect {| e | !e.empty? }
|
||||
if editor_cmd.nil?
|
||||
UI.abort_with_message! <<~NO_EDITOR_ERROR
|
||||
Could not find an editor, not even vi. Set the EDITOR environmental
|
||||
@@ -31,13 +33,13 @@ PACKAGE_ID = CredentialsManager::AppfileConfig.try_fetch_value( :package_name )
|
||||
def set_android_version_code( new_version_code )
|
||||
build_gradle_path = "../android/app/build.gradle"
|
||||
new_gradle = File.read( build_gradle_path ).sub( /versionCode\s+\d+/, "versionCode #{new_version_code}" )
|
||||
File.open( build_gradle_path, "w" ) { | f | f.write( new_gradle ) }
|
||||
File.open( build_gradle_path, "w" ) {| f | f.write( new_gradle ) }
|
||||
end
|
||||
|
||||
def set_android_version_name( new_version_name )
|
||||
def set_android_version_name( _new_version_name )
|
||||
build_gradle_path = "../android/app/build.gradle"
|
||||
new_gradle = File.read( build_gradle_path ).sub( /versionName\s+".+"/, "versionName \"#{VERSION}\"" )
|
||||
File.open( build_gradle_path, "w" ) { | f | f.write( new_gradle ) }
|
||||
File.open( build_gradle_path, "w" ) {| f | f.write( new_gradle ) }
|
||||
end
|
||||
|
||||
def get_changelog_path( build_number = nil )
|
||||
@@ -49,8 +51,8 @@ end
|
||||
|
||||
def get_aab_path( build_number = nil )
|
||||
build_number ||= get_build_number( xcodeproj: XCODEPROJ )
|
||||
aab_path = File.join(
|
||||
File.expand_path( File.dirname( __FILE__ ) ),
|
||||
File.join(
|
||||
__dir__,
|
||||
"..",
|
||||
"android",
|
||||
"app",
|
||||
@@ -64,8 +66,8 @@ end
|
||||
|
||||
def get_apk_path( build_number = nil )
|
||||
build_number ||= get_build_number( xcodeproj: XCODEPROJ )
|
||||
aab_path = File.join(
|
||||
File.expand_path( File.dirname( __FILE__ ) ),
|
||||
File.join(
|
||||
__dir__,
|
||||
"..",
|
||||
"android",
|
||||
"app",
|
||||
@@ -79,8 +81,8 @@ end
|
||||
|
||||
def get_ipa_path( build_number = nil )
|
||||
build_number ||= get_build_number( xcodeproj: XCODEPROJ )
|
||||
aab_path = File.join(
|
||||
File.expand_path( File.dirname( __FILE__ ) ),
|
||||
File.join(
|
||||
__dir__,
|
||||
"..",
|
||||
"ios",
|
||||
"build",
|
||||
@@ -94,6 +96,7 @@ lane :tag do
|
||||
last_tag = last_git_tag
|
||||
# Increment the iOS build number
|
||||
increment_build_number( xcodeproj: XCODEPROJ )
|
||||
increment_version_number( version_number: VERSION )
|
||||
build_number = get_build_number( xcodeproj: XCODEPROJ )
|
||||
# set android/app/build.gradle versionCode to this build_number
|
||||
set_android_version_code( build_number )
|
||||
@@ -127,7 +130,7 @@ lane :tag do
|
||||
end
|
||||
release_notes.strip!
|
||||
FileUtils.rm( fname )
|
||||
if release_notes.strip.size == 0
|
||||
if release_notes.strip.size.zero?
|
||||
reset_git_repo skip_clean: true
|
||||
UI.abort_with_message! "You gotta enter release notes!"
|
||||
end
|
||||
@@ -145,10 +148,14 @@ lane :tag do
|
||||
git_add( path: changelog_git_path )
|
||||
|
||||
# commit
|
||||
commit_version_bump( message: tag, xcodeproj: XCODEPROJ, include: [
|
||||
"android/app/build.gradle",
|
||||
changelog_git_path
|
||||
] )
|
||||
commit_version_bump(
|
||||
message: tag,
|
||||
xcodeproj: XCODEPROJ,
|
||||
include: [
|
||||
"android/app/build.gradle",
|
||||
changelog_git_path
|
||||
]
|
||||
)
|
||||
push_to_git_remote
|
||||
|
||||
# Create a tag for this release
|
||||
@@ -160,7 +167,7 @@ platform :android do
|
||||
lane :build do
|
||||
desc "Build release files for Android"
|
||||
keystore_properties_path = File.join(
|
||||
File.expand_path( File.dirname( __FILE__ ) ),
|
||||
__dir__,
|
||||
"..",
|
||||
"android",
|
||||
"keystore.properties"
|
||||
@@ -291,14 +298,18 @@ lane :release do
|
||||
)
|
||||
|
||||
if github_release
|
||||
UI.important "Release already exists at #{github_release["url"]}. You need to manually upload any missing assets."
|
||||
UI.important "Release already exists at #{github_release['url']}. You need to manually upload any missing assets."
|
||||
else
|
||||
set_github_release(
|
||||
repository_name: "inaturalist/iNaturalistReactNative",
|
||||
api_token: ENV["GITHUB_TOKEN"],
|
||||
name: last_tag,
|
||||
tag_name: last_tag,
|
||||
description: ( File.read( changelog_path ) rescue nil ),
|
||||
description: begin
|
||||
File.read( changelog_path )
|
||||
rescue StandardError
|
||||
nil
|
||||
end,
|
||||
# This is really just a fallback in case last_tag isn't really a tag
|
||||
commitish: "main",
|
||||
upload_assets: [apk_path]
|
||||
@@ -312,7 +323,9 @@ lane :internal do
|
||||
# Ensure build files exist for the latest tag
|
||||
aab_path = get_aab_path
|
||||
unless File.exist?( aab_path )
|
||||
UI.abort_with_message! "AAB does not exist at #{aab_path}. You may need to run the release lane before making a beta"
|
||||
UI.abort_with_message! <<~MSG
|
||||
AAB does not exist at #{aab_path}. You may need to run the release lane before making a beta
|
||||
MSG
|
||||
end
|
||||
last_tag = last_git_tag
|
||||
if last_tag.nil? || last_tag.empty?
|
||||
@@ -370,4 +383,3 @@ lane :prod do
|
||||
# been able to test that yet
|
||||
upload_to_play_store( version_code: build_number, track: "beta", track_promote_to: "production" )
|
||||
end
|
||||
|
||||
|
||||
97
ios/Podfile
97
ios/Podfile
@@ -1,5 +1,7 @@
|
||||
require_relative '../node_modules/react-native/scripts/react_native_pods'
|
||||
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative "../node_modules/react-native/scripts/react_native_pods"
|
||||
require_relative "../node_modules/@react-native-community/cli-platform-ios/native_modules"
|
||||
|
||||
platform :ios, min_ios_version_supported
|
||||
prepare_react_native_project!
|
||||
@@ -13,61 +15,61 @@ prepare_react_native_project!
|
||||
# dependencies: {
|
||||
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
|
||||
# ```
|
||||
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
|
||||
# flipper_config = ENV["NO_FLIPPER"] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
|
||||
|
||||
linkage = ENV['USE_FRAMEWORKS']
|
||||
if linkage != nil
|
||||
linkage = ENV["USE_FRAMEWORKS"]
|
||||
unless linkage.nil?
|
||||
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
|
||||
use_frameworks! :linkage => linkage.to_sym
|
||||
use_frameworks! linkage: linkage.to_sym
|
||||
end
|
||||
|
||||
target 'iNaturalistReactNative' do
|
||||
target "iNaturalistReactNative" do
|
||||
config = use_native_modules!
|
||||
|
||||
# Flags change depending on the env values.
|
||||
flags = get_default_flags()
|
||||
flags = get_default_flags
|
||||
|
||||
permissions_path = '../node_modules/react-native-permissions/ios'
|
||||
permissions_path = "../node_modules/react-native-permissions/ios"
|
||||
|
||||
use_react_native!(
|
||||
:path => config[:reactNativePath],
|
||||
path: config[:reactNativePath],
|
||||
# Hermes is now enabled by default. Disable by setting this flag to false.
|
||||
# Upcoming versions of React Native may rely on get_default_flags(), but
|
||||
# we make it explicit here to aid in the React Native upgrade process.
|
||||
:hermes_enabled => flags[:hermes_enabled],
|
||||
:fabric_enabled => flags[:fabric_enabled],
|
||||
hermes_enabled: flags[:hermes_enabled],
|
||||
fabric_enabled: flags[:fabric_enabled],
|
||||
# Enables Flipper.
|
||||
#
|
||||
# Note that if you have use_frameworks! enabled, Flipper will not work and
|
||||
# you should disable the next line.
|
||||
# :flipper_configuration => flipper_config,
|
||||
# An absolute path to your application root.
|
||||
:app_path => "#{Pod::Config.instance.installation_root}/.."
|
||||
app_path: "#{Pod::Config.instance.installation_root}/.."
|
||||
)
|
||||
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi', :modular_headers => true
|
||||
pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
|
||||
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
|
||||
pod "React-jsi", path: "../node_modules/react-native/ReactCommon/jsi", modular_headers: true
|
||||
pod "Permission-LocationWhenInUse", path: "#{permissions_path}/LocationWhenInUse"
|
||||
pod "Permission-PhotoLibrary", path: "#{permissions_path}/PhotoLibrary"
|
||||
|
||||
pod 'react-native-config', :path => '../node_modules/react-native-config'
|
||||
pod "react-native-config", path: "../node_modules/react-native-config"
|
||||
|
||||
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
|
||||
pod "RNVectorIcons", path: "../node_modules/react-native-vector-icons"
|
||||
|
||||
ENVFILES = {
|
||||
'Debug' => '$(PODS_ROOT)/../../.env.staging',
|
||||
'Release' => '$(PODS_ROOT)/../../.env',
|
||||
}
|
||||
envfiles = {
|
||||
"Debug" => "$(PODS_ROOT)/../../.env.staging",
|
||||
"Release" => "$(PODS_ROOT)/../../.env"
|
||||
}.freeze
|
||||
|
||||
post_install do |installer|
|
||||
post_install do | installer |
|
||||
# use different .env files for staging and production
|
||||
# https://github.com/luggit/react-native-config#ios-1
|
||||
installer.pods_project.targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
installer.pods_project.targets.each do | target |
|
||||
target.build_configurations.each do | build_config |
|
||||
# the following two lines allow the app to build with XCode 14.3 RC
|
||||
# https://stackoverflow.com/questions/72729591/fbreactnativespec-h-error-after-upgrading-from-0-68-x-to-0-69-0/74487309#74487309
|
||||
config.build_settings['SWIFT_VERSION'] = '5.0'
|
||||
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
|
||||
if target.name == 'react-native-config'
|
||||
config.build_settings['ENVFILE'] = ENVFILES[config.name]
|
||||
build_config.build_settings["SWIFT_VERSION"] = "5.0"
|
||||
build_config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] = "12.4"
|
||||
if target.name == "react-native-config"
|
||||
build_config.build_settings["ENVFILE"] = envfiles[build_config.name]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -77,38 +79,39 @@ target 'iNaturalistReactNative' do
|
||||
installer,
|
||||
# Set `mac_catalyst_enabled` to `true` in order to apply patches
|
||||
# necessary for Mac Catalyst builds
|
||||
:mac_catalyst_enabled => false
|
||||
mac_catalyst_enabled: false
|
||||
)
|
||||
__apply_Xcode_12_5_M1_post_install_workaround(installer)
|
||||
__apply_Xcode_12_5_M1_post_install_workaround( installer )
|
||||
# Add these lines for Xcode 14 builds
|
||||
installer.generated_projects.each do |project|
|
||||
project.targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
config.build_settings["DEVELOPMENT_TEAM"] = "iNaturalist, LLC"
|
||||
end
|
||||
installer.generated_projects.each do | project |
|
||||
project.targets.each do | target |
|
||||
target.build_configurations.each do | build_config |
|
||||
build_config.build_settings["DEVELOPMENT_TEAM"] = "iNaturalist, LLC"
|
||||
end
|
||||
end
|
||||
end
|
||||
# End of added lines
|
||||
# https://github.com/Agontuk/react-native-geolocation-service/issues/287#issuecomment-980772489
|
||||
installer.pods_project.targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
|
||||
installer.pods_project.targets.each do | target |
|
||||
target.build_configurations.each do | build_config |
|
||||
build_config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
|
||||
# code below appears to be necessary for building pods with XCode 14:
|
||||
# https://github.com/facebook/react-native/issues/34673#issuecomment-1252114414
|
||||
config.build_settings["DEVELOPMENT_TEAM"] = "iNaturalist, LLC"
|
||||
build_config.build_settings["DEVELOPMENT_TEAM"] = "iNaturalist, LLC"
|
||||
end
|
||||
end
|
||||
|
||||
installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
|
||||
target_installation_result.native_target.build_configurations.each do |config|
|
||||
installer.target_installation_results.pod_target_installation_results.each do | _pod_name, inst_result |
|
||||
inst_result.native_target.build_configurations.each do | build_config |
|
||||
# For third party modules who have React-bridging dependency to search correct headers
|
||||
config.build_settings['HEADER_SEARCH_PATHS'] ||= '$(inherited) '
|
||||
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging" '
|
||||
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers" '
|
||||
build_config.build_settings["HEADER_SEARCH_PATHS"] ||= "$(inherited) "
|
||||
build_config.build_settings["HEADER_SEARCH_PATHS"] <<
|
||||
'"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging" '
|
||||
build_config.build_settings["HEADER_SEARCH_PATHS"] <<
|
||||
'"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers" '
|
||||
end
|
||||
end
|
||||
#react_native_post_install(installer)
|
||||
# react_native_post_install(installer)
|
||||
`sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "nokogiri"
|
||||
|
||||
num_cleaned = 0
|
||||
@@ -5,11 +7,13 @@ num_cleaned = 0
|
||||
unless path.end_with?( ".svg" )
|
||||
raise "#{path} is not a .svg file"
|
||||
end
|
||||
|
||||
svg = File.read( path )
|
||||
doc = Nokogiri::XML( svg, &:noblanks )
|
||||
if doc.at( "svg" )["width"].to_i != 24 || doc.at( "svg" )["height"].to_i != 24
|
||||
raise "#{path} is not a 24x24 square"
|
||||
end
|
||||
|
||||
doc.search( "//path" ).each do | path_node |
|
||||
if path_node["fill-rule"] == "evenodd" || path_node["style"] =~ /fill-rule:\s+?evenodd/
|
||||
raise "#{path} has a path with evenodd. They should all have nonzero fill."
|
||||
@@ -17,20 +21,18 @@ num_cleaned = 0
|
||||
end
|
||||
doc.at( "defs" )&.remove
|
||||
if doc.namespaces.include?( "xmlns:sodipodi" )
|
||||
doc.search( "//sodipodi:namedview" ).each do | node |
|
||||
node.remove
|
||||
end
|
||||
doc.search( "//sodipodi:namedview" ).each( &:remove )
|
||||
end
|
||||
doc.traverse do | node |
|
||||
next unless node.respond_to? :attributes
|
||||
node.attributes.each do |key, val|
|
||||
if (
|
||||
|
||||
node.attributes.each do | key, val |
|
||||
next unless
|
||||
val&.namespace&.prefix == "sodipodi" ||
|
||||
val&.namespace&.prefix == "inkscape" ||
|
||||
%w(id style fill).include?( key )
|
||||
)
|
||||
val.remove
|
||||
end
|
||||
val&.namespace&.prefix == "inkscape" ||
|
||||
%w(id style fill).include?( key )
|
||||
|
||||
val.remove
|
||||
end
|
||||
end
|
||||
# doc.at("svg").remove_attribute "xmlns:inkscape"
|
||||
@@ -12,7 +12,7 @@ if ! type react-native-asset > /dev/null; then
|
||||
exit
|
||||
fi
|
||||
|
||||
bundle exec ruby scripts/clean-icon-svgs.rb src/images/icons/*.svg
|
||||
bundle exec ruby scripts/clean_icon_svgs.rb src/images/icons/*.svg
|
||||
|
||||
# Generate the font file and the glyphmap
|
||||
fantasticon src/images/icons/ \
|
||||
|
||||
Reference in New Issue
Block a user