architecture-js 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/HELP +18 -18
- data/VERSION +1 -1
- data/architecture-js.gemspec +1 -1
- data/lib/architecture-js/architect.rb +30 -30
- data/lib/architecture-js/blueprint.rb +1 -1
- data/lib/architecture-js/generator.rb +3 -2
- data/lib/architecture-js/watcher.rb +9 -5
- metadata +2 -2
data/HELP
CHANGED
@@ -1,29 +1,34 @@
|
|
1
1
|
create Creates a new architecture-js application in the
|
2
2
|
current working directory or sub directory within.
|
3
3
|
|
4
|
+
examples:
|
5
|
+
architect create myapp
|
6
|
+
architect create myapp subdirectory
|
7
|
+
architect create myapp -b modjs
|
8
|
+
|
4
9
|
Arguments:
|
5
10
|
application name - Name of the architecture-js application
|
6
11
|
subdirectory* - Directory where the application will be
|
7
|
-
|
12
|
+
installed (created if nonexistent)
|
8
13
|
|
9
|
-
|
14
|
+
Options:
|
10
15
|
-b, --blueprint - Optional Blueprint framework to create
|
11
16
|
|
12
|
-
examples:
|
13
|
-
architect create myapp
|
14
|
-
architect create myapp subdirectory
|
15
|
-
architect create myapp -b modjs
|
16
|
-
|
17
17
|
compile Compiles the architecture-js project in the current working directory.
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
example:
|
20
|
+
architect compile
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
Options:
|
23
|
+
-c, --compress - Compress output with JsMin
|
24
24
|
|
25
25
|
generate Generates scoffolding from a template.
|
26
26
|
|
27
|
+
examples:
|
28
|
+
architect generate mytemplate foo -f (boolean arguments use a single "-")
|
29
|
+
architect generate mytemplate foo --test "Hello" (named arguments can be boolean by passing no value `false`)
|
30
|
+
architect genreate mytemplate foo -f --test "Hello" (combined to generate complex templates)
|
31
|
+
|
27
32
|
Arguments:
|
28
33
|
name - Name of the template to generate
|
29
34
|
|
@@ -31,15 +36,10 @@ generate Generates scoffolding from a template.
|
|
31
36
|
*Options are arbitrary (optional) arguments specific to templates
|
32
37
|
There are two types of options: boolean and named attributes
|
33
38
|
|
34
|
-
examples:
|
35
|
-
architect generate mytemplate foo -f (boolean arguments use a single "-")
|
36
|
-
architect generate mytemplate foo --test "Hello" (named arguments can be boolean by passing no value `false`)
|
37
|
-
architect genreate mytemplate foo -f --test "Hello" (combined to generate complex templates)
|
38
|
-
|
39
39
|
watch Watches the current working directory for file
|
40
40
|
changes and compiles when changes are detected.
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
example:
|
43
|
+
architect watch
|
44
44
|
|
45
45
|
* optional argument
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.4
|
data/architecture-js.gemspec
CHANGED
@@ -22,6 +22,7 @@ module Architect
|
|
22
22
|
else
|
23
23
|
@root = File.expand_path(Dir.getwd)
|
24
24
|
end
|
25
|
+
@project = ArchitectureJS::Blueprint.new_from_config(@root)
|
25
26
|
end
|
26
27
|
|
27
28
|
def run
|
@@ -56,14 +57,11 @@ module Architect
|
|
56
57
|
|
57
58
|
require "#{blueprint}-architecture" unless blueprint == 'default'
|
58
59
|
|
59
|
-
project = ArchitectureJS::BLUEPRINTS[blueprint].new(config, @root)
|
60
|
-
project.create
|
60
|
+
@project = ArchitectureJS::BLUEPRINTS[blueprint].new(config, @root)
|
61
|
+
@project.create
|
61
62
|
end
|
62
63
|
|
63
64
|
def generate
|
64
|
-
project_path = File.expand_path(Dir.getwd)
|
65
|
-
project = ArchitectureJS::Blueprint.new_from_config(project_path)
|
66
|
-
|
67
65
|
config = {
|
68
66
|
arguments: @args,
|
69
67
|
template: @args.first,
|
@@ -71,36 +69,37 @@ module Architect
|
|
71
69
|
options: @template_options
|
72
70
|
}
|
73
71
|
begin
|
74
|
-
project.generator.generate config
|
72
|
+
@project.generator.generate config
|
75
73
|
rescue Exception => e
|
76
74
|
puts e.message
|
77
|
-
|
78
|
-
puts "Available templates:"
|
79
|
-
project.generator.templates.each { |k,v| puts " - #{k}" }
|
75
|
+
templates
|
80
76
|
end
|
81
77
|
end
|
82
78
|
|
83
79
|
def compile
|
84
|
-
project =
|
85
|
-
project.
|
86
|
-
project.update
|
80
|
+
@project.config[:output] = 'compressed' if options[:c] || options[:compress]
|
81
|
+
@project.update
|
87
82
|
end
|
88
|
-
#compile
|
89
83
|
|
90
84
|
def watch
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
project = ArchitectureJS::Blueprint::new_from_config(path)
|
95
|
-
project.update
|
96
|
-
watcher = project.watch
|
85
|
+
@project.update
|
86
|
+
@watcher = @project.watch
|
97
87
|
puts ArchitectureJS::Notification.log "architect is watching for changes. Type 'quit' to stop."
|
98
|
-
start_interactive_session
|
88
|
+
start_interactive_session
|
89
|
+
end
|
90
|
+
|
91
|
+
def templates
|
92
|
+
puts "Tempaltes:"
|
93
|
+
@project.generator.templates.each { |k,v| puts " - #{k}" }
|
94
|
+
end
|
95
|
+
|
96
|
+
def src_files
|
97
|
+
puts "Source files:"
|
98
|
+
@project.src_files.each { |f| puts " - #{File.basename f}" }
|
99
99
|
end
|
100
|
-
#watch
|
101
100
|
|
102
101
|
private
|
103
|
-
def start_interactive_session
|
102
|
+
def start_interactive_session
|
104
103
|
begin
|
105
104
|
command = ''
|
106
105
|
while not command =~ /^quit$/
|
@@ -108,17 +107,16 @@ module Architect
|
|
108
107
|
command = gets.chomp
|
109
108
|
case command
|
110
109
|
when /^quit$/
|
111
|
-
watcher.stop
|
110
|
+
@watcher.stop
|
112
111
|
when /src_files/
|
113
|
-
|
112
|
+
src_files
|
114
113
|
when /templates/
|
115
|
-
|
114
|
+
templates
|
116
115
|
when /compile/
|
117
116
|
begin
|
118
|
-
|
117
|
+
@project.update
|
119
118
|
rescue Exception => e
|
120
119
|
puts e.message
|
121
|
-
ArchitectureJS::Notification.prompt
|
122
120
|
end
|
123
121
|
when /generate/
|
124
122
|
begin
|
@@ -130,8 +128,7 @@ module Architect
|
|
130
128
|
rescue Exception => e
|
131
129
|
puts e.message
|
132
130
|
puts "Available templates:"
|
133
|
-
|
134
|
-
ArchitectureJS::Notification.prompt
|
131
|
+
@project.generator.templates.each { |k,v| puts " - #{k}" }
|
135
132
|
end
|
136
133
|
when /help/
|
137
134
|
puts 'Interactive commands:'
|
@@ -140,11 +137,14 @@ module Architect
|
|
140
137
|
puts ' templates - list available templates to generate'
|
141
138
|
puts ' src_files - list source files to be compiled into the build_dir'
|
142
139
|
puts ' help - show this menu'
|
140
|
+
puts ' quit - stop watching for changes'
|
141
|
+
else
|
142
|
+
puts ArchitectureJS::Notification.error "Unrecognized command `#{command}`. Try `help` or `quit`."
|
143
143
|
end
|
144
144
|
end
|
145
145
|
rescue SystemExit, Interrupt
|
146
146
|
puts
|
147
|
-
watcher.stop
|
147
|
+
@watcher.stop
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
@@ -31,7 +31,6 @@ module ArchitectureJS
|
|
31
31
|
@root = File.expand_path(root)
|
32
32
|
@template_directories = ["#{ArchitectureJS::base_directory}/templates", "#{@root}/templates"]
|
33
33
|
@directories = ['lib', 'src']
|
34
|
-
@src_files = []
|
35
34
|
@config = {
|
36
35
|
blueprint: 'default',
|
37
36
|
src_dir: 'src',
|
@@ -40,6 +39,7 @@ module ArchitectureJS
|
|
40
39
|
output: 'compressed'
|
41
40
|
}
|
42
41
|
@config.merge! config unless config.nil?
|
42
|
+
get_src_files
|
43
43
|
@generator = ArchitectureJS::Generator.new self
|
44
44
|
end
|
45
45
|
|
@@ -40,9 +40,10 @@ module ArchitectureJS
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def generate(config)
|
43
|
-
template
|
44
|
-
raise "There is no template named #{template} in the #{@blueprint[:name]} project"
|
43
|
+
raise "You must provide a template to generate:\n - architect generate <template>" unless config[:template]
|
44
|
+
raise "There is no template named '#{template}' in the #{@blueprint[:name]} project" unless @templates[config[:template]]
|
45
45
|
|
46
|
+
template = config[:template]
|
46
47
|
options = config[:options]
|
47
48
|
arguments = config[:arguments]
|
48
49
|
filename = "#{config[:filename]}#{@templates[template][:ext]}"
|
@@ -9,9 +9,9 @@ module ArchitectureJS
|
|
9
9
|
@listener.ignore(/#{@project.config[:build_dir]}|spec|test/)
|
10
10
|
.filter(/\.jst?$/)
|
11
11
|
.change do |modified, added, removed|
|
12
|
-
update_files(modified, "
|
13
|
-
update_files(added, "
|
14
|
-
update_files(removed, "
|
12
|
+
update_files(modified, "modified") if modified.length > 0
|
13
|
+
update_files(added, "added") if added.length > 0
|
14
|
+
update_files(removed, "deleted") if removed.length > 0
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -26,11 +26,15 @@ module ArchitectureJS
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
def update_files(files,
|
29
|
+
def update_files(files, action)
|
30
30
|
files.each do |f|
|
31
31
|
f = File.basename f
|
32
|
+
if action == "deleted"
|
33
|
+
FileUtils.rm_rf("#{@project.root}/#{f}")
|
34
|
+
puts "remove #{@project.root}/#{f}"
|
35
|
+
end
|
32
36
|
|
33
|
-
puts "\n" << ArchitectureJS::Notification.event("#{f} #{
|
37
|
+
puts "\n" << ArchitectureJS::Notification.event("#{f} was #{action}")
|
34
38
|
end
|
35
39
|
|
36
40
|
@project.read_config
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: architecture-js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -242,7 +242,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
242
242
|
version: '0'
|
243
243
|
segments:
|
244
244
|
- 0
|
245
|
-
hash:
|
245
|
+
hash: -1429009403293119997
|
246
246
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
247
247
|
none: false
|
248
248
|
requirements:
|