cordova-rake 0.0.3 → 0.0.5
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 +4 -4
- data/README.md +36 -2
- data/cordova-rake.gemspec +1 -1
- data/lib/cordova/rake.rb +35 -1
- data/lib/tasks/application.rake +48 -0
- data/lib/tasks/cordova.rake +8 -164
- data/lib/tasks/deploy.rake +105 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71077203a2b2b987cd353b49d7578bbc2dfd407c
|
4
|
+
data.tar.gz: fd4bf4324413714195af1f95bc44f3720a587615
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6d28ee438d03193f8cfa1699c85d106a24384d63a46c7909f8c23a1f92f439ba6a5e79229a408f72db81a021b3149b0e8d6af0bc6dc8e3ea4bf6b594627d7cd
|
7
|
+
data.tar.gz: a2f0dc2e66ec7aefe823f3bc2f513f93fa795715dd8ff29db7b306d455cf2c1a029d3661562236a5914bfa548435a69cd5624fe3715630dfb2b0f1009a10107c
|
data/README.md
CHANGED
@@ -17,10 +17,10 @@ Add to your `Rakefile`
|
|
17
17
|
|
18
18
|
If you don't have one
|
19
19
|
|
20
|
-
echo "require 'cordova
|
20
|
+
echo "require 'cordova/rake'" > Rakefile
|
21
21
|
|
22
22
|
|
23
|
-
##
|
23
|
+
## rake -T
|
24
24
|
|
25
25
|
```
|
26
26
|
rake compile # Compiles all resources
|
@@ -36,3 +36,37 @@ rake run:ios # Run on iOS plugged device or emulator
|
|
36
36
|
rake serve # Phonegap Dev App, optional: port
|
37
37
|
rake setup # Setup env for development
|
38
38
|
```
|
39
|
+
|
40
|
+
|
41
|
+
## Google | Play Store
|
42
|
+
|
43
|
+
|
44
|
+
### Binaries
|
45
|
+
|
46
|
+
Make sure you have `jarsigner` and `zipalign` on your path.
|
47
|
+
The latter is usually somewhere in /opt/android-sdk.
|
48
|
+
|
49
|
+
|
50
|
+
### Key password
|
51
|
+
|
52
|
+
To avoid typing keys on eack apk build:
|
53
|
+
Rakefile:
|
54
|
+
|
55
|
+
GOOGLE_KEY = 'mykeypassword'
|
56
|
+
|
57
|
+
Or an ENV var 'GOOGLE_KEY'
|
58
|
+
|
59
|
+
|
60
|
+
## Apple | App Store
|
61
|
+
|
62
|
+
|
63
|
+
### Binaries
|
64
|
+
|
65
|
+
Make sure you have `xcrun`.
|
66
|
+
Also you need to open the project once in Xcode. (working on xproject gem)
|
67
|
+
|
68
|
+
### Developer
|
69
|
+
|
70
|
+
To change developer per project:
|
71
|
+
|
72
|
+
APPLE_DEVELOPER = 'Developer X (XXXXX)'
|
data/cordova-rake.gemspec
CHANGED
data/lib/cordova/rake.rb
CHANGED
@@ -4,6 +4,40 @@ require 'tilt'
|
|
4
4
|
require 'nokogiri'
|
5
5
|
START = Time.now
|
6
6
|
|
7
|
-
#
|
7
|
+
#
|
8
|
+
# Some helper methods
|
9
|
+
#
|
10
|
+
def get_sources(ext, dir = 'app')
|
11
|
+
source_files = Rake::FileList.new("#{dir}/**/*.#{ext}") do |fl|
|
12
|
+
fl.exclude("~*")
|
13
|
+
fl.exclude(/^scratch\//)
|
14
|
+
# fl.exclude { |f| `git ls-files #{f}`.empty? } # Only commited
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def environment
|
19
|
+
ENV['TARGET'] || 'development'
|
20
|
+
end
|
21
|
+
|
22
|
+
def config(key)
|
23
|
+
return @xml[key] if @xml
|
24
|
+
xml = Nokogiri::XML(File.open('config.xml'))
|
25
|
+
@xml = {
|
26
|
+
app: xml.xpath("//xmlns:name").text,
|
27
|
+
desc: xml.xpath("//xmlns:description").text,
|
28
|
+
platforms: xml.xpath("//xmlns:platform").map { |os| os['name'] }
|
29
|
+
}
|
30
|
+
config(key)
|
31
|
+
end
|
32
|
+
|
33
|
+
def layout
|
34
|
+
@layout ||= Tilt.new('app/html/layout.haml')
|
35
|
+
end
|
36
|
+
|
37
|
+
def app
|
38
|
+
config(:app)
|
39
|
+
end
|
40
|
+
|
41
|
+
# And load all tasks
|
8
42
|
tasks = File.join(File.dirname(__FILE__), '..', 'tasks')
|
9
43
|
Dir.glob("#{tasks}/*.rake").each { |r| import r }
|
@@ -0,0 +1,48 @@
|
|
1
|
+
desc 'Compiles all resources'
|
2
|
+
task :compile => ['compile:all']
|
3
|
+
|
4
|
+
namespace :compile do
|
5
|
+
task :all => [:js, :css, :html, :vars]
|
6
|
+
|
7
|
+
desc 'Compiles Coffee -> JS'
|
8
|
+
task :js => get_sources(:coffee).ext('.js')
|
9
|
+
|
10
|
+
desc 'Compiles SASS -> CSS'
|
11
|
+
task :css => get_sources(:sass).ext('.css')
|
12
|
+
|
13
|
+
desc 'Compiles HAML -> HTML'
|
14
|
+
task :html => get_sources(:haml).ext('.html')
|
15
|
+
|
16
|
+
desc 'Postcompile ENV variables'
|
17
|
+
task :vars do
|
18
|
+
data = YAML.load_file('config/app.yml')[environment]
|
19
|
+
[:js, :css, :html].map { |f| get_sources(f, 'www/js') }.flatten.each do |f|
|
20
|
+
data.each do |k, v|
|
21
|
+
sh "sed -i \"s/'...#{k.upcase}...'/'#{v}'/g\" #{f}"
|
22
|
+
# sh "sed -i \"s/'####{k.upcase}###'/#{v}/g\" #{f}" # numbers
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
rule '.js' => '.coffee' do |t|
|
28
|
+
output = File.dirname(t.source).gsub(/app\//, 'www/')
|
29
|
+
# print "CoffeeScript | " # #{t.source} -> #{output}"
|
30
|
+
sh "coffee --no-header -b -o #{output} #{t.source}"
|
31
|
+
end
|
32
|
+
|
33
|
+
rule '.css' => '.sass' do |t|
|
34
|
+
# print "SASS | #{t.source} -> #{t.name} | "
|
35
|
+
sh "sass #{t.source} #{t.name.gsub(/app\//, 'www/')}"
|
36
|
+
end
|
37
|
+
|
38
|
+
rule '.html' => '.haml' do |t|
|
39
|
+
next if t.name =~ /layout/
|
40
|
+
template = Tilt.new(t.source)
|
41
|
+
# => #<Tilt::HAMLTemplate @file="path/to/file.haml" ...>
|
42
|
+
File.open(t.name.gsub(/app\//, 'www/'), 'w') do |f|
|
43
|
+
f.puts layout.render { template.render }
|
44
|
+
end
|
45
|
+
# print "HAML | #{t.source} -> #{t.name} | "
|
46
|
+
# sh "haml #{t.source} #{}"
|
47
|
+
end
|
48
|
+
end
|
data/lib/tasks/cordova.rake
CHANGED
@@ -1,36 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Rake / Cordova
|
3
3
|
#
|
4
|
-
def get_sources(ext, dir = 'app')
|
5
|
-
source_files = Rake::FileList.new("#{dir}/**/*.#{ext}") do |fl|
|
6
|
-
fl.exclude("~*")
|
7
|
-
fl.exclude(/^scratch\//)
|
8
|
-
# fl.exclude { |f| `git ls-files #{f}`.empty? } # Only commited
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def environment
|
13
|
-
ENV['TARGET'] || 'development'
|
14
|
-
end
|
15
|
-
|
16
|
-
def config(key)
|
17
|
-
return @xml[key] if @xml
|
18
|
-
xml = Nokogiri::XML(File.open('config.xml'))
|
19
|
-
@xml = {
|
20
|
-
app: xml.xpath("//xmlns:name").text,
|
21
|
-
desc: xml.xpath("//xmlns:description").text,
|
22
|
-
platforms: xml.xpath("//xmlns:platform").map { |os| os['name'] }
|
23
|
-
}
|
24
|
-
config(key)
|
25
|
-
end
|
26
|
-
|
27
|
-
def app
|
28
|
-
config(:app)
|
29
|
-
end
|
30
|
-
|
31
|
-
def layout
|
32
|
-
@layout ||= Tilt.new('app/html/layout.haml')
|
33
|
-
end
|
34
4
|
|
35
5
|
task default: [:greet, :compile, :report]
|
36
6
|
|
@@ -64,141 +34,15 @@ task :ripple do
|
|
64
34
|
end
|
65
35
|
|
66
36
|
namespace :run do
|
67
|
-
desc 'Run on Android device or emulator'
|
68
|
-
task :android do
|
69
|
-
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
desc 'Run on iOS plugged device or emulator'
|
74
|
-
task :ios do
|
75
|
-
sh 'cordova build ios'
|
76
|
-
sh 'cordova run ios --device'
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
desc 'Compiles all resources'
|
81
|
-
task :compile => ['compile:all']
|
82
|
-
|
83
|
-
namespace :compile do
|
84
|
-
task :all => [:js, :css, :html, :vars]
|
85
|
-
|
86
|
-
desc 'Compiles Coffee -> JS'
|
87
|
-
task :js => get_sources(:coffee).ext('.js')
|
88
|
-
|
89
|
-
desc 'Compiles SASS -> CSS'
|
90
|
-
task :css => get_sources(:sass).ext('.css')
|
91
|
-
|
92
|
-
desc 'Compiles HAML -> HTML'
|
93
|
-
task :html => get_sources(:haml).ext('.html')
|
94
|
-
|
95
|
-
desc 'Postcompile ENV variables'
|
96
|
-
task :vars do
|
97
|
-
data = YAML.load_file('config/app.yml')[environment]
|
98
|
-
[:js, :css, :html].map { |f| get_sources(f, 'www/js') }.flatten.each do |f|
|
99
|
-
data.each do |k, v|
|
100
|
-
sh "sed -i \"s/'...#{k.upcase}...'/'#{v}'/g\" #{f}"
|
101
|
-
# sh "sed -i \"s/'####{k.upcase}###'/#{v}/g\" #{f}" # numbers
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
rule '.js' => '.coffee' do |t|
|
107
|
-
output = File.dirname(t.source).gsub(/app\//, 'www/')
|
108
|
-
# print "CoffeeScript | " # #{t.source} -> #{output}"
|
109
|
-
sh "coffee --no-header -b -o #{output} #{t.source}"
|
110
|
-
end
|
111
|
-
|
112
|
-
rule '.css' => '.sass' do |t|
|
113
|
-
# print "SASS | #{t.source} -> #{t.name} | "
|
114
|
-
sh "sass #{t.source} #{t.name.gsub(/app\//, 'www/')}"
|
115
|
-
end
|
116
|
-
|
117
|
-
rule '.html' => '.haml' do |t|
|
118
|
-
next if t.name =~ /layout/
|
119
|
-
template = Tilt.new(t.source)
|
120
|
-
# => #<Tilt::HAMLTemplate @file="path/to/file.haml" ...>
|
121
|
-
File.open(t.name.gsub(/app\//, 'www/'), 'w') do |f|
|
122
|
-
f.puts layout.render { template.render }
|
123
|
-
end
|
124
|
-
# print "HAML | #{t.source} -> #{t.name} | "
|
125
|
-
# sh "haml #{t.source} #{}"
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
#
|
130
|
-
#
|
131
|
-
# RELEASE
|
132
|
-
#
|
133
|
-
#
|
134
|
-
namespace :release do
|
135
|
-
|
136
|
-
task :check_dirs do
|
137
|
-
%w( .keys build ).each do |dir|
|
138
|
-
FileUtils.mkdir dir unless File.exist?(dir)
|
139
|
-
end
|
37
|
+
desc 'Run on Android device or emulator'
|
38
|
+
task :android do
|
39
|
+
sh 'cordova build android'
|
40
|
+
sh 'cordova run android'
|
140
41
|
end
|
141
42
|
|
142
|
-
desc '
|
143
|
-
task
|
144
|
-
|
145
|
-
|
146
|
-
task :all => [:clean, :keygen, :archive, :sign, :align, :check, :submit]
|
147
|
-
|
148
|
-
# desc 'Clean up build folder from apks'
|
149
|
-
task :clean do
|
150
|
-
Dir['build/*.apk'].each { |f| File.delete(f) }
|
151
|
-
end
|
152
|
-
|
153
|
-
# desc 'Generates Google Play Store .keystore'
|
154
|
-
task :keygen do
|
155
|
-
next if File.exist?('.keys/google.keystore')
|
156
|
-
puts "\nGenerate key first!\n\n"
|
157
|
-
sh "keytool -genkey -v -keystore ./.keys/google.keystore "\
|
158
|
-
"-alias #{app} -keyalg RSA -keysize 2048 -validity 10000"
|
159
|
-
end
|
160
|
-
|
161
|
-
task :archive do
|
162
|
-
sh 'cordova build --release android'
|
163
|
-
FileUtils.cp 'platforms/android/build/outputs'\
|
164
|
-
'/apk/android-release-unsigned.apk',
|
165
|
-
"build/#{app}-unsigned.apk"
|
166
|
-
end
|
167
|
-
|
168
|
-
task :sign do
|
169
|
-
sh "jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 "\
|
170
|
-
"-keystore ./.keys/google.keystore build/#{app}-unsigned.apk "\
|
171
|
-
"#{app}"
|
172
|
-
FileUtils.cp "build/#{app}-unsigned.apk", "build/#{app}-signed.apk"
|
173
|
-
end
|
174
|
-
|
175
|
-
task :align do
|
176
|
-
sh "zipalign -f -v 4 build/#{app}-signed.apk build/#{app}.apk"
|
177
|
-
end
|
178
|
-
|
179
|
-
task :check do
|
180
|
-
arch = "build/#{app}.apk"
|
181
|
-
if File.exists? arch
|
182
|
-
puts "Build done! #{arch} #{File.size(arch).to_f/(1024 * 1024)} Mb"
|
183
|
-
else
|
184
|
-
puts "Something BAD! No #{arch}!"
|
185
|
-
exit 1
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
task :submit do
|
190
|
-
#hope we can soon
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
#
|
195
|
-
# Apple
|
196
|
-
#
|
197
|
-
desc 'Deploy to Apple’s App Store'
|
198
|
-
task apple: [:check_keys_dir, 'apple:all', :report]
|
199
|
-
|
200
|
-
namespace :apple do
|
201
|
-
task :all => [:archive, :upload, :check]
|
202
|
-
|
43
|
+
desc 'Run on iOS plugged device or emulator'
|
44
|
+
task :ios do
|
45
|
+
sh 'cordova build ios'
|
46
|
+
sh 'cordova run ios --device'
|
203
47
|
end
|
204
48
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
#
|
2
|
+
#
|
3
|
+
# Deploy!
|
4
|
+
#
|
5
|
+
#
|
6
|
+
namespace :release do
|
7
|
+
|
8
|
+
task :check_dirs do
|
9
|
+
%w( .keys build ).each do |dir|
|
10
|
+
FileUtils.mkdir dir unless File.exist?(dir)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Deploy to Google’s Play Store'
|
15
|
+
task google: [:check_dirs, 'google:all', :report]
|
16
|
+
|
17
|
+
namespace :google do
|
18
|
+
task :all => [:clean, :keygen, :archive, :sign, :align, :check, :submit]
|
19
|
+
|
20
|
+
# desc 'Clean up build folder from apks'
|
21
|
+
task :clean do
|
22
|
+
Dir['build/*.apk'].each { |f| File.delete(f) }
|
23
|
+
end
|
24
|
+
|
25
|
+
# desc 'Generates Google Play Store .keystore'
|
26
|
+
task :keygen do
|
27
|
+
next if File.exist?('.keys/google.keystore')
|
28
|
+
puts "\nGenerate key first!\n\n"
|
29
|
+
sh "keytool -genkey -v -keystore ./.keys/google.keystore "\
|
30
|
+
"-alias #{app} -keyalg RSA -keysize 2048 -validity 10000"
|
31
|
+
end
|
32
|
+
|
33
|
+
task :archive do
|
34
|
+
sh " cordova build --release android"
|
35
|
+
FileUtils.cp 'platforms/android/build/outputs'\
|
36
|
+
'/apk/android-release-unsigned.apk',
|
37
|
+
"build/#{app}-unsigned.apk"
|
38
|
+
end
|
39
|
+
|
40
|
+
task :sign do
|
41
|
+
key = ENV['GOOGLE_KEY']
|
42
|
+
key = GOOGLE_KEY if Object.const_defined?(:GOOGLE_KEY)
|
43
|
+
sh "echo '#{key}' | jarsigner -verbose -sigalg SHA1withRSA "\
|
44
|
+
"-digestalg SHA1 -keystore "\
|
45
|
+
"./.keys/google.keystore build/#{app}-unsigned.apk #{app}"
|
46
|
+
FileUtils.cp "build/#{app}-unsigned.apk", "build/#{app}-signed.apk"
|
47
|
+
end
|
48
|
+
|
49
|
+
task :align do
|
50
|
+
sh "zipalign -f -v 4 build/#{app}-signed.apk build/#{app}.apk"
|
51
|
+
end
|
52
|
+
|
53
|
+
task :check do
|
54
|
+
arch = "build/#{app}.apk"
|
55
|
+
if File.exists? arch
|
56
|
+
puts "Build done! #{arch} #{File.size(arch).to_f/(1024 * 1024)} Mb"
|
57
|
+
else
|
58
|
+
puts "Something BAD! No #{arch}!"
|
59
|
+
exit 1
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
task :submit do
|
64
|
+
#hope we can soon
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Apple
|
70
|
+
#
|
71
|
+
desc 'Deploy to Apple’s App Store'
|
72
|
+
task apple: [:check_dirs, 'apple:all', :report]
|
73
|
+
|
74
|
+
namespace :apple do
|
75
|
+
task :all => [:archive, :ipa, :check] #, :upload]
|
76
|
+
|
77
|
+
task :archive do
|
78
|
+
sh "cordova build --release ios"
|
79
|
+
# xcodebuild -target "#{app}" -sdk "${TARGET_SDK}" -configuration Release
|
80
|
+
end
|
81
|
+
|
82
|
+
task :ipa do
|
83
|
+
provision = Dir['platforms/ios/build/**/*.mobileprovision'].first
|
84
|
+
developer = ENV['APPLE_DEVELOPER']
|
85
|
+
developer = APPLE_DEVELOPER if Object.const_defined?(:APPLE_DEVELOPER)
|
86
|
+
comm = "xcrun -sdk iphoneos PackageApplication -v "\
|
87
|
+
"'platforms/ios/build/emulator/#{app}.app' -o "\
|
88
|
+
"'#{Rake.original_dir}/build/#{app}.ipa' "
|
89
|
+
comm << "--embed '#{provision}'" if provision
|
90
|
+
comm << "--sign #{APPLE_DEVELOPER}" if developer
|
91
|
+
sh comm
|
92
|
+
end
|
93
|
+
|
94
|
+
task :check do
|
95
|
+
arch = "build/#{app}.ipa"
|
96
|
+
if File.exists? arch
|
97
|
+
puts "Build done! #{arch} #{File.size(arch).to_f/(1024 * 1024)} Mb"
|
98
|
+
else
|
99
|
+
puts "Something BAD! No #{arch}!"
|
100
|
+
exit 1
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cordova-rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos Piccinini
|
@@ -28,7 +28,9 @@ files:
|
|
28
28
|
- Rakefile
|
29
29
|
- cordova-rake.gemspec
|
30
30
|
- lib/cordova/rake.rb
|
31
|
+
- lib/tasks/application.rake
|
31
32
|
- lib/tasks/cordova.rake
|
33
|
+
- lib/tasks/deploy.rake
|
32
34
|
homepage: http://github.com/nofxx/cordova-rake
|
33
35
|
licenses:
|
34
36
|
- MIT
|