andromeda_cms 0.4.1 → 0.4.2

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: b9f3ed101ba8cb54a4c157b5092773787db3eddf1b197a06d11cc4972d9d2597
4
- data.tar.gz: 170e9da5415fe1b1c2f647b3ba44208a8734d1f7f297ab9b2562df32c62d20a1
3
+ metadata.gz: b3e717009de7bff8e377893a2d94e810d58c3c26827124c63efefdb5e26871df
4
+ data.tar.gz: d7516800193e99d6a1b67ddf781f6703ea56dad3a76e20ed6bc5adbaf1618b33
5
5
  SHA512:
6
- metadata.gz: fa6b58344026eb2442967278f6c71baf40fb0846eb91e6c9915a29191d555f70510c5cb22fa4e0604756642076e5ca1bce9a12c126ec900cd1b5b505abbf2bfe
7
- data.tar.gz: af2769f8fe35b1a63da6595fe19772e98c0e4748a84c8a7c940f5782da2111908eb1fcf921e636e30d066c94ea66cba53dd64c4054d0193af97f2933ad733220
6
+ metadata.gz: 5062e06b1700c44ebd3adcc4d440d6d929a6f38d593c73491a3d87f7161593e2776b8f9d50fd1ad37b2d6e4c87e15a288bd5d864d5b0961eed113e177c064479
7
+ data.tar.gz: ebf5ff1699e815b80c540f41b897c0977197fa6a7e18089f42f0049800602178e3217f6f651e988b1f49b2b1dbcc16650e0dd904660ebe53ccf29a53e1d56030
data/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.4.2] - 2026-09-30
9
+
10
+ ### Fixed
11
+
12
+ - In development, a file added or edited under `app/content/` now shows up
13
+ without restarting the server. `Entry` used to keep the list it loaded
14
+ first, so a new file returned 404 and an edited one kept its old content.
15
+ The list is now reloaded when the paths, mtimes or sizes of the collection's
16
+ source files change; production is unchanged.
17
+
8
18
  ## [0.4.1] - 2026-09-29
9
19
 
10
20
  ### Fixed
@@ -131,6 +141,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
131
141
  - Generators: `andromeda:install`, `andromeda:collection`,
132
142
  `andromeda:component` and `andromeda:import_astro`.
133
143
 
144
+ [0.4.2]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.4.2
134
145
  [0.4.1]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.4.1
135
146
  [0.4.0]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.4.0
136
147
  [0.3.0]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.3.0
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "digest"
3
4
  require "pathname"
4
5
 
5
6
  module Andromeda
@@ -45,6 +46,7 @@ module Andromeda
45
46
  @base_dir = resolve_base(base)
46
47
  @pattern = pattern
47
48
  @entries = nil
49
+ @entries_signature = nil
48
50
  Andromeda::Registry.register(@collection_name, self)
49
51
  self
50
52
  end
@@ -174,10 +176,12 @@ module Andromeda
174
176
  end
175
177
 
176
178
  # Drops the in-memory cache, forcing the next query to re-run the
177
- # Loader. Used by tests that change fixtures mid-example, and is the
178
- # hook the dev-mode "reconvert on stale mtime" check will call.
179
+ # Loader. Used by tests that change fixtures mid-example and by
180
+ # Andromeda::Check; development queries notice source changes on their
181
+ # own (see `entries`).
179
182
  def reload!
180
183
  @entries = nil
184
+ @entries_signature = nil
181
185
  end
182
186
 
183
187
  private
@@ -190,10 +194,33 @@ module Andromeda
190
194
  # the index is only rewritten once a collection finishes converting,
191
195
  # so a component querying entries mid-build reads source instead
192
196
  # (see Andromeda::BuildContext).
197
+ #
198
+ # The development cache is dropped whenever the source files change
199
+ # (see `source_signature`), so a file added or edited while the server
200
+ # runs shows up on the next query without a restart.
193
201
  def entries
194
202
  return source_entries if Andromeda::BuildContext.building?
203
+ return @entries ||= entries_from_index if production?
204
+
205
+ signature = source_signature
206
+ if @entries.nil? || signature != @entries_signature
207
+ @entries = load_entries_from_source
208
+ @entries_signature = signature
209
+ end
210
+ @entries
211
+ end
212
+
213
+ # Paths, mtimes and sizes of the collection's source files: an added or
214
+ # removed file changes the path list, an edit changes mtime/size. Same
215
+ # scheme as Andromeda::Pipeline#render_key uses for component partials.
216
+ def source_signature
217
+ files = Dir.glob(pattern, base: base_dir).sort.filter_map do |relative|
218
+ file = File.join(base_dir, relative)
219
+ next unless File.file?(file)
195
220
 
196
- @entries ||= production? ? entries_from_index : load_entries_from_source
221
+ [relative, File.mtime(file).to_r, File.size(file)].join(":")
222
+ end
223
+ Digest::SHA256.hexdigest(files.join("\n"))
197
224
  end
198
225
 
199
226
  def production?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Andromeda
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: andromeda_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - LIMHAUS Inc.