roda-project 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aeff4fdaddf4c0b61eb4fe2f5f2f89b025897eda318d92ecf1a786ee9ff110d1
4
- data.tar.gz: 50891c013749f5b94378d1259834d5b6c8dafb7bc92ec3092aef74b5ac24080f
3
+ metadata.gz: a0848c0ffefb79c9a29e0f914ade9409ed3da6f94523afa9fd686647eb49c401
4
+ data.tar.gz: 9a100a0a6781bdd0c9d0a005f473db621f4f28749e95523186bddf338b0acd10
5
5
  SHA512:
6
- metadata.gz: 9bc4575aeb9625e2728ef01c6b5ce699c3b8d1c86a55936e75c5bf2a76105a6b91eaafbd2bca11c47118bd57ae30145b83e7ffda4e17099d09d1ea993f802211
7
- data.tar.gz: b57e42ba6d7e0c9867801bf52ddb25b341914b0d575761f23a6190ff12b36660ad9db8afb78535847b83ee06496ff78cce8ed422b0f4879e96e52c95371a8dab
6
+ metadata.gz: 883ecbdc87121a984469a003ab1f2350ef3aa998bdda14efb6443d151b9378adf56f0704b66eb40c8e9765d193a2b3fdce521fc3cae4b3faf0de0039a8822136
7
+ data.tar.gz: 06b3aeba438bb755926afff42b68a66303f42332c97fcb9bca23f96e47399a16cda090e42d6835837ee091bcefb135d6f5f2a6ba54d2070164616be113e4e3be
@@ -37,10 +37,10 @@ module Roda
37
37
  puts "$ rake db:migrate"
38
38
  end
39
39
  puts "\nrun and watch the project in dev mode:\n"
40
- puts "\n$ rake dev:watch"
40
+ puts "\n$ rake dev"
41
41
  if @context.fullstack?
42
42
  puts "\ncompile and watch assets:\n"
43
- puts "\n$ rake assets:watch"
43
+ puts "\n$ rake dev:assets"
44
44
  end
45
45
  puts "\nrun 'rake' inside #{@context.project_name} to see all available tasks\n\n"
46
46
  rescue TTY::Reader::InputInterrupt
@@ -106,18 +106,21 @@ module Roda
106
106
  def add_front_end
107
107
  if @context.fullstack?
108
108
  puts "* adding front-end"
109
- tty_cp_r("front-end", "app/assets")
110
- tty_cp("front-end", "esbuild.js")
111
- tty_cp("front-end", "package.json")
112
- cp_r("front-end", "app/views")
109
+ erb_cp_dir("front-end", "app/assets")
110
+ erb_cp_file("front-end", "esbuild.js")
111
+ erb_cp_file("front-end", "package.json")
112
+ cp_dir("front-end", "app/views")
113
+ cp_dir("front-end", "app/views")
114
+ cp_dir("front-end", "public/assets")
115
+ cp_dir("front-end", "public/images")
113
116
  end
114
117
  end
115
118
 
116
119
  def add_database
117
120
  if @context.database?
118
121
  puts "* adding database"
119
- tty_cp_r("database", "db")
120
- tty_cp("database", "app/config/providers/db/conn.rb")
122
+ erb_cp_dir("database", "db")
123
+ erb_cp_file("database", "app/config/providers/db/conn.rb")
121
124
  add_rodauth
122
125
  end
123
126
  end
@@ -125,10 +128,10 @@ module Roda
125
128
  def add_rodauth
126
129
  if @context.rodauth?
127
130
  puts "* adding rodauth"
128
- tty_cp_r("rodauth", "app/models")
129
- tty_cp("rodauth", "db/migrations/001_add_rodauth.rb")
131
+ erb_cp_dir("rodauth", "app/models")
132
+ erb_cp_file("rodauth", "db/migrations/001_add_rodauth.rb")
130
133
  if @context.fullstack?
131
- cp("rodauth", "app/views/create-account.erb")
134
+ cp_file("rodauth", "app/views/create-account.erb")
132
135
  end
133
136
  end
134
137
  end
@@ -138,9 +141,9 @@ module Roda
138
141
  minimal_dir = @context.minimal? ? "minimal/" : ""
139
142
 
140
143
  if @context.rspec?
141
- tty_cp_r("tests/#{minimal_dir}rspec", "spec")
144
+ erb_cp_dir("tests/#{minimal_dir}rspec", "spec")
142
145
  else
143
- tty_cp_r("tests/#{minimal_dir}minitest", "spec")
146
+ erb_cp_dir("tests/#{minimal_dir}minitest", "spec")
144
147
  end
145
148
  end
146
149
  end
@@ -2,7 +2,7 @@ module Roda
2
2
  module Project
3
3
  module Helpers
4
4
  module Template
5
- def tty_cp_r(type, path)
5
+ def erb_cp_dir(type, path)
6
6
  TTY::File.copy_directory(
7
7
  File.expand_path("../../templates/#{type}/#{path}", __dir__),
8
8
  "#{@dir}#{@context.project_name}/#{path}",
@@ -10,7 +10,7 @@ module Roda
10
10
  )
11
11
  end
12
12
 
13
- def tty_cp(type, path)
13
+ def erb_cp_file(type, path)
14
14
  TTY::File.copy_file(
15
15
  File.expand_path("../../templates/#{type}/#{path}", __dir__),
16
16
  "#{@dir}#{@context.project_name}/#{path}",
@@ -19,7 +19,7 @@ module Roda
19
19
  end
20
20
 
21
21
  # For copy without parse ERB files
22
- def cp_r(type, path)
22
+ def cp_dir(type, path)
23
23
  FileUtils.cp_r(
24
24
  File.expand_path("../../templates/#{type}/#{path}", __dir__),
25
25
  "#{@dir}#{@context.project_name}/#{path}"
@@ -27,7 +27,7 @@ module Roda
27
27
  end
28
28
 
29
29
  # For copy without parse ERB files
30
- def cp(type, path)
30
+ def cp_file(type, path)
31
31
  File.write(
32
32
  "#{@dir}#{@context.project_name}/#{path}",
33
33
  File.read(File.expand_path("../../templates/#{type}/#{path}", __dir__))
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Roda
4
4
  module Project
5
- VERSION = "0.1.5"
5
+ VERSION = "0.1.6"
6
6
  end
7
7
  end
@@ -16,9 +16,6 @@ gem "puma"
16
16
  gem "oj"
17
17
  # gem 'async'
18
18
 
19
- # CLI
20
- gem "rake"
21
-
22
19
  # Security
23
20
  # gem "rack-attack"
24
21
 
@@ -33,6 +30,7 @@ group :development do
33
30
  gem "standard"<% if context.minitest? %>
34
31
  gem "minitest"
35
32
  gem "minitest-hooks"
33
+ gem "rake"
36
34
  <% else %>
37
35
  gem "rspec"<% end %>
38
36
  end
@@ -2,59 +2,50 @@
2
2
 
3
3
  require "fileutils"
4
4
 
5
- # List rake tasks
6
5
  task :default do
7
6
  system("rake -T")
8
7
  end
9
8
 
10
- # Console Task
11
9
  desc "Open a console with application context (alias: rake c)"
12
10
  task :console do
13
11
  system("irb -r ./boot.rb")
14
12
  end
15
13
  task c: :console
16
14
 
17
- # Lint Task
18
15
  desc "Run lint"
19
16
  task :lint do
20
17
  system("bundle exec standardrb")
21
18
  end
22
19
 
23
- # Lint Fix Task
24
20
  desc "Auto fix lint warnings"
25
21
  task "lint:fix" do
26
22
  system("bundle exec standardrb --fix")
27
23
  end
28
24
 
29
- # Test Task
30
25
  desc "Run tests"
31
26
  task :test do<% if context.rspec? %>
32
27
  system("RACK_ENV=test bundle exec rspec")<% else %>
33
28
  system("RACK_ENV=test bundle exec minitest spec/")<% end %>
34
29
  end
35
30
 
36
- # Development Server Task
37
31
  desc "Exec development server"
38
- task :dev do
39
- system("RACK_ENV=development bundle exec puma --port 4000")
32
+ task :server do
33
+ if ENV["RACK_ENV"] == "production"<% if context.database? %>
34
+ if ENV["DATABASE_URL"].nil?
35
+ puts("DATABASE_URL is empty")
36
+ exit 1
37
+ end<% end %>
38
+ if ENV["SESSION_SECRET"].nil?
39
+ puts("SESSION_SECRET is empty")
40
+ exit 1
41
+ end
42
+ system("RUBYOPT=--yjit RUBY_YJIT_ENABLE=1 RACK_ENV=production bundle exec puma --port 4000")
43
+ else
44
+ system("RACK_ENV=development bundle exec puma --port 4000")
45
+ end
40
46
  end
41
47
 
42
- # Development Watch Task
43
48
  desc "Exec development server watching for changes"
44
- task "dev:watch" do
49
+ task "dev" do
45
50
  system("RACK_ENV=development bundle exec guard")
46
51
  end
47
-
48
- # Production Server Task
49
- desc "Exec production server"
50
- task :prod do
51
- if ENV["DATABASE_URL"].nil?
52
- puts("DATABASE_URL is empty")
53
- exit 1
54
- end
55
- if ENV["SESSION_SECRET"].nil?
56
- puts("SESSION_SECRET is empty")
57
- exit 1
58
- end
59
- system("RUBYOPT=--yjit RUBY_YJIT_ENABLE=1 RACK_ENV=production bundle exec puma --port 4000")
60
- end
@@ -25,9 +25,6 @@ gem "puma"
25
25
  gem "oj"
26
26
  # gem 'async'
27
27
 
28
- # CLI
29
- gem "rake"
30
-
31
28
  # Security
32
29
  # gem "rack-attack"
33
30
 
@@ -47,6 +44,7 @@ group :development do
47
44
  gem "standard"<% if context.minitest? %>
48
45
  gem "minitest"
49
46
  gem "minitest-hooks"
47
+ gem "rake"
50
48
  <% else %>
51
49
  gem "rspec"<% end %>
52
50
  end
@@ -2,12 +2,10 @@
2
2
 
3
3
  require "fileutils"
4
4
 
5
- # List rake tasks
6
5
  task :default do
7
6
  system("rake -T")
8
7
  end
9
8
  <% if context.database? %>
10
- # DB Migrate Task
11
9
  namespace :db do
12
10
  desc "Migrate the database. Optional: provide target version, e.g., 'rake db:migrate[123]'"
13
11
  task :migrate, [:target] do |t, args|
@@ -26,57 +24,61 @@ namespace :db do
26
24
  end
27
25
  end
28
26
  <% end %>
29
- # Console Task
30
27
  desc "Open a console with application context (alias: rake c)"
31
28
  task :console do
32
29
  system("irb -r ./boot.rb")
33
30
  end
34
31
  task c: :console
35
32
 
36
- # Lint Task
37
33
  desc "Run lint"
38
34
  task :lint do
39
35
  system("bundle exec standardrb")
40
36
  end
41
37
 
42
- # Lint Fix Task
43
38
  desc "Auto fix lint warnings"
44
39
  task "lint:fix" do
45
40
  system("bundle exec standardrb --fix")
46
41
  end
47
42
 
48
- # Test Task
49
43
  desc "Run tests"
50
44
  task :test do<% if context.rspec? %>
51
45
  system("RACK_ENV=test bundle exec rspec")<% else %>
52
46
  system("RACK_ENV=test bundle exec minitest spec/")<% end %>
53
47
  end
54
48
 
55
- # Development Server Task
56
49
  desc "Exec development server"
57
- task :dev do
58
- system("RACK_ENV=development bundle exec puma --port 4000")
50
+ task :server do
51
+ if ENV["RACK_ENV"] == "production"<% if context.database? %>
52
+ if ENV["DATABASE_URL"].nil?
53
+ puts("DATABASE_URL is empty")
54
+ exit 1
55
+ end<% end %>
56
+ if ENV["SESSION_SECRET"].nil?
57
+ puts("SESSION_SECRET is empty")
58
+ exit 1
59
+ end
60
+ system("RUBYOPT=--yjit RUBY_YJIT_ENABLE=1 RACK_ENV=production bundle exec puma --port 4000")
61
+ else
62
+ system("RACK_ENV=development bundle exec puma --port 4000")
63
+ end
59
64
  end
60
65
 
61
- # Development Watch Task
62
66
  desc "Exec development server watching for changes"
63
- task "dev:watch" do
67
+ task "dev" do
64
68
  system("RACK_ENV=development bundle exec guard")
65
69
  end
66
-
67
- # Development Assets Task
68
- desc "Watch and compile assets"
70
+ <% if context.fullstack? %>
71
+ desc "Compile assets"
69
72
  task :assets do
70
73
  system("npm i && npm run build")
71
74
  end
72
75
 
73
- # Development Assets Task
74
76
  desc "Watch and compile assets"
75
- task "assets:watch" do
77
+ task "dev:assets" do
76
78
  system("npm i && npm run build:watch")
77
79
  end
80
+ <% end %>
78
81
 
79
- # Production Server Task
80
82
  desc "Exec production server"
81
83
  task :prod do
82
84
  if ENV["DATABASE_URL"].nil?
@@ -90,7 +92,6 @@ task :prod do
90
92
  system("RUBYOPT=--yjit RUBY_YJIT_ENABLE=1 RACK_ENV=production bundle exec puma --port 4000")
91
93
  end
92
94
 
93
- # Generate Tasks
94
95
  namespace :g do<% if context.database? %>
95
96
  desc "Generate an empty Sequel migration. Usage: 'rake generate:migration[migration_name]'"
96
97
  task :migration, [:migration_name] do |t, args|
@@ -3,13 +3,13 @@ module Config
3
3
  def get
4
4
  @config ||= {
5
5
  secret: ENV["SESSION_SECRET"] || 'DEV-ONLY-8<FQF8HiF)>l0hbPk£vBQ#IrYsoO}14k\l+-/gIU[j}l0hbPk£vBQ#IrY',
6
- environment:,
6
+ environment:,<% if context.rodauth? %>
7
7
  hmac_secret: ENV["RODAUTH_HMAC_SECRET"] || 'DEV-ONLY',
8
- jwt_secret: ENV["JWT_SECRET"] || 'DEV-ONLY',
8
+ jwt_secret: ENV["JWT_SECRET"] || 'DEV-ONLY',<% end %><% if context.fullstack? %>
9
9
  i18n: {
10
10
  translations: ["app/config/locales", "app/config/locales/foo"],
11
11
  locale: ["en", "pt-br"]
12
- }<% if context.database? %>,
12
+ }<% end %><% if context.database? %>,
13
13
  db: {
14
14
  url: not_production? ? <%= context.dev_db_url %> : ENV["DATABASE_URL"]
15
15
  }<% end %><% if context.fullstack? %>,
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.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique F. Teixeira
@@ -95,10 +95,7 @@ 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/assets/app.css
99
- - lib/roda/templates/base/scaffold/public/assets/app.js
100
98
  - lib/roda/templates/base/scaffold/public/exception_page.css
101
- - lib/roda/templates/base/scaffold/public/images/roda-project.png
102
99
  - lib/roda/templates/database/app/config/providers/db/conn.rb
103
100
  - lib/roda/templates/database/db/seeds.rb
104
101
  - lib/roda/templates/front-end/app/assets/css/app.css
@@ -111,6 +108,9 @@ files:
111
108
  - lib/roda/templates/front-end/app/views/layout.erb
112
109
  - lib/roda/templates/front-end/esbuild.js
113
110
  - lib/roda/templates/front-end/package.json
111
+ - lib/roda/templates/front-end/public/assets/app.css
112
+ - lib/roda/templates/front-end/public/assets/app.js
113
+ - lib/roda/templates/front-end/public/images/roda-project.png
114
114
  - lib/roda/templates/rodauth/app/models/account.rb
115
115
  - lib/roda/templates/rodauth/app/views/create-account.erb
116
116
  - lib/roda/templates/rodauth/db/migrations/001_add_rodauth.rb
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  requirements: []
152
- rubygems_version: 4.0.6
152
+ rubygems_version: 4.0.17
153
153
  specification_version: 4
154
154
  summary: A command-line interface (CLI) tool that helps you quickly scaffold new Roda
155
155
  web applications