Skip to content

Commit

Permalink
Simplify installation by providing tailwind & vite installation steps
Browse files Browse the repository at this point in the history
  • Loading branch information
skryukov committed Aug 6, 2024
1 parent 0c94cab commit 96370f4
Show file tree
Hide file tree
Showing 19 changed files with 599 additions and 105 deletions.
51 changes: 42 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,53 @@ on:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
name: Linter
env:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler: latest
bundler-cache: true
- name: Run StandardRB
run: bundle exec standardrb

build:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
env:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
strategy:
matrix:
ruby:
- '3.2.3'
- "3.3"
- "3.2"
- "3.1"
- "3.0"

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run the default task
run: bundle exec rake
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
bundler: latest
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Set Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install yarn
run: npm install -g yarn
- name: Run tests
run: bundle exec rspec
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"

gem "standard", "~> 1.3"

gem "generator_spec", "~> 0.10"
41 changes: 41 additions & 0 deletions lib/generators/inertia/install/frameworks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
react:
packages:
- "@inertiajs/react"
- "react"
- "react-dom"
- "@vitejs/plugin-react"
vite_plugin_import: "import react from '@vitejs/plugin-react'"
vite_plugin_call: "react()"
copy_files:
"InertiaExample.jsx": "%{js_destination_path}/pages/InertiaExample.jsx"
"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:
packages:
- "@inertiajs/vue3"
- "vue"
- "@vitejs/plugin-vue"
vite_plugin_import: "import vue from '@vitejs/plugin-vue'"
vite_plugin_call: "vue()"
copy_files:
"InertiaExample.vue": "%{js_destination_path}/pages/InertiaExample.vue"
"../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"

svelte:
packages:
- "@inertiajs/svelte"
- "svelte"
- "@sveltejs/vite-plugin-svelte"
vite_plugin_import: "import { svelte } from '@sveltejs/vite-plugin-svelte'"
vite_plugin_call: "svelte()"
copy_files:
"svelte.config.js": "svelte.config.js"
"InertiaExample.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
"../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"
42 changes: 42 additions & 0 deletions lib/generators/inertia/install/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module Inertia
module Generators
module Helpers
### FS Helpers
def js_destination_path
defined?(ViteRuby) ? ViteRuby.config.source_code_dir : "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
Loading

0 comments on commit 96370f4

Please sign in to comment.