@longzai-intelligence-tsconfig/config 0.0.1 → 0.0.3
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 +33 -13
- package/dist/index.js +3 -5
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -13,16 +13,27 @@ type SingleTsconfigExemption = {
|
|
|
13
13
|
*/
|
|
14
14
|
reason: string;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* 模块根 paths 豁免声明
|
|
18
|
+
*
|
|
19
|
+
* 对应根溶液保留 `compilerOptions.paths` 承担全仓 IDE 解析的裁量形态,登记后模块根文件跳过 R7 判定
|
|
20
|
+
*/
|
|
21
|
+
type ModuleRootPathsExemption = {
|
|
22
|
+
/**
|
|
23
|
+
* 豁免依据
|
|
24
|
+
*
|
|
25
|
+
* 须引用 ADR 或用户裁定出处,如 `ADR 0008 裁量保留`
|
|
26
|
+
*/
|
|
27
|
+
reason: string;
|
|
28
|
+
};
|
|
16
29
|
/**
|
|
17
30
|
* 单包覆写声明
|
|
18
31
|
*/
|
|
19
32
|
type PackageOverride = {
|
|
20
33
|
/**
|
|
21
|
-
* app
|
|
22
|
-
*
|
|
23
|
-
* 如 `library`、`react`、`elysia`,对应共享配置包 `presets/<名>.json`
|
|
34
|
+
* app 片包型覆写
|
|
24
35
|
*
|
|
25
|
-
*
|
|
36
|
+
* 包型默认按依赖自动推断(如 `react`、`elysia`、`next`,无框架依赖默认 `library`),仅推断误判或特异预设(如 decorator 变体)时覆写
|
|
26
37
|
*/
|
|
27
38
|
appPreset?: string;
|
|
28
39
|
/**
|
|
@@ -46,24 +57,30 @@ type LziTsconfigConfig = {
|
|
|
46
57
|
* 精确匹配单元相对路径,如 `e2e/fixtures`
|
|
47
58
|
*/
|
|
48
59
|
exclude?: string[];
|
|
60
|
+
/**
|
|
61
|
+
* 模块根 paths 豁免声明
|
|
62
|
+
*
|
|
63
|
+
* 登记后模块根溶液与根 node 片跳过 R7 判定,子包单元的跨包 paths 不适用本豁免
|
|
64
|
+
*/
|
|
65
|
+
moduleRootPaths?: ModuleRootPathsExemption;
|
|
49
66
|
};
|
|
50
67
|
//#endregion
|
|
51
68
|
//#region src/define-config.config.d.ts
|
|
52
69
|
/**
|
|
53
70
|
* lzi-tsconfig 配置工厂
|
|
54
71
|
*
|
|
55
|
-
*
|
|
72
|
+
* 参数可选、零参返回空默认配置——消费仓无仓库特有事实时 `defineConfig()` 一行即接入,开箱即用;有参时纯类型透传原样返回,为配置文件提供类型推导与形态收口
|
|
56
73
|
*
|
|
57
|
-
* @param config -
|
|
58
|
-
* @returns
|
|
74
|
+
* @param config - 使用方就地配置对象,省略时取空配置
|
|
75
|
+
* @returns 配置对象,省略入参时为空对象
|
|
59
76
|
*/
|
|
60
|
-
declare function defineConfig(config
|
|
77
|
+
declare function defineConfig(config?: LziTsconfigConfig): LziTsconfigConfig;
|
|
61
78
|
//#endregion
|
|
62
79
|
//#region src/config-template.utils.d.ts
|
|
63
80
|
/**
|
|
64
81
|
* 构建配置文件模板内容
|
|
65
82
|
*
|
|
66
|
-
* 供 `lzi-tsconfig init` 写盘与 `--dry-run`
|
|
83
|
+
* 供 `lzi-tsconfig init` 写盘与 `--dry-run` 预览共用,零参开箱即用形态,注释遵循配置文件治理规范
|
|
67
84
|
*
|
|
68
85
|
* @returns 配置文件全文
|
|
69
86
|
*/
|
|
@@ -83,18 +100,21 @@ type LoadedConfig = {
|
|
|
83
100
|
*/
|
|
84
101
|
config: LziTsconfigConfig;
|
|
85
102
|
/**
|
|
86
|
-
*
|
|
103
|
+
* 配置来源绝对路径
|
|
87
104
|
*/
|
|
88
105
|
path: string;
|
|
89
106
|
};
|
|
90
107
|
/**
|
|
91
108
|
* 装载就地配置
|
|
92
109
|
*
|
|
93
|
-
*
|
|
110
|
+
* 经 shared-config 的 `loadUnifiedConfig` 统一加载:从目标仓根向上查找
|
|
111
|
+
* `lzi-tsconfig.config.ts`,回退统一配置 `lzi.config.ts` 的 `tsconfig` 字段,
|
|
112
|
+
* 命中后随加载执行 zod 结构校验,配置不存在时返回 `null` 由调用方按零配置继续
|
|
94
113
|
*
|
|
95
114
|
* @param rootDir - 目标仓根目录
|
|
96
|
-
* @returns
|
|
97
|
-
* @throws {@link
|
|
115
|
+
* @returns 装载结果,配置不存在时为 `null`
|
|
116
|
+
* @throws {@link SharedConfigLoadError} 配置文件加载失败或缺少默认导出时抛出
|
|
117
|
+
* @throws {@link SharedConfigValidationError} 配置结构校验失败时抛出
|
|
98
118
|
*/
|
|
99
119
|
declare function loadConfig(rootDir: string): Promise<LoadedConfig | null>;
|
|
100
120
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{loadUnifiedConfig as e}from"@longzai-intelligence-shared-config/core";import*as t from"zod";function n(e){return e??{}}function r(){return`import { defineConfig } from '@longzai-intelligence-tsconfig/config';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* lzi-tsconfig 配置
|
|
5
5
|
*/
|
|
6
|
-
export default defineConfig(
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
`}const a=`lzi-tsconfig.config.ts`;function o(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function s(e){if(!o(e))return!1;if(e.packages!==void 0){if(!o(e.packages))return!1;for(let t of Object.values(e.packages)){if(!o(t))return!1;let e=t.appPreset;if(e!==void 0&&typeof e!=`string`)return!1;let n=t.singleTsconfig;if(n!==void 0){if(!o(n))return!1;let e=n.reason;if(typeof e!=`string`||e.length===0)return!1}}}return e.exclude===void 0||!!Array.isArray(e.exclude)&&!e.exclude.some(e=>typeof e!=`string`)}async function c(r){let i=n(r,a);if(!t(i))return null;let c=await e(import.meta.url).import(i);if(!o(c))throw Error(`配置模块导出缺失`);let l=c.default;if(!s(l))throw Error(`配置默认导出形态不合规`);return{config:l,path:i}}export{a as CONFIG_FILE_NAME,i as buildConfigFileContent,r as defineConfig,c as loadConfig};
|
|
6
|
+
export default defineConfig();
|
|
7
|
+
`}const i=`lzi-tsconfig.config.ts`,a=t.looseObject({reason:t.string().min(1)}),o=t.looseObject({reason:t.string().min(1)}),s=t.looseObject({appPreset:t.string().optional(),singleTsconfig:a.optional()}),c=t.looseObject({packages:t.record(t.string(),s).optional(),exclude:t.array(t.string()).optional(),moduleRootPaths:o.optional()});async function l(t){let n=await e({cwd:t,standaloneFile:[i,`lzi-tsconfig.config.mts`],unifiedField:`tsconfig`,schema:c});return n.success?{config:n.config,path:n.configFilePath}:null}export{i as CONFIG_FILE_NAME,r as buildConfigFileContent,n as defineConfig,l as loadConfig};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-tsconfig/config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Longzai Intelligence tsconfig 形态门禁配置契约",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"clean": "lzi-dev-cli clean"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"
|
|
35
|
+
"@longzai-intelligence-shared-config/core": "^0.0.9",
|
|
36
|
+
"zod": "^4.4.3"
|
|
36
37
|
}
|
|
37
38
|
}
|