サンプル
semver 6.3.1: maxSatisfying
検証済みサンプル — npm semver 6.3.1: maxSatisfying. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: assert semver.maxSatisfying returns the highest…
sha256:8807006571f3989d88d5ca75d838b8b00f8fced177bd0e2c2795c8c8e86403b6
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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-28 |
ケース
HOW- ゴール
- verify semver.maxSatisfying in pkg:npm/semver@6.3.1
- パッケージ
- シンボル
-
- semver.maxSatisfying
- 環境
- node 22.23.2
- 作成日
- 2026-08-28T02:31:54Z
コントラクト
- assert semver.maxSatisfying returns the highest version in an array satisfying a caret range
- assert semver.maxSatisfying returns the highest version matching a bounded comparison range
- assert semver.maxSatisfying returns null when no version satisfies the specified range
- assert semver.maxSatisfying returns null for an empty array of versions
- assert semver.maxSatisfying respects the includePrerelease option to match prerelease versions
- assert semver.maxSatisfying respects the loose option for loose version string formats
ファイル
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
ソース
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.maxSatisfying 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.maxSatisfying
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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.
{"case":{"caseId":"case:sha256:96c0f1a505fbad0f8b71e44a6ea7d669004518616050c09ddf89b98a28568844","constraints":{"executionContext":"node"},"contract":["assert semver.maxSatisfying returns the highest version in an array satisfying a caret range","assert semver.maxSatisfying returns the highest version matching a bounded comparison range","assert semver.maxSatisfying returns null when no version satisfies the specified range","assert semver.maxSatisfying returns null for an empty array of versions","assert semver.maxSatisfying respects the includePrerelease option to match prerelease versions","assert semver.maxSatisfying respects the loose option for loose version string formats"],"goal":"verify semver.maxSatisfying in pkg:npm/semver@6.3.1","kind":"HOW","packages":["pkg:npm/semver@6.3.1"],"schemaVersion":1,"symbols":["semver.maxSatisfying"]},"contractCommand":["node","test/contract.mjs"],"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.maxSatisfying"],"verifierAdapter":"node-typescript@1"}
const semver = require('semver');
/**
* Finds the maximum satisfying version from a list of versions against a range.
*
* @param {string[]} versions - Array of version strings.
* @param {string} range - Semver range string.
* @param {object} [options] - Options object (e.g., includePrerelease, loose).
* @returns {string|null} The highest satisfying version string, or null if none match.
*/
function findMaxSatisfying(versions, range, options) {
return semver.maxSatisfying(versions, range, options);
}
module.exports = {
findMaxSatisfying,
semver,
};
{
"name": "sample-semver-max-satisfying",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-semver-max-satisfying",
"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"
}
}
}
}
{
"name": "sample-semver-max-satisfying",
"version": "1.0.0",
"description": "Clean-room sample verifying semver.maxSatisfying functionality",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"semver": "6.3.1"
}
}
{
"schemaVersion": 1,
"goal": "verify semver.maxSatisfying in pkg:npm/semver@6.3.1",
"kind": "HOW",
"packages": [
"pkg:npm/semver@6.3.1"
],
"symbols": [
"semver.maxSatisfying"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert';
import semver from 'semver';
import { findMaxSatisfying } from '../index.js';
// 1. Returns the highest version in an array satisfying a caret range
const versions1 = ['1.2.0', '1.2.3', '1.3.0', '2.0.0', '1.2.9'];
const max1 = findMaxSatisfying(versions1, '^1.2.0');
assert.strictEqual(max1, '1.3.0', 'semver.maxSatisfying must return the highest version satisfying ^1.2.0');
const directMax1 = semver.maxSatisfying(versions1, '^1.2.0');
assert.strictEqual(directMax1, '1.3.0', 'semver.maxSatisfying direct call must return 1.3.0');
// 2. Returns the highest version matching a bounded comparison range
const versions2 = ['1.0.0', '1.4.9', '1.5.0', '1.8.2', '2.0.1'];
const max2 = findMaxSatisfying(versions2, '>=1.0.0 <1.5.0');
assert.strictEqual(max2, '1.4.9', 'semver.maxSatisfying must return highest within range >=1.0.0 <1.5.0');
// 3. Returns null when no version satisfies the specified range
const versions3 = ['1.0.0', '1.2.0', '1.3.0'];
const max3 = findMaxSatisfying(versions3, '^2.0.0');
assert.strictEqual(max3, null, 'semver.maxSatisfying must return null when no version matches');
// 4. Returns null for an empty array of versions
const max4 = findMaxSatisfying([], '^1.0.0');
assert.strictEqual(max4, null, 'semver.maxSatisfying must return null for an empty versions array');
// 5. Respects the includePrerelease option to match prerelease versions
const versions5 = ['1.2.0', '1.2.4-alpha.1', '1.2.4-beta.0'];
const maxNoPrerelease = findMaxSatisfying(versions5, '^1.2.3');
assert.strictEqual(maxNoPrerelease, null, 'semver.maxSatisfying without includePrerelease must return null for prereleases');
const maxWithPrerelease = findMaxSatisfying(versions5, '^1.2.3', { includePrerelease: true });
assert.strictEqual(maxWithPrerelease, '1.2.4-beta.0', 'semver.maxSatisfying with includePrerelease must return the highest matching prerelease');
// 6. Respects the loose option for loose version string formats
const looseVersions = ['v1.2.0', 'v1.3.0', '2.0.0'];
const maxLoose = findMaxSatisfying(looseVersions, '^1.0.0', { loose: true });
assert.strictEqual(maxLoose, 'v1.3.0', 'semver.maxSatisfying with loose option must parse loose version strings');
console.log('All contract assertions passed.');
オリジンシーダー
匿名