jscompiler 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/jsc CHANGED
@@ -29,7 +29,8 @@ Signal.trap(:INT) { abort "\nAborting jscompiler task." }
29
29
  [ 'cli.rb',
30
30
  'config.rb',
31
31
  'commands/base.rb',
32
- 'commands/clojure.rb'
32
+ 'commands/clojure.rb',
33
+ 'commands/yahoo.rb',
33
34
  ].each do |f|
34
35
  require File.expand_path(File.join(File.dirname(__FILE__), "../lib/jscompiler/#{f}"))
35
36
  end
@@ -39,78 +39,83 @@ module Jscompiler
39
39
  def init
40
40
  say("Initializing your project...")
41
41
 
42
- # say("Which compiler would you like to use?")
43
- # comps = [
44
- # ["1:", "clojure"],
45
- # ]
46
- # print_table(comps)
47
- # num = ask_for_number(1)
48
- # @compiler = comps[num-1].last
49
- @compiler = 'clojure' # the only one for now
42
+ ask_for_compiler
50
43
 
51
44
  @root = ask("\r\nWhat is your files source folder (a relative path from the current directory)?")
52
- @files = Dir.glob("#{@root}/**/*.js")
53
- table = []
54
- @files.each_with_index do |fl, index|
55
- table << ["#{index + 1}: ", fl]
56
- end
57
- print_table(table)
45
+ @root = '.' if @root == ''
58
46
 
59
- say("\r\nEnter the file numbers in the order you want them to be compiled (separated with commas). For example: 2,4,1,3. If the order doesn't matter, just press enter.")
60
- nums = ask("File order: ")
61
- if nums.strip != ""
62
- files = []
63
- nums.split(",").each do |num|
64
- index = num.to_i - 1
65
- if index < 0 or index >= @files.size
66
- puts("Invalid file number: #{num}")
67
- next
68
- end
69
- files << @files[index]
70
- end
71
- @files = files
72
- say("The files will be compiled in the following order. You can change the order manually by modifying the .jscompiler file in this folder.")
73
- table = []
74
- @files.each_with_index do |fl, index|
75
- table << ["#{index + 1}: ", fl]
76
- end
77
- print_table(table)
47
+ ask_for_file_order
48
+ ask_for_output_path
49
+
50
+ template 'templates/jscompiler.yml.erb', "./#{Jscompiler::Config.path}"
51
+
52
+ say("Configuration has been saved in .jscompiler file. You now can run the compile commands.")
53
+ end
54
+
55
+ map 'g' => :group
56
+ desc 'group', 'Creates a new file group'
57
+ def group
58
+ unless Jscompiler::Config.configured?
59
+ say("This folder has not yet been configured to run jsc commands. Please run 'jsc init'.")
60
+ return
78
61
  end
79
62
 
80
- @filename = ask("\r\nWhat should the compiled file be named?")
63
+ @group_name = ask("What would you like to name this group?")
64
+ @root = Jscompiler::Config.source_root
65
+ ask_for_compiler(:default => true)
66
+ ask_for_file_order
67
+ ask_for_output_path
81
68
 
82
- @output = ask("\r\nWhere should the compiled file be saved (a relative path from this folder)?")
69
+ Jscompiler::Config.config['groups'][@group_name] = {
70
+ "files" => @files,
71
+ "output" => {"path" => @output},
72
+ }
83
73
 
84
- @debug = yes?("\r\nWould you like to create a debug version of the file (concatinated, but not compiled)?")
74
+ if @compiler != "default"
75
+ Jscompiler::Config.config['groups'][@group_name]["compiler"] = {"name" => @compiler}
76
+ end
85
77
 
86
- template 'templates/jscompiler.yml.erb', "./#{Jscompiler::Config.path}"
87
- FileUtils.mkdir_p(@output)
78
+ Jscompiler::Config.update_config
88
79
 
89
- say("Configuration has been saved. You now can run the compile command.")
80
+ say("Configuration has been saved in .jscompiler file. You now can run the compile commands.")
90
81
  end
91
82
 
92
83
  map 'c' => :compile
93
84
  desc 'compile', 'Compiles selected file group'
