metanorma-release 0.2.4 → 0.2.5

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: 83c0192b0bb05996d578d29961debb99d4600e0e1a178f259b1f4be4b8bbf065
4
- data.tar.gz: fe1669b07a72cceb289350d042e9a5eec6eea71ad77b3f5ae6699f30977a3ad3
3
+ metadata.gz: fb0e65e7f0e9f70aa92db6b778aced4b069a8de152db5227088569988fa691e3
4
+ data.tar.gz: 6482d90ac0568c9b2e8cda7b62b051981c14649d5eb7c3761ac62945ecbeafc9
5
5
  SHA512:
6
- metadata.gz: 4bf35ae312524e91297d084901835d75255a9af7dd5bff78f4fcd45eea0813ba3ac574eca6529ebc31b21624f5fd28eeefbc4c328fe42b4121a1211d538a0856
7
- data.tar.gz: c430938830a22af1df1a904253fd26a6710108b0bb544010f903ac7b5df141d2f6780961d4924579782a77fc6b19aa8dfc23fedebc8ccbad001fd6d2acf1c8e7
6
+ metadata.gz: 7fb10367dbc5b804eea4f9c4f8ef4ca14108c9c735952887028f943411a67586a49411309ff6ac049a7ca0ab6b801082801cecbd92761690a9b3321564effe62
7
+ data.tar.gz: f0c46507af66c462bfc5d8caa3a4c13642688da1a05a29312c98700fed51693319e2bf19f174866b67fff9b009e0ee1bb80b432f832ed3645dae9d3f35ca473f
data/README.adoc CHANGED
@@ -133,6 +133,8 @@ metanorma-release release [options]
133
133
  === `metanorma-release aggregate`
134
134
 
135
135
  Aggregate published releases from multiple repositories into a unified file tree.
136
+ Reads config from `metanorma.aggregate.yml` if present (auto-detected).
137
+ Idempotent: uses cached delta state (`.cache/aggregate/`) to skip unchanged repos.
136
138
 
137
139
  [source,sh]
138
140
  ----
@@ -142,21 +144,40 @@ metanorma-release aggregate [options]
142
144
  [cols="1m,3",options="header"]
143
145
  |===
144
146
  |Option |Description
147
+ |`--config FILE` |Config file (default: `metanorma.aggregate.yml`)
145
148
  |`--source SOURCE` |Discovery source: `github`, `local:PATH` (default: `github`)
146
- |`--organizations ORGS` |Organization list
149
+ |`--organizations ORGS` |Organization list (overrides config)
147
150
  |`--topic TOPIC` |Repository topic filter (default: `metanorma-release`)
148
151
  |`--repos REPOS` |Explicit repo list
149
152
  |`--channels CHANS` |Filter channels
150
153
  |`--stages STAGES` |Filter stages
151
154
  |`--output-dir DIR` |Output directory (default: `_site/cc`)
152
155
  |`--file-routing MODE` |File layout: `by-document`, `flat`, `by-format` (default: `by-document`)
153
- |`--cache-dir DIR` |Cache directory for delta state
154
156
  |`--[no-]include-drafts` |Include draft releases
155
157
  |`--concurrency N` |Parallel repos (default: 4)
156
158
  |`--min-documents N` |Fail if fewer documents found (default: 0)
157
- |`--token TOKEN` |Platform auth token
159
+ |`--token TOKEN` |Platform auth token (falls back to `GITHUB_TOKEN` env)
158
160
  |===
159
161
 
162
+ ==== Aggregate config file
163
+
164
+ Create `metanorma.aggregate.yml` in your project root:
165
+
166
+ [source,yaml]
167
+ ----
168
+ source: github
169
+ output_dir: _site/cc
170
+ file_routing: flat
171
+ cache_dir: .cache/aggregate
172
+
173
+ github:
174
+ organizations:
175
+ - MyOrg
176
+ topic: metanorma-release
177
+ ----
178
+
179
+ CLI flags override config file values. Cache is always enabled (defaults to `.cache/aggregate/`).
180
+
160
181
  == Concepts
161
182
 
162
183
  === Publication
@@ -88,9 +88,10 @@ module Metanorma
88
88
  option :min_documents, type: :numeric, default: 0,
89
89
  desc: "Minimum required documents"
90
90
  option :token, type: :string, desc: "Platform auth token"
91
+ option :config, type: :string, desc: "Config file (default: metanorma.aggregate.yml)"
91
92
 
92
93
  def aggregate
