@pnpm/git-fetcher
Advanced tools
Comparing version 5.0.0 to 5.1.0
import { Cafs, DeferredManifestPromise } from '@pnpm/fetcher-base'; | ||
declare const _default: () => { | ||
declare const _default: (createOpts?: { | ||
gitShallowHosts?: string[] | undefined; | ||
} | undefined) => { | ||
git: (cafs: Cafs, resolution: { | ||
@@ -4,0 +6,0 @@ commit: string; |
@@ -10,7 +10,16 @@ "use strict"; | ||
const execa_1 = __importDefault(require("execa")); | ||
exports.default = () => { | ||
const url_1 = require("url"); | ||
exports.default = (createOpts) => { | ||
const allowedHosts = new Set(createOpts?.gitShallowHosts ?? []); | ||
return { | ||
git: async function fetchFromGit(cafs, resolution, opts) { | ||
const tempLocation = await cafs.tempDir(); | ||
await execGit(['clone', resolution.repo, tempLocation]); | ||
if (allowedHosts.size > 0 && shouldUseShallow(resolution.repo, allowedHosts)) { | ||
await execGit(['init'], { cwd: tempLocation }); | ||
await execGit(['remote', 'add', 'origin', resolution.repo], { cwd: tempLocation }); | ||
await execGit(['fetch', '--depth', '1', 'origin', resolution.commit], { cwd: tempLocation }); | ||
} | ||
else { | ||
await execGit(['clone', resolution.repo, tempLocation]); | ||
} | ||
await execGit(['checkout', resolution.commit], { cwd: tempLocation }); | ||
@@ -28,2 +37,14 @@ await (0, prepare_package_1.default)(tempLocation); | ||
}; | ||
function shouldUseShallow(repoUrl, allowedHosts) { | ||
try { | ||
const { host } = new url_1.URL(repoUrl); | ||
if (allowedHosts.has(host)) { | ||
return true; | ||
} | ||
} | ||
catch (e) { | ||
// URL might be malformed | ||
} | ||
return false; | ||
} | ||
function prefixGitArgs() { | ||
@@ -30,0 +51,0 @@ return process.platform === 'win32' ? ['-c', 'core.longpaths=true'] : []; |
{ | ||
"name": "@pnpm/git-fetcher", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "A fetcher for git-hosted packages", | ||
@@ -27,3 +27,3 @@ "main": "lib/index.js", | ||
"@pnpm/fetcher-base": "12.0.0", | ||
"@pnpm/prepare-package": "2.0.0", | ||
"@pnpm/prepare-package": "2.0.1", | ||
"@zkochan/rimraf": "^2.1.2", | ||
@@ -34,4 +34,4 @@ "execa": "npm:safe-execa@^0.1.1" | ||
"@pnpm/cafs": "4.0.0", | ||
"@pnpm/git-fetcher": "5.0.0", | ||
"@pnpm/package-store": "13.0.0", | ||
"@pnpm/git-fetcher": "5.1.0", | ||
"@pnpm/package-store": "13.0.1", | ||
"@pnpm/types": "8.0.0", | ||
@@ -38,0 +38,0 @@ "p-defer": "^3.0.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7366
69
+ Added@pnpm/constants@6.1.0(transitive)
+ Added@pnpm/error@3.0.1(transitive)
+ Added@pnpm/prepare-package@2.0.1(transitive)
+ Added@pnpm/read-package-json@6.0.1(transitive)
- Removed@pnpm/constants@6.0.0(transitive)
- Removed@pnpm/error@3.0.0(transitive)
- Removed@pnpm/prepare-package@2.0.0(transitive)
- Removed@pnpm/read-package-json@6.0.0(transitive)
Updated@pnpm/prepare-package@2.0.1