ru.Bee 1.3.2 → 1.4.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.
- checksums.yaml +4 -4
- data/bin/rubee +114 -88
- data/lib/app/views/app.tsx +27 -0
- data/lib/app/views/index.html +47 -0
- data/lib/app/views/layout.erb +3 -3
- data/lib/app/views/utils/redirectToBackend.tsx +9 -0
- data/lib/app/views/welcome_show.erb +1 -1
- data/lib/config/base_configuration.rb +15 -6
- data/lib/config/routes.rb +2 -1
- data/lib/db/create_accounts.rb +8 -8
- data/lib/db/create_comments.rb +7 -7
- data/lib/db/create_posts.rb +8 -8
- data/lib/db/create_users.rb +8 -8
- data/lib/db/structure.rb +42 -42
- data/lib/esbuild.config.js +33 -0
- data/lib/inits/print_colors.rb +1 -1
- data/lib/js/app.js +13 -0
- data/lib/js/app.js.map +7 -0
- data/lib/js/bundle.js +26157 -0
- data/lib/js/bundle.js.map +7 -0
- data/lib/node_modules/@types/cookie/LICENSE +21 -0
- data/lib/node_modules/@types/cookie/README.md +15 -0
- data/lib/node_modules/@types/cookie/index.d.ts +154 -0
- data/lib/node_modules/@types/cookie/package.json +30 -0
- data/lib/node_modules/cookie/LICENSE +24 -0
- data/lib/node_modules/cookie/README.md +248 -0
- data/lib/node_modules/cookie/dist/index.d.ts +114 -0
- data/lib/node_modules/cookie/dist/index.js +239 -0
- data/lib/node_modules/cookie/dist/index.js.map +1 -0
- data/lib/node_modules/cookie/package.json +42 -0
- data/lib/node_modules/js-tokens/CHANGELOG.md +151 -0
- data/lib/node_modules/js-tokens/LICENSE +21 -0
- data/lib/node_modules/js-tokens/README.md +240 -0
- data/lib/node_modules/js-tokens/index.js +23 -0
- data/lib/node_modules/js-tokens/package.json +30 -0
- data/lib/node_modules/loose-envify/LICENSE +21 -0
- data/lib/node_modules/loose-envify/README.md +45 -0
- data/lib/node_modules/loose-envify/cli.js +16 -0
- data/lib/node_modules/loose-envify/custom.js +4 -0
- data/lib/node_modules/loose-envify/index.js +3 -0
- data/lib/node_modules/loose-envify/loose-envify.js +36 -0
- data/lib/node_modules/loose-envify/package.json +36 -0
- data/lib/node_modules/loose-envify/replace.js +65 -0
- data/lib/node_modules/react/LICENSE +21 -0
- data/lib/node_modules/react/README.md +37 -0
- data/lib/node_modules/react/cjs/react-jsx-dev-runtime.development.js +1315 -0
- data/lib/node_modules/react/cjs/react-jsx-dev-runtime.production.min.js +10 -0
- data/lib/node_modules/react/cjs/react-jsx-dev-runtime.profiling.min.js +10 -0
- data/lib/node_modules/react/cjs/react-jsx-runtime.development.js +1333 -0
- data/lib/node_modules/react/cjs/react-jsx-runtime.production.min.js +11 -0
- data/lib/node_modules/react/cjs/react-jsx-runtime.profiling.min.js +11 -0
- data/lib/node_modules/react/cjs/react.development.js +2740 -0
- data/lib/node_modules/react/cjs/react.production.min.js +26 -0
- data/lib/node_modules/react/cjs/react.shared-subset.development.js +20 -0
- data/lib/node_modules/react/cjs/react.shared-subset.production.min.js +10 -0
- data/lib/node_modules/react/index.js +7 -0
- data/lib/node_modules/react/jsx-dev-runtime.js +7 -0
- data/lib/node_modules/react/jsx-runtime.js +7 -0
- data/lib/node_modules/react/package.json +47 -0
- data/lib/node_modules/react/react.shared-subset.js +7 -0
- data/lib/node_modules/react/umd/react.development.js +3343 -0
- data/lib/node_modules/react/umd/react.production.min.js +31 -0
- data/lib/node_modules/react/umd/react.profiling.min.js +31 -0
- data/lib/node_modules/react-dom/LICENSE +21 -0
- data/lib/node_modules/react-dom/README.md +60 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.browser.development.js +7029 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +93 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js +7093 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js +101 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server.browser.development.js +7014 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js +96 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server.node.development.js +7070 -0
- data/lib/node_modules/react-dom/cjs/react-dom-server.node.production.min.js +102 -0
- data/lib/node_modules/react-dom/cjs/react-dom-test-utils.development.js +1763 -0
- data/lib/node_modules/react-dom/cjs/react-dom-test-utils.production.min.js +40 -0
- data/lib/node_modules/react-dom/cjs/react-dom.development.js +29923 -0
- data/lib/node_modules/react-dom/cjs/react-dom.production.min.js +322 -0
- data/lib/node_modules/react-dom/cjs/react-dom.profiling.min.js +366 -0
- data/lib/node_modules/react-dom/client.js +25 -0
- data/lib/node_modules/react-dom/index.js +38 -0
- data/lib/node_modules/react-dom/package.json +62 -0
- data/lib/node_modules/react-dom/profiling.js +38 -0
- data/lib/node_modules/react-dom/server.browser.js +17 -0
- data/lib/node_modules/react-dom/server.js +3 -0
- data/lib/node_modules/react-dom/server.node.js +17 -0
- data/lib/node_modules/react-dom/test-utils.js +7 -0
- data/lib/node_modules/react-dom/umd/react-dom-server-legacy.browser.development.js +7026 -0
- data/lib/node_modules/react-dom/umd/react-dom-server-legacy.browser.production.min.js +75 -0
- data/lib/node_modules/react-dom/umd/react-dom-server.browser.development.js +7011 -0
- data/lib/node_modules/react-dom/umd/react-dom-server.browser.production.min.js +76 -0
- data/lib/node_modules/react-dom/umd/react-dom-test-utils.development.js +1759 -0
- data/lib/node_modules/react-dom/umd/react-dom-test-utils.production.min.js +33 -0
- data/lib/node_modules/react-dom/umd/react-dom.development.js +29924 -0
- data/lib/node_modules/react-dom/umd/react-dom.production.min.js +267 -0
- data/lib/node_modules/react-dom/umd/react-dom.profiling.min.js +285 -0
- data/lib/node_modules/react-router/CHANGELOG.md +1526 -0
- data/lib/node_modules/react-router/LICENSE.md +23 -0
- data/lib/node_modules/react-router/README.md +7 -0
- data/lib/node_modules/react-router/dist/development/chunk-KNED5TY2.mjs +10476 -0
- data/lib/node_modules/react-router/dist/development/dom-export.d.mts +23 -0
- data/lib/node_modules/react-router/dist/development/dom-export.d.ts +23 -0
- data/lib/node_modules/react-router/dist/development/dom-export.js +6111 -0
- data/lib/node_modules/react-router/dist/development/dom-export.mjs +234 -0
- data/lib/node_modules/react-router/dist/development/fog-of-war-1hWhK5ey.d.mts +1690 -0
- data/lib/node_modules/react-router/dist/development/fog-of-war-oa9CGk10.d.ts +1690 -0
- data/lib/node_modules/react-router/dist/development/future-ldDp5FKH.d.mts +21 -0
- data/lib/node_modules/react-router/dist/development/future-ldDp5FKH.d.ts +21 -0
- data/lib/node_modules/react-router/dist/development/index.d.mts +841 -0
- data/lib/node_modules/react-router/dist/development/index.d.ts +841 -0
- data/lib/node_modules/react-router/dist/development/index.js +10624 -0
- data/lib/node_modules/react-router/dist/development/index.mjs +242 -0
- data/lib/node_modules/react-router/dist/development/lib/types/route-module.d.mts +209 -0
- data/lib/node_modules/react-router/dist/development/lib/types/route-module.d.ts +209 -0
- data/lib/node_modules/react-router/dist/development/lib/types/route-module.js +28 -0
- data/lib/node_modules/react-router/dist/development/lib/types/route-module.mjs +10 -0
- data/lib/node_modules/react-router/dist/development/route-data-5OzAzQtT.d.mts +1716 -0
- data/lib/node_modules/react-router/dist/development/route-data-5OzAzQtT.d.ts +1716 -0
- data/lib/node_modules/react-router/dist/production/chunk-ZIM7OIE3.mjs +10476 -0
- data/lib/node_modules/react-router/dist/production/dom-export.d.mts +23 -0
- data/lib/node_modules/react-router/dist/production/dom-export.d.ts +23 -0
- data/lib/node_modules/react-router/dist/production/dom-export.js +6111 -0
- data/lib/node_modules/react-router/dist/production/dom-export.mjs +234 -0
- data/lib/node_modules/react-router/dist/production/fog-of-war-1hWhK5ey.d.mts +1690 -0
- data/lib/node_modules/react-router/dist/production/fog-of-war-oa9CGk10.d.ts +1690 -0
- data/lib/node_modules/react-router/dist/production/future-ldDp5FKH.d.mts +21 -0
- data/lib/node_modules/react-router/dist/production/future-ldDp5FKH.d.ts +21 -0
- data/lib/node_modules/react-router/dist/production/index.d.mts +841 -0
- data/lib/node_modules/react-router/dist/production/index.d.ts +841 -0
- data/lib/node_modules/react-router/dist/production/index.js +10624 -0
- data/lib/node_modules/react-router/dist/production/index.mjs +242 -0
- data/lib/node_modules/react-router/dist/production/lib/types/route-module.d.mts +209 -0
- data/lib/node_modules/react-router/dist/production/lib/types/route-module.d.ts +209 -0
- data/lib/node_modules/react-router/dist/production/lib/types/route-module.js +28 -0
- data/lib/node_modules/react-router/dist/production/lib/types/route-module.mjs +10 -0
- data/lib/node_modules/react-router/dist/production/route-data-5OzAzQtT.d.mts +1716 -0
- data/lib/node_modules/react-router/dist/production/route-data-5OzAzQtT.d.ts +1716 -0
- data/lib/node_modules/react-router/package.json +116 -0
- data/lib/node_modules/react-router-dom/LICENSE.md +23 -0
- data/lib/node_modules/react-router-dom/README.md +6 -0
- data/lib/node_modules/react-router-dom/dist/index.d.mts +2 -0
- data/lib/node_modules/react-router-dom/dist/index.d.ts +2 -0
- data/lib/node_modules/react-router-dom/dist/index.js +45 -0
- data/lib/node_modules/react-router-dom/dist/index.mjs +18 -0
- data/lib/node_modules/react-router-dom/package.json +82 -0
- data/lib/node_modules/scheduler/LICENSE +21 -0
- data/lib/node_modules/scheduler/README.md +9 -0
- data/lib/node_modules/scheduler/cjs/scheduler-unstable_mock.development.js +700 -0
- data/lib/node_modules/scheduler/cjs/scheduler-unstable_mock.production.min.js +20 -0
- data/lib/node_modules/scheduler/cjs/scheduler-unstable_post_task.development.js +207 -0
- data/lib/node_modules/scheduler/cjs/scheduler-unstable_post_task.production.min.js +14 -0
- data/lib/node_modules/scheduler/cjs/scheduler.development.js +634 -0
- data/lib/node_modules/scheduler/cjs/scheduler.production.min.js +19 -0
- data/lib/node_modules/scheduler/index.js +7 -0
- data/lib/node_modules/scheduler/package.json +36 -0
- data/lib/node_modules/scheduler/umd/scheduler-unstable_mock.development.js +699 -0
- data/lib/node_modules/scheduler/umd/scheduler-unstable_mock.production.min.js +19 -0
- data/lib/node_modules/scheduler/umd/scheduler.development.js +152 -0
- data/lib/node_modules/scheduler/umd/scheduler.production.min.js +146 -0
- data/lib/node_modules/scheduler/umd/scheduler.profiling.min.js +146 -0
- data/lib/node_modules/scheduler/unstable_mock.js +7 -0
- data/lib/node_modules/scheduler/unstable_post_task.js +7 -0
- data/lib/node_modules/set-cookie-parser/LICENSE +21 -0
- data/lib/node_modules/set-cookie-parser/README.md +202 -0
- data/lib/node_modules/set-cookie-parser/lib/set-cookie.js +224 -0
- data/lib/node_modules/set-cookie-parser/package.json +45 -0
- data/lib/node_modules/turbo-stream/LICENSE +7 -0
- data/lib/node_modules/turbo-stream/README.md +31 -0
- data/lib/node_modules/turbo-stream/dist/flatten.d.ts +2 -0
- data/lib/node_modules/turbo-stream/dist/flatten.js +203 -0
- data/lib/node_modules/turbo-stream/dist/turbo-stream.d.ts +13 -0
- data/lib/node_modules/turbo-stream/dist/turbo-stream.js +207 -0
- data/lib/node_modules/turbo-stream/dist/turbo-stream.mjs +673 -0
- data/lib/node_modules/turbo-stream/dist/unflatten.d.ts +2 -0
- data/lib/node_modules/turbo-stream/dist/unflatten.js +243 -0
- data/lib/node_modules/turbo-stream/dist/utils.d.ts +44 -0
- data/lib/node_modules/turbo-stream/dist/utils.js +55 -0
- data/lib/node_modules/turbo-stream/package.json +50 -0
- data/lib/package-lock.json +133 -0
- data/lib/package.json +12 -0
- data/lib/rubee/async/asyncable.rb +2 -2
- data/lib/rubee/async/sidekiq_async.rb +11 -11
- data/lib/rubee/async/thread_async.rb +1 -1
- data/lib/rubee/async/thread_pool.rb +2 -2
- data/lib/rubee/controllers/base_controller.rb +44 -21
- data/lib/rubee/controllers/extensions/auth_tokenable.rb +10 -8
- data/lib/rubee/controllers/extensions/middlewarable.rb +1 -1
- data/lib/rubee/controllers/middlewares/auth_token_middleware.rb +12 -8
- data/lib/rubee/extensions/hookable.rb +3 -6
- data/lib/rubee/extensions/serializable.rb +3 -3
- data/lib/rubee/models/database_objectable.rb +11 -12
- data/lib/rubee/models/sequel_object.rb +23 -24
- data/lib/rubee.rb +106 -55
- data/lib/tests/account_model_test.rb +4 -4
- data/lib/tests/auth_tokenable_test.rb +6 -6
- data/lib/tests/comment_model_test.rb +7 -7
- data/lib/tests/example_models/account.rb +1 -0
- data/lib/tests/example_models/comment.rb +1 -0
- data/lib/tests/example_models/post.rb +1 -0
- data/lib/tests/example_models/user.rb +1 -0
- data/lib/tests/rubeeapp_test.rb +21 -6
- data/lib/tests/test.db +0 -0
- data/lib/tests/test_helper.rb +3 -5
- data/lib/tests/user_model_test.rb +71 -54
- data/readme.md +104 -2
- metadata +170 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f60bb8f17e35447c9cedd635d719a6b0d988486f9fe04668e0e07763a99cb740
|
|
4
|
+
data.tar.gz: a56dcac76060f5bb9ec71959ef4d21fa7c3e9b858eb6088e873e3ba50e4684f0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 03be1679bf032a1f292b4490a41286eb02f3a56984cf8dc7281715db53f880dc3ded8feb445ae41a22d60c2a4c3a5e47f8b8fe1be5f4c8188d26e57d403b746e
|
|
7
|
+
data.tar.gz: 0ffa4e0cc8c436d2ce7ac784c92465333d12ebaa67172f08bcfc55e59dd6f29472aa70211a3c2b766c234ef089b51d1c47a130cc6c0c8ab35e896f659b1ba43d
|
data/bin/rubee
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
require 'fileutils'
|
|
4
|
-
require 'date'
|
|
5
|
-
require 'irb'
|
|
6
|
-
require 'sequel'
|
|
7
|
-
require 'sqlite3'
|
|
8
|
-
require 'json'
|
|
9
|
-
require 'rack'
|
|
10
|
-
require 'rackup'
|
|
11
4
|
|
|
12
5
|
require_relative '../lib/inits/print_colors'
|
|
13
6
|
require_relative '../lib/rubee'
|
|
14
7
|
|
|
8
|
+
|
|
15
9
|
ENV['RACK_ENV'] ||= 'development'
|
|
16
10
|
|
|
17
11
|
LIB_ROOT = File.expand_path('../lib', File.dirname(__FILE__))
|
|
@@ -29,42 +23,60 @@ LOGO
|
|
|
29
23
|
command = ARGV.first
|
|
30
24
|
|
|
31
25
|
def print_logo
|
|
32
|
-
puts "\e[36m
|
|
26
|
+
puts "\e[36m#{LOGO % Rubee::VERSION}\e[0m" # Cyan color
|
|
33
27
|
end
|
|
34
28
|
|
|
35
29
|
if command =~ /^(start)$|^(start:(\d+))$/
|
|
36
|
-
|
|
30
|
+
_, port = ARGV.first&.split(':')
|
|
37
31
|
|
|
38
|
-
port ||=
|
|
32
|
+
port ||= '7000'
|
|
39
33
|
print_logo
|
|
40
34
|
color_puts "Starting takeoff of ruBee server on port #{port}...", color: :yellow
|
|
41
35
|
exec("rackup #{ENV['RACKUP_FILE']} -p #{port}")
|
|
42
36
|
elsif command =~ /^(start_dev)$|^(start_dev:(\d+))$/
|
|
43
|
-
|
|
37
|
+
_, port = ARGV.first&.split(':')
|
|
44
38
|
|
|
45
|
-
port ||=
|
|
39
|
+
port ||= '7000'
|
|
46
40
|
print_logo
|
|
47
41
|
|
|
48
42
|
color_puts "Starting takeoff of ruBee server on port #{port} in dev mode...", color: :yellow
|
|
49
43
|
|
|
50
44
|
exec("rerun -- rackup --port #{port} #{ENV['RACKUP_FILE']}")
|
|
51
|
-
elsif command ==
|
|
52
|
-
exec(
|
|
53
|
-
elsif command ==
|
|
54
|
-
exec(
|
|
55
|
-
elsif command ==
|
|
45
|
+
elsif command == 'stop'
|
|
46
|
+
exec('pkill -f rubee')
|
|
47
|
+
elsif command == 'status'
|
|
48
|
+
exec('ps aux | grep rubee')
|
|
49
|
+
elsif command == 'react'
|
|
50
|
+
case ARGV[1]
|
|
51
|
+
when 'prepare'
|
|
52
|
+
if Rubee::PROJECT_NAME == 'rubee'
|
|
53
|
+
exec('cd ./lib && npm run prepare')
|
|
54
|
+
else
|
|
55
|
+
exec('npm run prepare')
|
|
56
|
+
end
|
|
57
|
+
when 'watch'
|
|
58
|
+
if Rubee::PROJECT_NAME == 'rubee'
|
|
59
|
+
exec('cd ./lib && npm run watch')
|
|
60
|
+
else
|
|
61
|
+
exec('npm run watch')
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
color_puts "Unknown command: #{command}", color: :red
|
|
65
|
+
exit 1
|
|
66
|
+
end
|
|
67
|
+
elsif command == 'project'
|
|
56
68
|
project_name = ARGV[1]
|
|
57
69
|
if project_name.nil?
|
|
58
|
-
color_puts
|
|
70
|
+
color_puts 'Please indicate project name.', color: :red
|
|
59
71
|
exit 1
|
|
60
72
|
end
|
|
61
73
|
|
|
62
|
-
if project_name ==
|
|
74
|
+
if project_name == 'rubee'
|
|
63
75
|
color_puts "Error: Project 'rubee' is reserved", color: :red
|
|
64
76
|
exit 1
|
|
65
77
|
end
|
|
66
78
|
|
|
67
|
-
source_dir = File.expand_path(
|
|
79
|
+
source_dir = File.expand_path('../lib', __dir__)
|
|
68
80
|
target_dir = File.expand_path("./#{project_name}", Dir.pwd)
|
|
69
81
|
|
|
70
82
|
if Dir.exist?(target_dir)
|
|
@@ -76,12 +88,13 @@ elsif command == "project"
|
|
|
76
88
|
FileUtils.mkdir_p(target_dir)
|
|
77
89
|
|
|
78
90
|
# Define blacklist
|
|
79
|
-
blacklist_files = %w[rubee.rb print_colors.rb version.rb config.ru test_helper.rb Gemfile.lock test.yml test.db
|
|
80
|
-
|
|
91
|
+
blacklist_files = %w[rubee.rb print_colors.rb version.rb config.ru test_helper.rb Gemfile.lock test.yml test.db
|
|
92
|
+
development.db production.db]
|
|
93
|
+
blacklist_dirs = %w[rubee tests .git .github .idea node_modules db]
|
|
81
94
|
|
|
82
95
|
# Copy files, excluding blacklisted ones
|
|
83
96
|
Dir.glob("#{source_dir}/**/*", File::FNM_DOTMATCH).each do |file|
|
|
84
|
-
relative_path = file.sub("#{source_dir}/",
|
|
97
|
+
relative_path = file.sub("#{source_dir}/", '')
|
|
85
98
|
|
|
86
99
|
# Skip blacklisted directories
|
|
87
100
|
next if blacklist_dirs.any? { |dir| relative_path.split('/').include?(dir) }
|
|
@@ -102,26 +115,31 @@ elsif command == "project"
|
|
|
102
115
|
FileUtils.mkdir_p("#{target_dir}/tests")
|
|
103
116
|
FileUtils.cp("#{source_dir}/tests/user_model_test.rb", "#{target_dir}/tests/user_model_test.rb")
|
|
104
117
|
|
|
118
|
+
# create db dir
|
|
119
|
+
FileUtils.mkdir_p("#{target_dir}/db")
|
|
120
|
+
FileUtils.cp("#{source_dir}/db/structure.rb", "#{target_dir}/db/structure.rb")
|
|
121
|
+
FileUtils.cp("#{source_dir}/db/create_users.rb", "#{target_dir}/db/create_users.rb")
|
|
122
|
+
|
|
105
123
|
# create a gemfile context
|
|
106
124
|
gemfile = <<~GEMFILE
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
source 'https://rubygems.org'
|
|
126
|
+
|
|
127
|
+
gem 'ru.Bee'
|
|
128
|
+
gem 'sequel'
|
|
129
|
+
gem 'sqlite3'
|
|
130
|
+
gem 'rake'
|
|
131
|
+
gem 'rack'
|
|
132
|
+
gem 'rackup'
|
|
133
|
+
gem 'pry'
|
|
134
|
+
gem 'pry-byebug'
|
|
135
|
+
gem 'puma'
|
|
136
|
+
gem 'json'
|
|
137
|
+
|
|
138
|
+
group :development do
|
|
139
|
+
gem 'rerun'
|
|
140
|
+
gem 'minitest'
|
|
141
|
+
gem 'rack-test'
|
|
142
|
+
end
|
|
125
143
|
GEMFILE
|
|
126
144
|
# create a gemfile
|
|
127
145
|
File.open("#{target_dir}/Gemfile", 'w') do |file|
|
|
@@ -130,14 +148,14 @@ elsif command == "project"
|
|
|
130
148
|
|
|
131
149
|
# create test_helper.rb file
|
|
132
150
|
test_helper = <<~TESTHELPER
|
|
133
|
-
|
|
134
|
-
|
|
151
|
+
require "bundler/setup"
|
|
152
|
+
Bundler.require(:test)
|
|
135
153
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
154
|
+
require 'minitest/autorun'
|
|
155
|
+
require 'rack/test'
|
|
156
|
+
require 'rubee'
|
|
139
157
|
|
|
140
|
-
|
|
158
|
+
Rubee::Autoload.call
|
|
141
159
|
TESTHELPER
|
|
142
160
|
|
|
143
161
|
File.open("#{target_dir}/tests/test_helper.rb", 'w') do |file|
|
|
@@ -146,9 +164,14 @@ elsif command == "project"
|
|
|
146
164
|
|
|
147
165
|
color_puts "Project #{project_name} created successfully at #{target_dir}", color: :green
|
|
148
166
|
|
|
149
|
-
elsif command ==
|
|
167
|
+
elsif command == 'version'
|
|
150
168
|
color_puts "ru.Bee v#{Rubee::VERSION}", color: :yellow
|
|
151
|
-
elsif command ==
|
|
169
|
+
elsif command == 'routes'
|
|
170
|
+
file = Rubee::PROJECT_NAME == 'rubee' ? File.join('/lib', 'config/routes.rb') : 'config/routes.rb'
|
|
171
|
+
routes = eval(File.read(file))
|
|
172
|
+
|
|
173
|
+
puts routes
|
|
174
|
+
elsif command == 'test'
|
|
152
175
|
|
|
153
176
|
ENV['RACK_ENV'] = 'test'
|
|
154
177
|
file_name = ARGV[1] # Get the first argument
|
|
@@ -157,14 +180,14 @@ elsif command == "test"
|
|
|
157
180
|
color_puts "Running #{file_name} test ...", color: :yellow
|
|
158
181
|
exec("ruby -Itest -e \"require '.#{lib}/tests/#{file_name}'\"")
|
|
159
182
|
else
|
|
160
|
-
color_puts
|
|
183
|
+
color_puts 'Running all tests ...', color: :yellow
|
|
161
184
|
exec("ruby -Itest -e \"Dir.glob('.#{lib}/tests/**/*_test.rb').each { |file| require file }\"")
|
|
162
185
|
end
|
|
163
|
-
elsif [
|
|
186
|
+
elsif %w[generate gen].include?(command)
|
|
164
187
|
method, path = ARGV[1..2]
|
|
165
188
|
ENV['RACK_ENV'] ||= 'development'
|
|
166
|
-
|
|
167
|
-
routes = eval(File.read(
|
|
189
|
+
file = Rubee::PROJECT_NAME == 'rubee' ? File.join('/lib', 'config/routes.rb') : 'config/routes.rb'
|
|
190
|
+
routes = eval(File.read(file))
|
|
168
191
|
route = routes.find { |route| route[:path] == path.to_s && route[:method] == method.to_sym }
|
|
169
192
|
color_puts("Route not found with path: #{path} and method: #{method}", color: :red) unless route
|
|
170
193
|
|
|
@@ -172,16 +195,17 @@ elsif ['generate', 'gen'].include? command
|
|
|
172
195
|
route[:model]&.[](:name),
|
|
173
196
|
route[:model]&.[](:attributes),
|
|
174
197
|
"#{route[:controller]&.capitalize}Controller",
|
|
175
|
-
route[:action]
|
|
198
|
+
route[:action],
|
|
199
|
+
react: route[:react]
|
|
176
200
|
).call
|
|
177
|
-
elsif command ==
|
|
201
|
+
elsif command == 'db'
|
|
178
202
|
Rubee::Autoload.call
|
|
179
203
|
ENV['RACK_ENV'] ||= 'development'
|
|
180
204
|
|
|
181
205
|
command, file_name = ARGV[1]&.split(':')
|
|
182
206
|
if Rubee::PROJECT_NAME == 'rubee'
|
|
183
|
-
Rubee::Configuration.setup(env
|
|
184
|
-
config.database_url = { url:
|
|
207
|
+
Rubee::Configuration.setup(env = :test) do |config|
|
|
208
|
+
config.database_url = { url: 'sqlite://lib/tests/test.db', env: }
|
|
185
209
|
end
|
|
186
210
|
Rubee::SequelObject.reconnect! unless command == 'init'
|
|
187
211
|
end
|
|
@@ -189,29 +213,29 @@ elsif command == "db"
|
|
|
189
213
|
def ensure_database_exists(db_url)
|
|
190
214
|
uri = URI.parse(db_url)
|
|
191
215
|
case uri.scheme
|
|
192
|
-
when
|
|
216
|
+
when 'sqlite'
|
|
193
217
|
begin
|
|
194
218
|
Sequel.connect(db_url)
|
|
195
|
-
color_puts
|
|
196
|
-
rescue Exception
|
|
197
|
-
if File.exist?(db_path = db_url.sub(
|
|
198
|
-
color_puts
|
|
219
|
+
color_puts("Database #{ENV['RACK_ENV']} exists", color: :cyan)
|
|
220
|
+
rescue Exception
|
|
221
|
+
if File.exist?(db_path = db_url.sub(%r{^sqlite://}, ''))
|
|
222
|
+
color_puts("Database #{ENV['RACK_ENV']} exists", color: :cyan)
|
|
199
223
|
else
|
|
200
224
|
Sequel.sqlite(db_path)
|
|
201
|
-
color_puts
|
|
225
|
+
color_puts("Database #{ENV['RACK_ENV']} created", color: :green)
|
|
202
226
|
end
|
|
203
227
|
end
|
|
204
|
-
when
|
|
228
|
+
when 'postgres'
|
|
205
229
|
begin
|
|
206
230
|
Sequel.connect(db_url)
|
|
207
|
-
color_puts
|
|
208
|
-
rescue =>
|
|
209
|
-
con = Sequel.connect(Rubee::Configuration.get_database_url.gsub(/
|
|
231
|
+
color_puts("Database #{ENV['RACK_ENV']} exists", color: :cyan)
|
|
232
|
+
rescue StandardError => _e
|
|
233
|
+
con = Sequel.connect(Rubee::Configuration.get_database_url.gsub(%r{(/test|/development|/production)}, ''))
|
|
210
234
|
con.run("CREATE DATABASE #{ENV['RACK_ENV']}")
|
|
211
|
-
color_puts
|
|
235
|
+
color_puts("Database #{ENV['RACK_ENV']} created", color: :green)
|
|
212
236
|
end
|
|
213
237
|
else
|
|
214
|
-
color_puts
|
|
238
|
+
color_puts("Unsupported database type: #{db_url}", color: :red)
|
|
215
239
|
end
|
|
216
240
|
end
|
|
217
241
|
|
|
@@ -226,52 +250,54 @@ elsif command == "db"
|
|
|
226
250
|
end
|
|
227
251
|
end
|
|
228
252
|
formatted_hash = JSON.pretty_generate(schema_hash)
|
|
229
|
-
|
|
230
|
-
|
|
253
|
+
.gsub(/"(\w+)":/, '\1:') # Convert keys to symbols
|
|
254
|
+
.gsub(': null', ': nil') # Convert `null` to `nil`
|
|
231
255
|
|
|
232
|
-
File.open(
|
|
256
|
+
File.open('db/structure.rb', 'w') do |file|
|
|
233
257
|
file.puts "STRUCTURE = #{formatted_hash}"
|
|
234
258
|
end
|
|
235
259
|
|
|
236
|
-
color_puts
|
|
260
|
+
color_puts('db/structure.rb updated', color: :green)
|
|
237
261
|
end
|
|
238
262
|
|
|
239
|
-
|
|
240
|
-
|
|
263
|
+
case command
|
|
264
|
+
when 'run'
|
|
241
265
|
Rubee::Autoload.call
|
|
242
266
|
file_names = if file_name == 'all'
|
|
243
267
|
lib = Rubee::PROJECT_NAME == 'rubee' ? '/lib' : ''
|
|
244
|
-
Dir.glob(".#{lib}/db/*.rb").map
|
|
268
|
+
Dir.glob(".#{lib}/db/*.rb").map do |file|
|
|
269
|
+
File.basename(file, '.rb')
|
|
270
|
+
end.reject { |file| file == 'structure' }
|
|
245
271
|
else
|
|
246
272
|
[file_name]
|
|
247
273
|
end
|
|
248
274
|
Rubee::Configuration.envs.each do |env|
|
|
249
275
|
ENV['RACK_ENV'] = env.to_s
|
|
250
276
|
file_names.each do |file_name|
|
|
251
|
-
color_puts
|
|
277
|
+
color_puts("Run #{file_name} file for #{env} env", color: :cyan)
|
|
252
278
|
Object.const_get(file_name.split('_').map(&:capitalize).join).new.call
|
|
253
279
|
end
|
|
254
280
|
end
|
|
255
|
-
color_puts
|
|
281
|
+
color_puts("Migration for #{file_name} completed", color: :green)
|
|
256
282
|
unless Rubee::PROJECT_NAME == 'rubee'
|
|
257
|
-
color_puts
|
|
283
|
+
color_puts('Regenerate schema file', color: :cyan)
|
|
258
284
|
generate_structure
|
|
259
285
|
end
|
|
260
|
-
|
|
286
|
+
when 'init'
|
|
261
287
|
ensure_database_exists(Rubee::Configuration.get_database_url)
|
|
262
|
-
|
|
288
|
+
when 'structure'
|
|
263
289
|
generate_structure
|
|
264
290
|
else
|
|
265
|
-
color_puts
|
|
291
|
+
color_puts("Unknown command: #{command}", color: :red)
|
|
266
292
|
end
|
|
267
|
-
elsif ['console'].include?
|
|
293
|
+
elsif ['console'].include?(command)
|
|
268
294
|
ARGV.clear
|
|
269
295
|
ENV['RACK_ENV'] ||= 'development'
|
|
270
296
|
|
|
271
297
|
Rubee::Autoload.call
|
|
272
298
|
if Rubee::PROJECT_NAME == 'rubee'
|
|
273
|
-
Rubee::Configuration.setup(env
|
|
274
|
-
config.database_url = { url:
|
|
299
|
+
Rubee::Configuration.setup(env = :test) do |config|
|
|
300
|
+
config.database_url = { url: 'sqlite://lib/tests/test.db', env: }
|
|
275
301
|
end
|
|
276
302
|
Rubee::Autoload.call
|
|
277
303
|
Rubee::SequelObject.reconnect!
|
|
@@ -279,13 +305,13 @@ elsif ['console'].include? command
|
|
|
279
305
|
|
|
280
306
|
def reload
|
|
281
307
|
app_files = Dir["./#{Rubee::APP_ROOT}/**/*.rb"]
|
|
282
|
-
app_files.each { |file| load
|
|
283
|
-
color_puts
|
|
308
|
+
app_files.each { |file| load(file) }
|
|
309
|
+
color_puts('Reloaded ..', color: :green)
|
|
284
310
|
end
|
|
285
311
|
begin
|
|
286
312
|
# Start IRB
|
|
287
313
|
IRB.start
|
|
288
|
-
rescue Exception
|
|
314
|
+
rescue Exception
|
|
289
315
|
IRB.start
|
|
290
316
|
end
|
|
291
317
|
else
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BrowserRouter as Router, Routes, Route, Link } from "react-router-dom";
|
|
3
|
+
|
|
4
|
+
const Home = () => (
|
|
5
|
+
<div>
|
|
6
|
+
<h2>Reactive Bee</h2>
|
|
7
|
+
<p>Welcome to Reactive Bee ...</p>
|
|
8
|
+
<img src="images/rubee.svg" alt="rubee"></img>
|
|
9
|
+
<nav>
|
|
10
|
+
<Link to="/home">Home</Link><br />
|
|
11
|
+
</nav>
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const NotFound = () => <h2>404 Not Found</h2>;
|
|
16
|
+
|
|
17
|
+
export function App() {
|
|
18
|
+
return (
|
|
19
|
+
<Router>
|
|
20
|
+
<Routes>
|
|
21
|
+
<Route path="/home" element={<Home />} />
|
|
22
|
+
<Route path="*" element={<NotFound />} />
|
|
23
|
+
</Routes>
|
|
24
|
+
</Router>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>React App</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
height: 100vh;
|
|
13
|
+
margin: 0;
|
|
14
|
+
background-color: #fdf6a5;
|
|
15
|
+
text-align: center;
|
|
16
|
+
font-family: Arial, sans-serif;
|
|
17
|
+
}
|
|
18
|
+
.container {
|
|
19
|
+
padding: 20px;
|
|
20
|
+
background: white;
|
|
21
|
+
border-radius: 10px;
|
|
22
|
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
|
23
|
+
}
|
|
24
|
+
img {
|
|
25
|
+
width: 50px;
|
|
26
|
+
height: auto;
|
|
27
|
+
margin-top: 10px;
|
|
28
|
+
}
|
|
29
|
+
h1 {
|
|
30
|
+
font-size: 1.8rem;
|
|
31
|
+
margin: 10px 0;
|
|
32
|
+
}
|
|
33
|
+
@media (max-width: 600px) {
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 1.5rem;
|
|
36
|
+
}
|
|
37
|
+
img {
|
|
38
|
+
width: 60px;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
<div id="app"></div>
|
|
45
|
+
<script type="module" src="./../../js/bundle.js"></script>
|
|
46
|
+
</body>
|
|
47
|
+
</html>
|
data/lib/app/views/layout.erb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<div class="container">
|
|
2
2
|
<%= render_template :welcome_header %>
|
|
3
3
|
<br/>
|
|
4
|
-
<img src="images/rubee.svg" alt="
|
|
4
|
+
<img src="images/rubee.svg" alt="rubee">
|
|
5
5
|
<br/>
|
|
6
6
|
<p>rubee homepage: <a href="https://github.com/nucleom42/rubee"><br/>https://github.com/nucleom42/rubee</a></p>
|
|
7
7
|
<br/>
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
Rubee::Configuration.setup(env
|
|
2
|
-
config.database_url = { url:
|
|
1
|
+
Rubee::Configuration.setup(env = :development) do |config|
|
|
2
|
+
config.database_url = { url: 'sqlite://db/development.db', env: }
|
|
3
|
+
|
|
4
|
+
# Uncomment, if you want to use react
|
|
5
|
+
# config.react = { on: true, env: }
|
|
3
6
|
end
|
|
4
7
|
|
|
5
|
-
Rubee::Configuration.setup(env
|
|
6
|
-
config.database_url = { url:
|
|
8
|
+
Rubee::Configuration.setup(env = :test) do |config|
|
|
9
|
+
config.database_url = { url: 'sqlite://db/test.db', env: }
|
|
10
|
+
|
|
11
|
+
# Uncomment, if you want to use react
|
|
12
|
+
# config.react = { on: true, env: } # required if you want to use react
|
|
7
13
|
end
|
|
8
14
|
|
|
9
|
-
Rubee::Configuration.setup(env
|
|
10
|
-
config.database_url = { url:
|
|
15
|
+
Rubee::Configuration.setup(env = :production) do |config|
|
|
16
|
+
config.database_url = { url: 'sqlite://db/production.db', env: }
|
|
17
|
+
|
|
18
|
+
# Uncomment,if you want to use react
|
|
19
|
+
# config.react = { on: true, env: } # required if you want to use react
|
|
11
20
|
end
|
data/lib/config/routes.rb
CHANGED
data/lib/db/create_accounts.rb
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
class CreateAccounts
|
|
2
2
|
def call
|
|
3
|
-
|
|
4
|
-
Rubee::SequelObject::DB.create_table :accounts do
|
|
5
|
-
primary_key :id
|
|
6
|
-
String :addres
|
|
7
|
-
foreign_key :user_id, :users
|
|
8
|
-
end
|
|
3
|
+
return if Rubee::SequelObject::DB.tables.include?(:accounts)
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
Rubee::SequelObject::DB.create_table(:accounts) do
|
|
6
|
+
primary_key(:id)
|
|
7
|
+
String(:addres)
|
|
8
|
+
foreign_key(:user_id, :users)
|
|
12
9
|
end
|
|
10
|
+
|
|
11
|
+
Account.create(addres: '13th Ave, NY', user_id: User.all.first.id)
|
|
12
|
+
Account.create(addres: '14th Ave, NY', user_id: User.all.last.id)
|
|
13
13
|
end
|
|
14
14
|
end
|
data/lib/db/create_comments.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
class CreateComments
|
|
2
2
|
def call
|
|
3
|
-
|
|
4
|
-
Rubee::SequelObject::DB.create_table :comments do
|
|
5
|
-
primary_key :id
|
|
6
|
-
String :text
|
|
7
|
-
Integer :user_id
|
|
8
|
-
end
|
|
3
|
+
return if Rubee::SequelObject::DB.tables.include?(:comments)
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
Rubee::SequelObject::DB.create_table(:comments) do
|
|
6
|
+
primary_key(:id)
|
|
7
|
+
String(:text)
|
|
8
|
+
Integer(:user_id)
|
|
11
9
|
end
|
|
10
|
+
|
|
11
|
+
User.create(email: 'ok@ok.com', password: 'password')
|
|
12
12
|
end
|
|
13
13
|
end
|
data/lib/db/create_posts.rb
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
class CreatePosts
|
|
2
2
|
def call
|
|
3
|
-
|
|
4
|
-
Rubee::SequelObject::DB.create_table :posts do
|
|
5
|
-
primary_key :id
|
|
6
|
-
foreign_key :user_id, :users
|
|
7
|
-
foreign_key :comment_id, :comments
|
|
8
|
-
end
|
|
3
|
+
return if Rubee::SequelObject::DB.tables.include?(:posts)
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
Rubee::SequelObject::DB.create_table(:posts) do
|
|
6
|
+
primary_key(:id)
|
|
7
|
+
foreign_key(:user_id, :users)
|
|
8
|
+
foreign_key(:comment_id, :comments)
|
|
12
9
|
end
|
|
10
|
+
|
|
11
|
+
Post.create(user_id: User.all.first.id, comment_id: Comment.all.first.id)
|
|
12
|
+
Post.create(user_id: User.all.last.id, comment_id: Comment.all.last.id)
|
|
13
13
|
end
|
|
14
14
|
end
|
data/lib/db/create_users.rb
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
# Please make sure you executed it before using AuthTokenable module
|
|
3
3
|
class CreateUsers
|
|
4
4
|
def call
|
|
5
|
-
|
|
6
|
-
Rubee::SequelObject::DB.create_table :users do
|
|
7
|
-
primary_key :id
|
|
8
|
-
String :email
|
|
9
|
-
String :password
|
|
10
|
-
index :email
|
|
11
|
-
end
|
|
5
|
+
return if Rubee::SequelObject::DB.tables.include?(:users)
|
|
12
6
|
|
|
13
|
-
|
|
7
|
+
Rubee::SequelObject::DB.create_table(:users) do
|
|
8
|
+
primary_key(:id)
|
|
9
|
+
String(:email)
|
|
10
|
+
String(:password)
|
|
11
|
+
index(:email)
|
|
14
12
|
end
|
|
13
|
+
|
|
14
|
+
User.create(email: 'ok@ok.com', password: 'password')
|
|
15
15
|
end
|
|
16
16
|
end
|