93
- config = AggregateCommand::Config.new(
94
+ config = AggregateCommand.build_config(
94
95
  source: options[:source],
95
96
  organizations: options[:organizations],
96
97
  topic: options[:topic],
@@ -105,13 +106,14 @@ module Metanorma
105
106
  min_documents: options[:min_documents],
106
107
  token: options[:token],
107
108
  create_zip: nil,
109
+ config: options[:config],
108
110
  )
109
111
  result = AggregateCommand.new(config).call
110
112
  print_aggregate_result(result)
111
113
 
112
- if options[:min_documents].positive? && result.publications.length < options[:min_documents]
114
+ if config.min_documents.positive? && result.publications.length < config.min_documents
113
115
  raise PipelineError,
114
- "Found #{result.publications.length} documents, minimum is #{options[:min_documents]}"
116
+ "Found #{result.publications.length} documents, minimum is #{config.min_documents}"
115
117
  end
116
118
 
117
119
  unless result.failed_repos.empty?
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "yaml"
4
+
3
5
  module Metanorma
4
6
  module Release
5
7
  class AggregateCommand
@@ -10,6 +12,9 @@ module Metanorma
10
12
  keyword_init: true
11
13
  )
12
14
 
15
+ DEFAULT_CONFIG_FILE = "metanorma.aggregate.yml"
16
+ DEFAULT_CACHE_DIR = ".cache/aggregate"
17
+
13
18
  def initialize(config)
14
19
  @config = config
15
20
  end
@@ -28,6 +33,54 @@ module Metanorma
28
33
  result
29
34
  end
30
35
 
36
+ def self.build_config(cli_options)
37
+ file_data = load_config_file(cli_options[:config])
38
+ merged = merge_config(file_data, cli_options)
39
+ Config.new(
40
+ source: merged[:source],
41
+ organizations: merged[:organizations],
42
+ topic: merged[:topic],
43
+ repos: merged[:repos],
44
+ channels: merged[:channels],
45
+ stages: merged[:stages],
46
+ output_dir: merged[:output_dir],
47
+ file_routing: merged[:file_routing],
48
+ cache_dir: merged[:cache_dir] || DEFAULT_CACHE_DIR,
49
+ include_drafts: merged[:include_drafts],
50
+ concurrency: merged[:concurrency],
51
+ min_documents: merged[:min_documents],
52
+ token: merged[:token],
53
+ create_zip: merged[:create_zip],
54
+ )
55
+ end
56
+
57
+ def self.load_config_file(path)
58
+ path ||= DEFAULT_CONFIG_FILE
59
+ return {} unless File.exist?(path)
60
+
61
+ YAML.safe_load_file(path, permitted_classes: [Symbol]) || {}
62
+ end
63
+
64
+ def self.merge_config(file_data, cli_options)
65
+ gh = file_data["github"] || {}
66
+ {
67
+ source: cli_options[:source] || file_data["source"],
68
+ organizations: cli_options[:organizations].any? ? cli_options[:organizations] : Array(gh["organizations"]),
69
+ topic: cli_options[:topic] || gh["topic"],
70
+ repos: cli_options[:repos] || file_data["repos"],
71
+ channels: cli_options[:channels].any? ? cli_options[:channels] : Array(file_data["channels"]),
72
+ stages: cli_options[:stages].any? ? cli_options[:stages] : Array(file_data["stages"]),
73
+ output_dir: cli_options[:output_dir] || file_data["output_dir"],
74
+ file_routing: cli_options[:file_routing] || file_data["file_routing"],
75
+ cache_dir: cli_options[:cache_dir] || file_data["cache_dir"],
76
+ include_drafts: cli_options[:include_drafts] || file_data["include_drafts"],
77
+ concurrency: cli_options[:concurrency] || file_data["concurrency"],
78
+ min_documents: cli_options[:min_documents] || file_data["min_documents"],
79
+ token: cli_options[:token],
80
+ create_zip: cli_options[:create_zip],
81
+ }
82
+ end
83
+
31
84
  private
32
85
 
33
86
  def run_aggregation
@@ -64,7 +64,8 @@ module Metanorma
64
64
 
65
65
  def self.build_github_client(token)
66
66
  require "octokit"
67
- token ? Octokit::Client.new(access_token: token) : Octokit::Client.new
67
+ access_token = token || ENV.fetch("GITHUB_TOKEN", nil)
68
+ access_token ? Octokit::Client.new(access_token: access_token) : Octokit::Client.new
68
69
  end
69
70
 
70
71
  def self.register_publisher(name, factory)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Metanorma
4
4
  module Release
5
- VERSION = "0.2.4"
5
+ VERSION = "0.2.5"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.