@vltpkg/spec 0.0.0-3 → 0.0.0-4
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 +69 -78
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,12 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
This is a library for parsing **package specifiers**.
|
|
6
6
|
|
|
7
|
-
**[Namings](#named-vs-unnamed)**
|
|
8
|
-
·
|
|
9
|
-
**[Specifiers](#types-of-specifiers)**
|
|
10
|
-
·
|
|
11
|
-
**[Usage](#usage)**
|
|
12
|
-
·
|
|
7
|
+
**[Namings](#named-vs-unnamed)** ·
|
|
8
|
+
**[Specifiers](#types-of-specifiers)** · **[Usage](#usage)** ·
|
|
13
9
|
**[Properties](#properties)**
|
|
14
10
|
|
|
15
11
|
## Overview
|
|
@@ -17,86 +13,83 @@ This is a library for parsing **package specifiers**.
|
|
|
17
13
|
Specifiers are primarily used in the following cases:
|
|
18
14
|
|
|
19
15
|
- On the command line, like `vlt add foo@1.x`
|
|
20
|
-
- In manifests (such as `package.json`) where dependencies are
|
|
21
|
-
|
|
16
|
+
- In manifests (such as `package.json`) where dependencies are listed,
|
|
17
|
+
like `"dependencies": { "foo": "1.x" }`
|
|
22
18
|
- Internally within vlt, such as lockfiles and so on.
|
|
23
19
|
|
|
24
20
|
## Named vs Unnamed
|
|
25
21
|
|
|
26
|
-
A "named" specifier is one with the full name included, separated
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
A "named" specifier is one with the full name included, separated from
|
|
23
|
+
the specifier by a `@` character, such as `foo@1.x` or
|
|
24
|
+
`@vltpkg/spec@1.0.0`. The `name` in these cases would be `foo` and
|
|
25
|
+
`@vltpkg/spec`, respectively.
|
|
30
26
|
|
|
31
27
|
Note that it does _not_ always correspond to the `"name"` in the
|
|
32
|
-
manifest of the resolved package! For example,
|
|
33
|
-
|
|
34
|
-
`
|
|
35
|
-
loaded as `import('foo')`.
|
|
28
|
+
manifest of the resolved package! For example, `foo@npm:react@latest`
|
|
29
|
+
would resolve to the latest version of `react`, but would be named
|
|
30
|
+
`foo` in the dependency graph, and loaded as `import('foo')`.
|
|
36
31
|
|
|
37
32
|
## Types of Specifiers
|
|
38
33
|
|
|
39
34
|
The following specifier types are supported:
|
|
40
35
|
|
|
41
|
-
- `workspace:...` - Provide a semver range, or one of `~`, `*`,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
`
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
the repository, as in a monorepo. For example,
|
|
36
|
+
- `workspace:...` - Provide a semver range, or one of `~`, `*`, or `^`
|
|
37
|
+
to match against a dependency that exists in a workspace project of
|
|
38
|
+
a monorepo. The package name _must_ exist as a workspace project in
|
|
39
|
+
the monorepo. If a semver range is provided, then it must match the
|
|
40
|
+
referenced workspace package version. Otherwise:
|
|
41
|
+
|
|
42
|
+
- `*` - Fill in whatever version is in the workspace, without any
|
|
43
|
+
prefix. So, if `./packages/foo` depends on `bar@workspace*`, and
|
|
44
|
+
`bar` is version `1.2.3`, then `foo` will be published with
|
|
45
|
+
`{ "dependencies": { "bar": "1.2.3" }}`
|
|
46
|
+
- `~` or `^` - Publish with the version found in the monorepo,
|
|
47
|
+
prefixed by the character. So in the example above, it'd be
|
|
48
|
+
`bar@~1.2.3` or `bar@^1.2.3`, respectively.
|
|
49
|
+
|
|
50
|
+
- `semver range` - A valid semver range (including the empty string or
|
|
51
|
+
a single semver version). This is resolved against the default
|
|
52
|
+
registry. If the spec is a valid semver range, then no further
|
|
53
|
+
parsing is done.
|
|
54
|
+
|
|
55
|
+
- `git+ssh://<url>[selector]` or `git+https://<url>[selector]` - A
|
|
56
|
+
`git+ssh` or `git+https` url will be checked out by git. If no 'git
|
|
57
|
+
selector' is provided, then it will attempt to install from the
|
|
58
|
+
default version. The git selector can be:
|
|
59
|
+
|
|
60
|
+
- `#committish` Any valid `committish` value will be checked out.
|
|
61
|
+
So, shasum, branch, tag, etc., would all work.
|
|
62
|
+
- `#semver:<range>` If a semver range is provided, it will select
|
|
63
|
+
over all the tags that are valid semver versions, and pick the
|
|
64
|
+
highest version number that satisfies the range.
|
|
65
|
+
- Additional fields can be specified by a `::`-separated series of
|
|
66
|
+
`key:value` pairs. Currently only `path:<path in repo>` is
|
|
67
|
+
supported, for referencing packages living below the root of the
|
|
68
|
+
repository, as in a monorepo. For example,
|
|
75
69
|
`tcompare@github:tapjs/tapjs#bf457f24::path:src/tcompare`
|
|
76
70
|
|
|
77
|
-
- `https://some-host.com/path/to/file.tgz` - An https or http URL
|
|
78
|
-
|
|
71
|
+
- `https://some-host.com/path/to/file.tgz` - An https or http URL to a
|
|
72
|
+
tarball will resolve to itself.
|
|
79
73
|
|
|
80
|
-
- `file:///path/to/file` - A file URL will resolve to itself. If
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
- `file:///path/to/file` - A file URL will resolve to itself. If it is
|
|
75
|
+
a directory, it will be reified as a symbolic link to the folder
|
|
76
|
+
specified. If it is a file, it will be treated as a tarball that
|
|
77
|
+
gets unpacked into place. Relative paths are resolved from the
|
|
78
|
+
package with the dependency.
|
|
85
79
|
|
|
86
|
-
- `registry:<registry url>#<name>[@version range or dist-tag]` -
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
- `registry:<registry url>#<name>[@version range or dist-tag]` - This
|
|
81
|
+
will use the specified registry url, and look up the name and
|
|
82
|
+
version on that registry.
|
|
89
83
|
|
|
90
|
-
- If a registry shorthand is defined in the options, then you can
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
`
|
|
94
|
-
`registry:https://registry.npmjs.org/#<name>[@version-range]`.
|
|
84
|
+
- If a registry shorthand is defined in the options, then you can use
|
|
85
|
+
it as an alias for that registry. Currently, the only shorthand that
|
|
86
|
+
is enabled by default is `npm:<name>[@version-range]` as a shorthand
|
|
87
|
+
for `registry:https://registry.npmjs.org/#<name>[@version-range]`.
|
|
95
88
|
|
|
96
|
-
- If a git repository shorthand is defined in the options, then
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
- If a git repository shorthand is defined in the options, then you
|
|
90
|
+
can use that shorthand prefix as an alias for that git host.
|
|
91
|
+
Currently, `github:`, `bitbucket:`, `gitlab:`, and `gist:` are
|
|
92
|
+
supported by default.
|
|
100
93
|
|
|
101
94
|
- Anything else will be treated as a `dist-tag` in the registry
|
|
102
95
|
packument. For example, `foo@latest` or `blah@legacy-v2`
|
|
@@ -141,8 +134,8 @@ const fooFromAcmeReg = Spec.parse(
|
|
|
141
134
|
|
|
142
135
|
## Properties
|
|
143
136
|
|
|
144
|
-
- type - the type of spec that this is. One of `'registry'`,
|
|
145
|
-
`'
|
|
137
|
+
- type - the type of spec that this is. One of `'registry'`, `'git'`,
|
|
138
|
+
`'file'`, or `'remote'`.
|
|
146
139
|
- spec - the full named specifier passed to the constructor
|
|
147
140
|
- options - options passed to the constructor, plus defaults
|
|
148
141
|
- name - the name portion, so `foo` in `foo@1.x`
|
|
@@ -150,8 +143,7 @@ const fooFromAcmeReg = Spec.parse(
|
|
|
150
143
|
- when `type` === `'git'`:
|
|
151
144
|
- gitRemote - git remote url
|
|
152
145
|
- gitSelector - the `::`-separated set of `key:value` fields
|
|
153
|
-
- gitSelectorParsed - the `gitSelector` parsed into a Record
|
|
154
|
-
object
|
|
146
|
+
- gitSelectorParsed - the `gitSelector` parsed into a Record object
|
|
155
147
|
- gitCommittish - the commit sha, branch, or tag
|
|
156
148
|
- namedGitHost - `github`, `gitlab`, `bitbucket`, etc.
|
|
157
149
|
- remoteURL - when using a named git host with an archive url
|
|
@@ -161,15 +153,14 @@ const fooFromAcmeReg = Spec.parse(
|
|
|
161
153
|
- range - the parsed semver range, if valid
|
|
162
154
|
- when `type` === `'registry'`:
|
|
163
155
|
- registry - the registry to look up data from
|
|
164
|
-
- namedRegistry - in the case of alias specs, the named
|
|
165
|
-
registry
|
|
156
|
+
- namedRegistry - in the case of alias specs, the named registry
|
|
166
157
|
- registrySpec - the semver range or dist-tag
|
|
167
158
|
- semver - the semver range, if valid
|
|
168
159
|
- range - the parsed semver range, if valid
|
|
169
160
|
- distTag - the registrySpec when it is not a semver range
|
|
170
|
-
- subspec - the parsed spec to to be resolved against the
|
|
171
|
-
|
|
172
|
-
|
|
161
|
+
- subspec - the parsed spec to to be resolved against the registry
|
|
162
|
+
in question, if the spec is a named registry like `npm:x@2.x` or
|
|
163
|
+
an explicit registry url like
|
|
173
164
|
`registry:https://registry.npmjs.org#x@2.x`.
|
|
174
165
|
- when `type` === `'file'`:
|
|
175
166
|
- file - the path on disk to find the package
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/spec",
|
|
3
3
|
"description": "Package specifier library",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-4",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@vltpkg/error-cause": "0.0.0-
|
|
24
|
-
"@vltpkg/semver": "0.0.0-
|
|
23
|
+
"@vltpkg/error-cause": "0.0.0-4",
|
|
24
|
+
"@vltpkg/semver": "0.0.0-4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@eslint/js": "^9.20.0",
|