cocoapods-x 0.0.4

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.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +36 -0
  4. data/lib/cocoapods-x.rb +1 -0
  5. data/lib/cocoapods-x/command.rb +18 -0
  6. data/lib/cocoapods-x/command/edit.rb +81 -0
  7. data/lib/cocoapods-x/command/environment.rb +17 -0
  8. data/lib/cocoapods-x/command/environment/init.rb +29 -0
  9. data/lib/cocoapods-x/command/environment/install.rb +29 -0
  10. data/lib/cocoapods-x/command/environment/update.rb +30 -0
  11. data/lib/cocoapods-x/command/install.rb +35 -0
  12. data/lib/cocoapods-x/command/libary.rb +16 -0
  13. data/lib/cocoapods-x/command/libary/build.rb +14 -0
  14. data/lib/cocoapods-x/command/libary/create.rb +49 -0
  15. data/lib/cocoapods-x/command/repo.rb +91 -0
  16. data/lib/cocoapods-x/command/update.rb +28 -0
  17. data/lib/cocoapods-x/command/xcode.rb +15 -0
  18. data/lib/cocoapods-x/command/xcode/clean.rb +75 -0
  19. data/lib/cocoapods-x/command/xcode/open.rb +26 -0
  20. data/lib/cocoapods-x/extension.rb +4 -0
  21. data/lib/cocoapods-x/extension/configure.rb +84 -0
  22. data/lib/cocoapods-x/extension/environment.rb +31 -0
  23. data/lib/cocoapods-x/extension/installer.rb +145 -0
  24. data/lib/cocoapods-x/extension/installer/builder.rb +36 -0
  25. data/lib/cocoapods-x/extension/installer/dsl.rb +94 -0
  26. data/lib/cocoapods-x/extension/installer/podfile.rb +66 -0
  27. data/lib/cocoapods-x/extension/sandbox.rb +64 -0
  28. data/lib/cocoapods-x/extension/sandbox/project.rb +51 -0
  29. data/lib/cocoapods-x/extension/sandbox/projects.rb +25 -0
  30. data/lib/cocoapods-x/extension/sandbox/protocol.rb +24 -0
  31. data/lib/cocoapods-x/extension/sandbox/repos.rb +81 -0
  32. data/lib/cocoapods-x/extension/sandbox/template.rb +77 -0
  33. data/lib/cocoapods-x/extension/sandbox/workspace.rb +84 -0
  34. data/lib/cocoapods-x/extension/xcode.rb +1 -0
  35. data/lib/cocoapods-x/extension/xcode/open.rb +44 -0
  36. data/lib/cocoapods-x/gem_version.rb +3 -0
  37. data/lib/cocoapods_plugin.rb +2 -0
  38. metadata +109 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 42f6d120ab8628286834e79eb373915db74767a234f92d43aaa936a020941fbd
