archsight 0.5.3 → 0.5.4

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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/docs/configuration.md +1 -1
  3. data/docs/import.md +27 -2
  4. data/docs/modeling.md +1 -1
  5. data/docs/pages.md +1 -1
  6. data/lib/archsight/git_source.rb +5 -3
  7. data/lib/archsight/helpers.rb +3 -1
  8. data/lib/archsight/import/handlers/gitea.rb +195 -0
  9. data/lib/archsight/import/handlers/github.rb +1 -0
  10. data/lib/archsight/import/handlers/gitlab.rb +1 -0
  11. data/lib/archsight/import/handlers/repository.rb +7 -4
  12. data/lib/archsight/reading_time.rb +66 -0
  13. data/lib/archsight/resources/implementation_work_package.rb +2 -0
  14. data/lib/archsight/version.rb +1 -1
  15. data/lib/archsight/web/api/openapi/spec.yaml +20 -1
  16. data/lib/archsight/web/api/page_helpers.rb +5 -1
  17. data/lib/archsight/web/public/vue/{DocPage-B2AVspsD.js → DocPage-BHffBQ3u.js} +1 -1
  18. data/lib/archsight/web/public/vue/{EditorPage-BYSZG_O0.js → EditorPage-BHZtvtnN.js} +1 -1
  19. data/lib/archsight/web/public/vue/{ErrorPage-eL_Woec4.js → ErrorPage-BQARAwF8.js} +1 -1
  20. data/lib/archsight/web/public/vue/{GraphView-YEiPBxPd.js → GraphView-D84CH00D.js} +1 -1
  21. data/lib/archsight/web/public/vue/{HomePage-BeLTwv2y.js → HomePage-BJpTPWFz.js} +2 -2
  22. data/lib/archsight/web/public/vue/{InstanceRouter-DgvdUouW.js → InstanceRouter-C1Da3nWo.js} +1 -1
  23. data/lib/archsight/web/public/vue/{KindList-BkYvYpnh.js → KindList-DNRUVuEJ.js} +1 -1
  24. data/lib/archsight/web/public/vue/PageView-DzKj212I.js +1 -0
  25. data/lib/archsight/web/public/vue/{QueryError-DzGMgvyb.js → QueryError-CTVAL1Tm.js} +1 -1
  26. data/lib/archsight/web/public/vue/{ResourceList-Cr9ExUDn.js → ResourceList-CRt_FpfS.js} +1 -1
  27. data/lib/archsight/web/public/vue/{SearchResults-D6tx3Atc.js → SearchResults-BMwBz4BB.js} +1 -1
  28. data/lib/archsight/web/public/vue/{WikiPage-BhaaveRq.js → WikiPage-DSEL2gmd.js} +1 -1
  29. data/lib/archsight/web/public/vue/{index-le1guGp1.js → index-JZkWwfYg.js} +2 -2
  30. data/lib/archsight/web/public/vue.html +1 -1
  31. metadata +16 -14
  32. data/lib/archsight/web/public/vue/PageView-B3SnDw9S.js +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 902d20b9ffcd9cecfb00ce3ab315eb21e29d6bd886aad9f8a76f24e8243f450c
4
- data.tar.gz: 9c525ce80c3591e8f7ce4174ee88a9b38b5ddd876e5944c49382bc9b550ff9be
3
+ metadata.gz: 540f7640d06327e62c658d9bff6cb9e60475f10c63a36ba541170c8ca3077ef1
4
+ data.tar.gz: 8cfbe67e126f99e743e45935527b034f980531979ef76ee54295b81e7b27bbdc
5
5
  SHA512:
6
- metadata.gz: 76a974e8777040e76fdc415d3943812f0d060bbb9b52a03708b2743b1e06431bd173f674ffb7b71cfa010892edab55b506cd210cec5b3851f38d741d1144020e
7
- data.tar.gz: 6a04c4cd33b260b63717525427b35e69a2905e93c950740a01e44c46b4c7dd015f8daae7abe04ca2c4c032eb674924e7fb2fae621eb7c01790eb6e610d099990
6
+ metadata.gz: 185739ca5a2c52b6c4e1df7ab29f58772908df3bc5bcb53452b7b2114e042ea2a62624fa5d2254c088a36bd2118b3daa81c48eb4b475aa76308ecbe0b32737e4
7
+ data.tar.gz: 32384cbe603e19c21e2bdc661979777aeba42e8faeb2a97e88479320bf31fc844ba42c995d11fc316711e9609ab7197a052aa914a74b6808e1cebd6b5cda5a75
@@ -43,7 +43,7 @@ that is set but empty counts as not set.
43
43
  | `pdf.remote_images` | `ARCHSIGHT_PDF_REMOTE_IMAGES` | `false` stops the PDF export from fetching images that a page embeds by URL (default: fetched, public hosts only) |
44
44
  | `pdf.max_analyses` | `ARCHSIGHT_PDF_MAX_ANALYSES` | How many `![[Analysis/...]]` embeds one PDF may run (each can take as long as its own timeout). Default `5`; further ones are shown as a note |
