Class: Textus::Manifest::Entry::Publish::Tree

Inherits:
Mode
  • Object
show all
Defined in:
lib/textus/manifest/entry/publish/tree.rb

Overview

publish_tree (ADR 0047): mirror this entry’s whole subtree to one target dir by real path. No resolver, no keys — files are opaque payload (envelope nil). The prune honors ‘ignore` so a derived index (e.g. a SKILL.md written by a separate entry into the same dir) survives the whole-target prune (ADR 0047 D4).

Instance Attribute Summary

Attributes inherited from Mode

#entry

Instance Method Summary collapse

Methods inherited from Mode

#initialize

Constructor Details

This class inherits a constructor from Textus::Manifest::Entry::Publish::Mode

Instance Method Details

#keyless?Boolean

Mirrored files are opaque payload, never addressable keys (ADR 0047).

Returns:

  • (Boolean)


12
# File 'lib/textus/manifest/entry/publish/tree.rb', line 12

def keyless? = true

#publish(pctx, prefix: nil) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/textus/manifest/entry/publish/tree.rb', line 14

def publish(pctx, prefix: nil) # rubocop:disable Lint/UnusedMethodArgument
  target_rel = entry.publish_tree
  target_dir = repo_abs(pctx, target_rel)
  unless inside_repo?(pctx, target_dir)
    raise Textus::PublishError.new(
      "entry '#{entry.key}': publish_tree target '#{target_rel}' escapes repo root",
    )
  end

  result = SubtreeMirror.new(entry, pctx).mirror(
    base: store_base(pctx),
    walk_root: store_base(pctx),
    target_dir: target_dir,
    key: entry.key,
    envelope: nil,
    prune_honors_ignore: true,
  )
  { kind: :leaves, value: result[:written], pruned: result[:pruned] }
end

#validate!Object

Raises:



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/textus/manifest/entry/publish/tree.rb', line 34

def validate!
  publish_tree = entry.publish_tree
  raise UsageError.new("entry '#{entry.key}': publish.tree must be a string") unless publish_tree.is_a?(String)

  used_vars = publish_tree.scan(Template::VAR_RE).flatten
  return if used_vars.empty?

  raise UsageError.new(
    "entry '#{entry.key}': publish.tree names a single directory and takes no template variable(s) " \
    "#{used_vars.map { |v| "{#{v}}" }.join(", ")} — it mirrors the whole subtree to one target dir.",
  )
end