CodeSampleX

Exemplo

rimraf 3.0.2: rimraf

Amostra verificada para npm rimraf 3.0.2: rimraf. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: rimraf is exported as a callable function…

sha256:fcdf19ffe7a6a78c4e08eefdb910524736f11df4adbec874a08b63befb6aefe8

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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

Caso

HOW
Objetivo
verify pkg:npm/rimraf@3.0.2
Pacotes
Símbolos
  • rimraf
Criado
2026-08-28T07:50:02Z

Contrato

  1. rimraf is exported as a callable function with a sync method
  2. rimraf asynchronously removes a single file and invokes callback
  3. rimraf asynchronously removes a nested directory hierarchy
  4. rimraf asynchronously succeeds with null error when target path does not exist
  5. rimraf.sync synchronously removes a single file
  6. rimraf.sync synchronously removes a nested directory hierarchy
  7. rimraf.sync synchronously succeeds without error when target path does not exist

Arquivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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 pkg:npm/rimraf@3.0.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/rimraf@3.0.2
Demonstrate these symbols/APIs:
  - rimraf

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:277611601598a85289213a291db577a662e1b69f35ef8e85420a7bae946dc61d","contract":["rimraf is exported as a callable function with a sync method","rimraf asynchronously removes a single file and invokes callback","rimraf asynchronously removes a nested directory hierarchy","rimraf asynchronously succeeds with null error when target path does not exist","rimraf.sync synchronously removes a single file","rimraf.sync synchronously removes a nested directory hierarchy","rimraf.sync synchronously succeeds without error when target path does not exist"],"goal":"verify pkg:npm/rimraf@3.0.2","kind":"HOW","packages":["pkg:npm/rimraf@3.0.2"],"schemaVersion":1,"symbols":["rimraf"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/rimraf@3.0.2"],"schemaVersion":1,"subject":"pkg:npm/rimraf@3.0.2","symbols":["rimraf"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-rimraf",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-rimraf",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "rimraf": "3.0.2"
      }
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    },
    "node_modules/brace-expansion": {
      "version": "1.1.18",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
      "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^1.0.0",
        "concat-map": "0.0.1"
      }
    },
    "node_modules/concat-map": {
      "version": "0.0.1",
      "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
      "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
      "license": "MIT"
    },
    "node_modules/fs.realpath": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
      "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
      "license": "ISC"
    },
    "node_modules/glob": {
      "version": "7.2.3",
      "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
      "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
      "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me",
      "license": "ISC",
      "dependencies": {
        "fs.realpath": "^1.0.0",
        "inflight": "^1.0.4",
        "inherits": "2",
        "minimatch": "^3.1.1",
        "once": "^1.3.0",
        "path-is-absolute": "^1.0.0"
      },
      "engines": {
        "node": "*"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/inflight": {
      "version": "1.0.6",
      "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
      "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
      "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
      "license": "ISC",
      "dependencies": {
        "once": "^1.3.0",
        "wrappy": "1"
      }
    },
    "node_modules/inherits": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
      "license": "ISC"
    },
    "node_modules/minimatch": {
      "version": "3.1.5",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
      "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
      "license": "ISC",
      "dependencies": {
        "brace-expansion": "^1.1.7"
      },
      "engines": {
        "node": "*"
      }
    },
    "node_modules/once": {
      "version": "1.4.0",
      "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
      "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
      "license": "ISC",
      "dependencies": {
        "wrappy": "1"
      }
    },
    "node_modules/path-is-absolute": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
      "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/rimraf": {
      "version": "3.0.2",
      "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
      "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
      "deprecated": "Rimraf versions prior to v4 are no longer supported",
      "license": "ISC",
      "dependencies": {
        "glob": "^7.1.3"
      },
      "bin": {
        "rimraf": "bin.js"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/wrappy": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
      "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-rimraf",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for rimraf in rimraf@3.0.2",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "rimraf": "3.0.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/rimraf@3.0.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/rimraf@3.0.2"
  ],
  "symbols": [
    "rimraf"
  ]
}
src/index.js
const rimraf = require('rimraf');

/**
 * Recursively remove a file or directory asynchronously using rimraf.
 *
 * @param {string} targetPath - Path to remove.
 * @param {object} [options] - Optional configuration options.
 * @param {Function} callback - Node-style callback (err).
 */
function removeAsync(targetPath, options, callback) {
  if (typeof options === 'function') {
    callback = options;
    options = {};
  }
  return rimraf(targetPath, options, callback);
}

/**
 * Recursively remove a file or directory synchronously using rimraf.sync.
 *
 * @param {string} targetPath - Path to remove.
 * @param {object} [options] - Optional configuration options.
 */
function removeSync(targetPath, options) {
  return rimraf.sync(targetPath, options);
}

