cocoapods-modularization 0.0.2 → 0.0.3

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: 1cde6391ce2e9acbdfda733ce4ee1f7554efc154e25609497ed5e2c0311dc4ab
4
- data.tar.gz: 1136a975ded5270f9b57f521c97cfce57e13d3ba184bc9057cf93562540cf5f3
3
+ metadata.gz: 68ccf2c772ccb87aacdbcc0252fcb5f8457dca47a4679692535f275d5ee83853
4
+ data.tar.gz: 573dde912ff99643009415c6ef7885f2acc8b760de36f5b10466b8a938d02ed4
5
5
  SHA512:
6
- metadata.gz: 6cdb49c8786470aafae93516037445123a3305f9c6f7ff1eb406cbfe317fb1e300bfee9daee93df70e9de7960d7e278fa9f3f9e6610561e9b02b5ded5c78f4f0
7
- data.tar.gz: 6b22853de266f03dde6f0959ea24403dd7d8de592db92546449d034994bf9a5d64cb2436ab14fe89587e20ee72ecb00a7c854e36238a40ba303c892a6b25a3c7
6
+ metadata.gz: 5ad4c05aeb73a317e0d0ede705996c9eb8f920fadc3e83707ee75b24837e7fbbd893aa7ce2a7a4895170c0a225b2971302fd13423720f049b8fc1e4150a96718
7
+ data.tar.gz: 464c93e897086c05eda33b649831e002a9668584a0aeef712fde3514e874ef13c0693e9e23aba6b57a69317344b154dcaba1fc87187f56fed2fe5926e586ba1d
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cocoapods-modularization/generate'
4
+
5
+ module Pod
6
+ class Command
7
+ class Gen < Command
8
+ self.summary = 'Generates Xcode workspaces from a podspec.'
9
+
10
+ self.description = <<-DESC.strip_heredoc
11
+ #{summary}
12
+
13
+ pod gen allows you to keep your Podfile and podspecs as the single source of
14
+ truth for pods under development. By generating throw-away workspaces capable of
15
+ building, running, and testing a pod, you can focus on library development
16
+ without worrying about other code or managing an Xcode project.
17
+
18
+ pod gen works particularly well for monorepo projects, since it is capable of
19
+ using your existing settings when generating the workspace, making each gen'ed
20
+ project truly a small slice of the larger application.
21
+ DESC
22
+
23
+ def self.options
24
+ super.concat(Generate::Configuration.options.map do |option|
25
+ next unless option.cli_name
26
+
27
+ flag = "--#{option.cli_name}"
28
+ flag += "=#{option.arg_name}" if option.arg_name
29
+ [flag, option.message]
30
+ end.compact)
31
+ end
32
+
33
+ self.arguments = [
34
+ CLAide::Argument.new(%w[PODSPEC DIR], false, true)
35
+ ]
36
+
37
+ # @return [Configuration]
38
+ # the configuration used when generating workspaces
39
+ #
40
+ attr_reader :configuration
41
+
42
+ def initialize(argv)
43
+ options_hash = Generate::Configuration.options.each_with_object({}) do |option, options|
44
+ value =
45
+ if option.name == :podspec_paths
46
+ argv.arguments!
47
+ elsif option.flag?
48
+ argv.flag?(option.cli_name)
49
+ else
50
+ argv.option(option.cli_name)
51
+ end
52
+
53
+ next if value.nil?
54
+ options[option.name] = option.coerce(value)
55
+ end
56
+ UI.puts "options_hash: #{options_hash}"
57
+ @configuration = merge_configuration(options_hash)
58
+ super
59
+ end
60
+
61
+ def run
62
+ UI.puts "[pod gen] Running with #{configuration.to_s.gsub("\n", " \n")}" if configuration.pod_config.verbose?
63
+
64
+ # this is done here rather than in the installer so we only update sources once,
65
+ # even if there are multiple podspecs
66
+ update_sources if configuration.repo_update?
67
+
68
+ Generate::PodfileGenerator.new(configuration).podfiles_by_spec.each do |spec, podfile|
69
+ Generate::Installer.new(configuration, spec, podfile).install!
70
+ end
71
+
72
+ remove_warnings(UI.warnings)
73
+ end
74
+
75
+ def validate!
76
+ super
77
+
78
+ config_errors = configuration.validate
79
+ help! config_errors.join("\n ") if config_errors.any?
80
+ end
81
+
82
+ private
83
+
84
+ def merge_configuration(options)
85
+ # must use #to_enum explicitly since descend doesn't return an enumerator on 2.1
86
+ config_hashes = Pathname.pwd.to_enum(:descend).map do |dir|
87
+ path = dir + '.gen_config.yml'
88
+ next unless path.file?
89
+ Pod::Generate::Configuration.from_file(path)
90
+ end.compact
91
+
92
+ options.delete(:podspec_paths) if options[:podspec_paths].empty? && config_hashes.any? { |h| h.include?(:podspec_paths) }
93
+
94
+ env = Generate::Configuration.from_env(ENV)
95
+ config_hashes = [env] + config_hashes
96
+ config_hashes << options
97
+
98
+ configuration = config_hashes.compact.each_with_object({}) { |e, h| h.merge!(e) }
99
+ Pod::Generate::Configuration.new(pod_config: config, **configuration)
100
+ end
101
+
102
+ def remove_warnings(warnings)
103
+ warnings.reject! do |warning|
104
+ warning[:message].include? 'Automatically assigning platform'
105
+ end
106
+ end
107
+
108
+ def update_sources
109
+ UI.title 'Updating specs repos' do
110
+ configuration.sources.each do |source|
111
+ source = config.sources_manager.source_with_name_or_url(source)
112
+ UI.titled_section "Updating spec repo `#{source.name}`" do
113
+ source.update(config.verbose?)
114
+ source.verify_compatibility!
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -51,7 +51,7 @@ module Pod
51
51
  # encode podfile
