From 99e06be97ace893b827913732b7842017651331e Mon Sep 17 00:00:00 2001 From: Svyatoslav Kryukov Date: Mon, 23 Dec 2024 12:07:15 +0300 Subject: [PATCH] Drop upstreamed generators --- CHANGELOG.md | 4 + Gemfile | 2 - README.md | 150 +------ inertia_rails-contrib.gemspec | 3 +- .../controller/controller_generator.rb | 16 - .../controller/templates/controller.rb.tt | 10 - lib/generators/inertia/install/frameworks.yml | 98 ----- lib/generators/inertia/install/helpers.rb | 48 --- .../inertia/install/install_generator.rb | 286 -------------- .../install/templates/assets/inertia.svg | 1 - .../install/templates/assets/react.svg | 1 - .../install/templates/assets/svelte.svg | 1 - .../install/templates/assets/vite_ruby.svg | 1 - .../inertia/install/templates/assets/vue.svg | 1 - .../inertia/install/templates/controller.rb | 7 - lib/generators/inertia/install/templates/dev | 23 -- .../inertia/install/templates/initializer.rb | 4 - .../templates/react/InertiaExample.jsx | 60 --- .../templates/react/InertiaExample.module.css | 80 ---- .../templates/react/InertiaExample.tsx | 60 --- .../install/templates/react/inertia.js | 34 -- .../install/templates/react/inertia.ts | 36 -- .../install/templates/react/tsconfig.app.json | 27 -- .../install/templates/react/tsconfig.json | 11 - .../templates/react/tsconfig.node.json | 13 - .../install/templates/react/vite-env.d.ts | 1 - .../templates/svelte/InertiaExample.svelte | 112 ------ .../templates/svelte/InertiaExample.ts.svelte | 112 ------ .../install/templates/svelte/inertia.js | 30 -- .../install/templates/svelte/inertia.ts | 30 -- .../install/templates/svelte/svelte.config.js | 7 - .../install/templates/svelte/tsconfig.json | 21 - .../templates/svelte/tsconfig.node.json | 12 - .../install/templates/svelte/vite-env.d.ts | 2 - .../templates/svelte4/InertiaExample.svelte | 116 ------ .../svelte4/InertiaExample.ts.svelte | 116 ------ .../install/templates/svelte4/inertia.js | 29 -- .../install/templates/svelte4/inertia.ts | 29 -- .../templates/svelte4/svelte.config.js | 7 - .../install/templates/svelte4/tsconfig.json | 21 - .../templates/svelte4/tsconfig.node.json | 12 - .../install/templates/svelte4/vite-env.d.ts | 2 - .../templates/tailwind/application.css | 13 - .../templates/tailwind/postcss.config.js | 6 - .../templates/tailwind/tailwind.config.js.tt | 18 - .../templates/vue/InertiaExample.ts.vue | 117 ------ .../install/templates/vue/InertiaExample.vue | 117 ------ .../inertia/install/templates/vue/inertia.js | 33 -- .../inertia/install/templates/vue/inertia.ts | 33 -- .../install/templates/vue/tsconfig.app.json | 24 -- .../install/templates/vue/tsconfig.json | 11 - .../install/templates/vue/tsconfig.node.json | 22 -- .../install/templates/vue/vite-env.d.ts | 1 - .../inertia/scaffold/scaffold_generator.rb | 16 - .../scaffold_controller_generator.rb | 56 --- .../templates/controller.rb.tt | 100 ----- .../controller/controller_generator.rb | 12 - .../controller/templates/react/view.jsx.tt | 8 - .../templates/svelte/view.svelte.tt | 2 - .../templates/svelte4/view.svelte.tt | 2 - .../controller/templates/vue/view.vue.tt | 4 - .../scaffold/scaffold_generator.rb | 12 - .../scaffold/templates/react/Edit.jsx.tt | 35 -- .../scaffold/templates/react/Form.jsx.tt | 111 ------ .../scaffold/templates/react/Index.jsx.tt | 26 -- .../scaffold/templates/react/New.jsx.tt | 27 -- .../scaffold/templates/react/One.jsx.tt | 26 -- .../scaffold/templates/react/Show.jsx.tt | 39 -- .../scaffold/templates/svelte/Edit.svelte.tt | 36 -- .../scaffold/templates/svelte/Form.svelte.tt | 98 ----- .../scaffold/templates/svelte/Index.svelte.tt | 35 -- .../scaffold/templates/svelte/New.svelte.tt | 29 -- .../scaffold/templates/svelte/One.svelte.tt | 28 -- .../scaffold/templates/svelte/Show.svelte.tt | 41 -- .../scaffold/templates/svelte4/Edit.svelte.tt | 37 -- .../scaffold/templates/svelte4/Form.svelte.tt | 96 ----- .../templates/svelte4/Index.svelte.tt | 36 -- .../scaffold/templates/svelte4/New.svelte.tt | 30 -- .../scaffold/templates/svelte4/One.svelte.tt | 28 -- .../scaffold/templates/svelte4/Show.svelte.tt | 46 --- .../scaffold/templates/vue/Edit.vue.tt | 36 -- .../scaffold/templates/vue/Form.vue.tt | 94 ----- .../scaffold/templates/vue/Index.vue.tt | 31 -- .../scaffold/templates/vue/New.vue.tt | 29 -- .../scaffold/templates/vue/One.vue.tt | 26 -- .../scaffold/templates/vue/Show.vue.tt | 44 --- .../controller/controller_generator.rb | 12 - .../controller/templates/react/view.jsx.tt | 8 - .../templates/svelte/view.svelte.tt | 2 - .../templates/svelte4/view.svelte.tt | 2 - .../controller/templates/vue/view.vue.tt | 4 - .../scaffold/scaffold_generator.rb | 12 - .../scaffold/templates/react/Edit.jsx.tt | 42 -- .../scaffold/templates/react/Form.jsx.tt | 122 ------ .../scaffold/templates/react/Index.jsx.tt | 43 -- .../scaffold/templates/react/New.jsx.tt | 30 -- .../scaffold/templates/react/One.jsx.tt | 26 -- .../scaffold/templates/react/Show.jsx.tt | 54 --- .../scaffold/templates/svelte/Edit.svelte.tt | 44 --- .../scaffold/templates/svelte/Form.svelte.tt | 119 ------ .../scaffold/templates/svelte/Index.svelte.tt | 42 -- .../scaffold/templates/svelte/New.svelte.tt | 32 -- .../scaffold/templates/svelte/One.svelte.tt | 28 -- .../scaffold/templates/svelte/Show.svelte.tt | 57 --- .../scaffold/templates/svelte4/Edit.svelte.tt | 45 --- .../scaffold/templates/svelte4/Form.svelte.tt | 120 ------ .../templates/svelte4/Index.svelte.tt | 43 -- .../scaffold/templates/svelte4/New.svelte.tt | 33 -- .../scaffold/templates/svelte4/One.svelte.tt | 28 -- .../scaffold/templates/svelte4/Show.svelte.tt | 58 --- .../scaffold/templates/vue/Edit.vue.tt | 44 --- .../scaffold/templates/vue/Form.vue.tt | 127 ------ .../scaffold/templates/vue/Index.vue.tt | 43 -- .../scaffold/templates/vue/New.vue.tt | 32 -- .../scaffold/templates/vue/One.vue.tt | 26 -- .../scaffold/templates/vue/Show.vue.tt | 56 --- .../generators/controller_template_base.rb | 56 --- .../generators/scaffold_template_base.rb | 35 -- .../generators_helper.rb | 89 ----- spec/fixtures/dummy/Gemfile | 3 - .../app/views/layouts/application.html.erb | 13 - spec/fixtures/dummy/config/routes.rb | 0 .../app/views/layouts/application.html.erb | 16 - spec/fixtures/with_vite/config/vite.json | 1 - spec/fixtures/with_vite/package.json | 1 - spec/fixtures/with_vite/vite.config.ts | 8 - .../install/install_generator_spec.rb | 374 ------------------ 127 files changed, 17 insertions(+), 5220 deletions(-) delete mode 100644 lib/generators/inertia/controller/controller_generator.rb delete mode 100644 lib/generators/inertia/controller/templates/controller.rb.tt delete mode 100644 lib/generators/inertia/install/frameworks.yml delete mode 100644 lib/generators/inertia/install/helpers.rb delete mode 100644 lib/generators/inertia/install/install_generator.rb delete mode 100644 lib/generators/inertia/install/templates/assets/inertia.svg delete mode 100644 lib/generators/inertia/install/templates/assets/react.svg delete mode 100644 lib/generators/inertia/install/templates/assets/svelte.svg delete mode 100644 lib/generators/inertia/install/templates/assets/vite_ruby.svg delete mode 100644 lib/generators/inertia/install/templates/assets/vue.svg delete mode 100644 lib/generators/inertia/install/templates/controller.rb delete mode 100644 lib/generators/inertia/install/templates/dev delete mode 100644 lib/generators/inertia/install/templates/initializer.rb delete mode 100644 lib/generators/inertia/install/templates/react/InertiaExample.jsx delete mode 100644 lib/generators/inertia/install/templates/react/InertiaExample.module.css delete mode 100644 lib/generators/inertia/install/templates/react/InertiaExample.tsx delete mode 100644 lib/generators/inertia/install/templates/react/inertia.js delete mode 100644 lib/generators/inertia/install/templates/react/inertia.ts delete mode 100644 lib/generators/inertia/install/templates/react/tsconfig.app.json delete mode 100644 lib/generators/inertia/install/templates/react/tsconfig.json delete mode 100644 lib/generators/inertia/install/templates/react/tsconfig.node.json delete mode 100644 lib/generators/inertia/install/templates/react/vite-env.d.ts delete mode 100644 lib/generators/inertia/install/templates/svelte/InertiaExample.svelte delete mode 100644 lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte delete mode 100644 lib/generators/inertia/install/templates/svelte/inertia.js delete mode 100644 lib/generators/inertia/install/templates/svelte/inertia.ts delete mode 100644 lib/generators/inertia/install/templates/svelte/svelte.config.js delete mode 100644 lib/generators/inertia/install/templates/svelte/tsconfig.json delete mode 100644 lib/generators/inertia/install/templates/svelte/tsconfig.node.json delete mode 100644 lib/generators/inertia/install/templates/svelte/vite-env.d.ts delete mode 100644 lib/generators/inertia/install/templates/svelte4/InertiaExample.svelte delete mode 100644 lib/generators/inertia/install/templates/svelte4/InertiaExample.ts.svelte delete mode 100644 lib/generators/inertia/install/templates/svelte4/inertia.js delete mode 100644 lib/generators/inertia/install/templates/svelte4/inertia.ts delete mode 100644 lib/generators/inertia/install/templates/svelte4/svelte.config.js delete mode 100644 lib/generators/inertia/install/templates/svelte4/tsconfig.json delete mode 100644 lib/generators/inertia/install/templates/svelte4/tsconfig.node.json delete mode 100644 lib/generators/inertia/install/templates/svelte4/vite-env.d.ts delete mode 100644 lib/generators/inertia/install/templates/tailwind/application.css delete mode 100644 lib/generators/inertia/install/templates/tailwind/postcss.config.js delete mode 100644 lib/generators/inertia/install/templates/tailwind/tailwind.config.js.tt delete mode 100644 lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue delete mode 100644 lib/generators/inertia/install/templates/vue/InertiaExample.vue delete mode 100644 lib/generators/inertia/install/templates/vue/inertia.js delete mode 100644 lib/generators/inertia/install/templates/vue/inertia.ts delete mode 100644 lib/generators/inertia/install/templates/vue/tsconfig.app.json delete mode 100644 lib/generators/inertia/install/templates/vue/tsconfig.json delete mode 100644 lib/generators/inertia/install/templates/vue/tsconfig.node.json delete mode 100644 lib/generators/inertia/install/templates/vue/vite-env.d.ts delete mode 100644 lib/generators/inertia/scaffold/scaffold_generator.rb delete mode 100644 lib/generators/inertia/scaffold_controller/scaffold_controller_generator.rb delete mode 100644 lib/generators/inertia/scaffold_controller/templates/controller.rb.tt delete mode 100644 lib/generators/inertia_templates/controller/controller_generator.rb delete mode 100644 lib/generators/inertia_templates/controller/templates/react/view.jsx.tt delete mode 100644 lib/generators/inertia_templates/controller/templates/svelte/view.svelte.tt delete mode 100644 lib/generators/inertia_templates/controller/templates/svelte4/view.svelte.tt delete mode 100644 lib/generators/inertia_templates/controller/templates/vue/view.vue.tt delete mode 100644 lib/generators/inertia_templates/scaffold/scaffold_generator.rb delete mode 100644 lib/generators/inertia_templates/scaffold/templates/react/Edit.jsx.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/react/Index.jsx.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/react/New.jsx.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/react/One.jsx.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/react/Show.jsx.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte/Edit.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte/Form.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte/Index.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte/New.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte/One.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte/Show.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte4/Form.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte4/Index.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte4/New.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte4/One.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/svelte4/Show.svelte.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/vue/Edit.vue.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/vue/Index.vue.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/vue/New.vue.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/vue/One.vue.tt delete mode 100644 lib/generators/inertia_templates/scaffold/templates/vue/Show.vue.tt delete mode 100644 lib/generators/inertia_tw_templates/controller/controller_generator.rb delete mode 100644 lib/generators/inertia_tw_templates/controller/templates/react/view.jsx.tt delete mode 100644 lib/generators/inertia_tw_templates/controller/templates/svelte/view.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/controller/templates/svelte4/view.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/controller/templates/vue/view.vue.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/scaffold_generator.rb delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/react/Edit.jsx.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/react/Form.jsx.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/react/Index.jsx.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/react/New.jsx.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/react/One.jsx.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/react/Show.jsx.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte/Edit.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte/Index.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte/New.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte/One.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte/Show.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Edit.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte4/New.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.svelte.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/vue/Edit.vue.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/vue/Form.vue.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/vue/Index.vue.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/vue/New.vue.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/vue/One.vue.tt delete mode 100644 lib/generators/inertia_tw_templates/scaffold/templates/vue/Show.vue.tt delete mode 100644 lib/inertia_rails_contrib/generators/controller_template_base.rb delete mode 100644 lib/inertia_rails_contrib/generators/scaffold_template_base.rb delete mode 100644 lib/inertia_rails_contrib/generators_helper.rb delete mode 100644 spec/fixtures/dummy/Gemfile delete mode 100644 spec/fixtures/dummy/app/views/layouts/application.html.erb delete mode 100644 spec/fixtures/dummy/config/routes.rb delete mode 100644 spec/fixtures/with_vite/app/views/layouts/application.html.erb delete mode 100644 spec/fixtures/with_vite/config/vite.json delete mode 100644 spec/fixtures/with_vite/package.json delete mode 100644 spec/fixtures/with_vite/vite.config.ts delete mode 100644 spec/lib/generators/install/install_generator_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fb434d..367d029 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning]. ## [Unreleased] +Changed: + +- Generators are upstreamed to the `inertia_rails` gem ([@skryukov]) + ## [0.3.0] - 2024-10-25 Added: diff --git a/Gemfile b/Gemfile index 39b09a9..3eadde4 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,3 @@ gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "standard", "~> 1.3" - -gem "generator_spec", "~> 0.10" diff --git a/README.md b/README.md index 60a74f0..28822e7 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,22 @@ # InertiaRailsContrib -A collection of extensions and developer tools for [Inertia's Rails adapter](https://github.com/inertiajs/inertia-rails). +> Community documentation and generators has been upstreamed to the [Inertia Rails repository](https://github.com/inertiajs/inertia-rails). +> +> Please visit the official Inertia Rails documentation at https://inertia-rails.dev. + +From now on we're planning to use `InertiaRailsContrib` as a playground for new features and ideas. +The gem will be updated with new features and improvements, and then the most successful ones will be proposed to the core Inertia Rails repository. + +Future plans: +- Ruby LSP plugin for Inertia Rails +- Modals support + +Stay tuned! Built by Evil Martians -> Community documentation has been moved to the [Inertia Rails repository](https://github.com/inertiajs/inertia-rails). -> -> Please visit the official Inertia Rails documentation at https://inertia-rails.dev. - ## Installation Install the gem and add to the application's Gemfile by executing: @@ -20,139 +27,6 @@ If bundler is not being used to manage dependencies, install the gem by executin $ gem install inertia_rails-contrib -## Usage - -### Installation generator - -`InertiaRailsContrib` comes with a generator that installs and sets up Inertia in a Rails application. It automatically detects if the [Vite Rails](https://vite-ruby.netlify.app/guide/rails.html) gem is installed and will attempt to install it if not present. - -To install and setup Inertia in a Rails application, execute the following command in the terminal: - -```bash -bundle add inertia_rails-contrib -bin/rails generate inertia:install -``` - -This command will: -- Check for Vite Rails and install it if not present -- Ask if you want to use TypeScript -- Ask you to choose your preferred frontend framework (React, Vue, Svelte 4, or Svelte 5) -- Ask if you want to install Tailwind CSS -- Install necessary dependencies -- Set up the application to work with Inertia -- Copy example Inertia controller and views (can be skipped with the `--skip-example` option) - -Example output: - -```bash -$ bin/rails generate inertia:install -Installing Inertia's Rails adapter -Could not find a package.json file to install Inertia to. -Would you like to install Vite Ruby? (y/n) y - run bundle add vite_rails from "." -Vite Rails gem successfully installed - run bundle exec vite install from "." -Vite Rails successfully installed -Would you like to use TypeScript? (y/n) y -Adding TypeScript support -What framework do you want to use with Inertia? [react, vue, svelte4, svelte] (react) - run npm add @types/react @types/react-dom typescript --silent from "." -Would you like to install Tailwind CSS? (y/n) y -Installing Tailwind CSS - run npm add tailwindcss postcss autoprefixer @tailwindcss/forms @tailwindcss/typography @tailwindcss/container-queries --silent from "." - create tailwind.config.js - create postcss.config.js - create app/frontend/entrypoints/application.css -Adding Tailwind CSS to the application layout - insert app/views/layouts/application.html.erb -Adding Inertia's Rails adapter initializer - create config/initializers/inertia_rails.rb -Installing Inertia npm packages - run npm add @vitejs/plugin-react react react-dom --silent from "." - run npm add @inertiajs/react@latest --silent from "." -Adding Vite plugin for react - insert vite.config.ts - prepend vite.config.ts -Copying inertia.ts entrypoint - create app/frontend/entrypoints/inertia.ts -Adding inertia.ts script tag to the application layout - insert app/views/layouts/application.html.erb -Adding Vite React Refresh tag to the application layout - insert app/views/layouts/application.html.erb - gsub app/views/layouts/application.html.erb -Copying example Inertia controller - create app/controllers/inertia_example_controller.rb -Adding a route for the example Inertia controller - route get 'inertia-example', to: 'inertia_example#index' -Copying page assets - create app/frontend/pages/InertiaExample.module.css - create app/frontend/assets/react.svg - create app/frontend/assets/inertia.svg - create app/frontend/assets/vite_ruby.svg - create app/frontend/pages/InertiaExample.tsx - create tsconfig.json - create tsconfig.app.json - create tsconfig.node.json - create app/frontend/vite-env.d.ts -Copying bin/dev - create bin/dev -Inertia's Rails adapter successfully installed -``` - -With that done, you can now start the Rails server and the Vite development server (we recommend using [Overmind](https://github.com/DarthSim/overmind)): - -```bash -bin/dev -``` - -And navigate to `http://localhost:3100/inertia-example` to see the example Inertia page. - -### Scaffold generator - -`InertiaRailsContrib` also comes with a scaffold generator that generates a new resource with Inertia responses. To use it, execute the following command in the terminal: - -```bash -bin/rails generate inertia:scaffold ModelName field1:type field2:type -``` - -Example output: - -```bash -$ bin/rails generate inertia:scaffold Post title:string body:text - invoke active_record - create db/migrate/20240611123952_create_posts.rb - create app/models/post.rb - invoke test_unit - create test/models/post_test.rb - create test/fixtures/posts.yml - invoke resource_route - route resources :posts - invoke scaffold_controller - create app/controllers/posts_controller.rb - invoke inertia_templates - create app/frontend/pages/Post - create app/frontend/pages/Post/Index.svelte - create app/frontend/pages/Post/Edit.svelte - create app/frontend/pages/Post/Show.svelte - create app/frontend/pages/Post/New.svelte - create app/frontend/pages/Post/Form.svelte - create app/frontend/pages/Post/Post.svelte - invoke resource_route - invoke test_unit - create test/controllers/posts_controller_test.rb - create test/system/posts_test.rb - invoke helper - create app/helpers/posts_helper.rb - invoke test_unit -``` - -#### Tailwind CSS integration - -`InertiaRailsContrib` tries to detect the presence of Tailwind CSS in the application and generate the templates accordingly. If you want to specify templates type, use the `--inertia-templates` option: - -- `inertia_templates` - default -- `inertia_tw_templates` - Tailwind CSS - ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. diff --git a/inertia_rails-contrib.gemspec b/inertia_rails-contrib.gemspec index 9c815d7..12befb0 100644 --- a/inertia_rails-contrib.gemspec +++ b/inertia_rails-contrib.gemspec @@ -26,6 +26,5 @@ Gem::Specification.new do |spec| spec.files = Dir["{app,lib}/**/*", "CHANGELOG.md", "LICENSE.txt", "README.md"] spec.require_paths = ["lib"] - spec.add_dependency "railties", ">= 6.0.0" - spec.add_dependency "inertia_rails" + spec.add_dependency "inertia_rails", ">= 3.5.0" end diff --git a/lib/generators/inertia/controller/controller_generator.rb b/lib/generators/inertia/controller/controller_generator.rb deleted file mode 100644 index fa5a0f3..0000000 --- a/lib/generators/inertia/controller/controller_generator.rb +++ /dev/null @@ -1,16 +0,0 @@ -require "rails/generators/rails/controller/controller_generator" -require "inertia_rails_contrib/generators_helper" - -module Inertia - module Generators - class ControllerGenerator < Rails::Generators::ControllerGenerator - include InertiaRailsContrib::GeneratorsHelper - - source_root File.expand_path("./templates", __dir__) - - remove_hook_for :template_engine - - hook_for :inertia_templates, required: true, default: InertiaRailsContrib::GeneratorsHelper.guess_inertia_template - end - end -end diff --git a/lib/generators/inertia/controller/templates/controller.rb.tt b/lib/generators/inertia/controller/templates/controller.rb.tt deleted file mode 100644 index 53eb0eb..0000000 --- a/lib/generators/inertia/controller/templates/controller.rb.tt +++ /dev/null @@ -1,10 +0,0 @@ -<% module_namespacing do -%> -class <%= class_name %>Controller < <%= parent_class_name.classify %> -<% actions.each do |action| -%> - def <%= action %> - render inertia: '<%= "#{inertia_base_path}/#{action.camelize}" %>' - end -<%= "\n" unless action == actions.last -%> -<% end -%> -end -<% end -%> diff --git a/lib/generators/inertia/install/frameworks.yml b/lib/generators/inertia/install/frameworks.yml deleted file mode 100644 index 6a11dc6..0000000 --- a/lib/generators/inertia/install/frameworks.yml +++ /dev/null @@ -1,98 +0,0 @@ -react: - inertia_package: "@inertiajs/react" - packages: - - "@vitejs/plugin-react" - - "react" - - "react-dom" - packages_ts: - - "@types/react" - - "@types/react-dom" - - "typescript" - vite_plugin_import: "import react from '@vitejs/plugin-react'" - vite_plugin_call: "react()" - copy_files_ts: - "InertiaExample.tsx": "%{js_destination_path}/pages/InertiaExample.tsx" - "tsconfig.json": "tsconfig.json" - "tsconfig.app.json": "tsconfig.app.json" - "tsconfig.node.json": "tsconfig.node.json" - "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts" - copy_files_js: - "InertiaExample.jsx": "%{js_destination_path}/pages/InertiaExample.jsx" - copy_files: - "InertiaExample.module.css": "%{js_destination_path}/pages/InertiaExample.module.css" - "../assets/react.svg": "%{js_destination_path}/assets/react.svg" - "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg" - "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg" - -vue: - inertia_package: "@inertiajs/vue3" - packages: - - "vue" - - "@vitejs/plugin-vue" - packages_ts: - - "typescript" - - "vue-tsc" - vite_plugin_import: "import vue from '@vitejs/plugin-vue'" - vite_plugin_call: "vue()" - copy_files: - "../assets/vue.svg": "%{js_destination_path}/assets/vue.svg" - "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg" - "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg" - copy_files_ts: - "InertiaExample.ts.vue": "%{js_destination_path}/pages/InertiaExample.vue" - "tsconfig.json": "tsconfig.json" - "tsconfig.app.json": "tsconfig.app.json" - "tsconfig.node.json": "tsconfig.node.json" - "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts" - copy_files_js: - "InertiaExample.vue": "%{js_destination_path}/pages/InertiaExample.vue" - -svelte4: - inertia_package: "@inertiajs/svelte" - packages: - - "svelte@4" - - "@sveltejs/vite-plugin-svelte@3" - packages_ts: - - "@tsconfig/svelte@4" - - "svelte-check" - - "typescript" - - "tslib" - vite_plugin_import: "import { svelte } from '@sveltejs/vite-plugin-svelte'" - vite_plugin_call: "svelte()" - copy_files_ts: - "InertiaExample.ts.svelte": "%{js_destination_path}/pages/InertiaExample.svelte" - "tsconfig.json": "tsconfig.json" - "tsconfig.node.json": "tsconfig.node.json" - "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts" - copy_files_js: - "InertiaExample.svelte": "%{js_destination_path}/pages/InertiaExample.svelte" - copy_files: - "svelte.config.js": "svelte.config.js" - "../assets/svelte.svg": "%{js_destination_path}/assets/svelte.svg" - "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg" - "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg" - -svelte: - inertia_package: "@inertiajs/svelte" - packages: - - "svelte@5" - - "@sveltejs/vite-plugin-svelte@4" - packages_ts: - - "@tsconfig/svelte@5" - - "svelte-check" - - "typescript" - - "tslib" - vite_plugin_import: "import { svelte } from '@sveltejs/vite-plugin-svelte'" - vite_plugin_call: "svelte()" - copy_files_ts: - "InertiaExample.ts.svelte": "%{js_destination_path}/pages/InertiaExample.svelte" - "tsconfig.json": "tsconfig.json" - "tsconfig.node.json": "tsconfig.node.json" - "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts" - copy_files_js: - "InertiaExample.svelte": "%{js_destination_path}/pages/InertiaExample.svelte" - copy_files: - "svelte.config.js": "svelte.config.js" - "../assets/svelte.svg": "%{js_destination_path}/assets/svelte.svg" - "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg" - "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg" diff --git a/lib/generators/inertia/install/helpers.rb b/lib/generators/inertia/install/helpers.rb deleted file mode 100644 index 054b4a8..0000000 --- a/lib/generators/inertia/install/helpers.rb +++ /dev/null @@ -1,48 +0,0 @@ -module Inertia - module Generators - module Helpers - ### FS Helpers - def js_destination_path - return ViteRuby.config.source_code_dir if defined?(ViteRuby) - if file?("config/vite.json") - source_code_dir = JSON.parse(File.read(file_path("config/vite.json"))).dig("all", "sourceCodeDir") - return source_code_dir if source_code_dir - end - - "app/frontend" - end - - def js_destination_root - file_path(js_destination_path) - end - - def js_file_path(*relative_path) - File.join(js_destination_root, *relative_path) - end - - def file?(*relative_path) - File.file?(file_path(*relative_path)) - end - - def file_path(*relative_path) - File.join(destination_root, *relative_path) - end - - # Interactivity Helpers - def ask(*) - unless options[:interactive] - say_error "Specify all options when running the generator non-interactively.", :red - exit(1) - end - - super - end - - def yes?(*) - return false unless options[:interactive] - - super - end - end - end -end diff --git a/lib/generators/inertia/install/install_generator.rb b/lib/generators/inertia/install/install_generator.rb deleted file mode 100644 index 8315216..0000000 --- a/lib/generators/inertia/install/install_generator.rb +++ /dev/null @@ -1,286 +0,0 @@ -require "yaml" -require "rails/generators" -require "rails/generators/base" - -require_relative "helpers" - -module Inertia - module Generators - class InstallGenerator < Rails::Generators::Base - include Helpers - - FRAMEWORKS = YAML.load_file(File.expand_path("./frameworks.yml", __dir__)) - - source_root File.expand_path("./templates", __dir__) - - class_option :framework, type: :string, - desc: "The framework you want to use with Inertia", - enum: FRAMEWORKS.keys, - default: nil - - class_option :inertia_version, type: :string, default: "latest", - desc: "The version of Inertia.js to install" - - class_option :typescript, type: :boolean, default: false, - desc: "Whether to use TypeScript" - - class_option :package_manager, type: :string, default: nil, enum: %w[npm yarn bun pnpm], - desc: "The package manager you want to use to install Inertia's npm packages" - - class_option :interactive, type: :boolean, default: true, - desc: "Whether to prompt for optional installations" - - class_option :install_tailwind, type: :boolean, default: false, - desc: "Whether to install Tailwind CSS" - class_option :install_vite, type: :boolean, default: false, - desc: "Whether to install Vite Ruby" - class_option :example_page, type: :boolean, default: true, - desc: "Whether to add an example Inertia page" - - class_option :verbose, type: :boolean, default: false, - desc: "Run the generator in verbose mode" - - remove_class_option :skip_namespace, :skip_collision_check - - def install - say "Installing Inertia's Rails adapter" - - if inertia_resolved_version.version == "0" - say_error "Could not find the Inertia.js package version #{options[:inertia_version]}.", :red - exit(false) - end - - install_vite unless ruby_vite_installed? - - install_typescript if typescript? - - install_tailwind if install_tailwind? - - install_inertia - - install_example_page if options[:example_page] - - say "Copying bin/dev" - copy_file "#{__dir__}/templates/dev", "bin/dev" - chmod "bin/dev", 0o755, verbose: verbose? - - say "Inertia's Rails adapter successfully installed", :green - end - - private - - def install_inertia - say "Adding Inertia's Rails adapter initializer" - template "initializer.rb", file_path("config/initializers/inertia_rails.rb") - - say "Installing Inertia npm packages" - add_packages(*FRAMEWORKS[framework]["packages"]) - add_packages(inertia_package) - - unless File.read(vite_config_path).include?(FRAMEWORKS[framework]["vite_plugin_import"]) - say "Adding Vite plugin for #{framework}" - insert_into_file vite_config_path, "\n #{FRAMEWORKS[framework]["vite_plugin_call"]},", after: "plugins: [" - prepend_file vite_config_path, "#{FRAMEWORKS[framework]["vite_plugin_import"]}\n" - end - - say "Copying #{inertia_entrypoint} entrypoint" - template "#{framework}/#{inertia_entrypoint}", js_file_path("entrypoints/#{inertia_entrypoint}") - - if application_layout.exist? - say "Adding #{inertia_entrypoint} script tag to the application layout" - headers = <<-ERB - <%= #{vite_tag} "inertia" %> - <%= inertia_headers %> - ERB - insert_into_file application_layout.to_s, headers, after: "<%= vite_client_tag %>\n" - - if framework == "react" && !application_layout.read.include?("vite_react_refresh_tag") - say "Adding Vite React Refresh tag to the application layout" - insert_into_file application_layout.to_s, "<%= vite_react_refresh_tag %>\n ", before: "<%= vite_client_tag %>" - end - - gsub_file application_layout.to_s, //, "<title inertia>" unless svelte? - else - say_error "Could not find the application layout file. Please add the following tags manually:", :red - say_error "- <title>..." - say_error "+ ..." - say_error "+ <%= inertia_headers %>" - say_error "+ <%= vite_react_refresh_tag %>" if framework == "react" - say_error "+ <%= #{vite_tag} \"inertia\" %>" - end - end - - def install_typescript - say "Adding TypeScript support" - if svelte? && inertia_resolved_version.release < Gem::Version.new("1.3.0") - say "WARNING: @inertiajs/svelte < 1.3.0 does not support TypeScript (resolved version: #{inertia_resolved_version}).", :yellow - say "Skipping TypeScript support for @inertiajs/svelte", :yellow - @typescript = false - return - end - - add_packages(*FRAMEWORKS[framework]["packages_ts"]) - end - - def install_example_page - say "Copying example Inertia controller" - template "controller.rb", file_path("app/controllers/inertia_example_controller.rb") - - say "Adding a route for the example Inertia controller" - route "get 'inertia-example', to: 'inertia_example#index'" - - say "Copying page assets" - copy_files = FRAMEWORKS[framework]["copy_files"].merge(FRAMEWORKS[framework]["copy_files_#{typescript? ? "ts" : "js"}"]) - copy_files.each do |source, destination| - template "#{framework}/#{source}", file_path(destination % {js_destination_path: js_destination_path}) - end - end - - def install_tailwind - say "Installing Tailwind CSS" - add_packages(%w[tailwindcss postcss autoprefixer @tailwindcss/forms @tailwindcss/typography @tailwindcss/container-queries]) - - template "tailwind/tailwind.config.js", file_path("tailwind.config.js") - copy_file "tailwind/postcss.config.js", file_path("postcss.config.js") - copy_file "tailwind/application.css", js_file_path("entrypoints/application.css") - - if application_layout.exist? - say "Adding Tailwind CSS to the application layout" - insert_into_file application_layout.to_s, "<%= vite_stylesheet_tag \"application\" %>\n ", before: "<%= vite_client_tag %>" - else - say_error "Could not find the application layout file. Please add the following tags manually:", :red - say_error "+ <%= vite_stylesheet_tag \"application\" %>" if install_tailwind? - end - end - - def install_vite - unless install_vite? - say_error "This generator only supports Ruby on Rails with Vite.", :red - exit(false) - end - - in_root do - Bundler.with_original_env do - if (capture = run("bundle add vite_rails", capture: !verbose?)) - say "Vite Rails gem successfully installed", :green - else - say capture - say_error "Failed to install Vite Rails gem", :red - exit(false) - end - if (capture = run("bundle exec vite install", capture: !verbose?)) - say "Vite Rails successfully installed", :green - else - say capture - say_error "Failed to install Vite Rails", :red - exit(false) - end - end - end - end - - def ruby_vite_installed? - return true if package_manager && ruby_vite? - - if package_manager.nil? - say_status "Could not find a package.json file to install Inertia to.", nil - elsif gem_installed?("webpacker") || gem_installed?("shakapacker") - say "Webpacker or Shakapacker is installed.", :yellow - say "Vite Ruby can work alongside Webpacker or Shakapacker, but it might cause issues.", :yellow - say "Please see the Vite Ruby documentation for the migration guide:", :yellow - say "https://vite-ruby.netlify.app/guide/migration.html#webpacker-%F0%9F%93%A6", :yellow - else - say_status "Could not find a Vite configuration files (`config/vite.json` & `vite.config.{ts,js,mjs,cjs,mts,cts}`).", nil - end - false - end - - def gem_installed?(name) - regex = /^[^#]*gem\s+['"]#{name}['"]/ - File.read(file_path("Gemfile")).match?(regex) - end - - def application_layout - @application_layout ||= Pathname.new(file_path("app/views/layouts/application.html.erb")) - end - - def ruby_vite? - file?("config/vite.json") && vite_config_path - end - - def package_manager - options[:package_manager] || detect_package_manager - end - - def add_packages(*packages) - in_root do - run "#{package_manager} add #{packages.join(" ")} #{verbose? ? "" : "--silent"}" - end - end - - def detect_package_manager - return nil unless file?("package.json") - - if file?("package-lock.json") - "npm" - elsif file?("bun.lockb") - "bun" - elsif file?("pnpm-lock.yaml") - "pnpm" - else - "yarn" - end - end - - def vite_config_path - @vite_config_path ||= Dir.glob(file_path("vite.config.{ts,js,mjs,cjs,mts,cts}")).first - end - - def install_vite? - return @install_vite if defined?(@install_vite) - - @install_vite = options[:install_vite] || yes?("Would you like to install Vite Ruby? (y/n)", :green) - end - - def install_tailwind? - return @install_tailwind if defined?(@install_tailwind) - - @install_tailwind = options[:install_tailwind] || yes?("Would you like to install Tailwind CSS? (y/n)", :green) - end - - def typescript? - return @typescript if defined?(@typescript) - - @typescript = options[:typescript] || yes?("Would you like to use TypeScript? (y/n)", :green) - end - - def inertia_entrypoint - "inertia.#{typescript? ? "ts" : "js"}" - end - - def vite_tag - typescript? ? "vite_typescript_tag" : "vite_javascript_tag" - end - - def inertia_resolved_version - @inertia_resolved_version ||= Gem::Version.new(`npm show @inertiajs/core@#{options[:inertia_version]} version`.strip) - end - - def verbose? - options[:verbose] - end - - def svelte? - framework.start_with? "svelte" - end - - def inertia_package - "#{FRAMEWORKS[framework]["inertia_package"]}@#{options[:inertia_version]}" - end - - def framework - @framework ||= options[:framework] || ask("What framework do you want to use with Inertia?", :green, limited_to: FRAMEWORKS.keys, default: "react") - end - end - end -end diff --git a/lib/generators/inertia/install/templates/assets/inertia.svg b/lib/generators/inertia/install/templates/assets/inertia.svg deleted file mode 100644 index 61ec585..0000000 --- a/lib/generators/inertia/install/templates/assets/inertia.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/generators/inertia/install/templates/assets/react.svg b/lib/generators/inertia/install/templates/assets/react.svg deleted file mode 100644 index ae3e3f2..0000000 --- a/lib/generators/inertia/install/templates/assets/react.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/lib/generators/inertia/install/templates/assets/svelte.svg b/lib/generators/inertia/install/templates/assets/svelte.svg deleted file mode 100644 index dc9a29c..0000000 --- a/lib/generators/inertia/install/templates/assets/svelte.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/lib/generators/inertia/install/templates/assets/vite_ruby.svg b/lib/generators/inertia/install/templates/assets/vite_ruby.svg deleted file mode 100644 index c4d4270..0000000 --- a/lib/generators/inertia/install/templates/assets/vite_ruby.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/lib/generators/inertia/install/templates/assets/vue.svg b/lib/generators/inertia/install/templates/assets/vue.svg deleted file mode 100644 index 36a27ab..0000000 --- a/lib/generators/inertia/install/templates/assets/vue.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/lib/generators/inertia/install/templates/controller.rb b/lib/generators/inertia/install/templates/controller.rb deleted file mode 100644 index 1ceca04..0000000 --- a/lib/generators/inertia/install/templates/controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class InertiaExampleController < ApplicationController - def index - render inertia: "InertiaExample", props: { - name: params.fetch(:name, "World") - } - end -end diff --git a/lib/generators/inertia/install/templates/dev b/lib/generators/inertia/install/templates/dev deleted file mode 100644 index ef33f02..0000000 --- a/lib/generators/inertia/install/templates/dev +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env sh - -export PORT="${PORT:-3000}" - -if command -v overmind 1> /dev/null 2>&1 -then - overmind start -f Procfile.dev "$@" - exit $? -fi - -if command -v hivemind 1> /dev/null 2>&1 -then - echo "Hivemind is installed. Running the application with Hivemind..." - exec hivemind Procfile.dev "$@" - exit $? -fi - -if gem list --no-installed --exact --silent foreman; then - echo "Installing foreman..." - gem install foreman -fi - -foreman start -f Procfile.dev "$@" diff --git a/lib/generators/inertia/install/templates/initializer.rb b/lib/generators/inertia/install/templates/initializer.rb deleted file mode 100644 index 4922f16..0000000 --- a/lib/generators/inertia/install/templates/initializer.rb +++ /dev/null @@ -1,4 +0,0 @@ -InertiaRails.configure do |config| - config.ssr_enabled = ViteRuby.config.ssr_build_enabled - config.version = ViteRuby.digest -end diff --git a/lib/generators/inertia/install/templates/react/InertiaExample.jsx b/lib/generators/inertia/install/templates/react/InertiaExample.jsx deleted file mode 100644 index f159ccf..0000000 --- a/lib/generators/inertia/install/templates/react/InertiaExample.jsx +++ /dev/null @@ -1,60 +0,0 @@ -import { Head } from '@inertiajs/react' -import { useState } from 'react' - -import reactSvg from '/assets/react.svg' -import inertiaSvg from '/assets/inertia.svg' -import viteRubySvg from '/assets/vite_ruby.svg' - -import cs from './InertiaExample.module.css' - -export default function InertiaExample({ name }) { - const [count, setCount] = useState(0) - - return ( - <> - - -
-

