eucalypt 0.5.1 → 0.5.2
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 +4 -4
- data/README.md +1 -19
- data/eucalypt.gemspec +1 -2
- data/lib/eucalypt/blog/namespaces/blog/cli/blog.rb +0 -12
- data/lib/eucalypt/core/helpers/maintenance.rb +3 -3
- data/lib/eucalypt/core/helpers/static.rb +44 -10
- data/lib/eucalypt/core/templates/Gemfile.tt +1 -1
- data/lib/eucalypt/core/templates/eucalypt/app/controllers/application_controller.rb +3 -1
- data/lib/eucalypt/core/templates/eucalypt/app/static/{maintenance.html → public/maintenance.html} +0 -0
- data/lib/eucalypt/core/templates/eucalypt/app.rb +3 -7
- data/lib/eucalypt/core/templates/eucalypt/config/assets.rb +4 -4
- data/lib/eucalypt/guard.rb +7 -0
- data/lib/eucalypt/load.rb +1 -0
- data/lib/eucalypt/version.rb +1 -1
- data/lib/eucalypt.rb +0 -2
- metadata +4 -19
- data/lib/eucalypt/exceptions.rb +0 -12
- data/lib/eucalypt/whitelist.rb +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f37d0ae31182679a375f2f7187055526fe29b64277f3b7f4c618d11a5382989f
|
4
|
+
data.tar.gz: b7ae9fcf4881a3a56fd9e5acaed9152bada8575acd15b7b1e600702f7f211fad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd69f7f5cedf737faebcc0e2c54452bf521a6f40847cc83f7620d800396dc1a847d3a8d4cbfb846c70717762438f8da094f85c3cf5461dc765583ca5ede04055
|
7
|
+
data.tar.gz: 406bc23c4389ac1be9cf8097ae8a3f8f412bb3c0006d880720a7e0d76a14f5b4f3ef00cfac62de25d94442c9b5748934d360e4cf36f210305df516f202ba85f6
|
data/README.md
CHANGED
@@ -32,25 +32,7 @@ $ eucalypt init my-new-app
|
|
32
32
|
|
33
33
|
Move into your new application's directory and run the top-level `eucalypt` command to display a list of all available commands:
|
34
34
|
|
35
|
-
|
36
|
-
$ eucalypt
|
37
|
-
|
38
|
-
Commands:
|
39
|
-
eucalypt init [NAME] ·› Sets up your application
|
40
|
-
eucalypt launch [ENV] ·› Launches your application
|
41
|
-
eucalypt console ·› Interactive console with all files loaded
|
42
|
-
eucalypt test ·› Run all application tests
|
43
|
-
eucalypt version ·› Display installed Eucalypt version
|
44
|
-
eucalypt rake ·› Run all database migrations
|
45
|
-
eucalypt blog [COMMAND] ·› Manage static blog environment
|
46
|
-
eucalypt generate [COMMAND] ·› Generate individual MVC files or scaffolds
|
47
|
-
eucalypt destroy [COMMAND] ·› Destroy individual MVC files or scaffolds
|
48
|
-
eucalypt security [COMMAND] ·› Manage authentication and authorization
|
49
|
-
eucalypt migration [COMMAND] ·› Generate ActiveRecord migrations
|
50
|
-
|
51
|
-
For more information about a specific command, use eucalypt -H.
|
52
|
-
Example: eucalypt -H generate scaffold
|
53
|
-
```
|
35
|
+
<p align="center"><img width="70%" src="gfx/cli.png"></p>
|
54
36
|
|
55
37
|
## Documentation
|
56
38
|
|
data/eucalypt.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.license = "MIT"
|
14
14
|
spec.files = Dir.glob('lib/**/*', File::FNM_DOTMATCH) + %w[Gemfile LICENSE README.md Rakefile eucalypt.gemspec bin/eucalypt]
|
15
15
|
spec.bindir = "bin"
|
16
|
-
spec.executables =
|
16
|
+
spec.executables = "eucalypt"
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
19
|
spec.required_ruby_version = "~> 2.5"
|
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_runtime_dependency "string-builder", "~> 2.3"
|
28
28
|
spec.add_runtime_dependency "activesupport", "~> 5.2"
|
29
29
|
spec.add_runtime_dependency "activerecord", "~> 5.2"
|
30
|
-
spec.add_runtime_dependency "bcrypt", "~> 3.1"
|
31
30
|
spec.add_runtime_dependency "front_matter_parser", "0.2.0"
|
32
31
|
spec.add_runtime_dependency "thor", "~> 0.20"
|
33
32
|
spec.add_runtime_dependency "sinatra", "~> 2.0", ">= 2.0.4"
|
@@ -31,18 +31,6 @@ module Eucalypt
|
|
31
31
|
generator.helper
|
32
32
|
generator.controller(route: options[:route])
|
33
33
|
generator.views
|
34
|
-
|
35
|
-
assets_file = File.join(directory, 'config', 'assets.rb')
|
36
|
-
|
37
|
-
File.open(assets_file) do |f|
|
38
|
-
return if f.read.include? "assets.append_path Eucalypt.path 'app', 'assets', 'blog'"
|
39
|
-
end
|
40
|
-
|
41
|
-
insert_into_file(
|
42
|
-
assets_file,
|
43
|
-
" assets.append_path Eucalypt.path 'app', 'assets', 'blog'\n",
|
44
|
-
after: "set :assets, Sprockets::Environment.new\n"
|
45
|
-
)
|
46
34
|
else
|
47
35
|
Eucalypt::Error.wrong_directory
|
48
36
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'sinatra'
|
2
|
-
require '
|
2
|
+
require 'securerandom'
|
3
3
|
class ApplicationController < Sinatra::Base
|
4
4
|
if settings.methods(false).include?(:maintenance)
|
5
5
|
if settings.maintenance
|
@@ -14,9 +14,9 @@ class ApplicationController < Sinatra::Base
|
|
14
14
|
unlink '*', &block
|
15
15
|
end
|
16
16
|
else
|
17
|
-
define_singleton_method(:maintenance) {|&block| get "/#{
|
17
|
+
define_singleton_method(:maintenance) {|&block| get "/#{SecureRandom.random_bytes 16}", &block}
|
18
18
|
end
|
19
19
|
else
|
20
|
-
define_singleton_method(:maintenance) {|&block| get "/#{
|
20
|
+
define_singleton_method(:maintenance) {|&block| get "/#{SecureRandom.random_bytes 16}", &block}
|
21
21
|
end
|
22
22
|
end
|
@@ -1,15 +1,49 @@
|
|
1
1
|
require 'sinatra'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
module Eucalypt
|
3
|
+
class Static::Router
|
4
|
+
attr_reader :routes
|
5
|
+
|
6
|
+
def initialize(public_folder)
|
7
|
+
@routes = []
|
8
|
+
@public_folder = public_folder
|
8
9
|
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
def route(file, aliases: [])
|
12
|
+
raise ArgumentError.new("Invalid argument #{file} for 'file' - Expected string (file path with preceding /)") unless file.is_a?(String) && file.start_with?('/')
|
13
|
+
location = File.join @public_folder, file.sub('/', '')
|
14
|
+
raise ArgumentError.new("Invalid argument #{file} for 'file' - File \"#{location}\" doesn't exist") unless File.file? location
|
15
|
+
raise ArgumentError.new("Invalid keyword argument #{aliases} for 'aliases' - Expected Array of String") unless aliases.is_a?(Array) && aliases.all?{|a| a.is_a? String}
|
16
|
+
raise ArgumentError.new("Invalid keyword argument #{aliases} for 'aliases' - Expected Array of route names (preceded by /)") unless aliases.all?{|a| a.start_with? '/'}
|
17
|
+
@routes << {file: file, aliases: aliases}
|
18
|
+
end
|
19
|
+
|
20
|
+
alias_method :<<, :route
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class ApplicationController < Sinatra::Base
|
25
|
+
set :static_router, ->{ Eucalypt::Static::Router.new settings.public_folder }
|
26
|
+
|
27
|
+
def self.static(file = nil, aliases: [])
|
28
|
+
if settings.static_router.is_a? Eucalypt::Static::Router
|
29
|
+
if block_given?
|
30
|
+
yield settings.static_router
|
31
|
+
settings.static_router.routes.each do |route|
|
32
|
+
route.values.flatten.each do |path|
|
33
|
+
get(path) { send_file File.join(settings.public_folder, route[:file].sub('/','')) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
else
|
37
|
+
if file && aliases
|
38
|
+
raise ArgumentError.new("Invalid argument #{file} for 'file' - Expected string (file path with preceding /)") unless file.is_a?(String) && file.start_with?('/')
|
39
|
+
location = File.join settings.public_folder, file.sub('/', '')
|
40
|
+
raise ArgumentError.new("Invalid argument #{file} for 'file' - File \"#{location}\" doesn't exist") unless File.file? location
|
41
|
+
raise ArgumentError.new("Invalid keyword argument #{aliases} for 'aliases' - Expected Array of String") unless aliases.is_a?(Array) && aliases.all?{|a| a.is_a? String}
|
42
|
+
raise ArgumentError.new("Invalid keyword argument #{aliases} for 'aliases' - Expected Array of route names (preceded by /)") unless aliases.all?{|a| a.start_with? '/'}
|
43
|
+
routes = [file] + aliases
|
44
|
+
routes.each {|path| get(path){send_file location} }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
14
48
|
end
|
15
49
|
end
|
data/lib/eucalypt/core/templates/eucalypt/app/static/{maintenance.html → public/maintenance.html}
RENAMED
File without changes
|
@@ -9,11 +9,10 @@ class ApplicationController < Sinatra::Base
|
|
9
9
|
set :app_file, __FILE__
|
10
10
|
|
11
11
|
# Set public folder for static files
|
12
|
-
set :public_folder, Eucalypt.path('app', 'static')
|
12
|
+
set :public_folder, Eucalypt.path('app', 'static', 'public')
|
13
13
|
|
14
|
-
#
|
15
|
-
|
16
|
-
::Static = Eucalypt::Static.new(settings.public_folder, symbolize: true).freeze
|
14
|
+
# Set static data accessor
|
15
|
+
::Static = Eucalypt::Static.new(Eucalypt.path('app', 'static'), symbolize: true).freeze
|
17
16
|
|
18
17
|
# Set views directory
|
19
18
|
set :views, Eucalypt.path('app', 'views')
|
@@ -21,9 +20,6 @@ class ApplicationController < Sinatra::Base
|
|
21
20
|
# Set default ERB template
|
22
21
|
set :erb, layout: :'layouts/main'
|
23
22
|
|
24
|
-
# Set IP whitelist
|
25
|
-
set :whitelist, Eucalypt::Whitelist.new(Eucalypt.path 'config', 'whitelist')
|
26
|
-
|
27
23
|
# Toggle maintenance mode
|
28
24
|
disable :maintenance
|
29
25
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
class ApplicationController < Sinatra::Base
|
2
2
|
set :assets, Sprockets::Environment.new
|
3
|
-
assets.append_path Eucalypt.path 'app', 'assets', 'stylesheets'
|
4
|
-
assets.append_path Eucalypt.path 'app', 'assets', 'scripts'
|
5
|
-
assets.append_path Eucalypt.path 'app', 'assets', 'images'
|
6
|
-
assets.append_path Eucalypt.path 'app', 'assets', 'fonts'
|
7
3
|
|
8
4
|
assets.css_compressor = :scss
|
9
5
|
assets.js_compressor = :uglify
|
10
6
|
|
7
|
+
Eucalypt.glob 'app', 'assets', '*' do |item|
|
8
|
+
assets.append_path item if File.directory? item
|
9
|
+
end
|
10
|
+
|
11
11
|
get '/assets/*' do
|
12
12
|
env["PATH_INFO"].sub! '/assets', ''
|
13
13
|
settings.assets.call env
|
data/lib/eucalypt/load.rb
CHANGED
@@ -2,6 +2,7 @@ Eucalypt.require 'config', '*.rb'
|
|
2
2
|
Eucalypt.require 'config', 'initializers', '*.rb'
|
3
3
|
|
4
4
|
require 'eucalypt/core/helpers/maintenance'
|
5
|
+
require 'eucalypt/core/helpers/static'
|
5
6
|
|
6
7
|
Eucalypt.require 'app', 'helpers', '{application_helper.rb}'
|
7
8
|
Eucalypt.require 'app', 'controllers', 'application_controller.rb'
|
data/lib/eucalypt/version.rb
CHANGED
data/lib/eucalypt.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eucalypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edwin Onuonga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '5.2'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: bcrypt
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '3.1'
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '3.1'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: front_matter_parser
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -267,7 +253,7 @@ files:
|
|
267
253
|
- lib/eucalypt/core/templates/eucalypt/app/controllers/application_controller.rb
|
268
254
|
- lib/eucalypt/core/templates/eucalypt/app/helpers/application_helper.rb
|
269
255
|
- lib/eucalypt/core/templates/eucalypt/app/models/.empty_directory
|
270
|
-
- lib/eucalypt/core/templates/eucalypt/app/static/maintenance.html
|
256
|
+
- lib/eucalypt/core/templates/eucalypt/app/static/public/maintenance.html
|
271
257
|
- lib/eucalypt/core/templates/eucalypt/app/views/index.erb
|
272
258
|
- lib/eucalypt/core/templates/eucalypt/app/views/layouts/main.erb
|
273
259
|
- lib/eucalypt/core/templates/eucalypt/app/views/partials/.empty_directory
|
@@ -288,7 +274,6 @@ files:
|
|
288
274
|
- lib/eucalypt/destroy/namespaces/destroy/cli/destroy-scaffold.rb
|
289
275
|
- lib/eucalypt/destroy/namespaces/destroy/cli/destroy.rb
|
290
276
|
- lib/eucalypt/errors.rb
|
291
|
-
- lib/eucalypt/exceptions.rb
|
292
277
|
- lib/eucalypt/generate/.gitkeep
|
293
278
|
- lib/eucalypt/generate/namespaces/generate-controller/cli/generate-controller.rb
|
294
279
|
- lib/eucalypt/generate/namespaces/generate-controller/generators/controller.rb
|
@@ -306,6 +291,7 @@ files:
|
|
306
291
|
- lib/eucalypt/generate/namespaces/generate-model/templates/model_spec.tt
|
307
292
|
- lib/eucalypt/generate/namespaces/generate/cli/generate-scaffold.rb
|
308
293
|
- lib/eucalypt/generate/namespaces/generate/cli/generate.rb
|
294
|
+
- lib/eucalypt/guard.rb
|
309
295
|
- lib/eucalypt/helpers.rb
|
310
296
|
- lib/eucalypt/helpers/colorize.rb
|
311
297
|
- lib/eucalypt/helpers/gemfile.rb
|
@@ -373,7 +359,6 @@ files:
|
|
373
359
|
- lib/eucalypt/security/permissions.rb
|
374
360
|
- lib/eucalypt/static.rb
|
375
361
|
- lib/eucalypt/version.rb
|
376
|
-
- lib/eucalypt/whitelist.rb
|
377
362
|
homepage: https://eucalypt.gitbook.io/eucalypt
|
378
363
|
licenses:
|
379
364
|
- MIT
|
data/lib/eucalypt/exceptions.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
module Eucalypt
|
2
|
-
class NotWhitelistedError < Exception
|
3
|
-
def initialize(ip)
|
4
|
-
super "IP address #{ip} not whitelisted"
|
5
|
-
end
|
6
|
-
end
|
7
|
-
class InvalidSettingTypeError < Exception
|
8
|
-
def initialize(setting, actual, classes)
|
9
|
-
super "!\nInvalid type for setting :#{setting}, got:\n\t#{actual},\nmust be one of:\n\t#{classes}"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
data/lib/eucalypt/whitelist.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
require 'bcrypt'
|
3
|
-
require_relative 'exceptions'
|
4
|
-
module Eucalypt
|
5
|
-
class Whitelist
|
6
|
-
def initialize(file)
|
7
|
-
@file = file
|
8
|
-
File.new(file, "a").close
|
9
|
-
add '::1', '127.0.0.1', '0.0.0.0'
|
10
|
-
end
|
11
|
-
|
12
|
-
def add(*to_add)
|
13
|
-
to_add.flatten.each do |ip|
|
14
|
-
next if include? ip
|
15
|
-
File.open(@file, 'a+') do |f|
|
16
|
-
lines = File.readlines(@file)
|
17
|
-
if lines.empty? || lines.all? {|line| line == "\n"}
|
18
|
-
File.open(@file, 'w') do |f1|
|
19
|
-
f1.write "#{BCrypt::Password.create(ip)}\n"
|
20
|
-
end
|
21
|
-
else
|
22
|
-
prefix = f.read.last == "\n" ? '' : "\n"
|
23
|
-
f.puts prefix + BCrypt::Password.create(ip)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def remove(*to_remove)
|
30
|
-
whitelist = []
|
31
|
-
hashed = File.readlines(@file).select{|ip| /\$.*/.match ip}.map(&:strip)
|
32
|
-
|
33
|
-
hashed.each do |ip|
|
34
|
-
if to_remove.flatten.any? {|request| BCrypt::Password.new(ip) == request}
|
35
|
-
next
|
36
|
-
else
|
37
|
-
whitelist << ip unless whitelist.include?(ip)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
File.open(@file, 'w') {|f| f.write whitelist*("\n")<<"\n"}
|
42
|
-
end
|
43
|
-
|
44
|
-
def ips()
|
45
|
-
File.readlines(@file).map(&:strip).
|
46
|
-
select{|ip| /\$.*/.match ip}.
|
47
|
-
map {|ip| BCrypt::Password.new ip}
|
48
|
-
end
|
49
|
-
|
50
|
-
def include?(ip)
|
51
|
-
ips.any? {|whitelisted| whitelisted == ip}
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
class ApplicationController < Sinatra::Base
|
57
|
-
helpers do
|
58
|
-
def whitelisted?
|
59
|
-
case settings.whitelist
|
60
|
-
when Eucalypt::Whitelist then settings.whitelist.include?(request.ip)
|
61
|
-
when FalseClass then true
|
62
|
-
else raise Eucalypt::InvalidSettingTypeError.new(:whitelist, settings.whitelist.class, %w[FalseClass Eucalypt::Whitelist])
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def ip_check()
|
67
|
-
raise Eucalypt::NotWhitelistedError.new(request.ip) unless whitelisted?
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|