@longzai-intelligence-scripts/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 +31 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -174,6 +174,36 @@ type ScriptsConfigResult = {
|
|
|
174
174
|
*/
|
|
175
175
|
declare const defineConfig: (config?: LziScriptsConfig) => LziScriptsConfig;
|
|
176
176
|
//#endregion
|
|
177
|
+
//#region src/define.registry.d.ts
|
|
178
|
+
/**
|
|
179
|
+
* 脚本档案工厂(恒等返回,仅提供类型约束)
|
|
180
|
+
*
|
|
181
|
+
* @param entries - 档案条目列表
|
|
182
|
+
* @returns 原样返回的条目列表
|
|
183
|
+
*/
|
|
184
|
+
declare const defineProfile: (entries: ScriptEntry[]) => ScriptEntry[];
|
|
185
|
+
/**
|
|
186
|
+
* 遗留死链映射集工厂(恒等返回,仅提供类型约束)
|
|
187
|
+
*
|
|
188
|
+
* @param mappings - 遗留映射条目列表
|
|
189
|
+
* @returns 原样返回的映射列表
|
|
190
|
+
*/
|
|
191
|
+
declare const defineLegacyMappings: (mappings: LegacyMapping[]) => LegacyMapping[];
|
|
192
|
+
/**
|
|
193
|
+
* 兼伴配置集工厂(恒等返回,仅提供类型约束)
|
|
194
|
+
*
|
|
195
|
+
* @param companions - 兼伴配置条目列表
|
|
196
|
+
* @returns 原样返回的条目列表
|
|
197
|
+
*/
|
|
198
|
+
declare const defineCompanionEntries: (companions: CompanionEntry[]) => CompanionEntry[];
|
|
199
|
+
/**
|
|
200
|
+
* 真源注册数据工厂(恒等返回,仅提供类型约束)
|
|
201
|
+
*
|
|
202
|
+
* @param data - 注册数据整体
|
|
203
|
+
* @returns 原样返回的注册数据
|
|
204
|
+
*/
|
|
205
|
+
declare const defineRegistry: (data: ScriptsRegistryData) => ScriptsRegistryData;
|
|
206
|
+
//#endregion
|
|
177
207
|
//#region src/load.config.d.ts
|
|
178
208
|
/**
|
|
179
209
|
* 自起点目录逐级上溯查找就地配置文件
|
|
@@ -248,4 +278,4 @@ type ResolveRegistryOptions = {
|
|
|
248
278
|
*/
|
|
249
279
|
declare const resolveRegistry: (options: ResolveRegistryOptions) => Promise<ResolvedRegistry | null>;
|
|
250
280
|
//#endregion
|
|
251
|
-
export { type AlternativeDeclaration, type CompanionEntry, type ExemptionDeclaration, type LegacyMapping, type LziScriptsConfig, type RegistrySource, type ResolveRegistryOptions, type ResolvedRegistry, type ScriptEntry, type ScriptSeverity, type ScriptsConfigResult, type ScriptsProfileKey, type ScriptsRegistryData, asRegistryData, defineConfig, findScriptsConfigFile, loadScriptsConfig, resolveRegistry };
|
|
281
|
+
export { type AlternativeDeclaration, type CompanionEntry, type ExemptionDeclaration, type LegacyMapping, type LziScriptsConfig, type RegistrySource, type ResolveRegistryOptions, type ResolvedRegistry, type ScriptEntry, type ScriptSeverity, type ScriptsConfigResult, type ScriptsProfileKey, type ScriptsRegistryData, asRegistryData, defineCompanionEntries, defineConfig, defineLegacyMappings, defineProfile, defineRegistry, findScriptsConfigFile, loadScriptsConfig, resolveRegistry };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e}from"node:fs";import{dirname as t,isAbsolute as n,join as r,resolve as i}from"node:path";const a=(e={})=>e,o=[`root`,`root-engineering`,`package`],
|
|
1
|
+
import{existsSync as e}from"node:fs";import{dirname as t,isAbsolute as n,join as r,resolve as i}from"node:path";const a=(e={})=>e,o=e=>e,s=e=>e,c=e=>e,l=e=>e,u=[`root`,`root-engineering`,`package`],d=a=>{let o=n(a)?a:i(process.cwd(),a);for(;o!==`/`;){let n=r(o,`lzi-scripts.config.ts`);if(e(n))return n;o=t(o)}return null},f=e=>typeof e==`object`&&!!e&&!Array.isArray(e),p=e=>typeof e==`string`&&u.includes(e),m=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),h=e=>{if(!f(e))return{};let t={};typeof e.registryRoot==`string`&&(t.registryRoot=e.registryRoot),p(e.profile)&&(t.profile=e.profile);let n=[];if(Array.isArray(e.exempt))for(let t of e.exempt)f(t)&&m(t.scripts)&&typeof t.reason==`string`&&t.reason.length>0&&n.push({scripts:t.scripts,reason:t.reason});n.length>0&&(t.exempt=n);let r=[];if(Array.isArray(e.extraAlternatives))for(let t of e.extraAlternatives)f(t)&&typeof t.script==`string`&&typeof t.definition==`string`&&r.push({script:t.script,definition:t.definition});return r.length>0&&(t.extraAlternatives=r),t},g=async(e=process.cwd())=>{let t=d(e);if(t===null)return{config:{},configPath:null};try{let e=await import(t),n=typeof e==`object`&&e&&`default`in e?e.default:e;if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`配置 default export 须为对象: ${t}`);return{config:h(n),configPath:t}}catch(e){throw e instanceof Error&&e.message.startsWith(`配置 default export`)?e:Error(`加载配置文件失败: ${t} ${e instanceof Error?e.message:String(e)}`)}},_=r(`registry`,`index.ts`),v=e=>typeof e==`string`,y=e=>typeof e==`object`&&!!e&&!Array.isArray(e),b=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),x=e=>e===`required`||e===`recommended`,S=e=>{if(!y(e)||!v(e.name)||!v(e.definition)||!v(e.family)||!x(e.severity)||e.alternatives!==void 0&&!b(e.alternatives))return null;let t={name:e.name,definition:e.definition,severity:e.severity,family:e.family};return e.alternatives!==void 0&&(t.alternatives=e.alternatives),t},C=e=>{if(!y(e)||e.formatVersion!==1)return null;let t={};if(y(e.profiles))for(let[n,r]of Object.entries(e.profiles)){if(n!==`root`&&n!==`root-engineering`&&n!==`package`)continue;let e=[];if(Array.isArray(r))for(let t of r){let n=S(t);n!==null&&e.push(n)}t[n]=e}let n=[];if(Array.isArray(e.companions))for(let t of e.companions)y(t)&&v(t.path)&&v(t.reason)&&x(t.severity)&&n.push({path:t.path,severity:t.severity,reason:t.reason});let r=[];if(Array.isArray(e.legacyMappings))for(let t of e.legacyMappings)y(t)&&v(t.legacyPrefix)&&v(t.targetScript)&&v(t.targetPackage)&&v(t.note)&&r.push({legacyPrefix:t.legacyPrefix,targetScript:t.targetScript,targetPackage:t.targetPackage,note:t.note});return{formatVersion:1,profiles:t,companions:n,legacyMappings:r}},w=async t=>{let a=n(t)?t:i(process.cwd(),t),o=r(a,_);if(!e(o))return null;try{let e=await import(o),t=typeof e==`object`&&e&&`default`in e?e.default:e;return C(t)}catch{return null}},T=async e=>{if(e.explicit!==void 0&&e.explicit!==``){let t=await w(e.explicit);return t===null?null:{data:t,root:i(process.cwd(),e.explicit),source:`explicit`}}if(e.configRoot!==void 0&&e.configRoot!==``){let t=await w(i(e.repoDir,e.configRoot));if(t!==null)return{data:t,root:i(e.repoDir,e.configRoot),source:`config`}}let n=process.env.LZI_SCRIPTS_REGISTRY_ROOT;if(n!==void 0&&n!==``){let e=await w(n);if(e!==null)return{data:e,root:i(n),source:`env`}}let a=r(t(e.repoDir),`longzai-intelligence-scripts-registry`),o=await w(a);return o===null?null:{data:o,root:a,source:`sibling`}};export{C as asRegistryData,c as defineCompanionEntries,a as defineConfig,s as defineLegacyMappings,o as defineProfile,l as defineRegistry,d as findScriptsConfigFile,g as loadScriptsConfig,T as resolveRegistry};
|