vuejs 1.1.0.beta8 → 1.1.0.beta9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59a21c8c271288914f0c2042c6e66d0f1dfcf3794ecb2cb1d3337d5ee52de411
4
- data.tar.gz: 8bbd932072c3118d5a06d6bf048cff093d2f7bf502f5f99f8d2353a7c8f040fb
3
+ metadata.gz: dc4f7d0ccd9c4c49b951d2e6935fc2f9324cc96445c2e650df8eb52d3a2ad603
4
+ data.tar.gz: 5a9918f4673802f8869edf4d6b9004ce077b20d13e1c932154687ad3d843ca6d
5
5
  SHA512:
6
- metadata.gz: a32bb28637f9d5a9b508a1da3c7f93da4298977c29714579d85f3557dc144284e96b8901c0f158b4921fa8e0fc1f6a7d10b3a6697d64d192a6bc18547a4c8d5c
7
- data.tar.gz: 4518bd397157286fadbae01837a51734ed03e2c2648c7fa9060a63fab27b9934d347cc067c9cec1359c58a2e314c2d5d1bba72919e64827adb3758657f0e3857
6
+ metadata.gz: 8ece669487dc16e776fc0a500b54fab711bf9ac7ad685f32cd6bf3fbb76c61a43ff2a09a35470c549da1fe579d54e0f7c972d845ce950d3b030d660a8aa4f9d9
7
+ data.tar.gz: eedf25468ef8e5d98977c1792f1127911d9184c3d6e96e2e4daa8e4669e09bf85b339593bebb8c7fcfe82f3c9e0393a34d7c0e84dd4884f84d7ea0243e8853ac
data/README.md CHANGED
@@ -1,139 +1,68 @@
1
- # Welcome to Vuejs Gem
1
+ # Welcome to Vuejs Gem 💎
2
2
 
3
3
  > Vue for your favourite Ruby on Rails projects
4
4
 
5
- `vuejs` rubygem makes it easy to get started with Vue on Rails project. To create an empty Vue on Rails project, please run the following command
5
+ This gem aims to make it easy and simple to run Vue on Rails project. It ships out-of-the-box configuration, component generators and solutions to make life easy for both Vue and Rails.
6
6
 
7
- ```
8
- rails new app -m http://vueonrails.com/vue
9
- ```
10
-
11
- ## Installation
12
-
13
- Add this line to your application's Gemfile and run `bundle`
14
-
15
- ```ruby
16
- gem 'vuejs'
17
- ```
18
-
19
- and run `rails vue:setup`
7
+ ---
20
8
 
21
- ## Get started
9
+ ## Getting Started
22
10
 
23
- To generate an empty Vue on Rails project with all its dependencies, run Rails with its application template
11
+ To create an empty Vue on Rails project, please run the following Rails command with an application template
24
12
 
25
13
  ```
26
14
  rails new app -m http://vueonrails.com/vue
27
15
  ```
28
16
 
29
- To browse the application template, it's here http://vueonrails.com/vue
30
-
31
-
32
- ## Generate a new Vue component
33
-
34
- To generate a new vue component is easy. Please run the following command:
35
-
36
- ```
37
- rails generate vue something
38
- ```
39
-
40
- > Note: `vuejs` gem creates vue components as single-file component by default.
17
+ To browse the application template, it's here http://vueonrails.com/vue
41
18
 
42
- To generate a component with seperation of concern, please use the option `--seperate`,
43
- like `rails g vue something --seperate`
44
19
 
45
- > rails g vue something --seperate
20
+ ## Manual Installation
46
21
 
47
- ## Destroy a Vue component
22
+ Add this line to your application's Gemfile and run `bundle`
48
23
 
49
- To destroy a vue component is easy. Please run:
50
- ```
51
- rails destroy vue something
24
+ ```ruby
25
+ gem 'vuejs'
52
26
  ```
53
27
 
54
- ## View a standalone Vue component
55
-
56
- Vue-component viewer allows you to browse your individual & independent Vue component easily without its surrounding element outside the scope of the component. Simply visit http://localhost:3000/vue/<name>
57
-
58
- To mount the endpoint `/vue/<name>`, go to routes.rb and paste this:
59
-
60
- ```
61
- mount Vuejs::engine, to: 'vue'
62
- ```
28
+ and run `rails vue:setup`
63
29
 
64
- ## Generate a Vue component with Turbolinks support
30
+ You can scaffold a Vue component by reading along the [Vue on Rails Handbook](/vueonrails/tree/master/docs)
65
31
 
66
- ```
67
- rails generate vue something --turbolinks
68
- ```
32
+ ---
69
33
 
70
- ## Generate a Vue component with Vuex support
34
+ ## Getting Help & Contributing Back
71
35
 
72
- ```
73
- rails generate vue something --vuex
74
- ```
36
+ - [Official Rails documentation](https://guides.rubyonrails.org)
37
+ - [Official Vue documentation](https://vuejs.org/v2/guide/)
38
+ - [vuecomponents.com](https://vuecomponents.com)
39
+ - [Official Find vue curated component](https://curated.vuejs.org)
40
+ - [vuetoolbox.com](http://www.vuetoolbox.com)
41
+ - [github search for vue stuffs](https://github.com/search?o=desc&q=vue&s=stars&type=Repositories)
42
+ - [stackoverflow.com](https://stackoverflow.com/questions/tagged/vue.js+ruby-on-rails)
75
43
 
76
- ## Generate a Vue component with Specific Page Vue support
77
44
 
78
- ```
79
- rails generate vue something --spv
80
- ```
45
+ On stackoverflow.com, tag your Vue on Rails questions with Vue & Rails and we will try to answer you.
81
46
 
82
- ## Generate a Vue component with unit tests
47
+ - And it is likely that I missed some great online materials. If you think there is a more worthy resource, please edit this readme via a pull request.
83
48
 
84
- ```
85
- rails generate vue something --test
86
- ```
49
+ - Find a bug? [Submit an issue](https://github.com/ytbryan/vueonrails/issues) on our tracker.
87
50
 
88
- ## Passing Rails Variable into Vue component - coming soon
51
+ - Find something wrong? [Send a pull request](https://github.com/ytbryan/vueonrails/pulls).
89
52
 
90
53
  ---
91
54
 
92
- # Some Solution for assets pipeline
93
-
94
- ### Sprockets::FileNotFound: couldn't find file 'vue-validator'
95
-
96
- ```
97
- Sprockets::FileNotFound: couldn't find file 'vue-validator' with type 'application/javascript'
98
- ```
99
-
100
- vue-validator has been changed to vue-validator2
101
- and vue-validator3. Use `//= require vue-validator2` or `//= require vue-validator3` instead.
102
-
103
- ### Sprockets::FileNotFound: couldn't find file 'vuex'
104
-
105
- vuex has been updated to vuex2. Therefore use `//= require vuex2` to resolve the error `Sprockets::FileNotFound: couldn't find file 'vuex'`.
106
-
107
- ### You are running Vue in development mode.
108
-
109
- ```
110
- You are running Vue in development mode.
111
- Make sure to turn on production mode when deploying for production.
112
- See more tips at https://vuejs.org/guide/deployment.html
113
- ```
55
+ ## Contact
114
56
 
115
- Try to use `//= require vue2.min` to remove the warning statement from console.
57
+ 📮 Bryan Lim ytbryan@gmail.com
116
58
 
59
+ > If you are using Vue.js via this rubygem, please let me know so that I can list your project/company on this repo. Thank you!
117
60
 
