@longzai-intelligence-release/config 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,155 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * 发布包清单的双轨形态(ADR 0082:包级自治轨道)
4
+ *
5
+ * - 字符串数组(兼容形态):全部走公网 npm 轨(现状行为不变)
6
+ * - 对象形态 `{ npm, local }`:轨道必须显式落位——`npm` 走公网 registry, `local` 走本地私有
7
+ * registry(longzai-intelligence-npm-registry,地址经 env `LZI_NPM_REGISTRY_URL` 提供,不入库)。私有发布仅因包被显式放入
8
+ * `local` 才发生,杜绝「漏标 registry 静默公开发布」的事故面
9
+ */
10
+ type PublishPackagesConfig = string[] | {
11
+ /**
12
+ * 公网 npm 轨的包列表(包名或相对路径)
13
+ */
14
+ npm: string[];
15
+ /**
16
+ * 本地私有轨的包列表(包名或相对路径)
17
+ */
18
+ local: string[];
19
+ };
20
+ /**
21
+ * 发布配置
22
+ *
23
+ * 定义发布相关的配置选项(自 dev-tools 的 PublishConfig 迁入,字段语义不变,ADR 0087)
24
+ */
25
+ type PublishConfig = {
26
+ /**
27
+ * 要发布的包清单(双轨形态,ADR 0082)
28
+ *
29
+ * 支持包名(如 '@scope/pkg')或相对路径(如 'packages/pkg')
30
+ * 依赖拓扑顺序从各包 package.json 的 workspace:* 依赖自动推导(跨两轨统一计算)
31
+ */
32
+ packages: PublishPackagesConfig;
33
+ /**
34
+ * 是否在发布前安装依赖
35
+ *
36
+ * @default true
37
+ */
38
+ installDeps?: boolean;
39
+ /**
40
+ * 是否在发布前构建包
41
+ *
42
+ * @default true
43
+ */
44
+ buildBeforePublish?: boolean;
45
+ /**
46
+ * 是否在发布前清理构建产物
47
+ *
48
+ * 清零旧产物后全量重建,避免增量缓存残留导致残缺包发布
49
+ *
50
+ * @default true
51
+ */
52
+ cleanBeforePublish?: boolean;
53
+ /**
54
+ * 发布时使用的访问级别
55
+ *
56
+ * @default 'public'
57
+ */
58
+ access?: 'public' | 'restricted';
59
+ /**
60
+ * 发布前的前置钩子(在 clean 与 installDeps 之后、逐包构建之前执行)
61
+ *
62
+ * 以 shell 字符串执行(cwd 为 monorepo 根),非零退出码终止发布。
63
+ * 典型用途:自举场景——builder 仓库发布时 clean 后 lzi-builder 自身不可用,
64
+ * 需要先用 tsgo 冷启动构建 lzi-builder 自举闭包,后续逐包构建才能用 lzi-builder。
65
+ */
66
+ preBuildHook?: string;
67
+ };
68
+ /**
69
+ * LziRelease 配置
70
+ *
71
+ * 定义 lzi-release.config.ts 配置文件的结构
72
+ */
73
+ type LziReleaseConfig = {
74
+ /**
75
+ * 发布配置(发布域当前唯一的配置节)
76
+ */
77
+ publish?: PublishConfig;
78
+ };
79
+ //#endregion
80
+ //#region src/define.config.d.ts
81
+ /**
82
+ * 定义 LziRelease 配置
83
+ *
84
+ * 提供类型推导,用户无需手动 satisfies
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * import { defineConfig } from '@longzai-intelligence-release/config';
89
+ *
90
+ * export default defineConfig({
91
+ * publish: {
92
+ * packages: ['apps/cli'],
93
+ * },
94
+ * });
95
+ * ```;
96
+ *
97
+ * @param config - LziRelease 配置对象
98
+ * @returns 原样返回传入的配置对象
99
+ */
100
+ declare const defineConfig: (config: LziReleaseConfig) => LziReleaseConfig;
101
+ //#endregion
102
+ //#region src/load.config.d.ts
103
+ /**
104
+ * 新配置来源(lzi-release.config.ts 或统一 lzi.config.ts 的 release 字段)
105
+ */
106
+ type ReleaseSourceNew = 'release';
107
+ /**
108
+ * 兼容回退来源(lzi-dev.config.ts 或统一 lzi.config.ts 的 devTools 字段的 publish 字段)
109
+ */
110
+ type ReleaseSourceLegacy = 'legacy-dev-tools';
111
+ /**
112
+ * 配置来源
113
+ */
114
+ type ReleaseConfigSource = ReleaseSourceNew | ReleaseSourceLegacy;
115
+ /**
116
+ * 配置加载结果
117
+ */
118
+ type ReleaseConfigResult = {
119
+ /**
120
+ * 加载后的发布域配置对象
121
+ */
122
+ config: LziReleaseConfig;
123
+ /**
124
+ * 命中的配置文件绝对路径(用于推导 monorepo 根目录)
125
+ */
126
+ configPath: string;
127
+ /**
128
+ * 配置来源(legacy 命中时由调用方输出弃用提示)
129
+ */
130
+ source: ReleaseConfigSource;
131
+ };
132
+ /**
133
+ * 查找配置文件路径
134
+ *
135
+ * 优先查找 lzi-release.config.ts,其次 lzi-dev.config.ts(兼容回退),
136
+ * 均未找到时返回 null
137
+ *
138
+ * @returns 配置文件的绝对路径,如果找不到则返回 null
139
+ */
140
+ declare const findReleaseConfigFile: () => string | null;
141
+ /**
142
+ * 加载发布配置
143
+ *
144
+ * 三级优先(ADR 0087):
145
+ *
146
+ * - lzi-release.config.ts(standalone)> lzi.config.ts 的 release 字段(统一配置)
147
+ * - 均未命中时兼容回退 lzi-dev.config.ts 的 publish 字段(或 lzi.config.ts 的 devTools 字段)
148
+ * - 两轨 standalone 均要求存在其一(与 dev-tools 时代行为一致:统一配置不能单独成立)
149
+ *
150
+ * @returns 配置加载结果;任一配置文件都不存在时返回 null
151
+ * @throws {@link Error} 如果配置文件存在但加载失败
152
+ */
153
+ declare const loadReleaseConfig: () => Promise<ReleaseConfigResult | null>;
154
+ //#endregion
155
+ export { type LziReleaseConfig, type PublishConfig, type PublishPackagesConfig, type ReleaseConfigResult, type ReleaseConfigSource, defineConfig, findReleaseConfigFile, loadReleaseConfig };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{loadUnifiedConfig as e,resolveStandaloneConfigPath as t}from"@longzai-intelligence-shared-config/core";const n=e=>e,r=`lzi-release.config.ts`,i=`lzi-dev.config.ts`,a=()=>t(r)??t(i),o=async()=>{let t=a();if(!t)return null;let n=await e({standaloneFile:r,unifiedField:`release`});if(n.success)return{config:n.config,configPath:t,source:`release`};let o=await e({standaloneFile:i,unifiedField:`devTools`});return o.success&&o.config.publish!==void 0?{config:{publish:o.config.publish},configPath:t,source:`legacy-dev-tools`}:{config:{},configPath:t,source:`release`}};export{n as defineConfig,a as findReleaseConfigFile,o as loadReleaseConfig};
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@longzai-intelligence-release/config",
3
+ "version": "0.0.1",
4
+ "description": "Longzai Intelligence 发布工具配置类型定义与加载器",
5
+ "license": "UNLICENSED",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "type": "module",
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "scripts": {
19
+ "build": "lzi-builder",
20
+ "build:prod": "NODE_ENV=production bun run build",
21
+ "prepublishOnly": "bun run build:prod",
22
+ "typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
23
+ "typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
24
+ "typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
25
+ "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json",
26
+ "lint": "oxlint && oxfmt --check",
27
+ "lint:fix": "oxlint --fix && oxfmt",
28
+ "test": "bun test",
29
+ "test:watch": "bun test --watch",
30
+ "test:coverage": "bun test --coverage",
31
+ "clean": "lzi-dev-cli clean"
32
+ },
33
+ "dependencies": {
34
+ "@longzai-intelligence-shared-config/core": "^0.0.5"
35
+ }
36
+ }