gonative-cli 1.1.2 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c796ee2bfc6fc112573c9ad3dbd03ceb218de00a67ab8206ce8ee4b0fb073bea
4
- data.tar.gz: 94ab967e387b8ceab25ae73ca602ff772c07fcdb5f89957fec66576d8b22970f
3
+ metadata.gz: de98ab993a8962f18682d81561ffe9955b5820abb4ca6be4f3e07624d203aea2
4
+ data.tar.gz: b374cefeca6c9329b4f3d531b6a0a331e6fa61edd25b66c19f1ed9d8deb6a36a
5
5
  SHA512:
6
- metadata.gz: 7e4d7e0a9390cce397180ab7378df5eb14d3e731440616bfbd555918c0e5c604829e6e22ac4685a36cc5016c4b4540af1040df837f189a04f17c2f7304b2fa1b
7
- data.tar.gz: 604d0e7605a6348a3005d887d55b39822f8a05536bbfee1028d92481029b15e84e4f7aae44b8ae79dc2a6490d1c973c8060fceb60a05b21df92ae4cb3651ad0a
6
+ metadata.gz: ea85323ef9fea3dbbc95d614ac78b04e8c14dbedc5591dbe5af703478377f892e3ede539a3087287065afb9fc95106ca06df86f2850835172f623b40681c0d53
7
+ data.tar.gz: 32bb8a22a19dc8d60bdb708c5f351c4a81821faa21748f6caec2049e905c5256dff801b5fc49f0c6feb1a0db9dee14542a6e9f55c58b42a9e3f0b3b796cd4713
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gonative-cli (1.1.2)
4
+ gonative-cli (1.2.1)
5
5
  activesupport (~> 6.0)
6
6
  cocoapods (~> 1.10)
7
7
  colorize (~> 0.8.0)
@@ -29,10 +29,10 @@ GEM
29
29
  atomos (0.1.3)
30
30
  byebug (11.1.3)
31
31
  claide (1.1.0)
32
- cocoapods (1.12.0)
32
+ cocoapods (1.12.1)
33
33
  addressable (~> 2.8)
34
34
  claide (>= 1.0.2, < 2.0)
35
- cocoapods-core (= 1.12.0)
35
+ cocoapods-core (= 1.12.1)
36
36
  cocoapods-deintegrate (>= 1.0.3, < 2.0)
37
37
  cocoapods-downloader (>= 1.6.0, < 2.0)
38
38
  cocoapods-plugins (>= 1.0.0, < 2.0)
@@ -47,7 +47,7 @@ GEM
47
47
  nap (~> 1.0)
48
48
  ruby-macho (>= 2.3.0, < 3.0)
49
49
  xcodeproj (>= 1.21.0, < 2.0)
50
- cocoapods-core (1.12.0)
50
+ cocoapods-core (1.12.1)
51
51
  activesupport (>= 5.0, < 8)
52
52
  addressable (~> 2.8)
53
53
  algoliasearch (~> 1.0)
@@ -144,7 +144,7 @@ GEM
144
144
  colored2 (~> 3.1)
145
145
  nanaimo (~> 0.3.0)
146
146
  rexml (~> 3.2.4)
147
- zeitwerk (2.6.7)
147
+ zeitwerk (2.6.8)
148
148
 
149
149
  PLATFORMS
150
150
  arm64-darwin-21
@@ -5,13 +5,13 @@ module GoNative
5
5
  module Android
6
6
  class Create < Base
7
7
  desc 'Create a new android plugin'
8
-
8
+
9
9
  argument :name, required: true, desc: 'Name of the plugin'
10
-
10
+
11
11
  def call(name:, **)
12
12
  Plugins::Android::Create.call(name)
13
13
  end
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -5,31 +5,31 @@ module GoNative
5
5
  module Android
6
6
  class Publish < Base
7
7
  desc 'Used to update one of the android internal dependencies'
8
-
8
+
9
9
  def call
10
10
  assert_build_file_exists!
11
11
  create_and_push_tag!
12
12
  end
13
-
13
+
14
14
  def assert_build_file_exists!
15
15
  return unless gradle_files.empty?
16
16
 
17
17
  raise Error, "No build.gradle file exists"
18
18
  end
19
-
19
+
20
20
  private
