mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
7c9ad7d6ce
- 在包列表中新增 runtime 包配置 - 在包列表中新增 commands 包配置 - 确保新包路径和名称正确设置
44 lines
1.5 KiB
JavaScript
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;
|
|
}
|