renovate 42.58.0 → 42.58.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.
|
@@ -20,29 +20,19 @@ function cache({ namespace, key, cacheable = () => true, ttlMinutes = 30, }) {
|
|
|
20
20
|
if (!isCacheable) {
|
|
21
21
|
return callback();
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
else if ((0, is_1.isFunction)(namespace)) {
|
|
28
|
-
finalNamespace = namespace.apply(instance, args);
|
|
29
|
-
}
|
|
30
|
-
let finalKey;
|
|
31
|
-
if ((0, is_1.isString)(key)) {
|
|
32
|
-
finalKey = key;
|
|
33
|
-
}
|
|
34
|
-
else if ((0, is_1.isFunction)(key)) {
|
|
35
|
-
finalKey = key.apply(instance, args);
|
|
36
|
-
}
|
|
23
|
+
const finalNamespace = (0, is_1.isString)(namespace)
|
|
24
|
+
? namespace
|
|
25
|
+
: namespace.apply(instance, args);
|
|
26
|
+
const finalKey = (0, is_1.isString)(key) ? key : key.apply(instance, args);
|
|
37
27
|
// istanbul ignore if
|
|
38
28
|
if (!finalNamespace || !finalKey) {
|
|
39
29
|
return callback();
|
|
40
30
|
}
|
|
41
|
-
|
|
31
|
+
const cacheKey = `cache-decorator:${finalKey}`;
|
|
42
32
|
// prevent concurrent processing and cache writes
|
|
43
|
-
const releaseLock = await (0, mutex_1.acquireLock)(
|
|
33
|
+
const releaseLock = await (0, mutex_1.acquireLock)(cacheKey, finalNamespace);
|
|
44
34
|
try {
|
|
45
|
-
const
|
|
35
|
+
const cachedRecord = await packageCache.get(finalNamespace, cacheKey);
|
|
46
36
|
// eslint-disable-next-line prefer-const
|
|
47
37
|
let { softTtlMinutes, hardTtlMinutes } = (0, ttl_1.resolveTtlValues)(finalNamespace, ttlMinutes);
|
|
48
38
|
// The separation between "soft" and "hard" TTL allows us to treat
|
|
@@ -60,40 +50,38 @@ function cache({ namespace, key, cacheable = () => true, ttlMinutes = 30, }) {
|
|
|
60
50
|
if (methodName !== 'getReleases' && methodName !== 'getDigest') {
|
|
61
51
|
hardTtlMinutes = softTtlMinutes;
|
|
62
52
|
}
|
|
63
|
-
let
|
|
64
|
-
if (
|
|
53
|
+
let fallbackValue;
|
|
54
|
+
if (cachedRecord) {
|
|
65
55
|
const now = luxon_1.DateTime.local();
|
|
66
|
-
const cachedAt = luxon_1.DateTime.fromISO(
|
|
56
|
+
const cachedAt = luxon_1.DateTime.fromISO(cachedRecord.cachedAt);
|
|
67
57
|
const softDeadline = cachedAt.plus({ minutes: softTtlMinutes });
|
|
68
58
|
if (now < softDeadline) {
|
|
69
|
-
return
|
|
59
|
+
return cachedRecord.value;
|
|
70
60
|
}
|
|
71
61
|
const hardDeadline = cachedAt.plus({ minutes: hardTtlMinutes });
|
|
72
62
|
if (now < hardDeadline) {
|
|
73
|
-
|
|
63
|
+
fallbackValue = cachedRecord.value;
|
|
74
64
|
}
|
|
75
65
|
}
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
66
|
+
let newValue;
|
|
67
|
+
try {
|
|
68
|
+
newValue = await callback();
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
if (!(0, is_1.isUndefined)(fallbackValue)) {
|
|
82
72
|
logger_1.logger.debug({ err }, 'Package cache decorator: callback error, returning old data');
|
|
83
|
-
return
|
|
73
|
+
return fallbackValue;
|
|
84
74
|
}
|
|
75
|
+
throw err;
|
|
85
76
|
}
|
|
86
|
-
|
|
87
|
-
newData = await callback();
|
|
88
|
-
}
|
|
89
|
-
if (!(0, is_1.isUndefined)(newData)) {
|
|
77
|
+
if (!(0, is_1.isUndefined)(newValue)) {
|
|
90
78
|
const newRecord = {
|
|
91
79
|
cachedAt: luxon_1.DateTime.local().toISO(),
|
|
92
|
-
value:
|
|
80
|
+
value: newValue,
|
|
93
81
|
};
|
|
94
|
-
await packageCache.setWithRawTtl(finalNamespace,
|
|
82
|
+
await packageCache.setWithRawTtl(finalNamespace, cacheKey, newRecord, hardTtlMinutes);
|
|
95
83
|
}
|
|
96
|
-
return
|
|
84
|
+
return newValue;
|
|
97
85
|
}
|
|
98
86
|
finally {
|
|
99
87
|
releaseLock();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../../lib/util/cache/package/decorator.ts"],"names":[],"mappings":";;AAgDA,
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../../lib/util/cache/package/decorator.ts"],"names":[],"mappings":";;AAgDA,sBA4GC;;AA5JD,yCAAyD;AACzD,iCAAiC;AACjC,mDAAsD;AACtD,4CAAyC;AAEzC,+CAA2C;AAC3C,uCAA0C;AAC1C,+BAAyC;AAEzC,wDAAkC;AAoClC;;GAEG;AACH,SAAgB,KAAK,CAAI,EACvB,SAAS,EACT,GAAG,EACH,SAAS,GAAG,GAAG,EAAE,CAAC,IAAI,EACtB,UAAU,GAAG,EAAE,GACC;IAChB,OAAO,IAAA,oBAAQ,EAAC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;QACjE,MAAM,oBAAoB,GAAG,qBAAY,CAAC,GAAG,CAC3C,sBAAsB,EACtB,KAAK,CACN,CAAC;QACF,MAAM,WAAW,GAAG,oBAAoB,IAAI,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC5E,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,QAAQ,EAAE,CAAC;QACpB,CAAC;QAED,MAAM,cAAc,GAAG,IAAA,aAAQ,EAAC,SAAS,CAAC;YACxC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAEpC,MAAM,QAAQ,GAAG,IAAA,aAAQ,EAAC,GAAG,CAAC,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AAC;gBAED,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;gBAChE,IAAI,GAAG,GAAG,YAAY,EAAE,CAAC;oBACvB,aAAa,GAAG,YAAY,CAAC,KAAK,CAAC;gBACrC,CAAC;YACH,CAAC;YAED,IAAI,QAAiB,CAAC;YACtB,IAAI,CAAC;gBACH,QAAQ,GAAG,MAAM,QAAQ,EAAE,CAAC;YAC9B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,IAAA,gBAAW,EAAC,aAAa,CAAC,EAAE,CAAC;oBAChC,eAAM,CAAC,KAAK,CACV,EAAE,GAAG,EAAE,EACP,6DAA6D,CAC9D,CAAC;oBACF,OAAO,aAAa,CAAC;gBACvB,CAAC;gBACD,MAAM,GAAG,CAAC;YACZ,CAAC;YAED,IAAI,CAAC,IAAA,gBAAW,EAAC,QAAQ,CAAC,EAAE,CAAC;gBAC3B,MAAM,SAAS,GAA0B;oBACvC,QAAQ,EAAE,gBAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE;oBAClC,KAAK,EAAE,QAAQ;iBAChB,CAAC;gBACF,MAAM,YAAY,CAAC,aAAa,CAC9B,cAAc,EACd,QAAQ,EACR,SAAS,EACT,cAAc,CACf,CAAC;YACJ,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;gBAAS,CAAC;YACT,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isString, isUndefined } from '@sindresorhus/is';\nimport { DateTime } from 'luxon';\nimport { GlobalConfig } from '../../../config/global';\nimport { logger } from '../../../logger';\nimport type { Decorator } from '../../decorator';\nimport { decorate } from '../../decorator';\nimport { acquireLock } from '../../mutex';\nimport { resolveTtlValues } from './ttl';\nimport type { DecoratorCachedRecord, PackageCacheNamespace } from './types';\nimport * as packageCache from '.';\n\ntype HashFunction<T extends any[] = any[]> = (...args: T) => string;\ntype NamespaceFunction<T extends any[] = any[]> = (\n ...args: T\n) => PackageCacheNamespace;\ntype BooleanFunction<T extends any[] = any[]> = (...args: T) => boolean;\n\n/**\n * The cache decorator parameters.\n */\ninterface CacheParameters {\n /**\n * The cache namespace\n * Either a string or a hash function that generates a string\n */\n namespace: PackageCacheNamespace | NamespaceFunction;\n\n /**\n * The cache key\n * Either a string or a hash function that generates a string\n */\n key: string | HashFunction;\n\n /**\n * A function that returns true if a result is cacheable\n * Used to prevent caching of private, sensitive, results\n */\n cacheable?: BooleanFunction;\n\n /**\n * The TTL (or expiry) of the key in minutes\n */\n ttlMinutes?: number;\n}\n\n/**\n * caches the result of a decorated method.\n */\nexport function cache<T>({\n namespace,\n key,\n cacheable = () => true,\n ttlMinutes = 30,\n}: CacheParameters): Decorator<T> {\n return decorate(async ({ args, instance, callback, methodName }) => {\n const cachePrivatePackages = GlobalConfig.get(\n 'cachePrivatePackages',\n false,\n );\n const isCacheable = cachePrivatePackages || cacheable.apply(instance, args);\n if (!isCacheable) {\n return callback();\n }\n\n const finalNamespace = isString(namespace)\n ? namespace\n : namespace.apply(instance, args);\n\n const finalKey = isString(key) ? key : key.apply(instance, args);\n\n // istanbul ignore if\n if (!finalNamespace || !finalKey) {\n return callback();\n }\n\n const cacheKey = `cache-decorator:${finalKey}`;\n\n // prevent concurrent processing and cache writes\n const releaseLock = await acquireLock(cacheKey, finalNamespace);\n\n try {\n const cachedRecord = await packageCache.get<DecoratorCachedRecord>(\n finalNamespace,\n cacheKey,\n );\n\n // eslint-disable-next-line prefer-const\n let { softTtlMinutes, hardTtlMinutes } = resolveTtlValues(\n finalNamespace,\n ttlMinutes,\n );\n\n // The separation between \"soft\" and \"hard\" TTL allows us to treat\n // data as obsolete according to the \"soft\" TTL while physically storing it\n // according to the \"hard\" TTL.\n //\n // This helps us return obsolete data in case of upstream server errors,\n // which is more useful than throwing exceptions ourselves.\n //\n // However, since the default hard TTL is one week, it could create\n // unnecessary pressure on storage volume. Therefore,\n // we cache only `getReleases` and `getDigest` results for an extended period.\n //\n // For other method names being decorated, the \"soft\" just equals the \"hard\" ttl.\n if (methodName !== 'getReleases' && methodName !== 'getDigest') {\n hardTtlMinutes = softTtlMinutes;\n }\n\n let fallbackValue: unknown;\n if (cachedRecord) {\n const now = DateTime.local();\n const cachedAt = DateTime.fromISO(cachedRecord.cachedAt);\n\n const softDeadline = cachedAt.plus({ minutes: softTtlMinutes });\n if (now < softDeadline) {\n return cachedRecord.value;\n }\n\n const hardDeadline = cachedAt.plus({ minutes: hardTtlMinutes });\n if (now < hardDeadline) {\n fallbackValue = cachedRecord.value;\n }\n }\n\n let newValue: unknown;\n try {\n newValue = await callback();\n } catch (err) {\n if (!isUndefined(fallbackValue)) {\n logger.debug(\n { err },\n 'Package cache decorator: callback error, returning old data',\n );\n return fallbackValue;\n }\n throw err;\n }\n\n if (!isUndefined(newValue)) {\n const newRecord: DecoratorCachedRecord = {\n cachedAt: DateTime.local().toISO(),\n value: newValue,\n };\n await packageCache.setWithRawTtl(\n finalNamespace,\n cacheKey,\n newRecord,\n hardTtlMinutes,\n );\n }\n\n return newValue;\n } finally {\n releaseLock();\n }\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "renovate",
|
|
3
3
|
"description": "Automated dependency updates. Flexible so you don't need to be.",
|
|
4
|
-
"version": "42.58.
|
|
4
|
+
"version": "42.58.1",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"renovate": "dist/renovate.js",
|
|
@@ -213,7 +213,7 @@
|
|
|
213
213
|
},
|
|
214
214
|
"optionalDependencies": {
|
|
215
215
|
"better-sqlite3": "12.5.0",
|
|
216
|
-
"openpgp": "6.
|
|
216
|
+
"openpgp": "6.3.0",
|
|
217
217
|
"re2": "1.22.3"
|
|
218
218
|
},
|
|
219
219
|
"devDependencies": {
|
|
@@ -299,7 +299,7 @@
|
|
|
299
299
|
"typescript": "5.9.3",
|
|
300
300
|
"typescript-eslint": "8.49.0",
|
|
301
301
|
"unified": "11.0.5",
|
|
302
|
-
"vite": "
|
|
302
|
+
"vite": "8.0.0-beta.2",
|
|
303
303
|
"vite-tsconfig-paths": "5.1.4",
|
|
304
304
|
"vitest": "4.0.15",
|
|
305
305
|
"vitest-mock-extended": "3.1.0"
|
package/renovate-schema.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"title": "JSON schema for Renovate 42.58.
|
|
2
|
+
"title": "JSON schema for Renovate 42.58.1 config files (https://renovatebot.com/)",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
-
"x-renovate-version": "42.58.
|
|
4
|
+
"x-renovate-version": "42.58.1",
|
|
5
5
|
"allowComments": true,
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|