vue-generators 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ca22a1be57230f90cb0848c49db99329c9cb4eb3eebc90f30e797b98347dc95
4
- data.tar.gz: 30f654be8f2d389b3f17ded84a6d5c23e90fbbe4a09fb2f4724e57041e5f4a90
3
+ metadata.gz: cc33e8bbd2a6230bf7712427866a2563b9659fe7e0e45829206bdac03561cddc
4
+ data.tar.gz: bd3af6c2749b343c810484790dbb82a36a01c25879972d63a1f3739a15ec0cf8
5
5
  SHA512:
6
- metadata.gz: 9d4d78678668437f5694f7a383a17da40f1fbfaa2057f81a75c7d547c3ffea7ea0e6e41e23e1f9bcb952b396edc117330ef1118bca3ac0cace0bca91c390a3ea
7
- data.tar.gz: 0bacaedd570143d4605a0bbd801eab4e0971ebe05eee83c48d7ea27a2176338a319656a3e7c23427a10947fad32ab966568ec588842f47069a1c9abd30ccbfba
6
+ metadata.gz: 3d635851f9f760f75a42bb7a41756239c6ff0c2cac0a0da6b3aa01701657de7ad1983c76ccf11cdc9b84ea0ace43d0b79488ca103341ccd4b6ac84147ee0a666
7
+ data.tar.gz: cc987292d9e0eacb036157479bf9b91a09ef35562b3e8a7bc800fe65eafb2c02f7643ece5f9f57eeffd4b2dd4891e82cb6d378b788a8a7ab745af053df425ee7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.3
2
+ * Add pack generation
3
+ * Change destination of stores to app/javascript/stores/
4
+
1
5
  ## 0.1.2
2
6
 
3
7
  * Add store generation
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Vue::Generators
2
- vue-generators is an opinionated library for generating Vue components, mixins,
2
+ vue-generators is an opinionated library for generating Vue components, mixins, packs,
3
3
  and stores for a Rails project.
4
4
 
5
5
  ## Usage
@@ -9,6 +9,7 @@ and stores for a Rails project.
9
9
  rails g vue:component -h
10
10
  rails g vue:mixin -h
11
11
  rails g vue:store -h
12
+ rails g vue:pack -h
12
13
  ```
13
14
 
14
15
  ### Generate a component
@@ -123,6 +124,43 @@ export default {
123
124
  */
124
125
  },
125
126
  }
127
+ ```
128
+
129
+ ### Generate a pack
130
+ ```bash
131
+ rails g vue:pack admin
132
+ ```
133
+
134
+ **This will generate:**
135
+ *`app/javascript/packs/admin.js`
136
+ ```JavaScript
137
+ import VueRouter from 'vue-router'
138
+
139
+ // Routing
140
+ const router = new VueRouter({
141
+ })
142
+
143
+ // Vuex
144
+ const store = new Vuex.Store({
145
+
146
+ })
147
+
148
+ document.addEventListener("DOMContentLoaded", () => {
149
+ Vue.use(VueRouter)
150
+
151
+ const el = document.getElementById("root")
152
+
153
+ const app = new Vue({
154
+ el: el,
155
+ template: "<div><router-view /></div>",
156
+ components: {},
157
+ router,
158
+ store,
159
+ mounted() {
160
+ },
161
+ })
162
+ })
163
+
126
164
  ```
127
165
  ### Generate a store
128
166
 
@@ -132,7 +170,7 @@ rails g vue:store Application
132
170
 
133
171
  **This will generate:**
134
172
 
135
- *`app/javascript/application/store/Store.js`*
173
+ *`app/javascript/stores/application/Store.js`*
136
174
  ```JavaScript
137
175
  import { actions } from "./actions"
138
176
  import { getters } from "./getters"
@@ -149,28 +187,28 @@ export default {
149
187
  }
150
188
  ```
151
189
 
152
- *`app/javascript/application/store/actions.js`*
190
+ *`app/javascript/stores/application/actions.js`*
153
191
  ```JavaScript
154
192
  export const actions = {
155
193
 
156
194
  }
157
195
  ```
158
196
 
159
- *`app/javascript/application/store/getters.js`*
197
+ *`app/javascript/stores/application/getters.js`*
160
198
  ```JavaScript
161
199
  export const getters = {
162
200
 
163
201
  }
164
202
  ```
165
203
 
166
- *`app/javascript/application/store/mutations.js`*
204
+ *`app/javascript/stores/application/mutations.js`*
167
205
  ```JavaScript
168
206
  export const mutations = {
169
207
  }
170
208
 
171
209
  ```
172
210
 
