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:
Suslov-MD
2026-11-29 02:34:24 +03:00
parent 2ad470e5fe
commit e7adc89089
7 changed files with 92 additions and 8 deletions
+44
View File
@@ -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');
});