index
Classes
Spec
Defined in: spec/src/index.ts:17
The base, isomorphic Spec implementation.
Extends
Implements
Constructors
new Spec()
new Spec(
name,
bareSpec,
options?): SpecDefined in: spec/src/browser.ts:368
The initial value of Object.prototype.constructor is the standard built-in Object constructor.
Parameters
| Parameter | Type |
|---|---|
name | string |
bareSpec | string |
options? | SpecOptions |
Returns
Inherited from
new Spec()
new Spec(spec, options?): SpecDefined in: spec/src/browser.ts:369
The initial value of Object.prototype.constructor is the standard built-in Object constructor.
Parameters
| Parameter | Type |
|---|---|
spec | string |
options? | SpecOptions |
Returns
Inherited from
new Spec()
new Spec(
spec,
bareOrOptions?,
options?): SpecDefined in: spec/src/browser.ts:370
The initial value of Object.prototype.constructor is the standard built-in Object constructor.
Parameters
| Parameter | Type |
|---|---|
spec | string | Spec |
bareOrOptions? | string | SpecOptions |
options? | SpecOptions |
Returns
Inherited from
Properties
| Property | Type | Default value | Description | Inherited from |
|---|---|---|---|---|
bareSpec | string | undefined | just the part AFTER the name, so 1.x in foo@1.x | SpecLike.bareSpec Spec.bareSpec |
catalog? | string | undefined | - | Spec.catalog |
constructor | typeof Spec | undefined | The initial value of Object.prototype.constructor is the standard built-in Object constructor. | BrowserSpec.constructor |
conventionalRegistryTarball? | string | undefined | conventional location of the tarball on the registry, if it can be guessed. This is only attempted if the spec is a registry type, with a single version comparator. This can be used to elide resolved urls that are repetitive and predictable. | SpecLike.conventionalRegistryTarball Spec.conventionalRegistryTarball |
distTag? | string | undefined | a dist-tag like 'latest' | SpecLike.distTag Spec.distTag |
file? | string | undefined | file path for file:// url specs | SpecLike.file Spec.file |
gitCommittish? | string | undefined | the commit value we will check out | SpecLike.gitCommittish Spec.gitCommittish |
gitRemote? | string | undefined | the git remote to fetch from | SpecLike.gitRemote Spec.gitRemote |
gitSelector? | string | undefined | the committish, semver range, and/or path portion of a git remote | SpecLike.gitSelector Spec.gitSelector |
gitSelectorParsed? | GitSelectorParsed | undefined | the parsed '::'-separated key/value pairs: semver:<range> and path:<subpath> | SpecLike.gitSelectorParsed Spec.gitSelectorParsed |
name | string | undefined | the name portion, so foo in foo@1.x | SpecLike.name Spec.name |
namedGitHost? | string | undefined | github, gitlab, bitbucket, gist, etc. | SpecLike.namedGitHost Spec.namedGitHost |
namedGitHostPath? | string | undefined | the path that's parsed when we have a named git host | SpecLike.namedGitHostPath Spec.namedGitHostPath |
namedJsrRegistry? | string | undefined | - | Spec.namedJsrRegistry |
namedRegistry? | string | undefined | In specs like foo@npm:bar@1, this is the 'npm' part. Other registries can be mapped using the registries option. | SpecLike.namedRegistry Spec.namedRegistry |
options | SpecOptionsFilled | undefined | options passed to the constructor, plus defaults | SpecLike.options Spec.options |
overridden | boolean | false | Is this a spec that overrides another spec? | SpecLike.overridden Spec.overridden |
range? | Range | undefined | parsed semver range specifier | SpecLike.range Spec.range |
registry? | string | undefined | registry to consult to resolve this spec | SpecLike.registry Spec.registry |
registrySpec? | string | undefined | semver range or dist-tag for resolving against a packument | SpecLike.registrySpec Spec.registrySpec |
remoteURL? | string | undefined | URL to download a tarball from, if it can be determined. This is set for url specs of course, but also git remotes on known hosts that provide a gitHostArchive template. | SpecLike.remoteURL Spec.remoteURL |
scope? | `@${string}` | undefined | the name's scope, so @acme in @acme/foo@1.x | SpecLike.scope Spec.scope |
scopeRegistry? | string | undefined | if the name is scoped, and there's a registry associated with the scope, then this is that registry | SpecLike.scopeRegistry Spec.scopeRegistry |
semver? | string | undefined | spec to resolve against available versions | SpecLike.semver Spec.semver |
spec | string | undefined | the full named specifier passed to the constructor | SpecLike.spec Spec.spec |
subspec? | Spec | undefined | in bar@npm:foo@1.x, this is the spec for foo@1.x | SpecLike.subspec Spec.subspec |
type | SpecType | undefined | the type of spec that this is, ultimately | SpecLike.type Spec.type |
workspace? | string | undefined | the package name or path of the workspace being referenced | SpecLike.workspace Spec.workspace |
workspaceSpec? | string | undefined | the specifier when using workspace: specs This can be either a semver range, *, ~, or ^, if the name is not modified. Or, it can include a workspace package name or path, like workspace:packages/foo@* or workspace:@scope/foo@*. | SpecLike.workspaceSpec Spec.workspaceSpec |
nodejsDependencies? | NodeJSDependenciesOptions | undefined | - | Spec.nodejsDependencies |
Accessors
final
Get Signature
get final(): Spec & objectDefined in: spec/src/browser.ts:337
Return the final entry in the chain of subspecs When deciding which thing to actually fetch, spec.final is the thing to look at.
Returns
Spec & object
Implementation of
SpecLike.finalInherited from
Methods
[kCustomInspect]()
kCustomInspect: stringDefined in: spec/src/index.ts:18
Parameters
| Parameter | Type |
|---|---|
_depth? | number |
options? | InspectOptions |
Returns
string
Overrides
toString()
toString(): stringDefined in: spec/src/browser.ts:356
Normally, the string value of a Spec is just the string passed in to
be parsed. However, in the case of a chain of subspecs, like
foo@npm:bar@npm:baz@npm:quux@latest, this simplifies out the middle
parts of the chain, returning just foo@npm:quux@latest
Returns
string
Implementation of
SpecLike.toStringInherited from
parse()
Call Signature
static parse(
name,
bareSpec,
options?): SpecDefined in: spec/src/browser.ts:246
Create a Spec object from a full spec, name+bareSpec, or Spec object
Note: If a Spec object is provided, it is returned as-is, without investigating whether the options match.
Parameters
| Parameter | Type |
|---|---|
name | string |
bareSpec | string |
options? | SpecOptions |
Returns
Inherited from
Call Signature
static parse(spec, options?): SpecDefined in: spec/src/browser.ts:251
Create a Spec object from a full spec, name+bareSpec, or Spec object
Note: If a Spec object is provided, it is returned as-is, without investigating whether the options match.
Parameters
| Parameter | Type |
|---|---|
spec | string |
options? | SpecOptions |
Returns
Inherited from
Call Signature
static parse(spec, options?): SpecDefined in: spec/src/browser.ts:252
Create a Spec object from a full spec, name+bareSpec, or Spec object
Note: If a Spec object is provided, it is returned as-is, without investigating whether the options match.
Parameters
| Parameter | Type |
|---|---|
spec | Spec |
options? | SpecOptions |
Returns
Inherited from
parseArgs()
static parseArgs(specOrBareSpec, opts?): SpecDefined in: spec/src/browser.ts:263
Parameters
| Parameter | Type |
|---|---|
specOrBareSpec | string |
opts? | SpecOptions |
Returns
Inherited from
parseGitSelector()
static parseGitSelector(selector, spec?): [GitSelectorParsed, string, Range]Defined in: spec/src/browser.ts:878
Should only ever be called with the bit that comes AFTER the # in the git remote url.
Parameters
| Parameter | Type |
|---|---|
selector | string |
spec? | Spec |
Returns
[GitSelectorParsed, string, Range]
Inherited from
Type Aliases
GitSelectorParsed
type GitSelectorParsed = object;Defined in: spec/src/types.ts:48
Type declaration
| Name | Type |
|---|---|
path? | string |
semver? | string |
Scope
type Scope = `@${string}`;Defined in: spec/src/types.ts:7
SpecLike<Type>
type SpecLike<Type> = SpecLikeBase & object;Defined in: spec/src/types.ts:164
Type declaration
| Name | Type |
|---|---|
final | Type |
subspec? | Type |
Type Parameters
| Type Parameter |
|---|
Type extends SpecLikeBase |
SpecLikeBase
type SpecLikeBase = object;Defined in: spec/src/types.ts:56
Type declaration
| Name | Type | Description |
|---|---|---|
bareSpec | string | just the part AFTER the name, so 1.x in foo@1.x |
conventionalRegistryTarball? | string | conventional location of the tarball on the registry, if it can be guessed. This is only attempted if the spec is a registry type, with a single version comparator. This can be used to elide resolved urls that are repetitive and predictable. |
distTag? | string | a dist-tag like 'latest' |
file? | string | file path for file:// url specs |
final | SpecLikeBase | getter that retrieves the actual spec value to be used |
gitCommittish? | string | the commit value we will check out |
gitRemote? | string | the git remote to fetch from |
gitSelector? | string | the committish, semver range, and/or path portion of a git remote |
gitSelectorParsed? | GitSelectorParsed | the parsed '::'-separated key/value pairs: semver:<range> and path:<subpath> |
name | string | the name portion, so foo in foo@1.x |
namedGitHost? | string | github, gitlab, bitbucket, gist, etc. |
namedGitHostPath? | string | the path that's parsed when we have a named git host |
namedRegistry? | string | In specs like foo@npm:bar@1, this is the 'npm' part. Other registries can be mapped using the registries option. |
options | SpecOptionsFilled | options passed to the constructor, plus defaults |
overridden | boolean | Is this a spec that overrides another spec? |
range? | Range | parsed semver range specifier |
registry? | string | registry to consult to resolve this spec |
registrySpec? | string | semver range or dist-tag for resolving against a packument |
remoteURL? | string | URL to download a tarball from, if it can be determined. This is set for url specs of course, but also git remotes on known hosts that provide a gitHostArchive template. |
scope? | Scope | the name's scope, so @acme in @acme/foo@1.x |
scopeRegistry? | string | if the name is scoped, and there's a registry associated with the scope, then this is that registry |
semver? | string | spec to resolve against available versions |
spec | string | the full named specifier passed to the constructor |
subspec? | SpecLikeBase | in bar@npm:foo@1.x, this is the spec for foo@1.x |
type | SpecType | the type of spec that this is, ultimately |
workspace? | string | the package name or path of the workspace being referenced |
workspaceSpec? | string | the specifier when using workspace: specs This can be either a semver range, *, ~, or ^, if the name is not modified. Or, it can include a workspace package name or path, like workspace:packages/foo@* or workspace:@scope/foo@*. |
toString() | string | - |
SpecOptions
type SpecOptions = { [k in keyof SpecOptionsFilled]?: SpecOptionsFilled[k] };Defined in: spec/src/types.ts:3
SpecOptionsFilled
type SpecOptionsFilled = object;Defined in: spec/src/types.ts:9
Type declaration
| Name | Type | Description |
|---|---|---|
catalog | Record<string, string> | - |
catalogs? | Record<string, Record<string, string>> | - |
default-registry-alias | string | The name of the registry alias (a key in registries) that bare specs (e.g. foo@latest) and transitive deps without an explicit registry protocol resolve through, when no registry or scoped-registries entry applies. Defaults to 'npm'. The npm alias itself has no built-in URL -- it must be configured (e.g. via vlt setup), otherwise bare specs resolve with spec.registry === undefined. |
git-host-archives | Record<string, string> | tarball hosting services for hosts listed in git-hosts |
git-hosts | Record<string, string> | shorthand prefix names for known git hosts |
jsr-registries | Record<string, string> | registries that work like https://npm.jsr.io |
registries | Record<string, string> | shorthand prefix names for known registries |
registry? | string | The registry where a spec should be resolved against. There is no default. If no registry is configured, registry-type specs parsed without one will have spec.registry === undefined, and anything that needs to build a registry URL will fail. Named registry aliases (gh:, jsr:) and scoped-registries are unaffected. For bare specs, this takes precedence over the default-registry-alias lookup but not over a matching scoped-registries entry. |
scoped-registries | Record<Scope, string> | registries mapped to a @scope |
SpecType
type SpecType = "file" | "git" | "registry" | "remote" | "workspace" | "catalog";Defined in: spec/src/types.ts:53
Functions
assertPathSafeName()
function assertPathSafeName(name, from?): voidDefined in: spec/src/valid-name.ts:26
Throw unless name is usable as a filesystem path segment. from is
the actionable origin of the name: a tarball URL, git spec, or manifest
path.
Parameters
| Parameter | Type |
|---|---|
name | unknown |
from? | string |
Returns
void
isPathSafeName()
function isPathSafeName(name): booleanDefined in: spec/src/valid-name.ts:18
Is a given value usable as a filesystem path segment?
Parameters
| Parameter | Type |
|---|---|
name | unknown |
Returns
boolean
References
currentDefaultRegistryName
Re-exports currentDefaultRegistryName
defaultGitHostArchives
Re-exports defaultGitHostArchives
defaultGitHosts
Re-exports defaultGitHosts
defaultJsrRegistries
Re-exports defaultJsrRegistries
defaultRegistries
Re-exports defaultRegistries
defaultRegistryName
Re-exports defaultRegistryName
defaultScopeRegistries
Re-exports defaultScopeRegistries
getNormalizeFile
Re-exports getNormalizeFile
getOptions
Re-exports getOptions
gitHostWebsites
Re-exports gitHostWebsites
isSpec
Re-exports isSpec
kCustomInspect
Re-exports kCustomInspect
NodeJSDependenciesOptions
Re-exports NodeJSDependenciesOptions