ruby_cms 1.0.1 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f44433fd9e94400ce208e14151bf0a79f79f35a4c03a9e52699fd83483ce735f
4
- data.tar.gz: e99a049b39263d8cbfe4c1eaf05071652428401abd5fa1fec554c72286556dd5
3
+ metadata.gz: 4f85aad882d87190c071391e338a48b7f327af01400b5bc38fb71d64d014cf6a
4
+ data.tar.gz: de4bf71cc65a5068f636a0c6a20d7fa2b9dba70d74e768a6997fb94f5a2963e9
5
5
  SHA512:
6
- metadata.gz: c3873c8aa83f4ff9beaf7d6f819a4e823a97518a4d68c7d15f3d9193204ab27b6f6b157944b7c8f2c1bcf7573709011598a2d025951a25e513e8f8a3ce50f1c1
7
- data.tar.gz: 57a96a51c5e91ce0e8602cde488851e023e4d5966e90b7f021b046bd2db992538bdf669fee5c7fd12018c26514adb70d5a16c976e13a5d72858ee9cc6fc0b815
6
+ metadata.gz: 13d628925678ca174113efebf83567afe2624433030bcb6220357ca0c68084cb60f73d589034e9d0d8a6cbb2d966a68979db4c86c5f7609511f3faf12b6bb2ff
7
+ data.tar.gz: eaa696efdaeb63702871a4a6cb41147bd6916d4fe203cbe9518079a99f6fa08120914e37704ff6a883acd1f9b713498461c3a1fa52d29ce0471ddb593620fa00
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.1.0] - 2026-06-29
4
+
5
+ ### Added
6
+
7
+ - `RubyCms::MigrationReconciler` — partial-install recovery: stamps already-applied `noticed` migrations (`create_noticed_tables`, `add_notifications_count_to_noticed_event`) when their tables/columns already exist, so a re-run with duplicate migration files no longer fails `db:migrate`
8
+ - `rails ruby_cms:reconcile_migrations` rake task to run the reconciler manually
9
+ - Installer skips `noticed:install:migrations` when noticed migrations/tables are already present, and reconciles before `db:migrate`
10
+
11
+ ## [1.0.2] - 2026-06-29
12
+
13
+ ### Fixed
14
+
15
+ - `HelperWiring` no longer wires `Pagy::Frontend` (removed in Pagy 43+); admin pagination uses `Pagy::Offset` via `AdminPagination` / `RubyUI::DataTable`. The installer now also strips an obsolete `include Pagy::Frontend` from the host app's `application_helper.rb`
16
+
3
17
  ## [1.0.1] - 2026-06-29
4
18
 
5
19
  ### Fixed
@@ -1,6 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  namespace :ruby_cms do
4
+ desc "Stamp duplicate noticed migrations when tables already exist (partial install recovery)"
5
+ task reconcile_migrations: :environment do
6
+ require "ruby_cms/migration_reconciler"
7
+ RubyCms::MigrationReconciler.new(app_root: Rails.root).reconcile!
8
+ end
9
+
4
10
  desc "Create default permissions/settings and grant manage_admin to admin users"
5
11
  task seed_permissions: :environment do
6
12
  Permission.ensure_defaults!
@@ -7,10 +7,12 @@ module RubyCms
7
7
  # * RubyUI — Phlex::Kit, makes components callable as methods in ERB
8
8
  # (e.g. AdminPageHeader(...)); defined by ruby_ui:install
9
9
  # * CmsApplicationHelpers / ContentBlocksHelper — shipped by the gem
10
- # * Pagy::Frontend pagination helpers
10
+ # Pagy 43+ has no Pagy::Frontend; admin pagination uses Pagy::Offset in
11
+ # AdminPagination and RubyUI::DataTable components instead.
11
12
  # Idempotent: only adds includes that are missing.
12
13
  class HelperWiring
13
- INCLUDES = %w[CmsApplicationHelpers RubyUI ContentBlocksHelper Pagy::Frontend].freeze
14
+ INCLUDES = %w[CmsApplicationHelpers RubyUI ContentBlocksHelper].freeze
15
+ OBSOLETE_INCLUDES = %w[Pagy::Frontend].freeze
14
16
 
15
17
  def initialize(app_root:)
16
18
  @path = Pathname.new(app_root).join("app/helpers/application_helper.rb")
@@ -20,12 +22,19 @@ module RubyCms
20
22
  return false unless @path.exist?
21
23
 
22
24
  content = @path.read