85
+ method_option :compiler, :type => :string, :aliases => "-c", :required => false, :banner => "Compiler to use for compilation", :default => nil
94
86
  method_option :group, :type => :string, :aliases => "-g", :required => false, :banner => "Group to compile", :default => nil
87
+ method_option :output, :type => :string, :aliases => "-o", :required => false, :banner => "Path and name of the output file", :default => nil
88
+ method_option :prefix, :type => :string, :aliases => "-p", :required => false, :banner => "Prepand prefix to all compiled file names", :default => nil
89
+ method_option :suffix, :type => :string, :aliases => "-s", :required => false, :banner => "Append suffix to all compiled file names", :default => nil
95
90
  def compile
91
+ unless Jscompiler::Config.configured?
92
+ say("This folder has not yet been configured to run jsc commands. Please run 'jsc init'.")
93
+ return
94
+ end
95
+
96
96
  if @options[:group]
97
97
  unless Jscompiler::Config.groups.keys.include?(@options[:group])
98
98
  puts("Error: invalid group name")
99
99
  return
100
100
  end
101
101
 
102
- Jscompiler::Cli.compile_group(@options[:group])
102
+ Jscompiler::Commands::Base.compile_group(@options[:group], @options)
103
103
  return
104
104
  end
105
105
 
106
106
  Jscompiler::Config.groups.keys.each do |group|
107
- Jscompiler::Cli.compile_group(group)
107
+ Jscompiler::Commands::Base.compile_group(group, @options)
108
108
  end
109
109
  end
110
110
 
111
111
  map 'w' => :watch
112
112
  desc 'watch', 'Watches source root folder for cahnges and compiles all affected groups'
113
113
  def watch
114
+ unless Jscompiler::Config.configured?
115
+ say("This folder has not yet been configured to run jsc commands. Please run 'jsc init'.")
116
+ return
117
+ end
118
+
114
119
  say("Started monitoring #{Jscompiler::Config.source_root} folder. To stop use Ctrl+C.")
115
120
 
116
121
  monitor = FSSM::Monitor.new
@@ -127,8 +132,9 @@ module Jscompiler
127
132
 
128
133
  def compile(relative)
129
134
  Jscompiler::Config.groups.keys.each do |group|
130
- next unless Jscompiler::Config.files(group).include?("#{Jscompiler::Config.source_root}/#{relative}")
131
- Jscompiler::Cli.compile_group(group)
135
+ full_path = Jscompiler::Config.source_root == '.' ? relative : "#{Jscompiler::Config.source_root}/#{relative}"
136
+ next unless Jscompiler::Config.files(group).include?(full_path)
137
+ Jscompiler::Commands::Base.compile_group(group)
132
138
  end
133
139
  end
134
140
  end
@@ -136,19 +142,61 @@ module Jscompiler
136
142
  monitor.run
137
143
  end
138
144
 
139
- def self.compile_group(group)
140
- puts("Compiling #{group} group...")
141
-
142
- t0 = Time.now
143
- Jscompiler::Config.compiler_command.new({
144
- :group => group
145
- }).run
146
- t1 = Time.now
145
+ private
146
+
147
+ def ask_for_compiler(opts = {})
148
+ say("Which compiler would you like to use?")
149
+ compilers = ["clojure", "yahoo"]
150
+ if opts[:default]
151
+ compilers.unshift("default")
152
+ end
153
+ options = []
154
+ compilers.each_with_index do |c, index|
155
+ options << ["#{index + 1}:", c]
156
+ end
157
+ print_table(options)
158
+ num = ask_for_number(compilers.size)
159
+ @compiler = compilers[num-1]
160
+ end
147
161
 
148
- puts("\r\nDone. Compilation took #{t1-t0} seconds\r\n")
162
+ def ask_for_output_path(opts = {})
163
+ @output = ask("\r\nWhat is the path of the output file (a relative path from the current folder)?")
164
+ @output = './compiled.js' if @output == ''
165
+ if @output.index('/')
166
+ FileUtils.mkdir_p(@output.split('/')[0..-2].join('/'))
167
+ end
149
168
  end
150
169
 
