cocoapods-dev-env 0.1.0 → 0.2.0

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: c30aae7b6ff74fb5343c4562d3304650013fee69001f229bf3fa24f111bde341
4
- data.tar.gz: 1e24998ffa9d590a45f85375ec0884ed27928b151e8ced8372356a44f86ba335
3
+ metadata.gz: d78ac653372d85eb851f44990f6a247d1ea3ae2af35d953034ef82d7273bf759
4
+ data.tar.gz: cd0871f2a8e980ff86138b89617e428b011149f32c145a0efab571f946d5dc64
5
5
  SHA512:
6
- metadata.gz: 51a5c30eae583f03e56672ec1a21b77ddce37751371dfa97175fcc72662f52f2fa1d205ac838b28d713a99781072faa0ef45c765ba4565783b558bf2748d7402
7
- data.tar.gz: e529a467ad61d150169920ff4632716da6d30f338fd95b7f92585e60b36f2e6a85f235878fa26c6a84574a0e1ac5e02858ad9ecbbb00ba529d9ca5552556fa39
6
+ metadata.gz: 53c2713ed99af42e1320e3d8264c51f98227588d501a8a2eb989538de90d75044af096391f593fa99ca999037e49a0a6d0d7a2cb96d3d56cebd3e311f6e969c1
7
+ data.tar.gz: 64879fdb7ba348181c7bf02718ebdae32cb01cc6bf8c6d2fa385d42c7bbc935ced96936846d666b34c8fc7ab4bae68e7b2780d30097370a92c165c583e200219
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Cocoapods::Dev::Env
1
+ # Cocoapods Plugin: cocoapods-dev-env
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cocoapods/dev/env`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ cocoapods-dev-env is a useful plugin for cocoapods to manage your self-developing pods.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ When we have too many pod to developing, maybe you only care about one or two pods in local, this plugin may be can help you.
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,7 +22,27 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ In your podfile
26
+ ```ruby
27
+ plugin 'cocoapods-dev-env'
28
+
29
+ pod 'SomePod', :git => 'xxxxxx', :branch => 'master', :tag => '0.0.2.2', :dev_env => 'dev'
30
+ ```
31
+ We see a addtional key "dev_env" in defineation. And you must put "git", "branch", "tag" for the plugin.
32
+
33
+ 1. When you define "dev_env" to "dev", and run ```pod install``` .
34
+ We will add a ```git submodule``` linked to your pod git repo to local.
35
+ And check if the ```HEAD``` commit id of the branch is same to ```tag```commit id.
36
+
37
+ 2. When you define "dev_env" to "beta", and run ```pod install``` .
38
+ We will use the ```tag```: "tag_beta", e.g.: "0.0.2.2_beta"
39
+ When the local git submodule is exist, whe aslo try to check and add tag "tag_beta" on it and push to the origin.
40
+ Finally the state clean submodule will be removed automatically.
41
+
42
+ 3. When you define "dev_env" to "release", and run ```pod install``` .
43
+ We want to use the release version in cocoapods repo. And do many check for state, and help you to release the not released pod.
44
+ **But we hav't done it.**
45
+
26
46
 
27
47
  ## Development
28
48
 
@@ -32,7 +52,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
52
 
33
53
  ## Contributing
34
54
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cocoapods-dev-env. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/YoudaoMobile/cocoapods-dev-env. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
56
 
37
57
  ## License
38
58
 
@@ -40,4 +60,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
60
 
41
61
  ## Code of Conduct
42
62
 
43
- Everyone interacting in the Cocoapods::Dev::Env project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cocoapods-dev-env/blob/master/CODE_OF_CONDUCT.md).
63
+ Everyone interacting in the Cocoapods::Dev::Env project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/YoudaoMobile/cocoapods-dev-env/blob/master/CODE_OF_CONDUCT.md).
@@ -1,7 +1,7 @@
1
1
  module Cocoapods
2
2
  module Dev
3
3
  module Env
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
@@ -9,6 +9,7 @@ end
9
9
 
10
10
 
11
11
  $processedPodsState = Hash.new
12
+ $processedPodsOptions = Hash.new
12
13
 
13
14
  module Pod
14
15
  class DevEnv
@@ -19,35 +20,128 @@ module Pod
19
20
  class Podfile
20
21
  class TargetDefinition
21
22
 
23
+ def checkAndRemoveSubmodule(path)
24
+ currentDir = Dir.pwd
25
+ Dir.chdir(path)
26
+ output = `git status -s`
27
+ puts output
28
+ if output.length == 0
29
+ output = `git status`
30
+ if output.include?("push")
31
+ raise "submodule #{path} 移除失败,有推送的修改"
32
+ end
33
+ else
34
+ raise "submodule #{path} 移除失败,有未提交的修改"
35
+ end
36
+ Dir.chdir(currentDir)
37
+ `
38
+ git submodule deinit #{path}
39
+ rm -rf #{path}
40
+ git rm #{path}
41
+ `
42
+ end
43
+
44
+ def checkTagOrBranchIsEqalToHead(branchOrTag, path)
45
+ currentDir = Dir.pwd
46
+ Dir.chdir(path)
47
+ headCommitID = `git rev-parse HEAD`
48
+ tagCommitID = `git rev-parse #{branchOrTag}`
49
+ UI.puts headCommitID
50
+ Dir.chdir(currentDir)
51
+ return (headCommitID.length > 0 && headCommitID == tagCommitID)
52
+ end
53
+
22
54
  ## --- option for setting using prebuild framework ---
