cable_ready 5.0.0.pre9 → 5.0.0.pre10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -1
  3. data/Gemfile.lock +119 -100
  4. data/README.md +2 -5
  5. data/app/assets/javascripts/cable_ready.js +457 -151
  6. data/app/assets/javascripts/cable_ready.min.js +1 -1
  7. data/app/assets/javascripts/cable_ready.min.js.map +1 -1
  8. data/app/assets/javascripts/cable_ready.umd.js +441 -165
  9. data/app/assets/javascripts/cable_ready.umd.min.js +1 -1
  10. data/app/assets/javascripts/cable_ready.umd.min.js.map +1 -1
  11. data/app/channels/cable_ready/stream.rb +7 -5
  12. data/app/helpers/cable_ready/view_helper.rb +58 -0
  13. data/app/jobs/cable_ready_broadcast_job.rb +9 -8
  14. data/app/models/concerns/cable_ready/updatable/collection_updatable_callbacks.rb +2 -0
  15. data/app/models/concerns/cable_ready/updatable/collections_registry.rb +2 -0
  16. data/app/models/concerns/cable_ready/updatable/model_updatable_callbacks.rb +5 -2
  17. data/app/models/concerns/cable_ready/updatable.rb +67 -19
  18. data/app/models/concerns/extend_has_many.rb +2 -0
  19. data/cable_ready.gemspec +4 -6
  20. data/lib/cable_ready/broadcaster.rb +2 -0
  21. data/lib/cable_ready/cable_car.rb +2 -0
  22. data/lib/cable_ready/channel.rb +12 -4
  23. data/lib/cable_ready/channels.rb +3 -1
  24. data/lib/cable_ready/config.rb +16 -2
  25. data/lib/cable_ready/engine.rb +19 -9
  26. data/lib/cable_ready/identifiable.rb +23 -5
  27. data/lib/cable_ready/importmap.rb +2 -0
  28. data/lib/cable_ready/installer.rb +224 -0
  29. data/lib/cable_ready/operation_builder.rb +1 -1
  30. data/lib/cable_ready/sanity_checker.rb +1 -31
  31. data/lib/cable_ready/version.rb +1 -1
  32. data/lib/cable_ready.rb +3 -8
  33. data/lib/cable_ready_helper.rb +13 -0
  34. data/lib/generators/cable_ready/channel_generator.rb +51 -12
  35. data/lib/generators/cable_ready/templates/config/initializers/cable_ready.rb +10 -6
  36. data/lib/install/action_cable.rb +144 -0
  37. data/lib/install/broadcaster.rb +109 -0
  38. data/lib/install/bundle.rb +54 -0
  39. data/lib/install/compression.rb +51 -0
  40. data/lib/install/config.rb +39 -0
  41. data/lib/install/development.rb +34 -0
  42. data/lib/install/esbuild.rb +101 -0
  43. data/lib/install/importmap.rb +96 -0
  44. data/lib/install/initializers.rb +15 -0
  45. data/lib/install/mrujs.rb +121 -0
  46. data/lib/install/npm_packages.rb +13 -0
  47. data/lib/install/shakapacker.rb +61 -0
  48. data/lib/install/spring.rb +54 -0
  49. data/lib/install/updatable.rb +34 -0
  50. data/lib/install/vite.rb +62 -0
  51. data/lib/install/webpacker.rb +81 -0
  52. data/lib/install/yarn.rb +56 -0
  53. data/lib/tasks/cable_ready/cable_ready.rake +249 -0
  54. data/package.json +28 -18
  55. data/{rollup.config.js → rollup.config.mjs} +9 -8
  56. data/web-test-runner.config.mjs +12 -0
  57. data/yarn.lock +2210 -404
  58. metadata +37 -161
  59. data/LATEST +0 -1
  60. data/app/helpers/cable_ready_helper.rb +0 -26
  61. data/lib/generators/cable_ready/helpers_generator.rb +0 -43
  62. data/lib/generators/cable_ready/initializer_generator.rb +0 -14
  63. data/test/dummy/app/channels/application_cable/channel.rb +0 -4
  64. data/test/dummy/app/channels/application_cable/connection.rb +0 -4
  65. data/test/dummy/app/controllers/application_controller.rb +0 -2
  66. data/test/dummy/app/helpers/application_helper.rb +0 -2
  67. data/test/dummy/app/jobs/application_job.rb +0 -7
  68. data/test/dummy/app/mailers/application_mailer.rb +0 -4
  69. data/test/dummy/app/models/application_record.rb +0 -3
  70. data/test/dummy/app/models/dugong.rb +0 -4
  71. data/test/dummy/app/models/global_idable_entity.rb +0 -16
  72. data/test/dummy/app/models/post.rb +0 -4
  73. data/test/dummy/app/models/section.rb +0 -6
  74. data/test/dummy/app/models/team.rb +0 -6
  75. data/test/dummy/app/models/topic.rb +0 -4
  76. data/test/dummy/app/models/user.rb +0 -7
  77. data/test/dummy/config/application.rb +0 -22
  78. data/test/dummy/config/boot.rb +0 -5
  79. data/test/dummy/config/environment.rb +0 -5
  80. data/test/dummy/config/environments/development.rb +0 -76
  81. data/test/dummy/config/environments/production.rb +0 -120
  82. data/test/dummy/config/environments/test.rb +0 -59
  83. data/test/dummy/config/initializers/application_controller_renderer.rb +0 -8
  84. data/test/dummy/config/initializers/assets.rb +0 -12
  85. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -8
  86. data/test/dummy/config/initializers/cable_ready.rb +0 -18
  87. data/test/dummy/config/initializers/content_security_policy.rb +0 -28
  88. data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
  89. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -6
  90. data/test/dummy/config/initializers/inflections.rb +0 -16
  91. data/test/dummy/config/initializers/mime_types.rb +0 -4
  92. data/test/dummy/config/initializers/permissions_policy.rb +0 -11
  93. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  94. data/test/dummy/config/puma.rb +0 -43
  95. data/test/dummy/config/routes.rb +0 -3
  96. data/test/dummy/db/migrate/20210902154139_create_users.rb +0 -9
  97. data/test/dummy/db/migrate/20210902154153_create_posts.rb +0 -10
  98. data/test/dummy/db/migrate/20210904081930_create_topics.rb +0 -9
  99. data/test/dummy/db/migrate/20210904093607_create_sections.rb +0 -9
  100. data/test/dummy/db/migrate/20210913191735_create_teams.rb +0 -8
  101. data/test/dummy/db/migrate/20210913191759_add_team_reference_to_users.rb +0 -5
  102. data/test/dummy/db/migrate/20220329222959_create_dugongs.rb +0 -8
  103. data/test/dummy/db/migrate/20220329230221_create_active_storage_tables.active_storage.rb +0 -36
  104. data/test/dummy/db/schema.rb +0 -84
  105. data/test/dummy/test/models/dugong_test.rb +0 -7
  106. data/test/dummy/test/models/post_test.rb +0 -7
  107. data/test/dummy/test/models/section_test.rb +0 -7
  108. data/test/dummy/test/models/team_test.rb +0 -7
  109. data/test/dummy/test/models/topic_test.rb +0 -7
  110. data/test/dummy/test/models/user_test.rb +0 -7
  111. data/test/lib/cable_ready/cable_car_test.rb +0 -50
  112. data/test/lib/cable_ready/compoundable_test.rb +0 -26
  113. data/test/lib/cable_ready/helper_test.rb +0 -25
  114. data/test/lib/cable_ready/identifiable_test.rb +0 -69
  115. data/test/lib/cable_ready/operation_builder_test.rb +0 -189
  116. data/test/lib/cable_ready/updatable_test.rb +0 -135
  117. data/test/lib/generators/cable_ready/channel_generator_test.rb +0 -157
  118. data/test/support/generator_test_helpers.rb +0 -28
  119. data/test/test_helper.rb +0 -18
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cable_ready/installer"
4
+
5
+ if !package_json.exist?
6
+ say "⏩ No package.json file found. Skipping."
7
+
8
+ return
9
+ end
10
+
11
+ # run yarn install only when packages are waiting to be added or removed
12
+ add = package_list.exist? ? package_list.readlines.map(&:chomp) : []
13
+ dev = dev_package_list.exist? ? dev_package_list.readlines.map(&:chomp) : []
14
+ drop = drop_package_list.exist? ? drop_package_list.readlines.map(&:chomp) : []
15
+
16
+ json = JSON.parse(package_json.read)
17
+
18
+ if add.present? || dev.present? || drop.present?
19
+
20
+ add.each do |package|
21
+ matches = package.match(/(.+)@(.+)/)
22
+ name, version = matches[1], matches[2]
23
+ json["dependencies"] = {} unless json["dependencies"]
24
+ json["dependencies"][name] = version
25
+ end
26
+
27
+ dev.each do |package|
28
+ matches = package.match(/(.+)@(.+)/)
29
+ name, version = matches[1], matches[2]
30
+ json["devDependencies"] = {} unless json["devDependencies"]
31
+ json["devDependencies"][name] = version
32
+ end
33
+
34
+ drop.each do |package|
35
+ json["dependencies"].delete(package)
36
+ json["devDependencies"].delete(package)
37
+ end
38
+
39
+ package_json.write JSON.pretty_generate(json)
40
+
41
+ system "yarn install --silent"
42
+ else
43
+ say "⏩ No yarn depdencies to add or remove. Skipping."
44
+
45
+ end
46
+
47
+ if bundler == "esbuild" && json["scripts"]["build"] != "node esbuild.config.mjs"
48
+ json["scripts"]["build:default"] = json["scripts"]["build"]
49
+ json["scripts"]["build"] = "node esbuild.config.mjs"
50
+ package_json.write JSON.pretty_generate(json)
51
+ say "✅ Your build script has been updated to use esbuild.config.mjs"
52
+ else
53
+ say "⏩ Your build script is already setup. Skipping."
54
+ end
55
+
56
+ complete_step :yarn
@@ -0,0 +1,249 @@
1
+ # frozen_string_literal: true
2
+
3
+ include Rails.application.routes.url_helpers
4
+
5
+ CR_STEPS = {
6
+ "action_cable" => "Action Cable",
7
+ "webpacker" => "CableReady using Webpacker",
8
+ "shakapacker" => "CableReady using Shakapacker",
9
+ "npm_packages" => "Install CableReady npm package",
10
+ "importmap" => "Install CableReady using importmaps",
11
+ "esbuild" => "Install CableReady using esbuild",
12
+ "config" => "Client initialization",
13
+ "initializers" => "Generate and configure initializer",
14
+ "development" => "development environment configuration",
15
+ "spring" => "Disable spring gem. Spring has been removed from Rails 7",
16
+ "mrujs" => "Swap out UJS for mrujs",
17
+ "broadcaster" => "Make CableReady::Broadcaster available to channels, controllers, jobs and models",
18
+ "updatable" => "Include CableReady::Updatable in Active Record model classes",
19
+ "vite" => "CableReady using Vite",
20
+ "compression" => "Compress WebSockets traffic with gzip"
21
+ }
22
+
23
+ CR_BUNDLERS = {
24
+ "webpacker" => ["npm_packages", "webpacker", "config", "action_cable", "development", "initializers", "broadcaster", "updatable", "spring", "yarn", "bundle"],
25
+ "esbuild" => ["npm_packages", "esbuild", "config", "action_cable", "development", "initializers", "broadcaster", "updatable", "spring", "yarn", "bundle"],
26
+ "vite" => ["npm_packages", "vite", "config", "action_cable", "development", "initializers", "broadcaster", "updatable", "spring", "yarn", "bundle"],
27
+ "shakapacker" => ["npm_packages", "shakapacker", "config", "action_cable", "development", "initializers", "broadcaster", "updatable", "spring", "yarn", "bundle"],
28
+ "importmap" => ["config", "action_cable", "importmap", "development", "initializers", "broadcaster", "updatable", "spring", "bundle"]
29
+ }
30
+
31
+ def run_install_template(template, force: false, trace: false)
32
+ puts "--- [#{template}] ----"
33
+
34
+ if Rails.root.join("tmp/cable_ready_installer/halt").exist?
35
+ FileUtils.rm(Rails.root.join("tmp/cable_ready_installer/halt"))
36
+ puts "CableReady installation halted. Please fix the issues above and try again."
37
+ exit
38
+ end
39
+ if Rails.root.join("tmp/cable_ready_installer/#{template}").exist? && !force
40
+ puts "👍 Step #{template} already completed. Skipping."
41
+ return
42
+ end
43
+
44
+ system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/#{template}.rb", __dir__)} SKIP_SANITY_CHECK=true #{"--trace" if trace}"
45
+
46
+ puts
47
+ end
48
+
49
+ namespace :cable_ready do
50
+ desc "✨ Install CableReady ✨"
51
+ task :install do
52
+ FileUtils.mkdir_p(Rails.root.join("tmp/cable_ready_installer/templates"))
53
+ FileUtils.mkdir_p(Rails.root.join("tmp/cable_ready_installer/working"))
54
+ install_complete = Rails.root.join("tmp/cable_ready_installer/complete")
55
+
56
+ bundler = nil
57
+ options = {}
58
+
59
+ ARGV.each do |arg|
60
+ # make sure we have a valid build tool specified, or proceed to automatic detection
61
+ if ["webpacker", "esbuild", "vite", "shakapacker", "importmap"].include?(arg)
62
+ bundler = arg
63
+ else
64
+ kv = arg.split("=")
65
+ if kv.length == 2
66
+ kv[1] = if kv[1] == "true"
67
+ true
68
+ else
69
+ (kv[1] == "false") ? false : kv[1]
70
+ end
71
+ options[kv[0]] = kv[1]
72
+ end
73
+ end
74
+ end
75
+
76
+ options_path = Rails.root.join("tmp/cable_ready_installer/options")
77
+ options_path.write(options.to_yaml)
78
+
79
+ if defined?(StimulusReflex)
80
+ puts "✨ \e[38;5;220mStimulusReflex\e[0m is present in this project ✨"
81
+ puts
82
+ puts "CableReady will be installed with StimulusReflex. Just run: \e[38;5;231mrails stimulus_reflex:install\e[0m"
83
+ puts
84
+ puts "Get help on Discord: \e[4;97mhttps://discord.gg/stimulus-reflex\e[0m. \e[38;5;196mWe are here for you.\e[0m 💙"
85
+ puts
86
+ exit
87
+ end
88
+
89
+ if install_complete.exist?
90
+ puts "✨ \e[38;5;220mCableReady\e[0m is already installed ✨"
91
+ puts
92
+ puts "To restart the installation process, run: \e[38;5;231mrails cable_ready:install:restart\e[0m"
93
+ puts
94
+ puts "To get started, check out \e[4;97mhttps://cableready.stimulusreflex.com/guide/cableready-101\e[0m"
95
+ puts "or get help on Discord: \e[4;97mhttps://discord.gg/stimulus-reflex\e[0m. \e[38;5;196mWe are here for you.\e[0m 💙"
96
+ puts
97
+ exit
98
+ end
99
+
100
+ # if there is an installation in progress, continue where we left off
101
+ cached_entrypoint = Rails.root.join("tmp/cable_ready_installer/entrypoint")
102
+
103
+ if cached_entrypoint.exist?
104
+ entrypoint = File.read(cached_entrypoint)
105
+ puts "✨ Resuming \e[38;5;220mCableReady\e[0m installation ✨"
106
+ puts
107
+ puts "If you have any setup issues, please consult \e[4;97mhttps://cableready.stimulusreflex.com/hello-world/setup\e[0m"
108
+ puts "or get help on Discord: \e[4;97mhttps://discord.gg/stimulus-reflex\e[0m. \e[38;5;196mWe are here for you.\e[0m 💙"
109
+ puts
110
+ puts "Resuming installation into \e[1m#{entrypoint}\e[22m"
111
+ puts "Run \e[1;94mrails cable_ready:install:restart\e[0m to restart the installation process"
112
+ puts
113
+ else
114
+ puts "✨ Installing \e[38;5;220mCableReady\e[0m ✨"
115
+ puts
116
+ puts "If you have any setup issues, please consult \e[4;97mhttps://cableready.stimulusreflex.com/hello-world/setup\e[0m"
117
+ puts "or get help on Discord: \e[4;97mhttps://discord.gg/stimulus-reflex\e[0m. \e[38;5;196mWe are here for you.\e[0m 💙"
118
+ if Rails.root.join(".git").exist?
119
+ puts
120
+ puts "We recommend running \e[1;94mgit commit\e[0m before proceeding. A diff will be generated at the end."
121
+ end
122
+
123
+ if options.key? "entrypoint"
124
+ entrypoint = options["entrypoint"]
125
+ else
126
+ entrypoint = [
127
+ "app/javascript",
128
+ "app/frontend"
129
+ ].find { |path| File.exist?(Rails.root.join(path)) } || "app/javascript"
130
+
131
+ puts
132
+ puts "Where do JavaScript files live in your app? Our best guess is: \e[1m#{entrypoint}\e[22m 🤔"
133
+ puts "Press enter to accept this, or type a different path."
134
+ print "> "
135
+ input = $stdin.gets.chomp
136
+ entrypoint = input unless input.blank?
137
+ end
138
+ File.write(cached_entrypoint, entrypoint)
139
+ end
140
+
141
+ # verify their bundler before starting, unless they explicitly specified on CLI
142
+ if !bundler
143
+ # auto-detect build tool based on existing packages and configuration
144
+ if Rails.root.join("config/importmap.rb").exist?
145
+ bundler = "importmap"
146
+ elsif Rails.root.join("package.json").exist?
147
+ package_json = File.read(Rails.root.join("package.json"))
148
+ bundler = "webpacker" if package_json.include?('"@rails/webpacker":')
149
+ bundler = "esbuild" if package_json.include?('"esbuild":')
150
+ bundler = "vite" if package_json.include?('"vite":')
151
+ bundler = "shakapacker" if package_json.include?('"shakapacker":')
152
+ if !bundler
153
+ puts "❌ You must be using a node-based bundler such as esbuild, webpacker, vite or shakapacker (package.json) or importmap (config/importmap.rb) to use CableReady."
154
+ exit
155
+ end
156
+ else
157
+ puts "❌ You must be using a node-based bundler such as esbuild, webpacker, vite or shakapacker (package.json) or importmap (config/importmap.rb) to use CableReady."
158
+ exit
159
+ end
160
+
161
+ puts
162
+ puts "It looks like you're using \e[1m#{bundler}\e[22m as your bundler. Is that correct? (Y/n)"
163
+ print "> "
164
+ input = $stdin.gets.chomp
165
+ if input.downcase == "n"
166
+ puts
167
+ puts "CableReady installation supports: esbuild, webpacker, vite, shakapacker and importmap."
168
+ puts "Please run \e[1;94mrails cable_ready:install [bundler]\e[0m to install CableReady."
169
+ exit
170
+ end
171
+ end
172
+
173
+ File.write("tmp/cable_ready_installer/bundler", bundler)
174
+ FileUtils.touch("tmp/cable_ready_installer/backups")
175
+ File.write("tmp/cable_ready_installer/template_src", File.expand_path("../../generators/cable_ready/templates/", __dir__))
176
+
177
+ # do the things
178
+ CR_BUNDLERS[bundler].each do |template|
179
+ run_install_template(template, trace: !!options["trace"])
180
+ end
181
+
182
+ puts
183
+ puts "🎉 \e[1;92mCableReady has been successfully installed!\e[22m 🎉"
184
+ puts
185
+ puts "👉 \e[4;97mhttps://cableready.stimulusreflex.com/guide/cableready-101\e[0m"
186
+ puts
187
+ puts "Join over 2000 CableReady developers on Discord: \e[4;97mhttps://discord.gg/stimulus-reflex\e[0m"
188
+ puts
189
+
190
+ backups = File.readlines("tmp/cable_ready_installer/backups").map(&:chomp)
191
+
192
+ if backups.any?
193
+ puts "🙆 The following files were modified during installation:"
194
+ puts
195
+ backups.each { |backup| puts " #{backup}" }
196
+ puts
197
+ puts "Each of these files has been backed up with a .bak extension. Please review the changes carefully."
198
+ puts "If you're happy with the changes, you can delete the .bak files."
199
+ puts
200
+ end
201
+
202
+ if Rails.root.join(".git").exist?
203
+ system "git diff > tmp/cable_ready_installer.diff"
204
+ puts "🏮 A diff of all changes has been saved to \e[1mtmp/cable_ready_installer.diff\e[22m"
205
+ puts
206
+ end
207
+
208
+ FileUtils.touch(install_complete)
209
+ `pkill -f spring` if Rails.root.join("tmp/cable_ready_installer/kill_spring").exist?
210
+ exit
211
+ end
212
+
213
+ namespace :install do
214
+ desc "Restart CableReady installation"
215
+ task :restart do
216
+ FileUtils.rm_rf Rails.root.join("tmp/cable_ready_installer")
217
+ system "rails cable_ready:install #{ARGV.join(" ")}"
218
+ exit
219
+ end
220
+
221
+ desc <<~DESC
222
+ Re-run specific CableReady install steps
223
+
224
+ #{CR_STEPS.sort.map { |step, description| "#{step.ljust(20)} #{description}" }.join("\n")}
225
+ DESC
226
+
227
+ task :step do
228
+ def warning(step = nil)
229
+ return if step.to_s.include?("=")
230
+ if step
231
+ puts "⚠️ #{step} is not a valid step. Valid steps are: #{CR_STEPS.keys.join(", ")}"
232
+ else
233
+ puts "❌ You must specify a step to re-run. Valid steps are: #{CR_STEPS.keys.join(", ")}"
234
+ puts "Example: \e[1;94mrails cable_ready:install:step initializers\e[0m"
235
+ end
236
+ end
237
+
238
+ warning if ARGV.empty?
239
+
240
+ ARGV.each do |step|
241
+ CR_STEPS.include?(step) ? run_install_template(step, force: true) : warning(step)
242
+ end
243
+
244
+ run_install_template(:bundle, force: true)
245
+ run_install_template(:yarn, force: true)
246
+ exit
247
+ end
248
+ end
249
+ end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cable_ready",
3
- "version": "5.0.0-pre9",
3
+ "version": "5.0.0-pre10",
4
4
  "description": "CableReady helps you create great real-time user experiences by making it simple to trigger client-side DOM changes from server-side Ruby.",
5
5
  "keywords": [
6
6
  "ruby",
@@ -13,18 +13,23 @@
13
13
  "client-side",
14
14
  "dom"
15
15
  ],
16
- "homepage": "https://cableready.stimulusreflex.com/",
17
- "bugs": {
18
- "url": "https://github.com/stimulusreflex/cable_ready/issues"
19
- },
20
- "repository": {
21
- "type": "git",
22
- "url": "git+https://github.com:stimulusreflex/cable_ready.git"
23
- },
16
+ "homepage": "https://cableready.stimulusreflex.com",
17
+ "bugs": "https://github.com/stimulusreflex/cable_ready/issues",
18
+ "repository": "https://github.com/stimulusreflex/cable_ready",
24
19
  "license": "MIT",
25
20
  "author": "Nathan Hopkins <natehop@gmail.com>",
26
- "main": "./dist/cable_ready.umd.min.js",
27
- "module": "./dist/cable_ready.min.js",
21
+ "contributors": [
22
+ "Andrew Mason <andrewmcodes@protonmail.com>",
23
+ "Julian Rubisch <julian@julianrubisch.at>",
24
+ "Marco Roth <marco.roth@intergga.ch>",
25
+ "Nathan Hopkins <natehop@gmail.com>"
26
+ ],
27
+ "main": "./dist/cable_ready.js",
28
+ "module": "./dist/cable_ready.js",
29
+ "browser": "./dist/cable_ready.js",
30
+ "import": "./dist/cable_ready.js",
31
+ "unpkg": "./dist/cable_ready.umd.js",
32
+ "umd": "./dist/cable_ready.umd.js",
28
33
  "files": [
29
34
  "dist/*",
30
35
  "javascript/*"
@@ -35,17 +40,22 @@
35
40
  "prettier-standard:check": "yarn run prettier-standard --check ./javascript/**/*.js rollup.config.js",
36
41
  "prettier-standard:format": "yarn run prettier-standard ./javascript/**/*.js rollup.config.js",
37
42
  "build": "yarn rollup -c",
38
- "watch": "yarn rollup -wc"
43
+ "watch": "yarn rollup -wc",
44
+ "test": "web-test-runner javascript/test/**/*.test.js"
39
45
  },
