appmake 0.1.29 → 0.1.30

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.
@@ -1,36 +1,22 @@
1
1
  require "thor"
2
+ require "listen"
2
3
  require "appmake/version"
3
- require "appmake/listeners/css"
4
- require "appmake/listeners/coffee"
5
- require "appmake/listeners/js"
6
- require "appmake/listeners/tpl"
7
- require "appmake/installers/backbone"
8
- require "appmake/installers/bootstrap"
9
- require "appmake/installers/jquery"
10
- require "appmake/installers/underscore"
11
4
 
12
5
  module Appmake
13
- class Appmake < Thor
6
+ class Appmake < Thor
14
7
  include Thor::Actions
15
8
 
16
9
  def self.source_root
17
10
  File.dirname(File.dirname(__FILE__))
18
11
  end
19
12
 
20
- desc "init", "initialize new application"
21
- {
22
- :coffee => false,
23
- :jquery => false,
24
- :underscore => false,
25
- :backbone => false,
26
- :bootstrap => false
27
- }.each do |op, default|
28
- method_option op, :type => :boolean, :default => default
29
- end
30
-
13
+ desc "init", "initialize new app"
14
+ method_option :coffee, :type => :boolean, :default => false
15
+ method_option :jquery, :type => :boolean, :default => false
16
+ method_option :underscore, :type => :boolean, :default => false
17
+ method_option :backbone, :type => :boolean, :default => false
18
+ method_option :bootstrap, :type => :boolean, :default => false
31
19
  def init
32
- shell = Color.new
33
-
34
20
  template "templates/package.json.tt", "package.json"
35
21
  template "templates/README.md.tt", "README.md"
36
22
 
@@ -45,73 +31,133 @@ module Appmake
45
31
  template "templates/tpl/welcome.html.tt", "tpl/welcome.html"
46
32
 
47
33
  empty_directory "public"
34
+ template "templates/public/index.html.tt", "public/index.html"
35
+
48
36
  empty_directory "public/css"
49
37
  empty_directory "public/js"
50
38
  empty_directory "public/img"
51
- template "templates/public/index.html.tt", "public/index.html"
52
-
53
- shell.say_status :cmd, "npm install", :blue
54
- system "npm install &> /dev/null"
55
39
 
56
- if options.coffee
40
+ if options.coffee?
57
41
  empty_directory "coffee"
58
- Listeners::Coffee.compile
59
42
  end
60
43
 
61
- if options.jquery
62
- Installers::Jquery.install
44
+ if options.jquery?
45
+ install "jquery"
63
46
  end
64
47
 
65
- if options.underscore
66
- Installers::Underscore.install
48
+ if options.underscore?
49
+ install "underscore"
67
50
  end
68
51
 
69
- if options.backbone
70
- Installers::Backbone.install
52
+ if options.backbone?
53
+ install "backbone"
71
54
  end
72
55
 
73
- if options.bootstrap
74
- Installers::Bootstrap.install
56
+ if options.bootstrap?
57
+ install "bootstrap"
75
58
  end
76
59
 
77
- Listeners::Css.compile
78
- Listeners::Tpl.compile
79
- Listeners::Js.compile
60
+ run "npm install"
61
+
62
+ compile "css"
63
+ compile "tpl"
64
+ compile "coffee"
65
+ compile "js"
66
+ end
67
+
68
+ desc "compile", "compile files"
69
+ method_option :name, :type => :string
70
+ def compile(name)
71
+ if name == "css"
72
+ Dir.glob "css/*.scss" do |f|
73
+ name = f.split("/").last
74
+ if name[0] == name[0].upcase
75
+ new_name = name.gsub "scss", "css"
76
+ run "bundle exec sass css/#{name} public/css/#{new_name}"
77
+ end
78
+ end
79
+ elsif name == "js"
80
+ Dir.glob "js/*.js" do |f|
81
+ name = f.split("/").last
82
+ if name[0] == name[0].upcase
83
+ run "./node_modules/.bin/webmake js/#{name} public/js/#{name}"
84
+ end
85
+ end
86
+ elsif name == "tpl"
87
+ run "./node_modules/.bin/dot-module -d tpl/ -o js/templates.js"
88
+ elsif name == "coffee"
89
+ Dir.glob "coffee/*.coffee" do |f|
90
+ name = f.split("/").last
91
+ new_name = name.gsub "coffee", "js"
92
+ run "./node_modules/.bin/coffee -c coffee/#{name}"
93
+ run "mv coffee/#{new_name} js/#{new_name}"
94
+ if name[0] == name[0].upcase
95
+ run "./node_modules/.bin/webmake js/#{new_name} public/js/#{new_name}"
96
+ end
97
+ end
98
+ end
80
99
  end
