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.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rubee +114 -88
  3. data/lib/app/views/app.tsx +27 -0
  4. data/lib/app/views/index.html +47 -0
  5. data/lib/app/views/layout.erb +3 -3
  6. data/lib/app/views/utils/redirectToBackend.tsx +9 -0
  7. data/lib/app/views/welcome_show.erb +1 -1
  8. data/lib/config/base_configuration.rb +15 -6
  9. data/lib/config/routes.rb +2 -1
  10. data/lib/db/create_accounts.rb +8 -8
  11. data/lib/db/create_comments.rb +7 -7
  12. data/lib/db/create_posts.rb +8 -8
  13. data/lib/db/create_users.rb +8 -8
  14. data/lib/db/structure.rb +42 -42
  15. data/lib/esbuild.config.js +33 -0
  16. data/lib/inits/print_colors.rb +1 -1
  17. data/lib/js/app.js +13 -0
  18. data/lib/js/app.js.map +7 -0
  19. data/lib/js/bundle.js +26157 -0
  20. data/lib/js/bundle.js.map +7 -0
  21. data/lib/node_modules/@types/cookie/LICENSE +21 -0
  22. data/lib/node_modules/@types/cookie/README.md +15 -0
  23. data/lib/node_modules/@types/cookie/index.d.ts +154 -0
  24. data/lib/node_modules/@types/cookie/package.json +30 -0
  25. data/lib/node_modules/cookie/LICENSE +24 -0
  26. data/lib/node_modules/cookie/README.md +248 -0
  27. data/lib/node_modules/cookie/dist/index.d.ts +114 -0
  28. data/lib/node_modules/cookie/dist/index.js +239 -0
  29. data/lib/node_modules/cookie/dist/index.js.map +1 -0
  30. data/lib/node_modules/cookie/package.json +42 -0
  31. data/lib/node_modules/js-tokens/CHANGELOG.md +151 -0
  32. data/lib/node_modules/js-tokens/LICENSE +21 -0
  33. data/lib/node_modules/js-tokens/README.md +240 -0
  34. data/lib/node_modules/js-tokens/index.js +23 -0
  35. data/lib/node_modules/js-tokens/package.json +30 -0
  36. data/lib/node_modules/loose-envify/LICENSE +21 -0
  37. data/lib/node_modules/loose-envify/README.md +45 -0
  38. data/lib/node_modules/loose-envify/cli.js +16 -0
  39. data/lib/node_modules/loose-envify/custom.js +4 -0
  40. data/lib/node_modules/loose-envify/index.js +3 -0
  41. data/lib/node_modules/loose-envify/loose-envify.js +36 -0
  42. data/lib/node_modules/loose-envify/package.json +36 -0
  43. data/lib/node_modules/loose-envify/replace.js +65 -0
  44. data/lib/node_modules/react/LICENSE +21 -0
  45. data/lib/node_modules/react/README.md +37 -0
  46. data/lib/node_modules/react/cjs/react-jsx-dev-runtime.development.js +1315 -0
  47. data/lib/node_modules/react/cjs/react-jsx-dev-runtime.production.min.js +10 -0
  48. data/lib/node_modules/react/cjs/react-jsx-dev-runtime.profiling.min.js +10 -0
  49. data/lib/node_modules/react/cjs/react-jsx-runtime.development.js +1333 -0
  50. data/lib/node_modules/react/cjs/react-jsx-runtime.production.min.js +11 -0
  51. data/lib/node_modules/react/cjs/react-jsx-runtime.profiling.min.js +11 -0
  52. data/lib/node_modules/react/cjs/react.development.js +2740 -0
  53. data/lib/node_modules/react/cjs/react.production.min.js +26 -0
  54. data/lib/node_modules/react/cjs/react.shared-subset.development.js +20 -0
  55. data/lib/node_modules/react/cjs/react.shared-subset.production.min.js +10 -0
  56. data/lib/node_modules/react/index.js +7 -0
  57. data/lib/node_modules/react/jsx-dev-runtime.js +7 -0
  58. data/lib/node_modules/react/jsx-runtime.js +7 -0
  59. data/lib/node_modules/react/package.json +47 -0
  60. data/lib/node_modules/react/react.shared-subset.js +7 -0
  61. data/lib/node_modules/react/umd/react.development.js +3343 -0
  62. data/lib/node_modules/react/umd/react.production.min.js +31 -0
  63. data/lib/node_modules/react/umd/react.profiling.min.js +31 -0
  64. data/lib/node_modules/react-dom/LICENSE +21 -0
  65. data/lib/node_modules/react-dom/README.md +60 -0
  66. data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.browser.development.js +7029 -0
  67. data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +93 -0
  68. data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js +7093 -0
  69. data/lib/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js +101 -0
  70. data/lib/node_modules/react-dom/cjs/react-dom-server.browser.development.js +7014 -0
  71. data/lib/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js +96 -0
  72. data/lib/node_modules/react-dom/cjs/react-dom-server.node.development.js +7070 -0
  73. data/lib/node_modules/react-dom/cjs/react-dom-server.node.production.min.js +102 -0
  74. data/lib/node_modules/react-dom/cjs/react-dom-test-utils.development.js +1763 -0
  75. data/lib/node_modules/react-dom/cjs/react-dom-test-utils.production.min.js +40 -0
  76. data/lib/node_modules/react-dom/cjs/react-dom.development.js +29923 -0
  77. data/lib/node_modules/react-dom/cjs/react-dom.production.min.js +322 -0
  78. data/lib/node_modules/react-dom/cjs/react-dom.profiling.min.js +366 -0
  79. data/lib/node_modules/react-dom/client.js +25 -0
  80. data/lib/node_modules/react-dom/index.js +38 -0
  81. data/lib/node_modules/react-dom/package.json +62 -0
  82. data/lib/node_modules/react-dom/profiling.js +38 -0
  83. data/lib/node_modules/react-dom/server.browser.js +17 -0
  84. data/lib/node_modules/react-dom/server.js +3 -0
  85. data/lib/node_modules/react-dom/server.node.js +17 -0
  86. data/lib/node_modules/react-dom/test-utils.js +7 -0
  87. data/lib/node_modules/react-dom/umd/react-dom-server-legacy.browser.development.js +7026 -0
  88. data/lib/node_modules/react-dom/umd/react-dom-server-legacy.browser.production.min.js +75 -0
  89. data/lib/node_modules/react-dom/umd/react-dom-server.browser.development.js +7011 -0
  90. data/lib/node_modules/react-dom/umd/react-dom-server.browser.production.min.js +76 -0
  91. data/lib/node_modules/react-dom/umd/react-dom-test-utils.development.js +1759 -0
  92. data/lib/node_modules/react-dom/umd/react-dom-test-utils.production.min.js +33 -0
  93. data/lib/node_modules/react-dom/umd/react-dom.development.js +29924 -0
  94. data/lib/node_modules/react-dom/umd/react-dom.production.min.js +267 -0
  95. data/lib/node_modules/react-dom/umd/react-dom.profiling.min.js +285 -0
  96. data/lib/node_modules/react-router/CHANGELOG.md +1526 -0
  97. data/lib/node_modules/react-router/LICENSE.md +23 -0
  98. data/lib/node_modules/react-router/README.md +7 -0
  99. data/lib/node_modules/react-router/dist/development/chunk-KNED5TY2.mjs +10476 -0
  100. data/lib/node_modules/react-router/dist/development/dom-export.d.mts +23 -0
  101. data/lib/node_modules/react-router/dist/development/dom-export.d.ts +23 -0
  102. data/lib/node_modules/react-router/dist/development/dom-export.js +6111 -0
  103. data/lib/node_modules/react-router/dist/development/dom-export.mjs +234 -0
  104. data/lib/node_modules/react-router/dist/development/fog-of-war-1hWhK5ey.d.mts +1690 -0
  105. data/lib/node_modules/react-router/dist/development/fog-of-war-oa9CGk10.d.ts +1690 -0
  106. data/lib/node_modules/react-router/dist/development/future-ldDp5FKH.d.mts +21 -0
  107. data/lib/node_modules/react-router/dist/development/future-ldDp5FKH.d.ts +21 -0
  108. data/lib/node_modules/react-router/dist/development/index.d.mts +841 -0
  109. data/lib/node_modules/react-router/dist/development/index.d.ts +841 -0
  110. data/lib/node_modules/react-router/dist/development/index.js +10624 -0
  111. data/lib/node_modules/react-router/dist/development/index.mjs +242 -0
  112. data/lib/node_modules/react-router/dist/development/lib/types/route-module.d.mts +209 -0
  113. data/lib/node_modules/react-router/dist/development/lib/types/route-module.d.ts +209 -0
  114. data/lib/node_modules/react-router/dist/development/lib/types/route-module.js +28 -0
  115. data/lib/node_modules/react-router/dist/development/lib/types/route-module.mjs +10 -0
  116. data/lib/node_modules/react-router/dist/development/route-data-5OzAzQtT.d.mts +1716 -0
  117. data/lib/node_modules/react-router/dist/development/route-data-5OzAzQtT.d.ts +1716 -0
  118. data/lib/node_modules/react-router/dist/production/chunk-ZIM7OIE3.mjs +10476 -0
  119. data/lib/node_modules/react-router/dist/production/dom-export.d.mts +23 -0
  120. data/lib/node_modules/react-router/dist/production/dom-export.d.ts +23 -0
  121. data/lib/node_modules/react-router/dist/production/dom-export.js +6111 -0
  122. data/lib/node_modules/react-router/dist/production/dom-export.mjs +234 -0
  123. data/lib/node_modules/react-router/dist/production/fog-of-war-1hWhK5ey.d.mts +1690 -0
  124. data/lib/node_modules/react-router/dist/production/fog-of-war-oa9CGk10.d.ts +1690 -0
  125. data/lib/node_modules/react-router/dist/production/future-ldDp5FKH.d.mts +21 -0
  126. data/lib/node_modules/react-router/dist/production/future-ldDp5FKH.d.ts +21 -0
  127. data/lib/node_modules/react-router/dist/production/index.d.mts +841 -0
  128. data/lib/node_modules/react-router/dist/production/index.d.ts +841 -0
  129. data/lib/node_modules/react-router/dist/production/index.js +10624 -0
  130. data/lib/node_modules/react-router/dist/production/index.mjs +242 -0
  131. data/lib/node_modules/react-router/dist/production/lib/types/route-module.d.mts +209 -0
  132. data/lib/node_modules/react-router/dist/production/lib/types/route-module.d.ts +209 -0
  133. data/lib/node_modules/react-router/dist/production/lib/types/route-module.js +28 -0
  134. data/lib/node_modules/react-router/dist/production/lib/types/route-module.mjs +10 -0
  135. data/lib/node_modules/react-router/dist/production/route-data-5OzAzQtT.d.mts +1716 -0
  136. data/lib/node_modules/react-router/dist/production/route-data-5OzAzQtT.d.ts +1716 -0
  137. data/lib/node_modules/react-router/package.json +116 -0
  138. data/lib/node_modules/react-router-dom/LICENSE.md +23 -0
  139. data/lib/node_modules/react-router-dom/README.md +6 -0
  140. data/lib/node_modules/react-router-dom/dist/index.d.mts +2 -0
  141. data/lib/node_modules/react-router-dom/dist/index.d.ts +2 -0
  142. data/lib/node_modules/react-router-dom/dist/index.js +45 -0
  143. data/lib/node_modules/react-router-dom/dist/index.mjs +18 -0
  144. data/lib/node_modules/react-router-dom/package.json +82 -0
  145. data/lib/node_modules/scheduler/LICENSE +21 -0
  146. data/lib/node_modules/scheduler/README.md +9 -0
  147. data/lib/node_modules/scheduler/cjs/scheduler-unstable_mock.development.js +700 -0
  148. data/lib/node_modules/scheduler/cjs/scheduler-unstable_mock.production.min.js +20 -0
  149. data/lib/node_modules/scheduler/cjs/scheduler-unstable_post_task.development.js +207 -0
  150. data/lib/node_modules/scheduler/cjs/scheduler-unstable_post_task.production.min.js +14 -0
  151. data/lib/node_modules/scheduler/cjs/scheduler.development.js +634 -0
  152. data/lib/node_modules/scheduler/cjs/scheduler.production.min.js +19 -0
  153. data/lib/node_modules/scheduler/index.js +7 -0
  154. data/lib/node_modules/scheduler/package.json +36 -0
  155. data/lib/node_modules/scheduler/umd/scheduler-unstable_mock.development.js +699 -0
  156. data/lib/node_modules/scheduler/umd/scheduler-unstable_mock.production.min.js +19 -0
  157. data/lib/node_modules/scheduler/umd/scheduler.development.js +152 -0
  158. data/lib/node_modules/scheduler/umd/scheduler.production.min.js +146 -0
  159. data/lib/node_modules/scheduler/umd/scheduler.profiling.min.js +146 -0
  160. data/lib/node_modules/scheduler/unstable_mock.js +7 -0
  161. data/lib/node_modules/scheduler/unstable_post_task.js +7 -0
  162. data/lib/node_modules/set-cookie-parser/LICENSE +21 -0
  163. data/lib/node_modules/set-cookie-parser/README.md +202 -0
  164. data/lib/node_modules/set-cookie-parser/lib/set-cookie.js +224 -0
  165. data/lib/node_modules/set-cookie-parser/package.json +45 -0
  166. data/lib/node_modules/turbo-stream/LICENSE +7 -0
  167. data/lib/node_modules/turbo-stream/README.md +31 -0
  168. data/lib/node_modules/turbo-stream/dist/flatten.d.ts +2 -0
  169. data/lib/node_modules/turbo-stream/dist/flatten.js +203 -0
  170. data/lib/node_modules/turbo-stream/dist/turbo-stream.d.ts +13 -0
  171. data/lib/node_modules/turbo-stream/dist/turbo-stream.js +207 -0
  172. data/lib/node_modules/turbo-stream/dist/turbo-stream.mjs +673 -0
  173. data/lib/node_modules/turbo-stream/dist/unflatten.d.ts +2 -0
  174. data/lib/node_modules/turbo-stream/dist/unflatten.js +243 -0
  175. data/lib/node_modules/turbo-stream/dist/utils.d.ts +44 -0
  176. data/lib/node_modules/turbo-stream/dist/utils.js +55 -0
  177. data/lib/node_modules/turbo-stream/package.json +50 -0
  178. data/lib/package-lock.json +133 -0
  179. data/lib/package.json +12 -0
  180. data/lib/rubee/async/asyncable.rb +2 -2
  181. data/lib/rubee/async/sidekiq_async.rb +11 -11
  182. data/lib/rubee/async/thread_async.rb +1 -1
  183. data/lib/rubee/async/thread_pool.rb +2 -2
  184. data/lib/rubee/controllers/base_controller.rb +44 -21
  185. data/lib/rubee/controllers/extensions/auth_tokenable.rb +10 -8
  186. data/lib/rubee/controllers/extensions/middlewarable.rb +1 -1
  187. data/lib/rubee/controllers/middlewares/auth_token_middleware.rb +12 -8
  188. data/lib/rubee/extensions/hookable.rb +3 -6
  189. data/lib/rubee/extensions/serializable.rb +3 -3
  190. data/lib/rubee/models/database_objectable.rb +11 -12
  191. data/lib/rubee/models/sequel_object.rb +23 -24
  192. data/lib/rubee.rb +106 -55
  193. data/lib/tests/account_model_test.rb +4 -4
  194. data/lib/tests/auth_tokenable_test.rb +6 -6
  195. data/lib/tests/comment_model_test.rb +7 -7
  196. data/lib/tests/example_models/account.rb +1 -0
  197. data/lib/tests/example_models/comment.rb +1 -0
  198. data/lib/tests/example_models/post.rb +1 -0
  199. data/lib/tests/example_models/user.rb +1 -0
  200. data/lib/tests/rubeeapp_test.rb +21 -6
  201. data/lib/tests/test.db +0 -0
  202. data/lib/tests/test_helper.rb +3 -5
  203. data/lib/tests/user_model_test.rb +71 -54
  204. data/readme.md +104 -2
  205. metadata +170 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5810b6eb69d752cea118184cc0fd70559a7b6c76024f3fa2cccca1eaedc7305e