40
46
  "dependencies": {
41
- "morphdom": "^2.6.1"
47
+ "morphdom": "2.6.1"
42
48
  },
43
49
  "devDependencies": {
44
- "@rollup/plugin-commonjs": "^21.0.3",
45
- "@rollup/plugin-json": "^4.1.0",
46
- "@rollup/plugin-node-resolve": "^13.1.3",
50
+ "@open-wc/testing": "^3.1.7",
51
+ "@rollup/plugin-json": "^6.0.0",
52
+ "@rollup/plugin-node-resolve": "^15.0.1",
53
+ "@rollup/plugin-terser": "^0.4.0",
54
+ "@web/dev-server-esbuild": "^0.3.3",
55
+ "@web/dev-server-rollup": "^0.3.21",
56
+ "@web/test-runner": "^0.15.0",
47
57
  "prettier-standard": "^16.4.1",
48
- "rollup": "^2.70.1",
49
- "rollup-plugin-terser": "^7.0.2"
58
+ "rollup": "^3.15.0",
59
+ "sinon": "^15.0.1"
50
60
  }
51
61
  }
@@ -1,13 +1,13 @@
1
1
  import resolve from '@rollup/plugin-node-resolve'
2
- import commonjs from '@rollup/plugin-commonjs'
3
2
  import json from '@rollup/plugin-json'
