CodeSampleX

Beispiel

semver 6.3.1: satisfies

Verifiziertes Beispiel für npm semver 6.3.1: satisfies. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: semver.satisfies evaluates…

sha256:b649dbb035f7da91676e439f0cf1f854c6feb41cb9b01fcb2be01bc3ca76528d

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-26

Fall

HOW
Ziel
verify semver.satisfies in pkg:npm/semver@6.3.1
Pakete
Symbole
  • semver.satisfies
Umgebung
node 22.23.2
Erstellt
2026-08-26T07:19:50Z

Contract

  1. semver.satisfies evaluates semantic version strings against exact, comparison (>, >=, <, <=), and hyphen range expressions
  2. semver.satisfies evaluates caret (^) ranges across non-zero major, minor, and patch leading components
  3. semver.satisfies evaluates tilde (~) ranges across major, minor, and patch specified granularities
  4. semver.satisfies evaluates wildcard (*, x, X) and compound logical OR (||) range set expressions
  5. semver.satisfies enforces prerelease tag exclusion by default and enables prerelease matching via the includePrerelease option
  6. semver.satisfies accepts loose mode flags, SemVer and Range instances, and returns false for invalid versions or ranges

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.cjs

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify semver.satisfies in pkg:npm/semver@6.3.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/semver@6.3.1
Demonstrate these symbols/APIs:
  - semver.satisfies

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:e92d3483e3b18375880abad998033646fa3461e5c5238791f783ebe5bb927ed0","constraints":{"executionContext":"node"},"contract":["semver.satisfies evaluates semantic version strings against exact, comparison (\u003e, \u003e=, \u003c, \u003c=), and hyphen range expressions","semver.satisfies evaluates caret (^) ranges across non-zero major, minor, and patch leading components","semver.satisfies evaluates tilde (~) ranges across major, minor, and patch specified granularities","semver.satisfies evaluates wildcard (*, x, X) and compound logical OR (||) range set expressions","semver.satisfies enforces prerelease tag exclusion by default and enables prerelease matching via the includePrerelease option","semver.satisfies accepts loose mode flags, SemVer and Range instances, and returns false for invalid versions or ranges"],"goal":"verify semver.satisfies in pkg:npm/semver@6.3.1","kind":"HOW","packages":["pkg:npm/semver@6.3.1"],"schemaVersion":1,"symbols":["semver.satisfies"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/semver@6.3.1"],"schemaVersion":1,"subject":"pkg:npm/semver@6.3.1","symbols":["semver.satisfies"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-semver-satisfies",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-semver-satisfies",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "semver": "6.3.1"
      }
    },
    "node_modules/semver": {
      "version": "6.3.1",
      "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
      "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver.js"
      }
    }
  }
}
package.json
{
  "name": "sample-semver-satisfies",
  "version": "1.0.0",
  "private": true,
  "license": "MIT-0",
  "dependencies": {
    "semver": "6.3.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify semver.satisfies in pkg:npm/semver@6.3.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/semver@6.3.1"
  ],
  "symbols": [
    "semver.satisfies"
  ]
}
test/contract.cjs
const assert = require('node:assert/strict');
const semver = require('semver');

// Contract 1: semver.satisfies evaluates semantic version strings against exact, comparison (>, >=, <, <=), and hyphen range expressions
{
  assert.strictEqual(semver.satisfies('1.2.3', '1.2.3'), true, 'Exact version equality match');
  assert.strictEqual(semver.satisfies('1.2.4', '1.2.3'), false, 'Different version mismatch on exact range');

  assert.strictEqual(semver.satisfies('1.3.0', '>1.2.3'), true, 'Greater than comparison returns true');
  assert.strictEqual(semver.satisfies('1.2.3', '>1.2.3'), false, 'Strictly greater than fails on equal version');
  assert.strictEqual(semver.satisfies('1.2.3', '>=1.2.3'), true, 'Greater than or equal returns true on equal version');
  assert.strictEqual(semver.satisfies('1.2.2', '>=1.2.3'), false, 'Greater than or equal returns false on lower version');

  assert.strictEqual(semver.satisfies('1.2.2', '<1.2.3'), true, 'Less than comparison returns true');
  assert.strictEqual(semver.satisfies('1.2.3', '<1.2.3'), false, 'Strictly less than fails on equal version');
  assert.strictEqual(semver.satisfies('1.2.3', '<=1.2.3'), true, 'Less than or equal returns true on equal version');
  assert.strictEqual(semver.satisfies('1.2.4', '<=1.2.3'), false, 'Less than or equal returns false on higher version');

  assert.strictEqual(semver.satisfies('1.2.3', '1.2.0 - 1.3.0'), true, 'Hyphen range satisfies middle version');
  assert.strictEqual(semver.satisfies('1.3.0', '1.2.0 - 1.3.0'), true, 'Hyphen range satisfies inclusive upper boundary');
  assert.strictEqual(semver.satisfies('1.3.1', '1.2.0 - 1.3.0'), false, 'Hyphen range rejects version above upper boundary');
}

