bpm 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. data/.gitmodules +3 -0
  2. data/Gemfile +0 -13
  3. data/TODO.md +1 -0
  4. data/bpm.gemspec +8 -3
  5. data/lib/bpm/cli/base.rb +22 -20
  6. data/lib/bpm/generator.rb +3 -3
  7. data/lib/bpm/libgems_ext/dependency_installer.rb +4 -4
  8. data/lib/bpm/libgems_ext/installer.rb +1 -1
  9. data/lib/bpm/package.rb +13 -9
  10. data/lib/bpm/pipeline/generated_asset.rb +30 -3
  11. data/lib/bpm/pipeline/transport_processor.rb +20 -12
  12. data/lib/bpm/pipeline.rb +17 -9
  13. data/lib/bpm/project.rb +42 -10
  14. data/lib/bpm/server.rb +5 -0
  15. data/lib/bpm/version.rb +1 -1
  16. data/lib/bpm.rb +2 -0
  17. data/lib/vendored_sprockets.rb +7 -0
  18. data/spec/cli/add_spec.rb +40 -37
  19. data/spec/cli/build_spec.rb +5 -5
  20. data/spec/cli/new_spec.rb +49 -23
  21. data/spec/cli/push_spec.rb +5 -5
  22. data/spec/cli/unpack_spec.rb +14 -14
  23. data/spec/fixtures/{badrake-0.8.7.spd → badrake-0.8.7.bpkg} +0 -0
  24. data/spec/fixtures/{builder-3.0.0.spd → builder-3.0.0.bpkg} +0 -0
  25. data/spec/fixtures/{bundler-1.1.pre.spd → bundler-1.1.pre.bpkg} +0 -0
  26. data/spec/fixtures/{coffee-1.0.1.pre.spd → coffee-1.0.1.pre.bpkg} +0 -0
  27. data/spec/fixtures/{core-test-0.4.9.spd → core-test-0.4.9.bpkg} +0 -0
  28. data/spec/fixtures/{custom_generator-1.0.spd → custom_generator-1.0.bpkg} +0 -0
  29. data/spec/fixtures/custom_name/MyProject.json +4 -0
  30. data/spec/fixtures/hello_world/css/dummy.css +3 -0
  31. data/spec/fixtures/{highline-1.6.1.spd → highline-1.6.1.bpkg} +0 -0
  32. data/spec/fixtures/{ivory-0.0.1.spd → ivory-0.0.1.bpkg} +0 -0
  33. data/spec/fixtures/{jquery-1.4.3.spd → jquery-1.4.3.bpkg} +0 -0
  34. data/spec/fixtures/minitest/assets/bpm_packages.js +1 -0
  35. data/spec/fixtures/minitest/assets/bpm_styles.css +0 -0
  36. data/spec/fixtures/minitest/assets/minitest/app_package.js +1 -0
  37. data/spec/fixtures/minitest/lib/main.js +1 -0
  38. data/spec/fixtures/minitest/minitest.json +22 -0
  39. data/spec/fixtures/minitest/packages/uglyduck/lib/main.js +1 -0
  40. data/spec/fixtures/minitest/packages/uglyduck/minifier/main.js +4 -0
  41. data/spec/fixtures/minitest/packages/uglyduck/package.json +21 -0
  42. data/spec/fixtures/{optparse-1.0.1.spd → optparse-1.0.1.bpkg} +0 -0
  43. data/spec/fixtures/{rake-0.8.6.spd → rake-0.8.6.bpkg} +0 -0
  44. data/spec/fixtures/{rake-0.8.7.spd → rake-0.8.7.bpkg} +0 -0
  45. data/spec/fixtures/{spade-0.5.0.spd → spade-0.5.0.bpkg} +0 -0
  46. data/spec/fixtures/transporter/packages/transport/lib/main.js +1 -0
  47. data/spec/fixtures/transporter/packages/transport/package.json +1 -1
  48. data/spec/fixtures/transporter/packages/transport/transports/wrapper.js +5 -0
  49. data/spec/gauntlet_spec.rb +2 -2
  50. data/spec/package_spec.rb +3 -3
  51. data/spec/pipeline_spec.rb +175 -54
  52. data/spec/project_spec.rb +19 -3
  53. data/spec/support/fake_gem_server.rb +4 -4
  54. data/templates/init/project.json +3 -1
  55. data/templates/project/index.html +1 -1
  56. data/vendor/sprockets/.gitignore +7 -0
  57. data/vendor/sprockets/.travis.yml +6 -0
  58. data/vendor/sprockets/Gemfile +8 -0
  59. data/vendor/sprockets/LICENSE +20 -0
  60. data/vendor/sprockets/README.md +22 -0
  61. data/vendor/sprockets/Rakefile +8 -0
  62. data/vendor/sprockets/lib/sprockets/asset.rb +203 -0
  63. data/vendor/sprockets/lib/sprockets/asset_attributes.rb +161 -0
  64. data/vendor/sprockets/lib/sprockets/base.rb +147 -0
  65. data/vendor/sprockets/lib/sprockets/bundled_asset.rb +222 -0
  66. data/vendor/sprockets/lib/sprockets/cache/file_store.rb +41 -0
  67. data/vendor/sprockets/lib/sprockets/caching.rb +121 -0
  68. data/vendor/sprockets/lib/sprockets/charset_normalizer.rb +41 -0
  69. data/vendor/sprockets/lib/sprockets/context.rb +191 -0
  70. data/vendor/sprockets/lib/sprockets/digest.rb +73 -0
  71. data/vendor/sprockets/lib/sprockets/directive_processor.rb +380 -0
  72. data/vendor/sprockets/lib/sprockets/eco_template.rb +39 -0
  73. data/vendor/sprockets/lib/sprockets/ejs_template.rb +38 -0
  74. data/vendor/sprockets/lib/sprockets/engines.rb +92 -0
  75. data/vendor/sprockets/lib/sprockets/environment.rb +93 -0
  76. data/vendor/sprockets/lib/sprockets/errors.rb +17 -0
  77. data/vendor/sprockets/lib/sprockets/index.rb +80 -0
  78. data/vendor/sprockets/lib/sprockets/jst_processor.rb +26 -0
  79. data/vendor/sprockets/lib/sprockets/processing.rb +310 -0
  80. data/vendor/sprockets/lib/sprockets/processor.rb +32 -0
  81. data/vendor/sprockets/lib/sprockets/safety_colons.rb +28 -0
  82. data/vendor/sprockets/lib/sprockets/server.rb +270 -0
  83. data/vendor/sprockets/lib/sprockets/static_asset.rb +87 -0
  84. data/vendor/sprockets/lib/sprockets/static_compilation.rb +82 -0
  85. data/vendor/sprockets/lib/sprockets/trail.rb +122 -0
  86. data/vendor/sprockets/lib/sprockets/utils.rb +67 -0
  87. data/vendor/sprockets/lib/sprockets/version.rb +3 -0
  88. data/vendor/sprockets/lib/sprockets.rb +31 -0
  89. data/vendor/sprockets/sprockets.gemspec +30 -0
  90. data/vendor/sprockets/test/fixtures/asset/POW.png +0 -0
  91. data/vendor/sprockets/test/fixtures/asset/application.js +6 -0
  92. data/vendor/sprockets/test/fixtures/asset/bar-utf8.css +2 -0
  93. data/vendor/sprockets/test/fixtures/asset/charset.css +2 -0
  94. data/vendor/sprockets/test/fixtures/asset/circle/a.js +2 -0
  95. data/vendor/sprockets/test/fixtures/asset/circle/b.js +2 -0
  96. data/vendor/sprockets/test/fixtures/asset/circle/c.js +2 -0
  97. data/vendor/sprockets/test/fixtures/asset/compat.js +4 -0
  98. data/vendor/sprockets/test/fixtures/asset/constants.js +2 -0
  99. data/vendor/sprockets/test/fixtures/asset/constants.yml +1 -0
  100. data/vendor/sprockets/test/fixtures/asset/default_mime_type.js +1 -0
  101. data/vendor/sprockets/test/fixtures/asset/filename.js.erb +1 -0
  102. data/vendor/sprockets/test/fixtures/asset/foo-utf8.css +2 -0
  103. data/vendor/sprockets/test/fixtures/asset/included_header.js +4 -0
  104. data/vendor/sprockets/test/fixtures/asset/jquery.tmpl.min.js +1 -0
  105. data/vendor/sprockets/test/fixtures/asset/mismatch.js +1 -0
  106. data/vendor/sprockets/test/fixtures/asset/multiple.js +2 -0
  107. data/vendor/sprockets/test/fixtures/asset/multipleengine.js +1 -0
  108. data/vendor/sprockets/test/fixtures/asset/noengine.js +1 -0
  109. data/vendor/sprockets/test/fixtures/asset/noformat.coffee +1 -0
  110. data/vendor/sprockets/test/fixtures/asset/one.css +1 -0
  111. data/vendor/sprockets/test/fixtures/asset/oneengine.js +1 -0
  112. data/vendor/sprockets/test/fixtures/asset/project.css +1 -0
  113. data/vendor/sprockets/test/fixtures/asset/project.js.erb +4 -0
  114. data/vendor/sprockets/test/fixtures/asset/relative/include.js +4 -0
  115. data/vendor/sprockets/test/fixtures/asset/relative/require.js +1 -0
  116. data/vendor/sprockets/test/fixtures/asset/relative/require_outside_path.js +1 -0
  117. data/vendor/sprockets/test/fixtures/asset/require_self.css +9 -0
  118. data/vendor/sprockets/test/fixtures/asset/require_self_twice.css +8 -0
  119. data/vendor/sprockets/test/fixtures/asset/semicolons/bar.js +1 -0
  120. data/vendor/sprockets/test/fixtures/asset/semicolons/index.js +5 -0
  121. data/vendor/sprockets/test/fixtures/asset/sprite.css.erb +12 -0
  122. data/vendor/sprockets/test/fixtures/asset/tree/all/b/c/d.js +2 -0
  123. data/vendor/sprockets/test/fixtures/asset/tree/all/b/c/e.js +1 -0
  124. data/vendor/sprockets/test/fixtures/asset/tree/all/b/c.js +1 -0
  125. data/vendor/sprockets/test/fixtures/asset/tree/all/b.css +2 -0
  126. data/vendor/sprockets/test/fixtures/asset/tree/all/b.js.erb +1 -0
  127. data/vendor/sprockets/test/fixtures/asset/tree/all/d/c.js.coffee +1 -0
  128. data/vendor/sprockets/test/fixtures/asset/tree/all/d/e.js +1 -0
  129. data/vendor/sprockets/test/fixtures/asset/tree/all_with_require.js +7 -0
  130. data/vendor/sprockets/test/fixtures/asset/tree/all_with_require_directory.js +1 -0
  131. data/vendor/sprockets/test/fixtures/asset/tree/all_with_require_tree.js +2 -0
  132. data/vendor/sprockets/test/fixtures/asset/tree/directory/application.js +2 -0
  133. data/vendor/sprockets/test/fixtures/asset/tree/directory/bar.js +1 -0
  134. data/vendor/sprockets/test/fixtures/asset/tree/directory/foo.js +1 -0
  135. data/vendor/sprockets/test/fixtures/asset/tree/tree/application.js +2 -0
  136. data/vendor/sprockets/test/fixtures/asset/tree/tree/bar.js +1 -0
  137. data/vendor/sprockets/test/fixtures/asset/tree/tree/foo.js +1 -0
  138. data/vendor/sprockets/test/fixtures/asset/tree/with_logical_path/a/a.js +1 -0
  139. data/vendor/sprockets/test/fixtures/asset/tree/with_logical_path/require_tree_with_logical_path.js +1 -0
  140. data/vendor/sprockets/test/fixtures/asset/tree/without_argument/a.js +1 -0
  141. data/vendor/sprockets/test/fixtures/asset/tree/without_argument/b.js +1 -0
  142. data/vendor/sprockets/test/fixtures/asset/tree/without_argument/require_tree_without_argument.js +1 -0
  143. data/vendor/sprockets/test/fixtures/asset/two.css +1 -0
  144. data/vendor/sprockets/test/fixtures/asset/unicode.js +2 -0
  145. data/vendor/sprockets/test/fixtures/asset/unknownexts.min.js +2 -0
  146. data/vendor/sprockets/test/fixtures/asset/users.js.erb.str +4 -0
  147. data/vendor/sprockets/test/fixtures/context/POW.png +0 -0
  148. data/vendor/sprockets/test/fixtures/context/application.js.yml +3 -0
  149. data/vendor/sprockets/test/fixtures/context/bar.js +1 -0
  150. data/vendor/sprockets/test/fixtures/context/foo.js +2 -0
  151. data/vendor/sprockets/test/fixtures/context/helpers.css.erb +3 -0
  152. data/vendor/sprockets/test/fixtures/context/properties.js.erb +7 -0
  153. data/vendor/sprockets/test/fixtures/context/require_glob.js +1 -0
  154. data/vendor/sprockets/test/fixtures/context/resolve_content_type.js.erb +4 -0
  155. data/vendor/sprockets/test/fixtures/context/sprite.css.embed +3 -0
  156. data/vendor/sprockets/test/fixtures/default/application.js.coffee +4 -0
  157. data/vendor/sprockets/test/fixtures/default/coffee/foo.coffee +1 -0
  158. data/vendor/sprockets/test/fixtures/default/coffee/index.js +3 -0
  159. data/vendor/sprockets/test/fixtures/default/empty +0 -0
  160. data/vendor/sprockets/test/fixtures/default/gallery.css.erb +3 -0
  161. data/vendor/sprockets/test/fixtures/default/gallery.js +1 -0
  162. data/vendor/sprockets/test/fixtures/default/goodbye.jst.eco +1 -0
  163. data/vendor/sprockets/test/fixtures/default/hello.jst.ejs +1 -0
  164. data/vendor/sprockets/test/fixtures/default/hello.txt +1 -0
  165. data/vendor/sprockets/test/fixtures/default/interpolation.js +1 -0
  166. data/vendor/sprockets/test/fixtures/default/missing_require.js +1 -0
  167. data/vendor/sprockets/test/fixtures/default/mobile/a.js +1 -0
  168. data/vendor/sprockets/test/fixtures/default/mobile/b.js +1 -0
  169. data/vendor/sprockets/test/fixtures/default/mobile/c.css +1 -0
  170. data/vendor/sprockets/test/fixtures/default/mobile/d.css +1 -0
  171. data/vendor/sprockets/test/fixtures/default/mobile/index.css +3 -0
  172. data/vendor/sprockets/test/fixtures/default/mobile/index.js +1 -0
  173. data/vendor/sprockets/test/fixtures/default/noreturn.js +1 -0
  174. data/vendor/sprockets/test/fixtures/default/project.js.coffee.erb +2 -0
  175. data/vendor/sprockets/test/fixtures/directives/code_before_comment +3 -0
  176. data/vendor/sprockets/test/fixtures/directives/comment_without_directives +6 -0
  177. data/vendor/sprockets/test/fixtures/directives/directive_word_splitting +6 -0
  178. data/vendor/sprockets/test/fixtures/directives/directives_after_header +16 -0
  179. data/vendor/sprockets/test/fixtures/directives/double_slash +9 -0
  180. data/vendor/sprockets/test/fixtures/directives/hash +8 -0
  181. data/vendor/sprockets/test/fixtures/directives/no_header +2 -0
  182. data/vendor/sprockets/test/fixtures/directives/slash_star +10 -0
  183. data/vendor/sprockets/test/fixtures/directives/slash_star_single +4 -0
  184. data/vendor/sprockets/test/fixtures/directives/space_between_directive_word +2 -0
  185. data/vendor/sprockets/test/fixtures/directives/triple_hash +10 -0
  186. data/vendor/sprockets/test/fixtures/encoding/ascii.js +1 -0
  187. data/vendor/sprockets/test/fixtures/encoding/ascii_utf8.js +2 -0
  188. data/vendor/sprockets/test/fixtures/encoding/utf16.js +0 -0
  189. data/vendor/sprockets/test/fixtures/encoding/utf8.js +1 -0
  190. data/vendor/sprockets/test/fixtures/encoding/utf8_bom.js +1 -0
  191. data/vendor/sprockets/test/fixtures/engines/hello.alert +1 -0
  192. data/vendor/sprockets/test/fixtures/engines/moo.js.str +1 -0
  193. data/vendor/sprockets/test/fixtures/public/compiled-digest-0aa2105d29558f3eb790d411d7d8fb66.js +3 -0
  194. data/vendor/sprockets/test/fixtures/public/compiled-digest-1c41eb0cf934a0c76babe875f982f9d1.js +1 -0
  195. data/vendor/sprockets/test/fixtures/server/app/javascripts/application.js +5 -0
  196. data/vendor/sprockets/test/fixtures/server/app/javascripts/bar.js +1 -0
  197. data/vendor/sprockets/test/fixtures/server/app/javascripts/foo.js +1 -0
  198. data/vendor/sprockets/test/fixtures/server/app/javascripts/hello.txt +2 -0
  199. data/vendor/sprockets/test/fixtures/server/app/javascripts/tree.js +1 -0
  200. data/vendor/sprockets/test/fixtures/server/vendor/javascripts/missing_require.js +1 -0
  201. data/vendor/sprockets/test/fixtures/server/vendor/stylesheets/missing_require.css +1 -0
  202. data/vendor/sprockets/test/sprockets_test.rb +56 -0
  203. data/vendor/sprockets/test/test_asset.rb +593 -0
  204. data/vendor/sprockets/test/test_asset_attributes.rb +86 -0
  205. data/vendor/sprockets/test/test_caching.rb +62 -0
  206. data/vendor/sprockets/test/test_context.rb +115 -0
  207. data/vendor/sprockets/test/test_directive_processor.rb +124 -0
  208. data/vendor/sprockets/test/test_encoding.rb +65 -0
  209. data/vendor/sprockets/test/test_engines.rb +73 -0
  210. data/vendor/sprockets/test/test_environment.rb +610 -0
  211. data/vendor/sprockets/test/test_server.rb +227 -0
  212. metadata +258 -54
  213. data/spec/fixtures/transporter/packages/transport/lib/wrapper.js +0 -5
