diff --git a/lib/bpm/package.rb b/lib/bpm/package.rb index 3668c3e..5a44b81 100644 --- a/lib/bpm/package.rb +++ b/lib/bpm/package.rb @@ -148,7 +148,8 @@ def directory_files dir_names.reject! { |t| t == tests_path } build_names = bpm_build.values.map do |hash| - hash['directories'] || hash['assets'] + # Directories is deprecated + hash['files'] || hash['directories'] || hash['assets'] end build_names += PLUGIN_TYPES.map do |type| diff --git a/lib/bpm/pipeline.rb b/lib/bpm/pipeline.rb index fda8ec4..a3c18d1 100644 --- a/lib/bpm/pipeline.rb +++ b/lib/bpm/pipeline.rb @@ -112,7 +112,6 @@ def magic_paths # Returns an array of all the buildable assets in the current directory. # These are the assets that will be built when you compile the project. def buildable_assets - # make sure the logical_path can be used to simply build into the # assets directory when we are done ret = project.buildable_asset_filenames mode diff --git a/lib/bpm/project.rb b/lib/bpm/project.rb index 0718360..3638c94 100644 --- a/lib/bpm/project.rb +++ b/lib/bpm/project.rb @@ -135,33 +135,34 @@ def preview_root(*paths) end def build_app? - !!(bpm_build && bpm_build["bpm_libs.js"] && - bpm_build["bpm_libs.js"]["directories"] && - bpm_build["bpm_libs.js"]["directories"].size>0) + # Make sure we have some lib files + !!(bpm_build && + bpm_build["bpm_libs.js"] && + ((bpm_build["bpm_libs.js"]["files"] && bpm_build["bpm_libs.js"]["files"].size>0) || + (bpm_build["bpm_libs.js"]["directories"] && bpm_build["bpm_libs.js"]["directories"].size>0))) end def build_app=(value) - bpm_libs = "bpm_libs.js" bpm_styles = "bpm_styles.css" if value bpm_build[bpm_libs] ||= {} hash = bpm_build[bpm_libs] - hash['directories'] ||= [] - hash['directories'] << 'lib' if hash['directories'].size==0 + hash['files'] ||= hash['directories'] || [] + hash['files'] << 'lib' if hash['files'].size==0 hash['minifier'] ||= 'uglify-js' bpm_build[bpm_styles] ||= {} hash = bpm_build[bpm_styles] - hash['directories'] ||= [] - hash['directories'] << 'css' if hash['directories'].size==0 + hash['files'] ||= hash['directories'] || [] + hash['files'] << 'css' if hash['files'].size==0 directories ||= {} - directories['lib'] ||= ['app'] + directories['lib'] ||= ['lib'] else - bpm_build[bpm_libs]['directories'] = [] - bpm_build[bpm_styles]['directories'] = [] + bpm_build[bpm_libs]['files'] = [] + bpm_build[bpm_styles]['files'] = [] end value end @@ -761,7 +762,6 @@ def has_mode(opts, mode) ## BUILD OPTIONS def merge_build_opts(ret, dep_name, target_name, opts, mode) - ret[target_name] ||= {} if opts['assets'] @@ -769,8 +769,14 @@ def merge_build_opts(ret, dep_name, target_name, opts, mode) return end - if opts['directories'] && opts['directories'].size>0 - ret[target_name][dep_name] = opts['directories'] + if opts['directories'] + warn "[DEPRECATION] Use 'files' array instead of 'directories' array in #{dep_name} config" + opts['files'] ||= [] + opts['files'] += opts.delete('directories') + end + + if opts['files'] && opts['files'].size>0 + ret[target_name][dep_name] = opts['files'] end if opts['minifier'] @@ -807,13 +813,13 @@ def project_settings_excludes(dep_name, target_name) DEFAULT_BUILD_OPTS = { 'bpm_libs.js' => { - 'directories' => ['lib'], - 'modes' => ['*'] + 'files' => ['lib'], + 'modes' => ['*'] }, 'bpm_styles.css' => { - 'directories' => ['css'], - 'modes' => ['*'] + 'files' => ['css'], + 'modes' => ['*'] } } @@ -840,8 +846,8 @@ def default_build_opts(dep_name) } ret["#{dep_name}/bpm_tests.js"] = { - 'directories' => ['tests'], - 'modes' => ['debug'] + 'files' => ['tests'], + 'modes' => ['debug'] } @default_build_opts[dep_name] = ret diff --git a/spec/fixtures/gems/core-test-0.4.9.bpkg b/spec/fixtures/gems/core-test-0.4.9.bpkg index a7731f1..e78b097 100644 Binary files a/spec/fixtures/gems/core-test-0.4.9.bpkg and b/spec/fixtures/gems/core-test-0.4.9.bpkg differ diff --git a/spec/fixtures/packages/core-test/package.json b/spec/fixtures/packages/core-test/package.json index 372ce69..a45c6f8 100644 --- a/spec/fixtures/packages/core-test/package.json +++ b/spec/fixtures/packages/core-test/package.json @@ -39,7 +39,7 @@ "bpm:build": { "bpm_styles.css": { - "directories": ["resources"] + "files": ["resources"] }, "core-test": { diff --git a/spec/fixtures/projects/coffee/coffee.json b/spec/fixtures/projects/coffee/coffee.json index 525f179..e56bc80 100644 --- a/spec/fixtures/projects/coffee/coffee.json +++ b/spec/fixtures/projects/coffee/coffee.json @@ -10,7 +10,7 @@ "bpm:build": { "bpm_libs.js": { - "directories": ["lib", "templates"] + "files": ["lib", "templates"] } } } diff --git a/spec/fixtures/projects/hello_world/hello_world.json b/spec/fixtures/projects/hello_world/hello_world.json index 06d0128..ae5bbd5 100644 --- a/spec/fixtures/projects/hello_world/hello_world.json +++ b/spec/fixtures/projects/hello_world/hello_world.json @@ -26,15 +26,15 @@ "bpm:build": { "hello_world/bpm_libs.js": { - "directories": ["lib", "custom"] + "files": ["lib", "custom"] }, "hello_world/bpm_styles.css": { - "directories": ["css"] + "files": ["css"] }, "hello_world/bpm_tests.js": { - "directories": ["test"] + "files": ["test"] } } diff --git a/spec/fixtures/projects/hello_world/vendor/custom_package/package.json b/spec/fixtures/projects/hello_world/vendor/custom_package/package.json index 0c4529b..af9502c 100644 --- a/spec/fixtures/projects/hello_world/vendor/custom_package/package.json +++ b/spec/fixtures/projects/hello_world/vendor/custom_package/package.json @@ -18,7 +18,7 @@ "bpm:build": { "bpm_libs.js": { - "directories": ["lib", "not-normal"], + "files": ["lib", "not-normal"], "minifier": "uglify-js" } } diff --git a/spec/fixtures/projects/init_app/new_project.json b/spec/fixtures/projects/init_app/new_project.json index 4709199..13642da 100644 --- a/spec/fixtures/projects/init_app/new_project.json +++ b/spec/fixtures/projects/init_app/new_project.json @@ -4,15 +4,15 @@ "bpm:build": { "bpm_libs.js": { - "directories": [ + "files": [ "lib" ], "minifier": "uglify-js" }, "bpm_styles.css": { - "directories": [ + "files": [ "css" ] } } -} \ No newline at end of file +} diff --git a/spec/fixtures/projects/init_default/new_project.json b/spec/fixtures/projects/init_default/new_project.json index 29de5c5..bd39f41 100644 --- a/spec/fixtures/projects/init_default/new_project.json +++ b/spec/fixtures/projects/init_default/new_project.json @@ -4,12 +4,12 @@ "bpm:build": { "bpm_libs.js": { - "directories": [], + "files": [], "minifier": "uglify-js" }, "bpm_styles.css": { - "directories": [] + "files": [] } } } diff --git a/spec/fixtures/projects/minitest/minitest.json b/spec/fixtures/projects/minitest/minitest.json index dc54caa..37fc8e5 100644 --- a/spec/fixtures/projects/minitest/minitest.json +++ b/spec/fixtures/projects/minitest/minitest.json @@ -19,7 +19,7 @@ }, "minitest/bpm_libs.js": { - "directories": ["lib"], + "files": ["lib"], "minifier": { "uglyduck": ">= 0" }, "uglyduck:where": "sanfran" } diff --git a/spec/fixtures/projects/minitrans/minitrans.json b/spec/fixtures/projects/minitrans/minitrans.json index 1b40051..ff088d1 100644 --- a/spec/fixtures/projects/minitrans/minitrans.json +++ b/spec/fixtures/projects/minitrans/minitrans.json @@ -17,7 +17,7 @@ "bpm:build": { "bpm_libs.js": { - "directories": ["lib"], + "files": ["lib"], "minifier": "uglyduck" } } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0bafd79..8467bf6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,7 +25,7 @@ def reset_host # Use to avoid throwing errors just because an extra newline shows up # somewhere def normalize_whitespace(string) - string.gsub(/ +/, ' ').gsub(/\n+/,"\n") + string.gsub(/ +/, ' ').gsub(/\n+/,"\n").strip end def compare_file_contents(actual_path, expected_path) diff --git a/templates/init/project.json b/templates/init/project.json index fede896..a196ecd 100644 --- a/templates/init/project.json +++ b/templates/init/project.json @@ -4,13 +4,12 @@ "bpm:build": { "bpm_libs.js": { - "directories": [], + "files": [], "minifier": "uglify-js" }, "bpm_styles.css": { - "directories": [] + "files": [] } } } -