81
100
 
82
101
  desc "watch", "watch for files to compile"
83
102
  def watch
84
- Listeners::Css.listen(false)
85
- Listeners::Coffee.listen(false)
86
- Listeners::Tpl.listen(false)
87
- Listeners::Js.listen(true)
103
+ css = Listen.to "css", :filter => /\.scss$/
104
+ css.change do
105
+ compile "css"
106
+ end
107
+ css.start(false)
108
+
109
+ if Dir.exists? "coffee"
110
+ coffee = Listen.to "coffee", :filter => /\.coffee$/
111
+ coffee.change do
112
+ compile "coffee"
113
+ end
114
+ coffee.start(false)
115
+ end
116
+
117
+ tpl = Listen.to "tpl", :filter => /\.html$/
118
+ tpl.change do
119
+ compile "tpl"
120
+ end
121
+ tpl.start(false)
122
+
123
+ js = Listen.to "js", :filter => /\.js$/
124
+ js.change do
125
+ compile "js"
126
+ end
127
+ js.start(true)
88
128
  end
89
129
 
90
- desc "install", "install various libs"
130
+ desc "install", "install lib"
131
+ method_option :name, :type => :string
91
132
  def install(name)
92
- shell = Color.new
93
-
94
133
  if name == "jquery"
95
134
  empty_directory "public"
96
135
  empty_directory "public/js"
97
- Installers::Jquery.install
136
+ run "curl http://code.jquery.com/jquery-1.9.0.min.js -o public/js/jquery.min.js"
98
137
  elsif name == "underscore"
99
138
  empty_directory "public"
100
139
  empty_directory "public/js"
101
- Installers::Underscore.install
140
+ run "curl http://underscorejs.org/underscore-min.js -o public/underscore.min.js"
102
141
  elsif name == "backbone"
103
142
  empty_directory "public"
104
143
  empty_directory "public/js"
105
- Installers::Backbone.install
144
+ run "curl -silent http://backbonejs.org/backbone-min.js -o public/backbone.min.js"
106
145
  elsif name == "bootstrap"
107
146
  empty_directory "public"
108
147
  empty_directory "public/css"
109
148
  empty_directory "public/img"
110
149
  empty_directory "public/js"
111
- Installers::Bootstrap.install
150
+ run "curl -silent http://twitter.github.com/bootstrap/assets/bootstrap.zip -o public/bootstrap.zip"
151
+ run "unzip public/bootstrap.zip -d public"
152
+ run "mv public/bootstrap/js/bootstrap.min.js public/js/"
153
+ run "mv public/bootstrap/css/bootstrap.min.css public/css/"
154
+ run "mv public/bootstrap/css/bootstrap-responsive.min.css public/css/"
155
+ run "mv public/bootstrap/img/* public/img/"
156
+ run "rm -rf public/bootstrap"
157
+ run "rm public/bootstrap.zip"
112
158
  else
113
- abort "error: unsupported install: #{name}"
159
+ abort "error: cannot install #{name}"
114
160
  end
115
161
  end
116
162
  end
117
- end
163
+ end
@@ -1,3 +1,3 @@
1
1
  module Appmake
2
- VERSION = "0.1.29"
2
+ VERSION = "0.1.30"
3
3
  end
@@ -3,9 +3,14 @@
3
3
  <head>
4
4
  <title></title>
5
5
  <meta http=equiv="Content-Type" content="text/html; charset=UTF-8">
6
+ <% if options.bootstrap %><link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"><% end %>
6
7
  <link rel="stylesheet" type="text/css" href="css/App.css">
7
8
  </head>
8
9
  <body>
