spec/support/app_integration.rb in hanami-2.1.0.rc2 vs spec/support/app_integration.rb in hanami-2.1.0.rc3
- old
+ new
@@ -27,26 +27,34 @@
end
end
private
+ # TODO: make slice-aware
def stub_assets(*assets)
manifest_hash = assets.each_with_object({}) { |source_path, hsh|
hsh[source_path] = {url: File.join("/assets", source_path)}
}
- write "public/assets.json", JSON.generate(manifest_hash)
+ write "public/assets/assets.json", JSON.generate(manifest_hash)
+
+ # An assets dir isrequired to load the assets provider
+ write "app/assets/.keep", ""
end
def compile_assets!
link_node_modules
generate_assets_config
require "hanami/cli/command"
require "hanami/cli/commands/app/command"
require "hanami/cli/commands/app/assets/compile"
- assets_compile = Hanami::CLI::Commands::App::Assets::Compile.new(config: Hanami.app.config.assets)
+ assets_compile = Hanami::CLI::Commands::App::Assets::Compile.new(
+ config: Hanami.app.config.assets,
+ out: File.new(File::NULL, "w"),
+ err: File.new(File::NULL, "w"),
+ )
with_directory(Hanami.app.root) { assets_compile.call }
end
def link_node_modules
@@ -60,19 +68,17 @@
def generate_assets_config
root = Hanami.app.root
with_directory(root) do
- write("config/assets.mjs", <<~JS) unless root.join("config", "assets.mjs").exist?
+ write("config/assets.js", <<~JS) unless root.join("config", "assets.js").exist?
import * as assets from "hanami-assets";
await assets.run();
JS
write("package.json", <<~JSON) unless root.join("package.json").exist?
{
- "scripts": {
- "assets": "node config/assets.mjs"
- }
+ "type": "module"
}
JSON
end
end
end