23
- missing = INCLUDES.reject {|mod| content.include?("include #{mod}") }
24
- return false if missing.empty?
25
- return false unless content.include?("module ApplicationHelper\n")
25
+ cleaned = OBSOLETE_INCLUDES.reduce(content) do |text, mod|
26
+ text.gsub(/^\s*include #{Regexp.escape(mod)}\n/, "")
27
+ end
28
+ missing = INCLUDES.reject {|mod| cleaned.include?("include #{mod}") }
29
+ changed = cleaned != content
30
+ return false if missing.empty? && !changed
31
+ return false unless cleaned.include?("module ApplicationHelper\n")
26
32
 
27
- lines = missing.map {|mod| " include #{mod}" }.join("\n")
28
- @path.write(content.sub("module ApplicationHelper\n", "module ApplicationHelper\n#{lines}\n"))
33
+ if missing.any?
34
+ lines = missing.map {|mod| " include #{mod}" }.join("\n")
35
+ cleaned = cleaned.sub("module ApplicationHelper\n", "module ApplicationHelper\n#{lines}\n")
36
+ end
37
+ @path.write(cleaned)
29
38
  true
30
39
  end
31
40
  end
@@ -10,6 +10,7 @@ require "ruby_cms/file_installer"
10
10
  require "ruby_cms/routes_assembler"
11
11
  require "ruby_cms/nav_assembler"
12
12
  require "ruby_cms/migration_installer"
13
+ require "ruby_cms/migration_reconciler"
13
14
  require "ruby_cms/lockfile"
14
15
 
15
16
  module RubyCms
@@ -114,14 +115,42 @@ module RubyCms
114
115
  def run_framework_steps(modules)
115
116
  steps = BASE_FRAMEWORK_STEPS.dup
116
117
  steps.insert(2, AHOY_STEP) if modules.any? {|m| m.key == :analytics }
117
- steps.each {|cmd| @shell.run(cmd) }
118
+ steps.each {|cmd| run_framework_step(cmd) }
119
+ end
120
+
121
+ def run_framework_step(cmd)
122
+ if cmd.include?("noticed:install:migrations") && noticed_already_setup?
123
+ @shell.ok("notifications", hint: "migrations already present")
124
+ return
125
+ end
126
+
127
+ @shell.run(cmd)
128
+ end
129
+
130
+ def noticed_already_setup?
131
+ migrate = Pathname(@app_root).join("db/migrate")
132
+ return true if migrate.glob("*create_noticed_tables*.rb").any?
133
+
134
+ return false unless defined?(ActiveRecord::Base)
135
+
136
+ ActiveRecord::Base.connection.table_exists?(:noticed_events)
137
+ rescue StandardError
138
+ false
118
139
  end
119
140
 
120
141
  def run_rails_steps
142
+ reconcile_migrations
121
143
  run_critical("bin/rails db:migrate")
122
144
  @shell.run("bin/rails ruby_cms:seed_permissions")
123
145
  end
124
146
 
147
+ def reconcile_migrations
148
+ @shell.run(
149
+ 'bin/rails runner "require \"ruby_cms/migration_reconciler\"; ' \
150
+ 'RubyCms::MigrationReconciler.new(app_root: Rails.root).reconcile!"'
151
+ )
152
+ end
153
+
125
154
  # Run a command the rest of the install depends on; abort with a clear message
126
155
  # (rather than limping on to a misleading "installed") when it fails.
127
156
  def run_critical(cmd)
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+
5
+ module RubyCms
6
+ # Stamps pending framework migrations when their schema is already present.
7
+ # Covers partial installs where tables were created under an older timestamp
8
+ # and a re-run added duplicate migration files.
9
+ class MigrationReconciler
10
+ NOTICED_PATTERNS = [
11
+ "*create_noticed_tables*.rb",
12
+ "*add_notifications_count_to_noticed*.rb"
13
+ ].freeze
14
+
15
+ def initialize(app_root:)
16
+ @migrate_dir = Pathname(app_root).join("db/migrate")
17
+ end
18
+
19
+ def reconcile!
20
+ return unless defined?(ActiveRecord::Base)
21
+
22
+ conn = ActiveRecord::Base.connection
23
+ return unless conn.table_exists?(:noticed_events)
24
+
25
+ stamp_pending!(@migrate_dir.glob(NOTICED_PATTERNS[0]))
26
+ return unless conn.column_exists?(:noticed_events, :notifications_count)
27
+
28
+ stamp_pending!(@migrate_dir.glob(NOTICED_PATTERNS[1]))
29
+ end
30
+
31
+ private
32
+
33
+ def stamp_pending!(paths)
34
+ paths.each do |path|
35
+ version = path.basename.to_s[/\A(\d+)_/, 1]
36
+ next unless version
37
+ next if schema_migration.where(version: version).exists?
38
+
39
+ schema_migration.create!(version: version)
40
+ end
41
+ end
42
+
43
+ def schema_migration
44
+ ActiveRecord::SchemaMigration
45
+ end
46
+ end
47
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyCms
4
- VERSION = "1.0.1"
4
+ VERSION = "1.1.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codebyjob
@@ -682,6 +682,7 @@ files:
682
682
  - lib/ruby_cms/manifest.rb
683
683
  - lib/ruby_cms/manifest_data.rb
684
684
  - lib/ruby_cms/migration_installer.rb
685
+ - lib/ruby_cms/migration_reconciler.rb
685
686
  - lib/ruby_cms/nav_assembler.rb
686
687
  - lib/ruby_cms/passkey_wiring.rb
687
688
  - lib/ruby_cms/path_map.rb