@vltpkg/satisfies 1.0.0-rc.9 → 1.0.1

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.
@@ -7,4 +7,3 @@ import { Monorepo } from '@vltpkg/workspaces';
7
7
  */
8
8
  export declare const satisfies: (id: DepID | undefined, spec: Spec, fromLocation?: string, projectRoot?: string, monorepo?: Monorepo) => boolean;
9
9
  export declare const satisfiesTuple: (tuple: DepIDTuple, spec: Spec, fromLocation?: string, projectRoot?: string, monorepo?: Monorepo) => boolean;
10
- //# sourceMappingURL=index.d.ts.map
@@ -14,6 +14,22 @@ export const satisfiesTuple = (tuple, spec, fromLocation = process.cwd(), projec
14
14
  const { options } = spec;
15
15
  spec = spec.final;
16
16
  const [type, first, second] = tuple;
17
+ // When a registry spec matches a workspace package by name and
18
+ // version, treat it as satisfied. This allows monorepo packages
19
+ // that reference each other with plain semver specs (e.g.
20
+ // "@dev/build-tools": "^1.0.0") to resolve to local workspace
21
+ // packages, matching npm/pnpm/yarn behavior.
22
+ if (spec.type === 'registry' && type === 'workspace') {
23
+ if (!monorepo)
24
+ return false;
25
+ const ws = monorepo.get(first);
26
+ if (ws?.name !== spec.name)
27
+ return false;
28
+ if (!spec.range)
29
+ return true;
30
+ const v = parse(ws.manifest.version ?? '');
31
+ return !!v && spec.range.test(v);
32
+ }
17
33
  if (spec.type !== type)
18
34
  return false;
19
35
  switch (spec.type) {
@@ -26,7 +42,15 @@ export const satisfiesTuple = (tuple, spec, fromLocation = process.cwd(), projec
26
42
  }
27
43
  /* c8 ignore stop */
28
44
  }
29
- else {
45
+ else if (
46
+ // With no configured registry, a plain registry spec has no
47
+ // registry of its own, but getTuple() still stamps its DepID with
48
+ // the `npm` name. Treating that as a mismatch would make
49
+ // satisfies() contradict getId(), so let it through and fall to
50
+ // the name/version checks below.
51
+ !(first === defaultRegistryName &&
52
+ !spec.registry &&
53
+ !options.registry)) {
30
54
  let namedRegistry = options.registries[first];
31
55
  /* c8 ignore next 3 */
32
56
  if (!namedRegistry && first === defaultRegistryName) {
@@ -119,4 +143,3 @@ const parseNameVer = (nv) => {
119
143
  [nv, '']
120
144
  : [nv.substring(0, at), nv.substring(at + 1)];
121
145
  };
122
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,73 +1,71 @@
1
1
  {
2
2
  "name": "@vltpkg/satisfies",
3
3
  "description": "method for determining if a DepID satisfies a Spec",
4
- "version": "1.0.0-rc.9",
4
+ "version": "1.0.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
8
8
  "directory": "src/satisfies"
9
9
  },
10
- "author": "vlt technology inc. <support@vlt.sh> (http://vlt.sh)",
11
- "tshy": {
12
- "selfLink": false,
13
- "liveDev": true,
14
- "dialects": [
15
- "esm"
16
- ],
17
- "exports": {
18
- "./package.json": "./package.json",
19
- ".": "./src/index.ts"
20
- }
10
+ "author": {
11
+ "name": "vlt technology inc.",
12
+ "email": "support@vlt.sh",
13
+ "url": "http://vlt.sh"
21
14
  },
22
15
  "dependencies": {
23
- "@vltpkg/dep-id": "1.0.0-rc.9",
24
- "@vltpkg/error-cause": "1.0.0-rc.9",
25
- "@vltpkg/semver": "1.0.0-rc.9",
26
- "@vltpkg/spec": "1.0.0-rc.9",
27
- "@vltpkg/workspaces": "1.0.0-rc.9"
16
+ "@vltpkg/dep-id": "1.0.1",
17
+ "@vltpkg/error-cause": "1.0.1",
18
+ "@vltpkg/semver": "1.0.1",
19
+ "@vltpkg/spec": "1.0.1",
20
+ "@vltpkg/workspaces": "1.0.1"
28
21
  },
29
22
  "devDependencies": {
30
- "@eslint/js": "^9.34.0",
31
- "@types/node": "^22.17.2",
32
- "eslint": "^9.34.0",
33
- "prettier": "^3.6.2",
34
- "tap": "^21.1.0",
35
- "tshy": "^3.0.2",
23
+ "@eslint/js": "^9.39.1",
24
+ "@types/node": "^22.19.2",
25
+ "eslint": "^9.39.1",
26
+ "prettier": "^3.7.4",
27
+ "tap": "^21.5.0",
36
28
  "typedoc": "~0.27.9",
37
29
  "typescript": "5.7.3",
38
- "typescript-eslint": "^8.40.0"
30
+ "typescript-eslint": "^8.49.0"
39
31
  },
40
32
  "license": "BSD-2-Clause-Patent",
41
33
  "engines": {
42
- "node": ">=22"
34
+ "node": ">=22.22.0"
35
+ },
36
+ "scripts": {
37
+ "format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
38
+ "format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
39
+ "lint": "eslint . --fix",
40
+ "lint:check": "eslint .",
41
+ "prepack": "tsc -p tsconfig.publish.json && ../../scripts/update-dist-exports.ts",
42
+ "snap": "tap",
43
+ "test": "tap",
44
+ "posttest": "tsc --noEmit",
45
+ "typecheck": "tsc --noEmit"
43
46
  },
44
47
  "tap": {
45
48
  "extends": "../../tap-config.yaml"
46
49
  },
47
50
  "prettier": "../../.prettierrc.js",
48
- "module": "./dist/esm/index.js",
51
+ "module": "./dist/index.js",
49
52
  "type": "module",
50
53
  "exports": {
51
54
  "./package.json": "./package.json",
52
55
  ".": {
53
56
  "import": {
54
- "types": "./dist/esm/index.d.ts",
55
- "default": "./dist/esm/index.js"
57
+ "default": "./dist/index.js"
56
58
  }
57
59
  }
58
60
  },
59
61
  "files": [
60
62
  "dist"
61
63
  ],
62
- "scripts": {
63
- "format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
64
- "format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
65
- "lint": "eslint . --fix",
66
- "lint:check": "eslint .",
67
- "snap": "tap",
68
- "test": "tap",
69
- "posttest": "tsc --noEmit",
70
- "tshy": "tshy",
71
- "typecheck": "tsc --noEmit"
72
- }
73
- }
64
+ "bugs": [
65
+ {
66
+ "type": "link",
67
+ "url": "https://github.com/vltpkg/vltpkg/issues"
68
+ }
69
+ ],
70
+ "homepage": "https://github.com/vltpkg/vltpkg/tree/main/src/satisfies#readme"
71
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAGvD,OAAO,EAAuB,IAAI,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAG7C;;;GAGG;AACH,eAAO,MAAM,SAAS,OAChB,KAAK,GAAG,SAAS,QACf,IAAI,0DAGC,QAAQ,KAClB,OAQA,CAAA;AAEH,eAAO,MAAM,cAAc,UAClB,UAAU,QACX,IAAI,0DAGC,QAAQ,KAClB,OAwGF,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,EAAqB,EACrB,IAAU,EACV,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,EAC5B,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,EAC3B,QAAmB,EACV,EAAE,CACX,CAAC,CAAC,EAAE;IACJ,cAAc,CACZ,UAAU,CAAC,EAAE,CAAC,EACd,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,QAAQ,CACT,CAAA;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAiB,EACjB,IAAU,EACV,YAAY,GAAG,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YACD,OAAO,IAAI,CAAA;QACb,CAAC;QAED,qBAAqB;QACrB,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,KAAK,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;IACD,oBAAoB;AACtB,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAC,EAAU,EAAoB,EAAE;IACpD,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAC9B,6CAA6C;IAC7C,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QACZ,CAAC,EAAE,EAAE,EAAE,CAAC;QACV,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;AACjD,CAAC,CAAA","sourcesContent":["import { splitDepID } from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport { parse, Version } from '@vltpkg/semver'\nimport { defaultRegistryName, Spec } from '@vltpkg/spec'\nimport type { GitSelectorParsed } from '@vltpkg/spec'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { relative, resolve } from 'node:path'\n\n/**\n * Return true if the node referenced by this DepID would satisfy the\n * supplied Spec object.\n */\nexport const satisfies = (\n id: DepID | undefined,\n spec: Spec,\n fromLocation = process.cwd(),\n projectRoot = process.cwd(),\n monorepo?: Monorepo,\n): boolean =>\n !!id &&\n satisfiesTuple(\n splitDepID(id),\n spec,\n fromLocation,\n projectRoot,\n monorepo,\n )\n\nexport const satisfiesTuple = (\n tuple: DepIDTuple,\n spec: Spec,\n fromLocation = process.cwd(),\n projectRoot = process.cwd(),\n monorepo?: Monorepo,\n): boolean => {\n const { options } = spec\n spec = spec.final\n const [type, first, second] = tuple\n if (spec.type !== type) return false\n\n switch (spec.type) {\n case 'registry': {\n /* c8 ignore start - should be impossible */\n if (!first) {\n // must be from the default registry\n if (spec.registry !== options.registry) {\n return false\n }\n /* c8 ignore stop */\n } else {\n let namedRegistry = options.registries[first]\n /* c8 ignore next 3 */\n if (!namedRegistry && first === defaultRegistryName) {\n namedRegistry = options.registry\n }\n if (namedRegistry && namedRegistry !== spec.registry) {\n // we know the name, and it's not the registry being used\n return false\n } else if (!namedRegistry && first !== spec.registry) {\n // an explicit registry URL, but does not match\n return false\n }\n }\n /* c8 ignore next */\n if (!second) throw error('Invalid DepID', { found: tuple })\n const [name, version] = parseNameVer(second)\n return (\n // mismatched name always invalid\n name !== spec.name || !version ? false\n // if just a dist-tag, assume valid\n : !spec.range ? true\n : spec.range.test(Version.parse(version))\n )\n }\n\n case 'file': {\n /* c8 ignore next - should be impossible */\n if (spec.file === undefined) return false\n const resolvedSpec = resolve(\n projectRoot,\n fromLocation,\n spec.file,\n )\n const resolvedId = resolve(projectRoot, first)\n // valid if the relative path is '', refers to the same path\n return !relative(resolvedSpec, resolvedId)\n }\n\n case 'workspace': {\n monorepo ??= Monorepo.load(projectRoot)\n /* c8 ignore next */\n if (!spec.workspace) return false\n const fromID = monorepo.get(first)\n const fromSpec = monorepo.get(spec.workspace)\n if (fromID !== fromSpec || !fromSpec || !fromID) return false\n if (!spec.range) return true\n const v = parse(fromID.manifest.version ?? '')\n return !!v && spec.range.test(v)\n }\n\n case 'remote': {\n return spec.remoteURL === first\n }\n\n case 'git': {\n const {\n gitRemote,\n gitSelectorParsed = {},\n gitSelector,\n gitCommittish,\n namedGitHost,\n namedGitHostPath,\n } = spec\n if (gitRemote !== first) {\n if (namedGitHost && namedGitHostPath) {\n const ngh = `${namedGitHost}:`\n if (first.startsWith(ngh)) {\n if (first !== ngh + namedGitHostPath) return false\n } else return false\n } else return false\n }\n if (gitSelector && !second) return false\n /* c8 ignore next - always set to something, even if empty */\n const [parsed, committish] = Spec.parseGitSelector(second ?? '')\n if (gitCommittish && committish)\n return committish.startsWith(gitCommittish)\n for (const [k, v] of Object.entries(gitSelectorParsed)) {\n if (parsed[k as keyof GitSelectorParsed] !== v) return false\n }\n return true\n }\n\n /* c8 ignore start */\n default: {\n throw error('Invalid spec type', { spec })\n }\n }\n /* c8 ignore stop */\n}\n\nconst parseNameVer = (nv: string): [string, string] => {\n const at = nv.lastIndexOf('@')\n // if it's 0, means @scoped without a version\n return at <= 0 ?\n [nv, '']\n : [nv.substring(0, at), nv.substring(at + 1)]\n}\n"]}
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }