bpm 1.0.0.rc.3 → 1.0.0.rc.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -41,6 +41,9 @@ Install via RubyGems:
41
41
 
42
42
  `gem install bpm --pre`
43
43
 
44
+ WARNING: Make sure you have the most recent version of RubyGems and the
45
+ most recent version of RVM if you are using that.
46
+
44
47
  When we release, bpm will be also be available via PKG and EXE installers as well.
45
48
 
46
49
  # Current Development Status
data/lib/bpm/cli/base.rb CHANGED
@@ -12,20 +12,63 @@ module BPM
12
12
  :aliases => ['-V'],
13
13
  :desc => 'Show additional debug information while running'
14
14
 
15
- def self.help(shell, subcommand = false)
16
- shell.say "\nbpm (v#{BPM::VERSION}) - the browser package manager\n\n"
17
- super shell, subcommand
18
- end
15
+ class << self
16
+
17
+ def help(shell, subcommand = false)
18
+ shell.say <<LONGDESC
19
+ bpm (v#{BPM::VERSION}) - the browser package manager
20
+
21
+ BPM is a tool for aiding in development of JavaScript-based web applications.
22
+ It manages dependencies, custom file formats, minification and more.
23
+
24
+ Sample Usage:
25
+
26
+ bpm init my_app
27
+ cd my_app
28
+ bpm add my_dependency
29
+ bpm preview
19
30
 
20
- def self.start(given_args=ARGV, config={})
21
- if given_args.include?('--verbose') || given_args.include?('-V')
22
- BPM.show_deprecations = true
31
+ LONGDESC
32
+
33
+ super shell, subcommand
34
+ end
35
+
36
+ # Hacked so long description isn't wrapped
37
+ def task_help(shell, task_name)
38
+ meth = normalize_task_name(task_name)
39
+ task = all_tasks[meth]
40
+ handle_no_task_error(meth) unless task
41
+
42
+ shell.say "Usage:"
43
+ shell.say " #{banner(task)}"
44
+ shell.say
45
+ class_options_help(shell, nil => task.options.map { |_, o| o })
46
+ if task.long_description
47
+ shell.say "Description:"
48
+ shell.print_wrapped(task.long_description, :ident => 2)
49
+ else
50
+ shell.say task.description
51
+ end
23
52
  end
24
53
 
25
- super
54
+ def start(given_args=ARGV, config={})
55
+ if given_args.include?('--verbose') || given_args.include?('-V')
56
+ BPM.show_deprecations = true
57
+ end
58
+
59
+ super
26
60
 
27
- if BPM.deprecation_count > 0
28
- puts "[WARN] #{BPM.deprecation_count} deprecation warnings were hidden. Run with --verbose to see them."
61
+ if BPM.deprecation_count > 0
62
+ puts "[WARN] #{BPM.deprecation_count} deprecation warnings were hidden. Run with --verbose to see them."
63
+ end
64
+ end
65
+ end
66
+
67
+ def help(*args)
68
+ if args.first == "owner"
69
+ CLI::Owner.start( [ "help" ] + args[1..-1] )
70
+ else
71
+ super
29
72
  end
30
73
  end
31
74
 
@@ -33,10 +76,19 @@ module BPM
33
76
  subcommand "owner", BPM::CLI::Owner
34
77
 
35
78
  desc "fetch [PACKAGE]", "Fetch one or many bpm packages to local cache"
79
+ long_desc <<-LONGDESC
80
+ Fetch one or many bpm packages to local cache.
81
+
82
+ If no packages are specified, BPM will use the current project.
83
+
84
+ Note: This command is used internally and should not normally need to be called directly.
85
+ LONGDESC
36
86
  method_option :version, :type => :string, :default => ">= 0", :aliases => ['-v'], :desc => 'Specify a version to install'
37
87
  method_option :prerelease, :type => :boolean, :default => false, :aliases => ['--pre'], :desc => 'Install a prerelease version'
88
+ method_option :project, :type => :string, :default => nil, :aliases => ['-p'], :desc => 'Specify project location other than working directory'
89
+ method_option :package, :type => :boolean, :default => false, :desc => "Fetch for a package, instead of a project"
38
90
  def fetch(*packages)
39
- project = BPM::Project.nearest_project(Dir.pwd) if packages.empty?
91
+ project = find_project(false) if packages.empty?
40
92
  if project
41
93
  success = project.fetch_dependencies options[:verbose]
42
94
  if !success
@@ -66,19 +118,35 @@ module BPM
66
118
  end
67
119
 
68
120
 
69
- desc "fetched [PACKAGE]", "Display locally fetched bpm packages"
121
+ desc "fetched [PACKAGE]", "Displays a list of locally cached BPM packages"
70
122
  def fetched(*packages)
71
123
  local = BPM::Local.new
72
124
  index = local.installed(packages)
73
125
  print_specs(packages, index)
74
126
  end
75
127
 
76
- desc "add [PACKAGE]", "Add one or more packages to a bpm project"
77
- method_option :version, :type => :string, :default => nil, :aliases => ['-v'], :desc => 'Specify a version to install'
78
- method_option :project, :type => :string, :default => nil, :aliases => ['-p'], :desc => 'Specify project location other than working directory'
79
- method_option :prerelease, :type => :boolean, :default => false, :aliases => ['--pre'], :desc => 'Install a prerelease version'
128
+ desc "add [PACKAGE]", "Add one or more dependencies to a bpm project"
129
+ long_desc <<-LONGDESC
130
+ Adds one or more dependencies to a bpm project.
131
+
132
+ It first fetches the dependency from getbpm.org (or uses the locally vendored version)
133
+ and then adds it to your project's JSON config.
134
+
135
+ If multiple package names are passed they will all be added.
136
+
137
+ Run with --pre to install a prerelease version of your package.
138
+
139
+ Run with --version to specify a specific package version other than
140
+ the most recent.
141
+
142
+ To remove a dependency just run `bpm remove`.
143
+ LONGDESC
144
+ method_option :version, :type => :string, :default => nil, :aliases => ['-v'], :desc => 'Specify a version to install'
145
+ method_option :project, :type => :string, :default => nil, :aliases => ['-p'], :desc => 'Specify project location other than working directory'
146
+ method_option :prerelease, :type => :boolean, :default => false, :aliases => ['--pre'], :desc => 'Install a prerelease version'
80
147
  method_option :development, :type => :boolean, :default => false, :aliases => ['--dev'], :desc => "Add as a development dependency"
81
- method_option :mode, :type => :string, :default => :production, :aliases => ['-m'], :desc => "Build mode for compile"
148
+ method_option :mode, :type => :string, :default => :production, :aliases => ['-m'], :desc => "Build mode for compile"
149
+ method_option :package, :type => :boolean, :default => false, :desc => "Add to a package, instead of a project"
82
150
  def add(*package_names)
83
151
  # map to dependencies
84
152
  if package_names.empty?
@@ -106,9 +174,16 @@ module BPM
106
174
  project.build options[:mode], true
107
175
  end
108
176
 
109
- desc "remove [PACKAGE]", "Remove one or more packages from a bpm project"
110
- method_option :project, :type => :string, :default => nil, :aliases => ['-p'], :desc => 'Specify project location other than working directory'
111
- method_option :mode, :type => :string, :default => :production, :aliases => ['-m'], :desc => "Build mode for compile"
177
+ desc "remove [PACKAGE]", "Remove one or more dependencies from a BPM project"
178
+ long_desc <<-LONGDESC
179
+ Remove one or more dependencies from a BPM project.
180
+
181
+ This command will remove the dependency declaration from the project JSON.
182
+ It will then rebuild the project without the depedency.
183
+ LONGDESC
184
+ method_option :project, :type => :string, :default => nil, :aliases => ['-p'], :desc => 'Specify project location other than working directory'
185
+ method_option :mode, :type => :string, :default => :production, :aliases => ['-m'], :desc => "Build mode for compile"
186
+ method_option :package, :type => :boolean, :default => false, :desc => "Remove from a package, instead of a project"
112
187
  def remove(*package_names)
113
188
 
114
189
  # map to dependencies
@@ -122,20 +197,40 @@ module BPM
122
197
  project.build options[:mode], true
123
198
  end
124
199
 
125
- desc "preview", "Preview server that will autocompile assets as you request them. Useful for hacking"
126
- method_option :mode, :type => :string, :default => :debug, :aliases => ['-m'], :desc => 'Build mode for compile'
127
- method_option :project, :type => :string, :default => nil, :aliases => ['-p'], :desc => 'Specify project location other than working directory'
128
- method_option :port, :type => :string, :default => '4020', :desc => "Port to host server on"
200
+ desc "preview", "Preview server that autocompiles assets as they are requested"
201
+ long_desc <<-LONGDESC
202
+ Preview server that autocompiles assets as they are requested.
203
+
204
+ The primary use of `bpm preview` is that it is faster to use that `bpm rebuild`.
205
+ When developing with the preview server changes to your code are automatically
206
+ recognized and will be present when the page is reloaded.
207
+
208
+ Once you are satisfied with your project you will still need to run `bpm rebuild`
209
+ to save your updated assets to disk.
210
+ LONGDESC
211
+ method_option :mode, :type => :string, :default => :debug, :aliases => ['-m'], :desc => 'Build mode for compile'
212
+ method_option :project, :type => :string, :default => nil, :aliases => ['-p'], :desc => 'Specify project location other than working directory'
213
+ method_option :port, :type => :string, :default => '4020', :desc => "Port to host server on"
214
+ method_option :package, :type => :boolean, :default => false, :desc => "Preview a package, instead of a project"
129
215
  def preview
130
216
  project = find_project
131
217
  project.verify_and_repair options[:mode], options[:verbose]
132
218
  BPM::Server.start project, :Port => options[:port], :mode => options[:mode].to_sym
133
219
  end
134
220
 
135
- desc "rebuild", "Rebuilds bpm assets, does not update versions"
136
- method_option :mode, :type => :string, :default => :production, :aliases => ['-m'], :desc => 'Build mode for compile'
137
- method_option :project, :type => :string, :default => nil, :aliases => ['-p'], :desc => 'Specify project location other than working directory'
138
- method_option :update, :type => :boolean, :default => false, :aliases => ['-u'], :desc => 'Updates dependencies to latest compatible version'
221
+ desc "rebuild", "Rebuilds BPM assets"
222
+ long_desc <<-LONGDESC
223
+ Rebuilds BPM assets
224
+
225
+ `bpm rebuild` will rebuild all assets managed by BPM as declared in your project's
226
+ JSON config. This should always be run before deploying to the server. During active
227
+ development, consider using `bpm preview`. Though remember that you will have to run
228
+ `bpm rebuild` before deploying.
229
+ LONGDESC
230
+ method_option :mode, :type => :string, :default => :production, :aliases => ['-m'], :desc => 'Build mode for compile'
231
+ method_option :project, :type => :string, :default => nil, :aliases => ['-p'], :desc => 'Specify project location other than working directory'
232
+ method_option :update, :type => :boolean, :default => false, :aliases => ['-u'], :desc => 'Updates dependencies to latest compatible version'
233
+ method_option :package, :type => :boolean, :default => false, :desc => "Rebuild package, instead of a project"
139
234
  def rebuild
140
235
  find_project.fetch_dependencies(true) if options[:update]
141
236
  find_project.build options[:mode].to_sym, true
@@ -178,7 +273,14 @@ module BPM
178
273
  end
179
274
  end
180
275
 
181
- desc "push PACKAGE", "Distribute your bpm package"
276
+ desc "push PACKAGE", "Distribute your BPM package on GetBPM.org"
277
+ long_desc <<-LONGDESC
278
+ Distribute your BPM package on GetBPM.org
279
+
280
+ Pushes your package to GetBPM.org. You will need to run
281
+ `bpm pack` before you can run this command. You will also need
282
+ an account on GetBPM.org.
283
+ LONGDESC
182
284
  def push(package)
183
285
  remote = BPM::Remote.new
184
286
  if remote.logged_in?
@@ -188,7 +290,15 @@ module BPM
188
290
  end
189
291
  end
190
292
 
191
- desc "yank", "Remove a specific package version release from GetBPM.org"
293
+ desc "yank PACKAGE", "Remove a specific package version release from GetBPM.org"
294
+ long_desc <<-LONGDESC
295
+ Remove a specific package version release from GetBPM.org
296
+
297
+ This is useful if you have pushed a version in error or have discovered a serious bug.
298
+ Beware, however, that you cannot repush a version number. When you yank a package that
299
+ version number still remains active in the event that other pacakges depend on it. If
300
+ you need a package gone for good, please contact BPM support.
301
+ LONGDESC
192
302
  method_option :version, :type => :string, :default => nil, :aliases => ['-v'], :desc => 'Specify a version to yank'
193
303
  method_option :undo, :type => :boolean, :default => false, :desc => 'Unyank package'
194
304
  def yank(package)
@@ -209,14 +319,24 @@ module BPM
209
319
  end
210
320
 
211
321
  desc "list", "List BPM Packages"
322
+ long_desc <<-LONGDESC
323
+ List BPM Packages
324
+
325
+ By default this provides a list of all dependencies of the current project.
326
+
327
+ To see a list of all available BPM packages, run with --remote. Add --all to
328
+ see all possible (non-prerelease) versions and --pre to see prerelease versions.
329
+ LONGDESC
212
330
  method_option :remote, :type => :boolean, :default => false, :aliases => ['-r'],
213
331
  :desc => 'List packages on remote server'
214
332
  method_option :all, :type => :boolean, :default => false, :aliases => ['-a'],
215
- :desc => 'List all versions available (remote only)'
333
+ :desc => 'List all (non-prerelease) versions available (remote only)'
216
334
  method_option :prerelease, :type => :boolean, :default => false, :aliases => ['--pre'],
217
335
  :desc => 'List prerelease versions available (remote only)'
218
336
  method_option :development, :type => :boolean, :default => false, :aliases => ['--dev'],
219
337
  :desc => 'List development dependencies instead of runtime (local only)'
338
+ method_option :package, :type => :boolean, :default => false,
339
+ :desc => "List for a package, instead of a project"
220
340
  def list(*packages)
221
341
  if options[:remote]
222
342
  remote = BPM::Remote.new
@@ -235,10 +355,21 @@ module BPM
235
355
  end
236
356
  end
237
357
 
238
- desc "init [PATHS]", "Configure a project to use bpm for management"
239
- method_option :name, :type => :string, :default => nil, :desc => 'Specify a different name for the project'
358
+ desc "init [PATHS]", "Configure a project to use BPM for management"
359
+ long_desc <<-LONGDESC
360
+ Configure a project to use BPM for management
361
+
362
+ If the specified path does not exist it will be created with a basic BPM directory
363
+ structure. For existing directories, BPM does not create the full directory structure,
364
+ assuming that the current structure is adequate. In the event that you do want BPM to
365
+ create its full structure, pass --app.
366
+
367
+ By default, the app is given the same name as the directory it resides
368
+ in. If a different name is desired, pass the --name option.
369
+ LONGDESC
370
+ method_option :name, :type => :string, :default => nil, :desc => 'Specify a different name for the project'
240
371
  method_option :skip, :type => :boolean, :default => false, :desc => 'Skip any conflicting files'
241
- method_option :app, :type => :boolean, :default => false, :desc => 'Manage app files as well as packages. (Always true for new directories.)'
372
+ method_option :app, :type => :boolean, :default => false, :desc => 'Manage app files as well as packages. (Always true for new directories.)'
242
373
  #method_option :package, :type => :string, :default => nil, :desc => 'Specify a package template to build from'
243
374
  def init(*paths)
244
375
  paths = [Dir.pwd] if paths.empty?
@@ -271,7 +402,15 @@ module BPM
271
402
  end
272
403
  end
273
404
 
274
- desc "pack [PACKAGE]", "Build a bpm package from a package.json"
405
+ desc "pack [PACKAGE]", "Build a BPM package from a package.json"
406
+ long_desc <<-LONGDESC
407
+ Build a BPM package from a package.json
408
+
409
+ This provides a .bpkg file that can be distributed directly or via GetBPM.org.
410
+ If distributed directly, the package can be installed with `bpm add PACKAGE.bpkg`.
411
+ If using GetBPM.org, run `bpm push PACKAGE.bpkg` and it can then be installed
412
+ via a normal `bpm add NAME`.
413
+ LONGDESC
275
414
  method_option :email, :type => :string, :default => nil, :aliases => ['-e'], :desc => 'Specify an author email address'
276
415
  def pack(package_path=nil)
277
416
  package_path ||= Dir.pwd
@@ -289,7 +428,14 @@ module BPM
289
428
  end
290
429
  end
291
430
 
292
- desc "unpack [PACKAGE]", "Extract files from a bpm package"
431
+ desc "unpack [PACKAGE]", "Extract files from a BPM package"
432
+ long_desc <<-LONGDESC
433
+ Extract files from a BPM package
434
+
435
+ This is primarily useful for testing. If, for instance, a package
436
+ is not behaving as expected, it may be useful to unpack it to review
437
+ the contents.
438
+ LONGDESC
293
439
  method_option :target, :type => :string, :default => ".", :aliases => ['-t'], :desc => 'Unpack to given directory'
294
440
  def unpack(*paths)
295
441
  local = BPM::Local.new
@@ -305,7 +451,14 @@ module BPM
305
451
  end
306
452
  end
307
453
 
308
- desc "debug [OPTION]", "Display various options for debugging.\n build - Shows all project build settings\n repair - Verify and repair project"
454
+ desc "debug [OPTION]", "Display various options for debugging"
455
+ long_desc <<-LONGDESC
456
+ Display various options for debugging.
457
+
458
+ * build - Shows all project build settings
459
+
460
+ * repair - Verify and repair project
461
+ LONGDESC
309
462
  method_option :project, :type => :string, :default => nil, :aliases => ['-p'], :desc => 'Specify project location other than working directory'
310
463
  method_option :mode, :type => :string, :default => :debug, :aliases => ['-m'], :desc => 'Build mode'
311
464
  def debug(option)
@@ -361,18 +514,19 @@ module BPM
361
514
  self.class.handle_argument_error(self.class.tasks[name], nil)
362
515
  end
363
516
 
364
- def find_project
517
+ def find_project(required=true)
518
+ klass = options[:package] ? BPM::PackageProject : BPM::Project
365
519
  if options[:project]
366
520
  project_path = File.expand_path options[:project]
367
- if !BPM::Project.is_project_root?(project_path)
368
- abort "#{project_path} does not appear to be managed by bpm"
521
+ if required && !klass.is_project_root?(project_path)
522
+ abort "#{project_path} does not appear to be managed by BPM"
369
523
  else
370
- project = BPM::Project.new project_path
524
+ project = klass.new project_path
371
525
  end
372
526
  else
373
- project = BPM::Project.nearest_project Dir.pwd
374
- if project.nil?
375
- abort "You do not appear to be inside of a bpm project"
527
+ project = klass.nearest_project Dir.pwd
528
+ if required && project.nil?
529
+ abort "You do not appear to be inside of a BPM project"
376
530
  end
377
531
  end
378
532
 
data/lib/bpm/cli/owner.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  module BPM::CLI
2
2
  class Owner < Thor
3
- default_task :list
4
-
5
- desc "list [PACKAGE]", "Display owners of a package"
3
+ desc "owner list [PACKAGE]", "Display owners of a package"
6
4
  def list(package)
7
5
  remote = BPM::Remote.new
8
6
  if remote.logged_in?
@@ -22,7 +20,7 @@ module BPM::CLI
22
20
  end
23
21
  end
24
22
 
25
- desc "add [PACKAGE] [EMAIL]", "Allow another user to push new versions of your bpm package"
23
+ desc "owner add [PACKAGE] [EMAIL]", "Allow another user to push new versions of your BPM package"
26
24
  def add(package, email)
27
25
  remote = BPM::Remote.new
28
26
  if remote.logged_in?
@@ -32,7 +30,7 @@ module BPM::CLI
32
30
  end
33
31
  end
34
32
 
35
- desc "remove [PACKAGE] [EMAIL]", "Remove user's permission to push new versions of your bpm package"
33
+ desc "owner remove [PACKAGE] [EMAIL]", "Remove user's permission to push new versions of your BPM package"
36
34
  def remove(package, email)
37
35
  remote = BPM::Remote.new
38
36
  if remote.logged_in?
@@ -0,0 +1,23 @@
1
+ module BPM
2
+ class PackageProject < Project
3
+ def self.project_file_path(path)
4
+ file = File.join(path, 'package.json')
5
+ File.exist?(file) ? file : nil
6
+ end
7
+
8
+ def self.is_project_json?(path)
9
+ json = JSON.load(File.read(path)) rescue nil
10
+ return !!json
11
+ end
12
+
13
+ def self.is_project_root?(path)
14
+ !!project_file_path(path)
15
+ end
16
+
17
+ def as_json
18
+ json = super
19
+ json.delete("bpm")
20
+ json
21
+ end
22
+ end
23
+ end
data/lib/bpm/project.rb CHANGED
@@ -91,19 +91,15 @@ module BPM
91
91
 
92
92
  def vendored_packages
93
93
  @vendored_packages ||= begin
94
- # Packages path is deprecated
95
- packages_path = File.join(@root_path, 'packages')
96
- search_paths = [vendor_root, packages_path]
94
+ search_paths = [vendor_root, File.join(@root_path, 'packages')]
97
95
  paths = search_paths.map{|p| Dir.glob(File.join(p, '*')) }.flatten
98
96
  pkgs = paths.select{|p| Package.is_package_root?(p) }.map{|p| Package.new(p) }
99
- if pkgs.any?{|p| p.root_path =~ /^#{Regexp.escape(packages_path)}\// }
100
- BPM.deprecation_warning "Use the vendor directory instead of the packages directory for #{root_path}"
101
- end
102
97
  pkgs += vendored_projects.map{|p| p.vendored_packages }.flatten
103
98
  pkgs.select do |p|
104
99
  begin
105
100
  p.load_json
106
- rescue BPM::InvalidPackageError
101
+ rescue BPM::InvalidPackageError => e
102
+ raise e if ENV['DEBUG']
107
103
  false
108
104
  end
109
105
  end
data/lib/bpm/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module BPM
2
- VERSION = "1.0.0.rc.3"
2
+ VERSION = "1.0.0.rc.4"
3
3
  COMPAT_VERSION = '1.0.0'
4
4
  end
data/lib/bpm.rb CHANGED
@@ -14,6 +14,7 @@ module BPM
14
14
  autoload :Remote, 'bpm/remote'
15
15
  autoload :Repository, 'bpm/repository'
16
16
  autoload :Project, 'bpm/project'
17
+ autoload :PackageProject, 'bpm/package_project'
17
18
  autoload :Rack, 'bpm/rack'
18
19
  autoload :Server, 'bpm/server'
19
20
  autoload :Pipeline, 'bpm/pipeline'
data/spec/cli/add_spec.rb CHANGED
@@ -17,7 +17,7 @@ describe 'bpm add' do
17
17
  it "must be called from within a project" do
18
18
  cd home # outside of project
19
19
  bpm "add", "jquery", :track_stderr => true
20
- stderr.read.should include("inside of a bpm project")
20
+ stderr.read.should include("inside of a BPM project")
21
21
  end
22
22
 
23
23
  it "should add a new hard dependency" do
@@ -177,7 +177,7 @@ describe 'bpm add' do
177
177
  bpm "add", "custom_generator", "--dev" and wait
178
178
  output = stdout.read
179
179
  output.should include("Added development package 'custom_generator' (1.0)")
180
-
180
+
181
181
  bpm 'rebuild', '--mode=debug' and wait
182
182
  has_development_dependency 'custom_generator', '1.0'
183
183
  no_dependency 'custom_generator', false
@@ -188,7 +188,7 @@ describe 'bpm add' do
188
188
  end
189
189
 
190
190
  describe "bpm add using a vendor directory" do
191
- before do
191
+ before do
192
192
  goto_home
193
193
  set_host
194
194
  start_fake(FakeGemServer.new)
@@ -197,12 +197,27 @@ describe "bpm add using a vendor directory" do
197
197
  FileUtils.cp_r project_fixture('hello_world'), home('hello_dev', 'vendor', 'hello_world')
198
198
  cd home('hello_dev')
199
199
  end
200
-
200
+
201
201
  it "should include custom_package defined in a project found vendor" do
202
202
  bpm 'add', 'custom_package' and wait
203
-
203
+
204
204
  File.read(home('hello_dev', 'assets', 'bpm_libs.js')).should include("custom_package (2.0.0)")
205
205
  end
206
-
206
+
207
207
  end
208
208
 
209
+ describe "bpm add with a package" do
210
+ before do
211
+ goto_home
212
+ set_host
213
+ start_fake(FakeGemServer.new)
214
+ FileUtils.cp_r(package_fixture('spade'), '.')
215
+ cd home('spade')
216
+ end
217
+
218
+ it "should add dependency to package.json" do
219
+ File.read(home('spade', 'package.json')).should_not include('jquery')
220
+ bpm 'add', 'jquery', '--package' and wait
221
+ File.read(home('spade', 'package.json')).should include('jquery')
222
+ end
223
+ end
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
  require "json"
3
3
  describe 'bpm fetch' do
4
-
4
+
5
5
  before do
6
6
  goto_home
7
7
  FileUtils.cp_r(project_fixture('hello_world'), '.')
@@ -16,7 +16,7 @@ describe 'bpm fetch' do
16
16
  package_info = JSON.load File.read(home('hello_world', 'hello_world.json'))
17
17
  package_info['dependencies']['custom_package'] = '>= 0'
18
18
  File.open(home('hello_world', 'hello_world.json'), 'w+') { |fd| fd << package_info.to_json }
19
-
19
+
20
20
  bpm "fetch", '--verbose'
21
21
  out = stdout.read
22
22
  out.should include("Fetched dependent packages for hello_world")
@@ -28,7 +28,7 @@ describe 'bpm fetch' do
28
28
  package_name.should be_fetched
29
29
  package_name.should be_unpacked
30
30
  end
31
-
31
+
32
32
  end
33
33
 
34
34
  it "fetches a valid package" do
@@ -141,3 +141,19 @@ describe 'bpm fetch' do
141
141
  end
142
142
 
143
143
  end
144
+
145
+ describe "bpm fetch with a package" do
146
+ before do
147
+ goto_home
148
+ set_host
149
+ start_fake(FakeGemServer.new)
150
+ FileUtils.cp_r(package_fixture('coffee-1.0.1.pre'), '.')
151
+ cd home('coffee-1.0.1.pre')
152
+ end
153
+
154
+ it "should fetch dependencies" do
155
+ "jquery-1.4.3".should_not be_fetched
156
+ bpm 'fetch', '--package' and wait
157
+ "jquery-1.4.3".should be_fetched
158
+ end
159
+ end
@@ -13,21 +13,21 @@ describe "bpm list" do
13
13
  cd home('hello_world')
14
14
  bpm 'fetch' and wait # make sure rebuild step doesn't run
15
15
  end
16
-
16
+
17
17
  it "lists non-development dependencies by default" do
18
18
  bpm "list"
19
19
  output = stdout.read
20
20
  output.should include("ivory (0.0.1)")
21
21
  output.should_not include("jquery (1.4.3)")
22
22
  end
23
-
23
+
24
24
  it "lists development dependencies with --dev option" do
25
25
  bpm "list", "--dev"
26
26
  output = stdout.read
27
27
  output.should_not include("ivory (0.0.1)")
28
28
  output.should include("jquery (1.4.3)")
29
29
  end
30
-
30
+
31
31
  it "should filter output by package name" do
32
32
  bpm "list", "ivory", "spade"
33
33
  output = stdout.read
@@ -36,81 +36,96 @@ describe "bpm list" do
36
36
  output.should_not include("optparse")
37
37
  output.should_not include("core-test")
38
38
  end
39
-
39
+
40
40
  it "should complain when called outside of a project" do
41
41
  cd home
42
42
  bpm "list", :track_stderr => true
43
- stderr.read.should include("inside of a bpm project")
43
+ stderr.read.should include("inside of a BPM project")
44
44
  end
45
-
45
+
46
46
  end
47
-
47
+
48
48
  describe "remote" do
49
-
49
+
50
50
  it "lists latest packages by default" do
51
51
  bpm "list", "--remote"
52
-
52
+
53
53
  output = stdout.read
54
54
  output.should include("builder (3.0.0)")
55
55
  output.should include("rake (0.8.7)")
56
56
  end
57
-
57
+
58
58
  it "lists all packages when given the all argument" do
59
59
  bpm "list", "--remote", "-a"
60
-
60
+
61
61
  output = stdout.read
62
62
  output.should include("builder (3.0.0)")
63
63
  output.should include("rake (0.8.7, 0.8.6)")
64
64
  end
65
-
65
+
66
66
  it "filters packages when given an argument" do
67
67
  bpm "list", "builder", "--remote"
68
-
68
+
69
69
  output = stdout.read
70
70
  output.should include("builder (3.0.0)")
71
71
  output.should_not include("rake")
72
72
  end
73
-
73
+
74
74
  it "filters packages when given an argument and shows all versions" do
75
75
  bpm "list", "rake", "-a", "--remote"
76
-
76
+
77
77
  output = stdout.read
78
78
  output.should include("rake (0.8.7, 0.8.6)")
79
79
  output.should_not include("builder")
80
80
  end
81
-
81
+
82
82
  it "filters multiple packages" do
83
83
  bpm "list", "rake", "highline", "--remote"
84
-
84
+
85
85
  output = stdout.read
86
86
  output.should include("highline (1.6.1)")
87
87
  output.should include("rake (0.8.7)")
88
88
  output.should_not include("builder")
89
89
  end
90
-
90
+
91
91
  it "shows prerelease packages" do
92
92
  bpm "list", "--prerelease", "--remote"
93
-
93
+
94
94
  output = stdout.read
95
95
  output.should include("bundler (1.1.pre)")
96
96
  output.should_not include("highline")
97
97
  output.should_not include("rake")
98
98
  output.should_not include("builder")
99
99
  end
100
-
100
+
101
101
  it "says it couldn't find any if none found" do
102
102
  bpm "list", "rails", "--remote", :track_stderr => true
103
-
103
+
104
104
  stderr.read.strip.should == 'No packages found matching "rails".'
105
105
  exit_status.should_not be_success
106
106
  end
107
-
107
+
108
108
  it "says it couldn't find any if none found matching multiple packages" do
109
109
  bpm "list", "rails", "bake", "--remote", :track_stderr => true
110
-
110
+
111
111
  stderr.read.strip.should == 'No packages found matching "rails", "bake".'
112
112
  exit_status.should_not be_success
113
113
  end
114
114
  end
115
-
115
+
116
+ end
117
+
118
+ describe "bpm list with a package" do
119
+ before do
120
+ goto_home
121
+ set_host
122
+ start_fake(FakeGemServer.new)
123
+ FileUtils.cp_r(package_fixture('coffee-1.0.1.pre'), '.')
124
+ cd home('coffee-1.0.1.pre')
125
+ end
126
+
127
+ it "should list package dependencies" do
128
+ bpm 'list', '--package'
129
+ stdout.read.should include('jquery')
130
+ end
116
131
  end
@@ -106,9 +106,4 @@ describe "bpm owner with wrong arguments" do
106
106
  stderr.read.should include("called incorrectly")
107
107
  end
108
108
 
109
- it "requires a package name for list with default command" do
110
- bpm "owner", :track_stderr => true
111
-
112
- stderr.read.should include("called incorrectly")
113
- end
114
109
  end
@@ -8,3 +8,15 @@ describe "bpm preview" do
8
8
  # i.e. spade:format
9
9
 
10
10
  end
11
+
12
+ describe "bpm preview with a package" do
13
+ before do
14
+ goto_home
15
+ set_host
16
+ start_fake(FakeGemServer.new)
17
+ FileUtils.cp_r(package_fixture('spade'), '.')
18
+ cd home('spade')
19
+ end
20
+
21
+ it "should preview package"
22
+ end
@@ -2,31 +2,31 @@ require 'spec_helper'
2
2
  require 'json'
3
3
 
4
4
  describe 'bpm remove' do
5
-
5
+
6
6
  before do
7
7
  goto_home
8
8
  set_host
9
9
  start_fake(FakeGemServer.new)
10
10
  FileUtils.cp_r(project_fixture('hello_world'), '.')
11
11
  cd home('hello_world')
12
- bpm 'fetch' # make sure existing packages are installed
12
+ bpm 'fetch' # make sure existing packages are installed
13
13
  wait
14
14
  end
15
-
15
+
16
16
  it "should remove direct dependency from project" do
17
17
  bpm 'remove', 'spade'
18
-
18
+
19
19
  output = stdout.read
20
20
  output.should include("Removed package 'spade'")
21
-
21
+
22
22
  no_dependency 'spade'
23
23
  has_dependency 'core-test', '0.4.9', '0.4.9' # did not remove other dep
24
24
  end
25
-
25
+
26
26
  it "should remove soft dependencies" do
27
27
  bpm 'remove', 'core-test'
28
28
  wait
29
-
29
+
30
30
  output = stdout.read
31
31
  %w(core-test:0.4.9 ivory:0.0.1 optparse:1.0.1).each do |line|
32
32
  pkg_name, pkg_vers = line.split ':'
@@ -34,50 +34,70 @@ describe 'bpm remove' do
34
34
  no_dependency pkg_name
35
35
  end
36
36
  end
37
-
37
+
38
38
  it "should remove soft dependencies only when they are no longer needed" do
39
39
  bpm 'add', 'ivory', '-v', '0.0.1', '--verbose' # make a hard dep
40
40
  wait
41
-
41
+
42
42
  bpm 'remove', 'core-test', '--verbose'
43
43
  wait
44
-
44
+
45
45
  output = stdout.read
46
46
  %w(core-test:0.4.9 optparse:1.0.1).each do |line|
47
47
  pkg_name, pkg_vers = line.split ':'
48
48
  output.should include("Removed package '#{pkg_name}'")
49
49
  no_dependency pkg_name
50
50
  end
51
-
51
+
52
52
  has_dependency 'ivory', '0.0.1', '0.0.1'
53
-
53
+
54
54
  bpm 'remove', 'ivory'
55
55
  wait
56
-
56
+
57
57
  no_dependency 'ivory'
58
-
58
+
59
59
  end
60
-
60
+
61
61
  it "should do nothing when passed a non-existant dependency" do
62
62
  bpm 'remove', 'fake', :track_stderr => true
63
63
  wait
64
-
64
+
65
65
  output = stderr.read
66
66
  output.should include("'fake' is not a dependency")
67
67
  end
68
-
68
+
69
69
  it "should not uninstall local packages" do
70
70
  bpm 'add', 'custom_package'
71
71
  wait
72
72
  has_dependency 'custom_package', '2.0.0'
73
-
73
+
74
74
  bpm 'remove', 'custom_package'
75
75
  output = stdout.read
76
-
76
+
77
77
  no_dependency 'custom_package'
78
78
  File.exists?(home('hello_world', 'vendor', 'custom_package', 'package.json')).should be_true
79
79
  end
80
-
80
+
81
81
  it "should remove development dependencies"
82
-
82
+
83
+ end
84
+
85
+ describe "bpm remove with a package" do
86
+ before do
87
+ goto_home
88
+ set_host
89
+ start_fake(FakeGemServer.new)
90
+ FileUtils.cp_r(package_fixture('coffee-1.0.1.pre'), '.')
91
+ cd home('coffee-1.0.1.pre')
92
+
93
+ bpm 'fetch', '--package'
94
+ wait
95
+ end
96
+
97
+ it "should remove dependency from package.json" do
98
+ File.read(home('coffee-1.0.1.pre', 'package.json')).should include('jquery')
99
+ bpm 'remove', 'jquery', '--package'
100
+ puts stdout.read
101
+ File.read(home('coffee-1.0.1.pre', 'package.json')).should_not include('jquery')
102
+ end
83
103
  end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ describe "BPM::PackageProject class" do
4
+ it "should accept packages as project root" do
5
+ BPM::PackageProject.is_project_root?(fixtures('packages', 'backbone')).should be_true
6
+ BPM::PackageProject.is_project_root?(fixtures('projects', 'hello_world')).should be_false
7
+ BPM::PackageProject.is_project_root?(fixtures('packages', 'non_existent')).should be_false
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc.3
4
+ version: 1.0.0.rc.4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-15 00:00:00.000000000Z
13
+ date: 2011-09-21 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: libgems
17
- requirement: &70174351642100 !ruby/object:Gem::Requirement
17
+ requirement: &70200804575440 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.1.3
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70174351642100
25
+ version_requirements: *70200804575440
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: gemcutter
28
- requirement: &70174351641560 !ruby/object:Gem::Requirement
28
+ requirement: &70200804574640 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.6.1
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70174351641560
36
+ version_requirements: *70200804574640
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: highline
39
- requirement: &70174351641000 !ruby/object:Gem::Requirement
39
+ requirement: &70200804574020 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.6.1
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70174351641000
47
+ version_requirements: *70200804574020
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: json_pure
50
- requirement: &70174351640500 !ruby/object:Gem::Requirement
50
+ requirement: &70200804573300 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.4.6
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *70174351640500
58
+ version_requirements: *70200804573300
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: thor
61
- requirement: &70174351639980 !ruby/object:Gem::Requirement
61
+ requirement: &70200804571720 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 0.14.3
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *70174351639980
69
+ version_requirements: *70200804571720
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: execjs
72
- requirement: &70174351639500 !ruby/object:Gem::Requirement
72
+ requirement: &70200804568840 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 1.2.4
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *70174351639500
80
+ version_requirements: *70200804568840
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: sprockets
83
- requirement: &70174351639020 !ruby/object:Gem::Requirement
83
+ requirement: &70200804567780 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ~>
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: 2.0.0
89
89
  type: :runtime
90
90
  prerelease: false
91
- version_requirements: *70174351639020
91
+ version_requirements: *70200804567780
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: eventmachine
94
- requirement: &70174351638520 !ruby/object:Gem::Requirement
94
+ requirement: &70200804566780 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ~>
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: 1.0.0.beta.4
100
100
  type: :runtime
101
101
  prerelease: false
102
- version_requirements: *70174351638520
102
+ version_requirements: *70200804566780
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: thin
105
- requirement: &70174351638040 !ruby/object:Gem::Requirement
105
+ requirement: &70200804565580 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ~>
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: '1.2'
111
111
  type: :runtime
112
112
  prerelease: false
113
- version_requirements: *70174351638040
113
+ version_requirements: *70200804565580
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: rspec
116
- requirement: &70174351637660 !ruby/object:Gem::Requirement
116
+ requirement: &70200804564680 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ! '>='
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: '0'
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *70174351637660
124
+ version_requirements: *70200804564680
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rack
127
- requirement: &70174351637080 !ruby/object:Gem::Requirement
127
+ requirement: &70200804563740 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ~>
@@ -132,7 +132,7 @@ dependencies:
132
132
  version: 1.3.2
133
133
  type: :development
134
134
  prerelease: false
135
- version_requirements: *70174351637080
135
+ version_requirements: *70200804563740
136
136
  description: Browser Package Manager
137
137
  email:
138
138
  - charles@sproutcore.com
@@ -167,6 +167,7 @@ files:
167
167
  - lib/bpm/libgems_ext/spec_fetcher.rb
168
168
  - lib/bpm/local.rb
169
169
  - lib/bpm/package.rb
170
+ - lib/bpm/package_project.rb
170
171
  - lib/bpm/pipeline.rb
171
172
  - lib/bpm/pipeline/directive_processor.rb
172
173
  - lib/bpm/pipeline/format_processor.rb
@@ -528,6 +529,7 @@ files:
528
529
  - spec/fixtures/projects/transporter/vendor/transport/transports/wrapper.js
529
530
  - spec/gauntlet_spec.rb
530
531
  - spec/package_pipeline_spec.rb
532
+ - spec/package_project_spec.rb
531
533
  - spec/package_spec.rb
532
534
  - spec/pipeline_spec.rb
533
535
  - spec/plugins/format_spec.rb
@@ -570,7 +572,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
570
572
  version: 1.3.1
571
573
  requirements: []
572
574
  rubyforge_project:
573
- rubygems_version: 1.8.6
575
+ rubygems_version: 1.8.10
574
576
  signing_key:
575
577
  specification_version: 3
576
578
  summary: Browser Package Manager
@@ -902,6 +904,7 @@ test_files:
902
904
  - spec/fixtures/projects/transporter/vendor/transport/transports/wrapper.js
903
905
  - spec/gauntlet_spec.rb
904
906
  - spec/package_pipeline_spec.rb
907
+ - spec/package_project_spec.rb
905
908
  - spec/package_spec.rb
906
909
  - spec/pipeline_spec.rb
907
910
  - spec/plugins/format_spec.rb