stimulus-rails 0.3.4 → 0.3.8
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/app/assets/javascripts/stimulus-importmap-autoloader.js +2 -2
- data/lib/install/app/{assets/javascripts → javascript}/controllers/hello_controller.js +0 -0
- data/lib/install/app/{assets/javascripts → javascript}/controllers/index.js +0 -0
- data/lib/install/stimulus_with_asset_pipeline.rb +15 -8
- data/lib/install/stimulus_with_webpacker.rb +1 -1
- data/lib/stimulus/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a64fee1feee0e56676344567cace01dacfa01bb35d26ab4e6854f1f7883ac59f
|
4
|
+
data.tar.gz: afaa2386c12cb57d2dc6d027cb0f0e8fd412ce52f3f622b349cc6dfc3947b8e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9358c33379e5daddcf7ca18f81de2cbb74d1306f4183892f58529c351a76575287abc8d5139570edbaa1b95399f514ea9ca1d05b881c21650ef1ea94a230dc1
|
7
|
+
data.tar.gz: 9201fd2044696e5c30feeef59ea819a9c5260832483107ce5da89037debc1aadd37f1f1f710a8fae3d15ee6764b90866a3527ae80fe4e821f7d89e9b8e75cbca
|
@@ -2,11 +2,11 @@ import { Application } from "@hotwired/stimulus"
|
|
2
2
|
|
3
3
|
const application = Application.start()
|
4
4
|
|
5
|
-
const importmap =
|
5
|
+
const importmap = JSON.parse(document.querySelector("script[type=importmap]").text)
|
6
6
|
const importedControllerPaths = Object.keys(importmap.imports).filter((e) => e.match("controllers/"))
|
7
7
|
|
8
8
|
importedControllerPaths.forEach(function(path) {
|
9
|
-
const name = path.replace("controllers/", "").replace("_controller", "").replace(
|
9
|
+
const name = path.replace("controllers/", "").replace("_controller", "").replace(/\//g, "--").replace(/_/g, "-")
|
10
10
|
|
11
11
|
import(path)
|
12
12
|
.then(module => application.register(name, module.default))
|
File without changes
|
File without changes
|
@@ -1,20 +1,27 @@
|
|
1
|
-
APP_JS_ROOT = Rails.root.join("app/
|
2
|
-
|
1
|
+
APP_JS_ROOT = Rails.root.join("app/javascript")
|
2
|
+
APP_JS_PATH = APP_JS_ROOT.join("application.js")
|
3
|
+
IMPORTMAP_PATH = Rails.root.join("config/importmap.rb")
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
if APP_JS_PATH.exist?
|
6
|
+
say "Import Stimulus importmap autoloader in existing app/javascript/application.js"
|
7
|
+
append_to_file APP_JS_PATH, %(\nimport "@hotwired/stimulus-importmap-autoloader"\n)
|
8
|
+
else
|
9
|
+
say <<~INSTRUCTIONS, :red
|
10
|
+
You must import @hotwired/stimulus and @hotwired/stimulus-importmap-autoloader in your application.js.
|
11
|
+
INSTRUCTIONS
|
12
|
+
end
|
6
13
|
|
7
14
|
say "Creating controllers directory"
|
8
|
-
copy_file "#{__dir__}/app/
|
15
|
+
copy_file "#{__dir__}/app/javascript/controllers/hello_controller.js", APP_JS_ROOT.join("controllers/hello_controller.js")
|
9
16
|
|
10
17
|
if IMPORTMAP_PATH.exist?
|
11
|
-
say "Pin @hotwired/stimulus and @hotwired/stimulus-autoloader in config/
|
18
|
+
say "Pin @hotwired/stimulus and @hotwired/stimulus-importmap-autoloader in config/importmap.rb"
|
12
19
|
insert_into_file \
|
13
20
|
IMPORTMAP_PATH.to_s,
|
14
|
-
%( pin "@hotwired/stimulus", to: "stimulus.js"\n pin "@hotwired/stimulus-autoloader", to: "stimulus-autoloader.js"\n\n),
|
21
|
+
%( pin "@hotwired/stimulus", to: "stimulus.js"\n pin "@hotwired/stimulus-importmap-autoloader", to: "stimulus-importmap-autoloader.js"\n pin_all_from "app/javascript/controllers", under: "controllers"\n\n),
|
15
22
|
after: "Rails.application.config.importmap.draw do\n"
|
16
23
|
else
|
17
|
-
say <<~INSTRUCTIONS, :
|
24
|
+
say <<~INSTRUCTIONS, :red
|
18
25
|
You must add @rails/actiontext and trix to your importmap to reference them via ESM.
|
19
26
|
INSTRUCTIONS
|
20
27
|
end
|
@@ -2,7 +2,7 @@ say "Appending Stimulus setup code to #{Webpacker.config.source_entry_path}/appl
|
|
2
2
|
append_to_file "#{Webpacker.config.source_entry_path}/application.js", %(\nimport "controllers")
|
3
3
|
|
4
4
|
say "Creating controllers directory"
|
5
|
-
directory "#{__dir__}/app/
|
5
|
+
directory "#{__dir__}/app/javascript/controllers", "#{Webpacker.config.source_path}/controllers"
|
6
6
|
|
7
7
|
say "Using Stimulus NPM package"
|
8
8
|
gsub_file "#{Webpacker.config.source_path}/controllers/hello_controller.js", /@hotwired\//, ''
|
data/lib/stimulus/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stimulus-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
8
8
|
- Javan Mahkmali
|
9
9
|
- David Heinemeier Hansson
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-08-
|
13
|
+
date: 2021-08-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: 6.0.0
|
29
|
-
description:
|
29
|
+
description:
|
30
30
|
email: david@loudthinking.com
|
31
31
|
executables: []
|
32
32
|
extensions: []
|
@@ -39,8 +39,8 @@ files:
|
|
39
39
|
- app/assets/javascripts/stimulus-importmap-autoloader.js
|
40
40
|
- app/assets/javascripts/stimulus.js
|
41
41
|
- app/assets/javascripts/stimulus@2.js
|
42
|
-
- lib/install/app/
|
43
|
-
- lib/install/app/
|
42
|
+
- lib/install/app/javascript/controllers/hello_controller.js
|
43
|
+
- lib/install/app/javascript/controllers/index.js
|
44
44
|
- lib/install/stimulus_with_asset_pipeline.rb
|
45
45
|
- lib/install/stimulus_with_webpacker.rb
|
46
46
|
- lib/stimulus-rails.rb
|
@@ -53,7 +53,7 @@ licenses:
|
|
53
53
|
metadata:
|
54
54
|
homepage_uri: https://stimulus.hotwired.dev
|
55
55
|
source_code_uri: https://github.com/hotwired/stimulus-rails
|
56
|
-
post_install_message:
|
56
|
+
post_install_message:
|
57
57
|
rdoc_options: []
|
58
58
|
require_paths:
|
59
59
|
- lib
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
71
|
rubygems_version: 3.1.4
|
72
|
-
signing_key:
|
72
|
+
signing_key:
|
73
73
|
specification_version: 4
|
74
74
|
summary: A modest JavaScript framework for the HTML you already have.
|
75
75
|
test_files: []
|