Hello {name}!

- -
- - Inertia logo - - - Vite Ruby logo - - - React logo - -
- -

Inertia + Vite Ruby + React

- -
- -

- Edit app/frontend/pages/InertiaExample.jsx and save to - test HMR -

-
-

- Click on the Inertia, Vite Ruby, and React logos to learn more -

-
- - ) -} diff --git a/lib/generators/inertia/install/templates/react/InertiaExample.module.css b/lib/generators/inertia/install/templates/react/InertiaExample.module.css deleted file mode 100644 index dea73ca..0000000 --- a/lib/generators/inertia/install/templates/react/InertiaExample.module.css +++ /dev/null @@ -1,80 +0,0 @@ -.root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - color: #213547; - background-color: #ffffff; - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.h1 { - font-size: 3.2em; - line-height: 1.1; -} - -.h2 { - font-size: 2.6em; - line-height: 1.1; -} - -.button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #f9f9f9; - cursor: pointer; - transition: border-color 0.25s; -} -.button:hover { - border-color: #646cff; -} -.button:focus, -.button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -.logo { - display: inline-block; - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.vite:hover { - filter: drop-shadow(0 0 2em #e4023baa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - .logo.react { - animation: logo-spin infinite 20s linear; - } -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} diff --git a/lib/generators/inertia/install/templates/react/InertiaExample.tsx b/lib/generators/inertia/install/templates/react/InertiaExample.tsx deleted file mode 100644 index 8937b07..0000000 --- a/lib/generators/inertia/install/templates/react/InertiaExample.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { Head } from '@inertiajs/react' -import { useState } from 'react' - -import reactSvg from '/assets/react.svg' -import inertiaSvg from '/assets/inertia.svg' -import viteRubySvg from '/assets/vite_ruby.svg' - -import cs from './InertiaExample.module.css' - -export default function InertiaExample({ name }: { name: string }) { - const [count, setCount] = useState(0) - - return ( - <> - - -
-

