CodeSampleX

샘플

tmp 0.2.7

검증된 샘플 — npm tmp 0.2.7. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: tmp.fileSync creates a temporary file synchronously returning name, fd…

sha256:cec058791603add11e4bacc8a622c8e35561e6dfda019b59fc340ffa9c31a330

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
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 pkg:npm/tmp@0.2.7
패키지
생성일
2026-08-28T05:06:31Z

컨트랙트

  1. tmp.fileSync creates a temporary file synchronously returning name, fd, and removeCallback
  2. tmp.dirSync creates a temporary directory synchronously and removeCallback removes it
  3. tmp.file creates a temporary file asynchronously and passes path, fd, and cleanupCallback to the callback
  4. tmp.dir creates a temporary directory asynchronously and passes path and cleanupCallback to the callback
  5. tmp.tmpNameSync generates a unique temporary path matching prefix and postfix options

파일

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

소스 아티팩트 내려받기 (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 pkg:npm/tmp@0.2.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/tmp@0.2.7

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:e567298fe4893cc68dfa3389ba9b6a44eed7b9ce885fb93e0c1de33ce89227c8","contract":["tmp.fileSync creates a temporary file synchronously returning name, fd, and removeCallback","tmp.dirSync creates a temporary directory synchronously and removeCallback removes it","tmp.file creates a temporary file asynchronously and passes path, fd, and cleanupCallback to the callback","tmp.dir creates a temporary directory asynchronously and passes path and cleanupCallback to the callback","tmp.tmpNameSync generates a unique temporary path matching prefix and postfix options"],"goal":"verify pkg:npm/tmp@0.2.7","kind":"HOW","packages":["pkg:npm/tmp@0.2.7"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/tmp@0.2.7"],"schemaVersion":1,"subject":"pkg:npm/tmp@0.2.7","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-tmp",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-tmp",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "tmp": "0.2.7"
      }
    },
    "node_modules/tmp": {
      "version": "0.2.7",
      "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz",
      "integrity": "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==",
      "license": "MIT",
      "engines": {
        "node": ">=14.14"
      }
    }
  }
}
package.json
{
  "name": "sample-tmp",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for tmp",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "tmp": "0.2.7"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/tmp@0.2.7",
  "kind": "HOW",
  "packages": [
    "pkg:npm/tmp@0.2.7"
  ]
}
src/index.js
const tmp = require('tmp');

function createTempFile(options) {
  return tmp.fileSync(options);
}

function createTempDir(options) {
  return tmp.dirSync(options);
}

function generateTempName(options) {
  return tmp.tmpNameSync(options);
}

module.exports = {
  createTempFile,
  createTempDir,
  generateTempName,
  tmp
};
test/contract.js
const assert = require('node:assert');
const fs = require('node:fs');
const path = require('node:path');
const tmp = require('tmp');
const { createTempFile, createTempDir, generateTempName } = require('../src/index.js');

async function runTests() {
  // 1. tmp.fileSync creates a temporary file and returns name, fd, and removeCallback
  const tmpFile = createTempFile({ prefix: 'test-file-', postfix: '.tmp' });
  assert.strictEqual(typeof tmpFile.name, 'string', 'tmpFile.name should be a string');
  assert.strictEqual(typeof tmpFile.fd, 'number', 'tmpFile.fd should be a number');
  assert.strictEqual(typeof tmpFile.removeCallback, 'function', 'tmpFile.removeCallback should be a function');
  assert.strictEqual(fs.existsSync(tmpFile.name), true, 'temporary file should exist on disk');

  fs.writeSync(tmpFile.fd, Buffer.from('test data'));
  tmpFile.removeCallback();
  assert.strictEqual(fs.existsSync(tmpFile.name), false, 'temporary file should be removed after sync cleanup');

  // 2. tmp.dirSync creates a temporary directory and removeCallback removes it
  const tmpDir = createTempDir({ prefix: 'test-dir-', unsafeCleanup: true });
  assert.strictEqual(typeof tmpDir.name, 'string', 'tmpDir.name should be a string');
  assert.strictEqual(typeof tmpDir.removeCallback, 'function', 'tmpDir.removeCallback should be a function');
  assert.strictEqual(fs.existsSync(tmpDir.name), true, 'temporary directory should exist on disk');

  const nestedFile = path.join(tmpDir.name, 'nested.txt');
  fs.writeFileSync(nestedFile, 'nested content');
  assert.strictEqual(fs.existsSync(nestedFile), true, 'nested file should exist in temp dir');

  tmpDir.removeCallback();
  assert.strictEqual(fs.existsSync(tmpDir.name), false, 'temporary directory should be removed after sync cleanup');

  // 3. tmp.file creates a temporary file asynchronously and cleanupCallback removes it
  await new Promise((resolve, reject) => {
    tmp.file({ prefix: 'async-file-', postfix: '.dat' }, (err, filePath, fd, cleanupCallback) => {
      if (err) return reject(err);
      try {
        assert.strictEqual(typeof filePath, 'string', 'filePath should be a string');
        assert.strictEqual(typeof fd, 'number', 'fd should be a number');
        assert.strictEqual(typeof cleanupCallback, 'function', 'cleanupCallback should be a function');
        assert.strictEqual(fs.existsSync(filePath), true, 'async temporary file should exist');

        cleanupCallback((cleanupErr) => {
          if (cleanupErr) return reject(cleanupErr);
          try {
            assert.strictEqual(fs.existsSync(filePath), false, 'async temporary file should be removed after async cleanup');
            resolve();
          } catch (e) {
            reject(e);
          }
        });
      } catch (e) {
        reject(e);
      }
    });
  });

  // 4. tmp.dir creates a temporary directory asynchronously and cleanupCallback removes it
  await new Promise((resolve, reject) => {
    tmp.dir({ prefix: 'async-dir-', unsafeCleanup: true }, (err, dirPath, cleanupCallback) => {
      if (err) return reject(err);
      try {
        assert.strictEqual(typeof dirPath, 'string', 'dirPath should be a string');
        assert.strictEqual(typeof cleanupCallback, 'function', 'cleanupCallback should be a function');
        assert.strictEqual(fs.existsSync(dirPath), true, 'async temporary directory should exist');

        cleanupCallback((cleanupErr) => {
          if (cleanupErr) return reject(cleanupErr);
          try {
            assert.strictEqual(fs.existsSync(dirPath), false, 'async temporary directory should be removed after async cleanup');
            resolve();
          } catch (e) {
            reject(e);
          }
        });
      } catch (e) {
        reject(e);
      }
    });
  });

  // 5. tmp.tmpNameSync generates a unique temporary path matching prefix and postfix options
  const generatedName = generateTempName({ prefix: 'custom-pref-', postfix: '.custom' });
  assert.strictEqual(typeof generatedName, 'string', 'generatedName should be a string');
  assert.strictEqual(path.basename(generatedName).startsWith('custom-pref-'), true, 'name should start with prefix');
  assert.strictEqual(generatedName.endsWith('.custom'), true, 'name should end with postfix');
  assert.strictEqual(fs.existsSync(generatedName), false, 'generated tempName should not exist prior to creation');

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

runTests().catch(err => {
  console.error(err);
  process.exit(1);
});

오리진 시더

익명