CodeSampleX

示例

@istanbuljs/schema 0.1.6

已验证示例 — npm @istanbuljs/schema 0.1.6. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: defaults.nyc exposes standard default configuration options…

sha256:3f24ac36ac673344167fce1c2581ed2783f3108731219723687cfbf89c28d84e

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 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-27

案例

HOW
目标
verify pkg:npm/%40istanbuljs/schema@0.1.6
包
环境
node 22.23.2
创建时间
2026-08-27T21:27:49Z

契约

  1. defaults.nyc exposes standard default configuration options including default exclude patterns, supported file extensions, and coverage settings
  2. defaults.testExclude provides default exclusion patterns and supported extensions (.js, .cjs, .mjs, .ts, .tsx, .jsx)
  3. defaults.instrumentVisitor provides default coverage variable names and global scope settings
  4. defaults.instrumenter combines visitor and parser generator defaults including babel parser plugins
  5. schema objects (nyc, testExclude, babelPluginIstanbul, instrumentVisitor, instrumenter) expose json-schema property definitions with types and descriptions
  6. defaults getters dynamically evaluate cwd property from process.cwd() and return isolated array instances

文件

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

下载源代码构件 (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/%40istanbuljs/schema@0.1.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40istanbuljs/schema@0.1.6
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:e72931ac472ac329584fc2723c4ff0389cc27f88f9c55b3ce391ecba10c11b80","constraints":{"executionContext":"node"},"contract":["defaults.nyc exposes standard default configuration options including default exclude patterns, supported file extensions, and coverage settings","defaults.testExclude provides default exclusion patterns and supported extensions (.js, .cjs, .mjs, .ts, .tsx, .jsx)","defaults.instrumentVisitor provides default coverage variable names and global scope settings","defaults.instrumenter combines visitor and parser generator defaults including babel parser plugins","schema objects (nyc, testExclude, babelPluginIstanbul, instrumentVisitor, instrumenter) expose json-schema property definitions with types and descriptions","defaults getters dynamically evaluate cwd property from process.cwd() and return isolated array instances"],"goal":"verify pkg:npm/%40istanbuljs/schema@0.1.6","kind":"HOW","packages":["pkg:npm/%40istanbuljs/schema@0.1.6"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"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/%40istanbuljs/schema@0.1.6"],"schemaVersion":1,"subject":"pkg:npm/%40istanbuljs/schema@0.1.6","verifierAdapter":"node-typescript@1"}
index.js
'use strict';

const schema = require('@istanbuljs/schema');

function getNycDefaults() {
  return schema.defaults.nyc;
}

function getTestExcludeDefaults() {
  return schema.defaults.testExclude;
}

function getInstrumentVisitorDefaults() {
  return schema.defaults.instrumentVisitor;
}

function getInstrumenterDefaults() {
  return schema.defaults.instrumenter;
}

function getSchema(name) {
  return schema[name];
}

module.exports = {
  schema,
  getNycDefaults,
  getTestExcludeDefaults,
  getInstrumentVisitorDefaults,
  getInstrumenterDefaults,
  getSchema
};
package-lock.json
{
  "name": "sample-istanbuljs-schema",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-istanbuljs-schema",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@istanbuljs/schema": "0.1.6"
      }
    },
    "node_modules/@istanbuljs/schema": {
      "version": "0.1.6",
      "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz",
      "integrity": "sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    }
  }
}
package.json
{
  "name": "sample-istanbuljs-schema",
  "version": "1.0.0",
  "private": true,
  "description": "verify pkg:npm/@istanbuljs/schema@0.1.6",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.cjs"
  },
  "dependencies": {
    "@istanbuljs/schema": "0.1.6"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40istanbuljs/schema@0.1.6",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40istanbuljs/schema@0.1.6"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.cjs
'use strict';

const assert = require('assert');
const schema = require('@istanbuljs/schema');
const {
  getNycDefaults,
  getTestExcludeDefaults,
  getInstrumentVisitorDefaults,
  getInstrumenterDefaults,
  getSchema
} = require('../index.js');

async function run() {
  // 1. defaults.nyc exposes standard default configuration options including default exclude patterns, supported file extensions, and coverage settings
  const nycDefaults = getNycDefaults();
  assert(Array.isArray(nycDefaults.exclude), 'defaults.nyc.exclude must be an array');
  assert(nycDefaults.exclude.includes('coverage/**'), 'defaults.nyc.exclude must include coverage/**');
  assert(nycDefaults.exclude.includes('**/*.d.ts'), 'defaults.nyc.exclude must include **/*.d.ts');
  assert(nycDefaults.exclude.includes('test{,s}/**'), 'defaults.nyc.exclude must include test{,s}/**');
  assert(nycDefaults.exclude.includes('**/__tests__/**'), 'defaults.nyc.exclude must include **/__tests__/**');

  assert(Array.isArray(nycDefaults.extension), 'defaults.nyc.extension must be an array');
  assert.deepStrictEqual(
    nycDefaults.extension,
    ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
    'defaults.nyc.extension must match expected list of JavaScript and TypeScript extensions'
  );

  assert.strictEqual(nycDefaults.tempDir, './.nyc_output', 'defaults.nyc.tempDir default must be ./.nyc_output');
  assert.strictEqual(nycDefaults.lines, 90, 'defaults.nyc.lines default must be 90');
  assert(Array.isArray(nycDefaults.reporter) && nycDefaults.reporter.includes('text'), 'defaults.nyc.reporter must default to ["text"]');
  assert.strictEqual(nycDefaults.clean, true, 'defaults.nyc.clean must be true');
  assert.strictEqual(nycDefaults.instrument, true, 'defaults.nyc.instrument must be true');
  assert.strictEqual(nycDefaults.sourceMap, true, 'defaults.nyc.sourceMap must be true');

  // 2. defaults.testExclude provides default exclusion patterns and supported extensions (.js, .cjs, .mjs, .ts, .tsx, .jsx)
  const testExcludeDefaults = getTestExcludeDefaults();
  assert.strictEqual(testExcludeDefaults.excludeNodeModules, true, 'defaults.testExclude.excludeNodeModules must be true');
  assert(Array.isArray(testExcludeDefaults.include) && testExcludeDefaults.include.length === 0, 'defaults.testExclude.include must default to empty array');
  assert.deepStrictEqual(testExcludeDefaults.extension, nycDefaults.extension, 'defaults.testExclude.extension must match standard extensions');
  assert(testExcludeDefaults.exclude.includes('coverage/**'), 'defaults.testExclude.exclude must include default exclude patterns');

  // 3. defaults.instrumentVisitor provides default coverage variable names and global scope settings
  const visitorDefaults = getInstrumentVisitorDefaults();
  assert.strictEqual(visitorDefaults.coverageVariable, '__coverage__', 'defaults.instrumentVisitor.coverageVariable must be __coverage__');
  assert.strictEqual(visitorDefaults.coverageGlobalScope, 'this', 'defaults.instrumentVisitor.coverageGlobalScope must be this');
  assert.strictEqual(visitorDefaults.coverageGlobalScopeFunc, true, 'defaults.instrumentVisitor.coverageGlobalScopeFunc must be true');
  assert(Array.isArray(visitorDefaults.ignoreClassMethods) && visitorDefaults.ignoreClassMethods.length === 0, 'defaults.instrumentVisitor.ignoreClassMethods must default to empty array');

  // 4. defaults.instrumenter combines visitor and parser generator defaults including babel parser plugins
  const instrumenterDefaults = getInstrumenterDefaults();
  assert.strictEqual(instrumenterDefaults.autoWrap, true, 'defaults.instrumenter.autoWrap must be true');
  assert.strictEqual(instrumenterDefaults.esModules, true, 'defaults.instrumenter.esModules must be true');
  assert.strictEqual(instrumenterDefaults.compact, true, 'defaults.instrumenter.compact must be true');
  assert.strictEqual(instrumenterDefaults.preserveComments, true, 'defaults.instrumenter.preserveComments must be true');
  assert.strictEqual(instrumenterDefaults.produceSourceMap, true, 'defaults.instrumenter.produceSourceMap must be true');
  assert(Array.isArray(instrumenterDefaults.parserPlugins), 'defaults.instrumenter.parserPlugins must be an array');
  const expectedPlugins = ['asyncGenerators', 'bigInt', 'classProperties', 'dynamicImport', 'topLevelAwait'];
  for (const plugin of expectedPlugins) {
    assert(instrumenterDefaults.parserPlugins.includes(plugin), `defaults.instrumenter.parserPlugins must include ${plugin}`);
  }

  // 5. schema objects (nyc, testExclude, babelPluginIstanbul, instrumentVisitor, instrumenter) expose json-schema property definitions with types and descriptions
  const schemaNames = ['nyc', 'testExclude', 'babelPluginIstanbul', 'instrumentVisitor', 'instrumenter'];
  for (const name of schemaNames) {
    const s = getSchema(name);
    assert(s, `schema.${name} must exist`);
    assert.strictEqual(s.type, 'object', `schema.${name}.type must be object`);
    assert(typeof s.description === 'string' && s.description.length > 0, `schema.${name}.description must be non-empty`);
    assert(typeof s.properties === 'object', `schema.${name}.properties must be an object`);
  }
  assert.strictEqual(schema.nyc.properties.exclude.type, 'array', 'schema.nyc.properties.exclude.type must be array');
  assert.strictEqual(schema.nyc.properties.exclude.nycAlias, 'x', 'schema.nyc.properties.exclude.nycAlias must be x');
  assert.strictEqual(schema.nyc.properties.tempDir.default, './.nyc_output', 'schema.nyc.properties.tempDir.default must be ./.nyc_output');

  // 6. defaults getters dynamically evaluate cwd property from process.cwd() and return isolated array instances
  assert.strictEqual(nycDefaults.cwd, process.cwd(), 'defaults.nyc.cwd must match current working directory');
  assert.strictEqual(testExcludeDefaults.cwd, process.cwd(), 'defaults.testExclude.cwd must match current working directory');

  const initialExcludeLen = schema.defaults.nyc.exclude.length;
  const copy1 = schema.defaults.nyc;
  copy1.exclude.push('temporary-sentinel-pattern');
  const copy2 = schema.defaults.nyc;
  assert.strictEqual(
    copy2.exclude.length,
    initialExcludeLen,
    'schema.defaults getter must return a fresh copy of array properties'
  );

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

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

原始种子者

匿名