// Contract 2: semver.satisfies evaluates caret (^) ranges across non-zero major, minor, and patch leading components
{
  // Major > 0 (^1.2.3 matches >=1.2.3 <2.0.0)
  assert.strictEqual(semver.satisfies('1.2.3', '^1.2.3'), true, 'Caret major matches minimum version');
  assert.strictEqual(semver.satisfies('1.9.9', '^1.2.3'), true, 'Caret major matches higher minor/patch');
  assert.strictEqual(semver.satisfies('2.0.0', '^1.2.3'), false, 'Caret major rejects next major');
  assert.strictEqual(semver.satisfies('1.2.2', '^1.2.3'), false, 'Caret major rejects below minimum patch');

  // Major == 0, Minor > 0 (^0.2.3 matches >=0.2.3 <0.3.0)
  assert.strictEqual(semver.satisfies('0.2.3', '^0.2.3'), true, 'Caret 0.x matches minimum version');
  assert.strictEqual(semver.satisfies('0.2.9', '^0.2.3'), true, 'Caret 0.x matches higher patch');
  assert.strictEqual(semver.satisfies('0.3.0', '^0.2.3'), false, 'Caret 0.x rejects next minor');
  assert.strictEqual(semver.satisfies('0.2.2', '^0.2.3'), false, 'Caret 0.x rejects below minimum patch');

  // Major == 0, Minor == 0 (^0.0.3 matches >=0.0.3 <0.0.4)
  assert.strictEqual(semver.satisfies('0.0.3', '^0.0.3'), true, 'Caret 0.0.x matches exact patch');
  assert.strictEqual(semver.satisfies('0.0.4', '^0.0.3'), false, 'Caret 0.0.x rejects different patch');
}

// Contract 3: semver.satisfies evaluates tilde (~) ranges across major, minor, and patch specified granularities
{
  // ~1.2.3 matches >=1.2.3 <1.3.0
  assert.strictEqual(semver.satisfies('1.2.3', '~1.2.3'), true, 'Tilde matches minimum specified patch');
  assert.strictEqual(semver.satisfies('1.2.9', '~1.2.3'), true, 'Tilde matches higher patch in same minor');
  assert.strictEqual(semver.satisfies('1.3.0', '~1.2.3'), false, 'Tilde rejects next minor');
  assert.strictEqual(semver.satisfies('1.2.2', '~1.2.3'), false, 'Tilde rejects lower patch');

  // ~1.2 matches >=1.2.0 <1.3.0
  assert.strictEqual(semver.satisfies('1.2.0', '~1.2'), true, 'Tilde with major.minor matches base patch');
  assert.strictEqual(semver.satisfies('1.2.5', '~1.2'), true, 'Tilde with major.minor matches any patch');
  assert.strictEqual(semver.satisfies('1.3.0', '~1.2'), false, 'Tilde with major.minor rejects next minor');

  // ~1 matches >=1.0.0 <2.0.0
  assert.strictEqual(semver.satisfies('1.0.0', '~1'), true, 'Tilde with major only matches initial version');
  assert.strictEqual(semver.satisfies('1.9.9', '~1'), true, 'Tilde with major only matches higher minor/patch');
  assert.strictEqual(semver.satisfies('2.0.0', '~1'), false, 'Tilde with major only rejects next major');
}

