railman 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/railman/version.rb +1 -1
  3. data/railman.gemspec +0 -2
  4. data/templates/rails_app/.babelrc +5 -0
  5. data/templates/rails_app/.gitignore +8 -2
  6. data/templates/rails_app/.postcssrc.yml +4 -0
  7. data/templates/rails_app/Gemfile +15 -13
  8. data/templates/rails_app/Rakefile +1 -1
  9. data/templates/rails_app/app/assets/javascripts/application.js +1 -1
  10. data/templates/rails_app/app/assets/stylesheets/application.sass +1 -1
  11. data/templates/rails_app/app/assets/stylesheets/main.sass +7 -2
  12. data/templates/rails_app/app/javascript/packs/app.vue +22 -0
  13. data/templates/rails_app/app/javascript/packs/application.js +2 -9
  14. data/templates/rails_app/app/javascript/packs/hello_vue.js +19 -0
  15. data/templates/rails_app/bin/rails +0 -5
  16. data/templates/rails_app/bin/rake +0 -5
  17. data/templates/rails_app/bin/webpack +25 -11
  18. data/templates/rails_app/bin/webpack-dev-server +22 -16
  19. data/templates/rails_app/bin/yarn +3 -2
  20. data/templates/rails_app/config.ru +1 -1
  21. data/templates/rails_app/config/application.rb.tt +3 -0
  22. data/templates/rails_app/config/database.yml.tt +2 -2
  23. data/templates/rails_app/config/environments/development.rb +0 -3
  24. data/templates/rails_app/config/environments/production.rb.tt +0 -3
  25. data/templates/rails_app/config/{puma.rb → puma.rb.tt} +5 -6
  26. data/templates/rails_app/config/webpack/configuration.js +26 -0
  27. data/templates/rails_app/config/webpack/development.js +3 -17
  28. data/templates/rails_app/config/webpack/development.server.js +17 -0
  29. data/templates/rails_app/config/webpack/development.server.yml +17 -0
  30. data/templates/rails_app/config/webpack/loaders/assets.js +12 -0
  31. data/templates/rails_app/config/webpack/loaders/babel.js +5 -0
  32. data/templates/rails_app/config/webpack/loaders/coffee.js +4 -0
  33. data/templates/rails_app/config/webpack/loaders/erb.js +9 -0
  34. data/templates/rails_app/config/webpack/loaders/sass.js +14 -0
  35. data/templates/rails_app/config/webpack/loaders/vue.js +12 -0
  36. data/templates/rails_app/config/webpack/paths.yml +33 -0
  37. data/templates/rails_app/config/webpack/production.js +5 -7
  38. data/templates/rails_app/config/webpack/shared.js +28 -54
  39. data/templates/rails_app/config/webpack/test.js +6 -0
  40. data/templates/rails_app/package.json.tt +24 -17
  41. data/templates/rails_app/public/404.html +51 -51
  42. data/templates/rails_app/public/422.html +51 -51
  43. data/templates/rails_app/public/500.html +50 -50
  44. data/templates/rails_app/test/application_system_test_case.rb +5 -2
  45. data/templates/rails_app/test/fixtures/files/.keep +0 -0
  46. metadata +20 -37
  47. data/templates/rails_app/app/javascript/packs/hello.vue +0 -11
  48. data/templates/rails_app/bin/spring +0 -17
  49. data/templates/rails_app/bin/webpack-watcher +0 -10
  50. data/templates/rails_app/config/initializers/new_framework_defaults.rb +0 -25
  51. data/templates/rails_app/config/spring.rb +0 -6
@@ -1,30 +1,16 @@
1
- // Note: You must restart bin/webpack-watcher for changes to take effect
1
+ // Note: You must restart bin/webpack-dev-server for changes to take effect
2
2
 
3
- const webpack = require('webpack')
4
3
  const merge = require('webpack-merge')
5
-
6
4
  const sharedConfig = require('./shared.js')
7
5
 
