샘플
semver 7.8.5: clean and sanitize semantic version strings with semver.clean
검증된 샘플 — npm semver 7.8.5: clean and sanitize semantic version strings with semver.clean. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:6a6b80f4dd37641c3c3dcc5ff82926ff99b53b5e503d63b630959b27ce0a9045
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 2
선언된 환경
node windows 11 x64 node javascript npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-19 |
| 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-09-07 |
케이스
HOW- 목표
- clean and sanitize semantic version strings with semver.clean
- 패키지
- 심벌
-
- clean
- 환경
- node
- 생성일
- 2026-08-18T23:58:28Z
컨트랙트
- semver.clean strips leading whitespace, 'v' prefixes, and '=' characters from standard version strings
- semver.clean preserves prerelease tags while stripping build metadata from cleaned versions
- semver.clean returns null for invalid version strings, range expressions, and incomplete versions
- semver.clean supports loose mode and options configuration passed to parser
- semver.clean throws TypeError when non-string or nullish values are passed
파일
- PROMPT.md
- csx.json
- index.mjs
- 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: clean and sanitize semantic version strings with semver.clean
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/semver@7.8.5
Demonstrate these symbols/APIs:
- clean
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@11.8.0
- runtime: node@24.13.1
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:a24a3574dbb0e7f7112a3bd8e1d67eca893d9906c98f1f95a415ace9a5a6dcaf","constraints":{"executionContext":"node"},"contract":["semver.clean strips leading whitespace, 'v' prefixes, and '=' characters from standard version strings","semver.clean preserves prerelease tags while stripping build metadata from cleaned versions","semver.clean returns null for invalid version strings, range expressions, and incomplete versions","semver.clean supports loose mode and options configuration passed to parser","semver.clean throws TypeError when non-string or nullish values are passed"],"goal":"clean and sanitize semantic version strings with semver.clean","kind":"HOW","packages":["pkg:npm/semver@7.8.5"],"schemaVersion":1,"symbols":["clean"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"javascript","moduleSystem":"cjs","os":"windows","osVersionBucket":"11","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/semver@7.8.5"],"schemaVersion":1,"symbols":["clean"],"verifierAdapter":"node-typescript@1"}
import semver from 'semver';
/**
* Cleans and sanitizes a version string into a valid SemVer format.
* @param {string} version - Version string to clean
* @param {semver.Options} [options] - Options for parsing
* @returns {string | null} Cleaned version string or null if invalid
*/
export function cleanVersion(version, options) {
return semver.clean(version, options);
}
export default {
cleanVersion,
clean: semver.clean
};
{
"name": "sample-semver-clean",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-semver-clean",
"version": "1.0.0",
"dependencies": {
"semver": "7.8.5"
}
},
"node_modules/semver": {
"version": "7.8.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
}
}
}
{
"name": "sample-semver-clean",
"version": "1.0.0",
"type": "module",
"dependencies": {
"semver": "7.8.5"
}
}
{
"schemaVersion": 1,
"goal": "clean and sanitize semantic version strings with semver.clean",
"kind": "HOW",
"packages": [
"pkg:npm/semver@7.8.5"
],
"symbols": [
"clean"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@11.8.0",
"runtime": "node@24.13.1"
}
}
import assert from 'node:assert/strict';
import semver from 'semver';
import { cleanVersion } from '../index.mjs';
// Verify symbols and exported helpers
assert.equal(typeof semver.clean, 'function', 'semver.clean must be a function');
assert.equal(typeof cleanVersion, 'function', 'cleanVersion must be a function');
// Contract 1: semver.clean strips leading whitespace, 'v' prefixes, and '=' characters from standard version strings
{
assert.equal(semver.clean(' =v1.2.3 '), '1.2.3');
assert.equal(semver.clean('v1.2.3'), '1.2.3');
assert.equal(semver.clean(' =1.2.3 '), '1.2.3');
assert.equal(semver.clean(' 1.2.3 '), '1.2.3');
assert.equal(semver.clean('==v2.0.1'), '2.0.1');
assert.equal(cleanVersion(' =v1.2.3 '), '1.2.3');
assert.equal(cleanVersion('v3.4.5'), '3.4.5');
}
// Contract 2: semver.clean preserves prerelease tags while stripping build metadata from cleaned versions
{
assert.equal(semver.clean(' =v1.2.3-alpha.1 '), '1.2.3-alpha.1');
assert.equal(semver.clean('1.2.3-beta.2+build.99'), '1.2.3-beta.2');
assert.equal(semver.clean('v2.0.0+20130313144700'), '2.0.0');
assert.equal(cleanVersion(' v1.0.0-rc.1+sha.123 '), '1.0.0-rc.1');
}
// Contract 3: semver.clean returns null for invalid version strings, range expressions, and incomplete versions
{
assert.equal(semver.clean(''), null);
assert.equal(semver.clean('invalid'), null);
assert.equal(semver.clean('^1.2.3'), null);
assert.equal(semver.clean('~1.2.3'), null);
assert.equal(semver.clean('>=1.0.0'), null);
assert.equal(semver.clean('1.2'), null);
assert.equal(cleanVersion('not a semver'), null);
assert.equal(cleanVersion('^2.0.0'), null);
}
// Contract 4: semver.clean supports loose mode and options configuration passed to parser
{
assert.equal(semver.clean(' =v1.2.3 ', { loose: true }), '1.2.3');
assert.equal(semver.clean(' 1.2.3-0 ', { includePrerelease: true }), '1.2.3-0');
assert.equal(cleanVersion(' =v2.0.0 ', { loose: true }), '2.0.0');
}
// Contract 5: semver.clean throws TypeError when non-string or nullish values are passed
{
assert.throws(() => semver.clean(null), TypeError);
assert.throws(() => semver.clean(undefined), TypeError);
assert.throws(() => semver.clean(123), TypeError);
assert.throws(() => cleanVersion(null), TypeError);
assert.throws(() => cleanVersion(undefined), TypeError);
}
console.log('semver.clean contracts verified successfully.');
오리진 시더
익명