// Contract 4: semver.satisfies evaluates wildcard (*, x, X) and compound logical OR (||) range set expressions
{
  assert.strictEqual(semver.satisfies('1.2.3', '*'), true, 'Wildcard * satisfies version');
  assert.strictEqual(semver.satisfies('0.0.1', ''), true, 'Empty string range satisfies any version');
  assert.strictEqual(semver.satisfies('1.4.2', '1.x'), true, '1.x wildcard matches any 1.y.z version');
  assert.strictEqual(semver.satisfies('2.0.0', '1.x'), false, '1.x wildcard rejects 2.0.0');
  assert.strictEqual(semver.satisfies('1.2.4', '1.2.X'), true, '1.2.X wildcard matches patch variations');
  assert.strictEqual(semver.satisfies('1.3.0', '1.2.X'), false, '1.2.X wildcard rejects minor changes');

  assert.strictEqual(semver.satisfies('1.2.3', '^1.2.0 || >=3.0.0'), true, 'Logical OR matches left branch');
  assert.strictEqual(semver.satisfies('3.5.0', '^1.2.0 || >=3.0.0'), true, 'Logical OR matches right branch');
  assert.strictEqual(semver.satisfies('2.5.0', '^1.2.0 || >=3.0.0'), false, 'Logical OR rejects version between sets');
}

// Contract 5: semver.satisfies enforces prerelease tag exclusion by default and enables prerelease matching via the includePrerelease option
{
  assert.strictEqual(semver.satisfies('1.2.3-alpha.1', '^1.2.0'), false, 'Prerelease version is excluded from regular range by default');
  assert.strictEqual(semver.satisfies('1.2.3-alpha.2', '^1.2.3-alpha.1'), true, 'Prerelease satisfies range with matching major.minor.patch tuple');
  assert.strictEqual(semver.satisfies('1.2.4-alpha.0', '^1.2.3-alpha.1'), false, 'Prerelease with different tuple is excluded');

  assert.strictEqual(semver.satisfies('1.2.3-alpha.1', '^1.2.0', { includePrerelease: true }), true, 'includePrerelease option enables prerelease satisfaction in range');
  assert.strictEqual(semver.satisfies('1.2.4-alpha.0', '^1.2.3', { includePrerelease: true }), true, 'includePrerelease allows next patch prerelease');
  assert.strictEqual(semver.satisfies('2.0.0-alpha.0', '^1.2.3', { includePrerelease: true }), true, '2.0.0-alpha.0 is strictly less than 2.0.0 so satisfies ^1.2.3 when includePrerelease is true');
  assert.strictEqual(semver.satisfies('2.0.0', '^1.2.3', { includePrerelease: true }), false, '2.0.0 release itself does not satisfy ^1.2.3');
  assert.strictEqual(semver.satisfies('2.0.1-alpha.0', '^1.2.3', { includePrerelease: true }), false, 'includePrerelease rejects versions strictly greater than upper range bound');
}

// Contract 6: semver.satisfies accepts loose mode flags, SemVer and Range instances, and returns false for invalid versions or ranges
{
  assert.strictEqual(semver.satisfies('v1.2.3', '^1.0.0', true), true, 'Boolean loose flag accepts v prefix');
  assert.strictEqual(semver.satisfies('v1.2.3', '^1.0.0', { loose: true }), true, 'Options object loose flag accepts v prefix');

  const semverObj = new semver.SemVer('1.2.3');
  const rangeObj = new semver.Range('^1.0.0');
  assert.strictEqual(semver.satisfies(semverObj, rangeObj), true, 'Direct SemVer and Range instances are evaluated correctly');

  assert.strictEqual(semver.satisfies('not-a-valid-version', '^1.0.0'), false, 'Invalid version string returns false without throwing');
  assert.strictEqual(semver.satisfies('1.2.3', 'not-a-valid-range'), false, 'Invalid range string returns false without throwing');
  assert.strictEqual(semver.satisfies(null, '^1.0.0'), false, 'Null version returns false');
  assert.strictEqual(semver.satisfies('1.2.3', null), false, 'Null range returns false');
  assert.strictEqual(semver.satisfies(undefined, undefined), false, 'Undefined arguments return false');
}

console.log('All semver.satisfies contract assertions passed.');

Ursprungs-Seeder

anonym