roda-project 0.1.11 → 0.1.12
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/lib/roda/project/bin/generators/migration.rb +1 -1
- data/lib/roda/project/bin/generators/model.rb +2 -2
- data/lib/roda/project/bin/generators/routes.rb +25 -9
- data/lib/roda/project/cli.rb +11 -5
- data/lib/roda/project/generator.rb +2 -2
- data/lib/roda/project/jeremy_template_creator.rb +33 -0
- data/lib/roda/project/main_context.rb +2 -2
- data/lib/roda/project/templates/base/app/app.rb.erb +1 -1
- data/lib/roda/project/templates/base/scaffold/app/config/config.rb.erb +14 -1
- data/lib/roda/project/version.rb +1 -1
- data/lib/roda/project.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ba772c511bc001bfa35bf4345638652b7291dd2e144003922fa85880e7dc03f3
|
|
4
|
+
data.tar.gz: be9c85ed58652607a5614d7f37d0878085f7834f257cd2053d766d067fd71a44
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 63ef03a38f04ae88bda73eb7d890c3d80fda95521695a4e7ad6f19bd30a84630bff9f4daa4b7a8d08818fe77a235241bcb60f48e58e060646b2cd8c3dad62fd0
|
|
7
|
+
data.tar.gz: 9737a1545992102d0e82c5563cc0a29ae6c0c15d6b24bf07f16f493f5421b043b77be2b15ca2894157358f89b077e9cc9e7f42f84ed114fb9e59d8da0c92be38
|
|
@@ -22,7 +22,7 @@ class Roda
|
|
|
22
22
|
filename = File.join("spec/app/models", *name_segments[0..-2], "#{model_file_basename}_spec.rb")
|
|
23
23
|
File.write(filename, spec_code)
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
action_success_message(filename)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def create_model
|
|
@@ -30,7 +30,7 @@ class Roda
|
|
|
30
30
|
filename = File.join("app/models", *name_segments[0..-2], "#{model_file_basename}.rb")
|
|
31
31
|
File.write(filename, code)
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
action_success_message(filename)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def spec_code
|
|
@@ -23,8 +23,15 @@ class Roda
|
|
|
23
23
|
filename = File.join(ensure_and_get_path("app/routes", branch_name), "#{branch_name}.rb")
|
|
24
24
|
route_definitions = routes_list.map do |route_str|
|
|
25
25
|
method, name = parse_route_string(route_str)
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
view_name = name
|
|
27
|
+
view_name = "index" if view_name == ""
|
|
28
|
+
view_line = (method == "get" && must_generate_views?) ? "\n view('#{view_name}')" : ""
|
|
29
|
+
|
|
30
|
+
if name != ""
|
|
31
|
+
" r.#{method} \"#{name}\" do#{view_line}\n end"
|
|
32
|
+
else
|
|
33
|
+
" r.#{method} do#{view_line}\n end"
|
|
34
|
+
end
|
|
28
35
|
end.join("\n\n")
|
|
29
36
|
|
|
30
37
|
hash_branch_header = if branch_name.include?("/")
|
|
@@ -45,7 +52,7 @@ class Roda
|
|
|
45
52
|
end
|
|
46
53
|
RUBY
|
|
47
54
|
File.write(filename, content)
|
|
48
|
-
|
|
55
|
+
action_success_message(filename)
|
|
49
56
|
end
|
|
50
57
|
|
|
51
58
|
def generate_views
|
|
@@ -55,9 +62,10 @@ class Roda
|
|
|
55
62
|
routes_list.each do |route_str|
|
|
56
63
|
method, name = parse_route_string(route_str)
|
|
57
64
|
if method == "get"
|
|
65
|
+
name = "index" if name == ""
|
|
58
66
|
view_filename = File.join(branch_views_dir, "#{name}.erb")
|
|
59
67
|
File.write(view_filename, "")
|
|
60
|
-
|
|
68
|
+
action_success_message(view_filename)
|
|
61
69
|
end
|
|
62
70
|
end
|
|
63
71
|
end
|
|
@@ -70,10 +78,18 @@ class Roda
|
|
|
70
78
|
|
|
71
79
|
test_route_definitions = routes_list.map do |route_str|
|
|
72
80
|
method, name = parse_route_string(route_str)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
81
|
+
|
|
82
|
+
if name != ""
|
|
83
|
+
" it \"responds to #{method.upcase} /#{branch_name}/#{name}\" do\n" \
|
|
84
|
+
" #{method} \"/#{branch_name}/#{name}\"\n" \
|
|
85
|
+
" expect(last_response.status).to eq(200)\n" \
|
|
86
|
+
" end"
|
|
87
|
+
else
|
|
88
|
+
" it \"responds to #{method.upcase} /#{branch_name} do\n" \
|
|
89
|
+
" #{method} \"/#{branch_name}\n" \
|
|
90
|
+
" expect(last_response.status).to eq(200)\n" \
|
|
91
|
+
" end"
|
|
92
|
+
end
|
|
77
93
|
end.join("\n")
|
|
78
94
|
|
|
79
95
|
test_content = <<~RUBY
|
|
@@ -84,7 +100,7 @@ class Roda
|
|
|
84
100
|
end
|
|
85
101
|
RUBY
|
|
86
102
|
File.write(test_filename, test_content)
|
|
87
|
-
|
|
103
|
+
action_success_message(test_filename)
|
|
88
104
|
end
|
|
89
105
|
|
|
90
106
|
def must_generate_views?
|
data/lib/roda/project/cli.rb
CHANGED
|
@@ -10,8 +10,8 @@ class Roda
|
|
|
10
10
|
puts pastel.italic("#{Roda::Project.messages.sample.first}\n")
|
|
11
11
|
|
|
12
12
|
get_user_context
|
|
13
|
-
|
|
14
13
|
puts pastel.bright_black("\n[project: #{@context.project_name}]\n")
|
|
14
|
+
return JeremyTemplateCreator.new(context: @context).call if jeremy?
|
|
15
15
|
|
|
16
16
|
create_base_project
|
|
17
17
|
add_front_end
|
|
@@ -44,6 +44,8 @@ class Roda
|
|
|
44
44
|
|
|
45
45
|
def get_user_context
|
|
46
46
|
retry_on_error { @context.project_name = read_line("Project name › ", "project") }
|
|
47
|
+
return if jeremy?
|
|
48
|
+
|
|
47
49
|
retry_on_error { @context.base = read_line("(#{fullstack_id}) Fullstack (#{api_id}) API (#{minimal_id}) Minimal › ", fullstack_id).to_i }
|
|
48
50
|
retry_on_error { @context.tests = read_line("(#{rspec_id}) RSpec (#{minitest_id}) Minitest › ", rspec_id).to_i }
|
|
49
51
|
|
|
@@ -63,6 +65,10 @@ class Roda
|
|
|
63
65
|
end
|
|
64
66
|
end
|
|
65
67
|
|
|
68
|
+
def jeremy?
|
|
69
|
+
@jeremy ||= ARGV[0] == "--jeremy"
|
|
70
|
+
end
|
|
71
|
+
|
|
66
72
|
def create_base_project
|
|
67
73
|
puts "* creating base project"
|
|
68
74
|
if @context.minimal?
|
|
@@ -97,11 +103,11 @@ class Roda
|
|
|
97
103
|
erb_cp_file("front-end", "esbuild.js")
|
|
98
104
|
erb_cp_file("front-end", "package.json")
|
|
99
105
|
cp_dir("front-end", "app/views")
|
|
100
|
-
|
|
106
|
+
action_success_message("app/views")
|
|
101
107
|
cp_dir("front-end", "public/assets")
|
|
102
|
-
|
|
108
|
+
action_success_message("public/assets")
|
|
103
109
|
cp_dir("front-end", "public/images")
|
|
104
|
-
|
|
110
|
+
action_success_message("public/images")
|
|
105
111
|
end
|
|
106
112
|
end
|
|
107
113
|
|
|
@@ -121,7 +127,7 @@ class Roda
|
|
|
121
127
|
erb_cp_file("rodauth", "db/migrations/001_add_rodauth.rb")
|
|
122
128
|
if @context.fullstack?
|
|
123
129
|
cp_file("rodauth", "app/views/create-account.erb")
|
|
124
|
-
|
|
130
|
+
action_success_message("app/views/create-account.erb")
|
|
125
131
|
end
|
|
126
132
|
end
|
|
127
133
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
class Roda
|
|
4
|
+
module Project
|
|
5
|
+
class JeremyTemplateCreator < Generator
|
|
6
|
+
include Helpers::Inflections
|
|
7
|
+
|
|
8
|
+
def call
|
|
9
|
+
repo_url = "https://github.com/jeremyevans/roda-sequel-stack"
|
|
10
|
+
puts "* Downloading template with git...\n\n"
|
|
11
|
+
|
|
12
|
+
success = system("git clone --depth 1 #{repo_url} #{@context.project_name}")
|
|
13
|
+
abort("\nCould not download the template.") unless success
|
|
14
|
+
|
|
15
|
+
git_dir = File.join(@context.project_name, '.git')
|
|
16
|
+
if Dir.exist?(git_dir)
|
|
17
|
+
FileUtils.rm_rf(git_dir)
|
|
18
|
+
puts "\n* Cleaned up template git history.\n\n"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
action_success_message("./#{@context.project_name}")
|
|
22
|
+
|
|
23
|
+
setup_command = "cd #{@context.project_name} && rake setup[#{camelize(@context.project_name)}]"
|
|
24
|
+
system(setup_command)
|
|
25
|
+
|
|
26
|
+
action_success_message(setup_command, "run")
|
|
27
|
+
puts "\n Setup is done! follow the link below to learn about this template:"
|
|
28
|
+
puts "\n #{repo}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
@@ -23,9 +23,9 @@ class Roda
|
|
|
23
23
|
option :main_context, type: :hash, default: {
|
|
24
24
|
project_name: "#{project_name}",
|
|
25
25
|
base: #{id_to_string(base, :base)},
|
|
26
|
-
rodauth: #{rodauth},
|
|
26
|
+
rodauth: #{rodauth || false},
|
|
27
27
|
tests: #{id_to_string(tests, :tests)},
|
|
28
|
-
database: #{database},
|
|
28
|
+
database: #{database || false},
|
|
29
29
|
RUBY
|
|
30
30
|
if database?
|
|
31
31
|
option << " database_type: #{id_to_string(database_type, :database)},"
|
|
@@ -8,7 +8,7 @@ class <%= context.const_project_name %> < Roda
|
|
|
8
8
|
<% if context.fullstack? %>
|
|
9
9
|
# Views
|
|
10
10
|
plugin :partials, views: "app/views"
|
|
11
|
-
plugin :render,
|
|
11
|
+
plugin :render, **Config.get[:render]
|
|
12
12
|
plugin :content_for, append: false
|
|
13
13
|
plugin :flash
|
|
14
14
|
plugin :assets_manifest
|
|
@@ -12,7 +12,20 @@ module Config
|
|
|
12
12
|
}<% end %><% if context.database? %>,
|
|
13
13
|
db: {
|
|
14
14
|
url: not_production? ? <%= context.default_db_url %> : ENV["DATABASE_URL"]
|
|
15
|
-
}<% end
|
|
15
|
+
}<% end %><% if context.fullstack? %>,
|
|
16
|
+
render: {
|
|
17
|
+
layout: "./layout",
|
|
18
|
+
assume_fixed_locals: true, # Optimize plugin by assuming all templates use fixed locals
|
|
19
|
+
template_opts: {
|
|
20
|
+
scope_class: self, # Always uses current class as scope class for compiled templates
|
|
21
|
+
freeze: true, # Freeze string literals in templates
|
|
22
|
+
extract_fixed_locals: true, # Support fixed locals in templates
|
|
23
|
+
default_fixed_locals: '()', # Default to templates not supporting local variables
|
|
24
|
+
escape: true, # For Erubi templates, escapes %= by default (use %== for unescaped
|
|
25
|
+
chain_appends: true, # For Erubi templates, improves performance
|
|
26
|
+
skip_compiled_encoding_detection: true, # Unless you need encodings explicitly specified
|
|
27
|
+
}<% end %>
|
|
28
|
+
}
|
|
16
29
|
}
|
|
17
30
|
end
|
|
18
31
|
|
data/lib/roda/project/version.rb
CHANGED
data/lib/roda/project.rb
CHANGED
|
@@ -59,6 +59,7 @@ require_relative "project/helpers/inflections"
|
|
|
59
59
|
# Base
|
|
60
60
|
require_relative "project/main_context"
|
|
61
61
|
require_relative "project/generator"
|
|
62
|
+
require_relative "project/jeremy_template_creator"
|
|
62
63
|
require_relative "project/cli"
|
|
63
64
|
require_relative "project/bin/generator"
|
|
64
65
|
# Generators/migration
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: roda-project
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Henrique F. Teixeira
|
|
@@ -91,6 +91,7 @@ files:
|
|
|
91
91
|
- lib/roda/project/helpers/inflections.rb
|
|
92
92
|
- lib/roda/project/helpers/interactive_input.rb
|
|
93
93
|
- lib/roda/project/helpers/template.rb
|
|
94
|
+
- lib/roda/project/jeremy_template_creator.rb
|
|
94
95
|
- lib/roda/project/main_context.rb
|
|
95
96
|
- lib/roda/project/templates/base/app/app.rb.erb
|
|
96
97
|
- lib/roda/project/templates/base/minimal/AGENTS.md
|