CodeSampleX

Пример

node-abi 3.96.0

Проверенный пример — npm node-abi 3.96.0. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден: _getNextTarget is exported as a function from…

sha256:19fb4fd89ff0dec6a26d29ee71156ec0ab2821c511b396fbe7837a73adaed68e

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда linux 24 · ubuntu · glibc 2.39 x64 npm

Среды запусков проверки

Окружение Контракт Этапы Запуск
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-07

Кейс

HOW
Цель
verify pkg:npm/node-abi@3.96.0
Пакеты
Создан
2026-09-07T02:44:19Z

Контракт

  1. _getNextTarget is exported as a function from node-abi
  2. _getNextTarget calculates the next major release target for node runtime
  3. _getNextTarget calculates the next release target for electron runtime
  4. _getNextTarget calculates the next major release target for node-webkit runtime
  5. _getNextTarget accepts a custom targets array to determine the next version
  6. _getNextTarget increments minor version for non-prerelease electron target
  7. _getNextTarget double bumps major version when latest electron target is prerelease
  8. futureTargets exports pre-release registry targets
  9. additionalTargets exports node-webkit registry targets

Файлы

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • 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/node-abi@3.96.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/node-abi@3.96.0

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:e892795d8b64f45f2847e1f9fccdb93635b0d664c97d907baa63d1ff1d266df6","contract":["_getNextTarget is exported as a function from node-abi","_getNextTarget calculates the next major release target for node runtime","_getNextTarget calculates the next release target for electron runtime","_getNextTarget calculates the next major release target for node-webkit runtime","_getNextTarget accepts a custom targets array to determine the next version","_getNextTarget increments minor version for non-prerelease electron target","_getNextTarget double bumps major version when latest electron target is prerelease","futureTargets exports pre-release registry targets","additionalTargets exports node-webkit registry targets"],"goal":"verify pkg:npm/node-abi@3.96.0","kind":"HOW","packages":["pkg:npm/node-abi@3.96.0"],"schemaVersion":1},"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/node-abi@3.96.0"],"schemaVersion":1,"subject":"pkg:npm/node-abi@3.96.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-node-abi-next-target",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-node-abi-next-target",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "node-abi": "3.96.0"
      }
    },
    "node_modules/node-abi": {
      "version": "3.96.0",
      "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.96.0.tgz",
      "integrity": "sha512-rebQ/lz7i0EkoLzUVSrKRzA69zMkwLp95kKMWoMDkkM00Suxz0D7zEQPwRml5fQum24mj7bPvmlgLAmu2JCiYg==",
      "license": "MIT",
      "dependencies": {
        "semver": "^7.3.5"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/semver": {
      "version": "7.8.5",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
      "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver.js"
      },
      "engines": {
        "node": ">=10"
      }
    }
  }
}
package.json
{
  "name": "sample-node-abi-next-target",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for node-abi next target calculation in node-abi@3.96.0",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "node-abi": "3.96.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/node-abi@3.96.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/node-abi@3.96.0"
  ]
}
src/index.js
const nodeAbi = require('node-abi');

/**
 * Calculates the next expected release target for a given runtime.
 *
 * @param {string} runtime - Target runtime ('node', 'electron', etc.).
 * @param {Array<{runtime: string, target: string}>} [targets] - Optional target list.
 * @returns {string} The next target version string.
 */
function getNextTarget(runtime, targets) {
  return nodeAbi._getNextTarget(runtime, targets);
}

/**
 * Returns all future target definitions.
 *
 * @returns {Array<{runtime: string, target: string, abi: string, lts: boolean}>}
 */
function getFutureTargets() {
  return nodeAbi.futureTargets;
}

/**
 * Returns all additional target definitions (such as node-webkit).
 *
 * @returns {Array<{runtime: string, target: string, abi: string, lts: boolean}>}
 */
function getAdditionalTargets() {
  return nodeAbi.additionalTargets;
}

