gonative-cli 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/gonative/commands/android/create.rb +3 -3
- data/lib/gonative/commands/android/publish.rb +6 -6
- data/lib/gonative/commands/ios/create.rb +2 -2
- data/lib/gonative/commands/ios/embed_extensions.rb +2 -2
- data/lib/gonative/commands/ios/extract_extensions.rb +3 -3
- data/lib/gonative/commands/ios/publish.rb +1 -1
- data/lib/gonative/commands/ios/rename.rb +17 -0
- data/lib/gonative/commands/ios/set_bundle_id.rb +2 -2
- data/lib/gonative/commands/version.rb +1 -1
- data/lib/gonative/commands.rb +3 -1
- data/lib/gonative/plugins/android/create.rb +4 -4
- data/lib/gonative/plugins/ios/build_framework.rb +12 -9
- data/lib/gonative/plugins/ios/create.rb +8 -8
- data/lib/gonative/plugins/ios/embed_extensions.rb +23 -18
- data/lib/gonative/plugins/ios/extract_extensions.rb +28 -25
- data/lib/gonative/plugins/ios/release.rb +44 -43
- data/lib/gonative/plugins/ios/rename.rb +66 -0
- data/lib/gonative/plugins/ios/set_bundle_id.rb +11 -11
- data/lib/gonative/plugins/ios/verify.rb +2 -2
- data/lib/gonative/utils/template_inflator.rb +3 -3
- data/lib/gonative/utils/ui.rb +1 -1
- data/lib/gonative/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696be1b5e8b71bb4605450974d039505571a2dd5ab57635c3bf9e76673ac7847
|
4
|
+
data.tar.gz: 460e006f8a03e7f557e7dd0ea8f6fc4fb0c981c6e078b5eaf8fd33d1e040e4d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0088b9718dddb755e9cb8994a5bb80a3b07168938dbf2b604bcc3b1d96d6c721b77060c19a7b4916d4f30cbc6782ce5fbeecc00e1ab73b1c6df24dc77901e2e
|
7
|
+
data.tar.gz: 5d69260b7d62293d491bfcc8decac1cc6ddf6c9995dd1f3a54328c72d79ed2b5f6899ebc3b85110eac6e9da2b1965e86f0d8fcc90b211166fcf25d539222d41e
|
data/Gemfile.lock
CHANGED
@@ -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,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
|
data/lib/gonative/commands.rb
CHANGED
@@ -3,13 +3,15 @@
|
|
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
|
+
|
13
15
|
register 'android create', Android::Create
|
14
16
|
register 'android publish', Android::Publish
|
15
17
|
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|
|
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|
|
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
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
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|
|
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'] =
|
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|
|
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|
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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,
|
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
|
@@ -7,9 +7,9 @@ module GoNative
|
|
7
7
|
module IOS
|
8
8
|
class Release
|
9
9
|
extend DSL::Serviceable
|
10
|
-
|
10
|
+
|
11
11
|
GONATIVE_SOURCE_NAME = 'gonative-specs'.freeze
|
12
|
-
|
12
|
+
|
13
13
|
def call
|
14
14
|
Utils::UI.info 'Linting and releasing pod'
|
15
15
|
assert_spec_exists!
|
@@ -18,51 +18,52 @@ module GoNative
|
|
18
18
|
create_and_push_tag!
|
19
19
|
push_to_pod_repo!
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
private
|
23
|
-
|
24
|
-
def assert_spec_exists!
|
25
|
-
return if spec_name
|
26
|
-
|
27
|
-
raise Error, "No podspec file exists"
|
28
|
-
end
|
29
23
|
|
30
|
-
|
31
|
-
|
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
|
24
|
+
def assert_spec_exists!
|
25
|
+
return if spec_name
|
38
26
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
27
|
+
raise Error, "No podspec file exists"
|
28
|
+
end
|
29
|
+
|
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,
|
37
|
+
"#{name} (#{version}) has already been pushed to #{source.name}" if pushed_versions&.include? version.to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_and_push_tag!
|
41
|
+
unless system("git tag | grep #{spec.version} > /dev/null")
|
42
|
+
system "git add -A && git commit -m \"Releases #{spec.version}.\""
|
43
|
+
system "git tag #{spec.version}"
|
44
|
+
system "git push && git push --tags"
|
65
45
|
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def push_to_pod_repo!
|
49
|
+
system "pod repo push #{GONATIVE_SOURCE_NAME} #{spec_name} --private --allow-warnings"
|
50
|
+
end
|
51
|
+
|
52
|
+
def spec_name
|
53
|
+
@spec_name ||= Dir.entries(".").select { |s| s.end_with? ".podspec" }.first
|
54
|
+
end
|
55
|
+
|
56
|
+
def spec
|
57
|
+
@spec ||= Pod::Specification.from_file(spec_name)
|
58
|
+
end
|
59
|
+
|
60
|
+
def source
|
61
|
+
@source ||= sources_manager.source_with_name_or_url(GONATIVE_SOURCE_NAME)
|
62
|
+
end
|
63
|
+
|
64
|
+
def sources_manager
|
65
|
+
Pod::Config.instance.sources_manager
|
66
|
+
end
|
66
67
|
end
|
67
68
|
end
|
68
69
|
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
|
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'] = [
|
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
|
@@ -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
|
data/lib/gonative/utils/ui.rb
CHANGED
data/lib/gonative/version.rb
CHANGED
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.
|
4
|
+
version: 1.2.0
|
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-
|
11
|
+
date: 2023-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -194,6 +194,7 @@ 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
|
198
199
|
- lib/gonative/commands/version.rb
|
199
200
|
- lib/gonative/dsl/error_catchable.rb
|
@@ -204,6 +205,7 @@ files:
|
|
204
205
|
- lib/gonative/plugins/ios/embed_extensions.rb
|
205
206
|
- lib/gonative/plugins/ios/extract_extensions.rb
|
206
207
|
- lib/gonative/plugins/ios/release.rb
|
208
|
+
- lib/gonative/plugins/ios/rename.rb
|
207
209
|
- lib/gonative/plugins/ios/set_bundle_id.rb
|
208
210
|
- lib/gonative/plugins/ios/verify.rb
|
209
211
|
- lib/gonative/utils.rb
|