jscompiler 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,29 @@ This CLI utility simplifies the process of compiling your JS files by letting yo
7
7
  $ jsc compile
8
8
 
9
9
 
10
+ = Supported Compilers
11
+
12
+
13
+ === Google Closure
14
+
15
+ https://developers.google.com/closure/
16
+
17
+ The Closure Compiler compiles JavaScript into compact, high-performance code. The compiler removes dead code and rewrites and minimizes what's left so that it downloads and runs quickly. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls. These checks and optimizations help you write apps that are less buggy and easier to maintain.
18
+
19
+ === YUI Compressor
20
+
21
+ http://yui.github.io/yuicompressor/
22
+
23
+ The YUI Compressor is written in Java (requires Java >= 1.4) and relies on Rhino to tokenize the source JavaScript file. It starts by analyzing the source JavaScript file to understand how it is structured. It then prints out the token stream, omitting as many white space characters as possible, and replacing all local symbols by a 1 (or 2, or 3) letter symbol wherever such a substitution is appropriate (in the face of evil features such as eval or with, the YUI Compressor takes a defensive approach by not obfuscating any of the scopes containing the evil statement).
24
+
25
+ === Uglifier
26
+
27
+ https://github.com/lautis/uglifier
28
+
29
+ Ruby wrapper for UglifyJS JavaScript compressor.
30
+
31
+
32
+
10
33
  = Installation
11
34
 
12
35
  gem install jscompiler
@@ -20,27 +43,25 @@ To setup your project with some default parameters, run the following command:
20
43
 
21
44
  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
45
 
23
- source_root: "src" # Relative path from the project root to Where your JavaScript files are located
46
+ source_root: "src" # Relative path from the project root to Where your JavaScript files are located
24
47
  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
48
+ name: "closure" # Name of the compiler to use. By default "closure" compiler will be used
49
+ groups: # Groups of files you wish to compile
27
50
  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
51
+ files: # List of the JS files in the order they will be compiled
52
+ - src/file1.js
53
+ - src/file2.js
54
+ - src/file3.js
32
55
  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
56
+ path: "build/default.min.js" # Relative path to where the output files should be created
36
57
  just1and3:
37
- files: # List of the JS files in the order they will be compiled
38
- src/file1.js
39
- src/file3.js
58
+ compiler: # You can even specify different compilers for different groups
59
+ name: "yahoo"
60
+ files:
61
+ - src/file1.js
62
+ - src/file3.js
40
63
  output:
41
- name: "just1and3"
42
- debug: true
43
- path: "build"
64
+ path: "build/just1and3.min.js"
44
65
 
45
66
 
46
67
  You can configure any number of groups. The files in the groups will be concatenated and compiled in the order you entered them in.
data/bin/jsc CHANGED
@@ -29,8 +29,9 @@ 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/closure.rb',
33
33
  'commands/yahoo.rb',
34
+ 'commands/uglifier.rb',
34
35
  ].each do |f|
35
36
  require File.expand_path(File.join(File.dirname(__FILE__), "../lib/jscompiler/#{f}"))
36
37
  end
@@ -25,6 +25,6 @@ module Jscompiler
25
25
  autoload :Cli, 'jscompiler/cli'
26
26
  autoload :Config, 'jscompiler/config'
27
27
  autoload :Base, 'jscompiler/commands/base'
28
- autoload :Clojure, 'jscompiler/commands/clojure'
28
+ autoload :Closure, 'jscompiler/commands/closure'
29
29
  autoload :Yahoo, 'jscompiler/commands/yahoo'
30
30
  end
@@ -146,7 +146,7 @@ module Jscompiler
146
146
 
147
147
  def ask_for_compiler(opts = {})
148
148
  say("Which compiler would you like to use?")
149
- compilers = ["clojure", "yahoo"]
149
+ compilers = ["closure", "yahoo", "uglifier"]
150
150
  if opts[:default]
151
151
  compilers.unshift("default")
152
152
  end
@@ -24,10 +24,10 @@
24
24
  module Jscompiler
25
25
  module Commands
26
26
 
27
- class Clojure < Base
27
+ class Closure < Base
28
28
 
29
29
  def compiler_path
30
- File.expand_path(File.join(File.dirname(__FILE__), "../../../vendor/clojure/compiler.jar"))
30
+ File.expand_path(File.join(File.dirname(__FILE__), "../../../vendor/closure/compiler.jar"))
31
31
  end
32
32
 
33
33
  def args
@@ -0,0 +1,44 @@
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 'uglifier'
25
+
26
+ module Jscompiler
27
+ module Commands
28
+
29
+ class Uglifier < Base
30
+
31
+ def run
32
+ generate_temp_file
33
+
34
+ File.open(output_file_path, 'w') do |file|
35
+ file.write(::Uglifier.compile(File.read(temp_file_path)))
36
+ end
37
+
38
+ save_or_delete_temp_file
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+ end
@@ -64,10 +64,12 @@ module Jscompiler
64
64
  cmplr = opts[:compiler] || compiler(group)["name"]
65
65
 
66
66
  case cmplr
67
- when 'clojure'
68
- Jscompiler::Commands::Clojure
67
+ when 'closure'
68
+ Jscompiler::Commands::Closure
69
69
  when 'yahoo'
70
70
  Jscompiler::Commands::Yahoo
71
+ when 'uglifier'
72
+ Jscompiler::Commands::Uglifier
71
73
  else
72
74
  raise("Unsupported compiler")
73
75
  end
@@ -22,7 +22,7 @@
22
22
  #++
23
23
 
24
24
  module Jscompiler
25
- VERSION = "0.2.1"
25
+ VERSION = "0.2.2"
26
26
  end
27
27
 
28
28
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  source_root: <%=@root%> # Relative path from the project root to Where your JavaScript files are located
3
3
  compiler:
4
- name: <%=@compiler%> # Name of the compiler to use. By default "clojure" compiler will be used
4
+ name: <%=@compiler%> # Name of the compiler to use. By default "closure" compiler will be used
5
5
  warning_level: QUIET
6
6
  groups: # Groups of files you wish to compile
7
7
  default:
File without changes
File without changes
File without changes
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.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.16.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.7.7
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: 1.7.7
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: fssm
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -43,6 +59,22 @@ dependencies:
43
59
  - - ! '>='
44
60
  - !ruby/object:Gem::Version
45
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: uglifier
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
46
78
  description: Utility that allows you to use various JS compilers to compress and uglify
47
79
  your JavaScript code.
48
80
  email:
@@ -55,15 +87,16 @@ files:
55
87
  - bin/jsc
56
88
  - lib/jscompiler/cli.rb
57
89
  - lib/jscompiler/commands/base.rb
58
- - lib/jscompiler/commands/clojure.rb
90
+ - lib/jscompiler/commands/closure.rb
91
+ - lib/jscompiler/commands/uglifier.rb
59
92
  - lib/jscompiler/commands/yahoo.rb
60
93
  - lib/jscompiler/config.rb
61
94
  - lib/jscompiler/version.rb
62
95
  - lib/jscompiler.rb
63
96
  - lib/templates/jscompiler.yml.erb
64
- - vendor/clojure/compiler.jar
65
- - vendor/clojure/COPYING
66
- - vendor/clojure/README
97
+ - vendor/closure/compiler.jar
98
+ - vendor/closure/COPYING
99
+ - vendor/closure/README
67
100
  - vendor/yahoo/LICENSE
68
101
  - vendor/yahoo/README
69
102
  - vendor/yahoo/yuicompressor-2.4.2.jar