module.exports = {
  nodeAbi,
  getNextTarget,
  getFutureTargets,
  getAdditionalTargets,
  _getNextTarget: nodeAbi._getNextTarget,
  futureTargets: nodeAbi.futureTargets,
  additionalTargets: nodeAbi.additionalTargets
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  nodeAbi,
  getNextTarget,
  getFutureTargets,
  getAdditionalTargets,
  _getNextTarget,
  futureTargets,
  additionalTargets
} = require('../src/index.js');

async function runTests() {
  // 1. _getNextTarget is exported as a function from node-abi
  assert.equal(typeof nodeAbi._getNextTarget, 'function', 'nodeAbi._getNextTarget must be a function');
  assert.equal(typeof _getNextTarget, 'function', '_getNextTarget must be a function');
  assert.equal(typeof getNextTarget, 'function', 'getNextTarget wrapper must be a function');

  // 2. _getNextTarget calculates the next major release target for node runtime
  const nextNode = getNextTarget('node');
  assert.equal(typeof nextNode, 'string', 'nextNode must be a version string');
  assert.equal(nextNode, '27.0.0', 'node next target should bump the latest node target to 27.0.0');

  // 3. _getNextTarget calculates the next release target for electron runtime
  const nextElectron = getNextTarget('electron');
  assert.equal(typeof nextElectron, 'string', 'nextElectron must be a version string');
  assert.equal(nextElectron, '46.0.0', 'electron next target should bump 45.0.0-alpha.1 to 46.0.0');

  // 4. _getNextTarget calculates the next major release target for node-webkit runtime
  const nextNw = getNextTarget('node-webkit');
  assert.equal(typeof nextNw, 'string', 'nextNw must be a version string');
  assert.equal(nextNw, '1.0.0', 'node-webkit next target should bump 0.26.5 to 1.0.0');

  // 5. _getNextTarget accepts a custom targets array to determine the next version
  const customNodeTargets = [
    { runtime: 'node', target: '18.0.0' },
    { runtime: 'node', target: '20.0.0' }
  ];
  assert.equal(getNextTarget('node', customNodeTargets), '21.0.0', 'custom node targets should increment major version');

  // 6. _getNextTarget increments minor version for non-prerelease electron target
  const nonPrereleaseElectronTargets = [
    { runtime: 'electron', target: '22.0.0' }
  ];
  assert.equal(getNextTarget('electron', nonPrereleaseElectronTargets), '22.1.0', 'non-prerelease electron target should increment minor version');

  // 7. _getNextTarget double bumps major version when latest electron target is prerelease
  const prereleaseElectronTargets = [
    { runtime: 'electron', target: '22.0.0-beta.1' }
  ];
  assert.equal(getNextTarget('electron', prereleaseElectronTargets), '23.0.0', 'prerelease electron target should double bump major');

  // 8. futureTargets exports pre-release registry targets
  const futures = getFutureTargets();
  assert.ok(Array.isArray(futures), 'futureTargets must be an array');
  assert.ok(futures.length > 0, 'futureTargets must contain entries');
  for (const entry of futures) {
    assert.equal(typeof entry.runtime, 'string', 'runtime must be a string');
    assert.equal(typeof entry.target, 'string', 'target must be a string');
    assert.equal(typeof entry.abi, 'string', 'abi must be a string');
    assert.equal(typeof entry.lts, 'boolean', 'lts must be a boolean');
  }

  // 9. additionalTargets exports node-webkit registry targets
  const additionals = getAdditionalTargets();
  assert.ok(Array.isArray(additionals), 'additionalTargets must be an array');
  assert.ok(additionals.length > 0, 'additionalTargets must contain entries');
  for (const entry of additionals) {
    assert.equal(entry.runtime, 'node-webkit', 'all additionalTargets should be node-webkit');
    assert.equal(typeof entry.target, 'string', 'target must be a string');
    assert.equal(typeof entry.abi, 'string', 'abi must be a string');
  }

  console.log('All contract assertions for node-abi _getNextTarget passed.');
}

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

Исходный сидер

аноним