샘플
require-directory 2.1.1
검증된 샘플 — npm require-directory 2.1.1. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: requireDirectory loads all supported modules recursively…
sha256:cc9764aadfbf42acfb4d422d91ab2f297f0ff619f62616755634186c288533f8
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-23 |
케이스
HOW- 목표
- verify pkg:npm/require-directory@2.1.1
- 환경
- node 22.23.2
- 생성일
- 2026-08-23T08:24:02Z
컨트랙트
- requireDirectory loads all supported modules recursively from a directory into a nested object
- supports filtering files using include and exclude regular expressions or functions
- allows custom renaming of object keys using the rename option function
- allows transforming imported modules using the visit option callback
- honors recurse option to toggle recursive subfolder traversal
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
- test/fixtures/config.json
- test/fixtures/helpers/format.js
- test/fixtures/helpers/ignore.txt
- test/fixtures/math/add.js
- test/fixtures/math/subtract.js
소스
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/require-directory@2.1.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/require-directory@2.1.1
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.
{"case":{"caseId":"case:sha256:f88ff53ee4c4e6c10442b5933a66b82d30572983b6118d49f85cf39ee30c4fcc","contract":["requireDirectory loads all supported modules recursively from a directory into a nested object","supports filtering files using include and exclude regular expressions or functions","allows custom renaming of object keys using the rename option function","allows transforming imported modules using the visit option callback","honors recurse option to toggle recursive subfolder traversal"],"goal":"verify pkg:npm/require-directory@2.1.1","kind":"HOW","packages":["pkg:npm/require-directory@2.1.1"],"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/require-directory@2.1.1"],"schemaVersion":1,"subject":"pkg:npm/require-directory@2.1.1","verifierAdapter":"node-typescript@1"}
{
"name": "sample-require-directory",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-require-directory",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"require-directory": "2.1.1"
}
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
}
}
}
{
"name": "sample-require-directory",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for require-directory",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"require-directory": "2.1.1"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/require-directory@2.1.1",
"kind": "HOW",
"packages": [
"pkg:npm/require-directory@2.1.1"
]
}
const requireDirectory = require('require-directory');
function loadModules(callingModule, targetPath, options) {
return requireDirectory(callingModule, targetPath, options);
}
module.exports = {
requireDirectory,
loadModules
};
const assert = require('node:assert');
const path = require('node:path');
const requireDirectory = require('require-directory');
const { loadModules } = require('../src/index.js');
const fixturesDir = path.join(__dirname, 'fixtures');
// 1. requireDirectory loads all supported modules recursively from a directory into a nested object
const modules = loadModules(module, './fixtures');
assert.strictEqual(typeof modules, 'object', 'modules must be an object');
assert.ok(modules.math, 'modules should contain math namespace');
assert.ok(modules.helpers, 'modules should contain helpers namespace');
assert.ok(modules.config, 'modules should contain config JSON');
assert.strictEqual(typeof modules.math.add, 'function', 'math.add must be a function');
assert.strictEqual(typeof modules.math.subtract, 'function', 'math.subtract must be a function');
assert.strictEqual(typeof modules.helpers.format, 'function', 'helpers.format must be a function');
assert.strictEqual(modules.math.add(10, 5), 15, 'math.add(10, 5) should equal 15');
assert.strictEqual(modules.math.subtract(10, 5), 5, 'math.subtract(10, 5) should equal 5');
assert.strictEqual(modules.helpers.format(' hello '), 'hello', 'helpers.format should trim whitespace');
assert.strictEqual(modules.config.name, 'sample-config', 'config.name should match');
assert.strictEqual(modules.config.enabled, true, 'config.enabled should match');
assert.strictEqual(modules.helpers.ignore, undefined, 'unsupported extension files should be ignored');
// 2. supports filtering files using include and exclude regular expressions or functions
const mathOnly = loadModules(module, './fixtures', {
include: /math/
});
assert.ok(mathOnly.math, 'math directory should be included');
assert.strictEqual(mathOnly.helpers, undefined, 'helpers directory should not be included');
const excludeSubtract = loadModules(module, './fixtures', {
exclude: /subtract/
});
assert.ok(excludeSubtract.math.add, 'math.add should be included');
assert.strictEqual(excludeSubtract.math.subtract, undefined, 'math.subtract should be excluded');
const functionFiltered = loadModules(module, './fixtures', {
exclude: (filePath) => filePath.endsWith('add.js')
});
assert.strictEqual(functionFiltered.math.add, undefined, 'math.add should be excluded by predicate function');
assert.ok(functionFiltered.math.subtract, 'math.subtract should remain when not excluded');
// 3. allows custom renaming of object keys using the rename option function
const uppercaseKeys = loadModules(module, './fixtures', {
rename: (name) => name.toUpperCase()
});
assert.ok(uppercaseKeys.MATH, 'renamed key MATH should exist');
assert.ok(uppercaseKeys.MATH.ADD, 'renamed key MATH.ADD should exist');
assert.strictEqual(uppercaseKeys.MATH.ADD(3, 4), 7, 'renamed function should be callable');
// 4. allows transforming imported modules using the visit option callback
let visitedCount = 0;
const visitedModules = loadModules(module, './fixtures', {
visit: (obj, fullPath, filename) => {
visitedCount++;
if (typeof obj === 'function') {
return { wrapped: obj, filename };
}
return obj;
}
});
assert.ok(visitedCount > 0, 'visitor should be called for each imported module');
assert.strictEqual(typeof visitedModules.math.add.wrapped, 'function', 'math.add should be wrapped by visitor');
assert.strictEqual(visitedModules.math.add.wrapped(2, 3), 5, 'wrapped math.add should work');
assert.strictEqual(visitedModules.math.add.filename, 'add.js', 'visitor should receive filename');
// 5. honors recurse option to toggle recursive subfolder traversal
const nonRecursive = loadModules(module, './fixtures', {
recurse: false
});
assert.ok(nonRecursive.config, 'top-level config.json should be loaded');
assert.strictEqual(nonRecursive.math, undefined, 'math subdirectory should not be loaded when recurse is false');
assert.strictEqual(nonRecursive.helpers, undefined, 'helpers subdirectory should not be loaded when recurse is false');
console.log('All require-directory contract tests passed successfully.');
{
"name": "sample-config",
"enabled": true
}
module.exports = function format(str) {
return String(str).trim();
};
This is an ignored non-code file.
module.exports = function add(a, b) {
return a + b;
};
module.exports = function subtract(a, b) {
return a - b;
};
오리진 시더
익명