renovate 44.17.3 → 44.17.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/modules/versioning/cargo/index.js +19 -1
- package/dist/modules/versioning/cargo/index.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,12 +1,13 @@
|
|
|
1
|
+
import { ExecError } from "../../../util/exec/exec-error.js";
|
|
1
2
|
import { logger } from "../../../logger/index.js";
|
|
2
3
|
import { localPathIsSymbolicLink, readLocalSymlink } from "../../../util/fs/index.js";
|
|
3
4
|
import { map } from "../../../util/promises.js";
|
|
4
|
-
import { getGitEnvironmentVariables } from "../../../util/git/auth.js";
|
|
5
|
-
import { exec } from "../../../util/exec/index.js";
|
|
6
5
|
import { getRepoStatus } from "../../../util/git/index.js";
|
|
6
|
+
import { withGitEnvironment } from "../../../util/git/exec.js";
|
|
7
7
|
import { quote } from "shlex";
|
|
8
8
|
import upath from "upath";
|
|
9
9
|
//#region lib/modules/manager/hermit/artifacts.ts
|
|
10
|
+
const gitExec = withGitEnvironment(["hermit"]);
|
|
10
11
|
/**
|
|
11
12
|
* updateArtifacts runs hermit install for each updated dependencies
|
|
12
13
|
*/
|
|
@@ -133,18 +134,18 @@ async function updateHermitPackage(update) {
|
|
|
133
134
|
}
|
|
134
135
|
const execOptions = {
|
|
135
136
|
docker: {},
|
|
136
|
-
cwdFile: update.packageFileName
|
|
137
|
-
extraEnv: getGitEnvironmentVariables(["hermit"])
|
|
137
|
+
cwdFile: update.packageFileName
|
|
138
138
|
};
|
|
139
139
|
const fromPackages = from.map(quote).join(" ");
|
|
140
140
|
if (toUninstall.length > 0) {
|
|
141
141
|
const packagesToUninstall = toUninstall.map(quote).join(" ");
|
|
142
142
|
const uninstallCommands = `./hermit uninstall ${packagesToUninstall}`;
|
|
143
143
|
try {
|
|
144
|
-
const result = await
|
|
144
|
+
const result = await gitExec(uninstallCommands, execOptions);
|
|
145
145
|
logger.trace({ stdout: result.stdout }, `hermit uninstall command stdout`);
|
|
146
146
|
} catch (e) {
|
|
147
147
|
logger.warn({ err: e }, `error uninstall hermit package for replacement`);
|
|
148
|
+
if (!(e instanceof ExecError)) throw e;
|
|
148
149
|
throw new UpdateHermitError(fromPackages, packagesToUninstall, e.stderr, e.stdout);
|
|
149
150
|
}
|
|
150
151
|
}
|
|
@@ -155,10 +156,11 @@ async function updateHermitPackage(update) {
|
|
|
155
156
|
packagesToInstall
|
|
156
157
|
}, `performing updates`);
|
|
157
158
|
try {
|
|
158
|
-
const result = await
|
|
159
|
+
const result = await gitExec(execCommands, execOptions);
|
|
159
160
|
logger.trace({ stdout: result.stdout }, `hermit command stdout`);
|
|
160
161
|
} catch (e) {
|
|
161
162
|
logger.warn({ err: e }, `error updating hermit package`);
|
|
163
|
+
if (!(e instanceof ExecError)) throw e;
|
|
162
164
|
throw new UpdateHermitError(fromPackages, packagesToInstall, e.stderr, e.stdout);
|
|
163
165
|
}
|
|
164
166
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","names":["p.map"],"sources":["../../../../lib/modules/manager/hermit/artifacts.ts"],"sourcesContent":["import { quote } from 'shlex';\nimport upath from 'upath';\nimport { logger } from '../../../logger/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n localPathIsSymbolicLink,\n readLocalSymlink,\n} from '../../../util/fs/index.ts';\nimport { getGitEnvironmentVariables } from '../../../util/git/auth.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport * as p from '../../../util/promises.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport type { ReadContentResult } from './types.ts';\n\n/**\n * updateArtifacts runs hermit install for each updated dependencies\n */\nexport async function updateArtifacts(\n update: UpdateArtifact,\n): Promise<UpdateArtifactsResult[] | null> {\n const { packageFileName } = update;\n try {\n await updateHermitPackage(update);\n } catch (err) {\n logger.debug({ err }, `error updating hermit packages.`);\n if (err instanceof UpdateHermitError) {\n return [\n {\n artifactError: {\n fileName: `from: ${err.from}, to: ${err.to}`,\n stderr: err.stderr,\n },\n },\n ];\n }\n return [\n {\n artifactError: {\n stderr: err instanceof Error ? err.message : String(err),\n },\n },\n ];\n }\n\n logger.debug(`scanning the changes after update`);\n\n let updateResult: UpdateArtifactsResult[] | null = null;\n\n try {\n updateResult = await getUpdateResult(packageFileName);\n logger.debug({ updateResult }, `update result for hermit`);\n } catch (err) {\n logger.debug({ err }, 'Error getting hermet update results');\n return [\n {\n artifactError: {\n stderr: err.message,\n },\n },\n ];\n }\n\n return updateResult;\n}\n\n/**\n * getContent returns the content of either link or a normal file\n */\nasync function getContent(file: string): Promise<ReadContentResult> {\n let contents: string | null = '';\n const isSymlink = await localPathIsSymbolicLink(file);\n\n if (isSymlink) {\n contents = await readLocalSymlink(file);\n }\n\n if (contents === null) {\n throw new Error(`error getting content for ${file}`);\n }\n\n return {\n isSymlink,\n contents,\n };\n}\n\n/**\n * getAddResult returns the UpdateArtifactsResult for the added files\n */\nfunction getAddResult(\n path: string,\n contentRes: ReadContentResult,\n): UpdateArtifactsResult {\n return {\n file: {\n type: 'addition',\n path,\n contents: contentRes.contents,\n isSymlink: contentRes.isSymlink,\n isExecutable: contentRes.isExecutable,\n },\n };\n}\n\n/**\n * getDeleteResult returns the UpdateArtifactsResult for deleted files\n */\nfunction getDeleteResult(path: string): UpdateArtifactsResult {\n return {\n file: {\n type: 'deletion',\n path,\n },\n };\n}\n\n/**\n * getUpdateResult will return the update result after `hermit install`\n * has been performed for all packages\n */\nasync function getUpdateResult(\n packageFileName: string,\n): Promise<UpdateArtifactsResult[]> {\n const hermitFolder = `${upath.dirname(packageFileName)}/`;\n const hermitChanges = await getRepoStatus(hermitFolder);\n logger.debug(\n { hermitChanges, hermitFolder },\n `hermit changes after package update`,\n );\n\n // handle added files\n const added = await p.map(\n [...hermitChanges.created, ...hermitChanges.not_added],\n async (path: string): Promise<UpdateArtifactsResult> => {\n const contents = await getContent(path);\n\n return getAddResult(path, contents);\n },\n );\n\n const deleted = hermitChanges.deleted.map(getDeleteResult);\n\n const modified = await p.map(\n hermitChanges.modified,\n async (path: string): Promise<UpdateArtifactsResult[]> => {\n const contents = await getContent(path);\n return [\n getDeleteResult(path), // delete existing link\n getAddResult(path, contents), // add a new link\n ];\n },\n );\n\n const renamed = await p.map(\n hermitChanges.renamed,\n async (renamed): Promise<UpdateArtifactsResult[]> => {\n const from = renamed.from;\n const to = renamed.to;\n const toContents = await getContent(to);\n\n return [getDeleteResult(from), getAddResult(to, toContents)];\n },\n );\n\n return [\n // rename will need to go first, because\n // it needs to create the new link for the new version\n // for the modified links to use\n ...renamed.flat(),\n ...modified.flat(),\n ...added,\n ...deleted,\n ];\n}\n\n/**\n * getHermitPackage returns the hermit package for running the hermit install\n */\nfunction getHermitPackage(name: string, version: string): string {\n return `${name}-${version}`;\n}\n\n/**\n * updateHermitPackage runs hermit install for the given package\n */\nasync function updateHermitPackage(update: UpdateArtifact): Promise<void> {\n logger.trace({ update }, `hermit.updateHermitPackage()`);\n\n const toInstall = [];\n const from = [];\n // storing the old package for replacement\n const toUninstall = [];\n\n for (const pkg of update.updatedDeps) {\n if (!pkg.depName || !pkg.currentVersion || !pkg.newValue) {\n logger.debug(\n {\n depName: pkg.depName,\n currentVersion: pkg.currentVersion,\n newValue: pkg.newValue,\n },\n 'missing package update information',\n );\n\n throw new UpdateHermitError(\n getHermitPackage(pkg.depName ?? '', pkg.currentVersion ?? ''),\n getHermitPackage(pkg.depName ?? '', pkg.newValue ?? ''),\n 'invalid package to update',\n );\n }\n\n const depName = pkg.depName;\n const newName = pkg.newName;\n const currentVersion = pkg.currentVersion;\n const newValue = pkg.newValue;\n const fromPackage = getHermitPackage(depName, currentVersion);\n // newName will be available for replacement\n const toPackage = getHermitPackage(newName ?? depName, newValue);\n toInstall.push(toPackage);\n from.push(fromPackage);\n // skips uninstall for version only replacement\n if (pkg.updateType === 'replacement' && newName !== depName) {\n toUninstall.push(depName);\n }\n }\n\n const execOptions: ExecOptions = {\n docker: {},\n cwdFile: update.packageFileName,\n extraEnv: getGitEnvironmentVariables(['hermit']),\n };\n\n const fromPackages = from.map(quote).join(' ');\n\n // when a name replacement happens, need to uninstall the old package\n if (toUninstall.length > 0) {\n const packagesToUninstall = toUninstall.map(quote).join(' ');\n const uninstallCommands = `./hermit uninstall ${packagesToUninstall}`;\n\n try {\n const result = await exec(uninstallCommands, execOptions);\n logger.trace(\n { stdout: result.stdout },\n `hermit uninstall command stdout`,\n );\n } catch (e) {\n logger.warn({ err: e }, `error uninstall hermit package for replacement`);\n throw new UpdateHermitError(\n fromPackages,\n packagesToUninstall,\n e.stderr,\n e.stdout,\n );\n }\n }\n\n const packagesToInstall = toInstall.map(quote).join(' ');\n\n const execCommands = `./hermit install ${packagesToInstall}`;\n logger.debug(\n {\n packageFile: update.packageFileName,\n packagesToInstall,\n },\n `performing updates`,\n );\n\n try {\n const result = await exec(execCommands, execOptions);\n logger.trace({ stdout: result.stdout }, `hermit command stdout`);\n } catch (e) {\n logger.warn({ err: e }, `error updating hermit package`);\n throw new UpdateHermitError(\n fromPackages,\n packagesToInstall,\n e.stderr,\n e.stdout,\n );\n }\n}\n\nexport class UpdateHermitError extends Error {\n stdout: string;\n stderr: string;\n from: string;\n to: string;\n\n constructor(from: string, to: string, stderr: string, stdout = '') {\n super();\n this.stdout = stdout;\n this.stderr = stderr;\n this.from = from;\n this.to = to;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,eAAsB,gBACpB,QACyC;CACzC,MAAM,EAAE,oBAAoB;CAC5B,IAAI;EACF,MAAM,oBAAoB,MAAM;CAClC,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,iCAAiC;EACvD,IAAI,eAAe,mBACjB,OAAO,CACL,EACE,eAAe;GACb,UAAU,SAAS,IAAI,KAAK,QAAQ,IAAI;GACxC,QAAQ,IAAI;EACd,EACF,CACF;EAEF,OAAO,CACL,EACE,eAAe,EACb,QAAQ,eAAe,QAAQ,IAAI,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A,MAAM,cAA2B;EAC/B,QAAQ,CAAC;EACT,SAAS,OAAO;EAChB,UAAU,2BAA2B,CAAC,QAAQ,CAAC;CACjD;CAEA,MAAM,eAAe,KAAK,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG;CAG7C,IAAI,YAAY,SAAS,GAAG;EAC1B,MAAM,sBAAsB,YAAY,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG;EAC3D,MAAM,oBAAoB,sBAAsB;EAEhD,IAAI;GACF,MAAM,SAAS,MAAM,KAAK,mBAAmB,WAAW;GACxD,OAAO,MACL,EAAE,QAAQ,OAAO,OAAO,GACxB,iCACF;EACF,SAAS,GAAG;GACV,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,gDAAgD;GACxE,MAAM,IAAI,kBACR,cACA,qBACA,EAAE,QACF,EAAE,MACJ;EACF;CACF;CAEA,MAAM,oBAAoB,UAAU,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG;CAEvD,MAAM,eAAe,oBAAoB;CACzC,OAAO,MACL;EACE,aAAa,OAAO;EACpB;CACF,GACA,oBACF;CAEA,IAAI;EACF,MAAM,SAAS,MAAM,KAAK,cAAc,WAAW;EACnD,OAAO,MAAM,EAAE,QAAQ,OAAO,OAAO,GAAG,uBAAuB;CACjE,SAAS,GAAG;EACV,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,+BAA+B;EACvD,MAAM,IAAI,kBACR,cACA,mBACA,EAAE,QACF,EAAE,MACJ;CACF;AACF;AAEA,IAAa,oBAAb,cAAuC,MAAM;CAC3C;CACA;CACA;CACA;CAEA,YAAY,MAAc,IAAY,QAAgB,SAAS,IAAI;EACjE,MAAM;EACN,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,OAAO;EACZ,KAAK,KAAK;CACZ;AACF"}
|
|
1
|
+
{"version":3,"file":"artifacts.js","names":["p.map"],"sources":["../../../../lib/modules/manager/hermit/artifacts.ts"],"sourcesContent":["import { quote } from 'shlex';\nimport upath from 'upath';\nimport { logger } from '../../../logger/index.ts';\nimport { ExecError } from '../../../util/exec/exec-error.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n localPathIsSymbolicLink,\n readLocalSymlink,\n} from '../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../util/git/exec.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport * as p from '../../../util/promises.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport type { ReadContentResult } from './types.ts';\n\nconst gitExec = withGitEnvironment(['hermit']);\n\n/**\n * updateArtifacts runs hermit install for each updated dependencies\n */\nexport async function updateArtifacts(\n update: UpdateArtifact,\n): Promise<UpdateArtifactsResult[] | null> {\n const { packageFileName } = update;\n try {\n await updateHermitPackage(update);\n } catch (err) {\n logger.debug({ err }, `error updating hermit packages.`);\n if (err instanceof UpdateHermitError) {\n return [\n {\n artifactError: {\n fileName: `from: ${err.from}, to: ${err.to}`,\n stderr: err.stderr,\n },\n },\n ];\n }\n return [\n {\n artifactError: {\n stderr: err instanceof Error ? err.message : String(err),\n },\n },\n ];\n }\n\n logger.debug(`scanning the changes after update`);\n\n let updateResult: UpdateArtifactsResult[] | null = null;\n\n try {\n updateResult = await getUpdateResult(packageFileName);\n logger.debug({ updateResult }, `update result for hermit`);\n } catch (err) {\n logger.debug({ err }, 'Error getting hermet update results');\n return [\n {\n artifactError: {\n stderr: err.message,\n },\n },\n ];\n }\n\n return updateResult;\n}\n\n/**\n * getContent returns the content of either link or a normal file\n */\nasync function getContent(file: string): Promise<ReadContentResult> {\n let contents: string | null = '';\n const isSymlink = await localPathIsSymbolicLink(file);\n\n if (isSymlink) {\n contents = await readLocalSymlink(file);\n }\n\n if (contents === null) {\n throw new Error(`error getting content for ${file}`);\n }\n\n return {\n isSymlink,\n contents,\n };\n}\n\n/**\n * getAddResult returns the UpdateArtifactsResult for the added files\n */\nfunction getAddResult(\n path: string,\n contentRes: ReadContentResult,\n): UpdateArtifactsResult {\n return {\n file: {\n type: 'addition',\n path,\n contents: contentRes.contents,\n isSymlink: contentRes.isSymlink,\n isExecutable: contentRes.isExecutable,\n },\n };\n}\n\n/**\n * getDeleteResult returns the UpdateArtifactsResult for deleted files\n */\nfunction getDeleteResult(path: string): UpdateArtifactsResult {\n return {\n file: {\n type: 'deletion',\n path,\n },\n };\n}\n\n/**\n * getUpdateResult will return the update result after `hermit install`\n * has been performed for all packages\n */\nasync function getUpdateResult(\n packageFileName: string,\n): Promise<UpdateArtifactsResult[]> {\n const hermitFolder = `${upath.dirname(packageFileName)}/`;\n const hermitChanges = await getRepoStatus(hermitFolder);\n logger.debug(\n { hermitChanges, hermitFolder },\n `hermit changes after package update`,\n );\n\n // handle added files\n const added = await p.map(\n [...hermitChanges.created, ...hermitChanges.not_added],\n async (path: string): Promise<UpdateArtifactsResult> => {\n const contents = await getContent(path);\n\n return getAddResult(path, contents);\n },\n );\n\n const deleted = hermitChanges.deleted.map(getDeleteResult);\n\n const modified = await p.map(\n hermitChanges.modified,\n async (path: string): Promise<UpdateArtifactsResult[]> => {\n const contents = await getContent(path);\n return [\n getDeleteResult(path), // delete existing link\n getAddResult(path, contents), // add a new link\n ];\n },\n );\n\n const renamed = await p.map(\n hermitChanges.renamed,\n async (renamed): Promise<UpdateArtifactsResult[]> => {\n const from = renamed.from;\n const to = renamed.to;\n const toContents = await getContent(to);\n\n return [getDeleteResult(from), getAddResult(to, toContents)];\n },\n );\n\n return [\n // rename will need to go first, because\n // it needs to create the new link for the new version\n // for the modified links to use\n ...renamed.flat(),\n ...modified.flat(),\n ...added,\n ...deleted,\n ];\n}\n\n/**\n * getHermitPackage returns the hermit package for running the hermit install\n */\nfunction getHermitPackage(name: string, version: string): string {\n return `${name}-${version}`;\n}\n\n/**\n * updateHermitPackage runs hermit install for the given package\n */\nasync function updateHermitPackage(update: UpdateArtifact): Promise<void> {\n logger.trace({ update }, `hermit.updateHermitPackage()`);\n\n const toInstall = [];\n const from = [];\n // storing the old package for replacement\n const toUninstall = [];\n\n for (const pkg of update.updatedDeps) {\n if (!pkg.depName || !pkg.currentVersion || !pkg.newValue) {\n logger.debug(\n {\n depName: pkg.depName,\n currentVersion: pkg.currentVersion,\n newValue: pkg.newValue,\n },\n 'missing package update information',\n );\n\n throw new UpdateHermitError(\n getHermitPackage(pkg.depName ?? '', pkg.currentVersion ?? ''),\n getHermitPackage(pkg.depName ?? '', pkg.newValue ?? ''),\n 'invalid package to update',\n );\n }\n\n const depName = pkg.depName;\n const newName = pkg.newName;\n const currentVersion = pkg.currentVersion;\n const newValue = pkg.newValue;\n const fromPackage = getHermitPackage(depName, currentVersion);\n // newName will be available for replacement\n const toPackage = getHermitPackage(newName ?? depName, newValue);\n toInstall.push(toPackage);\n from.push(fromPackage);\n // skips uninstall for version only replacement\n if (pkg.updateType === 'replacement' && newName !== depName) {\n toUninstall.push(depName);\n }\n }\n\n const execOptions: ExecOptions = {\n docker: {},\n cwdFile: update.packageFileName,\n };\n\n const fromPackages = from.map(quote).join(' ');\n\n // when a name replacement happens, need to uninstall the old package\n if (toUninstall.length > 0) {\n const packagesToUninstall = toUninstall.map(quote).join(' ');\n const uninstallCommands = `./hermit uninstall ${packagesToUninstall}`;\n\n try {\n const result = await gitExec(uninstallCommands, execOptions);\n logger.trace(\n { stdout: result.stdout },\n `hermit uninstall command stdout`,\n );\n } catch (e) {\n logger.warn({ err: e }, `error uninstall hermit package for replacement`);\n if (!(e instanceof ExecError)) {\n throw e;\n }\n throw new UpdateHermitError(\n fromPackages,\n packagesToUninstall,\n e.stderr,\n e.stdout,\n );\n }\n }\n\n const packagesToInstall = toInstall.map(quote).join(' ');\n\n const execCommands = `./hermit install ${packagesToInstall}`;\n logger.debug(\n {\n packageFile: update.packageFileName,\n packagesToInstall,\n },\n `performing updates`,\n );\n\n try {\n const result = await gitExec(execCommands, execOptions);\n logger.trace({ stdout: result.stdout }, `hermit command stdout`);\n } catch (e) {\n logger.warn({ err: e }, `error updating hermit package`);\n if (!(e instanceof ExecError)) {\n throw e;\n }\n throw new UpdateHermitError(\n fromPackages,\n packagesToInstall,\n e.stderr,\n e.stdout,\n );\n }\n}\n\nexport class UpdateHermitError extends Error {\n stdout: string;\n stderr: string;\n from: string;\n to: string;\n\n constructor(from: string, to: string, stderr: string, stdout = '') {\n super();\n this.stdout = stdout;\n this.stderr = stderr;\n this.from = from;\n this.to = to;\n }\n}\n"],"mappings":";;;;;;;;;AAeA,MAAM,UAAU,mBAAmB,CAAC,QAAQ,CAAC;;;;AAK7C,eAAsB,gBACpB,QACyC;CACzC,MAAM,EAAE,oBAAoB;CAC5B,IAAI;EACF,MAAM,oBAAoB,MAAM;CAClC,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,iCAAiC;EACvD,IAAI,eAAe,mBACjB,OAAO,CACL,EACE,eAAe;GACb,UAAU,SAAS,IAAI,KAAK,QAAQ,IAAI;GACxC,QAAQ,IAAI;EACd,EACF,CACF;EAEF,OAAO,CACL,EACE,eAAe,EACb,QAAQ,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,EACzD,EACF,CACF;CACF;CAEA,OAAO,MAAM,mCAAmC;CAEhD,IAAI,eAA+C;CAEnD,IAAI;EACF,eAAe,MAAM,gBAAgB,eAAe;EACpD,OAAO,MAAM,EAAE,aAAa,GAAG,0BAA0B;CAC3D,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,qCAAqC;EAC3D,OAAO,CACL,EACE,eAAe,EACb,QAAQ,IAAI,QACd,EACF,CACF;CACF;CAEA,OAAO;AACT;;;;AAKA,eAAe,WAAW,MAA0C;CAClE,IAAI,WAA0B;CAC9B,MAAM,YAAY,MAAM,wBAAwB,IAAI;CAEpD,IAAI,WACF,WAAW,MAAM,iBAAiB,IAAI;CAGxC,IAAI,aAAa,MACf,MAAM,IAAI,MAAM,6BAA6B,MAAM;CAGrD,OAAO;EACL;EACA;CACF;AACF;;;;AAKA,SAAS,aACP,MACA,YACuB;CACvB,OAAO,EACL,MAAM;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AAM,eAAe,oBAAoB;CACzC,OAAO,MACL;EACE,aAAa,OAAO;EACpB;CACF,GACA,oBACF;CAEA,IAAI;EACF,MAAM,SAAS,MAAM,QAAQ,cAAc,WAAW;EACtD,OAAO,MAAM,EAAE,QAAQ,OAAO,OAAO,GAAG,uBAAuB;CACjE,SAAS,GAAG;EACV,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,+BAA+B;EACvD,IAAI,EAAE,aAAa,YACjB,MAAM;EAER,MAAM,IAAI,kBACR,cACA,mBACA,EAAE,QACF,EAAE,MACJ;CACF;AACF;AAEA,IAAa,oBAAb,cAAuC,MAAM;CAC3C;CACA;CACA;CACA;CAEA,YAAY,MAAc,IAAY,QAAgB,SAAS,IAAI;EACjE,MAAM;EACN,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,OAAO;EACZ,KAAK,KAAK;CACZ;AACF"}
|
|
@@ -2,15 +2,15 @@ import "../../../../constants/error-messages.js";
|
|
|
2
2
|
import { logger } from "../../../../logger/index.js";
|
|
3
3
|
import { getSiblingFileName, readLocalFile } from "../../../../util/fs/index.js";
|
|
4
4
|
import { Result } from "../../../../util/result.js";
|
|
5
|
-
import { getGitEnvironmentVariables } from "../../../../util/git/auth.js";
|
|
6
|
-
import { exec } from "../../../../util/exec/index.js";
|
|
7
5
|
import { PypiDatasource } from "../../../datasource/pypi/index.js";
|
|
6
|
+
import { withGitEnvironment } from "../../../../util/git/exec.js";
|
|
8
7
|
import { BasePyProjectProcessor } from "./abstract.js";
|
|
9
8
|
import { depTypes } from "../utils.js";
|
|
10
9
|
import { PdmLockfile } from "../schema.js";
|
|
11
10
|
import { quote } from "shlex";
|
|
12
11
|
//#region lib/modules/manager/pep621/processors/pdm.ts
|
|
13
12
|
const pdmUpdateCMD = "pdm update --no-sync --update-eager";
|
|
13
|
+
const gitExec = withGitEnvironment(["pep621"]);
|
|
14
14
|
var PdmProcessor = class extends BasePyProjectProcessor {
|
|
15
15
|
lockfileName = "pdm.lock";
|
|
16
16
|
process(project, deps) {
|
|
@@ -45,24 +45,21 @@ var PdmProcessor = class extends BasePyProjectProcessor {
|
|
|
45
45
|
logger.debug("No pdm.lock found");
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
|
-
const pythonConstraint = {
|
|
49
|
-
toolName: "python",
|
|
50
|
-
constraint: config.constraints?.python ?? project.project?.["requires-python"]
|
|
51
|
-
};
|
|
52
|
-
const pdmConstraint = {
|
|
53
|
-
toolName: "pdm",
|
|
54
|
-
constraint: config.constraints?.pdm
|
|
55
|
-
};
|
|
56
48
|
const execOptions = {
|
|
57
49
|
cwdFile: packageFileName,
|
|
58
|
-
extraEnv: { ...getGitEnvironmentVariables(["pep621"]) },
|
|
59
50
|
docker: {},
|
|
60
|
-
toolConstraints: [
|
|
51
|
+
toolConstraints: [{
|
|
52
|
+
toolName: "python",
|
|
53
|
+
constraint: config.constraints?.python ?? project.project?.["requires-python"]
|
|
54
|
+
}, {
|
|
55
|
+
toolName: "pdm",
|
|
56
|
+
constraint: config.constraints?.pdm
|
|
57
|
+
}]
|
|
61
58
|
};
|
|
62
59
|
const cmds = [];
|
|
63
60
|
if (isLockFileMaintenance) cmds.push(pdmUpdateCMD);
|
|
64
61
|
else cmds.push(...generateCMDs(updatedDeps));
|
|
65
|
-
await
|
|
62
|
+
await gitExec(cmds, execOptions);
|
|
66
63
|
const fileChanges = [];
|
|
67
64
|
const newLockContent = await readLocalFile(lockFileName, "utf8");
|
|
68
65
|
if (existingLockFileContent !== newLockContent) fileChanges.push({ file: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdm.js","names":[],"sources":["../../../../../lib/modules/manager/pep621/processors/pdm.ts"],"sourcesContent":["import { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../../constants/error-messages.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport
|
|
1
|
+
{"version":3,"file":"pdm.js","names":[],"sources":["../../../../../lib/modules/manager/pep621/processors/pdm.ts"],"sourcesContent":["import { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../../constants/error-messages.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport type {\n ExecOptions,\n ToolConstraint,\n} from '../../../../util/exec/types.ts';\nimport {\n getSiblingFileName,\n readLocalFile,\n} from '../../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../../util/git/exec.ts';\nimport { Result } from '../../../../util/result.ts';\nimport { PypiDatasource } from '../../../datasource/pypi/index.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsResult,\n Upgrade,\n} from '../../types.ts';\nimport { PdmLockfile, type PyProject } from '../schema.ts';\nimport type { Pep621ManagerData } from '../types.ts';\nimport { depTypes } from '../utils.ts';\nimport { BasePyProjectProcessor } from './abstract.ts';\n\nconst pdmUpdateCMD = 'pdm update --no-sync --update-eager';\nconst gitExec = withGitEnvironment(['pep621']);\n\nexport class PdmProcessor extends BasePyProjectProcessor {\n override lockfileName = 'pdm.lock';\n\n process(\n project: PyProject,\n deps: PackageDependency[],\n ): PackageDependency<Pep621ManagerData>[] {\n const devDependencies = project.tool?.pdm?.devDependencies;\n if (devDependencies) {\n deps.push(...devDependencies);\n }\n\n const registryUrls = project.tool?.pdm?.registryUrls;\n if (registryUrls) {\n for (const dep of deps) {\n if (dep.datasource === PypiDatasource.id) {\n dep.registryUrls = registryUrls;\n }\n }\n }\n\n return deps;\n }\n\n async extractLockedVersions(\n project: PyProject,\n deps: PackageDependency[],\n packageFile: string,\n ): Promise<PackageDependency[]> {\n if (\n !project.tool?.pdm &&\n project['build-system']?.['build-backend'] !== 'pdm.backend'\n ) {\n return Promise.resolve(deps);\n }\n\n const lockFileName = getSiblingFileName(packageFile, 'pdm.lock');\n const lockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (lockFileContent) {\n const lockFileMapping = Result.parse(\n lockFileContent,\n PdmLockfile.transform(({ lock }) => lock),\n ).unwrapOr({});\n\n for (const dep of deps) {\n const packageName = dep.packageName;\n if (packageName && packageName in lockFileMapping) {\n dep.lockedVersion = lockFileMapping[packageName];\n }\n }\n }\n\n return Promise.resolve(deps);\n }\n\n async updateArtifacts(\n updateArtifact: UpdateArtifact,\n project: PyProject,\n ): Promise<UpdateArtifactsResult[] | null> {\n const { config, updatedDeps, packageFileName } = updateArtifact;\n\n const { isLockFileMaintenance } = config;\n\n // abort if no lockfile is defined\n const lockFileName = getSiblingFileName(packageFileName, this.lockfileName);\n try {\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.debug('No pdm.lock found');\n return null;\n }\n\n const pythonConstraint: ToolConstraint = {\n toolName: 'python',\n constraint:\n config.constraints?.python ?? project.project?.['requires-python'],\n };\n const pdmConstraint: ToolConstraint = {\n toolName: 'pdm',\n constraint: config.constraints?.pdm,\n };\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n docker: {},\n toolConstraints: [pythonConstraint, pdmConstraint],\n };\n\n // on lockFileMaintenance do not specify any packages and update the complete lock file\n // else only update specific packages\n const cmds: string[] = [];\n if (isLockFileMaintenance) {\n cmds.push(pdmUpdateCMD);\n } else {\n cmds.push(...generateCMDs(updatedDeps));\n }\n await gitExec(cmds, execOptions);\n\n // check for changes\n const fileChanges: UpdateArtifactsResult[] = [];\n const newLockContent = await readLocalFile(lockFileName, 'utf8');\n const isLockFileChanged = existingLockFileContent !== newLockContent;\n if (isLockFileChanged) {\n fileChanges.push({\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newLockContent,\n },\n });\n } else {\n logger.debug('pdm.lock is unchanged');\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 PDM lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n }\n}\n\nfunction generateCMDs(updatedDeps: Upgrade<Pep621ManagerData>[]): string[] {\n const cmds: string[] = [];\n const packagesByCMD: Record<string, string[]> = {};\n for (const dep of updatedDeps) {\n switch (dep.depType) {\n case depTypes.optionalDependencies: {\n if (!dep.managerData?.depGroup) {\n logger.once.warn(\n { dep: dep.depName },\n 'Unexpected optional dependency without group',\n );\n continue;\n }\n addPackageToCMDRecord(\n packagesByCMD,\n `${pdmUpdateCMD} -G ${quote(dep.managerData.depGroup)}`,\n dep.packageName!,\n );\n break;\n }\n case depTypes.dependencyGroups:\n case depTypes.pdmDevDependencies: {\n if (!dep.managerData?.depGroup) {\n logger.once.warn(\n { dep: dep.depName },\n 'Unexpected dev dependency without group',\n );\n continue;\n }\n addPackageToCMDRecord(\n packagesByCMD,\n `${pdmUpdateCMD} -dG ${quote(dep.managerData.depGroup)}`,\n dep.packageName!,\n );\n break;\n }\n case depTypes.buildSystemRequires:\n // build requirements are not locked in the lock files, no need to update.\n // Reference: https://github.com/pdm-project/pdm/discussions/2869\n break;\n default: {\n addPackageToCMDRecord(packagesByCMD, pdmUpdateCMD, dep.packageName!);\n }\n }\n }\n\n for (const commandPrefix in packagesByCMD) {\n const packageList = packagesByCMD[commandPrefix].map(quote).join(' ');\n const cmd = `${commandPrefix} ${packageList}`;\n cmds.push(cmd);\n }\n\n return cmds;\n}\n\nfunction addPackageToCMDRecord(\n packagesByCMD: Record<string, string[]>,\n commandPrefix: string,\n packageName: string,\n): void {\n if (!packagesByCMD[commandPrefix]) {\n packagesByCMD[commandPrefix] = [];\n }\n packagesByCMD[commandPrefix].push(packageName);\n}\n"],"mappings":";;;;;;;;;;;AAyBA,MAAM,eAAe;AACrB,MAAM,UAAU,mBAAmB,CAAC,QAAQ,CAAC;AAE7C,IAAa,eAAb,cAAkC,uBAAuB;CACvD,eAAwB;CAExB,QACE,SACA,MACwC;EACxC,MAAM,kBAAkB,QAAQ,MAAM,KAAK;EAC3C,IAAI,iBACF,KAAK,KAAK,GAAG,eAAe;EAG9B,MAAM,eAAe,QAAQ,MAAM,KAAK;EACxC,IAAI,cACG;QAAA,MAAM,OAAO,MAChB,IAAI,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AAC;CAElC,cAAc,cAAc,CAAC,KAAK,WAAW;AAC/C"}
|
|
@@ -5,10 +5,9 @@ import { find } from "../../../../util/host-rules.js";
|
|
|
5
5
|
import { findLocalSiblingOrParent, readLocalFile } from "../../../../util/fs/index.js";
|
|
6
6
|
import { Result } from "../../../../util/result.js";
|
|
7
7
|
import { getGoogleAuthHostRule } from "../../../datasource/util.js";
|
|
8
|
-
import { getGitEnvironmentVariables } from "../../../../util/git/auth.js";
|
|
9
|
-
import { exec } from "../../../../util/exec/index.js";
|
|
10
8
|
import { PypiDatasource } from "../../../datasource/pypi/index.js";
|
|
11
9
|
import { applyGitSource } from "../../util.js";
|
|
10
|
+
import { withGitEnvironment } from "../../../../util/git/exec.js";
|
|
12
11
|
import { BasePyProjectProcessor } from "./abstract.js";
|
|
13
12
|
import { depTypes } from "../utils.js";
|
|
14
13
|
import { UvLockfile } from "../schema.js";
|
|
@@ -16,6 +15,7 @@ import { isString } from "@sindresorhus/is";
|
|
|
16
15
|
import { quote } from "shlex";
|
|
17
16
|
//#region lib/modules/manager/pep621/processors/uv.ts
|
|
18
17
|
const uvUpdateCMD = "uv lock";
|
|
18
|
+
const gitExec = withGitEnvironment(["pep621"]);
|
|
19
19
|
var UvProcessor = class extends BasePyProjectProcessor {
|
|
20
20
|
lockfileName = "uv.lock";
|
|
21
21
|
process(project, deps) {
|
|
@@ -95,7 +95,6 @@ var UvProcessor = class extends BasePyProjectProcessor {
|
|
|
95
95
|
const execOptions = {
|
|
96
96
|
cwdFile: packageFileName,
|
|
97
97
|
extraEnv: {
|
|
98
|
-
...getGitEnvironmentVariables(["pep621"]),
|
|
99
98
|
...await getUvExtraIndexUrl(project, updateArtifact.updatedDeps),
|
|
100
99
|
...await getUvIndexCredentials(project)
|
|
101
100
|
},
|
|
@@ -105,7 +104,7 @@ var UvProcessor = class extends BasePyProjectProcessor {
|
|
|
105
104
|
let cmd;
|
|
106
105
|
if (isLockFileMaintenance) cmd = `${uvUpdateCMD} --upgrade`;
|
|
107
106
|
else cmd = generateCMD(updatedDeps);
|
|
108
|
-
await
|
|
107
|
+
await gitExec(cmd, execOptions);
|
|
109
108
|
const fileChanges = [];
|
|
110
109
|
const newLockContent = await readLocalFile(lockFileName, "utf8");
|
|
111
110
|
if (existingLockFileContent !== newLockContent) fileChanges.push({ file: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uv.js","names":[],"sources":["../../../../../lib/modules/manager/pep621/processors/uv.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../../constants/error-messages.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport type { HostRule } from '../../../../types/index.ts';\nimport { exec } from '../../../../util/exec/index.ts';\nimport type {\n ExecOptions,\n ToolConstraint,\n} from '../../../../util/exec/types.ts';\nimport {\n findLocalSiblingOrParent,\n readLocalFile,\n} from '../../../../util/fs/index.ts';\nimport { getGitEnvironmentVariables } from '../../../../util/git/auth.ts';\nimport { find } from '../../../../util/host-rules.ts';\nimport { Result } from '../../../../util/result.ts';\nimport { parseUrl } from '../../../../util/url.ts';\nimport { PypiDatasource } from '../../../datasource/pypi/index.ts';\nimport { getGoogleAuthHostRule } from '../../../datasource/util.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsResult,\n Upgrade,\n} from '../../types.ts';\nimport { applyGitSource } from '../../util.ts';\nimport { type PyProject, UvLockfile } from '../schema.ts';\nimport { depTypes } from '../utils.ts';\n\nimport { BasePyProjectProcessor } from './abstract.ts';\n\nconst uvUpdateCMD = 'uv lock';\n\nexport class UvProcessor extends BasePyProjectProcessor {\n override lockfileName = 'uv.lock';\n\n process(project: PyProject, deps: PackageDependency[]): PackageDependency[] {\n const uv = project.tool?.uv;\n if (!uv) {\n return deps;\n }\n\n const hasExplicitDefault = uv.index?.some(\n (index) => index.default && index.explicit,\n );\n const defaultIndex = uv.index?.find(\n (index) => index.default && !index.explicit,\n );\n const implicitIndexUrls = uv.index\n ?.filter((index) => !index.explicit && index.name !== defaultIndex?.name)\n ?.map(({ url }) => url);\n\n const devDependencies = uv['dev-dependencies'];\n if (devDependencies) {\n deps.push(...devDependencies);\n }\n\n // https://docs.astral.sh/uv/concepts/dependencies/#dependency-sources\n // Skip sources that do not make sense to handle (e.g. path).\n if (uv.sources || defaultIndex || implicitIndexUrls) {\n for (const dep of deps) {\n /* v8 ignore next 3 -- needs test */\n if (!dep.packageName) {\n continue;\n }\n\n if (dep.depType === 'requires-python') {\n continue;\n }\n\n // Using `packageName` as it applies PEP 508 normalization, which is\n // also applied by uv when matching a source to a dependency.\n const depSource = uv.sources?.[dep.packageName];\n if (depSource) {\n // Dependency is pinned to a specific source.\n dep.depType = depTypes.uvSources;\n if ('index' in depSource) {\n const index = uv.index?.find(\n ({ name }) => name === depSource.index,\n );\n if (index) {\n dep.registryUrls = [index.url];\n }\n } else if ('git' in depSource) {\n applyGitSource(\n dep,\n depSource.git,\n depSource.rev,\n depSource.tag,\n depSource.branch,\n );\n } else if ('url' in depSource) {\n dep.skipReason = 'unsupported-url';\n } else if ('path' in depSource) {\n dep.skipReason = 'path-dependency';\n } else if ('workspace' in depSource) {\n dep.skipReason = 'inherited-dependency';\n } else {\n /* v8 ignore next -- unreachable through schema */\n dep.skipReason = 'unknown-registry';\n }\n } else {\n // Dependency is not pinned to a specific source, so we need to\n // determine the source based on the index configuration.\n if (hasExplicitDefault) {\n // don't fall back to pypi if there is an explicit default index\n dep.registryUrls = [];\n } else if (defaultIndex) {\n // There is a default index configured, so use it.\n dep.registryUrls = [defaultIndex.url];\n }\n\n if (implicitIndexUrls?.length) {\n // If there are implicit indexes, check them first and fall back\n // to the default.\n dep.registryUrls = implicitIndexUrls.concat(\n dep.registryUrls ?? PypiDatasource.defaultURL,\n );\n }\n }\n }\n }\n\n return deps;\n }\n\n async extractLockedVersions(\n project: PyProject,\n deps: PackageDependency[],\n packageFile: string,\n ): Promise<PackageDependency[]> {\n const lockFileName = await findLocalSiblingOrParent(\n packageFile,\n this.lockfileName,\n );\n if (lockFileName === null) {\n logger.debug({ packageFile }, `No uv lock file found`);\n } else {\n const lockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (lockFileContent) {\n const { val: lockFileMapping, err } = Result.parse(\n lockFileContent,\n UvLockfile,\n ).unwrap();\n\n if (err) {\n logger.debug({ packageFile, err }, `Error parsing uv lock file`);\n } else {\n for (const dep of deps) {\n const packageName = dep.packageName;\n if (packageName && packageName in lockFileMapping) {\n dep.lockedVersion = lockFileMapping[packageName];\n }\n }\n }\n }\n }\n\n return Promise.resolve(deps);\n }\n\n async updateArtifacts(\n updateArtifact: UpdateArtifact,\n project: PyProject,\n ): Promise<UpdateArtifactsResult[] | null> {\n const { config, updatedDeps, packageFileName } = updateArtifact;\n\n const { isLockFileMaintenance } = config;\n\n // abort if no lockfile is defined\n const lockFileName = await findLocalSiblingOrParent(\n packageFileName,\n 'uv.lock',\n );\n if (lockFileName === null) {\n logger.debug({ packageFileName }, `No uv lock file found`);\n return null;\n }\n try {\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.debug('No uv.lock found');\n return null;\n }\n\n const pythonConstraint: ToolConstraint = {\n toolName: 'python',\n constraint:\n config.constraints?.python ?? project.project?.['requires-python'],\n };\n const uvConstraint: ToolConstraint = {\n toolName: 'uv',\n constraint:\n config.constraints?.uv ?? project.tool?.uv?.['required-version'],\n };\n\n const extraEnv = {\n ...getGitEnvironmentVariables(['pep621']),\n ...(await getUvExtraIndexUrl(project, updateArtifact.updatedDeps)),\n ...(await getUvIndexCredentials(project)),\n };\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n extraEnv,\n docker: {},\n toolConstraints: [pythonConstraint, uvConstraint],\n };\n\n // on lockFileMaintenance do not specify any packages and update the complete lock file\n // else only update specific packages\n let cmd: string;\n if (isLockFileMaintenance) {\n cmd = `${uvUpdateCMD} --upgrade`;\n } else {\n cmd = generateCMD(updatedDeps);\n }\n await exec(cmd, execOptions);\n\n // check for changes\n const fileChanges: UpdateArtifactsResult[] = [];\n const newLockContent = await readLocalFile(lockFileName, 'utf8');\n const isLockFileChanged = existingLockFileContent !== newLockContent;\n if (isLockFileChanged) {\n fileChanges.push({\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newLockContent,\n },\n });\n } else {\n logger.debug('uv.lock is unchanged');\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 uv lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n }\n}\n\nfunction generateCMD(updatedDeps: Upgrade[]): string {\n const deps: string[] = [];\n\n for (const dep of updatedDeps) {\n switch (dep.depType) {\n case depTypes.optionalDependencies: {\n deps.push(dep.depName!);\n break;\n }\n case depTypes.uvDevDependencies:\n case depTypes.uvSources: {\n deps.push(dep.depName!);\n break;\n }\n case depTypes.buildSystemRequires:\n // build requirements are not locked in the lock files, no need to update.\n break;\n default: {\n deps.push(dep.packageName!);\n }\n }\n }\n\n return `${uvUpdateCMD} ${deps.map((dep) => `--upgrade-package ${quote(dep)}`).join(' ')}`;\n}\n\nfunction getMatchingHostRule(url: string | undefined): HostRule {\n return find({ hostType: PypiDatasource.id, url });\n}\n\nasync function getUsernamePassword(\n url: URL,\n): Promise<{ username?: string; password?: string }> {\n const rule = getMatchingHostRule(url.toString());\n if (rule.username || rule.password) {\n return rule;\n }\n\n if (url.hostname.endsWith('.pkg.dev')) {\n const hostRule = await getGoogleAuthHostRule();\n if (hostRule) {\n return hostRule;\n }\n logger.once.debug({ url }, 'Could not get Google access token');\n }\n\n return {};\n}\n\nasync function getUvExtraIndexUrl(\n project: PyProject,\n deps: Upgrade[],\n): Promise<NodeJS.ProcessEnv> {\n const pyPiRegistryUrls = deps\n .filter((dep) => dep.datasource === PypiDatasource.id)\n .filter((dep) => {\n // Remove dependencies that are pinned to a specific index\n const sources = project.tool?.uv?.sources;\n const packageName = dep.packageName!;\n return !sources || !(packageName in sources);\n })\n .flatMap((dep) => dep.registryUrls)\n .filter(isString)\n .filter((registryUrl) => {\n // Check if the registry URL is not the default one and not already configured\n const configuredIndexUrls =\n project.tool?.uv?.index?.map(({ url }) => url) ?? [];\n return (\n registryUrl !== PypiDatasource.defaultURL &&\n !configuredIndexUrls.includes(registryUrl)\n );\n });\n\n const registryUrls = new Set(pyPiRegistryUrls);\n const extraIndexUrls: string[] = [];\n\n for (const registryUrl of registryUrls) {\n const parsedUrl = parseUrl(registryUrl);\n if (!parsedUrl) {\n continue;\n }\n\n const { username, password } = await getUsernamePassword(parsedUrl);\n if (username || password) {\n if (username) {\n parsedUrl.username = username;\n }\n if (password) {\n parsedUrl.password = password;\n }\n }\n\n extraIndexUrls.push(parsedUrl.toString());\n }\n\n return {\n UV_EXTRA_INDEX_URL: extraIndexUrls.join(' '),\n };\n}\n\nasync function getUvIndexCredentials(\n project: PyProject,\n): Promise<NodeJS.ProcessEnv> {\n const uv_indexes = project.tool?.uv?.index;\n\n if (!uv_indexes) {\n return {};\n }\n\n const entries = [];\n\n for (const { name, url } of uv_indexes) {\n const parsedUrl = parseUrl(url);\n /* v8 ignore next 3 -- needs test */\n if (!parsedUrl) {\n continue;\n }\n\n // If no name is provided for the index, authentication information must be passed through alternative methods\n if (!name) {\n continue;\n }\n\n const { username, password } = await getUsernamePassword(parsedUrl);\n\n const NAME = name.toUpperCase().replace(/[^A-Z0-9]/g, '_');\n\n if (username) {\n entries.push([`UV_INDEX_${NAME}_USERNAME`, username]);\n }\n\n if (password) {\n entries.push([`UV_INDEX_${NAME}_PASSWORD`, password]);\n }\n }\n\n return Object.fromEntries(entries);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAM,cAAc;AAEpB,IAAa,cAAb,cAAiC,uBAAuB;CACtD,eAAwB;CAExB,QAAQ,SAAoB,MAAgD;EAC1E,MAAM,KAAK,QAAQ,MAA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I,UACF,QAAQ,KAAK,CAAC,YAAY,KAAK,YAAY,QAAQ,CAAC;EAGtD,IAAI,UACF,QAAQ,KAAK,CAAC,YAAY,KAAK,YAAY,QAAQ,CAAC;CAExD;CAEA,OAAO,OAAO,YAAY,OAAO;AACnC"}
|
|
1
|
+
{"version":3,"file":"uv.js","names":[],"sources":["../../../../../lib/modules/manager/pep621/processors/uv.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../../constants/error-messages.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport type { HostRule } from '../../../../types/index.ts';\nimport type {\n ExecOptions,\n ToolConstraint,\n} from '../../../../util/exec/types.ts';\nimport {\n findLocalSiblingOrParent,\n readLocalFile,\n} from '../../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../../util/git/exec.ts';\nimport { find } from '../../../../util/host-rules.ts';\nimport { Result } from '../../../../util/result.ts';\nimport { parseUrl } from '../../../../util/url.ts';\nimport { PypiDatasource } from '../../../datasource/pypi/index.ts';\nimport { getGoogleAuthHostRule } from '../../../datasource/util.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsResult,\n Upgrade,\n} from '../../types.ts';\nimport { applyGitSource } from '../../util.ts';\nimport { type PyProject, UvLockfile } from '../schema.ts';\nimport { depTypes } from '../utils.ts';\n\nimport { BasePyProjectProcessor } from './abstract.ts';\n\nconst uvUpdateCMD = 'uv lock';\nconst gitExec = withGitEnvironment(['pep621']);\n\nexport class UvProcessor extends BasePyProjectProcessor {\n override lockfileName = 'uv.lock';\n\n process(project: PyProject, deps: PackageDependency[]): PackageDependency[] {\n const uv = project.tool?.uv;\n if (!uv) {\n return deps;\n }\n\n const hasExplicitDefault = uv.index?.some(\n (index) => index.default && index.explicit,\n );\n const defaultIndex = uv.index?.find(\n (index) => index.default && !index.explicit,\n );\n const implicitIndexUrls = uv.index\n ?.filter((index) => !index.explicit && index.name !== defaultIndex?.name)\n ?.map(({ url }) => url);\n\n const devDependencies = uv['dev-dependencies'];\n if (devDependencies) {\n deps.push(...devDependencies);\n }\n\n // https://docs.astral.sh/uv/concepts/dependencies/#dependency-sources\n // Skip sources that do not make sense to handle (e.g. path).\n if (uv.sources || defaultIndex || implicitIndexUrls) {\n for (const dep of deps) {\n /* v8 ignore next 3 -- needs test */\n if (!dep.packageName) {\n continue;\n }\n\n if (dep.depType === 'requires-python') {\n continue;\n }\n\n // Using `packageName` as it applies PEP 508 normalization, which is\n // also applied by uv when matching a source to a dependency.\n const depSource = uv.sources?.[dep.packageName];\n if (depSource) {\n // Dependency is pinned to a specific source.\n dep.depType = depTypes.uvSources;\n if ('index' in depSource) {\n const index = uv.index?.find(\n ({ name }) => name === depSource.index,\n );\n if (index) {\n dep.registryUrls = [index.url];\n }\n } else if ('git' in depSource) {\n applyGitSource(\n dep,\n depSource.git,\n depSource.rev,\n depSource.tag,\n depSource.branch,\n );\n } else if ('url' in depSource) {\n dep.skipReason = 'unsupported-url';\n } else if ('path' in depSource) {\n dep.skipReason = 'path-dependency';\n } else if ('workspace' in depSource) {\n dep.skipReason = 'inherited-dependency';\n } else {\n /* v8 ignore next -- unreachable through schema */\n dep.skipReason = 'unknown-registry';\n }\n } else {\n // Dependency is not pinned to a specific source, so we need to\n // determine the source based on the index configuration.\n if (hasExplicitDefault) {\n // don't fall back to pypi if there is an explicit default index\n dep.registryUrls = [];\n } else if (defaultIndex) {\n // There is a default index configured, so use it.\n dep.registryUrls = [defaultIndex.url];\n }\n\n if (implicitIndexUrls?.length) {\n // If there are implicit indexes, check them first and fall back\n // to the default.\n dep.registryUrls = implicitIndexUrls.concat(\n dep.registryUrls ?? PypiDatasource.defaultURL,\n );\n }\n }\n }\n }\n\n return deps;\n }\n\n async extractLockedVersions(\n project: PyProject,\n deps: PackageDependency[],\n packageFile: string,\n ): Promise<PackageDependency[]> {\n const lockFileName = await findLocalSiblingOrParent(\n packageFile,\n this.lockfileName,\n );\n if (lockFileName === null) {\n logger.debug({ packageFile }, `No uv lock file found`);\n } else {\n const lockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (lockFileContent) {\n const { val: lockFileMapping, err } = Result.parse(\n lockFileContent,\n UvLockfile,\n ).unwrap();\n\n if (err) {\n logger.debug({ packageFile, err }, `Error parsing uv lock file`);\n } else {\n for (const dep of deps) {\n const packageName = dep.packageName;\n if (packageName && packageName in lockFileMapping) {\n dep.lockedVersion = lockFileMapping[packageName];\n }\n }\n }\n }\n }\n\n return Promise.resolve(deps);\n }\n\n async updateArtifacts(\n updateArtifact: UpdateArtifact,\n project: PyProject,\n ): Promise<UpdateArtifactsResult[] | null> {\n const { config, updatedDeps, packageFileName } = updateArtifact;\n\n const { isLockFileMaintenance } = config;\n\n // abort if no lockfile is defined\n const lockFileName = await findLocalSiblingOrParent(\n packageFileName,\n 'uv.lock',\n );\n if (lockFileName === null) {\n logger.debug({ packageFileName }, `No uv lock file found`);\n return null;\n }\n try {\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.debug('No uv.lock found');\n return null;\n }\n\n const pythonConstraint: ToolConstraint = {\n toolName: 'python',\n constraint:\n config.constraints?.python ?? project.project?.['requires-python'],\n };\n const uvConstraint: ToolConstraint = {\n toolName: 'uv',\n constraint:\n config.constraints?.uv ?? project.tool?.uv?.['required-version'],\n };\n\n const extraEnv = {\n ...(await getUvExtraIndexUrl(project, updateArtifact.updatedDeps)),\n ...(await getUvIndexCredentials(project)),\n };\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n extraEnv,\n docker: {},\n toolConstraints: [pythonConstraint, uvConstraint],\n };\n\n // on lockFileMaintenance do not specify any packages and update the complete lock file\n // else only update specific packages\n let cmd: string;\n if (isLockFileMaintenance) {\n cmd = `${uvUpdateCMD} --upgrade`;\n } else {\n cmd = generateCMD(updatedDeps);\n }\n await gitExec(cmd, execOptions);\n\n // check for changes\n const fileChanges: UpdateArtifactsResult[] = [];\n const newLockContent = await readLocalFile(lockFileName, 'utf8');\n const isLockFileChanged = existingLockFileContent !== newLockContent;\n if (isLockFileChanged) {\n fileChanges.push({\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newLockContent,\n },\n });\n } else {\n logger.debug('uv.lock is unchanged');\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 uv lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n }\n}\n\nfunction generateCMD(updatedDeps: Upgrade[]): string {\n const deps: string[] = [];\n\n for (const dep of updatedDeps) {\n switch (dep.depType) {\n case depTypes.optionalDependencies: {\n deps.push(dep.depName!);\n break;\n }\n case depTypes.uvDevDependencies:\n case depTypes.uvSources: {\n deps.push(dep.depName!);\n break;\n }\n case depTypes.buildSystemRequires:\n // build requirements are not locked in the lock files, no need to update.\n break;\n default: {\n deps.push(dep.packageName!);\n }\n }\n }\n\n return `${uvUpdateCMD} ${deps.map((dep) => `--upgrade-package ${quote(dep)}`).join(' ')}`;\n}\n\nfunction getMatchingHostRule(url: string | undefined): HostRule {\n return find({ hostType: PypiDatasource.id, url });\n}\n\nasync function getUsernamePassword(\n url: URL,\n): Promise<{ username?: string; password?: string }> {\n const rule = getMatchingHostRule(url.toString());\n if (rule.username || rule.password) {\n return rule;\n }\n\n if (url.hostname.endsWith('.pkg.dev')) {\n const hostRule = await getGoogleAuthHostRule();\n if (hostRule) {\n return hostRule;\n }\n logger.once.debug({ url }, 'Could not get Google access token');\n }\n\n return {};\n}\n\nasync function getUvExtraIndexUrl(\n project: PyProject,\n deps: Upgrade[],\n): Promise<NodeJS.ProcessEnv> {\n const pyPiRegistryUrls = deps\n .filter((dep) => dep.datasource === PypiDatasource.id)\n .filter((dep) => {\n // Remove dependencies that are pinned to a specific index\n const sources = project.tool?.uv?.sources;\n const packageName = dep.packageName!;\n return !sources || !(packageName in sources);\n })\n .flatMap((dep) => dep.registryUrls)\n .filter(isString)\n .filter((registryUrl) => {\n // Check if the registry URL is not the default one and not already configured\n const configuredIndexUrls =\n project.tool?.uv?.index?.map(({ url }) => url) ?? [];\n return (\n registryUrl !== PypiDatasource.defaultURL &&\n !configuredIndexUrls.includes(registryUrl)\n );\n });\n\n const registryUrls = new Set(pyPiRegistryUrls);\n const extraIndexUrls: string[] = [];\n\n for (const registryUrl of registryUrls) {\n const parsedUrl = parseUrl(registryUrl);\n if (!parsedUrl) {\n continue;\n }\n\n const { username, password } = await getUsernamePassword(parsedUrl);\n if (username || password) {\n if (username) {\n parsedUrl.username = username;\n }\n if (password) {\n parsedUrl.password = password;\n }\n }\n\n extraIndexUrls.push(parsedUrl.toString());\n }\n\n return {\n UV_EXTRA_INDEX_URL: extraIndexUrls.join(' '),\n };\n}\n\nasync function getUvIndexCredentials(\n project: PyProject,\n): Promise<NodeJS.ProcessEnv> {\n const uv_indexes = project.tool?.uv?.index;\n\n if (!uv_indexes) {\n return {};\n }\n\n const entries = [];\n\n for (const { name, url } of uv_indexes) {\n const parsedUrl = parseUrl(url);\n /* v8 ignore next 3 -- needs test */\n if (!parsedUrl) {\n continue;\n }\n\n // If no name is provided for the index, authentication information must be passed through alternative methods\n if (!name) {\n continue;\n }\n\n const { username, password } = await getUsernamePassword(parsedUrl);\n\n const NAME = name.toUpperCase().replace(/[^A-Z0-9]/g, '_');\n\n if (username) {\n entries.push([`UV_INDEX_${NAME}_USERNAME`, username]);\n }\n\n if (password) {\n entries.push([`UV_INDEX_${NAME}_PASSWORD`, password]);\n }\n }\n\n return Object.fromEntries(entries);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAM,cAAc;AACpB,MAAM,UAAU,mBAAmB,CAAC,QAAQ,CAAC;AAE7C,IAAa,cAAb,cAAiC,uBAAuB;CACtD,eAAwB;CAExB,QAAQ,SAAoB,MAAgD;EAC1E,MAAM,KAAK,QAAQ,MAAM;EACzB,IAAI,CAAC,IACH,OAAO;EA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ACF,QAAQ,KAAK,CAAC,YAAY,KAAK,YAAY,QAAQ,CAAC;CAExD;CAEA,OAAO,OAAO,YAAY,OAAO;AACnC"}
|
|
@@ -7,13 +7,13 @@ import { massage, parse } from "../../../util/toml.js";
|
|
|
7
7
|
import { deleteLocalFile, ensureCacheDir, getSiblingFileName, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
|
|
8
8
|
import { Result } from "../../../util/result.js";
|
|
9
9
|
import { getGoogleAuthHostRule } from "../../datasource/util.js";
|
|
10
|
-
import { getGitEnvironmentVariables } from "../../../util/git/auth.js";
|
|
11
|
-
import { exec } from "../../../util/exec/index.js";
|
|
12
10
|
import { PypiDatasource } from "../../datasource/pypi/index.js";
|
|
11
|
+
import { withGitEnvironment } from "../../../util/git/exec.js";
|
|
13
12
|
import { Lockfile, PoetryPyProject } from "./schema.js";
|
|
14
13
|
import { isNonEmptyArray, isNonEmptyObject, isString } from "@sindresorhus/is";
|
|
15
14
|
import { quote } from "shlex";
|
|
16
15
|
//#region lib/modules/manager/poetry/artifacts.ts
|
|
16
|
+
const gitExec = withGitEnvironment(["poetry"]);
|
|
17
17
|
function getPythonConstraint(pyProjectContent, existingLockFileContent) {
|
|
18
18
|
const pyprojectPythonConstraint = Result.parse(massage(pyProjectContent), PoetryPyProject.transform(({ packageFileContent }) => packageFileContent.deps.find((dep) => dep.depName === "python")?.currentValue)).unwrapOrNull();
|
|
19
19
|
if (pyprojectPythonConstraint) {
|
|
@@ -128,7 +128,6 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
|
|
|
128
128
|
cwdFile: packageFileName,
|
|
129
129
|
extraEnv: {
|
|
130
130
|
...await getSourceCredentialVars(newPackageFileContent, packageFileName),
|
|
131
|
-
...getGitEnvironmentVariables(["poetry"]),
|
|
132
131
|
PIP_CACHE_DIR: await ensureCacheDir("pip")
|
|
133
132
|
},
|
|
134
133
|
docker: {},
|
|
@@ -140,7 +139,7 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
|
|
|
140
139
|
constraint: poetryConstraint
|
|
141
140
|
}]
|
|
142
141
|
};
|
|
143
|
-
await
|
|
142
|
+
await gitExec(cmd, execOptions);
|
|
144
143
|
const newPoetryLockContent = await readLocalFile(lockFileName, "utf8");
|
|
145
144
|
if (existingLockFileContent === newPoetryLockContent) {
|
|
146
145
|
logger.debug(`${lockFileName} is unchanged`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","names":["massageToml","parseToml"],"sources":["../../../../lib/modules/manager/poetry/artifacts.ts"],"sourcesContent":["import { isNonEmptyArray, isNonEmptyObject, isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport type { HostRule } from '../../../types/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n ensureCacheDir,\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getGitEnvironmentVariables } from '../../../util/git/auth.ts';\nimport { find } from '../../../util/host-rules.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { Result } from '../../../util/result.ts';\nimport {\n massage as massageToml,\n parse as parseToml,\n} from '../../../util/toml.ts';\nimport { parseUrl } from '../../../util/url.ts';\nimport { PypiDatasource } from '../../datasource/pypi/index.ts';\nimport { getGoogleAuthHostRule } from '../../datasource/util.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { Lockfile, PoetryPyProject } from './schema.ts';\nimport type { PoetryFile, PoetrySource } from './types.ts';\n\nexport function getPythonConstraint(\n pyProjectContent: string,\n existingLockFileContent: string,\n): string | null {\n // Read Python version from `pyproject.toml` first as it could have been updated\n const pyprojectPythonConstraint = Result.parse(\n massageToml(pyProjectContent),\n PoetryPyProject.transform(\n ({ packageFileContent }) =>\n packageFileContent.deps.find((dep) => dep.depName === 'python')\n ?.currentValue,\n ),\n ).unwrapOrNull();\n if (pyprojectPythonConstraint) {\n logger.debug('Using python version from pyproject.toml');\n return pyprojectPythonConstraint;\n }\n\n const lockfilePythonConstraint = Result.parse(\n existingLockFileContent,\n Lockfile.transform(({ pythonVersions }) => pythonVersions),\n ).unwrapOrNull();\n if (lockfilePythonConstraint) {\n logger.debug('Using python version from poetry.lock');\n return lockfilePythonConstraint;\n }\n\n return null;\n}\n\nexport function getPoetryRequirement(\n pyProjectContent: string,\n existingLockFileContent: string,\n): undefined | string | null {\n // Read Poetry version from first line of poetry.lock\n const firstLine = existingLockFileContent.split('\\n')[0];\n const poetryVersionMatch = regEx(/by Poetry ([\\d\\\\.]+)/).exec(firstLine);\n if (poetryVersionMatch?.[1]) {\n const poetryVersion = poetryVersionMatch[1];\n logger.debug(\n `Using poetry version ${poetryVersion} from poetry.lock header`,\n );\n return poetryVersion;\n }\n\n const { val: lockfilePoetryConstraint } = Result.parse(\n existingLockFileContent,\n Lockfile.transform(({ poetryConstraint }) => poetryConstraint),\n ).unwrap();\n if (lockfilePoetryConstraint) {\n logger.debug(\n `Using poetry version ${lockfilePoetryConstraint} from poetry.lock metadata`,\n );\n return lockfilePoetryConstraint;\n }\n\n const { val: pyprojectPoetryConstraint } = Result.parse(\n massageToml(pyProjectContent),\n PoetryPyProject.transform(({ poetryRequirement }) => poetryRequirement),\n ).unwrap();\n if (pyprojectPoetryConstraint) {\n logger.debug(\n `Using poetry version ${pyprojectPoetryConstraint} from pyproject.toml`,\n );\n return pyprojectPoetryConstraint;\n }\n\n return null;\n}\n\nfunction getPoetrySources(content: string, fileName: string): PoetrySource[] {\n let pyprojectFile: PoetryFile;\n try {\n pyprojectFile = parseToml(massageToml(content)) as PoetryFile;\n } catch (err) {\n logger.debug({ err }, 'Error parsing pyproject.toml file');\n return [];\n }\n if (!pyprojectFile.tool?.poetry) {\n logger.debug(`${fileName} contains no poetry section`);\n return [];\n }\n\n const sources = pyprojectFile.tool?.poetry?.source ?? [];\n const sourceArray: PoetrySource[] = [];\n for (const source of sources) {\n if (source.name && source.url) {\n sourceArray.push({ name: source.name, url: source.url });\n }\n }\n return sourceArray;\n}\n\nasync function getMatchingHostRule(url: string | undefined): Promise<HostRule> {\n const scopedMatch = find({ hostType: PypiDatasource.id, url });\n const hostRule = isNonEmptyObject(scopedMatch) ? scopedMatch : find({ url });\n if (hostRule && Object.keys(hostRule).length !== 0) {\n return hostRule;\n }\n\n const parsedUrl = parseUrl(url);\n if (!parsedUrl) {\n logger.once.debug(`Failed to parse URL ${url}`);\n return {};\n }\n\n if (parsedUrl.hostname.endsWith('.pkg.dev')) {\n const hostRule = await getGoogleAuthHostRule();\n if (hostRule && Object.keys(hostRule).length !== 0) {\n return hostRule;\n }\n logger.once.debug(`Could not get Google access token (url=${url})`);\n }\n\n return {};\n}\n\nasync function getSourceCredentialVars(\n pyprojectContent: string,\n packageFileName: string,\n): Promise<NodeJS.ProcessEnv> {\n const poetrySources = getPoetrySources(pyprojectContent, packageFileName);\n const envVars: NodeJS.ProcessEnv = {};\n\n for (const source of poetrySources) {\n const matchingHostRule = await getMatchingHostRule(source.url);\n const formattedSourceName = source.name\n .replace(regEx(/(\\.|-)+/g), '_')\n .toUpperCase();\n if (matchingHostRule.username) {\n envVars[`POETRY_HTTP_BASIC_${formattedSourceName}_USERNAME`] =\n matchingHostRule.username;\n }\n if (matchingHostRule.password) {\n envVars[`POETRY_HTTP_BASIC_${formattedSourceName}_PASSWORD`] =\n matchingHostRule.password;\n }\n }\n return envVars;\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`poetry.updateArtifacts(${packageFileName})`);\n const { isLockFileMaintenance } = config;\n\n if (!isNonEmptyArray(updatedDeps) && !isLockFileMaintenance) {\n logger.debug('No updated poetry deps - returning null');\n return null;\n }\n // Try poetry.lock first\n let lockFileName = getSiblingFileName(packageFileName, 'poetry.lock');\n let existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n // Try pyproject.lock next\n lockFileName = getSiblingFileName(packageFileName, 'pyproject.lock');\n existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.debug(`No lock file found`);\n return null;\n }\n }\n logger.debug(`Updating ${lockFileName}`);\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n const cmd: string[] = [];\n if (isLockFileMaintenance) {\n await deleteLocalFile(lockFileName);\n cmd.push('poetry update --lock --no-interaction');\n } else {\n cmd.push(\n `poetry update --lock --no-interaction ${updatedDeps\n .map((dep) => dep.depName)\n .filter(isString)\n .map((dep) => quote(dep))\n .join(' ')}`,\n );\n }\n const pythonConstraint =\n config?.constraints?.python ??\n getPythonConstraint(newPackageFileContent, existingLockFileContent);\n const poetryConstraint =\n config.constraints?.poetry ??\n getPoetryRequirement(newPackageFileContent, existingLockFileContent);\n const extraEnv = {\n ...(await getSourceCredentialVars(\n newPackageFileContent,\n packageFileName,\n )),\n ...getGitEnvironmentVariables(['poetry']),\n PIP_CACHE_DIR: await ensureCacheDir('pip'),\n };\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n extraEnv,\n docker: {},\n toolConstraints: [\n { toolName: 'python', constraint: pythonConstraint },\n { toolName: 'poetry', constraint: poetryConstraint },\n ],\n };\n await exec(cmd, execOptions);\n const newPoetryLockContent = await readLocalFile(lockFileName, 'utf8');\n if (existingLockFileContent === newPoetryLockContent) {\n logger.debug(`${lockFileName} is unchanged`);\n return null;\n }\n logger.debug(`Returning updated ${lockFileName}`);\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newPoetryLockContent,\n },\n },\n ];\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, `Failed to update ${lockFileName} file`);\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: `${String(err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BAA2B,CAAC,QAAQ,CAAC;IACxC,eAAe,MAAM,eAAe,KAAK;GAKlC;GACP,QAAQ,CAAC;GACT,iBAAiB,CACf;IAAE,UAAU;IAAU,YAAY;GAAiB,GACnD;IAAE,UAAU;IAAU,YAAY;GAAiB,CACrD;EACF;EACA,MAAM,KAAK,KAAK,WAAW;EAC3B,MAAM,uBAAuB,MAAM,cAAc,cAAc,MAAM;EACrE,IAAI,4BAA4B,sBAAsB;GACpD,OAAO,MAAM,GAAG,aAAa,cAAc;GAC3C,OAAO;EACT;EACA,OAAO,MAAM,qBAAqB,cAAc;EAChD,OAAO,CACL,EACE,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU;EACZ,EACF,CACF;CACF,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,oBAAoB,aAAa,MAAM;EAC7D,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,GAAG,OAAO,IAAI,MAAM,EAAE,IAAI,OAAO,IAAI,MAAM;EACrD,EACF,CACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"artifacts.js","names":["massageToml","parseToml"],"sources":["../../../../lib/modules/manager/poetry/artifacts.ts"],"sourcesContent":["import { isNonEmptyArray, isNonEmptyObject, isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport type { HostRule } from '../../../types/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n ensureCacheDir,\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../util/git/exec.ts';\nimport { find } from '../../../util/host-rules.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { Result } from '../../../util/result.ts';\nimport {\n massage as massageToml,\n parse as parseToml,\n} from '../../../util/toml.ts';\nimport { parseUrl } from '../../../util/url.ts';\nimport { PypiDatasource } from '../../datasource/pypi/index.ts';\nimport { getGoogleAuthHostRule } from '../../datasource/util.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { Lockfile, PoetryPyProject } from './schema.ts';\nimport type { PoetryFile, PoetrySource } from './types.ts';\n\nconst gitExec = withGitEnvironment(['poetry']);\n\nexport function getPythonConstraint(\n pyProjectContent: string,\n existingLockFileContent: string,\n): string | null {\n // Read Python version from `pyproject.toml` first as it could have been updated\n const pyprojectPythonConstraint = Result.parse(\n massageToml(pyProjectContent),\n PoetryPyProject.transform(\n ({ packageFileContent }) =>\n packageFileContent.deps.find((dep) => dep.depName === 'python')\n ?.currentValue,\n ),\n ).unwrapOrNull();\n if (pyprojectPythonConstraint) {\n logger.debug('Using python version from pyproject.toml');\n return pyprojectPythonConstraint;\n }\n\n const lockfilePythonConstraint = Result.parse(\n existingLockFileContent,\n Lockfile.transform(({ pythonVersions }) => pythonVersions),\n ).unwrapOrNull();\n if (lockfilePythonConstraint) {\n logger.debug('Using python version from poetry.lock');\n return lockfilePythonConstraint;\n }\n\n return null;\n}\n\nexport function getPoetryRequirement(\n pyProjectContent: string,\n existingLockFileContent: string,\n): undefined | string | null {\n // Read Poetry version from first line of poetry.lock\n const firstLine = existingLockFileContent.split('\\n')[0];\n const poetryVersionMatch = regEx(/by Poetry ([\\d\\\\.]+)/).exec(firstLine);\n if (poetryVersionMatch?.[1]) {\n const poetryVersion = poetryVersionMatch[1];\n logger.debug(\n `Using poetry version ${poetryVersion} from poetry.lock header`,\n );\n return poetryVersion;\n }\n\n const { val: lockfilePoetryConstraint } = Result.parse(\n existingLockFileContent,\n Lockfile.transform(({ poetryConstraint }) => poetryConstraint),\n ).unwrap();\n if (lockfilePoetryConstraint) {\n logger.debug(\n `Using poetry version ${lockfilePoetryConstraint} from poetry.lock metadata`,\n );\n return lockfilePoetryConstraint;\n }\n\n const { val: pyprojectPoetryConstraint } = Result.parse(\n massageToml(pyProjectContent),\n PoetryPyProject.transform(({ poetryRequirement }) => poetryRequirement),\n ).unwrap();\n if (pyprojectPoetryConstraint) {\n logger.debug(\n `Using poetry version ${pyprojectPoetryConstraint} from pyproject.toml`,\n );\n return pyprojectPoetryConstraint;\n }\n\n return null;\n}\n\nfunction getPoetrySources(content: string, fileName: string): PoetrySource[] {\n let pyprojectFile: PoetryFile;\n try {\n pyprojectFile = parseToml(massageToml(content)) as PoetryFile;\n } catch (err) {\n logger.debug({ err }, 'Error parsing pyproject.toml file');\n return [];\n }\n if (!pyprojectFile.tool?.poetry) {\n logger.debug(`${fileName} contains no poetry section`);\n return [];\n }\n\n const sources = pyprojectFile.tool?.poetry?.source ?? [];\n const sourceArray: PoetrySource[] = [];\n for (const source of sources) {\n if (source.name && source.url) {\n sourceArray.push({ name: source.name, url: source.url });\n }\n }\n return sourceArray;\n}\n\nasync function getMatchingHostRule(url: string | undefined): Promise<HostRule> {\n const scopedMatch = find({ hostType: PypiDatasource.id, url });\n const hostRule = isNonEmptyObject(scopedMatch) ? scopedMatch : find({ url });\n if (hostRule && Object.keys(hostRule).length !== 0) {\n return hostRule;\n }\n\n const parsedUrl = parseUrl(url);\n if (!parsedUrl) {\n logger.once.debug(`Failed to parse URL ${url}`);\n return {};\n }\n\n if (parsedUrl.hostname.endsWith('.pkg.dev')) {\n const hostRule = await getGoogleAuthHostRule();\n if (hostRule && Object.keys(hostRule).length !== 0) {\n return hostRule;\n }\n logger.once.debug(`Could not get Google access token (url=${url})`);\n }\n\n return {};\n}\n\nasync function getSourceCredentialVars(\n pyprojectContent: string,\n packageFileName: string,\n): Promise<NodeJS.ProcessEnv> {\n const poetrySources = getPoetrySources(pyprojectContent, packageFileName);\n const envVars: NodeJS.ProcessEnv = {};\n\n for (const source of poetrySources) {\n const matchingHostRule = await getMatchingHostRule(source.url);\n const formattedSourceName = source.name\n .replace(regEx(/(\\.|-)+/g), '_')\n .toUpperCase();\n if (matchingHostRule.username) {\n envVars[`POETRY_HTTP_BASIC_${formattedSourceName}_USERNAME`] =\n matchingHostRule.username;\n }\n if (matchingHostRule.password) {\n envVars[`POETRY_HTTP_BASIC_${formattedSourceName}_PASSWORD`] =\n matchingHostRule.password;\n }\n }\n return envVars;\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`poetry.updateArtifacts(${packageFileName})`);\n const { isLockFileMaintenance } = config;\n\n if (!isNonEmptyArray(updatedDeps) && !isLockFileMaintenance) {\n logger.debug('No updated poetry deps - returning null');\n return null;\n }\n // Try poetry.lock first\n let lockFileName = getSiblingFileName(packageFileName, 'poetry.lock');\n let existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n // Try pyproject.lock next\n lockFileName = getSiblingFileName(packageFileName, 'pyproject.lock');\n existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.debug(`No lock file found`);\n return null;\n }\n }\n logger.debug(`Updating ${lockFileName}`);\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n const cmd: string[] = [];\n if (isLockFileMaintenance) {\n await deleteLocalFile(lockFileName);\n cmd.push('poetry update --lock --no-interaction');\n } else {\n cmd.push(\n `poetry update --lock --no-interaction ${updatedDeps\n .map((dep) => dep.depName)\n .filter(isString)\n .map((dep) => quote(dep))\n .join(' ')}`,\n );\n }\n const pythonConstraint =\n config?.constraints?.python ??\n getPythonConstraint(newPackageFileContent, existingLockFileContent);\n const poetryConstraint =\n config.constraints?.poetry ??\n getPoetryRequirement(newPackageFileContent, existingLockFileContent);\n const extraEnv = {\n ...(await getSourceCredentialVars(\n newPackageFileContent,\n packageFileName,\n )),\n PIP_CACHE_DIR: await ensureCacheDir('pip'),\n };\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n extraEnv,\n docker: {},\n toolConstraints: [\n { toolName: 'python', constraint: pythonConstraint },\n { toolName: 'poetry', constraint: poetryConstraint },\n ],\n };\n await gitExec(cmd, execOptions);\n const newPoetryLockContent = await readLocalFile(lockFileName, 'utf8');\n if (existingLockFileContent === newPoetryLockContent) {\n logger.debug(`${lockFileName} is unchanged`);\n return null;\n }\n logger.debug(`Returning updated ${lockFileName}`);\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newPoetryLockContent,\n },\n },\n ];\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, `Failed to update ${lockFileName} file`);\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: `${String(err.stdout)}\\n${String(err.stderr)}`,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,MAAM,UAAU,mBAAmB,CAAC,QAAQ,CAAC;AAE7C,SAAgB,oBACd,kBACA,yBACe;CAEf,MAAM,4BAA4B,OAAO,MACvCA,QAAY,gBAAgB,GAC5B,gBAAgB,WACb,EAAE,yBACD,mBAAmB,KAAK,MAAM,QAAQ,IAAI,YAAY,QAAQ,CAAC,EAC3D,YACR,CACF,CAAC,CAAC,aAAa;CACf,IAAI,2BAA2B;EAC7B,OAAO,MAAM,0CAA0C;EACvD,OAAO;CACT;CAEA,MAAM,2BAA2B,OAAO,MACtC,yBACA,SAAS,WAAW,EAAE,qBAAqB,cAAc,CAC3D,CAAC,CAAC,aAAa;CACf,IAAI,0BAA0B;EAC5B,OAAO,MAAM,uCAAuC;EACpD,OAAO;CACT;CAEA,OAAO;AACT;AAEA,SAAgB,qBACd,kBACA,yBAC2B;CAE3B,MAAM,YAAY,wBAAwB,MAAM,IAAI,CAAC,CAAC;CACtD,MAAM,qBAAqB,MAAM,sBAAsB,CAAC,CAAC,KAAK,SAAS;CACvE,IAAI,qBAAqB,IAAI;EAC3B,MAAM,gBAAgB,mBAAmB;EACzC,OAAO,MACL,wBAAwB,cAAc,yBACxC;EACA,OAAO;CACT;CAEA,MAAM,EAAE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IAAI,uBAAuB;GACzB,MAAM,gBAAgB,YAAY;GAClC,IAAI,KAAK,uCAAuC;EAClD,OACE,IAAI,KACF,yCAAyC,YACtC,KAAK,QAAQ,IAAI,OAAO,CAAC,CACzB,OAAO,QAAQ,CAAC,CAChB,KAAK,QAAQ,MAAM,GAAG,CAAC,CAAC,CACxB,KAAK,GAAG,GACb;EAEF,MAAM,mBACJ,QAAQ,aAAa,UACrB,oBAAoB,uBAAuB,uBAAuB;EACpE,MAAM,mBACJ,OAAO,aAAa,UACpB,qBAAqB,uBAAuB,uBAAuB;EASrE,MAAM,cAA2B;GAC/B,SAAS;GACT,UAAA;IATA,GAAI,MAAM,wBACR,uBACA,eACF;IACA,eAAe,MAAM,eAAe,KAAK;GAKlC;GACP,QAAQ,CAAC;GACT,iBAAiB,CACf;IAAE,UAAU;IAAU,YAAY;GAAiB,GACnD;IAAE,UAAU;IAAU,YAAY;GAAiB,CACrD;EACF;EACA,MAAM,QAAQ,KAAK,WAAW;EAC9B,MAAM,uBAAuB,MAAM,cAAc,cAAc,MAAM;EACrE,IAAI,4BAA4B,sBAAsB;GACpD,OAAO,MAAM,GAAG,aAAa,cAAc;GAC3C,OAAO;EACT;EACA,OAAO,MAAM,qBAAqB,cAAc;EAChD,OAAO,CACL,EACE,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU;EACZ,EACF,CACF;CACF,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,oBAAoB,aAAa,MAAM;EAC7D,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,GAAG,OAAO,IAAI,MAAM,EAAE,IAAI,OAAO,IAAI,MAAM;EACrD,EACF,CACF;CACF;AACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "../../../constants/error-messages.js";
|
|
2
2
|
import { logger } from "../../../logger/index.js";
|
|
3
3
|
import { getParentDir, getSiblingFileName, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
|
|
4
|
-
import { getGitEnvironmentVariables } from "../../../util/git/auth.js";
|
|
5
|
-
import { exec } from "../../../util/exec/index.js";
|
|
6
4
|
import { getRepoStatus } from "../../../util/git/index.js";
|
|
5
|
+
import { withGitEnvironment } from "../../../util/git/exec.js";
|
|
7
6
|
//#region lib/modules/manager/vendir/artifacts.ts
|
|
7
|
+
const gitExec = withGitEnvironment();
|
|
8
8
|
async function updateArtifacts({ packageFileName, newPackageFileContent, config }) {
|
|
9
9
|
logger.debug(`vendir.updateArtifacts(${packageFileName})`);
|
|
10
10
|
const lockFileName = getSiblingFileName(packageFileName, "vendir.lock.yml");
|
|
@@ -21,7 +21,6 @@ async function updateArtifacts({ packageFileName, newPackageFileContent, config
|
|
|
21
21
|
await writeLocalFile(packageFileName, newPackageFileContent);
|
|
22
22
|
logger.debug("Updating Vendir artifacts");
|
|
23
23
|
const execOptions = {
|
|
24
|
-
extraEnv: { ...getGitEnvironmentVariables([]) },
|
|
25
24
|
cwdFile: packageFileName,
|
|
26
25
|
docker: {},
|
|
27
26
|
toolConstraints: [{
|
|
@@ -32,7 +31,7 @@ async function updateArtifacts({ packageFileName, newPackageFileContent, config
|
|
|
32
31
|
constraint: config.constraints?.helm
|
|
33
32
|
}]
|
|
34
33
|
};
|
|
35
|
-
await
|
|
34
|
+
await gitExec(`vendir sync`, execOptions);
|
|
36
35
|
logger.debug("Returning updated Vendir artifacts");
|
|
37
36
|
const fileChanges = [];
|
|
38
37
|
const newVendirLockContent = await readLocalFile(lockFileName, "utf8");
|
|
@@ -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,KAAK,6BAA6B;EACzC,OAAO;CACT;CAEA,IAAI;EACF,MAAM,eAAe,iBAAiB,qBAAqB;EAC3D,OAAO,MAAM,2BAA2B;EACxC,MAAM,cAA2B;GAC/B,SAAS;GACT,QAAQ,CAAC;GACT,iBAAiB,CACf;IAAE,UAAU;IAAU,YAAY,OAAO,aAAa;GAAO,GAC7D;IAAE,UAAU;IAAQ,YAAY,OAAO,aAAa;GAAK,CAC3D;EACF;EAEA,MAAM,QAAQ,eAAe,WAAW;EAExC,OAAO,MAAM,oCAAoC;EAEjD,MAAM,cAAuC,CAAC;EAE9C,MAAM,uBAAuB,MAAM,cAAc,cAAc,MAAM;EAErE,IAD0B,4BAA4B,sBAEpD,YAAY,KAAK,EACf,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU;EACZ,EACF,CAAC;EAIH,OAAO,MAAM,4BAA4B;EAEzC,MAAM,YAAY,aAAa,eAAe;EAC9C,MAAM,SAAS,MAAM,cAAc;EACnC,IAAI,QAAQ;GACV,MAAM,gBAAgB,OAAO,YAAY,CAAC;GAC1C,MAAM,gBAAgB,OAAO;GAC7B,MAAM,eAAe,OAAO,WAAW,CAAC;GAExC,KAAK,MAAM,KAAK,cAAc,OAAO,aAAa,GAAG;IACnD,MAAM,oBAAoB,EAAE,WAAW,SAAS;IAChD,IAAI,aAAa,mBACf,YAAY,KAAK,EACf,MAAM;KACJ,MAAM;KACN,MAAM;KACN,UAAU,MAAM,cAAc,CAAC;IACjC,EACF,CAAC;GAEL;GAEA,KAAK,MAAM,KAAK,cACd,YAAY,KAAK,EACf,MAAM;IACJ,MAAM;IACN,MAAM;GACR,EACF,CAAC;EAEL,OACE,OAAO,MAAM,0BAA0B;EAGzC,OAAO,YAAY,SAAS,cAAc;CAC5C,SAAS,KAAK;EACZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,mCAAmC;EACzD,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
|
|
@@ -93,6 +93,22 @@ function getNewValue({ currentValue, rangeStrategy, currentVersion, newVersion }
|
|
|
93
93
|
}
|
|
94
94
|
return newCargo;
|
|
95
95
|
}
|
|
96
|
+
function subset(subRange, superRange) {
|
|
97
|
+
try {
|
|
98
|
+
return api$1.subset(cargo2npm(subRange), cargo2npm(superRange));
|
|
99
|
+
} catch (err) {
|
|
100
|
+
logger.debug({ err }, "cargo.subset error");
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function intersects(subRange, superRange) {
|
|
105
|
+
try {
|
|
106
|
+
return api$1.intersects(cargo2npm(subRange), cargo2npm(superRange));
|
|
107
|
+
} catch (err) {
|
|
108
|
+
logger.debug({ err }, "cargo.intersects error");
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
96
112
|
function isBreaking(current, version) {
|
|
97
113
|
if (!stable.is(version) || !stable.is(current)) return true;
|
|
98
114
|
const currentMajor = major(current);
|
|
@@ -112,7 +128,9 @@ const api = {
|
|
|
112
128
|
isValid,
|
|
113
129
|
matches,
|
|
114
130
|
getSatisfyingVersion,
|
|
115
|
-
minSatisfyingVersion
|
|
131
|
+
minSatisfyingVersion,
|
|
132
|
+
subset,
|
|
133
|
+
intersects
|
|
116
134
|
};
|
|
117
135
|
//#endregion
|
|
118
136
|
export { api, api as default, id, isValid };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["npm","semver","getMajor","getMinor"],"sources":["../../../../lib/modules/versioning/cargo/index.ts"],"sourcesContent":["import { major as getMajor, minor as getMinor } from 'semver';\nimport semver from 'semver-stable';\nimport { logger } from '../../../logger/index.ts';\nimport type { RangeStrategy } from '../../../types/versioning.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { api as npm } from '../npm/index.ts';\nimport type { NewValueConfig, VersioningApi } from '../types.ts';\n\nexport const id = 'cargo';\nexport const displayName = 'Cargo';\nexport const urls = [\n '[Cargo - Specifying Dependencies](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html)',\n];\nexport const supportsRanges = true;\nexport const supportedRangeStrategies: RangeStrategy[] = ['bump', 'replace'];\n\nfunction isVersion(input: string): boolean {\n return npm.isVersion(input);\n}\n\nfunction convertToCaret(item: string): string {\n // In Cargo, caret versions are used by default, so \"1.2.3\" actually means ^1.2.3.\n // Similarly, \"0.4\" actually means ^0.4.\n // See: https://doc.rust-lang.org/stable/cargo/reference/specifying-dependencies.html#caret-requirements\n if (isVersion(item) || isVersion(`${item}.0`) || isVersion(`${item}.0.0`)) {\n return `^${item.trim()}`;\n }\n return item.trim();\n}\n\nfunction cargo2npm(input: string): string {\n let versions = input.split(',');\n versions = versions.map(convertToCaret);\n return versions.join(' ');\n}\n\nfunction notEmpty(s: string): boolean {\n return s !== '';\n}\n\nfunction npm2cargo(input: string): string {\n // istanbul ignore if\n if (!input) {\n return input;\n }\n // Note: this doesn't remove the ^\n const res = input\n .split(regEx(/\\s+,?\\s*|\\s*,?\\s+/))\n .map((str) => str.trim())\n .filter(notEmpty);\n const operators = ['^', '~', '=', '>', '<', '<=', '>='];\n for (let i = 0; i < res.length - 1; i += 1) {\n if (operators.includes(res[i])) {\n const newValue = `${res[i]} ${res[i + 1]}`;\n res.splice(i, 2, newValue);\n }\n }\n return res.join(', ');\n}\n\nfunction isLessThanRange(version: string, range: string): boolean {\n return !!npm.isLessThanRange?.(version, cargo2npm(range));\n}\n\nexport function isValid(input: string): boolean {\n return npm.isValid(cargo2npm(input));\n}\n\nfunction matches(version: string, range: string): boolean {\n return npm.matches(version, cargo2npm(range));\n}\n\nfunction getSatisfyingVersion(\n versions: string[],\n range: string,\n): string | null {\n return npm.getSatisfyingVersion(versions, cargo2npm(range));\n}\n\nfunction minSatisfyingVersion(\n versions: string[],\n range: string,\n): string | null {\n return npm.minSatisfyingVersion(versions, cargo2npm(range));\n}\n\nfunction isSingleVersion(constraint: string): boolean {\n return (\n constraint.trim().startsWith('=') &&\n isVersion(constraint.trim().substring(1).trim())\n );\n}\n\nfunction getPinnedValue(newVersion: string): string {\n return `=${newVersion}`;\n}\n\nfunction getNewValue({\n currentValue,\n rangeStrategy,\n currentVersion,\n newVersion,\n}: NewValueConfig): string {\n if (!currentValue || currentValue === '*') {\n return currentValue;\n }\n // If the current value is a simple version, bump to fully specified newVersion\n if (rangeStrategy === 'bump' && regEx(/^\\d+(?:\\.\\d+)*$/).test(currentValue)) {\n return newVersion;\n }\n if (isSingleVersion(currentValue)) {\n let res = '=';\n if (currentValue.startsWith('= ')) {\n res += ' ';\n }\n res += newVersion;\n return res;\n }\n if (rangeStrategy === 'replace' && matches(newVersion, currentValue)) {\n return currentValue;\n }\n const newSemver = npm.getNewValue({\n currentValue: cargo2npm(currentValue),\n rangeStrategy,\n currentVersion,\n newVersion,\n });\n let newCargo = newSemver\n ? npm2cargo(newSemver)\n : /* istanbul ignore next: should never happen */ null;\n // istanbul ignore if\n if (!newCargo) {\n logger.info(\n { currentValue, newSemver },\n 'Could not get cargo version from semver',\n );\n return currentValue;\n }\n // Keep new range precision the same as current\n if (\n (currentValue.startsWith('~') || currentValue.startsWith('^')) &&\n rangeStrategy === 'replace' &&\n newCargo.split('.').length > currentValue.split('.').length\n ) {\n newCargo = newCargo\n .split('.')\n .slice(0, currentValue.split('.').length)\n .join('.');\n }\n // Try to reverse any caret we added\n if (newCargo.startsWith('^') && !currentValue.startsWith('^')) {\n const withoutCaret = newCargo.substring(1);\n // NOTE: We want the number of components in the new version to match the original.\n // e.g. \"5.0\" should be updated to \"6.0\".\n const components = currentValue.split('.').length;\n newCargo = withoutCaret.split('.').slice(0, components).join('.');\n }\n\n return newCargo;\n}\n\nfunction isBreaking(current: string, version: string): boolean {\n // The change may be breaking if either version is unstable\n if (!semver.is(version) || !semver.is(current)) {\n return true;\n }\n const currentMajor = getMajor(current);\n if (currentMajor === 0) {\n if (getMinor(current) === 0) {\n // This can only be non-breaking if they're the same version\n return current !== version;\n }\n // v0.x updates are breaking if x changes\n return getMinor(current) !== getMinor(version);\n }\n // Otherwise, only major updates are breaking\n return currentMajor !== getMajor(version);\n}\n\nexport const api: VersioningApi = {\n ...npm,\n getNewValue,\n getPinnedValue,\n isBreaking,\n isLessThanRange,\n isSingleVersion,\n isValid,\n matches,\n getSatisfyingVersion,\n minSatisfyingVersion,\n};\nexport default api;\n"],"mappings":";;;;;;AAQA,MAAa,KAAK;AAQlB,SAAS,UAAU,OAAwB;CACzC,OAAOA,MAAI,UAAU,KAAK;AAC5B;AAEA,SAAS,eAAe,MAAsB;CAI5C,IAAI,UAAU,IAAI,KAAK,UAAU,GAAG,KAAK,GAAG,KAAK,UAAU,GAAG,KAAK,KAAK,GACtE,OAAO,IAAI,K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ACC,OAAO,GAAG,OAAO,KAAK,CAACA,OAAO,GAAG,OAAO,GAC3C,OAAO;CAET,MAAM,eAAeC,MAAS,OAAO;CACrC,IAAI,iBAAiB,GAAG;EACtB,IAAIC,MAAS,OAAO,MAAM,GAExB,OAAO,YAAY;EAGrB,OAAOA,MAAS,OAAO,MAAMA,MAAS,OAAO;CAC/C;CAEA,OAAO,iBAAiBD,MAAS,OAAO;AAC1C;AAEA,MAAa,MAAqB;CAChC,GAAGF;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["npm","semver","getMajor","getMinor"],"sources":["../../../../lib/modules/versioning/cargo/index.ts"],"sourcesContent":["import { major as getMajor, minor as getMinor } from 'semver';\nimport semver from 'semver-stable';\nimport { logger } from '../../../logger/index.ts';\nimport type { RangeStrategy } from '../../../types/versioning.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { api as npm } from '../npm/index.ts';\nimport type { NewValueConfig, VersioningApi } from '../types.ts';\n\nexport const id = 'cargo';\nexport const displayName = 'Cargo';\nexport const urls = [\n '[Cargo - Specifying Dependencies](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html)',\n];\nexport const supportsRanges = true;\nexport const supportedRangeStrategies: RangeStrategy[] = ['bump', 'replace'];\n\nfunction isVersion(input: string): boolean {\n return npm.isVersion(input);\n}\n\nfunction convertToCaret(item: string): string {\n // In Cargo, caret versions are used by default, so \"1.2.3\" actually means ^1.2.3.\n // Similarly, \"0.4\" actually means ^0.4.\n // See: https://doc.rust-lang.org/stable/cargo/reference/specifying-dependencies.html#caret-requirements\n if (isVersion(item) || isVersion(`${item}.0`) || isVersion(`${item}.0.0`)) {\n return `^${item.trim()}`;\n }\n return item.trim();\n}\n\nfunction cargo2npm(input: string): string {\n let versions = input.split(',');\n versions = versions.map(convertToCaret);\n return versions.join(' ');\n}\n\nfunction notEmpty(s: string): boolean {\n return s !== '';\n}\n\nfunction npm2cargo(input: string): string {\n // istanbul ignore if\n if (!input) {\n return input;\n }\n // Note: this doesn't remove the ^\n const res = input\n .split(regEx(/\\s+,?\\s*|\\s*,?\\s+/))\n .map((str) => str.trim())\n .filter(notEmpty);\n const operators = ['^', '~', '=', '>', '<', '<=', '>='];\n for (let i = 0; i < res.length - 1; i += 1) {\n if (operators.includes(res[i])) {\n const newValue = `${res[i]} ${res[i + 1]}`;\n res.splice(i, 2, newValue);\n }\n }\n return res.join(', ');\n}\n\nfunction isLessThanRange(version: string, range: string): boolean {\n return !!npm.isLessThanRange?.(version, cargo2npm(range));\n}\n\nexport function isValid(input: string): boolean {\n return npm.isValid(cargo2npm(input));\n}\n\nfunction matches(version: string, range: string): boolean {\n return npm.matches(version, cargo2npm(range));\n}\n\nfunction getSatisfyingVersion(\n versions: string[],\n range: string,\n): string | null {\n return npm.getSatisfyingVersion(versions, cargo2npm(range));\n}\n\nfunction minSatisfyingVersion(\n versions: string[],\n range: string,\n): string | null {\n return npm.minSatisfyingVersion(versions, cargo2npm(range));\n}\n\nfunction isSingleVersion(constraint: string): boolean {\n return (\n constraint.trim().startsWith('=') &&\n isVersion(constraint.trim().substring(1).trim())\n );\n}\n\nfunction getPinnedValue(newVersion: string): string {\n return `=${newVersion}`;\n}\n\nfunction getNewValue({\n currentValue,\n rangeStrategy,\n currentVersion,\n newVersion,\n}: NewValueConfig): string {\n if (!currentValue || currentValue === '*') {\n return currentValue;\n }\n // If the current value is a simple version, bump to fully specified newVersion\n if (rangeStrategy === 'bump' && regEx(/^\\d+(?:\\.\\d+)*$/).test(currentValue)) {\n return newVersion;\n }\n if (isSingleVersion(currentValue)) {\n let res = '=';\n if (currentValue.startsWith('= ')) {\n res += ' ';\n }\n res += newVersion;\n return res;\n }\n if (rangeStrategy === 'replace' && matches(newVersion, currentValue)) {\n return currentValue;\n }\n const newSemver = npm.getNewValue({\n currentValue: cargo2npm(currentValue),\n rangeStrategy,\n currentVersion,\n newVersion,\n });\n let newCargo = newSemver\n ? npm2cargo(newSemver)\n : /* istanbul ignore next: should never happen */ null;\n // istanbul ignore if\n if (!newCargo) {\n logger.info(\n { currentValue, newSemver },\n 'Could not get cargo version from semver',\n );\n return currentValue;\n }\n // Keep new range precision the same as current\n if (\n (currentValue.startsWith('~') || currentValue.startsWith('^')) &&\n rangeStrategy === 'replace' &&\n newCargo.split('.').length > currentValue.split('.').length\n ) {\n newCargo = newCargo\n .split('.')\n .slice(0, currentValue.split('.').length)\n .join('.');\n }\n // Try to reverse any caret we added\n if (newCargo.startsWith('^') && !currentValue.startsWith('^')) {\n const withoutCaret = newCargo.substring(1);\n // NOTE: We want the number of components in the new version to match the original.\n // e.g. \"5.0\" should be updated to \"6.0\".\n const components = currentValue.split('.').length;\n newCargo = withoutCaret.split('.').slice(0, components).join('.');\n }\n\n return newCargo;\n}\n\nfunction subset(subRange: string, superRange: string): boolean | undefined {\n try {\n return npm.subset!(cargo2npm(subRange), cargo2npm(superRange));\n } catch (err) {\n logger.debug({ err }, 'cargo.subset error');\n return false;\n }\n}\n\nfunction intersects(subRange: string, superRange: string): boolean {\n try {\n return npm.intersects!(cargo2npm(subRange), cargo2npm(superRange));\n } catch (err) {\n logger.debug({ err }, 'cargo.intersects error');\n return false;\n }\n}\n\nfunction isBreaking(current: string, version: string): boolean {\n // The change may be breaking if either version is unstable\n if (!semver.is(version) || !semver.is(current)) {\n return true;\n }\n const currentMajor = getMajor(current);\n if (currentMajor === 0) {\n if (getMinor(current) === 0) {\n // This can only be non-breaking if they're the same version\n return current !== version;\n }\n // v0.x updates are breaking if x changes\n return getMinor(current) !== getMinor(version);\n }\n // Otherwise, only major updates are breaking\n return currentMajor !== getMajor(version);\n}\n\nexport const api: VersioningApi = {\n ...npm,\n getNewValue,\n getPinnedValue,\n isBreaking,\n isLessThanRange,\n isSingleVersion,\n isValid,\n matches,\n getSatisfyingVersion,\n minSatisfyingVersion,\n subset,\n intersects,\n};\nexport default api;\n"],"mappings":";;;;;;AAQA,MAAa,KAAK;AAQlB,SAAS,U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MAAM,GAAG,CAAC,CAAC;EAC3C,WAAW,aAAa,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC,KAAK,GAAG;CAClE;CAEA,OAAO;AACT;AAEA,SAAS,OAAO,UAAkB,YAAyC;CACzE,IAAI;EACF,OAAOA,MAAI,OAAQ,UAAU,QAAQ,GAAG,UAAU,UAAU,CAAC;CAC/D,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,oBAAoB;EAC1C,OAAO;CACT;AACF;AAEA,SAAS,WAAW,UAAkB,YAA6B;CACjE,IAAI;EACF,OAAOA,MAAI,WAAY,UAAU,QAAQ,GAAG,UAAU,UAAU,CAAC;CACnE,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,wBAAwB;EAC9C,OAAO;CACT;AACF;AAEA,SAAS,WAAW,SAAiB,SAA0B;CAE7D,IAAI,CAACC,OAAO,GAAG,OAAO,KAAK,CAACA,OAAO,GAAG,OAAO,GAC3C,OAAO;CAET,MAAM,eAAeC,MAAS,OAAO;CACrC,IAAI,iBAAiB,GAAG;EACtB,IAAIC,MAAS,OAAO,MAAM,GAExB,OAAO,YAAY;EAGrB,OAAOA,MAAS,OAAO,MAAMA,MAAS,OAAO;CAC/C;CAEA,OAAO,iBAAiBD,MAAS,OAAO;AAC1C;AAEA,MAAa,MAAqB;CAChC,GAAGF;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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,
|