Exemple
node-gyp 12.4.0
Échantillon vérifié pour npm node-gyp 12.4.0. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : node-gyp factory returns a Gyp…
sha256:c6a41b06d6bb23726b59b03ae718c14c5c2cb0b56c873773019a9951a31babec
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-28 |
Cas
HOW- Objectif
- verify pkg:npm/node-gyp@12.4.0
- Paquets
- Environnement
- node 22.23.2
- Créé
- 2026-08-28T05:44:07Z
Contrat
- node-gyp factory returns a Gyp instance inheriting from EventEmitter with version 12.4.0 and package metadata
- Gyp exposes command map for build, clean, configure, rebuild, install, list, and remove, and alias mappings for ls and rm
- Gyp.prototype.parseArgv parses command line options, flags, and command sequences into opts and todo objects
- Gyp.prototype.parseArgv maps command aliases and processes npm configuration environment variables
- Gyp.prototype.usage returns formatted CLI usage information containing command descriptions and version info
- findNodeDirectory resolves the root Node.js installation directory based on script location and runtime process
- parseConfigGypi parses GYP configuration strings with comments and quotes into structured JSON data
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Code source
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-gyp@12.4.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/node-gyp@12.4.0
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.
{"case":{"caseId":"case:sha256:2ab1befda83fb623f7e76664bf381e8546a944b90a14730ee265f91c5e75930d","constraints":{"executionContext":"node"},"contract":["node-gyp factory returns a Gyp instance inheriting from EventEmitter with version 12.4.0 and package metadata","Gyp exposes command map for build, clean, configure, rebuild, install, list, and remove, and alias mappings for ls and rm","Gyp.prototype.parseArgv parses command line options, flags, and command sequences into opts and todo objects","Gyp.prototype.parseArgv maps command aliases and processes npm configuration environment variables","Gyp.prototype.usage returns formatted CLI usage information containing command descriptions and version info","findNodeDirectory resolves the root Node.js installation directory based on script location and runtime process","parseConfigGypi parses GYP configuration strings with comments and quotes into structured JSON data"],"goal":"verify pkg:npm/node-gyp@12.4.0","kind":"HOW","packages":["pkg:npm/node-gyp@12.4.0"],"schemaVersion":1,"symbols":["Gyp","Gyp.prototype.parseArgv","Gyp.prototype.usage","findNodeDirectory","parseConfigGypi"]},"contractCommand":["node","test/contract.js"],"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/node-gyp@12.4.0"],"schemaVersion":1,"subject":"pkg:npm/node-gyp@12.4.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-node-gyp",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-node-gyp",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"node-gyp": "12.4.0"
}
},
"node_modules/@isaacs/fs-minipass": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz",
"integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==",
"license": "ISC",
"dependencies": {
"minipass": "^7.0.4"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/abbrev": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-4.0.0.tgz",
"integrity": "sha512-a1wflyaL0tHtJSmLSOVybYhy22vRih4eduhhrkcjgrWGnRfrZtovJ2FRjxuTtkkj47O/baf0R86QU5OuYpz8fA==",
"license": "ISC",
"engines": {
"node": "^20.17.0 || >=22.9.0"
}
},
"node_modules/chownr": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
"integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==",
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=18"
}
},
"node_modules/env-paths": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
"integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/exponential-backoff": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.3.tgz",
"integrity": "sha512-ZgEeZXj30q+I0EN+CbSSpIyPaJ5HVQD18Z1m+u1FXbAeT94mr1zw50q4q6jiiC447Nl/YTcIYSAftiGqetwXCA==",
"license": "Apache-2.0"
},
"node_modules/fdir": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
"license": "MIT",
"engines": {
"node": ">=12.0.0"
},
"peerDependencies": {
"picomatch": "^3 || ^4"
},
"peerDependenciesMeta": {
"picomatch": {
"optional": true
}
}
},
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"license": "ISC"
},
"node_modules/isexe": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-4.0.0.tgz",
"integrity": "sha512-FFUtZMpoZ8RqHS3XeXEmHWLA4thH+ZxCv2lOiPIn1Xc7CxrqhWzNSDzD+/chS/zbYezmiwWLdQC09JdQKmthOw==",
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=20"
}
},
"node_modules/minipass": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz",
"integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==",
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=16 || 14 >=14.17"
}
},
"node_modules/minizlib": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz",
"integrity": "sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==",
"license": "MIT",
"dependencies": {
"minipass": "^7.1.2"
},
"engines": {
"node": ">= 18"
}
},
"node_modules/node-gyp": {
"version": "12.4.0",
"resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-12.4.0.tgz",
"integrity": "sha512-OMcPNvqTCFUnNaBlmdgq+lfNqY7gTiSmNRDjY3uAXRyudeKZEZxu3CLtjMQrx4zZxCX2b/mpNqTtwuCJgXhHkw==",
"license": "MIT",
"dependencies": {
"env-paths": "^2.2.0",
"exponential-backoff": "^3.1.1",
"graceful-fs": "^4.2.6",
"nopt": "^9.0.0",
"proc-log": "^6.0.0",
"semver": "^7.3.5",
"tar": "^7.5.4",
"tinyglobby": "^0.2.12",
"undici": "^6.25.0",
"which": "^6.0.0"
},
"bin": {
"node-gyp": "bin/node-gyp.js"
},
"engines": {
"node": "^20.17.0 || >=22.9.0"
}
},
"node_modules/nopt": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-9.0.0.tgz",
"integrity": "sha512-Zhq3a+yFKrYwSBluL4H9XP3m3y5uvQkB/09CwDruCiRmR/UJYnn9W4R48ry0uGC70aeTPKLynBtscP9efFFcPw==",
"license": "ISC",
"dependencies": {
"abbrev": "^4.0.0"
},
"bin": {
"nopt": "bin/nopt.js"
},
"engines": {
"node": "^20.17.0 || >=22.9.0"
}
},
"node_modules/picomatch": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",
"integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/proc-log": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/proc-log/-/proc-log-6.1.0.tgz",
"integrity": "sha512-iG+GYldRf2BQ0UDUAd6JQ/RwzaQy6mXmsk/IzlYyal4A4SNFw54MeH4/tLkF4I5WoWG9SQwuqWzS99jaFQHBuQ==",
"license": "ISC",
"engines": {
"node": "^20.17.0 || >=22.9.0"
}
},
"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"
}
},
"node_modules/tar": {
"version": "7.5.22",
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.22.tgz",
"integrity": "sha512-MFO/QzvtAOmJbkhOaCTvbGcFN9L9b+JunIsDwaKljSOdcLMea3NJ1k9Usz/rjdfSXTq4dfzfeS7W4p4YOAAHeA==",
"license": "BlueOak-1.0.0",
"dependencies": {
"@isaacs/fs-minipass": "^4.0.0",
"chownr": "^3.0.0",
"minipass": "^7.1.2",
"minizlib": "^3.1.0",
"yallist": "^5.0.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/tinyglobby": {
"version": "0.2.17",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
"integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
"license": "MIT",
"dependencies": {
"fdir": "^6.5.0",
"picomatch": "^4.0.4"
},
"engines": {
"node": ">=12.0.0"
},
"funding": {
"url": "https://github.com/sponsors/SuperchupuDev"
}
},
"node_modules/undici": {
"version": "6.28.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.28.0.tgz",
"integrity": "sha512-LIY910g9TI13YS95lrMFrs8Rm/u/irgHeTWoKCoteeJ04CUJ92eEfj0rVn+7VKMPBpUPiUoBKfhNyLI23EE/KA==",
"license": "MIT",
"engines": {
"node": ">=18.17"
}
},
"node_modules/which": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/which/-/which-6.0.1.tgz",
"integrity": "sha512-oGLe46MIrCRqX7ytPUf66EAYvdeMIZYn3WaocqqKZAxrBpkqHfL/qvTyJ/bTk5+AqHCjXmrv3CEWgy368zhRUg==",
"license": "ISC",
"dependencies": {
"isexe": "^4.0.0"
},
"bin": {
"node-which": "bin/which.js"
},
"engines": {
"node": "^20.17.0 || >=22.9.0"
}
},
"node_modules/yallist": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz",
"integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==",
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=18"
}
}
}
}
{
"name": "sample-node-gyp",
"version": "1.0.0",
"description": "verify pkg:npm/node-gyp@12.4.0",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"node-gyp": "12.4.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/node-gyp@12.4.0",
"kind": "HOW",
"packages": [
"pkg:npm/node-gyp@12.4.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
'use strict';
const gyp = require('node-gyp');
const findNodeDirectory = require('node-gyp/lib/find-node-directory');
const { createConfigGypi, parseConfigGypi, getCurrentConfigGypi } = require('node-gyp/lib/create-config-gypi');
/**
* Creates a new Gyp instance.
*
* @returns {object} A new Gyp instance.
*/
function createGyp() {
return gyp();
}
/**
* Parses command-line arguments using node-gyp parser.
*
* @param {Array<string>} argv - The command-line argument list.
* @returns {object} The configured Gyp instance with parsed opts and todo commands.
*/
function parseGypArgv(argv) {
const inst = gyp();
inst.parseArgv(argv);
return inst;
}
/**
* Resolves the Node.js root directory.
*
* @param {string} [scriptLocation] - Optional script location path.
* @param {object} [processObj] - Optional process object.
* @returns {string} The resolved root directory.
*/
function getNodeDirectory(scriptLocation, processObj) {
return findNodeDirectory(scriptLocation, processObj);
}
/**
* Parses a config.gypi configuration string into a JavaScript object.
*
* @param {string} configContent - GYP config string content.
* @returns {object} The parsed configuration object.
*/
function parseGypi(configContent) {
return parseConfigGypi(configContent);
}
module.exports = {
gyp,
Gyp: gyp.Gyp,
createGyp,
parseGypArgv,
getNodeDirectory,
parseGypi,
createConfigGypi,
parseConfigGypi,
getCurrentConfigGypi,
findNodeDirectory
};
'use strict';
const assert = require('assert');
const { EventEmitter } = require('events');
const {
gyp,
Gyp,
createGyp,
parseGypArgv,
getNodeDirectory,
parseGypi,
findNodeDirectory,
parseConfigGypi
} = require('../src/index');
// 1. Export verification and instance types
{
assert.strictEqual(typeof gyp, 'function');
assert.strictEqual(typeof Gyp, 'function');
assert.strictEqual(typeof createGyp, 'function');
assert.strictEqual(typeof parseGypArgv, 'function');
assert.strictEqual(typeof getNodeDirectory, 'function');
assert.strictEqual(typeof parseGypi, 'function');
const inst = createGyp();
assert.strictEqual(inst instanceof Gyp, true);
assert.strictEqual(inst instanceof EventEmitter, true);
assert.strictEqual(inst.version, '12.4.0');
assert.strictEqual(inst.package.name, 'node-gyp');
assert.strictEqual(inst.package.version, '12.4.0');
}
// 2. Command map and alias mappings
{
const inst = createGyp();
const requiredCommands = ['build', 'clean', 'configure', 'rebuild', 'install', 'list', 'remove'];
for (const cmd of requiredCommands) {
assert.strictEqual(typeof inst.commands[cmd], 'function');
}
assert.deepStrictEqual(inst.aliases, {
ls: 'list',
rm: 'remove'
});
}
// 3. Command-line argument and option parsing
{
const argv = ['node', 'node-gyp', 'configure', 'build', '--debug', '--jobs=8', '--arch=x64'];
const inst = parseGypArgv(argv);
assert.strictEqual(inst.opts.debug, true);
assert.strictEqual(inst.opts.jobs, '8');
assert.strictEqual(inst.opts.arch, 'x64');
assert.deepStrictEqual(inst.todo, [
{ name: 'configure', args: [] },
{ name: 'build', args: [] }
]);
}
// 4. Command alias expansion and npm config integration
{
const inst = createGyp();
inst.parseArgv(['node', 'node-gyp', 'ls', 'rm']);
assert.deepStrictEqual(inst.todo, [
{ name: 'list', args: [] },
{ name: 'remove', args: [] }
]);
}
// 5. Usage instruction generation
{
const inst = createGyp();
const usageText = inst.usage();
assert.strictEqual(typeof usageText, 'string');
assert.strictEqual(usageText.includes('Usage: node-gyp <command> [options]'), true);
assert.strictEqual(usageText.includes('node-gyp@12.4.0'), true);
assert.strictEqual(usageText.includes('build'), true);
assert.strictEqual(usageText.includes('configure'), true);
assert.strictEqual(usageText.includes('clean'), true);
}
// 6. Node directory discovery
{
const mockScriptLocation = '/test/deps/npm/node_modules/node-gyp/lib';
const mockProcess = { platform: 'linux', execPath: '/test/bin/node' };
const nodeDir = getNodeDirectory(mockScriptLocation, mockProcess);
assert.strictEqual(nodeDir, '/test');
const execNodeDir = findNodeDirectory('/unknown/path', { platform: 'linux', execPath: '/usr/local/bin/node' });
assert.strictEqual(execNodeDir, '/usr/local');
}
// 7. GYP configuration string parsing and defaults calculation
{
const rawConfigGypi = `
# Comment line to be stripped
{
'target_defaults': {
'default_configuration': 'Debug'
},
'variables': {
'target_arch': 'x64',
'custom_flag': 'value'
}
}
`;
const parsed = parseGypi(rawConfigGypi);
assert.strictEqual(parsed.target_defaults.default_configuration, 'Debug');
assert.strictEqual(parsed.variables.target_arch, 'x64');
assert.strictEqual(parsed.variables.custom_flag, 'value');
}
console.log('All node-gyp contract assertions passed successfully.');
Seeder d'origine
anonyme