-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
647 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,7 @@ gemspec | |
gem "rake", "~> 13.0" | ||
|
||
gem "standard", "~> 1.3" | ||
|
||
gem "rspec", "~> 3.0" | ||
|
||
gem "generator_spec", "~> 0.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
require "bundler/gem_tasks" | ||
require "rspec/core/rake_task" | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
require "standard/rake" | ||
|
||
task default: :standard | ||
task default: %i[spec standard] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { buildRegisterFunction } from 'turbo-mount'; | ||
export { TurboMount } from 'turbo-mount'; | ||
|
||
const plugin = { | ||
mountComponent: (mountProps) => { | ||
const { el, Component, props } = mountProps; | ||
const component = new Component({ target: el, props }); | ||
return () => { | ||
component.$destroy(); | ||
}; | ||
}, | ||
}; | ||
const registerComponent = buildRegisterFunction(plugin); | ||
|
||
export { plugin as default, registerComponent }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
react: | ||
pins: "react react-dom react-dom/client" | ||
npm_packages: "react react-dom" | ||
vite_plugin: "@vitejs/plugin-react" | ||
extension: "jsx" | ||
|
||
vue: | ||
pins: "vue" | ||
npm_packages: "vue" | ||
vite_plugin: "@vitejs/plugin-vue" | ||
extension: "vue" | ||
|
||
svelte4: | ||
pins: "svelte" | ||
npm_packages: "svelte@4" | ||
vite_plugin: "@sveltejs/vite-plugin-svelte" | ||
extension: "svelte" | ||
|
||
svelte: | ||
pins: "svelte" | ||
npm_packages: "svelte@5" | ||
vite_plugin: "@sveltejs/vite-plugin-svelte" | ||
extension: "svelte" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
module TurboMount | ||
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 || "app/frontend" | ||
end | ||
|
||
"app/javascript" | ||
end | ||
|
||
def js_destination_root | ||
file_path(js_destination_path) | ||
end | ||
|
||
def js_entrypoint | ||
if vite? | ||
js_file_path "entrypoints/application.js" | ||
else | ||
js_file_path "application.js" | ||
end | ||
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 | ||
|
||
def vite? | ||
file?("config/vite.json") && Dir.glob(file_path("vite.config.*")).any? | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.