CodeSampleX

샘플

minimatch 3.1.5

검증된 샘플 — npm minimatch 3.1.5. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: minimatch tests paths against glob patterns with support for…

sha256:9e960e084fe3b9b9c9ba95ce08255514dd7f3f1d374fc235d8fb072c652031e0

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

실행 증거

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

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

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux alpine/x64 · docker ed25519:2a6aa94bf40f1df0 SKIPPED compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL
CONTAINER_RUN · node-typescript@1
2026-08-19
node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-20

케이스

HOW
목표
verify pkg:npm/minimatch@3.1.5
패키지
환경
node 22.23.2
생성일
2026-08-19T22:01:40Z

컨트랙트

  1. minimatch tests paths against glob patterns with support for wildcards, globstars, brace expansions, and options like nocase and dot
  2. minimatch.match filters an array of path strings against a glob pattern returning only matches
  3. minimatch.filter returns a predicate function compatible with Array.prototype.filter for glob matching
  4. minimatch.makeRe compiles a glob pattern into a RegExp instance for regular expression matching
  5. minimatch.Minimatch creates a reusable matcher instance with pre-parsed pattern set and match method

파일

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

소스 아티팩트 내려받기 (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@3.1.5
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/minimatch@3.1.5
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:dd5c34a40cd5e31fcadf86a7b62b5e0eff9141391c4fc5dec2d32ff42b08c991","constraints":{"executionContext":"node"},"contract":["minimatch tests paths against glob patterns with support for wildcards, globstars, brace expansions, and options like nocase and dot","minimatch.match filters an array of path strings against a glob pattern returning only matches","minimatch.filter returns a predicate function compatible with Array.prototype.filter for glob matching","minimatch.makeRe compiles a glob pattern into a RegExp instance for regular expression matching","minimatch.Minimatch creates a reusable matcher instance with pre-parsed pattern set and match method"],"goal":"verify pkg:npm/minimatch@3.1.5","kind":"HOW","packages":["pkg:npm/minimatch@3.1.5"],"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/minimatch@3.1.5"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "minimatch-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "minimatch-sample",
      "version": "1.0.0",
      "dependencies": {
        "minimatch": "3.1.5"
      }
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    },
    "node_modules/brace-expansion": {
      "version": "1.1.18",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
      "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^1.0.0",
        "concat-map": "0.0.1"
      }
    },
    "node_modules/concat-map": {
      "version": "0.0.1",
      "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
      "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
      "license": "MIT"
    },
    "node_modules/minimatch": {
      "version": "3.1.5",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
      "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
      "license": "ISC",
      "dependencies": {
        "brace-expansion": "^1.1.7"
      },
      "engines": {
        "node": "*"
      }
    }
  }
}
package.json
{
  "name": "minimatch-sample",
  "version": "1.0.0",
  "dependencies": {
    "minimatch": "3.1.5"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/minimatch@3.1.5",
  "kind": "HOW",
  "packages": [
    "pkg:npm/minimatch@3.1.5"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const minimatch = require('minimatch');

/**
 * Tests if a path matches a pattern.
 *
 * @param {string} p - Path to match.
 * @param {string} pattern - Glob pattern.
 * @param {object} [options] - Minimatch options.
 * @returns {boolean} True if matched.
 */
function matchPath(p, pattern, options) {
  return minimatch(p, pattern, options);
}

/**
 * Filters an array of paths against a pattern.
 *
 * @param {string[]} list - List of paths.
 * @param {string} pattern - Glob pattern.
 * @param {object} [options] - Minimatch options.
 * @returns {string[]} Filtered paths.
 */
function matchAll(list, pattern, options) {
  return minimatch.match(list, pattern, options);
}

/**
 * Returns a filter function for Array.prototype.filter.
 *
 * @param {string} pattern - Glob pattern.
 * @param {object} [options] - Minimatch options.
 * @returns {(p: string, index?: number, array?: string[]) => boolean} Filter function.
 */
function createFilter(pattern, options) {
  return minimatch.filter(pattern, options);
}

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

/**
 * Creates a Minimatch instance for repeated pattern evaluation.
 *
 * @param {string} pattern - Glob pattern.
 * @param {object} [options] - Minimatch options.
 * @returns {minimatch.Minimatch} Minimatch instance.
 */
function createMinimatch(pattern, options) {
  return new minimatch.Minimatch(pattern, options);
}

module.exports = {
  matchPath,
  matchAll,
  createFilter,
  compilePattern,
  createMinimatch,
  minimatch,
};
test/contract.js
const assert = require('node:assert/strict');
const {
  matchPath,
  matchAll,
  createFilter,
  compilePattern,
  createMinimatch,
} = require('../src/index.js');

// Contract 1: minimatch tests paths against glob patterns with support for wildcards, globstars, brace expansions, and options like nocase and dot
{
  assert.strictEqual(matchPath('foo.js', '*.js'), true, 'Matches simple glob');
  assert.strictEqual(matchPath('src/utils/math.js', 'src/**/*.js'), true, 'Matches globstar hierarchy');
  assert.strictEqual(matchPath('build/out.ts', 'src/**/*.js'), false, 'Rejects unmatched path and extension');
  assert.strictEqual(matchPath('app.test.js', '*.{test,spec}.js'), true, 'Matches brace expansion alternative 1');
  assert.strictEqual(matchPath('app.spec.js', '*.{test,spec}.js'), true, 'Matches brace expansion alternative 2');
  assert.strictEqual(matchPath('app.dev.js', '*.{test,spec}.js'), false, 'Rejects brace expansion non-match');

  assert.strictEqual(matchPath('INDEX.JS', '*.js', { nocase: true }), true, 'Supports nocase option');
  assert.strictEqual(matchPath('INDEX.JS', '*.js', { nocase: false }), false, 'Rejects case mismatch when nocase is false');

  assert.strictEqual(matchPath('.gitignore', '.*', { dot: true }), true, 'Matches dotfile with dot option');
  assert.strictEqual(matchPath('.gitignore', '*', { dot: false }), false, 'Rejects dotfile by default');
}

// Contract 2: minimatch.match filters an array of path strings against a glob pattern returning only matches
{
  const files = [
    'src/index.js',
    'src/index.test.js',
    'src/components/Header.jsx',
    'docs/readme.md',
    'package.json',
  ];

  const jsFiles = matchAll(files, '**/*.js');
  assert.deepStrictEqual(jsFiles, ['src/index.js', 'src/index.test.js'], 'Filters JS files across directories');

  const docFiles = matchAll(files, '*.md', { matchBase: true });
  assert.deepStrictEqual(docFiles, ['docs/readme.md'], 'Filters files matching basename');

  const emptyMatches = matchAll(files, '*.png');
  assert.deepStrictEqual(emptyMatches, [], 'Returns empty array on no match');
}

// Contract 3: minimatch.filter returns a predicate function compatible with Array.prototype.filter for glob matching
{
  const files = ['a.txt', 'b.md', 'c.txt', 'd.json'];
  const isTxt = createFilter('*.txt');
  const txtFiles = files.filter(isTxt);
  assert.deepStrictEqual(txtFiles, ['a.txt', 'c.txt'], 'Filters array using predicate');

  const isMdOrJson = createFilter('*.{md,json}');
  const mdAndJsonFiles = files.filter(isMdOrJson);
  assert.deepStrictEqual(mdAndJsonFiles, ['b.md', 'd.json'], 'Filters using brace expansion predicate');
}

// Contract 4: minimatch.makeRe compiles a glob pattern into a RegExp instance for regular expression matching
{
  const re = compilePattern('src/**/*.ts');
  assert.ok(re instanceof RegExp, 'Returns RegExp instance');
  assert.strictEqual(re.test('src/models/user.ts'), true, 'Compiled RegExp matches pattern');
  assert.strictEqual(re.test('dist/models/user.js'), false, 'Compiled RegExp rejects non-matching pattern');
}

// Contract 5: minimatch.Minimatch creates a reusable matcher instance with pre-parsed pattern set and match method
{
  const mm = createMinimatch('lib/**/*.js');
  assert.strictEqual(mm.match('lib/core/api.js'), true, 'Minimatch instance matches target file');
  assert.strictEqual(mm.match('lib/core/api.ts'), false, 'Minimatch instance rejects non-matching extension');
  assert.ok(Array.isArray(mm.set), 'Minimatch exposes parsed pattern set');
  assert.strictEqual(mm.pattern, 'lib/**/*.js', 'Minimatch retains original pattern');
}

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

오리진 시더

익명