cyborg 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/bin/cyborg +4 -17
- data/lib/cyborg/command.rb +21 -1
- data/lib/cyborg/command/help.rb +5 -0
- data/lib/cyborg/plugin.rb +6 -0
- data/lib/cyborg/plugin/assets/javascripts.rb +31 -6
- data/lib/cyborg/plugin/assets/stylesheets.rb +1 -1
- data/lib/cyborg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d2f44ea7c9403815f3e2e5e02ba3804bdf1e4e1
|
4
|
+
data.tar.gz: 9d74c36a6640a2410c1365040a0b43dd1d873cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a43f7b67340a52f143d2cd8bfe03391465faf139d449913d14082b05cdb6cb76f0006dcd935ba8a760619708e7572139b8ed7ef22222463489ea8770b06d953c
|
7
|
+
data.tar.gz: 01af22afd859ca34cff2e6c9637555ae56431a09794bb1176805f8bbb35165d5d22fea38944139fcdbc67673154b55ab381840da1b1f749bb8b1f0f0b5189d9e
|
data/bin/cyborg
CHANGED
@@ -62,6 +62,9 @@ OptionParser.new do |opts|
|
|
62
62
|
opts.on("-p", "--production", "Build assets as with production mode.") do |val|
|
63
63
|
options[:production] = true
|
64
64
|
end
|
65
|
+
opts.on("-C", "--clean", "Remove cache files before build.") do |val|
|
66
|
+
options[:clean] = true
|
67
|
+
end
|
65
68
|
end
|
66
69
|
|
67
70
|
opts.on("-v", "--version", "Print version") do |version|
|
@@ -78,20 +81,4 @@ OptionParser.new do |opts|
|
|
78
81
|
end
|
79
82
|
end.parse!
|
80
83
|
|
81
|
-
|
82
|
-
puts "Cyborg version #{Cyborg::VERSION}"
|
83
|
-
elsif options[:help]
|
84
|
-
|
85
|
-
if options[:help]
|
86
|
-
puts "Cyborg version #{Cyborg::VERSION}\n\n"
|
87
|
-
puts options[:help]
|
88
|
-
|
89
|
-
# Use this if commands get long
|
90
|
-
#IO.popen("less", "w") do |f|
|
91
|
-
#f.puts "Cyborg version #{Cyborg::VERSION}"
|
92
|
-
#f.puts options[:help]
|
93
|
-
#end
|
94
|
-
end
|
95
|
-
else
|
96
|
-
Cyborg::Command.run(options)
|
97
|
-
end
|
84
|
+
Cyborg::Command.run(options)
|
data/lib/cyborg/command.rb
CHANGED
@@ -18,6 +18,13 @@ module Cyborg
|
|
18
18
|
from_root { dispatch(:watch, options) }
|
19
19
|
when 'server', 's'
|
20
20
|
from_root { dispatch(:server, options) }
|
21
|
+
when 'clean', 'c'
|
22
|
+
from_root { clean }
|
23
|
+
when 'help', 'h'
|
24
|
+
version
|
25
|
+
puts options[:help]
|
26
|
+
when 'version'
|
27
|
+
version
|
21
28
|
when 'gem:build'
|
22
29
|
from_root { gem_build }
|
23
30
|
when 'gem:install'
|
@@ -27,6 +34,10 @@ module Cyborg
|
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
37
|
+
def version
|
38
|
+
puts "Cyborg version #{Cyborg::VERSION}\n\n"
|
39
|
+
end
|
40
|
+
|
30
41
|
def production?
|
31
42
|
@production == true
|
32
43
|
end
|
@@ -46,6 +57,15 @@ module Cyborg
|
|
46
57
|
system "bundle exec rake release"
|
47
58
|
end
|
48
59
|
|
60
|
+
def require_rails
|
61
|
+
require File.join(Dir.pwd, Cyborg.rails_path('config/application'))
|
62
|
+
end
|
63
|
+
|
64
|
+
def clean
|
65
|
+
require_rails
|
66
|
+
Cyborg.plugin.clean
|
67
|
+
end
|
68
|
+
|
49
69
|
# Handles running threaded commands
|
50
70
|
#
|
51
71
|
def dispatch(command, *args)
|
@@ -57,7 +77,7 @@ module Cyborg
|
|
57
77
|
# Build assets
|
58
78
|
def build(options={})
|
59
79
|
puts Cyborg.production? ? 'Building for production…' : 'Building…'
|
60
|
-
|
80
|
+
require_rails
|
61
81
|
@threads.concat Cyborg.plugin.build(options)
|
62
82
|
end
|
63
83
|
|
data/lib/cyborg/command/help.rb
CHANGED
@@ -27,6 +27,7 @@ Options:
|
|
27
27
|
when 'build', 'b'; build
|
28
28
|
when 'watch', 'w'; watch
|
29
29
|
when 'server', 's'; server
|
30
|
+
when 'clean', 'c'; clean
|
30
31
|
when 'help', 'h'; help
|
31
32
|
when 'gem:build'; gem_build
|
32
33
|
when 'gem:install'; gem_install
|
@@ -50,6 +51,10 @@ Options:
|
|
50
51
|
"server [options] # Serve documentation site"
|
51
52
|
end
|
52
53
|
|
54
|
+
def clean
|
55
|
+
"clean # Remove cache files"
|
56
|
+
end
|
57
|
+
|
53
58
|
def help
|
54
59
|
"help [command] # Show help for a specific command"
|
55
60
|
end
|
data/lib/cyborg/plugin.rb
CHANGED
@@ -92,6 +92,12 @@ module Cyborg
|
|
92
92
|
assets(options).map(&:watch)
|
93
93
|
end
|
94
94
|
|
95
|
+
def clean
|
96
|
+
FileUtils.rm_rf(Cyborg.rails_path('tmp/cache/'))
|
97
|
+
FileUtils.rm_rf('.sass-cache')
|
98
|
+
FileUtils.rm_rf(Cyborg.rails_path('.sass-cache'))
|
99
|
+
end
|
100
|
+
|
95
101
|
def config(options)
|
96
102
|
options = {
|
97
103
|
production_asset_root: "/assets/#{name}",
|
@@ -9,20 +9,45 @@ module Cyborg
|
|
9
9
|
javascript_include_tag(args)
|
10
10
|
end
|
11
11
|
|
12
|
+
def cache_file(name=nil)
|
13
|
+
Cyborg.rails_path("tmp/cache/assets/.browserify-cache-#{name}.json")
|
14
|
+
end
|
15
|
+
|
12
16
|
def build
|
17
|
+
files = find_files
|
18
|
+
FileUtils.mkdir_p(File.dirname(cache_file)) if !files.empty?
|
19
|
+
|
13
20
|
if Open3.capture3("npm ls browserify-incremental")[1].empty?
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
21
|
+
files.each do |file|
|
22
|
+
system build_command(file)
|
23
|
+
|
24
|
+
if Cyborg.production?
|
25
|
+
compress(destination(file))
|
26
|
+
end
|
27
|
+
|
20
28
|
puts build_msg(file)
|
21
29
|
end
|
22
30
|
else
|
23
31
|
abort "JS BUILD FAILED: browserifyinc NPM module not found.\n" << "Please add browserifyinc to your package.json and run `npm install`"
|
24
32
|
end
|
25
33
|
end
|
34
|
+
|
35
|
+
def build_command(file)
|
36
|
+
dest = destination(file).sub(/\.js$/,'')
|
37
|
+
options = " -t babelify --standalone #{plugin.name} -o #{dest}.js -d"
|
38
|
+
|
39
|
+
cmd = if Cyborg.production?
|
40
|
+
"browserify #{file} #{options}"
|
41
|
+
else
|
42
|
+
"browserifyinc --cachefile #{cache_file(File.basename(dest))} #{file} #{options}"
|
43
|
+
end
|
44
|
+
|
45
|
+
if Cyborg.production? || plugin.maps?
|
46
|
+
cmd += " -p [ minifyify --map #{url(file).sub(/\.js$/,'')}.map.json --output #{dest}.map.json ]"
|
47
|
+
end
|
48
|
+
|
49
|
+
cmd
|
50
|
+
end
|
26
51
|
end
|
27
52
|
end
|
28
53
|
end
|
data/lib/cyborg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyborg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|