webctx 0.2.1

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 (40) hide show
  1. package/AGENTS.md +97 -0
  2. package/CONTRIBUTORS.md +126 -0
  3. package/LICENSE +202 -0
  4. package/Makefile +69 -0
  5. package/README.md +121 -0
  6. package/bin/webctx.js +28 -0
  7. package/cmd/webctx/main.go +11 -0
  8. package/docs/porting-status.md +173 -0
  9. package/go.mod +3 -0
  10. package/internal/app/app.go +139 -0
  11. package/internal/app/app_test.go +194 -0
  12. package/internal/app/github.go +2084 -0
  13. package/internal/app/github_acceptance_test.go +166 -0
  14. package/internal/app/github_actions.go +1008 -0
  15. package/internal/app/github_actions_test.go +484 -0
  16. package/internal/app/github_activity_deployments.go +503 -0
  17. package/internal/app/github_activity_deployments_test.go +321 -0
  18. package/internal/app/github_commits.go +1004 -0
  19. package/internal/app/github_commits_test.go +503 -0
  20. package/internal/app/github_discussions_gists.go +1156 -0
  21. package/internal/app/github_discussions_gists_test.go +425 -0
  22. package/internal/app/github_issues.go +1616 -0
  23. package/internal/app/github_issues_test.go +731 -0
  24. package/internal/app/github_packages_projects.go +429 -0
  25. package/internal/app/github_packages_projects_test.go +168 -0
  26. package/internal/app/github_phase9_overview_stress_test.go +178 -0
  27. package/internal/app/github_pull_views.go +1141 -0
  28. package/internal/app/github_pull_views_test.go +603 -0
  29. package/internal/app/github_pulls.go +1459 -0
  30. package/internal/app/github_pulls_test.go +715 -0
  31. package/internal/app/github_refs.go +621 -0
  32. package/internal/app/github_refs_test.go +260 -0
  33. package/internal/app/github_search_profiles.go +505 -0
  34. package/internal/app/github_search_profiles_test.go +352 -0
  35. package/internal/app/github_test.go +888 -0
  36. package/internal/app/scrape.go +264 -0
  37. package/internal/app/tools.go +670 -0
  38. package/internal/buildinfo/buildinfo.go +16 -0
  39. package/package.json +66 -0
  40. package/scripts/postinstall.js +137 -0
