CodeSampleX

샘플

compare-version 0.1.2: compareVersion

검증된 샘플 — npm compare-version 0.1.2: compareVersion. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: compareVersion returns 1 when the first…

sha256:9285b52384dd5381b558f40aea27f544ffc21c67ee1cb4c9c4ff5a16154c2eb9

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
2
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
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
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-07

케이스

HOW
목표
verify compareVersion in pkg:npm/compare-version@0.1.2
패키지
심벌
  • compareVersion
생성일
2026-08-26T11:04:17Z

컨트랙트

  1. compareVersion returns 1 when the first version string is greater than the second
  2. compareVersion returns -1 when the first version string is less than the second
  3. compareVersion returns 0 when version strings are equal
  4. compareVersion returns false when either argument is not a string

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.js

소스 아티팩트 내려받기 (tar.gz)

소스

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 compareVersion in pkg:npm/compare-version@0.1.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/compare-version@0.1.2
Demonstrate these symbols/APIs:
  - compareVersion

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:8c9184cfdbbd4ad7da5ce6b1f960e0739e7c672765aeac5ad5df67c143c494ae","contract":["compareVersion returns 1 when the first version string is greater than the second","compareVersion returns -1 when the first version string is less than the second","compareVersion returns 0 when version strings are equal","compareVersion returns false when either argument is not a string"],"goal":"verify compareVersion in pkg:npm/compare-version@0.1.2","kind":"HOW","packages":["pkg:npm/compare-version@0.1.2"],"schemaVersion":1,"symbols":["compareVersion"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/compare-version@0.1.2"],"schemaVersion":1,"subject":"pkg:npm/compare-version@0.1.2","symbols":["compareVersion"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-compare-version",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-compare-version",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "compare-version": "0.1.2"
      }
    },
    "node_modules/compare-version": {
      "version": "0.1.2",
      "resolved": "https://registry.npmjs.org/compare-version/-/compare-version-0.1.2.tgz",
      "integrity": "sha512-pJDh5/4wrEnXX/VWRZvruAGHkzKdr46z11OlTPN+VrATlWWhSKewNCJ1futCO5C7eJB3nPMFZA1LeYtcFboZ2A==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    }
  }
}
package.json
{
  "name": "sample-compare-version",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for compare-version",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "compare-version": "0.1.2"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify compareVersion in pkg:npm/compare-version@0.1.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/compare-version@0.1.2"
  ],
  "symbols": [
    "compareVersion"
  ]
}
src/index.js
const compareVersion = require('compare-version');

function checkCompareVersion(a, b) {
  return compareVersion(a, b);
}

module.exports = {
  compareVersion,
  checkCompareVersion
};
test/contract.js
const assert = require('node:assert');
const compareVersion = require('compare-version');
const { checkCompareVersion } = require('../src/index.js');

// 1. compareVersion returns 1 when the first version string is greater than the second
assert.strictEqual(compareVersion('1.11.0', '1.10.0'), 1, '1.11.0 > 1.10.0 should return 1');
assert.strictEqual(compareVersion('2.0.0', '1.9.9'), 1, '2.0.0 > 1.9.9 should return 1');
assert.strictEqual(compareVersion('1.0.1', '1.0'), 1, '1.0.1 > 1.0 should return 1');
assert.strictEqual(checkCompareVersion('1.1.0', '1.0.9'), 1, 'checkCompareVersion 1.1.0 > 1.0.9 should return 1');

// 2. compareVersion returns -1 when the first version string is less than the second
assert.strictEqual(compareVersion('1.10.0', '1.11.0'), -1, '1.10.0 < 1.11.0 should return -1');
assert.strictEqual(compareVersion('1.9.9', '2.0.0'), -1, '1.9.9 < 2.0.0 should return -1');
assert.strictEqual(compareVersion('1.0', '1.0.1'), -1, '1.0 < 1.0.1 should return -1');
assert.strictEqual(checkCompareVersion('1.0.9', '1.1.0'), -1, 'checkCompareVersion 1.0.9 < 1.1.0 should return -1');

// 3. compareVersion returns 0 when version strings are equal
assert.strictEqual(compareVersion('1.0.0', '1.0.0'), 0, '1.0.0 === 1.0.0 should return 0');
assert.strictEqual(compareVersion('0.1.2', '0.1.2'), 0, '0.1.2 === 0.1.2 should return 0');
assert.strictEqual(compareVersion('1.0.0', '1.0'), 0, '1.0.0 and 1.0 are considered equal (0)');
assert.strictEqual(checkCompareVersion('2.1.0', '2.1.0'), 0, 'checkCompareVersion 2.1.0 === 2.1.0 should return 0');

// 4. compareVersion returns false when either argument is not a string
assert.strictEqual(compareVersion(1, '1.0.0'), false, 'non-string first argument should return false');
assert.strictEqual(compareVersion('1.0.0', 1), false, 'non-string second argument should return false');
assert.strictEqual(compareVersion(null, '1.0.0'), false, 'null argument should return false');
assert.strictEqual(compareVersion('1.0.0', undefined), false, 'undefined argument should return false');
assert.strictEqual(compareVersion({}, {}), false, 'object arguments should return false');
assert.strictEqual(checkCompareVersion(null, null), false, 'checkCompareVersion non-string arguments should return false');

console.log('Contract tests passed successfully.');

오리진 시더

익명