CodeSampleX

Ejemplo

browserslist 4.28.9: readConfig

Muestra verificada para npm browserslist 4.28.9: readConfig. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.

sha256:495f8ab8e189b9647150205294f1d468042aa87bad30e7677134a45c571b5bc6

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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-05

Caso

HOW
Objetivo
verify browserslist.readConfig in pkg:npm/browserslist@4.28.9
Paquetes
Símbolos
  • browserslist.readConfig
Entorno
node 22.23.2
Creado
2026-09-05T03:59:52Z

Contrato

  1. browserslist.readConfig(file) parses defaults section from a browserslist configuration file
  2. browserslist.readConfig(file) parses named environment sections specified with bracket syntax
  3. browserslist.readConfig(file) supports multiple environments sharing the same section header
  4. browserslist.readConfig(file) strips comment lines starting with hash and ignores empty lines
  5. browserslist.readConfig(file) supports comma-separated queries on a single line
  6. browserslist.readConfig(file) throws BrowserslistError when duplicate section header is encountered
  7. browserslist.readConfig(file) throws BrowserslistError when the specified configuration file does not exist
  8. browserslist.readConfig(file) throws BrowserslistError when target path is a directory instead of a regular file

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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 browserslist.readConfig in pkg:npm/browserslist@4.28.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/browserslist@4.28.9
Demonstrate these symbols/APIs:
  - browserslist.readConfig

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:9471491ccc6ccd67d0a35d57cf2bdfd4eb302e8d0c7fdcbde41c149b5cf02b3a","contract":["browserslist.readConfig(file) parses defaults section from a browserslist configuration file","browserslist.readConfig(file) parses named environment sections specified with bracket syntax","browserslist.readConfig(file) supports multiple environments sharing the same section header","browserslist.readConfig(file) strips comment lines starting with hash and ignores empty lines","browserslist.readConfig(file) supports comma-separated queries on a single line","browserslist.readConfig(file) throws BrowserslistError when duplicate section header is encountered","browserslist.readConfig(file) throws BrowserslistError when the specified configuration file does not exist","browserslist.readConfig(file) throws BrowserslistError when target path is a directory instead of a regular file"],"goal":"verify browserslist.readConfig in pkg:npm/browserslist@4.28.9","kind":"HOW","packages":["pkg:npm/browserslist@4.28.9"],"schemaVersion":1,"symbols":["browserslist.readConfig"]},"contractCommand":["node","test/contract.mjs"],"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/browserslist@4.28.9"],"schemaVersion":1,"subject":"pkg:npm/browserslist@4.28.9","symbols":["browserslist.readConfig"],"verifierAdapter":"node-typescript@1"}
index.js
const browserslist = require('browserslist');

/**
 * Reads and parses a browserslist configuration file.
 *
 * @param {string} file - Path to configuration file.
 * @returns {Record<string, string[]>} Parsed section map with environments and query lists.
 */
function readConfig(file) {
  return browserslist.readConfig(file);
}

module.exports = {
  browserslist,
  readConfig,
};
package-lock.json
{
  "name": "sample-browserslist-read-config",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-browserslist-read-config",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "browserslist": "4.28.9"
      }
    },
    "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",
      "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",
      "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"
    },
    "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"
    },
    "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",
      "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.2",
      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz",
      "integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==",
      "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-browserslist-read-config",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room sample verifying browserslist.readConfig",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "browserslist": "4.28.9"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify browserslist.readConfig in pkg:npm/browserslist@4.28.9",
  "kind": "HOW",
  "packages": [
    "pkg:npm/browserslist@4.28.9"
  ],
  "symbols": [
    "browserslist.readConfig"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import browserslist from 'browserslist';
import { readConfig } from '../index.js';

const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'csx-bll-contract-'));