8
- module.exports = merge(sharedConfig.config, {
6
+ module.exports = merge(sharedConfig, {
9
7
  devtool: 'sourcemap',
10
8
 
11
9
  stats: {
12
10
  errorDetails: true
13
11
  },
14
12
 
15
- devServer: {
16
- stats: {
17
- warnings: false
18
- }
19
- },
20
-
21
13
  output: {
22
14
  pathinfo: true
23
- },
24
-
25
- plugins: [
26
- new webpack.LoaderOptionsPlugin({
27
- debug: true
28
- })
29
- ]
15
+ }
30
16
  })
@@ -0,0 +1,17 @@
1
+ // Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ const { resolve } = require('path')
4
+ const merge = require('webpack-merge')
5
+ const devConfig = require('./development.js')
6
+ const { devServer, publicPath, paths } = require('./configuration.js')
7
+
8
+ module.exports = merge(devConfig, {
9
+ devServer: {
10
+ host: devServer.host,
11
+ port: devServer.port,
12
+ compress: true,
13
+ historyApiFallback: true,
14
+ contentBase: resolve(paths.output, paths.entry),
15
+ publicPath
16
+ }
17
+ })
@@ -0,0 +1,17 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ enabled: true
5
+ host: localhost
6
+ port: 8080
7
+
8
+ development:
9
+ <<: *default
10
+
11
+ test:
12
+ <<: *default
13
+ enabled: false
14
+
15
+ production:
16
+ <<: *default
17
+ enabled: false
@@ -0,0 +1,12 @@
1
+ const { env, publicPath } = require('../configuration.js')
2
+
3
+ module.exports = {
4
+ test: /\.(jpg|jpeg|png|gif|svg|eot|ttf|woff|woff2)$/i,
5
+ use: [{
6
+ loader: 'file-loader',
7
+ options: {
8
+ publicPath,
9
+ name: env.NODE_ENV === 'production' ? '[name]-[hash].[ext]' : '[name].[ext]'
10
+ }
11
+ }]
12
+ }
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ test: /\.js(\.erb)?$/,
3
+ exclude: /node_modules/,
4
+ loader: 'babel-loader'
5
+ }
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ test: /\.coffee(\.erb)?$/,
3
+ loader: 'coffee-loader'
4
+ }
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ test: /\.erb$/,
3
+ enforce: 'pre',
4
+ exclude: /node_modules/,
5
+ loader: 'rails-erb-loader',
6
+ options: {
7
+ runner: 'bin/rails runner'
8
+ }
9
+ }
@@ -0,0 +1,14 @@
1
+ const ExtractTextPlugin = require('extract-text-webpack-plugin')
2
+ const { env } = require('../configuration.js')
3
+
4
+ module.exports = {
5
+ test: /\.(scss|sass|css)$/i,
6
+ use: ExtractTextPlugin.extract({
7
+ fallback: 'style-loader',
8
+ use: [
9
+ { loader: 'css-loader', options: { minimize: env.NODE_ENV === 'production' } },
10
+ 'postcss-loader',
11
+ 'sass-loader'
12
+ ]
13
+ })
14
+ }
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ test: /.vue$/,
3
+ loader: 'vue-loader',
4
+ options: {
5
+ loaders: {
6
+ js: 'babel-loader',
7
+ file: 'file-loader',
8
+ scss: 'vue-style-loader!css-loader!postcss-loader!sass-loader',
9
+ sass: 'vue-style-loader!css-loader!postcss-loader!sass-loader?indentedSyntax'
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,33 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ config: config/webpack
5
+ entry: packs
6
+ output: public
7
+ manifest: manifest.json
8
+ node_modules: node_modules
9
+ source: app/javascript
10
+ extensions:
11
+ - .coffee
12
+ - .js
13
+ - .jsx
14
+ - .ts
15
+ - .vue
16
+ - .sass
17
+ - .scss
18
+ - .css
19
+ - .png
20
+ - .svg
21
+ - .gif
22
+ - .jpeg
23
+ - .jpg
24
+
25
+ development:
26
+ <<: *default
27
+
28
+ test:
29
+ <<: *default
30
+ manifest: manifest-test.json
31
+
32
+ production:
33
+ <<: *default
@@ -1,23 +1,21 @@
1
- // Note: You must restart bin/webpack-watcher for changes to take effect
1
+ // Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ /* eslint global-require: 0 */
2
4
 
3
5
  const webpack = require('webpack')
4
6
  const merge = require('webpack-merge')
5
7
  const CompressionPlugin = require('compression-webpack-plugin')
6
-
7
8
  const sharedConfig = require('./shared.js')
8
9
 
9
- module.exports = merge(sharedConfig.config, {
10
+ module.exports = merge(sharedConfig, {
10
11
  output: { filename: '[name]-[chunkhash].js' },
11
12
 
12
13
  plugins: [
13
- new webpack.LoaderOptionsPlugin({
14
- minimize: true
15
- }),
16
14
  new webpack.optimize.UglifyJsPlugin(),
17
15
  new CompressionPlugin({
18
16
  asset: '[path].gz[query]',
19
17
  algorithm: 'gzip',
20
- test: /\.js$/
18
+ test: /\.(js|css|svg|eot|ttf|woff|woff2)$/
21
19
  })
22
20
  ]
23
21
  })
@@ -1,80 +1,54 @@
1
- // Note: You must restart bin/webpack-watcher for changes to take effect
1
+ // Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ /* eslint global-require: 0 */
4
+ /* eslint import/no-dynamic-require: 0 */
2
5
 
3
6
  const webpack = require('webpack')
4
- const path = require('path')
5
- const process = require('process')
6
- const glob = require('glob')
7
+ const { basename, dirname, join, relative, resolve } = require('path')
8
+ const { sync } = require('glob')
9
+ const ExtractTextPlugin = require('extract-text-webpack-plugin')
10
+ const ManifestPlugin = require('webpack-manifest-plugin')
7
11
  const extname = require('path-complete-extname')
12
+ const { env, paths, publicPath, loadersDir } = require('./configuration.js')
8
13
 
9
- let distDir = process.env.WEBPACK_DIST_DIR
10
-
11
- if (distDir === undefined) {
12
- distDir = 'packs'
13
- }
14
+ const extensionGlob = `**/*{${paths.extensions.join(',')}}*`
15
+ const packPaths = sync(join(paths.source, paths.entry, extensionGlob))
14
16
 
15
- const config = {
16
- entry: glob.sync(path.join('app', 'javascript', 'packs', '*.js*')).reduce(
17
+ module.exports = {
18
+ entry: packPaths.reduce(
17
19
  (map, entry) => {
18
- const basename = path.basename(entry, extname(entry))
19
20
  const localMap = map
20
- localMap[basename] = path.resolve(entry)
21
+ const namespace = relative(join(paths.source, paths.entry), dirname(entry))
22
+ localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry)
21
23
  return localMap
22
24
  }, {}
23
25
  ),
24
26
 
25
- output: { filename: '[name].js', path: path.resolve('public', distDir) },
27
+ output: {
28
+ filename: '[name].js',
29
+ path: resolve(paths.output, paths.entry),
30
+ publicPath
31
+ },
26
32
 
27
33
  module: {
28
- rules: [
29
- {
30
- test: /.vue$/, loader: 'vue-loader',
31
- options: {
32
- loaders: { 'scss': 'vue-style-loader!css-loader!sass-loader', 'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax'}
33
- }
34
- },
35
- { test: /.png$/, loader: 'url-loader?mimetype=image/png'},
36
- { test: /\.coffee(\.erb)?$/, loader: 'coffee-loader' },
37
- {
38
- test: /\.js(\.erb)?$/,
39
- exclude: /node_modules/,
40
- loader: 'babel-loader',
41
- options: {
42
- presets: [
43
- ['env', { modules: false }]
44
- ]
45
- }
46
- },
47
- {
48
- test: /\.erb$/,
49
- enforce: 'pre',
50
- exclude: /node_modules/,
51
- loader: 'rails-erb-loader',
52
- options: {
53
- runner: 'DISABLE_SPRING=1 bin/rails runner'
54
- }
55
- }
56
- ]
34
+ rules: sync(join(loadersDir, '*.js')).map(loader => require(loader))
57
35
  },
58
36
 
59
37
  plugins: [
60
- new webpack.EnvironmentPlugin(Object.keys(process.env))
38
+ new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
39
+ new ExtractTextPlugin(env.NODE_ENV === 'production' ? '[name]-[hash].css' : '[name].css'),
40
+ new ManifestPlugin({ fileName: paths.manifest, publicPath, writeToFileEmit: true })
61
41
  ],
62
42
 
63
43
  resolve: {
64
- alias: { 'vue$':'vue/dist/vue.esm.js' },
65
- extensions: ['.js', '.coffee'],
44
+ extensions: paths.extensions,
66
45
  modules: [
67
- path.resolve('app/javascript'),
68
- path.resolve('node_modules')
46
+ resolve(paths.source),
47
+ resolve(paths.node_modules)
69
48
  ]
70
49
  },
71
50
 
72
51
  resolveLoader: {
73
- modules: [path.resolve('node_modules')]
52
+ modules: [paths.node_modules]
74
53
  }
75
54
  }
76
-
77
- module.exports = {
78
- distDir,
79
- config
80
- }
@@ -0,0 +1,6 @@
1
+ // Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ const merge = require('webpack-merge')
4
+ const sharedConfig = require('./shared.js')
5
+
6
+ module.exports = merge(sharedConfig, {})
@@ -2,27 +2,34 @@
2
2
  "name": "<%= @config.app_name %>",
3
3
  "private": true,
4
4
  "dependencies": {
5
- "axios": "^0.15.3",
6
- "babel-core": "^6.23.1",
7
- "babel-loader": "^6.3.2",
8
- "babel-preset-env": "^1.1.11",
5
+ "autoprefixer": "^7.0.1",
6
+ "babel-core": "^6.24.1",
7
+ "babel-loader": "7.x",
8
+ "babel-preset-env": "^1.4.0",
9
9
  "coffee-loader": "^0.7.3",
10
- "coffee-script": "^1.12.4",
11
- "compression-webpack-plugin": "^0.3.2",
12
- "css-loader": "^0.26.2",
10
+ "coffee-script": "^1.12.5",
11
+ "compression-webpack-plugin": "^0.4.0",
12
+ "css-loader": "^0.28.1",
13
+ "extract-text-webpack-plugin": "^2.1.0",
14
+ "file-loader": "^0.11.1",
13
15
  "glob": "^7.1.1",
14
- "node-sass": "^4.5.0",
16
+ "js-yaml": "^3.8.4",
17
+ "node-sass": "^4.5.2",
15
18
  "path-complete-extname": "^0.1.0",
16
- "rails-erb-loader": "^3.2.0",
17
- "sass-loader": "^6.0.2",
18
- "url-loader": "^0.5.8",
19
- "vue": "^2.2.1",
20
- "vue-loader": "^11.1.3",
21
- "vue-template-compiler": "^2.2.1",
22
- "webpack": "^2.2.1",
23
- "webpack-merge": "^3.0.0"
19
+ "postcss-loader": "^2.0.3",
20
+ "postcss-smart-import": "^0.6.13",
21
+ "precss": "^1.4.0",
22
+ "rails-erb-loader": "^5.0.0",
23
+ "sass-loader": "^6.0.4",
24
+ "style-loader": "^0.17.0",
25
+ "vue": "^2.3.3",
26
+ "vue-loader": "^12.0.3",
27
+ "vue-template-compiler": "^2.3.3",
28
+ "webpack": "^2.5.1",
29
+ "webpack-manifest-plugin": "^1.1.0",
30
+ "webpack-merge": "^4.1.0"
24
31
  },
25
32
  "devDependencies": {
26
- "webpack-dev-server": "^2.4.1"
33
+ "webpack-dev-server": "^2.4.5"
27
34
  }
28
35
  }
@@ -4,64 +4,64 @@
4
4
  <title>The page you were looking for doesn't exist (404)</title>
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
6
  <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
14
 
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
20
 
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
33
 
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
39
 
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
54
  </style>
55
55
  </head>
56
56
 
57
- <body>
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
65
63
  </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
66
  </body>
67
67
  </html>