CodeSampleX

샘플

node-abi 3.96.0: additionalTargets

검증된 샘플 — npm node-abi 3.96.0: additionalTargets. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: additionalTargets is exported as an array from…

sha256:d637f3ec40c08ccc2f31e50d52d044acfbbd8a1c8ac1edca24657573a647d7c3

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

컨트랙트

  1. additionalTargets is exported as an array from node-abi containing node-webkit runtime targets
  2. each target entry in additionalTargets has runtime, target, abi strings and lts set to false
  3. every target in additionalTargets is present in allTargets
  4. additionalTargets is disjoint from supportedTargets and deprecatedTargets
  5. getAbi resolves node-webkit target versions to their corresponding abi strings
  6. getTarget resolves node-webkit abi strings to their corresponding target versions
  7. getAbi and getTarget throw error when queried with unsupported node-webkit target or abi
  8. isAdditionalTarget identifies whether a given runtime and target version is in additionalTargets
  9. findAdditionalTarget looks up node-webkit target records by target version or abi string

파일

  • 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 node-abi.additionalTargets in pkg:npm/node-abi@3.96.0
Kind: HOW

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

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:9a4e5ea15e391f54eac8a2aeeb8f0d304940ad15499338bb61b52a17bfb9059c","contract":["additionalTargets is exported as an array from node-abi containing node-webkit runtime targets","each target entry in additionalTargets has runtime, target, abi strings and lts set to false","every target in additionalTargets is present in allTargets","additionalTargets is disjoint from supportedTargets and deprecatedTargets","getAbi resolves node-webkit target versions to their corresponding abi strings","getTarget resolves node-webkit abi strings to their corresponding target versions","getAbi and getTarget throw error when queried with unsupported node-webkit target or abi","isAdditionalTarget identifies whether a given runtime and target version is in additionalTargets","findAdditionalTarget looks up node-webkit target records by target version or abi string"],"goal":"verify node-abi.additionalTargets in pkg:npm/node-abi@3.96.0","kind":"HOW","packages":["pkg:npm/node-abi@3.96.0"],"schemaVersion":1,"symbols":["additionalTargets"]},"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","symbols":["additionalTargets"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-node-abi-additional-targets",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-node-abi-additional-targets",
      "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-additional-targets",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for node-abi.additionalTargets 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 node-abi.additionalTargets in pkg:npm/node-abi@3.96.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/node-abi@3.96.0"
  ],
  "symbols": [
    "additionalTargets"
  ]
}
src/index.js
const nodeAbi = require('node-abi');

/**
 * Checks whether a given target version string and runtime is in additionalTargets.
 *
 * @param {string} target - Target version string (e.g. '0.13.0').
 * @param {string} [runtime='node-webkit'] - Target runtime (defaults to 'node-webkit').
 * @returns {boolean} True if in additionalTargets, false otherwise.
 */
function isAdditionalTarget(target, runtime = 'node-webkit') {
  const normalized = String(target).replace(/^v/, '');
  return nodeAbi.additionalTargets.some(
    (t) => t.runtime === runtime && t.target === normalized
  );
}

/**
 * Finds a target record in additionalTargets by version string or abi number.
 *
 * @param {string} versionOrAbi - Target version string or ABI number string.
 * @param {string} [runtime='node-webkit'] - Target runtime.
 * @returns {object|undefined} The matched target record, or undefined.
 */
function findAdditionalTarget(versionOrAbi, runtime = 'node-webkit') {
  const normalized = String(versionOrAbi).replace(/^v/, '');
  return nodeAbi.additionalTargets.find(
    (t) => t.runtime === runtime && (t.target === normalized || t.abi === normalized)
  );
}

/**
 * Resolves the ABI string for a node-webkit target version.
 *
 * @param {string} target - Target version string (e.g. '0.13.0').
 * @param {string} [runtime='node-webkit'] - Target runtime.
 * @returns {string} The ABI version string.
 */
function resolveAdditionalAbi(target, runtime = 'node-webkit') {
  return nodeAbi.getAbi(target, runtime);
}

/**
 * Resolves the target version for a node-webkit ABI string.
 *
 * @param {string} abi - ABI number string (e.g. '47').
 * @param {string} [runtime='node-webkit'] - Target runtime.
 * @returns {string} The target version string.
 */
function resolveAdditionalTarget(abi, runtime = 'node-webkit') {
  return nodeAbi.getTarget(abi, runtime);
}

module.exports = {
  nodeAbi,
  additionalTargets: nodeAbi.additionalTargets,
  allTargets: nodeAbi.allTargets,
  supportedTargets: nodeAbi.supportedTargets,
  deprecatedTargets: nodeAbi.deprecatedTargets,
  getAbi: nodeAbi.getAbi,
  getTarget: nodeAbi.getTarget,
  isAdditionalTarget,
  findAdditionalTarget,
  resolveAdditionalAbi,
  resolveAdditionalTarget
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  nodeAbi,
  additionalTargets,
  allTargets,
  supportedTargets,
  deprecatedTargets,
  getAbi,
  getTarget,
  isAdditionalTarget,
  findAdditionalTarget,
  resolveAdditionalAbi,
  resolveAdditionalTarget
} = require('../src/index.js');

