Files
zeyu.fz 7c9ad7d6ce feat(packages): 添加 runtime 和 commands 包配置
- 在包列表中新增 runtime 包配置
- 在包列表中新增 commands 包配置
- 确保新包路径和名称正确设置
2026-06-29 18:18:44 +08:00

44 lines
1.5 KiB
JavaScript

import { readFileSync, writeFileSync } from "fs";
import { dirname, join, resolve } from "path";
import { fileURLToPath } from "url";
export const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../../..");
export const PACKAGES = [
{ key: "core", dir: "packages/core", name: "bailian-cli-core" },
{ key: "runtime", dir: "packages/runtime", name: "bailian-cli-runtime" },
{ key: "commands", dir: "packages/commands", name: "bailian-cli-commands" },
{ key: "cli", dir: "packages/cli", name: "bailian-cli" },
];
// knowledge-studio-cli shares the same library deps as bailian-cli.
// Published via publish.yml with package=knowledge-studio-cli (passes --knowledge flag).
export const KSCLI_PACKAGE = { key: "kscli", dir: "packages/kscli", name: "knowledge-studio-cli" };
export const ALL_PACKAGES = [...PACKAGES, KSCLI_PACKAGE];
export function readJson(path) {
return JSON.parse(readFileSync(path, "utf-8"));
}
export function packageJsonPath(pkg) {
return join(ROOT, pkg.dir, "package.json");
}
export function readPackageJson(pkg) {
return readJson(packageJsonPath(pkg));
}
export function writePackageJson(pkg, json) {
writeFileSync(packageJsonPath(pkg), `${JSON.stringify(json, null, 2)}\n`);
}
export function tarballFileName(name, version) {
return `${name.replace(/^@/, "").replace("/", "-")}-${version}.tgz`;
}
export function findPackage(key) {
const pkg = PACKAGES.find((p) => p.key === key);
if (!pkg) throw new Error(`unknown package key: ${key}`);
return pkg;
}