CodeSampleX

Beispiel

minimatch 10.2.6

Verifiziertes Beispiel für npm minimatch 10.2.6. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: matchPaths filters an array of file…

sha256:5c7faa03759ca818b307887d9bdf363606ed55c56db750b4d5c44a30c5fd61c9

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:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-21

Fall

HOW
Ziel
verify pkg:npm/minimatch@10.2.6
Pakete
Umgebung
node 22.23.2
Erstellt
2026-08-21T03:50:18Z

Contract

  1. matchPaths filters an array of file paths against glob patterns returning matching paths
  2. matchBase option enables matching slashless glob patterns against filename basenames across directory structures
  3. dotfiles are excluded from wildcard pattern matching by default and included when dot option is enabled
  4. nocase option enables case-insensitive glob matching across path segments and extensions
  5. makePatternRegex compiles glob expressions into valid RegExp objects preserving flags such as nocase
  6. escapePattern escapes special glob characters so they are treated as literal characters
  7. createMatcher produces Minimatch class instances providing hasMagic and match verification methods

Dateien

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

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/minimatch@10.2.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/minimatch@10.2.6
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:d95e8923f94cb5c596d44867c38e67a9cc5d014b62e56805d3b1874a42f91472","constraints":{"executionContext":"node"},"contract":["matchPaths filters an array of file paths against glob patterns returning matching paths","matchBase option enables matching slashless glob patterns against filename basenames across directory structures","dotfiles are excluded from wildcard pattern matching by default and included when dot option is enabled","nocase option enables case-insensitive glob matching across path segments and extensions","makePatternRegex compiles glob expressions into valid RegExp objects preserving flags such as nocase","escapePattern escapes special glob characters so they are treated as literal characters","createMatcher produces Minimatch class instances providing hasMagic and match verification methods"],"goal":"verify pkg:npm/minimatch@10.2.6","kind":"HOW","packages":["pkg:npm/minimatch@10.2.6"],"schemaVersion":1},"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/minimatch@10.2.6"],"schemaVersion":1,"subject":"pkg:npm/minimatch@10.2.6","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-minimatch",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-minimatch",
      "version": "1.0.0",
      "dependencies": {
        "minimatch": "10.2.6"
      }
    },
    "node_modules/balanced-match": {
      "version": "4.0.4",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
      "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
      "license": "MIT",
      "engines": {
        "node": "18 || 20 || >=22"
      }
    },
    "node_modules/brace-expansion": {
      "version": "5.0.9",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
      "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^4.0.2"
      },
      "engines": {
        "node": "20 || >=22"
      }
    },
    "node_modules/minimatch": {
      "version": "10.2.6",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
      "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
      "license": "BlueOak-1.0.0",
      "dependencies": {
        "brace-expansion": "^5.0.8"
      },
      "engines": {
        "node": "18 || 20 || >=22"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    }
  }
}
package.json
{
  "name": "sample-minimatch",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of minimatch",
  "main": "src/index.js",
  "dependencies": {
    "minimatch": "10.2.6"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/minimatch@10.2.6",
  "kind": "HOW",
  "packages": [
    "pkg:npm/minimatch@10.2.6"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const { minimatch, Minimatch, match, makeRe, escape } = require('minimatch');

/**
 * Filter an array of file paths against a glob pattern.
 * @param {string[]} list - Array of path strings to filter
 * @param {string} pattern - Glob pattern
 * @param {object} [options] - Minimatch options
 * @returns {string[]} Filtered array of matching paths
 */
function matchPaths(list, pattern, options) {
  return match(list, pattern, options);
}

/**
 * Compile a glob pattern into a regular expression.
 * @param {string} pattern - Glob pattern
 * @param {object} [options] - Minimatch options
 * @returns {RegExp|false} Compiled RegExp or false if invalid
 */
function makePatternRegex(pattern, options) {
  return makeRe(pattern, options);
}

/**
 * Escape special glob characters in a pattern.
 * @param {string} pattern - Glob pattern to escape
 * @param {object} [options] - Minimatch options
 * @returns {string} Escaped pattern string
 */
function escapePattern(pattern, options) {
  return escape(pattern, options);
}

/**
 * Create a Minimatch instance for reusable pattern matching.
 * @param {string} pattern - Glob pattern
 * @param {object} [options] - Minimatch options
 * @returns {Minimatch} Minimatch instance
 */
function createMatcher(pattern, options) {
  return new Minimatch(pattern, options);
}

module.exports = {
  minimatch,
  Minimatch,
  match,
  makeRe,
  escape,
  matchPaths,
  makePatternRegex,
  escapePattern,
  createMatcher
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  minimatch,
  Minimatch,
  match,
  makeRe,
  escape,
  matchPaths,
  makePatternRegex,
  escapePattern,
  createMatcher
} = require('../src/index.js');

// 1. Export verification
assert.strictEqual(typeof minimatch, 'function', 'minimatch should be exported as a function');
assert.strictEqual(typeof Minimatch, 'function', 'Minimatch class should be exported');
assert.strictEqual(typeof match, 'function', 'match should be a function');
assert.strictEqual(typeof makeRe, 'function', 'makeRe should be a function');
assert.strictEqual(typeof escape, 'function', 'escape should be a function');
assert.strictEqual(typeof matchPaths, 'function', 'matchPaths should be a function');
assert.strictEqual(typeof makePatternRegex, 'function', 'makePatternRegex should be a function');
assert.strictEqual(typeof escapePattern, 'function', 'escapePattern should be a function');
assert.strictEqual(typeof createMatcher, 'function', 'createMatcher should be a function');

const sampleFiles = [
  'src/index.js',
  'src/utils.ts',
  'test/contract.mjs',
  'docs/guide.md',
  '.env',
  '.eslintrc.json',
  'dist/app.JS'
];

// 2. matchPaths filters array of paths against glob pattern
const jsMatches = matchPaths(sampleFiles, '**/*.js');
assert.deepStrictEqual(jsMatches, ['src/index.js']);

const allCodeMatches = matchPaths(sampleFiles, '**/*.{js,ts,mjs}');
assert.deepStrictEqual(allCodeMatches, ['src/index.js', 'src/utils.ts', 'test/contract.mjs']);

// 3. matchBase option matches slash-less patterns against file basenames across directories
const baseMatches = matchPaths(sampleFiles, '*.js', { matchBase: true });
assert.deepStrictEqual(baseMatches, ['src/index.js']);

const tsBaseMatches = matchPaths(sampleFiles, '*.ts', { matchBase: true });
assert.deepStrictEqual(tsBaseMatches, ['src/utils.ts']);

// 4. dot option includes dotfiles in wildcard matching which are excluded by default
const defaultWildcard = matchPaths(sampleFiles, '*');
assert.strictEqual(defaultWildcard.includes('.env'), false);
assert.strictEqual(defaultWildcard.includes('.eslintrc.json'), false);

const dotWildcard = matchPaths(sampleFiles, '.*', { dot: true });
assert.deepStrictEqual(dotWildcard, ['.env', '.eslintrc.json']);

// 5. nocase option performs case-insensitive glob matching
const caseSensitive = matchPaths(sampleFiles, '**/*.js');
assert.strictEqual(caseSensitive.includes('dist/app.JS'), false);

const caseInsensitive = matchPaths(sampleFiles, '**/*.js', { nocase: true });
assert.deepStrictEqual(caseInsensitive, ['src/index.js', 'dist/app.JS']);

// 6. makePatternRegex compiles glob pattern to RegExp with appropriate flags and matching
const regex = makePatternRegex('**/*.js');
assert(regex instanceof RegExp);
assert.strictEqual(regex.test('src/index.js'), true);
assert.strictEqual(regex.test('src/utils.ts'), false);

const nocaseRegex = makePatternRegex('*.js', { nocase: true });
assert(nocaseRegex instanceof RegExp);
assert.strictEqual(nocaseRegex.flags.includes('i'), true);
assert.strictEqual(nocaseRegex.test('INDEX.JS'), true);

// 7. escapePattern escapes special glob characters for literal matching
const escaped = escapePattern('file[1]*.js');
assert.strictEqual(escaped, 'file\\[1\\]\\*.js');

// 8. createMatcher produces Minimatch instances with match and hasMagic methods
const matcher = createMatcher('**/*.ts', { nocase: true });
assert.strictEqual(matcher.hasMagic(), true);
assert.strictEqual(matcher.match('src/utils.ts'), true);
assert.strictEqual(matcher.match('src/utils.TS'), true);
assert.strictEqual(matcher.match('src/index.js'), false);

const literalMatcher = createMatcher('src/index.js');
assert.strictEqual(literalMatcher.hasMagic(), false);
assert.strictEqual(literalMatcher.match('src/index.js'), true);

console.log('Contract tests passed successfully.');

Ursprungs-Seeder

anonym