Beispiel
require-directory 2.1.1
Verifiziertes Beispiel für npm require-directory 2.1.1. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: requireDirectory loads all…
sha256:cc9764aadfbf42acfb4d422d91ab2f297f0ff619f62616755634186c288533f8
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- verify pkg:npm/require-directory@2.1.1
- Pakete
- Umgebung
- node 22.23.2
- Erstellt
- 2026-08-23T08:24:02Z
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
Dateien
- 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
Quelltext
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;
};
Ursprungs-Seeder
anonym