21
-
21
+
22
22
  def gradle_files
23
23
  @gradle_files ||= `find . -iname build.gradle`.split("\n")
24
24
  end
25
25
 
26
26
  def version
27
27
  return @version if @version
28
-
28
+
29
29
  gradle_files.each do |gradle_file|
30
30
  str = IO.read(gradle_file)
31
31
  @version = str.match(/versionName\s+\"(?<version>.+)\"/)[:version]
32
-
32
+
33
33
  break if @version
34
34
  end
35
35
 
@@ -5,10 +5,10 @@ module GoNative
5
5
  module IOS
6
6
  class Create < Base
7
7
  desc 'Create a new plugin'
8
-
8
+
9
9
  argument :name, required: true, desc: 'Name of the plugin'
10
10
  option :language, default: "objc", options: Plugins::IOS::Create::LANGUAGES, desc: "Plugin's language"
11
-
11
+
12
12
  def call(name:, language:, **)
13
13
  Plugins::IOS::Create.call(name, language)
14
14
  end
@@ -5,11 +5,11 @@ module GoNative
5
5
  module IOS
6
6
  class EmbedExtensions < Base
7
7
  desc 'Embeds all extensions from plugins to the project'
8
-
8
+
9
9
  def call(**)
10
10
  Plugins::IOS::EmbedExtensions.call
11
11
  end
12
12
  end
13
13
  end
14
14
  end
15
- end
15
+ end
@@ -5,13 +5,13 @@ module GoNative
5
5
  module IOS
6
6
  class ExtractExtensions < Base
7
7
  desc 'Extracts extension targets from a project'
8
-
8
+
9
9
  argument :path, required: false, desc: 'Path to the xcodeproj'
10
-
10
+
11
11
  def call(path:, **)
12
12
  Plugins::IOS::ExtractExtensions.call(path)
13
13
  end
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -9,7 +9,7 @@ module GoNative
9
9
  option :skip_build, type: :boolean, default: false
10
10
  option :debug, type: :boolean, default: false
11
11
  option :archs, default: 'x86_64,arm64'
12
-
12
+
13
13
  def call(skip_build:, debug:, archs:, **)
14
14
  Plugins::IOS::Verify.call
15
15
  Plugins::IOS::BuildFramework.call(archs, debug) unless skip_build
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GoNative
4
+ module Commands
5
+ module IOS
6
+ class Rename < Base
7
+ desc 'Rename an iOS project'
8
+
9
+ argument :name, required: true, desc: 'The new name of the project'
10
+
11
+ def call(name:)
12
+ Plugins::IOS::Rename.call(name)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -5,10 +5,10 @@ module GoNative
5
5
  module IOS
6
6
  class SetBundleId < Base
7
7
  desc 'Sets bundle Id '
8
-
8
+
9
9
  argument :bundle_id, required: true, desc: 'Bundle id for the app'
10
10
  option :with_entitlements, type: :boolean, default: false
11
-
11
+
12
12
  def call(bundle_id:, with_entitlements:, **)
13
13
  Plugins::IOS::SetBundleId.call(bundle_id, with_entitlements)
14
14
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GoNative
4
+ module Commands
5
+ module IOS
6
+ class Version < Base
7
+ desc 'Rename an iOS project'
8
+
9
+ def call
10
+ Plugins::IOS::Version.call
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -4,7 +4,7 @@ module GoNative
4
4
  module Commands
5
5
  class Version < Base
6
6
  desc 'Print version'
7
-
7
+
8
8
  def call(*)
9
9
  puts GoNative::VERSION
10
10
  end
@@ -3,13 +3,16 @@
3
3
  module GoNative
4
4
  module Commands
5
5
  extend Dry::CLI::Registry
6
-
6
+
7
7
  register 'version', Version, aliases: %w[--version -v]
8
8
  register 'ios create', IOS::Create
9
9
  register 'ios publish', IOS::Publish
10
10
  register 'ios extract-extensions', IOS::ExtractExtensions
11
11
  register 'ios embed-extensions', IOS::EmbedExtensions
12
12
  register 'ios set-bundle-id', IOS::SetBundleId
13
+ register 'ios rename', IOS::Rename
14
+ register 'ios version', IOS::Version
15
+
13
16
  register 'android create', Android::Create
14
17
  register 'android publish', Android::Publish
15
18
  end
@@ -17,7 +17,7 @@ module GoNative
17
17
  def initialize(plugin_name)
18
18
  @plugin_name = Utils::SanitizePluginName.call(plugin_name, 'android')
19
19
  end
20
-
20
+
21
21
  def call
22
22
  assert_not_exists!
23
23
  set_working_dir!
@@ -27,7 +27,7 @@ module GoNative
27
27
 
28
28
  def assert_not_exists!
29
29
  return unless File.directory?(plugin_name)
30
-
30
+
31
31
  raise Error, "Directory #{plugin_name} already exists"
32
32
  end
33
33
 
@@ -40,11 +40,11 @@ module GoNative
40
40
  FileUtils.cp_r("#{TEMPLATE_DIRECTORY_PATH}/.", '.')
41
41
  system('ditto', TEMPLATE_DIRECTORY_PATH, '.')
42
42
  end
43
-
43
+
44
44
  def capitalized_plugin_name
45
45
  [plugin_name, 'plugin'].join('_').camelize
46
46
  end
47
-
47
+
48
48
  def java_package
49
49
  plugin_name
50
50
  end
@@ -82,7 +82,9 @@ module GoNative
82
82
 
83
83
  def add_headers(target, group)
84
84
  headers_group = group.new_group('Headers', 'Headers')
85
- references = Dir.glob("../#{plugin_name}/Classes/**/*.h").map { |file| headers_group.new_file("../../#{file}") }
85
+ references = Dir.glob("../#{plugin_name}/Classes/**/*.h").map { |file|
86
+ headers_group.new_file("../../#{file}")
87
+ }
86
88
  header_files = target.add_file_references(references)
87
89
  header_files << target.headers_build_phase.add_file_reference(group.new_file("../#{plugin_name}-umbrella.h"))
88
90
  header_files.each do |header|
@@ -91,15 +93,16 @@ module GoNative
91
93
  end
92
94
 
93
95
  def move_template_files!
94
- plugin_dependencies = spec.dependencies.map{|d| ["pod '#{d.name}'", "'#{d.requirement}'"].compact.join(', ') } * "\n\t"
96
+ plugin_dependencies = spec.dependencies.map { |d|
97
+ ["pod '#{d.name}'", "'#{d.requirement}'"].compact.join(', ')
98
+ } * "\n\t"
95
99
  FileUtils.cp_r("#{BUILD_TEMPLATE_DIRECTORY_PATH}/.", '.')
96
- headers = Dir.glob("../#{plugin_name}/Classes/**/*.h").map{ |f| "#import \"#{File.basename(f)}\"" } * "\n"
100
+ headers = Dir.glob("../#{plugin_name}/Classes/**/*.h").map { |f| "#import \"#{File.basename(f)}\"" } * "\n"
97
101
  Utils::TemplateInflator.new(plugin_name: plugin_name,
98
102
  plugin_dependencies: plugin_dependencies,
99
103
  plugin_headers: headers,
100
104
  archs: archs,
101
- deployment_target: deployment_target
102
- ).call
105
+ deployment_target: deployment_target).call
103
106
  end
