stimulus-rails 0.3.9 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +0,0 @@
1
- // Load all the controllers within this directory and all subdirectories.
2
- // Controller files must be named *_controller.js or *_controller.ts.
3
-
4
- import { Application } from "stimulus"
5
- import { definitionsFromContext } from "stimulus/webpack-helpers"
6
-
7
- window.Stimulus = Application.start()
8
- const context = require.context("controllers", true, /_controller\.(js|ts)$/)
9
- Stimulus.load(definitionsFromContext(context))
@@ -1,27 +0,0 @@
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")
4
-
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
13
-
14
- say "Creating controllers directory"
15
- copy_file "#{__dir__}/app/javascript/controllers/hello_controller.js", APP_JS_ROOT.join("controllers/hello_controller.js")
16
-
17
- if IMPORTMAP_PATH.exist?
18
- say "Pin @hotwired/stimulus and @hotwired/stimulus-importmap-autoloader in config/importmap.rb"
19
- insert_into_file \
20
- IMPORTMAP_PATH.to_s,
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),
22
- after: "Rails.application.config.importmap.draw do\n"
23
- else
24
- say <<~INSTRUCTIONS, :red
25
- You must add @hotwired/stimulus and @hotwired/stimulus-importmap-autoloader to your importmap to reference them via ESM.
26
- INSTRUCTIONS
27
- end
@@ -1,11 +0,0 @@
1
- say "Appending Stimulus setup code to #{Webpacker.config.source_entry_path}/application.js"
2
- append_to_file "#{Webpacker.config.source_entry_path}/application.js", %(\nimport "controllers")
3
-
4
- say "Creating controllers directory"
5
- directory "#{__dir__}/app/javascript/controllers", "#{Webpacker.config.source_path}/controllers"
6
-
7
- say "Using Stimulus NPM package"
8
- gsub_file "#{Webpacker.config.source_path}/controllers/hello_controller.js", /@hotwired\//, ''
9
-
10
- say "Installing all Stimulus dependencies"
11
- run "yarn add stimulus"