CodeSampleX

Ejemplo

promzard 2.0.0: Promzard

Muestra verificada para npm promzard 2.0.0: Promzard. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó: promzard default export equals…

sha256:ee11454aac20b817182cfce2d0f51e91914cee4d89b81d9cbe3060db87826e5e

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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-10-21

Caso

HOW
Objetivo
verify Promzard in pkg:npm/promzard@2.0.0
Paquetes
Símbolos
  • Promzard
Creado
2026-10-21T02:55:55Z

Contrato

  1. promzard default export equals PromZard.promzard and exposes PromZard and fromBuffer
  2. promzard.fromBuffer(buf, ctx) evaluates a module template buffer with injected context, nested objects, callback functions (cb(null, val)), and zero-arg async functions
  3. promzard(file, ctx) and new PromZard(file, ctx).load() load and evaluate a CommonJS template file with injected __basename and context variables
  4. new PromZard(missingFile, ctx, { backupFile }).load() falls back to backupFile when the primary file cannot be read

Archivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/fixtures/backup-config.cjs
  • src/fixtures/primary-config.cjs
  • src/index.mjs
  • test/contract.mjs

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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 Promzard in pkg:npm/promzard@2.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/promzard@2.0.0
Demonstrate these symbols/APIs:
  - Promzard

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:ed50887f73741d8f2d192b474f0ed69d7711260b299cccc7bdb9cbeddbd25077","contract":["promzard default export equals PromZard.promzard and exposes PromZard and fromBuffer","promzard.fromBuffer(buf, ctx) evaluates a module template buffer with injected context, nested objects, callback functions (cb(null, val)), and zero-arg async functions","promzard(file, ctx) and new PromZard(file, ctx).load() load and evaluate a CommonJS template file with injected __basename and context variables","new PromZard(missingFile, ctx, { backupFile }).load() falls back to backupFile when the primary file cannot be read"],"goal":"verify Promzard in pkg:npm/promzard@2.0.0","kind":"HOW","packages":["pkg:npm/promzard@2.0.0"],"schemaVersion":1,"symbols":["Promzard"]},"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/promzard@2.0.0"],"schemaVersion":1,"subject":"pkg:npm/promzard@2.0.0","symbols":["Promzard"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "verify-promzard",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "verify-promzard",
      "version": "1.0.0",
      "dependencies": {
        "promzard": "2.0.0"
      }
    },
    "node_modules/mute-stream": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-2.0.0.tgz",
      "integrity": "sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==",
      "license": "ISC",
      "engines": {
        "node": "^18.17.0 || >=20.5.0"
      }
    },
    "node_modules/promzard": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/promzard/-/promzard-2.0.0.tgz",
      "integrity": "sha512-Ncd0vyS2eXGOjchIRg6PVCYKetJYrW1BSbbIo+bKdig61TB6nH2RQNF2uP+qMpsI73L/jURLWojcw8JNIKZ3gg==",
      "license": "ISC",
      "dependencies": {
        "read": "^4.0.0"
      },
      "engines": {
        "node": "^18.17.0 || >=20.5.0"
      }
    },
    "node_modules/read": {
      "version": "4.1.0",
      "resolved": "https://registry.npmjs.org/read/-/read-4.1.0.tgz",
      "integrity": "sha512-uRfX6K+f+R8OOrYScaM3ixPY4erg69f8DN6pgTvMcA9iRc8iDhwrA4m3Yu8YYKsXJgVvum+m8PkRboZwwuLzYA==",
      "license": "ISC",
      "dependencies": {
        "mute-stream": "^2.0.0"
      },
      "engines": {
        "node": "^18.17.0 || >=20.5.0"
      }
    }
  }
}
package.json
{
  "name": "verify-promzard",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "promzard": "2.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify Promzard in pkg:npm/promzard@2.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/promzard@2.0.0"
  ],
  "symbols": [
    "Promzard"
  ]
}
src/fixtures/backup-config.cjs
module.exports = {
  source: 'backup',
  basename: __basename,
  asyncValue: async function () {
    return 'from-backup:' + (typeof prefix === 'string' ? prefix : 'none')
  }
}
src/fixtures/primary-config.cjs
module.exports = {
  source: 'primary',
  basename: __basename,
  computed: function (cb) {
    cb(null, 'from-primary:' + (typeof prefix === 'string' ? prefix : 'none'))
  }
}
src/index.mjs
import promzard from 'promzard'
import { fileURLToPath } from 'node:url'
import { dirname, join } from 'node:path'

const __dirname = dirname(fileURLToPath(import.meta.url))

export const Promzard = promzard.PromZard

export async function evaluateBuffer(source, context = {}) {
  const buf = Buffer.isBuffer(source) ? source : Buffer.from(source, 'utf8')
  return promzard.fromBuffer(buf, { ...context })
}

export async function evaluateFileWithBackup(primaryPath, backupPath, context = {}) {
  const pz = new Promzard(primaryPath, { ...context }, { backupFile: backupPath })
  return pz.load()
}

export function getFixturePaths() {
  return {
    primary: join(__dirname, 'fixtures', 'primary-config.cjs'),
    missing: join(__dirname, 'fixtures', 'missing-config.cjs'),
    backup: join(__dirname, 'fixtures', 'backup-config.cjs')
  }
}
test/contract.mjs
import assert from 'node:assert/strict'
import promzard from 'promzard'
import { Promzard, evaluateBuffer, evaluateFileWithBackup, getFixturePaths } from '../src/index.mjs'

// 1. Verify default export is PromZard.promzard and static helpers exist
assert.equal(typeof promzard, 'function')
assert.equal(typeof promzard.fromBuffer, 'function')
assert.equal(typeof promzard.PromZard, 'function')
assert.equal(Promzard, promzard.PromZard)
assert.equal(promzard, Promzard.promzard)

// 2. Verify fromBuffer evaluates template buffer with context, nested objects, callback & async functions
const bufferResult = await evaluateBuffer(
  `
  module.exports = {
    appName: appName,
    nested: {
      port: function (cb) {
        cb(null, basePort + 80)
      },
      tag: async function () {
        return this.appName + '-v1'
      }
    }
  }
  `,
  { appName: 'demo-service', basePort: 8000 }
)

assert.deepEqual(bufferResult, {
  appName: 'demo-service',
  nested: {
    port: 8080,
    tag: 'demo-service-v1'
  }
})

// 3. Verify Promzard loads an existing primary file directly via promzard(file, ctx) and new PromZard(file, ctx).load()
const fixtures = getFixturePaths()
const primaryResult = await promzard(fixtures.primary, { prefix: 'ok' })
assert.deepEqual(primaryResult, {
  source: 'primary',
  basename: 'primary-config.cjs',
  computed: 'from-primary:ok'
})

const instanceResult = await new Promzard(fixtures.primary, { prefix: 'inst' }).load()
assert.deepEqual(instanceResult, {
  source: 'primary',
  basename: 'primary-config.cjs',
  computed: 'from-primary:inst'
})

// 4. Verify Promzard falls back to options.backupFile when the primary file does not exist
const backupResult = await evaluateFileWithBackup(fixtures.missing, fixtures.backup, { prefix: 'fallback' })
assert.deepEqual(backupResult, {
  source: 'backup',
  basename: 'backup-config.cjs',
  asyncValue: 'from-backup:fallback'
})

Seeder de origen

anónimo