init-boilerplate 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/init-boilerplate.rb +50 -16
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5d1d339f1bbf2586c033f212bea954a2239eb82751edd4eb015261d5693db97
4
- data.tar.gz: 64fabb83bae542f391d7e99b26a64ad4ccf917400a497f7c225c9a2522c435db
3
+ metadata.gz: 21289984f7d632e0a02b5d747b05c1d47af50db7116fcc5bf132383dc22d4eab
4
+ data.tar.gz: aed3c1e14b6041403a05bed188b11cc9b2f55ef7fefe925fa7ccbf8939ab40ef
5
5
  SHA512:
6
- metadata.gz: 24ec3174b3f86b490a6d07c3fa01b6c57cceab2bb9b3aed2ede2e7f94b8e49f582e699f52f51f0e725b03c73828dd33f7e9642108872f7879bee25ce6e0b550b
7
- data.tar.gz: 168bf2dc07a56904f60175091934bf3df5e1133f5d1a87f0fcaeaab46247f52f160c07f4b70434e34f75267ef719386cf6f67e29ee78832970c829f7b0901080
6
+ metadata.gz: a13df2bafe825abf45243b857c27e86ac48a49b61f329c4180926f8ed820b734e51347280a8af06348c3d920d1e77770df6dad1d1630c54153853750ae286066
7
+ data.tar.gz: 9b0d1873d37dcdb5e5c74385dfa841deeb50d880815afea47bb50677bb357fcec4e61af4fa5101e6fb781bca7f1088709fa78069927da16a0de6ba19e8a56f92
@@ -139,9 +139,42 @@ module InitBoilerplate
139
139
  puts 'Installing and configuring ESLint...'.colorize(:green)
140
140
  system('npm install --save-dev eslint eslint-plugin-prettier eslint-config-prettier')
141
141
  system('npx eslint --init')
142
+ if File.exist?(ES_LINT)
143
+ eslint_json_exists(react)
144
+ else
145
+ hash = {
146
+ plugins: [
147
+ 'prettier'
148
+ ],
149
+ rules: {
150
+ 'prettier/prettier': 'error',
151
+ 'no-console': 1
152
+ },
153
+ extends: [
154
+ 'prettier',
155
+ 'plugin:prettier/recommended'
156
+ ]
157
+ }
158
+ if react
159
+ hash['plugins'] << 'react'
160
+ hash['extends'] << 'plugin:react/recommended'
161
+ hash['extends'] << 'prettier/react'
162
+ end
163
+ File.open(ES_LINT, 'w+') do |file|
164
+ file.write(JSON.pretty_generate(hash))
165
+ file.close
166
+ end
167
+ end
168
+ end
169
+
170
+ def self.eslint_json_exists(react)
142
171
  es_lint = File.read(ES_LINT)
143
172
  es_lint_hash = JSON.parse(es_lint)
144
- es_lint_hash['plugins'] << 'prettier'
173
+ if es_lint_hash.key?('plugins')
174
+ es_lint_hash['plugins'] << 'prettier'
175
+ else
176
+ es_lint_hash['plugins'] = 'prettier'
177
+ end
145
178
  es_lint_hash['rules']['prettier/prettier'] = 'error'
146
179
  es_lint_hash['rules']['no-console'] = 1
147
180
  es_lint_hash['extends'] << 'prettier'
@@ -174,7 +207,7 @@ module InitBoilerplate
174
207
  end
175
208
 
176
209
  def self.configure_commitlint
177
- puts 'Installing and configuring commitlint...'
210
+ puts 'Installing and configuring commitlint...'.colorize(:green)
178
211
  system('npm install --save-dev @commitlint/{config-conventional,cli} stylefmt')
179
212
  hash = {
180
213
  extends: ['@commitlint/config-conventional']
@@ -186,7 +219,8 @@ module InitBoilerplate
186
219
  end
187
220
 
188
221
  def self.configure_husky
189
- puts 'Installing and configuring husky with lint-staged...'
222
+ system('git init') unless Dir.exist?('.git')
223
+ puts 'Installing and configuring husky with lint-staged...'.colorize(:green)
190
224
  system('npx mrm lint-staged')
191
225
  package_json = File.read(PACKAGE)
192
226
  package_hash = JSON.parse(package_json)
@@ -220,11 +254,11 @@ module InitBoilerplate
220
254
 
221
255
  def self.create_node_project
222
256
  puts 'Does your project use TypeScript? (y/n)'.colorize(:yellow)
223
- input = STDIN.gets.strip.chomp
257
+ input = STDIN.gets.strip.chomp.downcase
224
258
  typescript = input == 'y'
225
259
  puts 'Make sure this is where you want to create your project (y/n)'.colorize(:magenta)
226
260
  display_pwd
227
- confirm = STDIN.gets.strip.chomp
261
+ confirm = STDIN.gets.strip.chomp.downcase
228
262
  exit(0) if confirm != 'y'
229
263
  puts 'Creating node.js project'.colorize(:green)
230
264
  puts 'With TypeScript' if typescript
@@ -242,11 +276,11 @@ module InitBoilerplate
242
276
 
243
277
  def self.create_react_project
244
278
  puts 'Does your project use TypeScript? (y/n)'.colorize(:yellow)
245
- input = STDIN.gets.strip.chomp
279
+ input = STDIN.gets.strip.chomp.downcase
246
280
  typescript = input == 'y'
247
281
  puts 'Make sure this is where you want to create your project (y/n)'.colorize(:magenta)
248
282
  display_pwd
249
- confirm = STDIN.gets.strip.chomp
283
+ confirm = STDIN.gets.strip.chomp.downcase
250
284
  exit(0) if confirm != 'y'
251
285
  puts 'Creating react.js project'.colorize(:green)
252
286
  puts 'With TypeScript' if typescript
@@ -272,15 +306,15 @@ module InitBoilerplate
272
306
  FileUtils.mkdir_p pull_request_template_dir
273
307
 
274
308
  issue_templates = [
275
- 'https://github.com/gpnn/git-conventions-guide/raw/master/docs/ISSUE_TEMPLATE/bug.md'.freeze,
276
- 'https://github.com/gpnn/git-conventions-guide/raw/master/docs/ISSUE_TEMPLATE/epic.md'.freeze,
277
- 'https://github.com/gpnn/git-conventions-guide/raw/master/docs/ISSUE_TEMPLATE/story.md'.freeze,
278
- 'https://github.com/gpnn/git-conventions-guide/raw/master/docs/ISSUE_TEMPLATE/sub-task.md'.freeze,
279
- 'https://github.com/gpnn/git-conventions-guide/raw/master/docs/ISSUE_TEMPLATE/task.md'.freeze
309
+ 'https://github.com/gordonpn/git-conventions-guide/raw/master/docs/ISSUE_TEMPLATE/bug.md'.freeze,
310
+ 'https://github.com/gordonpn/git-conventions-guide/raw/master/docs/ISSUE_TEMPLATE/epic.md'.freeze,
311
+ 'https://github.com/gordonpn/git-conventions-guide/raw/master/docs/ISSUE_TEMPLATE/story.md'.freeze,
312
+ 'https://github.com/gordonpn/git-conventions-guide/raw/master/docs/ISSUE_TEMPLATE/sub-task.md'.freeze,
313
+ 'https://github.com/gordonpn/git-conventions-guide/raw/master/docs/ISSUE_TEMPLATE/task.md'.freeze
280
314
  ].freeze
281
315
 
282
- pull_request_template = 'https://github.com/gpnn/git-conventions-guide/raw/master/docs/PULL_REQUEST_TEMPLATE/pull_request_template.md'.freeze
283
- readme_template = 'https://github.com/gpnn/git-conventions-guide/raw/master/docs/README_template.md'.freeze
316
+ pull_request_template = 'https://github.com/gordonpn/git-conventions-guide/raw/master/docs/PULL_REQUEST_TEMPLATE/pull_request_template.md'.freeze
317
+ readme_template = 'https://github.com/gordonpn/git-conventions-guide/raw/master/docs/README_template.md'.freeze
284
318
 
285
319
  issue_templates.each do |issue_template|
286
320
  tempfile = Down.download(issue_template)
@@ -291,7 +325,7 @@ module InitBoilerplate
291
325
  FileUtils.mv tempfile.path, "./#{pull_request_template_dir}/#{tempfile.original_filename}"
292
326
 
293
327
  tempfile = Down.download(readme_template)
294
- FileUtils.mv tempfile.path, './README.md'
328
+ FileUtils.mv tempfile.path, "./#{tempfile.original_filename}"
295
329
 
296
330
  end
297
331
 
@@ -326,4 +360,4 @@ module InitBoilerplate
326
360
  clean_directory if ARGV[0] == 'clean'
327
361
  display_menu
328
362
  end
329
- end
363
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: init-boilerplate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gordon Pham-Nguyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-19 00:00:00.000000000 Z
11
+ date: 2020-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize