Skip to content

Commit 51c23ff

Browse files
committed
configure Stimulus and Turbo (#1296)
1 parent 21f0faf commit 51c23ff

File tree

15 files changed

+139
-110
lines changed

15 files changed

+139
-110
lines changed

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ gem "propshaft"
2222
gem "puma", "~> 7.0"
2323
gem "rack-ssl"
2424
gem "sass"
25+
gem "stimulus-rails"
2526
gem "stripe"
27+
gem "strong_migrations"
2628
gem "thread"
29+
gem "turbo-rails"
2730
gem "will_paginate"
2831

2932
group :development do
@@ -39,10 +42,12 @@ group :development do
3942
end
4043

4144
group :development, :test do
45+
gem "bundler-audit", require: false
4246
gem "capybara"
4347
gem "coveralls_reborn", require: false
4448
gem "debug"
4549
gem "factory_bot"
50+
gem "factory_bot_rails", require: false
4651
gem "pry-byebug"
4752
gem "rspec"
4853
gem "rspec-rails"

Gemfile.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ GEM
100100
brakeman (8.0.2)
101101
racc
102102
builder (3.3.0)
103+
bundler-audit (0.9.3)
104+
bundler (>= 1.2.0)
105+
thor (~> 1.0)
103106
byebug (13.0.0)
104107
reline (>= 0.6.0)
105108
capybara (3.40.0)
@@ -146,6 +149,9 @@ GEM
146149
tzinfo
147150
factory_bot (6.5.6)
148151
activesupport (>= 6.1.0)
152+
factory_bot_rails (6.5.1)
153+
factory_bot (~> 6.5)
154+
railties (>= 6.1.0)
149155
feedbag (1.0.2)
150156
addressable (~> 2.8)
151157
nokogiri (~> 1.8, >= 1.8.2)
@@ -381,8 +387,12 @@ GEM
381387
simplecov_json_formatter (~> 0.1)
382388
simplecov-html (0.13.2)
383389
simplecov_json_formatter (0.1.4)
390+
stimulus-rails (1.3.4)
391+
railties (>= 6.0.0)
384392
stringio (3.2.0)
385393
stripe (18.3.1)
394+
strong_migrations (2.5.2)
395+
activerecord (>= 7.1)
386396
sync (0.5.0)
387397
term-ansicolor (1.11.3)
388398
tins (~> 1)
@@ -396,6 +406,9 @@ GEM
396406
readline
397407
sync
398408
tsort (0.2.0)
409+
turbo-rails (2.0.20)
410+
actionpack (>= 7.1.0)
411+
railties (>= 7.1.0)
399412
tzinfo (2.0.6)
400413
concurrent-ruby (~> 1.0)
401414
unicode-display_width (3.2.0)
@@ -440,11 +453,13 @@ DEPENDENCIES
440453
bcrypt
441454
bootsnap
442455
brakeman
456+
bundler-audit
443457
capybara
444458
coveralls_reborn
445459
debug
446460
dotenv-rails
447461
factory_bot
462+
factory_bot_rails
448463
feedbag
449464
feedjira
450465
good_job (~> 4.13.0)
@@ -470,8 +485,11 @@ DEPENDENCIES
470485
sass
471486
selenium-webdriver
472487
simplecov
488+
stimulus-rails
473489
stripe
490+
strong_migrations
474491
thread
492+
turbo-rails
475493
web-console
476494
webdrivers
477495
webmock

app/javascript/application.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
// @ts-nocheck
2+
import "@hotwired/turbo-rails";
3+
import "@rails/activestorage";
24
import "jquery";
35
import "bootstrap";
46
import "mousetrap";
57
import "jquery-visible";
68
import _ from "underscore";
79
import Backbone from "backbone";
810

11+
import "./controllers/index";
12+
13+
Turbo.session.drive = false;
14+
915
/* global jQuery, Mousetrap */
1016
var $ = jQuery;
1117

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {Application} from "@hotwired/stimulus";
2+
3+
const application = Application.start();
4+
5+
export {application};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {Controller} from "@hotwired/stimulus";
2+
3+
export default class extends Controller {
4+
connect(): void {
5+
this.element.textContent = "Hello World!";
6+
}
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* This file is auto-generated by ./bin/rails stimulus:manifest:update
3+
* Run that command whenever you add a new controller or create them with
4+
* ./bin/rails generate stimulus controllerName
5+
*/
6+
7+
import {application} from "./application";
8+
9+
import DialogController from "./dialog_controller";
10+
application.register("dialog", DialogController);

app/javascript/helpers/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function assert<T>(value: T): NonNullable<T> {
2+
if (value === null || value === undefined) {
3+
throw new Error("value is null or undefined");
4+
}
5+
6+
return value;
7+
}
8+
9+
export {assert};

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
"test": "vitest run --coverage"
1111
},
1212
"dependencies": {
13+
"@hotwired/stimulus": "^3.2.2",
14+
"@hotwired/turbo": "^8.0.20",
15+
"@hotwired/turbo-rails": "^8.0.20",
1316
"@fontsource/lato": "^5.2.7",
1417
"@fontsource/reenie-beanie": "^5.2.8",
18+
"@rails/actioncable": "^8.1.100",
19+
"@rails/activestorage": "^8.1.100",
1520
"backbone": "1.0.0",
1621
"bootstrap": "3.1.1",
1722
"font-awesome": "4.7.0",
@@ -25,9 +30,11 @@
2530
"@eslint/js": "^10.0.1",
2631
"@stylistic/eslint-plugin": "^5.7.0",
2732
"@types/backbone": "latest",
33+
"@types/hotwired__turbo": "^8.0.5",
2834
"@types/jquery": "latest",
2935
"@types/mousetrap": "latest",
3036
"@types/node": "^25.2.3",
37+
"@types/rails__actioncable": "^8.0.3",
3138
"@types/underscore": "latest",
3239
"@typescript-eslint/eslint-plugin": "^8.50.0",
3340
"@typescript-eslint/parser": "^8.50.0",

pnpm-lock.yaml

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/javascript/channels/consumer_spec.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)