From 5d489bc87531ba24f39eb300401efbdaed9526cb Mon Sep 17 00:00:00 2001 From: p-sw Date: Sat, 16 May 2026 22:36:46 +0900 Subject: [PATCH] ci: package publish ready --- .npmignore | 27 ++++++++++++++++++++++++++ package.json | 38 ++++++++++++++++++++++++++++++++---- scripts/check-package.mjs | 41 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 .npmignore create mode 100644 scripts/check-package.mjs diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..76cac13 --- /dev/null +++ b/.npmignore @@ -0,0 +1,27 @@ +# Dependency and build cache directories +node_modules/ +.bun/ + +# Source, tests, and local development files +src/ +tests/ +scripts/ +coverage/ +tsconfig.json +bun.lock + +# Repository and CI metadata +.git/ +.gitea/ +.gitignore + +# Local runtime data and secrets +.data/ +.hermes/ +.env +.env.* +!.env.example +*.log + +# Package artifacts +*.tgz diff --git a/package.json b/package.json index b97c362..79cc41d 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,51 @@ { "name": "boxbrain", - "version": "0.1.0", + "version": "0.1.5", "description": "Human-like persona harness framework powered by LLMs and IdentityDB.", + "license": "MIT", "type": "module", "main": "dist/index.js", "module": "dist/index.js", - "types": "src/index.ts", + "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist", - "src", "README.md" ], + "sideEffects": false, + "keywords": [ + "llm", + "persona", + "memory", + "identitydb", + "agent" + ], + "repository": { + "type": "git", + "url": "git+https://git.psw.kr/p-sw/BoxBrain.git" + }, + "bugs": { + "url": "https://git.psw.kr/p-sw/BoxBrain/issues" + }, + "homepage": "https://git.psw.kr/p-sw/BoxBrain", + "publishConfig": { + "access": "public" + }, "scripts": { "test": "vitest run", "check": "tsc --noEmit", "build": "tsup src/index.ts --format esm --dts --sourcemap --clean", - "prepare": "bun run build" + "clean": "rm -rf dist", + "pack:check": "bun scripts/check-package.mjs", + "prepack": "bun run build && bun run pack:check", + "prepublishOnly": "bun run check && bun run test && bun run build && bun run pack:check" }, "dependencies": { "identitydb": "0.2.1" diff --git a/scripts/check-package.mjs b/scripts/check-package.mjs new file mode 100644 index 0000000..d779488 --- /dev/null +++ b/scripts/check-package.mjs @@ -0,0 +1,41 @@ +import { existsSync, readFileSync } from "node:fs"; + +const requiredFiles = [ + "README.md", + "dist/index.js", + "dist/index.d.ts", +]; + +const missingFiles = requiredFiles.filter((path) => !existsSync(path)); + +if (missingFiles.length > 0) { + console.error(`Missing package artifact(s): ${missingFiles.join(", ")}`); + process.exit(1); +} + +const packageJson = JSON.parse(readFileSync("package.json", "utf8")); + +const expectedFields = { + main: "dist/index.js", + module: "dist/index.js", + types: "dist/index.d.ts", +}; + +for (const [field, expected] of Object.entries(expectedFields)) { + if (packageJson[field] !== expected) { + console.error(`package.json ${field} must be ${expected}`); + process.exit(1); + } +} + +if (packageJson.exports?.["."]?.types !== "./dist/index.d.ts") { + console.error("package.json exports[\".\"].types must point to ./dist/index.d.ts"); + process.exit(1); +} + +if (packageJson.exports?.["."]?.import !== "./dist/index.js") { + console.error("package.json exports[\".\"].import must point to ./dist/index.js"); + process.exit(1); +} + +console.log("Package metadata and artifacts are publish-ready.");