샘플
import-local 3.2.0: importLocal
검증된 샘플 — npm import-local 3.2.0: importLocal. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: importLocal is exported as a function that checks…
sha256:5e86ad77451266da99a77f1114ae0225a3406647ba9d9dd57101847849fbd38c
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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/import-local@3.2.0
- 심벌
-
- importLocal
- 생성일
- 2026-08-27T15:41:52Z
컨트랙트
- importLocal is exported as a function that checks for a locally installed version of a package
- importLocal returns falsy when called on a file with no corresponding local installation in the current working directory
- importLocal accepts file:// URLs and file paths to package entry points
- importLocal imports and returns the local package module when a matching package exists in the current working directory's node_modules
- importLocal returns false when invoked from within the local node_modules directory to prevent recursive imports
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
소스
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/import-local@3.2.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/import-local@3.2.0
Demonstrate these symbols/APIs:
- importLocal
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:db00048acace335bf663bb2ea6636a2c893de02a8fc27c37364a63bfdfbaab1e","contract":["importLocal is exported as a function that checks for a locally installed version of a package","importLocal returns falsy when called on a file with no corresponding local installation in the current working directory","importLocal accepts file:// URLs and file paths to package entry points","importLocal imports and returns the local package module when a matching package exists in the current working directory's node_modules","importLocal returns false when invoked from within the local node_modules directory to prevent recursive imports"],"goal":"verify pkg:npm/import-local@3.2.0","kind":"HOW","packages":["pkg:npm/import-local@3.2.0"],"schemaVersion":1,"symbols":["importLocal"]},"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/import-local@3.2.0"],"schemaVersion":1,"subject":"pkg:npm/import-local@3.2.0","symbols":["importLocal"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-import-local",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-import-local",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"import-local": "3.2.0"
}
},
"node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"license": "MIT",
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/import-local": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz",
"integrity": "sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==",
"license": "MIT",
"dependencies": {
"pkg-dir": "^4.2.0",
"resolve-cwd": "^3.0.0"
},
"bin": {
"import-local-fixture": "fixtures/cli.js"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"license": "MIT",
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"license": "MIT",
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"license": "MIT",
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/pkg-dir": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
"integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==",
"license": "MIT",
"dependencies": {
"find-up": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/resolve-cwd": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz",
"integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==",
"license": "MIT",
"dependencies": {
"resolve-from": "^5.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/resolve-from": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
"integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"license": "MIT",
"engines": {
"node": ">=8"
}
}
}
}
{
"name": "sample-import-local",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for import-local",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"import-local": "3.2.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/import-local@3.2.0",
"kind": "HOW",
"packages": [
"pkg:npm/import-local@3.2.0"
],
"symbols": [
"importLocal"
]
}
const importLocal = require('import-local');
function tryImportLocal(filePath) {
return importLocal(filePath);
}
module.exports = {
importLocal,
tryImportLocal
};
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const importLocal = require('import-local');
const { tryImportLocal } = require('../src/index.js');
// 1. Symbol and function contract
assert.strictEqual(typeof importLocal, 'function', 'importLocal is exported as a callable function');
assert.strictEqual(typeof tryImportLocal, 'function', 'tryImportLocal helper wraps importLocal');
// 2. Returns falsy when no local duplicate exists in the working directory
const notLocalResult = importLocal(import.meta.url);
assert.strictEqual(!notLocalResult, true, 'importLocal returns falsy when local duplicate is not found in cwd');
// 3. Supports file:// URLs
const urlResult = tryImportLocal(import.meta.url);
assert.strictEqual(!urlResult, true, 'importLocal accepts file:// URLs and processes them without throwing');
// 4. Resolves and requires local package when called from outside local node_modules
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'csx-import-local-contract-'));
try {
// Global simulation
const globalPkgDir = path.join(tempDir, 'global-env', 'node_modules', 'contract-fixture-cli');
fs.mkdirSync(path.join(globalPkgDir, 'bin'), { recursive: true });
fs.writeFileSync(path.join(globalPkgDir, 'package.json'), JSON.stringify({
name: 'contract-fixture-cli',
version: '1.0.0',
bin: { 'contract-fixture-cli': 'bin/cli.js' }
}));
const globalCliFile = path.join(globalPkgDir, 'bin', 'cli.js');
fs.writeFileSync(globalCliFile, 'module.exports = { isLocal: false, version: "1.0.0" };');
// Local project simulation with local installation of contract-fixture-cli
const localProjectDir = path.join(tempDir, 'project-dir');
const localPkgDir = path.join(localProjectDir, 'node_modules', 'contract-fixture-cli');
fs.mkdirSync(path.join(localPkgDir, 'bin'), { recursive: true });
fs.writeFileSync(path.join(localPkgDir, 'package.json'), JSON.stringify({
name: 'contract-fixture-cli',
version: '2.5.0',
bin: { 'contract-fixture-cli': 'bin/cli.js' }
}));
const localCliFile = path.join(localPkgDir, 'bin', 'cli.js');
fs.writeFileSync(localCliFile, 'module.exports = { isLocal: true, version: "2.5.0", loaded: true };');
const previousCwd = process.cwd();
try {
process.chdir(localProjectDir);
// Call importLocal from global binary path
const resolvedLocal = importLocal(globalCliFile);
assert.ok(resolvedLocal, 'importLocal imports the local module when available in cwd node_modules');
assert.strictEqual(resolvedLocal.isLocal, true, 'imported module is the local version');
assert.strictEqual(resolvedLocal.version, '2.5.0', 'imported module matches local version 2.5.0');
assert.strictEqual(resolvedLocal.loaded, true, 'local module exports are returned');
// Call importLocal via file:// URL
const resolvedLocalFromUrl = importLocal(pathToFileURL(globalCliFile).href);
assert.ok(resolvedLocalFromUrl, 'importLocal resolves correctly when given file:// URL');
assert.strictEqual(resolvedLocalFromUrl.version, '2.5.0', 'version matches local module');
// Call importLocal from inside the local node_modules file itself (should not re-import)
const selfImportResult = importLocal(localCliFile);
assert.strictEqual(selfImportResult, false, 'importLocal returns false when the file is already inside local node_modules');
// Call importLocal in empty project directory
const emptyDir = path.join(tempDir, 'empty-dir');
fs.mkdirSync(emptyDir, { recursive: true });
process.chdir(emptyDir);
const emptyResult = importLocal(globalCliFile);
assert.strictEqual(!emptyResult, true, 'importLocal returns falsy when local package is absent');
} finally {
process.chdir(previousCwd);
}
} finally {
fs.rmSync(tempDir, { recursive: true, force: true });
}
console.log('Contract tests passed successfully.');
오리진 시더
익명