stimulus-rails 1.2.2 → 1.3.0
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.
- checksums.yaml +4 -4
- data/lib/install/stimulus_with_bun.rb +18 -0
- data/lib/stimulus/version.rb +1 -1
- data/lib/tasks/stimulus_tasks.rake +21 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c89b0f73a5f7933de25b0656cb2c82c916c05eef10141152bf2e3f21806c4425
|
4
|
+
data.tar.gz: b8d71e42951d906da9c8ec5aa3e7db501baec6f9b0e1c793a1e476394b00d246
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0299ff4d4b41706c1a07fbcca3342ec4ff88c5198ff5c24e5204fc34487c7a78b9ad844173bda7ef42e740ff4fb46fc83a59739fe456d58d80c90e0091e7b0e
|
7
|
+
data.tar.gz: acc3c4f0989139464e77e9308904b39dfe2b60058c71cb1c17a310a68f22b259b98f5ae511a42a9c614f0ffa059bac454d9dc870efb4aa79af4f7e003779f01c
|
@@ -0,0 +1,18 @@
|
|
1
|
+
say "Create controllers directory"
|
2
|
+
empty_directory "app/javascript/controllers"
|
3
|
+
copy_file "#{__dir__}/app/javascript/controllers/index_for_node.js",
|
4
|
+
"app/javascript/controllers/index.js"
|
5
|
+
copy_file "#{__dir__}/app/javascript/controllers/application.js",
|
6
|
+
"app/javascript/controllers/application.js"
|
7
|
+
copy_file "#{__dir__}/app/javascript/controllers/hello_controller.js",
|
8
|
+
"app/javascript/controllers/hello_controller.js"
|
9
|
+
|
10
|
+
if (Rails.root.join("app/javascript/application.js")).exist?
|
11
|
+
say "Import Stimulus controllers"
|
12
|
+
append_to_file "app/javascript/application.js", %(import "./controllers"\n)
|
13
|
+
else
|
14
|
+
say %(Couldn't find "app/javascript/application.js".\nYou must import "./controllers" in your JavaScript entrypoint file), :red
|
15
|
+
end
|
16
|
+
|
17
|
+
say "Install Stimulus"
|
18
|
+
run "bun add @hotwired/stimulus"
|
data/lib/stimulus/version.rb
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
require "stimulus/manifest"
|
2
2
|
|
3
|
-
|
3
|
+
module Stimulus
|
4
|
+
module Tasks
|
5
|
+
extend self
|
6
|
+
def run_stimulus_install_template(path)
|
7
|
+
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/#{path}.rb", __dir__)}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def using_bun?
|
11
|
+
Rails.root.join("bun.config.js").exist?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
4
15
|
|
5
16
|
namespace :stimulus do
|
6
17
|
desc "Install Stimulus into the app"
|
7
18
|
task :install do
|
8
19
|
if Rails.root.join("config/importmap.rb").exist?
|
9
20
|
Rake::Task["stimulus:install:importmap"].invoke
|
21
|
+
elsif Rails.root.join("package.json").exist? && Stimulus::Tasks.using_bun?
|
22
|
+
Rake::Task["stimulus:install:bun"].invoke
|
10
23
|
elsif Rails.root.join("package.json").exist?
|
11
24
|
Rake::Task["stimulus:install:node"].invoke
|
12
25
|
else
|
@@ -17,12 +30,17 @@ namespace :stimulus do
|
|
17
30
|
namespace :install do
|
18
31
|
desc "Install Stimulus on an app running importmap-rails"
|
19
32
|
task :importmap do
|
20
|
-
run_stimulus_install_template "stimulus_with_importmap"
|
33
|
+
Stimulus::Tasks.run_stimulus_install_template "stimulus_with_importmap"
|
21
34
|
end
|
22
35
|
|
23
36
|
desc "Install Stimulus on an app running node"
|
24
37
|
task :node do
|
25
|
-
run_stimulus_install_template "stimulus_with_node"
|
38
|
+
Stimulus::Tasks.run_stimulus_install_template "stimulus_with_node"
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Install Stimulus on an app running bun"
|
42
|
+
task :bun do
|
43
|
+
Stimulus::Tasks.run_stimulus_install_template "stimulus_with_bun"
|
26
44
|
end
|
27
45
|
end
|
28
46
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stimulus-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-10-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- lib/install/app/javascript/controllers/hello_controller.js
|
49
49
|
- lib/install/app/javascript/controllers/index_for_importmap.js
|
50
50
|
- lib/install/app/javascript/controllers/index_for_node.js
|
51
|
+
- lib/install/stimulus_with_bun.rb
|
51
52
|
- lib/install/stimulus_with_importmap.rb
|
52
53
|
- lib/install/stimulus_with_node.rb
|
53
54
|
- lib/stimulus-rails.rb
|
@@ -76,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
77
|
- !ruby/object:Gem::Version
|
77
78
|
version: '0'
|
78
79
|
requirements: []
|
79
|
-
rubygems_version: 3.4.
|
80
|
+
rubygems_version: 3.4.15
|
80
81
|
signing_key:
|
81
82
|
specification_version: 4
|
82
83
|
summary: A modest JavaScript framework for the HTML you already have.
|