CodeSampleX

샘플

micromatch 4.0.8: scan

검증된 샘플 — npm micromatch 4.0.8: scan. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: micromatch.scan is exported as a function on the micromatch…

sha256:764a06eaa7c89a10388debf253ce962c68b17718f1f6dcc86aa743cf4d726555

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

케이스

HOW
목표
verify micromatch.scan in pkg:npm/micromatch@4.0.8
패키지
심벌
  • micromatch.scan
환경
node 22.23.2
생성일
2026-08-27T13:25:32Z

컨트랙트

  1. micromatch.scan is exported as a function on the micromatch module
  2. micromatch.scan parses a glob pattern into base directory and glob suffix
  3. micromatch.scan detects leading prefixes and negation flag
  4. micromatch.scan returns path segments when parts option is enabled
  5. micromatch.scan returns token metadata with depth and glob flags when tokens option is enabled
  6. micromatch.scan identifies literal paths without glob characters as isGlob false
  7. micromatch.scan throws TypeError when input is null or undefined

파일

  • 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 micromatch.scan in pkg:npm/micromatch@4.0.8
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/micromatch@4.0.8
Demonstrate these symbols/APIs:
  - micromatch.scan

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:7930bd2b8f129a9beb6845ed0911304529d2c319c0b4324a8b5bdbcc26c1a0b8","contract":["micromatch.scan is exported as a function on the micromatch module","micromatch.scan parses a glob pattern into base directory and glob suffix","micromatch.scan detects leading prefixes and negation flag","micromatch.scan returns path segments when parts option is enabled","micromatch.scan returns token metadata with depth and glob flags when tokens option is enabled","micromatch.scan identifies literal paths without glob characters as isGlob false","micromatch.scan throws TypeError when input is null or undefined"],"goal":"verify micromatch.scan in pkg:npm/micromatch@4.0.8","kind":"HOW","packages":["pkg:npm/micromatch@4.0.8"],"schemaVersion":1,"symbols":["micromatch.scan"]},"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/micromatch@4.0.8"],"schemaVersion":1,"subject":"pkg:npm/micromatch@4.0.8","symbols":["micromatch.scan"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-micromatch-scan",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-micromatch-scan",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "micromatch": "4.0.8"
      }
    },
    "node_modules/braces": {
      "version": "3.0.3",
      "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
      "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
      "license": "MIT",
      "dependencies": {
        "fill-range": "^7.1.1"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/fill-range": {
      "version": "7.1.1",
      "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
      "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
      "license": "MIT",
      "dependencies": {
        "to-regex-range": "^5.0.1"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/is-number": {
      "version": "7.0.0",
      "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
      "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
      "license": "MIT",
      "engines": {
        "node": ">=0.12.0"
      }
    },
    "node_modules/micromatch": {
      "version": "4.0.8",
      "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
      "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
      "license": "MIT",
      "dependencies": {
        "braces": "^3.0.3",
        "picomatch": "^2.3.1"
      },
      "engines": {
        "node": ">=8.6"
      }
    },
    "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"
      }
    },
    "node_modules/to-regex-range": {
      "version": "5.0.1",
      "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
      "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
      "license": "MIT",
      "dependencies": {
        "is-number": "^7.0.0"
      },
      "engines": {
        "node": ">=8.0"
      }
    }
  }
}
package.json
{
  "name": "sample-micromatch-scan",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of micromatch.scan in micromatch@4.0.8",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "micromatch": "4.0.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify micromatch.scan in pkg:npm/micromatch@4.0.8",
  "kind": "HOW",
  "packages": [
    "pkg:npm/micromatch@4.0.8"
  ],
  "symbols": [
    "micromatch.scan"
  ]
}
src/index.js
const micromatch = require('micromatch');

/**
 * Scan a glob pattern and return parsed metadata.
 *
 * @param {string} pattern - Glob pattern or path to scan
 * @param {object} [options] - Micromatch scan options
 * @returns {object} Scan result containing base, glob, isGlob, etc.
 */
function scanPattern(pattern, options) {
  return micromatch.scan(pattern, options);
}

/**
 * Extract the static base directory prefix from a glob pattern.
 *
 * @param {string} pattern - Glob pattern to scan
 * @returns {string} Static base path before any glob syntax
 */
function getBaseDirectory(pattern) {
  const parsed = micromatch.scan(pattern);
  return parsed.base;
}

