rails_vue3_quasar 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4b9ed78cb5d8f56ac27abaa51f6f9b6ecd23a6258834988d31992ba1c756fa37
4
+ data.tar.gz: b1b9510b96b3a5c4da96182b2b8b7f62c2ac9f9c205027e82126aaf07ec74a49
5
+ SHA512:
6
+ metadata.gz: cca36d6434ee341720645b03f31f3c4e1e38853fb485a633cd493b27f71cb351487c15fa3e9123f9acee0e6007fe4fdc5777818d74fb9c1973f7207a05328f7f
7
+ data.tar.gz: 55dfa82e639460161a5b31fcfaf52575289c098bd20ecc86a240c9e7d68b87c1f43d9903931acdc816f9f2f5bff43b73f42e70f3e70b13cadb178ffc6ebcecbd
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at TODO: Write your email address. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in rails_vue3_quasar.gemspec
8
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 TODO: devhoanglv92
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # RailsVue3Quasar
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rails_vue3_quasar`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'rails_vue3_quasar'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install rails_vue3_quasar
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rails_vue3_quasar. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the RailsVue3Quasar project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rails_vue3_quasar/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rails_vue3_quasar"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'rails_vue3_quasar'
6
+
7
+ # Run the updater
8
+ puts 'Running add vue and quasar!!!!!'
9
+ RailsVue3Quasar::RailsVue3.run(*ARGV)
10
+ puts 'Finished add vue and quasar!!!!!'
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsVue3Quasar
4
+ # class base handle
5
+ # phaser
6
+ class BaseHandle
7
+ def self.process(*args, &block)
8
+ new(*args, &block).process
9
+ end
10
+
11
+ def project_root
12
+ current_dir = Dir.pwd
13
+ until File.exist?(File.join(current_dir, 'Gemfile'))
14
+ parent_dir = File.expand_path('..', current_dir)
15
+ return nil if current_dir == parent_dir # Reached the root directory
16
+
17
+ current_dir = parent_dir
18
+ end
19
+ current_dir
20
+ end
21
+
22
+ def install_yarn?
23
+ system('which yarn > /dev/null 2>&1')
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <q-layout view="hHh lpR fFf">
3
+ <q-header elevated class="bg-primary text-white">
4
+ <q-toolbar>
5
+ <q-btn flat dense round icon="menu" @click="toggleLeftDrawer" aria-label="Menu" />
6
+ <q-toolbar-title>
7
+ My Application
8
+ </q-toolbar-title>
9
+ </q-toolbar>
10
+ </q-header>
11
+
12
+ <q-drawer v-model="leftDrawerOpen" show-if-above bordered class="bg-grey-2">
13
+ <q-list>
14
+ <q-item clickable v-ripple>
15
+ <q-item-section avatar>
16
+ <q-icon name="home" />
17
+ </q-item-section>
18
+ <q-item-section>
19
+ <q-item-label>Home</q-item-label>
20
+ </q-item-section>
21
+ </q-item>
22
+ <q-item clickable v-ripple>
23
+ <q-item-section avatar>
24
+ <q-icon name="info" />
25
+ </q-item-section>
26
+ <q-item-section>
27
+ <q-item-label>About</q-item-label>
28
+ </q-item-section>
29
+ </q-item>
30
+ </q-list>
31
+ </q-drawer>
32
+
33
+ <q-page-container>
34
+ <q-page class="q-pa-md">
35
+ <slot></slot>
36
+ </q-page>
37
+ </q-page-container>
38
+ </q-layout>
39
+ </template>
40
+
41
+ <script>
42
+ import { ref } from 'vue'
43
+
44
+ export default {
45
+ name: 'SimpleLayout',
46
+ setup() {
47
+ const leftDrawerOpen = ref(false)
48
+
49
+ function toggleLeftDrawer() {
50
+ leftDrawerOpen.value = !leftDrawerOpen.value
51
+ }
52
+
53
+ return {
54
+ leftDrawerOpen,
55
+ toggleLeftDrawer,
56
+ }
57
+ },
58
+ }
59
+ </script>
60
+
61
+ <style scoped>
62
+ .q-layout {
63
+ min-height: 100vh;
64
+ }
65
+ </style>
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <div v-for="category in lists" :key="category.id + 2" class="pa-4">
3
+ <div>{{ $t('home.title') }}</div>
4
+ <v-card :text="category.name" :color="black" />
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+ import { usePage } from '@inertiajs/vue3'
10
+ export default {
11
+ props: {
12
+ lists: {
13
+ type: Array,
14
+ required: true
15
+ },
16
+ },
17
+ setup(props) {
18
+ // console.log(props)
19
+ return {
20
+ // lists: lists
21
+ }
22
+ }
23
+ }
24
+ </script>
@@ -0,0 +1,57 @@
1
+ import { createApp, h } from "vue";
2
+ import { createInertiaApp, Head, Link } from "@inertiajs/vue3";
3
+ import { vuetifyPlugin } from "./vuetify";
4
+ import { resolvePage } from "./pages";
5
+ // Pinia
6
+ import { createPinia } from 'pinia'
7
+ // mitt
8
+ import mitt from 'mitt'
9
+ import jQuery from "jquery";
10
+
11
+ import { Quasar, Notify, LocalStorage } from 'quasar';
12
+ import '@quasar/extras/material-icons/material-icons.css'
13
+ // Import Quasar css
14
+ import 'quasar/src/css/index.sass'
15
+ import { i18n } from "./i18n";
16
+
17
+ export default function () {
18
+ createInertiaApp({
19
+ resolve: resolvePage,
20
+ progress: {
21
+ // The delay after which the progress bar will appear, in milliseconds...
22
+ delay: 50,
23
+
24
+ // The color of the progress bar...
25
+ color: "#c62828",
26
+
27
+ // Whether to include the default NProgress styles...
28
+ includeCSS: true,
29
+
30
+ // Whether the NProgress spinner will be shown...
31
+ showSpinner: true,
32
+ },
33
+ setup({ el, App, props, plugin }) {
34
+ // Create emitter
35
+
36
+ window.emitter = mitt()
37
+ const app = createApp({ render: () => h(App, props) });
38
+ app.use(plugin);
39
+ app.use(vuetifyPlugin);
40
+ app.use(Quasar, {
41
+ plugins: [
42
+ Notify,
43
+ LocalStorage,
44
+ ],
45
+ });
46
+ app.use(jQuery);
47
+ app.use(i18n);
48
+
49
+ const pinia = createPinia()
50
+
51
+ app.component("iHead", Head);
52
+ app.component("iLink", Link);
53
+
54
+ app.use(pinia).mount(el);
55
+ },
56
+ });
57
+ }
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Constants
4
+ VITE_CONFIG = <<-vite
5
+ import { defineConfig } from 'vite'
6
+ import RubyPlugin from 'vite-plugin-ruby'
7
+ import VitePlugin from "@vitejs/plugin-vue"
8
+ import FullReload from 'vite-plugin-full-reload'
9
+ import vuetify from 'vite-plugin-vuetify'
10
+ import { quasar } from '@quasar/vite-plugin'
11
+ import { fileURLToPath } from 'node:url'
12
+
13
+ export default defineConfig({
14
+ plugins: [
15
+ RubyPlugin(),
16
+ VitePlugin(),
17
+ vuetify ({ autoImport : true }),
18
+ FullReload ([ 'config/routes.rb' , 'app/views/**/*' ], { delay : 200 }),
19
+ quasar({
20
+ sassVariables: fileURLToPath(
21
+ new URL('./app/frontend/css/quasar-variables.sass', import.meta.url)
22
+ )
23
+ }),
24
+ ],
25
+ })
26
+ vite
27
+
28
+ INIT_VITE = <<-vite
29
+ import createApp from "../../frontend/app";
30
+ createApp();
31
+ vite
32
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # class demo
4
+ class RailsVueController < ApplicationController
5
+ def index
6
+ demo = [{ name: 'John Doe', id: 1 }]
7
+ render inertia: 'rails_vue/index', props: { lists: demo }
8
+ end
9
+ end
@@ -0,0 +1,34 @@
1
+ $primary : #1976D2
2
+ $secondary : #26A69A
3
+ $accent : #9C27B0
4
+
5
+ $dark : #1D1D1D
6
+
7
+ $positive : #21BA45
8
+ $negative : #C10015
9
+ $info : #31CCEC
10
+ $warning : #F2C037
11
+
12
+ // other
13
+
14
+ $color-main: #FF3C00
15
+ $color-white: #FFFFFF
16
+ $color-base-gray-2: #f4f4f4
17
+ $color-base-gray-5: #E5E5E5
18
+ $color-base-gray-10: #CCCCCC
19
+ $color-base-gray-30: #B3B3B3
20
+ $color-base-gray-40: #999999
21
+ $color-base-gray-50: #808080
22
+ $color-base-gray-60: #666666
23
+ $color-base-gray-70: #4C4C4C
24
+ $color-light-green-50: #388A4A
25
+ $color-light-red-05: #FDF3F4
26
+ $color-warning: #FFFF99
27
+ $main-bold-color: #2B6074
28
+ $color-primary-05: #FCF1ED
29
+ $color-primary-60: #469AB9
30
+ $color-primary-90: #1E4351
31
+ $color-red-50: #DB1226
32
+ $container-background-color: #F6F6F6
33
+ $linear-gradient-main: linear-gradient(135deg, #FE9600 -16.8%, #FF3C00 138.64%)
34
+ $color-hover-row-table: #FFFBEF
@@ -0,0 +1,14 @@
1
+ import { createI18n } from 'vue-i18n'
2
+ export const i18n = createI18n({
3
+ // something vue-i18n options here ...
4
+ locale: 'en',
5
+ fallbackLocale: 'en',
6
+ messages: {
7
+ "en": {
8
+ "hello": "Hello world!"
9
+ },
10
+ "ja": {
11
+ "hello": "こんにちは、世界!"
12
+ }
13
+ }
14
+ })
@@ -0,0 +1,37 @@
1
+ {
2
+ "private": true,
3
+ "type": "module",
4
+ "devDependencies": {
5
+ "sass-embedded": "^1.80.2",
6
+ "vite": "^5.4.11",
7
+ "vite-plugin-ruby": "^5.1.1"
8
+ },
9
+ "dependencies": {
10
+ "@inertiajs/vue3": "^1.2.0",
11
+ "@js-from-routes/client": "^1.0.4",
12
+ "@js-from-routes/inertia": "^1.10.2",
13
+ "@mdi/font": "^7.4.47",
14
+ "@quasar/extras": "^1.16.13",
15
+ "@quasar/vite-plugin": "^1.8.1",
16
+ "@vitejs/plugin-vue": "^5.2.0",
17
+ "@vitejs/plugin-vue-jsx": "^4.1.0",
18
+ "@vue/compiler-sfc": "^3.5.13",
19
+ "jquery": "^3.7.1",
20
+ "mitt": "^3.0.1",
21
+ "pinia": "^2.2.7",
22
+ "quasar": "^2.17.4",
23
+ "vite-plugin-full-reload": "^1.2.0",
24
+ "vite-plugin-vuetify": "^2.0.4",
25
+ "vue": "^3.5.13",
26
+ "vue-i18n": "10",
27
+ "vue-loading-overlay": "^6.0.6",
28
+ "vue-router": "^4.0.13",
29
+ "vue3-transitions": "^1.0.0",
30
+ "vuetify": "^3.7.4"
31
+ },
32
+ "scripts": {
33
+ "dev": "vite --port 8000",
34
+ "build": "vite build",
35
+ "serve": "vite preview"
36
+ }
37
+ }
@@ -0,0 +1,21 @@
1
+ // NOTE: Optimize the SSR bundle by not splitting by page.
2
+
3
+ import Layout from "./Layouts/Main.vue";
4
+
5
+ const pages = import.meta.env.SSR
6
+ ? import.meta.globEagerDefault("./Pages/**/*.vue", { eager: true })
7
+ : import.meta.glob("./Pages/**/*.vue", { eager: true });
8
+
9
+ export async function resolvePage(name) {
10
+ const page = pages[`./Pages/${name}.vue`];
11
+
12
+ if (!page) {
13
+ throw new Error(
14
+ `Unknown page ${name}. Is it located under Pages with a .vue extension?`
15
+ );
16
+ }
17
+
18
+ page.default.layout = page.default.layout || Layout;
19
+
20
+ return import.meta.env.SSR ? page : (await page).default;
21
+ }
@@ -0,0 +1,7 @@
1
+ import 'vuetify/styles'
2
+ import '@mdi/font/css/materialdesignicons.css'
3
+ import { createVuetify } from 'vuetify'
4
+
5
+ export const vuetifyPlugin = createVuetify({
6
+ ssr: true
7
+ })
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_vue3_quasar/base_handle'
4
+
5
+ module RailsVue3Quasar
6
+ # class add gem
7
+ class HandleAddGem < RailsVue3Quasar::BaseHandle
8
+ def process
9
+ gems_to_add.each do |gem_name, gem_version|
10
+ add_gem_to_gemfile(gem_name, gem_version)
11
+ end
12
+
13
+ run_bundle_install
14
+ exec_vite_install
15
+ end
16
+
17
+ private
18
+
19
+ def gems_to_add
20
+ {
21
+ 'pagy' => '~> 9.1',
22
+ 'paranoia' => '~> 3.0',
23
+ 'pundit' => '~> 2.4',
24
+ 'rack-cors' => { version: '~> 2.0', additional_version: '>= 2.0.1' },
25
+ 'ransack' => { version: '~> 4.2', additional_version: '>= 4.2.1' },
26
+ 'vite_rails' => { version: '~> 3.0', additional_version: '>= 3.0.17' },
27
+ 'inertia_rails' => '~> 3.4',
28
+ 'js_from_routes' => { version: '~> 4.0', additional_version: '>= 4.0.1' }
29
+ }
30
+ end
31
+
32
+ def add_gem_to_gemfile(gem_name, gem_version)
33
+ gemfile_path = find_gemfile_path
34
+ gemfile_content = File.read(gemfile_path)
35
+
36
+ return if gemfile_content.include?("gem '#{gem_name}'")
37
+
38
+ File.open(gemfile_path, 'a') do |file|
39
+ unless gemfile_content.end_with?("\n")
40
+ file.puts "\n"
41
+ end
42
+ if gem_version.is_a?(Hash)
43
+ file.puts "gem '#{gem_name}', '#{gem_version[:version]}', '#{gem_version[:additional_version]}'"
44
+ else
45
+ file.puts "gem '#{gem_name}', '#{gem_version}'"
46
+ end
47
+ end
48
+ end
49
+
50
+ def run_bundle_install
51
+ puts('Running bundle install...')
52
+ system('bundle install')
53
+ puts('Running bundle install done...')
54
+ end
55
+
56
+ def exec_vite_install
57
+ system('bundle exec vite install')
58
+ end
59
+
60
+ def find_gemfile_path
61
+ current_dir = Dir.pwd
62
+
63
+ until File.exist?(File.join(current_dir, 'Gemfile'))
64
+ parent_dir = File.expand_path('..', current_dir)
65
+ break if current_dir == parent_dir # Reached the root directory
66
+
67
+ current_dir = parent_dir
68
+ end
69
+
70
+ gemfile_path = File.join(current_dir, 'Gemfile')
71
+ raise Error, 'Gemfile not found' unless File.exist?(gemfile_path)
72
+
73
+ gemfile_path
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_vue3_quasar/base_handle'
4
+ require 'FileUtils'
5
+ require 'rails_vue3_quasar/handle_add_gem'
6
+ require 'rails_vue3_quasar/handle_add_setting'
7
+ require 'rails_vue3_quasar/handle_run_dependency'
8
+ require 'rails_vue3_quasar/handle_change_routes'
9
+ require 'rails_vue3_quasar/handle_add_setting_vue'
10
+
11
+ module RailsVue3Quasar
12
+ # class add library BaseHandle
13
+ class HandleAddLib < RailsVue3Quasar::BaseHandle
14
+ attr_reader :add_phaser
15
+
16
+ def initialize(add_phaser)
17
+ @add_phaser = add_phaser
18
+ end
19
+
20
+ def process
21
+ add_file_package_json
22
+ add_phaser_lib if add_phaser == '-g'
23
+ HandleAddGem.process
24
+ HandleAddSetting.process
25
+ HandleRunDependency.run
26
+ run_install_lib_by_yarn
27
+ HandleChangeRoutes.process
28
+ HandleAddSettingVue.process
29
+ end
30
+
31
+ private
32
+
33
+ def run_install_lib_by_yarn
34
+ unless install_yarn?
35
+ puts 'Yarn is not installed. Please install Yarn and try again.'
36
+ return
37
+ end
38
+
39
+ system('yarn install')
40
+ end
41
+
42
+ def add_phaser_lib
43
+ unless install_yarn?
44
+ puts 'Yarn is not installed. Please install Yarn and try again.'
45
+ return
46
+ end
47
+
48
+ system('yarn add phaser')
49
+ end
50
+
51
+ def add_file_package_json
52
+ source_file = File.expand_path('../rails_vue3_quasar/constants/package.json', __dir__)
53
+ destination_file = "#{project_root}/package.json"
54
+
55
+ if File.exist?(destination_file)
56
+ puts 'The package.json file already exists, overwrite the old file.'
57
+ else
58
+ puts 'The package.json file does not exist yet, copy it from the constants folder.'
59
+ end
60
+
61
+ FileUtils.cp(source_file, destination_file)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_vue3_quasar/base_handle'
4
+ require 'FileUtils'
5
+ require 'rails_vue3_quasar/constants/constants'
6
+
7
+ module RailsVue3Quasar
8
+ # class add setting
9
+ class HandleAddSetting < RailsVue3Quasar::BaseHandle
10
+ def process
11
+ create_dir_fontend
12
+ add_vite_config_ts
13
+ add_file_app_js
14
+ add_file_i18n_js
15
+ add_file_pages_js
16
+ add_file_vuetify_js
17
+ add_file_main_vue
18
+ add_file_css_quasar
19
+ add_file_rails_vue
20
+ add_file_rails_vue_controller
21
+ end
22
+
23
+ private
24
+
25
+ def add_file_rails_vue_controller
26
+ source_file = File.expand_path('../rails_vue3_quasar/constants/controllers/rails_vue_controller.rb', __dir__)
27
+ destination_file = "#{project_root}/app/controllers/rails_vue_controller.rb"
28
+
29
+ if File.exist?(destination_file)
30
+ puts 'The RailsVueController.rb file already exists, overwrite the old file.'
31
+ else
32
+ puts 'The RailsVueController.rb file does not exist yet, copy it from the constants folder.'
33
+ end
34
+
35
+ FileUtils.cp(source_file, destination_file)
36
+ end
37
+
38
+ def add_file_rails_vue
39
+ source_file = File.expand_path('../rails_vue3_quasar/constants/Pages/rails_vue/index.vue', __dir__)
40
+ puts(source_file)
41
+ destination_file = "#{project_root}/app/frontend/Pages/rails_vue/index.vue"
42
+
43
+ if File.exist?(destination_file)
44
+ puts 'The index.vue file already exists, overwrite the old file.'
45
+ else
46
+ puts 'The index.vue file does not exist yet, copy it from the constants folder.'
47
+ end
48
+
49
+ FileUtils.cp(source_file, destination_file)
50
+ end
51
+
52
+ def add_file_main_vue
53
+ source_file = File.expand_path('../rails_vue3_quasar/constants/Layouts/Main.vue', __dir__)
54
+ destination_file = "#{project_root}/app/frontend/Layouts/Main.vue"
55
+
56
+ if File.exist?(destination_file)
57
+ puts 'The main.vue file already exists, overwrite the old file.'
58
+ else
59
+ puts 'The main.vue file does not exist yet, copy it from the constants folder.'
60
+ end
61
+
62
+ FileUtils.cp(source_file, destination_file)
63
+ end
64
+
65
+ def add_file_css_quasar
66
+ source_file = File.expand_path('../rails_vue3_quasar/constants/css/quasar-variables.sass', __dir__)
67
+ destination_file = "#{project_root}/app/frontend/css/quasar-variables.sass"
68
+
69
+ if File.exist?(destination_file)
70
+ puts 'The quasar.css file already exists, overwrite the old file.'
71
+ else
72
+ puts 'The quasar.css file does not exist yet, copy it from the constants folder.'
73
+ end
74
+
75
+ FileUtils.cp(source_file, destination_file)
76
+ end
77
+
78
+ def add_vite_config_ts
79
+ config = Constants::VITE_CONFIG
80
+ puts('vite.config.ts will be overwritten') if File.exist?("#{project_root}/vite.config.ts")
81
+ File.open("#{project_root}/vite.config.ts", 'w') { |file| file.write(config) }
82
+ end
83
+
84
+ def add_file_app_js
85
+ puts('file app.js will be overwritten') if File.exist?("#{project_root}/app/frontend/app.js")
86
+ source_file = File.expand_path('../rails_vue3_quasar/constants/app.js', __dir__)
87
+ FileUtils.cp(source_file, "#{project_root}/app/frontend/app.js")
88
+ end
89
+
90
+ def add_file_i18n_js
91
+ puts('file i18n.js will be overwritten') if File.exist?("#{project_root}/app/frontend/i18n.js")
92
+ source_file = File.expand_path('../rails_vue3_quasar/constants/i18n.js', __dir__)
93
+ FileUtils.cp(source_file, "#{project_root}/app/frontend/i18n.js")
94
+ end
95
+
96
+ def add_file_pages_js
97
+ puts('file pages.js will be overwritten') if File.exist?("#{project_root}/app/frontend/pages.js")
98
+ source_file = File.expand_path('../rails_vue3_quasar/constants/pages.js', __dir__)
99
+ FileUtils.cp(source_file, "#{project_root}/app/frontend/pages.js")
100
+ end
101
+
102
+ def add_file_vuetify_js
103
+ puts('file pages.js will be overwritten') if File.exist?("#{project_root}/app/frontend/vuetify.js")
104
+ source_file = File.expand_path('../rails_vue3_quasar/constants/vuetify.js', __dir__)
105
+ FileUtils.cp(source_file, "#{project_root}/app/frontend/vuetify.js")
106
+ end
107
+
108
+ def create_dir_fontend
109
+ FileUtils.mkdir_p("#{project_root}/app/frontend") unless File.exist?("#{project_root}/app/frontend")
110
+ FileUtils.mkdir_p("#{project_root}/app/frontend/Pages") unless File.exist?("#{project_root}/app/frontend/Pages")
111
+ FileUtils.mkdir_p("#{project_root}/app/frontend/css") unless File.exist?("#{project_root}/app/frontend/css")
112
+ FileUtils.mkdir_p("#{project_root}/app/frontend/Layouts") unless File.exist?("#{project_root}/app/frontend/Layouts")
113
+ FileUtils.mkdir_p("#{project_root}/app/frontend/Pages/rails_vue") unless File.exist?("#{project_root}/app/frontend/Pages/rails_vue")
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_vue3_quasar/base_handle'
4
+ require 'rails_vue3_quasar/constants/constants'
5
+
6
+ module RailsVue3Quasar
7
+ class HandleAddSettingVue < RailsVue3Quasar::BaseHandle
8
+ def process
9
+ add_init_rails
10
+ end
11
+
12
+ private
13
+
14
+ def add_init_rails
15
+ config = Constants::INIT_VITE
16
+ if File.exist?("#{project_root}/app/javascript/entrypoints/application.js")
17
+ puts('vite.config.ts will be overwritten')
18
+ end
19
+ File.open("#{project_root}/app/javascript/entrypoints/application.js", 'a') { |file| file.write(config) }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_vue3_quasar/base_handle'
4
+ require 'FileUtils'
5
+ module RailsVue3Quasar
6
+ # class change file routes
7
+ class HandleChangeRoutes < RailsVue3Quasar::BaseHandle
8
+ def process
9
+ change_file_routes
10
+ end
11
+
12
+ private
13
+
14
+ def change_file_routes
15
+ route_to_add = "defaults export: true do\n get 'demo_vue' => 'rails_vue#index', as: :rails_vue\n end\n"
16
+
17
+ file_path = "#{project_root}/config/routes.rb"
18
+ routes = File.read(file_path)
19
+
20
+ # Insert the new route at the top of the routes file
21
+ updated_routes = routes.sub(
22
+ 'Rails.application.routes.draw do', "Rails.application.routes.draw do\n #{route_to_add}"
23
+ )
24
+ File.write(file_path, updated_routes)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsVue3Quasar
4
+ # class handle run dependency
5
+ class HandleRunDependency
6
+ MESS = <<-message
7
+ # routes.rb
8
+ Rails.application.routes.draw do
9
+ defaults export: true do
10
+ resources :expenses
11
+ resources :categories
12
+ end
13
+ end
14
+ message
15
+
16
+ def self.run
17
+ puts('generate js from routes')
18
+ puts('please change file routes js:')
19
+ puts(MESS)
20
+ system('rake js_from_routes:generate')
21
+ puts('done generate js from routes')
22
+ puts('If you change your routes file, run `rake js_from_routes:generate` to update js_from_routes with the new paths')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsVue3Quasar
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_vue3_quasar/version'
4
+ require 'rails_vue3_quasar/handle_add_lib'
5
+ require 'rails_vue3_quasar'
6
+
7
+ module RailsVue3Quasar
8
+ class Error < StandardError; end
9
+
10
+ # class to run command
11
+ class RailsVue3
12
+ class << self
13
+ def run(add_phaser = '')
14
+ RailsVue3Quasar::HandleAddLib.new(add_phaser).process
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'rails_vue3_quasar/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'rails_vue3_quasar'
9
+ spec.version = RailsVue3Quasar::VERSION
10
+ spec.authors = %w[devhoanglv92]
11
+ spec.email = %w[devhoanglv92@gmail.com]
12
+
13
+ spec.summary = 'Auto add vue3 and quasar to rails project'
14
+ spec.description = 'Auto add vue3 and quasar to rails project'
15
+ spec.homepage = 'https://github.com/hoangdev92/rails_vue3_quasar'
16
+ spec.license = 'MIT'
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ if spec.respond_to?(:metadata)
21
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
22
+
23
+ spec.metadata['homepage_uri'] = spec.homepage
24
+ spec.metadata['source_code_uri'] = 'https://github.com/hoangdev92/rails_vue3_quasar'
25
+ spec.metadata['changelog_uri'] = 'https://github.com/hoangdev92/rails_vue3_quasa/rblob/master/CHANGELOG.md'
26
+ else
27
+ raise "RubyGems 2.0 or newer is required to protect against " \
28
+ "public gem pushes."
29
+ end
30
+
31
+ # Specify which files should be added to the gem when it is released.
32
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
33
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
34
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
35
+ end
36
+ spec.bindir = 'bin'
37
+ spec.executables = ['rails_vue3_quasar']
38
+ spec.require_paths = ['lib']
39
+
40
+ spec.add_development_dependency "bundler", "~> 1.17"
41
+ spec.add_development_dependency "rake", "~> 10.0"
42
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_vue3_quasar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - devhoanglv92
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-12-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Auto add vue3 and quasar to rails project
42
+ email:
43
+ - devhoanglv92@gmail.com
44
+ executables:
45
+ - rails_vue3_quasar
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/rails_vue3_quasar
57
+ - bin/setup
58
+ - lib/rails_vue3_quasar.rb
59
+ - lib/rails_vue3_quasar/base_handle.rb
60
+ - lib/rails_vue3_quasar/constants/Layouts/Main.vue
61
+ - lib/rails_vue3_quasar/constants/Pages/rails_vue/index.vue
62
+ - lib/rails_vue3_quasar/constants/app.js
63
+ - lib/rails_vue3_quasar/constants/constants.rb
64
+ - lib/rails_vue3_quasar/constants/controllers/rails_vue_controller.rb
65
+ - lib/rails_vue3_quasar/constants/css/quasar-variables.sass
66
+ - lib/rails_vue3_quasar/constants/i18n.js
67
+ - lib/rails_vue3_quasar/constants/package.json
68
+ - lib/rails_vue3_quasar/constants/pages.js
69
+ - lib/rails_vue3_quasar/constants/vuetify.js
70
+ - lib/rails_vue3_quasar/handle_add_gem.rb
71
+ - lib/rails_vue3_quasar/handle_add_lib.rb
72
+ - lib/rails_vue3_quasar/handle_add_setting.rb
73
+ - lib/rails_vue3_quasar/handle_add_setting_vue.rb
74
+ - lib/rails_vue3_quasar/handle_change_routes.rb
75
+ - lib/rails_vue3_quasar/handle_run_dependency.rb
76
+ - lib/rails_vue3_quasar/version.rb
77
+ - rails_vue3_quasar.gemspec
78
+ homepage: https://github.com/hoangdev92/rails_vue3_quasar
79
+ licenses:
80
+ - MIT
81
+ metadata:
82
+ allowed_push_host: https://rubygems.org
83
+ homepage_uri: https://github.com/hoangdev92/rails_vue3_quasar
84
+ source_code_uri: https://github.com/hoangdev92/rails_vue3_quasar
85
+ changelog_uri: https://github.com/hoangdev92/rails_vue3_quasa/rblob/master/CHANGELOG.md
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.0.3
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Auto add vue3 and quasar to rails project
105
+ test_files: []