@longzai-intelligence-git/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.
- package/dist/index.d.ts +180 -0
- package/dist/index.js +1 -0
- package/package.json +35 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* @longzai-intelligence-git/config
|
|
4
|
+
*
|
|
5
|
+
* 配置契约包,承载 lzi-git.config.ts 的类型定义与内置默认预设。
|
|
6
|
+
* 声明配置形状(types)+ 提供开箱即用的默认选项与默认分组预设(defineConfig 深合并消费)。
|
|
7
|
+
* 业务逻辑(归一化引擎)在 @longzai-intelligence-git/gitignore-formatter。
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* .gitignore 分组定义
|
|
11
|
+
*
|
|
12
|
+
* 用于把散落在 .gitignore 中的模式按主题归类,输出时以 `# <comment>` 作为分组头。
|
|
13
|
+
*/
|
|
14
|
+
interface GitignoreGroup {
|
|
15
|
+
/**
|
|
16
|
+
* 分组标题纯文本。
|
|
17
|
+
*
|
|
18
|
+
* **不含 `#` 前缀**——输出时由格式化器自动补 `# `,配置层只表达语义文本。
|
|
19
|
+
* 例如应写 `'依赖与构建产物'`,而非 `'# 依赖与构建产物'`。
|
|
20
|
+
*/
|
|
21
|
+
readonly comment: string;
|
|
22
|
+
/**
|
|
23
|
+
* 归属本组的模式集合。
|
|
24
|
+
*
|
|
25
|
+
* 用于把现有 .gitignore 中的行分类到分组;分类时按归一化后的模式精确匹配。
|
|
26
|
+
*/
|
|
27
|
+
readonly patterns: readonly string[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* .gitignore 格式化选项
|
|
31
|
+
*
|
|
32
|
+
* 控制归一化与分组编排的具体行为。所有字段在 lzi-git.config.ts 中以 Partial 形式可选,
|
|
33
|
+
* 未提供时由格式化器回退到默认值。
|
|
34
|
+
*/
|
|
35
|
+
interface GitignoreFormatOptions {
|
|
36
|
+
/**
|
|
37
|
+
* 是否按 config.groups 重组模式到分组下。
|
|
38
|
+
*
|
|
39
|
+
* - true:忽略原文件中的分组结构,按 groups 定义重新归类并输出分组头
|
|
40
|
+
* - false:保留原文件的 `#` 注释分组结构,仅在组内做归一化/排序/去重
|
|
41
|
+
*/
|
|
42
|
+
readonly groupByConfig: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 组内是否按大小写敏感升序稳定排序。
|
|
45
|
+
*
|
|
46
|
+
* 稳定排序保证相等键的模式不互换相对顺序,避免无谓 diff。
|
|
47
|
+
*/
|
|
48
|
+
readonly sortWithinGroup: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* 归一化后是否去重。
|
|
51
|
+
*
|
|
52
|
+
* 去重在尾空白清理之后进行,因此 `foo ` 与 `foo` 视为同一模式。
|
|
53
|
+
*/
|
|
54
|
+
readonly dedupe: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* 分组之间插入的空行数。
|
|
57
|
+
*
|
|
58
|
+
* 默认 1。0 表示分组紧邻。
|
|
59
|
+
*/
|
|
60
|
+
readonly blankLinesBetweenGroups: number;
|
|
61
|
+
/**
|
|
62
|
+
* 未匹配任何分组的模式所归入的尾部组标题。
|
|
63
|
+
*
|
|
64
|
+
* **纯文本,不含 `#` 前缀**(与 GitignoreGroup.comment 约定一致),输出时自动补 `# `。
|
|
65
|
+
* 默认 '其他'。
|
|
66
|
+
*/
|
|
67
|
+
readonly miscGroupComment: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* .gitignore 格式化的默认选项。
|
|
71
|
+
*
|
|
72
|
+
* 格式化器在用户未覆盖某字段时使用这些值。导出供 lzi-git.config.ts 的类型推断与 CLI 兜底使用。
|
|
73
|
+
*/
|
|
74
|
+
declare const DEFAULT_GITIGNORE_OPTIONS: GitignoreFormatOptions;
|
|
75
|
+
/**
|
|
76
|
+
* 内置预设键。
|
|
77
|
+
*
|
|
78
|
+
* 每个键对应一组通用忽略模式,用户在 lzi-git.config.ts 的 presets 里用同名 boolean 开关控制。
|
|
79
|
+
* 扩展新预设时在此联合类型追加键名。
|
|
80
|
+
*/
|
|
81
|
+
type GitignorePresetKey = 'node' | 'bun' | 'turbo' | 'coverage' | 'env' | 'idea' | 'vscode' | 'macos' | 'windows' | 'linux' | 'npm' | 'agent';
|
|
82
|
+
/**
|
|
83
|
+
* 内置预设定义。
|
|
84
|
+
*
|
|
85
|
+
* 每个 preset 含:归属分组标题(纯文本,不含 #)、模式集合、默认开关。
|
|
86
|
+
* - default=true 的 preset 在用户未配置时自动启用(开箱即用)
|
|
87
|
+
* - default=false 的 preset 需用户显式开启(如 vscode,多数团队希望保留 .vscode 共享配置提交)
|
|
88
|
+
*/
|
|
89
|
+
interface GitignorePresetDefinition {
|
|
90
|
+
/** 归属分组标题(纯文本,不含 #,输出时自动补) */
|
|
91
|
+
readonly comment: string;
|
|
92
|
+
/** 该预设注入的模式集合 */
|
|
93
|
+
readonly patterns: readonly string[];
|
|
94
|
+
/** 默认开关(用户未在 presets 里声明时使用) */
|
|
95
|
+
readonly default: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* 内置预设表(键 → 定义)。
|
|
99
|
+
*
|
|
100
|
+
* 顺序即输出顺序(启用的 preset 按此表顺序生成分组,先于用户自定义 groups)。
|
|
101
|
+
* 导出供格式化器消费、供 lzi-git.config.ts 类型推断。
|
|
102
|
+
*/
|
|
103
|
+
declare const GITIGNORE_PRESETS: Readonly<Record<GitignorePresetKey, GitignorePresetDefinition>>;
|
|
104
|
+
/**
|
|
105
|
+
* presets 开关字典(用户在 lzi-git.config.ts 里提供)。
|
|
106
|
+
*
|
|
107
|
+
* 键为内置预设名,值为 boolean:true=启用(format 时注入其模式),false=禁用(不注入)。
|
|
108
|
+
* 未列出的 preset 走其 default 值。
|
|
109
|
+
*/
|
|
110
|
+
type GitignorePresets = Partial<Record<GitignorePresetKey, boolean>>;
|
|
111
|
+
/**
|
|
112
|
+
* 内置预设的默认开关快照(从 GITIGNORE_PRESETS 派生)。
|
|
113
|
+
*
|
|
114
|
+
* defineConfig 合并 presets 时用此作为基底,用户覆盖优先。
|
|
115
|
+
*/
|
|
116
|
+
declare const DEFAULT_GITIGNORE_PRESETS: GitignorePresets;
|
|
117
|
+
/**
|
|
118
|
+
* lzi-git.config.ts 根配置。
|
|
119
|
+
*
|
|
120
|
+
* 顶层按工具域分块,当前仅有 gitignore。后续新增工具域(如 hooks、aliases)时在此扩展。
|
|
121
|
+
*/
|
|
122
|
+
interface LziGitConfig {
|
|
123
|
+
/**
|
|
124
|
+
* .gitignore 格式化配置。
|
|
125
|
+
*/
|
|
126
|
+
readonly gitignore?: {
|
|
127
|
+
/**
|
|
128
|
+
* 格式化选项(Partial,未提供字段回退到 DEFAULT_GITIGNORE_OPTIONS)。
|
|
129
|
+
*/
|
|
130
|
+
readonly options?: Partial<GitignoreFormatOptions>;
|
|
131
|
+
/**
|
|
132
|
+
* 内置预设开关字典。
|
|
133
|
+
*
|
|
134
|
+
* 控制各内置预设(node/vscode/macos 等)是否启用。未列出的 preset 走其 default。
|
|
135
|
+
* 启用的 preset 在 format 时会向文件注入其缺失的模式(inject),并作为分组参与输出。
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* // 默认 .vscode 不忽略;开启它进入 ignore
|
|
139
|
+
* presets: { vscode: true }
|
|
140
|
+
*/
|
|
141
|
+
readonly presets?: GitignorePresets;
|
|
142
|
+
/**
|
|
143
|
+
* 用户自定义分组定义(项目特有项)。
|
|
144
|
+
*
|
|
145
|
+
* 输出顺序:启用的 preset 分组在前,自定义 groups 在后,最后是 misc 组。
|
|
146
|
+
* 未提供时仅使用 preset 分组。
|
|
147
|
+
*/
|
|
148
|
+
readonly groups?: readonly GitignoreGroup[];
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/define-config.d.ts
|
|
153
|
+
/**
|
|
154
|
+
* lzi-git.config.ts 配置定义助手(内置默认预设 + 深合并覆盖)。
|
|
155
|
+
*
|
|
156
|
+
* 合并规则:
|
|
157
|
+
* - options:浅合并(用户字段覆盖 DEFAULT_GITIGNORE_OPTIONS 对应字段)
|
|
158
|
+
* - presets:浅合并(用户开关覆盖 DEFAULT_GITIGNORE_PRESETS 对应键,未列出的走 preset 自身 default)
|
|
159
|
+
* - groups:原样保留(用户自定义分组,可选;未提供则无自定义分组)
|
|
160
|
+
*
|
|
161
|
+
* 镜像 @longzai-intelligence-oxfmt/config 的 deep-merge defineConfig 模式。
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* // 开箱即用(默认预设:node/macos/env 等启用,vscode 禁用)
|
|
165
|
+
* export default defineConfig();
|
|
166
|
+
*
|
|
167
|
+
* // 开启 vscode 忽略(默认禁用)
|
|
168
|
+
* export default defineConfig({ gitignore: { presets: { vscode: true } } });
|
|
169
|
+
*
|
|
170
|
+
* // 追加项目特有分组
|
|
171
|
+
* export default defineConfig({
|
|
172
|
+
* gitignore: { groups: [{ comment: 'Agent', patterns: ['CLAUDE.local.md'] }] },
|
|
173
|
+
* });
|
|
174
|
+
*
|
|
175
|
+
* @param userConfig - 用户配置(可选,缺省则全用默认)
|
|
176
|
+
* @returns 合并后的完整配置
|
|
177
|
+
*/
|
|
178
|
+
declare const defineConfig: (userConfig?: LziGitConfig) => LziGitConfig;
|
|
179
|
+
//#endregion
|
|
180
|
+
export { DEFAULT_GITIGNORE_OPTIONS, DEFAULT_GITIGNORE_PRESETS, GITIGNORE_PRESETS, GitignoreFormatOptions, GitignoreGroup, GitignorePresetDefinition, GitignorePresetKey, GitignorePresets, LziGitConfig, defineConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={groupByConfig:!0,sortWithinGroup:!0,dedupe:!0,blankLinesBetweenGroups:1,miscGroupComment:`其他`},t={node:{comment:`依赖与构建`,patterns:[`node_modules/`,`.pnp/`,`.pnp.js`,`.pnp.cjs`,`dist/`,`out/`,`build/`,`*.log`,`*.tsbuildinfo`,`tsup.config.bundled_*.mjs`],default:!0},bun:{comment:`Bun`,patterns:[`.bun/`],default:!0},turbo:{comment:`Turbo`,patterns:[`.turbo/`],default:!0},coverage:{comment:`测试覆盖率`,patterns:[`coverage/`,`.nyc_output/`],default:!0},env:{comment:`环境变量`,patterns:[`.env`,`.env.*`,`!.env.example`],default:!0},idea:{comment:`JetBrains IDE`,patterns:[`.idea/`],default:!0},vscode:{comment:`VSCode`,patterns:[`.vscode/`,`!.vscode/settings.json`,`!.vscode/tasks.json`,`!.vscode/launch.json`,`!.vscode/extensions.json`],default:!1},macos:{comment:`macOS 系统文件`,patterns:[`.DS_Store`],default:!0},windows:{comment:`Windows 系统文件`,patterns:[`Thumbs.db`,`ehthumbs.db`,`Desktop.ini`],default:!1},linux:{comment:`Linux 系统文件`,patterns:[`*~`],default:!1},npm:{comment:`npm`,patterns:[`.npmrc`],default:!0},agent:{comment:`AI Agent 本地文件`,patterns:[`CLAUDE.local.md`],default:!0}},n=Object.fromEntries(Object.keys(t).map(e=>[e,t[e].default])),r={gitignore:{options:e,presets:n}},i=t=>{if(t===void 0||t.gitignore===void 0)return r;let i=t.gitignore,a={options:{...e,...i.options},presets:{...n,...i.presets},...i.groups===void 0?{}:{groups:i.groups}};return{...t,gitignore:a}};export{e as DEFAULT_GITIGNORE_OPTIONS,n as DEFAULT_GITIGNORE_PRESETS,t as GITIGNORE_PRESETS,i as defineConfig};
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@longzai-intelligence-git/config",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Longzai Intelligence Git - lzi-git.config.ts 配置契约",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "NODE_ENV=production lzi-builder",
|
|
19
|
+
"build:prod": "NODE_ENV=production lzi-builder",
|
|
20
|
+
"prepublishOnly": "bun run build:prod",
|
|
21
|
+
"typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
|
|
22
|
+
"typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
|
|
23
|
+
"typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
|
|
24
|
+
"typecheck:test": "lzi-tsgo typecheck tsconfig/test.json",
|
|
25
|
+
"lint": "oxlint && oxfmt --check",
|
|
26
|
+
"lint:fix": "oxlint --fix && oxfmt",
|
|
27
|
+
"test": "bun test",
|
|
28
|
+
"test:watch": "bun test --watch",
|
|
29
|
+
"test:coverage": "bun test --coverage",
|
|
30
|
+
"clean": "lzi-dev-cli clean"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {},
|
|
33
|
+
"devDependencies": {},
|
|
34
|
+
"peerDependencies": {}
|
|
35
|
+
}
|