bpm 0.1.4 → 1.0.0.beta.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +20 -0
- data/README.md +1 -1
- data/TODO.md +90 -2
- data/bpm.gemspec +3 -3
- data/lib/bpm/cli/base.rb +103 -52
- data/lib/bpm/errors.rb +51 -0
- data/lib/bpm/init_generator.rb +1 -8
- data/lib/bpm/libgems_ext/libgems.rb +9 -0
- data/lib/bpm/local.rb +6 -11
- data/lib/bpm/package.rb +272 -178
- data/lib/bpm/pipeline/generated_asset.rb +88 -28
- data/lib/bpm/pipeline/plugin_asset.rb +8 -2
- data/lib/bpm/pipeline/source_url_processor.rb +16 -0
- data/lib/bpm/pipeline/transport_processor.rb +5 -3
- data/lib/bpm/pipeline.rb +33 -23
- data/lib/bpm/project.rb +492 -167
- data/lib/bpm/project_generator.rb +14 -1
- data/lib/bpm/remote.rb +6 -4
- data/lib/bpm/server.rb +4 -15
- data/lib/bpm/version.rb +2 -1
- data/lib/bpm.rb +2 -0
- data/man/bpm-add.1.ronn +22 -0
- data/man/bpm-build.1.ronn +22 -0
- data/man/bpm-compile.1.ronn +23 -0
- data/man/bpm-config.7.ronn +21 -0
- data/man/bpm-fetch.1.ronn +22 -0
- data/man/bpm-fetched.1.ronn +22 -0
- data/man/bpm-init.1.ronn +22 -0
- data/man/bpm-list.1.ronn +22 -0
- data/man/bpm-login.1.ronn +22 -0
- data/man/bpm-new.1.ronn +22 -0
- data/man/bpm-owner.1.ronn +22 -0
- data/man/bpm-preview.1.ronn +22 -0
- data/man/bpm-push.1.ronn +22 -0
- data/man/bpm-remove.1.ronn +22 -0
- data/man/bpm-unpack.1.ronn +22 -0
- data/man/bpm-yank.1.ronn +22 -0
- data/man/bpm.1.ronn +31 -0
- data/spec/cli/add_spec.rb +26 -7
- data/spec/cli/fetch_spec.rb +15 -6
- data/spec/cli/init_spec.rb +165 -25
- data/spec/cli/{build_spec.rb → pack_spec.rb} +9 -10
- data/spec/cli/push_spec.rb +4 -4
- data/spec/cli/rebuild_spec.rb +181 -0
- data/spec/cli/remove_spec.rb +3 -4
- data/spec/cli/unpack_spec.rb +6 -6
- data/spec/fixtures/gems/core-test-0.4.9.bpkg +0 -0
- data/spec/fixtures/{core-test-0.4.9.bpkg → gems/uglify-js-1.0.4.bpkg} +0 -0
- data/spec/fixtures/packages/core-test/extras/extra_file.html +3 -0
- data/spec/fixtures/packages/core-test/index.html +3 -0
- data/spec/fixtures/{core-test → packages/core-test}/package.json +9 -3
- data/spec/fixtures/packages/invalid_json/package.json +3 -0
- data/spec/fixtures/packages/uglify-js/README.html +825 -0
- data/spec/fixtures/packages/uglify-js/README.org +431 -0
- data/spec/fixtures/packages/uglify-js/bin/uglifyjs +305 -0
- data/spec/fixtures/packages/uglify-js/docstyle.css +75 -0
- data/spec/fixtures/packages/uglify-js/lib/parse-js.js +1 -0
- data/spec/fixtures/packages/uglify-js/lib/process.js +1 -0
- data/spec/fixtures/packages/uglify-js/lib/squeeze-more.js +1 -0
- data/spec/fixtures/packages/uglify-js/package.json +27 -0
- data/spec/fixtures/packages/uglify-js/plugins/minifier.js +6 -0
- data/spec/fixtures/packages/uglify-js/uglify-js.js +17 -0
- data/spec/fixtures/projects/hello2/README.md +21 -0
- data/{templates/init → spec/fixtures/projects/hello2}/assets/bpm_packages.js +6 -1
- data/{templates/init → spec/fixtures/projects/hello2}/assets/bpm_styles.css +1 -1
- data/spec/fixtures/projects/hello2/hello2.json +16 -0
- data/spec/fixtures/projects/hello2/index.html +13 -0
- data/spec/fixtures/projects/hello2/packages/a/lib/main.js +2 -0
- data/spec/fixtures/projects/hello2/packages/a/package.json +17 -0
- data/spec/fixtures/projects/hello2/packages/b/lib/main.js +2 -0
- data/spec/fixtures/projects/hello2/packages/b/package.json +17 -0
- data/spec/fixtures/projects/hello2/packages/c/lib/main.js +2 -0
- data/spec/fixtures/projects/hello2/packages/c/package.json +16 -0
- data/spec/fixtures/projects/hello_dev/LICENSE +19 -0
- data/spec/fixtures/projects/hello_dev/README.md +21 -0
- data/spec/fixtures/projects/hello_dev/app/main.js +6 -0
- data/spec/fixtures/projects/hello_dev/assets/bpm_libs.js +5 -0
- data/spec/fixtures/projects/hello_dev/assets/bpm_styles.css +6 -0
- data/spec/fixtures/projects/hello_dev/css/main.css +1 -0
- data/spec/fixtures/projects/hello_dev/hello_dev.json +25 -0
- data/spec/fixtures/projects/hello_dev/index.html +14 -0
- data/spec/fixtures/projects/hello_dev/packages/style_package/css/some_style.css +3 -0
- data/spec/fixtures/{minitest/minitest.json → projects/hello_dev/packages/style_package/package.json} +5 -9
- data/spec/fixtures/projects/hello_world/LICENSE +19 -0
- data/spec/fixtures/projects/hello_world/assets/bpm_packages.js +1 -0
- data/spec/fixtures/projects/hello_world/assets/bpm_styles.css +1 -0
- data/spec/fixtures/projects/hello_world/custom_dir/custom.js +1 -0
- data/spec/fixtures/projects/hello_world/hello_world.json +41 -0
- data/spec/fixtures/projects/hello_world/lib/another.js +1 -0
- data/spec/fixtures/{hello_world → projects/hello_world}/packages/custom_package/package.json +5 -2
- data/spec/fixtures/projects/hello_world/vendor/lib/something.js +1 -0
- data/spec/fixtures/projects/init_app/assets/bpm_libs.js +6 -0
- data/spec/fixtures/projects/init_app/assets/bpm_styles.css +5 -0
- data/spec/fixtures/projects/init_app/assets/new_project/bpm_libs.js +6 -0
- data/spec/fixtures/projects/init_app/assets/new_project/bpm_styles.css +5 -0
- data/spec/fixtures/projects/init_app/new_project.json +27 -0
- data/spec/fixtures/projects/init_default/assets/bpm_libs.js +6 -0
- data/spec/fixtures/projects/init_default/assets/bpm_styles.css +5 -0
- data/spec/fixtures/projects/init_default/new_project.json +15 -0
- data/spec/fixtures/projects/minitest/minitest.json +26 -0
- data/spec/fixtures/{minitest → projects/minitest}/packages/uglyduck/package.json +1 -1
- data/spec/fixtures/projects/needs_rake/needs_rake.json +7 -0
- data/spec/fixtures/{transporter → projects/transporter}/packages/transport/package.json +1 -1
- data/spec/package_spec.rb +343 -315
- data/spec/pipeline_spec.rb +89 -71
- data/spec/plugins/minifier_spec.rb +25 -16
- data/spec/plugins/transport_spec.rb +1 -1
- data/spec/project_spec.rb +97 -34
- data/spec/spec_helper.rb +41 -0
- data/spec/support/fake_gem_server.rb +8 -4
- data/spec/support/path.rb +8 -0
- data/spec/support/project.rb +50 -17
- data/templates/init/project.json +12 -14
- data/templates/project/LICENSE +1 -1
- data/templates/project/app/main.js +6 -0
- data/templates/project/css/main.css +1 -0
- data/templates/project/index.html +4 -3
- data/vendor/sprockets/.travis.yml +3 -2
- data/vendor/sprockets/Gemfile +0 -6
- data/vendor/sprockets/lib/sprockets/asset.rb +7 -12
- data/vendor/sprockets/lib/sprockets/asset_attributes.rb +70 -53
- data/vendor/sprockets/lib/sprockets/base.rb +1 -14
- data/vendor/sprockets/lib/sprockets/bundled_asset.rb +72 -45
- data/vendor/sprockets/lib/sprockets/caching.rb +28 -23
- data/vendor/sprockets/lib/sprockets/context.rb +56 -26
- data/vendor/sprockets/lib/sprockets/directive_processor.rb +21 -4
- data/vendor/sprockets/lib/sprockets/eco_template.rb +3 -4
- data/vendor/sprockets/lib/sprockets/ejs_template.rb +3 -4
- data/vendor/sprockets/lib/sprockets/engines.rb +26 -1
- data/vendor/sprockets/lib/sprockets/environment.rb +2 -1
- data/vendor/sprockets/lib/sprockets/index.rb +1 -0
- data/vendor/sprockets/lib/sprockets/mime.rb +38 -0
- data/vendor/sprockets/lib/sprockets/processing.rb +4 -45
- data/vendor/sprockets/lib/sprockets/static_asset.rb +5 -6
- data/vendor/sprockets/lib/sprockets/static_compilation.rb +4 -12
- data/vendor/sprockets/lib/sprockets/trail.rb +2 -1
- data/vendor/sprockets/test/fixtures/default/blank.gif +0 -0
- data/vendor/sprockets/test/fixtures/default/with_data_uri.css.erb +3 -0
- data/vendor/sprockets/test/test_asset.rb +121 -15
- data/vendor/sprockets/test/test_asset_attributes.rb +85 -21
- data/vendor/sprockets/test/test_environment.rb +13 -36
- metadata +564 -444
- data/spec/cli/new_spec.rb +0 -118
- data/spec/fixtures/hello_world/assets/bpm_packages.js +0 -13
- data/spec/fixtures/hello_world/assets/bpm_styles.css +0 -14
- data/spec/fixtures/hello_world/hello_world.json +0 -20
- /data/spec/fixtures/{badrake-0.8.7.bpkg → gems/badrake-0.8.7.bpkg} +0 -0
- /data/spec/fixtures/{builder-3.0.0.bpkg → gems/builder-3.0.0.bpkg} +0 -0
- /data/spec/fixtures/{bundler-1.1.pre.bpkg → gems/bundler-1.1.pre.bpkg} +0 -0
- /data/spec/fixtures/{coffee-1.0.1.pre.bpkg → gems/coffee-1.0.1.pre.bpkg} +0 -0
- /data/spec/fixtures/{custom_generator-1.0.bpkg → gems/custom_generator-1.0.bpkg} +0 -0
- /data/spec/fixtures/{highline-1.6.1.bpkg → gems/highline-1.6.1.bpkg} +0 -0
- /data/spec/fixtures/{ivory-0.0.1.bpkg → gems/ivory-0.0.1.bpkg} +0 -0
- /data/spec/fixtures/{jquery-1.4.3.bpkg → gems/jquery-1.4.3.bpkg} +0 -0
- /data/spec/fixtures/{optparse-1.0.1.bpkg → gems/optparse-1.0.1.bpkg} +0 -0
- /data/spec/fixtures/{rake-0.8.6.bpkg → gems/rake-0.8.6.bpkg} +0 -0
- /data/spec/fixtures/{rake-0.8.7.bpkg → gems/rake-0.8.7.bpkg} +0 -0
- /data/spec/fixtures/{spade-0.5.0.bpkg → gems/spade-0.5.0.bpkg} +0 -0
- /data/spec/fixtures/{src → packages}/README.txt +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/.gitignore +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/CHANGELOG.md +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/ISSUES.md +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/LICENSE +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/README.md +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/UPGRADING.md +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/bin/bundle +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/lib/bundler/definition.js +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/lib/bundler/dependency.js +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/lib/bundler/dsl.js +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/lib/bundler/ui.js +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/lib/bundler.js +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/man/bundle-config.ronn +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/man/bundle-exec.ronn +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/man/bundle-install.ronn +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/man/bundle-package.ronn +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/man/bundle-update.ronn +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/man/bundle.ronn +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/man/gemfile.5.ronn +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/man/index.txt +0 -0
- /data/spec/fixtures/{src → packages}/bundler-1.1.pre/package.json +0 -0
- /data/spec/fixtures/{src → packages}/coffee-1.0.1.pre/bin/cake +0 -0
- /data/spec/fixtures/{src → packages}/coffee-1.0.1.pre/bin/coffee +0 -0
- /data/spec/fixtures/{src → packages}/coffee-1.0.1.pre/lib/coffee/base.js +0 -0
- /data/spec/fixtures/{src → packages}/coffee-1.0.1.pre/lib/coffee/mocha/chai.js +0 -0
- /data/spec/fixtures/{src → packages}/coffee-1.0.1.pre/lib/coffee.js +0 -0
- /data/spec/fixtures/{src → packages}/coffee-1.0.1.pre/package.json +0 -0
- /data/spec/fixtures/{src → packages}/coffee-1.0.1.pre/qunit/coffee/test.js +0 -0
- /data/spec/fixtures/{src → packages}/coffee-1.0.1.pre/qunit/test.js +0 -0
- /data/spec/fixtures/{core-test → packages/core-test}/bin/cot +0 -0
- /data/spec/fixtures/{core-test → packages/core-test}/lib/main.js +0 -0
- /data/spec/fixtures/{core-test → packages/core-test}/resources/runner.css +0 -0
- /data/spec/fixtures/{core-test → packages/core-test}/tests/test.js +0 -0
- /data/spec/fixtures/{custom_generator → packages/custom_generator}/lib/main.js +0 -0
- /data/spec/fixtures/{custom_generator → packages/custom_generator}/package.json +0 -0
- /data/spec/fixtures/{custom_generator → packages/custom_generator}/templates/init/project.json +0 -0
- /data/spec/fixtures/{custom_generator → packages/custom_generator}/templates/project/app.js +0 -0
- /data/spec/fixtures/{custom_generator → packages/custom_generator}/templates/project/lib/main.js +0 -0
- /data/spec/fixtures/{custom_generator → packages/custom_generator}/templates/project_generator.rb +0 -0
- /data/spec/fixtures/{src → packages}/jquery/lib/main.js +0 -0
- /data/spec/fixtures/{src → packages}/jquery/package.json +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/CHANGES +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/MIT-LICENSE +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/README +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/Rakefile +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/TODO +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/bin/rake +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/command_line_usage.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/example/Rakefile1 +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/example/Rakefile2 +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/example/a.c +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/example/b.c +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/example/main.c +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/glossary.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/jamis.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/proto_rake.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/rake.1.gz +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/rakefile.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/rational.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.4.14.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.4.15.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.5.0.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.5.3.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.5.4.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.6.0.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.7.0.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.7.1.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.7.2.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.7.3.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.8.0.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.8.2.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.8.3.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.8.4.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.8.5.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/doc/release_notes/rake-0.8.6.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/install.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/alt_system.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/classic_namespace.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/clean.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/contrib/compositepublisher.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/contrib/ftptools.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/contrib/publisher.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/contrib/rubyforgepublisher.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/contrib/sshpublisher.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/contrib/sys.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/gempackagetask.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/loaders/makefile.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/packagetask.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/rake_test_loader.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/rdoctask.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/ruby182_test_unit_fix.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/runtest.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/tasklib.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/testtask.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake/win32.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/lib/rake.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/package.json +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.6/test/capture_stdout.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/CHANGES +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/MIT-LICENSE +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/README +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/Rakefile +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/TODO +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/bin/rake +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/command_line_usage.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/example/Rakefile1 +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/example/Rakefile2 +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/example/a.c +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/example/b.c +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/example/main.c +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/glossary.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/jamis.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/proto_rake.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/rake.1.gz +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/rakefile.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/rational.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.4.14.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.4.15.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.5.0.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.5.3.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.5.4.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.6.0.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.7.0.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.7.1.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.7.2.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.7.3.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.8.0.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.8.2.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.8.3.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.8.4.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.8.5.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.8.6.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/doc/release_notes/rake-0.8.7.rdoc +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/install.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/alt_system.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/classic_namespace.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/clean.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/contrib/compositepublisher.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/contrib/ftptools.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/contrib/publisher.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/contrib/rubyforgepublisher.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/contrib/sshpublisher.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/contrib/sys.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/gempackagetask.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/loaders/makefile.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/packagetask.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/rake_test_loader.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/rdoctask.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/ruby182_test_unit_fix.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/runtest.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/tasklib.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/testtask.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake/win32.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/lib/rake.rb +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/package.json +0 -0
- /data/spec/fixtures/{src → packages}/rake-0.8.7/test/capture_stdout.rb +0 -0
- /data/spec/fixtures/{src → packages}/spade/lib/main.js +0 -0
- /data/spec/fixtures/{src → packages}/spade/package.json +0 -0
- /data/spec/fixtures/{custom_name → projects/custom_name}/MyProject.json +0 -0
- /data/spec/fixtures/{hello_world → projects/hello2}/LICENSE +0 -0
- /data/{templates/project → spec/fixtures/projects/hello2}/app.js +0 -0
- /data/spec/fixtures/{hello_world → projects/hello_world}/README.md +0 -0
- /data/spec/fixtures/{hello_world → projects/hello_world}/assets/papa-smurf.jpg +0 -0
- /data/spec/fixtures/{hello_world → projects/hello_world}/css/dummy.css +0 -0
- /data/spec/fixtures/{hello_world → projects/hello_world}/lib/main.js +0 -0
- /data/spec/fixtures/{hello_world → projects/hello_world}/packages/custom_package/assets/dummy.txt +0 -0
- /data/spec/fixtures/{hello_world → projects/hello_world}/packages/custom_package/css/sample_styles.css +0 -0
- /data/spec/fixtures/{hello_world → projects/hello_world}/packages/custom_package/custom_dir/basic-module.js +0 -0
- /data/spec/fixtures/{hello_world → projects/hello_world}/packages/custom_package/lib/main.js +0 -0
- /data/spec/fixtures/{hello_world → projects/hello_world}/tests/main-test.js +0 -0
- /data/spec/fixtures/{minitest → projects/minitest}/assets/bpm_packages.js +0 -0
- /data/spec/fixtures/{minitest → projects/minitest}/assets/bpm_styles.css +0 -0
- /data/spec/fixtures/{minitest → projects/minitest}/assets/minitest/app_package.js +0 -0
- /data/spec/fixtures/{minitest → projects/minitest}/lib/main.js +0 -0
- /data/spec/fixtures/{minitest → projects/minitest}/packages/uglyduck/lib/main.js +0 -0
- /data/spec/fixtures/{minitest → projects/minitest}/packages/uglyduck/minifier/main.js +0 -0
- /data/spec/fixtures/{simple_hello/assets/bpm_packages.js → projects/simple_hello/assets/bpm_libs.js} +0 -0
- /data/spec/fixtures/{simple_hello → projects/simple_hello}/lib/main.js +0 -0
- /data/spec/fixtures/{transporter → projects/transporter}/lib/main.js +0 -0
- /data/spec/fixtures/{transporter → projects/transporter}/packages/transport/lib/main.js +0 -0
- /data/spec/fixtures/{transporter → projects/transporter}/packages/transport/transports/wrapper.js +0 -0
- /data/spec/fixtures/{transporter → projects/transporter}/transporter.json +0 -0
data/lib/bpm/package.rb
CHANGED
@@ -2,63 +2,116 @@ require 'json'
|
|
2
2
|
|
3
3
|
module BPM
|
4
4
|
class Package
|
5
|
-
EXT
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
EXT = "bpkg"
|
6
|
+
|
7
|
+
# All JSON fields
|
8
|
+
FIELDS = {
|
9
|
+
"keywords" => :array,
|
10
|
+
"licenses" => :array,
|
11
|
+
"engines" => :array,
|
12
|
+
"main" => :string,
|
13
|
+
"bin" => :hash,
|
14
|
+
"directories" => :hash,
|
15
|
+
"pipeline" => :hash,
|
16
|
+
"name" => :string,
|
17
|
+
"version" => :string,
|
18
|
+
"description" => :string,
|
19
|
+
"author" => :string,
|
20
|
+
"homepage" => :string,
|
21
|
+
"summary" => :string,
|
22
|
+
"dependencies" => :hash,
|
23
|
+
"dependencies:development" => :hash,
|
24
|
+
"bpm:build" => :hash,
|
25
|
+
"bpm:formats" => :hash,
|
26
|
+
"bpm:transport" => :string,
|
27
|
+
"bpm:use:transport" => :string,
|
28
|
+
"bpm:minifier" => :string
|
29
|
+
}
|
30
|
+
|
31
|
+
PLUGIN_FIELDS = %w[bpm:formats bpm:minifier bpm:transport bpm:use:transport]
|
32
|
+
|
33
|
+
# Fields that can be loaded straight into the gemspec
|
34
|
+
SPEC_FIELDS = %w[name email homepage summary description]
|
35
|
+
|
36
|
+
# Fields that should be bundled up into JSON in the gemspec
|
37
|
+
METADATA_FIELDS = %w[keywords licenses engines main bin directories pipeline bpm:build bpm:formats bpm:transport]
|
38
|
+
|
39
|
+
REQUIRED_FIELDS = %w[name description summary homepage author version directories]
|
40
|
+
|
41
|
+
attr_accessor *FIELDS.keys.map{|f| f.gsub(':', '_') }
|
42
|
+
|
43
|
+
attr_accessor :json_path, :email
|
44
|
+
attr_reader :root_path, :errors
|
10
45
|
|
11
46
|
def self.from_spec(spec)
|
12
47
|
pkg = new(spec.full_gem_path)
|
13
|
-
pkg.
|
48
|
+
pkg.fill_from_gemspec(spec)
|
14
49
|
pkg
|
15
50
|
end
|
16
51
|
|
17
52
|
def initialize(root_path=nil, email = "")
|
18
|
-
@root_path
|
19
|
-
@json_path
|
20
|
-
@
|
21
|
-
|
22
|
-
@dependencies = {}
|
23
|
-
@directories = {}
|
24
|
-
@metadata = {}
|
25
|
-
end
|
26
|
-
|
27
|
-
def bpkg=(spec)
|
28
|
-
unless spec.is_a?(LibGems::Specification)
|
29
|
-
spec = LibGems::Format.from_file_by_path(spec.to_s).spec
|
53
|
+
@root_path = root_path || Dir.pwd
|
54
|
+
@json_path = File.join @root_path, 'bpm_package.json'
|
55
|
+
unless File.exists? @json_path
|
56
|
+
@json_path = File.join @root_path, 'package.json'
|
30
57
|
end
|
31
|
-
|
58
|
+
|
59
|
+
@email = email
|
60
|
+
@errors = []
|
61
|
+
# Set defaults
|
62
|
+
FIELDS.keys.each{|f| send("#{c2u(f)}=", fd(f))}
|
32
63
|
end
|
33
64
|
|
34
65
|
def to_spec
|
35
66
|
return unless valid?
|
36
67
|
LibGems::Specification.new do |spec|
|
37
|
-
spec.
|
38
|
-
spec.version
|
39
|
-
spec.authors
|
40
|
-
spec.
|
41
|
-
spec.
|
42
|
-
spec.
|
43
|
-
spec.
|
44
|
-
spec.
|
45
|
-
|
46
|
-
|
47
|
-
spec.
|
48
|
-
|
49
|
-
# TODO:
|
68
|
+
SPEC_FIELDS.each{|f| spec.send("#{f}=", send(f)) }
|
69
|
+
spec.version = version
|
70
|
+
spec.authors = [author]
|
71
|
+
spec.files = directory_files + ["package.json"]
|
72
|
+
spec.test_files = glob_files(tests_path)
|
73
|
+
spec.bindir = bin_path
|
74
|
+
spec.licenses = licenses.map{|l| l["type"]}
|
75
|
+
spec.executables = bin_files.map{|p| File.basename(p) } if bin_path
|
76
|
+
|
77
|
+
metadata = Hash[METADATA_FIELDS.map{|f| [f, send(c2u(f)) ] }]
|
78
|
+
spec.requirements = [metadata.to_json]
|
79
|
+
|
80
|
+
# TODO: Is this right?
|
50
81
|
spec.rubyforge_project = "bpm"
|
82
|
+
|
51
83
|
def spec.file_name
|
52
84
|
"#{full_name}.#{EXT}"
|
53
85
|
end
|
54
|
-
|
86
|
+
|
87
|
+
dependencies.each{|d,v| spec.add_dependency(d,v) }
|
88
|
+
dependencies_development.each{|d,v| spec.add_development_dependency(d,v) }
|
55
89
|
end
|
56
90
|
end
|
57
91
|
|
58
|
-
def as_json
|
59
|
-
|
60
|
-
|
61
|
-
json
|
92
|
+
def as_json
|
93
|
+
|
94
|
+
seen_keys = @read_keys || []
|
95
|
+
json = {}
|
96
|
+
|
97
|
+
# keep order of keys read in
|
98
|
+
seen_keys.each do |key|
|
99
|
+
if FIELDS.include?(key)
|
100
|
+
val = send(c2u(key == 'build' ? 'pipeline' : key))
|
101
|
+
else
|
102
|
+
val = @attributes[key]
|
103
|
+
end
|
104
|
+
|
105
|
+
json[key] = val if val && !val.empty?
|
106
|
+
end
|
107
|
+
|
108
|
+
FIELDS.keys.each do |key|
|
109
|
+
next if seen_keys.include?(key)
|
110
|
+
val = send(c2u(key))
|
111
|
+
key = 'build' if key == 'pipeline'
|
112
|
+
json[key] = val if val && !val.empty?
|
113
|
+
end
|
114
|
+
|
62
115
|
json
|
63
116
|
end
|
64
117
|
|
@@ -66,14 +119,93 @@ module BPM
|
|
66
119
|
as_json.to_json
|
67
120
|
end
|
68
121
|
|
69
|
-
def
|
122
|
+
def full_name
|
70
123
|
"#{name}-#{version}"
|
71
124
|
end
|
72
125
|
|
73
|
-
def
|
74
|
-
"#{
|
126
|
+
def file_name
|
127
|
+
"#{full_name}.#{EXT}"
|
128
|
+
end
|
129
|
+
|
130
|
+
def directory_files
|
131
|
+
dir_names = directories.reject { |k,_| k == 'tests' }.values
|
132
|
+
build_names = bpm_build.values.map do |hash|
|
133
|
+
hash['directories'] || hash['assets']
|
134
|
+
end
|
135
|
+
|
136
|
+
build_names += PLUGIN_FIELDS.map do |field_name|
|
137
|
+
val = self.send(c2u(field_name))
|
138
|
+
val = val && val =~ /^#{name}\// ? val[name.size+1..-1]+'.js' : nil
|
139
|
+
puts "FIELD: #{field_name} #{self.send(c2u(field_name))} val=#{val}"
|
140
|
+
val
|
141
|
+
end
|
142
|
+
|
143
|
+
(dir_names+build_names).flatten.compact.uniq.map do |dir|
|
144
|
+
glob_files(dir)
|
145
|
+
end.flatten
|
146
|
+
end
|
147
|
+
|
148
|
+
def bin_files
|
149
|
+
bin && bin.values
|
150
|
+
end
|
151
|
+
|
152
|
+
def bin_path
|
153
|
+
directories["bin"] || "bin"
|
154
|
+
end
|
155
|
+
|
156
|
+
def lib_path
|
157
|
+
directories["lib"] || "lib"
|
158
|
+
end
|
159
|
+
|
160
|
+
def tests_path
|
161
|
+
directories["tests"] || "tests"
|
75
162
|
end
|
76
163
|
|
164
|
+
def find_transport_plugins(project)
|
165
|
+
dependencies.keys.map do |pkg_name|
|
166
|
+
dep = project.local_deps.find do |pkg|
|
167
|
+
pkg.load_json
|
168
|
+
pkg.name == pkg_name
|
169
|
+
end
|
170
|
+
raise "Could not find dependency: #{pkg_name}" unless dep
|
171
|
+
dep.bpm_transport
|
172
|
+
end.compact
|
173
|
+
end
|
174
|
+
|
175
|
+
def pipeline_libs
|
176
|
+
(pipeline && pipeline['libs']) || ['lib']
|
177
|
+
end
|
178
|
+
|
179
|
+
def pipeline_css
|
180
|
+
(pipeline && pipeline['css']) || ['css']
|
181
|
+
end
|
182
|
+
|
183
|
+
def pipeline_assets
|
184
|
+
(pipeline && pipeline['assets']) || ['assets', 'resources']
|
185
|
+
end
|
186
|
+
|
187
|
+
def pipeline_tests
|
188
|
+
(pipeline && pipeline['tests']) || ['tests']
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns a hash of dependencies inferred from the build settings.
|
192
|
+
def dependencies_build
|
193
|
+
ret = {}
|
194
|
+
|
195
|
+
bpm_build.each do |target_name, opts|
|
196
|
+
next unless opts.is_a?(Hash)
|
197
|
+
|
198
|
+
minifier = opts['minifier']
|
199
|
+
case minifier
|
200
|
+
when String
|
201
|
+
ret[minifier] = '>= 0'
|
202
|
+
when Hash
|
203
|
+
ret.merge! minifier
|
204
|
+
end
|
205
|
+
end
|
206
|
+
ret
|
207
|
+
end
|
208
|
+
|
77
209
|
def template_path(name)
|
78
210
|
path = File.join(root_path, 'templates', name.to_s)
|
79
211
|
File.exist?(path) ? path : nil
|
@@ -88,10 +220,6 @@ module BPM
|
|
88
220
|
generator
|
89
221
|
end
|
90
222
|
|
91
|
-
def errors
|
92
|
-
@errors ||= []
|
93
|
-
end
|
94
|
-
|
95
223
|
def validate
|
96
224
|
validate_fields && validate_version && validate_paths
|
97
225
|
end
|
@@ -104,10 +232,60 @@ module BPM
|
|
104
232
|
File.exist?(json_path)
|
105
233
|
end
|
106
234
|
|
235
|
+
def validate_name_and_path
|
236
|
+
filename = File.basename(root_path)
|
237
|
+
unless filename==name || filename=="#{name}-#{version}"
|
238
|
+
raise BPM::InvalidPackageNameError.new self
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
107
242
|
def load_json
|
108
|
-
|
243
|
+
begin
|
244
|
+
json = JSON.parse(File.read(@json_path))
|
245
|
+
rescue JSON::ParserError, Errno::EACCES, Errno::ENOENT => ex
|
246
|
+
raise BPM::InvalidPackageError.new self, ex.message
|
247
|
+
end
|
248
|
+
|
249
|
+
@read_keys = json.keys.dup # to retain order on save
|
250
|
+
@attributes = json # save for saving
|
251
|
+
|
252
|
+
FIELDS.keys.each do |field|
|
253
|
+
if field == 'pipeline'
|
254
|
+
self.pipeline = json['build'] || fd(field)
|
255
|
+
else
|
256
|
+
send("#{c2u(field)}=", json[field] || fd(field))
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
validate_name_and_path
|
261
|
+
|
262
|
+
true
|
263
|
+
end
|
264
|
+
|
265
|
+
def fill_from_gemspec(spec)
|
266
|
+
unless spec.is_a?(LibGems::Specification)
|
267
|
+
spec = LibGems::Format.from_file_by_path(spec.to_s).spec
|
268
|
+
end
|
269
|
+
|
270
|
+
SPEC_FIELDS.each{|f| send("#{f}=", spec.send(f) || fd(field)) }
|
271
|
+
|
272
|
+
self.author = spec.authors.first
|
273
|
+
self.version = spec.version.to_s
|
274
|
+
|
275
|
+
metadata = spec.requirements.first
|
276
|
+
if metadata
|
277
|
+
metadata = JSON.parse(metadata)
|
278
|
+
METADATA_FIELDS.each{|f| send("#{c2u(f)}=", metadata[f] || fd(f))}
|
279
|
+
end
|
280
|
+
|
281
|
+
self.dependencies = Hash[spec.dependencies.map{|d| [d.name, d.requirement.to_s ]}]
|
282
|
+
self.dependencies_development = Hash[spec.development_dependencies.map{|d| [d.name, d.requirement.to_s ]}]
|
109
283
|
end
|
110
284
|
|
285
|
+
# Collects an expanded list of all dependencies this package depends on
|
286
|
+
# directly or indirectly. This assume the project has already resolved
|
287
|
+
# any needed dependencies and therefore will raise an exception if a
|
288
|
+
# dependency cannot be found locally in the project.
|
111
289
|
def expanded_deps(project)
|
112
290
|
ret = []
|
113
291
|
seen = []
|
@@ -122,14 +300,13 @@ module BPM
|
|
122
300
|
todo << found
|
123
301
|
ret << found
|
124
302
|
else
|
125
|
-
|
303
|
+
raise "Required local dependency not found #{dep_name}"
|
126
304
|
end
|
127
305
|
end
|
128
|
-
|
129
306
|
end
|
130
307
|
ret
|
131
308
|
end
|
132
|
-
|
309
|
+
|
133
310
|
# TODO: Make better errors
|
134
311
|
# TODO: This might not work well with conflicting versions
|
135
312
|
def local_deps(search_path=nil)
|
@@ -153,157 +330,74 @@ module BPM
|
|
153
330
|
end
|
154
331
|
end
|
155
332
|
|
156
|
-
|
157
|
-
directories.reject{|k,_| k == 'tests' }.values.map{|dir| glob_files(dir) }.flatten
|
158
|
-
end
|
333
|
+
private
|
159
334
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
else
|
164
|
-
[]
|
335
|
+
# colon to underscore
|
336
|
+
def c2u(key)
|
337
|
+
key.gsub(':', '_')
|
165
338
|
end
|
166
|
-
end
|
167
|
-
|
168
|
-
def template_files
|
169
|
-
glob_files("templates")
|
170
|
-
end
|
171
|
-
|
172
|
-
def transport_files
|
173
|
-
glob_files("transports")
|
174
|
-
end
|
175
|
-
|
176
|
-
def bin_path
|
177
|
-
@directories["bin"] || "bin"
|
178
|
-
end
|
179
|
-
|
180
|
-
def lib_path
|
181
|
-
@directories["lib"] || "lib"
|
182
|
-
end
|
183
|
-
|
184
|
-
def tests_path
|
185
|
-
@directories["tests"] || "tests"
|
186
|
-
end
|
187
339
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
[@attributes['plugin:minifier']].compact
|
194
|
-
end
|
195
|
-
|
196
|
-
def plugin_modules(key_name, project, own=true)
|
197
|
-
return [@attributes[key_name]] if own && @attributes[key_name]
|
198
|
-
dependencies.keys.map do |pkg_name|
|
199
|
-
dep = project.local_deps.find do |pkg|
|
200
|
-
pkg.load_json
|
201
|
-
pkg.name == pkg_name
|
340
|
+
# field default
|
341
|
+
def fd(key)
|
342
|
+
case FIELDS[key]
|
343
|
+
when :array then []
|
344
|
+
when :hash then {}
|
202
345
|
end
|
203
|
-
|
204
|
-
if dep
|
205
|
-
dep.attributes[key_name]
|
206
|
-
else
|
207
|
-
puts "COULD NOT FIND DEP: #{pkg_name}"
|
208
|
-
end
|
209
|
-
|
210
|
-
end.compact
|
211
|
-
end
|
212
|
-
|
213
|
-
# named directories that are expected to contain code. These will be
|
214
|
-
# searched for supported modules
|
215
|
-
def pipeline_libs
|
216
|
-
(@attributes['pipeline'] && @attributes['pipeline']['libs']) || ['lib']
|
217
|
-
end
|
218
|
-
|
219
|
-
def pipeline_css
|
220
|
-
(@attributes['pipeline'] && @attributes['pipeline']['css']) || ['css']
|
221
|
-
end
|
222
|
-
|
223
|
-
def pipeline_assets
|
224
|
-
(@attributes['pipeline'] && @attributes['pipeline']['assets']) || ['assets', 'resources']
|
225
|
-
end
|
226
|
-
|
227
|
-
private
|
228
|
-
|
229
|
-
def parse
|
230
|
-
FIELDS.each do |field|
|
231
|
-
send("#{field}=", @attributes[field])
|
232
346
|
end
|
233
347
|
|
234
|
-
|
235
|
-
|
236
|
-
self.metadata = Hash[*@attributes.select { |k, v| METADATA.include?(k) }.flatten(1)]
|
237
|
-
end
|
238
|
-
|
239
|
-
def read
|
240
|
-
@attributes = JSON.parse(File.read(@json_path))
|
241
|
-
rescue *[JSON::ParserError, Errno::EACCES, Errno::ENOENT] => ex
|
242
|
-
add_error "There was a problem parsing #{File.basename(@json_path)}: #{ex.message}"
|
243
|
-
end
|
244
|
-
|
245
|
-
def validate_paths
|
246
|
-
success = true
|
348
|
+
def validate_paths
|
349
|
+
success = true
|
247
350
|
|
248
|
-
|
249
|
-
non_dirs = paths.reject{|p| File.directory?(File.join(@root_path, p))}
|
351
|
+
paths = [*lib_path]
|
250
352
|
if paths.empty?
|
251
353
|
add_error "A lib directory is required"
|
252
354
|
success = false
|
253
|
-
|
254
|
-
|
355
|
+
else
|
356
|
+
non_dirs = paths.reject{|p| File.directory?(File.join(root_path, p))}
|
357
|
+
unless non_dirs.empty?
|
358
|
+
add_error "#{non_dirs.map{|p| "'#{p}'" }.join(", ")}, specified for lib directory, is not a directory"
|
359
|
+
success = false
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
# look for actual 'tests' in directories hash since simply having no
|
364
|
+
# tests dir is allowed as well.
|
365
|
+
unless directories['tests'].nil? || File.directory?(File.join(@root_path, tests_path))
|
366
|
+
add_error "'#{tests_path}', specified for tests directory, is not a directory"
|
255
367
|
success = false
|
256
368
|
end
|
257
|
-
end
|
258
369
|
|
259
|
-
|
260
|
-
# tests dir is allowed as well.
|
261
|
-
unless @directories['tests'].nil? || File.directory?(File.join(@root_path, tests_path))
|
262
|
-
add_error "'#{tests_path}', specified for tests directory, is not a directory"
|
263
|
-
success = false
|
370
|
+
success
|
264
371
|
end
|
265
372
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
add_error ex.to_s
|
274
|
-
end
|
373
|
+
def validate_version
|
374
|
+
LibGems::Version.new(version)
|
375
|
+
true
|
376
|
+
rescue ArgumentError => ex
|
377
|
+
add_error ex.to_s
|
378
|
+
false
|
379
|
+
end
|
275
380
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
381
|
+
def validate_fields
|
382
|
+
REQUIRED_FIELDS.all? do |field|
|
383
|
+
value = send(field)
|
384
|
+
if value.nil? || value.empty?
|
385
|
+
add_error "Package requires a '#{field}' field"
|
386
|
+
false
|
387
|
+
else
|
388
|
+
true
|
389
|
+
end
|
283
390
|
end
|
284
391
|
end
|
285
|
-
end
|
286
392
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
end
|
291
|
-
|
292
|
-
def glob_files(path)
|
293
|
-
Dir[File.join(path, "**", "*")].reject{|f| File.directory?(f) }
|
294
|
-
end
|
295
|
-
|
296
|
-
def fill_from_gemspec(spec)
|
297
|
-
FIELDS.each{|field| send("#{field}=", spec.send(field).to_s) }
|
298
|
-
|
299
|
-
self.dependencies = {}
|
300
|
-
spec.dependencies.each{|d| self.dependencies[d.name] = d.requirement.to_s }
|
393
|
+
def add_error(message)
|
394
|
+
self.errors << message
|
395
|
+
end
|
301
396
|
|
302
|
-
|
303
|
-
|
397
|
+
def glob_files(path)
|
398
|
+
return path if File.exists?(path) && !File.directory?(path)
|
399
|
+
Dir[File.join(path, "**", "*")].reject{|f| File.directory?(f) }
|
304
400
|
end
|
305
|
-
end
|
306
401
|
|
307
402
|
end
|
308
403
|
end
|
309
|
-
|
@@ -21,30 +21,86 @@ module BPM
|
|
21
21
|
minify super
|
22
22
|
end
|
23
23
|
|
24
|
-
def minify(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
24
|
+
def minify(hash)
|
25
|
+
return hash if environment.mode == :debug
|
26
|
+
|
27
|
+
hash = environment.cache_hash("#{pathname}:minify", id) do
|
28
|
+
project = environment.project
|
29
|
+
minifier_name = project.minifier_name asset_name
|
30
|
+
minifier_name = minifier_name.keys.first if minifier_name
|
31
|
+
|
32
|
+
if minifier_name && content_type == 'application/javascript'
|
33
|
+
pkg = project.package_from_name minifier_name
|
34
|
+
if pkg.nil?
|
35
|
+
raise MinifierNotFoundError.new(minifier_name)
|
36
|
+
end
|
37
|
+
|
38
|
+
minifier_plugin_name = pkg.bpm_minifier
|
39
|
+
if minifier_plugin_name.nil?
|
40
|
+
raise MinifierNotFoundError.new(minifier_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
plugin_ctx = environment.plugin_context_for minifier_plugin_name
|
44
|
+
|
45
|
+
# slice out the header at the top - we don't want the minifier to
|
46
|
+
# touch it.
|
47
|
+
data = hash['source']
|
48
|
+
header = data.match /^(\/\* ====.+====\*\/)$/m
|
49
|
+
if header
|
50
|
+
header = header[0] + "\n"
|
51
|
+
data = data[header.size..-1]
|
52
|
+
end
|
53
|
+
|
54
|
+
V8::C::Locker() do
|
55
|
+
plugin_ctx["PACKAGE_INFO"] = pkg.as_json
|
56
|
+
plugin_ctx["DATA"] = data
|
57
|
+
data = plugin_ctx.eval("BPM_PLUGIN.minify(DATA, PACKAGE_INFO)")
|
58
|
+
end
|
59
|
+
|
60
|
+
data = header+data if header
|
61
|
+
|
62
|
+
{ 'length' => Rack::Utils.bytesize(data),
|
63
|
+
'digest' => environment.digest.update(data).hexdigest,
|
64
|
+
'source' => data }
|
65
|
+
else
|
66
|
+
hash
|
36
67
|
end
|
37
68
|
end
|
38
|
-
|
39
|
-
|
69
|
+
|
70
|
+
hash['length'] = Integer(hash['length']) if hash['length'].is_a?(String)
|
71
|
+
|
72
|
+
@length = hash['length']
|
73
|
+
@digest = hash['digest']
|
74
|
+
@source = hash['source']
|
75
|
+
|
76
|
+
hash
|
77
|
+
end
|
78
|
+
|
79
|
+
def asset_name
|
80
|
+
project = environment.project
|
81
|
+
if pathname.to_s.include?(project.assets_root)
|
82
|
+
pathname.relative_path_from(Pathname.new(project.assets_root)).to_s
|
83
|
+
elsif pathname.to_s.include?(project.preview_root)
|
84
|
+
pathname.relative_path_from(Pathname.new(project.preview_root)).to_s
|
85
|
+
end
|
40
86
|
end
|
41
87
|
|
42
88
|
def build_dependency_context_and_body
|
43
89
|
|
44
|
-
project
|
45
|
-
|
90
|
+
project = environment.project
|
91
|
+
settings = project.build_settings(environment.mode)[asset_name]
|
92
|
+
pkgs = settings.keys.map do |pkg_name|
|
93
|
+
next if pkg_name == 'bpm:minifier'
|
94
|
+
if pkg_name == project.name
|
95
|
+
project
|
96
|
+
else
|
97
|
+
project.local_deps.find { |dep| dep.name == pkg_name }
|
98
|
+
end
|
99
|
+
end.compact
|
100
|
+
|
46
101
|
if pkgs.size > 0
|
47
|
-
manifest = pkgs.
|
102
|
+
manifest = pkgs.sort { |a,b| a.name <=> b.name }
|
103
|
+
manifest = manifest.map do |x|
|
48
104
|
"#{x.name} (#{x.version})"
|
49
105
|
end.join " "
|
50
106
|
else
|
@@ -54,10 +110,9 @@ module BPM
|
|
54
110
|
# Add in the generated header
|
55
111
|
body = <<EOF
|
56
112
|
/* ===========================================================================
|
57
|
-
BPM
|
113
|
+
BPM Combined Asset File
|
58
114
|
MANIFEST: #{manifest}
|
59
115
|
This file is generated automatically by the bpm (http://www.bpmjs.org)
|
60
|
-
To use this file, load this file in your HTML head.
|
61
116
|
=========================================================================*/
|
62
117
|
|
63
118
|
EOF
|
@@ -69,17 +124,22 @@ EOF
|
|
69
124
|
context = blank_context
|
70
125
|
context.require_asset(pathname) # start with self
|
71
126
|
|
72
|
-
|
127
|
+
if pathname.to_s =~ /_tests\.js$/
|
128
|
+
dir_name, dir_method = ['tests', 'pipeline_tests']
|
129
|
+
else
|
130
|
+
dir_name, dir_method = FORMAT_METHODS[content_type] || ['lib', 'pipeline_libs']
|
131
|
+
end
|
73
132
|
|
74
133
|
pkgs.map do |pkg|
|
75
|
-
pkg.
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
134
|
+
settings[pkg.name].each do |dir|
|
135
|
+
dir_names = Array(pkg.directories[dir] || dir)
|
136
|
+
dir_names.each do |dir_name|
|
137
|
+
search_path = File.expand_path File.join(pkg.root_path, dir_name)
|
138
|
+
|
139
|
+
Dir[File.join(search_path, '**', '*')].sort.each do |fn|
|
140
|
+
context.depend_on File.dirname(fn)
|
141
|
+
context.require_asset(fn) if context.asset_requirable? fn
|
142
|
+
end
|
83
143
|
end
|
84
144
|
end
|
85
145
|
end
|