@longzai-intelligence-npm-registry/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 +10 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -118,6 +118,12 @@ declare const UpstreamModeSchema: z.ZodEnum<{
|
|
|
118
118
|
off: "off";
|
|
119
119
|
passthrough: "passthrough";
|
|
120
120
|
}>;
|
|
121
|
+
/**
|
|
122
|
+
* 闲置自退段(ADR 0082 §4:registry 为按需拉起的临时服务,静默达阈值即优雅停机)
|
|
123
|
+
*/
|
|
124
|
+
declare const ShutdownSchema: z.ZodObject<{
|
|
125
|
+
idleMs: z.ZodNumber;
|
|
126
|
+
}, z.core.$strict>;
|
|
121
127
|
/**
|
|
122
128
|
* lzi-npm-registry 根配置 zod 契约(strict:多余键即报错,防止拼写漂移静默失效)
|
|
123
129
|
*/
|
|
@@ -132,6 +138,9 @@ declare const NpmRegistryConfigSchema: z.ZodObject<{
|
|
|
132
138
|
publish: z.ZodObject<{
|
|
133
139
|
allowPattern: z.ZodString;
|
|
134
140
|
}, z.core.$strict>;
|
|
141
|
+
shutdown: z.ZodDefault<z.ZodObject<{
|
|
142
|
+
idleMs: z.ZodNumber;
|
|
143
|
+
}, z.core.$strict>>;
|
|
135
144
|
}, z.core.$strict>;
|
|
136
145
|
/**
|
|
137
146
|
* lzi-npm-registry 根配置形态
|
|
@@ -185,4 +194,4 @@ type LoadedNpmRegistryConfig = {
|
|
|
185
194
|
*/
|
|
186
195
|
declare function loadNpmRegistryConfig(cwd?: string): Promise<LoadedNpmRegistryConfig>;
|
|
187
196
|
//#endregion
|
|
188
|
-
export { CENTRAL_DATA_DIR_NAME, DEFAULT_HOST, DEFAULT_NPM_REGISTRY_CONFIG, DEFAULT_PORT, ENV_KEYS, ENV_KEY_DATA_ROOT, ENV_KEY_HOST, ENV_KEY_PORT, type LoadedNpmRegistryConfig, type NpmRegistryConfig, NpmRegistryConfigSchema, type NpmRegistryEnv, NpmRegistryEnvSchema, type ResolvedDataRoot, STANDALONE_CONFIG_FILE, UNIFIED_CONFIG_FIELD, UPSTREAM_MODES, UpstreamModeSchema, loadEffectiveEnv, loadNpmRegistryConfig, parseEnvFileContent, parseNpmRegistryConfig, parseNpmRegistryEnv, resolveDataRoot };
|
|
197
|
+
export { CENTRAL_DATA_DIR_NAME, DEFAULT_HOST, DEFAULT_NPM_REGISTRY_CONFIG, DEFAULT_PORT, ENV_KEYS, ENV_KEY_DATA_ROOT, ENV_KEY_HOST, ENV_KEY_PORT, type LoadedNpmRegistryConfig, type NpmRegistryConfig, NpmRegistryConfigSchema, type NpmRegistryEnv, NpmRegistryEnvSchema, type ResolvedDataRoot, STANDALONE_CONFIG_FILE, ShutdownSchema, UNIFIED_CONFIG_FIELD, UPSTREAM_MODES, UpstreamModeSchema, loadEffectiveEnv, loadNpmRegistryConfig, parseEnvFileContent, parseNpmRegistryConfig, parseNpmRegistryEnv, resolveDataRoot };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import"./rolldown-runtime-BqT_7tdF.js";import{existsSync as e,readFileSync as t}from"node:fs";import{dirname as n,isAbsolute as r,join as i,resolve as a}from"node:path";import*as o from"zod";import{loadUnifiedConfig as s}from"@longzai-intelligence-shared-config/core";const c=`LZI_NPM_REGISTRY_DATA_ROOT`,l=`LZI_NPM_REGISTRY_HOST`,u=`LZI_NPM_REGISTRY_PORT`,d={dataRoot:c,host:l,port:u},f=`127.0.0.1`,p=4874,m=`longzai-intelligence-npm-registry-data`,h=o.object({host:o.string().min(1).default(f),port:o.coerce.number().int().min(0).max(65535).default(p),dataRoot:o.string().min(1).optional()});function g(e){let t={};for(let n of e.split(`
|
|
2
|
-
`)){let e=n.trim();if(e===``||e.startsWith(`#`))continue;let r=e.indexOf(`=`);if(r<=0)continue;let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)&&a.length>=2||a.startsWith(`'`)&&a.endsWith(`'`)&&a.length>=2)&&(a=a.slice(1,-1)),t[i]=a}return t}function _(n){let r={};if(n!==null){let a=i(n,`.env`);e(a)&&(r=g(t(a,`utf8`)))}return{...r,...process.env}}function v(e){let t=h.safeParse({host:e[d.host],port:e[d.port],dataRoot:e[d.dataRoot]});if(!t.success)throw Error(`[config] lzi-npm-registry env 不合法:${t.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`);return t.data}function y(e,t){if(e!==void 0&&e!==``)return{dataRoot:r(e)?e:a(process.cwd(),e),source:`env`};if(t!==null)return{dataRoot:a(t,`../../data`,m),source:`convention`};throw Error(`[config] 无法解析集中数据根(尝试:1) ${d.dataRoot} 环境变量/.env;2) 仓库根 ../../data/${m} 惯例回退,但未找到 lzi-npm-registry.config.ts 无法推导仓库根)。修复:在仓库根运行 \`bun run init\` 固化 .env,或显式设置 ${d.dataRoot}。`)}const b=[`off`,`passthrough`],x=o.enum(b),S=o.strictObject({upstream:o.strictObject({registry:o.url(),mode:x}),publish:o.strictObject({allowPattern:o.string().min(1).refine(e=>{try{return new RegExp(e),!0}catch{return!1}},{error:`allowPattern 必须是合法正则源文本`})})}),
|
|
2
|
+
`)){let e=n.trim();if(e===``||e.startsWith(`#`))continue;let r=e.indexOf(`=`);if(r<=0)continue;let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)&&a.length>=2||a.startsWith(`'`)&&a.endsWith(`'`)&&a.length>=2)&&(a=a.slice(1,-1)),t[i]=a}return t}function _(n){let r={};if(n!==null){let a=i(n,`.env`);e(a)&&(r=g(t(a,`utf8`)))}return{...r,...process.env}}function v(e){let t=h.safeParse({host:e[d.host],port:e[d.port],dataRoot:e[d.dataRoot]});if(!t.success)throw Error(`[config] lzi-npm-registry env 不合法:${t.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`);return t.data}function y(e,t){if(e!==void 0&&e!==``)return{dataRoot:r(e)?e:a(process.cwd(),e),source:`env`};if(t!==null)return{dataRoot:a(t,`../../data`,m),source:`convention`};throw Error(`[config] 无法解析集中数据根(尝试:1) ${d.dataRoot} 环境变量/.env;2) 仓库根 ../../data/${m} 惯例回退,但未找到 lzi-npm-registry.config.ts 无法推导仓库根)。修复:在仓库根运行 \`bun run init\` 固化 .env,或显式设置 ${d.dataRoot}。`)}const b=[`off`,`passthrough`],x=o.enum(b),S=o.strictObject({idleMs:o.number().int().nonnegative()}),C=o.strictObject({upstream:o.strictObject({registry:o.url(),mode:x}),publish:o.strictObject({allowPattern:o.string().min(1).refine(e=>{try{return new RegExp(e),!0}catch{return!1}},{error:`allowPattern 必须是合法正则源文本`})}),shutdown:S.default({idleMs:0})}),w={upstream:{registry:`https://mirrors.cloud.tencent.com/npm/`,mode:`passthrough`},publish:{allowPattern:`^@longzai-intelligence(-[a-z0-9-]+)?/`},shutdown:{idleMs:0}};function T(e){let t=C.safeParse(e);if(!t.success)throw Error(`[config] lzi-npm-registry.config.ts 不合法:${t.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`);return t.data}const E=`lzi-npm-registry.config.ts`,D=`npmRegistry`;async function O(e=process.cwd()){let t=await s({cwd:e,standaloneFile:E,unifiedField:D});return t.success?{config:T(t.config),source:t.source,repoRoot:a(n(t.configFilePath))}:{config:w,source:`builtin`,repoRoot:null}}export{m as CENTRAL_DATA_DIR_NAME,f as DEFAULT_HOST,w as DEFAULT_NPM_REGISTRY_CONFIG,p as DEFAULT_PORT,d as ENV_KEYS,c as ENV_KEY_DATA_ROOT,l as ENV_KEY_HOST,u as ENV_KEY_PORT,C as NpmRegistryConfigSchema,h as NpmRegistryEnvSchema,E as STANDALONE_CONFIG_FILE,S as ShutdownSchema,D as UNIFIED_CONFIG_FIELD,b as UPSTREAM_MODES,x as UpstreamModeSchema,_ as loadEffectiveEnv,O as loadNpmRegistryConfig,g as parseEnvFileContent,T as parseNpmRegistryConfig,v as parseNpmRegistryEnv,y as resolveDataRoot};
|
package/package.json
CHANGED