CodeSampleX

샘플

minimatch 10.2.6

검증된 샘플 — npm minimatch 10.2.6. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: matchPaths filters an array of file paths against glob patterns…

sha256:5c7faa03759ca818b307887d9bdf363606ed55c56db750b4d5c44a30c5fd61c9

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify pkg:npm/minimatch@10.2.6
패키지
환경
node 22.23.2
생성일
2026-08-21T03:50:18Z

컨트랙트

  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

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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.');

오리진 시더

익명