@vltpkg/spec 1.6.4 → 1.8.0

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 CHANGED
@@ -152,8 +152,9 @@ const fooFromAcmeReg = Spec.parse(
152
152
  - gitCommittish - the commit sha, branch, or tag
153
153
  - namedGitHost - `github`, `gitlab`, `bitbucket`, etc.
154
154
  - remoteURL - when using a named git host with an archive url
155
- template, and a committish is provided, this is the url to
156
- download a tarball archive
155
+ template, and no `path` or `semver` selector, this is the url to
156
+ download a tarball archive (no committish: `HEAD`, if the template
157
+ has `$committish`)
157
158
  - semver - the semver range, if provided in the gitSelector
158
159
  - range - the parsed semver range, if valid
159
160
  - when `type` === `'registry'`:
package/dist/browser.d.ts CHANGED
@@ -6,6 +6,7 @@ export declare const kCustomInspect: unique symbol;
6
6
  export declare const defaultRegistryName = "npm";
7
7
  export declare const defaultRegistries: {
8
8
  gh: string;
9
+ npm: string;
9
10
  };
10
11
  export declare const defaultJsrRegistries: {
11
12
  jsr: string;
package/dist/browser.js CHANGED
@@ -7,6 +7,7 @@ export const kCustomInspect = Symbol.for('nodejs.util.inspect.custom');
7
7
  export const defaultRegistryName = 'npm';
8
8
  export const defaultRegistries = {
9
9
  gh: 'https://npm.pkg.github.com/',
10
+ npm: 'https://registry.vlt.io/upstream/npm/',
10
11
  };
11
12
  export const defaultJsrRegistries = { jsr: 'https://npm.jsr.io/' };
12
13
  export const defaultGitHosts = {
@@ -16,10 +17,10 @@ export const defaultGitHosts = {
16
17
  gist: 'git+ssh://git@gist.github.com/$1.git',
17
18
  };
18
19
  export const defaultGitHostArchives = {
19
- github: 'https://api.github.com/repos/$1/$2/tarball/$committish',
20
+ github: 'https://codeload.github.com/$1/$2/legacy.tar.gz/$committish',
20
21
  bitbucket: 'https://bitbucket.org/$1/$2/get/$committish.tar.gz',
21
22
  gist: 'https://codeload.github.com/gist/$1/tar.gz/$committish',
22
- gitlab: 'https://gitlab.com/$1/$2/repository/archive.tar.gz?ref=$committish',
23
+ gitlab: 'https://gitlab.com/api/v4/projects/$1%2F$2/repository/archive.tar.gz?sha=$committish',
23
24
  };
24
25
  /**
25
26
  * These are just for legacy support of urls that are supported by npm
@@ -50,7 +51,13 @@ export const getOptions = (options) => ({
50
51
  },
51
52
  registry: options?.registry,
52
53
  'default-registry-alias': options?.['default-registry-alias'] ?? defaultRegistryName,
53
- 'scoped-registries': options?.['scoped-registries'] ?? {},
54
+ // JSR packages name their JSR deps `@jsr/*`: send that scope to the
55
+ // jsr alias unless the user maps it
56
+ 'scoped-registries': {
57
+ '@jsr': options?.['jsr-registries']?.jsr ??
58
+ defaultScopeRegistries['@jsr'],
59
+ ...options?.['scoped-registries'],
60
+ },
54
61
  'git-hosts': options?.['git-hosts'] ?
55
62
  {
56
63
  ...defaultGitHosts,
@@ -590,17 +597,25 @@ export class Spec {
590
597
  this.namedGitHost = name;
591
598
  this.namedGitHostPath = hostPath;
592
599
  this.#parseGitSelector(t);
593
- if (this.gitCommittish && !this.gitSelectorParsed?.path) {
594
- const archiveHost = this.options['git-host-archives'][name];
600
+ const archiveHost = this.options['git-host-archives'][name];
601
+ // no ref: the default branch, if the archive url can name it
602
+ const head = !this.gitCommittish &&
603
+ !this.range &&
604
+ this.gitSelectorParsed?.path === undefined &&
605
+ !!archiveHost?.includes('$committish');
606
+ if ((this.gitCommittish || head) &&
607
+ !this.gitSelectorParsed?.path) {
595
608
  if (name === 'github' &&
596
- this.gitCommittish.startsWith('pull/') &&
609
+ this.gitCommittish?.startsWith('pull/') &&
597
610
  this.gitCommittish.match(/\//g)?.length === 1) {
598
611
  this.gitCommittish += '/head';
599
612
  }
600
613
  if (archiveHost) {
601
614
  this.type = 'remote';
602
615
  let t = archiveHost;
603
- t = t.split('$committish').join(this.gitCommittish);
616
+ t = t
617
+ .split('$committish')
618
+ .join(this.gitCommittish || 'HEAD');
604
619
  for (let i = 0; i < split.length; i++) {
605
620
  t = t.split(`$${i + 1}`).join(split[i]);
606
621
  }
package/dist/types.d.ts CHANGED
@@ -7,10 +7,12 @@ export type SpecOptionsFilled = {
7
7
  /**
8
8
  * The registry where a spec should be resolved against.
9
9
  *
10
- * There is **no default**. If no registry is configured, registry-type
11
- * specs parsed without one will have `spec.registry === undefined`, and
12
- * anything that needs to build a registry URL will fail. Named registry
13
- * aliases (`gh:`, `jsr:`) and `scoped-registries` are unaffected.
10
+ * There is **no default**: when unset, bare specs resolve through the
11
+ * `default-registry-alias` (the built-in `npm` alias, vlt's public npm
12
+ * mirror, unless configured). Only when that alias has no URL do
13
+ * registry-type specs get `spec.registry === undefined`, and anything
14
+ * that needs to build a registry URL fails. Named registry aliases
15
+ * (`gh:`, `jsr:`) and `scoped-registries` are unaffected.
14
16
  *
15
17
  * For bare specs, this takes precedence over the
16
18
  * `default-registry-alias` lookup but not over a matching
@@ -23,9 +25,10 @@ export type SpecOptionsFilled = {
23
25
  * protocol resolve through, when no `registry` or `scoped-registries`
24
26
  * entry applies.
25
27
  *
26
- * Defaults to `'npm'`. The `npm` alias itself has **no** built-in URL --
27
- * it must be configured (e.g. via `vlt setup`), otherwise bare specs
28
- * resolve with `spec.registry === undefined`.
28
+ * Defaults to `'npm'`, whose built-in URL is vlt's public, read-only
29
+ * npm mirror (`https://registry.vlt.io/upstream/npm/`). `vlt setup` or
30
+ * `registries.npm` point it elsewhere. An alias with no URL makes bare
31
+ * specs resolve with `spec.registry === undefined`.
29
32
  */
30
33
  'default-registry-alias': string;
31
34
  /** shorthand prefix names for known registries */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/spec",
3
3
  "description": "Package specifier library",
4
- "version": "1.6.4",
4
+ "version": "1.8.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -13,21 +13,21 @@
13
13
  "url": "http://vlt.sh"
14
14
  },
15
15
  "dependencies": {
16
- "@vltpkg/error-cause": "1.6.4",
17
- "@vltpkg/semver": "1.6.4"
16
+ "@vltpkg/error-cause": "1.8.0",
17
+ "@vltpkg/semver": "1.8.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@eslint/js": "^9.39.1",
20
+ "@eslint/js": "^10.0.1",
21
21
  "@types/node": "^22.19.2",
22
22
  "@types/npm-package-arg": "^6.1.4",
23
23
  "@vltpkg/benchmark": "0.0.0",
24
- "eslint": "^9.39.1",
24
+ "eslint": "^10.14.0",
25
25
  "npm-package-arg": "^13.0.2",
26
26
  "prettier": "^3.7.4",
27
27
  "tap": "^21.8.0",
28
28
  "typedoc": "~0.27.9",
29
29
  "typescript": "5.7.3",
30
- "typescript-eslint": "^8.49.0"
30
+ "typescript-eslint": "^8.56.0"
31
31
  },
32
32
  "license": "BSD-2-Clause-Patent",
33
33
  "engines": {