/**
 * Check if the given pattern contains any glob characters.
 *
 * @param {string} pattern - Pattern to check
 * @returns {boolean} True if the pattern contains glob syntax
 */
function isGlobPattern(pattern) {
  const parsed = micromatch.scan(pattern);
  return Boolean(parsed.isGlob);
}

module.exports = {
  micromatch,
  scan: micromatch.scan,
  scanPattern,
  getBaseDirectory,
  isGlobPattern
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  micromatch,
  scan,
  scanPattern,
  getBaseDirectory,
  isGlobPattern
} = require('../src/index.js');

// 1. Module and function export verification
assert.equal(typeof micromatch, 'function', 'micromatch must be a function');
assert.equal(typeof micromatch.scan, 'function', 'micromatch.scan must be a function');
assert.equal(typeof scan, 'function', 'scan must be a function');
assert.equal(typeof scanPattern, 'function', 'scanPattern must be a function');
assert.equal(typeof getBaseDirectory, 'function', 'getBaseDirectory must be a function');
assert.equal(typeof isGlobPattern, 'function', 'isGlobPattern must be a function');
assert.equal(scan, micromatch.scan, 'scan should reference micromatch.scan');

// 2. Parses glob pattern into base directory and glob suffix
const parsed = micromatch.scan('src/components/**/*.tsx');
assert.equal(parsed.base, 'src/components', 'base should extract directory prefix before globs');
assert.equal(parsed.glob, '**/*.tsx', 'glob should extract the pattern portion');
assert.equal(parsed.isGlob, true, 'isGlob should be true for glob patterns');
assert.equal(parsed.negated, false, 'negated should be false for standard patterns');
assert.equal(getBaseDirectory('src/components/**/*.tsx'), 'src/components', 'getBaseDirectory helper should match base');
assert.equal(isGlobPattern('src/components/**/*.tsx'), true, 'isGlobPattern helper should be true');

// 3. Detects leading prefixes and negation flag
const negatedScan = micromatch.scan('!./assets/*.png');
assert.equal(negatedScan.prefix, '!./', 'prefix should capture leading negation and relative prefix');
assert.equal(negatedScan.base, 'assets', 'base should resolve to directory');
assert.equal(negatedScan.glob, '*.png', 'glob should capture wildcard filename');
assert.equal(negatedScan.negated, true, 'negated should be true when pattern starts with exclamation');

// 4. Returns path segments when parts option is enabled
const partsScan = micromatch.scan('app/routes/admin/*.js', { parts: true });
assert.equal(partsScan.isGlob, true, 'isGlob should be true');
assert.deepEqual(partsScan.parts, ['app', 'routes', 'admin', '*.js'], 'parts should contain array of path segments');
assert.equal(partsScan.base, 'app/routes/admin', 'base should be app/routes/admin');
assert.equal(partsScan.glob, '*.js', 'glob should be *.js');

// 5. Returns token metadata with depth and glob flags when tokens option is enabled
const tokensScan = micromatch.scan('src/utils/*.ts', { tokens: true });
assert.equal(Array.isArray(tokensScan.tokens), true, 'tokens should be an array');
assert.equal(tokensScan.tokens.length, 3, 'tokens should have 3 segments');
assert.deepEqual(
  tokensScan.tokens,
  [
    { value: 'src', depth: 1, isGlob: false },
    { value: 'utils', depth: 1, isGlob: false },
    { value: '*.ts', depth: 1, isGlob: true }
  ],
  'tokens array should have segment values, depth, and isGlob flags'
);

// 6. Identifies literal paths without glob characters as isGlob false
const literalScan = micromatch.scan('config/settings.json');
assert.equal(literalScan.isGlob, false, 'isGlob should be false for non-glob path');
assert.equal(literalScan.base, 'config/settings.json', 'base should equal full path when no glob');
assert.equal(literalScan.glob, '', 'glob should be empty string for literal path');
assert.equal(getBaseDirectory('config/settings.json'), 'config/settings.json', 'getBaseDirectory should return full path');
assert.equal(isGlobPattern('config/settings.json'), false, 'isGlobPattern should return false');

// 7. Throws TypeError when input is null or undefined
assert.throws(
  () => micromatch.scan(null),
  {
    name: 'TypeError'
  },
  'micromatch.scan should throw TypeError when pattern is null'
);
assert.throws(
  () => micromatch.scan(undefined),
  {
    name: 'TypeError'
  },
  'micromatch.scan should throw TypeError when pattern is undefined'
);

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

오리진 시더

익명