cocoapods-modularization 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/cocoapods-modularization/command/install.rb +98 -0
- data/lib/cocoapods-modularization/command/mod/add.rb +97 -0
- data/lib/cocoapods-modularization/command/mod/base.rb +35 -0
- data/lib/cocoapods-modularization/command/mod/binary.rb +82 -0
- data/lib/cocoapods-modularization/command/mod/config.rb +51 -0
- data/lib/cocoapods-modularization/command/mod/create.rb +34 -0
- data/lib/cocoapods-modularization/command/mod/inspect.rb +26 -0
- data/lib/cocoapods-modularization/command/mod/source.rb +81 -0
- data/lib/cocoapods-modularization/command/mod/sync.rb +29 -0
- data/lib/cocoapods-modularization/command/mod/update.rb +64 -0
- data/lib/cocoapods-modularization/command/mod.rb +28 -0
- data/lib/cocoapods-modularization/command.rb +2 -0
- data/lib/cocoapods-modularization/gem_version.rb +3 -0
- data/lib/cocoapods-modularization/generate/configuration.rb +364 -0
- data/lib/cocoapods-modularization/generate/installer.rb +388 -0
- data/lib/cocoapods-modularization/generate/podfile_generator.rb +398 -0
- data/lib/cocoapods-modularization/generate.rb +7 -0
- data/lib/cocoapods-modularization/meta/meta_accessor.rb +134 -0
- data/lib/cocoapods-modularization/meta/meta_constants.rb +135 -0
- data/lib/cocoapods-modularization/meta/meta_reference.rb +255 -0
- data/lib/cocoapods-modularization/meta.rb +7 -0
- data/lib/cocoapods-modularization/private/private_cache.rb +277 -0
- data/lib/cocoapods-modularization/private.rb +5 -0
- data/lib/cocoapods-modularization.rb +1 -0
- data/lib/cocoapods_plugin.rb +1 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1cde6391ce2e9acbdfda733ce4ee1f7554efc154e25609497ed5e2c0311dc4ab
|
4
|
+
data.tar.gz: 1136a975ded5270f9b57f521c97cfce57e13d3ba184bc9057cf93562540cf5f3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6cdb49c8786470aafae93516037445123a3305f9c6f7ff1eb406cbfe317fb1e300bfee9daee93df70e9de7960d7e278fa9f3f9e6610561e9b02b5ded5c78f4f0
|
7
|
+
data.tar.gz: 6b22853de266f03dde6f0959ea24403dd7d8de592db92546449d034994bf9a5d64cb2436ab14fe89587e20ee72ecb00a7c854e36238a40ba303c892a6b25a3c7
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'cocoapods-modularization/meta'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Install < Command
|
6
|
+
|
7
|
+
include RepoUpdate
|
8
|
+
include ProjectDirectory
|
9
|
+
|
10
|
+
self.summary = 'Install project dependencies according to versions from a Podfile.lock'
|
11
|
+
|
12
|
+
self.description = <<-DESC
|
13
|
+
Downloads all dependencies defined in `Podfile` and creates an Xcode
|
14
|
+
Pods library project in `./Pods`.
|
15
|
+
|
16
|
+
The Xcode project file should be specified in your `Podfile` like this:
|
17
|
+
|
18
|
+
project 'path/to/XcodeProject.xcodeproj'
|
19
|
+
|
20
|
+
If no project is specified, then a search for an Xcode project will
|
21
|
+
be made. If more than one Xcode project is found, the command will
|
22
|
+
raise an error.
|
23
|
+
|
24
|
+
This will configure the project to reference the Pods static library,
|
25
|
+
add a build configuration file, and add a post build script to copy
|
26
|
+
Pod resources.
|
27
|
+
|
28
|
+
This may return one of several error codes if it encounters problems.
|
29
|
+
* `1` Generic error code
|
30
|
+
* `31` Spec not found (i.e out-of-date source repos, mistyped Pod name etc...)
|
31
|
+
DESC
|
32
|
+
|
33
|
+
def self.options
|
34
|
+
[
|
35
|
+
['--repo-update', 'Force running `pod repo update` before install'],
|
36
|
+
['--deployment', 'Disallow any changes to the Podfile or the Podfile.lock during installation'],
|
37
|
+
['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
|
38
|
+
'applies to projects that have enabled incremental installation'],
|
39
|
+
['--enable-branch', 'Enable branch dependency'],
|
40
|
+
].concat(super).reject { |(name, _)| name == '--no-repo-update' }
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize(argv)
|
44
|
+
super
|
45
|
+
@deployment = argv.flag?('deployment', false)
|
46
|
+
@clean_install = argv.flag?('clean-install', false)
|
47
|
+
@enable_branch = argv.flag?('enable-branch', false)
|
48
|
+
end
|
49
|
+
|
50
|
+
def run
|
51
|
+
# encode podfile
|
52
|
+
begin
|
53
|
+
Meta::MetaReference.encode_podfile(@enable_branch)
|
54
|
+
rescue StandardError => e
|
55
|
+
UI.puts "pod install error: #{e}"
|
56
|
+
end
|
57
|
+
|
58
|
+
# install
|
59
|
+
verify_podfile_exists!
|
60
|
+
installer = installer_for_config
|
61
|
+
installer.repo_update = repo_update?(:default => false)
|
62
|
+
installer.update = false
|
63
|
+
installer.deployment = @deployment
|
64
|
+
installer.clean_install = @clean_install
|
65
|
+
installer.install!
|
66
|
+
|
67
|
+
begin
|
68
|
+
add_modularization_into_xcode_reference
|
69
|
+
rescue StandardError => e
|
70
|
+
UI.puts e
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
def add_modularization_into_xcode_reference
|
76
|
+
project = Xcodeproj::Project.open('Pods/Pods.xcodeproj')
|
77
|
+
|
78
|
+
[Meta::MetaConstants.podfile_local_path, Meta::MetaConstants.meta_path, Meta::MetaConstants.data_path].each do |file|
|
79
|
+
next unless File.exists?(file)
|
80
|
+
project.new_file("#{Dir.pwd}/#{file}", :project).tap do |podfile_ref|
|
81
|
+
podfile_ref.xc_language_specification_identifier = 'xcode.lang.yaml'
|
82
|
+
podfile_ref.explicit_file_type = 'text.script.yaml'
|
83
|
+
podfile_ref.last_known_file_type = 'text'
|
84
|
+
podfile_ref.tab_width = '2'
|
85
|
+
podfile_ref.indent_width = '2'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
if project.dirty?
|
90
|
+
project.save()
|
91
|
+
else
|
92
|
+
FileUtils.touch(project.path + 'project.pbxproj')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'cocoapods-modularization/meta'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Mod < Command
|
6
|
+
class Add < Mod
|
7
|
+
|
8
|
+
self.summary = 'Add a component into dependencies'
|
9
|
+
|
10
|
+
self.description = <<-DESC
|
11
|
+
DESC
|
12
|
+
|
13
|
+
self.arguments = [
|
14
|
+
CLAide::Argument.new('NAME', true)
|
15
|
+
]
|
16
|
+
|
17
|
+
def self.options
|
18
|
+
[
|
19
|
+
['--version=VERSION', 'Version of the component, default version is 0.1.0'],
|
20
|
+
['--targets=TARGETA,TARGETB', 'Targets need to insert component.if this option not specified, this command will add component into all targets'],
|
21
|
+
['--use-binary', 'Use this flag if the component supposed to be a binary, otherwise a source version will be added into dependencies']
|
22
|
+
].concat(super)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(argv)
|
26
|
+
@name = argv.shift_argument
|
27
|
+
@version = argv.option('version', '0.1.0')
|
28
|
+
@targets = argv.option('targets', '').split(',')
|
29
|
+
@use_binary = argv.flag?('use-binary')
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate!
|
34
|
+
super
|
35
|
+
help! "meta not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.meta_path)
|
36
|
+
help! "data not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.data_path)
|
37
|
+
|
38
|
+
help! 'A name for the Pod is required.' unless @name
|
39
|
+
help! 'The Pod name cannot contain spaces.' if @name =~ /\s/
|
40
|
+
help! 'The Pod name cannot contain plusses.' if @name =~ /\+/
|
41
|
+
help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
|
42
|
+
|
43
|
+
help! "version (#{@version}) illlegal" unless @version =~ /\d+\.\d+\.\d+/
|
44
|
+
|
45
|
+
return if @targets.empty?
|
46
|
+
podfile = Pod::Podfile.from_file(Meta::MetaReference.podfile_path_in_dir(Meta::MetaReference.installation_root))
|
47
|
+
target_definitions = podfile.target_definitions.map { |target| target.to_a.at(0) }
|
48
|
+
target_not_hits = Array.new
|
49
|
+
@targets.each do |target|
|
50
|
+
target_not_hits << target unless target_definitions.include?(target)
|
51
|
+
end
|
52
|
+
help! "Targets: #{target_not_hits} not found in Podfile" unless target_not_hits.empty?
|
53
|
+
end
|
54
|
+
|
55
|
+
def run
|
56
|
+
begin
|
57
|
+
UI.puts("Adding #{@name} into dependencies index")
|
58
|
+
Meta::MetaAccessor.edit_meta do |meta_hash|
|
59
|
+
# add index to dependencies
|
60
|
+
target_definitions = meta_hash['target_definitions']
|
61
|
+
target_definitions.each { |target| internal_add_dep(target, @name, @targets) } if target_definitions.kind_of?(Array)
|
62
|
+
end
|
63
|
+
|
64
|
+
UI.puts("Adding #{@name} into meta")
|
65
|
+
Meta::MetaAccessor.set_dep(@name, @use_binary, @version)
|
66
|
+
UI.puts("#{@name} added")
|
67
|
+
|
68
|
+
Meta::MetaReference.encode_podfile
|
69
|
+
UI.puts("Podfile encoded")
|
70
|
+
rescue Exception => e
|
71
|
+
UI.puts e
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
def internal_add_dep(map, key, targets)
|
77
|
+
children = map['children']
|
78
|
+
if children.kind_of?(Array)
|
79
|
+
children.each { |c| internal_add_dep(c, key, targets) }
|
80
|
+
end
|
81
|
+
|
82
|
+
target_name = map['name']
|
83
|
+
|
84
|
+
# if targets is not empty and targets not include target_name, return
|
85
|
+
return if !targets.empty? && !targets.include?(target_name)
|
86
|
+
|
87
|
+
dependencies = map['dependencies']
|
88
|
+
if dependencies.kind_of?(Array)
|
89
|
+
dependencies << key unless dependencies.include?(key)
|
90
|
+
else
|
91
|
+
map['dependencies'] = [key]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'cocoapods-modularization/private/private_cache'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Mod < Command
|
6
|
+
class Base < Mod
|
7
|
+
|
8
|
+
self.summary = 'Settle a base directory for pod specs'
|
9
|
+
|
10
|
+
self.description = <<-DESC
|
11
|
+
Settle a base directory for pod specs
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('PATH', true),
|
16
|
+
]
|
17
|
+
|
18
|
+
def initialize(argv)
|
19
|
+
@path = argv.shift_argument
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate!
|
24
|
+
super
|
25
|
+
help! 'A Path for the Base is required.' unless @path
|
26
|
+
help! 'The Path illlegal.' unless @path =~ /\/([^\/]*)/
|
27
|
+
end
|
28
|
+
|
29
|
+
def run
|
30
|
+
Private::PrivateCache.set_search_path(@path)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'cocoapods-modularization/meta'
|
2
|
+
require 'cocoapods-modularization/private'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Mod < Command
|
7
|
+
class Binary < Mod
|
8
|
+
|
9
|
+
self.summary = 'Use binary of a component'
|
10
|
+
|
11
|
+
self.description = <<-DESC
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME', true),
|
16
|
+
]
|
17
|
+
|
18
|
+
def self.options
|
19
|
+
[
|
20
|
+
["--path='./'", 'local_path of binary'],
|
21
|
+
["--local", 'use local binary, if local path is not specified, will clone from remote']
|
22
|
+
].concat(super)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(argv)
|
26
|
+
@name = argv.shift_argument
|
27
|
+
@path = argv.option('path', nil)
|
28
|
+
@use_local = argv.flag?('local')
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate!
|
33
|
+
super
|
34
|
+
help! "meta not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.meta_path)
|
35
|
+
help! "data not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.data_path)
|
36
|
+
|
37
|
+
help! 'A name for the Pod is required.' unless @name
|
38
|
+
help! 'The Pod name cannot contain spaces.' if @name =~ /\s/
|
39
|
+
help! 'The Pod name cannot contain plusses.' if @name =~ /\+/
|
40
|
+
help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
|
41
|
+
|
42
|
+
dependencies = Meta::MetaAccessor.dependencies()
|
43
|
+
help! "#{@name} not found in dependencies: #{dependencies}" unless dependencies.include?(@name)
|
44
|
+
|
45
|
+
if @path.kind_of?(String) && @path.empty?
|
46
|
+
podspec_exists = false
|
47
|
+
if File::exists?(@path)
|
48
|
+
podspec_exists = true
|
49
|
+
elsif File::exists?("#{@path}/#{@name}.podspec")
|
50
|
+
podspec_exists = true
|
51
|
+
end
|
52
|
+
help! "#{@name}.podspec not found #{@path}" unless podspec_exists
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def run
|
57
|
+
begin
|
58
|
+
Meta::MetaAccessor.set_binary(@name)
|
59
|
+
if @path && !@path.empty?
|
60
|
+
UI.puts("Switch #{@name} to local path")
|
61
|
+
# 写入缓存
|
62
|
+
Private::PrivateCache.write_path_into_cache(@name, @path)
|
63
|
+
Meta::MetaAccessor.set_local_path(@name, @path)
|
64
|
+
elsif @use_local
|
65
|
+
path = Private::PrivateCache.start(@name)
|
66
|
+
UI.puts("Switch #{@name} to local path: #{path}")
|
67
|
+
Meta::MetaAccessor.set_local_path(@name, path)
|
68
|
+
else
|
69
|
+
UI.puts("Switch #{@name} to remote")
|
70
|
+
Meta::MetaAccessor.remove_local_path(@name)
|
71
|
+
end
|
72
|
+
|
73
|
+
Meta::MetaReference.encode_podfile
|
74
|
+
UI.puts("Podfile encoded")
|
75
|
+
rescue Exception => e
|
76
|
+
UI.puts e
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'cocoapods-modularization/private'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Mod < Command
|
6
|
+
class Config < Mod
|
7
|
+
self.summary = 'Config source repo and binary repo'
|
8
|
+
|
9
|
+
self.description = <<-DESC
|
10
|
+
'pod mod config NAME URL --source' will add NAME into pod repo list, and cocoapods-modulization will use it as source repo.
|
11
|
+
So do 'pod mod config NAME URL --binary'
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME', true),
|
16
|
+
CLAide::Argument.new('URL', true)
|
17
|
+
]
|
18
|
+
|
19
|
+
def self.options
|
20
|
+
[
|
21
|
+
['--binary', 'Mark NAME as binary repo, is this options is not specified, repo will be marked as source repo']
|
22
|
+
].concat(super)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(argv)
|
26
|
+
@name = argv.shift_argument
|
27
|
+
@url = argv.shift_argument
|
28
|
+
@binary = argv.flag?('binary')
|
29
|
+
@binary ||= false
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate!
|
34
|
+
super
|
35
|
+
unless @name && @url
|
36
|
+
help! 'Adding a repo needs a `NAME` and a `URL`.'
|
37
|
+
end
|
38
|
+
if @name == 'trunk'
|
39
|
+
raise Informative,
|
40
|
+
"Repo name `trunk` is reserved for CocoaPods' main spec repo accessed via CDN."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def run
|
45
|
+
Private::PrivateCache.cache_repo(@name, @url, @binary)
|
46
|
+
`pod repo add #{@name} #{@url}`
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class Mod < Command
|
4
|
+
class Create < Mod
|
5
|
+
self.summary = 'Create a template repo with modulization template.'
|
6
|
+
|
7
|
+
self.description = <<-DESC
|
8
|
+
Be sure that you hase access right to gitlab.appshahe.com.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
self.arguments = [
|
12
|
+
CLAide::Argument.new('NAME', true)
|
13
|
+
]
|
14
|
+
|
15
|
+
def initialize(argv)
|
16
|
+
@name = argv.shift_argument
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate!
|
21
|
+
super
|
22
|
+
help! 'A name for the Pod is required.' unless @name
|
23
|
+
help! 'The Pod name cannot contain spaces.' if @name =~ /\s/
|
24
|
+
help! 'The Pod name cannot contain plusses.' if @name =~ /\+/
|
25
|
+
help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
|
26
|
+
end
|
27
|
+
|
28
|
+
def run
|
29
|
+
`pod lib create #{@name} --template-url='http://gitlab.appshahe.com/ios-specs/template.git'`
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'cocoapods-modularization/meta'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Mod < Command
|
6
|
+
class Inspect < Mod
|
7
|
+
self.summary = 'This command is for debug'
|
8
|
+
|
9
|
+
self.description = <<-DESC
|
10
|
+
DESC
|
11
|
+
|
12
|
+
def initialize(argv)
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def validate!
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
Meta::MetaReference.encode_podfile(true)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'cocoapods-modularization/meta'
|
2
|
+
require 'cocoapods-modularization/private'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Mod < Command
|
7
|
+
class Source < Mod
|
8
|
+
|
9
|
+
self.summary = 'Use source of a component'
|
10
|
+
|
11
|
+
self.description = <<-DESC
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME', true)
|
16
|
+
]
|
17
|
+
|
18
|
+
def self.options
|
19
|
+
[
|
20
|
+
['--path=URL', 'local filePath of the component'],
|
21
|
+
["--local", 'use local source, if local path is not specified, will clone from remote']
|
22
|
+
].concat(super)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(argv)
|
26
|
+
@name = argv.shift_argument
|
27
|
+
@path = argv.option('path', nil)
|
28
|
+
@use_local = argv.flag?('local')
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate!
|
33
|
+
super
|
34
|
+
help! "meta.yml not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.meta_path)
|
35
|
+
help! "data.yml not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.data_path)
|
36
|
+
|
37
|
+
help! 'A name for the Pod is required.' unless @name
|
38
|
+
help! 'The Pod name cannot contain spaces.' if @name =~ /\s/
|
39
|
+
help! 'The Pod name cannot contain plusses.' if @name =~ /\+/
|
40
|
+
help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
|
41
|
+
|
42
|
+
dependencies = Meta::MetaAccessor.dependencies()
|
43
|
+
help! "#{@name} not found in dependencies: #{dependencies}" unless dependencies.include?(@name)
|
44
|
+
|
45
|
+
if @path.kind_of?(String) && @path.empty?
|
46
|
+
podspec_exists = false
|
47
|
+
if File::exists?(@path)
|
48
|
+
podspec_exists = true
|
49
|
+
elsif File::exists?("#{@path}/#{@name}.podspec")
|
50
|
+
podspec_exists = true
|
51
|
+
end
|
52
|
+
help! "#{@name}.podspec not found #{@path}" unless podspec_exists
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def run
|
57
|
+
begin
|
58
|
+
Meta::MetaAccessor.set_source(@name)
|
59
|
+
if @path && !@path.empty?
|
60
|
+
UI.puts("Switch #{@name} to local path")
|
61
|
+
Private::PrivateCache.write_path_into_cache(@name, @path)
|
62
|
+
Meta::MetaAccessor.set_local_path(@name, @path)
|
63
|
+
elsif @use_local
|
64
|
+
path = Private::PrivateCache.start(@name)
|
65
|
+
UI.puts("Switch #{@name} to local path: #{path}")
|
66
|
+
Meta::MetaAccessor.set_local_path(@name, path)
|
67
|
+
else
|
68
|
+
UI.puts("Switch #{@name} to remote")
|
69
|
+
Meta::MetaAccessor.remove_local_path(@name)
|
70
|
+
end
|
71
|
+
|
72
|
+
Meta::MetaReference.encode_podfile
|
73
|
+
UI.puts("Podfile encoded")
|
74
|
+
rescue Exception => e
|
75
|
+
UI.puts e
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'cocoapods-modularization/meta'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Mod < Command
|
6
|
+
class Sync < Mod
|
7
|
+
self.summary = 'Generate meta.yml、data.yml、Podfile.yml with Podfile'
|
8
|
+
|
9
|
+
self.description = <<-DESC
|
10
|
+
In meta.yml, you can update structure of the Pod such as dependecies、sources、plugins.Meta.yml is jus like a index of a Pod.
|
11
|
+
There stores entities of all dependencies in data.yml such as version、source.
|
12
|
+
Podfile.yml is just similar with data.yml but Podfile.yml is git ignored.
|
13
|
+
DESC
|
14
|
+
|
15
|
+
def initialize(argv)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate!
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def run
|
24
|
+
Meta::MetaReference.decode_podfile(config)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class Mod < Command
|
4
|
+
class Update < Mod
|
5
|
+
|
6
|
+
self.summary = 'Update a component'
|
7
|
+
|
8
|
+
self.description = <<-DESC
|
9
|
+
pod dep update specs --version=0.0.1
|
10
|
+
DESC
|
11
|
+
|
12
|
+
self.arguments = [
|
13
|
+
CLAide::Argument.new('NAME', true)
|
14
|
+
]
|
15
|
+
|
16
|
+
def self.options
|
17
|
+
[
|
18
|
+
['--version=VERSION', 'version of the component, if this option is not indicate, version will be auto increased']
|
19
|
+
].concat(super)
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(argv)
|
23
|
+
@name = argv.shift_argument
|
24
|
+
|
25
|
+
version = Meta::MetaAccessor.version(@name)
|
26
|
+
@version = argv.option('version', version_auto_increase(version))
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def validate!
|
31
|
+
super
|
32
|
+
help! "meta not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.meta_path)
|
33
|
+
help! "data not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.data_path)
|
34
|
+
|
35
|
+
help! 'A component name is required.' unless @name
|
36
|
+
dependencies = Meta::MetaAccessor.dependencies()
|
37
|
+
help! "#{@name} not found in dependencies: #{dependencies}" unless dependencies.include?(@name)
|
38
|
+
|
39
|
+
help! "version (#{@version}) illlegal" unless @version =~ /\d+\.\d+\.\d+/
|
40
|
+
end
|
41
|
+
|
42
|
+
def run
|
43
|
+
Meta::MetaAccessor.update_dep(@name, @version)
|
44
|
+
UI.puts("#{@name} has been updated to #{@version}")
|
45
|
+
|
46
|
+
Meta::MetaReference.encode_podfile
|
47
|
+
UI.puts("Podfile encoded")
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
def version_auto_increase(version_input)
|
52
|
+
version = version_input
|
53
|
+
version_elements = version.to_s.split(".")
|
54
|
+
return nil unless version_elements.size == 3
|
55
|
+
last_version_element = version_elements.at(2)
|
56
|
+
last_version_num = last_version_element.to_i
|
57
|
+
last_version_num = last_version_num + 1
|
58
|
+
version_elements[2] = last_version_num
|
59
|
+
return version_elements.join(".")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'cocoapods-modularization/command/mod/create'
|
2
|
+
require 'cocoapods-modularization/command/mod/sync'
|
3
|
+
require 'cocoapods-modularization/command/mod/inspect'
|
4
|
+
require 'cocoapods-modularization/command/mod/source'
|
5
|
+
require 'cocoapods-modularization/command/mod/binary'
|
6
|
+
require 'cocoapods-modularization/command/mod/config'
|
7
|
+
require 'cocoapods-modularization/command/mod/add'
|
8
|
+
require 'cocoapods-modularization/command/mod/update'
|
9
|
+
require 'cocoapods-modularization/command/mod/base'
|
10
|
+
|
11
|
+
module Pod
|
12
|
+
class Command
|
13
|
+
class Mod < Command
|
14
|
+
self.summary = 'cocoapods-modularization commands group'
|
15
|
+
|
16
|
+
def initialize(argv)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate!
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|