CodeSampleX

샘플

update-browserslist-db 1.3.0

검증된 샘플 — npm update-browserslist-db 1.3.0. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: update-browserslist-db exports a callable update…

sha256:66fa5dfcae315c25f20270d693991f9cb9c6848fd24275f19c8f5be3c250fa97

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

케이스

HOW
목표
verify pkg:npm/update-browserslist-db@1.3.0
패키지
환경
node 22.23.2
생성일
2026-08-26T07:56:41Z

컨트랙트

  1. update-browserslist-db exports a callable update function that accepts a custom print handler
  2. update-browserslist-db detectLockfile throws BrowserslistUpdateError with browserslist flag when executed outside a project directory
  3. update-browserslist-db detectLockfile throws BrowserslistUpdateError when package.json exists without any supported lockfile

파일

  • 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 pkg:npm/update-browserslist-db@1.3.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/update-browserslist-db@1.3.0

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:d7f640bd248349489de5b0e77c557c2c8526d611d8e9f9185a19cbd55cbb9b69","constraints":{"executionContext":"node"},"contract":["update-browserslist-db exports a callable update function that accepts a custom print handler","update-browserslist-db detectLockfile throws BrowserslistUpdateError with browserslist flag when executed outside a project directory","update-browserslist-db detectLockfile throws BrowserslistUpdateError when package.json exists without any supported lockfile"],"goal":"verify pkg:npm/update-browserslist-db@1.3.0","kind":"HOW","packages":["pkg:npm/update-browserslist-db@1.3.0"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/update-browserslist-db@1.3.0"],"schemaVersion":1,"subject":"pkg:npm/update-browserslist-db@1.3.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "update-browserslist-db-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "update-browserslist-db-sample",
      "version": "1.0.0",
      "dependencies": {
        "update-browserslist-db": "1.3.0"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.19",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.19.tgz",
      "integrity": "sha512-Grytf1xOxOEMTGRwx6rLGKkTabd4vMg3VrKdj/7joCmV0qgh4QwMMO6xh34YEXQqirAuUdgQGa5orJQQ+69RBw==",
      "license": "Apache-2.0",
      "peer": true,
      "bin": {
        "baseline-browser-mapping": "dist/cli.cjs"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    },
    "node_modules/browserslist": {
      "version": "4.28.8",
      "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz",
      "integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/browserslist"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "peer": true,
      "dependencies": {
        "baseline-browser-mapping": "^2.11.12",
        "caniuse-lite": "^1.0.30001809",
        "electron-to-chromium": "^1.5.402",
        "node-releases": "^2.0.53",
        "update-browserslist-db": "^1.3.0"
      },
      "bin": {
        "browserslist": "cli.js"
      },
      "engines": {
        "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
      }
    },
    "node_modules/caniuse-lite": {
      "version": "1.0.30001810",
      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz",
      "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "CC-BY-4.0",
      "peer": true
    },
    "node_modules/electron-to-chromium": {
      "version": "1.5.415",
      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.415.tgz",
      "integrity": "sha512-958V+Kbhtgz+SxXeEVKBjrlKRBIDAYvUJfwhjxMZ5S6ut9jAl7l9ZKBkBrvjyjZE36PabLUo2L8kEeV5O4vgJg==",
      "license": "ISC",
      "peer": true
    },
    "node_modules/escalade": {
      "version": "3.2.0",
      "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
      "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
      "license": "MIT",
      "engines": {
        "node": ">=6"
      }
    },
    "node_modules/node-releases": {
      "version": "2.0.53",
      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.53.tgz",
      "integrity": "sha512-D9UOmYG3UH1V+ENW56t5QXBwJw1YEY18ruVeus89Rw+SyIgjPkCO84bRzO3uNIYosJbNwiabWVn48o3uJLjxFQ==",
      "license": "MIT",
      "peer": true,
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/picocolors": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
      "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
      "license": "ISC"
    },
    "node_modules/update-browserslist-db": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.0.tgz",
      "integrity": "sha512-x/M6q3w4Ybp91CNaS4S69UnliqR3BzRpOT6LWbksjth0S/+jhfaPJsWjt/TewpT8j9eLIojUf5jr29WextHroA==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/browserslist"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "escalade": "^3.2.0",
        "picocolors": "^1.1.1"
      },
      "bin": {
        "update-browserslist-db": "cli.js"
      },
      "peerDependencies": {
        "browserslist": ">= 4.21.0"
      }
    }
  }
}
package.json
{
  "name": "update-browserslist-db-sample",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "update-browserslist-db": "1.3.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/update-browserslist-db@1.3.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/update-browserslist-db@1.3.0"
  ]
}
src/index.js
const updateDb = require('update-browserslist-db');

