@longzai-intelligence-clean/config 0.0.0-stage → 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.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # @longzai-intelligence-clean/config
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ LziClean CLI 配置契约包:`lzi-clean.config.ts` 配置文件的类型定义与 `defineConfig` 工厂。
4
+
5
+ ## 用法
6
+
7
+ ```ts
8
+ // lzi-clean.config.ts
9
+ import { defineConfig } from '@longzai-intelligence-clean/config';
10
+
11
+ export default defineConfig({
12
+ clean: {
13
+ // 显式声明 plugin(省略则按仓结构自动检测)
14
+ plugins: ['turbo', 'tsgo'],
15
+ // 额外清理目标(相对包根)
16
+ extraTargets: ['coverage'],
17
+ },
18
+ });
19
+ ```
20
+
21
+ ## 配置字段
22
+
23
+ | 字段 | 类型 | 说明 |
24
+ | -------------------- | --------------------------- | ------------------------------------------------ |
25
+ | `clean.plugins` | `string[] \| CleanPlugin[]` | 启用的 clean plugin 清单;省略时按仓结构自动检测 |
26
+ | `clean.extraTargets` | `string[]` | plugin 覆盖不到时额外清理的路径,相对包根 |
@@ -0,0 +1,97 @@
1
+ /**
2
+ * clean plugin 的包上下文
3
+ *
4
+ * 提供当前正在清理的子包信息,供 plugin 派生清理目标
5
+ */
6
+ type PackageContext = {
7
+ /**
8
+ * 仓库根绝对路径
9
+ */
10
+ root: string;
11
+ /**
12
+ * 包相对仓库根的路径,如 'packages/core'
13
+ */
14
+ relativePath: string;
15
+ /**
16
+ * 该包的 package.json 解析结果
17
+ */
18
+ manifest: Record<string, unknown>;
19
+ };
20
+ /**
21
+ * clean plugin 接口
22
+ *
23
+ * 每个工具/技术栈提供一个 plugin,声明自己产出的清理目标。
24
+ * lzi-clean 不认识任何具体工具,只负责遍历 plugin、收集声明、统一执行删除。
25
+ */
26
+ type CleanPlugin = {
27
+ /**
28
+ * plugin 名称,用于在配置中按字符串引用内置 plugin
29
+ */
30
+ name: string;
31
+ /**
32
+ * 给定一个子包上下文,返回该 plugin 负责清理的产物路径(相对包根)
33
+ */
34
+ getTargets: (ctx: PackageContext) => string[] | Promise<string[]>;
35
+ };
36
+ /**
37
+ * 工程化 clean 配置
38
+ *
39
+ * 以 plugin 派生为主干,clean 目标由各工具 plugin 自行声明,
40
+ * 而非由人维护一份固定清单,plugin 缺省面随仓库结构自动检测
41
+ */
42
+ type CleanConfig = {
43
+ /**
44
+ * 启用的 clean plugin 清单
45
+ *
46
+ * @remarks
47
+ * 支持两种形态:字符串数组按名引用内置 plugin 如 `turbo` 与 `tsgo`,
48
+ * CleanPlugin 对象数组承接用户自定义 plugin
49
+ * 省略时随仓库结构自动检测,仓根 `.turbo` 缓存目录在场加 turbo,
50
+ * `tsconfig` 目录含 composite 配置加 tsgo,检测逻辑与 `lzi-clean init`
51
+ * 落盘推导同源,两信号均未命中时 clean 终止并指路显式声明,
52
+ * 显式空数组尊重为无 plugin,仅清理 `extraTargets` 声明目标
53
+ * @default 按仓库结构自动检测
54
+ */
55
+ plugins?: string[] | CleanPlugin[];
56
+ /**
57
+ * plugin 覆盖不到时额外清理的路径(escape hatch)
58
+ *
59
+ * 相对包根,无默认值。仅在特殊仓库需要追加时显式声明
60
+ */
61
+ extraTargets?: string[];
62
+ };
63
+ /**
64
+ * LziClean CLI 配置
65
+ *
66
+ * 定义 lzi-clean.config.ts 配置文件的结构
67
+ */
68
+ type LziCleanConfig = {
69
+ /**
70
+ * 工程化 clean 配置
71
+ */
72
+ clean?: CleanConfig;
73
+ };
74
+ /**
75
+ * 定义 LziClean CLI 配置
76
+ *
77
+ * 提供类型推导,用户无需手动 satisfies
78
+ *
79
+ * @remarks
80
+ * 无配置仓可无参调用,家族声明仓的既有形态即 `defineConfig()`,参数可选以保持该形态合法
81
+ * @example
82
+ * ```typescript
83
+ * import { defineConfig } from '@longzai-intelligence-clean/config';
84
+ *
85
+ * export default defineConfig({
86
+ * clean: {
87
+ * plugins: ['turbo'],
88
+ * },
89
+ * });
90
+ * ```;
91
+ *
92
+ * @default {}
93
+ * @param config - LziClean CLI 配置对象,无配置仓可省略
94
+ * @returns 原样返回传入的配置对象
95
+ */
96
+ declare const defineConfig: (config?: LziCleanConfig) => LziCleanConfig;
97
+ export { type CleanConfig, type CleanPlugin, type LziCleanConfig, type PackageContext, defineConfig };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ const e=(e={})=>e;export{e as defineConfig};
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-clean/config",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "Longzai Intelligence 工程清理配置契约",
5
+ "keywords": [
6
+ "clean",
7
+ "config",
8
+ "longzai-intelligence",
9
+ "schema"
10
+ ],
11
+ "license": "UNLICENSED",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "type": "module",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ }
23
+ },
24
+ "scripts": {
25
+ "build": "lzi-builder",
26
+ "build:prod": "NODE_ENV=production bun run build",
27
+ "prepublishOnly": "bun run build:prod",
28
+ "typecheck": "lzi-typecheck",
29
+ "lint": "lzi-lint lint",
30
+ "lint:fix": "lzi-lint fix",
31
+ "test": "lzi-bun test",
32
+ "test:watch": "lzi-bun test --watch",
33
+ "test:coverage": "lzi-bun test --coverage",
34
+ "clean": "lzi-clean"
35
+ }
36
+ }