cli-mergeguard 7.0.42 → 7.0.43
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/official-skill-update.mjs +16 -3
- package/package.json +1 -1
- package/skill/SKILL.md +1 -1
- package/skill/skill.json +1 -1
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { refreshManagedSkillCopies } from './installer-storage.mjs'
|
|
2
2
|
import { execFile, spawn } from 'node:child_process'
|
|
3
|
+
import { setTimeout as delay } from 'node:timers/promises'
|
|
3
4
|
import { promisify } from 'node:util'
|
|
4
5
|
import { lstat, mkdtemp, readFile, rename, rm } from 'node:fs/promises'
|
|
5
6
|
import { join, win32 } from 'node:path'
|
|
6
7
|
import { assertAccountAncestors, currentAccountHome, ensureAccountDirectory, windowsSystemExecutable } from './broker-account-storage.mjs'
|
|
7
8
|
import { pathToFileURL } from 'node:url'
|
|
8
9
|
import { accountBrokerDirectory } from './broker-credentials.mjs'
|
|
9
|
-
import { createBrokerTransport } from './broker-transport.mjs'
|
|
10
|
+
import { BrokerTransportError, createBrokerTransport } from './broker-transport.mjs'
|
|
10
11
|
|
|
11
12
|
const runFile = promisify(execFile)
|
|
12
|
-
export const LOOKUP_TIMEOUT_MS =
|
|
13
|
+
export const LOOKUP_TIMEOUT_MS = 20_000
|
|
14
|
+
const LOOKUP_ATTEMPTS = 2
|
|
15
|
+
const LOOKUP_RETRY_DELAY_MS = 250
|
|
13
16
|
const INSTALL_TIMEOUT_MS = 120_000
|
|
14
17
|
const RELEASE_PATTERN = /^(?:v)?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/
|
|
15
18
|
const OFFICIAL_IDENTITIES = Object.freeze({
|
|
@@ -23,6 +26,16 @@ function releaseVersion(value) {
|
|
|
23
26
|
return value.replace(/^v/, '')
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
async function readOfficialRelease(request, endpoint) {
|
|
30
|
+
for (let attempt = 1; attempt <= LOOKUP_ATTEMPTS; attempt += 1) {
|
|
31
|
+
try { return await request(endpoint, { redirect: 'error', signal: AbortSignal.timeout(LOOKUP_TIMEOUT_MS) }) }
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (!(error instanceof BrokerTransportError) || attempt === LOOKUP_ATTEMPTS) throw error
|
|
34
|
+
await delay(LOOKUP_RETRY_DELAY_MS)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
26
39
|
export async function inspectOfficialRelease(context, dependencies = {}) {
|
|
27
40
|
if (OFFICIAL_IDENTITIES[context.npmName] !== context.runtimeCode || typeof context.packageRoot !== 'string'
|
|
28
41
|
|| context.endpoint !== 'https://cli.tax/' + context.runtimeCode) {
|
|
@@ -32,7 +45,7 @@ export async function inspectOfficialRelease(context, dependencies = {}) {
|
|
|
32
45
|
const request = dependencies.request === undefined ? createBrokerTransport({ environment }) : dependencies.request
|
|
33
46
|
const endpoint = 'https://cli.tax/api/public/skills/' + context.runtimeCode
|
|
34
47
|
if (!/^[A-Za-z0-9]{10}$/.test(context.runtimeCode)) throw new Error('Official runtime code is invalid')
|
|
35
|
-
const response = await request
|
|
48
|
+
const response = await readOfficialRelease(request, endpoint)
|
|
36
49
|
if (!response.ok) throw new Error('Official release lookup failed: HTTP ' + response.status)
|
|
37
50
|
const payload = await response.json()
|
|
38
51
|
const version = releaseVersion(payload.version)
|
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED