CodeSampleX

Exemple

env-paths 3.0.0

Échantillon vérifié pour npm env-paths 3.0.0. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : Calling envPaths returns…

sha256:798b06939f794d41048167c25627713219fa9434b6d8870a803b14f97ec0a5a4

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
2
Clés de signature qui l’ont compilé
1
Environnement déclaré linux 24 · ubuntu · glibc 2.39 x64 npm

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-23
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

Cas

HOW
Objectif
verify pkg:npm/env-paths@3.0.0
Paquets
Créé
2026-08-23T08:26:42Z

Contrat

  1. Calling envPaths returns standard XDG paths on Linux including data, config, cache, log, and temp directories
  2. Calling envPaths with default options appends the '-nodejs' suffix to the application directory name
  3. Setting suffix option to false disables the suffix and uses the bare application name
  4. Setting suffix option to a custom string appends the custom suffix to the application directory name
  5. Passing a non-string name argument throws a TypeError

Fichiers

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Télécharger l’artefact source (tar.gz)

Code source

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/env-paths@3.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/env-paths@3.0.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:b26e1813e0887c1a843662debd9ad9c29c28fcbfbec759a38bf26ecdb9f7b1a2","contract":["Calling envPaths returns standard XDG paths on Linux including data, config, cache, log, and temp directories","Calling envPaths with default options appends the '-nodejs' suffix to the application directory name","Setting suffix option to false disables the suffix and uses the bare application name","Setting suffix option to a custom string appends the custom suffix to the application directory name","Passing a non-string name argument throws a TypeError"],"goal":"verify pkg:npm/env-paths@3.0.0","kind":"HOW","packages":["pkg:npm/env-paths@3.0.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/env-paths@3.0.0"],"schemaVersion":1,"subject":"pkg:npm/env-paths@3.0.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-env-paths",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-env-paths",
      "version": "1.0.0",
      "dependencies": {
        "env-paths": "3.0.0"
      }
    },
    "node_modules/env-paths": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-3.0.0.tgz",
      "integrity": "sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==",
      "license": "MIT",
      "engines": {
        "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    }
  }
}
package.json
{
  "name": "sample-env-paths",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "env-paths": "3.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/env-paths@3.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/env-paths@3.0.0"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import os from 'node:os';
import path from 'node:path';
import process from 'node:process';
import envPaths from 'env-paths';

// 1. envPaths returns an object containing data, config, cache, log, and temp directory paths
{
	const paths = envPaths('myapp', { suffix: false });
	assert.equal(typeof paths, 'object');
	assert.ok(typeof paths.data === 'string' && paths.data.length > 0);
	assert.ok(typeof paths.config === 'string' && paths.config.length > 0);
	assert.ok(typeof paths.cache === 'string' && paths.cache.length > 0);
	assert.ok(typeof paths.log === 'string' && paths.log.length > 0);
	assert.ok(typeof paths.temp === 'string' && paths.temp.length > 0);

	const homedir = os.homedir();
	const expectedData = process.env.XDG_DATA_HOME || path.join(homedir, '.local', 'share');
	const expectedConfig = process.env.XDG_CONFIG_HOME || path.join(homedir, '.config');
	const expectedCache = process.env.XDG_CACHE_HOME || path.join(homedir, '.cache');
	const expectedLog = process.env.XDG_STATE_HOME || path.join(homedir, '.local', 'state');

	assert.equal(paths.data, path.join(expectedData, 'myapp'));
	assert.equal(paths.config, path.join(expectedConfig, 'myapp'));
	assert.equal(paths.cache, path.join(expectedCache, 'myapp'));
	assert.equal(paths.log, path.join(expectedLog, 'myapp'));
}

// 2. envPaths defaults to appending '-nodejs' suffix to the provided application name
{
	const paths = envPaths('myapp');
	assert.ok(paths.data.endsWith('myapp-nodejs'));
	assert.ok(paths.config.endsWith('myapp-nodejs'));
	assert.ok(paths.cache.endsWith('myapp-nodejs'));
	assert.ok(paths.log.endsWith('myapp-nodejs'));
	assert.ok(paths.temp.endsWith('myapp-nodejs'));
}

// 3. envPaths with suffix option set to false disables suffixing and keeps the original application name
{
	const paths = envPaths('myapp', { suffix: false });
	assert.ok(paths.data.endsWith(path.sep + 'myapp'));
	assert.ok(!paths.data.endsWith('myapp-nodejs'));
}

// 4. envPaths with custom suffix option appends the custom suffix string to the application name
{
	const paths = envPaths('myapp', { suffix: 'server' });
	assert.ok(paths.data.endsWith('myapp-server'));
}

// 5. envPaths validates argument type and throws TypeError when name is not a string
{
	assert.throws(
		() => {
			envPaths(12345);
		},
		{
			name: 'TypeError',
			message: 'Expected a string, got number',
		}
	);
}

Seeder d'origine

anonyme