Пример
glob 13.0.7
Проверенный пример — npm glob 13.0.7. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден: glob and globSync match nested files using wildcard…
sha256:02ad439a737ae414b00ce2a7dd59bd44588dbfdce65e0f74397520a4ee8e6126
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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-11-21 |
Кейс
HOW- Цель
- verify pkg:npm/glob@13.0.7
- Пакеты
- Окружение
- node 22.23.2
- Создан
- 2026-11-21T17:00:35Z
Контракт
- glob and globSync match nested files using wildcard, globstar, and array patterns
- globSync filters matches with ignore patterns, custom IgnoreLike objects, nodir, dot, maxDepth, dotRelative, and includeChildMatches: false
- glob with withFileTypes: true returns Path objects with isFile and isDirectory, and throws when combined with absolute: true
- Glob requires an options object (throwing TypeError when omitted), supports walk, walkSync, sync/async iteration, and shares its scurry cache when passed as options to another Glob
- globIterate, globIterateSync, globStream, and globStreamSync yield the same matches as glob and globSync
- hasMagic detects wildcard characters, treats brace sets as non-magic by default, and treats them as magic when magicalBraces: true
- escape and unescape round-trip special pattern characters so globSync matches literal bracketed filenames
- passing an aborted AbortSignal via signal causes glob to reject and globSync to throw with the abort reason
Файлы
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Исходный код
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/glob@13.0.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/glob@13.0.7
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:3d2b99a2f1965a51fe0a80f01dc9af4660be95b09b62560f0c195632123207cf","constraints":{"executionContext":"node"},"contract":["glob and globSync match nested files using wildcard, globstar, and array patterns","globSync filters matches with ignore patterns, custom IgnoreLike objects, nodir, dot, maxDepth, dotRelative, and includeChildMatches: false","glob with withFileTypes: true returns Path objects with isFile and isDirectory, and throws when combined with absolute: true","Glob requires an options object (throwing TypeError when omitted), supports walk, walkSync, sync/async iteration, and shares its scurry cache when passed as options to another Glob","globIterate, globIterateSync, globStream, and globStreamSync yield the same matches as glob and globSync","hasMagic detects wildcard characters, treats brace sets as non-magic by default, and treats them as magic when magicalBraces: true","escape and unescape round-trip special pattern characters so globSync matches literal bracketed filenames","passing an aborted AbortSignal via signal causes glob to reject and globSync to throw with the abort reason"],"goal":"verify pkg:npm/glob@13.0.7","kind":"HOW","packages":["pkg:npm/glob@13.0.7"],"schemaVersion":1},"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/glob@13.0.7"],"schemaVersion":1,"subject":"pkg:npm/glob@13.0.7","verifierAdapter":"node-typescript@1"}
{
"name": "glob-verify-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "glob-verify-sample",
"version": "1.0.0",
"dependencies": {
"glob": "13.0.7"
}
},
"node_modules/balanced-match": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
"integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
"license": "MIT",
"engines": {
"node": "18 || 20 || >=22"
}
},
"node_modules/brace-expansion": {
"version": "5.0.13",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz",
"integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==",
"license": "MIT",
"dependencies": {
"balanced-match": "^4.0.2"
},
"engines": {
"node": "20 || >=22"
}
},
"node_modules/glob": {
"version": "13.0.7",
"resolved": "https://registry.npmjs.org/glob/-/glob-13.0.7.tgz",
"integrity": "sha512-wfsFgXQ8A3SEI9XGf7Nl3Y9l7ffSrGh7SUCT7vU/2CzYPep9kjxAn1S40F9OPKxAMGCVl7HtNlJhrCJUeUq83g==",
"license": "BlueOak-1.0.0",
"dependencies": {
"minimatch": "^10.2.2",
"minipass": "^7.1.3",
"path-scurry": "^2.0.2"
},
"engines": {
"node": "18 || 20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/lru-cache": {
"version": "11.5.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz",
"integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==",
"license": "BlueOak-1.0.0",
"engines": {
"node": "20 || >=22"
}
},
"node_modules/minimatch": {
"version": "10.2.6",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
"integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
"license": "BlueOak-1.0.0",
"dependencies": {
"brace-expansion": "^5.0.8"
},
"engines": {
"node": "18 || 20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"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/path-scurry": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz",
"integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==",
"license": "BlueOak-1.0.0",
"dependencies": {
"lru-cache": "^11.0.0",
"minipass": "^7.1.2"
},
"engines": {
"node": "18 || 20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
}
}
}
{
"name": "glob-verify-sample",
"version": "1.0.0",
"private": true,
"description": "Verify pkg:npm/glob@13.0.7 behavior in Node.js (CommonJS)",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"glob": "13.0.7"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/glob@13.0.7",
"kind": "HOW",
"packages": [
"pkg:npm/glob@13.0.7"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
'use strict';
const {
glob,
globSync,
globStream,
globStreamSync,
globIterate,
globIterateSync,
Glob,
hasMagic,
escape,
unescape,
} = require('glob');
async function collectStream(stream) {
const items = [];
for await (const entry of stream) {
items.push(entry);
}
return items;
}
function collectStreamSync(stream) {
const items = [];
stream.on('data', (entry) => items.push(entry));
stream.read();
return items;
}
function findMatchingFiles(pattern, options) {
return glob(pattern, options);
}
function findMatchingFilesSync(pattern, options) {
return globSync(pattern, options);
}
module.exports = {
glob,
globSync,
globStream,
globStreamSync,
globIterate,
globIterateSync,
Glob,
hasMagic,
escape,
unescape,
collectStream,
collectStreamSync,
findMatchingFiles,
findMatchingFilesSync,
};
'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const {
glob,
globSync,
globStream,
globStreamSync,
globIterate,
globIterateSync,
Glob,
hasMagic,
escape,
unescape,
collectStream,
collectStreamSync,
findMatchingFiles,
findMatchingFilesSync,
} = require('../src/index.js');
function sort(list) {
return [...list].sort();
}
function createFixtureTree() {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'glob-13-sample-'));
const dirs = [
'src',
'src/nested',
'src/nested/deep',
'docs',
'ignored-dir',
'pkg',
'pkg/node_modules',
'pkg/node_modules/sub',
'pkg/node_modules/sub/node_modules',
];
for (const dir of dirs) {
fs.mkdirSync(path.join(root, dir), { recursive: true });
}
const files = [
'README.md',
'.hidden',
'src/app.js',
'src/util.ts',
'src/nested/helper.js',
'src/nested/deep/leaf.js',
'docs/guide.md',
'ignored-dir/skip.js',
'src/literal[1].txt',
'pkg/node_modules/a.js',
'pkg/node_modules/sub/node_modules/b.js',
];
for (const file of files) {
fs.writeFileSync(path.join(root, file), 'fixture\n', 'utf8');
}
return root;
}
async function run() {
const root = createFixtureTree();
try {
// 1. Async glob and sync globSync with wildcard, globstar, and array patterns
const asyncJs = await findMatchingFiles('src/**/*.js', { cwd: root, posix: true });
const syncJs = findMatchingFilesSync('src/**/*.js', { cwd: root, posix: true });
const expectedSrcJs = [
'src/app.js',
'src/nested/deep/leaf.js',
'src/nested/helper.js',
];
assert.deepEqual(sort(asyncJs), expectedSrcJs);
assert.deepEqual(sort(syncJs), expectedSrcJs);
const multiPattern = await glob(['*.md', 'docs/*.md'], { cwd: root, posix: true });
assert.deepEqual(sort(multiPattern), ['README.md', 'docs/guide.md']);
// 2. Filtering options: ignore (string/array & custom IgnoreLike), nodir, dot, maxDepth, dotRelative, includeChildMatches
const withIgnorePattern = globSync('**/*.js', {
cwd: root,
posix: true,
ignore: ['ignored-dir/**', 'pkg/**'],
});
assert.deepEqual(sort(withIgnorePattern), expectedSrcJs);
const withCustomIgnore = globSync('**/*', {
cwd: root,
posix: true,
nodir: true,
ignore: {
ignored: (p) => p.name.endsWith('.md') || p.name.endsWith('.txt'),
childrenIgnored: (p) => p.name === 'ignored-dir' || p.name === 'pkg',
},
});
assert.deepEqual(sort(withCustomIgnore), [
'src/app.js',
'src/nested/deep/leaf.js',
'src/nested/helper.js',
'src/util.ts',
]);
const withoutDot = globSync('*', { cwd: root, nodir: true });
assert.deepEqual(sort(withoutDot), ['README.md']);
const withDot = globSync('*', { cwd: root, nodir: true, dot: true });
assert.deepEqual(sort(withDot), ['.hidden', 'README.md']);
const depthLimited = globSync('src/**/*.js', {
cwd: root,
posix: true,
maxDepth: 2,
});
assert.deepEqual(sort(depthLimited), ['src/app.js']);
const dotRel = globSync('src/*.js', {
cwd: root,
posix: true,
dotRelative: true,
});
assert.deepEqual(sort(dotRel), ['./src/app.js']);
const topNodeModulesOnly = globSync('**/node_modules', {
cwd: root,
posix: true,
includeChildMatches: false,
});
assert.deepEqual(sort(topNodeModulesOnly), ['pkg/node_modules']);
// 3. withFileTypes returns Path objects and conflicts with absolute: true
const pathEntries = await glob('src/*', {
cwd: root,
withFileTypes: true,
});
const byName = new Map(pathEntries.map((entry) => [entry.name, entry]));
assert.equal(byName.get('app.js').isFile(), true);
assert.equal(byName.get('app.js').isDirectory(), false);
assert.equal(byName.get('nested').isDirectory(), true);
assert.equal(byName.get('nested').isFile(), false);
assert.throws(
() => globSync('src/*', { cwd: root, withFileTypes: true, absolute: true }),
/cannot set absolute and withFileTypes/i
);
// 4. Glob class: options required, walk/walkSync, iterators, streams, cache reuse
assert.throws(() => new Glob('src/**/*.js'), TypeError);
const g1 = new Glob('src/**/*.js', { cwd: root, posix: true });
assert.deepEqual(sort(await g1.walk()), expectedSrcJs);
assert.deepEqual(sort(g1.walkSync()), expectedSrcJs);
const g1AsyncIter = [];
for await (const entry of g1) {
g1AsyncIter.push(entry);
}
assert.deepEqual(sort(g1AsyncIter), expectedSrcJs);
const g1SyncIter = [...g1];
assert.deepEqual(sort(g1SyncIter), expectedSrcJs);
// Passing existing Glob instance as options shares its scurry cache and settings
const g2 = new Glob('src/*.ts', g1);
assert.equal(g2.scurry, g1.scurry);
assert.deepEqual(sort(g2.walkSync()), ['src/util.ts']);
// 5. globIterate, globIterateSync, globStream, globStreamSync
const iterAsync = [];
for await (const entry of globIterate('src/**/*.js', { cwd: root, posix: true })) {
iterAsync.push(entry);
}
assert.deepEqual(sort(iterAsync), expectedSrcJs);
const iterSync = [...globIterateSync('src/**/*.js', { cwd: root, posix: true })];
assert.deepEqual(sort(iterSync), expectedSrcJs);
const streamedAsync = await collectStream(
globStream('src/**/*.js', { cwd: root, posix: true })
);
assert.deepEqual(sort(streamedAsync), expectedSrcJs);
const streamedSync = collectStreamSync(
globStreamSync('src/**/*.js', { cwd: root, posix: true })
);
assert.deepEqual(sort(streamedSync), expectedSrcJs);
// 6. hasMagic with and without magicalBraces
assert.equal(hasMagic('src/*.js'), true);
assert.equal(hasMagic('src/app.js'), false);
assert.equal(hasMagic('src/{app,util}.js'), false);
assert.equal(hasMagic('src/{app,util}.js', { magicalBraces: true }), true);
// 7. escape and unescape for literal special characters
const literalPath = 'src/literal[1].txt';
const escaped = escape(literalPath);
assert.equal(hasMagic(escaped), false);
assert.equal(unescape(escaped), literalPath);
assert.deepEqual(
globSync(escaped, { cwd: root, posix: true }),
[literalPath]
);
// Unescaped character class [1] matches literal1.txt, not literal[1].txt
assert.deepEqual(
globSync(literalPath, { cwd: root, posix: true }),
[]
);
// 8. AbortSignal cancellation
const abortReason = new Error('walk aborted');
const abortedSignal = AbortSignal.abort(abortReason);
await assert.rejects(
() => glob('**/*.js', { cwd: root, signal: abortedSignal }),
(err) => err === abortReason
);
assert.throws(
() => globSync('**/*.js', { cwd: root, signal: abortedSignal }),
(err) => err === abortReason
);
console.log('ALL CONTRACT ASSERTIONS PASSED');
} finally {
fs.rmSync(root, { recursive: true, force: true });
}
}
run().catch((err) => {
console.error(err);
process.exit(1);
});
Исходный сидер
аноним