45
45
  | `slides.script_hosts` | `ARCHSIGHT_SLIDES_SCRIPT_HOSTS` | `https://` hosts (space or comma separated) from which an HTML [slide deck](/doc/slide-decks) may load scripts, styles and fonts. Default `https://unpkg.com https://cdn.jsdelivr.net https://cdnjs.cloudflare.com` |
46
- | `import.cache_root` | `ARCHSIGHT_IMPORT_CACHE_ROOT` | Where the GitHub, GitLab and repository imports clone repositories, and what importers of the resources repository get as `cache_root` / `ARCHSIGHT_CACHE_DIR`. Default `~/.cache/archsight/git`; an import's own `import/config/cacheRoot` wins, see [Importers of the Resources Repository](/doc/import#importers-of-the-resources-repository). Every import makes sure the clones are not indexed by Spotlight (macOS): an empty `.metadata_never_index` in `~/.cache/archsight`, or in the cache root when it is elsewhere |
46
+ | `import.cache_root` | `ARCHSIGHT_IMPORT_CACHE_ROOT` | Where the GitHub, GitLab, Gitea and repository imports clone repositories, and what importers of the resources repository get as `cache_root` / `ARCHSIGHT_CACHE_DIR`. Default `~/.cache/archsight/git`; an import's own `import/config/cacheRoot` wins, see [Importers of the Resources Repository](/doc/import#importers-of-the-resources-repository). Every import makes sure the clones are not indexed by Spotlight (macOS): an empty `.metadata_never_index` in `~/.cache/archsight`, or in the cache root when it is elsewhere |
47
47
 
48
48
  ## Command line
49
49
 
data/docs/import.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Import System
2
2
 
3
- The import system allows you to declaratively define data imports that generate architecture resources from external sources like GitLab, GitHub, and git repositories.
3
+ The import system allows you to declaratively define data imports that generate architecture resources from external sources like GitLab, GitHub, Gitea, and git repositories.
4
4
 
5
5
  ## Overview
6
6
 
@@ -159,6 +159,7 @@ Lists repositories from a GitLab instance and generates child Import resources.
159
159
  - `fallbackTeam` - Default team when no contributor match found (propagated to child imports)
160
160
  - `botTeam` - Team for bot-only repositories (propagated to child imports)
161
161
  - `corporateAffixes` - Comma-separated corporate username affixes for team matching, e.g., "ionos,1and1" (propagated to child imports)
162
+ - `gitService` - TechnologyService that supplies the repositories (default: `Git:Gitlab` for gitlab, `Git:Github` for github; propagated to child imports)
162
163
 
163
164
  **Environment:**
164
165
  - `GITLAB_TOKEN` - Personal access token (required)
@@ -175,6 +176,7 @@ Lists repositories from a GitHub organization and generates child Import resourc
175
176
  - `fallbackTeam` - Default team when no contributor match found (propagated to child imports)
176
177
  - `botTeam` - Team for bot-only repositories (propagated to child imports)
177
178
  - `corporateAffixes` - Comma-separated corporate username affixes for team matching, e.g., "ionos,1and1" (propagated to child imports)
179
+ - `gitService` - TechnologyService that supplies the repositories (default: `Git:Gitlab` for gitlab, `Git:Github` for github; propagated to child imports)
178
180
 
179
181
  **Environment:**
180
182
  - `GITHUB_TOKEN` - GitHub Personal Access Token (required)
@@ -184,6 +186,28 @@ Lists repositories from a GitHub organization and generates child Import resourc
184
186
 
185
187
  **Output:** Generates `Import:Repo:github:*` resources for each repository.
186
188
 
189
+ ### gitea
190
+
191
+ Lists repositories from a Gitea (or Forgejo) server and generates child Import resources.
192
+
193
+ **Configuration:**
194
+ - `host` - Gitea host, e.g. `gitea.example.com` (required)
195
+ - `org` - Organization or user to list; without it every repository the token can see is listed
196
+ - `scheme` - `https` (default) or `http`
197
+ - `verifySSL` - `"false"` skips certificate verification (default: true)
198
+ - `rateLimitMs` - Pause between API requests in milliseconds (default: 0)
199
+ - `repoOutputPath` - Output path for repository handler results
200
+ - `fallbackTeam`, `botTeam`, `corporateAffixes` - Team matching, propagated to child imports like for GitHub
201
+ - `gitService` - TechnologyService that supplies the repositories (default: `Git:Gitea`; propagated to child imports)
202
+ - `defaultVisibility` - Visibility of private repositories (default: `internal`; public ones are `open-source`)
203
+
204
+ **Environment:**
205
+ - `GITEA_TOKEN` - Access token (required), created at `<host>/user/settings/applications`; scope `read:repository`, plus `read:organization` when `org` is set
206
+
207
+ Repositories are cloned over SSH, so the SSH keys of the user must work for the host.
208
+
209
+ **Output:** Generates `Import:Repo:gitea:<owner>:<repo>` resources for each repository.
210
+
187
211
  ### repository
188
212
 
189
213
  Analyzes a single git repository and generates a TechnologyArtifact resource.
@@ -196,6 +220,7 @@ Analyzes a single git repository and generates a TechnologyArtifact resource.
196
220
  - `sccPath` - Path to scc binary (default: scc)
197
221
  - `fallbackTeam` - Default team when no contributor match found
198
222
  - `botTeam` - Team for bot-only repositories
223
+ - `gitService` - TechnologyService the repository is `suppliedBy`, set by the listing import; without it the service is guessed from `gitUrl` (`Git:Github` when it contains `github`, else `Git:Gitlab`)
199
224
  - `corporateAffixes` - Comma-separated corporate username affixes for team matching (e.g., "ionos,1and1"). Enables matching git usernames like `jsmith-ionos` or `ionos-jsmith` to team member "John Smith". Without this, corporate username pattern matching is inactive.
200
225
 
201
226
  **Output:** Generates one TechnologyArtifact resource with:
@@ -555,7 +580,7 @@ spec: {}
555
580
 
556
581
  ### Shared state and outputs
557
582
 
558
- - `cache_root` (Ruby) and `ARCHSIGHT_CACHE_DIR` (command) are the directory the GitHub, GitLab and repository
583
+ - `cache_root` (Ruby) and `ARCHSIGHT_CACHE_DIR` (command) are the directory the GitHub, GitLab, Gitea and repository
559
584
  imports clone into: `import/config/cacheRoot`, else `import.cache_root` in the
560
585
  [configuration](configuration.md) (`ARCHSIGHT_IMPORT_CACHE_ROOT`), else `~/.cache/archsight/git`.
561
586
  - `database` holds the model as loaded after the dependencies ran (the import command loads the kinds the importers
data/docs/modeling.md CHANGED
@@ -831,7 +831,7 @@ How to model it:
831
831
  - **Process side.** Model a control once, let every process it governs point to it with `guidedBy`, and link it with `satisfies` to each requirement it addresses. Give it an owner (the accountable actor) and executors (the actors carrying it out). The `control/status` and `control/frequency` filters find, for example, the controls that are only partially implemented.
832
832
  - **Application side.** Whether an application implements a requirement is stated on the application (`realizes`, `plans`, `evidencedBy`), never on the control. Evidence is per resource and requirement: it says how *this* service or component meets *that* requirement.
833
833
  - **Evidence of a control.** A control can be `evidencedBy` evidence too. Use it for the records the control itself produces (reviews, diagrams, change history, audit logs) and set `evidence/type` to `process`, `documentation` or `audit-log`. Evidence that an application meets a requirement is linked from the application, not from a control.
834
- - **Reading it back.** A requirement's page lists its controls and evidence as incoming `satisfies` relations. The "Requirements" table of an application page and the `requirements` blocks list what applications implement (`realizes`, `partiallyRealizes`, `plans`); controls are not part of that table.
834
+ - **Reading it back.** A requirement's page lists its controls and evidence as incoming `satisfies` relations. The "Requirements" table of an application page and the `requirements` blocks list what applications implement (`realizes`, `partiallyRealizes`, `plans`); controls are not part of that table. An `ImplementationWorkPackage` can `plan` requirements as well, so a requirements block over open work (`of: 'ImplementationWorkPackage: name == "X"'`) shows them as planned; move them to `realizes` when the work is done.
835
835
 
836
836
  ```yaml
837
837
  # process side
data/docs/pages.md CHANGED
@@ -194,7 +194,7 @@ status: [implemented, partial] # optional: implemented, partial,
194
194
  ````
195
195
 
196
196
  The table has one row per requirement of all selected resources. Its status is the best one any of them gives it
197
- (`realizes` = implemented, then `partially`, then `plans` = planned), and a "Realized by" column names the resources with their own
197
+ (`realizes` = implemented, then `partially`, then `plans` = planned; an `ImplementationWorkPackage` uses `plans` for requirements of work that is not done yet), and a "Realized by" column names the resources with their own
198
198
  status (left out when only one resource is selected). Rows are sorted by priority, then name; `priority` and `status` filter the rows.
199
199
  Like views, the block is only a placeholder on the server (`<div class="requirements-embed" data-title data-of data-priority
200
200
  data-status>` around the source): the frontend loads the rows from `GET /api/v1/requirements?of=&priority=&status=`, so rendering a page
@@ -11,7 +11,7 @@ module Archsight
11
11
  # file, its `origin` remote, the checked out branch), nothing goes over the network.
12
12
  #
13
13
  # The web URL is `https://<host>/<owner>/<repo>` of the remote, without the user, password or token a remote URL
14
- # may carry. GitHub files are `/blob/<ref>/<path>`, GitLab files `/-/blob/<ref>/<path>`; on other hosts, and for a
14
+ # may carry. GitHub files are `/blob/<ref>/<path>`, GitLab files `/-/blob/<ref>/<path>`, Gitea/Forgejo files `/src/branch/<ref>/<path>` (`/src/commit/<sha>/<path>`); on other hosts, and for a
15
15
  # file git does not track, only the repository is linked. The ref is the checked out branch, the commit when the
16
16
  # HEAD is detached (CI).
17
17
  module GitSource
@@ -58,8 +58,10 @@ module Archsight
58
58
  end
59
59
 
60
60
  def file_url(host, repository_url, ref, path)
61
- blob = if host.match?(/(\A|\.)github\./) then "blob"
62
- elsif host.match?(/(\A|\.)gitlab\./) then "-/blob"
61
+ blob = case host
62
+ when /(\A|\.)github\./ then "blob"
63
+ when /(\A|\.)gitlab\./ then "-/blob"
64
+ when /(\A|\.)(gitea|forgejo|codeberg)\./ then ref&.match?(/\A\h{40,64}\z/) ? "src/commit" : "src/branch"
63
65
  end
64
66
  return nil unless blob && ref
65
67
 
@@ -83,6 +83,8 @@ module Archsight
83
83
  "iconoir-github"
84
84
  when /gitlab/
85
85
  "iconoir-git-fork"
86
+ when /gitea|forgejo|codeberg/
87
+ "iconoir-git-fork"
86
88
  when /confluence\.|atlassian\.net/
87
89
  "iconoir-page-edit"
88
90
  when /jira\.|atlassian\.net.*jira/
@@ -138,7 +140,7 @@ module Archsight
138
140
  case url
139
141
  when %r{docs\.google\.com/(document|spreadsheets|presentation)}
140
142
  "Documentation"
141
- when /github\.com|gitlab/
143
+ when /github\.com|gitlab|gitea|forgejo|codeberg/
142
144
  "Code Repository"
143
145
  when /confluence\.|atlassian\.net/
144
146
  "Documentation"
@@ -0,0 +1,195 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "net/http"
5
+ require "json"
6
+ require "uri"
7
+ require "openssl"
8
+ require_relative "../handler"
9
+ require_relative "../registry"
10
+ require_relative "cache_pruner"
11
+
12
+ # Gitea handler - lists repositories of a Gitea (or Forgejo) server and generates child Import resources
13
+ #
14
+ # Configuration:
15
+ # import/config/host - Gitea host, e.g. "gitea.example.com" (required)
16
+ # import/config/org - Organization (or user) to list; without it every repository the token can see is listed
17
+ # import/config/scheme - "https" (default) or "http"
18
+ # import/config/verifySSL - "false" to skip certificate verification (default: true)
19
+ # import/config/rateLimitMs - Pause between API requests in milliseconds (default: 0)
20
+ # import/config/repoOutputPath - Output path for repository handler results (e.g., "generated/repositories.yaml")
21
+ # import/config/childCacheTime - Cache time for generated child imports (e.g., "1h", "30m")
22
+ # import/config/fallbackTeam - Default team when no contributor match found (propagated to child imports)
23
+ # import/config/botTeam - Team for bot-only repositories (propagated to child imports)
24
+ # import/config/corporateAffixes - Comma-separated corporate username affixes for team matching (propagated to child imports)
25
+ # import/config/defaultVisibility - Default visibility for non-public repos (default: "internal")
26
+ # import/config/cacheRoot - Override for the local git cache root (default: ~/.cache/archsight/git)
27
+ #
28
+ # Environment:
29
+ # GITEA_TOKEN - Gitea access token (required)
30
+ # Create at: <host>/user/settings/applications (scope read:repository, plus read:organization for `org`)
31
+ #
32
+ # Output:
33
+ # Generates Import:Repo:* resources for each repository
34
+ # The repository handler will clone/sync the actual git repositories (over SSH, so the SSH keys must work)
35
+ #
36
+ # Before generating imports, prunes any cache subdirectory under
37
+ # cacheRoot/gitea/<host>/<owner> that no longer corresponds to a repo returned by
38
+ # the API (e.g. a repo that was renamed or deleted), so stale clones don't
39
+ # linger and get picked up by later importers.
40
+ class Archsight::Import::Handlers::Gitea < Archsight::Import::Handler
41
+ # generates child imports (see Handler.generates_imports?)
42
+ def self.generates_imports? = true
43
+
44
+ include Archsight::Import::Handlers::CachePruner
45
+
46
+ # Gitea caps the page size (50 by default), so the listing runs until an empty page
47
+ PER_PAGE = 50
48
+
49
+ def execute
50
+ @host = config("host")
51
+ raise "Missing required config: host" unless @host
52
+
53
+ @token = ENV.fetch("GITEA_TOKEN", nil)
54
+ raise "Missing required environment variable: GITEA_TOKEN" unless @token
55
+
56
+ @org = config("org")
57
+ @scheme = config("scheme", default: "https")
58
+ @verify_ssl = config("verifySSL", default: "true").to_s != "false"
59
+ @rate_limit_ms = config("rateLimitMs", default: "0").to_i
60
+ @repo_output_path = config("repoOutputPath")
61
+ @child_cache_time = config("childCacheTime")
62
+ @default_visibility = config("defaultVisibility", default: "internal")
63
+ @host_dir = File.join(Archsight::Import.cache_root(config("cacheRoot")), "gitea", @host)
64
+
65
+ progress.update("Fetching repositories from #{@org || @host}")
66
+ repos = fetch_all_repos
67
+
68
+ if repos.empty?
69
+ progress.warn("No repositories found in #{@org || @host}")
70
+ return
71
+ end
72
+
73
+ prune_stale_cache(repos)
74
+
75
+ progress.update("Generating #{repos.size} import resources")
76
+ generate_repository_imports(repos)
77
+
78
+ write_generates_meta
79
+ end
80
+
81
+ private
82
+
83
+ def fetch_all_repos
84
+ repos = {}
85
+ page = 1
86
+
87
+ loop do
88
+ progress.update("Fetching repositories (page #{page})")
89
+ batch = fetch_repos_page(page)
90
+ break if batch.empty?
91
+
92
+ before = repos.size
93
+ batch.each { |repo| repos[repo["id"] || repo["fullName"]] = repo }
94
+ break if repos.size == before # a server that ignores `page` would repeat the first one forever
95
+
96
+ progress.update("Fetched #{repos.size} repositories")
97
+ page += 1
98
+ sleep(@rate_limit_ms / 1000.0) if @rate_limit_ms.positive?
99
+ end
100
+
101
+ repos.values
102
+ end
103
+
104
+ def fetch_repos_page(page)
105
+ data = if @org
106
+ make_request("/orgs/#{URI.encode_www_form_component(@org)}/repos", page: page, limit: PER_PAGE)
107
+ else
108
+ # the search wraps the repositories: { ok: true, data: [...] }
109
+ make_request("/repos/search", page: page, limit: PER_PAGE)["data"]
110
+ end
111
+
112
+ Array(data).map do |repo|
113
+ {
114
+ "id" => repo["id"],
115
+ "name" => repo["name"],
116
+ "fullName" => repo["full_name"],
117
+ "owner" => repo.dig("owner", "login") || repo["full_name"].to_s.split("/").first,
118
+ "isArchived" => repo["archived"],
119
+ "private" => repo["private"],
120
+ "sshUrl" => repo["ssh_url"],
121
+ "url" => repo["clone_url"] || repo["html_url"]
122
+ }
123
+ end
124
+ end
125
+
126
+ def make_request(path, params = {})
127
+ uri = URI("#{@scheme}://#{@host}/api/v1#{path}")
128
+ uri.query = URI.encode_www_form(params) unless params.empty?
129
+
130
+ http = Net::HTTP.new(uri.host, uri.port)
131
+ http.use_ssl = uri.scheme == "https"
132
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl? && !@verify_ssl
133
+
134
+ request = Net::HTTP::Get.new(uri)
135
+ request["Authorization"] = "token #{@token}"
136
+ request["Accept"] = "application/json"
137
+
138
+ handle_response(http.request(request))
139
+ end
140
+
141
+ def handle_response(response)
142
+ case response
143
+ when Net::HTTPSuccess
144
+ JSON.parse(response.body)
145
+ when Net::HTTPUnauthorized
146
+ raise "Gitea API error: 401 Unauthorized - Invalid or expired GITEA_TOKEN"
147
+ when Net::HTTPForbidden
148
+ raise "Gitea API error: 403 Forbidden - Check token permissions"
149
+ when Net::HTTPNotFound
150
+ raise "Gitea API error: 404 Not Found - #{@org ? "Organization '#{@org}'" : "API"} not found or not accessible on #{@host}"
151
+ else
152
+ raise "Gitea API error: #{response.code} #{response.message}"
153
+ end
154
+ end
155
+
156
+ # Each owner has its own directory; owners that are not listed are left alone
157
+ def prune_stale_cache(repos)
158
+ repos.group_by { |repo| repo["owner"] }.each do |owner, owned|
159
+ prune_stale_cache_entries(File.join(@host_dir, owner), owned.map { |repo| repo["name"] })
160
+ end
161
+ end
162
+
163
+ def generate_repository_imports(repos)
164
+ yaml_documents = repos.map do |repo|
165
+ child_annotations = {}
166
+ child_annotations["import/outputPath"] = @repo_output_path if @repo_output_path
167
+ child_annotations["import/cacheTime"] = @child_cache_time if @child_cache_time
168
+
169
+ child_config = {
170
+ "path" => File.join(@host_dir, repo["owner"], repo["name"]),
171
+ "gitUrl" => repo["sshUrl"] || repo["url"],
172
+ "archived" => repo["isArchived"].to_s,
173
+ "visibility" => repo["private"] == false ? "open-source" : @default_visibility
174
+ }
175
+ child_config["fallbackTeam"] = config("fallbackTeam") if config("fallbackTeam")
176
+ child_config["botTeam"] = config("botTeam") if config("botTeam")
177
+ child_config["corporateAffixes"] = config("corporateAffixes") if config("corporateAffixes")
178
+ child_config["gitService"] = config("gitService", default: "Git:Gitea")
179
+
180
+ import_yaml(
181
+ name: "Import:Repo:gitea:#{repo["owner"]}:#{repo["name"]}",
182
+ handler: "repository",
183
+ config: child_config,
184
+ annotations: child_annotations
185
+ )
186
+ end
187
+
188
+ # Add self-marker with generated/at for caching
189
+ yaml_documents << self_marker
190
+
191
+ write_yaml(yaml_documents.map { |doc| YAML.dump(doc) }.join("\n"))
192
+ end
193
+ end
194
+
195
+ Archsight::Import::Registry.register("gitea", Archsight::Import::Handlers::Gitea)
@@ -165,6 +165,7 @@ class Archsight::Import::Handlers::Github < Archsight::Import::Handler
165
165
  child_config["fallbackTeam"] = config("fallbackTeam") if config("fallbackTeam")
166
166
  child_config["botTeam"] = config("botTeam") if config("botTeam")
167
167
  child_config["corporateAffixes"] = config("corporateAffixes") if config("corporateAffixes")
168
+ child_config["gitService"] = config("gitService", default: "Git:Github")
168
169
 
169
170
  import_yaml(
170
171
  name: "Import:Repo:github:#{@org}:#{repo_name}",
@@ -214,6 +214,7 @@ class Archsight::Import::Handlers::Gitlab < Archsight::Import::Handler
214
214
  child_config["fallbackTeam"] = config("fallbackTeam") if config("fallbackTeam")
215
215
  child_config["botTeam"] = config("botTeam") if config("botTeam")
216
216
  child_config["corporateAffixes"] = config("corporateAffixes") if config("corporateAffixes")
217
+ child_config["gitService"] = config("gitService", default: "Git:Gitlab")
217
218
 
218
219
  import_yaml(
219
220
  name: "Import:Repo:gitlab:#{dir_name}",
@@ -356,10 +356,7 @@ class Archsight::Import::Handlers::Repository < Archsight::Import::Handler
356
356
  spec = {}
357
357
 
358
358
  # Technology component (Git provider)
359
- if git_url
360
- provider = git_url.include?("github") ? "Git:Github" : "Git:Gitlab"
361
- spec["suppliedBy"] = { "technologyComponents" => [provider] }
362
- end
359
+ spec["suppliedBy"] = { "technologyComponents" => [git_service(git_url)] } if git_url
363
360
 
364
361
  # Team relations from contributor matching
365
362
  if team_result
@@ -386,6 +383,12 @@ class Archsight::Import::Handlers::Repository < Archsight::Import::Handler
386
383
  url_line.split("=").last.strip
387
384
  end
388
385
 
386
+ # The TechnologyService that supplies the repository: `gitService` as passed by the listing import
387
+ # (github, gitlab, gitea), else guessed from the clone URL for repository imports written by hand
388
+ def git_service(git_url)
389
+ config("gitService") || (git_url.include?("github") ? "Git:Github" : "Git:Gitlab")
390
+ end
391
+
389
392
  def repository_name(git_url_or_path)
390
393
  if git_url_or_path.include?(":")
391
394
  # Git URL format
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "diagram"
4
+ require_relative "helpers/diagram_blocks"
5
+ require_relative "helpers/asset_images"
6
+
7
+ module Archsight
8
+ # Estimated reading time of a markdown page: its words plus the diagrams (fenced ```asd blocks and embedded
9
+ # .asd files), which take longer the more nodes and edges they have.
10
+ module ReadingTime
11
+ WORDS_PER_MINUTE = 200
12
+ CODE_WEIGHT = 0.5 # code is read, but slower to count: every code word counts this much
13
+ SECONDS_PER_DIAGRAM = 10
14
+ SECONDS_PER_NODE = 3
15
+ SECONDS_PER_EDGE = 2
16
+
17
+ FENCE = /^[ \t]*(```|~~~)[^\n]*\n.*?^[ \t]*\1[ \t]*$/m
18
+ WORD = /\p{L}[\p{L}\p{N}'’-]*|\p{N}+/
19
+ MARKUP = /!\[[^\]]*\]\([^)]*\)|<[^>]+>|\{[a-z]+:[^}]*\}|https?:\/\/\S+/
20
+
21
+ # @return [Hash] `{ minutes:, words:, diagrams: }`; minutes is rounded up, at least 1
22
+ def self.estimate(markdown, base_dir: nil, resources_dir: nil, includes: nil)
23
+ markdown = markdown.to_s
24
+ prose, code = split(markdown)
25
+ words = count(prose)
26
+ sources = Helpers::DiagramBlocks.sources(markdown) + embedded(markdown, base_dir, resources_dir)
27
+ seconds = (words + (count(code) * CODE_WEIGHT)) * 60.0 / WORDS_PER_MINUTE
28
+ seconds += sources.sum { |source| diagram_seconds(source, includes) }
29
+ { minutes: [(seconds / 60.0).ceil, 1].max, words: words, diagrams: sources.size }
30
+ end
31
+
32
+ # Splits the markdown into prose and the text of non-diagram code blocks (diagram blocks are counted separately).
33
+ def self.split(markdown)
34
+ code = []
35
+ prose = markdown.gsub(FENCE) do |block|
36
+ code << block unless block.match?(/\A[ \t]*(?:```|~~~)asd\b/)
37
+ " "
38
+ end
39
+ [prose.gsub(MARKUP, " "), code.join("\n")]
40
+ end
41
+ private_class_method :split
42
+
43
+ def self.count(text)
44
+ text.scan(WORD).size
45
+ end
46
+ private_class_method :count
47
+
48
+ def self.embedded(markdown, base_dir, resources_dir)
49
+ return [] unless resources_dir
50
+
51
+ Helpers::AssetImages.asd_files(markdown, base_dir: base_dir, resources_dir: resources_dir).filter_map do |_path, file|
52
+ source = File.read(file, encoding: "UTF-8") if File.size(file) <= Helpers::AssetImages::MAX_ASD
53
+ source if source&.valid_encoding?
54
+ end
55
+ end
56
+ private_class_method :embedded
57
+
58
+ def self.diagram_seconds(source, includes)
59
+ graph = Diagram::Graph.build(Diagram.expand(source, includes: includes).statements)
60
+ SECONDS_PER_DIAGRAM + (graph.nodes_by_id.size * SECONDS_PER_NODE) + (graph.edges.size * SECONDS_PER_EDGE)
61
+ rescue Diagram::Error
62
+ SECONDS_PER_DIAGRAM
63
+ end
64
+ private_class_method :diagram_seconds
65
+ end
66
+ end
@@ -28,6 +28,7 @@ class Archsight::Resources::ImplementationWorkPackage < Archsight::Resources::Ba
28
28
 
29
29
  - `ownedBy` the accountable actor or role, `performedBy` the actors or roles that carry it out
30
30
  - `realizes` deliverables (its results), requirements and goals
31
+ - `plans` the requirements it will meet but does not yet: the "Requirements" table and `requirements` blocks show them as "planned" (`realizes` shows "implemented"); move them to `realizes` when the work is done
31
32
  - `affects` the assets it changes, for example the `TechnologyEquipment` a project installs; the assessments (risks, findings) it treats are `mitigatedBy` it (written on the assessment)
32
33
  - `triggers` the work packages that follow it; an `ImplementationEvent` can trigger it
33
34
  - A `ImplementationGap` is `closedBy` it
@@ -74,6 +75,7 @@ class Archsight::Resources::ImplementationWorkPackage < Archsight::Resources::Ba
74
75
  relation :performedBy, :businessRoles, :BusinessRole
75
76
  relation :realizes, :implementationDeliverables, :ImplementationDeliverable
76
77
  relation :realizes, :motivationRequirements, :MotivationRequirement
78
+ relation :plans, :motivationRequirements, :MotivationRequirement
77
79
  relation :realizes, :goals, :MotivationGoal
78
80
  relation :affects, :businessProcesses, :BusinessProcess
79
81
  relation :affects, :applicationComponents, :ApplicationComponent
@@ -4,5 +4,5 @@
4
4
  # Do not edit manually.
5
5
 
6
6
  module Archsight
7
- VERSION = "0.5.3"
7
+ VERSION = "0.5.4"
8
8
  end
@@ -313,6 +313,10 @@ paths:
313
313
  tags:
314
314
  - howto
315
315
  - wiki
316
+ reading:
317
+ minutes: 2
318
+ words: 310
319
+ diagrams: 1
316
320
  toc:
317
321
  - level: 2
318
322
  id: create-a-page
@@ -2289,7 +2293,7 @@ components:
2289
2293
 
2290
2294
  PageResponse:
2291
2295
  type: object
2292
- required: [name, title, status, author, owner, created, updated, properties, links, tags, slides, toc, breadcrumb, html, backlinks]
2296
+ required: [name, title, status, author, owner, created, updated, properties, links, tags, slides, reading, toc, breadcrumb, html, backlinks]
2293
2297
  properties:
2294
2298
  name:
2295
2299
  type: string
@@ -2344,6 +2348,21 @@ components:
2344
2348
  - $ref: '#/components/schemas/PageSlides'
2345
2349
  - type: 'null'
2346
2350
  description: The slide deck of the page, null if it has none or the file cannot be served
2351
+ reading:
2352
+ type: object
2353
+ description: Estimated reading time of the body, its words plus its `asd` diagrams (more nodes and edges take longer)
2354
+ required: [minutes, words, diagrams]
2355
+ properties:
2356
+ minutes:
2357
+ type: integer
2358
+ minimum: 1
2359
+ description: Rounded up, at least 1
2360
+ words:
2361
+ type: integer
2362
+ description: Words of the text (code blocks and diagram sources not included)
2363
+ diagrams:
2364
+ type: integer
2365
+ description: Number of `asd` diagrams (fenced blocks and embedded `.asd` files)
2347
2366
  toc:
2348
2367
  type: array
2349
2368
  description: Headings of the body; empty unless the frontmatter has `toc` `yes`
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "../../page_tree"
4
4
  require_relative "../../slides"
5
+ require_relative "../../reading_time"
5
6
 
6
7
  module Archsight; end
7
8
  module Archsight::Web; end
@@ -33,6 +34,7 @@ module Archsight::Web::API::PageHelpers
33
34
  annotations = page.annotations
34
35
  body = strip_duplicate_title(annotations["page/content"].to_s, page)
35
36
  tree = Archsight::PageTree.new(db)
37
+ base = Archsight::Assets.base_dir_for(page, resources_dir: Archsight.resources_dir)
36
38
  {
37
39
  name: page.name,
38
40
  title: page.title,
@@ -45,9 +47,11 @@ module Archsight::Web::API::PageHelpers
45
47
  links: annotations.select { |key, _| key.start_with?("link/") }.transform_keys { |key| key.delete_prefix("link/") },
46
48
  tags: Archsight::Resources::Page.annotation_matching("page/tags")&.value_for(page) || [],
47
49
  slides: Archsight::Slides.for_page(page),
50
+ reading: Archsight::ReadingTime.estimate(body, base_dir: base, resources_dir: Archsight.resources_dir,
51
+ includes: Archsight::Helpers::DiagramIncludes.for(db)),
48
52
  toc: annotations["page/toc"] == "yes" ? Archsight::PageTree.toc(body) : [],
49
53
  breadcrumb: tree.breadcrumb(page),
50
- html: markdown(body, base: Archsight::Assets.base_dir_for(page, resources_dir: Archsight.resources_dir), page: page),
54
+ html: markdown(body, base: base, page: page),
51
55
  backlinks: page_backlinks(page)
52
56
  }
53
57
  end
@@ -1 +1 @@
1
- import{B as e,L as t,R as n,X as r,it as i,p as a,t as o,tt as s}from"./index-le1guGp1.js";import{t as c}from"./WikiPage-BhaaveRq.js";var l={key:1},u={__name:`DocPage`,props:{filename:String},setup(u){let d=u,f=i(null);function p(e,t){let n=new DOMParser().parseFromString(e,`text/html`).body,r=n.querySelector(`:scope > article`)||n,i=r.querySelector(`h1`),a=i?.textContent.trim()||t.split(`/`).pop().replace(/[-_]/g,` `);i?.remove();let o=[...r.querySelectorAll(`h2[id], h3[id], h4[id]`)].map(e=>({level:Number(e.tagName[1]),id:e.id,text:e.textContent.trim()})),s=[{title:`Documentation`}];return t.startsWith(`resources/`)&&s.push({title:`Resource types`}),{title:a,html:r.innerHTML,toc:o.length>=2?o:[],breadcrumb:s}}async function m(){let e=await a(d.filename);f.value=e?p(e,d.filename):{title:`Not found`,html:`<p>Documentation not found.</p>`,toc:[],breadcrumb:[{title:`Documentation`}]},o(f.value.title)}return s(()=>d.filename,m,{immediate:!0}),(i,a)=>f.value?(r(),n(c,{key:0,title:f.value.title,html:f.value.html,breadcrumb:f.value.breadcrumb,toc:f.value.toc},null,8,[`title`,`html`,`breadcrumb`,`toc`])):(r(),e(`article`,l,[...a[0]||=[t(`p`,null,`Loading...`,-1)]]))}};export{u as default};
1
+ import{B as e,L as t,R as n,X as r,it as i,p as a,t as o,tt as s}from"./index-JZkWwfYg.js";import{t as c}from"./WikiPage-DSEL2gmd.js";var l={key:1},u={__name:`DocPage`,props:{filename:String},setup(u){let d=u,f=i(null);function p(e,t){let n=new DOMParser().parseFromString(e,`text/html`).body,r=n.querySelector(`:scope > article`)||n,i=r.querySelector(`h1`),a=i?.textContent.trim()||t.split(`/`).pop().replace(/[-_]/g,` `);i?.remove();let o=[...r.querySelectorAll(`h2[id], h3[id], h4[id]`)].map(e=>({level:Number(e.tagName[1]),id:e.id,text:e.textContent.trim()})),s=[{title:`Documentation`}];return t.startsWith(`resources/`)&&s.push({title:`Resource types`}),{title:a,html:r.innerHTML,toc:o.length>=2?o:[],breadcrumb:s}}async function m(){let e=await a(d.filename);f.value=e?p(e,d.filename):{title:`Not found`,html:`<p>Documentation not found.</p>`,toc:[],breadcrumb:[{title:`Documentation`}]},o(f.value.title)}return s(()=>d.filename,m,{immediate:!0}),(i,a)=>f.value?(r(),n(c,{key:0,title:f.value.title,html:f.value.html,breadcrumb:f.value.breadcrumb,toc:f.value.toc},null,8,[`title`,`html`,`breadcrumb`,`toc`])):(r(),e(`article`,l,[...a[0]||=[t(`p`,null,`Loading...`,-1)]]))}};export{u as default};