This repository has been archived by the owner on Jul 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 515
/
Rakefile
40 lines (34 loc) · 1.42 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'colorize'
require 'fileutils'
require_relative 'generator/lib/generator'
task :default do
puts "[Parse] Parsing JSON".yellow
table = parse_json('property.json')
puts "[Parse] Add superclass relation".green
add_superklass_relation(table)
puts "[Parse] Fix method setter and getter".green
handle_method(table)
xcode_proj_file = find_xcodeproj('.')
basename = File.basename(xcode_proj_file)
production = basename.start_with?('Pod')
puts "[Generate] Start to generates UIKit files".yellow
path = if production then 'DKNightVersion' else '.' end
files = objc_code_generator(table, path)
json_file_path = File.join('generator', 'lib', 'generator', 'json', 'project.json')
File.write json_file_path, files.to_json
puts "[Link] Find pbxproj file path".yellow
puts "[Link] pbxproj is at '#{xcode_proj_file}'".green
puts "[Link] Linking to xcodeproj".yellow
add_files_to_project(xcode_proj_file, json_file_path)
# remove null source files in project.pbxproj
puts "[Link] Refine project.pbxproj file".yellow
output_file = 'tmp'
input_file = File.join(xcode_proj_file, "project.pbxproj")
File.open(output_file, "w") do |out_file|
File.foreach(input_file) do |line|
out_file.puts line unless line.match("(null)")
end
end
FileUtils.mv(output_file, input_file)
puts "[DKNightVersion] has already generate all files".green
end