4
+ data.tar.gz: 38233cd868c014a4d2bc76af14adfc79c6d2405d46dfa8b99c4047648e3bd884
5
+ SHA512:
6
+ metadata.gz: 282fba66c0f61166fae1999a438622a4ef18f12a69d3dc149d9751258d288cf8c789c90e8a11742472ddcfba2f7eb03d55806d3f68e6a42838b33885f8bdde40
7
+ data.tar.gz: e76c09f47966545cf60303894e1b1a2dd15065bb8edadd55b4e0108d7bfd759dba7dfcd646ea1a480b3e7291c4cafb1051b243d8c0e4b9f31dc7e76a76969fa4
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2020 panghu <panghu.lee@gmail.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ # cocoapods-x
2
+
3
+ 扩展pod x命令, 实现快速清理缓存, 快速打开Xcode等操作, 使用souce, pods两个dsl实现快速切换pod 'NAME', :path=>'url'开发模式, 对壳工程无入侵.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-x
8
+
9
+ ## Usage
10
+
11
+ alias pox="pod x"
12
+ pox env install # 拉取必要的模版文件在~/.cocoapods/x中, 用于包括lib模版 pods模版 source模版
13
+ pox env update # 更新到最新的模版文件
14
+ pox env init # 在拥有Podfile的项目中初始化构建环境, 映射的工程目录在~/.cocoapods/x/projects/{name}中
15
+ pox lib create NAME # 创建项目脚手架
16
+ pox lib build # 尚未开发完成
17
+ pox xc clean # 清理 Pods Podfile.lock 和 DerivedData
18
+ pox xc open # 打开Xcode, 优先打开当前目录的 *.xcworkspace
19
+
20
+ 例: 在项目Demo中, 将AFNetworking切换到Development Pods开发模式
21
+ (Demo) $ pox env init
22
+ (Demo) $ pox edit --pods # 编辑pods文件
23
+ 在pods文件中添加
24
+ pod 'AFNetworking'
25
+ (Demo) $ pox edit --source # 编辑source文件
26
+ 在source文件中添加
27
+ source 'https://github.com' do # source 'git@github.com' do
28
+ pod 'AFNetworking'
29
+ end
30
+ (Demo) $ pod install
31
+ 完成AFNetworking开发模式切换, AFNetworking将被存放在Demo映射项目下的repos中.
32
+ 通过命令快速打开AFNetworking所在目录
33
+ (Demo) $ pox repos AFNetworking
34
+
35
+ pods 文件用于声明需要切换Development Pods的pod, 不同的项目拥有各自的pods文件, 项目隔离.
36
+ source 文件用于声明pod对应git源地址, 全局公用一份.
@@ -0,0 +1 @@
1
+ require 'cocoapods-x/gem_version'
@@ -0,0 +1,18 @@
1
+ require 'cocoapods-x/command/edit'
2
+ require 'cocoapods-x/command/environment'
3
+ require 'cocoapods-x/command/install'
4
+ require 'cocoapods-x/command/libary'
5
+ require 'cocoapods-x/command/repo'
6
+ require 'cocoapods-x/command/update'
7
+ require 'cocoapods-x/command/xcode'
8
+
9
+ module Pod
10
+ class Command
11
+ class X < Command
12
+
13
+ self.abstract_command = true
14
+ self.summary = 'Cocoapods Extension X.'
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,81 @@
1
+ require 'cocoapods-x/extension/sandbox'
2
+ require 'cocoapods-x/extension/environment'
3
+
4
+ module Pod
5
+ class Command
6
+ class X < Command
7
+ class Edit < X
8
+
9
+ self.summary = 'Cocoapods X Edit.'
10
+ self.description = <<-DESC
11
+ NAME is 'pods' edit pods file,\n
12
+ NAME is 'sources' edit source file,\n
13
+ NAME is 'podfile' edit Podfile file.
14
+ DESC
15
+
16
+ self.arguments = [
17
+ CLAide::Argument.new('NAME', true),
18
+ ]
19
+
20
+ def initialize(argv)
21
+ @name = argv.shift_argument
22
+ super
23
+ end
24
+
25
+ def run
26
+ if @name == 'pods'
27
+ open_pods!
28
+ elsif @name == 'sources'
29
+ open_source!
30
+ elsif @name == 'Podfile'
31
+ open_podfile!
32
+ else
33
+ self.help!
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ extend Executable
40
+ executable :open
41
+
42
+ def open_pods!
43
+ project = Pod::X::Environment::init!
44
+ open_ide! project.pods_file
45
+ end
46
+
47
+ def open_source!
48
+ workspace = Pod::X::Environment::install!
49
+ open_ide! workspace.source_file
50
+ end
51
+
52
+ def open_podfile!
53
+ project_url = Pathname(Dir.pwd)
54
+ podfile = Pod::X::Sandbox::podfile_exists! project_url
55
+ open_ide! podfile
56
+ end
57
+
58
+ private
59
+
60
+ def open_ide! url
61
+ ide = sel_ide
62
+ if ide
63
+ open! ['-a', ide, url]
64
+ else
65
+ open! [url]
66
+ end
67
+ end
68
+
69
+ def sel_ide
70
+ ides = ['/Applications/Visual Studio Code.app', '/Applications/Sublime Text.app', '/Applications/Xcode.app']
71
+ ides.each do |i|
72
+ path = Pathname(i)
73
+ return path if path.exist?
74
+ end
75
+ nil
76
+ end
77
+
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,17 @@
1
+ require 'cocoapods-x/command/environment/init'
2
+ require 'cocoapods-x/command/environment/install'
3
+ require 'cocoapods-x/command/environment/update'
4
+
5
+ module Pod
6
+ class Command
7
+ class X < Command
8
+ class Env < X
9
+
10
+ self.abstract_command = true
11
+ self.summary = 'Cocoapods X Environment.'
12
+
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,29 @@
1
+ require 'cocoapods-x/extension/environment'
2
+
3
+ module Pod
4
+ class Command
5
+ class X < Command
6
+ class Env < X
7
+ class Init < Env
8
+
9
+ self.summary = 'Init project X environment.'
10
+ self.description = 'Init project X environment.'
11
+
12
+ def initialize(argv)
13
+ super
14
+ end
15
+
16
+ def run
17
+ begin
18
+ UI.puts 'Pod::X '.magenta + "Initing X environment."
19
+ project = Pod::X::Environment::init!
20
+ UI.puts 'Pod::X '.magenta + "'#{project.project_name}' initialization complete!".green
21
+ rescue => exception
22
+ UI.puts '[!] Pod::X '.magenta + "#{exception}".red
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require 'cocoapods-x/extension/environment'
2
+
3
+ module Pod
4
+ class Command
5
+ class X < Command
6
+ class Env < X
7
+ class Install < Env
8
+
9
+ self.summary = 'Install X environment.'
10
+ self.description = 'Install X environment.'
11
+
12
+ def initialize(argv)
13
+ super
14
+ end
15
+
16
+ def run
17
+ begin
18
+ UI.puts 'Pod::X '.magenta + "Installing X environment."
19
+ Pod::X::Environment::install!
20
+ UI.puts 'Pod::X '.magenta + "Env installation complete!".green
21
+ rescue => exception
22
+ UI.puts '[!] Pod::X '.magenta + "#{exception}".red
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ require 'cocoapods-x/extension/environment'
2
+
3
+ module Pod
4
+ class Command
5
+ class X < Command
6
+ class Env < X
7
+ class Update < Env
8
+
9
+ self.summary = 'Update X environment.'
10
+ self.description = 'Update X environment.'
11
+
12
+ def initialize(argv)
13
+ super
14
+ end
15
+
16
+ def run
17
+ begin
18
+ UI.puts 'Pod::X '.magenta + "Updating X environment."
19
+ Pod::X::Environment::update!
20
+ UI.puts 'Pod::X '.magenta + "Env installation complete!".green
21
+ rescue => exception
22
+ UI.puts '[!] Pod::X '.magenta + "#{exception}".red
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,35 @@
1
+ require 'cocoapods-x/extension/xcode/open'
2
+
3
+ module Pod
4
+ class Command
5
+ class X < Command
6
+ class Install < X
7
+
8
+ self.summary = Pod::Command::Install::summary
9
+
10
+ self.description = Pod::Command::Install::description
11
+
12
+ def self.options
13
+ options = Pod::Command::Install::options
14
+ options << ['--open', 'Remove all the cached without asking']
15
+ options
16
+ end
17
+
18
+ def initialize(argv)
19
+ @wipe_all = argv.flag?('open')
20
+ @install = Pod::Command::Install::new(argv)
21
+ super
22
+ end
23
+
24
+ def run
25
+ @install::run
26
+ if @wipe_all
27
+ xcopen = Pod::X::Xcode::Open::new
28
+ xcopen.run!
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,16 @@
1
+ require 'cocoapods-x/command/libary/build'
2
+ require 'cocoapods-x/command/libary/create'
3
+
4
+ module Pod
5
+ class Command
6
+ class X < Command
7
+ class Lib < X
8
+
9
+ self.abstract_command = true
10
+ self.summary = 'Cocoapods Extension X Lib.'
11
+
12
+ end
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,14 @@
1
+ module Pod
2
+ class Command
3
+ class X < Command
4
+ class Lib < X
5
+ class Build < Lib
6
+
7
+ self.abstract_command = true
8
+ self.summary = 'Cocoapods X Lib Build.'
9
+
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,49 @@
1
+ require 'cocoapods-x/extension/sandbox'
2
+
3
+ module Pod
4
+ class Command
5
+ class X < Command
6
+ class Lib < X
7
+ class Create < Lib
8
+
9
+ extend Executable
10
+ executable :rm
11
+
12
+ self.summary = 'Creates a new project'
13
+ self.description = <<-DESC
14
+ Creates a scaffold for the development of a new project named `NAME`.
15
+ DESC
16
+
17
+ self.arguments = [
18
+ CLAide::Argument.new('NAME', true),
19
+ ]
20
+
21
+ def initialize(argv)
22
+ @name = argv.shift_argument
23
+ super
24
+ end
25
+
26
+ def run
27
+ project_name = @name
28
+ target_url = File.join(Dir::pwd, project_name)
29
+ configure_url = Pod::X::Sandbox::workspace::template::configure
30
+ template_url = Pod::X::Sandbox::workspace::template::ios_template
31
+ if Dir::exist?(target_url) && !Dir::empty?(target_url)
32
+ UI.puts 'Pod::X '.magenta + "fatal: destination path '#{project_name}' already exists and is not an empty directory.".red
33
+ else
34
+ rm! ['-rf', target_url]
35
+ if !template_url.exist?
36
+ Pod::X::Sandbox::update!
37
+ end
38
+ UI.section("Configuring #{project_name} template.") do
39
+ system('ruby', configure_url.to_s, template_url.to_s, target_url.to_s, project_name.to_s)
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,91 @@
1
+ module Pod
2
+ class Command
3
+ class X < Command
4
+ class Repo < X
5
+
6
+ self.summary = 'Opens pods dir.'
7
+ self.description = <<-DESC
8
+ Opens pods.
9
+ DESC
10
+
11
+ self.arguments = [
12
+ CLAide::Argument.new('NAME', true),
13
+ ]
14
+
15
+ def self.options
16
+ [
17
+ ['--terminal', 'Use terminal open pod']
18
+ ].concat(super)
19
+ end
20
+
21
+ def initialize(argv)
22
+ @name = argv.shift_argument
23
+ @wipe_terminal = argv.flag?('terminal')
24
+ super
25
+ end
26
+
27
+ def run
28
+ pods = Pod::X::Sandbox::workspace::all_pods
29
+ if !@name.nil? && @name.size > 0
30
+ pods = pods.select{ |pod| pod.name == @name }
31
+ end
32
+ open_pods pods
33
+ end
34
+
35
+ private
36
+
37
+ extend Executable
38
+ executable :open
39
+
40
+ def open_pods pods
41
+ return if (pods.nil? || pods.size <= 0)
42
+
43
+ choices = Array::new
44
+ pods.each do |pod|
45
+ choice = pod.name
46
+ unless pod.branch.nil?
47
+ choice += " (#{pod.branch})".red
48
+ end
49
+ unless pod.project.nil?
50
+ choice += " => project: #{pod.project}"
51
+ end
52
+ choice += " => path: #{pod.location_url}"
53
+ choices << choice
54
+ end
55
+
56
+ begin
57
+ if choices.size == 1
58
+ index = 0
59
+ else
60
+ index = UI.choose_from_array(choices, 'Which item do you?')
61
+ end
62
+ url = pods[index].location_url
63
+ open_url! url
64
+ rescue => exception
65
+ UI.puts '[!] Pod::X '.magenta + "#{exception}".red
66
+ end
67
+
68
+ end
69
+
70
+ def open_url! url
71
+ ter = sel_ter
72
+ if @wipe_terminal && ter
73
+ open! ['-a', ter, url]
74
+ else
75
+ open! [url]
76
+ end
77
+ end
78
+
79
+ def sel_ter
80
+ ters = ['/Applications/iTerm.app', '/System/Applications/Utilities/Terminal.app']
81
+ ters.each do |t|
82
+ path = Pathname(t)
83
+ return path if path.exist?
84
+ end
85
+ nil
86
+ end
87
+
88
+ end
89
+ end
90
+ end
91
+ end