10
+ <% if options.jquery %><script type="text/javascript" src="js/jquery.min.js"></script><% end %>
11
+ <% if options.underscore %><script type="text/javascript" src="js/underscore.min.js"></script><% end %>
12
+ <% if options.backbone %><script type="text/javascript" src="js/backbone.min.js"></script><% end %>
13
+ <% if options.bootstrap %><script type="text/javascript" src="js/bootstrap.min.js"></script><% end %>
9
14
  <script type="text/javascript" src="js/App.js"></script>
10
15
  </body>
11
16
  </html>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appmake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.29
4
+ version: 0.1.30
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -93,14 +93,6 @@ files:
93
93
  - appmake.gemspec
94
94
  - bin/appmake
95
95
  - lib/appmake.rb
96
- - lib/appmake/installers/backbone.rb
97
- - lib/appmake/installers/bootstrap.rb
98
- - lib/appmake/installers/jquery.rb
99
- - lib/appmake/installers/underscore.rb
100
- - lib/appmake/listeners/coffee.rb
101
- - lib/appmake/listeners/css.rb
102
- - lib/appmake/listeners/js.rb
103
- - lib/appmake/listeners/tpl.rb
104
96
  - lib/appmake/version.rb
105
97
  - templates/README.md.tt
106
98
  - templates/css/app.scss.tt
