build: NPM-упаковка @baseline-harness/bhl (BHL-028)
- tsc → dist/ (prepare при pack); bin dist/cli.js — Node запрещает type-stripping в node_modules; rewriteRelativeImportExtensions - files: dist+src+доки; engines >=22.19; private:true — публикация только по отдельному поручению (D-034); publishConfig.access public - тест pack: pack → установка tarball → bhl version (пакет 42/42) - dist/ в .gitignore
This commit is contained in:
@@ -43,4 +43,8 @@ npm run bhl -- version
|
||||
|
||||
Runtime-зависимости: `ajv` (JSON Schema 2020-12) и `yaml`. LLM-клиента, сети, сервера и БД у CLI нет; офлайн-работа после загрузки версий спецификации — требование BHL-021. Схемы спецификации живут в [spec/schemas](../../spec/schemas/) лаборатории; их версионирование — D-039.
|
||||
|
||||
## Упаковка и публикация
|
||||
|
||||
Пакет `@baseline-harness/bhl` (scope свободен в npm — перепроверено 2026-11-28), исполняемое имя `bhl`, `engines.node >= 22.19.0`. Публикуемый артефакт собирается `npm run build` (TypeScript → `dist/`, выполняется как `prepare` при `npm pack`); `bin` указывает на `dist/cli.js` — Node запрещает type-stripping внутри `node_modules`, поэтому в tarball идут готовые JS-модули. Локальная проверка артефакта: `npm pack` → `npm install <tarball> --prefix <временный каталог>` → `bhl version` (тест `tests/pack.test.mjs`). Публикация в реестр не выполнена: пакет `private`, публикация — по отдельному поручению владельца (D-034).
|
||||
|
||||
Профиль качества и границы принятия — в [QUALITY.md](QUALITY.md).
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"description": "Детерминированный CLI Baseline Harness Standard: валидация, разрешение профилей, аудит",
|
||||
"license": "UNLICENSED",
|
||||
"bin": {
|
||||
"bhl": "./src/cli.ts"
|
||||
"bhl": "./dist/cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.19.0"
|
||||
@@ -19,7 +19,9 @@
|
||||
"typecheck": "tsc --project tsconfig.json",
|
||||
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.{ts,mjs}\" eslint.config.mjs tsconfig.json .prettierrc.json",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.{ts,mjs}\" eslint.config.mjs tsconfig.json .prettierrc.json",
|
||||
"quality": "npm run check && npm test"
|
||||
"quality": "npm run check && npm test",
|
||||
"build": "tsc -p tsconfig.build.json",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"ajv": "8.20.0",
|
||||
@@ -36,5 +38,14 @@
|
||||
"prettier": "3.6.2",
|
||||
"typescript": "5.9.3",
|
||||
"typescript-eslint": "8.65.0"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"README.md",
|
||||
"QUALITY.md"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { runAudit, writeAuditReport } from './audit.ts';
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { mkdtempSync, readdirSync, rmSync } from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
const pkgRoot = path.join(import.meta.dirname, '..');
|
||||
|
||||
test('pack: tarball устанавливается локально, bhl version отвечает конвертом', (t) => {
|
||||
const tmp = mkdtempSync(path.join(os.tmpdir(), 'bhl-pack-'));
|
||||
t.after(() => rmSync(tmp, { recursive: true, force: true }));
|
||||
const pack = spawnSync('npm', ['pack', '--pack-destination', tmp], {
|
||||
cwd: pkgRoot,
|
||||
encoding: 'utf8',
|
||||
});
|
||||
assert.equal(pack.status, 0, pack.stderr);
|
||||
const tarball = readdirSync(tmp).find((name) => name.endsWith('.tgz'));
|
||||
assert.ok(tarball, 'tarball создан');
|
||||
const installDir = path.join(tmp, 'install');
|
||||
const install = spawnSync(
|
||||
'npm',
|
||||
[
|
||||
'install',
|
||||
path.join(tmp, tarball),
|
||||
'--prefix',
|
||||
installDir,
|
||||
'--no-save',
|
||||
'--ignore-scripts',
|
||||
'--no-audit',
|
||||
'--no-fund',
|
||||
],
|
||||
{ encoding: 'utf8' },
|
||||
);
|
||||
assert.equal(install.status, 0, install.stderr);
|
||||
const bin = path.join(installDir, 'node_modules', '.bin', 'bhl');
|
||||
const run = spawnSync(bin, ['version'], { encoding: 'utf8' });
|
||||
assert.equal(run.status, 0, run.stderr);
|
||||
const envelope = JSON.parse(run.stdout);
|
||||
assert.equal(envelope.ok, true);
|
||||
assert.equal(envelope.command, 'version');
|
||||
assert.equal(envelope.data.name, '@baseline-harness/bhl');
|
||||
assert.equal(envelope.data.version, '0.0.1');
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": false,
|
||||
"rewriteRelativeImportExtensions": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user