ormdev 0.1.7 → 0.1.8

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: 52473a5610798b6c4cac93a671ae0b55c452fba5d7815b7cecf80e925acef601
4
- data.tar.gz: 7bcebd831048dafbacaa1c10999f45213d24efe8a074f7a5cca26ca6299fe1b1
3
+ metadata.gz: 0d2bdbfdfcd5e054ba3331fabb1aec411d9c2b7eee6622473026cab8a975a0ad
4
+ data.tar.gz: 558371dd86d508d209426f1dab8e507b2cfaa42690d51cda8754fa2302092096
5
5
  SHA512:
6
- metadata.gz: b1bca7e67150b27d0e74608edc7a5f5259a08e1fe9297e809848886dba092df36a40b64eaf8a9d55436f85d51cad2beb22a8df55276a7e1ea1fe8a92bae57304
7
- data.tar.gz: 102cc83d26fbb4202073769e52e32b422baaf22a67b02dc94d7bd18c31834e1020c07502f7cca507b844e85ed33a0ab43c513b0bf57da5155484975335330c38
6
+ metadata.gz: ed6668d63d1188e392bd2b0860622a155299cd3327be02b21e41d15b16d0ac36351d29395bde452adf2f85b2830dc8e4759f99d6f20ff5d433133380161a2e7d
7
+ data.tar.gz: 26da2af8226a9abe7d892eaa3188fe69178f1181115d1e3d1bfaedb70e15f294c8778e0ba17d33e5bbf09ab612ec4ec0469ff1a27b814fbbb8ca08632bb563e4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ormdev (0.1.7)
4
+ ormdev (0.1.8)
5
5
  claide (~> 1.0, >= 1.0.2)
6
6
  cocoapods (~> 1.5, >= 1.5.3)
7
7
  cocoapods-packager (~> 1.5)
@@ -7,6 +7,10 @@ module OrmDev
7
7
 
8
8
  self.description = <<-DESC
9
9
  新建 iOS => Application => Single View Application 工程,工程名为`NAME`
10
+
11
+ zip插件模板创建:
12
+
13
+ 'ormdev create --template-url=http://112.65.142.83:7788/ceshi/tmpl/pod-fast-template.zip --fast CIPXxx'
10
14
  DESC
11
15
 