module.exports = {
  rimraf,
  removeAsync,
  removeSync
};
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const { rimraf, removeAsync, removeSync } = require('../src/index.js');

function createTempDir(prefix) {
  return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
}

async function runTests() {
  // 1. rimraf is exported as a callable function with a sync method
  assert.equal(typeof rimraf, 'function', 'rimraf must be exported as a function');
  assert.equal(typeof rimraf.sync, 'function', 'rimraf.sync must be a function');
  assert.equal(typeof removeAsync, 'function', 'removeAsync helper must be a function');
  assert.equal(typeof removeSync, 'function', 'removeSync helper must be a function');

  // 2. rimraf asynchronously removes a single file and invokes callback
  {
    const tempDir = createTempDir('csx-rimraf-async-file-');
    const filePath = path.join(tempDir, 'file.txt');
    fs.writeFileSync(filePath, 'hello rimraf', 'utf8');
    assert.equal(fs.existsSync(filePath), true, 'File must exist prior to removal');

    await new Promise((resolve, reject) => {
      rimraf(filePath, (err) => {
        if (err) return reject(err);
        resolve();
      });
    });

    assert.equal(fs.existsSync(filePath), false, 'File must be deleted after rimraf async call');
    fs.rmSync(tempDir, { recursive: true, force: true });
  }

  // 3. rimraf asynchronously removes a nested directory hierarchy
  {
    const tempDir = createTempDir('csx-rimraf-async-dir-');
    const nestedDir = path.join(tempDir, 'a', 'b', 'c');
    fs.mkdirSync(nestedDir, { recursive: true });
    fs.writeFileSync(path.join(nestedDir, 'data.txt'), 'nested content', 'utf8');
    fs.writeFileSync(path.join(tempDir, 'a', 'top.txt'), 'top content', 'utf8');
    assert.equal(fs.existsSync(nestedDir), true, 'Nested directory must exist');

    await new Promise((resolve, reject) => {
      removeAsync(path.join(tempDir, 'a'), (err) => {
        if (err) return reject(err);
        resolve();
      });
    });

    assert.equal(fs.existsSync(path.join(tempDir, 'a')), false, 'Nested hierarchy must be removed completely');
    fs.rmSync(tempDir, { recursive: true, force: true });
  }

  // 4. rimraf asynchronously succeeds with null error when target path does not exist
  {
    const nonExistentPath = path.join(os.tmpdir(), `csx-nonexistent-${Date.now()}-${Math.random().toString(36).slice(2)}`);
    assert.equal(fs.existsSync(nonExistentPath), false, 'Target path must not exist');

    const err = await new Promise((resolve) => {
      rimraf(nonExistentPath, (error) => {
        resolve(error);
      });
    });

    assert.equal(err, null, 'rimraf callback must receive null error for nonexistent path');
  }

  // 5. rimraf.sync synchronously removes a single file
  {
    const tempDir = createTempDir('csx-rimraf-sync-file-');
    const filePath = path.join(tempDir, 'sync-file.txt');
    fs.writeFileSync(filePath, 'sync file content', 'utf8');
    assert.equal(fs.existsSync(filePath), true, 'Sync target file must exist');

    rimraf.sync(filePath);
    assert.equal(fs.existsSync(filePath), false, 'File must be deleted after rimraf.sync call');
    fs.rmSync(tempDir, { recursive: true, force: true });
  }

  // 6. rimraf.sync synchronously removes a nested directory hierarchy
  {
    const tempDir = createTempDir('csx-rimraf-sync-dir-');
    const targetDir = path.join(tempDir, 'level1', 'level2');
    fs.mkdirSync(targetDir, { recursive: true });
    fs.writeFileSync(path.join(targetDir, 'sync-test.json'), '{"key":"val"}', 'utf8');
    assert.equal(fs.existsSync(targetDir), true, 'Directory tree must exist before sync deletion');

    removeSync(path.join(tempDir, 'level1'));
    assert.equal(fs.existsSync(path.join(tempDir, 'level1')), false, 'Directory tree must be removed after removeSync');
    fs.rmSync(tempDir, { recursive: true, force: true });
  }

  // 7. rimraf.sync synchronously succeeds without error when target path does not exist
  {
    const nonExistentPath = path.join(os.tmpdir(), `csx-sync-nonexistent-${Date.now()}-${Math.random().toString(36).slice(2)}`);
    assert.equal(fs.existsSync(nonExistentPath), false, 'Path must not exist');

    assert.doesNotThrow(() => {
      rimraf.sync(nonExistentPath);
    }, 'rimraf.sync on nonexistent path must not throw');
  }

  console.log('All contract assertions for rimraf passed successfully.');
}

runTests().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

Seeder de origem

anônimo