uncial-cms 2.0.1 → 2.0.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.
- package/LICENSE +21 -0
- package/dist/github/adapter.js +61 -2
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 David A. Flood
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/github/adapter.js
CHANGED
|
@@ -75,17 +75,76 @@ class GitHubAdapter {
|
|
|
75
75
|
.filter((entry) => entry.type === 'file' || entry.type === 'dir')
|
|
76
76
|
.map((entry) => ({ path: entry.path, type: entry.type }));
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Both of GitHub's two answers to "how did this commit fare", because a repo
|
|
80
|
+
* may use either.
|
|
81
|
+
*
|
|
82
|
+
* ⚠ The combined Status API aggregates the *Status* API alone, and GitHub
|
|
83
|
+
* Actions writes **check runs**, not statuses. A repository built by Actions
|
|
84
|
+
* — which is every Pages site deployed from a workflow — therefore has
|
|
85
|
+
* `state: "pending"` and an empty `statuses` array on that endpoint for
|
|
86
|
+
* ever, and a poll that trusted it would sit at "building…" through a deploy
|
|
87
|
+
* that has already succeeded. So an empty `statuses` is read as *no signal*
|
|
88
|
+
* rather than as pending, and the check runs are asked as well.
|
|
89
|
+
*/
|
|
78
90
|
async commitStatus(commitSha) {
|
|
79
|
-
const
|
|
91
|
+
const sha = encodeURIComponent(commitSha);
|
|
92
|
+
const base = `${GITHUB_API_URL}/repos/${this.#config.repo}/commits/${sha}`;
|
|
93
|
+
const [fromStatuses, fromChecks] = await Promise.all([
|
|
94
|
+
this.#statusApiSignal(`${base}/status`),
|
|
95
|
+
this.#checkRunSignal(`${base}/check-runs`)
|
|
96
|
+
]);
|
|
97
|
+
const signals = [fromStatuses, fromChecks].filter((signal) => signal !== 'unknown');
|
|
98
|
+
if (signals.includes('failure'))
|
|
99
|
+
return 'failure';
|
|
100
|
+
if (signals.includes('pending'))
|
|
101
|
+
return 'pending';
|
|
102
|
+
return signals.includes('success') ? 'success' : 'unknown';
|
|
103
|
+
}
|
|
104
|
+
async #statusApiSignal(url) {
|
|
105
|
+
const response = await this.#request(url);
|
|
80
106
|
if (!response.ok)
|
|
81
107
|
return 'unknown';
|
|
82
|
-
const { state } = (await response.json());
|
|
108
|
+
const { state, statuses } = (await response.json());
|
|
109
|
+
if ((statuses ?? []).length === 0)
|
|
110
|
+
return 'unknown';
|
|
83
111
|
if (state === 'pending' || state === 'success')
|
|
84
112
|
return state;
|
|
85
113
|
if (state === 'failure' || state === 'error')
|
|
86
114
|
return 'failure';
|
|
87
115
|
return 'unknown';
|
|
88
116
|
}
|
|
117
|
+
async #checkRunSignal(url) {
|
|
118
|
+
const response = await this.#request(url);
|
|
119
|
+
if (!response.ok)
|
|
120
|
+
return 'unknown';
|
|
121
|
+
const { check_runs: runs } = (await response.json());
|
|
122
|
+
if (!runs || runs.length === 0)
|
|
123
|
+
return 'unknown';
|
|
124
|
+
let pending = false;
|
|
125
|
+
let success = false;
|
|
126
|
+
for (const run of runs) {
|
|
127
|
+
if (run.status !== 'completed') {
|
|
128
|
+
pending = true;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
switch (run.conclusion) {
|
|
132
|
+
case 'success':
|
|
133
|
+
case 'neutral':
|
|
134
|
+
case 'skipped':
|
|
135
|
+
success = true;
|
|
136
|
+
break;
|
|
137
|
+
// A run superseded by a later one says nothing about this commit.
|
|
138
|
+
case 'stale':
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
return 'failure';
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (pending)
|
|
145
|
+
return 'pending';
|
|
146
|
+
return success ? 'success' : 'unknown';
|
|
147
|
+
}
|
|
89
148
|
#contentsUrl(path) {
|
|
90
149
|
return `${GITHUB_API_URL}/repos/${this.#config.repo}/contents/${encodeRepoPath(path)}`;
|
|
91
150
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uncial-cms",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@sveltejs/kit": "^2.0.0",
|
|
66
66
|
"svelte": "^5.0.0",
|
|
67
|
-
"uncial": "^2.0.
|
|
67
|
+
"uncial": "^2.0.3"
|
|
68
68
|
},
|
|
69
69
|
"peerDependenciesMeta": {
|
|
70
70
|
"@sveltejs/kit": {
|