@@ -1,17 +0,0 @@
1
- require "thor"
2
-
3
- module Appmake
4
- module Installers
5
- class Backbone
6
- include Thor::Shell
7
-
8
- def self.install
9
- shell = Color.new
10
-
11
- shell.say_status :install, "Backbone", :green
12
- shell.say_status :cmd, "curl http://backbonejs.org/backbonejs-min.js -o public/backbone.min.js", :blue
13
- system("curl -silent http://backbonejs.org/backbone-min.js -o public/backbone.min.js")
14
- end
15
- end
16
- end
17
- end
@@ -1,24 +0,0 @@
1
- require "thor"
2
-
3
- module Appmake
4
- module Installers
5
- class Bootstrap
6
- include Thor::Shell
7
-
8
- def self.install
9
- shell = Color.new
10
-
11
- shell.say_status :install, "Bootstrap", :green
12
- shell.say_status :cmd, "curl http://twitter.github.com/bootstrap/assets/bootstrap.zip -o public/bootstrap.zip", :blue
13
- shell.say_status :cmd, "cd public", :blue
14
- shell.say_status :cmd, "unzip bootstrap.zip &> /dev/null", :blue
15
- shell.say_status :cmd, "mv bootstrap/js/bootstrap.min.js js/", :blue
16
- shell.say_status :cmd, "mv bootstrap/css/bootstrap.min.css css/", :blue
17
- shell.say_status :cmd, "mv bootstrap/css/bootstrap-responsive.min.css css/", :blue
18
- shell.say_status :cmd, "mv bootstrap/img/* img/", :blue
19
- shell.say_status :cmd, "rm -rf bootstrap && rm bootstrap.zip", :blue
20
- system("curl -silent http://twitter.github.com/bootstrap/assets/bootstrap.zip -o public/bootstrap.zip && cd public && unzip bootstrap.zip &> /dev/null && mv bootstrap/js/bootstrap.min.js js/ && mv bootstrap/css/bootstrap.min.css css/ && mv bootstrap/css/bootstrap-responsive.min.css css/ && mv bootstrap/img/* img/ && rm -rf bootstrap && rm bootstrap.zip")
21
- end
22
- end
23
- end
24
- end
@@ -1,17 +0,0 @@
1
- require "thor"
2
-
3
- module Appmake
4
- module Installers
5
- class Jquery
6
- include Thor::Shell
7
-
8
- def self.install
9
- shell = Color.new
10
-
11
- shell.say_status :install, "jQuery", :green
12
- shell.say_status :cmd, "curl http://code.jquery.com/jquery-1.9.0.min.js -o public/js/jquery.min.js", :blue
13
- system("curl -silent http://code.jquery.com/jquery.min.js -o public/js/jquery.min.js")
14
- end
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require "thor"
2
-
3
- module Appmake
4
- module Installers
5
- class Underscore
6
- include Thor::Shell
7
-
8
- def self.install
9
- shell = Color.new
10
-
11
- shell.say_status :install, "Underscore", :green
12
- shell.say_status :cmd, "curl http://underscorejs.org/underscore-min.js -o public/underscore.min.js", :blue
13
- system("curl -silent http://underscorejs.org/underscore-min.js -o public/underscore.min.js")
14
- end
15
- end
16
- end
17
- end
@@ -1,38 +0,0 @@
1
- require "listen"
2
-
3
- module Appmake
4
- module Listeners
5
- class Coffee
6
- include Thor::Shell
7
-
8
- def self.listen(block = true)
9
- callback = Proc.new do |modified, added, removed|
10
- self.compile()
11
- end
12
-
13
- listener = Listen.to "coffee", :filter => /\.coffee$/
14
- listener.change(&callback)
15
- listener.start(block)
16
- end
17
-
18
- def self.compile
19
- shell = Color.new
20
-
21
- shell.say_status :compile, "CoffeScript", :green
22
-
23
- Dir.glob "coffee/*.coffee" do |f|
24
- name = f.split("/").last
25
- new_name = name.gsub "coffee", "js"
26
-
27
- shell.say_status :cmd, "./node_modules/.bin/coffee -c coffee/#{name} && mv coffee/#{new_name} js/#{new_name}", :blue
28
- system "./node_modules/.bin/coffee -c coffee/#{name} > /dev/null && mv coffee/#{new_name} js/#{new_name} > /dev/null"
29
-
30
- if name[0] == name[0].upcase
31
- shell.say_status :cmd, "./node_modules/.bin/webmake js/#{new_name} public/js/#{new_name}", :blue
32
- system "./node_modules/.bin/webmake js/#{new_name} public/js/#{new_name} > /dev/null"
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,36 +0,0 @@
1
- require "listen"
2
- require "thor"
3
-
4
- module Appmake
5
- module Listeners
6
- class Css
7
- include Thor::Shell
8
-
9
- def self.listen(block = true)
10
- callback = Proc.new do |modified, added, removed|
11
- self.compile()
12
- end
13
-
14
- listener = Listen.to "css", :filter => /\.scss$/
15
- listener.change(&callback)
16
- listener.start(block)
17
- end
18
-
19
- def self.compile
20
- shell = Color.new
21
-
22
- shell.say_status :compile, "CSS", :green
23
-
24
- Dir.glob "css/*" do |f|
25
- name = f.split("/").last
26
-
27
- if name[0] == name[0].upcase
28
- new_name = name.gsub "scss", "css"
29
- shell.say_status :cmd, "bundle exec sass css/#{name} public/css/#{new_name}", :blue
30
- system "bundle exec sass css/#{name} public/css/#{new_name} > /dev/null"
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,34 +0,0 @@
1
- require "listen"
2
-
3
- module Appmake
4
- module Listeners
5
- class Js
6
- include Thor::Shell
7
-
8
- def self.listen(block = true)
9
- callback = Proc.new do |modified, added, removed|
10
- self.compile()
11
- end
12
-
13
- listener = Listen.to "js", :filter => /\.js$/
14
- listener.change(&callback)
15
- listener.start(block)
16
- end
17
-
18
- def self.compile
19
- shell = Color.new
20
-
21
- shell.say_status :compile, "JavaScript", :green
22
-
23
- Dir.glob "js/*.js" do |f|
24
- name = f.split("/").last
25
-
26
- if name[0] == name[0].upcase
27
- shell.say_status :cmd, "./node_modules/.bin/webmake js/#{name} public/js/#{name}", :blue
28
- system "./node_modules/.bin/webmake js/#{name} public/js/#{name} > /dev/null"
29
- end
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,28 +0,0 @@
1
- require "listen"
2
-
3
- module Appmake
4
- module Listeners
5
- class Tpl
6
- include Thor::Shell
7
-
8
- def self.listen(block = true)
9
- callback = Proc.new do |modified, added, removed|
10
- self.compile()
11
- end
12
-
13
- listener = Listen.to "tpl", :filter => /\.html$/
14
- listener.change(&callback)
15
- listener.start(block)
16
- end
17
-
18
- def self.compile
19
- shell = Color.new
20
-
21
- shell.say_status :compile, "Templates", :green
22
-
23
- shell.say_status :cmd, "./node_modules/.bin/dot-module -d tpl/ -o js/templates.js", :blue
24
- system("./node_modules/.bin/dot-module -d tpl/ -o js/templates.js > /dev/null")
25
- end
26
- end
27
- end
28
- end