bpm 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +3 -0
- data/Gemfile +0 -13
- data/TODO.md +1 -0
- data/bpm.gemspec +8 -3
- data/lib/bpm/cli/base.rb +22 -20
- data/lib/bpm/generator.rb +3 -3
- data/lib/bpm/libgems_ext/dependency_installer.rb +4 -4
- data/lib/bpm/libgems_ext/installer.rb +1 -1
- data/lib/bpm/package.rb +13 -9
- data/lib/bpm/pipeline/generated_asset.rb +30 -3
- data/lib/bpm/pipeline/transport_processor.rb +20 -12
- data/lib/bpm/pipeline.rb +17 -9
- data/lib/bpm/project.rb +42 -10
- data/lib/bpm/server.rb +5 -0
- data/lib/bpm/version.rb +1 -1
- data/lib/bpm.rb +2 -0
- data/lib/vendored_sprockets.rb +7 -0
- data/spec/cli/add_spec.rb +40 -37
- data/spec/cli/build_spec.rb +5 -5
- data/spec/cli/new_spec.rb +49 -23
- data/spec/cli/push_spec.rb +5 -5
- data/spec/cli/unpack_spec.rb +14 -14
- data/spec/fixtures/{badrake-0.8.7.spd → badrake-0.8.7.bpkg} +0 -0
- data/spec/fixtures/{builder-3.0.0.spd → builder-3.0.0.bpkg} +0 -0
- data/spec/fixtures/{bundler-1.1.pre.spd → bundler-1.1.pre.bpkg} +0 -0
- data/spec/fixtures/{coffee-1.0.1.pre.spd → coffee-1.0.1.pre.bpkg} +0 -0
- data/spec/fixtures/{core-test-0.4.9.spd → core-test-0.4.9.bpkg} +0 -0
- data/spec/fixtures/{custom_generator-1.0.spd → custom_generator-1.0.bpkg} +0 -0
- data/spec/fixtures/custom_name/MyProject.json +4 -0
- data/spec/fixtures/hello_world/css/dummy.css +3 -0
- data/spec/fixtures/{highline-1.6.1.spd → highline-1.6.1.bpkg} +0 -0
- data/spec/fixtures/{ivory-0.0.1.spd → ivory-0.0.1.bpkg} +0 -0
- data/spec/fixtures/{jquery-1.4.3.spd → jquery-1.4.3.bpkg} +0 -0
- data/spec/fixtures/minitest/assets/bpm_packages.js +1 -0
- data/spec/fixtures/minitest/assets/bpm_styles.css +0 -0
- data/spec/fixtures/minitest/assets/minitest/app_package.js +1 -0
- data/spec/fixtures/minitest/lib/main.js +1 -0
- data/spec/fixtures/minitest/minitest.json +22 -0
- data/spec/fixtures/minitest/packages/uglyduck/lib/main.js +1 -0
- data/spec/fixtures/minitest/packages/uglyduck/minifier/main.js +4 -0
- data/spec/fixtures/minitest/packages/uglyduck/package.json +21 -0
- data/spec/fixtures/{optparse-1.0.1.spd → optparse-1.0.1.bpkg} +0 -0
- data/spec/fixtures/{rake-0.8.6.spd → rake-0.8.6.bpkg} +0 -0
- data/spec/fixtures/{rake-0.8.7.spd → rake-0.8.7.bpkg} +0 -0
- data/spec/fixtures/{spade-0.5.0.spd → spade-0.5.0.bpkg} +0 -0
- data/spec/fixtures/transporter/packages/transport/lib/main.js +1 -0
- data/spec/fixtures/transporter/packages/transport/package.json +1 -1
- data/spec/fixtures/transporter/packages/transport/transports/wrapper.js +5 -0
- data/spec/gauntlet_spec.rb +2 -2
- data/spec/package_spec.rb +3 -3
- data/spec/pipeline_spec.rb +175 -54
- data/spec/project_spec.rb +19 -3
- data/spec/support/fake_gem_server.rb +4 -4
- data/templates/init/project.json +3 -1
- data/templates/project/index.html +1 -1
- data/vendor/sprockets/.gitignore +7 -0
- data/vendor/sprockets/.travis.yml +6 -0
- data/vendor/sprockets/Gemfile +8 -0
- data/vendor/sprockets/LICENSE +20 -0
- data/vendor/sprockets/README.md +22 -0
- data/vendor/sprockets/Rakefile +8 -0
- data/vendor/sprockets/lib/sprockets/asset.rb +203 -0
- data/vendor/sprockets/lib/sprockets/asset_attributes.rb +161 -0
- data/vendor/sprockets/lib/sprockets/base.rb +147 -0
- data/vendor/sprockets/lib/sprockets/bundled_asset.rb +222 -0
- data/vendor/sprockets/lib/sprockets/cache/file_store.rb +41 -0
- data/vendor/sprockets/lib/sprockets/caching.rb +121 -0
- data/vendor/sprockets/lib/sprockets/charset_normalizer.rb +41 -0
- data/vendor/sprockets/lib/sprockets/context.rb +191 -0
- data/vendor/sprockets/lib/sprockets/digest.rb +73 -0
- data/vendor/sprockets/lib/sprockets/directive_processor.rb +380 -0
- data/vendor/sprockets/lib/sprockets/eco_template.rb +39 -0
- data/vendor/sprockets/lib/sprockets/ejs_template.rb +38 -0
- data/vendor/sprockets/lib/sprockets/engines.rb +92 -0
- data/vendor/sprockets/lib/sprockets/environment.rb +93 -0
- data/vendor/sprockets/lib/sprockets/errors.rb +17 -0
- data/vendor/sprockets/lib/sprockets/index.rb +80 -0
- data/vendor/sprockets/lib/sprockets/jst_processor.rb +26 -0
- data/vendor/sprockets/lib/sprockets/processing.rb +310 -0
- data/vendor/sprockets/lib/sprockets/processor.rb +32 -0
- data/vendor/sprockets/lib/sprockets/safety_colons.rb +28 -0
- data/vendor/sprockets/lib/sprockets/server.rb +270 -0
- data/vendor/sprockets/lib/sprockets/static_asset.rb +87 -0
- data/vendor/sprockets/lib/sprockets/static_compilation.rb +82 -0
- data/vendor/sprockets/lib/sprockets/trail.rb +122 -0
- data/vendor/sprockets/lib/sprockets/utils.rb +67 -0
- data/vendor/sprockets/lib/sprockets/version.rb +3 -0
- data/vendor/sprockets/lib/sprockets.rb +31 -0
- data/vendor/sprockets/sprockets.gemspec +30 -0
- data/vendor/sprockets/test/fixtures/asset/POW.png +0 -0
- data/vendor/sprockets/test/fixtures/asset/application.js +6 -0
- data/vendor/sprockets/test/fixtures/asset/bar-utf8.css +2 -0
- data/vendor/sprockets/test/fixtures/asset/charset.css +2 -0
- data/vendor/sprockets/test/fixtures/asset/circle/a.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/circle/b.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/circle/c.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/compat.js +4 -0
- data/vendor/sprockets/test/fixtures/asset/constants.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/constants.yml +1 -0
- data/vendor/sprockets/test/fixtures/asset/default_mime_type.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/filename.js.erb +1 -0
- data/vendor/sprockets/test/fixtures/asset/foo-utf8.css +2 -0
- data/vendor/sprockets/test/fixtures/asset/included_header.js +4 -0
- data/vendor/sprockets/test/fixtures/asset/jquery.tmpl.min.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/mismatch.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/multiple.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/multipleengine.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/noengine.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/noformat.coffee +1 -0
- data/vendor/sprockets/test/fixtures/asset/one.css +1 -0
- data/vendor/sprockets/test/fixtures/asset/oneengine.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/project.css +1 -0
- data/vendor/sprockets/test/fixtures/asset/project.js.erb +4 -0
- data/vendor/sprockets/test/fixtures/asset/relative/include.js +4 -0
- data/vendor/sprockets/test/fixtures/asset/relative/require.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/relative/require_outside_path.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/require_self.css +9 -0
- data/vendor/sprockets/test/fixtures/asset/require_self_twice.css +8 -0
- data/vendor/sprockets/test/fixtures/asset/semicolons/bar.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/semicolons/index.js +5 -0
- data/vendor/sprockets/test/fixtures/asset/sprite.css.erb +12 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/b/c/d.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/b/c/e.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/b/c.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/b.css +2 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/b.js.erb +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/d/c.js.coffee +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all/d/e.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all_with_require.js +7 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all_with_require_directory.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/all_with_require_tree.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/tree/directory/application.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/tree/directory/bar.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/directory/foo.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/tree/application.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/tree/tree/bar.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/tree/foo.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/with_logical_path/a/a.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/with_logical_path/require_tree_with_logical_path.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/without_argument/a.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/without_argument/b.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/tree/without_argument/require_tree_without_argument.js +1 -0
- data/vendor/sprockets/test/fixtures/asset/two.css +1 -0
- data/vendor/sprockets/test/fixtures/asset/unicode.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/unknownexts.min.js +2 -0
- data/vendor/sprockets/test/fixtures/asset/users.js.erb.str +4 -0
- data/vendor/sprockets/test/fixtures/context/POW.png +0 -0
- data/vendor/sprockets/test/fixtures/context/application.js.yml +3 -0
- data/vendor/sprockets/test/fixtures/context/bar.js +1 -0
- data/vendor/sprockets/test/fixtures/context/foo.js +2 -0
- data/vendor/sprockets/test/fixtures/context/helpers.css.erb +3 -0
- data/vendor/sprockets/test/fixtures/context/properties.js.erb +7 -0
- data/vendor/sprockets/test/fixtures/context/require_glob.js +1 -0
- data/vendor/sprockets/test/fixtures/context/resolve_content_type.js.erb +4 -0
- data/vendor/sprockets/test/fixtures/context/sprite.css.embed +3 -0
- data/vendor/sprockets/test/fixtures/default/application.js.coffee +4 -0
- data/vendor/sprockets/test/fixtures/default/coffee/foo.coffee +1 -0
- data/vendor/sprockets/test/fixtures/default/coffee/index.js +3 -0
- data/vendor/sprockets/test/fixtures/default/empty +0 -0
- data/vendor/sprockets/test/fixtures/default/gallery.css.erb +3 -0
- data/vendor/sprockets/test/fixtures/default/gallery.js +1 -0
- data/vendor/sprockets/test/fixtures/default/goodbye.jst.eco +1 -0
- data/vendor/sprockets/test/fixtures/default/hello.jst.ejs +1 -0
- data/vendor/sprockets/test/fixtures/default/hello.txt +1 -0
- data/vendor/sprockets/test/fixtures/default/interpolation.js +1 -0
- data/vendor/sprockets/test/fixtures/default/missing_require.js +1 -0
- data/vendor/sprockets/test/fixtures/default/mobile/a.js +1 -0
- data/vendor/sprockets/test/fixtures/default/mobile/b.js +1 -0
- data/vendor/sprockets/test/fixtures/default/mobile/c.css +1 -0
- data/vendor/sprockets/test/fixtures/default/mobile/d.css +1 -0
- data/vendor/sprockets/test/fixtures/default/mobile/index.css +3 -0
- data/vendor/sprockets/test/fixtures/default/mobile/index.js +1 -0
- data/vendor/sprockets/test/fixtures/default/noreturn.js +1 -0
- data/vendor/sprockets/test/fixtures/default/project.js.coffee.erb +2 -0
- data/vendor/sprockets/test/fixtures/directives/code_before_comment +3 -0
- data/vendor/sprockets/test/fixtures/directives/comment_without_directives +6 -0
- data/vendor/sprockets/test/fixtures/directives/directive_word_splitting +6 -0
- data/vendor/sprockets/test/fixtures/directives/directives_after_header +16 -0
- data/vendor/sprockets/test/fixtures/directives/double_slash +9 -0
- data/vendor/sprockets/test/fixtures/directives/hash +8 -0
- data/vendor/sprockets/test/fixtures/directives/no_header +2 -0
- data/vendor/sprockets/test/fixtures/directives/slash_star +10 -0
- data/vendor/sprockets/test/fixtures/directives/slash_star_single +4 -0
- data/vendor/sprockets/test/fixtures/directives/space_between_directive_word +2 -0
- data/vendor/sprockets/test/fixtures/directives/triple_hash +10 -0
- data/vendor/sprockets/test/fixtures/encoding/ascii.js +1 -0
- data/vendor/sprockets/test/fixtures/encoding/ascii_utf8.js +2 -0
- data/vendor/sprockets/test/fixtures/encoding/utf16.js +0 -0
- data/vendor/sprockets/test/fixtures/encoding/utf8.js +1 -0
- data/vendor/sprockets/test/fixtures/encoding/utf8_bom.js +1 -0
- data/vendor/sprockets/test/fixtures/engines/hello.alert +1 -0
- data/vendor/sprockets/test/fixtures/engines/moo.js.str +1 -0
- data/vendor/sprockets/test/fixtures/public/compiled-digest-0aa2105d29558f3eb790d411d7d8fb66.js +3 -0
- data/vendor/sprockets/test/fixtures/public/compiled-digest-1c41eb0cf934a0c76babe875f982f9d1.js +1 -0
- data/vendor/sprockets/test/fixtures/server/app/javascripts/application.js +5 -0
- data/vendor/sprockets/test/fixtures/server/app/javascripts/bar.js +1 -0
- data/vendor/sprockets/test/fixtures/server/app/javascripts/foo.js +1 -0
- data/vendor/sprockets/test/fixtures/server/app/javascripts/hello.txt +2 -0
- data/vendor/sprockets/test/fixtures/server/app/javascripts/tree.js +1 -0
- data/vendor/sprockets/test/fixtures/server/vendor/javascripts/missing_require.js +1 -0
- data/vendor/sprockets/test/fixtures/server/vendor/stylesheets/missing_require.css +1 -0
- data/vendor/sprockets/test/sprockets_test.rb +56 -0
- data/vendor/sprockets/test/test_asset.rb +593 -0
- data/vendor/sprockets/test/test_asset_attributes.rb +86 -0
- data/vendor/sprockets/test/test_caching.rb +62 -0
- data/vendor/sprockets/test/test_context.rb +115 -0
- data/vendor/sprockets/test/test_directive_processor.rb +124 -0
- data/vendor/sprockets/test/test_encoding.rb +65 -0
- data/vendor/sprockets/test/test_engines.rb +73 -0
- data/vendor/sprockets/test/test_environment.rb +610 -0
- data/vendor/sprockets/test/test_server.rb +227 -0
- metadata +258 -54
- data/spec/fixtures/transporter/packages/transport/lib/wrapper.js +0 -5
data/.gitmodules
CHANGED
data/Gemfile
CHANGED
@@ -1,16 +1,3 @@
|
|
1
|
-
# A sample Gemfile
|
2
1
|
source "http://rubygems.org"
|
3
2
|
|
4
|
-
if ENV["SPADE_PATH"]
|
5
|
-
gem 'spade', :path => ENV["SPADE_PATH"]
|
6
|
-
else
|
7
|
-
gem 'spade', :git => "git://github.com/sproutcore/spade-ruby"
|
8
|
-
end
|
9
|
-
|
10
|
-
if ENV["SPOCKETS_PATH"]
|
11
|
-
gem 'sprockets', :path => ENV["SPROCKETS_PATH"]
|
12
|
-
else
|
13
|
-
gem 'sprockets', :git => "git://github.com/sstephenson/sprockets"
|
14
|
-
end
|
15
|
-
|
16
3
|
gemspec
|
data/TODO.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
1
|
|
2
2
|
* Better support for using plugins during builds. Ideal solution would create a .js file for each plugin and load it in a separate context. This would allow each plugin to actually require other dependencies, etc. This is required to properly support format plugins.
|
3
3
|
|
4
|
+
* Development dependencies
|
data/bpm.gemspec
CHANGED
@@ -21,14 +21,19 @@ 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 "
|
25
|
-
|
24
|
+
s.add_dependency "therubyracer", "~> 0.9.2"
|
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
|
26
31
|
|
27
32
|
s.add_development_dependency "rspec"
|
28
33
|
s.add_development_dependency "rack", "~> 1.2.1"
|
29
34
|
|
30
35
|
paths = `git submodule`.split("\n").map do |line|
|
31
|
-
path = line.gsub(
|
36
|
+
path = line.gsub(/^.\w+\s+(\S+).*/,'\1')
|
32
37
|
`cd #{path}; git ls-files`.split("\n").map { |p| File.join(path, p) }
|
33
38
|
end
|
34
39
|
paths << `git ls-files`.split("\n")
|
data/lib/bpm/cli/base.rb
CHANGED
@@ -56,27 +56,27 @@ module BPM
|
|
56
56
|
end
|
57
57
|
|
58
58
|
desc "add [PACKAGE]", "Add package to project"
|
59
|
-
method_option :version, :type => :string, :default =>
|
59
|
+
method_option :version, :type => :string, :default => nil, :aliases => ['-v'], :desc => 'Specify a version to install'
|
60
60
|
method_option :project, :type => :string, :default => nil, :aliases => ['-p'], :desc => 'Specify project location other than working directory'
|
61
61
|
method_option :prerelease, :type => :boolean, :default => false, :aliases => ['--pre'], :desc => 'Install a prerelease version'
|
62
62
|
def add(*package_names)
|
63
|
-
|
64
63
|
# map to dependencies
|
65
|
-
if package_names.
|
64
|
+
if package_names.empty?
|
66
65
|
abort "You must specify at least one package"
|
67
|
-
elsif package_names.size == 1
|
68
|
-
deps = {}
|
69
|
-
vers = options[:version]
|
70
|
-
vers = '>= 0-pre' if vers == '>= 0' && options[:prerelease]
|
71
|
-
deps[package_names.first] = vers
|
72
66
|
else
|
73
|
-
if options[:version]
|
67
|
+
if package_names.size > 1 && options[:version]
|
74
68
|
abort "You can only name one package with the version option"
|
75
69
|
end
|
76
|
-
|
70
|
+
|
77
71
|
deps = {}
|
78
|
-
|
79
|
-
|
72
|
+
package_names.each do |name|
|
73
|
+
vers = options[:version] || (options[:prerelease] ? '>= 0-pre' : '>= 0')
|
74
|
+
if name =~ /^(.+?)(-(\d[\w\.]*))?\.bpkg$/
|
75
|
+
name = $1
|
76
|
+
vers = $3 if $3
|
77
|
+
end
|
78
|
+
deps[name] = vers
|
79
|
+
end
|
80
80
|
end
|
81
81
|
|
82
82
|
# find project
|
@@ -85,8 +85,8 @@ module BPM
|
|
85
85
|
begin
|
86
86
|
project.add_dependencies deps, true
|
87
87
|
project.build :debug, true
|
88
|
-
|
89
|
-
|
88
|
+
rescue Exception => e
|
89
|
+
abort e.message
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -220,7 +220,7 @@ module BPM
|
|
220
220
|
|
221
221
|
path = File.expand_path(options[:path] || underscore(name))
|
222
222
|
generator = get_generator(:project, package)
|
223
|
-
success = generator.new(self, name, path, template_path).run
|
223
|
+
success = generator.new(self, name, path, template_path, package).run
|
224
224
|
|
225
225
|
run_init(name, path, package) if success
|
226
226
|
end
|
@@ -287,7 +287,7 @@ module BPM
|
|
287
287
|
template_path = package ? package.template_path(:init) : nil
|
288
288
|
|
289
289
|
generator = get_generator(:init, package)
|
290
|
-
generator.new(self, name, path, package
|
290
|
+
generator.new(self, name, path, template_path, package).run
|
291
291
|
|
292
292
|
project = BPM::Project.new(path, name)
|
293
293
|
project.fetch_dependencies true
|
@@ -335,10 +335,12 @@ module BPM
|
|
335
335
|
|
336
336
|
def install_package(pkg_name)
|
337
337
|
return nil unless pkg_name
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
338
|
+
begin
|
339
|
+
# Try remote first to get the latest versions
|
340
|
+
installed = BPM::Remote.new.install(pkg_name, ">= 0", false)
|
341
|
+
rescue LibGems::GemNotFoundException
|
342
|
+
dep = LibGems::Dependency.new(pkg_name)
|
343
|
+
installed = LibGems.source_index.search(dep)
|
342
344
|
end
|
343
345
|
spec = installed.find{|p| p.name == pkg_name }
|
344
346
|
abort "Unable to find package: #{pkg_name}" unless spec
|
data/lib/bpm/generator.rb
CHANGED
@@ -29,10 +29,10 @@ module BPM
|
|
29
29
|
class Generator
|
30
30
|
include Thor::Actions
|
31
31
|
|
32
|
-
attr_reader :name
|
32
|
+
attr_reader :name, :package
|
33
33
|
|
34
|
-
def initialize(thor, name, root, template_path=nil)
|
35
|
-
@thor, @name, @template_path = thor, name, template_path
|
34
|
+
def initialize(thor, name, root, template_path=nil, package=nil)
|
35
|
+
@thor, @name, @template_path, @package = thor, name, template_path, package
|
36
36
|
|
37
37
|
self.destination_root = root
|
38
38
|
end
|
@@ -3,7 +3,7 @@ require 'libgems/dependency_installer'
|
|
3
3
|
module LibGems
|
4
4
|
class DependencyInstaller
|
5
5
|
|
6
|
-
# Had to overwrite this all just to change the match from /gem$/ to /
|
6
|
+
# Had to overwrite this all just to change the match from /gem$/ to /bpkg$/
|
7
7
|
# TODO: Consider whether extension should be settable in LibGems
|
8
8
|
def find_spec_by_name_and_version(gem_name,
|
9
9
|
version = LibGems::Requirement.default,
|
@@ -20,7 +20,7 @@ module LibGems
|
|
20
20
|
|
21
21
|
unless local_gems.empty? then
|
22
22
|
local_gems.each do |gem_file|
|
23
|
-
next unless gem_file =~ /
|
23
|
+
next unless gem_file =~ /bpkg$/
|
24
24
|
begin
|
25
25
|
spec = LibGems::Format.from_file_by_path(gem_file).spec
|
26
26
|
spec_and_source = [spec, gem_file]
|
@@ -69,7 +69,7 @@ module LibGems
|
|
69
69
|
next if @source_index.any? { |n,_| n == spec.full_name } and not last
|
70
70
|
|
71
71
|
# TODO: make this sorta_verbose so other users can benefit from it
|
72
|
-
say "Installing
|
72
|
+
say "Installing bpkg #{spec.full_name}" if LibGems.configuration.really_verbose
|
73
73
|
|
74
74
|
_, source_uri = @specs_and_sources.assoc spec
|
75
75
|
begin
|
@@ -108,7 +108,7 @@ module LibGems
|
|
108
108
|
gems_and_sources = []
|
109
109
|
|
110
110
|
if @domain == :both or @domain == :local then
|
111
|
-
Dir[File.join(Dir.pwd, "#{dep.name}-[0-9]*.
|
111
|
+
Dir[File.join(Dir.pwd, "#{dep.name}-[0-9]*.bpkg")].each do |gem_file|
|
112
112
|
spec = LibGems::Format.from_file_by_path(gem_file).spec
|
113
113
|
gems_and_sources << [spec, gem_file] if spec.name == dep.name
|
114
114
|
end
|
@@ -9,7 +9,7 @@ module LibGems
|
|
9
9
|
#
|
10
10
|
# This file was generated by BPM.
|
11
11
|
#
|
12
|
-
# The application '#{@spec.name}' is installed as part of an
|
12
|
+
# The application '#{@spec.name}' is installed as part of an bpkg, and
|
13
13
|
# this file is here to facilitate running it.
|
14
14
|
#
|
15
15
|
|
data/lib/bpm/package.rb
CHANGED
@@ -2,7 +2,7 @@ require 'json'
|
|
2
2
|
|
3
3
|
module BPM
|
4
4
|
class Package
|
5
|
-
EXT = "
|
5
|
+
EXT = "bpkg"
|
6
6
|
METADATA = %w[keywords licenses engines main bin directories]
|
7
7
|
FIELDS = %w[name version description author homepage summary]
|
8
8
|
attr_accessor :metadata, :lib_path, :tests_path, :errors, :json_path, :attributes, :directories, :dependencies, :root_path
|
@@ -24,10 +24,6 @@ module BPM
|
|
24
24
|
@metadata = {}
|
25
25
|
end
|
26
26
|
|
27
|
-
def bpm
|
28
|
-
@bpm || BPM::VERSION
|
29
|
-
end
|
30
|
-
|
31
27
|
def bpkg=(spec)
|
32
28
|
unless spec.is_a?(LibGems::Specification)
|
33
29
|
spec = LibGems::Format.from_file_by_path(spec.to_s).spec
|
@@ -46,7 +42,7 @@ module BPM
|
|
46
42
|
spec.summary = summary
|
47
43
|
spec.description = description
|
48
44
|
spec.requirements = [metadata.to_json]
|
49
|
-
spec.files = directory_files + template_files + ["package.json"]
|
45
|
+
spec.files = directory_files + template_files + transport_files + ["package.json"]
|
50
46
|
spec.test_files = glob_files(tests_path)
|
51
47
|
spec.bindir = bin_path
|
52
48
|
spec.executables = bin_files.map{|p| File.basename(p) } if bin_path
|
@@ -151,6 +147,10 @@ module BPM
|
|
151
147
|
glob_files("templates")
|
152
148
|
end
|
153
149
|
|
150
|
+
def transport_files
|
151
|
+
glob_files("transports")
|
152
|
+
end
|
153
|
+
|
154
154
|
def bin_path
|
155
155
|
@directories["bin"] || "bin"
|
156
156
|
end
|
@@ -164,11 +164,15 @@ module BPM
|
|
164
164
|
end
|
165
165
|
|
166
166
|
def transport_plugins(project)
|
167
|
-
plugin_modules('plugin:transport', project)
|
167
|
+
plugin_modules('plugin:transport', project, false)
|
168
|
+
end
|
169
|
+
|
170
|
+
def minifier_plugins(project)
|
171
|
+
[@attributes['plugin:minifier']].compact
|
168
172
|
end
|
169
173
|
|
170
|
-
def plugin_modules(key_name, project)
|
171
|
-
return [@attributes[key_name]] if @attributes[key_name]
|
174
|
+
def plugin_modules(key_name, project, own=true)
|
175
|
+
return [@attributes[key_name]] if own && @attributes[key_name]
|
172
176
|
dependencies.keys.map do |pkg_name|
|
173
177
|
dep = project.local_deps.find do |pkg|
|
174
178
|
pkg.load_json
|
@@ -17,11 +17,38 @@ module BPM
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
+
def build_source
|
21
|
+
minify super
|
22
|
+
end
|
23
|
+
|
24
|
+
def minify(body)
|
25
|
+
project = environment.project
|
26
|
+
minifier_name = project.minifier_name
|
27
|
+
if minifier_name && content_type == 'application/javascript'
|
28
|
+
pkg = project.package_from_name minifier_name
|
29
|
+
minifier_plugin = pkg.minifier_plugins(project).first
|
30
|
+
|
31
|
+
minifier_path = blank_context.resolve(project.path_from_module(minifier_plugin))
|
32
|
+
|
33
|
+
ctx = environment.js_context_for minifier_path
|
34
|
+
out = ''
|
35
|
+
|
36
|
+
V8::C::Locker() do
|
37
|
+
ctx["PACKAGE_INFO"] = pkg.attributes
|
38
|
+
ctx["DATA"] = body
|
39
|
+
body = ctx.eval("exports.minify(DATA, PACKAGE_INFO);")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
body
|
44
|
+
end
|
45
|
+
|
20
46
|
def build_dependency_context_and_body
|
21
47
|
|
22
48
|
project = environment.project
|
23
|
-
|
24
|
-
|
49
|
+
pkgs = pathname.to_s =~ /app_/ ? [project] : project.local_deps
|
50
|
+
if pkgs.size > 0
|
51
|
+
manifest = pkgs.map do |x|
|
25
52
|
"#{x.name} (#{x.version})"
|
26
53
|
end.join " "
|
27
54
|
else
|
@@ -48,7 +75,7 @@ EOF
|
|
48
75
|
|
49
76
|
dir_name, dir_method = FORMAT_METHODS[content_type] || ['lib', 'pipeline_libs']
|
50
77
|
|
51
|
-
|
78
|
+
pkgs.map do |pkg|
|
52
79
|
pkg.load_json
|
53
80
|
pkg.send(dir_method).each do |dir|
|
54
81
|
dir_name = pkg.directories[dir] || dir
|
@@ -8,23 +8,31 @@ module BPM
|
|
8
8
|
project = context.environment.project
|
9
9
|
pkg, module_id = project.package_and_module_from_path file
|
10
10
|
transport_plugins = pkg.transport_plugins(project)
|
11
|
-
|
11
|
+
|
12
|
+
# No transport, just return the existing data
|
13
|
+
return data if transport_plugins.empty?
|
14
|
+
|
12
15
|
if transport_plugins.size > 1
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
# TODO: Maybe make custom error for this
|
17
|
+
raise "#{pkg.name} depends on #{transport_plugins.size} packages that define transport plugins. " \
|
18
|
+
"Select a plugin by adding a `plugin:transport` property to the package.json"
|
19
|
+
end
|
20
|
+
|
21
|
+
project_path = project.root_path.to_s
|
22
|
+
project_path << '/' if project_path !~ /\/$/
|
23
|
+
filepath = file.sub(/^#{project_path}/,'') # relative file path from project
|
18
24
|
|
19
|
-
|
25
|
+
transport_path = context.resolve project.path_from_module(transport_plugins.first)
|
26
|
+
ctx = context.environment.js_context_for transport_path
|
27
|
+
out = ''
|
28
|
+
|
29
|
+
V8::C::Locker() do
|
20
30
|
ctx["PACKAGE_INFO"] = pkg.attributes
|
21
31
|
ctx["DATA"] = data
|
22
|
-
|
23
|
-
|
24
|
-
wrapped
|
25
|
-
else
|
26
|
-
data
|
32
|
+
out = ctx.eval("exports.compileTransport(DATA, PACKAGE_INFO, '#{module_id}', '#{filepath}');")
|
27
33
|
end
|
34
|
+
|
35
|
+
out + "\n\n"
|
28
36
|
end
|
29
37
|
|
30
38
|
end
|
data/lib/bpm/pipeline.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'sprockets'
|
2
|
+
require 'v8'
|
2
3
|
|
3
4
|
module BPM
|
4
5
|
|
@@ -26,9 +27,11 @@ module BPM
|
|
26
27
|
unregister_processor kind, Sprockets::DirectiveProcessor
|
27
28
|
register_processor kind, BPM::DirectiveProcessor
|
28
29
|
end
|
29
|
-
|
30
|
+
|
30
31
|
register_postprocessor 'application/javascript', BPM::TransportProcessor
|
31
|
-
|
32
|
+
|
33
|
+
# This gunks things up. I'm not a fan - PDW
|
34
|
+
unregister_postprocessor 'application/javascript', Sprockets::SafetyColons
|
32
35
|
|
33
36
|
# configure search paths
|
34
37
|
append_path File.join project_path, '.bpm', 'packages'
|
@@ -49,7 +52,7 @@ module BPM
|
|
49
52
|
|
50
53
|
# make sure the logical_path can be used to simply build into the
|
51
54
|
# assets directory when we are done
|
52
|
-
ret = ['bpm_packages.js', 'bpm_styles.css']
|
55
|
+
ret = ['bpm_packages.js', 'bpm_styles.css', "#{project.name}/app_package.js", "#{project.name}/app_styles.css"]
|
53
56
|
|
54
57
|
project.local_deps.each do |pkg|
|
55
58
|
pkg.load_json
|
@@ -74,6 +77,10 @@ module BPM
|
|
74
77
|
File.join project.root_path, 'assets', filename
|
75
78
|
end
|
76
79
|
|
80
|
+
magic_paths += %w(app_package.js app_styles.css).map do |filename|
|
81
|
+
File.join project.root_path, 'assets', project.name, filename
|
82
|
+
end
|
83
|
+
|
77
84
|
if magic_paths.include? pathname.to_s
|
78
85
|
BPM::GeneratedAsset.new(self, logical_path, pathname, options)
|
79
86
|
else
|
@@ -84,14 +91,15 @@ module BPM
|
|
84
91
|
private
|
85
92
|
|
86
93
|
def build_js_context(path)
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
94
|
+
ctx = nil
|
95
|
+
V8::C::Locker() do
|
96
|
+
ctx = V8::Context.new do |ctx|
|
97
|
+
ctx['exports'] = {}
|
98
|
+
ctx.eval "(function(exports) { #{File.read path} })(exports);"
|
99
|
+
end
|
92
100
|
end
|
101
|
+
ctx
|
93
102
|
|
94
|
-
@js_contexts[path] = ctx
|
95
103
|
end
|
96
104
|
|
97
105
|
|
data/lib/bpm/project.rb
CHANGED
@@ -9,9 +9,12 @@ module BPM
|
|
9
9
|
BPM_DIR = '.bpm'
|
10
10
|
|
11
11
|
def self.project_file_path(path)
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
Dir[File.join(path, '*.json')].find{|p| is_project_json?(p) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.is_project_json?(path)
|
16
|
+
json = JSON.load(File.read(path)) rescue nil
|
17
|
+
return !!(json && json["bpm"])
|
15
18
|
end
|
16
19
|
|
17
20
|
def self.is_project_root?(path)
|
@@ -36,12 +39,22 @@ module BPM
|
|
36
39
|
def initialize(root_path, name=nil)
|
37
40
|
super root_path
|
38
41
|
|
42
|
+
if !name
|
43
|
+
# If no name, try to find project json and get name from it
|
44
|
+
project_file = self.class.project_file_path(root_path)
|
45
|
+
name = File.basename(project_file, '.json') if project_file
|
46
|
+
end
|
47
|
+
|
39
48
|
@name = name || File.basename(root_path)
|
40
|
-
@json_path = File.join
|
49
|
+
@json_path = File.join(root_path, "#{@name}.json")
|
41
50
|
|
42
51
|
load_json && validate
|
43
52
|
end
|
44
53
|
|
54
|
+
def bpm
|
55
|
+
@bpm || BPM::VERSION
|
56
|
+
end
|
57
|
+
|
45
58
|
def add_dependencies(new_deps, verbose=false)
|
46
59
|
|
47
60
|
old_deps = build_local_deps(false) || []
|
@@ -94,7 +107,8 @@ module BPM
|
|
94
107
|
end
|
95
108
|
|
96
109
|
def fetch_dependencies(verbose=false)
|
97
|
-
|
110
|
+
exp_deps = expand_local_packages dependencies, true
|
111
|
+
core_fetch_dependencies(exp_deps, :runtime, verbose)
|
98
112
|
end
|
99
113
|
|
100
114
|
# Builds assets directory for dependent packages
|
@@ -148,11 +162,15 @@ module BPM
|
|
148
162
|
puts "\n" if verbose
|
149
163
|
end
|
150
164
|
|
165
|
+
def package_from_name(package_name)
|
166
|
+
return self if package_name == self.name
|
167
|
+
local_deps.find { |pkg| pkg.name == package_name }
|
168
|
+
end
|
169
|
+
|
151
170
|
# Returns the path on disk to reach a given package name
|
152
171
|
def path_from_package(package_name)
|
153
|
-
|
154
|
-
|
155
|
-
path && path.root_path
|
172
|
+
ret = package_from_name package_name
|
173
|
+
ret && ret.root_path
|
156
174
|
end
|
157
175
|
|
158
176
|
# Returns the path on disk for a given module id (relative to the project)
|
@@ -229,7 +247,17 @@ module BPM
|
|
229
247
|
|
230
248
|
@local_deps = nil
|
231
249
|
end
|
250
|
+
|
251
|
+
def as_json
|
252
|
+
json = super
|
253
|
+
json["bpm"] = self.bpm
|
254
|
+
json
|
255
|
+
end
|
232
256
|
|
257
|
+
def minifier_name
|
258
|
+
@attributes['pipeline'] && @attributes['pipeline']['minifier']
|
259
|
+
end
|
260
|
+
|
233
261
|
private
|
234
262
|
|
235
263
|
def read
|
@@ -314,8 +342,12 @@ module BPM
|
|
314
342
|
dep = LibGems::Dependency.new(package_name, vers, kind)
|
315
343
|
cur_installed = LibGems.source_index.search(dep)
|
316
344
|
|
317
|
-
|
318
|
-
|
345
|
+
begin
|
346
|
+
installed = BPM::Remote.new.install(package_name, vers, prerelease)
|
347
|
+
rescue LibGems::GemNotFoundException
|
348
|
+
# If we have it locally but not remote, that's ok
|
349
|
+
installed = []
|
350
|
+
end
|
319
351
|
|
320
352
|
cur_installed.each do |ci|
|
321
353
|
installed.reject! { |i| ci.name == i.name && ci.version == i.version }
|
data/lib/bpm/server.rb
CHANGED
data/lib/bpm/version.rb
CHANGED
data/lib/bpm.rb
CHANGED