CodeSampleX

Exemplo

update-browserslist-db 1.2.3: update-browserslist-db

Amostra verificada para npm update-browserslist-db 1.2.3: update-browserslist-db. O contrato rodou em node 22 · linux debian/x64 · docker e passou.

sha256:dfe68576153c1a7e6a026b43c3b863e5a4e2f5ee474a51a39eb5cb2f192be91d

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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

Caso

HOW
Objetivo
verify update-browserslist-db in pkg:npm/update-browserslist-db@1.2.3
Pacotes
Símbolos
  • update-browserslist-db
Criado
2026-09-07T00:44:20Z

Contrato

  1. assert update-browserslist-db exports a callable update function
  2. assert update-browserslist-db throws BrowserslistUpdateError when package.json is missing
  3. assert update-browserslist-db throws BrowserslistUpdateError when lockfile is missing

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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

Use EXACTLY these public packages and versions:
  - pkg:npm/update-browserslist-db@1.2.3
Demonstrate these symbols/APIs:
  - update-browserslist-db

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:d1bba95ca8c17e0b7baf16dca1dc9ed74ee309650729ad7b41311280a5a5dde4","contract":["assert update-browserslist-db exports a callable update function","assert update-browserslist-db throws BrowserslistUpdateError when package.json is missing","assert update-browserslist-db throws BrowserslistUpdateError when lockfile is missing"],"goal":"verify update-browserslist-db in pkg:npm/update-browserslist-db@1.2.3","kind":"HOW","packages":["pkg:npm/update-browserslist-db@1.2.3"],"schemaVersion":1,"symbols":["update-browserslist-db"]},"contractCommand":["node","test/contract.mjs"],"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/update-browserslist-db@1.2.3"],"schemaVersion":1,"subject":"pkg:npm/update-browserslist-db@1.2.3","symbols":["update-browserslist-db"],"verifierAdapter":"node-typescript@1"}
index.js
const updateDb = require('update-browserslist-db');

/**
 * Invokes updateDb with an optional custom print function.
 *
 * @param {(str: string) => void} [print] - Custom print callback.
 */
function runUpdateDb(print) {
  return updateDb(print);
}

module.exports = {
  updateDb,
  runUpdateDb,
};
package-lock.json
{
  "name": "sample-update-browserslist-db",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-update-browserslist-db",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "update-browserslist-db": "1.2.3"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.21",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.21.tgz",
      "integrity": "sha512-uh8vpY/1/YyFkunIDFH/12p7/7VdPKA1hejMVEbdkEaWnUz0Hesvx5EbiU6XxjyHZIOju+ZMbQJkRh+es3/spQ==",
      "license": "Apache-2.0",
      "peer": true,
      "bin": {
        "baseline-browser-mapping": "dist/cli.cjs"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    },
    "node_modules/browserslist": {
      "version": "4.28.9",
      "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.9.tgz",
      "integrity": "sha512-EWazOblFYUvlGZcfGhPUPmYh3nikUxBVb+y9MJun5f3hBi812X+8MSQTujLBtgK3cf51fJWbWfOjyeO954d+Eg==",
      "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.20",
        "caniuse-lite": "^1.0.30001810",
        "electron-to-chromium": "^1.5.420",
        "node-releases": "^2.0.54",
        "update-browserslist-db": "^1.3.2"
      },
      "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.422",
      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.422.tgz",
      "integrity": "sha512-UvA/32XqrLDdZSn7Jllo1AYNcWji/G0d5M0GTViE7KoGBiMunw3a34Sb2KO4ZZyrSEhqsxFoVhWWJshdyfKqJA==",
      "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.54",
      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz",
      "integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==",
      "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.2.3",
      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz",
      "integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==",
      "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": "sample-update-browserslist-db",
  "version": "1.0.0",
  "description": "Clean-room sample verifying pkg:npm/update-browserslist-db@1.2.3 functionality",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "update-browserslist-db": "1.2.3"
  },
  "overrides": {
    "update-browserslist-db": "1.2.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify update-browserslist-db in pkg:npm/update-browserslist-db@1.2.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/update-browserslist-db@1.2.3"
  ],
  "symbols": [
    "update-browserslist-db"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import updateDb from 'update-browserslist-db';
import { runUpdateDb } from '../index.js';

// 1. Symbol verification: update-browserslist-db exports a function
assert.strictEqual(
  typeof updateDb,
  'function',
  'assert update-browserslist-db exports a callable update function'
);
assert.strictEqual(
  typeof runUpdateDb,
  'function',
  'assert runUpdateDb wrapper is a function'
);

// 2. Behavior when package.json is missing
const tempDirWithoutPackageJson = fs.mkdtempSync(
  path.join(os.tmpdir(), 'csx-test-nopkg-')
);
const originalCwd = process.cwd();

try {
  process.chdir(tempDirWithoutPackageJson);
  assert.throws(
    () => {
      updateDb(() => {});
    },
    (err) => {
      assert.strictEqual(err.name, 'BrowserslistUpdateError');
      assert.strictEqual(err.browserslist, true);
      assert.ok(err instanceof Error);
      return err.message.includes('Cannot find package.json');
    },
    'assert update-browserslist-db throws BrowserslistUpdateError when package.json is missing'
  );
} finally {
  process.chdir(originalCwd);
  fs.rmSync(tempDirWithoutPackageJson, { recursive: true, force: true });
}

// 3. Behavior when lockfile is missing
const tempDirWithoutLockfile = fs.mkdtempSync(
  path.join(os.tmpdir(), 'csx-test-nolock-')
);

try {
  fs.writeFileSync(
    path.join(tempDirWithoutLockfile, 'package.json'),
    JSON.stringify({ name: 'isolated-test-fixture' })
  );
  process.chdir(tempDirWithoutLockfile);
  assert.throws(
    () => {
      runUpdateDb(() => {});
    },
    (err) => {
      assert.strictEqual(err.name, 'BrowserslistUpdateError');
      assert.strictEqual(err.browserslist, true);
      assert.ok(err instanceof Error);
      return err.message.includes('No lockfile found');
    },
    'assert update-browserslist-db throws BrowserslistUpdateError when lockfile is missing'
  );
} finally {
  process.chdir(originalCwd);
  fs.rmSync(tempDirWithoutLockfile, { recursive: true, force: true });
}

console.log('All contract assertions passed.');

Seeder de origem

anônimo