52
52
  begin
53
53
  Meta::MetaReference.encode_podfile(@enable_branch)
54
- rescue StandardError => e
54
+ rescue Exception => e
55
55
  UI.puts "pod install error: #{e}"
56
56
  end
57
57
 
@@ -66,7 +66,7 @@ module Pod
66
66
 
67
67
  begin
68
68
  add_modularization_into_xcode_reference
69
- rescue StandardError => e
69
+ rescue Exception => e
70
70
  UI.puts e
71
71
  end
72
72
  end
@@ -1,2 +1,3 @@
1
1
  require 'cocoapods-modularization/command/mod'
2
2
  require 'cocoapods-modularization/command/install'
3
+ require 'cocoapods-modularization/command/gen'
@@ -1,3 +1,3 @@
1
1
  module CocoapodsModularization
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -29,7 +29,10 @@ module Pod
29
29
 
30
30
  # podfile <= meta & data
31
31
  def encode_podfile(enable_branch = false)
32
+ raise 'meta.yml not found, run \'pod mod sync\' at first' unless File.exists?(Meta::MetaConstants.meta_path)
32
33
  meta = MetaConstants.generate_yml_to_hash(MetaConstants.meta_path)
34
+
35
+ raise 'data.yml not found, run \'pod mod sync\' at first' unless File.exists?(Meta::MetaConstants.data_path)
33
36
  data = MetaConstants.read_data(enable_branch)
34
37
 
35
38
  target_definitions = meta['target_definitions']
@@ -198,7 +198,7 @@ module Pod
198
198
 
199
199
  def make_branch_cache_workspace_if_needed
200
200
  unless File.directory?(Meta::MetaConstants.pods_generator_path)
201
- raise "#{Meta::MetaConstants.pods_generator_path} not found"
201
+ raise "#{Meta::MetaConstants.pods_generator_path} not found, run 'pod sync' at first"
202
202
  end
203
203
 
204
204
  unless File.exists?(Meta::MetaConstants.branch_cache_path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-modularization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - lazy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-26 00:00:00.000000000 Z
11
+ date: 2021-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cocoapods-disable-podfile-validations
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.1
41
55
  description: A short description of cocoapods-modularization.
42
56
  email:
43
57
  - 515310192@qq.com
@@ -47,6 +61,7 @@ extra_rdoc_files: []
47
61
  files:
48
62
  - lib/cocoapods-modularization.rb
49
63
  - lib/cocoapods-modularization/command.rb
64
+ - lib/cocoapods-modularization/command/gen.rb
50
65
  - lib/cocoapods-modularization/command/install.rb
51
66
  - lib/cocoapods-modularization/command/mod.rb
52
67
  - lib/cocoapods-modularization/command/mod/add.rb