diff options
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/@npmcli/git')
17 files changed, 748 insertions, 0 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/LICENSE b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/LICENSE new file mode 100644 index 00000000..8f90f96f --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) npm, Inc. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE NPM DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE NPM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, +OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/README.md b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/README.md new file mode 100644 index 00000000..ca8afcbc --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/README.md @@ -0,0 +1,157 @@ +# @npmcli/git + +A utility for spawning git from npm CLI contexts. + +This is _not_ an implementation of git itself, it's just a thing that +spawns child processes to tell the system git CLI implementation to do +stuff. + +## USAGE + +```js +const git = require('@npmcli/git') +git.clone('git://foo/bar.git', 'some-branch', 'some-path', opts) // clone a repo + .then(() => git.spawn(['checkout', 'some-branch'], {cwd: 'bar'})) + .then(() => git.spawn(['you get the idea'])) +``` + +## API + +Most methods take an options object. Options are described below. + +### `git.spawn(args, opts = {})` + +Launch a `git` subprocess with the arguments specified. + +All the other functions call this one at some point. + +Processes are launched using +[`@npmcli/promise-spawn`](http://npm.im/@npmcli/promise-spawn), with the +`stdioString: true` option enabled by default, since git output is +generally in readable string format. + +Return value is a `Promise` that resolves to a result object with `{cmd, +args, code, signal, stdout, stderr}` members, or rejects with an error with +the same fields, passed back from +[`@npmcli/promise-spawn`](http://npm.im/@npmcli/promise-spawn). + +### `git.clone(repo, ref = 'HEAD', target = null, opts = {})` -> `Promise<sha String>` + +Clone the repository into `target` path (or the default path for the name +of the repository), checking out `ref`. + +Return value is the sha of the current HEAD in the locally cloned +repository. + +In lieu of a specific `ref`, you may also pass in a `spec` option, which is +a [`npm-package-arg`](http://npm.im/npm-package-arg) object for a `git` +package dependency reference. In this way, you can select SemVer tags +within a range, or any git committish value. For example: + +```js +const npa = require('npm-package-arg') +git.clone('git@github.com:npm/git.git', '', null, { + spec: npa('github:npm/git#semver:1.x'), +}) + +// only gitRange and gitCommittish are relevant, so this works, too +git.clone('git@github.com:npm/git.git', null, null, { + spec: { gitRange: '1.x' } +}) +``` + +This will automatically do a shallow `--depth=1` clone on any hosts that +are known to support it. To force a shallow or deep clone, you can set the +`gitShallow` option to `true` or `false` respectively. + +### `git.revs(repo, opts = {})` -> `Promise<rev doc Object>` + +Fetch a representation of all of the named references in a given +repository. The resulting doc is intentionally somewhat +[packument](https://www.npmjs.com/package/pacote#packuments)-like, so that +git semver ranges can be applied using the same +[`npm-pick-manifest`](http://npm.im/npm-pick-manifest) logic. + +The resulting object looks like: + +```js +revs = { + versions: { + // all semver-looking tags go in here... + // version: { sha, ref, rawRef, type } + '1.0.0': { + sha: '1bc5fba3353f8e1b56493b266bc459276ab23139', + ref: 'v1.0.0', + rawRef: 'refs/tags/v1.0.0', + type: 'tag', + }, + }, + 'dist-tags': { + HEAD: '1.0.0', + latest: '1.0.0', + }, + refs: { + // all the advertised refs that can be cloned down remotely + HEAD: { sha, ref, rawRef, type: 'head' }, + master: { ... }, + 'v1.0.0': { ... }, + 'refs/tags/v1.0.0': { ... }, + }, + shas: { + // all named shas referenced above + // sha: [list, of, refs] + '6b2501f9183a1753027a9bf89a184b7d3d4602c7': [ + 'HEAD', + 'master', + 'refs/heads/master', + ], + '1bc5fba3353f8e1b56493b266bc459276ab23139': [ 'v1.0.0', 'refs/tags/v1.0.0' ], + }, +} +``` + +### `git.is(opts)` -> `Promise<Boolean>` + +Resolve to `true` if the path argument refers to the root of a git +repository. + +It does this by looking for a file in `${path}/.git/index`, which is not an +airtight indicator, but at least avoids being fooled by an empty directory +or a file named `.git`. + +### `git.find(opts)` -> `Promise<String | null>` + +Given a path, walk up the file system tree until a git repo working +directory is found. Since this calls `stat` a bunch of times, it's +probably best to only call it if you're reasonably sure you're likely to be +in a git project somewhere. + +Resolves to `null` if not in a git project. + +### `git.isClean(opts = {})` -> `Promise<Boolean>` + +Return true if in a git dir, and that git dir is free of changes. This +will resolve `true` if the git working dir is clean, or `false` if not, and +reject if the path is not within a git directory or some other error +occurs. + +## OPTIONS + +- `retry` An object to configure retry behavior for transient network + errors with exponential backoff. + - `retries`: Defaults to `opts.fetchRetries` or 2 + - `factor`: Defaults to `opts.fetchRetryFactor` or 10 + - `maxTimeout`: Defaults to `opts.fetchRetryMaxtimeout` or 60000 + - `minTimeout`: Defaults to `opts.fetchRetryMintimeout` or 1000 +- `git` Path to the `git` binary to use. Will look up the first `git` in + the `PATH` if not specified. +- `spec` The [`npm-package-arg`](http://npm.im/npm-package-arg) specifier + object for the thing being fetched (if relevant). +- `fakePlatform` set to a fake value of `process.platform` to use. (Just + for testing `win32` behavior on Unix, and vice versa.) +- `cwd` The current working dir for the git command. Particularly for + `find` and `is` and `isClean`, it's good to know that this defaults to + `process.cwd()`, as one might expect. +- Any other options that can be passed to + [`@npmcli/promise-spawn`](http://npm.im/@npmcli/promise-spawn), or + `child_process.spawn()`. diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/clone.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/clone.js new file mode 100644 index 00000000..6754fd76 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/clone.js @@ -0,0 +1,163 @@ +// The goal here is to minimize both git workload and +// the number of refs we download over the network. +// +// Every method ends up with the checked out working dir +// at the specified ref, and resolves with the git sha. + +// Only certain whitelisted hosts get shallow cloning. +// Many hosts (including GHE) don't always support it. +// A failed shallow fetch takes a LOT longer than a full +// fetch in most cases, so we skip it entirely. +// Set opts.gitShallow = true/false to force this behavior +// one way or the other. +const shallowHosts = new Set([ + 'github.com', + 'gist.github.com', + 'gitlab.com', + 'bitbucket.com', + 'bitbucket.org' +]) +// we have to use url.parse until we add the same shim that hosted-git-info has +// to handle scp:// urls +const { parse } = require('url') // eslint-disable-line node/no-deprecated-api +const { basename, resolve } = require('path') + +const revs = require('./revs.js') +const spawn = require('./spawn.js') +const { isWindows } = require('./utils.js') + +const pickManifest = require('npm-pick-manifest') +const fs = require('fs') +const mkdirp = require('mkdirp') + +module.exports = (repo, ref = 'HEAD', target = null, opts = {}) => + revs(repo, opts).then(revs => clone( + repo, + revs, + ref, + resolveRef(revs, ref, opts), + target || defaultTarget(repo, opts.cwd), + opts + )) + +const maybeShallow = (repo, opts) => { + if (opts.gitShallow === false || opts.gitShallow) { + return opts.gitShallow + } + return shallowHosts.has(parse(repo).host) +} + +const defaultTarget = (repo, /* istanbul ignore next */ cwd = process.cwd()) => + resolve(cwd, basename(repo.replace(/[/\\]?\.git$/, ''))) + +const clone = (repo, revs, ref, revDoc, target, opts) => { + if (!revDoc) { + return unresolved(repo, ref, target, opts) + } + if (revDoc.sha === revs.refs.HEAD.sha) { + return plain(repo, revDoc, target, opts) + } + if (revDoc.type === 'tag' || revDoc.type === 'branch') { + return branch(repo, revDoc, target, opts) + } + return other(repo, revDoc, target, opts) +} + +const resolveRef = (revs, ref, opts) => { + const { spec = {} } = opts + ref = spec.gitCommittish || ref + /* istanbul ignore next - will fail anyway, can't pull */ + if (!revs) { + return null + } + if (spec.gitRange) { + return pickManifest(revs, spec.gitRange, opts) + } + if (!ref) { + return revs.refs.HEAD + } + if (revs.refs[ref]) { + return revs.refs[ref] + } + if (revs.shas[ref]) { + return revs.refs[revs.shas[ref][0]] + } + return null +} + +// pull request or some other kind of advertised ref +const other = (repo, revDoc, target, opts) => { + const shallow = maybeShallow(repo, opts) + + const fetchOrigin = ['fetch', 'origin', revDoc.rawRef] + .concat(shallow ? ['--depth=1'] : []) + + const git = (args) => spawn(args, { ...opts, cwd: target }) + return mkdirp(target) + .then(() => git(['init'])) + .then(() => isWindows(opts) + ? git(['config', '--local', '--add', 'core.longpaths', 'true']) + : null) + .then(() => git(['remote', 'add', 'origin', repo])) + .then(() => git(fetchOrigin)) + .then(() => git(['checkout', revDoc.sha])) + .then(() => updateSubmodules(target, opts)) + .then(() => revDoc.sha) +} + +// tag or branches. use -b +const branch = (repo, revDoc, target, opts) => { + const args = [ + 'clone', + '-b', + revDoc.ref, + repo, + target, + '--recurse-submodules' + ] + if (maybeShallow(repo, opts)) { args.push('--depth=1') } + if (isWindows(opts)) { args.push('--config', 'core.longpaths=true') } + return spawn(args, opts).then(() => revDoc.sha) +} + +// just the head. clone it +const plain = (repo, revDoc, target, opts) => { + const args = [ + 'clone', + repo, + target, + '--recurse-submodules' + ] + if (maybeShallow(repo, opts)) { args.push('--depth=1') } + if (isWindows(opts)) { args.push('--config', 'core.longpaths=true') } + return spawn(args, opts).then(() => revDoc.sha) +} + +const updateSubmodules = (target, opts) => new Promise(resolve => + fs.stat(target + '/.gitmodules', er => { + if (er) { + return resolve(null) + } + return resolve(spawn([ + 'submodule', + 'update', + '-q', + '--init', + '--recursive' + ], { ...opts, cwd: target })) + })) + +const unresolved = (repo, ref, target, opts) => { + // can't do this one shallowly, because the ref isn't advertised + // but we can avoid checking out the working dir twice, at least + const lp = isWindows(opts) ? ['--config', 'core.longpaths=true'] : [] + const cloneArgs = ['clone', '--mirror', '-q', repo, target + '/.git'] + const git = (args) => spawn(args, { ...opts, cwd: target }) + return mkdirp(target) + .then(() => git(cloneArgs.concat(lp))) + .then(() => git(['init'])) + .then(() => git(['checkout', ref])) + .then(() => updateSubmodules(target, opts)) + .then(() => git(['rev-parse', '--revs-only', 'HEAD'])) + .then(({ stdout }) => stdout.trim()) +} diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/errors.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/errors.js new file mode 100644 index 00000000..25b2b9f9 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/errors.js @@ -0,0 +1,36 @@ + +const maxRetry = 3 + +class GitError extends Error { + shouldRetry () { + return false + } +} + +class GitConnectionError extends GitError { + constructor (message) { + super('A git connection error occurred') + } + + shouldRetry (number) { + return number < maxRetry + } +} + +class GitPathspecError extends GitError { + constructor (message) { + super('The git reference could not be found') + } +} + +class GitUnknownError extends GitError { + constructor (message) { + super('An unknown git error occurred') + } +} + +module.exports = { + GitConnectionError, + GitPathspecError, + GitUnknownError +} diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/find.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/find.js new file mode 100644 index 00000000..d58f01db --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/find.js @@ -0,0 +1,15 @@ +const is = require('./is.js') +const { dirname } = require('path') + +module.exports = async ({ cwd = process.cwd() } = {}) => { + if (await is({ cwd })) { + return cwd + } + while (cwd !== dirname(cwd)) { + cwd = dirname(cwd) + if (await is({ cwd })) { + return cwd + } + } + return null +} diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/index.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/index.js new file mode 100644 index 00000000..20d7cfd0 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/index.js @@ -0,0 +1,9 @@ +module.exports = { + clone: require('./clone.js'), + revs: require('./revs.js'), + spawn: require('./spawn.js'), + is: require('./is.js'), + find: require('./find.js'), + isClean: require('./is-clean.js'), + errors: require('./errors.js') +} diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/is-clean.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/is-clean.js new file mode 100644 index 00000000..182373be --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/is-clean.js @@ -0,0 +1,6 @@ +const spawn = require('./spawn.js') + +module.exports = (opts = {}) => + spawn(['status', '--porcelain=v1', '-uno'], opts) + .then(res => !res.stdout.trim().split(/\r?\n+/) + .map(l => l.trim()).filter(l => l).length) diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/is.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/is.js new file mode 100644 index 00000000..e2542f21 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/is.js @@ -0,0 +1,6 @@ +// not an airtight indicator, but a good gut-check to even bother trying +const { promisify } = require('util') +const fs = require('fs') +const stat = promisify(fs.stat) +module.exports = ({ cwd = process.cwd() } = {}) => + stat(cwd + '/.git').then(() => true, () => false) diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/lines-to-revs.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/lines-to-revs.js new file mode 100644 index 00000000..9f879ca2 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/lines-to-revs.js @@ -0,0 +1,141 @@ +// turn an array of lines from `git ls-remote` into a thing +// vaguely resembling a packument, where docs are a resolved ref + +const semver = require('semver') + +module.exports = lines => finish(lines.reduce(linesToRevsReducer, { + versions: {}, + 'dist-tags': {}, + refs: {}, + shas: {} +})) + +const finish = revs => distTags(shaList(peelTags(revs))) + +// We can check out shallow clones on specific SHAs if we have a ref +const shaList = revs => { + Object.keys(revs.refs).forEach(ref => { + const doc = revs.refs[ref] + if (!revs.shas[doc.sha]) { + revs.shas[doc.sha] = [ref] + } else { + revs.shas[doc.sha].push(ref) + } + }) + return revs +} + +// Replace any tags with their ^{} counterparts, if those exist +const peelTags = revs => { + Object.keys(revs.refs).filter(ref => ref.endsWith('^{}')).forEach(ref => { + const peeled = revs.refs[ref] + const unpeeled = revs.refs[ref.replace(/\^\{\}$/, '')] + if (unpeeled) { + unpeeled.sha = peeled.sha + delete revs.refs[ref] + } + }) + return revs +} + +const distTags = revs => { + // not entirely sure what situations would result in an + // ichabod repo, but best to be careful in Sleepy Hollow anyway + const HEAD = revs.refs.HEAD || /* istanbul ignore next */ {} + const versions = Object.keys(revs.versions) + versions.forEach(v => { + // simulate a dist-tags with latest pointing at the + // 'latest' branch if one exists and is a version, + // or HEAD if not. + const ver = revs.versions[v] + if (revs.refs.latest && ver.sha === revs.refs.latest.sha) { + revs['dist-tags'].latest = v + } else if (ver.sha === HEAD.sha) { + revs['dist-tags'].HEAD = v + if (!revs.refs.latest) { revs['dist-tags'].latest = v } + } + }) + return revs +} + +const refType = ref => { + if (ref.startsWith('refs/tags/')) { + return 'tag' + } + if (ref.startsWith('refs/heads/')) { + return 'branch' + } + if (ref.startsWith('refs/pull/')) { + return 'pull' + } + if (ref === 'HEAD') { + return 'head' + } + // Could be anything, ignore for now + /* istanbul ignore next */ + return 'other' +} + +// return the doc, or null if we should ignore it. +const lineToRevDoc = line => { + const split = line.trim().split(/\s+/, 2) + if (split.length < 2) { return null } + + const sha = split[0].trim() + const rawRef = split[1].trim() + const type = refType(rawRef) + + if (type === 'tag') { + // refs/tags/foo^{} is the 'peeled tag', ie the commit + // that is tagged by refs/tags/foo they resolve to the same + // content, just different objects in git's data structure. + // But, we care about the thing the tag POINTS to, not the tag + // object itself, so we only look at the peeled tag refs, and + // ignore the pointer. + // For now, though, we have to save both, because some tags + // don't have peels, if they were not annotated. + const ref = rawRef.substr('refs/tags/'.length) + return { sha, ref, rawRef, type } + } + + if (type === 'branch') { + const ref = rawRef.substr('refs/heads/'.length) + return { sha, ref, rawRef, type } + } + + if (type === 'pull') { + // NB: merged pull requests installable with #pull/123/merge + // for the merged pr, or #pull/123 for the PR head + const ref = rawRef.substr('refs/'.length).replace(/\/head$/, '') + return { sha, ref, rawRef, type } + } + + if (type === 'head') { + const ref = 'HEAD' + return { sha, ref, rawRef, type } + } + + // at this point, all we can do is leave the ref un-munged + return { sha, ref: rawRef, rawRef, type } +} + +const linesToRevsReducer = (revs, line) => { + const doc = lineToRevDoc(line) + + if (!doc) { return revs } + + revs.refs[doc.ref] = doc + revs.refs[doc.rawRef] = doc + + if (doc.type === 'tag') { + // try to pull a semver value out of tags like `release-v1.2.3` + // which is a pretty common pattern. + const match = !doc.ref.endsWith('^{}') && + doc.ref.match(/v?(\d+\.\d+\.\d+(?:[-+].+)?)$/) + if (match && semver.valid(match[1], true)) { + revs.versions[semver.clean(match[1], true)] = doc + } + } + + return revs +} diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/make-error.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/make-error.js new file mode 100644 index 00000000..043a8e6e --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/make-error.js @@ -0,0 +1,33 @@ +const { + GitConnectionError, + GitPathspecError, + GitUnknownError +} = require('./errors.js') + +const connectionErrorRe = new RegExp([ + 'remote error: Internal Server Error', + 'The remote end hung up unexpectedly', + 'Connection timed out', + 'Operation timed out', + 'Failed to connect to .* Timed out', + 'Connection reset by peer', + 'SSL_ERROR_SYSCALL', + 'The requested URL returned error: 503' +].join('|')) + +const missingPathspecRe = /pathspec .* did not match any file\(s\) known to git/ + +function makeError (er) { + const message = er.stderr + let gitEr + if (connectionErrorRe.test(message)) { + gitEr = new GitConnectionError(message) + } else if (missingPathspecRe.test(message)) { + gitEr = new GitPathspecError(message) + } else { + gitEr = new GitUnknownError(message) + } + return Object.assign(gitEr, er) +} + +module.exports = makeError diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/opts.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/opts.js new file mode 100644 index 00000000..144e0a3a --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/opts.js @@ -0,0 +1,12 @@ +// Values we want to set if they're not already defined by the end user +// This defaults to accepting new ssh host key fingerprints +const gitEnv = { + GIT_ASKPASS: 'echo', + GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new' +} +module.exports = (opts = {}) => ({ + stdioString: true, + ...opts, + shell: false, + env: opts.env || { ...gitEnv, ...process.env } +}) diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/proc-log.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/proc-log.js new file mode 100644 index 00000000..b2bdd9dc --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/proc-log.js @@ -0,0 +1,21 @@ +// default logger. +// emits 'log' events on the process +const LEVELS = [ + 'notice', + 'error', + 'warn', + 'info', + 'verbose', + 'http', + 'silly', + 'pause', + 'resume' +] + +const log = level => (...args) => process.emit('log', level, ...args) + +const logger = {} +for (const level of LEVELS) { + logger[level] = log(level) +} +module.exports = logger diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/revs.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/revs.js new file mode 100644 index 00000000..81059594 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/revs.js @@ -0,0 +1,28 @@ +const pinflight = require('promise-inflight') +const spawn = require('./spawn.js') +const LRU = require('lru-cache') + +const revsCache = new LRU({ + max: 100, + maxAge: 5 * 60 * 1000 +}) + +const linesToRevs = require('./lines-to-revs.js') + +module.exports = async (repo, opts = {}) => { + if (!opts.noGitRevCache) { + const cached = revsCache.get(repo) + if (cached) { + return cached + } + } + + return pinflight(`ls-remote:${repo}`, () => + spawn(['ls-remote', repo], opts) + .then(({ stdout }) => linesToRevs(stdout.trim().split('\n'))) + .then(revs => { + revsCache.set(repo, revs) + return revs + }) + ) +} diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/spawn.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/spawn.js new file mode 100644 index 00000000..1c89a4c5 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/spawn.js @@ -0,0 +1,43 @@ +const spawn = require('@npmcli/promise-spawn') +const promiseRetry = require('promise-retry') +const makeError = require('./make-error.js') +const whichGit = require('./which.js') +const makeOpts = require('./opts.js') +const procLog = require('./proc-log.js') + +module.exports = (gitArgs, opts = {}) => { + const gitPath = whichGit(opts) + + if (gitPath instanceof Error) { return Promise.reject(gitPath) } + + // undocumented option, mostly only here for tests + const args = opts.allowReplace || gitArgs[0] === '--no-replace-objects' + ? gitArgs + : ['--no-replace-objects', ...gitArgs] + + const log = opts.log || procLog + let retry = opts.retry + if (retry === null || retry === undefined) { + retry = { + retries: opts.fetchRetries || 2, + factor: opts.fetchRetryFactor || 10, + maxTimeout: opts.fetchRetryMaxtimeout || 60000, + minTimeout: opts.fetchRetryMintimeout || 1000 + } + } + return promiseRetry((retry, number) => { + if (number !== 1) { + log.silly('git', `Retrying git command: ${ + args.join(' ')} attempt # ${number}`) + } + + return spawn(gitPath, args, makeOpts(opts)) + .catch(er => { + const gitError = makeError(er) + if (!gitError.shouldRetry(number)) { + throw gitError + } + retry(gitError) + }) + }, retry) +} diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/utils.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/utils.js new file mode 100644 index 00000000..fcd9578a --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/utils.js @@ -0,0 +1,3 @@ +const isWindows = opts => (opts.fakePlatform || process.platform) === 'win32' + +exports.isWindows = isWindows diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/which.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/which.js new file mode 100644 index 00000000..a2f690e1 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/lib/which.js @@ -0,0 +1,16 @@ +const which = require('which') + +let gitPath +try { + gitPath = which.sync('git') +} catch (e) {} + +module.exports = (opts = {}) => { + if (opts.git) { + return opts.git + } + if (!gitPath || opts.git === false) { + return Object.assign(new Error('No git binary found in $PATH'), { code: 'ENOGIT' }) + } + return gitPath +} diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/git/package.json b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/package.json new file mode 100644 index 00000000..9475da50 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/git/package.json @@ -0,0 +1,44 @@ +{ + "name": "@npmcli/git", + "version": "2.1.0", + "main": "lib/index.js", + "files": [ + "lib/*.js" + ], + "description": "a util for spawning git from npm CLI contexts", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/git" + }, + "author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)", + "license": "ISC", + "scripts": { + "lint": "standard", + "lint:fix": "standard --fix", + "postversion": "npm publish", + "prepublishOnly": "git push origin --follow-tags", + "preversion": "npm test", + "snap": "tap", + "test": "tap", + "posttest": "npm run lint" + }, + "tap": { + "check-coverage": true, + "coverage-map": "map.js" + }, + "devDependencies": { + "slash": "^3.0.0", + "standard": "^16.0.3", + "tap": "^15.0.6" + }, + "dependencies": { + "@npmcli/promise-spawn": "^1.3.2", + "lru-cache": "^6.0.0", + "mkdirp": "^1.0.4", + "npm-pick-manifest": "^6.1.1", + "promise-inflight": "^1.0.1", + "promise-retry": "^2.0.1", + "semver": "^7.3.5", + "which": "^2.0.2" + } +} |