stimulus-rails 0.4.1 → 0.4.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e7e80a2e07dc6e40f109bc5c009bbea41b02057c8a7b489b638c0a964d14f22
|
4
|
+
data.tar.gz: aa0979ef349cd0c4a49b27c11448663cb40728643bbf43f68a3136ae491e7ab7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 694ab07e593aca69e7abfb0e22c4459ddc27be5d7a5f8cdaa35dfb957f05d6da45e580ec7b9c22af09911a0c2901b4b459a4fdad5ecbbf9165052c047d44d56e
|
7
|
+
data.tar.gz: 3c1412141e0c2a9c2b29fea34f3946c0c14610d69b37c15557100d0a12422948f9be6d6d8977b7059d8b0aa233e1456eb3d82b78ec164881df39a2d1c3a8dc1d
|
@@ -1,13 +1,17 @@
|
|
1
1
|
// FIXME: es-module-shim won't shim the dynamic import without this explicit import
|
2
2
|
import "@hotwired/stimulus"
|
3
3
|
|
4
|
-
export function registerControllersFrom(under,
|
5
|
-
const paths = Object.keys(
|
4
|
+
export function registerControllersFrom(under, application) {
|
5
|
+
const paths = Object.keys(parseImportmapJson())
|
6
6
|
.filter(path => path.match(new RegExp(`^${under}/.*_controller$`)))
|
7
7
|
|
8
8
|
paths.forEach(path => registerControllerFromPath(path, under, application))
|
9
9
|
}
|
10
10
|
|
11
|
+
export function parseImportmapJson() {
|
12
|
+
return JSON.parse(document.querySelector("script[type=importmap]").text).imports
|
13
|
+
}
|
14
|
+
|
11
15
|
function registerControllerFromPath(path, under, application) {
|
12
16
|
const name = path
|
13
17
|
.replace(`${under}/`, "")
|
@@ -9,5 +9,4 @@ window.Stimulus = application
|
|
9
9
|
|
10
10
|
// Import and register all your controllers from the importmap under controllers/*
|
11
11
|
import { registerControllersFrom } from "@hotwired/stimulus-importmap-autoloader"
|
12
|
-
|
13
|
-
registerControllersFrom("controllers", importmap, application)
|
12
|
+
registerControllersFrom("controllers", application)
|
@@ -12,8 +12,12 @@ end
|
|
12
12
|
copy_file "#{__dir__}/app/javascript/controllers/hello_controller.js",
|
13
13
|
"app/javascript/controllers/hello_controller.js"
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
if (Rails.root.join("app/javascript/application.js")).exist?
|
16
|
+
say "Import Stimulus controllers"
|
17
|
+
append_to_file "app/javascript/application.js", %(import "./controllers"\n)
|
18
|
+
else
|
19
|
+
say %(You must import "./controllers" in your JavaScript entrypoint), :red
|
20
|
+
end
|
17
21
|
|
18
22
|
say "Install Stimulus"
|
19
23
|
run "yarn add @hotwired/stimulus"
|
data/lib/stimulus/version.rb
CHANGED
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: 0.4.
|
4
|
+
version: 0.4.2
|
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: 2021-09-
|
13
|
+
date: 2021-09-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|