CodeSampleX

Beispiel

picomatch 2.3.2

Verifiziertes Beispiel für npm picomatch 2.3.2. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: picomatch creates compiled matcher…

sha256:25d40cbbc2f3e20cbc753bb393104c57f0b7f2178c74ab89c044c78fb20d7aed

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-19

Fall

HOW
Ziel
verify pkg:npm/picomatch@2.3.2
Pakete
Umgebung
node 22.23.2
Erstellt
2026-08-19T19:02:46Z

Contract

  1. picomatch creates compiled matcher functions supporting wildcards, brace expansions, and negated patterns
  2. picomatch.isMatch evaluates paths against glob patterns with support for case-insensitivity, dotfiles, and ignore rules
  3. picomatch.scan parses glob patterns into components including static base directory, glob portion, and isGlob metadata
  4. picomatch.makeRe compiles glob patterns into RegExp instances for regular expression matching

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/picomatch@2.3.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/picomatch@2.3.2
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:4c8d305f92c97cfc254d87f30ab3ec866843a00e18d6b707d97faac9407398f1","constraints":{"executionContext":"node"},"contract":["picomatch creates compiled matcher functions supporting wildcards, brace expansions, and negated patterns","picomatch.isMatch evaluates paths against glob patterns with support for case-insensitivity, dotfiles, and ignore rules","picomatch.scan parses glob patterns into components including static base directory, glob portion, and isGlob metadata","picomatch.makeRe compiles glob patterns into RegExp instances for regular expression matching"],"goal":"verify pkg:npm/picomatch@2.3.2","kind":"HOW","packages":["pkg:npm/picomatch@2.3.2"],"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/picomatch@2.3.2"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "picomatch-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "picomatch-sample",
      "version": "1.0.0",
      "dependencies": {
        "picomatch": "2.3.2"
      }
    },
    "node_modules/picomatch": {
      "version": "2.3.2",
      "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
      "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
      "license": "MIT",
      "engines": {
        "node": ">=8.6"
      },
      "funding": {
        "url": "https://github.com/sponsors/jonschlinkert"
      }
    }
  }
}
package.json
{
  "name": "picomatch-sample",
  "version": "1.0.0",
  "dependencies": {
    "picomatch": "2.3.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/picomatch@2.3.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/picomatch@2.3.2"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const picomatch = require('picomatch');

/**
 * Creates a compiled matcher function for one or more glob patterns.
 *
 * @param {string|string[]} patterns - Glob pattern or array of patterns.
 * @param {object} [options] - Picomatch options.
 * @returns {(input: string) => boolean} Matcher function.
 */
function createMatcher(patterns, options) {
  return picomatch(patterns, options);
}

/**
 * Tests whether a path string matches a glob pattern.
 *
 * @param {string} input - Path string to test.
 * @param {string|string[]} patterns - Glob pattern or patterns.
 * @param {object} [options] - Options such as ignore, nocase, dot.
 * @returns {boolean} True if matched.
 */
function matchPath(input, patterns, options) {
  return picomatch.isMatch(input, patterns, options);
}

/**
 * Scans a glob pattern string to extract static base path, glob component, and metadata.
 *
 * @param {string} pattern - Glob pattern to analyze.
 * @param {object} [options] - Scan options.
 * @returns {object} Scan result object.
 */
function scanPattern(pattern, options) {
  return picomatch.scan(pattern, options);
}

/**
 * Compiles a glob pattern into a regular expression.
 *
 * @param {string} pattern - Glob pattern.
 * @param {object} [options] - Regex options.
 * @returns {RegExp} Compiled RegExp.
 */
function compilePattern(pattern, options) {
  return picomatch.makeRe(pattern, options);
}

module.exports = {
  createMatcher,
  matchPath,
  scanPattern,
  compilePattern,
  picomatch,
};
test/contract.js
const assert = require('node:assert/strict');
const {
  createMatcher,
  matchPath,
  scanPattern,
  compilePattern,
} = require('../src/index.js');

// Contract 1: picomatch creates compiled matcher functions supporting wildcards, brace expansions, and negated patterns
{
  const isImage = createMatcher('*.{png,jpg,webp}');
  assert.strictEqual(isImage('photo.jpg'), true, 'Should match jpg via brace expansion');
  assert.strictEqual(isImage('banner.webp'), true, 'Should match webp via brace expansion');
  assert.strictEqual(isImage('vector.svg'), false, 'Should not match non-listed extension');

  const isSource = createMatcher(['src/**/*.js', 'src/**/*.ts']);
  assert.strictEqual(isSource('src/index.js'), true, 'Should match js file in src');
  assert.strictEqual(isSource('src/components/App.ts'), true, 'Should match ts file in nested src');
  assert.strictEqual(isSource('docs/readme.md'), false, 'Should not match md file outside src');

  const notTest = createMatcher('!**/*.test.js');
  assert.strictEqual(notTest('src/index.js'), true, 'Negated pattern matches non-test file');
  assert.strictEqual(notTest('src/index.test.js'), false, 'Negated pattern rejects test file');
}

// Contract 2: picomatch.isMatch evaluates paths against glob patterns with support for case-insensitivity, dotfiles, and ignore rules
{
  assert.strictEqual(matchPath('lib/utils.js', 'lib/*.js'), true, 'Direct match in lib directory');
  assert.strictEqual(matchPath('lib/sub/utils.js', 'lib/*.js'), false, 'Single star should not cross directory boundaries');

  assert.strictEqual(matchPath('README.MD', '*.md', { nocase: true }), true, 'nocase: true allows case-insensitive match');
  assert.strictEqual(matchPath('README.MD', '*.md', { nocase: false }), false, 'nocase: false enforces case sensitivity');

  assert.strictEqual(matchPath('.env', '*.env', { dot: true }), true, 'dot: true matches dotfiles');
  assert.strictEqual(matchPath('.env', '*.env', { dot: false }), false, 'dot: false ignores dotfiles by default');

  assert.strictEqual(
    matchPath('node_modules/pkg/index.js', '**/*.js', { ignore: '**/node_modules/**' }),
    false,
    'ignore option excludes matching paths'
  );
}

// Contract 3: picomatch.scan parses glob patterns into components including static base directory, glob portion, and isGlob metadata
{
  const scanned = scanPattern('src/assets/**/*.svg');
  assert.strictEqual(scanned.base, 'src/assets', 'Base directory before any glob characters');
  assert.strictEqual(scanned.glob, '**/*.svg', 'Glob portion extracted');
  assert.strictEqual(scanned.isGlob, true, 'isGlob should be true for wildcard pattern');

  const staticScan = scanPattern('src/config/settings.json');
  assert.strictEqual(staticScan.base, 'src/config/settings.json', 'Static path base equals full input');
  assert.strictEqual(staticScan.glob, '', 'Static path has empty glob portion');
  assert.strictEqual(staticScan.isGlob, false, 'isGlob should be false for static path');
}

// Contract 4: picomatch.makeRe compiles glob patterns into RegExp instances for regular expression matching
{
  const re = compilePattern('build/*.min.js');
  assert.ok(re instanceof RegExp, 'Should return a RegExp instance');
  assert.strictEqual(re.test('build/app.min.js'), true, 'Compiled regex matches expected target');
  assert.strictEqual(re.test('build/app.js'), false, 'Compiled regex rejects unmatched target');
  assert.strictEqual(re.test('dist/app.min.js'), false, 'Compiled regex respects directory prefix');
}

console.log('All pkg:npm/picomatch@2.3.2 contracts passed successfully.');

Ursprungs-Seeder

anonym