emerge 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b51ab2fab1683825f19ebb9be0eb07b7901cb49d194adcfcb3488ebf17440dd
4
- data.tar.gz: cb8d2ead013d712c99e5213a7d4d39cac1b2ad67afa0d51aaed3b06e86a43605
3
+ metadata.gz: fd7bc43fdddfcd51ef2ebe7a5fe44510137974eef76b54bef580fc063adf9154
4
+ data.tar.gz: 5d1dc8515182aa0eebf2db62ebb7f659099c9fc29de9ea70be874146a30d3c88
5
5
  SHA512:
6
- metadata.gz: 1360c8d0acde63b549d69c23468fdd24b7c4a37e399988faec47e88060d9edf7e9abf945657f6deaa4af052c9b9cc307b6f4cd2c5eefe741bc3e9cce4dbff1b0
7
- data.tar.gz: 7c515b04f02ef2c28e9452f9edeb36d62bf4754fe52c0a78b727b202c233a1291d418cab3d341e2eab527afd7fd5ffc77726b2e7af85c46693538fc273cfd3c6
6
+ metadata.gz: '012119f0978a9a996d33e5de12a0aef3b04a996123bbd20aa8fe9cdc0cd5e7763335ee4b3b22d94852ed768de436f50562009e185dfb195ce3bd527028eb4810'
7
+ data.tar.gz: dac2c3e4324c29746d75f689ebc1e4d92f2fcda30c4c30b6cadd79367f0ee4af7c0b465e0a082e6dfdfa886bace6c791bbfec3949aa18645cbde33f881d2300f
@@ -0,0 +1,101 @@
1
+ require 'xcodeproj'
2
+
3
+ module EmergeCLI
4
+ module Commands
5
+ module Config
6
+ class OrderFilesIOS < EmergeCLI::Commands::GlobalOptions
7
+ desc 'Configure order files for iOS'
8
+
9
+ # Optional options
10
+ option :skip_download_script, type: :boolean, required: false, desc: 'Only enable linkmaps'
11
+ option :project_path, type: :string, required: false,
12
+ desc: 'Path to the xcode project (will use first found if not provided)'
13
+
14
+ # Constants
15
+ LINK_MAPS_CONFIG = 'LD_GENERATE_MAP_FILE'.freeze
16
+ LINK_MAPS_PATH = 'LD_MAP_FILE_PATH'.freeze
17
+ PATH_TO_LINKMAP = '$(TARGET_TEMP_DIR)/$(PRODUCT_NAME)-LinkMap-$(CURRENT_VARIANT)-$(CURRENT_ARCH).txt'.freeze
18
+ ORDER_FILE = 'ORDER_FILE'.freeze
19
+ ORDER_FILE_PATH = '$(PROJECT_DIR)/orderfiles/orderfile.txt'.freeze
20
+
21
+ def initialize; end
22
+
23
+ def call(**options)
24
+ @options = options
25
+ before(options)
26
+
27
+ if @options[:project_path]
28
+ project = Xcodeproj::Project.open(@options[:project_path])
29
+ else
30
+ project = Xcodeproj::Project.open(Dir.glob('*.xcodeproj').first)
31
+ Logger.warn 'No project path provided, using first found xcodeproj in current directory'
32
+ end
33
+
34
+ enable_linkmaps(project)
35
+
36
+ add_order_files_download_script(project) unless @options[:skip_download_script]
37
+
38
+ project.save
39
+ end
40
+
41
+ private
42
+
43
+ def enable_linkmaps(project)
44
+ Logger.info 'Enabling Linkmaps'
45
+ project.targets.each do |target|
46
+ # Only do it for app targets
47
+ next unless target.product_type == 'com.apple.product-type.application'
48
+
49
+ Logger.info " Target: #{target.name}"
50
+ target.build_configurations.each do |config|
51
+ config.build_settings[LINK_MAPS_CONFIG] = 'YES'
52
+ config.build_settings[LINK_MAPS_PATH] = PATH_TO_LINKMAP
53
+ end
54
+ end
55
+ end
56
+
57
+ def add_order_files_download_script(project)
58
+ Logger.info 'Adding order files download script'
59
+ project.targets.each do |target|
60
+ # Only do it for app targets
61
+ next unless target.product_type == 'com.apple.product-type.application'
62
+
63
+ Logger.info " Target: #{target.name}"
64
+
65
+ # Create the script phase if it doesn't exist
66
+ phase = target.shell_script_build_phases.find { |item| item.name == 'EmergeTools Download Order Files' }
67
+ if phase.nil?
68
+ Logger.info " Creating script 'EmergeTools Download Order Files'"
69
+ phase = target.new_shell_script_build_phase('EmergeTools Download Order Files')
70
+ phase.shell_script = <<~BASH
71
+ if [ "$CONFIGURATION" != "Release" ]; then
72
+ echo "Skipping script for non-Release build"
73
+ exit 0
74
+ fi
75
+
76
+ if curl --fail "https://order-files-prod.emergetools.com/$PRODUCT_BUNDLE_IDENTIFIER/$MARKETING_VERSION" \
77
+ -H "X-API-Token: $EMERGE_API_TOKEN" -o ORDER_FILE.gz ; then
78
+ mkdir -p "$PROJECT_DIR/orderfiles"
79
+ gunzip -c ORDER_FILE.gz > $PROJECT_DIR/orderfiles/orderfile.txt
80
+ else
81
+ echo "cURL request failed. Creating an empty file."
82
+ mkdir -p "$PROJECT_DIR/orderfiles"
83
+ touch "$PROJECT_DIR/orderfiles/orderfile.txt"
84
+ fi;
85
+ BASH
86
+ phase.output_paths = ['$(PROJECT_DIR)/orderfiles/orderfile.txt']
87
+ else
88
+ Logger.info " 'EmergeTools Download Order Files' already exists"
89
+ end
90
+ # Make sure it is the first build phase
91
+ target.build_phases.move(phase, 0)
92
+
93
+ target.build_configurations.each do |config|
94
+ config.build_settings[ORDER_FILE] = ORDER_FILE_PATH
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,34 @@
1
+ module EmergeCLI
2
+ module Commands
3
+ module Upload
4
+ module ClientLibraries
5
+ class Roborazzi
6
+ def initialize(project_root)
7
+ @project_root = project_root
8
+ end
9
+
10
+ def image_files
11
+ Dir.glob(File.join(@project_root, '**/build/outputs/roborazzi/**/*.png'))
12
+ end
13
+
14
+ def parse_file_info(image_path)
15
+ file_name = image_path.split('build/outputs/roborazzi/').last
16
+ base_name = File.basename(file_name, '.png')
17
+ parts = base_name.split('.')
18
+
19
+ # Get the last two parts regardless of whether there's a package name in the file name
20
+ # For "com.example.MyTest.testName" -> ["MyTest", "testName"]
21
+ # For "MyTest.testName" -> ["MyTest", "testName"]
22
+ relevant_parts = parts.last(2)
23
+
24
+ {
25
+ file_name:,
26
+ group_name: relevant_parts[0],
27
+ variant_name: relevant_parts[1]
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -27,7 +27,7 @@ module EmergeCLI
27
27
  option :pr_number, type: :string, required: false, desc: 'PR number'
28
28
  option :concurrency, type: :integer, default: 5, desc: 'Number of concurrency for parallel uploads'
29
29
 
30
- option :client_library, type: :string, required: false, values: %w[swift-snapshot-testing paparazzi],
30
+ option :client_library, type: :string, required: false, values: %w[swift-snapshot-testing paparazzi roborazzi],
31
31
  desc: 'Client library used for snapshots'
32
32
  option :project_root, type: :string, required: false, desc: 'Path to the project root'
33
33
 
@@ -88,7 +88,7 @@ module EmergeCLI
88
88
 
89
89
  def validate_options(image_paths)
90
90
  if @options[:client_library] && !@options[:project_root]
91
- raise 'Project path is required when using a client library'
91
+ raise 'Project root is required when using a client library'
92
92
  end
93
93
  if @options[:project_root] && !@options[:client_library]
94
94
  raise 'Client library is required when using a project path'
@@ -98,11 +98,17 @@ module EmergeCLI
98
98
  end
99
99
 
100
100
  def create_client(image_paths)
101
- case @options[:client_library]
102
- when 'swift-snapshot-testing'
103
- ClientLibraries::SwiftSnapshotTesting.new(@options[:project_root])
104
- when 'paparazzi'
105
- ClientLibraries::Paparazzi.new(@options[:project_root])
101
+ if @options[:client_library]
102
+ case @options[:client_library]
103
+ when 'swift-snapshot-testing'
104
+ ClientLibraries::SwiftSnapshotTesting.new(@options[:project_root])
105
+ when 'paparazzi'
106
+ ClientLibraries::Paparazzi.new(@options[:project_root])
107
+ when 'roborazzi'
108
+ ClientLibraries::Roborazzi.new(@options[:project_root])
109
+ else
110
+ raise "Unsupported client library: #{@options[:client_library]}"
111
+ end
106
112
  else
107
113
  ClientLibraries::Default.new(image_paths)
108
114
  end
data/lib/emerge_cli.rb CHANGED
@@ -2,9 +2,11 @@ require_relative './commands/global_options'
2
2
  require_relative './commands/upload/snapshots/snapshots'
3
3
  require_relative './commands/upload/snapshots/client_libraries/swift_snapshot_testing'
4
4
  require_relative './commands/upload/snapshots/client_libraries/paparazzi'
5
+ require_relative './commands/upload/snapshots/client_libraries/roborazzi'
5
6
  require_relative './commands/upload/snapshots/client_libraries/default'
6
7
  require_relative './commands/integrate/fastlane'
7
8
  require_relative './commands/config/snapshots/snapshots_ios'
9
+ require_relative './commands/config/orderfiles/orderfiles_ios'
8
10
 
9
11
  require_relative './utils/git_info_provider'
10
12
  require_relative './utils/git_result'
@@ -29,7 +31,8 @@ module EmergeCLI
29
31
  end
30
32
 
31
33
  register 'configure' do |prefix|
32
- prefix.register 'snapshots-ios', Commands::Config::SnapshotsIOS, aliases: ['c']
34
+ prefix.register 'snapshots-ios', Commands::Config::SnapshotsIOS
35
+ prefix.register 'order-files-ios', Commands::Config::OrderFilesIOS
33
36
  end
34
37
  end
35
38
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module EmergeCli
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emerge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emerge Tools
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-19 00:00:00.000000000 Z
11
+ date: 2024-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.12.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: xcodeproj
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 1.27.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 1.27.0
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: minitest
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -231,11 +245,13 @@ files:
231
245
  - CHANGELOG.md
232
246
  - README.md
233
247
  - exe/emerge
248
+ - lib/commands/config/orderfiles/orderfiles_ios.rb
234
249
  - lib/commands/config/snapshots/snapshots_ios.rb
235
250
  - lib/commands/global_options.rb
236
251
  - lib/commands/integrate/fastlane.rb
237
252
  - lib/commands/upload/snapshots/client_libraries/default.rb
238
253
  - lib/commands/upload/snapshots/client_libraries/paparazzi.rb
254
+ - lib/commands/upload/snapshots/client_libraries/roborazzi.rb
239
255
  - lib/commands/upload/snapshots/client_libraries/swift_snapshot_testing.rb
240
256
  - lib/commands/upload/snapshots/snapshots.rb
241
257
  - lib/emerge_cli.rb