6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/generators/action_push_web/install/install_generator.rb', line 6
def copy_files
template "app/models/application_push_subscription.rb"
template "app/models/application_push_web_notification.rb"
template "app/jobs/application_push_web_notification_job.rb"
template "app/views/pwa/service-worker.js"
route "mount ActionPushWeb::Engine => \"/action_push_web\""
if Rails.root.join("config/push.yml").exist?
append_to_file "config/push.yml", File.read("#{self.class.source_root}/config/push.yml.tt").split("\n")[1..].join("\n").prepend("\n")
else
template "config/push.yml"
end
if Rails.root.join("app/javascript/application.js").exist?
append_to_file "app/javascript/application.js", %(import "action_push_web"\n)
end
if Rails.root.join("package.json").exist? && Rails.root.join("bun.config.js").exist?
elsif Rails.root.join("package.json").exist?
end
rails_command "railties:install:migrations FROM=action_push_web",
inline: true
vapid_key = ActionPushWeb::VapidKeyGenerator.new
puts "\n"
puts <<~MSG
Add this entry to the credentials of the target environment:#{' '}
action_push_web:
public_key: #{vapid_key.public_key}
private_key: #{vapid_key.private_key}
MSG
end
|