try {
  // 1. browserslist.readConfig(file) parses defaults section from a browserslist configuration file
  const f1 = path.join(tmpDir, 'c1');
  fs.writeFileSync(f1, 'last 2 versions\n> 1%\n');
  assert.deepStrictEqual(browserslist.readConfig(f1), { defaults: ['last 2 versions', '> 1%'] });
  assert.deepStrictEqual(readConfig(f1), { defaults: ['last 2 versions', '> 1%'] });

  // 2. browserslist.readConfig(file) parses named environment sections specified with bracket syntax
  const f2 = path.join(tmpDir, 'c2');
  fs.writeFileSync(f2, 'defaults\n\n[production]\n> 0.2%\nnot dead\n\n[development]\nlast 1 chrome version\n');
  const expected2 = {
    defaults: ['defaults'],
    production: ['> 0.2%', 'not dead'],
    development: ['last 1 chrome version']
  };
  assert.deepStrictEqual(browserslist.readConfig(f2), expected2);
  assert.deepStrictEqual(readConfig(f2), expected2);

  // 3. browserslist.readConfig(file) supports multiple environments sharing the same section header
  const f3 = path.join(tmpDir, 'c3');
  fs.writeFileSync(f3, '[production modern]\n> 1%\n');
  const expected3 = {
    defaults: [],
    production: ['> 1%'],
    modern: ['> 1%']
  };
  assert.deepStrictEqual(browserslist.readConfig(f3), expected3);
  assert.deepStrictEqual(readConfig(f3), expected3);

  // 4. browserslist.readConfig(file) strips comment lines starting with hash and ignores empty lines
  const f4 = path.join(tmpDir, 'c4');
  fs.writeFileSync(f4, '# Main config\nlast 2 versions # inline comment\n\n# another comment\n> 5%\n');
  const expected4 = {
    defaults: ['last 2 versions', '> 5%']
  };
  assert.deepStrictEqual(browserslist.readConfig(f4), expected4);
  assert.deepStrictEqual(readConfig(f4), expected4);

  // 5. browserslist.readConfig(file) supports comma-separated queries on a single line
  const f5 = path.join(tmpDir, 'c5');
  fs.writeFileSync(f5, 'last 1 chrome version, last 1 firefox version\n');
  const expected5 = {
    defaults: ['last 1 chrome version', 'last 1 firefox version']
  };
  assert.deepStrictEqual(browserslist.readConfig(f5), expected5);
  assert.deepStrictEqual(readConfig(f5), expected5);

  // 6. browserslist.readConfig(file) throws BrowserslistError when duplicate section header is encountered
  const f6 = path.join(tmpDir, 'c6');
  fs.writeFileSync(f6, '[production]\n> 1%\n\n[production]\n> 2%\n');
  assert.throws(
    () => browserslist.readConfig(f6),
    (err) => err.name === 'BrowserslistError' && err.message.includes('Duplicate section production in Browserslist config')
  );
  assert.throws(
    () => readConfig(f6),
    (err) => err.name === 'BrowserslistError' && err.message.includes('Duplicate section production in Browserslist config')
  );

  // 7. browserslist.readConfig(file) throws BrowserslistError when the specified configuration file does not exist
  const f7 = path.join(tmpDir, 'non-existent-config');
  assert.throws(
    () => browserslist.readConfig(f7),
    (err) => err.name === 'BrowserslistError' && err.message === `Can't read ${f7} config`
  );
  assert.throws(
    () => readConfig(f7),
    (err) => err.name === 'BrowserslistError' && err.message === `Can't read ${f7} config`
  );

  // 8. browserslist.readConfig(file) throws BrowserslistError when target path is a directory instead of a regular file
  const f8 = path.join(tmpDir, 'dir-target');
  fs.mkdirSync(f8);
  assert.throws(
    () => browserslist.readConfig(f8),
    (err) => err.name === 'BrowserslistError' && err.message === `Can't read ${f8} config`
  );
  assert.throws(
    () => readConfig(f8),
    (err) => err.name === 'BrowserslistError' && err.message === `Can't read ${f8} config`
  );

  console.log('Contract passed successfully.');
} finally {
  fs.rmSync(tmpDir, { recursive: true, force: true });
}

Seeder de origen

anónimo