CodeSampleX

Exemple

update-browserslist-db 1.3.4

Échantillon vérifié pour npm update-browserslist-db 1.3.4. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.

sha256:874d7ec1261c1f7626467945d15baaaa055c272cb30171a584a0d3b54e105185

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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-11-07

Cas

HOW
Objectif
verify pkg:npm/update-browserslist-db@1.3.4
Paquets
Environnement
node 22.23.2
Créé
2026-11-07T08:37:26Z

Contrat

  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

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code source

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

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

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:c2f454f1ce35661f8eca133cbefcd788beb8be6d594c7e456d6a3c5811662b84","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.4","kind":"HOW","packages":["pkg:npm/update-browserslist-db@1.3.4"],"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.4"],"schemaVersion":1,"subject":"pkg:npm/update-browserslist-db@1.3.4","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "verify-update-browserslist-db",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "verify-update-browserslist-db",
      "version": "1.0.0",
      "dependencies": {
        "update-browserslist-db": "1.3.4"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.35",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.35.tgz",
      "integrity": "sha512-GNk8KX52CHqeNKGk8+7tZnQab/2k1t/BgrUHPKNdijzpEhF1saPQZHVKb6m5loSAxB39gyrTYw34Qf9CQ3u1qQ==",
      "license": "Apache-2.0",
      "peer": true,
      "bin": {
        "baseline-browser-mapping": "dist/cli.cjs"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    },
    "node_modules/browserslist": {
      "version": "4.29.5",
      "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.5.tgz",
      "integrity": "sha512-khTmKu5NGYTotqcYo8Bew2k4RAE9PuXRSFRXG2lQBrCEQHyeQ/vX6gKMxfokwywBsLiXZMnHsmWMG1pnO8J7uQ==",
      "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.33",
        "caniuse-lite": "^1.0.30001819",
        "electron-to-chromium": "^1.5.464",
        "node-releases": "^2.0.60",
        "update-browserslist-db": "^1.3.4"
      },
      "bin": {
        "browserslist": "cli.js"
      },
      "engines": {
        "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
      }
    },
    "node_modules/caniuse-lite": {
      "version": "1.0.30001823",
      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001823.tgz",
      "integrity": "sha512-TQ5s/djDjNk1axreUW+4rULH+BmdCMLiJkhaXnO5wqivG7tITkSUj4ItIdzqdZHKaXcHAV8dhH3JxOM7/7bwqw==",
      "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.478",
      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.478.tgz",
      "integrity": "sha512-pftG+ma5Lm8O6/p45bhYT6StBN5ziQymaRzmCZwFl8DwWHKPPD93FdOmP1aqftcepolQYvrcyTLa17kE8Yf+jg==",
      "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.63",
      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.63.tgz",
      "integrity": "sha512-6li2QanLsAXpIH2R6j77MzRyvOyrvdTqlKtO4CgBdHGNvN99ZZfyxszHc5o5+IZBWD5u6Hzwg83JoGXmqZNG9Q==",
      "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.4",
      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.4.tgz",
      "integrity": "sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A==",
      "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": "verify-update-browserslist-db",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "update-browserslist-db": "1.3.4"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/update-browserslist-db@1.3.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/update-browserslist-db@1.3.4"
  ]
}
src/index.js
const updateDb = require("update-browserslist-db");

function invokeUpdateDb(printFn) {
  if (typeof printFn === "function") {
    updateDb(printFn);
  } else {
    updateDb();
  }
}

function isBrowserslistUpdateError(err) {
  return Boolean(
    err &&
      typeof err === "object" &&
      err.name === "BrowserslistUpdateError" &&
      err.browserslist === true
  );
}

module.exports = {
  updateDb,
  invokeUpdateDb,
  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,
  invokeUpdateDb,
  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");
  assert.strictEqual(typeof invokeUpdateDb, "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(), "ubdb-empty-"));
  const prevCwd = process.cwd();
  try {
    process.chdir(tempDir);
    const logs = [];
    assert.throws(
      () => {
        invokeUpdateDb((msg) => logs.push(msg));
      },
      (err) => {
        assert.ok(isBrowserslistUpdateError(err));
        assert.strictEqual(err.name, "BrowserslistUpdateError");
        assert.strictEqual(err.browserslist, true);
        assert.ok(err.message.includes("Cannot find 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(), "ubdb-nolock-"));
  const prevCwd = process.cwd();
  try {
    fs.writeFileSync(path.join(tempDir, "package.json"), "{}");
    process.chdir(tempDir);
    const logs = [];
    assert.throws(
      () => {
        invokeUpdateDb((msg) => logs.push(msg));
      },
      (err) => {
        assert.ok(isBrowserslistUpdateError(err));
        assert.strictEqual(err.name, "BrowserslistUpdateError");
        assert.strictEqual(err.browserslist, true);
        assert.ok(err.message.includes("No lockfile found"));
        return true;
      }
    );
  } finally {
    process.chdir(prevCwd);
    fs.rmSync(tempDir, { recursive: true, force: true });
  }
}

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

Seeder d'origine

anonyme