async function runTests() {
  // 1. additionalTargets is exported as an array from node-abi containing node-webkit runtime targets
  assert.ok(Array.isArray(additionalTargets), 'additionalTargets must be an array');
  assert.ok(additionalTargets.length > 0, 'additionalTargets must not be empty');
  assert.equal(additionalTargets, nodeAbi.additionalTargets, 'exported additionalTargets must match node-abi');

  // 2. each target entry in additionalTargets has runtime, target, abi strings and lts set to false
  for (const entry of additionalTargets) {
    assert.equal(typeof entry.runtime, 'string', 'entry runtime must be a string');
    assert.equal(typeof entry.target, 'string', 'entry target must be a string');
    assert.equal(typeof entry.abi, 'string', 'entry abi must be a string');
    assert.equal(typeof entry.lts, 'boolean', 'entry lts must be boolean');
    assert.equal(entry.runtime, 'node-webkit', 'entry runtime must be node-webkit');
    assert.equal(entry.lts, false, 'entry lts must be false');
  }

  // 3. every target in additionalTargets is present in allTargets
  assert.ok(Array.isArray(allTargets), 'allTargets must be an array');
  for (const entry of additionalTargets) {
    assert.ok(allTargets.includes(entry), `allTargets must include additional target ${entry.target}`);
  }

  // 4. additionalTargets is disjoint from supportedTargets and deprecatedTargets
  assert.ok(Array.isArray(supportedTargets), 'supportedTargets must be an array');
  assert.ok(Array.isArray(deprecatedTargets), 'deprecatedTargets must be an array');
  for (const entry of additionalTargets) {
    assert.ok(!supportedTargets.includes(entry), `supportedTargets must not include additional target ${entry.target}`);
    assert.ok(!deprecatedTargets.includes(entry), `deprecatedTargets must not include additional target ${entry.target}`);
  }

  // 5. getAbi resolves node-webkit target versions to their corresponding abi strings
  assert.equal(resolveAdditionalAbi('0.13.0'), '47', '0.13.0 should resolve to abi 47');
  assert.equal(resolveAdditionalAbi('0.15.0'), '48', '0.15.0 should resolve to abi 48');
  assert.equal(resolveAdditionalAbi('0.18.3'), '51', '0.18.3 should resolve to abi 51');
  assert.equal(resolveAdditionalAbi('0.23.0'), '57', '0.23.0 should resolve to abi 57');
  assert.equal(resolveAdditionalAbi('0.26.5'), '59', '0.26.5 should resolve to abi 59');
  assert.equal(getAbi('0.13.0', 'node-webkit'), '47', 'getAbi direct call should match');

  // 6. getTarget resolves node-webkit abi strings to their corresponding target versions
  assert.equal(resolveAdditionalTarget('47'), '0.13.0', 'abi 47 should resolve to target 0.13.0');
  assert.equal(resolveAdditionalTarget('48'), '0.15.0', 'abi 48 should resolve to target 0.15.0');
  assert.equal(resolveAdditionalTarget('51'), '0.18.3', 'abi 51 should resolve to target 0.18.3');
  assert.equal(resolveAdditionalTarget('57'), '0.23.0', 'abi 57 should resolve to target 0.23.0');
  assert.equal(resolveAdditionalTarget('59'), '0.26.5', 'abi 59 should resolve to target 0.26.5');
  assert.equal(getTarget('47', 'node-webkit'), '0.13.0', 'getTarget direct call should match');

  // 7. getAbi and getTarget throw error when queried with unsupported node-webkit target or abi
  assert.throws(
    () => resolveAdditionalAbi('999.0.0'),
    /Could not detect abi for version 999\.0\.0 and runtime node-webkit/,
    'getAbi should throw on unsupported node-webkit version'
  );
  assert.throws(
    () => resolveAdditionalTarget('99999'),
    /Could not detect target for abi 99999 and runtime node-webkit/,
    'getTarget should throw on unsupported node-webkit abi'
  );

  // 8. isAdditionalTarget identifies whether a given runtime and target version is in additionalTargets
  assert.equal(isAdditionalTarget('0.13.0'), true, '0.13.0 should be an additional target');
  assert.equal(isAdditionalTarget('v0.13.0'), true, 'v0.13.0 should be an additional target');
  assert.equal(isAdditionalTarget('0.26.5'), true, '0.26.5 should be an additional target');
  assert.equal(isAdditionalTarget('99.0.0'), false, '99.0.0 should not be an additional target');
  assert.equal(isAdditionalTarget('0.13.0', 'node'), false, '0.13.0 node runtime should not be an additional target');

  // 9. findAdditionalTarget looks up node-webkit target records by target version or abi string
  const byTarget = findAdditionalTarget('0.13.0');
  assert.ok(byTarget, 'findAdditionalTarget should find entry by target');
  assert.equal(byTarget.abi, '47');
  assert.equal(byTarget.runtime, 'node-webkit');

  const byAbi = findAdditionalTarget('47');
  assert.ok(byAbi, 'findAdditionalTarget should find entry by abi');
  assert.equal(byAbi.target, '0.13.0');

  const notFound = findAdditionalTarget('unknown');
  assert.equal(notFound, undefined, 'findAdditionalTarget should return undefined when not found');

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

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

오리진 시더

익명