hauler 0.3.2 → 0.3.3

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
  SHA1:
3
- metadata.gz: 4cd675c7de6a613d2c1f6c3acd43a769701f22a1
4
- data.tar.gz: 01f5153a0f2f3e3a50078a5088c66a8335d95569
3
+ metadata.gz: c6cb5e994895c6ec1f1fd43894c85b5b8b4dbfa3
4
+ data.tar.gz: ca388ac352dc98f86929f93d9a85021c355040ec
5
5
  SHA512:
6
- metadata.gz: 13b60c5957883730a2f676251cbfd1837828d052fed55d4f9ef916df6037726824a23c08ea8d2ffe9fa5b1e9dcd98357b8d159fdda471e194ae6e57cb073eb48
7
- data.tar.gz: fedbb6e8a610c293f5371b8aca4665044be4b43345f40dea11fb5455b96f453a23e2d5ced148075edb5e4321df3b6419f1ae497a0a87ccdb7ee04754453ee1e8
6
+ metadata.gz: 43cced488b291575b476f790b99d54a7ac4f16c15eed7d441892396b3a5ebc272e17e4042cb4731d20e8e10ed5e08d7a27d9666407dde6cda32eeca3d453ab8a
7
+ data.tar.gz: 4b96959984b6372ed7534ffc20db343b69c31abe0095b687d5c62d36ef0d2df4d315571926adb5723895c92fa89f48e76847c9bd8427c9230995d078d1cf05a5
@@ -32,7 +32,7 @@ module Hauler
32
32
  end
33
33
 
34
34
  def add_node_modules_to_gitignore
35
- has_gitignore = File.exist?(Rails.root.join('package.json'))
35
+ has_gitignore = File.exist?(Rails.root.join('.gitignore'))
36
36
  return if !has_gitignore
37
37
 
38
38
  has_node_modules = IO.read('.gitignore').include? 'node_modules'
@@ -48,6 +48,12 @@ module Hauler
48
48
  def install_npm
49
49
  generate 'hauler:install_npm'
50
50
  end
51
+
52
+ private
53
+
54
+ def rails_app_name
55
+ Rails.application.class.parent.name
56
+ end
51
57
  end
52
58
  end
53
59
  end
@@ -15,7 +15,7 @@ module Hauler
15
15
  css-loader@0.23.1
16
16
  extract-text-webpack-plugin@2.0.0-beta.3
17
17
  file-loader@0.9.0
18
- hauler@0.3.2
18
+ hauler@0.3.3
19
19
  image-webpack-loader@2.0.0
20
20
  immutable-devtools@0.0.7
21
21
  style-loader@0.13.1
@@ -1,4 +1,5 @@
1
1
  {
2
+ "name": "<%= rails_app_name.underscore %>",
2
3
  "private": true,
3
4
  "scripts": {
4
5
  },
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  module Hauler
3
- VERSION = '0.3.2'.freeze
3
+ VERSION = '0.3.3'.freeze
4
4
 
5
5
  def self.version
6
6
  VERSION
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hauler",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "NodeJS binary for the hauler gem",
5
5
  "author": "Arturo Guzman @guzart",
6
6
  "license": "MIT",
@@ -8,11 +8,11 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/guzart/hauler.git"
10
10
  },
11
- "main": "src/index.js",
11
+ "main": "dist/index.js",
12
12
  "bin": {
13
- "hauler-read-config": "src/bin/read-config.js",
14
- "hauler-server": "src/bin/dev-server.js",
15
- "hauler-update-scripts": "src/bin/update-scripts.js"
13
+ "hauler-read-config": "dist/bin/read-config.js",
14
+ "hauler-server": "dist/bin/dev-server.js",
15
+ "hauler-update-scripts": "dist/bin/update-scripts.js"
16
16
  },
17
17
  "scripts": {
18
18
  "build": "npm-run-all clean generate_package compile",
@@ -1,14 +1,16 @@
1
1
  #!/usr/bin/env node
2
+ // @flow
2
3
 
3
- const hauler = require('../index');
4
- const webpack = require('webpack');
5
- const WebpackDevServer = require('webpack-dev-server');
4
+ import webpack from 'webpack';
5
+ import WebpackDevServer from 'webpack-dev-server';
6
+ import { getAppName, getCompilerConfig, getDevServerConfig, getEnvName } from '../index';
6
7
 
7
- const env = hauler.getEnvName();
8
- const railsRoot = process.argv[2];
8
+ const env = getEnvName();
9
+ const railsRoot = process.argv[2] || process.cwd();
10
+ const appName = process.argv[3] || getAppName(railsRoot);
9
11
 
10
- const devServerConfig = hauler.getDevServerConfig(env, railsRoot);
11
- const compilerConfig = hauler.getCompilerConfig(env, railsRoot);
12
+ const devServerConfig = getDevServerConfig(env, railsRoot, appName);
13
+ const compilerConfig = getCompilerConfig(env, railsRoot, appName);
12
14
 
13
15
  // console.log(devServerConfig);
14
16
  // console.log(compilerConfig);
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  // @flow
3
- 'use strict';
4
3
 
5
- const railsRoot = process.argv[2];
4
+ import { getAppName, getCompilerConfig, getDevServerConfig, getEnvName } from '../index';
6
5
 
7
- const hauler = require('../index');
8
- const env = hauler.getEnvName();
6
+ const env = getEnvName();
7
+ const railsRoot = process.argv[2] || process.cwd();
8
+ const appName = process.argv[3] || getAppName(railsRoot);
9
9
 
10
- const devServerConfig = hauler.getDevServerConfig(env, railsRoot);
11
- const compilerConfig = hauler.getCompilerConfig(env, railsRoot);
10
+ const devServerConfig = getDevServerConfig(env, railsRoot, appName);
11
+ const compilerConfig = getCompilerConfig(env, railsRoot, appName);
12
12
  const config = { devServerConfig, compilerConfig };
13
13
  const output = JSON.stringify(config);
14
14
 
@@ -10,7 +10,6 @@ export default function defaultConfigFactory(env: string): WebpackConfig {
10
10
  resolve: {
11
11
  modules: [
12
12
  'node_modules',
13
- '~app/assets',
14
13
  '~lib/assets',
15
14
  ],
16
15
  extensions: ['.js', '.json', '.jsx']
data/src/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // @flow
2
2
 
3
+ import fs from 'fs';
4
+ import path from 'path';
3
5
  import * as utils from './utils';
4
6
 
5
7
  function getProjectConfig(env: string): ProjectConfig {
@@ -51,3 +53,9 @@ export function getCompilerConfig(
51
53
  }
52
54
 
53
55
  export { getEnvName } from './utils';
56
+
57
+ export function getAppName(railsRoot: string): string {
58
+ const contents = fs.readFileSync(path.join(railsRoot, 'package.json'));
59
+ const pkg = JSON.parse(contents.toString());
60
+ return pkg.name;
61
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hauler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arturo Guzman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-18 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: bundler