Beispiel
fs-extra 10.1.0
Verifiziertes Beispiel für npm fs-extra 10.1.0. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: ensureDir creates nested directory…
sha256:f0c98bf169e06d3abfccee3c5a4d926603803d4b965d36c348bb41bdc8d75602
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
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@1 |
2026-08-20 |
Fall
HOW- Ziel
- verify pkg:npm/fs-extra@10.1.0
- Pakete
- Umgebung
- node 22.23.2
- Erstellt
- 2026-08-20T20:13:16Z
Contract
- ensureDir creates nested directory structures if they do not exist
- outputJson and readJson write and read JSON documents while automatically creating parent directories
- outputFile writes string data creating parent directories automatically and readFile retrieves the written content
- copy recursively copies directory hierarchies and supports custom filter functions
- emptyDir deletes all contents within a directory while leaving the directory itself intact
- pathExists accurately checks the existence of files and directories
- remove recursively removes directories and files without throwing if the target does not exist
- move moves files and directories across paths with optional overwrite
Dateien
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
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/fs-extra@10.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/fs-extra@10.1.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- 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.
{"case":{"caseId":"case:sha256:78e43567fa76fb3b50a4a390cb358812983664af183d35af4298771fa7a20b36","constraints":{"executionContext":"node"},"contract":["ensureDir creates nested directory structures if they do not exist","outputJson and readJson write and read JSON documents while automatically creating parent directories","outputFile writes string data creating parent directories automatically and readFile retrieves the written content","copy recursively copies directory hierarchies and supports custom filter functions","emptyDir deletes all contents within a directory while leaving the directory itself intact","pathExists accurately checks the existence of files and directories","remove recursively removes directories and files without throwing if the target does not exist","move moves files and directories across paths with optional overwrite"],"goal":"verify pkg:npm/fs-extra@10.1.0","kind":"HOW","packages":["pkg:npm/fs-extra@10.1.0"],"schemaVersion":1},"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","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/fs-extra@10.1.0"],"schemaVersion":1,"subject":"pkg:npm/fs-extra@10.1.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-fs-extra",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-fs-extra",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"fs-extra": "10.1.0"
}
},
"node_modules/fs-extra": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
"integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
"license": "MIT",
"dependencies": {
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"license": "ISC"
},
"node_modules/jsonfile": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz",
"integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==",
"license": "MIT",
"dependencies": {
"universalify": "^2.0.0"
},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
},
"node_modules/universalify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
"license": "MIT",
"engines": {
"node": ">= 10.0.0"
}
}
}
}
{
"name": "sample-fs-extra",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of fs-extra",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"fs-extra": "10.1.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/fs-extra@10.1.0",
"kind": "HOW",
"packages": [
"pkg:npm/fs-extra@10.1.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"runtime": "node@22.23.2"
}
}
const fs = require('fs-extra');
/**
* Creates directory and writes JSON file inside nested directory structure.
*/
async function writeConfig(filePath, data) {
await fs.outputJson(filePath, data, { spaces: 2 });
}
/**
* Reads JSON file using fs-extra readJson.
*/
async function readConfig(filePath) {
return await fs.readJson(filePath);
}
/**
* Ensures directory exists, creating all intermediate directories.
*/
async function createDirectoryStructure(dirPath) {
await fs.ensureDir(dirPath);
}
/**
* Writes text file, automatically creating parent directories.
*/
async function writeTextFile(filePath, content) {
await fs.outputFile(filePath, content, 'utf8');
}
/**
* Copies a source directory or file to a destination path.
*/
async function copyPath(src, dest, options = {}) {
await fs.copy(src, dest, options);
}
/**
* Empties a directory without deleting the directory itself.
*/
async function emptyDirectory(dirPath) {
await fs.emptyDir(dirPath);
}
/**
* Checks if path exists.
*/
async function checkExists(targetPath) {
return await fs.pathExists(targetPath);
}
/**
* Moves file or directory from source to destination.
*/
async function movePath(src, dest, options = {}) {
await fs.move(src, dest, options);
}
/**
* Removes file or directory recursively.
*/
async function removePath(targetPath) {
await fs.remove(targetPath);
}
module.exports = {
fs,
writeConfig,
readConfig,
createDirectoryStructure,
writeTextFile,
copyPath,
emptyDirectory,
checkExists,
movePath,
removePath
};
import assert from 'node:assert';
import path from 'node:path';
import os from 'node:os';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
fs,
writeConfig,
readConfig,
createDirectoryStructure,
writeTextFile,
copyPath,
emptyDirectory,
checkExists,
movePath,
removePath
} = require('../src/index.js');
async function runContract() {
const tmpBase = path.join(os.tmpdir(), `csx-contract-fs-extra-${Date.now()}-${Math.random().toString(36).slice(2)}`);
await fs.ensureDir(tmpBase);
try {
// 1. ensureDir creates nested directory structures if they do not exist
const nestedDir = path.join(tmpBase, 'a', 'b', 'c', 'nested');
assert.strictEqual(await checkExists(nestedDir), false, 'Nested dir should not exist initially');
await createDirectoryStructure(nestedDir);
assert.strictEqual(await checkExists(nestedDir), true, 'Nested dir should exist after ensureDir');
// 2. outputJson and readJson write and read JSON documents while automatically creating parent directories
const jsonPath = path.join(tmpBase, 'configs', 'app', 'settings.json');
const testData = { name: 'sample-app', port: 8080, features: ['logging', 'metrics'], active: true };
await writeConfig(jsonPath, testData);
assert.strictEqual(await checkExists(jsonPath), true, 'JSON file should exist');
const readData = await readConfig(jsonPath);
assert.deepStrictEqual(readData, testData, 'readJson must match written json data');
// 3. outputFile writes string data creating parent directories automatically and readFile retrieves the written content
const textPath = path.join(tmpBase, 'docs', 'readme.txt');
const textContent = 'Hello from clean-room contract verification!';
await writeTextFile(textPath, textContent);
assert.strictEqual(await checkExists(textPath), true, 'Text file should exist');
const readText = await fs.readFile(textPath, 'utf8');
assert.strictEqual(readText, textContent, 'readFile must return the written string');
// 4. copy recursively copies directory hierarchies and supports custom filter functions
const srcDir = path.join(tmpBase, 'source-tree');
const destDir = path.join(tmpBase, 'dest-tree');
await fs.outputFile(path.join(srcDir, 'file1.txt'), 'content-1');
await fs.outputFile(path.join(srcDir, 'ignored.tmp'), 'ignore-me');
await fs.outputFile(path.join(srcDir, 'sub', 'file2.txt'), 'content-2');
await copyPath(srcDir, destDir, {
filter: (src) => !src.endsWith('.tmp')
});
assert.strictEqual(await checkExists(path.join(destDir, 'file1.txt')), true, 'Copied file1 must exist');
assert.strictEqual(await checkExists(path.join(destDir, 'sub', 'file2.txt')), true, 'Copied file2 must exist');
assert.strictEqual(await checkExists(path.join(destDir, 'ignored.tmp')), false, 'Filtered file must not be copied');
// 5. emptyDir deletes all contents within a directory while leaving the directory itself intact
const dirToEmpty = path.join(tmpBase, 'to-empty');
await fs.outputFile(path.join(dirToEmpty, 'nested', 'data.bin'), 'data');
assert.strictEqual(await checkExists(path.join(dirToEmpty, 'nested', 'data.bin')), true);
await emptyDirectory(dirToEmpty);
assert.strictEqual(await checkExists(dirToEmpty), true, 'Directory itself must still exist after emptyDir');
const dirEntries = await fs.readdir(dirToEmpty);
assert.strictEqual(dirEntries.length, 0, 'Directory should have 0 entries after emptyDir');
// 6. pathExists accurately checks the existence of files and directories
assert.strictEqual(await checkExists(dirToEmpty), true, 'pathExists must return true for existing dir');
assert.strictEqual(await checkExists(path.join(tmpBase, 'non-existent-path')), false, 'pathExists must return false for missing path');
// 7. remove recursively removes directories and files without throwing if the target does not exist
await removePath(destDir);
assert.strictEqual(await checkExists(destDir), false, 'Directory must be removed');
await removePath(path.join(tmpBase, 'non-existent-file-12345.xyz')); // should not throw
// 8. move moves files and directories across paths with optional overwrite
const moveSrc = path.join(tmpBase, 'move-source.txt');
const moveDest = path.join(tmpBase, 'moved', 'target.txt');
await fs.outputFile(moveSrc, 'to-be-moved');
await movePath(moveSrc, moveDest);
assert.strictEqual(await checkExists(moveSrc), false, 'Source must no longer exist after move');
assert.strictEqual(await checkExists(moveDest), true, 'Destination must exist after move');
assert.strictEqual(await fs.readFile(moveDest, 'utf8'), 'to-be-moved', 'Moved content must match');
console.log('Contract tests passed successfully.');
} finally {
await fs.remove(tmpBase);
}
}
runContract().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Ursprungs-Seeder
anonym