CodeSampleX

샘플

adm-zip 0.6.1

검증된 샘플 — npm adm-zip 0.6.1. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: AdmZip creates an in-memory zip archive and adds file entries

sha256:03dd301bd633ef294815fa8e88247ec4d0489bce941cb14df11986713cedc4c2

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

실행 증거

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

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

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-16

케이스

HOW
목표
verify pkg:npm/adm-zip@0.6.1
패키지
환경
node 22.23.2
생성일
2026-09-16T11:04:16Z

컨트랙트

  1. AdmZip creates an in-memory zip archive and adds file entries
  2. readAsText retrieves decompressed file contents as string
  3. getEntry returns entry metadata and getData returns raw decompressed Buffer
  4. nested file entry preserves byte-for-byte binary content
  5. serialize archive to buffer and reload into new AdmZip instance
  6. deleteFile removes an entry from the archive

파일

  • PROMPT.md
  • csx.json
  • index.js
  • 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 pkg:npm/adm-zip@0.6.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/adm-zip@0.6.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.
csx.json
{"case":{"caseId":"case:sha256:db6f5c987450b115cc734dafcd8125568af3d52652fac5b7ba660c3029f15afa","contract":["AdmZip creates an in-memory zip archive and adds file entries","readAsText retrieves decompressed file contents as string","getEntry returns entry metadata and getData returns raw decompressed Buffer","nested file entry preserves byte-for-byte binary content","serialize archive to buffer and reload into new AdmZip instance","deleteFile removes an entry from the archive"],"goal":"verify pkg:npm/adm-zip@0.6.1","kind":"HOW","packages":["pkg:npm/adm-zip@0.6.1"],"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","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/adm-zip@0.6.1"],"schemaVersion":1,"subject":"pkg:npm/adm-zip@0.6.1","verifierAdapter":"node-typescript@1"}
index.js
const AdmZip = require('adm-zip');

/**
 * Creates an in-memory zip archive with initial files.
 * @param {Array<{path: string, content: Buffer|string, comment?: string}>} files
 * @returns {AdmZip}
 */
function createArchive(files = []) {
  const zip = new AdmZip();
  for (const file of files) {
    const data = Buffer.isBuffer(file.content)
      ? file.content
      : Buffer.from(file.content, 'utf8');
    zip.addFile(file.path, data, file.comment || '');
  }
  return zip;
}

/**
 * Reads entry content as text.
 * @param {AdmZip} zip
 * @param {string} entryPath
 * @returns {string}
 */
function readEntryText(zip, entryPath) {
  return zip.readAsText(entryPath);
}

/**
 * Serializes archive to a Buffer and reloads a fresh AdmZip instance.
 * @param {AdmZip} zip
 * @returns {AdmZip}
 */
function reloadArchive(zip) {
  const buffer = zip.toBuffer();
  return new AdmZip(buffer);
}

module.exports = {
  AdmZip,
  createArchive,
  readEntryText,
  reloadArchive
};
package-lock.json
{
  "name": "sample-adm-zip",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-adm-zip",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "adm-zip": "0.6.1"
      }
    },
    "node_modules/adm-zip": {
      "version": "0.6.1",
      "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.6.1.tgz",
      "integrity": "sha512-Xwrja8nx9e5o2N1my4DsKCeKpdrnACyr1wtbPxBDgGzKzKyE9kRtBFA8mWldI+RVlD7CBZNWY/wQ2+ydwOR6kQ==",
      "license": "MIT",
      "engines": {
        "node": ">=14.0"
      }
    }
  }
}
package.json
{
  "name": "sample-adm-zip",
  "version": "1.0.0",
  "description": "Clean-room sample verifying pkg:npm/adm-zip@0.6.1 functionality",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "adm-zip": "0.6.1"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/adm-zip@0.6.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/adm-zip@0.6.1"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import AdmZip from 'adm-zip';
import { createArchive, readEntryText, reloadArchive } from '../index.js';

// 1. AdmZip creates an in-memory zip archive and adds file entries
const testContent = 'Hello CodeSampleX adm-zip verification!';
const binaryData = Buffer.from([0x50, 0x4b, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04]);
const zip = createArchive([
  { path: 'test.txt', content: testContent, comment: 'test comment' },
  { path: 'nested/binary.bin', content: binaryData }
]);

assert.strictEqual(zip.getEntries().length, 2, 'zip should contain 2 entries');

// 2. readAsText retrieves decompressed file contents as string
const text = readEntryText(zip, 'test.txt');
assert.strictEqual(text, testContent, 'readAsText should return exact text content');

// 3. getEntry returns entry metadata and getData returns raw decompressed Buffer
const entry = zip.getEntry('test.txt');
assert.ok(entry, 'entry should exist');
assert.strictEqual(entry.entryName, 'test.txt', 'entryName should match');
assert.strictEqual(entry.comment, 'test comment', 'comment should match');
const buffer = entry.getData();
assert.ok(Buffer.isBuffer(buffer), 'getData should return a Buffer');
assert.strictEqual(buffer.toString('utf8'), testContent, 'buffer content should match testContent');

// 4. nested file entry preserves byte-for-byte binary content
const binEntry = zip.getEntry('nested/binary.bin');
assert.ok(binEntry, 'nested entry should exist');
assert.ok(binEntry.getData().equals(binaryData), 'binary data should be byte-identical');

// 5. serialize archive to buffer and reload into new AdmZip instance
const reloaded = reloadArchive(zip);
assert.strictEqual(reloaded.getEntries().length, 2, 'reloaded zip should contain 2 entries');
assert.strictEqual(reloaded.readAsText('test.txt'), testContent, 'reloaded readAsText should match');
assert.ok(reloaded.getEntry('nested/binary.bin').getData().equals(binaryData), 'reloaded binary data should match');

// 6. deleteFile removes an entry from the archive
reloaded.deleteFile('test.txt');
assert.strictEqual(reloaded.getEntries().length, 1, 'archive should have 1 entry after deletion');
assert.strictEqual(reloaded.getEntry('test.txt'), null, 'deleted entry should be null');

console.log('Contract assertions passed.');

오리진 시더

익명