23
55
  def parse_pod_dev_env(name, requirements)
24
56
  options = requirements.last
25
57
  pod_name = Specification.root_name(name)
26
- dev_env = $processedPodsState[pod_name]
58
+ last_options = $processedPodsOptions[pod_name]
59
+ if (last_options != nil)
60
+ UI.puts "####### #{name} use last_options: #{last_options}"
61
+ if options != nil && options.is_a?(Hash)
62
+ requirements[requirements.length - 1] = last_options
63
+ else
64
+ requirements.push(last_options)
65
+ end
66
+
67
+ return
68
+ end
27
69
  if options.is_a?(Hash)
28
- if dev_env == nil
29
- if options[Pod::DevEnv::keyword] != nil
30
- dev_env = options.delete(Pod::DevEnv::keyword)
31
- $processedPodsState[pod_name] = dev_env
32
- else
33
- options.delete(Pod::DevEnv::keyword)
34
- return
35
- end
70
+ dev_env = options.delete(Pod::DevEnv::keyword)
71
+ if dev_env == nil
72
+ return
36
73
  end
37
- UI.puts "####### proccess dev-env for pod #{pod_name} env: #{dev_env}"
38
- if dev_env == 'dev'
39
- git = options.delete(:git)
40
- branch = options.delete(:branch)
74
+ UI.puts "####### proccess dev-env for pod #{name} env: #{dev_env}"
75
+ git = options.delete(:git)
76
+ branch = options.delete(:branch)
77
+ tag = options.delete(:tag)
78
+ path = options.delete(:path)
79
+ if path == nil
41
80
  path = "./developing_pods/#{pod_name}"
81
+ end
82
+ if dev_env == 'dev'
83
+ # 开发模式,使用path方式引用本地的submodule git库
42
84
  if !File.directory?(path)
43
- `git submodule add -b #{branch} #{git} #{path}`
85
+ UI.puts "####### add submodule for #{pod_name}"
86
+ `git submodule add --force -b #{branch} #{git} #{path}`
87
+
88
+ if !checkTagOrBranchIsEqalToHead(tag, path)
89
+ raise "#{pod_name} branch:#{branch} 与 tag:#{tag} 内容不同步,请自行确认所用分支和tag后重新 install"
90
+ end
44
91
  end
45
92
  options[:path] = path
46
- UI.puts "####### enable dev-mode for #{pod_name}"
93
+ UI.puts "####### enabled dev-mode for #{pod_name}"
94
+ elsif dev_env == 'beta'
95
+ # Beta模式,使用tag引用远端git库的代码
96
+ if File.directory?(path)
97
+ # 从Dev模式刚刚切换过来,需要打tag并且push
98
+ UI.puts "####### gen beta env for #{pod_name}"
99
+ if tag == nil || tag.length == 0
100
+ raise "#{pod_name} 未定义tag"
101
+ end
102
+ tag = "#{tag}_beta"
103
+ currentDir = Dir.pwd
104
+ Dir.chdir(path)
105
+ output = `git status -s`
106
+ puts output
107
+ if output.length == 0
108
+ output = `git status`
109
+ if output.include?("push")
110
+ ret = system("git push")
111
+ if ret != true
112
+ raise "#{pod_name} push 失败"
113
+ end
114
+ end
115
+ else
116
+ raise "有未提交的数据"
117
+ end
118
+ ## TODO:: 检查tag版本号与podspec里的版本号是否一致
119
+ ret = system("git tag #{tag}")
120
+ if ret == true
121
+ ret = system("git push origin #{tag}")
122
+ if ret != true
123
+ raise "#{pod_name} push tag 失败"
124
+ end
125
+ else
126
+ if checkTagOrBranchIsEqalToHead(tag, "./")
127
+ UI.puts "#{pod_name} 没做任何调整,切换回beta"
128
+ else
129
+ raise "#{pod_name} tag:#{tag} 已存在, 请确认已经手动修改tag版本号"
130
+ end
131
+ end
132
+ Dir.chdir(currentDir)
133
+ checkAndRemoveSubmodule(path)
134
+ end
135
+ options[:git] = git
136
+ options[:tag] = tag
137
+ UI.puts "####### enabled beta-mode for #{pod_name}"
138
+ elsif dev_env == 'release'
139
+ # Release模式,直接使用远端对应的版本
140
+ # 需要考虑从dev直接跳跃到release的情况,需要谨慎处理,给予报错或执行两次的操作
47
141
  else
48
- # 移除有可能误删往提交的内容,需要谨慎处理
49
- #`git rm #{path}`
142
+ raise ":dev_env 必须要设置成 dev/beta/release之一,不接受其他值"
50
143
  end
144
+ $processedPodsOptions[pod_name] = options
51
145
  requirements.pop if options.empty?
52
146
  end
53
147
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-dev-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 吴锡苗
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-10 00:00:00.000000000 Z
11
+ date: 2019-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler