jscompiler 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Michael Berkovich
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,78 @@
1
+ = Introduction
2
+
3
+ There are many tools out there that help you obfuscate, compress, compile or uglify your JavaScript so the file size will be smaller, the script will load faster and the code will be harder to steal.
4
+
5
+ This CLI utility simplifies the process of compiling your JS files by letting you choose your compression library and use it with a single command:
6
+
7
+ $ jsc compile
8
+
9
+
10
+ = Installation
11
+
12
+ gem install jscompiler
13
+
14
+
15
+ = Configuration
16
+
17
+ To setup your project with some default parameters, run the following command:
18
+
19
+ $ jsc init
20
+
21
+ This command will ask you a few questions about your project. If you don't like being asked questions and prefer to configure your project manually, just create a .jscompiler file in your project folder and provide the following information:
22
+
23
+ source_root: "src" # Relative path from the project root to Where your JavaScript files are located
24
+ compiler:
25
+ name: "clojure" # Name of the compiler to use. By default "clojure" compiler will be used
26
+ groups: # Groups of files you wish to compile
27
+ default:
28
+ files: # List of the JS files in the order they will be compiled
29
+ src/file1.js
30
+ src/file2.js
31
+ src/file3.js
32
+ output:
33
+ name: "default" # Name of the output file
34
+ debug: true # Wether you want to produce an uncompiled version as well
35
+ path: "build" # Relative path to where the output files should be created
36
+ just1and3:
37
+ files: # List of the JS files in the order they will be compiled
38
+ src/file1.js
39
+ src/file3.js
40
+ output:
41
+ name: "just1and3"
42
+ debug: true
43
+ path: "build"
44
+
45
+
46
+ You can configure any number of groups. The files in the groups will be concatenated and compiled in the order you entered them in.
47
+
48
+ = Execution
49
+
50
+ Once you have configured your file groups, you can run the compile command:
51
+
52
+ $ jsc c
53
+
54
+ This will compile all groups. To compile only a specific group, provide the group name:
55
+
56
+ $ jsc c -g just1and3
57
+
58
+ To get help on any of the tasks, run:
59
+
60
+ $ jsc
61
+
62
+
63
+ = Watching folders for changes
64
+
65
+ Many times you want the compilation to be done automatically when you change the JavaScript files. JSC provides this option as well.
66
+
67
+ You can start watching the source_root folder for changes by running the following command:
68
+
69
+ $ jsc w
70
+
71
+ Any time a JavaScript file is changed anywhere in the folder, the JSC will find all of the groups where the file is listed and compile these groups.
72
+
73
+
74
+ = Contribution
75
+
76
+ Clone the repository, make any changes you like and send me a pull request.
77
+
78
+
data/bin/jsc ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #--
4
+ # Copyright (c) 2013 Michael Berkovich
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #++
25
+
26
+ # Abort beautifully with ctrl+c.
27
+ Signal.trap(:INT) { abort "\nAborting jscompiler task." }
28
+
29
+ [ 'cli.rb',
30
+ 'config.rb',
31
+ 'commands/base.rb',
32
+ 'commands/clojure.rb'
33
+ ].each do |f|
34
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/jscompiler/#{f}"))
35
+ end
36
+
37
+ # require 'jscompiler'
38
+ Jscompiler::Cli.start
@@ -0,0 +1,171 @@
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
+ require 'thor'
25
+ require 'fssm'
26
+
27
+ module Jscompiler
28
+ class Cli < Thor
29
+ include Thor::Actions
30
+
31
+ class << self
32
+ def source_root
33
+ File.expand_path('../../',__FILE__)
34
+ end
35
+ end
36
+
37
+ map 'i' => :init
38
+ desc 'init', 'Initializes your project and writes your preferences into a .jscompiler configuration file'
39
+ def init
40
+ say("Initializing your project...")
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
50
+
51
+ @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)
58
+
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)
78
+ end
79
+
80
+ @filename = ask("\r\nWhat should the compiled file be named?")
81
+
82
+ @output = ask("\r\nWhere should the compiled file be saved (a relative path from this folder)?")
83
+
84
+ @debug = yes?("\r\nWould you like to create a debug version of the file (concatinated, but not compiled)?")
85
+
86
+ template 'templates/jscompiler.yml.erb', "./#{Jscompiler::Config.path}"
87
+ FileUtils.mkdir_p(@output)
88
+
89
+ say("Configuration has been saved. You now can run the compile command.")
90
+ end
91
+
92
+ map 'c' => :compile
93
+ desc 'compile', 'Compiles selected file group'
94
+ method_option :group, :type => :string, :aliases => "-g", :required => false, :banner => "Group to compile", :default => nil
95
+ def compile
96
+ if @options[:group]
97
+ unless Jscompiler::Config.groups.keys.include?(@options[:group])
98
+ puts("Error: invalid group name")
99
+ return
100
+ end
101
+
102
+ Jscompiler::Cli.compile_group(@options[:group])
103
+ return
104
+ end
105
+
106
+ Jscompiler::Config.groups.keys.each do |group|
107
+ Jscompiler::Cli.compile_group(group)
108
+ end
109
+ end
110
+
111
+ map 'w' => :watch
112
+ desc 'watch', 'Watches source root folder for cahnges and compiles all affected groups'
113
+ def watch
114
+ say("Started monitoring #{Jscompiler::Config.source_root} folder. To stop use Ctrl+C.")
115
+
116
+ monitor = FSSM::Monitor.new
117
+ monitor.path("./#{Jscompiler::Config.source_root}/", '**/*.js') do
118
+ update do |base, relative|
119
+ puts("#{relative} file changed")
120
+ compile(relative)
121
+ end
122
+
123
+ delete do |base, relative|
124
+ puts("#{relative} deleted")
125
+ compile(relative)
126
+ end
127
+
128
+ def compile(relative)
129
+ 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)
132
+ end
133
+ end
134
+ end
135
+
136
+ monitor.run
137
+ end
138
+
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
147
+
148
+ puts("\r\nDone. Compilation took #{t1-t0} seconds\r\n")
149
+ end
150
+
151
+ private
152
+
153
+ def ask_for_number(max, opts = {})
154
+ opts[:message] ||= "Choose: "
155
+ while true
156
+ value = ask(opts[:message])
157
+ if /^[\d]+$/ === value
158
+ num = value.to_i
159
+ if num < 1 or num > max
160
+ say("Hah?")
161
+ else
162
+ return num
163
+ end
164
+ else
165
+ say("Hah?")
166
+ end
167
+ end
168
+ end
169
+
170
+ end
171
+ end
@@ -0,0 +1,73 @@
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 Base
28
+
29
+ attr_reader :options
30
+
31
+ def initialize(opts = {})
32
+ @options = opts
33
+ end
34
+
35
+ def group
36
+ options[:group]
37
+ end
38
+
39
+ def run
40
+ raise("Must be implemented by the extending class")
41
+ end
42
+
43
+ def comments_regexp
44
+ /\/\*(!)*[^*]*\*+(?:[^*\/][^*]*\*+)*\//
45
+ end
46
+
47
+ def sanitize(content)
48
+ content.gsub(comments_regexp, '')
49
+ end
50
+
51
+ def prepare(cmd, args)
52
+ "#{cmd} #{args.collect{|arg| arg.join(' ')}.join(' ')};"
53
+ end
54
+
55
+ def execute(cmd, opts = {})
56
+ puts("\r\n$ " + cmd)
57
+ return if opts[:cold]
58
+
59
+ # Kernel.spawn(command)
60
+
61
+ result = system(cmd)
62
+ return if opts[:ignore_result]
63
+
64
+ unless result
65
+ puts("Build failed.")
66
+ exit 1
67
+ end
68
+ end
69
+
70
+ end
71
+
72
+ end
73
+ end
@@ -0,0 +1,54 @@
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 Clojure < Base
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
40
+
41
+ args = [
42
+ ["--js", Jscompiler::Config.files(group).join(' ')],
43
+ ["--js_output_file", Jscompiler::Config.output_destination(group)],
44
+ ["--warning_level", Jscompiler::Config.compiler["warning_level"] || "DEFAULT"]
45
+ ]
46
+
47
+ compiler_path = File.expand_path(File.join(File.dirname(__FILE__), "../../../vendor/clojure/compiler.jar"))
48
+ execute(prepare("java -jar #{compiler_path}", args))
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,90 @@
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
+ require 'fileutils'
25
+ require 'yaml'
26
+ require 'plist'
27
+ require 'pp'
28
+
29
+ module Jscompiler
30
+ class Config
31
+
32
+ def self.path
33
+ '.jscompiler'
34
+ end
35
+
36
+ ##################################################
37
+ ## Configuration Attributes
38
+ ##################################################
39
+
40
+ def self.config
41
+ @config ||= YAML::load(File.open(path))
42
+ end
43
+
44
+ def self.groups
45
+ config["groups"]
46
+ end
47
+
48
+ def self.compiler(group = nil)
49
+ return config["compiler"] if group.nil?
50
+ groups[group]["compiler"] || config["compiler"]
51
+ end
52
+
53
+ def self.compiler_command(group = nil)
54
+ if compiler(group)["name"] == 'clojure'
55
+ Jscompiler::Commands::Clojure
56
+ else
57
+ raise("Unsupported compiler")
58
+ end
59
+ end
60
+
61
+ def self.source_root
62
+ config["source_root"]
63
+ end
64
+
65
+ def self.files(group = "default")
66
+ groups[group]["files"].split(" ")
67
+ end
68
+
69
+ def self.output(group = "default")
70
+ groups[group]["output"]
71
+ end
72
+
73
+ def self.output_path(group = "default")
74
+ output(group)["path"]
75
+ end
76
+
77
+ def self.output_name(group = "default")
78
+ output(group)["name"]
79
+ end
80
+
81
+ def self.debug?(group = "default")
82
+ output(group)["debug"]
83
+ end
84
+
85
+ def self.output_destination(group = "default", suffix = "")
86
+ "#{Jscompiler::Config.output_path(group)}/#{Jscompiler::Config.output_name(group)}#{suffix}.js"
87
+ end
88
+
89
+ end
90
+ end
@@ -0,0 +1,28 @@
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
+ VERSION = "0.1.0"
26
+ end
27
+
28
+
data/lib/jscompiler.rb ADDED
@@ -0,0 +1,29 @@
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
+ autoload :Cli, 'jscompiler/cli'
26
+ autoload :Config, 'jscompiler/config'
27
+ autoload :Base, 'jscompiler/commands/base'
28
+ autoload :Clojure, 'jscompiler/commands/clojure'
29
+ end
@@ -0,0 +1,12 @@
1
+ source_root: <%=@root%> # Relative path from the project root to Where your JavaScript files are located
2
+ compiler:
3
+ name: <%=@compiler%> # Name of the compiler to use. By default "clojure" compiler will be used
4
+ warning_level: QUIET
5
+ groups: # Groups of files you wish to compile
6
+ default:
7
+ files: # List of the JS files in the order they will be compiled
8
+ <%= @files.join("\r\n ") %>
9
+ output:
10
+ name: <%=@filename%> # Name of the output file
11
+ debug: <%=@debug%> # Wether you want to produce an uncompiled version as well
12
+ path: <%=@output%> # Relative path to where the output files should be created
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,292 @@
1
+ /*
2
+ * Copyright 2009 The Closure Compiler Authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ //
18
+ // Contents
19
+ //
20
+
21
+ The Closure Compiler performs checking, instrumentation, and
22
+ optimizations on JavaScript code. The purpose of this README is to
23
+ explain how to build and run the Closure Compiler.
24
+
25
+ The Closure Compiler requires Java 6 or higher.
26
+ http://www.java.com/
27
+
28
+
29
+ //
30
+ // Building The Closure Compiler
31
+ //
32
+
33
+ There are three ways to get a Closure Compiler executable.
34
+
35
+ 1) Use one we built for you.
36
+
37
+ Pre-built Closure binaries can be found at
38
+ http://code.google.com/p/closure-compiler/downloads/list
39
+
40
+
41
+ 2) Check out the source and build it with Apache Ant.
42
+
43
+ First, check out the full source tree of the Closure Compiler. There
44
+ are instructions on how to do this at the project site.
45
+ http://code.google.com/p/closure-compiler/source/checkout
46
+
47
+ Apache Ant is a cross-platform build tool.
48
+ http://ant.apache.org/
49
+
50
+ At the root of the source tree, there is an Ant file named
51
+ build.xml. To use it, navigate to the same directory and type the
52
+ command
53
+
54
+ ant jar
55
+
56
+ This will produce a jar file called "build/compiler.jar".
57
+
58
+
59
+ 3) Check out the source and build it with Eclipse.
60
+
61
+ Eclipse is a cross-platform IDE.
62
+ http://www.eclipse.org/
63
+
64
+ Under Eclipse's File menu, click "New > Project ..." and create a
65
+ "Java Project." You will see an options screen. Give the project a
66
+ name, select "Create project from existing source," and choose the
67
+ root of the checked-out source tree as the existing directory. Verify
68
+ that you are using JRE version 6 or higher.
69
+
70
+ Eclipse can use the build.xml file to discover rules. When you
71
+ navigate to the build.xml file, you will see all the build rules in
72
+ the "Outline" pane. Run the "jar" rule to build the compiler in
73
+ build/compiler.jar.
74
+
75
+
76
+ //
77
+ // Running The Closure Compiler
78
+ //
79
+
80
+ Once you have the jar binary, running the Closure Compiler is straightforward.
81
+
82
+ On the command line, type
83
+
84
+ java -jar compiler.jar
85
+
86
+ This starts the compiler in interactive mode. Type
87
+
88
+ var x = 17 + 25;
89
+
90
+ then hit "Enter", then hit "Ctrl-Z" (on Windows) or "Ctrl-D" (on Mac or Linux)
91
+ and "Enter" again. The Compiler will respond:
92
+
93
+ var x=42;
94
+
95
+ The Closure Compiler has many options for reading input from a file,
96
+ writing output to a file, checking your code, and running
97
+ optimizations. To learn more, type
98
+
99
+ java -jar compiler.jar --help
100
+
101
+ You can read more detailed documentation about the many flags at
102
+ http://code.google.com/closure/compiler/docs/gettingstarted_app.html
103
+
104
+
105
+ //
106
+ // Compiling Multiple Scripts
107
+ //
108
+
109
+ If you have multiple scripts, you should compile them all together with
110
+ one compile command.
111
+
112
+ java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js
113
+
114
+ The Closure Compiler will concatenate the files in the order they're
115
+ passed at the command line.
116
+
117
+ If you need to compile many, many scripts together, you may start to
118
+ run into problems with managing dependencies between scripts. You
119
+ should check out the Closure Library. It contains functions for
120
+ enforcing dependencies between scripts, and a tool called calcdeps.py
121
+ that knows how to give scripts to the Closure Compiler in the right
122
+ order.
123
+
124
+ http://code.google.com/p/closure-library/
125
+
126
+ //
127
+ // Licensing
128
+ //
129
+
130
+ Unless otherwise stated, all source files are licensed under
131
+ the Apache License, Version 2.0.
132
+
133
+
134
+ -----
135
+ Code under:
136
+ src/com/google/javascript/rhino
137
+ test/com/google/javascript/rhino
138
+
139
+ URL: http://www.mozilla.org/rhino
140
+ Version: 1.5R3, with heavy modifications
141
+ License: Netscape Public License and MPL / GPL dual license
142
+
143
+ Description: A partial copy of Mozilla Rhino. Mozilla Rhino is an
144
+ implementation of JavaScript for the JVM. The JavaScript parser and
145
+ the parse tree data structures were extracted and modified
146
+ significantly for use by Google's JavaScript compiler.
147
+
148
+ Local Modifications: The packages have been renamespaced. All code not
149
+ relavant to parsing has been removed. A JSDoc parser and static typing
150
+ system have been added.
151
+
152
+
153
+ -----
154
+ Code in:
155
+ lib/rhino
156
+
157
+ Rhino
158
+ URL: http://www.mozilla.org/rhino
159
+ Version: Trunk
160
+ License: Netscape Public License and MPL / GPL dual license
161
+
162
+ Description: Mozilla Rhino is an implementation of JavaScript for the JVM.
163
+
164
+ Local Modifications: Minor changes to parsing JSDoc that usually get pushed
165
+ up-stream to Rhino trunk.
166
+
167
+
168
+ -----
169
+ Code in:
170
+ lib/args4j.jar
171
+
172
+ Args4j
173
+ URL: https://args4j.dev.java.net/
174
+ Version: 2.0.12
175
+ License: MIT
176
+
177
+ Description:
178
+ args4j is a small Java class library that makes it easy to parse command line
179
+ options/arguments in your CUI application.
180
+
181
+ Local Modifications: None.
182
+
183
+
184
+ -----
185
+ Code in:
186
+ lib/guava.jar
187
+
188
+ Guava Libraries
189
+ URL: http://code.google.com/p/guava-libraries/
190
+ Version: r08
191
+ License: Apache License 2.0
192
+
193
+ Description: Google's core Java libraries.
194
+
195
+ Local Modifications: None.
196
+
197
+
198
+ -----
199
+ Code in:
200
+ lib/jsr305.jar
201
+
202
+ Annotations for software defect detection
203
+ URL: http://code.google.com/p/jsr-305/
204
+ Version: svn revision 47
205
+ License: BSD License
206
+
207
+ Description: Annotations for software defect detection.
208
+
209
+ Local Modifications: None.
210
+
211
+
212
+ -----
213
+ Code in:
214
+ lib/jarjar.jar
215
+
216
+ Jar Jar Links
217
+ URL: http://jarjar.googlecode.com/
218
+ Version: 1.1
219
+ License: Apache License 2.0
220
+
221
+ Description:
222
+ A utility for repackaging Java libraries.
223
+
224
+ Local Modifications: None.
225
+
226
+
227
+ ----
228
+ Code in:
229
+ lib/junit.jar
230
+
231
+ JUnit
232
+ URL: http://sourceforge.net/projects/junit/
233
+ Version: 4.8.2
234
+ License: Common Public License 1.0
235
+
236
+ Description: A framework for writing and running automated tests in Java.
237
+
238
+ Local Modifications: None.
239
+
240
+
241
+ ---
242
+ Code in:
243
+ lib/protobuf-java.jar
244
+
245
+ Protocol Buffers
246
+ URL: http://code.google.com/p/protobuf/
247
+ Version: 2.3.0
248
+ License: New BSD License
249
+
250
+ Description: Supporting libraries for protocol buffers,
251
+ an encoding of structured data.
252
+
253
+ Local Modifications: None
254
+
255
+
256
+ ---
257
+ Code in:
258
+ lib/ant.jar
259
+ lib/ant-launcher.jar
260
+
261
+ URL: http://ant.apache.org/bindownload.cgi
262
+ Version: 1.8.1
263
+ License: Apache License 2.0
264
+ Description:
265
+ Ant is a Java based build tool. In theory it is kind of like "make"
266
+ without make's wrinkles and with the full portability of pure java code.
267
+
268
+ Local Modifications: None
269
+
270
+
271
+ ---
272
+ Code in:
273
+ lib/json.jar
274
+ URL: http://json.org/java/index.html
275
+ Version: JSON version 20090211
276
+ License: MIT license
277
+ Description:
278
+ JSON is a set of java files for use in transmitting data in JSON format.
279
+
280
+ Local Modifications: None
281
+
282
+ ---
283
+ Code in:
284
+ tools/maven-ant-tasks-2.1.1.jar
285
+ URL: http://maven.apache.org
286
+ Version 2.1.1
287
+ License: Apache License 2.0
288
+ Description:
289
+ Maven Ant tasks are used to manage dependencies and to install/deploy to
290
+ maven repositories.
291
+
292
+ Local Modifications: None
Binary file
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jscompiler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Berkovich
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.16.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.16.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: fssm
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Utility that allows you to use various JS compilers to compress and uglify
47
+ your JavaScript code.
48
+ email:
49
+ - theiceberk@gmail.com
50
+ executables:
51
+ - jsc
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - bin/jsc
56
+ - lib/jscompiler/cli.rb
57
+ - lib/jscompiler/commands/base.rb
58
+ - lib/jscompiler/commands/clojure.rb
59
+ - lib/jscompiler/config.rb
60
+ - lib/jscompiler/version.rb
61
+ - lib/jscompiler.rb
62
+ - lib/templates/jscompiler.yml.erb
63
+ - vendor/clojure/compiler.jar
64
+ - vendor/clojure/COPYING
65
+ - vendor/clojure/README
66
+ - LICENSE
67
+ - README.rdoc
68
+ homepage: https://github.com/berk/jscompiler
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - - lib
74
+ - lib/jscompiler
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.23
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: JavaScript Compiler (JSC)
93
+ test_files: []