/**
 * Runs the browserslist DB update procedure with an optional print handler.
 *
 * @param {Function} [printFn] - Custom print handler receiving log strings.
 */
function runUpdateDb(printFn) {
  if (printFn) {
    updateDb(printFn);
  } else {
    updateDb();
  }
}

/**
 * Validates if an error is a BrowserslistUpdateError.
 *
 * @param {Error|*} err - The error object to check.
 * @returns {boolean} True if the error is from Browserslist update routines.
 */
function isBrowserslistUpdateError(err) {
  return Boolean(
    err &&
    typeof err === 'object' &&
    err.name === 'BrowserslistUpdateError' &&
    err.browserslist === true
  );
}

module.exports = {
  updateDb,
  runUpdateDb,
  isBrowserslistUpdateError,
};
test/contract.js
const assert = require('node:assert/strict');
const os = require('node:os');
const fs = require('node:fs');
const path = require('node:path');
const {
  updateDb,
  runUpdateDb,
  isBrowserslistUpdateError,
} = require('../src/index.js');

// Contract 1: update-browserslist-db exports a callable update function that accepts a custom print handler
{
  assert.strictEqual(typeof updateDb, 'function', 'updateDb should be an exported function');
  assert.strictEqual(typeof runUpdateDb, 'function', 'runUpdateDb should be a helper function');
}

// Contract 2: update-browserslist-db detectLockfile throws BrowserslistUpdateError with browserslist flag when executed outside a project directory
{
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'contract-empty-'));
  const prevCwd = process.cwd();
  try {
    process.chdir(tempDir);
    let logs = [];
    const customPrint = (msg) => logs.push(msg);

    assert.throws(
      () => {
        runUpdateDb(customPrint);
      },
      (err) => {
        assert.ok(isBrowserslistUpdateError(err), 'Should be BrowserslistUpdateError');
        assert.strictEqual(err.name, 'BrowserslistUpdateError');
        assert.strictEqual(err.browserslist, true);
        assert.ok(err.message.includes('Cannot find package.json'), 'Message should indicate missing package.json');
        return true;
      }
    );
  } finally {
    process.chdir(prevCwd);
    fs.rmSync(tempDir, { recursive: true, force: true });
  }
}

// Contract 3: update-browserslist-db detectLockfile throws BrowserslistUpdateError when package.json exists without any supported lockfile
{
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'contract-nolock-'));
  const prevCwd = process.cwd();
  try {
    fs.writeFileSync(path.join(tempDir, 'package.json'), '{}');
    process.chdir(tempDir);
    let logs = [];
    const customPrint = (msg) => logs.push(msg);

    assert.throws(
      () => {
        runUpdateDb(customPrint);
      },
      (err) => {
        assert.ok(isBrowserslistUpdateError(err), 'Should be BrowserslistUpdateError');
        assert.strictEqual(err.name, 'BrowserslistUpdateError');
        assert.strictEqual(err.browserslist, true);
        assert.ok(err.message.includes('No lockfile found'), 'Message should indicate missing lockfile');
        return true;
      }
    );
  } finally {
    process.chdir(prevCwd);
    fs.rmSync(tempDir, { recursive: true, force: true });
  }
}

console.log('All pkg:npm/update-browserslist-db@1.3.0 contracts passed successfully.');

오리진 시더

익명