vuejs 1.1.0.beta1 → 1.1.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -59
- data/lib/generators/generator_templates/{index.css → packs/index.css} +0 -0
- data/lib/generators/generator_templates/{index.js → packs/index.js} +8 -6
- data/lib/generators/generator_templates/{index.vue → packs/index.vue} +0 -0
- data/lib/generators/generator_templates/{pack.js.erb → packs/pack.js.erb} +7 -7
- data/lib/generators/generator_templates/{single.vue → sfc/single-file-component.vue} +8 -5
- data/lib/generators/generator_templates/tests/unit.test.js.erb +23 -0
- data/lib/generators/generator_templates/{turbolink-pack.js.erb → turbolinks/turbolinks-pack.js.erb} +5 -3
- data/lib/generators/generator_templates/vuex/index.js +1 -1
- data/lib/generators/vue/USAGE +3 -16
- data/lib/generators/vue/vue_generator.rb +53 -29
- data/lib/install/alias.rb +12 -0
- data/lib/install/component_with_seperate_concern.rb +4 -0
- data/lib/install/config/alias.js +10 -0
- data/lib/install/setup.rb +27 -0
- data/lib/install/single-file-component.rb +0 -0
- data/lib/install/test.rb +1 -0
- data/lib/install/turbolinks.rb +3 -0
- data/lib/install/ui.rb +0 -0
- data/lib/install/vuex.rb +9 -0
- data/lib/tasks/info.rake +0 -5
- data/lib/tasks/setup.rake +44 -0
- data/lib/vuejs/post_message.rb +2 -1
- data/lib/vuejs/version.rb +1 -1
- data/vendor/assets/javascripts/vue-on-rails.js +20 -0
- metadata +21 -12
- data/lib/generators/generator_templates/vuex-pack.js.erb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccdc51477ca262d861c03be1932f7d9d5c83cc99b10c6ab4618b441d9c5ca5ea
|
4
|
+
data.tar.gz: c97ea07ed73b4e640de884fcef67cc3d42ad3076605996730dcd91005f38896d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85b9c74a8f439cfa75abe054f9aeebbd9299720e176e994eb46bd309bafa49b1a2ebc719becd1ad490cb50d27edd5138c456b1298901174efddbff7fdf801864
|
7
|
+
data.tar.gz: 5e02a2dd5bb1efbf5e92ee7b8dcc1cba8911ce926501dc2f3ee19acf8bc3c9c6323cee8d82f3f277292662cd3f5e0cc6867449ddab38508cafa60ece82f627e9
|
data/README.md
CHANGED
@@ -2,7 +2,17 @@
|
|
2
2
|
|
3
3
|
> Vue for your favourite Ruby on Rails projects
|
4
4
|
|
5
|
-
|
5
|
+
`vuejs` rubygem makes it easy to get started with Vue on Rails project by shipping the following tools.
|
6
|
+
|
7
|
+
- Vuex support
|
8
|
+
- HTML Form helper
|
9
|
+
- Turbolinks support
|
10
|
+
- Support Webpacker
|
11
|
+
- Vue component Scaffold
|
12
|
+
- Mapping to Rails resources
|
13
|
+
- Auto-loading of Vue component
|
14
|
+
- Vue-cli service & Vue-ui compatibility
|
15
|
+
- Unit component tests compatible to vue-tests-utils using Jest
|
6
16
|
|
7
17
|
## Installation
|
8
18
|
|
@@ -18,83 +28,58 @@ And then execute:
|
|
18
28
|
|
19
29
|
# Webpacker
|
20
30
|
|
21
|
-
## Vue component view helper
|
22
|
-
|
23
|
-
```
|
24
|
-
<%= vue_component "" %>
|
25
|
-
```
|
26
|
-
|
27
31
|
## Vue component generator
|
28
32
|
|
29
33
|
```
|
30
|
-
rails generate vue
|
34
|
+
rails generate vue something
|
31
35
|
```
|
32
36
|
|
33
|
-
Note: `vuejs` gem creates vue components
|
37
|
+
Note: `vuejs` gem creates vue components as single-file component by default.
|
38
|
+
|
39
|
+
To generate a component with seperation of concern, please use the `--seperate`
|
34
40
|
|
35
|
-
|
41
|
+
> rails g vue something --seperate
|
36
42
|
|
37
43
|
## Vue component destroyer
|
38
44
|
|
39
45
|
```
|
40
|
-
rails destroy vue
|
46
|
+
rails destroy vue something
|
41
47
|
```
|
42
48
|
|
43
|
-
## Vue viewer
|
49
|
+
## Vue component viewer
|
44
50
|
|
45
|
-
Vue viewer allows you to browse your
|
51
|
+
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>
|
46
52
|
|
47
|
-
|
53
|
+
To mount the endpoint `/vue/<name>`, go to routes.rb and paste this:
|
48
54
|
|
49
55
|
```
|
50
56
|
mount Vuejs::engine, to: 'vue'
|
51
57
|
```
|
58
|
+
## Turbolinks support
|
59
|
+
```
|
60
|
+
rails generate vue something --turbolinks
|
61
|
+
```
|
52
62
|
|
53
63
|
## Vuex support - coming soon
|
54
64
|
|
55
65
|
```
|
56
|
-
rails
|
66
|
+
rails generate vue something --vuex
|
57
67
|
```
|
58
68
|
|
59
69
|
This will add vuex using yarn. And generate a vue component with vuex support
|
60
70
|
|
61
|
-
##
|
71
|
+
## Enable Specific page vue
|
62
72
|
|
63
73
|
```
|
64
|
-
rails
|
74
|
+
rails generate vue something --spv
|
65
75
|
```
|
66
76
|
|
67
|
-
|
68
|
-
|
69
|
-
# Asset Pipeline
|
70
|
-
|
71
|
-
The ruby gem `vuejs` ships with the following goodies for assets pipeline:
|
72
|
-
|
73
|
-
* `vue` (v2.1.10)
|
74
|
-
* `vuex` (v2.1.1)
|
75
|
-
* `vue-router` (v2.1.3)
|
76
|
-
* `vue-validator2` (v2.1.7) + `vue-validator3` (v3.0.0-alpha.2)
|
77
|
-
* `axios` (v0.15.3)
|
78
|
-
|
79
|
-
It also ships with the following legacy goodies
|
80
|
-
|
81
|
-
* `vue` (v1.0.28)
|
82
|
-
* `vuex` (v1.0.1)
|
83
|
-
* `vue-router` (v0.7.13)
|
84
|
-
* `vue-resource` (v1.2.0)
|
85
|
-
* `vue-validator` (v1.4.4)
|
86
|
-
|
87
|
-
## Usage
|
88
|
-
|
89
|
-
For 2.x Vue & vue-router or Vue-validator
|
77
|
+
### Generate unit tests for component - coming soon
|
90
78
|
|
91
79
|
```
|
92
|
-
|
93
|
-
//= require vue-router2
|
94
|
-
//= require vue-validator2
|
95
|
-
//= require vuex2
|
96
|
-
//= require axios
|
80
|
+
rails generate vue something --test
|
97
81
|
```
|
82
|
+
---
|
98
83
|
|
99
84
|
# Some Solution for assets pipeline
|
100
85
|
|
@@ -121,19 +106,14 @@ vuex has been updated to vuex2. Therefore use `//= require vuex2` to resolve the
|
|
121
106
|
|
122
107
|
Try to use `//= require vue2.min` to remove the warning statement from console.
|
123
108
|
|
124
|
-
For 1.x
|
125
109
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
//= require vue-resource
|
134
|
-
//= require vue-validator
|
135
|
-
//= require_tree .
|
136
|
-
```
|
110
|
+
## Requirement
|
111
|
+
|
112
|
+
- Rails
|
113
|
+
- Webpacker
|
114
|
+
- Vue
|
115
|
+
- Node
|
116
|
+
- Webpack
|
137
117
|
|
138
118
|
## Contributing and License
|
139
119
|
|
@@ -142,10 +122,10 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
142
122
|
|
143
123
|
## Book
|
144
124
|
|
145
|
-
Richard LaFranchi and I are writing a book on Vue on rails. If you are interested to be one of the early reviewers of our drafts, please email me.
|
125
|
+
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.
|
146
126
|
|
147
127
|
## Contact
|
148
128
|
|
149
129
|
📮 Bryan Lim ytbryan@gmail.com
|
150
130
|
|
151
|
-
> If you are using
|
131
|
+
> 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!
|
File without changes
|
@@ -1,9 +1,6 @@
|
|
1
|
-
// Generated by
|
1
|
+
// Generated by Vuejs gem ~> github.com/ytbryan/vuejs
|
2
2
|
|
3
3
|
export default {
|
4
|
-
// components: {},
|
5
|
-
// mixins: [],
|
6
|
-
// props: {},
|
7
4
|
data: function() {
|
8
5
|
return {
|
9
6
|
message: "Hello <%= name %>!",
|
@@ -21,6 +18,11 @@ export default {
|
|
21
18
|
}
|
22
19
|
},
|
23
20
|
computed: {
|
24
|
-
|
25
|
-
}
|
21
|
+
},
|
22
|
+
// asyncComputed: {},
|
23
|
+
// components: {},
|
24
|
+
// mixins: [],
|
25
|
+
// props: {},
|
26
|
+
// directives: {},
|
27
|
+
// filters: {},
|
26
28
|
};
|
File without changes
|
@@ -1,14 +1,14 @@
|
|
1
|
-
// Generated by
|
2
|
-
//
|
3
|
-
//
|
1
|
+
// Generated by Vuejs gem ~> github.com/ytbryan/vuejs
|
2
|
+
// Run this example by adding <%= '<%=' %> javascript_pack_tag "<%= name %>" <%= '%' %><%= '>' %> into your
|
3
|
+
// rails' view
|
4
|
+
// To generate another of this component, please run `rails g vue something`
|
4
5
|
|
5
6
|
import Vue from 'vue'
|
6
|
-
<% if options[
|
7
|
-
import App from '../parts/<%= name %>.vue'
|
8
|
-
<% else %>
|
7
|
+
<% if options['seperate'] %>
|
9
8
|
import App from '../parts/<%= name %>/<%= name %>.vue'
|
9
|
+
<% else %>
|
10
|
+
import App from '../parts/<%= name %>.vue'
|
10
11
|
<% end %>
|
11
|
-
|
12
12
|
document.addEventListener('DOMContentLoaded', () => {
|
13
13
|
document.body.appendChild(document.createElement('hello'))
|
14
14
|
const app = new Vue({
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<!-- Generated by
|
1
|
+
<!-- Generated by vuejs gem ~> github.com/ytbryan/vuejs -->
|
2
2
|
|
3
3
|
<template>
|
4
4
|
<div id="app">
|
@@ -9,9 +9,6 @@
|
|
9
9
|
|
10
10
|
<script>
|
11
11
|
export default {
|
12
|
-
// components: {},
|
13
|
-
// mixins: [],
|
14
|
-
// props: {},
|
15
12
|
data: function () {
|
16
13
|
return {
|
17
14
|
message: "Hello <%= name %>!"
|
@@ -29,7 +26,13 @@ export default {
|
|
29
26
|
},
|
30
27
|
computed: {
|
31
28
|
|
32
|
-
}
|
29
|
+
},
|
30
|
+
// asyncComputed: {},
|
31
|
+
// components: {},
|
32
|
+
// mixins: [],
|
33
|
+
// props: {},
|
34
|
+
// directives: {},
|
35
|
+
// filters: {},
|
33
36
|
}
|
34
37
|
</script>
|
35
38
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// Generated by vuejs gem ~> github.com/ytbryan/vuejs
|
2
|
+
// To generate another component with test, please run `rails g vue something --test`
|
3
|
+
|
4
|
+
import { shallowMount } from '@vue/test-utils'
|
5
|
+
import List from '../parts/<%= name %>/<%= name %>.vue'
|
6
|
+
|
7
|
+
describe('<%= name %>.vue', () => {
|
8
|
+
it('renders li for each item in props.items', () => {
|
9
|
+
const items = ['1', '2']
|
10
|
+
const wrapper = shallowMount(List, {
|
11
|
+
propsData: { items }
|
12
|
+
})
|
13
|
+
expect(wrapper.findAll('li')).toHaveLength(items.length)
|
14
|
+
})
|
15
|
+
|
16
|
+
it('matches snapshot', () => {
|
17
|
+
const items = ['item 1', 'item 2']
|
18
|
+
const wrapper = shallowMount(List, {
|
19
|
+
propsData: { items }
|
20
|
+
})
|
21
|
+
expect(wrapper.html()).toMatchSnapshot()
|
22
|
+
})
|
23
|
+
})
|
data/lib/generators/generator_templates/{turbolink-pack.js.erb → turbolinks/turbolinks-pack.js.erb}
RENAMED
@@ -1,14 +1,16 @@
|
|
1
|
-
// Generated by
|
1
|
+
// Generated by Vuejs gem ~> github.com/ytbryan/vuejs
|
2
|
+
// Run this example by adding <%= '<%=' %> javascript_pack_tag "<%= name %>" <%= '%' %><%= '>' %> into your
|
3
|
+
// rails' view
|
4
|
+
// To generate another of this component with turbolinks, please run `rails g vue something --turbolinks`
|
2
5
|
|
3
6
|
import TurbolinksAdapter from 'vue-turbolinks';
|
4
|
-
import Vue from 'vue
|
7
|
+
import Vue from 'vue.esm'
|
5
8
|
<% if options[:single] %>
|
6
9
|
import App from '../parts/<%= name %>.vue'
|
7
10
|
<% else %>
|
8
11
|
import App from '../parts/<%= name %>/<%= name %>.vue'
|
9
12
|
<% end %>
|
10
13
|
Vue.use(TurbolinksAdapter)
|
11
|
-
|
12
14
|
document.addEventListener('turbolinks:load', () => {
|
13
15
|
if(isView("###")){
|
14
16
|
const app = new Vue({
|
data/lib/generators/vue/USAGE
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Description:
|
2
|
-
Vue generator generates a vue component in Rails project.
|
2
|
+
Vue generator generates a vue component in Single-file component in Rails project.
|
3
3
|
|
4
4
|
Example:
|
5
5
|
rails generate vue <component>
|
@@ -9,22 +9,9 @@ Example:
|
|
9
9
|
|
10
10
|
Here's an example of component.vue
|
11
11
|
|
12
|
-
rails g vue <component> --
|
13
|
-
|
14
|
-
|
12
|
+
rails g vue <component> --no-single
|
13
|
+
|
15
14
|
This will create:
|
16
15
|
app/javascript/component/component.vue
|
17
16
|
app/javascript/component/component.css
|
18
17
|
app/javascript/component/component.js
|
19
|
-
|
20
|
-
rails g vue <component> --no-prop
|
21
|
-
|
22
|
-
This will remove prop property in Vue element
|
23
|
-
|
24
|
-
rails g vue <component> --no-data
|
25
|
-
|
26
|
-
This will remove data property in Vue element
|
27
|
-
|
28
|
-
rails g vue <component> --erb
|
29
|
-
|
30
|
-
This will integrate with erb on rails
|
@@ -2,71 +2,95 @@ class VueGenerator < Rails::Generators::NamedBase
|
|
2
2
|
source_root File.expand_path('../../generator_templates', __FILE__)
|
3
3
|
|
4
4
|
argument :name, type: :string, default: :index
|
5
|
+
class_option :seperate, type: :boolean, default: false
|
5
6
|
class_option :single, type: :boolean, default: false
|
6
7
|
class_option :vuex, type: :boolean, default: false
|
7
|
-
class_option :
|
8
|
-
|
8
|
+
class_option :turbolinks, type: :boolean, default: false
|
9
|
+
class_option :test, type: :boolean, default: false
|
10
|
+
class_option 'form-for', type: :boolean, default: false
|
9
11
|
|
10
12
|
PACKS_PATH = "app/javascript/packs"
|
11
13
|
PARTS_PATH = "app/javascript/parts"
|
14
|
+
TESTS_PATH = "app/javascript/tests"
|
12
15
|
|
13
16
|
def vue
|
14
|
-
if options[:
|
15
|
-
if options[:
|
16
|
-
|
17
|
+
if options[:seperate]
|
18
|
+
if options[:turbolinks]
|
19
|
+
create_turbolink_component_with_seperate_concern_using(name)
|
17
20
|
else
|
18
|
-
|
21
|
+
create_component_with_seperate_concern_using(name)
|
19
22
|
end
|
20
23
|
else
|
21
|
-
if options[:
|
22
|
-
|
24
|
+
if options[:turbolinks]
|
25
|
+
create_turbolink_single_file_component_using(name)
|
23
26
|
else
|
24
|
-
|
27
|
+
create_single_file_component_using(name)
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
28
|
-
|
29
|
-
|
31
|
+
options[:test] ? add_tests_to_component(name) : nil
|
32
|
+
options[:vuex] ? add_vuex_to_component(name) : nil
|
33
|
+
options['form-for'] ? add_helpers_to_component(name) : nil
|
30
34
|
end
|
31
35
|
|
32
36
|
private
|
37
|
+
|
38
|
+
def add_tests_to_component name
|
39
|
+
template "tests/unit.test.js.erb", "#{TESTS_PATH}/#{name}.test.js"
|
40
|
+
end
|
41
|
+
|
33
42
|
def add_helpers_to_component name
|
34
|
-
|
43
|
+
run "yarn add vue-form-for"
|
44
|
+
|
45
|
+
insert_into_file "#{PACKS_PATH}/#{name}.js" ,
|
46
|
+
"import FormFor from 'vue-form-for'",
|
47
|
+
after: "import Vue from 'vue'\n"
|
48
|
+
|
49
|
+
insert_into_file "#{PACKS_PATH}/#{name}.js",
|
50
|
+
"Vue.use(FormFor)\n",
|
51
|
+
before: "document.addEventListener"
|
35
52
|
end
|
36
53
|
|
37
54
|
def add_vuex_to_component name
|
38
|
-
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
|
55
|
+
run "yarn add vuex"
|
56
|
+
insert_into_file "#{PACKS_PATH}/#{name}.js" ,
|
57
|
+
"import Vuex from 'vuex'",
|
58
|
+
after: "import Vue from 'vue'\n"
|
59
|
+
|
60
|
+
insert_into_file "#{PACKS_PATH}/#{name}.js",
|
61
|
+
"Vue.use(Vuex)\n",
|
62
|
+
before: "document.addEventListener"
|
43
63
|
end
|
44
64
|
|
45
65
|
def create_component_with_seperate_concern_using name
|
66
|
+
say "Generating a Vue component with seperation of concern"
|
46
67
|
@code = "<%= vue \"#{name}\" %>"
|
47
|
-
template "pack.js.erb", "#{PACKS_PATH}/#{name}.js"
|
48
|
-
template "index.vue", "#{PARTS_PATH}/#{name}/#{name}.vue"
|
49
|
-
template "index.js", "#{PARTS_PATH}/#{name}/#{name}.js"
|
50
|
-
copy_file "index.css", "#{PARTS_PATH}/#{name}/#{name}.css"
|
68
|
+
template "packs/pack.js.erb", "#{PACKS_PATH}/#{name}.js"
|
69
|
+
template "packs/index.vue", "#{PARTS_PATH}/#{name}/#{name}.vue"
|
70
|
+
template "packs/index.js", "#{PARTS_PATH}/#{name}/#{name}.js"
|
71
|
+
copy_file "packs/index.css", "#{PARTS_PATH}/#{name}/#{name}.css"
|
51
72
|
end
|
52
73
|
|
53
74
|
def create_single_file_component_using name
|
75
|
+
say "Generating a Single File Component"
|
54
76
|
@code = "<%= vue \"#{name}\" %>"
|
55
|
-
template "pack.js.erb", "#{PACKS_PATH}/#{name}.js"
|
56
|
-
template "single.vue", "#{PARTS_PATH}/#{name}.vue"
|
77
|
+
template "packs/pack.js.erb", "#{PACKS_PATH}/#{name}.js"
|
78
|
+
template "sfc/single-file-component.vue", "#{PARTS_PATH}/#{name}.vue"
|
57
79
|
end
|
58
80
|
|
59
81
|
def create_turbolink_single_file_component_using name
|
82
|
+
say "Adding Turbolinks to a Single File Component"
|
60
83
|
@code = "<%= vue \"#{name}\" %>"
|
61
|
-
template "
|
62
|
-
template "single.vue", "#{PARTS_PATH}/#{name}.vue"
|
84
|
+
template "turbolinks/turbolinks-pack.js.erb", "#{PACKS_PATH}/#{name}.js"
|
85
|
+
template "sfc/single-file-component.vue", "#{PARTS_PATH}/#{name}.vue"
|
63
86
|
end
|
64
87
|
|
65
88
|
def create_turbolink_component_with_seperate_concern_using name
|
89
|
+
say "Adding turbolinks to Vue component with seperate of concerns"
|
66
90
|
@code = "<%= vue \"#{name}\" %>"
|
67
|
-
template "
|
68
|
-
template "index.vue", "#{PARTS_PATH}/#{name}/#{name}.vue"
|
69
|
-
template "index.js", "#{PARTS_PATH}/#{name}/#{name}.js"
|
70
|
-
copy_file "index.css", "#{PARTS_PATH}/#{name}/#{name}.css"
|
91
|
+
template "turbolinks/turbolinks-pack.js.erb", "#{PACKS_PATH}/#{name}.js"
|
92
|
+
template "packs/index.vue", "#{PARTS_PATH}/#{name}/#{name}.vue"
|
93
|
+
template "packs/index.js", "#{PARTS_PATH}/#{name}/#{name}.js"
|
94
|
+
copy_file "packs/index.css", "#{PARTS_PATH}/#{name}/#{name}.css"
|
71
95
|
end
|
72
96
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
say "Adding alias.js to config/webpack/alias"
|
2
|
+
copy_file "#{__dir__}/config/alias.js", Rails.root.join("config/webpack/alias/alias.js").to_s
|
3
|
+
|
4
|
+
say "Adding alias to config/webpack/environment.js"
|
5
|
+
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
6
|
+
"const alias = require('./alias/alias')\n",
|
7
|
+
after: "require('@rails/webpacker')\n"
|
8
|
+
|
9
|
+
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
10
|
+
"environment.config.merge(alias)\n",
|
11
|
+
before: "module.exports"
|
12
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
say "Adding alias.js to config/webpack/alias"
|
2
|
+
copy_file "#{__dir__}/config/alias.js", Rails.root.join("config/webpack/alias/alias.js").to_s
|
3
|
+
|
4
|
+
say "Adding alias to config/webpack/environment.js"
|
5
|
+
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
6
|
+
"const alias = require('./alias/alias')\n",
|
7
|
+
after: "require('@rails/webpacker')\n"
|
8
|
+
|
9
|
+
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
10
|
+
"environment.config.merge(alias)\n",
|
11
|
+
before: "module.exports"
|
12
|
+
|
13
|
+
say "Adding vue-autorequest and vue-form-for"
|
14
|
+
run "yarn add vue-autorequest vue-form-for"
|
15
|
+
|
16
|
+
say "Adding Vuex"
|
17
|
+
run "yarn add vuex vuex-rails-plugin"
|
18
|
+
|
19
|
+
say "Adding tests"
|
20
|
+
run "yarn add @vue/test-utils"
|
21
|
+
|
22
|
+
say "Adding turbolinks"
|
23
|
+
run "yarn add vue-turbolinks"
|
24
|
+
|
25
|
+
say "Making Vue on Rails compatible with Vue-ui"
|
26
|
+
run "yarn add @vue/cli-service --dev"
|
27
|
+
|
File without changes
|
data/lib/install/test.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
template "tests/unit.test.js.erb", "#{TESTS_PATH}/#{name}.test.js"
|
data/lib/install/ui.rb
ADDED
File without changes
|
data/lib/install/vuex.rb
ADDED
data/lib/tasks/info.rake
CHANGED
@@ -0,0 +1,44 @@
|
|
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/alias.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 other plugins"
|
17
|
+
task :others do
|
18
|
+
$stdout.puts "#{`yarn add @vue/cli-plugin-babel
|
19
|
+
@vue/cli-plugin-eslint
|
20
|
+
@vue/cli-plugin-unit-jest
|
21
|
+
@vue/cli-plugin-pwa
|
22
|
+
vue-i18n`}"
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "install turbolinks"
|
26
|
+
task :turbolinks do
|
27
|
+
$stdout.puts "#{`yarn add vue-turbolinks`}"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "install vue-test-utils"
|
31
|
+
task :test do
|
32
|
+
$stdout.puts "#{`yarn add @vue/test-utils`}"
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "install Vuex"
|
36
|
+
task :vuex do
|
37
|
+
$stdout.puts "#{`yarn add vuex`}"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "make this Rails project Vue-ui compatible"
|
41
|
+
task :ui do
|
42
|
+
$stdout.puts "yarn add @vue/cli-service --dev"
|
43
|
+
end
|
44
|
+
end
|
data/lib/vuejs/post_message.rb
CHANGED
data/lib/vuejs/version.rb
CHANGED
@@ -10,4 +10,24 @@ function puts(obj){
|
|
10
10
|
|
11
11
|
function p(obj){
|
12
12
|
console.log({obj})
|
13
|
+
}
|
14
|
+
|
15
|
+
function addClass(identifier, className){
|
16
|
+
document.getElementById(identifier).classList.addClass(className)
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleClass(identifier, className){
|
20
|
+
document.getElementById(identifier).classList.toggle(className)
|
21
|
+
}
|
22
|
+
|
23
|
+
function table(obj){
|
24
|
+
console.table(obj)
|
25
|
+
}
|
26
|
+
|
27
|
+
function titleize(str){
|
28
|
+
return str.replace(/\b\S/g, function(t) { return t.toUpperCase() });
|
29
|
+
}
|
30
|
+
|
31
|
+
function isArray(obj){
|
32
|
+
return Object.prototype.toString.call(obj) === '[object Array]' ;
|
13
33
|
}
|
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.
|
4
|
+
version: 1.1.0.beta2
|
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-
|
11
|
+
date: 2018-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,18 +52,28 @@ files:
|
|
52
52
|
- app/helpers/syntax_helper.rb
|
53
53
|
- app/views/vue/index.html.erb
|
54
54
|
- config/routes.rb
|
55
|
-
- lib/generators/generator_templates/index.css
|
56
|
-
- lib/generators/generator_templates/index.js
|
57
|
-
- lib/generators/generator_templates/index.vue
|
58
|
-
- lib/generators/generator_templates/pack.js.erb
|
59
|
-
- lib/generators/generator_templates/single.vue
|
60
|
-
- lib/generators/generator_templates/
|
61
|
-
- lib/generators/generator_templates/
|
55
|
+
- lib/generators/generator_templates/packs/index.css
|
56
|
+
- lib/generators/generator_templates/packs/index.js
|
57
|
+
- lib/generators/generator_templates/packs/index.vue
|
58
|
+
- lib/generators/generator_templates/packs/pack.js.erb
|
59
|
+
- lib/generators/generator_templates/sfc/single-file-component.vue
|
60
|
+
- lib/generators/generator_templates/tests/unit.test.js.erb
|
61
|
+
- lib/generators/generator_templates/turbolinks/turbolinks-pack.js.erb
|
62
62
|
- lib/generators/generator_templates/vuex/index.js
|
63
63
|
- lib/generators/vue/USAGE
|
64
64
|
- lib/generators/vue/vue_generator.rb
|
65
|
+
- lib/install/alias.rb
|
66
|
+
- lib/install/component_with_seperate_concern.rb
|
67
|
+
- lib/install/config/alias.js
|
68
|
+
- lib/install/setup.rb
|
69
|
+
- lib/install/single-file-component.rb
|
70
|
+
- lib/install/test.rb
|
71
|
+
- lib/install/turbolinks.rb
|
72
|
+
- lib/install/ui.rb
|
73
|
+
- lib/install/vuex.rb
|
65
74
|
- lib/tasks/assets.rake
|
66
75
|
- lib/tasks/info.rake
|
76
|
+
- lib/tasks/setup.rake
|
67
77
|
- lib/vuejs.rb
|
68
78
|
- lib/vuejs/post_message.rb
|
69
79
|
- lib/vuejs/version.rb
|
@@ -88,7 +98,7 @@ homepage: http://github.com/ytbryan/vuejs
|
|
88
98
|
licenses:
|
89
99
|
- MIT
|
90
100
|
metadata: {}
|
91
|
-
post_install_message: Send me Pull Request -> https://github.com/ytbryan/vuejs/pulls
|
101
|
+
post_install_message: "Send me Pull Request -> \n https://github.com/ytbryan/vuejs/pulls"
|
92
102
|
rdoc_options: []
|
93
103
|
require_paths:
|
94
104
|
- lib
|
@@ -107,6 +117,5 @@ rubyforge_project:
|
|
107
117
|
rubygems_version: 2.7.6
|
108
118
|
signing_key:
|
109
119
|
specification_version: 4
|
110
|
-
summary:
|
111
|
-
- ship with Vue 2.x
|
120
|
+
summary: Vue on Rails
|
112
121
|
test_files: []
|
@@ -1,25 +0,0 @@
|
|
1
|
-
// Generated by http://github.com/ytbryan/vuejs
|
2
|
-
|
3
|
-
import VuexRailsPlugin from 'vuex-rails-plugin'
|
4
|
-
import VueFormFor from 'vue-form-for'
|
5
|
-
import Autorequest from 'vue-autorequest'
|
6
|
-
import TurbolinksAdapter from 'vue-turbolinks';
|
7
|
-
import Vue from 'vue/dist/vue.esm'
|
8
|
-
<% if options[:single] %>
|
9
|
-
import App from '../parts/<%= name %>.vue'
|
10
|
-
<% else %>
|
11
|
-
import App from '../parts/<%= name %>/<%= name %>.vue'
|
12
|
-
<% end %>
|
13
|
-
|
14
|
-
Vue.use(TurbolinksAdapter)
|
15
|
-
Vue.use(VuexRailsPlugin)
|
16
|
-
Vue.use(VueFormFor)
|
17
|
-
Vue.use(Autorequest)
|
18
|
-
|
19
|
-
document.addEventListener('turbolinks:load', () => {
|
20
|
-
if(isView("###")){
|
21
|
-
const app = new Vue({
|
22
|
-
render: h => h(App)
|
23
|
-
}).$mount('#something')
|
24
|
-
}
|
25
|
-
})
|