roda-project 0.1.3 → 0.1.5
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/context.rb +3 -1
- data/lib/roda/project/version.rb +1 -1
- data/lib/roda/project.rb +1 -1
- data/lib/roda/templates/base/minimal/app.rb +1 -1
- data/lib/roda/templates/base/minimal/config.ru +1 -1
- data/lib/roda/templates/base/scaffold/Rakefile.erb +5 -5
- data/lib/roda/templates/base/scaffold/app/config/config.rb.erb +12 -2
- data/lib/roda/templates/front-end/app/views/html.rb +16 -0
- data/lib/roda/templates/front-end/app/views/layout.erb +3 -1
- data/lib/roda/templates/front-end/esbuild.js +24 -17
- data/lib/roda/templates/front-end/package.json +1 -0
- metadata +3 -3
- /data/lib/roda/templates/base/scaffold/public/{css → assets}/app.css +0 -0
- /data/lib/roda/templates/base/scaffold/public/{js → assets}/app.js +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aeff4fdaddf4c0b61eb4fe2f5f2f89b025897eda318d92ecf1a786ee9ff110d1
|
|
4
|
+
data.tar.gz: 50891c013749f5b94378d1259834d5b6c8dafb7bc92ec3092aef74b5ac24080f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9bc4575aeb9625e2728ef01c6b5ce699c3b8d1c86a55936e75c5bf2a76105a6b91eaafbd2bca11c47118bd57ae30145b83e7ffda4e17099d09d1ea993f802211
|
|
7
|
+
data.tar.gz: b57e42ba6d7e0c9867801bf52ddb25b341914b0d575761f23a6190ff12b36660ad9db8afb78535847b83ee06496ff78cce8ed422b0f4879e96e52c95371a8dab
|
data/lib/roda/project/context.rb
CHANGED
|
@@ -45,6 +45,7 @@ module Roda
|
|
|
45
45
|
@database = val
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
+
# rubocop:disable Lint/InterpolationCheck
|
|
48
49
|
def database_type=(val)
|
|
49
50
|
if ![mysql_id, postgresql_id, sqlite_id].include?(val)
|
|
50
51
|
raise InvalidValue, "Invalid database option"
|
|
@@ -63,6 +64,7 @@ module Roda
|
|
|
63
64
|
@db_gem = "sqlite3"
|
|
64
65
|
end
|
|
65
66
|
end
|
|
67
|
+
# rubocop:enable Lint/InterpolationCheck
|
|
66
68
|
|
|
67
69
|
def project_name=(val)
|
|
68
70
|
if !(val =~ VALID_PROJECT_NAME_REGEX)
|
|
@@ -133,7 +135,7 @@ module Roda
|
|
|
133
135
|
end
|
|
134
136
|
|
|
135
137
|
def const_project_name
|
|
136
|
-
@const_project_name ||= project_name.split(
|
|
138
|
+
@const_project_name ||= project_name.split("_").map(&:capitalize).join
|
|
137
139
|
end
|
|
138
140
|
end
|
|
139
141
|
end
|
data/lib/roda/project/version.rb
CHANGED
data/lib/roda/project.rb
CHANGED
|
@@ -50,7 +50,7 @@ module Roda
|
|
|
50
50
|
['"Start where you are. Use what you have. Do what you can." - Arthur Ashe'],
|
|
51
51
|
['"A goal is a dream with a deadline." - Napoleon Hill'],
|
|
52
52
|
['"Things do not happen. Things are made to happen." - John F. Kennedy'],
|
|
53
|
-
['"Quality is not an act, it is a habit." - Aristotle']
|
|
53
|
+
['"Quality is not an act, it is a habit." - Aristotle']
|
|
54
54
|
]
|
|
55
55
|
end
|
|
56
56
|
end
|
|
@@ -137,7 +137,7 @@ namespace :g do<% if context.database? %>
|
|
|
137
137
|
exit 1
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
-
must_generate_views = Dir.exist?(File.expand_path("
|
|
140
|
+
must_generate_views = Dir.exist?(File.expand_path("./app/views", __dir__))
|
|
141
141
|
ensure_and_get_path = proc do |path|
|
|
142
142
|
base_path = File.expand_path(path, __dir__)
|
|
143
143
|
full_path_dir = File.join(base_path, File.dirname(branch_name))
|
|
@@ -145,14 +145,14 @@ namespace :g do<% if context.database? %>
|
|
|
145
145
|
|
|
146
146
|
base_path
|
|
147
147
|
end
|
|
148
|
-
parse_route_string = proc do
|
|
148
|
+
parse_route_string = proc do |route_str|
|
|
149
149
|
name, method = route_str.split(":", 2)
|
|
150
150
|
method ||= "get"
|
|
151
151
|
[method, name]
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
# Generate routes
|
|
155
|
-
filename = File.join(ensure_and_get_path.call("
|
|
155
|
+
filename = File.join(ensure_and_get_path.call("./app/routes"), "#{branch_name}.rb")
|
|
156
156
|
route_definitions = routes_list.map do |route_str|
|
|
157
157
|
method, name = parse_route_string.call(route_str)
|
|
158
158
|
view_line = (method == "get" && must_generate_views) ? "\n view('#{name}')" : ""
|
|
@@ -171,7 +171,7 @@ namespace :g do<% if context.database? %>
|
|
|
171
171
|
|
|
172
172
|
# Generate views
|
|
173
173
|
if must_generate_views
|
|
174
|
-
branch_views_dir = File.join(File.expand_path("
|
|
174
|
+
branch_views_dir = File.join(File.expand_path("./app/views", __dir__), branch_name)
|
|
175
175
|
FileUtils.mkdir_p(branch_views_dir)
|
|
176
176
|
routes_list.each do |route_str|
|
|
177
177
|
method, name = parse_route_string.call(route_str)
|
|
@@ -184,7 +184,7 @@ namespace :g do<% if context.database? %>
|
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
# Generate tests
|
|
187
|
-
test_filename = File.join(ensure_and_get_path.call("
|
|
187
|
+
test_filename = File.join(ensure_and_get_path.call("./spec/app/routes"), "#{branch_name}_spec.rb")
|
|
188
188
|
nesting_level = branch_name.count("/")
|
|
189
189
|
relative_spec_helper_path = "../" * (2 + nesting_level) + "spec_helper"
|
|
190
190
|
|
|
@@ -9,15 +9,25 @@ module Config
|
|
|
9
9
|
i18n: {
|
|
10
10
|
translations: ["app/config/locales", "app/config/locales/foo"],
|
|
11
11
|
locale: ["en", "pt-br"]
|
|
12
|
-
}
|
|
12
|
+
}<% if context.database? %>,
|
|
13
13
|
db: {
|
|
14
14
|
url: not_production? ? <%= context.dev_db_url %> : ENV["DATABASE_URL"]
|
|
15
|
+
}<% end %><% if context.fullstack? %>,
|
|
16
|
+
assets: {
|
|
17
|
+
host: '/public/assets',
|
|
18
|
+
manifest:
|
|
15
19
|
}<% end %>
|
|
16
20
|
}
|
|
17
21
|
end
|
|
18
22
|
|
|
19
|
-
def not_production? = environment != "production"
|
|
23
|
+
def not_production? = environment != "production"<% if context.fullstack? %>
|
|
24
|
+
def manifest
|
|
25
|
+
manifest_path = File.expand_path("../../public/assets/manifest.json", __dir__)
|
|
26
|
+
return JSON.parse(File.read(manifest_path)) if File.exist?(manifest_path)
|
|
20
27
|
|
|
28
|
+
{}
|
|
29
|
+
end
|
|
30
|
+
<% end %>
|
|
21
31
|
def environment
|
|
22
32
|
ENV["RACK_ENV"] || "development"
|
|
23
33
|
end
|
|
@@ -10,6 +10,22 @@ module Views
|
|
|
10
10
|
@foo = Views::Foo::Html.new
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
def js_entrypoint_tag(entrypoint)
|
|
14
|
+
if Config.not_production?
|
|
15
|
+
"<script src=\"/public/assets/#{entrypoint}.js\" defer></script>"
|
|
16
|
+
else
|
|
17
|
+
"<script src=\"#{Config.get[:assets][:host]}/#{Config.get[:assets][:manifest]["#{entrypoint}.js"]}\" defer></script>"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def css_entrypoint_tag(entrypoint)
|
|
22
|
+
if Config.not_production?
|
|
23
|
+
"<link rel=\"stylesheet\" href=\"/public/assets/#{entrypoint}.css\" />"
|
|
24
|
+
else
|
|
25
|
+
"<link rel=\"stylesheet\" href=\"#{Config.get[:assets][:host]}/#{Config.get[:assets][:manifest]["#{entrypoint}.css"]}\" />"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
13
29
|
def navbar
|
|
14
30
|
html_slice do
|
|
15
31
|
div class: "navbar" do
|
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
const esbuild = require('esbuild');
|
|
2
|
-
|
|
2
|
+
const manifestPlugin = require('esbuild-plugin-manifest');
|
|
3
3
|
const isWatchMode = process.argv.includes('--watch');
|
|
4
|
+
const isProduction = process.env.RACK_ENV === 'production';
|
|
5
|
+
|
|
6
|
+
const cssEntryPoints = ['app']
|
|
7
|
+
const jsEntryPoints = ['app']
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
function config() {
|
|
10
|
+
const assetsEntryPoints =
|
|
11
|
+
cssEntryPoints.map((e) => `css/${e}.css`)
|
|
12
|
+
.concat(
|
|
13
|
+
jsEntryPoints.map((e) => `js/${e}.js`)
|
|
14
|
+
)
|
|
9
15
|
|
|
10
|
-
function configFor(name) {
|
|
11
16
|
return {
|
|
12
|
-
entryPoints:
|
|
17
|
+
entryPoints: assetsEntryPoints.map((name) => `app/assets/${name}`),
|
|
13
18
|
bundle: true,
|
|
14
|
-
minify:
|
|
15
|
-
|
|
19
|
+
minify: isProduction,
|
|
20
|
+
outdir: "public/assets",
|
|
21
|
+
entryNames: isProduction ? '[name]-[hash]' : '[name]',
|
|
22
|
+
plugins: isProduction ? [
|
|
23
|
+
manifestPlugin({ shortNames: true })
|
|
24
|
+
] : [],
|
|
16
25
|
}
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
async function build() {
|
|
20
29
|
try {
|
|
21
30
|
if (isWatchMode) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
console.log(`Watching for css and js changes in '${entrypoints.join(', ')}'...`);
|
|
31
|
+
const ctx = await esbuild.context(config());
|
|
32
|
+
await ctx.watch();
|
|
33
|
+
|
|
34
|
+
console.log(`Watching for css and js changes in '${assetsEntryPoints.join(', ')}'...`);
|
|
27
35
|
} else {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
})
|
|
36
|
+
await esbuild.build(config());
|
|
37
|
+
|
|
31
38
|
console.log(`Build complete.`);
|
|
32
39
|
}
|
|
33
40
|
} catch (error) {
|
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.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Henrique F. Teixeira
|
|
@@ -95,10 +95,10 @@ files:
|
|
|
95
95
|
- lib/roda/templates/base/scaffold/app/routes/foo.rb.erb
|
|
96
96
|
- lib/roda/templates/base/scaffold/boot.rb.erb
|
|
97
97
|
- lib/roda/templates/base/scaffold/config.ru.erb
|
|
98
|
-
- lib/roda/templates/base/scaffold/public/
|
|
98
|
+
- lib/roda/templates/base/scaffold/public/assets/app.css
|
|
99
|
+
- lib/roda/templates/base/scaffold/public/assets/app.js
|
|
99
100
|
- lib/roda/templates/base/scaffold/public/exception_page.css
|
|
100
101
|
- lib/roda/templates/base/scaffold/public/images/roda-project.png
|
|
101
|
-
- lib/roda/templates/base/scaffold/public/js/app.js
|
|
102
102
|
- lib/roda/templates/database/app/config/providers/db/conn.rb
|
|
103
103
|
- lib/roda/templates/database/db/seeds.rb
|
|
104
104
|
- lib/roda/templates/front-end/app/assets/css/app.css
|
|
File without changes
|
|
File without changes
|