renovate 44.17.4 → 44.18.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/options/index.js +1 -1
- package/dist/config/options/index.js.map +1 -1
- package/dist/global-config-option-defaults.generated.js +1 -1
- package/dist/global-config-option-defaults.generated.js.map +1 -1
- package/dist/modules/datasource/git-refs/base.js +1 -3
- package/dist/modules/datasource/git-refs/base.js.map +1 -1
- package/dist/modules/manager/cargo/artifacts.js +6 -10
- package/dist/modules/manager/cargo/artifacts.js.map +1 -1
- package/dist/modules/manager/conan/artifacts.js +4 -6
- package/dist/modules/manager/conan/artifacts.js.map +1 -1
- package/dist/modules/manager/copier/artifacts.js +3 -4
- package/dist/modules/manager/copier/artifacts.js.map +1 -1
- package/dist/modules/manager/fingerprint.generated.js +3 -3
- package/dist/modules/manager/fingerprint.generated.js.map +1 -1
- package/dist/modules/manager/git-submodules/update.js +3 -4
- package/dist/modules/manager/git-submodules/update.js.map +1 -1
- package/dist/modules/manager/gomod/artifacts.js +4 -5
- package/dist/modules/manager/gomod/artifacts.js.map +1 -1
- package/dist/modules/manager/hermit/artifacts.js +8 -6
- package/dist/modules/manager/hermit/artifacts.js.map +1 -1
- package/dist/modules/manager/pep621/processors/pdm.js +10 -13
- package/dist/modules/manager/pep621/processors/pdm.js.map +1 -1
- package/dist/modules/manager/pep621/processors/uv.js +3 -4
- package/dist/modules/manager/pep621/processors/uv.js.map +1 -1
- package/dist/modules/manager/poetry/artifacts.js +3 -4
- package/dist/modules/manager/poetry/artifacts.js.map +1 -1
- package/dist/modules/manager/vendir/artifacts.js +3 -4
- package/dist/modules/manager/vendir/artifacts.js.map +1 -1
- package/dist/util/exec/index.js +10 -5
- package/dist/util/exec/index.js.map +1 -1
- package/dist/util/exec/utils.js.map +1 -1
- package/dist/util/git/auth.js +16 -18
- package/dist/util/git/auth.js.map +1 -1
- package/dist/util/git/exec.js +34 -0
- package/dist/util/git/exec.js.map +1 -0
- package/dist/util/git/index.d.ts +6 -2
- package/dist/util/git/index.js +9 -7
- package/dist/util/git/index.js.map +1 -1
- package/dist/workers/repository/update/branch/execute-post-upgrade-commands.js +4 -5
- package/dist/workers/repository/update/branch/execute-post-upgrade-commands.js.map +1 -1
- package/package.json +1 -1
- package/renovate-schema.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/vendir/artifacts.ts"],"sourcesContent":["import { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport
|
|
1
|
+
{"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/vendir/artifacts.ts"],"sourcesContent":["import { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n getParentDir,\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../util/git/exec.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\n\nconst gitExec = withGitEnvironment();\n\nexport async function updateArtifacts({\n packageFileName,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`vendir.updateArtifacts(${packageFileName})`);\n\n const lockFileName = getSiblingFileName(packageFileName, 'vendir.lock.yml');\n if (!lockFileName) {\n logger.warn('No vendir.lock.yml found');\n return null;\n }\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.warn('Empty vendir.lock.yml found');\n return null;\n }\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n logger.debug('Updating Vendir artifacts');\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n docker: {},\n toolConstraints: [\n { toolName: 'vendir', constraint: config.constraints?.vendir },\n { toolName: 'helm', constraint: config.constraints?.helm },\n ],\n };\n\n await gitExec(`vendir sync`, execOptions);\n\n logger.debug('Returning updated Vendir artifacts');\n\n const fileChanges: UpdateArtifactsResult[] = [];\n\n const newVendirLockContent = await readLocalFile(lockFileName, 'utf8');\n const isLockFileChanged = existingLockFileContent !== newVendirLockContent;\n if (isLockFileChanged) {\n fileChanges.push({\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newVendirLockContent,\n },\n });\n }\n\n // add modified vendir archives to artifacts\n logger.debug(\"Adding Sync'd files to git\");\n // Files must be in the vendor path to get added\n const vendorDir = getParentDir(packageFileName);\n const status = await getRepoStatus();\n if (status) {\n const modifiedFiles = status.modified ?? [];\n const notAddedFiles = status.not_added;\n const deletedFiles = status.deleted ?? [];\n\n for (const f of modifiedFiles.concat(notAddedFiles)) {\n const isFileInVendorDir = f.startsWith(vendorDir);\n if (vendorDir || isFileInVendorDir) {\n fileChanges.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n\n for (const f of deletedFiles) {\n fileChanges.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n } else {\n logger.error('Failed to get git status');\n }\n\n return fileChanges.length ? fileChanges : null;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update Vendir lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;AAaA,MAAM,UAAU,mBAAmB;AAEnC,eAAsB,gBAAgB,EACpC,iBACA,uBACA,UAC0D;CAC1D,OAAO,MAAM,0BAA0B,gBAAgB,EAAE;CAEzD,MAAM,eAAe,mBAAmB,iBAAiB,iBAAiB;CAC1E,IAAI,CAAC,cAAc;EACjB,OAAO,KAAK,0BAA0B;EACtC,OAAO;CACT;CACA,MAAM,0BAA0B,MAAM,cAAc,cAAc,MAAM;CACxE,IAAI,CAAC,yBAAyB;EAC5B,OAAO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,IAAI;EACd,EACF,CACF;CACF;AACF"}
|
package/dist/util/exec/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { TEMPORARY_ERROR } from "../../constants/error-messages.js";
|
|
|
2
2
|
import { getCustomEnv, getUserEnv } from "../env.js";
|
|
3
3
|
import { GlobalConfig } from "../../config/global.js";
|
|
4
4
|
import { logger } from "../../logger/index.js";
|
|
5
|
+
import { coerceArray } from "../array.js";
|
|
5
6
|
import { getChildEnv } from "./utils.js";
|
|
6
7
|
import { generateInstallCommands, isDynamicInstall } from "./containerbase.js";
|
|
7
8
|
import { coerceObject } from "../object.js";
|
|
@@ -53,11 +54,15 @@ async function prepareRawExec(cmd, opts, sideCarImage) {
|
|
|
53
54
|
let rawCommands = typeof cmd === "string" ? [cmd] : cmd;
|
|
54
55
|
if (isDocker(docker)) {
|
|
55
56
|
logger.debug({ image: sideCarImage }, "Using docker to execute");
|
|
56
|
-
const envVars = [
|
|
57
|
-
...
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const envVars = [
|
|
58
|
+
...dockerEnvVars({
|
|
59
|
+
...opts.extraEnv,
|
|
60
|
+
...customEnvVariables,
|
|
61
|
+
...userConfiguredEnv
|
|
62
|
+
}, getChildEnv(opts)),
|
|
63
|
+
...coerceArray(docker.envVars),
|
|
64
|
+
"CONTAINERBASE_CACHE_DIR"
|
|
65
|
+
];
|
|
61
66
|
const cwd = getCwd(opts);
|
|
62
67
|
const dockerOptions = {
|
|
63
68
|
...docker,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../lib/util/exec/index.ts"],"sourcesContent":["import { isNonEmptyString } from '@sindresorhus/is';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../config/global.ts';\nimport type { RepoToolSettingsOptions } from '../../config/types.ts';\nimport { TEMPORARY_ERROR } from '../../constants/error-messages.ts';\nimport { logger } from '../../logger/index.ts';\nimport { getCustomEnv, getUserEnv } from '../env.ts';\nimport { coerceObject } from '../object.ts';\nimport { rawExec } from './common.ts';\nimport { generateInstallCommands, isDynamicInstall } from './containerbase.ts';\nimport {\n generateDockerCommand,\n removeDockerContainer,\n} from './docker/index.ts';\nimport { getHermitEnvs, isHermit } from './hermit.ts';\nimport type {\n CommandWithOptions,\n DockerOptions,\n ExecOptions,\n ExecResult,\n ExtraEnv,\n Opt,\n RawExecOptions,\n} from './types.ts';\nimport { getChildEnv } from './utils.ts';\n\nfunction dockerEnvVars(extraEnv: ExtraEnv, childEnv: ExtraEnv): string[] {\n const extraEnvKeys = Object.keys(extraEnv);\n return extraEnvKeys.filter((key) => isNonEmptyString(childEnv[key]));\n}\n\nfunction getCwd({ cwd, cwdFile }: ExecOptions): string | undefined {\n // TODO: types (#22198)\n const defaultCwd = GlobalConfig.get('localDir');\n const paramCwd = cwdFile\n ? upath.join(defaultCwd, upath.dirname(cwdFile))\n : cwd;\n return paramCwd ?? defaultCwd;\n}\n\nfunction getRawExecOptions(opts: ExecOptions): RawExecOptions {\n const defaultExecutionTimeout = GlobalConfig.get('executionTimeout');\n const childEnv = getChildEnv(opts);\n const cwd = getCwd(opts);\n let timeout = opts.timeout;\n timeout ??= defaultExecutionTimeout * 60 * 1000;\n\n // Set default max buffer size to 10MB\n const maxBuffer = opts.maxBuffer ?? 10 * 1024 * 1024;\n\n return {\n cwd,\n env: childEnv,\n maxBuffer,\n timeout,\n ...(opts.shell !== undefined && { shell: opts.shell }),\n stdin: 'pipe',\n stdout: opts.ignoreStdout ? 'ignore' : 'pipe',\n stderr: 'pipe',\n };\n}\n\nfunction isDocker(docker: Opt<DockerOptions>): docker is DockerOptions {\n return GlobalConfig.get('binarySource') === 'docker' && !!docker;\n}\n\ninterface RawExecArguments {\n rawCommands: (string | CommandWithOptions)[];\n rawOptions: RawExecOptions;\n}\n\nasync function prepareRawExec(\n cmd:\n | string\n | string[]\n | CommandWithOptions[]\n | (string | CommandWithOptions)[],\n opts: ExecOptions,\n sideCarImage: string,\n): Promise<RawExecArguments> {\n const { docker } = opts;\n const preCommands = opts.preCommands ?? [];\n const customEnvVariables = getCustomEnv();\n const userConfiguredEnv = getUserEnv();\n const { containerbaseDir, binarySource } = GlobalConfig.get();\n\n if (binarySource === 'docker' || binarySource === 'install') {\n logger.debug(`Setting CONTAINERBASE_CACHE_DIR to ${containerbaseDir!}`);\n opts.env ??= {};\n opts.env.CONTAINERBASE_CACHE_DIR = containerbaseDir;\n }\n\n let rawOptions = getRawExecOptions(opts);\n\n let rawCommands = typeof cmd === 'string' ? [cmd] : cmd;\n\n if (isDocker(docker)) {\n logger.debug({ image: sideCarImage }, 'Using docker to execute');\n const extraEnv = {\n ...opts.extraEnv,\n ...customEnvVariables,\n ...userConfiguredEnv,\n };\n const childEnv = getChildEnv(opts);\n const envVars = [\n ...dockerEnvVars(extraEnv, childEnv),\n 'CONTAINERBASE_CACHE_DIR',\n ];\n const cwd = getCwd(opts);\n const dockerOptions: DockerOptions = { ...docker, cwd, envVars };\n const dockerCommand = await generateDockerCommand(\n rawCommands,\n [\n ...(await generateInstallCommands(opts.toolConstraints)),\n ...preCommands,\n ],\n dockerOptions,\n sideCarImage,\n );\n rawCommands = [dockerCommand];\n } else if (isDynamicInstall(opts.toolConstraints)) {\n logger.debug('Using containerbase dynamic installs');\n rawCommands = [\n ...(await generateInstallCommands(opts.toolConstraints)),\n ...preCommands,\n ...rawCommands,\n ];\n } else if (isHermit()) {\n const hermitEnvVars = await getHermitEnvs(rawOptions);\n logger.debug(\n { hermitEnvVars },\n 'merging hermit environment variables into the execution options',\n );\n rawOptions = {\n ...rawOptions,\n env: {\n ...rawOptions.env,\n ...hermitEnvVars,\n },\n };\n }\n\n if (\n GlobalConfig.get('binarySource') === 'global' &&\n opts.toolConstraints?.length\n ) {\n logger.once.debug(\n { toolConstraints: opts.toolConstraints },\n 'Ignoring tool contraints because of `binarySource=global`',\n );\n }\n\n return { rawCommands, rawOptions };\n}\n\nexport async function exec(\n cmd:\n | string\n | string[]\n | CommandWithOptions[]\n | (string | CommandWithOptions)[],\n opts: ExecOptions = {},\n): Promise<ExecResult> {\n const { docker } = opts;\n const dockerChildPrefix = GlobalConfig.get('dockerChildPrefix');\n const sideCarImage = GlobalConfig.get('dockerSidecarImage');\n\n const { rawCommands, rawOptions } = await prepareRawExec(\n cmd,\n opts,\n sideCarImage,\n );\n const useDocker = isDocker(docker);\n\n let res: ExecResult = { stdout: '', stderr: '' };\n for (const rawCmd of rawCommands) {\n const startTime = Date.now();\n if (useDocker) {\n await removeDockerContainer(sideCarImage, dockerChildPrefix);\n }\n logger.debug(\n { command: rawCmd, env: Object.keys(coerceObject(rawOptions.env)) },\n 'Executing command',\n );\n logger.trace({ commandOptions: rawOptions }, 'Command options');\n try {\n res = await rawExec(rawCmd, rawOptions);\n } catch (err) {\n const durationMs = Math.round(Date.now() - startTime);\n logger.debug({ err, durationMs }, 'rawExec err');\n if (useDocker) {\n await removeDockerContainer(sideCarImage, dockerChildPrefix).catch(\n (removeErr: Error) => {\n const message: string = err.message;\n throw new Error(\n `Error: \"${removeErr.message}\" - Original Error: \"${message}\"`,\n );\n },\n );\n }\n if (err.signal === `SIGTERM`) {\n logger.debug(\n { err },\n 'exec interrupted by SIGTERM - run needs to be aborted',\n );\n throw new Error(TEMPORARY_ERROR);\n }\n throw err;\n }\n const durationMs = Math.round(Date.now() - startTime);\n logger.debug(\n {\n durationMs,\n stdout: res.stdout,\n stderr: res.stderr,\n },\n 'exec completed',\n );\n }\n\n return res;\n}\n\n/**\n * When we resolve `toolSettings` in `getToolSettingsOptions`, we provide a stronger type than our input types, because we set defaults on config options.\n *\n * We do not have a default that is set for `nodeMaxMemory`, so it must remain as optional.\n */\ntype ResolvedToolSettingsOptions = Required<\n Omit<RepoToolSettingsOptions, 'nodeMaxMemory'>\n> &\n Pick<RepoToolSettingsOptions, 'nodeMaxMemory'>;\n\nexport function getToolSettingsOptions(\n repoConfig?: RepoToolSettingsOptions,\n): ResolvedToolSettingsOptions {\n let defaults = GlobalConfig.get('toolSettings');\n defaults ??= {\n jvmMaxMemory: 512,\n jvmMemory: 512,\n };\n\n const jvmMaxMemory = defaults?.jvmMaxMemory ?? 512;\n const options: ResolvedToolSettingsOptions = {\n jvmMaxMemory,\n jvmMemory: defaults?.jvmMemory ?? jvmMaxMemory,\n nodeMaxMemory: defaults?.nodeMaxMemory,\n };\n\n if (repoConfig !== undefined) {\n if (repoConfig.jvmMaxMemory) {\n if (repoConfig.jvmMaxMemory > options.jvmMaxMemory) {\n logger.once.debug(\n `A higher jvmMaxMemory (${repoConfig.jvmMaxMemory}) than the global configuration (${options.jvmMaxMemory}) is not permitted for Java VM invocations. Using global configuration instead`,\n );\n }\n\n options.jvmMaxMemory = Math.min(\n options.jvmMaxMemory,\n repoConfig.jvmMaxMemory,\n );\n }\n\n if (repoConfig.jvmMemory) {\n options.jvmMemory = repoConfig.jvmMemory;\n }\n\n if (repoConfig.nodeMaxMemory) {\n if (\n options.nodeMaxMemory &&\n repoConfig.nodeMaxMemory > options.nodeMaxMemory\n ) {\n logger.once.debug(\n `A higher nodeMaxMemory (${repoConfig.nodeMaxMemory}) than the global configuration (${options.nodeMaxMemory}) is not permitted for Node invocations. Using global configuration instead`,\n );\n } else {\n options.nodeMaxMemory = repoConfig.nodeMaxMemory;\n }\n }\n }\n\n options.jvmMaxMemory = Math.floor(options.jvmMaxMemory);\n options.jvmMemory = Math.floor(options.jvmMemory);\n if (options.nodeMaxMemory) {\n options.nodeMaxMemory = Math.floor(options.nodeMaxMemory);\n }\n\n // make sure that the starting memory can't be more than the max memory\n options.jvmMemory = Math.min(options.jvmMemory, options.jvmMaxMemory);\n\n if (options.jvmMaxMemory < 512 || options.jvmMemory < 512) {\n options.jvmMaxMemory = Math.max(options.jvmMaxMemory, 512);\n\n logger.once.debug(\n 'Overriding low memory settings for Java VM invocations to a minimum of 512M',\n );\n options.jvmMemory = Math.max(options.jvmMemory, 512);\n }\n\n return options;\n}\n\nexport function gradleJvmArg(config: RepoToolSettingsOptions): string {\n return ` -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QAAQ,cACR,WAAW,YACb;EACF;EAEA,IAAI,WAAW,WACb,QAAQ,YAAY,WAAW;EAGjC,IAAI,WAAW,eACb,IACE,QAAQ,iBACR,WAAW,gBAAgB,QAAQ,eAEnC,OAAO,KAAK,MACV,2BAA2B,WAAW,cAAc,mCAAmC,QAAQ,cAAc,4EAC/G;OAEA,QAAQ,gBAAgB,WAAW;CAGzC;CAEA,QAAQ,eAAe,KAAK,MAAM,QAAQ,YAAY;CACtD,QAAQ,YAAY,KAAK,MAAM,QAAQ,SAAS;CAChD,IAAI,QAAQ,eACV,QAAQ,gBAAgB,KAAK,MAAM,QAAQ,aAAa;CAI1D,QAAQ,YAAY,KAAK,IAAI,QAAQ,WAAW,QAAQ,YAAY;CAEpE,IAAI,QAAQ,eAAe,OAAO,QAAQ,YAAY,KAAK;EACzD,QAAQ,eAAe,KAAK,IAAI,QAAQ,cAAc,GAAG;EAEzD,OAAO,KAAK,MACV,6EACF;EACA,QAAQ,YAAY,KAAK,IAAI,QAAQ,WAAW,GAAG;CACrD;CAEA,OAAO;AACT;AAEA,SAAgB,aAAa,QAAyC;CACpE,OAAO,8BAA8B,OAAO,UAAU,QAAQ,OAAO,aAAa;AACpF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../lib/util/exec/index.ts"],"sourcesContent":["import { isNonEmptyString } from '@sindresorhus/is';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../config/global.ts';\nimport type { RepoToolSettingsOptions } from '../../config/types.ts';\nimport { TEMPORARY_ERROR } from '../../constants/error-messages.ts';\nimport { logger } from '../../logger/index.ts';\nimport { coerceArray } from '../array.ts';\nimport { getCustomEnv, getUserEnv } from '../env.ts';\nimport { coerceObject } from '../object.ts';\nimport { rawExec } from './common.ts';\nimport { generateInstallCommands, isDynamicInstall } from './containerbase.ts';\nimport {\n generateDockerCommand,\n removeDockerContainer,\n} from './docker/index.ts';\nimport { getHermitEnvs, isHermit } from './hermit.ts';\nimport type {\n CommandWithOptions,\n DockerOptions,\n ExecOptions,\n ExecResult,\n ExtraEnv,\n Opt,\n RawExecOptions,\n} from './types.ts';\nimport { getChildEnv } from './utils.ts';\n\nfunction dockerEnvVars(extraEnv: ExtraEnv, childEnv: ExtraEnv): string[] {\n const extraEnvKeys = Object.keys(extraEnv);\n return extraEnvKeys.filter((key) => isNonEmptyString(childEnv[key]));\n}\n\nfunction getCwd({ cwd, cwdFile }: ExecOptions): string | undefined {\n // TODO: types (#22198)\n const defaultCwd = GlobalConfig.get('localDir');\n const paramCwd = cwdFile\n ? upath.join(defaultCwd, upath.dirname(cwdFile))\n : cwd;\n return paramCwd ?? defaultCwd;\n}\n\nfunction getRawExecOptions(opts: ExecOptions): RawExecOptions {\n const defaultExecutionTimeout = GlobalConfig.get('executionTimeout');\n const childEnv = getChildEnv(opts);\n const cwd = getCwd(opts);\n let timeout = opts.timeout;\n timeout ??= defaultExecutionTimeout * 60 * 1000;\n\n // Set default max buffer size to 10MB\n const maxBuffer = opts.maxBuffer ?? 10 * 1024 * 1024;\n\n return {\n cwd,\n env: childEnv,\n maxBuffer,\n timeout,\n ...(opts.shell !== undefined && { shell: opts.shell }),\n stdin: 'pipe',\n stdout: opts.ignoreStdout ? 'ignore' : 'pipe',\n stderr: 'pipe',\n };\n}\n\nfunction isDocker(docker: Opt<DockerOptions>): docker is DockerOptions {\n return GlobalConfig.get('binarySource') === 'docker' && !!docker;\n}\n\ninterface RawExecArguments {\n rawCommands: (string | CommandWithOptions)[];\n rawOptions: RawExecOptions;\n}\n\nasync function prepareRawExec(\n cmd:\n | string\n | string[]\n | CommandWithOptions[]\n | (string | CommandWithOptions)[],\n opts: ExecOptions,\n sideCarImage: string,\n): Promise<RawExecArguments> {\n const { docker } = opts;\n const preCommands = opts.preCommands ?? [];\n const customEnvVariables = getCustomEnv();\n const userConfiguredEnv = getUserEnv();\n const { containerbaseDir, binarySource } = GlobalConfig.get();\n\n if (binarySource === 'docker' || binarySource === 'install') {\n logger.debug(`Setting CONTAINERBASE_CACHE_DIR to ${containerbaseDir!}`);\n opts.env ??= {};\n opts.env.CONTAINERBASE_CACHE_DIR = containerbaseDir;\n }\n\n let rawOptions = getRawExecOptions(opts);\n\n let rawCommands = typeof cmd === 'string' ? [cmd] : cmd;\n\n if (isDocker(docker)) {\n logger.debug({ image: sideCarImage }, 'Using docker to execute');\n const extraEnv = {\n ...opts.extraEnv,\n ...customEnvVariables,\n ...userConfiguredEnv,\n };\n const childEnv = getChildEnv(opts);\n const envVars = [\n ...dockerEnvVars(extraEnv, childEnv),\n ...coerceArray(docker.envVars),\n 'CONTAINERBASE_CACHE_DIR',\n ];\n const cwd = getCwd(opts);\n const dockerOptions: DockerOptions = { ...docker, cwd, envVars };\n const dockerCommand = await generateDockerCommand(\n rawCommands,\n [\n ...(await generateInstallCommands(opts.toolConstraints)),\n ...preCommands,\n ],\n dockerOptions,\n sideCarImage,\n );\n rawCommands = [dockerCommand];\n } else if (isDynamicInstall(opts.toolConstraints)) {\n logger.debug('Using containerbase dynamic installs');\n rawCommands = [\n ...(await generateInstallCommands(opts.toolConstraints)),\n ...preCommands,\n ...rawCommands,\n ];\n } else if (isHermit()) {\n const hermitEnvVars = await getHermitEnvs(rawOptions);\n logger.debug(\n { hermitEnvVars },\n 'merging hermit environment variables into the execution options',\n );\n rawOptions = {\n ...rawOptions,\n env: {\n ...rawOptions.env,\n ...hermitEnvVars,\n },\n };\n }\n\n if (\n GlobalConfig.get('binarySource') === 'global' &&\n opts.toolConstraints?.length\n ) {\n logger.once.debug(\n { toolConstraints: opts.toolConstraints },\n 'Ignoring tool contraints because of `binarySource=global`',\n );\n }\n\n return { rawCommands, rawOptions };\n}\n\nexport async function exec(\n cmd:\n | string\n | string[]\n | CommandWithOptions[]\n | (string | CommandWithOptions)[],\n opts: ExecOptions = {},\n): Promise<ExecResult> {\n const { docker } = opts;\n const dockerChildPrefix = GlobalConfig.get('dockerChildPrefix');\n const sideCarImage = GlobalConfig.get('dockerSidecarImage');\n\n const { rawCommands, rawOptions } = await prepareRawExec(\n cmd,\n opts,\n sideCarImage,\n );\n const useDocker = isDocker(docker);\n\n let res: ExecResult = { stdout: '', stderr: '' };\n for (const rawCmd of rawCommands) {\n const startTime = Date.now();\n if (useDocker) {\n await removeDockerContainer(sideCarImage, dockerChildPrefix);\n }\n logger.debug(\n { command: rawCmd, env: Object.keys(coerceObject(rawOptions.env)) },\n 'Executing command',\n );\n logger.trace({ commandOptions: rawOptions }, 'Command options');\n try {\n res = await rawExec(rawCmd, rawOptions);\n } catch (err) {\n const durationMs = Math.round(Date.now() - startTime);\n logger.debug({ err, durationMs }, 'rawExec err');\n if (useDocker) {\n await removeDockerContainer(sideCarImage, dockerChildPrefix).catch(\n (removeErr: Error) => {\n const message: string = err.message;\n throw new Error(\n `Error: \"${removeErr.message}\" - Original Error: \"${message}\"`,\n );\n },\n );\n }\n if (err.signal === `SIGTERM`) {\n logger.debug(\n { err },\n 'exec interrupted by SIGTERM - run needs to be aborted',\n );\n throw new Error(TEMPORARY_ERROR);\n }\n throw err;\n }\n const durationMs = Math.round(Date.now() - startTime);\n logger.debug(\n {\n durationMs,\n stdout: res.stdout,\n stderr: res.stderr,\n },\n 'exec completed',\n );\n }\n\n return res;\n}\n\n/**\n * When we resolve `toolSettings` in `getToolSettingsOptions`, we provide a stronger type than our input types, because we set defaults on config options.\n *\n * We do not have a default that is set for `nodeMaxMemory`, so it must remain as optional.\n */\ntype ResolvedToolSettingsOptions = Required<\n Omit<RepoToolSettingsOptions, 'nodeMaxMemory'>\n> &\n Pick<RepoToolSettingsOptions, 'nodeMaxMemory'>;\n\nexport function getToolSettingsOptions(\n repoConfig?: RepoToolSettingsOptions,\n): ResolvedToolSettingsOptions {\n let defaults = GlobalConfig.get('toolSettings');\n defaults ??= {\n jvmMaxMemory: 512,\n jvmMemory: 512,\n };\n\n const jvmMaxMemory = defaults?.jvmMaxMemory ?? 512;\n const options: ResolvedToolSettingsOptions = {\n jvmMaxMemory,\n jvmMemory: defaults?.jvmMemory ?? jvmMaxMemory,\n nodeMaxMemory: defaults?.nodeMaxMemory,\n };\n\n if (repoConfig !== undefined) {\n if (repoConfig.jvmMaxMemory) {\n if (repoConfig.jvmMaxMemory > options.jvmMaxMemory) {\n logger.once.debug(\n `A higher jvmMaxMemory (${repoConfig.jvmMaxMemory}) than the global configuration (${options.jvmMaxMemory}) is not permitted for Java VM invocations. Using global configuration instead`,\n );\n }\n\n options.jvmMaxMemory = Math.min(\n options.jvmMaxMemory,\n repoConfig.jvmMaxMemory,\n );\n }\n\n if (repoConfig.jvmMemory) {\n options.jvmMemory = repoConfig.jvmMemory;\n }\n\n if (repoConfig.nodeMaxMemory) {\n if (\n options.nodeMaxMemory &&\n repoConfig.nodeMaxMemory > options.nodeMaxMemory\n ) {\n logger.once.debug(\n `A higher nodeMaxMemory (${repoConfig.nodeMaxMemory}) than the global configuration (${options.nodeMaxMemory}) is not permitted for Node invocations. Using global configuration instead`,\n );\n } else {\n options.nodeMaxMemory = repoConfig.nodeMaxMemory;\n }\n }\n }\n\n options.jvmMaxMemory = Math.floor(options.jvmMaxMemory);\n options.jvmMemory = Math.floor(options.jvmMemory);\n if (options.nodeMaxMemory) {\n options.nodeMaxMemory = Math.floor(options.nodeMaxMemory);\n }\n\n // make sure that the starting memory can't be more than the max memory\n options.jvmMemory = Math.min(options.jvmMemory, options.jvmMaxMemory);\n\n if (options.jvmMaxMemory < 512 || options.jvmMemory < 512) {\n options.jvmMaxMemory = Math.max(options.jvmMaxMemory, 512);\n\n logger.once.debug(\n 'Overriding low memory settings for Java VM invocations to a minimum of 512M',\n );\n options.jvmMemory = Math.max(options.jvmMemory, 512);\n }\n\n return options;\n}\n\nexport function gradleJvmArg(config: RepoToolSettingsOptions): string {\n return ` -Dorg.gradle.jvmargs=\"-Xms${config.jvmMemory}m -Xmx${config.jvmMaxMemory}m\"`;\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,SAAS,cAAc,UAAoB,UAA8B;CAEvE,OADqB,OAAO,KAAK,QACf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AQ,eAEnC,OAAO,KAAK,MACV,2BAA2B,WAAW,cAAc,mCAAmC,QAAQ,cAAc,4EAC/G;OAEA,QAAQ,gBAAgB,WAAW;CAGzC;CAEA,QAAQ,eAAe,KAAK,MAAM,QAAQ,YAAY;CACtD,QAAQ,YAAY,KAAK,MAAM,QAAQ,SAAS;CAChD,IAAI,QAAQ,eACV,QAAQ,gBAAgB,KAAK,MAAM,QAAQ,aAAa;CAI1D,QAAQ,YAAY,KAAK,IAAI,QAAQ,WAAW,QAAQ,YAAY;CAEpE,IAAI,QAAQ,eAAe,OAAO,QAAQ,YAAY,KAAK;EACzD,QAAQ,eAAe,KAAK,IAAI,QAAQ,cAAc,GAAG;EAEzD,OAAO,KAAK,MACV,6EACF;EACA,QAAQ,YAAY,KAAK,IAAI,QAAQ,WAAW,GAAG;CACrD;CAEA,OAAO;AACT;AAEA,SAAgB,aAAa,QAAyC;CACpE,OAAO,8BAA8B,OAAO,UAAU,QAAQ,OAAO,aAAa;AACpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../lib/util/exec/utils.ts"],"sourcesContent":["import {\n isBoolean,\n isNonEmptyStringAndNotWhitespace,\n isString,\n} from '@sindresorhus/is';\nimport { join } from 'shlex';\nimport { getCustomEnv, getUserEnv } from '../env.ts';\nimport { getChildProcessEnv } from './env.ts';\nimport type { CommandWithOptions, ExecOptions } from './types.ts';\n\nexport function getChildEnv({\n extraEnv,\n env: forcedEnv = {},\n}: Pick<ExecOptions, 'env' | 'extraEnv'> = {}):
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../lib/util/exec/utils.ts"],"sourcesContent":["import {\n isBoolean,\n isNonEmptyStringAndNotWhitespace,\n isString,\n} from '@sindresorhus/is';\nimport { join } from 'shlex';\nimport { getCustomEnv, getUserEnv } from '../env.ts';\nimport { getChildProcessEnv } from './env.ts';\nimport type { CommandWithOptions, ExecOptions } from './types.ts';\n\nexport type ResolvedChildEnv = Record<string, string>;\n\nexport function getChildEnv({\n extraEnv,\n env: forcedEnv = {},\n}: Pick<ExecOptions, 'env' | 'extraEnv'> = {}): ResolvedChildEnv {\n const globalConfigEnv = getCustomEnv();\n const userConfiguredEnv = getUserEnv();\n\n const inheritedKeys: string[] = [];\n for (const [key, val] of Object.entries(extraEnv ?? {})) {\n if (isString(val)) {\n inheritedKeys.push(key);\n }\n }\n\n const parentEnv = getChildProcessEnv(inheritedKeys);\n const combinedEnv = {\n ...extraEnv,\n ...parentEnv,\n ...globalConfigEnv,\n ...userConfiguredEnv,\n ...forcedEnv,\n };\n\n const result: Record<string, string> = {};\n for (const [key, val] of Object.entries(combinedEnv)) {\n if (isString(val)) {\n result[key] = `${val}`;\n }\n }\n\n return result;\n}\n\nexport function isCommandWithOptions(cmd: unknown): cmd is CommandWithOptions {\n if (!(typeof cmd === 'object' && cmd !== null && 'command' in cmd)) {\n return false;\n }\n\n if (!Array.isArray(cmd.command)) {\n return false;\n }\n\n if (!cmd.command.length) {\n return false;\n }\n\n if (cmd.command.some((v) => !isString(v))) {\n return false;\n }\n\n if ('ignoreFailure' in cmd && !isBoolean(cmd.ignoreFailure)) {\n return false;\n }\n\n if (\n 'shell' in cmd &&\n !(isBoolean(cmd.shell) || isNonEmptyStringAndNotWhitespace(cmd.shell))\n ) {\n return false;\n }\n\n return true;\n}\n\nexport function asRawCommand(cmd: string | CommandWithOptions): string {\n if (isCommandWithOptions(cmd)) {\n return join(cmd.command);\n }\n\n return cmd;\n}\n\nexport function asRawCommands(\n cmds: string | (string | CommandWithOptions)[],\n): string[] {\n if (isString(cmds)) {\n return [cmds];\n }\n return cmds.map((cmd) => asRawCommand(cmd));\n}\n"],"mappings":";;;;;AAYA,SAAgB,YAAY,EAC1B,UACA,KAAK,YAAY,CAAC,MACuB,CAAC,GAAqB;CAC/D,MAAM,kBAAkB,aAAa;CACrC,MAAM,oBAAoB,WAAW;CAErC,MAAM,gBAA0B,CAAC;CACjC,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,YAAY,CAAC,CAAC,GACpD,IAAI,SAAS,GAAG,GACd,cAAc,KAAK,GAAG;CAI1B,MAAM,YAAY,mBAAmB,aAAa;CAClD,MAAM,cAAc;EAClB,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;CACL;CAEA,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,WAAW,GACjD,IAAI,SAAS,GAAG,GACd,OAAO,OAAO,GAAG;CAIrB,OAAO;AACT;AAEA,SAAgB,qBAAqB,KAAyC;CAC5E,IAAI,EAAE,OAAO,QAAQ,YAAY,QAAQ,QAAQ,aAAa,MAC5D,OAAO;CAGT,IAAI,CAAC,MAAM,QAAQ,IAAI,OAAO,GAC5B,OAAO;CAGT,IAAI,CAAC,IAAI,QAAQ,QACf,OAAO;CAGT,IAAI,IAAI,QAAQ,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,GACtC,OAAO;CAGT,IAAI,mBAAmB,OAAO,CAAC,UAAU,IAAI,aAAa,GACxD,OAAO;CAGT,IACE,WAAW,OACX,EAAE,UAAU,IAAI,KAAK,KAAK,iCAAiC,IAAI,KAAK,IAEpE,OAAO;CAGT,OAAO;AACT;AAEA,SAAgB,aAAa,KAA0C;CACrE,IAAI,qBAAqB,GAAG,GAC1B,OAAO,KAAK,IAAI,OAAO;CAGzB,OAAO;AACT"}
|
package/dist/util/git/auth.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getEnv } from "../env.js";
|
|
2
1
|
import { regEx } from "../regex.js";
|
|
3
2
|
import { logger } from "../../logger/index.js";
|
|
4
3
|
import { PLATFORM_HOST_TYPES } from "../../constants/platforms.js";
|
|
@@ -15,21 +14,20 @@ const githubApiUrls = /* @__PURE__ */ new Set([
|
|
|
15
14
|
"https://api.github.com/"
|
|
16
15
|
]);
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @returns a new
|
|
17
|
+
* Append Git authentication configuration to a resolved child environment.
|
|
18
|
+
* @returns a new environment without modifying the input
|
|
20
19
|
*/
|
|
21
|
-
function getGitAuthenticatedEnvironmentVariables(originalGitUrl, { token, username, password, hostType, matchHost }
|
|
20
|
+
function getGitAuthenticatedEnvironmentVariables(environmentVariables, originalGitUrl, { token, username, password, hostType, matchHost }) {
|
|
22
21
|
if (!token && !(username && password)) {
|
|
23
22
|
logger.warn({ host: matchHost }, `Could not create environment variable for host as neither token or username and password was set`);
|
|
24
23
|
return { ...environmentVariables };
|
|
25
24
|
}
|
|
26
|
-
const
|
|
27
|
-
const gitConfigCountEnvVariable = environmentVariables?.GIT_CONFIG_COUNT ?? env.GIT_CONFIG_COUNT;
|
|
25
|
+
const gitConfigCountEnvVariable = environmentVariables.GIT_CONFIG_COUNT;
|
|
28
26
|
let gitConfigCount = 0;
|
|
29
27
|
if (gitConfigCountEnvVariable) {
|
|
30
28
|
gitConfigCount = parseInt(gitConfigCountEnvVariable, 10);
|
|
31
29
|
if (Number.isNaN(gitConfigCount)) {
|
|
32
|
-
logger.warn({ GIT_CONFIG_COUNT:
|
|
30
|
+
logger.warn({ GIT_CONFIG_COUNT: gitConfigCountEnvVariable }, `Found GIT_CONFIG_COUNT env variable, but couldn't parse the value to an integer. Ignoring it.`);
|
|
33
31
|
gitConfigCount = 0;
|
|
34
32
|
}
|
|
35
33
|
}
|
|
@@ -91,26 +89,26 @@ function getAuthenticationRules(gitUrl, hostType, token) {
|
|
|
91
89
|
});
|
|
92
90
|
return authenticationRules;
|
|
93
91
|
}
|
|
94
|
-
function getGitEnvironmentVariables(
|
|
95
|
-
let
|
|
92
|
+
function getGitEnvironmentVariables(environmentVariables, hostTypes = []) {
|
|
93
|
+
let gitEnvironmentVariables = { ...environmentVariables };
|
|
96
94
|
const gitHubHostRule = find({
|
|
97
95
|
hostType: "github",
|
|
98
96
|
url: "https://api.github.com/"
|
|
99
97
|
});
|
|
100
|
-
if (gitHubHostRule?.token)
|
|
101
|
-
const gitAllowedHostTypes = /* @__PURE__ */ new Set([...PLATFORM_HOST_TYPES, ...
|
|
98
|
+
if (gitHubHostRule?.token) gitEnvironmentVariables = getGitAuthenticatedEnvironmentVariables(gitEnvironmentVariables, "https://github.com/", gitHubHostRule);
|
|
99
|
+
const gitAllowedHostTypes = /* @__PURE__ */ new Set([...PLATFORM_HOST_TYPES, ...hostTypes]);
|
|
102
100
|
const hostRules = getAll().filter((r) => r.matchHost && (r.token ?? (r.username && r.password))).filter((r) => !gitHubHostRule || !githubApiUrls.has(r.matchHost));
|
|
103
|
-
for (const hostRule of hostRules) if (!hostRule.hostType || gitAllowedHostTypes.has(hostRule.hostType))
|
|
104
|
-
return
|
|
101
|
+
for (const hostRule of hostRules) if (!hostRule.hostType || gitAllowedHostTypes.has(hostRule.hostType)) gitEnvironmentVariables = addAuthFromHostRule(hostRule, gitEnvironmentVariables);
|
|
102
|
+
return gitEnvironmentVariables;
|
|
105
103
|
}
|
|
106
|
-
function addAuthFromHostRule(hostRule,
|
|
107
|
-
let environmentVariables = env;
|
|
104
|
+
function addAuthFromHostRule(hostRule, environmentVariables) {
|
|
108
105
|
const httpUrl = createURLFromHostOrURL(hostRule.matchHost)?.toString();
|
|
109
106
|
if (isHttpUrl(httpUrl)) {
|
|
110
107
|
logger.trace(`Adding Git authentication for ${httpUrl} using token auth.`);
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
108
|
+
return getGitAuthenticatedEnvironmentVariables(environmentVariables, httpUrl, hostRule);
|
|
109
|
+
}
|
|
110
|
+
logger.debug(`Could not parse registryUrl ${hostRule.matchHost} or not using http(s). Ignoring`);
|
|
111
|
+
return { ...environmentVariables };
|
|
114
112
|
}
|
|
115
113
|
//#endregion
|
|
116
114
|
export { getAuthenticationRules, getGitAuthenticatedEnvironmentVariables, getGitEnvironmentVariables };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","names":[],"sources":["../../../lib/util/git/auth.ts"],"sourcesContent":["import { isEmptyString } from '@sindresorhus/is';\nimport { PLATFORM_HOST_TYPES } from '../../constants/platforms.ts';\nimport { logger } from '../../logger/index.ts';\nimport type { HostRule } from '../../types/index.ts';\nimport { detectPlatform } from '../common.ts';\nimport { getEnv } from '../env.ts';\nimport { find, getAll } from '../host-rules.ts';\nimport { regEx } from '../regex.ts';\nimport { createURLFromHostOrURL, isHttpUrl } from '../url.ts';\nimport type { AuthenticationRule } from './types.ts';\nimport { parseGitUrl } from './url.ts';\n\nconst githubApiUrls = new Set([\n 'github.com',\n 'api.github.com',\n 'https://api.github.com',\n 'https://api.github.com/',\n]);\n\n/**\n * Add authorization to a Git Url and returns a new environment variables object\n * @returns a new NodeJS.ProcessEnv object without modifying any input parameters\n */\nexport function getGitAuthenticatedEnvironmentVariables(\n originalGitUrl: string,\n { token, username, password, hostType, matchHost }: HostRule,\n environmentVariables?: NodeJS.ProcessEnv,\n): NodeJS.ProcessEnv {\n if (!token && !(username && password)) {\n logger.warn(\n { host: matchHost },\n `Could not create environment variable for host as neither token or username and password was set`,\n );\n return { ...environmentVariables };\n }\n\n const env = getEnv();\n // check if the environmentVariables already contain a GIT_CONFIG_COUNT or if the process has one\n const gitConfigCountEnvVariable =\n environmentVariables?.GIT_CONFIG_COUNT ?? env.GIT_CONFIG_COUNT;\n let gitConfigCount = 0;\n if (gitConfigCountEnvVariable) {\n // passthrough the gitConfigCountEnvVariable environment variable as start value of the index count\n gitConfigCount = parseInt(gitConfigCountEnvVariable, 10);\n if (Number.isNaN(gitConfigCount)) {\n logger.warn(\n {\n GIT_CONFIG_COUNT: env.GIT_CONFIG_COUNT,\n },\n `Found GIT_CONFIG_COUNT env variable, but couldn't parse the value to an integer. Ignoring it.`,\n );\n gitConfigCount = 0;\n }\n }\n let authenticationRules: AuthenticationRule[];\n if (token) {\n authenticationRules = getAuthenticationRulesWithToken(\n originalGitUrl,\n hostType,\n token,\n );\n } else {\n const encodedUsername = encodeURIComponent(username!);\n const encodedPassword = encodeURIComponent(password!);\n\n authenticationRules = getAuthenticationRules(\n originalGitUrl,\n hostType,\n `${encodedUsername}:${encodedPassword}`,\n );\n }\n\n // create a shallow copy of the environmentVariables as base so we don't modify the input parameter object\n // add the two new config key and value to the returnEnvironmentVariables object\n // increase the CONFIG_COUNT by one for each rule and add it to the object\n const newEnvironmentVariables = {\n ...environmentVariables,\n };\n for (const rule of authenticationRules) {\n newEnvironmentVariables[`GIT_CONFIG_KEY_${gitConfigCount}`] =\n `url.${rule.url}.insteadOf`;\n newEnvironmentVariables[`GIT_CONFIG_VALUE_${gitConfigCount}`] =\n rule.insteadOf;\n gitConfigCount++;\n }\n newEnvironmentVariables.GIT_CONFIG_COUNT = gitConfigCount.toString();\n\n return newEnvironmentVariables;\n}\n\nfunction getAuthenticationRulesWithToken(\n url: string,\n hostType: string | undefined | null,\n authToken: string,\n): AuthenticationRule[] {\n let token = authToken;\n let type = hostType;\n type ??= detectPlatform(url);\n if (type === 'gitlab') {\n token = `gitlab-ci-token:${authToken}`;\n }\n return getAuthenticationRules(url, type, token);\n}\n\n/**\n * Generates the authentication rules for later git usage for the given host\n * @link https://coolaj86.com/articles/vanilla-devops-git-credentials-cheatsheet/\n * @param gitUrl Git repository URL\n * @param hostType Git host type\n * @param token Authentication token or `username:password` string\n */\nexport function getAuthenticationRules(\n gitUrl: string,\n hostType: string | undefined | null,\n token: string,\n): AuthenticationRule[] {\n const authenticationRules = [];\n const hasUser = token.split(':').length > 1;\n const insteadUrl = parseGitUrl(gitUrl);\n let sshPort = insteadUrl.port;\n\n if (hostType === 'bitbucket-server') {\n // For Bitbucket Server/Data Center, `source` must be `bitbucket-server`\n // to generate HTTP(s) URLs correctly.\n // https://github.com/IonicaBizau/git-url-parse/blob/28828546c148d58bbcff61409915a4e1e8f7eb11/lib/index.js#L304\n insteadUrl.source = 'bitbucket-server';\n\n // sshPort is string, wrong type!\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/72361\n // https://github.com/IonicaBizau/parse-path/blob/87f71f273da90f85f6845937a70b7c032eeae4e3/lib/index.js#L45\n // v8 ignore next -- TODO: add test #40625\n if (!sshPort || isEmptyString(sshPort)) {\n // By default, bitbucket-server SSH port is 7999.\n // For non-default port, the generated auth config will likely be incorrect.\n sshPort = '7999';\n }\n }\n\n const url = { ...insteadUrl };\n const protocol = regEx(/^https?$/).test(url.protocol)\n ? url.protocol\n : 'https';\n\n // ssh protocol with user if empty\n url.token = hasUser ? token : `ssh:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n // only edge case, need to stringify ourself because the exact syntax is not supported by the library\n // https://github.com/IonicaBizau/git-url-parse/blob/246c9119fb42c2ea1c280028fe77c53eb34c190c/lib/index.js#L246\n insteadOf: `ssh://git@${insteadUrl.resource}${\n sshPort ? `:${sshPort}` : ''\n }/${insteadUrl.full_name}${insteadUrl.git_suffix ? '.git' : ''}`,\n });\n\n // alternative ssh protocol with user if empty\n url.token = hasUser ? token : `git:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: { ...insteadUrl, port: sshPort }.toString('ssh'),\n });\n\n // https protocol with no user as default fallback\n url.token = token;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: insteadUrl.toString(protocol),\n });\n\n return authenticationRules;\n}\n\nexport function getGitEnvironmentVariables(\n additionalHostTypes: string[] = [],\n): NodeJS.ProcessEnv {\n let environmentVariables: NodeJS.ProcessEnv = {};\n\n // hard-coded logic to use authentication for github.com based on the githubToken for api.github.com\n const gitHubHostRule = find({\n hostType: 'github',\n url: 'https://api.github.com/',\n });\n\n if (gitHubHostRule?.token) {\n environmentVariables = getGitAuthenticatedEnvironmentVariables(\n 'https://github.com/',\n gitHubHostRule,\n );\n }\n\n // construct the Set of allowed hostTypes consisting of the standard Git provides\n // plus additionalHostTypes, which are provided as parameter\n const gitAllowedHostTypes = new Set<string>([\n ...PLATFORM_HOST_TYPES,\n ...additionalHostTypes,\n ]);\n\n // filter rules without `matchHost` and `token` or username and password and github api github rules\n const hostRules = getAll()\n .filter((r) => r.matchHost && (r.token ?? (r.username && r.password)))\n .filter((r) => !gitHubHostRule || !githubApiUrls.has(r.matchHost!));\n\n // for each hostRule without hostType we add additional authentication variables to the environmentVariables\n // for each hostRule with hostType we add additional authentication variables to the environmentVariables\n for (const hostRule of hostRules) {\n if (!hostRule.hostType || gitAllowedHostTypes.has(hostRule.hostType)) {\n environmentVariables = addAuthFromHostRule(\n hostRule,\n environmentVariables,\n );\n }\n }\n return environmentVariables;\n}\n\nfunction addAuthFromHostRule(\n hostRule: HostRule,\n env: NodeJS.ProcessEnv,\n): NodeJS.ProcessEnv {\n let environmentVariables = env;\n const httpUrl = createURLFromHostOrURL(hostRule.matchHost!)?.toString();\n if (isHttpUrl(httpUrl)) {\n logger.trace(`Adding Git authentication for ${httpUrl} using token auth.`);\n environmentVariables = getGitAuthenticatedEnvironmentVariables(\n httpUrl!,\n hostRule,\n environmentVariables,\n );\n } else {\n logger.debug(\n `Could not parse registryUrl ${hostRule.matchHost!} or not using http(s). Ignoring`,\n );\n }\n return environmentVariables;\n}\n"],"mappings":";;;;;;;;;;AAYA,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;AACF,CAAC;;;;;AAMD,SAAgB,wCACd,gBACA,EAAE,OAAO,UAAU,UAAU,UAAU,aACvC,sBACmB;CACnB,IAAI,CAAC,SAAS,EAAE,YAAY,WAAW;EACrC,OAAO,KACL,EAAE,MAAM,UAAU,GAClB,kGACF;EACA,OAAO,EAAE,GAAG,qBAAqB;CACnC;CAEA,MAAM,MAAM,OAAO;CAEnB,MAAM,4BACJ,sBAAsB,oBAAoB,IAAI;CAChD,IAAI,iBAAiB;CACrB,IAAI,2BAA2B;EAE7B,iBAAiB,SAAS,2BAA2B,EAAE;EACvD,IAAI,OAAO,MAAM,cAAc,GAAG;GAChC,OAAO,KACL,EACE,kBAAkB,IAAI,iBACxB,GACA,+FACF;GACA,iBAAiB;EACnB;CACF;CACA,IAAI;CACJ,IA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AG;GAAY,MAAM;EAAQ,EAAE,SAAS,KAAK;CAC5D,CAAC;CAGD,IAAI,QAAQ;CACZ,oBAAoB,KAAK;EACvB,KAAK,IAAI,SAAS,QAAQ;EAC1B,WAAW,WAAW,SAAS,QAAQ;CACzC,CAAC;CAED,OAAO;AACT;AAEA,SAAgB,2BACd,sBAAgC,CAAC,GACd;CACnB,IAAI,uBAA0C,CAAC;CAG/C,MAAM,iBAAiB,KAAK;EAC1B,UAAU;EACV,KAAK;CACP,CAAC;CAED,IAAI,gBAAgB,OAClB,uBAAuB,wCACrB,uBACA,cACF;CAKF,MAAM,sCAAsB,IAAI,IAAY,CAC1C,GAAG,qBACH,GAAG,mBACL,CAAC;CAGD,MAAM,YAAY,OAAO,CAAC,CACvB,QAAQ,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CACrE,QAAQ,MAAM,CAAC,kBAAkB,CAAC,cAAc,IAAI,EAAE,SAAU,CAAC;CAIpE,KAAK,MAAM,YAAY,WACrB,IAAI,CAAC,SAAS,YAAY,oBAAoB,IAAI,SAAS,QAAQ,GACjE,uBAAuB,oBACrB,UACA,oBACF;CAGJ,OAAO;AACT;AAEA,SAAS,oBACP,UACA,KACmB;CACnB,IAAI,uBAAuB;CAC3B,MAAM,UAAU,uBAAuB,SAAS,SAAU,CAAC,EAAE,SAAS;CACtE,IAAI,UAAU,OAAO,GAAG;EACtB,OAAO,MAAM,iCAAiC,QAAQ,mBAAmB;EACzE,uBAAuB,wCACrB,SACA,UACA,oBACF;CACF,OACE,OAAO,MACL,+BAA+B,SAAS,UAAW,gCACrD;CAEF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"auth.js","names":[],"sources":["../../../lib/util/git/auth.ts"],"sourcesContent":["import { isEmptyString } from '@sindresorhus/is';\nimport { PLATFORM_HOST_TYPES } from '../../constants/platforms.ts';\nimport { logger } from '../../logger/index.ts';\nimport type { HostRule } from '../../types/index.ts';\nimport { detectPlatform } from '../common.ts';\nimport type { ResolvedChildEnv } from '../exec/utils.ts';\nimport { find, getAll } from '../host-rules.ts';\nimport { regEx } from '../regex.ts';\nimport { createURLFromHostOrURL, isHttpUrl } from '../url.ts';\nimport type { AuthenticationRule } from './types.ts';\nimport { parseGitUrl } from './url.ts';\n\nconst githubApiUrls = new Set([\n 'github.com',\n 'api.github.com',\n 'https://api.github.com',\n 'https://api.github.com/',\n]);\n\n/**\n * Append Git authentication configuration to a resolved child environment.\n * @returns a new environment without modifying the input\n */\nexport function getGitAuthenticatedEnvironmentVariables(\n environmentVariables: Readonly<ResolvedChildEnv>,\n originalGitUrl: string,\n { token, username, password, hostType, matchHost }: HostRule,\n): ResolvedChildEnv {\n if (!token && !(username && password)) {\n logger.warn(\n { host: matchHost },\n `Could not create environment variable for host as neither token or username and password was set`,\n );\n return { ...environmentVariables };\n }\n\n const gitConfigCountEnvVariable = environmentVariables.GIT_CONFIG_COUNT;\n let gitConfigCount = 0;\n if (gitConfigCountEnvVariable) {\n // passthrough the gitConfigCountEnvVariable environment variable as start value of the index count\n gitConfigCount = parseInt(gitConfigCountEnvVariable, 10);\n if (Number.isNaN(gitConfigCount)) {\n logger.warn(\n {\n GIT_CONFIG_COUNT: gitConfigCountEnvVariable,\n },\n `Found GIT_CONFIG_COUNT env variable, but couldn't parse the value to an integer. Ignoring it.`,\n );\n gitConfigCount = 0;\n }\n }\n let authenticationRules: AuthenticationRule[];\n if (token) {\n authenticationRules = getAuthenticationRulesWithToken(\n originalGitUrl,\n hostType,\n token,\n );\n } else {\n const encodedUsername = encodeURIComponent(username!);\n const encodedPassword = encodeURIComponent(password!);\n\n authenticationRules = getAuthenticationRules(\n originalGitUrl,\n hostType,\n `${encodedUsername}:${encodedPassword}`,\n );\n }\n\n // create a shallow copy of the environmentVariables as base so we don't modify the input parameter object\n // add the two new config key and value to the returnEnvironmentVariables object\n // increase the CONFIG_COUNT by one for each rule and add it to the object\n const newEnvironmentVariables = {\n ...environmentVariables,\n };\n for (const rule of authenticationRules) {\n newEnvironmentVariables[`GIT_CONFIG_KEY_${gitConfigCount}`] =\n `url.${rule.url}.insteadOf`;\n newEnvironmentVariables[`GIT_CONFIG_VALUE_${gitConfigCount}`] =\n rule.insteadOf;\n gitConfigCount++;\n }\n newEnvironmentVariables.GIT_CONFIG_COUNT = gitConfigCount.toString();\n\n return newEnvironmentVariables;\n}\n\nfunction getAuthenticationRulesWithToken(\n url: string,\n hostType: string | undefined | null,\n authToken: string,\n): AuthenticationRule[] {\n let token = authToken;\n let type = hostType;\n type ??= detectPlatform(url);\n if (type === 'gitlab') {\n token = `gitlab-ci-token:${authToken}`;\n }\n return getAuthenticationRules(url, type, token);\n}\n\n/**\n * Generates the authentication rules for later git usage for the given host\n * @link https://coolaj86.com/articles/vanilla-devops-git-credentials-cheatsheet/\n * @param gitUrl Git repository URL\n * @param hostType Git host type\n * @param token Authentication token or `username:password` string\n */\nexport function getAuthenticationRules(\n gitUrl: string,\n hostType: string | undefined | null,\n token: string,\n): AuthenticationRule[] {\n const authenticationRules = [];\n const hasUser = token.split(':').length > 1;\n const insteadUrl = parseGitUrl(gitUrl);\n let sshPort = insteadUrl.port;\n\n if (hostType === 'bitbucket-server') {\n // For Bitbucket Server/Data Center, `source` must be `bitbucket-server`\n // to generate HTTP(s) URLs correctly.\n // https://github.com/IonicaBizau/git-url-parse/blob/28828546c148d58bbcff61409915a4e1e8f7eb11/lib/index.js#L304\n insteadUrl.source = 'bitbucket-server';\n\n // sshPort is string, wrong type!\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/72361\n // https://github.com/IonicaBizau/parse-path/blob/87f71f273da90f85f6845937a70b7c032eeae4e3/lib/index.js#L45\n // v8 ignore next -- TODO: add test #40625\n if (!sshPort || isEmptyString(sshPort)) {\n // By default, bitbucket-server SSH port is 7999.\n // For non-default port, the generated auth config will likely be incorrect.\n sshPort = '7999';\n }\n }\n\n const url = { ...insteadUrl };\n const protocol = regEx(/^https?$/).test(url.protocol)\n ? url.protocol\n : 'https';\n\n // ssh protocol with user if empty\n url.token = hasUser ? token : `ssh:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n // only edge case, need to stringify ourself because the exact syntax is not supported by the library\n // https://github.com/IonicaBizau/git-url-parse/blob/246c9119fb42c2ea1c280028fe77c53eb34c190c/lib/index.js#L246\n insteadOf: `ssh://git@${insteadUrl.resource}${\n sshPort ? `:${sshPort}` : ''\n }/${insteadUrl.full_name}${insteadUrl.git_suffix ? '.git' : ''}`,\n });\n\n // alternative ssh protocol with user if empty\n url.token = hasUser ? token : `git:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: { ...insteadUrl, port: sshPort }.toString('ssh'),\n });\n\n // https protocol with no user as default fallback\n url.token = token;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: insteadUrl.toString(protocol),\n });\n\n return authenticationRules;\n}\n\nexport function getGitEnvironmentVariables(\n environmentVariables: Readonly<ResolvedChildEnv>,\n hostTypes: readonly string[] = [],\n): ResolvedChildEnv {\n let gitEnvironmentVariables: ResolvedChildEnv = { ...environmentVariables };\n\n // hard-coded logic to use authentication for github.com based on the githubToken for api.github.com\n const gitHubHostRule = find({\n hostType: 'github',\n url: 'https://api.github.com/',\n });\n\n if (gitHubHostRule?.token) {\n gitEnvironmentVariables = getGitAuthenticatedEnvironmentVariables(\n gitEnvironmentVariables,\n 'https://github.com/',\n gitHubHostRule,\n );\n }\n\n // Manager-scoped rules are opt-in so unrelated credentials are not exposed to Git.\n const gitAllowedHostTypes = new Set<string>([\n ...PLATFORM_HOST_TYPES,\n ...hostTypes,\n ]);\n\n // filter rules without `matchHost` and `token` or username and password and github api github rules\n const hostRules = getAll()\n .filter((r) => r.matchHost && (r.token ?? (r.username && r.password)))\n .filter((r) => !gitHubHostRule || !githubApiUrls.has(r.matchHost!));\n\n // for each hostRule without hostType we add additional authentication variables to the environmentVariables\n // for each hostRule with hostType we add additional authentication variables to the environmentVariables\n for (const hostRule of hostRules) {\n if (!hostRule.hostType || gitAllowedHostTypes.has(hostRule.hostType)) {\n gitEnvironmentVariables = addAuthFromHostRule(\n hostRule,\n gitEnvironmentVariables,\n );\n }\n }\n return gitEnvironmentVariables;\n}\n\nfunction addAuthFromHostRule(\n hostRule: HostRule,\n environmentVariables: Readonly<ResolvedChildEnv>,\n): ResolvedChildEnv {\n const httpUrl = createURLFromHostOrURL(hostRule.matchHost!)?.toString();\n if (isHttpUrl(httpUrl)) {\n logger.trace(`Adding Git authentication for ${httpUrl} using token auth.`);\n return getGitAuthenticatedEnvironmentVariables(\n environmentVariables,\n httpUrl!,\n hostRule,\n );\n }\n\n logger.debug(\n `Could not parse registryUrl ${hostRule.matchHost!} or not using http(s). Ignoring`,\n );\n return { ...environmentVariables };\n}\n"],"mappings":";;;;;;;;;AAYA,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;AACF,CAAC;;;;;AAMD,SAAgB,wCACd,sBACA,gBACA,EAAE,OAAO,UAAU,UAAU,UAAU,aACrB;CAClB,IAAI,CAAC,SAAS,EAAE,YAAY,WAAW;EACrC,OAAO,KACL,EAAE,MAAM,UAAU,GAClB,kGACF;EACA,OAAO,EAAE,GAAG,qBAAqB;CACnC;CAEA,MAAM,4BAA4B,qBAAqB;CACvD,IAAI,iBAAiB;CACrB,IAAI,2BAA2B;EAE7B,iBAAiB,SAAS,2BAA2B,EAAE;EACvD,IAAI,OAAO,MAAM,cAAc,GAAG;GAChC,OAAO,KACL,EACE,kBAAkB,0BACpB,GACA,+FACF;GACA,iBAAiB;EACnB;CACF;CACA,IAAI;CACJ,IAAI,OACF,sBAAsB,gCACpB,gBACA,UACA,KACF;MAKA,sBAAsB,uBACpB,gBACA,UACA,GANsB,mBAAmB,QAMxB,EAAE,GALG,mBAAmB,QAKL,GACtC;CAMF,MAAM,0BAA0B,EAC9B,GAAG,qBACL;CACA,KAAK,MAAM,QAAQ,qBAAqB;EACtC,wBAAwB,kBAAkB,oBACxC,OAAO,KAAK,IAAI;EAClB,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AE,GAAG,qBAAqB;CAG1E,MAAM,iBAAiB,KAAK;EAC1B,UAAU;EACV,KAAK;CACP,CAAC;CAED,IAAI,gBAAgB,OAClB,0BAA0B,wCACxB,yBACA,uBACA,cACF;CAIF,MAAM,sCAAsB,IAAI,IAAY,CAC1C,GAAG,qBACH,GAAG,SACL,CAAC;CAGD,MAAM,YAAY,OAAO,CAAC,CACvB,QAAQ,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CACrE,QAAQ,MAAM,CAAC,kBAAkB,CAAC,cAAc,IAAI,EAAE,SAAU,CAAC;CAIpE,KAAK,MAAM,YAAY,WACrB,IAAI,CAAC,SAAS,YAAY,oBAAoB,IAAI,SAAS,QAAQ,GACjE,0BAA0B,oBACxB,UACA,uBACF;CAGJ,OAAO;AACT;AAEA,SAAS,oBACP,UACA,sBACkB;CAClB,MAAM,UAAU,uBAAuB,SAAS,SAAU,CAAC,EAAE,SAAS;CACtE,IAAI,UAAU,OAAO,GAAG;EACtB,OAAO,MAAM,iCAAiC,QAAQ,mBAAmB;EACzE,OAAO,wCACL,sBACA,SACA,QACF;CACF;CAEA,OAAO,MACL,+BAA+B,SAAS,UAAW,gCACrD;CACA,OAAO,EAAE,GAAG,qBAAqB;AACnC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { regEx } from "../regex.js";
|
|
2
|
+
import { coerceArray, deduplicateArray } from "../array.js";
|
|
3
|
+
import { getChildEnv } from "../exec/utils.js";
|
|
4
|
+
import { getGitEnvironmentVariables } from "./auth.js";
|
|
5
|
+
import { coerceObject } from "../object.js";
|
|
6
|
+
import { exec } from "../exec/index.js";
|
|
7
|
+
//#region lib/util/git/exec.ts
|
|
8
|
+
const gitConfigEnvironmentVariableRegex = regEx(/^GIT_CONFIG_(?:COUNT|KEY_\d+|VALUE_\d+)$/);
|
|
9
|
+
function getGitExecOptions(execOptions, hostTypes) {
|
|
10
|
+
const childEnv = getChildEnv(execOptions);
|
|
11
|
+
const environmentVariables = getGitEnvironmentVariables(childEnv, hostTypes);
|
|
12
|
+
const gitConfigEnv = {};
|
|
13
|
+
for (const [key, value] of Object.entries(environmentVariables)) if (gitConfigEnvironmentVariableRegex.test(key)) gitConfigEnv[key] = value;
|
|
14
|
+
const gitConfigKeys = Object.keys(gitConfigEnv);
|
|
15
|
+
if (!gitConfigKeys.length) return { ...execOptions };
|
|
16
|
+
return {
|
|
17
|
+
...execOptions,
|
|
18
|
+
env: {
|
|
19
|
+
...execOptions.env,
|
|
20
|
+
...gitConfigEnv
|
|
21
|
+
},
|
|
22
|
+
...execOptions.docker && { docker: {
|
|
23
|
+
...execOptions.docker,
|
|
24
|
+
envVars: deduplicateArray([...coerceArray(execOptions.docker.envVars), ...gitConfigKeys])
|
|
25
|
+
} }
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function withGitEnvironment(hostTypes = []) {
|
|
29
|
+
return (command, execOptions) => exec(command, getGitExecOptions(coerceObject(execOptions), hostTypes));
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { withGitEnvironment };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","names":[],"sources":["../../../lib/util/git/exec.ts"],"sourcesContent":["import { coerceArray, deduplicateArray } from '../array.ts';\nimport { exec } from '../exec/index.ts';\nimport type { ExecOptions } from '../exec/types.ts';\nimport { getChildEnv } from '../exec/utils.ts';\nimport { coerceObject } from '../object.ts';\nimport { regEx } from '../regex.ts';\nimport { getGitEnvironmentVariables } from './auth.ts';\n\nconst gitConfigEnvironmentVariableRegex = regEx(\n /^GIT_CONFIG_(?:COUNT|KEY_\\d+|VALUE_\\d+)$/,\n);\n\nfunction getGitExecOptions(\n execOptions: ExecOptions,\n hostTypes: readonly string[],\n): ExecOptions {\n const childEnv = getChildEnv(execOptions);\n const environmentVariables = getGitEnvironmentVariables(childEnv, hostTypes);\n const gitConfigEnv: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(environmentVariables)) {\n if (gitConfigEnvironmentVariableRegex.test(key)) {\n gitConfigEnv[key] = value;\n }\n }\n\n const gitConfigKeys = Object.keys(gitConfigEnv);\n if (!gitConfigKeys.length) {\n return { ...execOptions };\n }\n\n return {\n ...execOptions,\n env: {\n ...execOptions.env,\n ...gitConfigEnv,\n },\n ...(execOptions.docker && {\n docker: {\n ...execOptions.docker,\n envVars: deduplicateArray([\n ...coerceArray(execOptions.docker.envVars),\n ...gitConfigKeys,\n ]),\n },\n }),\n };\n}\n\nexport function withGitEnvironment(\n hostTypes: readonly string[] = [],\n): typeof exec {\n return (command, execOptions) =>\n exec(command, getGitExecOptions(coerceObject(execOptions), hostTypes));\n}\n"],"mappings":";;;;;;;AAQA,MAAM,oCAAoC,MACxC,0CACF;AAEA,SAAS,kBACP,aACA,WACa;CACb,MAAM,WAAW,YAAY,WAAW;CACxC,MAAM,uBAAuB,2BAA2B,UAAU,SAAS;CAC3E,MAAM,eAAuC,CAAC;CAE9C,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,oBAAoB,GAC5D,IAAI,kCAAkC,KAAK,GAAG,GAC5C,aAAa,OAAO;CAIxB,MAAM,gBAAgB,OAAO,KAAK,YAAY;CAC9C,IAAI,CAAC,cAAc,QACjB,OAAO,EAAE,GAAG,YAAY;CAG1B,OAAO;EACL,GAAG;EACH,KAAK;GACH,GAAG,YAAY;GACf,GAAG;EACL;EACA,GAAI,YAAY,UAAU,EACxB,QAAQ;GACN,GAAG,YAAY;GACf,SAAS,iBAAiB,CACxB,GAAG,YAAY,YAAY,OAAO,OAAO,GACzC,GAAG,aACL,CAAC;EACH,EACF;CACF;AACF;AAEA,SAAgB,mBACd,YAA+B,CAAC,GACnB;CACb,QAAQ,SAAS,gBACf,KAAK,SAAS,kBAAkB,aAAa,WAAW,GAAG,SAAS,CAAC;AACzE"}
|
package/dist/util/git/index.d.ts
CHANGED
|
@@ -9,10 +9,14 @@ import { DateTime } from "luxon";
|
|
|
9
9
|
import { SimpleGit, SimpleGitOptions } from "simple-git";
|
|
10
10
|
//#region lib/util/git/index.d.ts
|
|
11
11
|
declare const RENOVATE_FORK_UPSTREAM = "renovate-fork-upstream";
|
|
12
|
-
|
|
12
|
+
interface CreateSimpleGitOptions {
|
|
13
13
|
config?: Partial<SimpleGitOptions>;
|
|
14
14
|
env?: ExtraEnv;
|
|
15
|
-
|
|
15
|
+
authentication?: {
|
|
16
|
+
hostTypes?: readonly string[];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
declare function createSimpleGit({ config, env, authentication }?: CreateSimpleGitOptions): SimpleGit;
|
|
16
20
|
declare function gitRetry<T>(gitFunc: () => Promise<T>): Promise<T>;
|
|
17
21
|
declare const GIT_MINIMUM_VERSION = "2.33.0";
|
|
18
22
|
declare function validateGitVersion(): Promise<boolean>;
|
package/dist/util/git/index.js
CHANGED
|
@@ -38,18 +38,20 @@ const retryCount = 5;
|
|
|
38
38
|
const delaySeconds = 3;
|
|
39
39
|
const delayFactor = 2;
|
|
40
40
|
const RENOVATE_FORK_UPSTREAM = "renovate-fork-upstream";
|
|
41
|
-
function createSimpleGit({ config, env } = {}) {
|
|
42
|
-
|
|
43
|
-
...simpleGitConfig(),
|
|
44
|
-
...config
|
|
45
|
-
}).env(getChildEnv({
|
|
41
|
+
function createSimpleGit({ config, env, authentication } = {}) {
|
|
42
|
+
const childEnv = getChildEnv({
|
|
46
43
|
extraEnv: { GIT_SSH_COMMAND: "ssh -o BatchMode=yes" },
|
|
47
44
|
env: {
|
|
48
45
|
...env,
|
|
49
46
|
LANG: "C.UTF-8",
|
|
50
47
|
LC_ALL: "C.UTF-8"
|
|
51
48
|
}
|
|
52
|
-
})
|
|
49
|
+
});
|
|
50
|
+
const gitEnv = authentication ? getGitEnvironmentVariables(childEnv, authentication.hostTypes) : childEnv;
|
|
51
|
+
return simpleGit({
|
|
52
|
+
...simpleGitConfig(),
|
|
53
|
+
...config
|
|
54
|
+
}).env(gitEnv);
|
|
53
55
|
}
|
|
54
56
|
async function gitRetry(gitFunc) {
|
|
55
57
|
let round = 0;
|
|
@@ -278,7 +280,7 @@ async function getSubmodules() {
|
|
|
278
280
|
async function cloneSubmodules(shouldClone, cloneSubmodulesFilter) {
|
|
279
281
|
if (!shouldClone || submodulesInitizialized) return;
|
|
280
282
|
submodulesInitizialized = true;
|
|
281
|
-
const gitEnv = getChildEnv(
|
|
283
|
+
const gitEnv = getGitEnvironmentVariables(getChildEnv());
|
|
282
284
|
await syncGit();
|
|
283
285
|
const submodules = await getSubmodules();
|
|
284
286
|
for (const submodule of submodules) {
|