roda-project 0.1.0

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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/bin/console +11 -0
  3. data/bin/roda-project +6 -0
  4. data/bin/roda-project.rb +9 -0
  5. data/bin/setup +8 -0
  6. data/lib/roda/project/cli.rb +134 -0
  7. data/lib/roda/project/context.rb +136 -0
  8. data/lib/roda/project/helpers/ids.rb +15 -0
  9. data/lib/roda/project/helpers/input.rb +20 -0
  10. data/lib/roda/project/helpers/template.rb +37 -0
  11. data/lib/roda/project/version.rb +7 -0
  12. data/lib/roda/project.rb +54 -0
  13. data/lib/roda/templates/base/app/app.rb.erb +87 -0
  14. data/lib/roda/templates/base/scaffold/AGENTS.md +9 -0
  15. data/lib/roda/templates/base/scaffold/Gemfile.erb +51 -0
  16. data/lib/roda/templates/base/scaffold/Guardfile +25 -0
  17. data/lib/roda/templates/base/scaffold/README.md +29 -0
  18. data/lib/roda/templates/base/scaffold/Rakefile.erb +209 -0
  19. data/lib/roda/templates/base/scaffold/app/config/config.rb.erb +25 -0
  20. data/lib/roda/templates/base/scaffold/app/config/locales/en.yml +273 -0
  21. data/lib/roda/templates/base/scaffold/app/config/locales/foo/en.yml +2 -0
  22. data/lib/roda/templates/base/scaffold/app/config/locales/foo/pt-br.yml +2 -0
  23. data/lib/roda/templates/base/scaffold/app/config/locales/pt-br.yml +244 -0
  24. data/lib/roda/templates/base/scaffold/app/config/providers/logger.rb +9 -0
  25. data/lib/roda/templates/base/scaffold/app/config/providers/mailer.rb +11 -0
  26. data/lib/roda/templates/base/scaffold/app/routes/foo.rb.erb +7 -0
  27. data/lib/roda/templates/base/scaffold/boot.rb.erb +35 -0
  28. data/lib/roda/templates/base/scaffold/config.ru.erb +13 -0
  29. data/lib/roda/templates/base/scaffold/public/css/app.css +1 -0
  30. data/lib/roda/templates/base/scaffold/public/exception_page.css +16 -0
  31. data/lib/roda/templates/base/scaffold/public/images/roda-project.png +0 -0
  32. data/lib/roda/templates/base/scaffold/public/js/app.js +27 -0
  33. data/lib/roda/templates/database/app/config/providers/db/conn.rb +15 -0
  34. data/lib/roda/templates/database/db/seeds.rb +1 -0
  35. data/lib/roda/templates/front-end/app/assets/css/app.css +20 -0
  36. data/lib/roda/templates/front-end/app/assets/js/app.js +7 -0
  37. data/lib/roda/templates/front-end/app/assets/js/some/foo.js +5 -0
  38. data/lib/roda/templates/front-end/app/views/foo/bar.erb +1 -0
  39. data/lib/roda/templates/front-end/app/views/foo/html.rb +6 -0
  40. data/lib/roda/templates/front-end/app/views/html.rb +22 -0
  41. data/lib/roda/templates/front-end/app/views/index.erb +1 -0
  42. data/lib/roda/templates/front-end/app/views/layout.erb +13 -0
  43. data/lib/roda/templates/front-end/esbuild.js +39 -0
  44. data/lib/roda/templates/front-end/package.json +20 -0
  45. data/lib/roda/templates/rodauth/app/models/account.rb +2 -0
  46. data/lib/roda/templates/rodauth/app/views/create-account.erb +9 -0
  47. data/lib/roda/templates/rodauth/db/migrations/001_add_rodauth.rb +71 -0
  48. data/lib/roda/templates/tests/minitest/spec/app/app_spec.rb.erb +15 -0
  49. data/lib/roda/templates/tests/minitest/spec/app/routes/foo_spec.rb +8 -0
  50. data/lib/roda/templates/tests/minitest/spec/app/routes/test_branch_spec.rb +4 -0
  51. data/lib/roda/templates/tests/minitest/spec/app/views/html_spec.rb +0 -0
  52. data/lib/roda/templates/tests/minitest/spec/spec_helper.rb.erb +33 -0
  53. data/lib/roda/templates/tests/rspec/spec/app/app_spec.rb.erb +15 -0
  54. data/lib/roda/templates/tests/rspec/spec/app/routes/foo_spec.rb +8 -0
  55. data/lib/roda/templates/tests/rspec/spec/app/routes/test_branch_spec.rb +4 -0
  56. data/lib/roda/templates/tests/rspec/spec/app/views/html_spec.rb +0 -0
  57. data/lib/roda/templates/tests/rspec/spec/spec_helper.rb.erb +19 -0
  58. metadata +142 -0
@@ -0,0 +1,22 @@
1
+ module Views
2
+ class Html
3
+ include HtmlSlice
4
+
5
+ # for more component classes
6
+ attr_reader :foo
7
+
8
+ def initialize(t)
9
+ @t = t
10
+ @foo = Views::Foo::Html.new
11
+ end
12
+
13
+ def navbar
14
+ html_slice do
15
+ div class: "navbar" do
16
+ a "home", href: "/"
17
+ a "foo/bar", href: "/foo/bar"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1 @@
1
+ <%= t.hello.message %>
@@ -0,0 +1,13 @@
1
+ <html>
2
+ <head>
3
+ <meta charset='utf-8' />
4
+ <link rel="stylesheet" type="text/css" href="/public/css/app.css">
5
+ </head>
6
+ <body>
7
+ <img src='/public/images/roda-project.png' />
8
+ <br>
9
+ <%= html.navbar %>
10
+
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1,39 @@
1
+ const esbuild = require('esbuild');
2
+
3
+ const isWatchMode = process.argv.includes('--watch');
4
+
5
+ const entrypoints = [
6
+ 'js/app.js',
7
+ 'css/app.css'
8
+ ]
9
+
10
+ function configFor(name) {
11
+ return {
12
+ entryPoints: [`app/assets/${name}`],
13
+ bundle: true,
14
+ minify: true,
15
+ outfile: `public/${name}`,
16
+ }
17
+ }
18
+
19
+ async function build() {
20
+ try {
21
+ if (isWatchMode) {
22
+ entrypoints.forEach(async (entrypoint) => {
23
+ const jsCtx = await esbuild.context(configFor(entrypoint));
24
+ await jsCtx.watch();
25
+ })
26
+ console.log(`Watching for css and js changes in '${entrypoints.join(', ')}'...`);
27
+ } else {
28
+ entrypoints.forEach(async () => {
29
+ await esbuild.build(configFor(entrypoint));
30
+ })
31
+ console.log(`Build complete.`);
32
+ }
33
+ } catch (error) {
34
+ console.error('Build failed:', error);
35
+ process.exit(1);
36
+ }
37
+ }
38
+
39
+ build();
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "rackr_scaffold",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "esbuild.config.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "node esbuild.js",
9
+ "build:watch": "node esbuild.js --watch"
10
+ },
11
+ "author": "",
12
+ "license": "ISC",
13
+ "dependencies": {
14
+ "@hotwired/turbo": "^7.3.0"
15
+ },
16
+ "devDependencies": {
17
+ "esbuild": "^0.19.0",
18
+ "path": "^0.12.7"
19
+ }
20
+ }
@@ -0,0 +1,2 @@
1
+ class Account < Sequel::Model
2
+ end
@@ -0,0 +1,9 @@
1
+ <form method="post" class="rodauth" role="form" id="create-account-form">
2
+ <%= rodauth.create_account_additional_form_tags %>
3
+ <%= rodauth.csrf_tag %>
4
+ <%= rodauth.render('login-field') %>
5
+ <%= rodauth.render('login-confirm-field') if rodauth.require_login_confirmation? %>
6
+ <%= rodauth.render('password-field') if rodauth.create_account_set_password? %>
7
+ <%= rodauth.render('password-confirm-field') if rodauth.create_account_set_password? && rodauth.require_password_confirmation? %>
8
+ <%= rodauth.button(t.rodauth.create_account_button) %>
9
+ </form>
@@ -0,0 +1,71 @@
1
+ Sequel.migration do
2
+ change do
3
+ db = self
4
+
5
+ extension :date_arithmetic
6
+
7
+ deadline_opts = proc do |days|
8
+ {null: false, default: Sequel.date_add(Sequel::CURRENT_TIMESTAMP, days: days)}
9
+ end
10
+
11
+ # Used by the account verification and close account features
12
+ create_table(:account_statuses) do
13
+ Integer :id, primary_key: true
14
+ String :name, null: false, unique: true
15
+ end
16
+ from(:account_statuses).import([:id, :name], [[1, "Unverified"], [2, "Verified"], [3, "Closed"]])
17
+
18
+ # Accounts base table
19
+ create_table(:accounts) do
20
+ primary_key :id
21
+ String :email, null: false, unique: true
22
+ column :status, Integer, default: 1, null: false
23
+ if db.database_type == :postgres
24
+ constraint :valid_email, email: /^[^,;@ \r\n]+@[^,@; \r\n]+\.[^,@; \r\n]+$/
25
+ end
26
+ index :email, unique: true
27
+ foreign_key :status_id, :account_statuses, null: false, default: 1
28
+ end
29
+
30
+ # Store the password hashes
31
+ create_table(:account_password_hashes) do
32
+ foreign_key :id, :accounts, primary_key: true
33
+
34
+ String :password_hash, text: true, null: false
35
+ end
36
+
37
+ # Used by the account verification feature
38
+ create_table(:account_verification_keys) do
39
+ foreign_key :id, :accounts, primary_key: true, type: :Bignum
40
+ String :key, null: false
41
+ DateTime :requested_at, null: false, default: Sequel::CURRENT_TIMESTAMP
42
+ DateTime :email_last_sent, null: false, default: Sequel::CURRENT_TIMESTAMP
43
+ end
44
+
45
+ # Used by the password reset feature
46
+ create_table(:account_password_reset_keys) do
47
+ foreign_key :id, :accounts, primary_key: true, type: :Bignum
48
+ String :key, null: false
49
+ DateTime :deadline, deadline_opts[1]
50
+ DateTime :email_last_sent, null: false, default: Sequel::CURRENT_TIMESTAMP
51
+ end
52
+
53
+ if db.database_type == :postgres
54
+ user = get(Sequel.lit("current_user")).sub(/_password\z/, "")
55
+
56
+ run "REVOKE ALL ON account_password_hashes FROM public"
57
+ run "GRANT INSERT, UPDATE, DELETE ON account_password_hashes TO #{user}"
58
+ run "GRANT SELECT(id) ON account_password_hashes TO #{user}"
59
+ end
60
+ end
61
+
62
+ down do
63
+ drop_table(
64
+ :account_password_hashes,
65
+ :account_password_reset_keys,
66
+ :account_verification_keys,
67
+ :accounts,
68
+ :account_statuses
69
+ )
70
+ end
71
+ end
@@ -0,0 +1,15 @@
1
+ require_relative "../spec_helper"
2
+
3
+ describe "hello" do
4
+ it "test requests" do
5
+ get "/"<% if context.rodauth? %>
6
+ _(last_response.status).must_equal 302<% else %>
7
+ _(last_response.status).must_equal 200<% end %>
8
+ end
9
+ <% if context.rodauth? %>
10
+ it "test models" do
11
+ Account.create(email: "foo@bar.com")
12
+
13
+ _(Account.count).must_equal 1
14
+ end<% end %>
15
+ end
@@ -0,0 +1,8 @@
1
+ require_relative "../../spec_helper"
2
+
3
+ describe "Routes for foo" do
4
+ it "responds to GET /foo/bar" do
5
+ get "/foo/bar"
6
+ _(last_response.status).must_equal 200
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ require_relative "../../spec_helper"
2
+
3
+ describe "Routes for test_branch" do
4
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV["RACK_ENV"] = "test"
4
+
5
+ require_relative "../boot"
6
+ require 'rack/test'
7
+ require "minitest/autorun"
8
+ require 'minitest/hooks/default'
9
+
10
+ class Minitest::HooksSpec
11
+ include Rack::Test::Methods
12
+
13
+ def app
14
+ <%= context.const_project_name %>.freeze.app
15
+ end
16
+ end
17
+
18
+ class Minitest::HooksSpec<% if context.database? %>
19
+ around(:all) do |&block|
20
+ DB.transaction(rollback: :always){super(&block)}
21
+ end
22
+
23
+ around do |&block|
24
+ DB.transaction(rollback: :always, savepoint: true, auto_savepoint: true){super(&block)}
25
+ end
26
+ <% end %>
27
+ def log
28
+ LOGGER.level = Logger::INFO
29
+ yield
30
+ ensure
31
+ LOGGER.level = Logger::FATAL
32
+ end
33
+ end
@@ -0,0 +1,15 @@
1
+ require_relative "../spec_helper"
2
+
3
+ describe "hello" do
4
+ it "test requests" do
5
+ get "/"<% if context.rodauth? %>
6
+ expect(last_response.status).to eq(302)<% else %>
7
+ expect(last_response.status).to eq(200)<% end %>
8
+ end
9
+ <% if context.rodauth? %>
10
+ it "test models" do
11
+ Account.create(email: "foo@bar.com")
12
+
13
+ expect(Account.count).to eq(1)
14
+ end<% end %>
15
+ end
@@ -0,0 +1,8 @@
1
+ require_relative "../../spec_helper"
2
+
3
+ describe "Routes for foo" do
4
+ it "responds to GET /foo/bar" do
5
+ get "/foo/bar"
6
+ expect(last_response.status).to eq(200)
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ require_relative "../../spec_helper"
2
+
3
+ describe "Routes for test_branch" do
4
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV["RACK_ENV"] = "test"
4
+
5
+ require_relative "../boot"
6
+ require "rack/test"
7
+ require "rspec"
8
+
9
+ RSpec.configure do |config|
10
+ config.include Rack::Test::Methods
11
+ <% if context.database? %>
12
+ config.around(:each) do |example|
13
+ DB.transaction(rollback: :always, savepoint: true, auto_savepoint: true) { example.run }
14
+ end
15
+ <% end %>
16
+ def app
17
+ <%= context.const_project_name %>.freeze.app
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roda-project
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Henrique F. Teixeira
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: tty-file
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: tty-reader
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: pastel
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ email:
55
+ - hriqueft@gmail.com
56
+ executables:
57
+ - roda-project
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - bin/console
62
+ - bin/roda-project
63
+ - bin/roda-project.rb
64
+ - bin/setup
65
+ - lib/roda/project.rb
66
+ - lib/roda/project/cli.rb
67
+ - lib/roda/project/context.rb
68
+ - lib/roda/project/helpers/ids.rb
69
+ - lib/roda/project/helpers/input.rb
70
+ - lib/roda/project/helpers/template.rb
71
+ - lib/roda/project/version.rb
72
+ - lib/roda/templates/base/app/app.rb.erb
73
+ - lib/roda/templates/base/scaffold/AGENTS.md
74
+ - lib/roda/templates/base/scaffold/Gemfile.erb
75
+ - lib/roda/templates/base/scaffold/Guardfile
76
+ - lib/roda/templates/base/scaffold/README.md
77
+ - lib/roda/templates/base/scaffold/Rakefile.erb
78
+ - lib/roda/templates/base/scaffold/app/config/config.rb.erb
79
+ - lib/roda/templates/base/scaffold/app/config/locales/en.yml
80
+ - lib/roda/templates/base/scaffold/app/config/locales/foo/en.yml
81
+ - lib/roda/templates/base/scaffold/app/config/locales/foo/pt-br.yml
82
+ - lib/roda/templates/base/scaffold/app/config/locales/pt-br.yml
83
+ - lib/roda/templates/base/scaffold/app/config/providers/logger.rb
84
+ - lib/roda/templates/base/scaffold/app/config/providers/mailer.rb
85
+ - lib/roda/templates/base/scaffold/app/routes/foo.rb.erb
86
+ - lib/roda/templates/base/scaffold/boot.rb.erb
87
+ - lib/roda/templates/base/scaffold/config.ru.erb
88
+ - lib/roda/templates/base/scaffold/public/css/app.css
89
+ - lib/roda/templates/base/scaffold/public/exception_page.css
90
+ - lib/roda/templates/base/scaffold/public/images/roda-project.png
91
+ - lib/roda/templates/base/scaffold/public/js/app.js
92
+ - lib/roda/templates/database/app/config/providers/db/conn.rb
93
+ - lib/roda/templates/database/db/seeds.rb
94
+ - lib/roda/templates/front-end/app/assets/css/app.css
95
+ - lib/roda/templates/front-end/app/assets/js/app.js
96
+ - lib/roda/templates/front-end/app/assets/js/some/foo.js
97
+ - lib/roda/templates/front-end/app/views/foo/bar.erb
98
+ - lib/roda/templates/front-end/app/views/foo/html.rb
99
+ - lib/roda/templates/front-end/app/views/html.rb
100
+ - lib/roda/templates/front-end/app/views/index.erb
101
+ - lib/roda/templates/front-end/app/views/layout.erb
102
+ - lib/roda/templates/front-end/esbuild.js
103
+ - lib/roda/templates/front-end/package.json
104
+ - lib/roda/templates/rodauth/app/models/account.rb
105
+ - lib/roda/templates/rodauth/app/views/create-account.erb
106
+ - lib/roda/templates/rodauth/db/migrations/001_add_rodauth.rb
107
+ - lib/roda/templates/tests/minitest/spec/app/app_spec.rb.erb
108
+ - lib/roda/templates/tests/minitest/spec/app/routes/foo_spec.rb
109
+ - lib/roda/templates/tests/minitest/spec/app/routes/test_branch_spec.rb
110
+ - lib/roda/templates/tests/minitest/spec/app/views/html_spec.rb
111
+ - lib/roda/templates/tests/minitest/spec/spec_helper.rb.erb
112
+ - lib/roda/templates/tests/rspec/spec/app/app_spec.rb.erb
113
+ - lib/roda/templates/tests/rspec/spec/app/routes/foo_spec.rb
114
+ - lib/roda/templates/tests/rspec/spec/app/routes/test_branch_spec.rb
115
+ - lib/roda/templates/tests/rspec/spec/app/views/html_spec.rb
116
+ - lib/roda/templates/tests/rspec/spec/spec_helper.rb.erb
117
+ homepage: https://github.com/roda-project
118
+ licenses:
119
+ - MIT
120
+ metadata:
121
+ homepage_uri: https://github.com/roda-project
122
+ source_code_uri: https://github.com/roda-project/roda-project
123
+ changelog_uri: https://github.com/roda-project/roda-project/blob/main/CHANGELOG.md
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 3.2.0
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubygems_version: 4.0.6
139
+ specification_version: 4
140
+ summary: A command-line interface (CLI) tool that helps you quickly scaffold new Roda
141
+ web applications
142
+ test_files: []