poad 2.55.0 → 2.55.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.
- package/package.json +1 -1
- package/utils/latest.js +9 -4
package/package.json
CHANGED
package/utils/latest.js
CHANGED
|
@@ -14,9 +14,14 @@
|
|
|
14
14
|
const { isVersion, isRelease, compareVersions } = require('./version');
|
|
15
15
|
|
|
16
16
|
const TAGS_URL = 'https://hub.docker.com/v2/repositories/poadio/engine/tags?page_size=100';
|
|
17
|
+
// permalink par l'API de GitHub (contenu brut) : la dernière version tout de suite, là où
|
|
18
|
+
// raw.githubusercontent.com garde jusqu'à 5 min de cache ; raw en secours (limite de l'API atteinte)
|
|
19
|
+
const PERMALINK_API = 'https://api.github.com/repos/poadio/permalink/contents/poad.json';
|
|
17
20
|
const PERMALINK_URL = 'https://raw.githubusercontent.com/poadio/permalink/main/poad.json';
|
|
18
21
|
const CHANNELS = ['stable', 'beta'];
|
|
19
|
-
|
|
22
|
+
// 15 min : une version publiée est vue vite (plusieurs versions par jour en développement),
|
|
23
|
+
// sans dépasser la limite de l'API de GitHub sans authentification (60 lectures par heure)
|
|
24
|
+
const CACHE_TTL = 15 * 60 * 1000;
|
|
20
25
|
|
|
21
26
|
// Seules les versions x.y.z comptent : ni latest, ni préversion
|
|
22
27
|
const pickLatest = (tags) => {
|
|
@@ -24,9 +29,9 @@ const pickLatest = (tags) => {
|
|
|
24
29
|
return versions.length ? versions.sort(compareVersions).pop() : null;
|
|
25
30
|
};
|
|
26
31
|
|
|
27
|
-
const fetchJson = async (url, timeout) => {
|
|
32
|
+
const fetchJson = async (url, timeout, headers = {}) => {
|
|
28
33
|
try {
|
|
29
|
-
const res = await fetch(url, { signal: AbortSignal.timeout(timeout), headers: { 'cache-control': 'no-cache' } });
|
|
34
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(timeout), headers: { 'cache-control': 'no-cache', ...headers } });
|
|
30
35
|
return res.ok ? await res.json() : null;
|
|
31
36
|
} catch {
|
|
32
37
|
return null;
|
|
@@ -40,7 +45,7 @@ const latestEngine = async (timeout = 4000) => {
|
|
|
40
45
|
|
|
41
46
|
/** Versions d'engine par canal lues dans permalink : { stable?, beta? }, ou null */
|
|
42
47
|
const permalinkEngines = async (timeout = 4000) => {
|
|
43
|
-
const body = await fetchJson(PERMALINK_URL, timeout);
|
|
48
|
+
const body = (await fetchJson(PERMALINK_API, timeout, { accept: 'application/vnd.github.raw+json', 'user-agent': 'poad-cli' })) || (await fetchJson(PERMALINK_URL, timeout));
|
|
44
49
|
const engine = body && typeof body === 'object' ? body.engine : null;
|
|
45
50
|
if (!engine || typeof engine !== 'object') return null;
|
|
46
51
|
const out = {};
|