activeadmin-tom_select 4.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 (196) hide show
  1. checksums.yaml +7 -0
  2. data/.actrc +20 -0
  3. data/.claude/commands/fix-tests.md +203 -0
  4. data/.github/workflows/ci.yml +174 -0
  5. data/.github/workflows/npm-publish.yml +50 -0
  6. data/.gitignore +35 -0
  7. data/.npmignore +58 -0
  8. data/.rspec +1 -0
  9. data/.rubocop.yml +75 -0
  10. data/.yardopts +2 -0
  11. data/AGENTS.md +39 -0
  12. data/Appraisals +9 -0
  13. data/CHANGELOG.md +64 -0
  14. data/CLAUDE.md +157 -0
  15. data/Gemfile +12 -0
  16. data/Gemfile.lock +368 -0
  17. data/LICENSE.txt +25 -0
  18. data/README.md +483 -0
  19. data/Rakefile +4 -0
  20. data/activeadmin-tom_select.gemspec +43 -0
  21. data/bin/rspec +17 -0
  22. data/config/database.yml +16 -0
  23. data/docs/activeadmin-4-detailed-reference.md +932 -0
  24. data/docs/activeadmin-4-gem-migration-guide.md +313 -0
  25. data/docs/combustion.md +213 -0
  26. data/docs/fail.png +0 -0
  27. data/docs/guide-update-your-app.md +283 -0
  28. data/docs/normal.png +0 -0
  29. data/docs/propshaft-readme.md +320 -0
  30. data/docs/propshaft-upgrade.md +484 -0
  31. data/docs/setup-activeadmin-app.md +552 -0
  32. data/docs/setup-activeadmin-gem.md +535 -0
  33. data/docs/tailwind/blog-page.md +341 -0
  34. data/docs/tailwind/upgrade-guide-enhanced.md +438 -0
  35. data/docs/tailwind/upgrade-guide.md +416 -0
  36. data/docs/tailwind-4/active_admin.rake +38 -0
  37. data/docs/tailwind-4/active_admin.tailwind.css +415 -0
  38. data/docs/tailwind-4/tailwind-active_admin.config.js +18 -0
  39. data/docs/test-app-change.md +154 -0
  40. data/docs/test-environment-fixes.md +58 -0
  41. data/docs/update-tom-select.md +184 -0
  42. data/docs/upload-system.md +225 -0
  43. data/gemfiles/rails_7.x_active_admin_4.x.gemfile +10 -0
  44. data/gemfiles/rails_7.x_active_admin_4.x.gemfile.lock +377 -0
  45. data/gemfiles/rails_8.x_active_admin_4.x.gemfile +10 -0
  46. data/gemfiles/rails_8.x_active_admin_4.x.gemfile.lock +372 -0
  47. data/lefthook.yml +17 -0
  48. data/lib/activeadmin/inputs/filters/searchable_select_input.rb +19 -0
  49. data/lib/activeadmin/inputs/searchable_select_input.rb +16 -0
  50. data/lib/activeadmin/tom_select/engine.rb +17 -0
  51. data/lib/activeadmin/tom_select/option_collection.rb +128 -0
  52. data/lib/activeadmin/tom_select/resource_dsl_extension.rb +56 -0
  53. data/lib/activeadmin/tom_select/resource_extension.rb +10 -0
  54. data/lib/activeadmin/tom_select/select_input_extension.rb +168 -0
  55. data/lib/activeadmin/tom_select/version.rb +5 -0
  56. data/lib/activeadmin/tom_select.rb +20 -0
  57. data/lib/activeadmin-tom_select.rb +5 -0
  58. data/lib/generators/active_admin/tom_select/install/install_generator.rb +180 -0
  59. data/npm-package/package-lock.json +51 -0
  60. data/npm-package/package.json +43 -0
  61. data/npm-package/src/index.js +153 -0
  62. data/npm-package/src/tom-select-tailwind.css +392 -0
  63. data/sonar-project.properties +25 -0
  64. data/spec/features/ajax_params_spec.rb +31 -0
  65. data/spec/features/asset_pipeline_diagnostic_spec.rb +155 -0
  66. data/spec/features/end_to_end_spec.rb +273 -0
  67. data/spec/features/filter_input_spec.rb +144 -0
  68. data/spec/features/form_input_spec.rb +122 -0
  69. data/spec/features/inline_ajax_setting_spec.rb +26 -0
  70. data/spec/features/input_errors_spec.rb +76 -0
  71. data/spec/features/input_html_options_spec.rb +30 -0
  72. data/spec/features/options_dsl_spec.rb +230 -0
  73. data/spec/features/production_build_spec.rb +108 -0
  74. data/spec/internal/.node-version +1 -0
  75. data/spec/internal/Gemfile +43 -0
  76. data/spec/internal/Gemfile.lock +333 -0
  77. data/spec/internal/Procfile.dev +3 -0
  78. data/spec/internal/README.md +24 -0
  79. data/spec/internal/Rakefile +6 -0
  80. data/spec/internal/app/admin/categories.rb +26 -0
  81. data/spec/internal/app/admin/dashboard.rb +29 -0
  82. data/spec/internal/app/admin/option_types.rb +19 -0
  83. data/spec/internal/app/admin/option_values.rb +30 -0
  84. data/spec/internal/app/admin/posts.rb +27 -0
  85. data/spec/internal/app/admin/products.rb +22 -0
  86. data/spec/internal/app/admin/rgb_colors.rb +25 -0
  87. data/spec/internal/app/admin/tag_names.rb +21 -0
  88. data/spec/internal/app/admin/test_ajax_params_category.rb +10 -0
  89. data/spec/internal/app/admin/test_ajax_params_post.rb +20 -0
  90. data/spec/internal/app/admin/test_form_post_class.rb +7 -0
  91. data/spec/internal/app/admin/test_form_post_custom.rb +11 -0
  92. data/spec/internal/app/admin/test_form_post_resource.rb +11 -0
  93. data/spec/internal/app/admin/test_form_post_resource_custom.rb +12 -0
  94. data/spec/internal/app/admin/test_inline_ajax_post.rb +9 -0
  95. data/spec/internal/app/admin/test_input_html_post.rb +11 -0
  96. data/spec/internal/app/admin/test_posts_display_text.rb +9 -0
  97. data/spec/internal/app/admin/test_posts_filter.rb +9 -0
  98. data/spec/internal/app/admin/test_posts_named.rb +9 -0
  99. data/spec/internal/app/admin/test_posts_pagination.rb +9 -0
  100. data/spec/internal/app/admin/test_posts_payload_lambda.rb +11 -0
  101. data/spec/internal/app/admin/test_posts_payload_proc.rb +9 -0
  102. data/spec/internal/app/admin/test_posts_scope_lambda.rb +8 -0
  103. data/spec/internal/app/admin/test_posts_scope_params.rb +8 -0
  104. data/spec/internal/app/admin/test_posts_scope_user.rb +8 -0
  105. data/spec/internal/app/admin/test_posts_text_attr.rb +5 -0
  106. data/spec/internal/app/admin/users.rb +23 -0
  107. data/spec/internal/app/admin/variants.rb +31 -0
  108. data/spec/internal/app/assets/config/manifest.js +2 -0
  109. data/spec/internal/app/assets/images/.keep +0 -0
  110. data/spec/internal/app/assets/stylesheets/active_admin.tailwind.css +16 -0
  111. data/spec/internal/app/assets/stylesheets/application.tailwind.css +15 -0
  112. data/spec/internal/app/controllers/application_controller.rb +9 -0
  113. data/spec/internal/app/controllers/concerns/.keep +0 -0
  114. data/spec/internal/app/helpers/application_helper.rb +2 -0
  115. data/spec/internal/app/javascript/active_admin.js +19 -0
  116. data/spec/internal/app/javascript/application.js +2 -0
  117. data/spec/internal/app/jobs/application_job.rb +7 -0
  118. data/spec/internal/app/mailers/application_mailer.rb +4 -0
  119. data/spec/internal/app/models/admin_user.rb +9 -0
  120. data/spec/internal/app/models/application_record.rb +3 -0
  121. data/spec/internal/app/models/article.rb +12 -0
  122. data/spec/internal/app/models/category.rb +12 -0
  123. data/spec/internal/app/models/color.rb +9 -0
  124. data/spec/internal/app/models/concerns/.keep +0 -0
  125. data/spec/internal/app/models/internal/tag_name.rb +14 -0
  126. data/spec/internal/app/models/internal_tag_name.rb +11 -0
  127. data/spec/internal/app/models/option_type.rb +12 -0
  128. data/spec/internal/app/models/option_value.rb +4 -0
  129. data/spec/internal/app/models/post.rb +15 -0
  130. data/spec/internal/app/models/product.rb +12 -0
  131. data/spec/internal/app/models/rgb_color.rb +16 -0
  132. data/spec/internal/app/models/tag.rb +12 -0
  133. data/spec/internal/app/models/tagging.rb +12 -0
  134. data/spec/internal/app/models/user.rb +12 -0
  135. data/spec/internal/app/models/variant.rb +12 -0
  136. data/spec/internal/app/views/layouts/application.html.erb +28 -0
  137. data/spec/internal/app/views/layouts/mailer.html.erb +13 -0
  138. data/spec/internal/app/views/layouts/mailer.text.erb +1 -0
  139. data/spec/internal/app/views/pwa/manifest.json.erb +22 -0
  140. data/spec/internal/app/views/pwa/service-worker.js +26 -0
  141. data/spec/internal/bin/bundle +117 -0
  142. data/spec/internal/bin/dev +11 -0
  143. data/spec/internal/bin/rackup +27 -0
  144. data/spec/internal/bin/rails +4 -0
  145. data/spec/internal/bin/rake +4 -0
  146. data/spec/internal/bin/setup +37 -0
  147. data/spec/internal/config/application.rb +50 -0
  148. data/spec/internal/config/boot.rb +3 -0
  149. data/spec/internal/config/credentials.yml.enc +1 -0
  150. data/spec/internal/config/database.yml +32 -0
  151. data/spec/internal/config/environment.rb +5 -0
  152. data/spec/internal/config/environments/development.rb +63 -0
  153. data/spec/internal/config/environments/production.rb +86 -0
  154. data/spec/internal/config/environments/test.rb +50 -0
  155. data/spec/internal/config/initializers/active_admin.rb +54 -0
  156. data/spec/internal/config/initializers/assets.rb +8 -0
  157. data/spec/internal/config/initializers/content_security_policy.rb +25 -0
  158. data/spec/internal/config/initializers/devise.rb +315 -0
  159. data/spec/internal/config/initializers/filter_parameter_logging.rb +8 -0
  160. data/spec/internal/config/initializers/inflections.rb +16 -0
  161. data/spec/internal/config/initializers/searchable_select.rb +6 -0
  162. data/spec/internal/config/locales/devise.en.yml +65 -0
  163. data/spec/internal/config/locales/en.yml +31 -0
  164. data/spec/internal/config/master.key +1 -0
  165. data/spec/internal/config/puma.rb +38 -0
  166. data/spec/internal/config/routes.rb +17 -0
  167. data/spec/internal/config.ru +6 -0
  168. data/spec/internal/db/schema.rb +174 -0
  169. data/spec/internal/db/seeds.rb +167 -0
  170. data/spec/internal/esbuild.config.js +34 -0
  171. data/spec/internal/lib/tasks/.keep +0 -0
  172. data/spec/internal/lib/tasks/active_admin.rake +55 -0
  173. data/spec/internal/log/.keep +0 -0
  174. data/spec/internal/package-lock.json +1954 -0
  175. data/spec/internal/package.json +21 -0
  176. data/spec/internal/public/400.html +114 -0
  177. data/spec/internal/public/404.html +114 -0
  178. data/spec/internal/public/406-unsupported-browser.html +114 -0
  179. data/spec/internal/public/422.html +114 -0
  180. data/spec/internal/public/500.html +114 -0
  181. data/spec/internal/public/icon.png +0 -0
  182. data/spec/internal/public/icon.svg +3 -0
  183. data/spec/internal/public/robots.txt +1 -0
  184. data/spec/internal/script/.keep +0 -0
  185. data/spec/internal/storage/.keep +0 -0
  186. data/spec/internal/tailwind.config.js +23 -0
  187. data/spec/internal/vendor/.keep +0 -0
  188. data/spec/internal/yarn.lock +824 -0
  189. data/spec/rails_helper.rb +62 -0
  190. data/spec/spec_helper.rb +138 -0
  191. data/spec/support/active_admin_helpers.rb +17 -0
  192. data/spec/support/capybara.rb +8 -0
  193. data/spec/support/models.rb +11 -0
  194. data/spec/support/pluck_polyfill.rb +12 -0
  195. data/spec/support/reset_settings.rb +5 -0
  196. metadata +497 -0
@@ -0,0 +1,174 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema[8.0].define(version: 0) do
14
+ create_table 'active_admin_comments', force: :cascade do |t|
15
+ t.string 'namespace'
16
+ t.text 'body'
17
+ t.string 'resource_type'
18
+ t.integer 'resource_id'
19
+ t.string 'author_type'
20
+ t.integer 'author_id'
21
+ t.datetime 'created_at', null: false
22
+ t.datetime 'updated_at', null: false
23
+ t.index %w[author_type author_id], name: 'index_active_admin_comments_on_author'
24
+ t.index ['namespace'], name: 'index_active_admin_comments_on_namespace'
25
+ t.index %w[resource_type resource_id], name: 'index_active_admin_comments_on_resource'
26
+ end
27
+
28
+ create_table 'admin_users', force: :cascade do |t|
29
+ t.string 'email', default: '', null: false
30
+ t.string 'encrypted_password', default: '', null: false
31
+ t.string 'reset_password_token'
32
+ t.datetime 'reset_password_sent_at'
33
+ t.datetime 'remember_created_at'
34
+ t.datetime 'created_at', null: false
35
+ t.datetime 'updated_at', null: false
36
+ t.index ['email'], name: 'index_admin_users_on_email', unique: true
37
+ t.index ['reset_password_token'], name: 'index_admin_users_on_reset_password_token',
38
+ unique: true
39
+ end
40
+
41
+ create_table 'articles', force: :cascade do |t|
42
+ t.string 'title'
43
+ t.text 'body'
44
+ t.integer 'category_id'
45
+ t.datetime 'created_at', null: false
46
+ t.datetime 'updated_at', null: false
47
+ t.index ['category_id'], name: 'index_articles_on_category_id'
48
+ end
49
+
50
+ create_table 'categories', force: :cascade do |t|
51
+ t.string 'name'
52
+ t.text 'description'
53
+ t.integer 'created_by_id'
54
+ t.datetime 'created_at', null: false
55
+ t.datetime 'updated_at', null: false
56
+ t.index ['created_by_id'], name: 'index_categories_on_created_by_id'
57
+ end
58
+
59
+ create_table 'colors', force: :cascade do |t|
60
+ t.string 'name'
61
+ t.string 'hex'
62
+ t.datetime 'created_at', null: false
63
+ t.datetime 'updated_at', null: false
64
+ end
65
+
66
+ create_table 'internal_tag_names', force: :cascade do |t|
67
+ t.string 'name'
68
+ t.datetime 'created_at', null: false
69
+ t.datetime 'updated_at', null: false
70
+ end
71
+
72
+ create_table 'option_types', force: :cascade do |t|
73
+ t.string 'name'
74
+ t.integer 'position'
75
+ t.datetime 'created_at', null: false
76
+ t.datetime 'updated_at', null: false
77
+ end
78
+
79
+ create_table 'option_values', force: :cascade do |t|
80
+ t.string 'name'
81
+ t.integer 'option_type_id'
82
+ t.datetime 'created_at', null: false
83
+ t.datetime 'updated_at', null: false
84
+ t.index ['option_type_id'], name: 'index_option_values_on_option_type_id'
85
+ end
86
+
87
+ create_table 'posts', force: :cascade do |t|
88
+ t.string 'title'
89
+ t.text 'body'
90
+ t.integer 'category_id'
91
+ t.integer 'created_by_id'
92
+ t.integer 'user_id'
93
+ t.integer 'color_id'
94
+ t.boolean 'published', default: false
95
+ t.integer 'position'
96
+ t.datetime 'created_at', null: false
97
+ t.datetime 'updated_at', null: false
98
+ t.index ['category_id'], name: 'index_posts_on_category_id'
99
+ t.index ['color_id'], name: 'index_posts_on_color_id'
100
+ t.index ['created_by_id'], name: 'index_posts_on_created_by_id'
101
+ t.index ['user_id'], name: 'index_posts_on_user_id'
102
+ end
103
+
104
+ create_table 'posts_tags', id: false, force: :cascade do |t|
105
+ t.integer 'post_id', null: false
106
+ t.integer 'tag_id', null: false
107
+ t.index ['post_id'], name: 'index_posts_tags_on_post_id'
108
+ t.index ['tag_id'], name: 'index_posts_tags_on_tag_id'
109
+ end
110
+
111
+ create_table 'products', force: :cascade do |t|
112
+ t.string 'name'
113
+ t.integer 'option_type_id'
114
+ t.datetime 'created_at', null: false
115
+ t.datetime 'updated_at', null: false
116
+ t.index ['option_type_id'], name: 'index_products_on_option_type_id'
117
+ end
118
+
119
+ create_table 'rgb_colors', force: :cascade do |t|
120
+ t.string 'name'
121
+ t.string 'code'
122
+ t.text 'description'
123
+ t.datetime 'created_at', null: false
124
+ t.datetime 'updated_at', null: false
125
+ end
126
+
127
+ create_table 'taggings', force: :cascade do |t|
128
+ t.integer 'tag_id'
129
+ t.string 'taggable_type'
130
+ t.integer 'taggable_id'
131
+ t.string 'tagger_type'
132
+ t.integer 'tagger_id'
133
+ t.string 'context', limit: 128
134
+ t.datetime 'created_at', null: false
135
+ t.datetime 'updated_at', null: false
136
+ t.index ['context'], name: 'index_taggings_on_context'
137
+ t.index %w[tag_id taggable_id taggable_type context tagger_id tagger_type],
138
+ name: 'taggings_idx', unique: true
139
+ t.index ['tag_id'], name: 'index_taggings_on_tag_id'
140
+ t.index %w[taggable_id taggable_type context], name: 'taggings_taggable_context_idx'
141
+ t.index %w[taggable_id taggable_type tagger_id context], name: 'taggings_idy'
142
+ t.index ['taggable_id'], name: 'index_taggings_on_taggable_id'
143
+ t.index %w[taggable_type taggable_id], name: 'index_taggings_on_taggable'
144
+ t.index ['taggable_type'], name: 'index_taggings_on_taggable_type'
145
+ t.index %w[tagger_id tagger_type], name: 'index_taggings_on_tagger'
146
+ t.index ['tagger_id'], name: 'index_taggings_on_tagger_id'
147
+ t.index %w[tagger_type tagger_id], name: 'index_taggings_on_tagger_type_and_tagger_id'
148
+ end
149
+
150
+ create_table 'tags', force: :cascade do |t|
151
+ t.string 'name'
152
+ t.integer 'taggings_count', default: 0
153
+ t.datetime 'created_at', null: false
154
+ t.datetime 'updated_at', null: false
155
+ t.index ['name'], name: 'index_tags_on_name', unique: true
156
+ end
157
+
158
+ create_table 'users', force: :cascade do |t|
159
+ t.string 'name'
160
+ t.string 'email'
161
+ t.datetime 'created_at', null: false
162
+ t.datetime 'updated_at', null: false
163
+ end
164
+
165
+ create_table 'variants', force: :cascade do |t|
166
+ t.integer 'product_id'
167
+ t.integer 'option_value_id'
168
+ t.decimal 'price'
169
+ t.datetime 'created_at', null: false
170
+ t.datetime 'updated_at', null: false
171
+ t.index ['option_value_id'], name: 'index_variants_on_option_value_id'
172
+ t.index ['product_id'], name: 'index_variants_on_product_id'
173
+ end
174
+ end
@@ -0,0 +1,167 @@
1
+ # This file should ensure the existence of records required to run the application in every
2
+ # environment (production, development, test). The code here should be idempotent so that it
3
+ # can be executed at any point in every environment. The data can then be loaded with the
4
+ # bin/rails db:seed command (or created alongside the database with db:setup).
5
+
6
+ # Create admin user for ActiveAdmin
7
+ AdminUser.find_or_create_by(email: 'admin@example.com') do |admin|
8
+ admin.password = 'password'
9
+ admin.password_confirmation = 'password'
10
+ end
11
+
12
+ # Create sample users
13
+ users = []
14
+ 10.times do |i|
15
+ users << User.find_or_create_by(name: "User #{i + 1}") do |user|
16
+ user.email = "user#{i + 1}@example.com"
17
+ end
18
+ end
19
+
20
+ # Create sample categories with created_by association
21
+ categories = []
22
+ 5.times do |i|
23
+ categories << Category.find_or_create_by(name: "Category #{i + 1}") do |category|
24
+ category.description = "Description for category #{i + 1}"
25
+ category.created_by = users.sample
26
+ end
27
+ end
28
+
29
+ # Create sample posts with published status
30
+ 20.times do |i|
31
+ Post.find_or_create_by(title: "Post #{i + 1}") do |post|
32
+ post.body = "Body content for post #{i + 1}"
33
+ post.category = categories.sample
34
+ post.user = users.sample
35
+ post.published = [true, false].sample
36
+ post.position = i
37
+ # We'll set color_id after colors are created
38
+ end
39
+ end
40
+
41
+ # Create RGB colors
42
+ rgb_colors_data = [
43
+ { code: '#FF0000', description: 'Red' },
44
+ { code: '#00FF00', description: 'Green' },
45
+ { code: '#0000FF', description: 'Blue' },
46
+ { code: '#FFFF00', description: 'Yellow' },
47
+ { code: '#FF00FF', description: 'Magenta' },
48
+ { code: '#00FFFF', description: 'Cyan' },
49
+ { code: '#000000', description: 'Black' },
50
+ { code: '#FFFFFF', description: 'White' }
51
+ ]
52
+
53
+ rgb_colors = rgb_colors_data.map do |color|
54
+ RgbColor.find_or_create_by(code: color[:code]) do |rgb|
55
+ rgb.description = color[:description]
56
+ end
57
+ end
58
+
59
+ # Create internal tag names
60
+ 10.times do |i|
61
+ InternalTagName.find_or_create_by(name: "Internal Tag #{i + 1}") do |tag|
62
+ tag.description = "Description for internal tag #{i + 1}"
63
+ tag.color_id = rgb_colors.sample.id
64
+ end
65
+ end
66
+
67
+ # Create option types and values
68
+ option_types = []
69
+ 3.times do |i|
70
+ option_type = OptionType.find_or_create_by(name: "Option Type #{i + 1}")
71
+ option_types << option_type
72
+
73
+ 5.times do |j|
74
+ OptionValue.find_or_create_by(
75
+ value: "Value #{j + 1} for #{option_type.name}",
76
+ option_type_id: option_type.id
77
+ )
78
+ end
79
+ end
80
+
81
+ # Create products and variants
82
+ 10.times do |i|
83
+ product = Product.find_or_create_by(name: "Product #{i + 1}") do |p|
84
+ p.option_type = option_types.sample
85
+ end
86
+
87
+ 3.times do |j|
88
+ option_value = product.option_type&.option_values&.sample
89
+ option_value_id = option_value&.id || OptionValue.first&.id
90
+
91
+ Variant.find_or_create_by(
92
+ product_id: product.id,
93
+ option_value_id: option_value_id
94
+ ) do |variant|
95
+ variant.price = (10 + j) * 100
96
+ end
97
+ end
98
+ end
99
+
100
+ # Create Colors (different from RGB colors)
101
+ colors_data = [
102
+ { name: 'Red', hex: '#FF0000' },
103
+ { name: 'Green', hex: '#00FF00' },
104
+ { name: 'Blue', hex: '#0000FF' },
105
+ { name: 'Orange', hex: '#FFA500' },
106
+ { name: 'Purple', hex: '#800080' }
107
+ ]
108
+
109
+ colors = colors_data.map do |color_attrs|
110
+ Color.find_or_create_by(name: color_attrs[:name]) do |color|
111
+ color.hex = color_attrs[:hex]
112
+ end
113
+ end
114
+
115
+ # Update posts with colors
116
+ Post.all.each do |post|
117
+ post.update(color: colors.sample) if post.color_id.nil?
118
+ end
119
+
120
+ # Create Tags
121
+ tags_data = [
122
+ { name: 'Ruby' },
123
+ { name: 'Rails' },
124
+ { name: 'JavaScript' },
125
+ { name: 'CSS' },
126
+ { name: 'HTML' },
127
+ { name: 'ActiveAdmin' },
128
+ { name: 'Testing' }
129
+ ]
130
+
131
+ tags = tags_data.map do |tag_attrs|
132
+ Tag.find_or_create_by(name: tag_attrs[:name])
133
+ end
134
+
135
+ # Create some taggings (many-to-many between posts and tags)
136
+ Post.all.sample(10).each do |post|
137
+ tags.sample(rand(1..3)).each do |tag|
138
+ Tagging.find_or_create_by(post_id: post.id, tag_id: tag.id)
139
+ end
140
+ end
141
+
142
+ # Create Articles
143
+ 5.times do |i|
144
+ Article.find_or_create_by(title: "Article #{i + 1}") do |article|
145
+ article.body = "Body content for article #{i + 1}"
146
+ article.category = categories.sample
147
+ end
148
+ end
149
+
150
+ puts '=' * 50
151
+ puts 'Seed data created successfully!'
152
+ puts '=' * 50
153
+ puts "AdminUsers: #{AdminUser.count}"
154
+ puts "Users: #{User.count}"
155
+ puts "Categories: #{Category.count}"
156
+ puts "Posts: #{Post.count}"
157
+ puts "Articles: #{Article.count}"
158
+ puts "RgbColors: #{RgbColor.count}"
159
+ puts "Colors: #{Color.count}"
160
+ puts "InternalTagNames: #{InternalTagName.count}"
161
+ puts "OptionTypes: #{OptionType.count}"
162
+ puts "OptionValues: #{OptionValue.count}"
163
+ puts "Products: #{Product.count}"
164
+ puts "Variants: #{Variant.count}"
165
+ puts "Tags: #{Tag.count}"
166
+ puts "Taggings: #{Tagging.count}"
167
+ puts '=' * 50
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ const esbuild = require('esbuild');
3
+ const path = require('path');
4
+
5
+ // Configuration for esbuild with proper module resolution
6
+ const config = {
7
+ entryPoints: ['app/javascript/active_admin.js'],
8
+ bundle: true,
9
+ sourcemap: true,
10
+ format: 'iife',
11
+ outdir: 'app/assets/builds',
12
+ publicPath: '/assets',
13
+ // Add node paths for module resolution
14
+ nodePaths: [
15
+ path.join(__dirname, 'node_modules'),
16
+ path.join(__dirname, '../../node_modules')
17
+ ]
18
+ };
19
+
20
+ // Check if we're in watch mode
21
+ const watchMode = process.argv.includes('--watch');
22
+
23
+ if (watchMode) {
24
+ // Start the build with watch mode
25
+ esbuild.context(config).then(ctx => {
26
+ ctx.watch();
27
+ console.log('Watching for changes...');
28
+ });
29
+ } else {
30
+ // Single build
31
+ esbuild.build(config).then(() => {
32
+ console.log('Build completed');
33
+ }).catch(() => process.exit(1));
34
+ }
File without changes
@@ -0,0 +1,55 @@
1
+ namespace :active_admin do
2
+ desc 'Build Active Admin Tailwind stylesheets'
3
+ task :build do
4
+ require 'fileutils'
5
+
6
+ root = File.expand_path('../../', __dir__)
7
+
8
+ # Ensure builds directory exists
9
+ FileUtils.mkdir_p(File.join(root, 'app/assets/builds'))
10
+
11
+ # Build with Tailwind CLI
12
+ command = [
13
+ 'npx', 'tailwindcss',
14
+ '-i', File.join(root, 'app/assets/stylesheets/active_admin.tailwind.css'),
15
+ '-o', File.join(root, 'app/assets/builds/active_admin.css'),
16
+ '-c', File.join(root, 'tailwind.config.js'),
17
+ '-m'
18
+ ]
19
+
20
+ system(*command, exception: true)
21
+
22
+ puts 'Built Active Admin CSS with Tailwind'
23
+ end
24
+
25
+ desc 'Watch Active Admin Tailwind stylesheets'
26
+ task :watch do
27
+ root = File.expand_path('../../', __dir__)
28
+
29
+ # Watch for changes
30
+ command = [
31
+ 'npx', 'tailwindcss',
32
+ '--watch',
33
+ '-i', File.join(root, 'app/assets/stylesheets/active_admin.tailwind.css'),
34
+ '-o', File.join(root, 'app/assets/builds/active_admin.css'),
35
+ '-c', File.join(root, 'tailwind.config.js'),
36
+ '-m'
37
+ ]
38
+
39
+ system(*command)
40
+ end
41
+ end
42
+
43
+ # Enhance existing rake tasks
44
+ if Rake::Task.task_defined?('assets:precompile')
45
+ Rake::Task['assets:precompile'].enhance(['active_admin:build'])
46
+ end
47
+ if Rake::Task.task_defined?('test:prepare')
48
+ Rake::Task['test:prepare'].enhance(['active_admin:build'])
49
+ end
50
+ if Rake::Task.task_defined?('spec:prepare')
51
+ Rake::Task['spec:prepare'].enhance(['active_admin:build'])
52
+ end
53
+ if Rake::Task.task_defined?('db:test:prepare')
54
+ Rake::Task['db:test:prepare'].enhance(['active_admin:build'])
55
+ end
File without changes