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,26 +1,48 @@
1
+ require "stimulus/manifest"
2
+
1
3
  def run_stimulus_install_template(path) system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/#{path}.rb", __dir__)}" end
2
4
 
3
5
  namespace :stimulus do
4
6
  desc "Install Stimulus into the app"
5
7
  task :install do
6
- if defined?(Webpacker::Engine)
7
- Rake::Task["stimulus:install:webpacker"].invoke
8
- elsif defined?(Importmap)
9
- Rake::Task["stimulus:install:asset_pipeline"].invoke
8
+ if Rails.root.join("config/importmap.rb").exist?
9
+ Rake::Task["stimulus:install:importmap"].invoke
10
+ elsif Rails.root.join("package.json").exist?
11
+ Rake::Task["stimulus:install:node"].invoke
10
12
  else
11
- puts "You must either be running Webpacker or importmap-rails to use this gem."
13
+ puts "You must either be running with node (package.json) or importmap-rails (config/importmap.rb) to use this gem."
12
14
  end
13
15
  end
14
16
 
15
17
  namespace :install do
16
- desc "Install Stimulus on the app with the asset pipeline"
17
- task :asset_pipeline do
18
- run_stimulus_install_template "stimulus_with_asset_pipeline"
18
+ desc "Install Stimulus on an app running importmap-rails"
19
+ task :importmap do
20
+ run_stimulus_install_template "stimulus_with_importmap"
21
+ end
22
+
23
+ desc "Install Stimulus on an app running node"
24
+ task :node do
25
+ run_stimulus_install_template "stimulus_with_node"
19
26
  end
27
+ end
28
+
29
+ namespace :manifest do
30
+ task :display do
31
+ puts Stimulus::Manifest.generate_from(Rails.root.join("app/javascript/controllers"))
32
+ end
33
+
34
+ task :update do
35
+ manifest =
36
+ Stimulus::Manifest.generate_from(Rails.root.join("app/javascript/controllers"))
20
37
 
21
- desc "Install Stimulus on the app with webpacker"
22
- task :webpacker do
23
- run_stimulus_install_template "stimulus_with_webpacker"
38
+ File.open(Rails.root.join("app/javascript/controllers/index.js"), "w+") do |index|
39
+ index.puts "// This file is auto-generated by ./bin/rails stimulus:manifest:update"
40
+ index.puts "// Run that command whenever you add a new controller or create them with"
41
+ index.puts "// ./bin/rails generate stimulus controllerName"
42
+ index.puts
43
+ index.puts %(import { application } from "./application")
44
+ index.puts manifest
45
+ end
24
46
  end
25
47
  end
26
48
  end
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.3.9
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
@@ -10,10 +10,10 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-08-25 00:00:00.000000000 Z
13
+ date: 2021-12-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: rails
16
+ name: railties
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - ">="
@@ -37,14 +37,22 @@ files:
37
37
  - Rakefile
38
38
  - app/assets/javascripts/stimulus-autoloader.js
39
39
  - app/assets/javascripts/stimulus-importmap-autoloader.js
40
+ - app/assets/javascripts/stimulus-loading.js
40
41
  - app/assets/javascripts/stimulus.js
41
- - app/assets/javascripts/stimulus@2.js
42
+ - app/assets/javascripts/stimulus.min.js
43
+ - app/assets/javascripts/stimulus.min.js.map
44
+ - lib/generators/stimulus/USAGE
45
+ - lib/generators/stimulus/stimulus_generator.rb
46
+ - lib/generators/stimulus/templates/controller.js.tt
47
+ - lib/install/app/javascript/controllers/application.js
42
48
  - lib/install/app/javascript/controllers/hello_controller.js
43
- - lib/install/app/javascript/controllers/index.js
44
- - lib/install/stimulus_with_asset_pipeline.rb
45
- - lib/install/stimulus_with_webpacker.rb
49
+ - lib/install/app/javascript/controllers/index_for_importmap.js
50
+ - lib/install/app/javascript/controllers/index_for_node.js
51
+ - lib/install/stimulus_with_importmap.rb
52
+ - lib/install/stimulus_with_node.rb
46
53
  - lib/stimulus-rails.rb
47
54
  - lib/stimulus/engine.rb
55
+ - lib/stimulus/manifest.rb
48
56
  - lib/stimulus/version.rb
49
57
  - lib/tasks/stimulus_tasks.rake
50
58
  homepage: https://stimulus.hotwired.dev
@@ -68,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
76
  - !ruby/object:Gem::Version
69
77
  version: '0'
70
78
  requirements: []
71
- rubygems_version: 3.1.4
79
+ rubygems_version: 3.2.32
72
80
  signing_key:
73
81
  specification_version: 4
74
82
  summary: A modest JavaScript framework for the HTML you already have.