renovate 44.153.0 → 44.154.0
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/config/global.d.ts +4 -0
- package/dist/config/global.js +13 -1
- package/dist/config/global.js.map +1 -1
- package/dist/modules/datasource/metadata.js +7 -6
- package/dist/modules/datasource/metadata.js.map +1 -1
- package/dist/modules/datasource/rpm/providers/common.js +16 -6
- package/dist/modules/datasource/rpm/providers/common.js.map +1 -1
- package/dist/modules/manager/terraform/lockfile/hash.js +2 -2
- package/dist/modules/manager/terraform/lockfile/hash.js.map +1 -1
- package/dist/modules/platform/github/index.js +6 -2
- package/dist/modules/platform/github/index.js.map +1 -1
- package/dist/util/compress.d.ts +2 -0
- package/dist/util/compress.js +44 -1
- package/dist/util/compress.js.map +1 -1
- package/dist/util/fs/index.js +2 -2
- package/dist/util/fs/index.js.map +1 -1
- package/dist/workers/global/config/parse/index.js +40 -1
- package/dist/workers/global/config/parse/index.js.map +1 -1
- package/dist/workers/global/index.js +3 -15
- package/dist/workers/global/index.js.map +1 -1
- package/dist/workers/repository/dependency-dashboard.js +2 -2
- package/dist/workers/repository/dependency-dashboard.js.map +1 -1
- package/package.json +1 -1
- package/renovate-schema.json +2 -2
package/dist/util/compress.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { promisify } from "node:util";
|
|
2
|
+
import { finished, pipeline } from "node:stream";
|
|
2
3
|
import zlib, { constants } from "node:zlib";
|
|
3
4
|
//#region lib/util/compress.ts
|
|
4
5
|
const brotliCompress = promisify(zlib.brotliCompress);
|
|
@@ -18,7 +19,49 @@ async function compressToBase64(input) {
|
|
|
18
19
|
async function decompressFromBase64(input) {
|
|
19
20
|
return await decompressFromBuffer(Buffer.from(input, "base64"));
|
|
20
21
|
}
|
|
22
|
+
function peekHeader(readable, length) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
function read() {
|
|
25
|
+
const result = readable.read(length);
|
|
26
|
+
if (result) {
|
|
27
|
+
readable.removeListener("readable", read);
|
|
28
|
+
cleanup();
|
|
29
|
+
readable.unshift(result);
|
|
30
|
+
resolve(result);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
readable.on("readable", read);
|
|
34
|
+
const cleanup = finished(readable, {
|
|
35
|
+
readable: true,
|
|
36
|
+
writable: false
|
|
37
|
+
}, (err) => {
|
|
38
|
+
readable.removeListener("readable", read);
|
|
39
|
+
cleanup();
|
|
40
|
+
if (err) reject(err);
|
|
41
|
+
else resolve(Buffer.from([]));
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const algorithms = [{
|
|
46
|
+
header: Uint8Array.from([31, 139]),
|
|
47
|
+
createStream: zlib.createGunzip
|
|
48
|
+
}, {
|
|
49
|
+
header: Uint8Array.from([
|
|
50
|
+
40,
|
|
51
|
+
181,
|
|
52
|
+
47,
|
|
53
|
+
253
|
|
54
|
+
]),
|
|
55
|
+
createStream: zlib.createZstdDecompress
|
|
56
|
+
}];
|
|
57
|
+
const maxHeaderLength = algorithms.reduce((maxLength, { header }) => Math.max(maxLength, header.length), 0);
|
|
58
|
+
async function createDecompressStream(input) {
|
|
59
|
+
const header = await peekHeader(input, maxHeaderLength);
|
|
60
|
+
const algorithm = algorithms.find((entry) => header.subarray(0, entry.header.length).compare(entry.header) === 0);
|
|
61
|
+
if (!algorithm) return input;
|
|
62
|
+
return pipeline(input, algorithm.createStream(), () => {});
|
|
63
|
+
}
|
|
21
64
|
//#endregion
|
|
22
|
-
export { compressToBase64, compressToBuffer, decompressFromBase64, decompressFromBuffer };
|
|
65
|
+
export { compressToBase64, compressToBuffer, createDecompressStream, decompressFromBase64, decompressFromBuffer };
|
|
23
66
|
|
|
24
67
|
//# sourceMappingURL=compress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.js","names":[],"sources":["../../lib/util/compress.ts"],"sourcesContent":["import { promisify } from 'node:util';\nimport zlib, { constants } from 'node:zlib';\n\nconst brotliCompress = promisify(zlib.brotliCompress);\nconst brotliDecompress = promisify(zlib.brotliDecompress);\n\nexport async function compressToBuffer(\n input: string,\n quality = 8,\n): Promise<Buffer> {\n return await brotliCompress(input, {\n params: {\n [constants.BROTLI_PARAM_MODE]: constants.BROTLI_MODE_TEXT,\n [constants.BROTLI_PARAM_QUALITY]: quality,\n },\n });\n}\n\nexport async function decompressFromBuffer(input: Buffer): Promise<string> {\n const str = await brotliDecompress(input);\n return str.toString('utf8');\n}\n\nexport async function compressToBase64(input: string): Promise<string> {\n const buf = await compressToBuffer(input);\n return buf.toString('base64');\n}\n\nexport async function decompressFromBase64(input: string): Promise<string> {\n return await decompressFromBuffer(Buffer.from(input, 'base64'));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"compress.js","names":[],"sources":["../../lib/util/compress.ts"],"sourcesContent":["import { type Readable, type Transform, finished, pipeline } from 'node:stream';\nimport { promisify } from 'node:util';\nimport zlib, { constants } from 'node:zlib';\n\nconst brotliCompress = promisify(zlib.brotliCompress);\nconst brotliDecompress = promisify(zlib.brotliDecompress);\n\nexport async function compressToBuffer(\n input: string,\n quality = 8,\n): Promise<Buffer> {\n return await brotliCompress(input, {\n params: {\n [constants.BROTLI_PARAM_MODE]: constants.BROTLI_MODE_TEXT,\n [constants.BROTLI_PARAM_QUALITY]: quality,\n },\n });\n}\n\nexport async function decompressFromBuffer(input: Buffer): Promise<string> {\n const str = await brotliDecompress(input);\n return str.toString('utf8');\n}\n\nexport async function compressToBase64(input: string): Promise<string> {\n const buf = await compressToBuffer(input);\n return buf.toString('base64');\n}\n\nexport async function decompressFromBase64(input: string): Promise<string> {\n return await decompressFromBuffer(Buffer.from(input, 'base64'));\n}\n\nfunction peekHeader(readable: Readable, length: number): Promise<Buffer> {\n return new Promise((resolve, reject) => {\n function read(): void {\n const result = readable.read(length);\n if (result) {\n readable.removeListener('readable', read);\n cleanup();\n readable.unshift(result);\n resolve(result);\n }\n }\n\n readable.on('readable', read);\n\n const cleanup = finished(\n readable,\n { readable: true, writable: false },\n (err) => {\n readable.removeListener('readable', read);\n cleanup();\n if (err) {\n reject(err);\n } else {\n resolve(Buffer.from([]));\n }\n },\n );\n });\n}\n\nconst algorithms: { header: Uint8Array; createStream: () => Transform }[] = [\n {\n header: Uint8Array.from([0x1f, 0x8b]),\n createStream: zlib.createGunzip,\n },\n {\n header: Uint8Array.from([0x28, 0xb5, 0x2f, 0xfd]),\n createStream: zlib.createZstdDecompress,\n },\n];\n\nconst maxHeaderLength = algorithms.reduce(\n (maxLength, { header }) => Math.max(maxLength, header.length),\n 0,\n);\n\nexport async function createDecompressStream(\n input: Readable,\n): Promise<Readable> {\n const header = await peekHeader(input, maxHeaderLength);\n const algorithm = algorithms.find(\n (entry) =>\n header.subarray(0, entry.header.length).compare(entry.header) === 0,\n );\n if (!algorithm) {\n return input;\n }\n return pipeline(input, algorithm.createStream(), () => {\n // Nothing to do here, but the callback argument is required\n });\n}\n"],"mappings":";;;;AAIA,MAAM,iBAAiB,UAAU,KAAK,cAAc;AACpD,MAAM,mBAAmB,UAAU,KAAK,gBAAgB;AAExD,eAAsB,iBACpB,OACA,UAAU,GACO;CACjB,OAAO,MAAM,eAAe,OAAO,EACjC,QAAQ;GACL,UAAU,oBAAoB,UAAU;GACxC,UAAU,uBAAuB;CACpC,EACF,CAAC;AACH;AAEA,eAAsB,qBAAqB,OAAgC;CAEzE,QAAO,MADW,iBAAiB,KAAK,EAAA,CAC7B,SAAS,MAAM;AAC5B;AAEA,eAAsB,iBAAiB,OAAgC;CAErE,QAAO,MADW,iBAAiB,KAAK,EAAA,CAC7B,SAAS,QAAQ;AAC9B;AAEA,eAAsB,qBAAqB,OAAgC;CACzE,OAAO,MAAM,qBAAqB,OAAO,KAAK,OAAO,QAAQ,CAAC;AAChE;AAEA,SAAS,WAAW,UAAoB,QAAiC;CACvE,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,SAAS,OAAa;GACpB,MAAM,SAAS,SAAS,KAAK,MAAM;GACnC,IAAI,QAAQ;IACV,SAAS,eAAe,YAAY,IAAI;IACxC,QAAQ;IACR,SAAS,QAAQ,MAAM;IACvB,QAAQ,MAAM;GAChB;EACF;EAEA,SAAS,GAAG,YAAY,IAAI;EAE5B,MAAM,UAAU,SACd,UACA;GAAE,UAAU;GAAM,UAAU;EAAM,IACjC,QAAQ;GACP,SAAS,eAAe,YAAY,IAAI;GACxC,QAAQ;GACR,IAAI,KACF,OAAO,GAAG;QAEV,QAAQ,OAAO,KAAK,CAAC,CAAC,CAAC;EAE3B,CACF;CACF,CAAC;AACH;AAEA,MAAM,aAAsE,CAC1E;CACE,QAAQ,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC;CACpC,cAAc,KAAK;AACrB,GACA;CACE,QAAQ,WAAW,KAAK;EAAC;EAAM;EAAM;EAAM;CAAI,CAAC;CAChD,cAAc,KAAK;AACrB,CACF;AAEA,MAAM,kBAAkB,WAAW,QAChC,WAAW,EAAE,aAAa,KAAK,IAAI,WAAW,OAAO,MAAM,GAC5D,CACF;AAEA,eAAsB,uBACpB,OACmB;CACnB,MAAM,SAAS,MAAM,WAAW,OAAO,eAAe;CACtD,MAAM,YAAY,WAAW,MAC1B,UACC,OAAO,SAAS,GAAG,MAAM,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAM,MAAM,CACtE;CACA,IAAI,CAAC,WACH,OAAO;CAET,OAAO,SAAS,OAAO,UAAU,aAAa,SAAS,CAEvD,CAAC;AACH"}
|
package/dist/util/fs/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import stream from "node:stream";
|
|
|
9
9
|
import upath from "upath";
|
|
10
10
|
import { findUp } from "find-up";
|
|
11
11
|
//#region lib/util/fs/index.ts
|
|
12
|
-
const pipeline = util.promisify(stream.pipeline);
|
|
12
|
+
const pipeline$1 = util.promisify(stream.pipeline);
|
|
13
13
|
function getParentDir(fileName) {
|
|
14
14
|
return upath.parse(fileName).dir;
|
|
15
15
|
}
|
|
@@ -221,6 +221,6 @@ async function getLocalFiles(fileNames) {
|
|
|
221
221
|
return fileContentMap;
|
|
222
222
|
}
|
|
223
223
|
//#endregion
|
|
224
|
-
export { cachePathExists, chmodLocalFile, createCacheReadStream, createCacheWriteStream, deleteLocalFile, ensureCacheDir, ensureDir, ensureLocalDir, findLocalSiblingOrParent, findUpLocal, getLocalFiles, getParentDir, getSiblingFileName, isValidLocalPath, localPathExists, localPathIsFile, localPathIsSymbolicLink, outputCacheFile, pipeline, privateCacheDir, readCacheFile, readLocalDirectory, readLocalFile, readLocalSymlink, readSystemFile, renameCacheFile, renameLocalFile, rmCache, statCacheFile, statLocalFile, writeLocalFile, writeSystemFile };
|
|
224
|
+
export { cachePathExists, chmodLocalFile, createCacheReadStream, createCacheWriteStream, deleteLocalFile, ensureCacheDir, ensureDir, ensureLocalDir, findLocalSiblingOrParent, findUpLocal, getLocalFiles, getParentDir, getSiblingFileName, isValidLocalPath, localPathExists, localPathIsFile, localPathIsSymbolicLink, outputCacheFile, pipeline$1 as pipeline, privateCacheDir, readCacheFile, readLocalDirectory, readLocalFile, readLocalSymlink, readSystemFile, renameCacheFile, renameLocalFile, rmCache, statCacheFile, statLocalFile, writeLocalFile, writeSystemFile };
|
|
225
225
|
|
|
226
226
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../lib/util/fs/index.ts"],"sourcesContent":["import stream from 'node:stream';\nimport util from 'node:util';\nimport { isNonEmptyString } from '@sindresorhus/is';\nimport { findUp } from 'find-up';\nimport fs from 'fs-extra';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../config/global.ts';\nimport { logger } from '../../logger/index.ts';\nimport { logWarningIfUnicodeHiddenCharactersInPackageFile } from '../unicode.ts';\nimport { ensureCachePath, ensureLocalPath, isValidPath } from './util.ts';\n\nexport const pipeline = util.promisify(stream.pipeline);\n\nexport function getParentDir(fileName: string): string {\n return upath.parse(fileName).dir;\n}\n\nexport function getSiblingFileName(\n fileName: string,\n siblingName: string,\n): string {\n const subDirectory = getParentDir(fileName);\n return upath.join(subDirectory, siblingName);\n}\n\nexport async function readLocalFile(fileName: string): Promise<Buffer | null>;\nexport async function readLocalFile(\n fileName: string,\n encoding: 'utf8',\n): Promise<string | null>;\nexport async function readLocalFile(\n fileName: string,\n encoding?: BufferEncoding,\n): Promise<string | Buffer | null> {\n const localFileName = ensureLocalPath(fileName);\n try {\n const fileContent = encoding\n ? await fs.readFile(localFileName, encoding)\n : await fs.readFile(localFileName);\n\n logWarningIfUnicodeHiddenCharactersInPackageFile(fileName, fileContent);\n\n return fileContent;\n } catch (err) {\n logger.trace({ err }, 'Error reading local file');\n return null;\n }\n}\n\nexport async function readLocalSymlink(\n fileName: string,\n): Promise<string | null> {\n const localFileName = ensureLocalPath(fileName);\n try {\n const linkContent = await fs.readlink(localFileName);\n return linkContent;\n } catch (err) {\n logger.trace({ err }, 'Error reading local symlink');\n return null;\n }\n}\n\nexport async function writeLocalFile(\n fileName: string,\n fileContent: string | Buffer,\n): Promise<void> {\n const localFileName = ensureLocalPath(fileName);\n await fs.outputFile(localFileName, fileContent);\n}\n\nexport async function deleteLocalFile(fileName: string): Promise<void> {\n // This a failsafe and hopefully will never be triggered\n if (GlobalConfig.get('platform') === 'local') {\n throw new Error('Cannot delete file when platform=local');\n }\n const localDir = GlobalConfig.get('localDir');\n if (localDir) {\n const localFileName = ensureLocalPath(fileName);\n await fs.remove(localFileName);\n }\n}\n\nexport async function renameLocalFile(\n fromFile: string,\n toFile: string,\n): Promise<void> {\n const fromPath = ensureLocalPath(fromFile);\n const toPath = ensureLocalPath(toFile);\n await fs.move(fromPath, toPath);\n}\n\nexport async function renameCacheFile(\n fromFile: string,\n toFile: string,\n): Promise<void> {\n const fromPath = ensureCachePath(fromFile);\n const toPath = ensureCachePath(toFile);\n await fs.rename(fromPath, toPath);\n}\n\nexport async function ensureDir(dirName: string): Promise<void> {\n // v8 ignore else -- TODO: add test #40625\n if (isNonEmptyString(dirName)) {\n await fs.ensureDir(dirName);\n }\n}\n\nexport async function ensureLocalDir(dirName: string): Promise<string> {\n const fullPath = ensureLocalPath(dirName);\n await fs.ensureDir(fullPath);\n return fullPath;\n}\n\nexport async function ensureCacheDir(name: string): Promise<string> {\n const cacheDirName = ensureCachePath(`others/${name}`);\n await fs.ensureDir(cacheDirName);\n return cacheDirName;\n}\n\n/**\n * Return the path of the private cache directory. This directory is wiped\n * between repositories, so they can be used to store private registries' index\n * without risk of that information leaking to other repositories/users.\n */\nexport function privateCacheDir(): string {\n // TODO: types (#22198)\n const cacheDir = GlobalConfig.get('cacheDir');\n return upath.join(cacheDir, '__renovate-private-cache');\n}\n\nexport async function localPathExists(pathName: string): Promise<boolean> {\n // Works for both files as well as directories\n const path = ensureLocalPath(pathName);\n try {\n const s = await fs.stat(path);\n return !!s;\n } catch {\n return false;\n }\n}\n\n/**\n * Validate local path without throwing.\n * @param path Path to check\n * @returns `true` if given `path` is a valid local path, otherwise `false`.\n */\nexport function isValidLocalPath(path: string): boolean {\n return isValidPath(path, 'localDir');\n}\n\n/**\n * Tries to find `otherFileName` in the directory where\n * `existingFileNameWithPath` is, then in its parent directory, then in the\n * grandparent, until we reach the top-level directory. All paths\n * must be relative to `localDir`.\n */\nexport async function findLocalSiblingOrParent(\n existingFileNameWithPath: string,\n otherFileName: string,\n): Promise<string | null> {\n if (upath.isAbsolute(existingFileNameWithPath)) {\n return null;\n }\n if (upath.isAbsolute(otherFileName)) {\n return null;\n }\n\n let current = existingFileNameWithPath;\n while (current !== '') {\n current = getParentDir(current);\n const candidate = upath.join(current, otherFileName);\n if (await localPathExists(candidate)) {\n return candidate;\n }\n }\n\n return null;\n}\n\n/**\n * Get files by name from directory\n */\nexport async function readLocalDirectory(path: string): Promise<string[]> {\n const localPath = ensureLocalPath(path);\n const fileList = await fs.readdir(localPath);\n return fileList;\n}\n\nexport function createCacheWriteStream(path: string): fs.WriteStream {\n const fullPath = ensureCachePath(path);\n return fs.createWriteStream(fullPath);\n}\n\nexport function createCacheReadStream(path: string): fs.ReadStream {\n const fullPath = ensureCachePath(path);\n return fs.createReadStream(fullPath);\n}\n\nexport async function localPathIsFile(pathName: string): Promise<boolean> {\n const path = ensureLocalPath(pathName);\n try {\n const s = await fs.stat(path);\n return s.isFile();\n } catch {\n return false;\n }\n}\n\nexport async function localPathIsSymbolicLink(\n pathName: string,\n): Promise<boolean> {\n const path = ensureLocalPath(pathName);\n try {\n const s = await fs.lstat(path);\n return s.isSymbolicLink();\n } catch {\n return false;\n }\n}\n\n/**\n * Find a file or directory by walking up parent directories within localDir\n */\n\nexport async function findUpLocal(\n fileName: string | string[],\n cwd: string,\n): Promise<string | null> {\n // TODO: types (#22198)\n const localDir = GlobalConfig.get('localDir');\n const absoluteCwd = upath.join(localDir, cwd);\n const normalizedAbsoluteCwd = upath.normalizeSafe(absoluteCwd);\n const res = await findUp(fileName, {\n cwd: normalizedAbsoluteCwd,\n type: 'file',\n });\n // Return null if nothing found\n if (!isNonEmptyString(res) || !isNonEmptyString(localDir)) {\n return null;\n }\n const safePath = upath.normalizeSafe(res);\n // Return relative path if file is inside of local dir\n if (safePath.startsWith(localDir)) {\n let relativePath = safePath.replace(localDir, '');\n // v8 ignore else -- TODO: add test #40625\n if (relativePath.startsWith('/')) {\n relativePath = relativePath.substring(1);\n }\n return relativePath;\n }\n // Return null if found file is outside of localDir\n return null;\n}\n\nexport function chmodLocalFile(\n fileName: string,\n mode: string | number,\n): Promise<void> {\n const fullFileName = ensureLocalPath(fileName);\n return fs.chmod(fullFileName, mode);\n}\n\nexport async function statLocalFile(\n fileName: string,\n): Promise<fs.Stats | null> {\n const fullFileName = ensureLocalPath(fileName);\n try {\n return await fs.stat(fullFileName);\n } catch {\n return null;\n }\n}\n\nexport async function statCacheFile(\n pathName: string,\n): Promise<fs.Stats | null> {\n const path = ensureCachePath(pathName);\n try {\n return await fs.stat(path);\n } catch {\n return null;\n }\n}\n\nexport function listCacheDir(\n path: string,\n options: { recursive: boolean } = { recursive: false },\n): Promise<string[]> {\n const fullPath = ensureCachePath(path);\n return fs.readdir(fullPath, {\n encoding: 'utf-8',\n recursive: options.recursive,\n });\n}\n\nexport async function rmCache(path: string): Promise<void> {\n const fullPath = ensureCachePath(path);\n // force: a missing path is a no-op, callers use this for cleanup\n await fs.rm(fullPath, { recursive: true, force: true });\n}\n\nexport async function cachePathExists(pathName: string): Promise<boolean> {\n const path = ensureCachePath(pathName);\n try {\n const s = await fs.stat(path);\n return !!s;\n } catch {\n return false;\n }\n}\n\nexport async function cachePathIsFile(pathName: string): Promise<boolean> {\n const path = ensureCachePath(pathName);\n try {\n const s = await fs.stat(path);\n return s.isFile();\n } catch {\n return false;\n }\n}\n\nexport async function readCacheFile(fileName: string): Promise<Buffer>;\nexport async function readCacheFile(\n fileName: string,\n encoding: 'utf8',\n): Promise<string>;\nexport function readCacheFile(\n fileName: string,\n encoding?: BufferEncoding,\n): Promise<string | Buffer> {\n const fullPath = ensureCachePath(fileName);\n return encoding ? fs.readFile(fullPath, encoding) : fs.readFile(fullPath);\n}\n\nexport function outputCacheFile(\n file: string,\n data: string | NodeJS.ArrayBufferView,\n): Promise<void> {\n const filePath = ensureCachePath(file);\n return fs.outputFile(filePath, data);\n}\n\nexport async function readSystemFile(fileName: string): Promise<Buffer>;\nexport async function readSystemFile(\n fileName: string,\n encoding: 'utf8',\n): Promise<string>;\nexport function readSystemFile(\n fileName: string,\n encoding?: BufferEncoding,\n): Promise<string | Buffer> {\n return encoding ? fs.readFile(fileName, encoding) : fs.readFile(fileName);\n}\n\nexport async function writeSystemFile(\n fileName: string,\n data: string | Buffer,\n): Promise<void> {\n await fs.outputFile(fileName, data);\n}\n\nexport async function getLocalFiles(\n fileNames: string[],\n): Promise<Record<string, string | null>> {\n const fileContentMap: Record<string, string | null> = {};\n\n for (const fileName of fileNames) {\n fileContentMap[fileName] = await readLocalFile(fileName, 'utf8');\n }\n\n return fileContentMap;\n}\n"],"mappings":";;;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M,OAAO,gBAAgB,QAAQ;CACrC,IAAI;EACF,OAAO,MAAM,GAAG,KAAK,IAAI;CAC3B,QAAQ;EACN,OAAO;CACT;AACF;AAaA,eAAsB,QAAQ,MAA6B;CACzD,MAAM,WAAW,gBAAgB,IAAI;CAErC,MAAM,GAAG,GAAG,UAAU;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;AACxD;AAEA,eAAsB,gBAAgB,UAAoC;CACxE,MAAM,OAAO,gBAAgB,QAAQ;CACrC,IAAI;EAEF,OAAO,CAAC,CAAC,MADO,GAAG,KAAK,IAAI;CAE9B,QAAQ;EACN,OAAO;CACT;AACF;AAiBA,SAAgB,cACd,UACA,UAC0B;CAC1B,MAAM,WAAW,gBAAgB,QAAQ;CACzC,OAAO,WAAW,GAAG,SAAS,UAAU,QAAQ,IAAI,GAAG,SAAS,QAAQ;AAC1E;AAEA,SAAgB,gBACd,MACA,MACe;CACf,MAAM,WAAW,gBAAgB,IAAI;CACrC,OAAO,GAAG,WAAW,UAAU,IAAI;AACrC;AAOA,SAAgB,eACd,UACA,UAC0B;CAC1B,OAAO,WAAW,GAAG,SAAS,UAAU,QAAQ,IAAI,GAAG,SAAS,QAAQ;AAC1E;AAEA,eAAsB,gBACpB,UACA,MACe;CACf,MAAM,GAAG,WAAW,UAAU,IAAI;AACpC;AAEA,eAAsB,cACpB,WACwC;CACxC,MAAM,iBAAgD,CAAC;CAEvD,KAAK,MAAM,YAAY,WACrB,eAAe,YAAY,MAAM,cAAc,UAAU,MAAM;CAGjE,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["pipeline"],"sources":["../../../lib/util/fs/index.ts"],"sourcesContent":["import stream from 'node:stream';\nimport util from 'node:util';\nimport { isNonEmptyString } from '@sindresorhus/is';\nimport { findUp } from 'find-up';\nimport fs from 'fs-extra';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../config/global.ts';\nimport { logger } from '../../logger/index.ts';\nimport { logWarningIfUnicodeHiddenCharactersInPackageFile } from '../unicode.ts';\nimport { ensureCachePath, ensureLocalPath, isValidPath } from './util.ts';\n\nexport const pipeline = util.promisify(stream.pipeline);\n\nexport function getParentDir(fileName: string): string {\n return upath.parse(fileName).dir;\n}\n\nexport function getSiblingFileName(\n fileName: string,\n siblingName: string,\n): string {\n const subDirectory = getParentDir(fileName);\n return upath.join(subDirectory, siblingName);\n}\n\nexport async function readLocalFile(fileName: string): Promise<Buffer | null>;\nexport async function readLocalFile(\n fileName: string,\n encoding: 'utf8',\n): Promise<string | null>;\nexport async function readLocalFile(\n fileName: string,\n encoding?: BufferEncoding,\n): Promise<string | Buffer | null> {\n const localFileName = ensureLocalPath(fileName);\n try {\n const fileContent = encoding\n ? await fs.readFile(localFileName, encoding)\n : await fs.readFile(localFileName);\n\n logWarningIfUnicodeHiddenCharactersInPackageFile(fileName, fileContent);\n\n return fileContent;\n } catch (err) {\n logger.trace({ err }, 'Error reading local file');\n return null;\n }\n}\n\nexport async function readLocalSymlink(\n fileName: string,\n): Promise<string | null> {\n const localFileName = ensureLocalPath(fileName);\n try {\n const linkContent = await fs.readlink(localFileName);\n return linkContent;\n } catch (err) {\n logger.trace({ err }, 'Error reading local symlink');\n return null;\n }\n}\n\nexport async function writeLocalFile(\n fileName: string,\n fileContent: string | Buffer,\n): Promise<void> {\n const localFileName = ensureLocalPath(fileName);\n await fs.outputFile(localFileName, fileContent);\n}\n\nexport async function deleteLocalFile(fileName: string): Promise<void> {\n // This a failsafe and hopefully will never be triggered\n if (GlobalConfig.get('platform') === 'local') {\n throw new Error('Cannot delete file when platform=local');\n }\n const localDir = GlobalConfig.get('localDir');\n if (localDir) {\n const localFileName = ensureLocalPath(fileName);\n await fs.remove(localFileName);\n }\n}\n\nexport async function renameLocalFile(\n fromFile: string,\n toFile: string,\n): Promise<void> {\n const fromPath = ensureLocalPath(fromFile);\n const toPath = ensureLocalPath(toFile);\n await fs.move(fromPath, toPath);\n}\n\nexport async function renameCacheFile(\n fromFile: string,\n toFile: string,\n): Promise<void> {\n const fromPath = ensureCachePath(fromFile);\n const toPath = ensureCachePath(toFile);\n await fs.rename(fromPath, toPath);\n}\n\nexport async function ensureDir(dirName: string): Promise<void> {\n // v8 ignore else -- TODO: add test #40625\n if (isNonEmptyString(dirName)) {\n await fs.ensureDir(dirName);\n }\n}\n\nexport async function ensureLocalDir(dirName: string): Promise<string> {\n const fullPath = ensureLocalPath(dirName);\n await fs.ensureDir(fullPath);\n return fullPath;\n}\n\nexport async function ensureCacheDir(name: string): Promise<string> {\n const cacheDirName = ensureCachePath(`others/${name}`);\n await fs.ensureDir(cacheDirName);\n return cacheDirName;\n}\n\n/**\n * Return the path of the private cache directory. This directory is wiped\n * between repositories, so they can be used to store private registries' index\n * without risk of that information leaking to other repositories/users.\n */\nexport function privateCacheDir(): string {\n // TODO: types (#22198)\n const cacheDir = GlobalConfig.get('cacheDir');\n return upath.join(cacheDir, '__renovate-private-cache');\n}\n\nexport async function localPathExists(pathName: string): Promise<boolean> {\n // Works for both files as well as directories\n const path = ensureLocalPath(pathName);\n try {\n const s = await fs.stat(path);\n return !!s;\n } catch {\n return false;\n }\n}\n\n/**\n * Validate local path without throwing.\n * @param path Path to check\n * @returns `true` if given `path` is a valid local path, otherwise `false`.\n */\nexport function isValidLocalPath(path: string): boolean {\n return isValidPath(path, 'localDir');\n}\n\n/**\n * Tries to find `otherFileName` in the directory where\n * `existingFileNameWithPath` is, then in its parent directory, then in the\n * grandparent, until we reach the top-level directory. All paths\n * must be relative to `localDir`.\n */\nexport async function findLocalSiblingOrParent(\n existingFileNameWithPath: string,\n otherFileName: string,\n): Promise<string | null> {\n if (upath.isAbsolute(existingFileNameWithPath)) {\n return null;\n }\n if (upath.isAbsolute(otherFileName)) {\n return null;\n }\n\n let current = existingFileNameWithPath;\n while (current !== '') {\n current = getParentDir(current);\n const candidate = upath.join(current, otherFileName);\n if (await localPathExists(candidate)) {\n return candidate;\n }\n }\n\n return null;\n}\n\n/**\n * Get files by name from directory\n */\nexport async function readLocalDirectory(path: string): Promise<string[]> {\n const localPath = ensureLocalPath(path);\n const fileList = await fs.readdir(localPath);\n return fileList;\n}\n\nexport function createCacheWriteStream(path: string): fs.WriteStream {\n const fullPath = ensureCachePath(path);\n return fs.createWriteStream(fullPath);\n}\n\nexport function createCacheReadStream(path: string): fs.ReadStream {\n const fullPath = ensureCachePath(path);\n return fs.createReadStream(fullPath);\n}\n\nexport async function localPathIsFile(pathName: string): Promise<boolean> {\n const path = ensureLocalPath(pathName);\n try {\n const s = await fs.stat(path);\n return s.isFile();\n } catch {\n return false;\n }\n}\n\nexport async function localPathIsSymbolicLink(\n pathName: string,\n): Promise<boolean> {\n const path = ensureLocalPath(pathName);\n try {\n const s = await fs.lstat(path);\n return s.isSymbolicLink();\n } catch {\n return false;\n }\n}\n\n/**\n * Find a file or directory by walking up parent directories within localDir\n */\n\nexport async function findUpLocal(\n fileName: string | string[],\n cwd: string,\n): Promise<string | null> {\n // TODO: types (#22198)\n const localDir = GlobalConfig.get('localDir');\n const absoluteCwd = upath.join(localDir, cwd);\n const normalizedAbsoluteCwd = upath.normalizeSafe(absoluteCwd);\n const res = await findUp(fileName, {\n cwd: normalizedAbsoluteCwd,\n type: 'file',\n });\n // Return null if nothing found\n if (!isNonEmptyString(res) || !isNonEmptyString(localDir)) {\n return null;\n }\n const safePath = upath.normalizeSafe(res);\n // Return relative path if file is inside of local dir\n if (safePath.startsWith(localDir)) {\n let relativePath = safePath.replace(localDir, '');\n // v8 ignore else -- TODO: add test #40625\n if (relativePath.startsWith('/')) {\n relativePath = relativePath.substring(1);\n }\n return relativePath;\n }\n // Return null if found file is outside of localDir\n return null;\n}\n\nexport function chmodLocalFile(\n fileName: string,\n mode: string | number,\n): Promise<void> {\n const fullFileName = ensureLocalPath(fileName);\n return fs.chmod(fullFileName, mode);\n}\n\nexport async function statLocalFile(\n fileName: string,\n): Promise<fs.Stats | null> {\n const fullFileName = ensureLocalPath(fileName);\n try {\n return await fs.stat(fullFileName);\n } catch {\n return null;\n }\n}\n\nexport async function statCacheFile(\n pathName: string,\n): Promise<fs.Stats | null> {\n const path = ensureCachePath(pathName);\n try {\n return await fs.stat(path);\n } catch {\n return null;\n }\n}\n\nexport function listCacheDir(\n path: string,\n options: { recursive: boolean } = { recursive: false },\n): Promise<string[]> {\n const fullPath = ensureCachePath(path);\n return fs.readdir(fullPath, {\n encoding: 'utf-8',\n recursive: options.recursive,\n });\n}\n\nexport async function rmCache(path: string): Promise<void> {\n const fullPath = ensureCachePath(path);\n // force: a missing path is a no-op, callers use this for cleanup\n await fs.rm(fullPath, { recursive: true, force: true });\n}\n\nexport async function cachePathExists(pathName: string): Promise<boolean> {\n const path = ensureCachePath(pathName);\n try {\n const s = await fs.stat(path);\n return !!s;\n } catch {\n return false;\n }\n}\n\nexport async function cachePathIsFile(pathName: string): Promise<boolean> {\n const path = ensureCachePath(pathName);\n try {\n const s = await fs.stat(path);\n return s.isFile();\n } catch {\n return false;\n }\n}\n\nexport async function readCacheFile(fileName: string): Promise<Buffer>;\nexport async function readCacheFile(\n fileName: string,\n encoding: 'utf8',\n): Promise<string>;\nexport function readCacheFile(\n fileName: string,\n encoding?: BufferEncoding,\n): Promise<string | Buffer> {\n const fullPath = ensureCachePath(fileName);\n return encoding ? fs.readFile(fullPath, encoding) : fs.readFile(fullPath);\n}\n\nexport function outputCacheFile(\n file: string,\n data: string | NodeJS.ArrayBufferView,\n): Promise<void> {\n const filePath = ensureCachePath(file);\n return fs.outputFile(filePath, data);\n}\n\nexport async function readSystemFile(fileName: string): Promise<Buffer>;\nexport async function readSystemFile(\n fileName: string,\n encoding: 'utf8',\n): Promise<string>;\nexport function readSystemFile(\n fileName: string,\n encoding?: BufferEncoding,\n): Promise<string | Buffer> {\n return encoding ? fs.readFile(fileName, encoding) : fs.readFile(fileName);\n}\n\nexport async function writeSystemFile(\n fileName: string,\n data: string | Buffer,\n): Promise<void> {\n await fs.outputFile(fileName, data);\n}\n\nexport async function getLocalFiles(\n fileNames: string[],\n): Promise<Record<string, string | null>> {\n const fileContentMap: Record<string, string | null> = {};\n\n for (const fileName of fileNames) {\n fileContentMap[fileName] = await readLocalFile(fileName, 'utf8');\n }\n\n return fileContentMap;\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAaA,aAAW,KAAK,UAAU,OAAO,QAAQ;AAEtD,SAAgB,aAAa,UAA0B;CACrD,OAAO,MAAM,MAAM,QAAQ,CAAC,CAAC;AAC/B;AAEA,SAAgB,mBACd,UACA,aACQ;CACR,MAAM,eAAe,aAAa,QAAQ;CAC1C,OAAO,MAAM,KAAK,cAAc,WAAW;AAC7C;AAOA,eAAsB,cACpB,UACA,UACiC;CACjC,MAAM,gBAAgB,gBAAgB,QAAQ;CAC9C,IAAI;EACF,MAAM,cAAc,WAChB,MAAM,GAAG,SAAS,eAAe,QAAQ,IACzC,MAAM,GAAG,SAAS,aAAa;EAEnC,iDAAiD,UAAU,WAAW;EAEtE,OAAO;CACT,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,0BAA0B;EAChD,OAAO;CACT;AACF;AAEA,eAAsB,iBACpB,UACwB;CACxB,MAAM,gBAAgB,gBAAgB,QAAQ;CAC9C,IAAI;EAEF,OAAO,MADmB,GAAG,SAAS,aAAa;CAErD,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,6BAA6B;EACnD,OAAO;CACT;AACF;AAEA,eAAsB,eACpB,UACA,aACe;CACf,MAAM,gBAAgB,gBAAgB,QAAQ;CAC9C,MAAM,GAAG,WAAW,eAAe,WAAW;AAChD;AAEA,eAAsB,gBAAgB,UAAiC;CAErE,IAAI,aAAa,IAAI,UAAU,MAAM,SACnC,MAAM,IAAI,MAAM,wCAAwC;CAG1D,IADiB,aAAa,IAAI,UACvB,GAAG;EACZ,MAAM,gBAAgB,gBAAgB,QAAQ;EAC9C,MAAM,GAAG,OAAO,aAAa;CAC/B;AACF;AAEA,eAAsB,gBACpB,UACA,QACe;CACf,MAAM,WAAW,gBAAgB,QAAQ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AgB,QAAQ;CAC7C,IAAI;EACF,OAAO,MAAM,GAAG,KAAK,YAAY;CACnC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAsB,cACpB,UAC0B;CAC1B,MAAM,OAAO,gBAAgB,QAAQ;CACrC,IAAI;EACF,OAAO,MAAM,GAAG,KAAK,IAAI;CAC3B,QAAQ;EACN,OAAO;CACT;AACF;AAaA,eAAsB,QAAQ,MAA6B;CACzD,MAAM,WAAW,gBAAgB,IAAI;CAErC,MAAM,GAAG,GAAG,UAAU;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;AACxD;AAEA,eAAsB,gBAAgB,UAAoC;CACxE,MAAM,OAAO,gBAAgB,QAAQ;CACrC,IAAI;EAEF,OAAO,CAAC,CAAC,MADO,GAAG,KAAK,IAAI;CAE9B,QAAQ;EACN,OAAO;CACT;AACF;AAiBA,SAAgB,cACd,UACA,UAC0B;CAC1B,MAAM,WAAW,gBAAgB,QAAQ;CACzC,OAAO,WAAW,GAAG,SAAS,UAAU,QAAQ,IAAI,GAAG,SAAS,QAAQ;AAC1E;AAEA,SAAgB,gBACd,MACA,MACe;CACf,MAAM,WAAW,gBAAgB,IAAI;CACrC,OAAO,GAAG,WAAW,UAAU,IAAI;AACrC;AAOA,SAAgB,eACd,UACA,UAC0B;CAC1B,OAAO,WAAW,GAAG,SAAS,UAAU,QAAQ,IAAI,GAAG,SAAS,QAAQ;AAC1E;AAEA,eAAsB,gBACpB,UACA,MACe;CACf,MAAM,GAAG,WAAW,UAAU,IAAI;AACpC;AAEA,eAAsB,cACpB,WACwC;CACxC,MAAM,iBAAgD,CAAC;CAEvD,KAAK,MAAM,YAAY,WACrB,eAAe,YAAY,MAAM,cAAc,UAAU,MAAM;CAGjE,OAAO;AACT"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { CONFIG_PRESETS_INVALID } from "../../../../constants/error-messages.js";
|
|
2
2
|
import { setCustomEnv } from "../../../../util/env.js";
|
|
3
3
|
import { setUserConfigFileNames } from "../../../../config/app-strings.js";
|
|
4
|
+
import { GlobalConfig, setHttpGlobalConfig } from "../../../../config/global.js";
|
|
4
5
|
import { coerceArray } from "../../../../util/array.js";
|
|
5
6
|
import { addSecretForSanitizing } from "../../../../util/sanitize.js";
|
|
6
7
|
import { logger, setContext } from "../../../../logger/index.js";
|
|
8
|
+
import { clone } from "../../../../util/clone.js";
|
|
7
9
|
import { ensureTrailingSlash } from "../../../../util/url.js";
|
|
8
10
|
import { mergeChildConfig } from "../../../../config/utils.js";
|
|
11
|
+
import { add, clear } from "../../../../util/host-rules.js";
|
|
9
12
|
import { resolveConfigPresets } from "../../../../config/presets/index.js";
|
|
10
13
|
import { readSystemFile } from "../../../../util/fs/index.js";
|
|
11
14
|
import { deleteNonDefaultConfig, getConfig } from "./file.js";
|
|
@@ -30,6 +33,42 @@ async function resolveGlobalExtends(globalExtends, ignorePresets) {
|
|
|
30
33
|
throw new Error(CONFIG_PRESETS_INVALID);
|
|
31
34
|
}
|
|
32
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the administrator's `hostRules` whose secrets and variables can be applied yet, or none if a rule which restricts access cannot.
|
|
38
|
+
*/
|
|
39
|
+
function getInterpolatedHostRules(config) {
|
|
40
|
+
const interpolated = [];
|
|
41
|
+
for (const rule of coerceArray(config.hostRules)) try {
|
|
42
|
+
const { hostRules } = applySecretsAndVariablesToConfig({
|
|
43
|
+
config: { hostRules: [clone(rule)] },
|
|
44
|
+
secrets: config.secrets,
|
|
45
|
+
variables: config.variables,
|
|
46
|
+
deleteSecrets: true,
|
|
47
|
+
deleteVariables: true
|
|
48
|
+
});
|
|
49
|
+
interpolated.push(...coerceArray(hostRules));
|
|
50
|
+
} catch (err) {
|
|
51
|
+
if (rule.allowInternal === false || rule.enabled === false) {
|
|
52
|
+
logger.debug({ err }, "Not applying hostRules to globalExtends, as a rule which restricts access cannot be resolved yet");
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
logger.debug({ err }, "Not applying a hostRule to globalExtends, as its secrets or variables cannot be resolved yet");
|
|
56
|
+
}
|
|
57
|
+
return interpolated;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolves `globalExtends` presets with the administrator's own `hostRules` and `internalHostAccess` in effect.
|
|
61
|
+
*/
|
|
62
|
+
async function resolveGlobalExtendsAsAdmin(globalExtends, config) {
|
|
63
|
+
try {
|
|
64
|
+
setHttpGlobalConfig(config);
|
|
65
|
+
for (const rule of getInterpolatedHostRules(config)) add(rule, { trusted: true });
|
|
66
|
+
return await resolveGlobalExtends(globalExtends, config.ignorePresets);
|
|
67
|
+
} finally {
|
|
68
|
+
clear();
|
|
69
|
+
GlobalConfig.reset();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
33
72
|
async function parseConfigs(env, argv) {
|
|
34
73
|
logger.debug("Parsing configs");
|
|
35
74
|
const defaultConfig = getConfig$1();
|
|
@@ -44,7 +83,7 @@ async function parseConfigs(env, argv) {
|
|
|
44
83
|
config = await setConfig(config);
|
|
45
84
|
let resolvedGlobalExtends;
|
|
46
85
|
if (isNonEmptyArray(config?.globalExtends)) {
|
|
47
|
-
resolvedGlobalExtends = await
|
|
86
|
+
resolvedGlobalExtends = await resolveGlobalExtendsAsAdmin(config.globalExtends, config);
|
|
48
87
|
config = mergeChildConfig(resolvedGlobalExtends, config);
|
|
49
88
|
delete config.globalExtends;
|
|
50
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["defaultsParser.getConfig","fileParser.getConfig","additionalConfigFileParser.getConfig","cliParser.getConfig","envParser.getConfig","codespaces.setConfig","fileParser.deleteNonDefaultConfig","additionalConfigFileParser.deleteNonDefaultConfig"],"sources":["../../../../../lib/workers/global/config/parse/index.ts"],"sourcesContent":["import { isNonEmptyArray, isNonEmptyObject, isString } from '@sindresorhus/is';\nimport { setUserConfigFileNames } from '../../../../config/app-strings.ts';\nimport { setPrivateKeys } from '../../../../config/decrypt.ts';\nimport * as defaultsParser from '../../../../config/defaults.ts';\nimport { resolveConfigPresets } from '../../../../config/presets/index.ts';\nimport { applySecretsAndVariablesToConfig } from '../../../../config/secrets.ts';\nimport type { AllConfig } from '../../../../config/types.ts';\nimport { mergeChildConfig } from '../../../../config/utils.ts';\nimport { CONFIG_PRESETS_INVALID } from '../../../../constants/error-messages.ts';\nimport { logger, setContext } from '../../../../logger/index.ts';\nimport { coerceArray } from '../../../../util/array.ts';\nimport { setCustomEnv } from '../../../../util/env.ts';\nimport { readSystemFile } from '../../../../util/fs/index.ts';\nimport { addSecretForSanitizing } from '../../../../util/sanitize.ts';\nimport { ensureTrailingSlash } from '../../../../util/url.ts';\nimport * as additionalConfigFileParser from './additional-config-file.ts';\nimport * as cliParser from './cli.ts';\nimport * as codespaces from './codespaces.ts';\nimport * as envParser from './env.ts';\nimport * as fileParser from './file.ts';\n\nexport async function resolveGlobalExtends(\n globalExtends: string[],\n ignorePresets?: string[],\n): Promise<AllConfig> {\n try {\n // Make a \"fake\" config to pass to resolveConfigPresets and resolve globalPresets\n const config = { extends: globalExtends, ignorePresets };\n const { config: resolvedConfig } = await resolveConfigPresets(config);\n return resolvedConfig;\n } catch (err) {\n logger.error({ err }, 'Error resolving config preset');\n throw new Error(CONFIG_PRESETS_INVALID);\n }\n}\n\nexport async function parseConfigs(\n env: NodeJS.ProcessEnv,\n argv: string[],\n): Promise<AllConfig> {\n logger.debug('Parsing configs');\n\n // Get configs\n const defaultConfig = defaultsParser.getConfig();\n const fileConfig = await fileParser.getConfig(env);\n const additionalFileConfig = await additionalConfigFileParser.getConfig(env);\n const cliConfig = cliParser.getConfig(argv);\n const envConfig = await envParser.getConfig(env);\n\n let config: AllConfig = mergeChildConfig(fileConfig, additionalFileConfig);\n // merge extends from file config and additional file config\n if (\n isNonEmptyArray(fileConfig.extends) &&\n isNonEmptyArray(additionalFileConfig.extends)\n ) {\n config.extends = [...fileConfig.extends, ...coerceArray(config.extends)];\n }\n config = mergeChildConfig(config, envConfig);\n config = mergeChildConfig(config, cliConfig);\n\n config = await codespaces.setConfig(config);\n\n let resolvedGlobalExtends: AllConfig | undefined;\n\n if (isNonEmptyArray(config?.globalExtends)) {\n // resolve global presets immediately\n resolvedGlobalExtends = await resolveGlobalExtends(\n config.globalExtends,\n config.ignorePresets,\n );\n config = mergeChildConfig(resolvedGlobalExtends, config);\n delete config.globalExtends;\n }\n\n const combinedConfig = config;\n\n config = mergeChildConfig(defaultConfig, config);\n\n if (config.forceCli) {\n const forcedCli = { ...cliConfig };\n delete forcedCli.token;\n delete forcedCli.hostRules;\n if (config.force) {\n config.force = { ...config.force, ...forcedCli };\n } else {\n config.force = forcedCli;\n }\n }\n\n if (!config.privateKey && config.privateKeyPath) {\n config.privateKey = await readSystemFile(config.privateKeyPath, 'utf8');\n delete config.privateKeyPath;\n }\n\n if (!config.privateKeyOld && config.privateKeyPathOld) {\n config.privateKeyOld = await readSystemFile(\n config.privateKeyPathOld,\n 'utf8',\n );\n delete config.privateKeyPathOld;\n }\n\n // Add private keys for sanitizing then set and delete them\n addSecretForSanitizing(config.privateKey, 'global');\n addSecretForSanitizing(config.privateKeyOld, 'global');\n setPrivateKeys(config.privateKey, config.privateKeyOld);\n delete config.privateKey;\n delete config.privateKeyOld;\n\n if (config.logContext) {\n // This only has an effect if logContext was defined via file or CLI, otherwise it would already have been detected in env\n setContext(config.logContext);\n }\n\n logger.trace({ config: defaultConfig }, 'Default config');\n logger.debug({ config: fileConfig }, 'File config');\n logger.debug({ config: additionalFileConfig }, 'Additional file config');\n logger.debug({ config: cliConfig }, 'CLI config');\n logger.debug({ config: envConfig }, 'Env config');\n logger.debug({ config: resolvedGlobalExtends }, 'Resolved global extends');\n logger.debug({ config: combinedConfig }, 'Combined config');\n\n // TODO #41551\n if (isNonEmptyArray(cliConfig.repositories)) {\n const existingRepos = [\n ...coerceArray(fileConfig.repositories),\n ...coerceArray(additionalFileConfig.repositories),\n ...coerceArray(envConfig.repositories),\n ];\n\n if (isNonEmptyArray(existingRepos)) {\n const allStrings = existingRepos.every((repo) => isString(repo));\n let shouldWarn = true;\n\n if (allStrings) {\n const areEqual =\n cliConfig.repositories.length === existingRepos.length &&\n cliConfig.repositories.every(\n (repo, idx) => repo === existingRepos[idx],\n );\n\n if (areEqual) {\n shouldWarn = false;\n }\n }\n\n if (shouldWarn) {\n logger.warn(\n 'CLI config is overridding the `repositories` config previously set',\n );\n }\n }\n }\n\n if (config.detectGlobalManagerConfig) {\n logger.debug('Detecting global manager config');\n const { detectAllGlobalConfig } =\n await import('../../../../modules/manager/index.ts');\n const globalManagerConfig = await detectAllGlobalConfig();\n logger.debug({ config: globalManagerConfig }, 'Global manager config');\n config = mergeChildConfig(config, globalManagerConfig);\n }\n\n if (config.detectHostRulesFromEnv) {\n const { hostRulesFromEnv } = await import('./host-rules-from-env.ts');\n const hostRules = hostRulesFromEnv(env);\n config.hostRules = [...coerceArray(config.hostRules), ...hostRules];\n }\n // Get global config\n logger.trace({ config }, 'Full config');\n\n // Massage endpoint to have a trailing slash\n if (config.endpoint) {\n logger.debug('Adding trailing slash to endpoint');\n config.endpoint = ensureTrailingSlash(config.endpoint);\n }\n\n // Massage forkProcessing\n if (!config.autodiscover && config.forkProcessing !== 'disabled') {\n logger.debug('Enabling forkProcessing while in non-autodiscover mode');\n config.forkProcessing = 'enabled';\n }\n\n // Only try deletion if RENOVATE_CONFIG_FILE is set\n await fileParser.deleteNonDefaultConfig(env, !!config.deleteConfigFile);\n\n // Only try deletion if RENOVATE_ADDITIONAL_CONFIG_FILE is set\n await additionalConfigFileParser.deleteNonDefaultConfig(\n env,\n !!config.deleteAdditionalConfigFile,\n );\n\n // Massage onboardingNoDeps\n if (!config.autodiscover && config.onboardingNoDeps !== 'disabled') {\n logger.debug('Enabling onboardingNoDeps while in non-autodiscover mode');\n config.onboardingNoDeps = 'enabled';\n }\n\n // do not add these secrets to repoSecrets and,\n // do not delete the secrets/variables object after applying on global config as it needs to be re-used for repo config\n if (isNonEmptyObject(config.secrets) || isNonEmptyObject(config.variables)) {\n config = applySecretsAndVariablesToConfig({\n config,\n secrets: config.secrets,\n variables: config.variables,\n deleteSecrets: false,\n deleteVariables: false,\n });\n // adding these secrets to the globalSecrets set so that they can be redacted from logs\n for (const secret of Object.values(config.secrets!)) {\n addSecretForSanitizing(secret, 'global');\n }\n }\n\n if (isNonEmptyObject(config.customEnvVariables)) {\n setCustomEnv(config.customEnvVariables);\n }\n\n if (isNonEmptyArray(config.configFileNames)) {\n logger.debug(\n { configFileNames: config.configFileNames },\n 'Updated the config filenames list',\n );\n setUserConfigFileNames(config.configFileNames);\n delete config.configFileNames;\n }\n\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,eAAsB,qBACpB,eACA,eACoB;CACpB,IAAI;EAGF,MAAM,EAAE,QAAQ,mBAAmB,MAAM,qBAAqB;GAD7C,SAAS;GAAe;EAC0B,CAAC;EACpE,OAAO;CACT,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,+BAA+B;EACrD,MAAM,IAAI,MAAM,sBAAsB;CACxC;AACF;AAEA,eAAsB,aACpB,KACA,MACoB;CACpB,OAAO,MAAM,iBAAiB;CAG9B,MAAM,gBAAgBA,YAAyB;CAC/C,MAAM,aAAa,MAAMC,UAAqB,GAAG;CACjD,MAAM,uBAAuB,MAAMC,YAAqC,GAAG;CAC3E,MAAM,YAAYC,YAAoB,IAAI;CAC1C,MAAM,YAAY,MAAMC,YAAoB,GAAG;CAE/C,IAAI,SAAoB,iBAAiB,YAAY,oBAAoB;CAEzE,IACE,gBAAgB,WAAW,OAAO,KAClC,gBAAgB,qBAAqB,OAAO,GAE5C,OAAO,UAAU,CAAC,GAAG,WAAW,SAAS,GAAG,YAAY,OAAO,OAAO,CAAC;CAEzE,SAAS,iBAAiB,QAAQ,SAAS;CAC3C,SAAS,iBAAiB,QAAQ,SAAS;CAE3C,SAAS,MAAMC,UAAqB,MAAM;CAE1C,IAAI;CAEJ,IAAI,gBAAgB,QAAQ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AO,OAAO,KAAK,iBAAiB,OAAO,SAAS,GAAG;EAC1E,SAAS,iCAAiC;GACxC;GACA,SAAS,OAAO;GAChB,WAAW,OAAO;GAClB,eAAe;GACf,iBAAiB;EACnB,CAAC;EAED,KAAK,MAAM,UAAU,OAAO,OAAO,OAAO,OAAQ,GAChD,uBAAuB,QAAQ,QAAQ;CAE3C;CAEA,IAAI,iBAAiB,OAAO,kBAAkB,GAC5C,aAAa,OAAO,kBAAkB;CAGxC,IAAI,gBAAgB,OAAO,eAAe,GAAG;EAC3C,OAAO,MACL,EAAE,iBAAiB,OAAO,gBAAgB,GAC1C,mCACF;EACA,uBAAuB,OAAO,eAAe;EAC7C,OAAO,OAAO;CAChB;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["defaultsParser.getConfig","fileParser.getConfig","additionalConfigFileParser.getConfig","cliParser.getConfig","envParser.getConfig","codespaces.setConfig","fileParser.deleteNonDefaultConfig","additionalConfigFileParser.deleteNonDefaultConfig"],"sources":["../../../../../lib/workers/global/config/parse/index.ts"],"sourcesContent":["import { isNonEmptyArray, isNonEmptyObject, isString } from '@sindresorhus/is';\nimport { setUserConfigFileNames } from '../../../../config/app-strings.ts';\nimport { setPrivateKeys } from '../../../../config/decrypt.ts';\nimport * as defaultsParser from '../../../../config/defaults.ts';\nimport {\n GlobalConfig,\n setHttpGlobalConfig,\n} from '../../../../config/global.ts';\nimport { resolveConfigPresets } from '../../../../config/presets/index.ts';\nimport { applySecretsAndVariablesToConfig } from '../../../../config/secrets.ts';\nimport type { AllConfig } from '../../../../config/types.ts';\nimport { mergeChildConfig } from '../../../../config/utils.ts';\nimport { CONFIG_PRESETS_INVALID } from '../../../../constants/error-messages.ts';\nimport { logger, setContext } from '../../../../logger/index.ts';\nimport type { HostRule } from '../../../../types/host-rules.ts';\nimport { coerceArray } from '../../../../util/array.ts';\nimport { clone } from '../../../../util/clone.ts';\nimport { setCustomEnv } from '../../../../util/env.ts';\nimport { readSystemFile } from '../../../../util/fs/index.ts';\nimport {\n add as addHostRule,\n clear as clearHostRules,\n} from '../../../../util/host-rules.ts';\nimport { addSecretForSanitizing } from '../../../../util/sanitize.ts';\nimport { ensureTrailingSlash } from '../../../../util/url.ts';\nimport * as additionalConfigFileParser from './additional-config-file.ts';\nimport * as cliParser from './cli.ts';\nimport * as codespaces from './codespaces.ts';\nimport * as envParser from './env.ts';\nimport * as fileParser from './file.ts';\n\nexport async function resolveGlobalExtends(\n globalExtends: string[],\n ignorePresets?: string[],\n): Promise<AllConfig> {\n try {\n // Make a \"fake\" config to pass to resolveConfigPresets and resolve globalPresets\n const config = { extends: globalExtends, ignorePresets };\n const { config: resolvedConfig } = await resolveConfigPresets(config);\n return resolvedConfig;\n } catch (err) {\n logger.error({ err }, 'Error resolving config preset');\n throw new Error(CONFIG_PRESETS_INVALID);\n }\n}\n\n/**\n * Returns the administrator's `hostRules` whose secrets and variables can be applied yet, or none if a rule which restricts access cannot.\n */\nfunction getInterpolatedHostRules(config: AllConfig): HostRule[] {\n const interpolated: HostRule[] = [];\n for (const rule of coerceArray(config.hostRules)) {\n try {\n const { hostRules } = applySecretsAndVariablesToConfig({\n config: { hostRules: [clone(rule)] },\n secrets: config.secrets,\n variables: config.variables,\n deleteSecrets: true,\n deleteVariables: true,\n });\n interpolated.push(...coerceArray(hostRules));\n } catch (err) {\n // skipping only this rule would let a broader rule apply where it was meant to restrict, so apply none of them, as before admin `hostRules` were applied here\n if (rule.allowInternal === false || rule.enabled === false) {\n logger.debug(\n { err },\n 'Not applying hostRules to globalExtends, as a rule which restricts access cannot be resolved yet',\n );\n return [];\n }\n logger.debug(\n { err },\n 'Not applying a hostRule to globalExtends, as its secrets or variables cannot be resolved yet',\n );\n }\n }\n return interpolated;\n}\n\n/**\n * Resolves `globalExtends` presets with the administrator's own `hostRules` and `internalHostAccess` in effect.\n */\nasync function resolveGlobalExtendsAsAdmin(\n globalExtends: string[],\n config: AllConfig,\n): Promise<AllConfig> {\n // `globalExtends` is fetched before `start()` sets `GlobalConfig` and `globalInitialize()` registers `hostRules`, so the administrator's own `internalHostAccess`, `endpoint` and `hostRules` are applied for the duration of that fetch only - `globalInitialize()` then registers the final, merged `hostRules`\n try {\n setHttpGlobalConfig(config);\n for (const rule of getInterpolatedHostRules(config)) {\n // the same `trusted` tier as `setGlobalHostRules()`, so that `allowInternal` is kept and can grant\n addHostRule(rule, { trusted: true });\n }\n return await resolveGlobalExtends(globalExtends, config.ignorePresets);\n } finally {\n clearHostRules();\n GlobalConfig.reset();\n }\n}\n\nexport async function parseConfigs(\n env: NodeJS.ProcessEnv,\n argv: string[],\n): Promise<AllConfig> {\n logger.debug('Parsing configs');\n\n // Get configs\n const defaultConfig = defaultsParser.getConfig();\n const fileConfig = await fileParser.getConfig(env);\n const additionalFileConfig = await additionalConfigFileParser.getConfig(env);\n const cliConfig = cliParser.getConfig(argv);\n const envConfig = await envParser.getConfig(env);\n\n let config: AllConfig = mergeChildConfig(fileConfig, additionalFileConfig);\n // merge extends from file config and additional file config\n if (\n isNonEmptyArray(fileConfig.extends) &&\n isNonEmptyArray(additionalFileConfig.extends)\n ) {\n config.extends = [...fileConfig.extends, ...coerceArray(config.extends)];\n }\n config = mergeChildConfig(config, envConfig);\n config = mergeChildConfig(config, cliConfig);\n\n config = await codespaces.setConfig(config);\n\n let resolvedGlobalExtends: AllConfig | undefined;\n\n if (isNonEmptyArray(config?.globalExtends)) {\n // resolve global presets immediately\n resolvedGlobalExtends = await resolveGlobalExtendsAsAdmin(\n config.globalExtends,\n config,\n );\n config = mergeChildConfig(resolvedGlobalExtends, config);\n delete config.globalExtends;\n }\n\n const combinedConfig = config;\n\n config = mergeChildConfig(defaultConfig, config);\n\n if (config.forceCli) {\n const forcedCli = { ...cliConfig };\n delete forcedCli.token;\n delete forcedCli.hostRules;\n if (config.force) {\n config.force = { ...config.force, ...forcedCli };\n } else {\n config.force = forcedCli;\n }\n }\n\n if (!config.privateKey && config.privateKeyPath) {\n config.privateKey = await readSystemFile(config.privateKeyPath, 'utf8');\n delete config.privateKeyPath;\n }\n\n if (!config.privateKeyOld && config.privateKeyPathOld) {\n config.privateKeyOld = await readSystemFile(\n config.privateKeyPathOld,\n 'utf8',\n );\n delete config.privateKeyPathOld;\n }\n\n // Add private keys for sanitizing then set and delete them\n addSecretForSanitizing(config.privateKey, 'global');\n addSecretForSanitizing(config.privateKeyOld, 'global');\n setPrivateKeys(config.privateKey, config.privateKeyOld);\n delete config.privateKey;\n delete config.privateKeyOld;\n\n if (config.logContext) {\n // This only has an effect if logContext was defined via file or CLI, otherwise it would already have been detected in env\n setContext(config.logContext);\n }\n\n logger.trace({ config: defaultConfig }, 'Default config');\n logger.debug({ config: fileConfig }, 'File config');\n logger.debug({ config: additionalFileConfig }, 'Additional file config');\n logger.debug({ config: cliConfig }, 'CLI config');\n logger.debug({ config: envConfig }, 'Env config');\n logger.debug({ config: resolvedGlobalExtends }, 'Resolved global extends');\n logger.debug({ config: combinedConfig }, 'Combined config');\n\n // TODO #41551\n if (isNonEmptyArray(cliConfig.repositories)) {\n const existingRepos = [\n ...coerceArray(fileConfig.repositories),\n ...coerceArray(additionalFileConfig.repositories),\n ...coerceArray(envConfig.repositories),\n ];\n\n if (isNonEmptyArray(existingRepos)) {\n const allStrings = existingRepos.every((repo) => isString(repo));\n let shouldWarn = true;\n\n if (allStrings) {\n const areEqual =\n cliConfig.repositories.length === existingRepos.length &&\n cliConfig.repositories.every(\n (repo, idx) => repo === existingRepos[idx],\n );\n\n if (areEqual) {\n shouldWarn = false;\n }\n }\n\n if (shouldWarn) {\n logger.warn(\n 'CLI config is overridding the `repositories` config previously set',\n );\n }\n }\n }\n\n if (config.detectGlobalManagerConfig) {\n logger.debug('Detecting global manager config');\n const { detectAllGlobalConfig } =\n await import('../../../../modules/manager/index.ts');\n const globalManagerConfig = await detectAllGlobalConfig();\n logger.debug({ config: globalManagerConfig }, 'Global manager config');\n config = mergeChildConfig(config, globalManagerConfig);\n }\n\n if (config.detectHostRulesFromEnv) {\n const { hostRulesFromEnv } = await import('./host-rules-from-env.ts');\n const hostRules = hostRulesFromEnv(env);\n config.hostRules = [...coerceArray(config.hostRules), ...hostRules];\n }\n // Get global config\n logger.trace({ config }, 'Full config');\n\n // Massage endpoint to have a trailing slash\n if (config.endpoint) {\n logger.debug('Adding trailing slash to endpoint');\n config.endpoint = ensureTrailingSlash(config.endpoint);\n }\n\n // Massage forkProcessing\n if (!config.autodiscover && config.forkProcessing !== 'disabled') {\n logger.debug('Enabling forkProcessing while in non-autodiscover mode');\n config.forkProcessing = 'enabled';\n }\n\n // Only try deletion if RENOVATE_CONFIG_FILE is set\n await fileParser.deleteNonDefaultConfig(env, !!config.deleteConfigFile);\n\n // Only try deletion if RENOVATE_ADDITIONAL_CONFIG_FILE is set\n await additionalConfigFileParser.deleteNonDefaultConfig(\n env,\n !!config.deleteAdditionalConfigFile,\n );\n\n // Massage onboardingNoDeps\n if (!config.autodiscover && config.onboardingNoDeps !== 'disabled') {\n logger.debug('Enabling onboardingNoDeps while in non-autodiscover mode');\n config.onboardingNoDeps = 'enabled';\n }\n\n // do not add these secrets to repoSecrets and,\n // do not delete the secrets/variables object after applying on global config as it needs to be re-used for repo config\n if (isNonEmptyObject(config.secrets) || isNonEmptyObject(config.variables)) {\n config = applySecretsAndVariablesToConfig({\n config,\n secrets: config.secrets,\n variables: config.variables,\n deleteSecrets: false,\n deleteVariables: false,\n });\n // adding these secrets to the globalSecrets set so that they can be redacted from logs\n for (const secret of Object.values(config.secrets!)) {\n addSecretForSanitizing(secret, 'global');\n }\n }\n\n if (isNonEmptyObject(config.customEnvVariables)) {\n setCustomEnv(config.customEnvVariables);\n }\n\n if (isNonEmptyArray(config.configFileNames)) {\n logger.debug(\n { configFileNames: config.configFileNames },\n 'Updated the config filenames list',\n );\n setUserConfigFileNames(config.configFileNames);\n delete config.configFileNames;\n }\n\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+BA,eAAsB,qBACpB,eACA,eACoB;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ChE,OAAO,MAAM,wDAAwD;EACrE,OAAO,iBAAiB;CAC1B;CAGA,MAAMC,uBAAkC,KAAK,CAAC,CAAC,OAAO,gBAAgB;CAGtE,MAAMC,yBACJ,KACA,CAAC,CAAC,OAAO,0BACX;CAGA,IAAI,CAAC,OAAO,gBAAgB,OAAO,qBAAqB,YAAY;EAClE,OAAO,MAAM,0DAA0D;EACvE,OAAO,mBAAmB;CAC5B;CAIA,IAAI,iBAAiB,OAAO,OAAO,KAAK,iBAAiB,OAAO,SAAS,GAAG;EAC1E,SAAS,iCAAiC;GACxC;GACA,SAAS,OAAO;GAChB,WAAW,OAAO;GAClB,eAAe;GACf,iBAAiB;EACnB,CAAC;EAED,KAAK,MAAM,UAAU,OAAO,OAAO,OAAO,OAAQ,GAChD,uBAAuB,QAAQ,QAAQ;CAE3C;CAEA,IAAI,iBAAiB,OAAO,kBAAkB,GAC5C,aAAa,OAAO,kBAAkB;CAGxC,IAAI,gBAAgB,OAAO,eAAe,GAAG;EAC3C,OAAO,MACL,EAAE,iBAAiB,OAAO,gBAAgB,GAC1C,mCACF;EACA,uBAAuB,OAAO,eAAe;EAC7C,OAAO,OAAO;CAChB;CAEA,OAAO;AACT"}
|
|
@@ -2,7 +2,7 @@ import { CONFIG_PRESETS_INVALID } from "../../constants/error-messages.js";
|
|
|
2
2
|
import { pkg } from "../../expose.js";
|
|
3
3
|
import { getEnv } from "../../util/env.js";
|
|
4
4
|
import { regexEngineStatus } from "../../util/regex.js";
|
|
5
|
-
import { GlobalConfig } from "../../config/global.js";
|
|
5
|
+
import { GlobalConfig, setHttpGlobalConfig } from "../../config/global.js";
|
|
6
6
|
import { setGlobalLogLevelRemaps } from "../../logger/remap.js";
|
|
7
7
|
import { coerceString } from "../../util/string.js";
|
|
8
8
|
import { addSecretForSanitizing } from "../../util/sanitize.js";
|
|
@@ -100,21 +100,9 @@ async function start() {
|
|
|
100
100
|
if (isNonEmptyStringAndNotWhitespace(env.COREPACK_NPM_PASSWORD)) addSecretForSanitizing(env.COREPACK_NPM_PASSWORD, "global");
|
|
101
101
|
await instrument("config", async () => {
|
|
102
102
|
config = await getGlobalConfig();
|
|
103
|
-
|
|
104
|
-
allowedHeaders: config.allowedHeaders,
|
|
105
|
-
endpoint: config.endpoint,
|
|
106
|
-
internalHostAccess: config.internalHostAccess,
|
|
107
|
-
platform: config.platform,
|
|
108
|
-
userAgent: config.userAgent
|
|
109
|
-
});
|
|
103
|
+
setHttpGlobalConfig(config);
|
|
110
104
|
config = await globalInitialize(config);
|
|
111
|
-
|
|
112
|
-
allowedHeaders: config.allowedHeaders,
|
|
113
|
-
platform: config.platform,
|
|
114
|
-
endpoint: config.endpoint,
|
|
115
|
-
internalHostAccess: config.internalHostAccess,
|
|
116
|
-
userAgent: config.userAgent
|
|
117
|
-
});
|
|
105
|
+
setHttpGlobalConfig(config);
|
|
118
106
|
await validatePresets(config);
|
|
119
107
|
setGlobalLogLevelRemaps(config.logLevelRemap);
|
|
120
108
|
checkEnv();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["configParser.filterConfig","repositoryWorker.renovateRepository"],"sources":["../../../lib/workers/global/index.ts"],"sourcesContent":["import {\n ATTR_VCS_OWNER_NAME,\n ATTR_VCS_PROVIDER_NAME,\n ATTR_VCS_REPOSITORY_NAME,\n} from '@opentelemetry/semantic-conventions/incubating';\nimport {\n isNonEmptyObject,\n isNonEmptyString,\n isNonEmptyStringAndNotWhitespace,\n isString,\n} from '@sindresorhus/is';\nimport { ERROR } from 'bunyan';\nimport fs from 'fs-extra';\nimport semver from 'semver';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../config/global.ts';\nimport * as configParser from '../../config/index.ts';\nimport { resolveConfigPresets } from '../../config/presets/index.ts';\nimport { validateConfigSecretsAndVariables } from '../../config/secrets.ts';\nimport type {\n AllConfig,\n InternalGlobalConfigOptions,\n RenovateConfig,\n RenovateRepository,\n RepoGlobalConfig,\n} from '../../config/types.ts';\nimport { CONFIG_PRESETS_INVALID } from '../../constants/error-messages.ts';\nimport { pkg } from '../../expose.ts';\nimport { instrument } from '../../instrumentation/index.ts';\nimport {\n exportStats,\n finalizeReport,\n} from '../../instrumentation/reporting.ts';\nimport { getProblems, logLevel, logger, setMeta } from '../../logger/index.ts';\nimport { setGlobalLogLevelRemaps } from '../../logger/remap.ts';\nimport { getEnv } from '../../util/env.ts';\nimport * as hostRules from '../../util/host-rules.ts';\nimport * as queue from '../../util/http/queue.ts';\nimport * as throttle from '../../util/http/throttle.ts';\nimport { regexEngineStatus } from '../../util/regex.ts';\nimport { addSecretForSanitizing } from '../../util/sanitize.ts';\nimport { coerceString } from '../../util/string.ts';\nimport * as repositoryWorker from '../repository/index.ts';\nimport type { RepositoryWorkerConfig } from '../repository/init/types.ts';\nimport { autodiscoverRepositories } from './autodiscover.ts';\nimport { parseConfigs } from './config/parse/index.ts';\nimport { globalFinalize, globalInitialize } from './initialize.ts';\nimport { isLimitReached } from './limits.ts';\n\nfunction applyGlobalOption<\n K extends keyof RepoGlobalConfig | keyof InternalGlobalConfigOptions,\n>(\n target: RepoGlobalConfig & InternalGlobalConfigOptions,\n source: RepoGlobalConfig & InternalGlobalConfigOptions,\n key: K,\n): void {\n target[key] = source[key];\n delete source[key];\n}\n\nexport async function getRepositoryConfig(\n globalConfig: RenovateConfig,\n repository: RenovateRepository,\n): Promise<RepositoryWorkerConfig> {\n const repoIsString = isString(repository);\n const repoName = repoIsString ? repository : repository.repository;\n\n const repoConfig: RepositoryWorkerConfig = {\n ...globalConfig,\n repository: repoName,\n };\n\n if (!repoIsString) {\n const { repository: _repository, ...repositoryEntryConfig } = repository;\n\n // Promote GlobalConfig.OPTIONS keys into repoConfig directly so that\n // GlobalConfig.set(repoConfig) in the repository worker picks them up\n // with per-repo overrides before onboarding checks run.\n for (const option of GlobalConfig.OPTIONS) {\n if (option in repositoryEntryConfig) {\n applyGlobalOption(repoConfig, repositoryEntryConfig, option);\n }\n }\n\n if (isNonEmptyObject(repositoryEntryConfig)) {\n // mergeRenovateConfig later resolves this repositories[] object-entry\n // config in the correct order\n repoConfig.repositoryEntryConfig = repositoryEntryConfig;\n }\n }\n\n const repoParts = repoName.split('/');\n repoParts.pop();\n repoConfig.parentOrg = repoParts.join('/');\n repoConfig.topLevelOrg = repoParts.shift();\n const platform = GlobalConfig.get('platform');\n repoConfig.localDir =\n platform === 'local'\n ? process.cwd()\n : // TODO: types (#22198)\n upath.join(repoConfig.baseDir!, `./repos/${platform}/${repoName}`);\n await fs.ensureDir(repoConfig.localDir);\n delete repoConfig.baseDir;\n return configParser.filterConfig(repoConfig, 'repository');\n}\n\nfunction getGlobalConfig(): Promise<RenovateConfig> {\n return parseConfigs(getEnv(), process.argv);\n}\n\nfunction haveReachedLimits(): boolean {\n if (isLimitReached('Commits')) {\n logger.info('Max commits created for this run.');\n return true;\n }\n return false;\n}\n\n/* istanbul ignore next */\nfunction checkEnv(): void {\n const range = pkg.engines.node;\n if (process.release?.name !== 'node' || !process.versions?.node) {\n logger.warn(\n { release: process.release, versions: process.versions },\n 'Unknown node environment detected.',\n );\n } else if (!semver.satisfies(process.versions?.node, range)) {\n logger.error(\n { versions: process.versions, range },\n 'Unsupported node environment detected. Please update your node version.',\n );\n }\n}\n\nexport async function validatePresets(config: AllConfig): Promise<void> {\n logger.debug('validatePresets()');\n try {\n await resolveConfigPresets(config);\n } catch (err) /* istanbul ignore next */ {\n logger.error({ err }, CONFIG_PRESETS_INVALID);\n throw new Error(CONFIG_PRESETS_INVALID);\n }\n}\n\nexport async function start(): Promise<number> {\n logger.info({ renovateVersion: pkg.version }, 'Renovate started');\n // istanbul ignore next\n if (regexEngineStatus.type === 'available') {\n logger.debug('Using RE2 regex engine');\n } else if (regexEngineStatus.type === 'unavailable') {\n logger.warn(\n { err: regexEngineStatus.err },\n 'RE2 not usable, falling back to RegExp',\n );\n } else if (regexEngineStatus.type === 'ignored') {\n logger.debug('RE2 regex engine is ignored via RENOVATE_X_IGNORE_RE2');\n }\n\n let config: AllConfig;\n let repoExitCode = 0;\n const env = getEnv();\n try {\n if (isNonEmptyStringAndNotWhitespace(env.AWS_SECRET_ACCESS_KEY)) {\n addSecretForSanitizing(env.AWS_SECRET_ACCESS_KEY, 'global');\n }\n if (isNonEmptyStringAndNotWhitespace(env.AWS_SESSION_TOKEN)) {\n addSecretForSanitizing(env.AWS_SESSION_TOKEN, 'global');\n }\n if (isNonEmptyStringAndNotWhitespace(env.COREPACK_NPM_TOKEN)) {\n addSecretForSanitizing(env.COREPACK_NPM_TOKEN, 'global');\n }\n if (isNonEmptyStringAndNotWhitespace(env.COREPACK_NPM_PASSWORD)) {\n addSecretForSanitizing(env.COREPACK_NPM_PASSWORD, 'global');\n }\n\n await instrument('config', async () => {\n // read global config from file, env and cli args\n config = await getGlobalConfig();\n\n // Set allowedHeaders and userAgent in case hostRules headers are configured in file config\n // `platform`, `endpoint` and `internalHostAccess` are set here too, so that the platform's own initialization requests - which happen inside `globalInitialize()`, before the config below is set - are judged by the administrator's `internalHostAccess` setting, and are recognized as going to the platform endpoint\n GlobalConfig.set({\n allowedHeaders: config.allowedHeaders,\n endpoint: config.endpoint,\n internalHostAccess: config.internalHostAccess,\n platform: config.platform,\n userAgent: config.userAgent,\n });\n // initialize all submodules\n config = await globalInitialize(config);\n\n // Set platform, endpoint, allowedHeaders and userAgent in case local presets are used, now that platform initialization may have changed them\n GlobalConfig.set({\n allowedHeaders: config.allowedHeaders,\n platform: config.platform,\n endpoint: config.endpoint,\n internalHostAccess: config.internalHostAccess,\n userAgent: config.userAgent,\n });\n\n await validatePresets(config);\n\n setGlobalLogLevelRemaps(config.logLevelRemap);\n\n checkEnv();\n\n // validate secrets and variables. Will throw and abort if invalid\n validateConfigSecretsAndVariables(config);\n });\n\n // autodiscover repositories (needs to come after platform initialization)\n config = await instrument('discover', () =>\n autodiscoverRepositories(config),\n );\n\n if (isNonEmptyString(config.writeDiscoveredRepos)) {\n const content = JSON.stringify(config.repositories);\n await fs.writeFile(config.writeDiscoveredRepos, content);\n logger.info(\n `Written discovered repositories to ${config.writeDiscoveredRepos}`,\n );\n return 0;\n }\n\n // Iterate through repositories sequentially\n for (const repository of config.repositories!) {\n if (haveReachedLimits()) {\n break;\n }\n\n const { owner, repo } = repositoryToOwnerAndRepo(\n isString(repository) ? repository : repository.repository,\n );\n\n await instrument(\n 'repository',\n async () => {\n const repoConfig = await getRepositoryConfig(config, repository);\n if (repoConfig.hostRules) {\n logger.debug('Reinitializing hostRules for repo');\n hostRules.clear();\n for (const rule of repoConfig.hostRules) {\n // the self-hosted admin's own rules: `trusted`, so that their `headers` are applied over any a repository or preset sets for the same host, and exempt from `allowedHeaders` altogether\n hostRules.add(rule, { trusted: true });\n }\n repoConfig.hostRules = [];\n }\n\n // host rules can change concurrency\n queue.clear();\n throttle.clear();\n\n const repoResult =\n await repositoryWorker.renovateRepository(repoConfig);\n if (config.exitCodeForErrors && !repoExitCode) {\n repoExitCode = repoResult?.exitCode ?? 0;\n }\n setMeta({});\n },\n {\n attributes: {\n [ATTR_VCS_PROVIDER_NAME]: config.platform,\n [ATTR_VCS_OWNER_NAME]: owner,\n [ATTR_VCS_REPOSITORY_NAME]: repo,\n /** @deprecated TODO remove */\n repository: isString(repository)\n ? repository\n : repository.repository,\n },\n },\n );\n }\n\n finalizeReport();\n await exportStats(config);\n } catch (err) /* istanbul ignore next */ {\n if (err.message.startsWith('Init: ')) {\n logger.fatal(\n { errorMessage: err.message.substring(6) },\n 'Initialization error',\n );\n } else {\n logger.fatal({ err }, 'Unknown error');\n }\n if (!config!) {\n // return early if we can't parse config options\n logger.debug(`Missing config`);\n return 2;\n }\n } finally {\n await globalFinalize(config!);\n if (logLevel() === 'info') {\n logger.info(\n `Renovate was run at log level \"${logLevel()}\". Set LOG_LEVEL=debug in environment variables to see extended debug logs.`,\n );\n }\n }\n if (repoExitCode) {\n logger.info(\n { exitCode: repoExitCode },\n 'Renovate is exiting with an error-specific code due to a repository error',\n );\n return repoExitCode;\n }\n const loggerErrors = getProblems().filter((p) => p.level >= ERROR);\n if (loggerErrors.length) {\n logger.info(\n { loggerErrors },\n 'Renovate is exiting with a non-zero code due to the following logged errors',\n );\n return 1;\n }\n return 0;\n}\n\nfunction repositoryToOwnerAndRepo(fullName: string): {\n owner: string;\n repo: string;\n} {\n const parts = fullName.split('/');\n const repo = coerceString(parts.pop());\n const owner = parts.join('/');\n return { owner, repo };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAS,kBAGP,QACA,QACA,KACM;CACN,OAAO,OAAO,OAAO;CACrB,OAAO,OAAO;AAChB;AAEA,eAAsB,oBACpB,cACA,YACiC;CACjC,MAAM,eAAe,SAAS,UAAU;CACxC,MAAM,WAAW,eAAe,aAAa,WAAW;CAExD,MAAM,aAAqC;EACzC,GAAG;EACH,YAAY;CACd;CAEA,IAAI,CAAC,cAAc;EACjB,MAAM,EAAE,YAAY,aAAa,GAAG,0BAA0B;EAK9D,KAAK,MAAM,UAAU,aAAa,SAChC,IAAI,UAAU,uBACZ,kBAAkB,YAAY,uBAAuB,MAAM;EAI/D,IAAI,iBAAiB,qBAAqB,GAGxC,WAAW,wBAAwB;CAEvC;CAEA,MAAM,YAAY,SAAS,MAAM,GAAG;CACpC,UAAU,IAAI;CACd,WAAW,YAAY,UAAU,KAAK,GAAG;CACzC,WAAW,cAAc,UAAU,MAAM;CACzC,MAAM,WAAW,aAAa,IAAI,UAAU;CAC5C,WAAW,WACT,aAAa,UACT,QAAQ,IAAI,IAEZ,MAAM,KAAK,WAAW,SAAU,WAAW,SAAS,GAAG,UAAU;CACvE,MAAM,GAAG,UAAU,WAAW,QAAQ;CACtC,OAAO,WAAW;CAClB,OAAOA,aAA0B,YAAY,YAAY;AAC3D;AAEA,SAAS,kBAA2C;CAClD,OAAO,aAAa,OAAO,GAAG,QAAQ,IAAI;AAC5C;AAEA,SAAS,oBAA6B;CACpC,IAAI,eAAe,SAAS,GAAG;EAC7B,OAAO,KAAK,mCAAmC;EAC/C,OA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AC3B,aACA,WAAW;GACjB,EACF,CACF;EACF;EAEA,eAAe;EACf,MAAM,YAAY,MAAM;CAC1B,SAAS,gCAAgC;EACvC,IAAI,IAAI,QAAQ,WAAW,QAAQ,GACjC,OAAO,MACL,EAAE,cAAc,IAAI,QAAQ,UAAU,CAAC,EAAE,GACzC,sBACF;OAEA,OAAO,MAAM,EAAE,IAAI,GAAG,eAAe;EAEvC,IAAI,CAAC,QAAS;GAEZ,OAAO,MAAM,gBAAgB;GAC7B,OAAO;EACT;CACF,UAAU;EACR,MAAM,eAAe,MAAO;EAC5B,IAAI,SAAS,MAAM,QACjB,OAAO,KACL,kCAAkC,SAAS,EAAE,4EAC/C;CAEJ;CACA,IAAI,cAAc;EAChB,OAAO,KACL,EAAE,UAAU,aAAa,GACzB,2EACF;EACA,OAAO;CACT;CACA,MAAM,eAAe,YAAY,CAAC,CAAC,QAAQ,MAAM,EAAE,SAAS,KAAK;CACjE,IAAI,aAAa,QAAQ;EACvB,OAAO,KACL,EAAE,aAAa,GACf,6EACF;EACA,OAAO;CACT;CACA,OAAO;AACT;AAEA,SAAS,yBAAyB,UAGhC;CACA,MAAM,QAAQ,SAAS,MAAM,GAAG;CAChC,MAAM,OAAO,aAAa,MAAM,IAAI,CAAC;CAErC,OAAO;EAAE,OADK,MAAM,KAAK,GACZ;EAAG;CAAK;AACvB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["configParser.filterConfig","repositoryWorker.renovateRepository"],"sources":["../../../lib/workers/global/index.ts"],"sourcesContent":["import {\n ATTR_VCS_OWNER_NAME,\n ATTR_VCS_PROVIDER_NAME,\n ATTR_VCS_REPOSITORY_NAME,\n} from '@opentelemetry/semantic-conventions/incubating';\nimport {\n isNonEmptyObject,\n isNonEmptyString,\n isNonEmptyStringAndNotWhitespace,\n isString,\n} from '@sindresorhus/is';\nimport { ERROR } from 'bunyan';\nimport fs from 'fs-extra';\nimport semver from 'semver';\nimport upath from 'upath';\nimport { GlobalConfig, setHttpGlobalConfig } from '../../config/global.ts';\nimport * as configParser from '../../config/index.ts';\nimport { resolveConfigPresets } from '../../config/presets/index.ts';\nimport { validateConfigSecretsAndVariables } from '../../config/secrets.ts';\nimport type {\n AllConfig,\n InternalGlobalConfigOptions,\n RenovateConfig,\n RenovateRepository,\n RepoGlobalConfig,\n} from '../../config/types.ts';\nimport { CONFIG_PRESETS_INVALID } from '../../constants/error-messages.ts';\nimport { pkg } from '../../expose.ts';\nimport { instrument } from '../../instrumentation/index.ts';\nimport {\n exportStats,\n finalizeReport,\n} from '../../instrumentation/reporting.ts';\nimport { getProblems, logLevel, logger, setMeta } from '../../logger/index.ts';\nimport { setGlobalLogLevelRemaps } from '../../logger/remap.ts';\nimport { getEnv } from '../../util/env.ts';\nimport * as hostRules from '../../util/host-rules.ts';\nimport * as queue from '../../util/http/queue.ts';\nimport * as throttle from '../../util/http/throttle.ts';\nimport { regexEngineStatus } from '../../util/regex.ts';\nimport { addSecretForSanitizing } from '../../util/sanitize.ts';\nimport { coerceString } from '../../util/string.ts';\nimport * as repositoryWorker from '../repository/index.ts';\nimport type { RepositoryWorkerConfig } from '../repository/init/types.ts';\nimport { autodiscoverRepositories } from './autodiscover.ts';\nimport { parseConfigs } from './config/parse/index.ts';\nimport { globalFinalize, globalInitialize } from './initialize.ts';\nimport { isLimitReached } from './limits.ts';\n\nfunction applyGlobalOption<\n K extends keyof RepoGlobalConfig | keyof InternalGlobalConfigOptions,\n>(\n target: RepoGlobalConfig & InternalGlobalConfigOptions,\n source: RepoGlobalConfig & InternalGlobalConfigOptions,\n key: K,\n): void {\n target[key] = source[key];\n delete source[key];\n}\n\nexport async function getRepositoryConfig(\n globalConfig: RenovateConfig,\n repository: RenovateRepository,\n): Promise<RepositoryWorkerConfig> {\n const repoIsString = isString(repository);\n const repoName = repoIsString ? repository : repository.repository;\n\n const repoConfig: RepositoryWorkerConfig = {\n ...globalConfig,\n repository: repoName,\n };\n\n if (!repoIsString) {\n const { repository: _repository, ...repositoryEntryConfig } = repository;\n\n // Promote GlobalConfig.OPTIONS keys into repoConfig directly so that\n // GlobalConfig.set(repoConfig) in the repository worker picks them up\n // with per-repo overrides before onboarding checks run.\n for (const option of GlobalConfig.OPTIONS) {\n if (option in repositoryEntryConfig) {\n applyGlobalOption(repoConfig, repositoryEntryConfig, option);\n }\n }\n\n if (isNonEmptyObject(repositoryEntryConfig)) {\n // mergeRenovateConfig later resolves this repositories[] object-entry\n // config in the correct order\n repoConfig.repositoryEntryConfig = repositoryEntryConfig;\n }\n }\n\n const repoParts = repoName.split('/');\n repoParts.pop();\n repoConfig.parentOrg = repoParts.join('/');\n repoConfig.topLevelOrg = repoParts.shift();\n const platform = GlobalConfig.get('platform');\n repoConfig.localDir =\n platform === 'local'\n ? process.cwd()\n : // TODO: types (#22198)\n upath.join(repoConfig.baseDir!, `./repos/${platform}/${repoName}`);\n await fs.ensureDir(repoConfig.localDir);\n delete repoConfig.baseDir;\n return configParser.filterConfig(repoConfig, 'repository');\n}\n\nfunction getGlobalConfig(): Promise<RenovateConfig> {\n return parseConfigs(getEnv(), process.argv);\n}\n\nfunction haveReachedLimits(): boolean {\n if (isLimitReached('Commits')) {\n logger.info('Max commits created for this run.');\n return true;\n }\n return false;\n}\n\n/* istanbul ignore next */\nfunction checkEnv(): void {\n const range = pkg.engines.node;\n if (process.release?.name !== 'node' || !process.versions?.node) {\n logger.warn(\n { release: process.release, versions: process.versions },\n 'Unknown node environment detected.',\n );\n } else if (!semver.satisfies(process.versions?.node, range)) {\n logger.error(\n { versions: process.versions, range },\n 'Unsupported node environment detected. Please update your node version.',\n );\n }\n}\n\nexport async function validatePresets(config: AllConfig): Promise<void> {\n logger.debug('validatePresets()');\n try {\n await resolveConfigPresets(config);\n } catch (err) /* istanbul ignore next */ {\n logger.error({ err }, CONFIG_PRESETS_INVALID);\n throw new Error(CONFIG_PRESETS_INVALID);\n }\n}\n\nexport async function start(): Promise<number> {\n logger.info({ renovateVersion: pkg.version }, 'Renovate started');\n // istanbul ignore next\n if (regexEngineStatus.type === 'available') {\n logger.debug('Using RE2 regex engine');\n } else if (regexEngineStatus.type === 'unavailable') {\n logger.warn(\n { err: regexEngineStatus.err },\n 'RE2 not usable, falling back to RegExp',\n );\n } else if (regexEngineStatus.type === 'ignored') {\n logger.debug('RE2 regex engine is ignored via RENOVATE_X_IGNORE_RE2');\n }\n\n let config: AllConfig;\n let repoExitCode = 0;\n const env = getEnv();\n try {\n if (isNonEmptyStringAndNotWhitespace(env.AWS_SECRET_ACCESS_KEY)) {\n addSecretForSanitizing(env.AWS_SECRET_ACCESS_KEY, 'global');\n }\n if (isNonEmptyStringAndNotWhitespace(env.AWS_SESSION_TOKEN)) {\n addSecretForSanitizing(env.AWS_SESSION_TOKEN, 'global');\n }\n if (isNonEmptyStringAndNotWhitespace(env.COREPACK_NPM_TOKEN)) {\n addSecretForSanitizing(env.COREPACK_NPM_TOKEN, 'global');\n }\n if (isNonEmptyStringAndNotWhitespace(env.COREPACK_NPM_PASSWORD)) {\n addSecretForSanitizing(env.COREPACK_NPM_PASSWORD, 'global');\n }\n\n await instrument('config', async () => {\n // read global config from file, env and cli args\n config = await getGlobalConfig();\n\n // set before `globalInitialize()`, so that `hostRules` headers from file config are checked against `allowedHeaders`, and the platform's own initialization requests are judged by the administrator's `internalHostAccess` setting and recognized as going to the platform endpoint\n setHttpGlobalConfig(config);\n // initialize all submodules\n config = await globalInitialize(config);\n\n // set again in case local presets are used, now that platform initialization may have changed `platform` and `endpoint`\n setHttpGlobalConfig(config);\n\n await validatePresets(config);\n\n setGlobalLogLevelRemaps(config.logLevelRemap);\n\n checkEnv();\n\n // validate secrets and variables. Will throw and abort if invalid\n validateConfigSecretsAndVariables(config);\n });\n\n // autodiscover repositories (needs to come after platform initialization)\n config = await instrument('discover', () =>\n autodiscoverRepositories(config),\n );\n\n if (isNonEmptyString(config.writeDiscoveredRepos)) {\n const content = JSON.stringify(config.repositories);\n await fs.writeFile(config.writeDiscoveredRepos, content);\n logger.info(\n `Written discovered repositories to ${config.writeDiscoveredRepos}`,\n );\n return 0;\n }\n\n // Iterate through repositories sequentially\n for (const repository of config.repositories!) {\n if (haveReachedLimits()) {\n break;\n }\n\n const { owner, repo } = repositoryToOwnerAndRepo(\n isString(repository) ? repository : repository.repository,\n );\n\n await instrument(\n 'repository',\n async () => {\n const repoConfig = await getRepositoryConfig(config, repository);\n if (repoConfig.hostRules) {\n logger.debug('Reinitializing hostRules for repo');\n hostRules.clear();\n for (const rule of repoConfig.hostRules) {\n // the self-hosted admin's own rules: `trusted`, so that their `headers` are applied over any a repository or preset sets for the same host, and exempt from `allowedHeaders` altogether\n hostRules.add(rule, { trusted: true });\n }\n repoConfig.hostRules = [];\n }\n\n // host rules can change concurrency\n queue.clear();\n throttle.clear();\n\n const repoResult =\n await repositoryWorker.renovateRepository(repoConfig);\n if (config.exitCodeForErrors && !repoExitCode) {\n repoExitCode = repoResult?.exitCode ?? 0;\n }\n setMeta({});\n },\n {\n attributes: {\n [ATTR_VCS_PROVIDER_NAME]: config.platform,\n [ATTR_VCS_OWNER_NAME]: owner,\n [ATTR_VCS_REPOSITORY_NAME]: repo,\n /** @deprecated TODO remove */\n repository: isString(repository)\n ? repository\n : repository.repository,\n },\n },\n );\n }\n\n finalizeReport();\n await exportStats(config);\n } catch (err) /* istanbul ignore next */ {\n if (err.message.startsWith('Init: ')) {\n logger.fatal(\n { errorMessage: err.message.substring(6) },\n 'Initialization error',\n );\n } else {\n logger.fatal({ err }, 'Unknown error');\n }\n if (!config!) {\n // return early if we can't parse config options\n logger.debug(`Missing config`);\n return 2;\n }\n } finally {\n await globalFinalize(config!);\n if (logLevel() === 'info') {\n logger.info(\n `Renovate was run at log level \"${logLevel()}\". Set LOG_LEVEL=debug in environment variables to see extended debug logs.`,\n );\n }\n }\n if (repoExitCode) {\n logger.info(\n { exitCode: repoExitCode },\n 'Renovate is exiting with an error-specific code due to a repository error',\n );\n return repoExitCode;\n }\n const loggerErrors = getProblems().filter((p) => p.level >= ERROR);\n if (loggerErrors.length) {\n logger.info(\n { loggerErrors },\n 'Renovate is exiting with a non-zero code due to the following logged errors',\n );\n return 1;\n }\n return 0;\n}\n\nfunction repositoryToOwnerAndRepo(fullName: string): {\n owner: string;\n repo: string;\n} {\n const parts = fullName.split('/');\n const repo = coerceString(parts.pop());\n const owner = parts.join('/');\n return { owner, repo };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAS,kBAGP,QACA,QACA,KACM;CACN,OAAO,OAAO,OAAO;CACrB,OAAO,OAAO;AAChB;AAEA,eAAsB,oBACpB,cACA,YACiC;CACjC,MAAM,eAAe,SAAS,UAAU;CACxC,MAAM,WAAW,eAAe,aAAa,WAAW;CAExD,MAAM,aAAqC;EACzC,GAAG;EACH,YAAY;CACd;CAEA,IAAI,CAAC,cAAc;EACjB,MAAM,EAAE,YAAY,aAAa,GAAG,0BAA0B;EAK9D,KAAK,MAAM,UAAU,aAAa,SAChC,IAAI,UAAU,uBACZ,kBAAkB,YAAY,uBAAuB,MAAM;EAI/D,IAAI,iBAAiB,qBAAqB,GAGxC,WAAW,wBAAwB;CAEvC;CAEA,MAAM,YAAY,SAAS,MAAM,GAAG;CACpC,UAAU,IAAI;CACd,WAAW,YAAY,UAAU,KAAK,GAAG;CACzC,WAAW,cAAc,UAAU,MAAM;CACzC,MAAM,WAAW,aAAa,IAAI,UAAU;CAC5C,WAAW,WACT,aAAa,UACT,QAAQ,IAAI,IAEZ,MAAM,KAAK,WAAW,SAAU,WAAW,SAAS,GAAG,UAAU;CACvE,MAAM,GAAG,UAAU,WAAW,QAAQ;CACtC,OAAO,WAAW;CAClB,OAAOA,aAA0B,YAAY,YAAY;AAC3D;AAEA,SAAS,kBAA2C;CAClD,OAAO,aAAa,OAAO,GAAG,QAAQ,IAAI;AAC5C;AAEA,SAAS,oBAA6B;CACpC,IAAI,eAAe,SAAS,GAAG;EAC7B,OAAO,KAAK,mCAAmC;EAC/C,OAAO;CACT;CACA,OAAO;AACT;;AAGA,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AAG,eAAe;EAEvC,IAAI,CAAC,QAAS;GAEZ,OAAO,MAAM,gBAAgB;GAC7B,OAAO;EACT;CACF,UAAU;EACR,MAAM,eAAe,MAAO;EAC5B,IAAI,SAAS,MAAM,QACjB,OAAO,KACL,kCAAkC,SAAS,EAAE,4EAC/C;CAEJ;CACA,IAAI,cAAc;EAChB,OAAO,KACL,EAAE,UAAU,aAAa,GACzB,2EACF;EACA,OAAO;CACT;CACA,MAAM,eAAe,YAAY,CAAC,CAAC,QAAQ,MAAM,EAAE,SAAS,KAAK;CACjE,IAAI,aAAa,QAAQ;EACvB,OAAO,KACL,EAAE,aAAa,GACf,6EACF;EACA,OAAO;CACT;CACA,OAAO;AACT;AAEA,SAAS,yBAAyB,UAGhC;CACA,MAAM,QAAQ,SAAS,MAAM,GAAG;CAChC,MAAM,OAAO,aAAa,MAAM,IAAI,CAAC;CAErC,OAAO;EAAE,OADK,MAAM,KAAK,GACZ;EAAG;CAAK;AACvB"}
|
|
@@ -251,7 +251,7 @@ async function ensureDependencyDashboard(config, allBranches, packageFiles = {},
|
|
|
251
251
|
if (hasDeprecationsOrReplacements) {
|
|
252
252
|
issueBody += "## Deprecations / Replacements\n";
|
|
253
253
|
issueBody += emojify("> :warning: **Warning**\n> \n");
|
|
254
|
-
issueBody += "The following dependencies are either deprecated or have replacements available.\n\n";
|
|
254
|
+
issueBody += "> The following dependencies are either deprecated or have replacements available.\n\n";
|
|
255
255
|
issueBody += "| Datasource | Package | Replacement PR? |\n";
|
|
256
256
|
issueBody += "|------------|------|--------------|\n";
|
|
257
257
|
for (const manager of Object.keys(deprecatedPackages).sort()) {
|
|
@@ -342,7 +342,7 @@ function getAbandonedPackagesMd(config, packageFiles) {
|
|
|
342
342
|
let abandonedMd = "## Abandoned Dependencies\n\n";
|
|
343
343
|
abandonedMd += "The following dependencies have not received updates for an extended period and may be unmaintained.\n\n";
|
|
344
344
|
abandonedMd += emojify("> :information_source: **Note**\n> \n");
|
|
345
|
-
abandonedMd +=
|
|
345
|
+
abandonedMd += `> Packages are marked as abandoned when they exceed the [\`abandonmentThreshold\`](${GlobalConfig.get("productLinks").documentation}configuration-options/#abandonmentthreshold) since their last release. `;
|
|
346
346
|
abandonedMd += "Unlike deprecated packages with official notices, abandonment is detected by release inactivity.\n> \n";
|
|
347
347
|
abandonedMd += "<details>\n";
|
|
348
348
|
abandonedMd += `<summary>View abandoned dependencies (${abandonedCount})</summary>\n\n`;
|