railspack 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
  SHA1:
3
- metadata.gz: 8f7a3251194a5d83fe9264cba0e6eaea153920e7
4
- data.tar.gz: ef9878cccb304fe06c3f79382f1d72658e58edad
3
+ metadata.gz: 212441dbc951327c53fb8721a922963da670d0c6
4
+ data.tar.gz: 728816d54d0bc12c181439063c8074cc01f244ff
5
5
  SHA512:
6
- metadata.gz: b3991414754154b63b61f10a320eb1c63898e32a785eec40e25319d0be912a19c137783d92ffe177b8e758f64ddcdd05f4f1dc0ac6fce579303ecc70982417e8
7
- data.tar.gz: ccd1fd44d31c9ca6dc05a07894e66782ea662c2e1fb37f07ceafad581bce7fe805e7aafe242f37f5e6c785115c8403f10058393825768c926734e326937c5b2b
6
+ metadata.gz: bc95717ba0a937f4ae29b9aa504c0f834467ac0497480e7f0ab832c57ebd5f29c8973d8e74be60ce6643789ac2c810f81d297564294a3d936981542a08d7f64c
7
+ data.tar.gz: 4279bb674a694aa0286e98087b69eb9a17c4692ca9efc02b149a7e5f396386ee4209b29bb3490eade30d72a875869650d3f3a9a98d81889839da18c80ca7ce72
data/README.md CHANGED
@@ -28,12 +28,25 @@ Make sure that you run `npm install` after running the `railspack generate`
28
28
  command. This will install all the dependencies defined in the `package.json`
29
29
  file.
30
30
 
31
- Take a look at the [Generated Files Guide](docs/generated_files) page to see
31
+ If you would like `npm install` to be run for you after the files have been
32
+ generated, you can pass the `--install` or `-i` option to the generate command.
33
+
34
+ ```
35
+ railspack generate --install
36
+ ```
37
+
38
+ or
39
+
40
+ ```
41
+ railspack generate -i
42
+ ```
43
+
44
+ Take a look at the [Generated Files Guide](docs/generated_files.md) page to see
32
45
  a full description of all the files that are generated.
33
46
 
34
47
  ## Contributing
35
48
 
36
- Please check out the [Contributing Guide](docs/contributing)
49
+ Please check out the [Contributing Guide](docs/contributing.md)
37
50
 
38
51
  ## License
39
52
 
data/lib/railspack/cli.rb CHANGED
@@ -2,6 +2,8 @@ require 'thor'
2
2
  require 'erubis'
3
3
  require 'pathname'
4
4
 
5
+ require 'railspack/template_helper'
6
+
5
7
  module Railspack
6
8
  class CLI < Thor
7
9
  include Thor::Actions
@@ -11,11 +13,9 @@ module Railspack
11
13
  end
12
14
 
13
15
  desc "generate", "Generate all webpack files"
16
+ method_option :install, aliases: '-i', desc: 'Run npm install after generating files'
14
17
  def generate
15
- if !npm_available?
16
- puts "NPM not installed"
17
- return
18
- end
18
+ run_npm_install = options[:install]
19
19
 
20
20
  build_package_json
21
21
  copy_file("index.js", "frontend/index.js")
@@ -24,8 +24,16 @@ module Railspack
24
24
  copy_file("babelrc.js", ".babelrc")
25
25
  copy_file("webpack.js", "webpack.config.babel.js")
26
26
 
27
- puts "Running `npm install`"
28
- exec("npm install")
27
+ if run_npm_install
28
+ unless npm_available?
29
+ puts "NPM is not installed, please install and then run `npm install` manually"
30
+ return
31
+ end
32
+
33
+ puts "Running `npm install`"
34
+ exec("npm install")
35
+ end
36
+
29
37
  end
30
38
 
31
39
  private
@@ -44,23 +52,12 @@ module Railspack
44
52
  directory_path.basename
45
53
  end
46
54
 
47
- def get_template_from_file(template_name)
48
- template_path = File.join(File.dirname(__FILE__), 'templates', template_name)
49
- file = File.open(template_path, "rb")
50
- contents = file.read
51
- end
52
-
53
- def render_template(template_name, locals)
54
- contents = get_template_from_file(template_name)
55
- Erubis::Eruby.new(contents).result(locals)
56
- end
57
-
58
55
  def build_package_json
59
56
  project_name = get_project_name
60
57
  author_name = get_git_username
61
58
 
62
59
  locals = { application_name: project_name, author_name: author_name }
63
- contents = render_template('package.json.erb', locals)
60
+ contents = TemplateHelper.render('package.json.erb', locals)
64
61
  create_file('package.json', contents)
65
62
  end
66
63
  end
@@ -0,0 +1,16 @@
1
+ module Railspack
2
+ module TemplateHelper
3
+ # Given a template_name, looks in the templates/ directory
4
+ # and returns the contents of the file.
5
+ def self.get_from_file(template_name)
6
+ template_path = File.join(File.dirname(__FILE__), 'templates', template_name)
7
+ file = File.open(template_path, "rb")
8
+ contents = file.read
9
+ end
10
+
11
+ def self.render(template_name, locals)
12
+ contents = TemplateHelper.get_from_file(template_name)
13
+ Erubis::Eruby.new(contents).result(locals)
14
+ end
15
+ end
16
+ end
@@ -8,5 +8,5 @@ import { registerComponent } from 'registerComponent'
8
8
 
9
9
  const domReadyEvent = (typeof TurboLinks !== 'undefined') ? 'turbolinks:load' : 'DOMContentLoaded'
10
10
  document.addEventListener(domReadyEvent, () => {
11
- // registerComponent(OhHai, 'oh-hai'));
12
- }
11
+ // registerComponent(OhHai, 'oh-hai')
12
+ })
@@ -1,3 +1,3 @@
1
1
  module Railspack
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railspack
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
  - jdmorlan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-20 00:00:00.000000000 Z
11
+ date: 2016-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -93,6 +93,7 @@ files:
93
93
  - bin/railspack
94
94
  - lib/railspack.rb
95
95
  - lib/railspack/cli.rb
96
+ - lib/railspack/template_helper.rb
96
97
  - lib/railspack/templates/babelrc.js
97
98
  - lib/railspack/templates/index.js
98
99
  - lib/railspack/templates/package.json.erb