4
- data.tar.gz: 648ef60b8a9d94ec49c5cd8e31882873637660935097cadcca5124aad19198ba
3
+ metadata.gz: f60bb8f17e35447c9cedd635d719a6b0d988486f9fe04668e0e07763a99cb740
4
+ data.tar.gz: a56dcac76060f5bb9ec71959ef4d21fa7c3e9b858eb6088e873e3ba50e4684f0
5
5
  SHA512:
6
- metadata.gz: 30c9cdc416a9875128b2ca186cf0a60ae9f85463f49492c625972d8a908a1acab524f024c926a2fcc05f519af3b5112f96bcc32a0953b756f57effdb7eaefe49
7
- data.tar.gz: 21de68b11a410bd67aeea32707409ecc173b3af5dceab016675c41904cc6e452dcc889668c05ec1918e5a683049f02ebfce778fc3c0f2008e071ea49c8ffe5b1
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" + (LOGO % Rubee::VERSION) + "\e[0m" # Cyan color
26
+ puts "\e[36m#{LOGO % Rubee::VERSION}\e[0m" # Cyan color
33
27
  end
34
28
 
35
29
  if command =~ /^(start)$|^(start:(\d+))$/
36
- command, port = ARGV.first&.split(':')
30
+ _, port = ARGV.first&.split(':')
37
31
 
38
- port ||= "7000"
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
- command, port = ARGV.first&.split(':')
37
+ _, port = ARGV.first&.split(':')
44
38
 
45
- port ||= "7000"
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 == "stop"
52
- exec("pkill -f rubee")
53
- elsif command == "status"
54
- exec("ps aux | grep rubee")
55
- elsif command == "project"
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 "Please indicate project name.", color: :red
70
+ color_puts 'Please indicate project name.', color: :red
59
71
  exit 1
60
72
  end
61
73
 
62
- if project_name == "rubee"
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("../lib", __dir__)
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 development.db production.db]
80
- blacklist_dirs = %w[rubee tests .git .github .idea]
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
- source 'https://rubygems.org'
108
-
109
- gem 'ru.Bee'
110
- gem 'sequel'
111
- gem 'sqlite3'
112
- gem 'rake'
113
- gem 'rack'
114
- gem 'rackup'
115
- gem 'pry'
116
- gem 'pry-byebug'
117
- gem 'puma'
118
- gem 'json'
119
-
120
- group :development do
121
- gem 'rerun'
122
- gem 'minitest'
123
- gem 'rack-test'
124
- end
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
- require "bundler/setup"
134
- Bundler.require(:test)
151
+ require "bundler/setup"
152
+ Bundler.require(:test)
135
153
 
