@vltpkg/git 0.0.0-3 → 0.0.0-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/README.md +36 -41
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -4,11 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
A utility for spawning git from npm CLI contexts.
|
|
6
6
|
|
|
7
|
-
**[Usage](#usage)**
|
|
8
|
-
·
|
|
9
|
-
**[API](#api)**
|
|
10
|
-
·
|
|
11
|
-
**[Options](#options)**
|
|
7
|
+
**[Usage](#usage)** · **[API](#api)** · **[Options](#options)**
|
|
12
8
|
|
|
13
9
|
## Overview
|
|
14
10
|
|
|
@@ -49,23 +45,23 @@ All the other functions call this one at some point.
|
|
|
49
45
|
Processes are launched using
|
|
50
46
|
[`@vltpkg/promise-spawn`](http://npm.im/@vltpkg/promise-spawn).
|
|
51
47
|
|
|
52
|
-
Return value is a `SpawnPromise` that resolves to a result object
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
Return value is a `SpawnPromise` that resolves to a result object with
|
|
49
|
+
`{cmd, args, code, signal, stdout, stderr}` members, or rejects with
|
|
50
|
+
an error with the same fields, passed back from
|
|
55
51
|
[`@vltpkg/promise-spawn`](http://npm.im/@vltpkg/promise-spawn).
|
|
56
52
|
|
|
57
53
|
### `clone(repo, ref = 'HEAD', target = null, opts = {})` -> `Promise<sha string>`
|
|
58
54
|
|
|
59
|
-
Clone the repository into `target` path (or the default path for the
|
|
60
|
-
of the repository), checking out `ref`.
|
|
55
|
+
Clone the repository into `target` path (or the default path for the
|
|
56
|
+
name of the repository), checking out `ref`.
|
|
61
57
|
|
|
62
58
|
Return value is the sha of the current HEAD in the locally cloned
|
|
63
59
|
repository.
|
|
64
60
|
|
|
65
|
-
In lieu of a specific `ref`, you may also pass in a `spec` option,
|
|
66
|
-
a [`npm-package-arg`](http://npm.im/npm-package-arg) object
|
|
67
|
-
package dependency reference. In this way, you can select
|
|
68
|
-
within a range, or any git committish value. For example:
|
|
61
|
+
In lieu of a specific `ref`, you may also pass in a `spec` option,
|
|
62
|
+
which is a [`npm-package-arg`](http://npm.im/npm-package-arg) object
|
|
63
|
+
for a `git` package dependency reference. In this way, you can select
|
|
64
|
+
SemVer tags within a range, or any git committish value. For example:
|
|
69
65
|
|
|
70
66
|
```js
|
|
71
67
|
import { Spec } from '@vltpkg/spec'
|
|
@@ -75,17 +71,16 @@ clone('git@github.com:npm/git.git', '', null, {
|
|
|
75
71
|
})
|
|
76
72
|
```
|
|
77
73
|
|
|
78
|
-
This will automatically do a shallow `--depth=1` clone on any hosts
|
|
79
|
-
are known to support it. To force a shallow or deep clone, you
|
|
80
|
-
`gitShallow` option to `true` or `false` respectively.
|
|
74
|
+
This will automatically do a shallow `--depth=1` clone on any hosts
|
|
75
|
+
that are known to support it. To force a shallow or deep clone, you
|
|
76
|
+
can set the `gitShallow` option to `true` or `false` respectively.
|
|
81
77
|
|
|
82
78
|
### `revs(repo, opts = {})` -> `Promise<rev doc Object>`
|
|
83
79
|
|
|
84
80
|
Fetch a representation of all of the named references in a given
|
|
85
81
|
repository. The resulting doc is intentionally somewhat
|
|
86
|
-
packument-like, so that git semver ranges can be applied using
|
|
87
|
-
|
|
88
|
-
[`@vltpkg/pick-manifest`](http://npm.im/@vltpkg/pick-manifest)
|
|
82
|
+
packument-like, so that git semver ranges can be applied using the
|
|
83
|
+
same [`@vltpkg/pick-manifest`](http://npm.im/@vltpkg/pick-manifest)
|
|
89
84
|
logic.
|
|
90
85
|
|
|
91
86
|
The resulting object looks like:
|
|
@@ -131,30 +126,30 @@ revs = {
|
|
|
131
126
|
Resolve to `true` if the `cwd` option refers to the root of a git
|
|
132
127
|
repository.
|
|
133
128
|
|
|
134
|
-
It does this by looking for a file or folder at `${path}/.git`,
|
|
135
|
-
|
|
129
|
+
It does this by looking for a file or folder at `${path}/.git`, which
|
|
130
|
+
is not an airtight indicator, but usually pretty reliable.
|
|
136
131
|
|
|
137
132
|
### `git.find(opts)` -> `Promise<string | undefined>`
|
|
138
133
|
|
|
139
|
-
Given a path, walk up the file system tree until a git repo
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
134
|
+
Given a path, walk up the file system tree until a git repo working
|
|
135
|
+
directory is found. Since this calls `stat` a bunch of times, it's
|
|
136
|
+
probably best to only call it if you're reasonably sure you're likely
|
|
137
|
+
to be in a git project somewhere. Pass in `opts.root` to stop checking
|
|
138
|
+
at that directory.
|
|
144
139
|
|
|
145
140
|
Resolves to `undefined` if not in a git project.
|
|
146
141
|
|
|
147
142
|
### `isClean(opts = {})` -> `Promise<boolean>`
|
|
148
143
|
|
|
149
|
-
Return true if in a git dir, and that git dir is free of changes.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
Return true if in a git dir, and that git dir is free of changes. This
|
|
145
|
+
will resolve `true` if the git working dir is clean, or `false` if
|
|
146
|
+
not, and reject if the path is not within a git directory or some
|
|
147
|
+
other error occurs.
|
|
153
148
|
|
|
154
149
|
### `getUser(opts = {})` -> `Promise<{name, email} | undefined>`
|
|
155
150
|
|
|
156
|
-
Returns the user.name and user.email from the git config if found.
|
|
157
|
-
|
|
151
|
+
Returns the user.name and user.email from the git config if found. If
|
|
152
|
+
no value is found, it will return `undefined`.
|
|
158
153
|
|
|
159
154
|
## Options
|
|
160
155
|
|
|
@@ -164,15 +159,15 @@ If no value is found, it will return `undefined`.
|
|
|
164
159
|
- `factor`: Defaults to `opts.fetchRetryFactor` or 10
|
|
165
160
|
- `maxTimeout`: Defaults to `opts.fetchRetryMaxtimeout` or 60000
|
|
166
161
|
- `minTimeout`: Defaults to `opts.fetchRetryMintimeout` or 1000
|
|
167
|
-
- `git` Path to the `git` binary to use. Will look up the first `git`
|
|
168
|
-
the `PATH` if not specified.
|
|
169
|
-
- `spec` The [`@vltpkg/spec`](http://npm.im/@vltpkg/spec)
|
|
170
|
-
|
|
171
|
-
- `fakePlatform` set to a fake value of `process.platform` to use.
|
|
172
|
-
for testing `win32` behavior on Unix, and vice versa.)
|
|
162
|
+
- `git` Path to the `git` binary to use. Will look up the first `git`
|
|
163
|
+
in the `PATH` if not specified.
|
|
164
|
+
- `spec` The [`@vltpkg/spec`](http://npm.im/@vltpkg/spec) specifier
|
|
165
|
+
object for the thing being fetched (if relevant).
|
|
166
|
+
- `fakePlatform` set to a fake value of `process.platform` to use.
|
|
167
|
+
(Just for testing `win32` behavior on Unix, and vice versa.)
|
|
173
168
|
- `cwd` The current working dir for the git command. Particularly for
|
|
174
|
-
`find` and `is` and `isClean`, it's good to know that this defaults
|
|
175
|
-
`process.cwd()`, as one might expect.
|
|
169
|
+
`find` and `is` and `isClean`, it's good to know that this defaults
|
|
170
|
+
to `process.cwd()`, as one might expect.
|
|
176
171
|
- Any other options that can be passed to
|
|
177
172
|
[`@vltpkg/promise-spawn`](http://npm.im/@vltpkg/promise-spawn), or
|
|
178
173
|
`child_process.spawn()`.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/git",
|
|
3
3
|
"description": "a util for spawning git from npm CLI contexts",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-5",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"lru-cache": "^11.0.2",
|
|
24
24
|
"promise-retry": "^2.0.1",
|
|
25
25
|
"retry": "^0.13.1",
|
|
26
|
-
"@vltpkg/git-scp-url": "0.0.0-
|
|
27
|
-
"@vltpkg/
|
|
28
|
-
"@vltpkg/promise-spawn": "0.0.0-
|
|
29
|
-
"@vltpkg/
|
|
30
|
-
"@vltpkg/
|
|
31
|
-
"@vltpkg/
|
|
32
|
-
"@vltpkg/
|
|
26
|
+
"@vltpkg/git-scp-url": "0.0.0-5",
|
|
27
|
+
"@vltpkg/error-cause": "0.0.0-5",
|
|
28
|
+
"@vltpkg/promise-spawn": "0.0.0-5",
|
|
29
|
+
"@vltpkg/pick-manifest": "0.0.0-5",
|
|
30
|
+
"@vltpkg/spec": "0.0.0-5",
|
|
31
|
+
"@vltpkg/semver": "0.0.0-5",
|
|
32
|
+
"@vltpkg/which": "0.0.0-5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@eslint/js": "^9.20.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"typedoc": "0.27.6",
|
|
44
44
|
"typescript": "5.7.3",
|
|
45
45
|
"typescript-eslint": "^8.23.0",
|
|
46
|
-
"@vltpkg/types": "0.0.0-
|
|
46
|
+
"@vltpkg/types": "0.0.0-5"
|
|
47
47
|
},
|
|
48
48
|
"license": "ISC",
|
|
49
49
|
"engines": {
|