151
- private
170
+ def ask_for_file_order(opts = {})
171
+ @files = Dir.glob("#{@root}/**/*.js")
172
+
173
+ table = []
174
+ @files.each_with_index do |fl, index|
175
+ table << ["#{index + 1}: ", fl]
176
+ end
177
+ print_table(table)
178
+
179
+ say("\r\nEnter the file numbers in the order you want them to be compiled (separated with commas). For example: 2,4,1,3. If the order doesn't matter, just press enter.")
180
+ nums = ask("File order: ")
181
+ if nums.strip != ""
182
+ files = []
183
+ nums.split(",").each do |num|
184
+ index = num.to_i - 1
185
+ if index < 0 or index >= @files.size
186
+ puts("Invalid file number: #{num}")
187
+ next
188
+ end
189
+ files << @files[index]
190
+ end
191
+ @files = files
192
+ say("The files will be compiled in the following order. You can change the order manually by modifying the .jscompiler file in this folder.")
193
+ table = []
194
+ @files.each_with_index do |fl, index|
195
+ table << ["#{index + 1}: ", fl]
196
+ end
197
+ print_table(table)
198
+ end
199
+ end
152
200
 
153
201
  def ask_for_number(max, opts = {})
154
202
  opts[:message] ||= "Choose: "
@@ -48,8 +48,44 @@ module Jscompiler
48
48
  content.gsub(comments_regexp, '')
49
49
  end
50
50
 
51
- def prepare(cmd, args)
52
- "#{cmd} #{args.collect{|arg| arg.join(' ')}.join(' ')};"
51
+ def prepare_arguments(args)
52
+ args.collect{|arg| arg.join(' ')}.join(' ')
53
+ end
54
+
55
+ def prepare_command(cmd, args)
56
+ "#{cmd} #{prepare_arguments(args)}"
57
+ end
58
+
59
+ def save_or_delete_temp_file
60
+ if Jscompiler::Config.debug?(group)
61
+ FileUtils.mv(temp_file_path, debug_file_path)
62
+ else
63
+ FileUtils.rm(temp_file_path)
64
+ end
65
+ end
66
+
67
+ def temp_file_path
68
+ Jscompiler::Config.output_destination(group, :suffix => ".tmp")
69
+ end
70
+
71
+ def debug_file_path
72
+ Jscompiler::Config.output_destination(group, :suffix => ".debug")
73
+ end
74
+
75
+ def generate_temp_file
76
+ File.open(temp_file_path, 'w') do |file|
77
+ Jscompiler::Config.files(group).each do |fl|
78
+ puts("Processing #{fl}...")
79
+ content = File.read(fl)
80
+ content = sanitize(content)
81
+ file.write(content)
82
+ end
83
+ end
84
+ end
85
+
86
+ def output_file_path
87
+ return options["output"] if options["output"]
88
+ Jscompiler::Config.output_destination(group, options)
53
89
  end
54
90
 
55
91
  def execute(cmd, opts = {})
@@ -65,7 +101,19 @@ module Jscompiler
65
101
  puts("Build failed.")
66
102
  exit 1
67
103
  end
68
- end
104
+ end
105
+
106
+ def self.compile_group(group, opts = {})
107
+ puts("\r\nCompiling #{group} group...")
108
+
109
+ t0 = Time.now
110
+ Jscompiler::Config.compiler_command(group, opts).new(opts.merge({
111
+ :group => group
112
+ })).run
113
+ t1 = Time.now
114
+
115
+ puts("Done. Compilation took #{t1-t0} seconds\r\n")
116
+ end
69
117
 
70
118
  end
71
119
 
@@ -26,26 +26,22 @@ module Jscompiler
26
26
 
27
27
  class Clojure < Base
28
28
 
29
- def run
30
- if Jscompiler::Config.debug?(group)
31
- File.open(Jscompiler::Config.output_destination(group, "-debug"), 'w') do |file|
32
- Jscompiler::Config.files(group).each do |fl|
33
- pp "Processing #{fl}..."
34
- content = File.read(fl)
35
- content = sanitize(content)
36
- file.write(content)
37
- end
38
- end
39
- end
29
+ def compiler_path
30
+ File.expand_path(File.join(File.dirname(__FILE__), "../../../vendor/clojure/compiler.jar"))
31
+ end
40
32
 
41
- args = [
42
- ["--js", Jscompiler::Config.files(group).join(' ')],
43
- ["--js_output_file", Jscompiler::Config.output_destination(group)],
33
+ def args
34
+ [
35
+ ["--js", temp_file_path],
36
+ ["--js_output_file", output_file_path],
44
37
  ["--warning_level", Jscompiler::Config.compiler["warning_level"] || "DEFAULT"]
45
38
  ]
39
+ end
46
40
 
47
- compiler_path = File.expand_path(File.join(File.dirname(__FILE__), "../../../vendor/clojure/compiler.jar"))
48
- execute(prepare("java -jar #{compiler_path}", args))
41
+ def run
42
+ generate_temp_file
43
+ execute(prepare_command("java -jar #{compiler_path}", args))
44
+ save_or_delete_temp_file
49
45
  end
50
46
 
51
47
  end
@@ -0,0 +1,48 @@
1
+ #--
2
+ # Copyright (c) 2013 Michael Berkovich
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ module Jscompiler
25
+ module Commands
26
+
27
+ class Yahoo < Base
28
+
29
+ def compiler_path
30
+ File.expand_path(File.join(File.dirname(__FILE__), "../../../vendor/yahoo/yuicompressor-2.4.2.jar"))
31
+ end
32
+
33
+ def args
34
+ [
35
+ ["-o", output_file_path],
36
+ ]
37
+ end
38
+
39
+ def run
40
+ generate_temp_file
41
+ execute("java -jar #{compiler_path} #{prepare_arguments(args)} #{temp_file_path}")
42
+ save_or_delete_temp_file
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+ end
@@ -41,6 +41,16 @@ module Jscompiler
41
41
  @config ||= YAML::load(File.open(path))
42
42
  end
43
43
 
44
+ def self.update_config
45
+ File.open(path, 'w') do |file|
46
+ file.write(config.to_yaml)
47
+ end
48
+ end
49
+
50
+ def self.configured?
51
+ File.exists?(path)
52
+ end
53
+
44
54
  def self.groups
45
55
  config["groups"]
46
56
  end
@@ -50,9 +60,14 @@ module Jscompiler
50
60
  groups[group]["compiler"] || config["compiler"]
51
61
  end
52
62
 
53
- def self.compiler_command(group = nil)
54
- if compiler(group)["name"] == 'clojure'
63
+ def self.compiler_command(group=nil, opts = {})
64
+ cmplr = opts[:compiler] || compiler(group)["name"]
65
+
66
+ case cmplr
67
+ when 'clojure'
55
68
  Jscompiler::Commands::Clojure
69
+ when 'yahoo'
70
+ Jscompiler::Commands::Yahoo
56
71
  else
57
72
  raise("Unsupported compiler")
58
73
  end
@@ -62,28 +77,33 @@ module Jscompiler
62
77
  config["source_root"]
63
78
  end
64
79
 
65
- def self.files(group = "default")
66
- groups[group]["files"].split(" ")
80
+ def self.files(group)
81
+ groups[group]["files"]
67
82
  end
68
83
 
69
- def self.output(group = "default")
84
+ def self.output(group)
70
85
  groups[group]["output"]
71
86
  end
72
87
 
73
- def self.output_path(group = "default")
88
+ def self.output_path(group)
74
89
  output(group)["path"]
75
90
  end
76
91
 
77
- def self.output_name(group = "default")
78
- output(group)["name"]
79
- end
80
-
81
- def self.debug?(group = "default")
92
+ def self.debug?(group)
82
93
  output(group)["debug"]
83
94
  end
84
95
 
85
- def self.output_destination(group = "default", suffix = "")
86
- "#{Jscompiler::Config.output_path(group)}/#{Jscompiler::Config.output_name(group)}#{suffix}.js"
96
+ def self.output_destination(group, opts = {})
97
+ path = output_path(group)
98
+ parts = path.split("/")
99
+ file_name = parts.pop
100
+ if opts[:suffix]
101
+ file_name = file_name.index('.js') ? file_name.gsub(".js", "#{opts[:suffix]}.js") : "#{file_name}#{opts[:suffix]}"
102
+ end
103
+ if opts[:prefix]
104
+ file_name = "#{opts[:prefix]}#{file_name}"
105
+ end
106
+ "#{parts.join("/")}/#{file_name}"
87
107
  end
88
108
 
89
109
  end
@@ -22,7 +22,7 @@
22
22
  #++
23
23
 
24
24
  module Jscompiler
25
- VERSION = "0.1.0"
25
+ VERSION = "0.2.1"
26
26
  end
27
27
 
28
28
 
data/lib/jscompiler.rb CHANGED
@@ -26,4 +26,5 @@ module Jscompiler
26
26
  autoload :Config, 'jscompiler/config'
27
27
  autoload :Base, 'jscompiler/commands/base'
28
28
  autoload :Clojure, 'jscompiler/commands/clojure'
29
+ autoload :Yahoo, 'jscompiler/commands/yahoo'
29
30
  end
@@ -1,3 +1,4 @@
1
+ ---
1
2
  source_root: <%=@root%> # Relative path from the project root to Where your JavaScript files are located
2
3
  compiler:
3
4
  name: <%=@compiler%> # Name of the compiler to use. By default "clojure" compiler will be used
@@ -5,8 +6,6 @@ compiler:
5
6
  groups: # Groups of files you wish to compile
6
7
  default:
7
8
  files: # List of the JS files in the order they will be compiled
8
- <%= @files.join("\r\n ") %>
9
+ - <%= @files.join("\r\n - ") %>
9
10
  output:
10
- name: <%=@filename%> # Name of the output file
11
- debug: <%=@debug%> # Wether you want to produce an uncompiled version as well
12
11
  path: <%=@output%> # Relative path to where the output files should be created
@@ -0,0 +1,53 @@
1
+ All code under this directory and any subdirectories, with the exception
2
+ of the "lib" directory, is licensed under the BSD license, presented below:
3
+
4
+ Copyright (c) 2009, Yahoo! Inc. All rights reserved.
5
+
6
+ Code licensed under the BSD License:
7
+ http://developer.yahoo.net/yui/license.txt
8
+
9
+ The "lib" directory contains build support tools, which are packaged
10
+ along with the YUI component build code, in order to simplify installation.
11
+
12
+ The contents of "lib" are covered by the individual licenses below:
13
+
14
+ 1). lib/ant-contrib/ant-contrib-1.0b3-modified.jar:
15
+
16
+ Is issued under the Apache Software License. For more information, see:
17
+
18
+ http://ant-contrib.sourceforge.net/
19
+ http://ant-contrib.sourceforge.net/LICENSE.txt
20
+
21
+ The ant-contrib-1.0b3 release has been modified by YUI to add the
22
+ missing lookup entry for the "for" task to antcontrib.properties:
23
+
24
+ for=net.sf.antcontrib.logic.ForTask
25
+
26
+ 2). lib/rhino/js.jar:
27
+
28
+ Rhino is issued under the Mozilla Public License (MPL), and MPL applies
29
+ to the Rhino source and binaries that are distributed under the
30
+ "lib/rhino" directory. For more information on Rhino licensing, see:
31
+
32
+ https://developer.mozilla.org/en/Rhino_License
33
+
34
+ 3). lib/jslint/jslint-console.js:
35
+
36
+ Is derived from rhino.js available at www.jslint.com/rhino/rhino.js,
37
+ the contents of which are in the public domain. See the contents of the
38
+ file for licensing information.
39
+
40
+ 4). lib/jslint/fulljslint.js:
41
+
42
+ Is derived from fulljslint.js, available at
43
+ http://www.jslint.com/fulljslint.js, the contents of which are in the public
44
+ domain. See the contents of the file for licensing information.
45
+
46
+ 5). lib/yuicompressor:
47
+
48
+ Is covered by the BSD license, specified on
49
+ http://developer.yahoo.com/yui/compressor/
50
+
51
+ YUI Compressor ships with a modified version of Rhino, which is covered by
52
+ the Mozilla Public License, further details of which can be found at the above
53
+ url.
@@ -0,0 +1,229 @@
1
+ INTRODUCTION
2
+ ------------
3
+
4
+ YUI uses ANT to create component build files from individual source files.
5
+
6
+ Each component has its own ANT build file residing in the component's
7
+ source folder with an associated properties file used to define build
8
+ parameters specific to the component e.g:
9
+
10
+ yui2/src/autocomplete/build.xml
11
+ yui2/src/autocomplete/build.properties
12
+
13
+ The component build will automate the conversion from component source
14
+ to <component>.js, <component>-min.js, <component>-debug.js by:
15
+
16
+ a) Concatenating individual source files
17
+ b) Stripping logger statements
18
+ c) Compressing files, using yuicompressor
19
+ d) Running jslint on all 3 built files
20
+ e) Adding boiler plate module/version registration code
21
+ f) Building skin files from <component>-core.css, <component>-skin.css
22
+ g) Deploying built JS, CSS and assets to <project>/build
23
+
24
+ The same component build system is also used for CSS components such as
25
+ reset, base, fonts and grids.
26
+
27
+ The component build does not currently:
28
+
29
+ a) Check in any code
30
+
31
+ The developer is responsible for checking modified source code
32
+ into the <project>/src directory, and built code into the
33
+ <project>/build directory, allowing them to review diffs,
34
+ before committing changes.
35
+
36
+ b) Generate API documentation
37
+
38
+ INSTALLATION
39
+ ------------
40
+
41
+ Below is a brief summary as well as a detailed step-by-step guide
42
+ for installing the build system, allowing you to build the "src"
43
+ component code.
44
+
45
+ SUMMARY
46
+
47
+ 1) Install ANT 1.7 or above, and add ant to your path
48
+
49
+ 2) Clone the YUI "builder" project from http://github.com/yui/builder/
50
+
51
+ 3) At the command line, cd to the source directory of the component
52
+ you wish to build, and execute "ant all" to build, e.g.:
53
+
54
+ prompt> cd yui2/src/autocomplete
55
+ prompt> ant all
56
+
57
+ DETAILED INSTRUCTIONS
58
+
59
+ To use the build system, you'll need to install ANT and obtain
60
+ the YUI build infrastructure from github.
61
+
62
+ These are both one-time install tasks.
63
+
64
+ INSTALLING ANT
65
+
66
+ 1) Download and install ANT 1.7 (or above)
67
+
68
+ http://ant.apache.org/bindownload.cgi
69
+
70
+ 2) Be sure to define an ANT_HOME environment variable to point to
71
+ your ANT install root, and add the ANT executable to your
72
+ environment's PATH variable.
73
+
74
+ INSTALLING YUI BUILD INFRASTRUCTURE
75
+
76
+ 1) Clone the YUI "builder" project from github:
77
+
78
+ http://github.com/yui/builder/
79
+
80
+ This project contains the files used by the
81
+ YUI ant build process.
82
+
83
+ 2) Out of the box, the build system is designed to work
84
+ when cloned to the default "builder" directory, parallel
85
+ to the project source directories:
86
+
87
+ <gitroot>/yui2 [ cloned yui2 project ]
88
+ <gitroot>/yui3 [ cloned yui2 project ]
89
+ <gitroot>/builder [ cloned builder project ]
90
+
91
+ Cloning it to the default location will allow you to
92
+ build any of the components without having to modify any
93
+ component build scripts.
94
+
95
+ NOTE: YUI Builder is also available for download as a zip from
96
+ http://yuilibrary.com/downloads. If downloading from this location
97
+ to build yui2 or yui3 source, make sure to unzip the contents into
98
+ the directory structure mentioned above, to have the build work out
99
+ of the box.
100
+
101
+ BUILDING AN EXISTING COMPONENT
102
+ ------------------------------
103
+
104
+ With ANT and the YUI build infrastructure installed, you can now build any
105
+ of the components from source, using the build.xml file in the component's
106
+ source directory.
107
+
108
+ The build system allows you to build locally, within the component's
109
+ source directory, and also run a full build to update the top level build
110
+ directory for a component.
111
+
112
+ FULL BUILD
113
+
114
+ To perform a full build for a component, run ant with the "all" target:
115
+
116
+ e.g:
117
+
118
+ prompt> cd yui2/src/autocomplete
119
+ prompt> ant all
120
+
121
+ The "all" build target will build the component from its source files AND
122
+ deploy the built files, as well as any assets, to the top level build
123
+ folder:
124
+
125
+ <project>/build/<component>
126
+
127
+ So, for autocomplete, the built files would be copied to:
128
+
129
+ yui2/build/autocomplete
130
+
131
+ NOTE: When invoking ant without a file argument, as we do above, it will
132
+ use build.xml, if present in the current directory - which is what we want.
133
+
134
+ LOCAL BUILD
135
+
136
+ To perform a local build for a component, run ant without a target:
137
+
138
+ e.g:
139
+
140
+ prompt> cd yui2/src/autocomplete
141
+ prompt> ant
142
+
143
+ This will run the default target, which is "local".
144
+
145
+ The "local" build target will build the autocomplete component from its
146
+ source files, but will NOT deploy the built files to the top level build
147
+ folder.
148
+
149
+ The locally built files are stored in the temporary directory:
150
+
151
+ <project>/src/<component>/build_tmp
152
+
153
+ So, for autocomplete, the built files can be found in the directory below:
154
+
155
+ yui2/src/autocomplete/build_tmp
156
+
157
+ BUILD OUTPUT
158
+
159
+ ANT will output build information to the screen, as it runs through the
160
+ build, which can be redirected to a file if required:
161
+
162
+ prompt> ant all
163
+
164
+ Buildfile: build.xml
165
+ [echo] Starting Build For autocomplete
166
+ ...
167
+ [echo] builddir : ../../../builder/componentbuild
168
+ ...
169
+ ...
170
+ BUILD SUCCESSFUL
171
+ Total time: 7 seconds
172
+
173
+ prompt>
174
+
175
+ NOTE: Most components will have warnings which are output during the
176
+ "minify" and "lint" steps, which the component developer has evaluated
177
+ and determined to have no impact on functionality.
178
+
179
+ CREATING BUILD FILES FOR A NEW COMPONENT
180
+ ----------------------------------------
181
+
182
+ The builder/componentbuild/templates directory has basic build.xml and
183
+ build.properties templates for the various component types supported.
184
+
185
+ For most new components, you should be able to start with the
186
+ appropriate template files and simply change the values of the basic
187
+ properties defined to suit your component.
188
+
189
+ If you're creating:
190
+
191
+ * A YUI 2 Component (either a JS or CSS component), use:
192
+
193
+ builder/componentbuild/templates/yui2
194
+
195
+ build.xml
196
+ build.properties
197
+
198
+ * A YUI 3 Component (either a JS or CSS component), use:
199
+
200
+ builder/componentbuild/templates/yui3
201
+
202
+ build.xml
203
+ build.properties
204
+
205
+ * A YUI 3 Rollup Component, use:
206
+
207
+ builder/componentbuild/templates/yui3/rollup
208
+
209
+ For the rollup component:
210
+ build.xml
211
+ build.properties
212
+
213
+ For the sub components:
214
+ subcomponentone.xml
215
+ subcomponentone.properties
216
+ subcomponenttwo.xml
217
+ subcomponenttwo.properties
218
+
219
+ FURTHER CUSTOMIZATION
220
+
221
+ If required, you can define custom values for any of the properties
222
+ defined in builder/componentbuild/docs/properties.html to customize the
223
+ build for your new component, however as mentioned above, for most
224
+ components the properties defined in the template files should be
225
+ sufficient.
226
+
227
+ You can also override or extend existing targets, to customize the actual
228
+ build process for a component if required. The list of targets and their
229
+ role is defined in builder/componentbuild/docs/targets.html.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jscompiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -56,6 +56,7 @@ files:
56
56
  - lib/jscompiler/cli.rb
57
57
  - lib/jscompiler/commands/base.rb
58
58
  - lib/jscompiler/commands/clojure.rb
59
+ - lib/jscompiler/commands/yahoo.rb
59
60
  - lib/jscompiler/config.rb
60
61
  - lib/jscompiler/version.rb
61
62
  - lib/jscompiler.rb
@@ -63,6 +64,9 @@ files:
63
64
  - vendor/clojure/compiler.jar
64
65
  - vendor/clojure/COPYING
65
66
  - vendor/clojure/README
67
+ - vendor/yahoo/LICENSE
68
+ - vendor/yahoo/README
69
+ - vendor/yahoo/yuicompressor-2.4.2.jar
66
70
  - LICENSE
67
71
  - README.rdoc
68
72
  homepage: https://github.com/berk/jscompiler