CodeSampleX

サンプル

micromatch 4.0.8: every

検証済みサンプル — npm micromatch 4.0.8: every. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: micromatch.every is exported as a function on the…

sha256:5ad79e0982ca54746ff5629bde1a475b0892ebee74c8a3403810f8f5a5b81722

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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-28

ケース

HOW
ゴール
verify micromatch.every in pkg:npm/micromatch@4.0.8
パッケージ
シンボル
  • micromatch.every
環境
node 22.23.2
作成日
2026-08-28T02:43:54Z

コントラクト

  1. micromatch.every is exported as a function on the micromatch module
  2. micromatch.every returns true when all elements in an array match the given glob pattern
  3. micromatch.every returns false when any element in an array fails to match the pattern
  4. micromatch.every accepts a single string or array of strings as input list
  5. micromatch.every supports multiple glob patterns requiring all elements to match every pattern
  6. micromatch.every respects custom options including nocase and dot

ファイル

  • 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.every 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.every
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:c140412b97ac1d6e7c2d8c5e1d1ee749ce084706c47b34d06780899a677c2e33","constraints":{"executionContext":"node"},"contract":["micromatch.every is exported as a function on the micromatch module","micromatch.every returns true when all elements in an array match the given glob pattern","micromatch.every returns false when any element in an array fails to match the pattern","micromatch.every accepts a single string or array of strings as input list","micromatch.every supports multiple glob patterns requiring all elements to match every pattern","micromatch.every respects custom options including nocase and dot"],"goal":"verify micromatch.every in pkg:npm/micromatch@4.0.8","kind":"HOW","packages":["pkg:npm/micromatch@4.0.8"],"schemaVersion":1,"symbols":["micromatch.every"]},"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.every"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-micromatch-every",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-micromatch-every",
      "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-every",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of micromatch.every in micromatch@4.0.8",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "micromatch": "4.0.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify micromatch.every in pkg:npm/micromatch@4.0.8",
  "kind": "HOW",
  "packages": [
    "pkg:npm/micromatch@4.0.8"
  ],
  "symbols": [
    "micromatch.every"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const micromatch = require('micromatch');

/**
 * Check if every file path in a list matches the given glob pattern(s).
 *
 * @param {string|string[]} list - File path or array of file paths to test
 * @param {string|string[]} patterns - Glob pattern or array of patterns that must match
 * @param {object} [options] - Micromatch options
 * @returns {boolean} True if all items match all patterns
 */
function checkAllMatch(list, patterns, options) {
  return micromatch.every(list, patterns, options);
}

/**
 * Validate that a batch of files adheres to naming conventions or directory restrictions.
 *
 * @param {string[]} filepaths - Array of file paths to validate
 * @param {string|string[]} patterns - Glob patterns every file must satisfy
 * @param {object} [options] - Micromatch options
 * @returns {boolean} True if all paths satisfy the pattern requirements
 */
function validateBatch(filepaths, patterns, options) {
  return micromatch.every(filepaths, patterns, options);
}

module.exports = {
  micromatch,
  every: micromatch.every,
  checkAllMatch,
  validateBatch
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  micromatch,
  every,
  checkAllMatch,
  validateBatch
} = require('../src/index.js');

// 1. Module and function export verification
assert.equal(typeof micromatch, 'function', 'micromatch must be a function');
assert.equal(typeof micromatch.every, 'function', 'micromatch.every must be a function');
assert.equal(typeof every, 'function', 'every must be a function');
assert.equal(typeof checkAllMatch, 'function', 'checkAllMatch must be a function');
assert.equal(typeof validateBatch, 'function', 'validateBatch must be a function');
assert.equal(every, micromatch.every, 'every should reference micromatch.every');

// 2. Returns true when all elements in an array match the pattern
assert.equal(
  micromatch.every(['foo.js', 'bar.js', 'baz.js'], '*.js'),
  true,
  'micromatch.every should return true when all files match glob'
);
assert.equal(
  checkAllMatch(['src/index.ts', 'src/utils.ts'], 'src/**/*.ts'),
  true,
  'checkAllMatch should return true when all files match glob'
);

// 3. Returns false when any element fails to match the pattern
assert.equal(
  micromatch.every(['foo.js', 'bar.txt', 'baz.js'], '*.js'),
  false,
  'micromatch.every should return false when at least one item fails to match'
);
assert.equal(
  validateBatch(['components/Button.tsx', 'styles/theme.css'], '**/*.tsx'),
  false,
  'validateBatch should return false when a file does not match the extension'
);

// 4. Accepts a single string as input list
assert.equal(
  micromatch.every('foo.js', '*.js'),
  true,
  'micromatch.every should accept single string as list and return true on match'
);
assert.equal(
  micromatch.every('foo.txt', '*.js'),
  false,
  'micromatch.every should accept single string as list and return false on mismatch'
);

// 5. Supports multiple glob patterns requiring all elements to match every pattern
assert.equal(
  micromatch.every(['src/components/Header.tsx', 'src/components/Footer.tsx'], ['src/**', '**/*.tsx']),
  true,
  'micromatch.every should return true when all items match all patterns'
);
assert.equal(
  micromatch.every(['src/components/Header.tsx', 'dist/bundle.tsx'], ['src/**', '**/*.tsx']),
  false,
  'micromatch.every should return false when an item fails one of the patterns'
);

// 6. Respects custom options (nocase, dot)
assert.equal(
  micromatch.every(['FILE.JS', 'OTHER.JS'], '*.js', { nocase: true }),
  true,
  'micromatch.every should respect nocase option'
);
assert.equal(
  micromatch.every(['FILE.JS', 'OTHER.JS'], '*.js', { nocase: false }),
  false,
  'micromatch.every should fail case-sensitive match when nocase is false'
);
assert.equal(
  micromatch.every(['.env.local', '.env.prod'], '.env.*', { dot: true }),
  true,
  'micromatch.every should respect dot option for hidden files'
);

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

オリジンシーダー

匿名