CodeSampleX

サンプル

update-browserslist-db 1.3.3

検証済みサンプル — npm update-browserslist-db 1.3.3. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: update-browserslist-db exports a callable update…

sha256:8e01c368c8f40d505a095b417a4e623eff1d183d80104f35d2ed8458ddcf688d

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。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 debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-17

ケース

HOW
ゴール
verify pkg:npm/update-browserslist-db@1.3.3
パッケージ
環境
node 22.23.2
作成日
2026-09-17T12:40:55Z

コントラクト

  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.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/update-browserslist-db@1.3.3
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.
csx.json
{"case":{"caseId":"case:sha256:570f49bdb7a56ea8e90bcde106b6506c730b65965b3211619f828928b6ce496f","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.3","kind":"HOW","packages":["pkg:npm/update-browserslist-db@1.3.3"],"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.3"],"schemaVersion":1,"subject":"pkg:npm/update-browserslist-db@1.3.3","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.3"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.24",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.24.tgz",
      "integrity": "sha512-hYrgxie335U08WqICoGqKRzV1HFXv6zdxwJE4ekCb80CM9a0SVVsN4QPwT67RraRo+9h8IATk6uxHJw7QSkdOg==",
      "license": "Apache-2.0",
      "peer": true,
      "bin": {
        "baseline-browser-mapping": "dist/cli.cjs"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    },
    "node_modules/browserslist": {
      "version": "4.29.0",
      "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.0.tgz",
      "integrity": "sha512-3GSvyjvDI4Dur1Meg2BekJquu5uF+9R9a1+5M1Mde192eZoXbeXjzgOsgqPS2V8D5wrrip0gR5Hf/GhWQ9ZzaA==",
      "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.23",
        "caniuse-lite": "^1.0.30001810",
        "electron-to-chromium": "^1.5.427",
        "node-releases": "^2.0.55",
        "update-browserslist-db": "^1.3.3"
      },
      "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.430",
      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.430.tgz",
      "integrity": "sha512-e1QEj72Y4zd8RlNZVmoTg+iCOSVwpk05IOiiQwdrkwCSVlZfPthevErhE+nckGd2YbsXfp1SkisznhGVIXP2NQ==",
      "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.56",
      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.56.tgz",
      "integrity": "sha512-x0InOIyzgdk+eyaWaRJFH5snEtiImgBgblZ2CyPrLmqqcuMQkEvcDPHbzqbD8eDsSeJbVOjn+crzyzHaM4D+/A==",
      "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.3",
      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz",
      "integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==",
      "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",
  "dependencies": {
    "update-browserslist-db": "1.3.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/update-browserslist-db@1.3.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/update-browserslist-db@1.3.3"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const updateDb = require("update-browserslist-db");

/**
 * Runs the update-browserslist-db routine with an optional print handler.
 *
 * @param {Function} [printFn] - Custom print callback.
 */
function runUpdateDb(printFn) {
  if (typeof printFn === "function") {
    updateDb(printFn);
  } else {
    updateDb();
  }
}

/**
 * Checks if the given error is a BrowserslistUpdateError.
 *
 * @param {Error|unknown} err - The error to check.
 * @returns {boolean} True if the error is a BrowserslistUpdateError.
 */
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 fs = require("node:fs");
const os = require("node:os");
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 originalCwd = process.cwd();
  try {
    process.chdir(tempDir);
    let printed = [];
    const printHandler = (msg) => { printed.push(msg); };

    assert.throws(
      () => {
        runUpdateDb(printHandler);
      },
      (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"),
          "Error message should indicate missing package.json"
        );
        return true;
      }
    );
  } finally {
    process.chdir(originalCwd);
    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 originalCwd = process.cwd();
  try {
    fs.writeFileSync(path.join(tempDir, "package.json"), "{}");
    process.chdir(tempDir);
    let printed = [];
    const printHandler = (msg) => { printed.push(msg); };

    assert.throws(
      () => {
        runUpdateDb(printHandler);
      },
      (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"),
          "Error message should indicate missing lockfile"
        );
        return true;
      }
    );
  } finally {
    process.chdir(originalCwd);
    fs.rmSync(tempDir, { recursive: true, force: true });
  }
}

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

オリジンシーダー

匿名