@faable/faable 4.5.4 → 4.5.5
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/dist/lib/UpdateChecker.js +10 -4
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ import { log } from '../log.js';
|
|
|
6
6
|
|
|
7
7
|
const CLI_PACKAGE = "@faable/faable";
|
|
8
8
|
const REGISTRY_URL = `https://registry.npmjs.org/${CLI_PACKAGE}/latest`;
|
|
9
|
+
const PACKUMENT_URL = `https://registry.npmjs.org/${CLI_PACKAGE.replace("/", "%2f")}`;
|
|
9
10
|
// Hitting the registry at most once a day keeps the background refresh rare.
|
|
10
11
|
const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
11
12
|
const UPGRADE_FETCH_TIMEOUT_MS = 10_000;
|
|
@@ -77,16 +78,21 @@ const spawnBackgroundRefresh = () => {
|
|
|
77
78
|
*/
|
|
78
79
|
const getLatestVersion = async () => {
|
|
79
80
|
try {
|
|
80
|
-
|
|
81
|
+
// The same (abbreviated) packument `npm install` resolves against, not
|
|
82
|
+
// `/latest`: for a few minutes after a release the two endpoints
|
|
83
|
+
// disagree, and offering a version npm can't find yet ends in ETARGET.
|
|
84
|
+
const res = await fetch(PACKUMENT_URL, {
|
|
85
|
+
headers: { Accept: "application/vnd.npm.install-v1+json" },
|
|
81
86
|
signal: AbortSignal.timeout(UPGRADE_FETCH_TIMEOUT_MS),
|
|
82
87
|
});
|
|
83
88
|
if (!res.ok)
|
|
84
89
|
return;
|
|
85
90
|
const data = (await res.json());
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
const version = data["dist-tags"]?.latest;
|
|
92
|
+
if (version) {
|
|
93
|
+
await writeCache({ last_check: new Date().toISOString(), latest: version });
|
|
88
94
|
}
|
|
89
|
-
return
|
|
95
|
+
return version;
|
|
90
96
|
}
|
|
91
97
|
catch {
|
|
92
98
|
return;
|