@@ -0,0 +1,178 @@
1
+ package app
2
+
3
+ import (
4
+ "encoding/json"
5
+ "fmt"
6
+ "net/url"
7
+ "strings"
8
+ "testing"
9
+ "unicode/utf8"
10
+ )
11
+
12
+ func assertGitHubOverviewBound(t *testing.T, name, out string) {
13
+ t.Helper()
14
+ if got := utf8.RuneCountInString(out); got > githubOverviewRunes {
15
+ t.Fatalf("%s exceeded shared overview target: %d runes\n%s", name, got, out)
16
+ }
17
+ }
18
+
19
+ func TestPhase9AdversarialHumanTextCannotAmplifyMajorOverviews(t *testing.T) {
20
+ long := strings.Repeat("very long human-authored metadata ", 600)
21
+ body := long
22
+
23
+ t.Run("issue-root", func(t *testing.T) {
24
+ issue := githubIssue{ID: 123, Number: 42, State: "open", Title: long, Body: &body, HTMLURL: "https://github.com/o/r/issues/42", Comments: 500}
25
+ for i := 0; i < 100; i++ {
26
+ issue.Labels = append(issue.Labels, githubIssueLabel{Name: fmt.Sprintf("label-%03d-%s", i, strings.Repeat("x", 80))})
27
+ issue.Assignees = append(issue.Assignees, githubUser{Login: fmt.Sprintf("assignee-%03d-%s", i, strings.Repeat("y", 80))})
28
+ }
29
+ rel := githubIssueRelationships{SubIssues: []githubIssue{{Number: 43, Title: long, HTMLURL: "https://github.com/o/r/issues/43"}}, Fields: []githubIssueFieldValue{{IssueFieldName: long, Value: long}}}
30
+ out := renderGitHubIssue(parseGitHubTarget("https://github.com/o/r/issues/42"), issue, nil, rel, githubIssueAvailability{TimelineProviderMore: true})
31
+ assertGitHubOverviewBound(t, "Issue root", out)
32
+ for _, want := range []string{"title_preview_truncated: true", "labels_local_omitted: 95", "assignees_local_omitted: 95", "https://github.com/o/r/issues/42#issue-123"} {
33
+ if !strings.Contains(out, want) {
34
+ t.Fatalf("Issue overview missing %q:\n%s", want, out)
35
+ }
36
+ }
37
+ })
38
+
39
+ t.Run("pull-root", func(t *testing.T) {
40
+ pr := githubPullRequest{Number: 42, State: "open", Title: long, Body: &body, HTMLURL: "https://github.com/o/r/pull/42", Comments: 500, ReviewComments: 500, Commits: 400, ChangedFiles: 1000}
41
+ pr.Base.Label = long
42
+ pr.Head.Label = long
43
+ out := renderGitHubPullRequest(parseGitHubTarget("https://github.com/o/r/pull/42"), pr, 99, nil, nil, nil, githubPullOverviewAvailability{TimelineProviderMore: true}, "", false)
44
+ assertGitHubOverviewBound(t, "Pull Request root", out)
45
+ if !strings.Contains(out, "title_preview_truncated: true") || !strings.Contains(out, "#issue-99") {
46
+ t.Fatalf("PR overview lost bounded-title/exact-body navigation:\n%s", out)
47
+ }
48
+ })
49
+
50
+ t.Run("release-root", func(t *testing.T) {
51
+ release := githubRelease{TagName: long, Name: long, HTMLURL: "https://github.com/o/r/releases/tag/v1", Body: &body}
52
+ out := renderGitHubRelease(parseGitHubTarget("https://github.com/o/r/releases/tag/v1"), release, githubReleaseAssetsAvailability{})
53
+ assertGitHubOverviewBound(t, "Release root", out)
54
+ if !strings.Contains(out, "tag_preview_truncated: true") || !strings.Contains(out, "name_preview_truncated: true") || !strings.Contains(out, "Canonical GitHub release page (complete notes in the browser):") {
55
+ t.Fatalf("release overview lost truncation/deeper navigation:\n%s", out)
56
+ }
57
+ })
58
+
59
+ t.Run("discussion-root", func(t *testing.T) {
60
+ detail := githubDiscussionDetail{githubDiscussionSummary: githubDiscussionSummary{Number: 7, Title: long, URL: "https://github.com/o/r/discussions/7", Category: long}, Body: body, CommentsReported: 100, CommentsProviderMore: true}
61
+ out := renderGitHubDiscussion(parseGitHubTarget("https://github.com/o/r/discussions/7"), detail)
62
+ assertGitHubOverviewBound(t, "Discussion root", out)
63
+ if !strings.Contains(out, "title_preview_truncated: true") || !strings.Contains(out, "category_preview_truncated: true") {
64
+ t.Fatalf("Discussion overview lost bounded metadata:\n%s", out)
65
+ }
66
+ })
67
+ }
68
+
69
+ func TestPhase9AdversarialOverviewIndexesStayBounded(t *testing.T) {
70
+ long := strings.Repeat("long index value ", 200)
71
+ target := parseGitHubTarget("https://github.com/o/r")
72
+
73
+ t.Run("issues", func(t *testing.T) {
74
+ items := make([]githubIssue, githubPageableListSize)
75
+ for i := range items {
76
+ items[i] = githubIssue{Number: i + 1, State: "open", Title: long, HTMLURL: fmt.Sprintf("https://github.com/o/r/issues/%d", i+1)}
77
+ for j := 0; j < 20; j++ {
78
+ items[i].Labels = append(items[i].Labels, githubIssueLabel{Name: long})
79
+ }
80
+ }
81
+ listTarget := parseGitHubTarget("https://github.com/o/r/issues")
82
+ out := renderGitHubIssueList(listTarget, items, nil, 100, false)
83
+ assertGitHubOverviewBound(t, "Issue list", out)
84
+ if !strings.Contains(out, fmt.Sprintf("results_indexed: %d", githubPageableListSize)) || !strings.Contains(out, "results_local_omitted: 0") {
85
+ t.Fatalf("Issue provider page was not rendered completely:\n%s", out)
86
+ }
87
+ })
88
+
89
+ t.Run("pulls", func(t *testing.T) {
90
+ items := make([]githubPullListItem, githubPageableListSize)
91
+ for i := range items {
92
+ items[i] = githubPullListItem{Number: i + 1, State: "open", Title: long, HTMLURL: fmt.Sprintf("https://github.com/o/r/pull/%d", i+1)}
93
+ }
94
+ out := renderGitHubPullList(parseGitHubTarget("https://github.com/o/r/pulls"), items, nil, 100, false)
95
+ assertGitHubOverviewBound(t, "Pull list", out)
96
+ })
97
+
98
+ t.Run("repository-lists", func(t *testing.T) {
99
+ branches := make([]githubBranch, githubPageableListSize)
100
+ tags := make([]githubTag, githubPageableListSize)
101
+ releases := make([]githubRelease, githubPageableListSize)
102
+ forks := make([]githubFork, githubPageableListSize)
103
+ stars := make([]githubStar, githubPageableListSize)
104
+ users := make([]githubUser, githubPageableListSize)
105
+ for i := range branches {
106
+ branches[i].Name = fmt.Sprintf("branch-%02d-%s", i, strings.Repeat("x", 80))
107
+ tags[i].Name = fmt.Sprintf("tag-%02d-%s", i, strings.Repeat("y", 80))
108
+ releases[i].Name, releases[i].TagName = long, fmt.Sprintf("v%d", i)
109
+ releases[i].HTMLURL = fmt.Sprintf("https://github.com/o/r/releases/tag/%d", i)
110
+ forks[i].FullName, forks[i].HTMLURL = long, fmt.Sprintf("https://github.com/fork/%d", i)
111
+ stars[i].User.Login = fmt.Sprintf("user-%d", i)
112
+ users[i].Login = fmt.Sprintf("user-%d", i)
113
+ }
114
+ for name, out := range map[string]string{
115
+ "branches": renderGitHubBranches(target, branches, nil),
116
+ "tags": renderGitHubTags(target, tags, nil),
117
+ "releases": renderGitHubReleases(target, releases, nil),
118
+ "forks": renderGitHubForks(target, forks, nil),
119
+ "stargazers": renderGitHubStargazers(target, stars, nil),
120
+ "watchers": renderGitHubWatchers(target, users, nil),
121
+ } {
122
+ assertGitHubOverviewBound(t, name, out)
123
+ }
124
+ })
125
+
126
+ t.Run("search", func(t *testing.T) {
127
+ items := make([]githubRepository, githubPageableListSize)
128
+ for i := range items {
129
+ items[i] = githubRepository{FullName: fmt.Sprintf("o/r-%d", i), HTMLURL: fmt.Sprintf("https://github.com/o/r-%d", i), Description: long}
130
+ }
131
+ raw, _ := json.Marshal(items)
132
+ searchTarget := &GitHubTarget{Kind: GitHubTargetSearch, Query: url.Values{"q": []string{long}}}
133
+ out, err := renderGitHubSearch(searchTarget, "repositories", githubSearchEnvelope{Items: raw, TotalCount: 5000}, nil)
134
+ if err != nil {
135
+ t.Fatal(err)
136
+ }
137
+ assertGitHubOverviewBound(t, "Search", out)
138
+ if !strings.Contains(out, fmt.Sprintf("indexed: %d", githubPageableListSize)) || !strings.Contains(out, "local_omitted: 0") || !strings.Contains(out, "query_preview_truncated: true") {
139
+ t.Fatalf("Search bounds not explicit:\n%s", out)
140
+ }
141
+ })
142
+
143
+ t.Run("package-project-workflow-history", func(t *testing.T) {
144
+ pkg := githubPackage{Name: "pkg", PackageType: "container", HTMLURL: "https://github.com/users/o/packages/container/package/pkg"}
145
+ pkg.Description = &long
146
+ versions := make([]githubPackageVersion, githubPageableListSize)
147
+ for i := range versions {
148
+ versions[i].Name = long
149
+ versions[i].PackageHTMLURL = fmt.Sprintf("https://github.com/pkg/%d", i)
150
+ versions[i].Metadata.Container.Tags = make([]string, 3)
151
+ for j := range versions[i].Metadata.Container.Tags {
152
+ versions[i].Metadata.Container.Tags[j] = long
153
+ }
154
+ }
155
+ assertGitHubOverviewBound(t, "Package", renderGitHubPackage(&GitHubTarget{Owner: "o", Query: url.Values{}}, pkg, versions, nil))
156
+
157
+ project := githubProjectV2{Number: 1, Title: long, ShortDescription: long, URL: "https://github.com/orgs/o/projects/1", Items: make([]githubProjectV2Item, 50), MoreItems: true}
158
+ for i := range project.Items {
159
+ project.Items[i] = githubProjectV2Item{Title: long, URL: fmt.Sprintf("https://github.com/o/r/issues/%d", i+1), Type: long, Repository: long, State: long}
160
+ }
161
+ assertGitHubOverviewBound(t, "Project", renderGitHubProjectV2(&GitHubTarget{Owner: "o"}, project))
162
+
163
+ workflows := make([]githubWorkflow, githubPageableListSize)
164
+ for i := range workflows {
165
+ workflows[i] = githubWorkflow{ID: int64(i + 1), Name: long, Path: fmt.Sprintf(".github/workflows/workflow-%02d.yml", i), HTMLURL: fmt.Sprintf("https://github.com/o/r/blob/main/.github/workflows/workflow-%02d.yml", i)}
166
+ }
167
+ assertGitHubOverviewBound(t, "Workflow list", renderGitHubWorkflows(target, workflows, 30, nil))
168
+
169
+ commits := make([]githubPullCommit, githubPageableListSize)
170
+ for i := range commits {
171
+ commits[i].SHA = fmt.Sprintf("%040x", i+1)
172
+ commits[i].HTMLURL = fmt.Sprintf("https://github.com/o/r/commit/%040x", i+1)
173
+ commits[i].Commit.Message = long
174
+ commits[i].Commit.Author.Name = long
175
+ }
176
+ assertGitHubOverviewBound(t, "History", renderGitHubHistory(target, resolvedGitHubPath{Ref: "main"}, 1, commits, nil))
177
+ })
178
+ }