173
- *`app/javascript/application/store/state.js`*
211
+ *`app/javascript/stores/application/state.js`*
174
212
  ```JavaScript
175
213
  export const state = {
176
214
 
@@ -1,3 +1,4 @@
1
1
  require "vue/generators/vue/component/component_generator.rb"
2
2
  require "vue/generators/vue/mixin/mixin_generator.rb"
3
+ require "vue/generators/vue/pack/pack_generator.rb"
3
4
  require "vue/generators/vue/store/store_generator.rb"
@@ -1,5 +1,5 @@
1
1
  module Vue
2
2
  module Generators
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
@@ -5,5 +5,5 @@ Example:
5
5
  rails generate vue:mixin Thing
6
6
 
7
7
  This will create:
8
- app/javascript/mixins/Thing.vue
8
+ app/javascript/mixins/Thing.js
9
9
 
@@ -0,0 +1,9 @@
1
+ Description:
2
+ Generates a stub pack
3
+
4
+ Example:
5
+ rails generate vue:pack blog
6
+
7
+ This will create:
8
+ app/javascript/packs/blog.js
9
+
@@ -0,0 +1,19 @@
1
+ module Vue
2
+ class PackGenerator < Rails::Generators::NamedBase
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def generate_pack
6
+ template 'Pack.template', Rails.root.join("app", "javascript", "packs", "#{pack_name}.js")
7
+ end
8
+
9
+ private
10
+ def pack_name
11
+ file = name.split("/").last
12
+ if file.downcase.ends_with?(".js") || file.downcase.ends_with?(".vue")
13
+ file = file.split(".")[0]
14
+ end
15
+ file
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ import VueRouter from 'vue-router'
2
+
3
+ // Routing
4
+ const router = new VueRouter({
5
+ })
6
+
7
+ // Vuex
8
+ const store = new Vuex.Store({
9
+
10
+ })
11
+
12
+ document.addEventListener("DOMContentLoaded", () => {
13
+ Vue.use(VueRouter)
14
+
15
+ const el = document.getElementById("root")
16
+
17
+ const app = new Vue({
18
+ el: el,
19
+ template: "<div><router-view /></div>",
20
+ components: {},
21
+ router,
22
+ store,
23
+ mounted() {
24
+ },
25
+ })
26
+ })
27
+
28
+
@@ -5,19 +5,19 @@ Example:
5
5
  rails generate vue:store Application
6
6
 
7
7
  This will create:
8
- app/javascript/application/store/Store.js
9
- app/javascript/application/store/actions.js
10
- app/javascript/application/store/getters.js
11
- app/javascript/application/store/mutations.js
12
- app/javascript/application/store/state.js
8
+ app/javascript/stores/application/Store.js
9
+ app/javascript/stores/application/actions.js
10
+ app/javascript/stores/application/getters.js
11
+ app/javascript/stores/application/mutations.js
12
+ app/javascript/stores/application/state.js
13
13
 
14
14
  Example:
15
15
  rails generate vue:store pets/Kittens
16
16
 
17
17
  This will create:
18
- app/javascript/pets/kittens/store/Store.js
19
- app/javascript/pets/kittens/store/actions.js
20
- app/javascript/pets/kittens/store/getters.js
21
- app/javascript/pets/kittens/store/mutations.js
22
- app/javascript/pets/kittens/store/state.js
18
+ app/javascript/stores/pets/kittens/Store.js
19
+ app/javascript/stores/pets/kittens/actions.js
20
+ app/javascript/stores/pets/kittens/getters.js
21
+ app/javascript/stores/pets/kittens/mutations.js
22
+ app/javascript/stores/pets/kittens/state.js
23
23
 
@@ -6,7 +6,7 @@ module Vue
6
6
  [
7
7
  'Store', 'actions', 'getters', 'mutations', 'state'
8
8
  ].each do |template|
9
- template "#{template}.template", Rails.root.join("app", "javascript", *path, "#{template}.js")
9
+ template "#{template}.template", Rails.root.join("app", "javascript", "stores", *path, "#{template}.js")
10
10
  end
11
11
  end
12
12
 
@@ -18,7 +18,7 @@ module Vue
18
18
  end
19
19
 
20
20
  def path
21
- name.split("/").map {|part| part.underscore.tr('_', '-') } + ['store']
21
+ name.split("/").map {|part| part.underscore.tr('_', '-') }
22
22
  end
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vue-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Naegle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-16 00:00:00.000000000 Z
11
+ date: 2019-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -59,6 +59,9 @@ files:
59
59
  - lib/vue/generators/vue/mixin/USAGE
60
60
  - lib/vue/generators/vue/mixin/mixin_generator.rb
61
61
  - lib/vue/generators/vue/mixin/templates/Mixin.template
62
+ - lib/vue/generators/vue/pack/USAGE
63
+ - lib/vue/generators/vue/pack/pack_generator.rb
64
+ - lib/vue/generators/vue/pack/templates/Pack.template
62
65
  - lib/vue/generators/vue/store/USAGE
63
66
  - lib/vue/generators/vue/store/store_generator.rb
64
67
  - lib/vue/generators/vue/store/templates/Store.template