@vltpkg/dep-id 0.0.0-0.1730239248325
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/LICENSE +15 -0
- package/README.md +55 -0
- package/dist/esm/browser.d.ts +54 -0
- package/dist/esm/browser.d.ts.map +1 -0
- package/dist/esm/browser.js +69 -0
- package/dist/esm/browser.js.map +1 -0
- package/dist/esm/index.d.ts +78 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +219 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Copyright (c) vlt technology, Inc.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
7
|
+
Subject to the terms and conditions of this license, each copyright holder and contributor hereby grants to those receiving rights under this license a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except for failure to satisfy the conditions of this license) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer this software, where such license applies only to those patent claims, already acquired or hereafter acquired, licensable by such copyright holder or contributor that are necessarily infringed by:
|
|
8
|
+
|
|
9
|
+
(a) their Contribution(s) (the licensed copyrights of copyright holders and non-copyrightable additions of contributors, in source or binary form) alone; or
|
|
10
|
+
(b) combination of their Contribution(s) with the work of authorship to which such Contribution(s) was added by such copyright holder or contributor, if, at the time the Contribution is added, such addition causes such combination to be necessarily infringed. The patent license shall not apply to any other combinations which include the Contribution.
|
|
11
|
+
Except as expressly stated above, no rights or licenses from any copyright holder or contributor is granted under this license, whether expressly, by implication, estoppel or otherwise.
|
|
12
|
+
|
|
13
|
+
DISCLAIMER
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# `@vltpkg/dep-id`
|
|
2
|
+
|
|
3
|
+
A library for serializing dependencies into terse string
|
|
4
|
+
identifiers, and turning those serialized identifiers back into
|
|
5
|
+
`Spec` objects.
|
|
6
|
+
|
|
7
|
+
## USAGE
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import {
|
|
11
|
+
getId,
|
|
12
|
+
getTuple,
|
|
13
|
+
hydrate,
|
|
14
|
+
hydrateTuple,
|
|
15
|
+
joinDepIDTuple,
|
|
16
|
+
splitDepID,
|
|
17
|
+
} from '@vltpkg/dep-id'
|
|
18
|
+
import { manifest } from '@vltpkg/package-info'
|
|
19
|
+
|
|
20
|
+
{
|
|
21
|
+
// default registry
|
|
22
|
+
const spec = Spec.parse('x@latest')
|
|
23
|
+
const mani = await manifest(spec)
|
|
24
|
+
const id = getId(spec, mani) // registry;;x@1.2.3
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
{
|
|
28
|
+
// not default registry
|
|
29
|
+
const spec = Spec.parse('x@vlt:y@latest', {
|
|
30
|
+
registries: { vlt: 'http://vlt.sh' },
|
|
31
|
+
})
|
|
32
|
+
const mani = await manifest(spec)
|
|
33
|
+
const id = getId(spec, mani) // registry;vlt;y@latest
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
{
|
|
37
|
+
// git, hosted
|
|
38
|
+
const spec = Spec.parse('x@github:a/b#branch')
|
|
39
|
+
const mani = await manifest(spec)
|
|
40
|
+
const id = getId(spec, mani) // git;github:a/b;branch
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Hydrate by providing a name, and options for the spec creation
|
|
44
|
+
const spec = hydrate('git;github:a/b;branch', 'x') // x@github:a/b#branch
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Note: multiple different spec/manifest combinations _can_ result
|
|
48
|
+
in the same identifier. For example, the specifiers
|
|
49
|
+
`x@npm:y@latest` and `asdf@npm:y@1.x` might both ultimately
|
|
50
|
+
resolve to the same package, so they only need to appear in the
|
|
51
|
+
store once.
|
|
52
|
+
|
|
53
|
+
## BROWSER API
|
|
54
|
+
|
|
55
|
+
An isomorphic API `@vltpkg/dep-id/browser` is provided for use in the browser.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const delimiter: Delimiter;
|
|
2
|
+
export type Delimiter = '·';
|
|
3
|
+
/**
|
|
4
|
+
* Dependency IDs are a URI-encoded set of strings, separated
|
|
5
|
+
* by the {@link Delimiter} character (`'·'`).
|
|
6
|
+
*
|
|
7
|
+
* The first entry is always the specifier type. The rest depend on the
|
|
8
|
+
* type. `git`, `registry`, and `workspace` entries have 3 fields, the rest
|
|
9
|
+
* have 2.
|
|
10
|
+
*
|
|
11
|
+
* - `registry`: `'registry·<registry>·name@specifier'`
|
|
12
|
+
* The `<registry>` portion can be a known named registry name, or a
|
|
13
|
+
* url to a registry. If empty, it is the default registry.
|
|
14
|
+
* Examples:
|
|
15
|
+
* - `··some-package@2.0.1`
|
|
16
|
+
* - `·npm·whatever@1.2.3'
|
|
17
|
+
* - `·http%3A%2F%2Fvlt.sh%2F·x@1.2.3`
|
|
18
|
+
* - `git`: `'git·<git remote>·<git selector>`. For example:
|
|
19
|
+
* - `git·github:user/project·branchname`
|
|
20
|
+
* - `git·git%2Bssh%3A%2F%2Fuser%40host%3Aproject.git·semver:1.x`
|
|
21
|
+
* - `workspace`: `'workspace·<path>`. For example:
|
|
22
|
+
* - `workspace·src/mything`
|
|
23
|
+
* - `remote`: `'remote·<url>'`
|
|
24
|
+
* - `file`: `'file·<path>`
|
|
25
|
+
*
|
|
26
|
+
* Lastly, the final portion can contain arbitrary string data, and is
|
|
27
|
+
* used to store peer dep resolutions to maintain the peerDep contract.
|
|
28
|
+
*/
|
|
29
|
+
export type DepID = `${'' | 'git'}${Delimiter}${string}${Delimiter}${string}${Delimiter}${string}` | `${'' | 'git'}${Delimiter}${string}${Delimiter}${string}` | `${'file' | 'remote' | 'workspace'}${Delimiter}${string}${Delimiter}${string}` | `${'file' | 'remote' | 'workspace'}${Delimiter}${string}`;
|
|
30
|
+
/**
|
|
31
|
+
* A {@link DepID}, split apart and URI-decoded
|
|
32
|
+
*/
|
|
33
|
+
export type DepIDTuple = [
|
|
34
|
+
type: 'git',
|
|
35
|
+
gitRemote: string,
|
|
36
|
+
gitSelector: string,
|
|
37
|
+
extra?: string
|
|
38
|
+
] | [
|
|
39
|
+
type: 'registry',
|
|
40
|
+
registry: string,
|
|
41
|
+
registrySpec: string,
|
|
42
|
+
extra?: string
|
|
43
|
+
] | [type: 'file', path: string, extra?: string] | [type: 'remote', url: string, extra?: string] | [type: 'workspace', workspace: string, extra?: string];
|
|
44
|
+
export declare const isDepID: (str: unknown) => str is DepID;
|
|
45
|
+
export declare const asDepID: (str: string) => DepID;
|
|
46
|
+
/**
|
|
47
|
+
* turn a {@link DepIDTuple} into a {@link DepID}
|
|
48
|
+
*/
|
|
49
|
+
export declare const joinDepIDTuple: (list: DepIDTuple) => DepID;
|
|
50
|
+
/**
|
|
51
|
+
* turn a {@link DepID} into a {@link DepIDTuple}
|
|
52
|
+
*/
|
|
53
|
+
export declare const splitDepID: (id: string) => DepIDTuple;
|
|
54
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,EAAE,SAAe,CAAA;AACvC,MAAM,MAAM,SAAS,GAAG,GAAG,CAAA;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,KAAK,GACb,GAAG,EAAE,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAC9E,GAAG,EAAE,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GACzD,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAC9E,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,EAAE,CAAA;AAE7D;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB;IACE,IAAI,EAAE,KAAK;IACX,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,MAAM;IACnB,KAAK,CAAC,EAAE,MAAM;CACf,GACD;IACE,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,MAAM;IAChB,YAAY,EAAE,MAAM;IACpB,KAAK,CAAC,EAAE,MAAM;CACf,GACD,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,GAC5C,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,GAC7C,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,CAAA;AAY1D,eAAO,MAAM,OAAO,QAAS,OAAO,KAAG,GAAG,IAAI,KACI,CAAA;AAElD,eAAO,MAAM,OAAO,QAAS,MAAM,KAAG,KAOrC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,SAAU,UAAU,KAAG,KAWjD,CAAA;AAMD;;GAEG;AACH,eAAO,MAAM,UAAU,OAAQ,MAAM,KAAG,UA+BvC,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
export const delimiter = '·';
|
|
3
|
+
const depIDRegExp = new RegExp(`^((git)?${delimiter}[^${delimiter}]*${delimiter}[^${delimiter}]*(${delimiter}[^${delimiter}]*)?$` +
|
|
4
|
+
`|` +
|
|
5
|
+
`^(file|remote|workspace)${delimiter}[^${delimiter}]*)(${delimiter}[^${delimiter}]*)?$`);
|
|
6
|
+
export const isDepID = (str) => typeof str === 'string' && depIDRegExp.test(str);
|
|
7
|
+
export const asDepID = (str) => {
|
|
8
|
+
if (!isDepID(str)) {
|
|
9
|
+
throw error('Expected dep id', {
|
|
10
|
+
found: str,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return str;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* turn a {@link DepIDTuple} into a {@link DepID}
|
|
17
|
+
*/
|
|
18
|
+
export const joinDepIDTuple = (list) => {
|
|
19
|
+
const [type, first, second, extra] = list;
|
|
20
|
+
const f = encode(first);
|
|
21
|
+
switch (type) {
|
|
22
|
+
case 'registry':
|
|
23
|
+
return `${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ''}`;
|
|
24
|
+
case 'git':
|
|
25
|
+
return `${type}${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ''}`;
|
|
26
|
+
default:
|
|
27
|
+
return `${type}${delimiter}${f}${second ? `${delimiter}${encode(second)}` : ''}`;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
// allow @, but otherwise, escape everything urls do
|
|
31
|
+
const encode = (s) => encodeURIComponent(s).replaceAll('%40', '@');
|
|
32
|
+
/**
|
|
33
|
+
* turn a {@link DepID} into a {@link DepIDTuple}
|
|
34
|
+
*/
|
|
35
|
+
export const splitDepID = (id) => {
|
|
36
|
+
const [type, first = '', second, extra] = id.split(delimiter, 4);
|
|
37
|
+
const f = decodeURIComponent(first);
|
|
38
|
+
switch (type) {
|
|
39
|
+
case 'git':
|
|
40
|
+
case '': {
|
|
41
|
+
if (second === undefined) {
|
|
42
|
+
throw error(`invalid ${type} id`, { found: id });
|
|
43
|
+
}
|
|
44
|
+
const t = [
|
|
45
|
+
type || 'registry',
|
|
46
|
+
f,
|
|
47
|
+
decodeURIComponent(second),
|
|
48
|
+
];
|
|
49
|
+
if (extra)
|
|
50
|
+
t.push(decodeURIComponent(extra));
|
|
51
|
+
return t;
|
|
52
|
+
}
|
|
53
|
+
case 'file':
|
|
54
|
+
case 'remote':
|
|
55
|
+
case 'workspace': {
|
|
56
|
+
const t = [type, f];
|
|
57
|
+
if (second)
|
|
58
|
+
t.push(decodeURIComponent(second));
|
|
59
|
+
return t;
|
|
60
|
+
}
|
|
61
|
+
default: {
|
|
62
|
+
throw error('invalid DepID type', {
|
|
63
|
+
found: type,
|
|
64
|
+
validOptions: ['git', 'file', 'workspace', 'remote', ''],
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CA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AAC,CAAC;YACjB,MAAM,CAAC,GAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;YAC/B,IAAI,MAAM;gBAAE,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAA;YAC9C,OAAO,CAAC,CAAA;QACV,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,KAAK,CAAC,oBAAoB,EAAE;gBAChC,KAAK,EAAE,IAAI;gBACX,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,CAAC;aACzD,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\n\nexport const delimiter: Delimiter = '·'\nexport type Delimiter = '·'\n\n/**\n * Dependency IDs are a URI-encoded set of strings, separated\n * by the {@link Delimiter} character (`'·'`).\n *\n * The first entry is always the specifier type. The rest depend on the\n * type. `git`, `registry`, and `workspace` entries have 3 fields, the rest\n * have 2.\n *\n * - `registry`: `'registry·<registry>·name@specifier'`\n * The `<registry>` portion can be a known named registry name, or a\n * url to a registry. If empty, it is the default registry.\n * Examples:\n * - `··some-package@2.0.1`\n * - `·npm·whatever@1.2.3'\n * - `·http%3A%2F%2Fvlt.sh%2F·x@1.2.3`\n * - `git`: `'git·<git remote>·<git selector>`. For example:\n * - `git·github:user/project·branchname`\n * - `git·git%2Bssh%3A%2F%2Fuser%40host%3Aproject.git·semver:1.x`\n * - `workspace`: `'workspace·<path>`. For example:\n * - `workspace·src/mything`\n * - `remote`: `'remote·<url>'`\n * - `file`: `'file·<path>`\n *\n * Lastly, the final portion can contain arbitrary string data, and is\n * used to store peer dep resolutions to maintain the peerDep contract.\n */\nexport type DepID =\n | `${'' | 'git'}${Delimiter}${string}${Delimiter}${string}${Delimiter}${string}`\n | `${'' | 'git'}${Delimiter}${string}${Delimiter}${string}`\n | `${'file' | 'remote' | 'workspace'}${Delimiter}${string}${Delimiter}${string}`\n | `${'file' | 'remote' | 'workspace'}${Delimiter}${string}`\n\n/**\n * A {@link DepID}, split apart and URI-decoded\n */\nexport type DepIDTuple =\n | [\n type: 'git',\n gitRemote: string,\n gitSelector: string,\n extra?: string,\n ]\n | [\n type: 'registry',\n registry: string,\n registrySpec: string,\n extra?: string,\n ]\n | [type: 'file', path: string, extra?: string]\n | [type: 'remote', url: string, extra?: string]\n | [type: 'workspace', workspace: string, extra?: string]\n\nconst depIDRegExp = new RegExp(\n `^((git)?${delimiter}[^${delimiter}]*${delimiter}[^${delimiter}]*(${\n delimiter\n }[^${delimiter}]*)?$` +\n `|` +\n `^(file|remote|workspace)${delimiter}[^${\n delimiter\n }]*)(${delimiter}[^${delimiter}]*)?$`,\n)\n\nexport const isDepID = (str: unknown): str is DepID =>\n typeof str === 'string' && depIDRegExp.test(str)\n\nexport const asDepID = (str: string): DepID => {\n if (!isDepID(str)) {\n throw error('Expected dep id', {\n found: str,\n })\n }\n return str\n}\n\n/**\n * turn a {@link DepIDTuple} into a {@link DepID}\n */\nexport const joinDepIDTuple = (list: DepIDTuple): DepID => {\n const [type, first, second, extra] = list\n const f = encode(first)\n switch (type) {\n case 'registry':\n return `${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ''}`\n case 'git':\n return `${type}${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ''}`\n default:\n return `${type}${delimiter}${f}${second ? `${delimiter}${encode(second)}` : ''}`\n }\n}\n\n// allow @, but otherwise, escape everything urls do\nconst encode = (s: string): string =>\n encodeURIComponent(s).replaceAll('%40', '@')\n\n/**\n * turn a {@link DepID} into a {@link DepIDTuple}\n */\nexport const splitDepID = (id: string): DepIDTuple => {\n const [type, first = '', second, extra] = id.split(delimiter, 4)\n const f = decodeURIComponent(first)\n switch (type) {\n case 'git':\n case '': {\n if (second === undefined) {\n throw error(`invalid ${type} id`, { found: id })\n }\n const t: DepIDTuple = [\n type || 'registry',\n f,\n decodeURIComponent(second),\n ]\n if (extra) t.push(decodeURIComponent(extra))\n return t\n }\n case 'file':\n case 'remote':\n case 'workspace': {\n const t: DepIDTuple = [type, f]\n if (second) t.push(decodeURIComponent(second))\n return t\n }\n default: {\n throw error('invalid DepID type', {\n found: type,\n validOptions: ['git', 'file', 'workspace', 'remote', ''],\n })\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Spec, SpecOptions } from '@vltpkg/spec';
|
|
2
|
+
import { Manifest } from '@vltpkg/types';
|
|
3
|
+
export declare const delimiter: Delimiter;
|
|
4
|
+
export type Delimiter = '·';
|
|
5
|
+
/**
|
|
6
|
+
* Dependency IDs are a URI-encoded set of strings, separated
|
|
7
|
+
* by the {@link Delimiter} character (`'·'`).
|
|
8
|
+
*
|
|
9
|
+
* The first entry is always the specifier type. The rest depend on the
|
|
10
|
+
* type. `git`, `registry`, and `workspace` entries have 3 fields, the rest
|
|
11
|
+
* have 2.
|
|
12
|
+
*
|
|
13
|
+
* - `registry`: `'registry·<registry>·name@specifier'`
|
|
14
|
+
* The `<registry>` portion can be a known named registry name, or a
|
|
15
|
+
* url to a registry. If empty, it is the default registry.
|
|
16
|
+
* Examples:
|
|
17
|
+
* - `··some-package@2.0.1`
|
|
18
|
+
* - `·npm·whatever@1.2.3'
|
|
19
|
+
* - `·http%3A%2F%2Fvlt.sh%2F·x@1.2.3`
|
|
20
|
+
* - `git`: `'git·<git remote>·<git selector>`. For example:
|
|
21
|
+
* - `git·github:user/project·branchname`
|
|
22
|
+
* - `git·git%2Bssh%3A%2F%2Fuser%40host%3Aproject.git·semver:1.x`
|
|
23
|
+
* - `workspace`: `'workspace·<path>`. For example:
|
|
24
|
+
* - `workspace·src/mything`
|
|
25
|
+
* - `remote`: `'remote·<url>'`
|
|
26
|
+
* - `file`: `'file·<path>`
|
|
27
|
+
*
|
|
28
|
+
* Lastly, the final portion can contain arbitrary string data, and is
|
|
29
|
+
* used to store peer dep resolutions to maintain the peerDep contract.
|
|
30
|
+
*/
|
|
31
|
+
export type DepID = `${'' | 'git'}${Delimiter}${string}${Delimiter}${string}${Delimiter}${string}` | `${'' | 'git'}${Delimiter}${string}${Delimiter}${string}` | `${'file' | 'remote' | 'workspace'}${Delimiter}${string}${Delimiter}${string}` | `${'file' | 'remote' | 'workspace'}${Delimiter}${string}`;
|
|
32
|
+
/**
|
|
33
|
+
* A {@link DepID}, split apart and URI-decoded
|
|
34
|
+
*/
|
|
35
|
+
export type DepIDTuple = [
|
|
36
|
+
type: 'git',
|
|
37
|
+
gitRemote: string,
|
|
38
|
+
gitSelector: string,
|
|
39
|
+
extra?: string
|
|
40
|
+
] | [
|
|
41
|
+
type: 'registry',
|
|
42
|
+
registry: string,
|
|
43
|
+
registrySpec: string,
|
|
44
|
+
extra?: string
|
|
45
|
+
] | [type: 'file', path: string, extra?: string] | [type: 'remote', url: string, extra?: string] | [type: 'workspace', workspace: string, extra?: string];
|
|
46
|
+
export declare const isDepID: (str: unknown) => str is DepID;
|
|
47
|
+
export declare const asDepID: (str: string) => DepID;
|
|
48
|
+
/**
|
|
49
|
+
* turn a {@link DepIDTuple} into a {@link DepID}
|
|
50
|
+
*/
|
|
51
|
+
export declare const joinDepIDTuple: (list: DepIDTuple) => DepID;
|
|
52
|
+
/**
|
|
53
|
+
* turn a {@link DepID} into a {@link DepIDTuple}
|
|
54
|
+
*/
|
|
55
|
+
export declare const splitDepID: (id: string) => DepIDTuple;
|
|
56
|
+
/**
|
|
57
|
+
* Turn a {@link DepID} into a {@link Spec} object
|
|
58
|
+
*/
|
|
59
|
+
export declare const hydrate: (id: DepID, name?: string, options?: SpecOptions) => Spec;
|
|
60
|
+
/**
|
|
61
|
+
* Turn a {@link DepIDTuple} into a {@link Spec} object
|
|
62
|
+
*/
|
|
63
|
+
export declare const hydrateTuple: (tuple: DepIDTuple, name?: string, options?: SpecOptions) => import("@vltpkg/spec/browser").Spec;
|
|
64
|
+
/**
|
|
65
|
+
* Get the {@link DepIDTuple} for a given {@link Spec} and {@link Manifest}.
|
|
66
|
+
* The Manifest is used to get the name and version, if possible. If not found
|
|
67
|
+
* in the manifest, registry ID types will use the name or bareSpec from the
|
|
68
|
+
* specifier, so at least there's something to use later.
|
|
69
|
+
*/
|
|
70
|
+
export declare const getTuple: (spec: Spec, mani: Manifest) => DepIDTuple;
|
|
71
|
+
/**
|
|
72
|
+
* Get the {@link DepID} for a given {@link Spec} and {@link Manifest}. The
|
|
73
|
+
* Manifest is used to get the name and version, if possible. If not found in
|
|
74
|
+
* the manifest, registry ID types will use the name or bareSpec from the
|
|
75
|
+
* specifier, so at least there's something to use later.
|
|
76
|
+
*/
|
|
77
|
+
export declare const getId: (spec: Spec, mani: Manifest) => DepID;
|
|
78
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,eAAO,MAAM,SAAS,EAAE,SAAe,CAAA;AACvC,MAAM,MAAM,SAAS,GAAG,GAAG,CAAA;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,KAAK,GACb,GAAG,EAAE,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAC9E,GAAG,EAAE,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GACzD,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAC9E,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,EAAE,CAAA;AAE7D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';
|
|
3
|
+
export const delimiter = '·';
|
|
4
|
+
const depIDRegExp = new RegExp(`^((git)?${delimiter}[^${delimiter}]*${delimiter}[^${delimiter}]*(${delimiter}[^${delimiter}]*)?$` +
|
|
5
|
+
`|` +
|
|
6
|
+
`^(file|remote|workspace)${delimiter}[^${delimiter}]*)(${delimiter}[^${delimiter}]*)?$`);
|
|
7
|
+
export const isDepID = (str) => typeof str === 'string' && depIDRegExp.test(str);
|
|
8
|
+
export const asDepID = (str) => {
|
|
9
|
+
if (!isDepID(str)) {
|
|
10
|
+
throw error('Expected dep id', {
|
|
11
|
+
found: str,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return str;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* turn a {@link DepIDTuple} into a {@link DepID}
|
|
18
|
+
*/
|
|
19
|
+
export const joinDepIDTuple = (list) => {
|
|
20
|
+
const [type, first, second, extra] = list;
|
|
21
|
+
const f = encode(first);
|
|
22
|
+
switch (type) {
|
|
23
|
+
case 'registry':
|
|
24
|
+
return `${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ''}`;
|
|
25
|
+
case 'git':
|
|
26
|
+
return `${type}${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ''}`;
|
|
27
|
+
default:
|
|
28
|
+
return `${type}${delimiter}${f}${second ? `${delimiter}${encode(second)}` : ''}`;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
// allow @, but otherwise, escape everything urls do
|
|
32
|
+
const encode = (s) => encodeURIComponent(s).replaceAll('%40', '@');
|
|
33
|
+
/**
|
|
34
|
+
* turn a {@link DepID} into a {@link DepIDTuple}
|
|
35
|
+
*/
|
|
36
|
+
export const splitDepID = (id) => {
|
|
37
|
+
const [type, first = '', second, extra] = id.split(delimiter, 4);
|
|
38
|
+
const f = decodeURIComponent(first);
|
|
39
|
+
switch (type) {
|
|
40
|
+
case 'git':
|
|
41
|
+
case '': {
|
|
42
|
+
if (second === undefined) {
|
|
43
|
+
throw error(`invalid ${type} id`, { found: id });
|
|
44
|
+
}
|
|
45
|
+
const t = [
|
|
46
|
+
type || 'registry',
|
|
47
|
+
f,
|
|
48
|
+
decodeURIComponent(second),
|
|
49
|
+
];
|
|
50
|
+
if (extra)
|
|
51
|
+
t.push(decodeURIComponent(extra));
|
|
52
|
+
return t;
|
|
53
|
+
}
|
|
54
|
+
case 'file':
|
|
55
|
+
case 'remote':
|
|
56
|
+
case 'workspace': {
|
|
57
|
+
const t = [type, f];
|
|
58
|
+
if (second)
|
|
59
|
+
t.push(decodeURIComponent(second));
|
|
60
|
+
return t;
|
|
61
|
+
}
|
|
62
|
+
default: {
|
|
63
|
+
throw error('invalid DepID type', {
|
|
64
|
+
found: type,
|
|
65
|
+
validOptions: ['git', 'file', 'workspace', 'remote', ''],
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Turn a {@link DepID} into a {@link Spec} object
|
|
72
|
+
*/
|
|
73
|
+
export const hydrate = (id, name, options = {}) => hydrateTuple(splitDepID(id), name, options);
|
|
74
|
+
/**
|
|
75
|
+
* Turn a {@link DepIDTuple} into a {@link Spec} object
|
|
76
|
+
*/
|
|
77
|
+
export const hydrateTuple = (tuple, name, options = {}) => {
|
|
78
|
+
const [type, first, second] = tuple;
|
|
79
|
+
switch (type) {
|
|
80
|
+
case 'remote': {
|
|
81
|
+
if (!first)
|
|
82
|
+
throw error('no remoteURL found on remote id', {
|
|
83
|
+
found: tuple,
|
|
84
|
+
});
|
|
85
|
+
return Spec.parse(name ?? '(unknown)', first);
|
|
86
|
+
}
|
|
87
|
+
case 'file': {
|
|
88
|
+
if (!first) {
|
|
89
|
+
throw error('no file path found on remote id', {
|
|
90
|
+
found: tuple,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return Spec.parse(name ?? '(unknown)', `file:${first}`, options);
|
|
94
|
+
}
|
|
95
|
+
case 'registry': {
|
|
96
|
+
if (typeof first !== 'string') {
|
|
97
|
+
throw error('no registry url or name in registry ID', {
|
|
98
|
+
found: tuple,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (!second) {
|
|
102
|
+
throw error('no name/specifier in registry ID', {
|
|
103
|
+
found: tuple,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (!first) {
|
|
107
|
+
// just a normal name@version on the default registry
|
|
108
|
+
const s = Spec.parse(second);
|
|
109
|
+
if (name && s.name !== name) {
|
|
110
|
+
return Spec.parse(`${name}@npm:${second}`);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
return s;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (!/^https?:\/\//.test(first)) {
|
|
117
|
+
const reg = options.registries?.[first];
|
|
118
|
+
if (first !== 'npm' && !reg) {
|
|
119
|
+
throw error('named registry not found in options', {
|
|
120
|
+
name: first,
|
|
121
|
+
found: tuple,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return Spec.parse(name ?? '(unknown)', `${first}:${second}`, options);
|
|
125
|
+
}
|
|
126
|
+
const s = Spec.parse(name ?? '(unknown)', `registry:${first}#${second}`, options);
|
|
127
|
+
return name && s.final.name !== name ?
|
|
128
|
+
Spec.parse(s.final.name + '@' + s.bareSpec)
|
|
129
|
+
: s;
|
|
130
|
+
}
|
|
131
|
+
case 'git': {
|
|
132
|
+
if (!first) {
|
|
133
|
+
throw error('no git remote in git ID', {
|
|
134
|
+
found: tuple,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return Spec.parse(name ?? '(unknown)', first + '#' + second, options);
|
|
138
|
+
}
|
|
139
|
+
case 'workspace': {
|
|
140
|
+
if (!first) {
|
|
141
|
+
throw error('no name/path on workspace id', { found: tuple });
|
|
142
|
+
}
|
|
143
|
+
return name && name !== first ?
|
|
144
|
+
Spec.parse(name, `workspace:${first}@*`, options)
|
|
145
|
+
: Spec.parse(first, `workspace:*`, options);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
// Strip out the default registry, there's no need to store that
|
|
150
|
+
const omitDefReg = (s) => (!s ||
|
|
151
|
+
s === 'https://registry.npmjs.org' ||
|
|
152
|
+
s === 'https://registry.npmjs.org/') ?
|
|
153
|
+
''
|
|
154
|
+
: s;
|
|
155
|
+
/**
|
|
156
|
+
* Get the {@link DepIDTuple} for a given {@link Spec} and {@link Manifest}.
|
|
157
|
+
* The Manifest is used to get the name and version, if possible. If not found
|
|
158
|
+
* in the manifest, registry ID types will use the name or bareSpec from the
|
|
159
|
+
* specifier, so at least there's something to use later.
|
|
160
|
+
*/
|
|
161
|
+
export const getTuple = (spec, mani) => {
|
|
162
|
+
const f = spec.final;
|
|
163
|
+
switch (f.type) {
|
|
164
|
+
case 'registry': {
|
|
165
|
+
// try to shorten to a known name if we can.
|
|
166
|
+
const reg = omitDefReg(f.registry);
|
|
167
|
+
if (!f.namedRegistry && reg) {
|
|
168
|
+
for (const [alias, host] of Object.entries(spec.options.registries)) {
|
|
169
|
+
if (reg === host) {
|
|
170
|
+
f.namedRegistry = alias;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return [
|
|
176
|
+
f.type,
|
|
177
|
+
f.namedRegistry ?? reg,
|
|
178
|
+
`${mani.name ?? spec.name}@${mani.version ?? spec.bareSpec}`,
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
case 'git': {
|
|
182
|
+
const { namedGitHost, namedGitHostPath, gitRemote, gitSelector = '', } = f;
|
|
183
|
+
if (!gitRemote)
|
|
184
|
+
throw error('no host on git specifier', { spec });
|
|
185
|
+
if (namedGitHost) {
|
|
186
|
+
if (!namedGitHostPath) {
|
|
187
|
+
throw error('named git host without path portion', {
|
|
188
|
+
spec,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return [
|
|
192
|
+
f.type,
|
|
193
|
+
`${namedGitHost}:${namedGitHostPath}`,
|
|
194
|
+
gitSelector,
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
return [f.type, gitRemote, gitSelector];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
case 'remote': {
|
|
202
|
+
const { remoteURL } = f;
|
|
203
|
+
if (!remoteURL)
|
|
204
|
+
throw error('no URL on remote specifier', { spec });
|
|
205
|
+
return [f.type, remoteURL];
|
|
206
|
+
}
|
|
207
|
+
case 'file':
|
|
208
|
+
case 'workspace':
|
|
209
|
+
throw error('Path-based dep ids are not supported', { spec });
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Get the {@link DepID} for a given {@link Spec} and {@link Manifest}. The
|
|
214
|
+
* Manifest is used to get the name and version, if possible. If not found in
|
|
215
|
+
* the manifest, registry ID types will use the name or bareSpec from the
|
|
216
|
+
* specifier, so at least there's something to use later.
|
|
217
|
+
*/
|
|
218
|
+
export const getId = (spec, mani) => joinDepIDTuple(getTuple(spec, mani));
|
|
219
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAe,MAAM,cAAc,CAAA;AAGhD,MAAM,CAAC,MAAM,SAAS,GAAc,GAAG,CAAA;AAuDvC,MAAM,WAAW,GAAG,IAAI,MAAM,CAC5B,WAAW,SAAS,KAAK,SAAS,KAAK,SAAS,KAAK,SAAS,MAC5D,SACF,KAAK,SAAS,OAAO;IACnB,GAAG;IACH,2BAA2B,SAAS,KAClC,SACF,OAAO,SAAS,KAAK,SAAS,OAAO,CACxC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAY,EAAgB,EAAE,CACpD,OAAO,GA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I,EAAE,CAAC,CAAA;YACrD,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QAC5B,CAAC;QACD,KAAK,MAAM,CAAC;QACZ,KAAK,WAAW;YACd,MAAM,KAAK,CAAC,sCAAsC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;IACjE,CAAC;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAU,EAAE,IAAc,EAAS,EAAE,CACzD,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { Spec, SpecOptions } from '@vltpkg/spec'\nimport { Manifest } from '@vltpkg/types'\n\nexport const delimiter: Delimiter = '·'\nexport type Delimiter = '·'\n\n/**\n * Dependency IDs are a URI-encoded set of strings, separated\n * by the {@link Delimiter} character (`'·'`).\n *\n * The first entry is always the specifier type. The rest depend on the\n * type. `git`, `registry`, and `workspace` entries have 3 fields, the rest\n * have 2.\n *\n * - `registry`: `'registry·<registry>·name@specifier'`\n * The `<registry>` portion can be a known named registry name, or a\n * url to a registry. If empty, it is the default registry.\n * Examples:\n * - `··some-package@2.0.1`\n * - `·npm·whatever@1.2.3'\n * - `·http%3A%2F%2Fvlt.sh%2F·x@1.2.3`\n * - `git`: `'git·<git remote>·<git selector>`. For example:\n * - `git·github:user/project·branchname`\n * - `git·git%2Bssh%3A%2F%2Fuser%40host%3Aproject.git·semver:1.x`\n * - `workspace`: `'workspace·<path>`. For example:\n * - `workspace·src/mything`\n * - `remote`: `'remote·<url>'`\n * - `file`: `'file·<path>`\n *\n * Lastly, the final portion can contain arbitrary string data, and is\n * used to store peer dep resolutions to maintain the peerDep contract.\n */\nexport type DepID =\n | `${'' | 'git'}${Delimiter}${string}${Delimiter}${string}${Delimiter}${string}`\n | `${'' | 'git'}${Delimiter}${string}${Delimiter}${string}`\n | `${'file' | 'remote' | 'workspace'}${Delimiter}${string}${Delimiter}${string}`\n | `${'file' | 'remote' | 'workspace'}${Delimiter}${string}`\n\n/**\n * A {@link DepID}, split apart and URI-decoded\n */\nexport type DepIDTuple =\n | [\n type: 'git',\n gitRemote: string,\n gitSelector: string,\n extra?: string,\n ]\n | [\n type: 'registry',\n registry: string,\n registrySpec: string,\n extra?: string,\n ]\n | [type: 'file', path: string, extra?: string]\n | [type: 'remote', url: string, extra?: string]\n | [type: 'workspace', workspace: string, extra?: string]\n\nconst depIDRegExp = new RegExp(\n `^((git)?${delimiter}[^${delimiter}]*${delimiter}[^${delimiter}]*(${\n delimiter\n }[^${delimiter}]*)?$` +\n `|` +\n `^(file|remote|workspace)${delimiter}[^${\n delimiter\n }]*)(${delimiter}[^${delimiter}]*)?$`,\n)\n\nexport const isDepID = (str: unknown): str is DepID =>\n typeof str === 'string' && depIDRegExp.test(str)\n\nexport const asDepID = (str: string): DepID => {\n if (!isDepID(str)) {\n throw error('Expected dep id', {\n found: str,\n })\n }\n return str\n}\n\n/**\n * turn a {@link DepIDTuple} into a {@link DepID}\n */\nexport const joinDepIDTuple = (list: DepIDTuple): DepID => {\n const [type, first, second, extra] = list\n const f = encode(first)\n switch (type) {\n case 'registry':\n return `${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ''}`\n case 'git':\n return `${type}${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ''}`\n default:\n return `${type}${delimiter}${f}${second ? `${delimiter}${encode(second)}` : ''}`\n }\n}\n\n// allow @, but otherwise, escape everything urls do\nconst encode = (s: string): string =>\n encodeURIComponent(s).replaceAll('%40', '@')\n\n/**\n * turn a {@link DepID} into a {@link DepIDTuple}\n */\nexport const splitDepID = (id: string): DepIDTuple => {\n const [type, first = '', second, extra] = id.split(delimiter, 4)\n const f = decodeURIComponent(first)\n switch (type) {\n case 'git':\n case '': {\n if (second === undefined) {\n throw error(`invalid ${type} id`, { found: id })\n }\n const t: DepIDTuple = [\n type || 'registry',\n f,\n decodeURIComponent(second),\n ]\n if (extra) t.push(decodeURIComponent(extra))\n return t\n }\n case 'file':\n case 'remote':\n case 'workspace': {\n const t: DepIDTuple = [type, f]\n if (second) t.push(decodeURIComponent(second))\n return t\n }\n default: {\n throw error('invalid DepID type', {\n found: type,\n validOptions: ['git', 'file', 'workspace', 'remote', ''],\n })\n }\n }\n}\n\n/**\n * Turn a {@link DepID} into a {@link Spec} object\n */\nexport const hydrate = (\n id: DepID,\n name?: string,\n options: SpecOptions = {},\n): Spec => hydrateTuple(splitDepID(id), name, options)\n\n/**\n * Turn a {@link DepIDTuple} into a {@link Spec} object\n */\nexport const hydrateTuple = (\n tuple: DepIDTuple,\n name?: string,\n options: SpecOptions = {},\n) => {\n const [type, first, second] = tuple\n switch (type) {\n case 'remote': {\n if (!first)\n throw error('no remoteURL found on remote id', {\n found: tuple,\n })\n return Spec.parse(name ?? '(unknown)', first)\n }\n case 'file': {\n if (!first) {\n throw error('no file path found on remote id', {\n found: tuple,\n })\n }\n return Spec.parse(name ?? '(unknown)', `file:${first}`, options)\n }\n case 'registry': {\n if (typeof first !== 'string') {\n throw error('no registry url or name in registry ID', {\n found: tuple,\n })\n }\n if (!second) {\n throw error('no name/specifier in registry ID', {\n found: tuple,\n })\n }\n if (!first) {\n // just a normal name@version on the default registry\n const s = Spec.parse(second)\n if (name && s.name !== name) {\n return Spec.parse(`${name}@npm:${second}`)\n } else {\n return s\n }\n }\n if (!/^https?:\\/\\//.test(first)) {\n const reg = options.registries?.[first]\n if (first !== 'npm' && !reg) {\n throw error('named registry not found in options', {\n name: first,\n found: tuple,\n })\n }\n return Spec.parse(\n name ?? '(unknown)',\n `${first}:${second}`,\n options,\n )\n }\n const s = Spec.parse(\n name ?? '(unknown)',\n `registry:${first}#${second}`,\n options,\n )\n return name && s.final.name !== name ?\n Spec.parse(s.final.name + '@' + s.bareSpec)\n : s\n }\n case 'git': {\n if (!first) {\n throw error('no git remote in git ID', {\n found: tuple,\n })\n }\n return Spec.parse(\n name ?? '(unknown)',\n first + '#' + second,\n options,\n )\n }\n case 'workspace': {\n if (!first) {\n throw error('no name/path on workspace id', { found: tuple })\n }\n return name && name !== first ?\n Spec.parse(name, `workspace:${first}@*`, options)\n : Spec.parse(first, `workspace:*`, options)\n }\n }\n}\n\n// Strip out the default registry, there's no need to store that\nconst omitDefReg = (s?: string): string =>\n (\n !s ||\n s === 'https://registry.npmjs.org' ||\n s === 'https://registry.npmjs.org/'\n ) ?\n ''\n : s\n\n/**\n * Get the {@link DepIDTuple} for a given {@link Spec} and {@link Manifest}.\n * The Manifest is used to get the name and version, if possible. If not found\n * in the manifest, registry ID types will use the name or bareSpec from the\n * specifier, so at least there's something to use later.\n */\nexport const getTuple = (spec: Spec, mani: Manifest): DepIDTuple => {\n const f = spec.final\n switch (f.type) {\n case 'registry': {\n // try to shorten to a known name if we can.\n const reg = omitDefReg(f.registry)\n if (!f.namedRegistry && reg) {\n for (const [alias, host] of Object.entries(\n spec.options.registries,\n )) {\n if (reg === host) {\n f.namedRegistry = alias\n break\n }\n }\n }\n return [\n f.type,\n f.namedRegistry ?? reg,\n `${mani.name ?? spec.name}@${mani.version ?? spec.bareSpec}`,\n ]\n }\n case 'git': {\n const {\n namedGitHost,\n namedGitHostPath,\n gitRemote,\n gitSelector = '',\n } = f\n if (!gitRemote)\n throw error('no host on git specifier', { spec })\n if (namedGitHost) {\n if (!namedGitHostPath) {\n throw error('named git host without path portion', {\n spec,\n })\n }\n return [\n f.type,\n `${namedGitHost}:${namedGitHostPath}`,\n gitSelector,\n ]\n } else {\n return [f.type, gitRemote, gitSelector]\n }\n }\n case 'remote': {\n const { remoteURL } = f\n if (!remoteURL)\n throw error('no URL on remote specifier', { spec })\n return [f.type, remoteURL]\n }\n case 'file':\n case 'workspace':\n throw error('Path-based dep ids are not supported', { spec })\n }\n}\n\n/**\n * Get the {@link DepID} for a given {@link Spec} and {@link Manifest}. The\n * Manifest is used to get the name and version, if possible. If not found in\n * the manifest, registry ID types will use the name or bareSpec from the\n * specifier, so at least there's something to use later.\n */\nexport const getId = (spec: Spec, mani: Manifest): DepID =>\n joinDepIDTuple(getTuple(spec, mani))\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vltpkg/dep-id",
|
|
3
|
+
"description": "create and hydrate dependency IDs",
|
|
4
|
+
"version": "0.0.0-0.1730239248325",
|
|
5
|
+
"tshy": {
|
|
6
|
+
"selfLink": false,
|
|
7
|
+
"dialects": [
|
|
8
|
+
"esm"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
"./package.json": "./package.json",
|
|
12
|
+
".": "./src/index.ts",
|
|
13
|
+
"./browser": "./src/browser.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@vltpkg/error-cause": "0.0.0-0.1730239248325",
|
|
18
|
+
"@vltpkg/types": "0.0.0-0.1730239248325",
|
|
19
|
+
"@vltpkg/spec": "0.0.0-0.1730239248325"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@eslint/js": "^9.8.0",
|
|
23
|
+
"@types/eslint__js": "^8.42.3",
|
|
24
|
+
"@types/node": "^22.4.1",
|
|
25
|
+
"eslint": "^9.8.0",
|
|
26
|
+
"prettier": "^3.3.2",
|
|
27
|
+
"tap": "^21.0.1",
|
|
28
|
+
"tshy": "^3.0.2",
|
|
29
|
+
"typescript": "^5.5.4",
|
|
30
|
+
"typescript-eslint": "^8.0.1"
|
|
31
|
+
},
|
|
32
|
+
"license": "BSD-2-Clause-Patent",
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": "20 || >=22"
|
|
35
|
+
},
|
|
36
|
+
"tap": {
|
|
37
|
+
"extends": "../../tap-config.yaml"
|
|
38
|
+
},
|
|
39
|
+
"prettier": "../../.prettierrc.js",
|
|
40
|
+
"module": "./dist/esm/index.js",
|
|
41
|
+
"type": "module",
|
|
42
|
+
"exports": {
|
|
43
|
+
"./package.json": "./package.json",
|
|
44
|
+
".": {
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./dist/esm/index.d.ts",
|
|
47
|
+
"default": "./dist/esm/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"./browser": {
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./dist/esm/browser.d.ts",
|
|
53
|
+
"default": "./dist/esm/browser.js"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"files": [
|
|
58
|
+
"dist"
|
|
59
|
+
],
|
|
60
|
+
"scripts": {
|
|
61
|
+
"format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
|
|
62
|
+
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
63
|
+
"lint": "eslint . --fix",
|
|
64
|
+
"lint:check": "eslint .",
|
|
65
|
+
"presnap": "tshy",
|
|
66
|
+
"snap": "tap",
|
|
67
|
+
"pretest": "tshy",
|
|
68
|
+
"test": "tap"
|
|
69
|
+
}
|
|
70
|
+
}
|