118
- ## Requirement
61
+ Richard LaFranchi and I are writing a book [Vue on rails](http://vueonrails.com). If you are interested to be one of the early reviewers of our drafts, please email me.
119
62
 
120
- - Rails
121
- - Webpacker
122
- - Vue
123
- - Node
124
- - Webpack
63
+ ---
125
64
 
126
- ## Contributing and License
65
+ ## MIT License
127
66
 
128
- Bug reports and pull requests are welcome on GitHub at https://github.com/ytbryan/vuejs. 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.
67
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ytbryan/vueonrails. 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.
129
68
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
130
-
131
- ## Book
132
-
133
- Richard LaFranchi and I are writing a book on [Vue on rails](http://vueonrails.com). If you are interested to be one of the early reviewers of our drafts, please email me.
134
-
135
- ## Contact
136
-
137
- 📮 Bryan Lim ytbryan@gmail.com
138
-
139
- > If you are using Vue.js via this rubygem, do let me know so that I can list your project/company on this repo. Thank you!
@@ -1,5 +1,5 @@
1
1
  module SyntaxHelper
2
- def page_specific_vue
2
+ def specific_page_vue
3
3
  return " #{controller_name} #{action_name} "
4
4
  end
5
5
 
@@ -26,11 +26,11 @@ module SyntaxHelper
26
26
  end
27
27
  end
28
28
 
29
- def vue(identifier)
30
- concat("<div id=\"#{identifier}\" refs=\"#{identifier}\">".html_safe)
31
- yield
32
- concat("</div>".html_safe)
33
- end
29
+ # def vue(identifier)
30
+ # concat("<div id=\"#{identifier}\" refs=\"#{identifier}\">".html_safe)
31
+ # yield
32
+ # concat("</div>".html_safe)
33
+ # end
34
34
 
35
- alias v vue
35
+ # alias v vue
36
36
  end
@@ -16,8 +16,8 @@ export default {
16
16
  }
17
17
  },
18
18
  methods: {
19
- onClick: function(response){
20
- alert("clicked")
19
+ //uncomment the <button @click="onClick"> at your <%= name %>.vue
20
+ onClick: function(){
21
21
  console.log("clicked")
22
22
  }
23
23
  },
@@ -22,8 +22,8 @@ export default {
22
22
  }
23
23
  },
24
24
  methods: {
25
- onClick: function(response){
26
- alert("clicked")
25
+ //uncomment the <button @click="onClick"> at your template
26
+ onClick: function(){
27
27
  console.log("clicked")
28
28
  }
29
29
  },
@@ -10,8 +10,8 @@ import App from '../parts/<%= name %>/<%= name %>.vue'
10
10
  <% else -%>
11
11
  import App from '../parts/<%= name %>.vue'
12
12
  <% end -%>
13
- Vue.use(TurbolinksAdapter)
14
13
 
14
+ Vue.use(TurbolinksAdapter)
15
15
  document.addEventListener('turbolinks:load', () => {
16
16
  if(isView("###")){
17
17
  const <%= name %> = new Vue({
@@ -0,0 +1,10 @@
1
+ click = <<-eos
2
+ <button @click="onClick()">click</button>
3
+ eos
4
+
5
+ say "Inserted click example into component"
6
+ insert_into_file "#{PARTS_PATH}/#{name}.vue",
7
+ click, after: "<p>{{ message }}</p>\n"
8
+
9
+ insert_into_file "#{PARTS_PATH}/#{name}.vue",
10
+ " alert('click');\n", after: "console.log(\"clicked\")\n"
@@ -0,0 +1,19 @@
1
+ say "Inserted form example into component"
2
+ insert_into_file "#{PACKS_PATH}/#{name}.js" ,
3
+ "import FormFor from 'vue-form-for'\n",
4
+ after: "import Vue from 'vue'\n"
5
+
6
+ insert_into_file "#{PACKS_PATH}/#{name}.js",
7
+ "Vue.use(FormFor)\n",
8
+ before: "document.addEventListener"
9
+
10
+ form = <<-eos
11
+ <form-for model="#{name}">
12
+ <text-field/>
13
+ <submit-tag/>
14
+ </form-for>
15
+ eos
16
+
17
+ insert_into_file "#{PARTS_PATH}/#{name}.vue",
18
+ form,
19
+ after: "<p>{{ message }}</p>\n"
@@ -0,0 +1,32 @@
1
+ list = <<-eos
2
+ <button @click="add()">add</button>
3
+ <button @click="remove()">remove</button>
4
+ <ul>
5
+ <li v-for="(item, index) in items" :key="index">
6
+ {{item}}
7
+ </li>
8
+ </ul>
9
+ eos
10
+
11
+ array = <<-eos
12
+ items: [],
13
+ eos
14
+
15
+ addandremove = <<-eos
16
+ remove: function(){
17
+ this.items.pop()
18
+ },
19
+ add: function(){
20
+ this.items.push(this.message)
21
+ },
22
+ eos
23
+
24
+ say "Inserted list example into component"
25
+ insert_into_file "#{PARTS_PATH}/#{name}.vue",
26
+ list, after: "<p>{{ message }}</p>\n"
27
+
28
+ insert_into_file "#{PARTS_PATH}/#{name}.vue",
29
+ addandremove, after: "methods: {\n"
30
+
31
+ insert_into_file "#{PARTS_PATH}/#{name}.vue",
32
+ array, after: "return {\n"
@@ -0,0 +1,26 @@
1
+ run "yarn add vue-js-modal"
2
+
3
+ say "Inserted vue-js-modal example into component"
4
+ insert_into_file "#{PACKS_PATH}/#{name}.js" ,
5
+ "import VModal from 'vue-js-modal'\n",
6
+ after: "import Vue from 'vue'\n"
7
+
8
+ insert_into_file "#{PACKS_PATH}/#{name}.js",
9
+ "Vue.use(VModal)\n",
10
+ before: "document.addEventListener"
11
+
12
+ modal = <<-eos
13
+ <button @click="onClick">click this</button>
14
+ <modal name="hello-world">
15
+ <div style="padding: 30px;">
16
+ {{ message }}
17
+ </div>
18
+ <v-dialog/>
19
+ </modal>
20
+ eos
21
+
22
+ insert_into_file "#{PARTS_PATH}/#{name}.vue",
23
+ modal, after: "<p>{{ message }}</p>\n"
24
+
25
+ insert_into_file "#{PARTS_PATH}/#{name}.vue",
26
+ " this.$modal.show('hello-world');\n", after: "console.log(\"clicked\")\n"
@@ -0,0 +1,5 @@
1
+ say "Generated a vue component with seperation of concern"
2
+ template "packs/pack.js.erb", "#{PACKS_PATH}/#{name}.js"
3
+ template "packs/index.vue", "#{PARTS_PATH}/#{name}/#{name}.vue"
4
+ template "packs/index.js", "#{PARTS_PATH}/#{name}/#{name}.js"
5
+ copy_file "packs/index.css", "#{PARTS_PATH}/#{name}/#{name}.css"
@@ -0,0 +1,3 @@
1
+ say "Generated a single file component"
2
+ template "packs/pack.js.erb", "#{PACKS_PATH}/#{name}.js"
3
+ template "sfc/single-file-component.vue", "#{PARTS_PATH}/#{name}.vue"
@@ -0,0 +1,10 @@
1
+ run "yarn add vuetable-2"
2
+
3
+ say "Inserted table example into component"
4
+ insert_into_file "#{PACKS_PATH}/#{name}.js" ,
5
+ "import Vuetable from 'vuetable-2/src/components/Vuetable'\n",
6
+ after: "import Vue from 'vue'\n"
7
+
8
+ insert_into_file "#{PACKS_PATH}/#{name}.js",
9
+ "Vue.use(Vuetable)\n",
10
+ before: "document.addEventListener"
@@ -0,0 +1,2 @@
1
+ say "Included Jest test"
2
+ template "tests/unit.test.js.erb", "#{TESTS_PATH}/#{name}.test.js"
@@ -0,0 +1,5 @@
1
+ say "Adding turbolinks to a single file component"
2
+ template "turbolinks/turbolinks-pack.js.erb", "#{PACKS_PATH}/#{name}.js"
3
+ template "packs/index.vue", "#{PARTS_PATH}/#{name}/#{name}.vue"
4
+ template "packs/index.js", "#{PARTS_PATH}/#{name}/#{name}.js"
5
+ copy_file "packs/index.css", "#{PARTS_PATH}/#{name}/#{name}.css"
@@ -0,0 +1,3 @@
1
+ say "Added turbolinks to a single file component"
2
+ template "turbolinks/turbolinks-pack.js.erb", "#{PACKS_PATH}/#{name}.js"
3
+ template "sfc/single-file-component.vue", "#{PARTS_PATH}/#{name}.vue"
@@ -0,0 +1,10 @@
1
+ run "yarn add vuex"
2
+
3
+ say "Added Vuex"
4
+ insert_into_file "#{PACKS_PATH}/#{name}.js" ,
5
+ "import Vuex from 'vuex'\n",
6
+ after: "import Vue from 'vue'\n"
7
+
8
+ insert_into_file "#{PACKS_PATH}/#{name}.js",
9
+ "Vue.use(Vuex)\n",
10
+ before: "document.addEventListener"
@@ -1,95 +1,59 @@
1
+ require 'ostruct'
2
+
1
3
  class VueGenerator < Rails::Generators::NamedBase
2
4
  source_root File.expand_path('../../generator_templates', __FILE__)
3
5
 
4
6
  argument :name, type: :string, default: :index
5
- class_option :seperate, type: :boolean, default: false
6
- class_option :vuex, type: :boolean, default: false
7
- class_option :turbolinks, type: :boolean, default: false
8
- class_option :test, type: :boolean, default: false
9
- class_option 'form-for', type: :boolean, default: false
10
7
 
11
8
  PACKS_PATH = "app/javascript/packs"
12
9
  PARTS_PATH = "app/javascript/parts"
13
10
  TESTS_PATH = "app/javascript/tests"
14
11
 
15
- def vue
16
- if options[:seperate]
12
+
13
+ OPTIONS = {
14
+ test: {type: :boolean, default: false},
15
+ vuex: {type: :boolean, default: false},
16
+ form: {type: :boolean, default: false},
17
+ tab: {type: :boolean, default: false},
18
+ list: {type: :boolean, default: false},
19
+ table: {type: :boolean, default: false},
20
+ modal: {type: :boolean, default: false},
21
+ click: {type: :boolean, default: false},
22
+ }.freeze
23
+
24
+ class_option :seperate, type: :boolean, default: false
25
+ class_option :turbolinks, type: :boolean, default: false
26
+
27
+ OPTIONS.each do |each_option, value|
28
+ class_option each_option, type: :boolean, default: false
29
+ end
30
+
31
+ def vue
32
+ if options[:seperate]
17
33
  if options[:turbolinks]
18
- create_turbolink_component_with_seperate_concern_using(name)
34
+ add_to_component("turbolinks-seperate", name)
19
35
  else
20
- create_component_with_seperate_concern_using(name)
36
+ add_to_component("seperate", name)
21
37
  end
22
38
  else
23
39
  if options[:turbolinks]
24
- create_turbolink_single_file_component_using(name)
40
+ add_to_component("turbolinks-single", name)
25
41
  else
26
- create_single_file_component_using(name)
42
+ add_to_component("single", name)
27
43
  end
28
44
  end
29
-
30
- options[:test] ? add_tests_to_component(name) : nil
31
- options[:vuex] ? add_vuex_to_component(name) : nil
32
- options['form-for'] ? add_helpers_to_component(name) : nil
33
- end
34
45
 
35
- private
36
-
37
- def add_tests_to_component name
38
- template "tests/unit.test.js.erb", "#{TESTS_PATH}/#{name}.test.js"
39
- end
40
-
41
- def add_helpers_to_component name
42
- insert_into_file "#{PACKS_PATH}/#{name}.js" ,
43
- "import FormFor from 'vue-form-for'",
44
- after: "import Vue from 'vue'\n"
45
-
46
- insert_into_file "#{PACKS_PATH}/#{name}.js",
47
- "Vue.use(FormFor)\n",
48
- before: "document.addEventListener"
49
-
50
- run "yarn add vue-form-for"
51
- end
52
-
53
- def add_vuex_to_component name
54
- insert_into_file "#{PACKS_PATH}/#{name}.js" ,
55
- "import Vuex from 'vuex'\n",
56
- after: "import Vue from 'vue'\n"
57
-
58
- insert_into_file "#{PACKS_PATH}/#{name}.js",
59
- "Vue.use(Vuex)\n",
60
- before: "document.addEventListener"
61
- run "yarn add vuex"
62
- end
63
-
64
- def create_component_with_seperate_concern_using name
65
- say "Generated a vue component with seperation of concern"
66
- @code = "<%= vue \"#{name}\" %>"
67
- template "packs/pack.js.erb", "#{PACKS_PATH}/#{name}.js"
68
- template "packs/index.vue", "#{PARTS_PATH}/#{name}/#{name}.vue"
69
- template "packs/index.js", "#{PARTS_PATH}/#{name}/#{name}.js"
70
- copy_file "packs/index.css", "#{PARTS_PATH}/#{name}/#{name}.css"
71
- end
72
-
73
- def create_single_file_component_using name
74
- say "Generated a single file component"
75
- @code = "<%= vue \"#{name}\" %>"
76
- template "packs/pack.js.erb", "#{PACKS_PATH}/#{name}.js"
77
- template "sfc/single-file-component.vue", "#{PARTS_PATH}/#{name}.vue"
78
- end
79
-
80
- def create_turbolink_single_file_component_using name
81
- say "Adding turbolinks to a single file component"
82
- @code = "<%= vue \"#{name}\" %>"
83
- template "turbolinks/turbolinks-pack.js.erb", "#{PACKS_PATH}/#{name}.js"
84
- template "sfc/single-file-component.vue", "#{PARTS_PATH}/#{name}.vue"
46
+ OPTIONS.each do |each_option, value|
47
+ options[each_option] ? add_to_component(each_option, name) : nil
48
+ end
85
49
  end
86
50
 
87
- def create_turbolink_component_with_seperate_concern_using name
88
- say "Adding turbolinks to vue component with seperate of concerns"
89
- @code = "<%= vue \"#{name}\" %>"
90
- template "turbolinks/turbolinks-pack.js.erb", "#{PACKS_PATH}/#{name}.js"
91
- template "packs/index.vue", "#{PARTS_PATH}/#{name}/#{name}.vue"
92
- template "packs/index.js", "#{PARTS_PATH}/#{name}/#{name}.js"
93
- copy_file "packs/index.css", "#{PARTS_PATH}/#{name}/#{name}.css"
51
+ private
52
+ def add_to_component(example, name)
53
+ puts "add to component #{name} running #{example}"
54
+ namespace = OpenStruct.new(TESTS_PATH: TESTS_PATH, PARTS_PATH: PARTS_PATH, PACKS_PATH: PACKS_PATH, name: name)
55
+ template = File.read(File.expand_path("../options/#{example}.rb", __dir__))
56
+ erbtemplate = ERB.new(template).result(namespace.instance_eval { binding })
57
+ eval erbtemplate
94
58
  end
95
59
  end
@@ -0,0 +1,2 @@
1
+ rails: rails server -p 3000
2
+ webpack: ./bin/webpack-dev-server
@@ -1,18 +1,25 @@
1
- say "Adding alias.js to config/webpack/alias"
1
+ say "Adding @vue/test-utils and other Jest devdependencies"
2
+ run "yarn add @vue/test-utils jest jest-serializer-vue vue-jest babel-jest --dev --no-progress --silent"
3
+
4
+ say "Setup Vue on Rails"
2
5
  copy_file "#{__dir__}/config/alias.js", Rails.root.join("config/webpack/alias/alias.js").to_s
3
6
 
4
- say "Adding alias configuration to config/webpack/environment.js"
7
+ # say "Adding alias configuration to config/webpack/environment.js"
5
8
  insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
6
9
  "const alias = require('./alias/alias')\n",
7
10
  after: "require('@rails/webpacker')\n"
8
11
 
9
- say "Adding javascript_packs_tag and stylesheet_packs_tag into head"
12
+ pack_tag = <<-eos
13
+ <%= javascript_pack_tag 'application' %>
14
+ <%= stylesheet_pack_tag 'application' %>
15
+ eos
16
+
17
+ # say "Added javascript_packs_tag and stylesheet_packs_tag into head"
10
18
  insert_into_file Rails.root.join("app/views/layouts/application.html.erb").to_s,
11
- " <%= javascript_pack_tag 'application' %>
12
- <%= stylesheet_pack_tag 'application' %>\n",
19
+ pack_tag,
13
20
  before: " </head>\n"
14
21
 
15
- say "Adding hello vue example"
22
+ # say "Added hello vue example"
16
23
  insert_into_file Rails.root.join("app/javascript/packs/application.js").to_s,
17
24
  "\nrequire('./hello_vue')\n",
18
25
  after: "console.log('Hello World from Webpacker')\n"
@@ -23,11 +30,11 @@ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
23
30
 
24
31
  scripts = <<-eos
25
32
  "scripts": {
26
- "rails server": "rails server",
27
- "webpack-dev-server": "./bin/webpack-dev-server",
28
- "rails assets:precompile": "yarn install; rails assets:precompile",
33
+ "yarn test": "jest",
29
34
  "yarn install": "yarn install",
30
- "yarn test": "jest"
35
+ "rails assets:precompile": "yarn install; rails assets:precompile",
36
+ "rails server": "rails server",
37
+ "webpack-dev-server": "./bin/webpack-dev-server"
31
38
  },
32
39
  "jest": {
33
40
  "moduleFileExtensions": [
@@ -47,12 +54,12 @@ scripts = <<-eos
47
54
  },
48
55
  eos
49
56
 
50
- say "Adding scripts and Jest configuration to package.json"
57
+ # say "Added scripts and Jest configuration to package.json"
51
58
  insert_into_file Rails.root.join("package.json").to_s,
52
59
  "#{scripts}",
53
60
  after: "\"private\": true,\n"
54
61
 
55
- say "Adding test presets to .babelrc"
62
+ # say "Adding test presets to .babelrc"
56
63
  babelrc = <<-eos
57
64
  "env": {
58
65
  "test": {
@@ -67,5 +74,9 @@ insert_into_file Rails.root.join(".babelrc").to_s,
67
74
  "#{babelrc}",
68
75
  before: " \"presets\": ["
69
76
 
70
- say "Adding @vue/test-utils and other Jest devdependencies"
71
- run "yarn add @vue/test-utils jest jest-serializer-vue vue-jest babel-jest --dev"
77
+ # say "Adding foreman's Procfile"
78
+ template "#{__dir__}/Procfile", Rails.root.join("Procfile").to_s
79
+
80
+ # say "Enabling Specific Page Vue"
81
+ gsub_file Rails.root.join("app/views/layouts/application.html.erb").to_s,
82
+ /<body>/, '<body class="<%= specific_page_vue %>">'
@@ -0,0 +1,20 @@
1
+ gsub_file Rails.root.join("app/views/layouts/application.html.erb").to_s,
2
+ /<body>/, '<body class="<%= specific_page_vue %>">'
3
+
4
+ pack_tag = <<-eos
5
+ <%= javascript_pack_tag 'application' %>
6
+ <%= stylesheet_pack_tag 'application' %>
7
+ eos
8
+
9
+ # say "Added javascript_packs_tag and stylesheet_packs_tag into head"
10
+ insert_into_file Rails.root.join("app/views/layouts/application.html.erb").to_s,
11
+ pack_tag,
12
+ before: " </head>\n"
13
+
14
+ vue_on_rails = <<-eos
15
+ //= vue-on-rails
16
+ eos
17
+
18
+ insert_into_file Rails.root.join("app/assets/javascripts/application.js").to_s,
19
+ vue_on_rails,
20
+ before: "//= require_tree ."
@@ -43,4 +43,4 @@ insert_into_file Rails.root.join(".babelrc").to_s,
43
43
  before: " \"presets\": ["
44
44
 
45
45
  say "Adding @vue/test-util and other Jest dependencies"
46
- run "yarn add jest-serializer-vue vue-jest babel-jest"
46
+ run "yarn add jest-serializer-vue vue-jest babel-jest --no-progress --silent"
@@ -1,3 +1,3 @@
1
- @code = "<%= vue \"#{name}\" %>"
2
- template "packs/pack.js.erb", "#{PACKS_PATH}/#{name}.js"
3
- template "sfc/single-file-component.vue", "#{PARTS_PATH}/#{name}.vue"
1
+ # template "packs/pack.js.erb", "#{PACKS_PATH}/#{name}.js"
2
+ # template "sfc/single-file-component.vue", "#{PARTS_PATH}/#{name}.vue"
3
+ run "yarn list vue-turbolinks --no-progress --silent"
@@ -1,2 +1,4 @@
1
- say "Adding @vue/cli-service to make Vue-ui compatible"
2
- run "yarn add @vue/cli-service --dev"
1
+ # say "Adding @vue/cli-service to make Vue-ui compatible"
2
+ # run "yarn add @vue/cli-service --dev"
3
+
4
+ run "yarn list @vue/cli-service --no-progress --silent"
@@ -1,10 +1,12 @@
1
- say "Adding Vuex & Vuex Rails Plugins to Vue on Rails"
2
- run "yarn add vuex vuex-rails-plugins"
1
+ # say "Adding Vuex & Vuex Rails Plugins to Vue on Rails"
2
+ # run "yarn add vuex vuex-rails-plugins"
3
3
 
4
- insert_into_file "#{PACKS_PATH}/#{name}.js" ,
5
- "import Vuex from 'vuex'",
6
- after: "import Vue from 'vue'\n"
4
+ # insert_into_file "#{PACKS_PATH}/#{name}.js" ,
5
+ # "import Vuex from 'vuex'",
6
+ # after: "import Vue from 'vue'\n"
7
7
 
8
- insert_into_file "#{PACKS_PATH}/#{name}.js",
9
- "Vue.use(Vuex)\n",
10
- before: "document.addEventListener"
8
+ # insert_into_file "#{PACKS_PATH}/#{name}.js",
9
+ # "Vue.use(Vuex)\n",
10
+ # before: "document.addEventListener"
11
+
12
+ puts "vuex"
@@ -1,7 +1,7 @@
1
1
  require 'open-uri'
2
2
 
3
3
  namespace :vue do
4
- desc "install vue.js into assets pipeline"
4
+ desc "Install Vue.js into assets pipeline"
5
5
  task :assets do
6
6
  version = "2.5.16"
7
7
  source = "https://cdnjs.cloudflare.com/ajax/libs/vue/#{version}/vue.js"
@@ -1,5 +1,5 @@
1
1
  namespace :vue do
2
- desc "provide information on Webpacker's environment"
2
+ desc "Provide information on Webpacker's environment"
3
3
  task :info do
4
4
  $stdout.puts "Ruby: #{`ruby --version`}"
5
5
  $stdout.puts "Rails: #{Rails.version}"
@@ -0,0 +1,27 @@
1
+ bin_path = ENV["BUNDLE_BIN"] || "./bin"
2
+
3
+ TASKS = {
4
+ turbolinks: "Check Vue-turbolinks ready",
5
+ setup: "Check Vue on Rails ready",
6
+ test: "Check Jest tests ready",
7
+ vuex: "Check Vuex ready",
8
+ ui: "Check Vue-ui ready",
9
+ spv: "Check Specific-page Vue ready?"
10
+ }.freeze
11
+
12
+ namespace :vue do
13
+ TASKS.each do |task_name, description|
14
+ desc description
15
+ task task_name do
16
+ template = File.expand_path("../install/#{task_name}.rb", __dir__)
17
+ base_path =
18
+ if Rails::VERSION::MAJOR >= 5
19
+ "#{RbConfig.ruby} #{bin_path}/rails app:template"
20
+ else
21
+ "#{RbConfig.ruby} #{bin_path}/rake rails:template"
22
+ end
23
+
24
+ exec "#{base_path} LOCATION=#{template}"
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Vuejs
2
- VERSION = "1.1.0.beta8"
2
+ VERSION = "1.1.0.beta9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vuejs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.beta8
4
+ version: 1.1.0.beta9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Lim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-24 00:00:00.000000000 Z
11
+ date: 2018-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -46,7 +46,6 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - LICENSE
50
49
  - README.md
51
50
  - app/controllers/vue_controller.rb
52
51
  - app/helpers/syntax_helper.rb
@@ -59,18 +58,30 @@ files:
59
58
  - lib/generators/generator_templates/sfc/single-file-component.vue
60
59
  - lib/generators/generator_templates/tests/unit.test.js.erb
61
60
  - lib/generators/generator_templates/turbolinks/turbolinks-pack.js.erb
62
- - lib/generators/generator_templates/vuex/index.js
61
+ - lib/generators/options/click.rb
62
+ - lib/generators/options/form.rb
63
+ - lib/generators/options/list.rb
64
+ - lib/generators/options/modal.rb
65
+ - lib/generators/options/seperate.rb
66
+ - lib/generators/options/single.rb
67
+ - lib/generators/options/table.rb
68
+ - lib/generators/options/test.rb
69
+ - lib/generators/options/turbolinks-seperate.rb
70
+ - lib/generators/options/turbolinks-single.rb
71
+ - lib/generators/options/vuex.rb
63
72
  - lib/generators/vue/USAGE
64
73
  - lib/generators/vue/vue_generator.rb
74
+ - lib/install/Procfile
65
75
  - lib/install/config/alias.js
66
76
  - lib/install/setup.rb
77
+ - lib/install/spv.rb
67
78
  - lib/install/test.rb
68
79
  - lib/install/turbolinks.rb
69
80
  - lib/install/ui.rb
70
81
  - lib/install/vuex.rb
71
82
  - lib/tasks/assets.rake
72
83
  - lib/tasks/info.rake
73
- - lib/tasks/setup.rake
84
+ - lib/tasks/vue.rake
74
85
  - lib/vuejs.rb
75
86
  - lib/vuejs/post_message.rb
76
87
  - lib/vuejs/version.rb
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 Bryan Lim (@ytbryan)
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 all
13
- 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 THE
21
- SOFTWARE.
@@ -1,22 +0,0 @@
1
- // Generated by Vuejs gem ~> github.com/ytbryan/vuejs
2
-
3
- export default {
4
- // components: {},
5
- // mixins: [],
6
- // props: {},
7
- data: function() {
8
- return {
9
- message: "Hello <%= name %>!"
10
- };
11
- },
12
- watch: {
13
- onMounted: function(response){
14
- this.items = response.data
15
- }
16
- },
17
- methods: {
18
- click: function(response){
19
- console.log("clicked")
20
- }
21
- }
22
- };
@@ -1,72 +0,0 @@
1
- bin_path = ENV["BUNDLE_BIN"] || "./bin"
2
- namespace :vue do
3
- desc "setup your vue on rails project"
4
- task :setup do
5
- template = File.expand_path("../install/setup.rb", __dir__)
6
- base_path =
7
- if Rails::VERSION::MAJOR >= 5
8
- "#{RbConfig.ruby} #{bin_path}/rails app:template"
9
- else
10
- "#{RbConfig.ruby} #{bin_path}/rake rails:template"
11
- end
12
-
13
- exec "#{base_path} LOCATION=#{template}"
14
- end
15
-
16
- desc "install turbolinks"
17
- task :turbolinks do
18
- template = File.expand_path("../install/turbolinks.rb", __dir__)
19
- base_path =
20
- if Rails::VERSION::MAJOR >= 5
21
- "#{RbConfig.ruby} #{bin_path}/rails app:template"
22
- else
23
- "#{RbConfig.ruby} #{bin_path}/rake rails:template"
24
- end
25
-
26
- exec "#{base_path} LOCATION=#{template}"
27
- end
28
-
29
- desc "setup vue on rails to be ready for Jest tests"
30
- task :test do
31
- template = File.expand_path("../install/test.rb", __dir__)
32
- base_path =
33
- if Rails::VERSION::MAJOR >= 5
34
- "#{RbConfig.ruby} #{bin_path}/rails app:template"
35
- else
36
- "#{RbConfig.ruby} #{bin_path}/rake rails:template"
37
- end
38
-
39
- exec "#{base_path} LOCATION=#{template}"
40
- end
41
-
42
- desc "install vuex and vuex-rails-plugins"
43
- task :vuex do
44
- template = File.expand_path("../install/vuex.rb", __dir__)
45
- base_path =
46
- if Rails::VERSION::MAJOR >= 5
47
- "#{RbConfig.ruby} #{bin_path}/rails app:template"
48
- else
49
- "#{RbConfig.ruby} #{bin_path}/rake rails:template"
50
- end
51
-
52
- exec "#{base_path} LOCATION=#{template}"
53
- end
54
-
55
- desc "make this rails project vue-ui compatible"
56
- task :ui do
57
- template = File.expand_path("../install/ui.rb", __dir__)
58
- base_path =
59
- if Rails::VERSION::MAJOR >= 5
60
- "#{RbConfig.ruby} #{bin_path}/rails app:template"
61
- else
62
- "#{RbConfig.ruby} #{bin_path}/rake rails:template"
63
- end
64
-
65
- exec "#{base_path} LOCATION=#{template}"
66
- end
67
-
68
- desc "is this rail project specific-page vue enabled?"
69
- task :spv do
70
- puts "check if spv is enabled and setup?"
71
- end
72
- end