104
107
 
105
108
  def run_pod_install
@@ -113,19 +116,19 @@ module GoNative
113
116
  def build_framework!
114
117
  Utils::UI.info 'Building framework'
115
118
  return if system('sh create-framework.sh >/dev/null 2>/dev/null')
116
-
119
+
117
120
  raise Error, "Error building framework. Please run the create-framework file manually to fix any errors"
118
121
  end
119
-
122
+
120
123
  def move_framework_file
121
124
  FileUtils.rm_rf('../XCFramework')
122
125
  FileUtils.mv("XCFramework", '..', force: true)
123
126
  end
124
-
127
+
125
128
  def deployment_target
126
129
  spec.deployment_target('ios') || '11.0'
127
130
  end
128
-
131
+
129
132
  def spec
130
133
  @spec ||= Pod::Specification.from_file("../#{plugin_name}.podspec")
131
134
  end
@@ -12,16 +12,16 @@ module GoNative
12
12
 
13
13
  TEMPLATE_DIRECTORY_PATH = File.expand_path(File.join(__dir__, '../../../..', 'templates', 'plugins', 'ios'))
14
14
  COMMON_TEMPLATES_PATH = File.join(TEMPLATE_DIRECTORY_PATH, 'common')
15
-
15
+
16
16
  LANGUAGES = %w[objc swift].freeze
