frails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +7 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +93 -0
- data/README.md +72 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/frails.gemspec +43 -0
- data/lib/frails/dev_server.rb +24 -0
- data/lib/frails/dev_server_proxy.rb +37 -0
- data/lib/frails/helper.rb +21 -0
- data/lib/frails/instance.rb +11 -0
- data/lib/frails/manifest.rb +90 -0
- data/lib/frails/railtie.rb +35 -0
- data/lib/frails/server_manifest.rb +7 -0
- data/lib/frails/version.rb +5 -0
- data/lib/frails.rb +33 -0
- data/lib/install/template.rb +19 -0
- data/lib/tasks/frails.rake +11 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6ee508fa6664a6ab99ce98455154178494206803ec8d377d0fe305b6b5601bdc
|
4
|
+
data.tar.gz: d55d3414d0e8e105abfc59a23dffc6d09feaeaf1a54924231137b91949abad9c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e68db6995b9d72a2250b1f6f4672fe171f3aa3464627270a9dd8d9e4f710ad2313a4ebb0f5bc6d1a4aabe9b7dcb185df34652598d8f6e88bc659d9f2d954a83
|
7
|
+
data.tar.gz: '09e905d8ac0b2df6a9f90bdfaabe9501182982817e8a777060b151c9babd239ad4c94a9ebae6f8c4173e63146d1a514f9e8ee93db40329672cfcca0bd07c41b6'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Describe the bug**
|
11
|
+
A clear and concise description of what the bug is.
|
12
|
+
|
13
|
+
**To Reproduce**
|
14
|
+
Steps to reproduce the behavior:
|
15
|
+
1. Go to '...'
|
16
|
+
2. Click on '....'
|
17
|
+
3. Scroll down to '....'
|
18
|
+
4. See error
|
19
|
+
|
20
|
+
**Expected behavior**
|
21
|
+
A clear and concise description of what you expected to happen.
|
22
|
+
|
23
|
+
**Screenshots**
|
24
|
+
If applicable, add screenshots to help explain your problem.
|
25
|
+
|
26
|
+
**Desktop (please complete the following information):**
|
27
|
+
- OS: [e.g. iOS]
|
28
|
+
- Browser [e.g. chrome, safari]
|
29
|
+
- Version [e.g. 22]
|
30
|
+
|
31
|
+
**Smartphone (please complete the following information):**
|
32
|
+
- Device: [e.g. iPhone6]
|
33
|
+
- OS: [e.g. iOS8.1]
|
34
|
+
- Browser [e.g. stock browser, safari]
|
35
|
+
- Version [e.g. 22]
|
36
|
+
|
37
|
+
**Additional context**
|
38
|
+
Add any other context about the problem here.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
name: Feature request
|
3
|
+
about: Suggest an idea for this project
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
12
|
+
|
13
|
+
**Describe the solution you'd like**
|
14
|
+
A clear and concise description of what you want to happen.
|
15
|
+
|
16
|
+
**Describe alternatives you've considered**
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
18
|
+
|
19
|
+
**Additional context**
|
20
|
+
Add any other context or screenshots about the feature request here.
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
Style/Documentation:
|
4
|
+
Enabled: false
|
5
|
+
Style/ModuleFunction:
|
6
|
+
Enabled: false
|
7
|
+
Style/ClassAndModuleChildren:
|
8
|
+
Enabled: false
|
9
|
+
Metrics/LineLength:
|
10
|
+
Max: 100
|
11
|
+
Layout/IndentationConsistency:
|
12
|
+
EnforcedStyle: rails
|
13
|
+
SupportedStyles:
|
14
|
+
- rails
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
frails (0.1.0)
|
5
|
+
rack-proxy (>= 0.6.5)
|
6
|
+
railties (>= 5.2)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (5.2.3)
|
12
|
+
actionview (= 5.2.3)
|
13
|
+
activesupport (= 5.2.3)
|
14
|
+
rack (~> 2.0)
|
15
|
+
rack-test (>= 0.6.3)
|
16
|
+
rails-dom-testing (~> 2.0)
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
18
|
+
actionview (5.2.3)
|
19
|
+
activesupport (= 5.2.3)
|
20
|
+
builder (~> 3.1)
|
21
|
+
erubi (~> 1.4)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
24
|
+
activesupport (5.2.3)
|
25
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
+
i18n (>= 0.7, < 2)
|
27
|
+
minitest (~> 5.1)
|
28
|
+
tzinfo (~> 1.1)
|
29
|
+
ast (2.4.0)
|
30
|
+
builder (3.2.3)
|
31
|
+
concurrent-ruby (1.1.5)
|
32
|
+
crass (1.0.4)
|
33
|
+
erubi (1.8.0)
|
34
|
+
i18n (1.6.0)
|
35
|
+
concurrent-ruby (~> 1.0)
|
36
|
+
jaro_winkler (1.5.2)
|
37
|
+
loofah (2.2.3)
|
38
|
+
crass (~> 1.0.2)
|
39
|
+
nokogiri (>= 1.5.9)
|
40
|
+
method_source (0.9.2)
|
41
|
+
mini_portile2 (2.4.0)
|
42
|
+
minitest (5.11.3)
|
43
|
+
nokogiri (1.10.2)
|
44
|
+
mini_portile2 (~> 2.4.0)
|
45
|
+
parallel (1.16.0)
|
46
|
+
parser (2.6.2.0)
|
47
|
+
ast (~> 2.4.0)
|
48
|
+
psych (3.1.0)
|
49
|
+
rack (2.0.7)
|
50
|
+
rack-proxy (0.6.5)
|
51
|
+
rack
|
52
|
+
rack-test (1.1.0)
|
53
|
+
rack (>= 1.0, < 3)
|
54
|
+
rails-dom-testing (2.0.3)
|
55
|
+
activesupport (>= 4.2.0)
|
56
|
+
nokogiri (>= 1.6)
|
57
|
+
rails-html-sanitizer (1.0.4)
|
58
|
+
loofah (~> 2.2, >= 2.2.2)
|
59
|
+
railties (5.2.3)
|
60
|
+
actionpack (= 5.2.3)
|
61
|
+
activesupport (= 5.2.3)
|
62
|
+
method_source
|
63
|
+
rake (>= 0.8.7)
|
64
|
+
thor (>= 0.19.0, < 2.0)
|
65
|
+
rainbow (3.0.0)
|
66
|
+
rake (10.5.0)
|
67
|
+
rubocop (0.66.0)
|
68
|
+
jaro_winkler (~> 1.5.1)
|
69
|
+
parallel (~> 1.10)
|
70
|
+
parser (>= 2.5, != 2.5.1.1)
|
71
|
+
psych (>= 3.1.0)
|
72
|
+
rainbow (>= 2.2.2, < 4.0)
|
73
|
+
ruby-progressbar (~> 1.7)
|
74
|
+
unicode-display_width (>= 1.4.0, < 1.6)
|
75
|
+
ruby-progressbar (1.10.0)
|
76
|
+
thor (0.20.3)
|
77
|
+
thread_safe (0.3.6)
|
78
|
+
tzinfo (1.2.5)
|
79
|
+
thread_safe (~> 0.1)
|
80
|
+
unicode-display_width (1.5.0)
|
81
|
+
|
82
|
+
PLATFORMS
|
83
|
+
ruby
|
84
|
+
|
85
|
+
DEPENDENCIES
|
86
|
+
bundler (~> 2.0)
|
87
|
+
frails!
|
88
|
+
minitest (~> 5.0)
|
89
|
+
rake (~> 10.0)
|
90
|
+
rubocop
|
91
|
+
|
92
|
+
BUNDLED WITH
|
93
|
+
2.0.1
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Frails == Modern Front End on Rails
|
2
|
+
|
3
|
+
Frails is a modern asset pipeline for [Rails](https://rubyonrails.org), built on [Webpack](https://webpack.js.org/). Its aims are:
|
4
|
+
|
5
|
+
- Follow convention over configuration as much as possible.
|
6
|
+
- Tight integration with Rails, without tying you up in knots.
|
7
|
+
- Full Webpack control without fighting with the likes of Webpacker.
|
8
|
+
- Embrace modern front end practises.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Frails is designed to work only within a Rails application, so must be installed in an existing Rails app. It also requires Node.js and a valid `package.json` file in your app root.
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'frails'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Then run the installer:
|
25
|
+
|
26
|
+
$ bin/rails frails:install
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
Frails tries to keep as close as possible to a standard Webpack setup, so you can run webpack and webpack-dev-server in the usual way. For example, using yarn you can build:
|
31
|
+
|
32
|
+
$ yarn webpack
|
33
|
+
|
34
|
+
or run the dev server:
|
35
|
+
|
36
|
+
$ yarn webpack-dev-server
|
37
|
+
|
38
|
+
Rails will proxy requests to any running Webpack dev server
|
39
|
+
|
40
|
+
## Configuration
|
41
|
+
|
42
|
+
Frails is built to be as simple as possible, so has very few configuration options. But if you really must change the defaults, just add any of the following config options by adding to `config/application.rb` or and/any of the environment initialzers at `config/environment`.
|
43
|
+
|
44
|
+
For example:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
Rails.application.configure do
|
48
|
+
config.frails.dev_server_port = 3035
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
Of course, if you do change any of these options, be sure to modify your Webpack config accordingly.
|
53
|
+
|
54
|
+
### Options
|
55
|
+
|
56
|
+
- `dev_server_port` - The HTTP port that Rails will proxy asset requests to. (default: `8080`)
|
57
|
+
- `dev_server_host` - The HTTP host that Rails will proxy asset requests to. (default: `localhost`)
|
58
|
+
- `public_output_path` - The public path where Webpack will output its build to, relative to your app's `/public` directory. (default: `/assets`)
|
59
|
+
|
60
|
+
## Development
|
61
|
+
|
62
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
63
|
+
|
64
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/joelmoss/frails.
|
69
|
+
|
70
|
+
## Thanks...
|
71
|
+
|
72
|
+
A huge thank you goes out to the peeps behind [Webpacker](https://github.com/rails/webpacker). Frails has borrowed heavily from Webpacker, particularly for the dev server proxy and minifest code. 🙏
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'frails'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/frails.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'frails/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'frails'
|
9
|
+
spec.version = Frails::VERSION
|
10
|
+
spec.authors = ['Joel Moss']
|
11
|
+
spec.email = ['joel@developwithstyle.com']
|
12
|
+
|
13
|
+
spec.summary = 'A Modern Front End on Rails and Webpack'
|
14
|
+
spec.homepage = 'https://github.com/joelmoss/frails'
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
unless spec.respond_to?(:metadata)
|
19
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
20
|
+
end
|
21
|
+
|
22
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
23
|
+
|
24
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
25
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
26
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/releases"
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
32
|
+
end
|
33
|
+
spec.bindir = 'exe'
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ['lib']
|
36
|
+
|
37
|
+
spec.add_dependency 'rack-proxy', '>= 0.6.5'
|
38
|
+
spec.add_dependency 'railties', '>= 5.2'
|
39
|
+
|
40
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
41
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
42
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
43
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Frails::DevServer
|
4
|
+
# rubocop:disable Style/RescueStandardError
|
5
|
+
def running?
|
6
|
+
Socket.tcp(host, port, connect_timeout: 0.01).close
|
7
|
+
true
|
8
|
+
rescue
|
9
|
+
false
|
10
|
+
end
|
11
|
+
# rubocop:enable Style/RescueStandardError
|
12
|
+
|
13
|
+
def host_with_port
|
14
|
+
"#{host}:#{port}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def host
|
18
|
+
Rails.configuration.frails.dev_server_host
|
19
|
+
end
|
20
|
+
|
21
|
+
def port
|
22
|
+
Rails.configuration.frails.dev_server_port
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rack/proxy'
|
4
|
+
|
5
|
+
class Frails::DevServerProxy < Rack::Proxy
|
6
|
+
delegate :dev_server, to: :@frails
|
7
|
+
|
8
|
+
def initialize(app = nil, opts = {})
|
9
|
+
@frails = Frails.instance
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def rewrite_response(response)
|
14
|
+
_status, headers, _body = response
|
15
|
+
headers.delete 'transfer-encoding'
|
16
|
+
response
|
17
|
+
end
|
18
|
+
|
19
|
+
def perform_request(env)
|
20
|
+
if env['PATH_INFO'].start_with?(public_output_path) && dev_server.running?
|
21
|
+
host = dev_server.host_with_port
|
22
|
+
env['HTTP_HOST'] = env['HTTP_X_FORWARDED_HOST'] = env['HTTP_X_FORWARDED_SERVER'] = host
|
23
|
+
env['HTTP_X_FORWARDED_PROTO'] = env['HTTP_X_FORWARDED_SCHEME'] = 'http'
|
24
|
+
env['SCRIPT_NAME'] = ''
|
25
|
+
|
26
|
+
super(env)
|
27
|
+
else
|
28
|
+
@app.call(env)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def public_output_path
|
35
|
+
Rails.configuration.frails.public_output_path
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Frails::Helper
|
4
|
+
def javascript_pack_tag(*names, **options)
|
5
|
+
javascript_include_tag(*sources_from_manifest_entries(names, :javascript), **options)
|
6
|
+
end
|
7
|
+
|
8
|
+
def stylesheet_pack_tag(*names, **options)
|
9
|
+
stylesheet_link_tag(*sources_from_manifest_entries(names, :stylesheet), **options)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def sources_from_manifest_entries(names, type)
|
15
|
+
names.map { |name| frails_instance.manifest.lookup!(name, type: type) }.flatten
|
16
|
+
end
|
17
|
+
|
18
|
+
def frails_instance
|
19
|
+
Frails.instance
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Frails::Manifest
|
4
|
+
class MissingEntryError < StandardError; end
|
5
|
+
|
6
|
+
def refresh
|
7
|
+
@data = load
|
8
|
+
end
|
9
|
+
|
10
|
+
# Computes the relative path for a given Frails asset using manifest.json. If no asset is found,
|
11
|
+
# returns nil.
|
12
|
+
#
|
13
|
+
# Example:
|
14
|
+
# Frails.manifest.lookup('calendar.js') # => "/packs/calendar-1016838bab065ae1e122.js"
|
15
|
+
def lookup(name, type: nil)
|
16
|
+
# When using SplitChunks or RuntimeChunks the manifest hash will contain an extra object called
|
17
|
+
# "entrypoints". When the entrypoints key is not present in the manifest, or the name is not
|
18
|
+
# found in the entrypoints hash, it will raise a NoMethodError. If this happens, we should try
|
19
|
+
# to lookup a single instance of the pack based on the given name.
|
20
|
+
manifest_pack_type = manifest_type(type)
|
21
|
+
manifest_pack_name = manifest_name(name, manifest_pack_type)
|
22
|
+
|
23
|
+
# Lookup the pack in the entrypoints of the manifest
|
24
|
+
find('entrypoints')[manifest_pack_name][manifest_pack_type]
|
25
|
+
rescue NoMethodError
|
26
|
+
# Lookup a single instance of the pack.
|
27
|
+
find full_pack_name(name, type)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Like lookup, except that if no asset is found, raises a Frails::Manifest::MissingEntryError.
|
31
|
+
def lookup!(name, type: nil)
|
32
|
+
lookup(name, type: type) || handle_missing_entry(name)
|
33
|
+
end
|
34
|
+
|
35
|
+
def manifest_path
|
36
|
+
@manifest_path ||= Rails.root.join('public', 'packs', 'manifest.json')
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def load
|
42
|
+
manifest_path.exist? ? JSON.parse(manifest_path.read) : {}
|
43
|
+
end
|
44
|
+
|
45
|
+
def data
|
46
|
+
if Rails.env.production?
|
47
|
+
@data ||= load
|
48
|
+
else
|
49
|
+
refresh
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def handle_missing_entry(name)
|
54
|
+
raise Frails::Manifest::MissingEntryError, missing_file_from_manifest_error(name)
|
55
|
+
end
|
56
|
+
|
57
|
+
def find(name)
|
58
|
+
data[name.to_s].presence
|
59
|
+
end
|
60
|
+
|
61
|
+
def full_pack_name(name, type)
|
62
|
+
return name unless File.extname(name.to_s).empty?
|
63
|
+
|
64
|
+
"#{name}.#{manifest_type(type)}"
|
65
|
+
end
|
66
|
+
|
67
|
+
# The `manifest_name` method strips of the file extension of the name, because in the
|
68
|
+
# manifest hash the entrypoints are defined by their pack name without the extension.
|
69
|
+
# When the user provides a name with a file extension, we want to try to strip it off.
|
70
|
+
def manifest_name(name, type)
|
71
|
+
return name if File.extname(name.to_s).empty?
|
72
|
+
|
73
|
+
File.basename(name, type)
|
74
|
+
end
|
75
|
+
|
76
|
+
def manifest_type(type)
|
77
|
+
case type
|
78
|
+
when :javascript then 'js'
|
79
|
+
when :stylesheet then 'css'
|
80
|
+
else type.to_s
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def missing_file_from_manifest_error(bundle_name)
|
85
|
+
<<~MSG
|
86
|
+
Frails can't find #{bundle_name} in #{manifest_path}. Your manifest contains:
|
87
|
+
#{JSON.pretty_generate(@data)}
|
88
|
+
MSG
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/railtie'
|
4
|
+
|
5
|
+
require 'frails/helper'
|
6
|
+
require 'frails/dev_server_proxy'
|
7
|
+
|
8
|
+
class Frails::Engine < ::Rails::Engine
|
9
|
+
# Allows Webpacker config values to be set via Rails env config files
|
10
|
+
config.frails = ActiveSupport::OrderedOptions.new
|
11
|
+
|
12
|
+
initializer 'frails.default_config' do |app|
|
13
|
+
assign_config app, :public_output_path, '/assets'
|
14
|
+
assign_config app, :dev_server_port, 8080
|
15
|
+
assign_config app, :dev_server_host, 'localhost'
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer 'frails.proxy' do |app|
|
19
|
+
app.middleware.insert_before 0, Frails::DevServerProxy, ssl_verify_none: true
|
20
|
+
end
|
21
|
+
|
22
|
+
initializer 'frails.helper' do
|
23
|
+
ActiveSupport.on_load :action_controller do
|
24
|
+
ActionController::Base.helper Frails::Helper
|
25
|
+
end
|
26
|
+
|
27
|
+
ActiveSupport.on_load :action_view do
|
28
|
+
include Frails::Helper
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def assign_config(app, name, default_value)
|
34
|
+
app.config.frails[name] = app.config.frails.fetch(name, default_value)
|
35
|
+
end
|
data/lib/frails.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'frails/version'
|
4
|
+
require 'active_support/core_ext/module'
|
5
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
6
|
+
|
7
|
+
module Frails
|
8
|
+
extend self
|
9
|
+
|
10
|
+
def instance=(instance)
|
11
|
+
@instance = instance
|
12
|
+
end
|
13
|
+
|
14
|
+
def instance
|
15
|
+
@instance ||= Frails::Instance.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def with_node_env(env)
|
19
|
+
original = ENV['NODE_ENV']
|
20
|
+
ENV['NODE_ENV'] = env
|
21
|
+
yield
|
22
|
+
ensure
|
23
|
+
ENV['NODE_ENV'] = original
|
24
|
+
end
|
25
|
+
|
26
|
+
delegate :manifest, :dev_server, to: :instance
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'frails/instance'
|
30
|
+
require 'frails/dev_server_proxy'
|
31
|
+
require 'frails/manifest'
|
32
|
+
require 'frails/dev_server'
|
33
|
+
require 'frails/railtie'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if File.exist?('.gitignore')
|
4
|
+
append_to_file '.gitignore' do
|
5
|
+
"\n" \
|
6
|
+
"/node_modules\n" \
|
7
|
+
"/yarn-error.log\n" \
|
8
|
+
"yarn-debug.log*\n" \
|
9
|
+
".yarn-integrity\n"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
say "Installing all JavaScript dependencies [#{Frails::VERSION}]"
|
14
|
+
run 'yarn add webpack webpack-cli'
|
15
|
+
|
16
|
+
say 'Installing Webpack dev server for live reloading'
|
17
|
+
run 'yarn add --dev webpack-dev-server'
|
18
|
+
|
19
|
+
say 'Frails successfully installed 🎉', :green
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
install_template_path = File.expand_path('../install/template.rb', __dir__).freeze
|
4
|
+
bin_path = ENV['BUNDLE_BIN'] || './bin'
|
5
|
+
|
6
|
+
namespace :frails do
|
7
|
+
desc 'Install Frails in this application'
|
8
|
+
task :install do
|
9
|
+
exec "#{RbConfig.ruby} #{bin_path}/rails app:template LOCATION=#{install_template_path}"
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: frails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joel Moss
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack-proxy
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: railties
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- joel@developwithstyle.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
91
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rubocop.yml"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- frails.gemspec
|
102
|
+
- lib/frails.rb
|
103
|
+
- lib/frails/dev_server.rb
|
104
|
+
- lib/frails/dev_server_proxy.rb
|
105
|
+
- lib/frails/helper.rb
|
106
|
+
- lib/frails/instance.rb
|
107
|
+
- lib/frails/manifest.rb
|
108
|
+
- lib/frails/railtie.rb
|
109
|
+
- lib/frails/server_manifest.rb
|
110
|
+
- lib/frails/version.rb
|
111
|
+
- lib/install/template.rb
|
112
|
+
- lib/tasks/frails.rake
|
113
|
+
homepage: https://github.com/joelmoss/frails
|
114
|
+
licenses: []
|
115
|
+
metadata:
|
116
|
+
allowed_push_host: https://rubygems.org
|
117
|
+
homepage_uri: https://github.com/joelmoss/frails
|
118
|
+
source_code_uri: https://github.com/joelmoss/frails
|
119
|
+
changelog_uri: https://github.com/joelmoss/frails/releases
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubygems_version: 3.0.3
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: A Modern Front End on Rails and Webpack
|
139
|
+
test_files: []
|