4
- import { terser } from 'rollup-plugin-terser'
3
+ import terser from '@rollup/plugin-terser'
5
4
 
6
5
  const pretty = () => {
7
6
  return terser({
8
7
  mangle: false,
9
8
  compress: false,
10
9
  format: {
10
+ comments: 'all',
11
11
  beautify: true,
12
12
  indent_level: 2
13
13
  }
@@ -33,29 +33,30 @@ const umdConfig = {
33
33
  globals: { morphdom: 'morphdom' }
34
34
  }
35
35
 
36
- const distFolders = ['dist/', 'app/assets/javascripts/']
36
+ const baseName = 'cable_ready'
37
+ const distFolders = ['dist', 'app/assets/javascripts']
37
38
 
38
39
  const output = distFolders
39
40
  .map(distFolder => [
40
41
  {
41
42
  ...esConfig,
42
- file: `${distFolder}/cable_ready.js`,
43
+ file: `${distFolder}/${baseName}.js`,
43
44
  plugins: [pretty()]
44
45
  },
45
46
  {
46
47
  ...esConfig,
47
- file: `${distFolder}/cable_ready.min.js`,
48
+ file: `${distFolder}/${baseName}.min.js`,
48
49
  sourcemap: true,
49
50
  plugins: [minify()]
50
51
  },
51
52
  {
52
53
  ...umdConfig,
53
- file: `${distFolder}/cable_ready.umd.js`,
54
+ file: `${distFolder}/${baseName}.umd.js`,
54
55
  plugins: [pretty()]
55
56
  },
56
57
  {
57
58
  ...umdConfig,
58
- file: `${distFolder}/cable_ready.umd.min.js`,
59
+ file: `${distFolder}/${baseName}.umd.min.js`,
59
60
  sourcemap: true,
60
61
  plugins: [minify()]
61
62
  }
@@ -67,7 +68,7 @@ export default [
67
68
  external: ['morphdom'],
68
69
  input: 'javascript/index.js',
69
70
  output,
70
- plugins: [commonjs(), resolve(), json()],
71
+ plugins: [resolve(), json()],
71
72
  watch: {
72
73
  include: 'javascript/**'
73
74
  }
@@ -0,0 +1,12 @@
1
+ import rollupJson from '@rollup/plugin-json'
2
+ import { fromRollup } from '@web/dev-server-rollup'
3
+
4
+ const json = fromRollup(rollupJson)
5
+
6
+ export default {
7
+ nodeResolve: true,
8
+ mimeTypes: {
9
+ '**/*.json': 'js'
10
+ },
11
+ plugins: [json({})]
12
+ }