17
-
17
+
18
18
  attr_reader :plugin_name, :language
19
-
19
+
20
20
  def initialize(plugin_name, language)
21
21
  @plugin_name = plugin_name
22
22
  @language = language
23
23
  end
24
-
24
+
25
25
  def call
26
26
  assert_not_exists!
27
27
  set_working_dir!
@@ -31,20 +31,20 @@ module GoNative
31
31
 
32
32
  def assert_not_exists!
33
33
  return unless File.directory?(plugin_name)
34
-
34
+
35
35
  raise Error, "Directory #{plugin_name} already exists"
36
36
  end
37
-
37
+
38
38
  def set_working_dir!
39
39
  FileUtils.mkdir(plugin_name)
40
40
  FileUtils.cd(plugin_name)
41
41
  end
42
-
42
+
43
43
  def cp_template_files!
44
44
  FileUtils.cp_r("#{COMMON_TEMPLATES_PATH}/.", '.')
45
45
  system('ditto', File.join(TEMPLATE_DIRECTORY_PATH, 'language-specific', language), '.')
46
46
  end
47
-
47
+
48
48
  def repo_name
49
49
  plugin_name.underscore.dasherize.prepend 'ios-'
50
50
  end
@@ -9,15 +9,15 @@ module GoNative
9
9
  class EmbedExtensions
10
10
  extend DSL::Serviceable
11
11
  autoload :FileUtils, 'fileutils'
12
-
12
+
13
13
  attr_reader :extensions
14
-
14
+
15
15
  def call
16
16
  prepare_extensions
17
17
  embed_in_project
18
18
  modify_podfile
19
19
  end
20
-
20
+
21
21
  def prepare_extensions
22
22
  extension_paths = `find ./Pods -iname Extensions -not -empty -type d`.split("\n")
23
23
  extension_paths
@@ -25,23 +25,25 @@ module GoNative
25
25
  .flatten
26
26
  .each { |path| FileUtils.cp_r(path, '.') }
27
27
  @extensions = extension_paths
28
- .map { |path| Pathname(path).children.select { |p| p.extname == '.json' } }
29
- .flatten
30
- .map { |p| JSON.parse(File.read(p)) }
28
+ .map { |path| Pathname(path).children.select { |p| p.extname == '.json' } }
29
+ .flatten
30
+ .map { |p| JSON.parse(File.read(p)) }
31
31
  end
32
-
32
+
33
33
  def embed_in_project
34
34
  proj = Xcodeproj::Project.open('GoNativeIOS.xcodeproj')
35
35
  app_target = proj.native_targets.first
36
36
  extensions.each do |extension|
37
37
  extension_target = proj.new_target(:app_extension,
38
- extension['name'],
39
- :ios,
40
- '11.0')
38
+ extension['name'],
39
+ :ios,
40
+ '11.0')
41
41
  extension_group = proj.new_group(extension['name'], extension['name'])
42
-
42
+
43
43
  extension['headers'].each { |path| extension_group.new_file(path) }
44
- extension_target.add_file_references(extension['source_files'].map { |path| extension_group.new_file(path) })
44
+ extension_target.add_file_references(extension['source_files'].map { |path|
45
+ extension_group.new_file(path)
46
+ })
45
47
  extension_target.add_resources(extension['resources'].map { |path| extension_group.new_file(path) })
46
48
  extension_target.add_system_frameworks(extension['system_frameworks'])
47
49
  extension_group.new_file(extension['info'])
@@ -49,19 +51,22 @@ module GoNative
49
51
  extension_target.build_configurations.each do |config|
50
52
  config.build_settings['PRODUCT_NAME'] = "$(TARGET_NAME)"
51
53
  config.build_settings['INFOPLIST_FILE'] = "#{extension['name']}/#{extension['info']}"
52
- config.build_settings['CODE_SIGN_ENTITLEMENTS'] = "#{extension['name']}/#{extension['entitlements']}" if extension['entitlements']
54
+ config.build_settings['CODE_SIGN_ENTITLEMENTS'] =
55
+ "#{extension['name']}/#{extension['entitlements']}" if extension['entitlements']
53
56
  end