136
- require 'minitest/autorun'
137
- require 'rack/test'
138
- require 'rubee'
154
+ require 'minitest/autorun'
155
+ require 'rack/test'
156
+ require 'rubee'
139
157
 
140
- Rubee::Autoload.call
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 == "version"
167
+ elsif command == 'version'
150
168
  color_puts "ru.Bee v#{Rubee::VERSION}", color: :yellow
151
- elsif command == "test"
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 "Running all tests ...", color: :yellow
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 ['generate', 'gen'].include? command
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('config/routes.rb'))
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 == "db"
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=:test) do |config|
184
- config.database_url = { url: "sqlite://lib/tests/test.db", env: }
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 "sqlite"
216
+ when 'sqlite'
193
217
  begin
194
218
  Sequel.connect(db_url)
195
- color_puts "Database #{ENV['RACK_ENV']} exists", color: :cyan
196
- rescue Exception => e
197
- if File.exist?(db_path = db_url.sub(/^sqlite:\/\//, ''))
198
- color_puts "Database #{ENV['RACK_ENV']} exists", color: :cyan
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 "Database #{ENV['RACK_ENV']} created", color: :green
225
+ color_puts("Database #{ENV['RACK_ENV']} created", color: :green)
202
226
  end
203
227
  end
204
- when "postgres"
228
+ when 'postgres'
205
229
  begin
206
230
  Sequel.connect(db_url)
207
- color_puts "Database #{ENV['RACK_ENV']} exists", color: :cyan
208
- rescue => _
209
- con = Sequel.connect(Rubee::Configuration.get_database_url.gsub(/(\/test|\/development|\/production)/, ''))
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 "Database #{ENV['RACK_ENV']} created", color: :green
235
+ color_puts("Database #{ENV['RACK_ENV']} created", color: :green)
212
236
  end
213
237
  else
214
- color_puts "Unsupported database type: #{db_url}", color: :red
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
- .gsub(/\"(\w+)\":/, '\1:') # Convert keys to symbols
230
- .gsub(': null', ': nil') # Convert `null` to `nil`
253
+ .gsub(/"(\w+)":/, '\1:') # Convert keys to symbols
254
+ .gsub(': null', ': nil') # Convert `null` to `nil`
231
255
 
232
- File.open("db/structure.rb", 'w') do |file|
256
+ File.open('db/structure.rb', 'w') do |file|
233
257
  file.puts "STRUCTURE = #{formatted_hash}"
234
258
  end
235
259
 
236
- color_puts "db/structure.rb updated", color: :green
260
+ color_puts('db/structure.rb updated', color: :green)
237
261
  end
238
262
 
239
-
240
- if command == 'run'
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 { |file| File.basename(file, '.rb') }.select { |file| file != 'structure' }
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 "Run #{file_name} file for #{env} env", color: :cyan
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 "Migration for #{file_name} completed", color: :green
281
+ color_puts("Migration for #{file_name} completed", color: :green)
256
282
  unless Rubee::PROJECT_NAME == 'rubee'
257
- color_puts "Regenerate schema file", color: :cyan
283
+ color_puts('Regenerate schema file', color: :cyan)
258
284
  generate_structure
259
285
  end
260
- elsif command == 'init'
286
+ when 'init'
261
287
  ensure_database_exists(Rubee::Configuration.get_database_url)
262
- elsif command == 'structure'
288
+ when 'structure'
263
289
  generate_structure
264
290
  else
265
- color_puts "Unknown command: #{command}", color: :red
291
+ color_puts("Unknown command: #{command}", color: :red)
266
292
  end
267
- elsif ['console'].include? command
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=:test) do |config|
274
- config.database_url = { url: "sqlite://lib/tests/test.db", env: }
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 file }
283
- color_puts "Reloaded ..", color: :green
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 => e
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>
@@ -40,7 +40,7 @@
40
40
  }