Hello {name}!

- -
- - Inertia logo - - - Vite Ruby logo - - - React logo - -
- -

Inertia + Vite Ruby + React

- -
- -

- Edit app/frontend/pages/InertiaExample.jsx and save to - test HMR -

-
-

- Click on the Inertia, Vite Ruby, and React logos to learn more -

-
- - ) -} diff --git a/lib/generators/inertia/install/templates/react/inertia.js b/lib/generators/inertia/install/templates/react/inertia.js deleted file mode 100644 index f00cad6..0000000 --- a/lib/generators/inertia/install/templates/react/inertia.js +++ /dev/null @@ -1,34 +0,0 @@ -import { createInertiaApp } from '@inertiajs/react' -import { createElement } from 'react' -import { createRoot } from 'react-dom/client' - -createInertiaApp({ - // Set default page title - // see https://inertia-rails.netlify.app/guide/title-and-meta - // - // title: title => title ? `${title} - App` : 'App', - - // Disable progress bar - // - // see https://inertia-rails.netlify.app/guide/progress-indicators - // progress: false, - - resolve: (name) => { - const pages = import.meta.glob('../pages/**/*.jsx', { eager: true }) - return pages[`../pages/${name}.jsx`] - - // To use a default layout, import the Layout component - // and use the following lines. - // see https://inertia-rails.netlify.app/guide/pages#default-layouts - // - // const page = pages[`../pages/${name}.jsx`] - // page.default.layout ||= (page) => createElement(Layout, null, page) - // return page - }, - - setup({ el, App, props }) { - const root = createRoot(el) - - root.render(createElement(App, props)) - }, -}) diff --git a/lib/generators/inertia/install/templates/react/inertia.ts b/lib/generators/inertia/install/templates/react/inertia.ts deleted file mode 100644 index 4ef3a28..0000000 --- a/lib/generators/inertia/install/templates/react/inertia.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { createInertiaApp } from '@inertiajs/react' -import { createElement, ReactNode } from 'react' -import { createRoot } from 'react-dom/client' - -type ResolvedComponent = { default: ReactNode, layout?: (page: ReactNode) => ReactNode } - -createInertiaApp({ - // Set default page title - // see https://inertia-rails.netlify.app/guide/title-and-meta - // - // title: title => title ? `${title} - App` : 'App', - - // Disable progress bar - // - // see https://inertia-rails.netlify.app/guide/progress-indicators - // progress: false, - - resolve: (name) => { - const pages = import.meta.glob('../pages/**/*.tsx', { eager: true }) - return pages[`../pages/${name}.tsx`] - - // To use a default layout, import the Layout component - // and use the following lines. - // see https://inertia-rails.netlify.app/guide/pages#default-layouts - // - // const page = pages[`../pages/${name}.tsx`] - // page.default.layout ||= (page) => createElement(Layout, null, page) - // return page - }, - - setup({ el, App, props }) { - const root = createRoot(el) - - root.render(createElement(App, props)) - }, -}) diff --git a/lib/generators/inertia/install/templates/react/tsconfig.app.json b/lib/generators/inertia/install/templates/react/tsconfig.app.json deleted file mode 100644 index ff1c5b1..0000000 --- a/lib/generators/inertia/install/templates/react/tsconfig.app.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", - "target": "ES2020", - "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, - "jsx": "react-jsx", - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - }, - "include": ["<%= js_destination_path %>"] -} diff --git a/lib/generators/inertia/install/templates/react/tsconfig.json b/lib/generators/inertia/install/templates/react/tsconfig.json deleted file mode 100644 index ea9d0cd..0000000 --- a/lib/generators/inertia/install/templates/react/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "files": [], - "references": [ - { - "path": "./tsconfig.app.json" - }, - { - "path": "./tsconfig.node.json" - } - ] -} diff --git a/lib/generators/inertia/install/templates/react/tsconfig.node.json b/lib/generators/inertia/install/templates/react/tsconfig.node.json deleted file mode 100644 index 3afdd6e..0000000 --- a/lib/generators/inertia/install/templates/react/tsconfig.node.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "skipLibCheck": true, - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true, - "strict": true, - "noEmit": true - }, - "include": ["vite.config.ts"] -} diff --git a/lib/generators/inertia/install/templates/react/vite-env.d.ts b/lib/generators/inertia/install/templates/react/vite-env.d.ts deleted file mode 100644 index 11f02fe..0000000 --- a/lib/generators/inertia/install/templates/react/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte b/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte deleted file mode 100644 index 4c6d294..0000000 --- a/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte +++ /dev/null @@ -1,112 +0,0 @@ - - - - Inertia + Vite Ruby + Svelte Example - - -
-

Hello {name}!

- -
- - - - - - - - - -
- -

Inertia + Vite Ruby + Svelte

- -
- -

- Edit app/frontend/pages/InertiaExample.svelte and save to test - HMR -

-
-

- Click on the Inertia, Vite Ruby, and Svelte logos to learn more -

-
- - diff --git a/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte b/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte deleted file mode 100644 index 0ed1c7d..0000000 --- a/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +++ /dev/null @@ -1,112 +0,0 @@ - - - - Inertia + Vite Ruby + Svelte Example - - -
-

Hello {name}!

- -
- - - - - - - - - -
- -

Inertia + Vite Ruby + Svelte

- -
- -

- Edit app/frontend/pages/InertiaExample.svelte and save to test - HMR -

-
-

- Click on the Inertia, Vite Ruby, and Svelte logos to learn more -

-
- - diff --git a/lib/generators/inertia/install/templates/svelte/inertia.js b/lib/generators/inertia/install/templates/svelte/inertia.js deleted file mode 100644 index 1ea6c22..0000000 --- a/lib/generators/inertia/install/templates/svelte/inertia.js +++ /dev/null @@ -1,30 +0,0 @@ -import { createInertiaApp } from '@inertiajs/svelte' -import { mount } from 'svelte'; - -createInertiaApp({ - // Set default page title - // see https://inertia-rails.netlify.app/guide/title-and-meta - // - // title: title => title ? `${title} - App` : 'App', - - // Disable progress bar - // - // see https://inertia-rails.netlify.app/guide/progress-indicators - // progress: false, - - resolve: (name) => { - const pages = import.meta.glob('../pages/**/*.svelte', { eager: true }) - return pages[`../pages/${name}.svelte`] - - // To use a default layout, import the Layout component - // and use the following lines. - // see https://inertia-rails.netlify.app/guide/pages#default-layouts - // - // const page = pages[`../pages/${name}.svelte`] - // return { default: page.default, layout: page.layout || Layout } - }, - - setup({ el, App, props }) { - mount(App, { target: el, props }) - }, -}) diff --git a/lib/generators/inertia/install/templates/svelte/inertia.ts b/lib/generators/inertia/install/templates/svelte/inertia.ts deleted file mode 100644 index d6d55cd..0000000 --- a/lib/generators/inertia/install/templates/svelte/inertia.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { createInertiaApp, type ResolvedComponent } from '@inertiajs/svelte' -import { mount } from 'svelte' - -createInertiaApp({ - // Set default page title - // see https://inertia-rails.netlify.app/guide/title-and-meta - // - // title: title => title ? `${title} - App` : 'App', - - // Disable progress bar - // - // see https://inertia-rails.netlify.app/guide/progress-indicators - // progress: false, - - resolve: (name) => { - const pages = import.meta.glob('../pages/**/*.svelte', { eager: true }) - return pages[`../pages/${name}.svelte`] - - // To use a default layout, import the Layout component - // and use the following lines. - // see https://inertia-rails.netlify.app/guide/pages#default-layouts - // - // const page = pages[`../pages/${name}.svelte`] - // return { default: page.default, layout: page.layout || Layout } - }, - - setup({ el, App, props }) { - mount(App, { target: el, props }) - }, -}) diff --git a/lib/generators/inertia/install/templates/svelte/svelte.config.js b/lib/generators/inertia/install/templates/svelte/svelte.config.js deleted file mode 100644 index b0683fd..0000000 --- a/lib/generators/inertia/install/templates/svelte/svelte.config.js +++ /dev/null @@ -1,7 +0,0 @@ -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' - -export default { - // Consult https://svelte.dev/docs#compile-time-svelte-preprocess - // for more information about preprocessors - preprocess: vitePreprocess(), -} diff --git a/lib/generators/inertia/install/templates/svelte/tsconfig.json b/lib/generators/inertia/install/templates/svelte/tsconfig.json deleted file mode 100644 index acbc1cd..0000000 --- a/lib/generators/inertia/install/templates/svelte/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "extends": "@tsconfig/svelte/tsconfig.json", - "compilerOptions": { - "target": "ESNext", - "useDefineForClassFields": true, - "module": "ESNext", - "resolveJsonModule": true, - /** - * Typecheck JS in `.svelte` and `.js` files by default. - * Disable checkJs if you'd like to use dynamic types in JS. - * Note that setting allowJs false does not prevent the use - * of JS in `.svelte` files. - */ - "allowJs": true, - "checkJs": true, - "isolatedModules": true, - "moduleDetection": "force", - }, - "include": ["<%= js_destination_path %>/**/*.ts", "<%= js_destination_path %>/**/*.js", "<%= js_destination_path %>/**/*.svelte"], - "references": [{ "path": "./tsconfig.node.json" }] -} diff --git a/lib/generators/inertia/install/templates/svelte/tsconfig.node.json b/lib/generators/inertia/install/templates/svelte/tsconfig.node.json deleted file mode 100644 index 3126cd7..0000000 --- a/lib/generators/inertia/install/templates/svelte/tsconfig.node.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "skipLibCheck": true, - "module": "ESNext", - "moduleResolution": "bundler", - "strict": true, - "noEmit": true, - }, - "include": ["vite.config.ts"] -} diff --git a/lib/generators/inertia/install/templates/svelte/vite-env.d.ts b/lib/generators/inertia/install/templates/svelte/vite-env.d.ts deleted file mode 100644 index 4078e74..0000000 --- a/lib/generators/inertia/install/templates/svelte/vite-env.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -/// diff --git a/lib/generators/inertia/install/templates/svelte4/InertiaExample.svelte b/lib/generators/inertia/install/templates/svelte4/InertiaExample.svelte deleted file mode 100644 index 96785fe..0000000 --- a/lib/generators/inertia/install/templates/svelte4/InertiaExample.svelte +++ /dev/null @@ -1,116 +0,0 @@ - - - - Inertia + Vite Ruby + Svelte Example - - -
-

Hello {name}!

- - - -

Inertia + Vite Ruby + Svelte

- -
- -

- Edit app/frontend/pages/InertiaExample.svelte and save to test - HMR -

-
-

- Click on the Inertia, Vite Ruby, and Svelte logos to learn more -

-
- - diff --git a/lib/generators/inertia/install/templates/svelte4/InertiaExample.ts.svelte b/lib/generators/inertia/install/templates/svelte4/InertiaExample.ts.svelte deleted file mode 100644 index b0d42e3..0000000 --- a/lib/generators/inertia/install/templates/svelte4/InertiaExample.ts.svelte +++ /dev/null @@ -1,116 +0,0 @@ - - - - Inertia + Vite Ruby + Svelte Example - - -
-

Hello {name}!

- - - -

Inertia + Vite Ruby + Svelte

- -
- -

- Edit app/frontend/pages/InertiaExample.svelte and save to test - HMR -

-
-

- Click on the Inertia, Vite Ruby, and Svelte logos to learn more -

-
- - diff --git a/lib/generators/inertia/install/templates/svelte4/inertia.js b/lib/generators/inertia/install/templates/svelte4/inertia.js deleted file mode 100644 index 7c288a6..0000000 --- a/lib/generators/inertia/install/templates/svelte4/inertia.js +++ /dev/null @@ -1,29 +0,0 @@ -import { createInertiaApp } from '@inertiajs/svelte' - -createInertiaApp({ - // Set default page title - // see https://inertia-rails.netlify.app/guide/title-and-meta - // - // title: title => title ? `${title} - App` : 'App', - - // Disable progress bar - // - // see https://inertia-rails.netlify.app/guide/progress-indicators - // progress: false, - - resolve: (name) => { - const pages = import.meta.glob('../pages/**/*.svelte', { eager: true }) - return pages[`../pages/${name}.svelte`] - - // To use a default layout, import the Layout component - // and use the following lines. - // see https://inertia-rails.netlify.app/guide/pages#default-layouts - // - // const page = pages[`../pages/${name}.svelte`] - // return { default: page.default, layout: page.layout || Layout } - }, - - setup({ el, App, props }) { - new App({ target: el, props }) - }, -}) diff --git a/lib/generators/inertia/install/templates/svelte4/inertia.ts b/lib/generators/inertia/install/templates/svelte4/inertia.ts deleted file mode 100644 index a4a7549..0000000 --- a/lib/generators/inertia/install/templates/svelte4/inertia.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { createInertiaApp, type ResolvedComponent } from '@inertiajs/svelte' - -createInertiaApp({ - // Set default page title - // see https://inertia-rails.netlify.app/guide/title-and-meta - // - // title: title => title ? `${title} - App` : 'App', - - // Disable progress bar - // - // see https://inertia-rails.netlify.app/guide/progress-indicators - // progress: false, - - resolve: (name) => { - const pages = import.meta.glob('../pages/**/*.svelte', { eager: true }) - return pages[`../pages/${name}.svelte`] - - // To use a default layout, import the Layout component - // and use the following lines. - // see https://inertia-rails.netlify.app/guide/pages#default-layouts - // - // const page = pages[`../pages/${name}.svelte`] - // return { default: page.default, layout: page.layout || Layout } - }, - - setup({ el, App, props }) { - new App({ target: el, props }) - }, -}) diff --git a/lib/generators/inertia/install/templates/svelte4/svelte.config.js b/lib/generators/inertia/install/templates/svelte4/svelte.config.js deleted file mode 100644 index b0683fd..0000000 --- a/lib/generators/inertia/install/templates/svelte4/svelte.config.js +++ /dev/null @@ -1,7 +0,0 @@ -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' - -export default { - // Consult https://svelte.dev/docs#compile-time-svelte-preprocess - // for more information about preprocessors - preprocess: vitePreprocess(), -} diff --git a/lib/generators/inertia/install/templates/svelte4/tsconfig.json b/lib/generators/inertia/install/templates/svelte4/tsconfig.json deleted file mode 100644 index acbc1cd..0000000 --- a/lib/generators/inertia/install/templates/svelte4/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "extends": "@tsconfig/svelte/tsconfig.json", - "compilerOptions": { - "target": "ESNext", - "useDefineForClassFields": true, - "module": "ESNext", - "resolveJsonModule": true, - /** - * Typecheck JS in `.svelte` and `.js` files by default. - * Disable checkJs if you'd like to use dynamic types in JS. - * Note that setting allowJs false does not prevent the use - * of JS in `.svelte` files. - */ - "allowJs": true, - "checkJs": true, - "isolatedModules": true, - "moduleDetection": "force", - }, - "include": ["<%= js_destination_path %>/**/*.ts", "<%= js_destination_path %>/**/*.js", "<%= js_destination_path %>/**/*.svelte"], - "references": [{ "path": "./tsconfig.node.json" }] -} diff --git a/lib/generators/inertia/install/templates/svelte4/tsconfig.node.json b/lib/generators/inertia/install/templates/svelte4/tsconfig.node.json deleted file mode 100644 index 3126cd7..0000000 --- a/lib/generators/inertia/install/templates/svelte4/tsconfig.node.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "skipLibCheck": true, - "module": "ESNext", - "moduleResolution": "bundler", - "strict": true, - "noEmit": true, - }, - "include": ["vite.config.ts"] -} diff --git a/lib/generators/inertia/install/templates/svelte4/vite-env.d.ts b/lib/generators/inertia/install/templates/svelte4/vite-env.d.ts deleted file mode 100644 index 4078e74..0000000 --- a/lib/generators/inertia/install/templates/svelte4/vite-env.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -/// diff --git a/lib/generators/inertia/install/templates/tailwind/application.css b/lib/generators/inertia/install/templates/tailwind/application.css deleted file mode 100644 index 8666d2f..0000000 --- a/lib/generators/inertia/install/templates/tailwind/application.css +++ /dev/null @@ -1,13 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -/* - -@layer components { - .btn-primary { - @apply py-2 px-4 bg-blue-200; - } -} - -*/ diff --git a/lib/generators/inertia/install/templates/tailwind/postcss.config.js b/lib/generators/inertia/install/templates/tailwind/postcss.config.js deleted file mode 100644 index 2e7af2b..0000000 --- a/lib/generators/inertia/install/templates/tailwind/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -} diff --git a/lib/generators/inertia/install/templates/tailwind/tailwind.config.js.tt b/lib/generators/inertia/install/templates/tailwind/tailwind.config.js.tt deleted file mode 100644 index dae9371..0000000 --- a/lib/generators/inertia/install/templates/tailwind/tailwind.config.js.tt +++ /dev/null @@ -1,18 +0,0 @@ -/** @type {import('tailwindcss').Config} */ - -module.exports = { - content: [ - './public/*.html', - './app/helpers/**/*.rb', - './<%= js_destination_path %>/**/*.{js,ts,jsx,tsx,vue,svelte}', - './app/views/**/*.{erb,haml,html,slim}' - ], - theme: { - extend: {}, - }, - plugins: [ - require('@tailwindcss/forms'), - require('@tailwindcss/typography'), - require('@tailwindcss/container-queries'), - ] -} diff --git a/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue b/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue deleted file mode 100644 index 42392ac..0000000 --- a/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue +++ /dev/null @@ -1,117 +0,0 @@ - - - - - diff --git a/lib/generators/inertia/install/templates/vue/InertiaExample.vue b/lib/generators/inertia/install/templates/vue/InertiaExample.vue deleted file mode 100644 index 06d00c5..0000000 --- a/lib/generators/inertia/install/templates/vue/InertiaExample.vue +++ /dev/null @@ -1,117 +0,0 @@ - - - - - diff --git a/lib/generators/inertia/install/templates/vue/inertia.js b/lib/generators/inertia/install/templates/vue/inertia.js deleted file mode 100644 index 5e72d48..0000000 --- a/lib/generators/inertia/install/templates/vue/inertia.js +++ /dev/null @@ -1,33 +0,0 @@ -import { createInertiaApp } from '@inertiajs/vue3' -import { createApp, h } from 'vue' - -createInertiaApp({ - // Set default page title - // see https://inertia-rails.netlify.app/guide/title-and-meta - // - // title: title => title ? `${title} - App` : 'App', - - // Disable progress bar - // - // see https://inertia-rails.netlify.app/guide/progress-indicators - // progress: false, - - resolve: (name) => { - const pages = import.meta.glob('../pages/**/*.vue', { eager: true }) - return pages[`../pages/${name}.vue`] - - // To use a default layout, import the Layout component - // and use the following lines. - // see https://inertia-rails.netlify.app/guide/pages#default-layouts - // - // const page = pages[`../pages/${name}.vue`] - // page.default.layout = page.default.layout || Layout - // return page - }, - - setup({ el, App, props, plugin }) { - createApp({ render: () => h(App, props) }) - .use(plugin) - .mount(el) - }, -}) diff --git a/lib/generators/inertia/install/templates/vue/inertia.ts b/lib/generators/inertia/install/templates/vue/inertia.ts deleted file mode 100644 index b4c62d6..0000000 --- a/lib/generators/inertia/install/templates/vue/inertia.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { createInertiaApp } from '@inertiajs/vue3' -import {createApp, DefineComponent, h} from 'vue' - -createInertiaApp({ - // Set default page title - // see https://inertia-rails.netlify.app/guide/title-and-meta - // - // title: title => title ? `${title} - App` : 'App', - - // Disable progress bar - // - // see https://inertia-rails.netlify.app/guide/progress-indicators - // progress: false, - - resolve: (name) => { - const pages = import.meta.glob('../pages/**/*.vue', { eager: true }) - return pages[`../pages/${name}.vue`] - - // To use a default layout, import the Layout component - // and use the following lines. - // see https://inertia-rails.netlify.app/guide/pages#default-layouts - // - // const page = pages[`../pages/${name}.vue`] - // page.default.layout = page.default.layout || Layout - // return page - }, - - setup({ el, App, props, plugin }) { - createApp({ render: () => h(App, props) }) - .use(plugin) - .mount(el) - }, -}) diff --git a/lib/generators/inertia/install/templates/vue/tsconfig.app.json b/lib/generators/inertia/install/templates/vue/tsconfig.app.json deleted file mode 100644 index dc7d6ca..0000000 --- a/lib/generators/inertia/install/templates/vue/tsconfig.app.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "useDefineForClassFields": true, - "module": "ESNext", - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, - "jsx": "preserve", - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["<%= js_destination_path %>/**/*.ts", "<%= js_destination_path %>/**/*.tsx", "<%= js_destination_path %>/**/*.vue"] -} diff --git a/lib/generators/inertia/install/templates/vue/tsconfig.json b/lib/generators/inertia/install/templates/vue/tsconfig.json deleted file mode 100644 index ea9d0cd..0000000 --- a/lib/generators/inertia/install/templates/vue/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "files": [], - "references": [ - { - "path": "./tsconfig.app.json" - }, - { - "path": "./tsconfig.node.json" - } - ] -} diff --git a/lib/generators/inertia/install/templates/vue/tsconfig.node.json b/lib/generators/inertia/install/templates/vue/tsconfig.node.json deleted file mode 100644 index 0d3d714..0000000 --- a/lib/generators/inertia/install/templates/vue/tsconfig.node.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2022", - "lib": ["ES2023"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["vite.config.ts"] -} diff --git a/lib/generators/inertia/install/templates/vue/vite-env.d.ts b/lib/generators/inertia/install/templates/vue/vite-env.d.ts deleted file mode 100644 index 11f02fe..0000000 --- a/lib/generators/inertia/install/templates/vue/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/lib/generators/inertia/scaffold/scaffold_generator.rb b/lib/generators/inertia/scaffold/scaffold_generator.rb deleted file mode 100644 index caec0f5..0000000 --- a/lib/generators/inertia/scaffold/scaffold_generator.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require "rails/generators/rails/resource/resource_generator" - -module Inertia - module Generators - class ScaffoldGenerator < Rails::Generators::ResourceGenerator # :nodoc: - remove_hook_for :resource_controller - remove_class_option :actions - - class_option :resource_route, type: :boolean - - hook_for :scaffold_controller, required: true - end - end -end diff --git a/lib/generators/inertia/scaffold_controller/scaffold_controller_generator.rb b/lib/generators/inertia/scaffold_controller/scaffold_controller_generator.rb deleted file mode 100644 index d20e9ac..0000000 --- a/lib/generators/inertia/scaffold_controller/scaffold_controller_generator.rb +++ /dev/null @@ -1,56 +0,0 @@ -require "rails/generators/resource_helpers" -require "inertia_rails_contrib/generators_helper" - -module Inertia - module Generators - # This class is a modified copy of Rails::Generators::ScaffoldControllerGenerator. - # We don't use inheritance because some gems (i.e. jsbuilder) monkey-patch it. - class ScaffoldControllerGenerator < Rails::Generators::NamedBase - include InertiaRailsContrib::GeneratorsHelper - include Rails::Generators::ResourceHelpers - - source_root File.expand_path("./templates", __dir__) - - check_class_collision suffix: "Controller" - - class_option :helper, type: :boolean - class_option :orm, banner: "NAME", type: :string, required: true, - desc: "ORM to generate the controller for" - - class_option :skip_routes, type: :boolean, desc: "Don't add routes to config/routes.rb." - - argument :attributes, type: :array, default: [], banner: "field:type field:type" - - def create_controller_files - template "controller.rb", File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb") - end - - hook_for :inertia_templates, as: :scaffold, required: true, default: InertiaRailsContrib::GeneratorsHelper.guess_inertia_template - - hook_for :resource_route, in: :rails, required: true do |route| - invoke route unless options.skip_routes? - end - - hook_for :test_framework, in: :rails, as: :scaffold - - # Invoke the helper using the controller name (pluralized) - hook_for :helper, in: :rails, as: :scaffold do |invoked| - invoke invoked, [controller_name] - end - - private - - def permitted_params - attachments, others = attributes_names.partition { |name| attachments?(name) } - params = others.map { |name| ":#{name}" } - params += attachments.map { |name| "#{name}: []" } - params.join(", ") - end - - def attachments?(name) - attribute = attributes.find { |attr| attr.name == name } - attribute&.attachments? - end - end - end -end diff --git a/lib/generators/inertia/scaffold_controller/templates/controller.rb.tt b/lib/generators/inertia/scaffold_controller/templates/controller.rb.tt deleted file mode 100644 index 03e9a49..0000000 --- a/lib/generators/inertia/scaffold_controller/templates/controller.rb.tt +++ /dev/null @@ -1,100 +0,0 @@ -<% module_namespacing do -%> -class <%= controller_class_name %>Controller < ApplicationController - before_action :set_<%= singular_table_name %>, only: %i[ show edit update destroy ] - -<% if regular_class_path.any? -%> - wrap_parameters :<%= singular_table_name %> - -<% end -%> - inertia_share flash: -> { flash.to_hash } - - # GET <%= route_url %> - def index - @<%= plural_table_name %> = <%= orm_class.all(class_name) %> - render inertia: '<%= "#{inertia_base_path}/Index" %>', props: { - <%= plural_table_name %>: @<%= plural_table_name %>.map do |<%= singular_table_name %>| - <%= "serialize_#{singular_table_name}" %>(<%= singular_table_name %>) - end - } - end - - # GET <%= route_url %>/1 - def show - render inertia: '<%= "#{inertia_base_path}/Show" %>', props: { - <%= singular_table_name %>: <%= "serialize_#{singular_table_name}" %>(@<%= singular_table_name %>) - } - end - - # GET <%= route_url %>/new - def new - @<%= singular_table_name %> = <%= orm_class.build(class_name) %> - render inertia: '<%= "#{inertia_base_path}/New" %>', props: { - <%= singular_table_name %>: <%= "serialize_#{singular_table_name}" %>(@<%= singular_table_name %>) - } - end - - # GET <%= route_url %>/1/edit - def edit - render inertia: '<%= "#{inertia_base_path}/Edit" %>', props: { - <%= singular_table_name %>: <%= "serialize_#{singular_table_name}" %>(@<%= singular_table_name %>) - } - end - - # POST <%= route_url %> - def create - @<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %> - - if @<%= orm_instance.save %> - redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully created.") %> - else - redirect_to <%= new_helper %>, inertia: { errors: @<%= singular_table_name %>.errors } - end - end - - # PATCH/PUT <%= route_url %>/1 - def update - if @<%= orm_instance.update("#{singular_table_name}_params") %> - redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully updated.") %> - else - redirect_to <%= edit_helper %>, inertia: { errors: @<%= singular_table_name %>.errors } - end - end - - # DELETE <%= route_url %>/1 - def destroy - @<%= orm_instance.destroy %> - redirect_to <%= index_helper %>_url, notice: <%= %("#{human_name} was successfully destroyed.") %> - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_<%= singular_table_name %> - @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %> - end - - # Only allow a list of trusted parameters through. - def <%= "#{singular_table_name}_params" %> - <%- if attributes_names.empty? -%> - params.fetch(:<%= singular_table_name %>, {}) - <%- else -%> - params.require(:<%= singular_table_name %>).permit(<%= permitted_params %>) - <%- end -%> - end - - def <%= "serialize_#{singular_table_name}" %>(<%= singular_table_name %>) - <%= singular_table_name %>.as_json(only: [ - <%= attributes_to_serialize.map { |attribute| ":#{attribute}" }.join(", ") %> - ])<%- if attributes.any?(&:attachment?) || attributes.any?(&:attachments?) -%>.tap do |hash| - <%- attributes.filter(&:attachment?).map do |attribute| -%> - hash["<%= attribute.column_name %>"] = {filename: <%= singular_table_name %>.<%= attribute.column_name %>.filename, url: url_for(<%= singular_table_name %>.<%= attribute.column_name %>)} if <%= singular_table_name %>.<%= attribute.column_name %>.attached? - <%- end -%> - <%- attributes.filter(&:attachments?).map do |attribute| -%> - hash["<%= attribute.column_name %>"] = - <%= singular_table_name %>.<%= attribute.column_name %>.flat_map do |file| - {filename: file.filename.to_s, url: url_for(file)} - end - <%- end -%> - end<% end %> - end -end -<% end -%> diff --git a/lib/generators/inertia_templates/controller/controller_generator.rb b/lib/generators/inertia_templates/controller/controller_generator.rb deleted file mode 100644 index 2a7ec0d..0000000 --- a/lib/generators/inertia_templates/controller/controller_generator.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -require "inertia_rails_contrib/generators/controller_template_base" - -module InertiaTemplates - module Generators - class ControllerGenerator < InertiaRailsContrib::Generators::ControllerTemplateBase - hide! - source_root File.expand_path("./templates", __dir__) - end - end -end diff --git a/lib/generators/inertia_templates/controller/templates/react/view.jsx.tt b/lib/generators/inertia_templates/controller/templates/react/view.jsx.tt deleted file mode 100644 index 799ea4c..0000000 --- a/lib/generators/inertia_templates/controller/templates/react/view.jsx.tt +++ /dev/null @@ -1,8 +0,0 @@ -export default function <%= @action.camelize %>() { - return ( - <> -

<%= class_name %>#<%= @action %>

-

Find me in <%= @path %>

- - ); -} diff --git a/lib/generators/inertia_templates/controller/templates/svelte/view.svelte.tt b/lib/generators/inertia_templates/controller/templates/svelte/view.svelte.tt deleted file mode 100644 index cd54d13..0000000 --- a/lib/generators/inertia_templates/controller/templates/svelte/view.svelte.tt +++ /dev/null @@ -1,2 +0,0 @@ -

<%= class_name %>#<%= @action %>

-

Find me in <%= @path %>

diff --git a/lib/generators/inertia_templates/controller/templates/svelte4/view.svelte.tt b/lib/generators/inertia_templates/controller/templates/svelte4/view.svelte.tt deleted file mode 100644 index cd54d13..0000000 --- a/lib/generators/inertia_templates/controller/templates/svelte4/view.svelte.tt +++ /dev/null @@ -1,2 +0,0 @@ -

<%= class_name %>#<%= @action %>

-

Find me in <%= @path %>

diff --git a/lib/generators/inertia_templates/controller/templates/vue/view.vue.tt b/lib/generators/inertia_templates/controller/templates/vue/view.vue.tt deleted file mode 100644 index 14e2f96..0000000 --- a/lib/generators/inertia_templates/controller/templates/vue/view.vue.tt +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/lib/generators/inertia_templates/scaffold/scaffold_generator.rb b/lib/generators/inertia_templates/scaffold/scaffold_generator.rb deleted file mode 100644 index f2ce5b8..0000000 --- a/lib/generators/inertia_templates/scaffold/scaffold_generator.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -require "inertia_rails_contrib/generators/scaffold_template_base" - -module InertiaTemplates - module Generators - class ScaffoldGenerator < InertiaRailsContrib::Generators::ScaffoldTemplateBase - hide! - source_root File.expand_path("./templates", __dir__) - end - end -end diff --git a/lib/generators/inertia_templates/scaffold/templates/react/Edit.jsx.tt b/lib/generators/inertia_templates/scaffold/templates/react/Edit.jsx.tt deleted file mode 100644 index faf0c3b..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/react/Edit.jsx.tt +++ /dev/null @@ -1,35 +0,0 @@ -import { Link, Head } from '@inertiajs/react' -import Form from './Form' - -export default function Edit({ <%= singular_table_name %> }) { - return ( - <> - - -

Editing <%= human_name.downcase %>

- -
={<%= singular_table_name %>} - onSubmit={(form) => { - form.transform((data) => ({ <%= singular_table_name %>: data })) -<% if attributes.any?(&:attachments?) -%> - form.post(`<%= js_resource_path %>`, { - headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' }, - }) -<% else -%> - form.patch(`<%= js_resource_path %>`) -<% end -%> - }} - submitText="Update <%= human_name.downcase %>" - /> - -
- -
- `}>Show this <%= human_name.downcase %> - {' | '} - Back to <%= human_name.pluralize.downcase %> -
- - ) -} diff --git a/lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt b/lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt deleted file mode 100644 index e062dcb..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt +++ /dev/null @@ -1,111 +0,0 @@ -import { useForm } from '@inertiajs/react' - -export default function Form({ <%= singular_table_name %>, onSubmit, submitText }) { - const form = useForm({ -<% attributes.each do |attribute| -%> -<% if attribute.password_digest? -%> - password: '', - password_confirmation: '', -<% else -%> - <%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %> || <%= default_value(attribute) %>, -<% end -%> -<% end -%> - }) - const { data, setData, errors, processing } = form - - const handleSubmit = (e) => { - e.preventDefault() - onSubmit(form) - } - - return ( - -<% attributes.each do |attribute| -%> -<% if attribute.password_digest? -%> -
- - setData('password', e.target.value)} - /> - {errors.password && ( -
{errors.password.join(', ')}
- )} -
- -
- - setData('password_confirmation', e.target.value)} - /> - {errors.password_confirmation && ( -
{errors.password_confirmation.join(', ')}
- )} -
-<% else -%> -
- -<% if input_type(attribute) == "text_area" -%> - -<% elsif attribute.attachment? -%> - ($form.<%= attribute.column_name %> = e.target.files[0])} - /> -<% elsif attribute.attachments? -%> - ($form.<%= attribute.column_name %> = Array.from(e.target.files))} - /> -<% else -%> - ={$form.<%= attribute.column_name %>} - /> -<% end -%> - {#if $form.errors.<%= attribute.column_name %>} -
{$form.errors.<%= attribute.column_name %>.join(', ')}
- {/if} -
-<% end -%> -<% end -%> -
- -
-
- - diff --git a/lib/generators/inertia_templates/scaffold/templates/svelte/Index.svelte.tt b/lib/generators/inertia_templates/scaffold/templates/svelte/Index.svelte.tt deleted file mode 100644 index e8a7e7d..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/svelte/Index.svelte.tt +++ /dev/null @@ -1,35 +0,0 @@ - - - - <%= human_name.pluralize %> - - -{#if flash.notice} -

{flash.notice}

-{/if} - -

<%= human_name.pluralize %>

- -
- {#each <%= plural_table_name %> as <%= singular_table_name %> (<%= singular_table_name %>.id)} -
- <<%= inertia_component_name %> {<%= singular_table_name %>} /> -

- `}>Show this <%= human_name.downcase %> -

-
- {/each} -
- -New <%= human_name.downcase %> - - diff --git a/lib/generators/inertia_templates/scaffold/templates/svelte/New.svelte.tt b/lib/generators/inertia_templates/scaffold/templates/svelte/New.svelte.tt deleted file mode 100644 index d46b465..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/svelte/New.svelte.tt +++ /dev/null @@ -1,29 +0,0 @@ - - - - New <%= human_name.downcase %> - - -

New <%= human_name.downcase %>

- -
} - submitText="Create <%= human_name.downcase %>" - onSubmit={handleSubmit} -/> - -
- -
- Back to <%= human_name.pluralize.downcase %> -
diff --git a/lib/generators/inertia_templates/scaffold/templates/svelte/One.svelte.tt b/lib/generators/inertia_templates/scaffold/templates/svelte/One.svelte.tt deleted file mode 100644 index 717b129..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/svelte/One.svelte.tt +++ /dev/null @@ -1,28 +0,0 @@ - - -
-<% attributes.reject(&:password_digest?).each do |attribute| -%> -

- <%= attribute.human_name %>: -<% if attribute.attachment? -%> - {#if <%= singular_table_name %>.<%= attribute.column_name %>} - .<%= attribute.column_name %>.url}> - {<%= singular_table_name %>.<%= attribute.column_name %>.filename} - - {/if} -

-<% elsif attribute.attachments? -%> -

- {#each <%= singular_table_name %>.<%= attribute.column_name %> as { url, filename }} - - {/each} -<% else -%> - {<%= singular_table_name %>.<%= attribute.column_name %>} -

-<% end -%> -<% end -%> -
diff --git a/lib/generators/inertia_templates/scaffold/templates/svelte/Show.svelte.tt b/lib/generators/inertia_templates/scaffold/templates/svelte/Show.svelte.tt deleted file mode 100644 index 065a058..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/svelte/Show.svelte.tt +++ /dev/null @@ -1,41 +0,0 @@ - - - - <%= human_name %> #{<%= singular_table_name %>.id} - - -{#if flash.notice} -

{flash.notice}

-{/if} - -

<%= human_name %> #{<%= singular_table_name %>.id}

- -<<%= inertia_component_name %> {<%= singular_table_name %>} /> - -
- `}>Edit this <%= human_name.downcase %> | - Back to <%= human_name.pluralize.downcase %> - -
- - `} method="delete" onclick={onDestroy}> - Destroy this <%= human_name.downcase %> - -
- - diff --git a/lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.svelte.tt b/lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.svelte.tt deleted file mode 100644 index 8f45c81..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.svelte.tt +++ /dev/null @@ -1,37 +0,0 @@ - - - - Editing <%= human_name.downcase %> - - -

Editing <%= human_name.downcase %>

- -} - submitText="Update <%= human_name.downcase %>" - on:submit={handleSubmit} -/> - -
- -
- `}>Show this <%= human_name.downcase %> | - Back to <%= human_name.pluralize.downcase %> -
diff --git a/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.svelte.tt b/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.svelte.tt deleted file mode 100644 index 8519c33..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.svelte.tt +++ /dev/null @@ -1,96 +0,0 @@ - - - -<% attributes.each do |attribute| -%> -<% if attribute.password_digest? -%> -
- - - {#if $form.errors.password} -
{$form.errors.password.join(', ')}
- {/if} -
- -
- - - {#if $form.errors.password_confirmation} -
{$form.errors.password_confirmation.join(', ')}
- {/if} -
-<% else -%> -
- -<% if input_type(attribute) == "text_area" -%> - -<% elsif attribute.attachment? -%> - ($form.<%= attribute.column_name %> = e.target.files[0])} - /> -<% elsif attribute.attachments? -%> - ($form.<%= attribute.column_name %> = Array.from(e.target.files))} - /> -<% else -%> - ={$form.<%= attribute.column_name %>} - /> -<% end -%> - {#if $form.errors.<%= attribute.column_name %>} -
{$form.errors.<%= attribute.column_name %>.join(', ')}
- {/if} -
-<% end -%> -<% end -%> -
- -
-
- - diff --git a/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.svelte.tt b/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.svelte.tt deleted file mode 100644 index 7164c7b..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.svelte.tt +++ /dev/null @@ -1,36 +0,0 @@ - - - - <%= human_name.pluralize %> - - -{#if flash.notice} -

{flash.notice}

-{/if} - -

<%= human_name.pluralize %>

- -
- {#each <%= plural_table_name %> as <%= singular_table_name %> (<%= singular_table_name %>.id)} -
- <<%= inertia_component_name %> {<%= singular_table_name %>} /> -

- `}>Show this <%= human_name.downcase %> -

-
- {/each} -
- -New <%= human_name.downcase %> - - diff --git a/lib/generators/inertia_templates/scaffold/templates/svelte4/New.svelte.tt b/lib/generators/inertia_templates/scaffold/templates/svelte4/New.svelte.tt deleted file mode 100644 index 6238cd2..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/svelte4/New.svelte.tt +++ /dev/null @@ -1,30 +0,0 @@ - - - - New <%= human_name.downcase %> - - -

New <%= human_name.downcase %>

- -
} - submitText="Create <%= human_name.downcase %>" - on:submit={handleSubmit} -/> - -
- -
- Back to <%= human_name.pluralize.downcase %> -
diff --git a/lib/generators/inertia_templates/scaffold/templates/svelte4/One.svelte.tt b/lib/generators/inertia_templates/scaffold/templates/svelte4/One.svelte.tt deleted file mode 100644 index 01b918a..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/svelte4/One.svelte.tt +++ /dev/null @@ -1,28 +0,0 @@ - - -
-<% attributes.reject(&:password_digest?).each do |attribute| -%> -

- <%= attribute.human_name %>: -<% if attribute.attachment? -%> - {#if <%= singular_table_name %>.<%= attribute.column_name %>} - .<%= attribute.column_name %>.url}> - {<%= singular_table_name %>.<%= attribute.column_name %>.filename} - - {/if} -

-<% elsif attribute.attachments? -%> -

- {#each <%= singular_table_name %>.<%= attribute.column_name %> as { url, filename }} - - {/each} -<% else -%> - {<%= singular_table_name %>.<%= attribute.column_name %>} -

-<% end -%> -<% end -%> -
diff --git a/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.svelte.tt b/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.svelte.tt deleted file mode 100644 index c165323..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.svelte.tt +++ /dev/null @@ -1,46 +0,0 @@ - - - - <%= human_name %> #{<%= singular_table_name %>.id} - - -{#if flash.notice} -

{flash.notice}

-{/if} - -

<%= human_name %> #{<%= singular_table_name %>.id}

- -<<%= inertia_component_name %> {<%= singular_table_name %>} /> - -
- `}>Edit this <%= human_name.downcase %> | - Back to <%= human_name.pluralize.downcase %> - -
- - -
- - diff --git a/lib/generators/inertia_templates/scaffold/templates/vue/Edit.vue.tt b/lib/generators/inertia_templates/scaffold/templates/vue/Edit.vue.tt deleted file mode 100644 index 8e78923..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/vue/Edit.vue.tt +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt b/lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt deleted file mode 100644 index 226d933..0000000 --- a/lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt +++ /dev/null @@ -1,94 +0,0 @@ -