CodeSampleX

샘플

temp-file 3.4.0: temp-file

검증된 샘플 — npm temp-file 3.4.0: temp-file. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: getTempName generates prefixed and unprefixed unique…

sha256:235cfa609edb85ce4b57123a4314bac8003f37f817eecba19e242c90399f16fa

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

케이스

HOW
목표
verify temp-file in pkg:npm/temp-file@3.4.0
패키지
심벌
  • temp-file
환경
node 22.23.2
생성일
2026-08-26T11:09:13Z

컨트랙트

  1. getTempName generates prefixed and unprefixed unique temporary file names
  2. TmpDir.getTempFile constructs temporary file paths with optional prefix and suffix
  3. TmpDir.getTempDir returns temporary directory path and createTempDir creates it on disk
  4. TmpDir.rootTempDir resolves to an existing base temporary directory
  5. TmpDir.cleanup asynchronously removes tracked files and removes base directory when last manager completes
  6. TmpDir.cleanup invokes custom disposer callbacks when multiple managers are active
  7. TmpDir.cleanupSync synchronously removes tracked temporary files and executes disposers
  8. TmpDir.toString returns the configured debug name

파일

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

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

Use EXACTLY these public packages and versions:
  - pkg:npm/temp-file@3.4.0
Demonstrate these symbols/APIs:
  - temp-file
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - 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.
csx.json
{"case":{"caseId":"case:sha256:d122270bcedafed12291f58b60682574eddd9b61e3e12a09ee684504e5d87a2a","constraints":{"executionContext":"node"},"contract":["getTempName generates prefixed and unprefixed unique temporary file names","TmpDir.getTempFile constructs temporary file paths with optional prefix and suffix","TmpDir.getTempDir returns temporary directory path and createTempDir creates it on disk","TmpDir.rootTempDir resolves to an existing base temporary directory","TmpDir.cleanup asynchronously removes tracked files and removes base directory when last manager completes","TmpDir.cleanup invokes custom disposer callbacks when multiple managers are active","TmpDir.cleanupSync synchronously removes tracked temporary files and executes disposers","TmpDir.toString returns the configured debug name"],"goal":"verify temp-file in pkg:npm/temp-file@3.4.0","kind":"HOW","packages":["pkg:npm/temp-file@3.4.0"],"schemaVersion":1,"symbols":["temp-file"]},"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","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/temp-file@3.4.0"],"schemaVersion":1,"subject":"pkg:npm/temp-file@3.4.0","symbols":["temp-file"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-temp-file",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-temp-file",
      "version": "1.0.0",
      "dependencies": {
        "temp-file": "3.4.0"
      }
    },
    "node_modules/async-exit-hook": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/async-exit-hook/-/async-exit-hook-2.0.1.tgz",
      "integrity": "sha512-NW2cX8m1Q7KPA7a5M2ULQeZ2wR5qI5PAbw5L0UOMxdioVk9PMZ0h1TmyZEkPYrCvYjDlFICusOu1dlEKAAeXBw==",
      "license": "MIT",
      "engines": {
        "node": ">=0.12.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/temp-file": {
      "version": "3.4.0",
      "resolved": "https://registry.npmjs.org/temp-file/-/temp-file-3.4.0.tgz",
      "integrity": "sha512-C5tjlC/HCtVUOi3KWVokd4vHVViOmGjtLwIh4MuzPo/nMYTV/p1urt3RnMz2IWXDdKEGJH3k5+KPxtqRsUYGtg==",
      "license": "MIT",
      "dependencies": {
        "async-exit-hook": "^2.0.1",
        "fs-extra": "^10.0.0"
      }
    },
    "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"
      }
    }
  }
}
package.json
{
  "name": "sample-temp-file",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "temp-file": "3.4.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify temp-file in pkg:npm/temp-file@3.4.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/temp-file@3.4.0"
  ],
  "symbols": [
    "temp-file"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { getTempName, TmpDir } from 'temp-file';

// 1. getTempName generates prefixed and unprefixed unique temporary file names
{
  const name1 = getTempName();
  const name2 = getTempName();
  assert.equal(typeof name1, 'string');
  assert.ok(name1.length > 0);
  assert.notEqual(name1, name2);

  const prefixed = getTempName('custom-prefix');
  assert.ok(prefixed.startsWith('custom-prefix-'));

  const nullPrefixed = getTempName(null);
  assert.ok(!nullPrefixed.startsWith('null'));
  assert.ok(!nullPrefixed.startsWith('-'));

  const undefinedPrefixed = getTempName(undefined);
  assert.ok(!undefinedPrefixed.startsWith('undefined'));
  assert.ok(!undefinedPrefixed.startsWith('-'));
}

// 2. TmpDir.getTempFile constructs temporary file paths with optional prefix and suffix
{
  const tmpDir = new TmpDir('file-test');
  const filePath1 = await tmpDir.getTempFile({ prefix: 'myprefix', suffix: 'txt' });
  const filename1 = path.basename(filePath1);
  assert.ok(filename1.startsWith('myprefix-'));
  assert.ok(filename1.endsWith('-txt'));

  const filePath2 = await tmpDir.getTempFile({ suffix: '.json' });
  const filename2 = path.basename(filePath2);
  assert.ok(filename2.endsWith('.json'));
  assert.ok(!filename2.endsWith('-.json'));

  const filePath3 = await tmpDir.getTempFile();
  assert.ok(path.isAbsolute(filePath3));
  assert.notEqual(filePath1, filePath3);

  await tmpDir.cleanup();
}

// 3. TmpDir.getTempDir returns temporary directory path and createTempDir creates it on disk
{
  const tmpDir = new TmpDir('dir-test');
  const dirPath = await tmpDir.getTempDir({ prefix: 'planned-dir' });
  assert.equal(fs.existsSync(dirPath), false);

  const createdDirPath = await tmpDir.createTempDir({ prefix: 'created-dir' });
  assert.equal(fs.existsSync(createdDirPath), true);
  assert.equal(fs.statSync(createdDirPath).isDirectory(), true);

  await tmpDir.cleanup();
  assert.equal(fs.existsSync(createdDirPath), false);
}

// 4. TmpDir.rootTempDir resolves to an existing base temporary directory
{
  const tmpDir = new TmpDir('root-test');
  const rootDir = await tmpDir.rootTempDir;
  assert.ok(typeof rootDir === 'string');
  assert.ok(rootDir.length > 0);
  assert.ok(path.isAbsolute(rootDir));

  const tmpDir2 = new TmpDir('root-test-2');
  const rootDir2 = await tmpDir2.rootTempDir;
  assert.equal(rootDir, rootDir2);

  await tmpDir.cleanup();
  await tmpDir2.cleanup();
}

// 5. TmpDir.cleanup asynchronously removes tracked files and removes base directory when last manager completes
{
  const activeManager = new TmpDir('active-keeper');
  await activeManager.getTempFile();

  const tmpDir = new TmpDir('cleanup-test');
  const testFile = await tmpDir.getTempFile({ suffix: '.txt' });
  fs.writeFileSync(testFile, 'hello world', 'utf8');
  assert.equal(fs.existsSync(testFile), true);

  const testSubDir = await tmpDir.createTempDir({ prefix: 'nested' });
  const nestedFile = path.join(testSubDir, 'child.txt');
  fs.writeFileSync(nestedFile, 'nested data', 'utf8');
  assert.equal(fs.existsSync(nestedFile), true);

  await tmpDir.cleanup();
  assert.equal(fs.existsSync(testFile), false);
  assert.equal(fs.existsSync(testSubDir), false);

  await activeManager.cleanup();
}

// 6. TmpDir.cleanup invokes custom disposer callbacks when multiple managers are active
{
  const activeManager = new TmpDir('keeper');
  await activeManager.getTempFile();

  const tmpDir = new TmpDir('disposer-test');
  let disposedPath = null;
  const customFile = await tmpDir.getTempFile({
    disposer: async (file) => {
      disposedPath = file;
      if (fs.existsSync(file)) {
        fs.unlinkSync(file);
      }
    },
  });
  fs.writeFileSync(customFile, 'custom dispose content', 'utf8');

  await tmpDir.cleanup();
  assert.equal(disposedPath, customFile);
  assert.equal(fs.existsSync(customFile), false);

  await activeManager.cleanup();
}

// 7. TmpDir.cleanupSync synchronously removes tracked temporary files and executes disposers
{
  const tmpDir = new TmpDir('sync-test');
  let syncDisposed = null;
  const syncFile = await tmpDir.getTempFile({
    suffix: '.sync',
    disposer: async (file) => {
      syncDisposed = file;
      if (fs.existsSync(file)) {
        fs.unlinkSync(file);
      }
    },
  });
  fs.writeFileSync(syncFile, 'sync content', 'utf8');
  assert.equal(fs.existsSync(syncFile), true);

  const syncDir = await tmpDir.createTempDir({ prefix: 'sync-dir' });
  assert.equal(fs.existsSync(syncDir), true);

  tmpDir.cleanupSync();
  assert.equal(syncDisposed, syncFile);
  assert.equal(fs.existsSync(syncFile), false);
  assert.equal(fs.existsSync(syncDir), false);
}

// 8. TmpDir.toString returns the configured debug name
{
  const named = new TmpDir('custom-debug-label');
  assert.equal(named.toString(), 'custom-debug-label');

  const defaultNamed = new TmpDir();
  assert.equal(defaultNamed.toString(), '');
}

오리진 시더

익명