41
41
  </style>
42
42
  </head>
43
- <body>
44
- <%= _yield_template %>
45
- </body>
43
+ <body>
44
+ <%= _yield_template %>
45
+ </body>
46
46
  </html>
@@ -0,0 +1,9 @@
1
+ import { useEffect } from "react";
2
+
3
+ export function RedirectToBackend({ url }: { url: string }) {
4
+ useEffect(() => {
5
+ window.location.replace(url);
6
+ }, []);
7
+
8
+ return null; // or a spinner while redirecting
9
+ }
@@ -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="ruBee">
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=:development) do |config|
2
- config.database_url = { url: "sqlite://db/development.db", env: }
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=:test) do |config|
6
- config.database_url = { url: "sqlite://db/test.db", env: }
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=:production) do |config|
10
- config.database_url = { url: "sqlite://db/production.db", env: }
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
@@ -1,3 +1,4 @@
1
1
  Rubee::Router.draw do |router|
2
- router.get "/", to: "welcome#show" # override it for your app
2
+ router.get('/', to: 'welcome#show') # override it for your app
3
3
  end
4
+
@@ -1,14 +1,14 @@
1
1
  class CreateAccounts
2
2
  def call
3
- unless Rubee::SequelObject::DB.tables.include?(:accounts)
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
- Account.create(addres: "13th Ave, NY", user_id: User.all.first.id)
11
- Account.create(addres: "14th Ave, NY", user_id: User.all.last.id)
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
@@ -1,13 +1,13 @@
1
1
  class CreateComments
2
2
  def call
3
- unless Rubee::SequelObject::DB.tables.include?(:comments)
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
- User.create(email: "ok@ok.com", password: "password")
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
@@ -1,14 +1,14 @@
1
1
  class CreatePosts
2
2
  def call
3
- unless Rubee::SequelObject::DB.tables.include?(:posts)
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
- Post.create(user_id: User.all.first.id, comment_id: Comment.all.first.id)
11
- Post.create(user_id: User.all.last.id, comment_id: Comment.all.last.id)
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
@@ -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
- unless Rubee::SequelObject::DB.tables.include?(:users)
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
- User.create(email: "ok@ok.com", password: "password")
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