12
16
  self.arguments = [
@@ -15,7 +19,7 @@ module OrmDev
15
19
 
16
20
  def self.options
17
21
  [
18
- ['--template-url=URL', 'Orm插件模板git地址'],
22
+ ['--template-url=URL', 'Orm插件模板git地址,或者zip地址'],
19
23
  ['--fast', '快速创建Orm插件模板工程(带测试用例)'],
20
24
  ['--prefix=XXX', 'Orm插件模板工程前缀(fast有效)'],
21
25
  ['--skip', '跳过打开Orm插件模板工程(fast有效)'],
@@ -37,6 +41,9 @@ module OrmDev
37
41
  help! 'The Pod name cannot contain spaces.' if @name =~ /\s/
38
42
  help! 'The Pod name cannot contain plusses.' if @name =~ /\+/
39
43
  help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
44
+ unless @template_url then
45
+ help! '模板地址只能是以[git|zip]结尾的地址.' if !(@template_url.downcase.end_with?('.git') || @template_url.downcase.end_with?('.zip'))
46
+ end
40
47
  end
41
48
 
42
49
  def run
@@ -1,6 +1,8 @@
1
1
  require 'cocoapods'
2
+ require 'zip'
2
3
 
3
4
  require_relative '../util/sh_util'
5
+ require_relative '../util/download_util'
4
6
 
5
7
  module OrmDev
6
8
  class CreateHelper
@@ -54,8 +56,28 @@ module OrmDev
54
56
  # @return [void]
55
57
  #
56
58
  def clone_template
57
- Pod::UI.section("Cloning `#{template_repo_url}` into `#{@project_name}`.") do
58
- git! ['clone', template_repo_url, @project_name]
59
+ if @template_url.downcase.end_with?('.zip') then
60
+ unzip_dir = File.basename(@template_url, 'zip')
61
+ abort('插件目录本地已存在。') if Dir.exist?(unzip_dir)
62
+ zip_path = File.join('./', File.basename(@template_url))
63
+
64
+ if (@template_url.downcase.start_with?('http://') || @template_url.downcase.start_with?('https://')) then
65
+ OrmDev::DownloadUtil.download( @template_url, zip_path )#Pathname.pwd
66
+ OrmDev::LogUtil.info "【创建插件工程】下载#{@template_url}到#{zip_path}"
67
+ elsif File.exist?(@template_url) then
68
+ OrmDev::LogUtil.info "【创建插件工程】复制#{@template_url}到#{zip_path}"
69
+ FileUtils.cp( @template_url, zip_path )
70
+ end
71
+ abort('插件模板zip下载失败') unless File.exist? zip_path
72
+ # 解压模板
73
+ result = OrmDev::SHUtil.run_command("unzip #{zip_path}",'解压模板工程', false)
74
+ File.rename('CIPPROJECT', @project_name)
75
+ FileUtils.rm zip_path
76
+ abort('插件模板zip解压失败') unless result
77
+ else
78
+ Pod::UI.section("Cloning `#{template_repo_url}` into `#{@project_name}`.") do
79
+ git! ['clone', template_repo_url, @project_name]
80
+ end
59
81
  end
60
82
  end
61
83
 
@@ -68,7 +90,8 @@ module OrmDev
68
90
  # "PROJECT_OWNER" => @configurator.user_name,
69
91
  "TODAYS_DATE" => Time.now.strftime("%m/%d/%Y"),
70
92
  "TODAYS_YEAR" => Time.now.year.to_s,
71
- "CIPPROJECT" => @project_name
93
+ "CIPPROJECT" => @project_name,
94
+ "cipPROJECT" => @project_name.gsub(/^CIP/, 'cip'),#模板替换,插件名->js对象
72
95
  }
73
96
  Dir.glob(project_folder + "/**/**/**/**").each do |name|
74
97
  next if Dir.exists? name
@@ -103,6 +126,9 @@ module OrmDev
103
126
  safe_rename_file("#{project_folder}/Example/CIPPROJECT.xcworkspace", "#{project_folder}/Example/#{@project_name}.xcworkspace")
104
127
  safe_rename_file("#{project_folder}/Example/CIPPROJECT/CIPPROJECT-Info.plist", "#{project_folder}/Example/CIPPROJECT/#{@project_name}-Info.plist")
105
128
  safe_rename_file("#{project_folder}/Example/CIPPROJECT/CIPPROJECT-Prefix.pch", "#{project_folder}/Example/CIPPROJECT/#{@project_name}-Prefix.pch")
129
+ #模板替换
130
+ safe_rename_file("#{project_folder}/Example/CIPPROJECT/asset/www/V2/data/CIPPROJECT.js", "#{project_folder}/Example/CIPPROJECT/asset/www/V2/data/#{@project_name}.js")
131
+ safe_rename_file("#{project_folder}/Example/CIPPROJECT/asset/www/V2/html/CIPPROJECT.html", "#{project_folder}/Example/CIPPROJECT/asset/www/V2/html/#{@project_name}.html")
106
132
  safe_rename_file("#{project_folder}/Example/CIPPROJECT", "#{project_folder}/Example/#{@project_name}")
107
133
  safe_rename_file("#{project_folder}/CIPPROJECT/Classes/CIPPROJECT.h", "#{project_folder}/CIPPROJECT/Classes/#{@project_name}.h")
108
134
  safe_rename_file("#{project_folder}/CIPPROJECT/Classes/CIPPROJECT.m", "#{project_folder}/CIPPROJECT/Classes/#{@project_name}.m")
@@ -112,6 +138,7 @@ module OrmDev
112
138
  safe_rename_file("#{project_folder}/CIPPROJECT/Classes/CIPPROJECTMacros.h", "#{project_folder}/CIPPROJECT/Classes/#{@project_name}Macros.h")
113
139
  safe_rename_file("#{project_folder}/CIPPROJECT", "#{project_folder}/#{@project_name}")
114
140
  safe_rename_file("#{project_folder}/CIPPROJECT.podspec", "#{project_folder}/#{@project_name}.podspec")
141
+
115
142
  reinitialize_svn_repo
116
143
 
117
144
  OrmDev::LogUtil.info "\nRunning " + "pod install".magenta + " on your new library."
@@ -135,6 +162,7 @@ module OrmDev
135
162
 
136
163
  def reinitialize_svn_repo
137
164
  `rm -rf .svn`
165
+ `rm -rf .git`
138
166
  end
139
167
 
140
168
  def safe_rename_dir(old, dir_name)
@@ -0,0 +1,39 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'ruby-progressbar'
4
+
5
+ module OrmDev
6
+ class DownloadUtil
7
+ def self.download(url, save_path, title = '文件')
8
+ uri = URI(url)
9
+ Net::HTTP.start(uri.host, uri.port) do |http|
10
+ request = Net::HTTP::Get.new uri
11
+ http.request request do |response|
12
+ file_size = response['content-length'].to_i
13
+ pbar = ProgressBar.create(:title => title, :starting_at => 0, :total => file_size, :format => '%a |%b>>%i| %p%% %t')
14
+ amount_downloaded = 0
15
+ File.open save_path, 'wb' do |io| # 'b' opens the file in binary mode
16
+ response.read_body do |chunk|
17
+ io.write chunk
18
+ amount_downloaded += chunk.size
19
+ pbar.progress=amount_downloaded
20
+ # puts "%.2f%" % (amount_downloaded.to_f / file_size * 100)
21
+ end
22
+ end
23
+ pbar.finish
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.download_cp(path, save_dir, save_name, title = '文件')
29
+ save_path = File.join(save_dir, save_name)
30
+ FileUtils.mkdir_p(save_dir) unless Dir.exist?(save_dir)
31
+ FileUtils.rm_rf(save_path) if Dir.exist?(save_path)
32
+ if (path.downcase.start_with?('http://') || path.downcase.start_with?('https://')) then
33
+ ORM::DownloadUtil.download(path, save_path, title )
34
+ else
35
+ FileUtils.cp( path, save_path )
36
+ end
37
+ end
38
+ end
39
+ end
@@ -112,7 +112,7 @@ module OrmDev
112
112
  info
113
113
  end
114
114
 
115
- ORMDEV_CLT_API_THIRD_PLUGIN_CHECK
115
+
116
116
 
117
117
 
118
118
  private
@@ -1,3 +1,3 @@
1
1
  module OrmDev
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ormdev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - devorm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-07 00:00:00.000000000 Z
11
+ date: 2018-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide
@@ -205,6 +205,7 @@ files:
205
205
  - lib/ormdev/command/update.rb
206
206
  - lib/ormdev/source/core/create_helper.rb
207
207
  - lib/ormdev/source/core/run_helper.rb
208
+ - lib/ormdev/source/util/download_util.rb
208
209
  - lib/ormdev/source/util/http_util.rb
209
210
  - lib/ormdev/source/util/log_util.rb
210
211
  - lib/ormdev/source/util/sh_util.rb
@@ -219,7 +220,7 @@ post_install_message: "\e[32m\n _____ __ __ ________\n
219
220
  ___ \\ / / / / / _ _ /\n / / / // /_/ / / // // /\n / / / //
220
221
  ____/ / // // /\n / /__/ // / / // // /\n \\_____//_/ /_//_//_/
221
222
  \ Dev\n\n\n -- 欢迎使用OrmDev for iOS --\n ---- 技术支持:devorm@163.com ----\n\n
222
- \ \e[0m\t\t\t\tv0.1.7\n\n"
223
+ \ \e[0m\t\t\t\tv0.1.8\n\n"
223
224
  rdoc_options: []
224
225
  require_paths:
225
226
  - lib