54
57
  app_target.add_dependency(extension_target)
55
- extension_file = proj.files.find{|f| f.path == "#{extension['name']}.appex" }
56
- embed_phase = app_target.build_phases.find { |phase| phase.class.method_defined?(:name) && phase.name == 'Embed App Extensions' }
58
+ extension_file = proj.files.find { |f| f.path == "#{extension['name']}.appex" }
59
+ embed_phase = app_target.build_phases.find { |phase|
60
+ phase.class.method_defined?(:name) && phase.name == 'Embed App Extensions'
61
+ }
57
62
  embed_phase.add_file_reference(extension_file, true)
58
- app_config = proj.files.find{|f| f.path == 'appConfig.json' }
63
+ app_config = proj.files.find { |f| f.path == 'appConfig.json' }
59
64
  extension_target.resources_build_phase.add_file_reference(app_config, true)
60
65
  end
61
-
66
+
62
67
  proj.save
63
68
  end
64
-
69
+
65
70
  def modify_podfile
66
71
  extensions.each do |extension|
67
72
  open('Podfile', 'a') do |f|
@@ -10,45 +10,47 @@ module GoNative
10
10
  class ExtractExtensions
11
11
  extend DSL::Serviceable
12
12
  autoload :FileUtils, 'fileutils'
13
-
13
+
14
14
  attr_reader :proj_path
15
-
15
+
16
16
  def initialize(path)
17
17
  @proj_path = path
18
18
  end
19
-
19
+
20
20
  def call
21
21
  original_path = FileUtils.pwd
22
22
  FileUtils.cd(File.dirname(proj_path))
23
23
  proj = Xcodeproj::Project.open(proj_path)
24
- extension_targets = proj.targets.select { |target| target.product_type == Xcodeproj::Constants::PRODUCT_TYPE_UTI[:app_extension] }
25
-
24
+ extension_targets = proj.targets.select { |target|
25
+ target.product_type == Xcodeproj::Constants::PRODUCT_TYPE_UTI[:app_extension]
26
+ }
27
+
26
28
  extension_targets.each do |target|
27
29
  extension_name = target.name
28
30
  extension_path = "Extensions/#{target.name}"
29
-
31
+
30
32
  target_definition = {}
31
33
  target_definition[:name] = extension_name
32
-
34
+
33
35
  FileUtils.cd(extension_name)
34
36
  target_definition[:info] = `find . -name '*Info.plist'`.split("\n").first
35
37
  target_definition[:entitlements] = `find -E . -regex ".*\.(entitlements)"`.split("\n").first
36
38
  target_definition[:headers] = `find -E . -regex ".*\.(h)"`.split("\n")
37
39
  target_definition[:source_files] = `find -E . -regex ".*\.(m|swift)"`.split("\n")
38
40
  target_definition[:resources] = target
39
- .resources_build_phase
40
- .files
41
- .map(&:file_ref)
42
- .map(&:name)
43
- .map { |name| `find . -name #{name}`.strip }
44
-
41
+ .resources_build_phase
42
+ .files
43
+ .map(&:file_ref)
44
+ .map(&:name)
45
+ .map { |name| `find . -name #{name}`.strip }
46
+
45
47
  target_definition[:system_frameworks] = target
46
- .frameworks_build_phase
47
- .files
48
- .map(&:file_ref)
49
- .map(&:path)
50
- .select{|p| p.start_with? 'System'}
51
- .map{ |p| File.basename(p)}
48
+ .frameworks_build_phase
49
+ .files
50
+ .map(&:file_ref)
51
+ .map(&:path)
52
+ .select { |p| p.start_with? 'System' }
53
+ .map { |p| File.basename(p) }
52
54
 
53
55
  target_definition[:dependencies] = podfile.target_definitions[extension_name].dependencies.map do |dependency|
54
56
  {
@@ -56,19 +58,20 @@ module GoNative
56
58
  requirement: dependency.requirement.requirements.map { |r| r.map(&:to_s).join(' ') }.join(', ')
57
59
  }
58
60
  end
59
-
60
- target_definition.slice(:info, :entitlements, :headers, :source_files, :resources).values.compact.flatten.each do |file_path|
61
+
62
+ target_definition.slice(:info, :entitlements, :headers, :source_files,
63
+ :resources).values.compact.flatten.each do |file_path|
61
64
  system('ditto', file_path, "#{original_path}/#{extension_path}/#{file_path}")
62
65
  end
63
-
64
- File.open("#{original_path}/#{extension_path}.json","w") do |f|
66
+
67
+ File.open("#{original_path}/#{extension_path}.json", "w") do |f|
65
68
  f.write(JSON.pretty_generate(target_definition))
66
69
  end
67
-
70
+
68
71
  FileUtils.cd('..')
69
72
  end
70
73
  end
71
-
74
+
72
75
  def podfile
73
76
  @podfile ||= Pod::Podfile.from_file(Pathname.new(File.dirname(proj_path) + '/Podfile'))
74
77
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cocoapods'
4
+
5
+ module GoNative
6
+ module Plugins
7
+ module IOS
8
+ module Helpers
9
+ module SpecReader
10
+ def spec_name
11
+ @spec_name ||= Dir.entries('.').select { |s| s.end_with? '.podspec' }.first
12
+ end
13
+
14
+ def spec
15
+ @spec ||= Pod::Specification.from_file(spec_name)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GoNative
4
+ module Plugins
5
+ module IOS
6
+ module Helpers
7
+ end
8
+ end
9
+ end
10
+ end
@@ -7,9 +7,10 @@ module GoNative
7
7
  module IOS
8
8
  class Release
9
9
  extend DSL::Serviceable
10
-
11
- GONATIVE_SOURCE_NAME = 'gonative-specs'.freeze
12
-
10
+ include Helpers::SpecReader
11
+
12
+ GONATIVE_SOURCE_NAME = 'gonative-specs'
13
+
13
14
  def call
14
15
  Utils::UI.info 'Linting and releasing pod'
15
16
  assert_spec_exists!
@@ -18,51 +19,46 @@ module GoNative
18
19
  create_and_push_tag!
19
20
  push_to_pod_repo!
20
21
  end
21
-
22
+
22
23
  private
23
-
24
- def assert_spec_exists!
25
- return if spec_name
26
-
27
- raise Error, "No podspec file exists"
28
- end
29
24
 
30
- def assert_not_pushed!
31
- version = spec.version
32
- name = spec.name
33
-
34
- pushed_versions = source.versions(name)&.collect(&:to_s)
35
-
36
- raise Error, "#{name} (#{version}) has already been pushed to #{source.name}" if pushed_versions&.include? version.to_s
37
- end
25
+ def assert_spec_exists!
26
+ return if spec_name
38
27
 
39
- def create_and_push_tag!
40
- unless system("git tag | grep #{spec.version} > /dev/null")
41
- system "git add -A && git commit -m \"Releases #{spec.version}.\""
42
- system "git tag #{spec.version}"
43
- system "git push && git push --tags"
44
- end
45
- end
46
-
47
- def push_to_pod_repo!
48
- system "pod repo push #{GONATIVE_SOURCE_NAME} #{spec_name} --private --allow-warnings"
49
- end
50
-
51
- def spec_name
52
- @spec_name ||= Dir.entries(".").select { |s| s.end_with? ".podspec" }.first
53
- end
54
-
55
- def spec
56
- @spec ||= Pod::Specification.from_file(spec_name)
57
- end
58
-
59
- def source
60
- @source ||= sources_manager.source_with_name_or_url(GONATIVE_SOURCE_NAME)
61
- end
62
-
63
- def sources_manager
64
- Pod::Config.instance.sources_manager
28
+ raise Error, 'No podspec file exists'
29
+ end
30
+
31
+ def assert_not_pushed!
32
+ version = spec.version
33
+ name = spec.name
34
+
35
+ pushed_versions = source.versions(name)&.collect(&:to_s)
36
+
37
+ if pushed_versions&.include? version.to_s
38
+ raise Error,
39
+ "#{name} (#{version}) has already been pushed to #{source.name}"
65
40
  end
41
+ end
42
+
43
+ def create_and_push_tag!
44
+ return if system("git tag | grep #{spec.version} > /dev/null")
45
+
46
+ system "git add -A && git commit -m \"Releases #{spec.version}.\""
47
+ system "git tag #{spec.version}"
48
+ system 'git push && git push --tags'
49
+ end
50
+
51
+ def push_to_pod_repo!
52
+ system "pod repo push #{GONATIVE_SOURCE_NAME} #{spec_name} --private --allow-warnings"
53
+ end
54
+
55
+ def source
56
+ @source ||= sources_manager.source_with_name_or_url(GONATIVE_SOURCE_NAME)
57
+ end
58
+
59
+ def sources_manager
60
+ Pod::Config.instance.sources_manager
61
+ end
66
62
  end
67
63
  end
68
64
  end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xcodeproj'
4
+
5
+ module GoNative
6
+ module Plugins
7
+ module IOS
8
+ class Rename
9
+ extend DSL::Serviceable
10
+
11
+ attr_reader :name, :proj
12
+
13
+ def initialize(name)
14
+ @name = name
15
+ end
16
+
17
+ def call
18
+ system("git mv GoNativeIOS.xcodeproj #{proj_path}")
19
+ @proj = Xcodeproj::Project.open(proj_path)
20
+ rename_target!
21
+ recreate_scheme!
22
+ fix_workspace_refs!
23
+ system('pod install')
24
+ end
25
+
26
+ def rename_target!
27
+ proj.targets.first.name = name
28
+ proj.save
29
+ end
30
+
31
+ def recreate_scheme!
32
+ schemes_dir = Xcodeproj::XCScheme.shared_data_dir(proj_path)
33
+ FileUtils.rm_rf(schemes_dir)
34
+ FileUtils.mkdir_p(schemes_dir)
35
+
36
+ scheme = Xcodeproj::XCScheme.new
37
+ target = proj.targets.first
38
+
39
+ test_target = target if target.respond_to?(:test_target_type?) && target.test_target_type?
40
+ launch_target = target.respond_to?(:launchable_target_type?) && target.launchable_target_type?
41
+ scheme.configure_with_targets(target, test_target, launch_target: launch_target)
42
+
43
+ scheme.save_as(proj_path, target.name, true)
44
+ end
45
+
46
+ def fix_workspace_refs!
47
+ FileUtils.rm_rf('GoNativeIOS.xcworkspace')
48
+ proj_ref = Xcodeproj::Workspace::FileReference.new(proj_path)
49
+ pods_ref = Xcodeproj::Workspace::FileReference.new('Pods/Pods.xcodeproj')
50
+ workspace = Xcodeproj::Workspace.new(nil, proj_ref, pods_ref)
51
+ workspace.save_as(workspace_path)
52
+ end
53
+
54
+ private
55
+
56
+ def proj_path
57
+ "#{name}.xcodeproj"
58
+ end
59
+
60
+ def workspace_path
61
+ "#{name}.xcworkspace"
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -8,19 +8,19 @@ module GoNative
8
8
  module IOS
9
9
  class SetBundleId
10
10
  extend DSL::Serviceable
11
-
11
+
12
12
  attr_reader :bundle_id
13
-
13
+
14
14
  def initialize(bundle_id, update_entitlements)
15
15
  @bundle_id = bundle_id
16
16
  @update_entitlements = update_entitlements
17
17
  end
18
-
18
+
19
19
  def call
20
20
  update_project
21
21
  update_entitlements if update_entitlements?
22
22
  end
23
-
23
+
24
24
  def update_project
25
25
  proj = Xcodeproj::Project.open('./GoNativeIOS.xcodeproj')
26
26
  proj.targets.each do |target|
@@ -28,34 +28,34 @@ module GoNative
28
28
  when Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application]
29
29
  set_target_bundle_id(target, bundle_id)
30
30
  when Xcodeproj::Constants::PRODUCT_TYPE_UTI[:app_extension]
31
- set_target_bundle_id(target, bundle_id + '.' + target.name)
31
+ set_target_bundle_id(target, "#{bundle_id}.#{target.name}")
32
32
  else
33
33
  next
34
34
  end
35
35
  end
36
-
36
+
37
37
  proj.save
38
38
  end
39
-
39
+
40
40
  def update_entitlements
41
41
  entitlement_files = `find -E . -maxdepth 2 -regex ".*\.(entitlements)"`.split("\n")
