bpm 1.0.0.beta.8 → 1.0.0.beta.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG.md +9 -0
- data/bpm.gemspec +2 -7
- data/lib/bpm/pipeline/generated_asset.rb +19 -21
- data/lib/bpm/pipeline/plugin_context.rb +7 -7
- data/lib/bpm/pipeline/plugin_processor.rb +11 -20
- data/lib/bpm/pipeline/transport_processor.rb +8 -13
- data/lib/bpm/pipeline.rb +47 -42
- data/lib/bpm/project_generator.rb +2 -2
- data/lib/bpm/version.rb +1 -1
- data/lib/bpm.rb +0 -3
- data/spec/cli/init_spec.rb +48 -48
- data/spec/cli/rebuild_spec.rb +30 -30
- data/spec/fixtures/projects/init_app/assets/bpm_libs.js +1 -1
- data/spec/fixtures/projects/init_app/assets/bpm_styles.css +1 -1
- data/spec/fixtures/projects/init_default/assets/bpm_libs.js +1 -1
- data/spec/fixtures/projects/init_default/assets/bpm_styles.css +1 -1
- data/spec/plugins/minifier_spec.rb +8 -8
- data/templates/project/index.html +0 -2
- data/templates/project/{app → lib}/main.js +0 -0
- metadata +24 -209
- data/.gitmodules +0 -3
- data/vendor/sprockets/.gitignore +0 -7
- data/vendor/sprockets/.travis.yml +0 -7
- data/vendor/sprockets/Gemfile +0 -2
- data/vendor/sprockets/LICENSE +0 -20
- data/vendor/sprockets/README.md +0 -22
- data/vendor/sprockets/Rakefile +0 -8
- data/vendor/sprockets/lib/sprockets/asset.rb +0 -198
- data/vendor/sprockets/lib/sprockets/asset_attributes.rb +0 -178
- data/vendor/sprockets/lib/sprockets/base.rb +0 -134
- data/vendor/sprockets/lib/sprockets/bundled_asset.rb +0 -249
- data/vendor/sprockets/lib/sprockets/cache/file_store.rb +0 -41
- data/vendor/sprockets/lib/sprockets/caching.rb +0 -126
- data/vendor/sprockets/lib/sprockets/charset_normalizer.rb +0 -41
- data/vendor/sprockets/lib/sprockets/context.rb +0 -221
- data/vendor/sprockets/lib/sprockets/digest.rb +0 -73
- data/vendor/sprockets/lib/sprockets/directive_processor.rb +0 -397
- data/vendor/sprockets/lib/sprockets/eco_template.rb +0 -38
- data/vendor/sprockets/lib/sprockets/ejs_template.rb +0 -37
- data/vendor/sprockets/lib/sprockets/engines.rb +0 -117
- data/vendor/sprockets/lib/sprockets/environment.rb +0 -94
- data/vendor/sprockets/lib/sprockets/errors.rb +0 -17
- data/vendor/sprockets/lib/sprockets/index.rb +0 -81
- data/vendor/sprockets/lib/sprockets/jst_processor.rb +0 -26
- data/vendor/sprockets/lib/sprockets/mime.rb +0 -38
- data/vendor/sprockets/lib/sprockets/processing.rb +0 -269
- data/vendor/sprockets/lib/sprockets/processor.rb +0 -32
- data/vendor/sprockets/lib/sprockets/safety_colons.rb +0 -28
- data/vendor/sprockets/lib/sprockets/server.rb +0 -270
- data/vendor/sprockets/lib/sprockets/static_asset.rb +0 -86
- data/vendor/sprockets/lib/sprockets/static_compilation.rb +0 -74
- data/vendor/sprockets/lib/sprockets/trail.rb +0 -123
- data/vendor/sprockets/lib/sprockets/utils.rb +0 -67
- data/vendor/sprockets/lib/sprockets/version.rb +0 -3
- data/vendor/sprockets/lib/sprockets.rb +0 -31
- data/vendor/sprockets/sprockets.gemspec +0 -30
- data/vendor/sprockets/test/fixtures/asset/POW.png +0 -0
- data/vendor/sprockets/test/fixtures/asset/application.js +0 -6
- data/vendor/sprockets/test/fixtures/asset/bar-utf8.css +0 -2
- data/vendor/sprockets/test/fixtures/asset/charset.css +0 -2
- data/vendor/sprockets/test/fixtures/asset/circle/a.js +0 -2
- data/vendor/sprockets/test/fixtures/asset/circle/b.js +0 -2
- data/vendor/sprockets/test/fixtures/asset/circle/c.js +0 -2
- data/vendor/sprockets/test/fixtures/asset/compat.js +0 -4
- data/vendor/sprockets/test/fixtures/asset/constants.js +0 -2
- data/vendor/sprockets/test/fixtures/asset/constants.yml +0 -1
- data/vendor/sprockets/test/fixtures/asset/default_mime_type.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/filename.js.erb +0 -1
- data/vendor/sprockets/test/fixtures/asset/foo-utf8.css +0 -2
- data/vendor/sprockets/test/fixtures/asset/included_header.js +0 -4
- data/vendor/sprockets/test/fixtures/asset/jquery.tmpl.min.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/mismatch.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/multiple.js +0 -2
- data/vendor/sprockets/test/fixtures/asset/multipleengine.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/noengine.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/noformat.coffee +0 -1
- data/vendor/sprockets/test/fixtures/asset/one.css +0 -1
- data/vendor/sprockets/test/fixtures/asset/oneengine.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/project.css +0 -1
- data/vendor/sprockets/test/fixtures/asset/project.js.erb +0 -4
- data/vendor/sprockets/test/fixtures/asset/relative/include.js +0 -4
- data/vendor/sprockets/test/fixtures/asset/relative/require.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/relative/require_outside_path.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/require_self.css +0 -9
- data/vendor/sprockets/test/fixtures/asset/require_self_twice.css +0 -8
- data/vendor/sprockets/test/fixtures/asset/semicolons/bar.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/semicolons/index.js +0 -5
- data/vendor/sprockets/test/fixtures/asset/sprite.css.erb +0 -12
- data/vendor/sprockets/test/fixtures/asset/tree/all/b/c/d.js +0 -2
- data/vendor/sprockets/test/fixtures/asset/tree/all/b/c/e.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/all/b/c.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/all/b.css +0 -2
- data/vendor/sprockets/test/fixtures/asset/tree/all/b.js.erb +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/all/d/c.js.coffee +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/all/d/e.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/all_with_require.js +0 -7
- data/vendor/sprockets/test/fixtures/asset/tree/all_with_require_directory.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/all_with_require_tree.js +0 -2
- data/vendor/sprockets/test/fixtures/asset/tree/directory/application.js +0 -2
- data/vendor/sprockets/test/fixtures/asset/tree/directory/bar.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/directory/foo.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/tree/application.js +0 -2
- data/vendor/sprockets/test/fixtures/asset/tree/tree/bar.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/tree/foo.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/with_logical_path/a/a.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/with_logical_path/require_tree_with_logical_path.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/without_argument/a.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/without_argument/b.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/tree/without_argument/require_tree_without_argument.js +0 -1
- data/vendor/sprockets/test/fixtures/asset/two.css +0 -1
- data/vendor/sprockets/test/fixtures/asset/unicode.js +0 -2
- data/vendor/sprockets/test/fixtures/asset/unknownexts.min.js +0 -2
- data/vendor/sprockets/test/fixtures/asset/users.js.erb.str +0 -4
- data/vendor/sprockets/test/fixtures/context/POW.png +0 -0
- data/vendor/sprockets/test/fixtures/context/application.js.yml +0 -3
- data/vendor/sprockets/test/fixtures/context/bar.js +0 -1
- data/vendor/sprockets/test/fixtures/context/foo.js +0 -2
- data/vendor/sprockets/test/fixtures/context/helpers.css.erb +0 -3
- data/vendor/sprockets/test/fixtures/context/properties.js.erb +0 -7
- data/vendor/sprockets/test/fixtures/context/require_glob.js +0 -1
- data/vendor/sprockets/test/fixtures/context/resolve_content_type.js.erb +0 -4
- data/vendor/sprockets/test/fixtures/context/sprite.css.embed +0 -3
- data/vendor/sprockets/test/fixtures/default/application.js.coffee +0 -4
- data/vendor/sprockets/test/fixtures/default/blank.gif +0 -0
- data/vendor/sprockets/test/fixtures/default/coffee/foo.coffee +0 -1
- data/vendor/sprockets/test/fixtures/default/coffee/index.js +0 -3
- data/vendor/sprockets/test/fixtures/default/empty +0 -0
- data/vendor/sprockets/test/fixtures/default/gallery.css.erb +0 -3
- data/vendor/sprockets/test/fixtures/default/gallery.js +0 -1
- data/vendor/sprockets/test/fixtures/default/goodbye.jst.eco +0 -1
- data/vendor/sprockets/test/fixtures/default/hello.jst.ejs +0 -1
- data/vendor/sprockets/test/fixtures/default/hello.txt +0 -1
- data/vendor/sprockets/test/fixtures/default/interpolation.js +0 -1
- data/vendor/sprockets/test/fixtures/default/missing_require.js +0 -1
- data/vendor/sprockets/test/fixtures/default/mobile/a.js +0 -1
- data/vendor/sprockets/test/fixtures/default/mobile/b.js +0 -1
- data/vendor/sprockets/test/fixtures/default/mobile/c.css +0 -1
- data/vendor/sprockets/test/fixtures/default/mobile/d.css +0 -1
- data/vendor/sprockets/test/fixtures/default/mobile/index.css +0 -3
- data/vendor/sprockets/test/fixtures/default/mobile/index.js +0 -1
- data/vendor/sprockets/test/fixtures/default/noreturn.js +0 -1
- data/vendor/sprockets/test/fixtures/default/project.js.coffee.erb +0 -2
- data/vendor/sprockets/test/fixtures/default/with_data_uri.css.erb +0 -3
- data/vendor/sprockets/test/fixtures/directives/code_before_comment +0 -3
- data/vendor/sprockets/test/fixtures/directives/comment_without_directives +0 -6
- data/vendor/sprockets/test/fixtures/directives/directive_word_splitting +0 -6
- data/vendor/sprockets/test/fixtures/directives/directives_after_header +0 -16
- data/vendor/sprockets/test/fixtures/directives/double_slash +0 -9
- data/vendor/sprockets/test/fixtures/directives/hash +0 -8
- data/vendor/sprockets/test/fixtures/directives/no_header +0 -2
- data/vendor/sprockets/test/fixtures/directives/slash_star +0 -10
- data/vendor/sprockets/test/fixtures/directives/slash_star_single +0 -4
- data/vendor/sprockets/test/fixtures/directives/space_between_directive_word +0 -2
- data/vendor/sprockets/test/fixtures/directives/triple_hash +0 -10
- data/vendor/sprockets/test/fixtures/encoding/ascii.js +0 -1
- data/vendor/sprockets/test/fixtures/encoding/ascii_utf8.js +0 -2
- data/vendor/sprockets/test/fixtures/encoding/utf16.js +0 -0
- data/vendor/sprockets/test/fixtures/encoding/utf8.js +0 -1
- data/vendor/sprockets/test/fixtures/encoding/utf8_bom.js +0 -1
- data/vendor/sprockets/test/fixtures/engines/hello.alert +0 -1
- data/vendor/sprockets/test/fixtures/engines/moo.js.str +0 -1
- data/vendor/sprockets/test/fixtures/public/compiled-digest-0aa2105d29558f3eb790d411d7d8fb66.js +0 -3
- data/vendor/sprockets/test/fixtures/public/compiled-digest-1c41eb0cf934a0c76babe875f982f9d1.js +0 -1
- data/vendor/sprockets/test/fixtures/server/app/javascripts/application.js +0 -5
- data/vendor/sprockets/test/fixtures/server/app/javascripts/bar.js +0 -1
- data/vendor/sprockets/test/fixtures/server/app/javascripts/foo.js +0 -1
- data/vendor/sprockets/test/fixtures/server/app/javascripts/hello.txt +0 -2
- data/vendor/sprockets/test/fixtures/server/app/javascripts/tree.js +0 -1
- data/vendor/sprockets/test/fixtures/server/vendor/javascripts/missing_require.js +0 -1
- data/vendor/sprockets/test/fixtures/server/vendor/stylesheets/missing_require.css +0 -1
- data/vendor/sprockets/test/sprockets_test.rb +0 -56
- data/vendor/sprockets/test/test_asset.rb +0 -699
- data/vendor/sprockets/test/test_asset_attributes.rb +0 -150
- data/vendor/sprockets/test/test_caching.rb +0 -62
- data/vendor/sprockets/test/test_context.rb +0 -115
- data/vendor/sprockets/test/test_directive_processor.rb +0 -124
- data/vendor/sprockets/test/test_encoding.rb +0 -65
- data/vendor/sprockets/test/test_engines.rb +0 -73
- data/vendor/sprockets/test/test_environment.rb +0 -587
- data/vendor/sprockets/test/test_server.rb +0 -227
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
|
2
|
+
# 1.0.0.beta.9
|
3
|
+
|
4
|
+
* Fixed bug with init where it would generate broken apps at first.
|
5
|
+
* Fixed bug when exceptions are thrown in preview mode that would force you
|
6
|
+
to restart the server. Should recover more smoothly now.
|
7
|
+
* Other minor bug fixes.
|
8
|
+
|
9
|
+
# 1.0.0.beta.8
|
10
|
+
|
2
11
|
* First cut at support for formats.
|
3
12
|
* Also introduces new requirement for defining transport and format plugins
|
4
13
|
in the package.json. Now you must use the "bpm:provides" keyword:
|
data/bpm.gemspec
CHANGED
@@ -21,13 +21,8 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_dependency "highline", "~> 1.6.1"
|
22
22
|
s.add_dependency "json_pure", "~> 1.4.6"
|
23
23
|
s.add_dependency "thor", "~> 0.14.3"
|
24
|
-
s.add_dependency "therubyracer", "~> 0.9.
|
25
|
-
|
26
|
-
# Begin Sprockets Deps
|
27
|
-
s.add_dependency "hike", "~> 1.1"
|
28
|
-
s.add_dependency "rack", "~> 1.0"
|
29
|
-
s.add_dependency "tilt", ["~> 1.1", "!= 1.3.0"]
|
30
|
-
# End Sprockets Deps
|
24
|
+
s.add_dependency "therubyracer", "~> 0.9.3beta1"
|
25
|
+
s.add_dependency "sprockets", "~> 2.0.0.beta.12"
|
31
26
|
|
32
27
|
s.add_development_dependency "rspec"
|
33
28
|
s.add_development_dependency "rack", "~> 1.2.1"
|
@@ -1,34 +1,34 @@
|
|
1
1
|
require 'sprockets'
|
2
2
|
|
3
3
|
module BPM
|
4
|
-
|
4
|
+
|
5
5
|
class GeneratedAsset < Sprockets::BundledAsset
|
6
6
|
|
7
7
|
FORMAT_METHODS = {
|
8
8
|
'text/css' => ['css', 'pipeline_css'],
|
9
9
|
'application/javascript' => ['lib', 'pipeline_libs']
|
10
10
|
}
|
11
|
-
|
11
|
+
|
12
12
|
def self.generating_asset
|
13
13
|
@generating_asset && @generating_asset.last
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def self.push_generating_asset(asset)
|
17
17
|
@generating_asset ||= []
|
18
18
|
@generating_asset.push asset
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def self.pop_generating_asset
|
22
22
|
@generating_asset && @generating_asset.pop
|
23
23
|
end
|
24
24
|
|
25
25
|
def build_settings
|
26
|
-
ret = environment.project.build_settings[asset_name]
|
26
|
+
ret = environment.project.build_settings[asset_name]
|
27
27
|
(ret && ret['bpm:settings']) || {}
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def minify_body(data)
|
31
|
-
|
31
|
+
|
32
32
|
project = environment.project
|
33
33
|
minifier_name = project.minifier_name asset_name
|
34
34
|
minifier_name = minifier_name.keys.first if minifier_name
|
@@ -46,7 +46,7 @@ module BPM
|
|
46
46
|
|
47
47
|
plugin_ctx = environment.plugin_context_for minifier_plugin_name
|
48
48
|
|
49
|
-
# slice out the header at the top - we don't want the minifier to
|
49
|
+
# slice out the header at the top - we don't want the minifier to
|
50
50
|
# touch it.
|
51
51
|
header = data.match /^(\/\* ====.+====\*\/)$/m
|
52
52
|
if header
|
@@ -54,11 +54,9 @@ module BPM
|
|
54
54
|
data = data[header.size..-1]
|
55
55
|
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
data = plugin_ctx.eval("BPM_PLUGIN.minify(DATA, CTX)")
|
61
|
-
end
|
57
|
+
plugin_ctx["CTX"] = BPM::PluginContext.new(pkg)
|
58
|
+
plugin_ctx["DATA"] = data
|
59
|
+
data = plugin_ctx.eval("BPM_PLUGIN.minify(DATA, CTX)")
|
62
60
|
|
63
61
|
data = header+data if header
|
64
62
|
end
|
@@ -82,7 +80,7 @@ module BPM
|
|
82
80
|
|
83
81
|
def minify(hash)
|
84
82
|
return hash if environment.mode == :debug
|
85
|
-
|
83
|
+
|
86
84
|
hash = environment.cache_hash("#{pathname}:minify", id) do
|
87
85
|
data = minify_body hash['source']
|
88
86
|
{ 'length' => Rack::Utils.bytesize(data),
|
@@ -98,7 +96,7 @@ module BPM
|
|
98
96
|
|
99
97
|
hash
|
100
98
|
end
|
101
|
-
|
99
|
+
|
102
100
|
def asset_name
|
103
101
|
project = environment.project
|
104
102
|
if pathname.to_s.include?(project.assets_root)
|
@@ -107,23 +105,23 @@ module BPM
|
|
107
105
|
pathname.relative_path_from(Pathname.new(project.preview_root)).to_s
|
108
106
|
end
|
109
107
|
end
|
110
|
-
|
108
|
+
|
111
109
|
def build_dependency_context_and_body
|
112
110
|
|
113
111
|
project = environment.project
|
114
112
|
settings = project.build_settings(environment.mode)[asset_name]
|
115
|
-
pkgs = settings.keys.map do |pkg_name|
|
113
|
+
pkgs = settings.keys.map do |pkg_name|
|
116
114
|
next if pkg_name == 'bpm:minifier'
|
117
115
|
if pkg_name == project.name
|
118
116
|
project
|
119
117
|
else
|
120
|
-
project.local_deps.find { |dep| dep.name == pkg_name }
|
118
|
+
project.local_deps.find { |dep| dep.name == pkg_name }
|
121
119
|
end
|
122
120
|
end.compact
|
123
121
|
|
124
122
|
if pkgs.size > 0
|
125
|
-
manifest = pkgs.sort { |a,b| a.name <=> b.name }
|
126
|
-
manifest = manifest.map do |x|
|
123
|
+
manifest = pkgs.sort { |a,b| a.name <=> b.name }
|
124
|
+
manifest = manifest.map do |x|
|
127
125
|
"#{x.name} (#{x.version})"
|
128
126
|
end.join " "
|
129
127
|
else
|
@@ -135,7 +133,7 @@ module BPM
|
|
135
133
|
/* ===========================================================================
|
136
134
|
BPM Combined Asset File
|
137
135
|
MANIFEST: #{manifest}
|
138
|
-
This file is generated automatically by the bpm (http://www.bpmjs.org)
|
136
|
+
This file is generated automatically by the bpm (http://www.bpmjs.org)
|
139
137
|
=========================================================================*/
|
140
138
|
|
141
139
|
EOF
|
@@ -1,16 +1,16 @@
|
|
1
1
|
module BPM
|
2
|
-
|
3
|
-
class PluginContext
|
4
|
-
|
2
|
+
|
3
|
+
class PluginContext
|
4
|
+
|
5
5
|
attr_reader :moduleId
|
6
6
|
attr_reader :package
|
7
|
-
|
7
|
+
|
8
8
|
def initialize(pkg, module_id=nil)
|
9
9
|
@generating_asset = BPM::GeneratedAsset.generating_asset
|
10
10
|
@package = pkg.as_json
|
11
11
|
@moduleId = module_id
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def minify(body)
|
15
15
|
@generating_asset ? @generating_asset.minify_body(body) : body
|
16
16
|
end
|
@@ -18,7 +18,7 @@ module BPM
|
|
18
18
|
def settings
|
19
19
|
@generating_asset ? @generating_asset.build_settings : {}
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
end
|
@@ -2,11 +2,11 @@ require 'sprockets'
|
|
2
2
|
|
3
3
|
module BPM
|
4
4
|
|
5
|
-
# A processor that will invoke a JavaScript-based plugin provided by a
|
6
|
-
# package in the system. The passed method name will be invoked on the
|
5
|
+
# A processor that will invoke a JavaScript-based plugin provided by a
|
6
|
+
# package in the system. The passed method name will be invoked on the
|
7
7
|
# plugin.
|
8
8
|
class PluginProcessor < Tilt::Template
|
9
|
-
|
9
|
+
|
10
10
|
def self.with_plugin(plugin_opts, method_name)
|
11
11
|
ret = Class.new(self)
|
12
12
|
ret.instance_eval do
|
@@ -19,34 +19,25 @@ module BPM
|
|
19
19
|
def self.method_name
|
20
20
|
@method_name
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def self.plugin_name
|
24
24
|
@plugin_opts["main"]
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def prepare
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def evaluate(context, locals, &block)
|
31
31
|
ctx = context.environment.plugin_context_for self.class.plugin_name
|
32
32
|
project = context.environment.project
|
33
33
|
pkg, module_id = project.package_and_module_from_path file
|
34
|
-
|
35
|
-
filepath = file.to_s
|
36
|
-
out = ''
|
37
34
|
|
38
|
-
|
39
|
-
ctx["DATA"] = data
|
40
|
-
ctx["CTX"] = BPM::PluginContext.new(pkg, module_id)
|
41
|
-
out = ctx.eval("BPM_PLUGIN.#{self.class.method_name}(DATA, CTX, '#{filepath}');")
|
42
|
-
end
|
35
|
+
filepath = file.to_s
|
43
36
|
|
44
|
-
|
37
|
+
ctx["DATA"] = data
|
38
|
+
ctx["CTX"] = BPM::PluginContext.new(pkg, module_id)
|
39
|
+
ctx.eval("BPM_PLUGIN.#{self.class.method_name}(DATA, CTX, '#{filepath}');")
|
45
40
|
end
|
46
|
-
|
41
|
+
|
47
42
|
end
|
48
43
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'sprockets'
|
2
2
|
|
3
3
|
module BPM
|
4
|
-
|
4
|
+
|
5
5
|
class TransportProcessor < Sprockets::Processor
|
6
|
-
|
6
|
+
|
7
7
|
def evaluate(context, locals)
|
8
8
|
environment = context.environment
|
9
9
|
project = environment.project
|
10
10
|
pkg, module_id = project.package_and_module_from_path file
|
11
11
|
transport_plugins = Array(pkg.bpm_use_transport || pkg.find_transport_plugins(project))
|
12
|
-
|
12
|
+
|
13
13
|
transport_plugins = [] if transport_plugins.first == 'none'
|
14
14
|
|
15
15
|
# No transport, just return the existing data
|
@@ -20,20 +20,15 @@ module BPM
|
|
20
20
|
raise "#{pkg.name} depends on #{transport_plugins.size} packages that define transport plugins. " \
|
21
21
|
"Select a plugin by adding a `bpm:use:transport` property to the package.json"
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
plugin_ctx = environment.plugin_context_for transport_plugins.first
|
25
25
|
filepath = file.to_s
|
26
|
-
out = ''
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
out = plugin_ctx.eval("BPM_PLUGIN.compileTransport(DATA, CTX, '#{filepath}');")
|
32
|
-
end
|
33
|
-
|
34
|
-
out + "\n\n"
|
27
|
+
plugin_ctx["DATA"] = data
|
28
|
+
plugin_ctx["CTX"] = BPM::PluginContext.new(pkg, module_id)
|
29
|
+
plugin_ctx.eval("BPM_PLUGIN.compileTransport(DATA, CTX, '#{filepath}');") + "\n\n"
|
35
30
|
end
|
36
|
-
|
31
|
+
|
37
32
|
end
|
38
33
|
|
39
34
|
end
|
data/lib/bpm/pipeline.rb
CHANGED
@@ -7,28 +7,28 @@ module BPM
|
|
7
7
|
def log(str)
|
8
8
|
shell.say str
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
private
|
12
|
-
|
12
|
+
|
13
13
|
def shell
|
14
14
|
@shell ||= Thor::Base.shell.new
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
# A BPM package-aware asset pipeline. Asset lookup respects package.json
|
20
20
|
# directory configurations as well as loading preprocessors, formats, and
|
21
21
|
# postprocessors from the package config.
|
22
22
|
#
|
23
23
|
class Pipeline < Sprockets::Environment
|
24
|
-
|
24
|
+
|
25
25
|
attr_reader :project
|
26
26
|
attr_reader :mode
|
27
27
|
attr_reader :package_pipelines
|
28
28
|
|
29
29
|
# Pass in the project you want the pipeline to manage.
|
30
30
|
def initialize(project, mode = :debug, include_preview = false)
|
31
|
-
|
31
|
+
|
32
32
|
@project = project
|
33
33
|
@mode = mode
|
34
34
|
@plugin_contexts = {}
|
@@ -38,12 +38,12 @@ module BPM
|
|
38
38
|
BPM::PackagePipeline.new self, pkg
|
39
39
|
end
|
40
40
|
@package_pipelines << BPM::PackagePipeline.new(self, project)
|
41
|
-
|
41
|
+
|
42
42
|
project_path = project.root_path
|
43
43
|
|
44
44
|
super project_path
|
45
45
|
|
46
|
-
# Unregister built-in processors. We want most things served by the
|
46
|
+
# Unregister built-in processors. We want most things served by the
|
47
47
|
# pipeline directly to just pass through. (package pipelines do the
|
48
48
|
# processing)
|
49
49
|
%w(text/css application/javascript).each do |kind|
|
@@ -54,19 +54,19 @@ module BPM
|
|
54
54
|
# configure search paths
|
55
55
|
append_path project.assets_root
|
56
56
|
append_path project.preview_root if include_preview
|
57
|
-
end
|
58
|
-
|
59
|
-
# determines the proper pipeline for the path
|
57
|
+
end
|
58
|
+
|
59
|
+
# determines the proper pipeline for the path
|
60
60
|
def pipeline_for(path)
|
61
61
|
return nil if magic_paths.include?(path)
|
62
62
|
package_pipelines.find do |cur_pipeline|
|
63
63
|
path.to_s[cur_pipeline.package.root_path.to_s]
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def attributes_for(path)
|
68
68
|
if path.to_s[File.join(project.root_path, '.bpm')] || !Pathname.new(path).absolute?
|
69
|
-
return super(path)
|
69
|
+
return super(path)
|
70
70
|
end
|
71
71
|
|
72
72
|
pipeline = pipeline_for path
|
@@ -74,23 +74,23 @@ module BPM
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def resolve(logical_path, options={}, &block)
|
77
|
-
|
77
|
+
|
78
78
|
magic_path = magic_paths.find do |path|
|
79
79
|
path =~ /#{Regexp.escape logical_path.to_s}(\..+)?$/
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
package_name = logical_path.to_s.sub(/#{Regexp.escape File::SEPARATOR}.+/,'')
|
83
|
-
pipeline = package_pipelines.find do |cur_pipeline|
|
83
|
+
pipeline = package_pipelines.find do |cur_pipeline|
|
84
84
|
cur_pipeline.package_name == package_name
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
if pipeline && magic_path.nil?
|
88
88
|
logical_path = logical_path.to_s[package_name.size+1..-1]
|
89
89
|
pipeline.resolve Pathname.new(logical_path), options, &block
|
90
90
|
else
|
91
91
|
super logical_path, options, &block
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
end
|
95
95
|
|
96
96
|
# Detect whenever we are asked to build some of the magic files and swap
|
@@ -113,16 +113,16 @@ module BPM
|
|
113
113
|
# Returns an array of all the buildable assets in the current directory.
|
114
114
|
# These are the assets that will be built when you compile the project.
|
115
115
|
def buildable_assets
|
116
|
-
|
117
|
-
# make sure the logical_path can be used to simply build into the
|
116
|
+
|
117
|
+
# make sure the logical_path can be used to simply build into the
|
118
118
|
# assets directory when we are done
|
119
119
|
ret = project.buildable_asset_filenames mode
|
120
|
-
|
120
|
+
|
121
121
|
# Add in the static assets that we just need to copy
|
122
122
|
project.build_settings(mode).each do |target_name, opts|
|
123
123
|
next unless opts.is_a? Array
|
124
|
-
opts.each do |dir_name|
|
125
|
-
|
124
|
+
opts.each do |dir_name|
|
125
|
+
|
126
126
|
dep = project.local_deps.find { |dep| dep.name == target_name }
|
127
127
|
dep = project if project.name == target_name
|
128
128
|
|
@@ -147,46 +147,51 @@ module BPM
|
|
147
147
|
def plugin_context_for(logical_path)
|
148
148
|
@plugin_contexts[logical_path] ||= build_plugin_context(logical_path)
|
149
149
|
end
|
150
|
-
|
150
|
+
|
151
151
|
protected
|
152
152
|
|
153
153
|
def build_magic_paths
|
154
154
|
magic_paths = project.buildable_asset_filenames(mode).map do |filename|
|
155
155
|
project.assets_root filename
|
156
156
|
end
|
157
|
-
|
157
|
+
|
158
158
|
magic_paths += project.buildable_asset_filenames(mode).map do |filename|
|
159
159
|
project.preview_root filename
|
160
160
|
end
|
161
161
|
end
|
162
|
-
|
162
|
+
|
163
163
|
# Pass along to package pipelines
|
164
164
|
def expire_index!
|
165
165
|
super
|
166
166
|
@magic_paths = nil
|
167
167
|
package_pipelines.each { |pipeline| pipeline.expire_index! }
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
private
|
171
|
-
|
171
|
+
|
172
|
+
def javascript_exception_response(exception)
|
173
|
+
expire_index!
|
174
|
+
super exception
|
175
|
+
end
|
176
|
+
|
177
|
+
def css_exception_response(exception)
|
178
|
+
expire_index!
|
179
|
+
super exception
|
180
|
+
end
|
181
|
+
|
172
182
|
def build_plugin_context(logical_path)
|
173
183
|
asset = BPM::PluginAsset.new(self, logical_path)
|
174
184
|
plugin_text = asset.to_s
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
ctx =
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
ctx['BPM_PLUGIN'] = {}
|
183
|
-
ctx.eval plugin_text
|
184
|
-
end
|
185
|
+
|
186
|
+
V8::Context.new do |ctx|
|
187
|
+
ctx['window'] = ctx # make browser-like environment
|
188
|
+
ctx['console'] = BPM::Console.new
|
189
|
+
|
190
|
+
ctx['BPM_PLUGIN'] = {}
|
191
|
+
ctx.eval plugin_text
|
185
192
|
end
|
186
|
-
|
187
|
-
ctx
|
188
193
|
end
|
189
|
-
|
194
|
+
|
190
195
|
end
|
191
|
-
|
196
|
+
|
192
197
|
end
|
@@ -7,7 +7,7 @@ module BPM
|
|
7
7
|
return false if directory_exists?
|
8
8
|
|
9
9
|
empty_directory '.', :verbose => false
|
10
|
-
empty_directory '
|
10
|
+
empty_directory 'lib'
|
11
11
|
|
12
12
|
create_files
|
13
13
|
|
@@ -25,7 +25,7 @@ module BPM
|
|
25
25
|
template "README.md"
|
26
26
|
template "index.html"
|
27
27
|
|
28
|
-
inside '
|
28
|
+
inside 'lib' do
|
29
29
|
template 'main.js'
|
30
30
|
end
|
31
31
|
|
data/lib/bpm/version.rb
CHANGED