tracker-boot-git-hooks 0.1.0 → 0.1.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/README.md +3 -3
- package/package.json +5 -2
- package/src/apiClient.js +2 -2
- package/src/updateChecker.js +21 -15
package/README.md
CHANGED
|
@@ -144,7 +144,7 @@ tracker-boot-git-hooks install --base-url https://trackerboot.staging.example.co
|
|
|
144
144
|
|
|
145
145
|
### TODO
|
|
146
146
|
|
|
147
|
-
- [
|
|
147
|
+
- [x] 世界へのリリース 🌍
|
|
148
148
|
- [ ] キーワードに基づくストーリー状態変更のサポート
|
|
149
149
|
- [ ] より多くのGitホスティングプロバイダーのサポート(GitLab、Bitbucketなど)
|
|
150
150
|
|
|
@@ -286,7 +286,7 @@ tracker-boot-git-hooks install --base-url https://trackerboot.staging.example.co
|
|
|
286
286
|
|
|
287
287
|
### TODO
|
|
288
288
|
|
|
289
|
-
- [
|
|
289
|
+
- [x] 세상에 출시하기 🌍
|
|
290
290
|
- [ ] 키워드를 기반으로 한 스토리 상태 변경 지원
|
|
291
291
|
- [ ] 더 많은 Git 호스팅 제공업체 지원(GitLab、Bitbucket 등)
|
|
292
292
|
|
|
@@ -428,6 +428,6 @@ The hook never blocks a push — if the API is unreachable or returns an error,
|
|
|
428
428
|
|
|
429
429
|
### TODO
|
|
430
430
|
|
|
431
|
-
- [
|
|
431
|
+
- [x] Release to the world 🌍
|
|
432
432
|
- [ ] Support story state changes based on keywords
|
|
433
433
|
- [ ] Support more Git hosting providers (GitLab, Bitbucket, etc.)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tracker-boot-git-hooks",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Git hooks for Tracker Boot — automatically comments on stories when commits are pushed",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -31,7 +31,10 @@
|
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": ">=18.0.0"
|
|
33
33
|
},
|
|
34
|
-
"os": [
|
|
34
|
+
"os": [
|
|
35
|
+
"darwin",
|
|
36
|
+
"linux"
|
|
37
|
+
],
|
|
35
38
|
"dependencies": {
|
|
36
39
|
"boxen": "^8.0.1"
|
|
37
40
|
},
|
package/src/apiClient.js
CHANGED
|
@@ -37,7 +37,7 @@ function assertNoErrors(json) {
|
|
|
37
37
|
if (json.errors?.length) throw new Error(json.errors[0].message)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
async function graphqlPost(url, headers, body, timeoutMs =
|
|
40
|
+
async function graphqlPost(url, headers, body, timeoutMs = 2000) {
|
|
41
41
|
const controller = new AbortController()
|
|
42
42
|
const timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
43
43
|
let res
|
|
@@ -49,7 +49,7 @@ async function graphqlPost(url, headers, body, timeoutMs = 5000) {
|
|
|
49
49
|
signal: controller.signal,
|
|
50
50
|
})
|
|
51
51
|
} catch (err) {
|
|
52
|
-
throw new Error(err.name === 'AbortError' ?
|
|
52
|
+
throw new Error(err.name === 'AbortError' ? `request timed out after ${timeoutMs}ms` : err.message)
|
|
53
53
|
} finally {
|
|
54
54
|
clearTimeout(timer)
|
|
55
55
|
}
|
package/src/updateChecker.js
CHANGED
|
@@ -14,21 +14,27 @@ function isNewer(latest, current) {
|
|
|
14
14
|
|
|
15
15
|
export async function checkForUpdate({ timeoutMs = 2000, fetch: _fetch = fetch } = {}) {
|
|
16
16
|
const current = require('../package.json').version
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const controller = new AbortController()
|
|
18
|
+
const deadline = new Promise(resolve => {
|
|
19
|
+
controller.signal.addEventListener('abort', () => resolve(null))
|
|
20
|
+
})
|
|
21
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
22
|
+
const attempt = (async () => {
|
|
21
23
|
try {
|
|
22
|
-
res
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
let res
|
|
25
|
+
try {
|
|
26
|
+
res = await _fetch(NPM_REGISTRY_URL, { signal: controller.signal })
|
|
27
|
+
} finally {
|
|
28
|
+
clearTimeout(timer)
|
|
29
|
+
}
|
|
30
|
+
if (!res.ok) return null
|
|
31
|
+
const data = await res.json()
|
|
32
|
+
const latest = data?.version
|
|
33
|
+
if (typeof latest !== 'string' || !isNewer(latest, current)) return null
|
|
34
|
+
return { latest, current }
|
|
35
|
+
} catch {
|
|
36
|
+
return null
|
|
25
37
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const latest = data?.version
|
|
29
|
-
if (typeof latest !== 'string' || !isNewer(latest, current)) return null
|
|
30
|
-
return { latest, current }
|
|
31
|
-
} catch {
|
|
32
|
-
return null
|
|
33
|
-
}
|
|
38
|
+
})()
|
|
39
|
+
return Promise.race([attempt, deadline])
|
|
34
40
|
}
|