42
42
  entitlement_files.each do |entitlement_file|
43
43
  plist = CFPropertyList::List.new(file: entitlement_file)
44
44
  entitlements = CFPropertyList.native_types(plist.value)
45
- entitlements['com.apple.security.application-groups'] = ['group.' + bundle_id]
45
+ entitlements['com.apple.security.application-groups'] = ["group.#{bundle_id}"]
46
46
  plist.value = CFPropertyList.guess(entitlements)
47
47
  plist.save(entitlement_file, CFPropertyList::List::FORMAT_XML)
48
48
  end
49
49
  end
50
-
50
+
51
51
  private
52
-
52
+
53
53
  def set_target_bundle_id(target, bundle_id)
54
54
  target.build_configurations.each do |config|
55
55
  config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = bundle_id
56
56
  end
57
57
  end
58
-
58
+
59
59
  def update_entitlements?
60
60
  @update_entitlements
61
61
  end
@@ -5,11 +5,11 @@ module GoNative
5
5
  module IOS
6
6
  class Verify
7
7
  extend DSL::Serviceable
8
-
8
+
9
9
  def call
10
10
  assert_staging_clear!
11
11
  end
12
-
12
+
13
13
  def assert_staging_clear!
14
14
  return if `git status --porcelain`.empty?
15
15
 
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cocoapods'
4
+
5
+ module GoNative
6
+ module Plugins
7
+ module IOS
8
+ class Version
9
+ extend DSL::Serviceable
10
+ include Helpers::SpecReader
11
+
12
+ def call
13
+ Utils::UI.output(spec.version)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -4,7 +4,7 @@ module GoNative
4
4
  module Utils
5
5
  class TemplateInflator
6
6
  autoload :FileUtils, 'fileutils'
7
-
7
+
8
8
  extend DSL::Serviceable
9
9
 
10
10
  def initialize(options)
@@ -42,9 +42,9 @@ module GoNative
42
42
  end
43
43
  new_name.delete_suffix(TEMPLATE_FILES_EXTENSION)
44
44
  end
45
-
45
+
46
46
  private
47
-
47
+
48
48
  attr_reader :options
49
49
  end
50
50
  end
@@ -9,7 +9,11 @@ module GoNative
9
9
  def info(msg)
10
10
  puts msg.colorize(:green)
11
11
  end
12
+
13
+ def output(msg)
14
+ puts msg
15
+ end
12
16
  end
13
17
  end
14
18
  end
15
- end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GoNative
4
- VERSION = '1.1.2'
4
+ VERSION = '1.2.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gonative-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hunaid Hassan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-02 00:00:00.000000000 Z
11
+ date: 2023-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -194,7 +194,9 @@ files:
194
194
  - lib/gonative/commands/ios/embed_extensions.rb
195
195
  - lib/gonative/commands/ios/extract_extensions.rb
196
196
  - lib/gonative/commands/ios/publish.rb
197
+ - lib/gonative/commands/ios/rename.rb
197
198
  - lib/gonative/commands/ios/set_bundle_id.rb
199
+ - lib/gonative/commands/ios/version.rb
198
200
  - lib/gonative/commands/version.rb
199
201
  - lib/gonative/dsl/error_catchable.rb
200
202
  - lib/gonative/dsl/serviceable.rb
@@ -203,9 +205,13 @@ files:
203
205
  - lib/gonative/plugins/ios/create.rb
204
206
  - lib/gonative/plugins/ios/embed_extensions.rb
205
207
  - lib/gonative/plugins/ios/extract_extensions.rb
208
+ - lib/gonative/plugins/ios/helpers.rb
209
+ - lib/gonative/plugins/ios/helpers/spec_reader.rb
206
210
  - lib/gonative/plugins/ios/release.rb
211
+ - lib/gonative/plugins/ios/rename.rb
207
212
  - lib/gonative/plugins/ios/set_bundle_id.rb
208
213
  - lib/gonative/plugins/ios/verify.rb
214
+ - lib/gonative/plugins/ios/version.rb
209
215
  - lib/gonative/utils.rb
210
216
  - lib/gonative/utils/content_evaluator.rb
211
217
  - lib/gonative/utils/sanitize_plugin_name.rb