data/.gitmodules CHANGED
@@ -0,0 +1,3 @@
1
+ [submodule "vendor/sprockets"]
2
+ path = vendor/sprockets
3
+ url = git://github.com/sstephenson/sprockets.git
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 "sprockets"
25
- s.add_dependency "spade"
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(/^ \w+ ([^\s]+) .+$/,'\1')
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 => ">= 0", :aliases => ['-v'], :desc => 'Specify a version to install'
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.size.zero?
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] != '>= 0'
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
- vers = options[:prerelease] ? '>= 0-pre' : '>= 0'
79
- package_names.each { |name| deps[name] = vers }
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
- # rescue Exception => e
89
- # abort e.message
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 && template_path).run
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
- dep = LibGems::Dependency.new(pkg_name)
339
- installed = LibGems.source_index.search(dep)
340
- if installed.empty?
341
- installed = BPM::Remote.new.install(pkg_name)
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 /spd$/
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 =~ /spd$/
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 spd #{spec.full_name}" if LibGems.configuration.really_verbose
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]*.spd")].each do |gem_file|
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 spd, and
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 = "spd"
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
- if project.local_deps.size > 0
24
- manifest = project.local_deps.map do |x|
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
- project.local_deps.map do |pkg|
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
- raise "#{pkg.name} depends on #{transport_plugins.size} packages that define transport plugins. Select a plugin by adding a `plugin:transport` property to the package.json"
14
- elsif transport_plugins.size == 1
15
- transport_module = transport_plugins.first
16
-
17
- transport_path = context.resolve project.path_from_module(transport_module)
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
- ctx = context.environment.js_context_for transport_path
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
- wrapped = ctx.eval "exports.compileTransport(DATA, PACKAGE_INFO, '#{module_id}');"
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
- require 'v8'
88
-
89
- ctx = V8::Context.new do |ctx|
90
- ctx['exports'] = {}
91
- ctx.eval "(function(exports) { #{File.read path} })(exports);"
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
- json_path = File.join path, "#{File.basename(path)}.json"
13
- json = JSON.load(File.read(json_path)) rescue nil
14
- return json && json["bpm"] && json_path
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 root_path, "#{@name}.json"
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
- core_fetch_dependencies(dependencies, :runtime, verbose)
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
- return root_path if package_name == self.name
154
- path = local_deps.find { |pkg| pkg.name == package_name }
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
- # TODO: Why are we fetching even if we already have it? Are we looking for newer versions?
318
- installed = BPM::Remote.new.install(package_name, vers, prerelease)
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
@@ -37,6 +37,11 @@ module BPM
37
37
  map '/assets' do
38
38
  run BPM::Trial.new(BPM::Pipeline.new cur_project)
39
39
  end
40
+
41
+ map '/' do
42
+ run Rack::Directory.new cur_project.root_path
43
+ end
44
+
40
45
  end.to_app
41
46
  end
42
47
 
data/lib/bpm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module BPM
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/bpm.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'vendored_sprockets'
2
+
1
3
  module BPM
2
4
  BPM_DIR = ".bpm"
3
5
  TEMPLATES_DIR = File.expand_path("../../templates", __FILE__)
@@ -0,0 +1,7 @@
1
+ if defined?(Sprockets)
2
+ warn "Sprockets has already been required. " +
3
+ "This may cause BPM to malfunction in unexpected ways."
4
+ end
5
+ $:.unshift File.expand_path('../../vendor/sprockets/lib', __FILE__)
6
+ require 'sprockets'
7
+