@longzai-intelligence-oxlint/lzi-builder-config-plugin 0.1.38 → 0.1.40

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.
@@ -1 +1 @@
1
- import"../rolldown-runtime-BqT_7tdF.js";const e={"@longzai-intelligence-oxlint/lzi-builder-config-plugin/require-bin-banner":`error`};export{e as recommended};
1
+ import"../rolldown-runtime-BqT_7tdF.js";const e={"@longzai-intelligence-oxlint/lzi-builder-config-plugin/require-bin-banner":`error`,"@longzai-intelligence-oxlint/lzi-builder-config-plugin/require-version-injection":`error`};export{e as recommended};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import{existsSync as n,readFileSync as r}from"node:fs";import{dirname as i,join as a}from"node:path";const o=/(^|\/)lzi-builder\.config\.(ts|mts)$/,s=`lzi.config.ts`,c=[`lzi-builder.config.ts`,`lzi-builder.config.mts`],l=/banner\s*:\s*['"]#!/,u=/banner\s*:\s*\{[^}]*#!/,d=/(^|\/)dist\//,f=/(^|\/)src\//;function p(e){return typeof e==`object`&&!!e}function m(e){let t=e.replace(/\\/g,`/`);return o.test(t)||t.endsWith(`/${s}`)}function h(e){let t=e.bin;return typeof t==`string`?[t]:p(t)?Object.values(t).filter(e=>typeof e==`string`):[]}function g(e){return l.test(e)||u.test(e)}function _(e){let t=a(e,`package.json`);if(!n(t))return null;try{let e=JSON.parse(r(t,`utf8`));return p(e)?e:null}catch{return null}}function v(e,t){let n=h(e);return n.length===0?null:n.some(e=>d.test(e.replace(/^\.\//,``)))?g(t)?null:`missingBanner`:e.private===!0?null:n.some(e=>f.test(e.replace(/^\.\//,``)))?`binPointsToSource`:null}const y={missingBanner:`bin 入口指向 dist 产物但构建配置缺少 banner,发布后经 npm 软链直执行会交系统 shell 解析而报语法错误。请配置 "banner: '#!/usr/bin/env bun'",规范见 architecture 仓 "docs/best-practices/build-and-toolchain/guides/cli-bin-shebang.md"。`,binPointsToSource:`可发布包的 bin 入口指向 src 源码,安装链软链直指 TS 源码无法执行。请将 bin 指向 "dist" 产物并配置 banner。`},b=e({meta:{type:`problem`,docs:{description:`要求 bin 指向 dist 产物的包在构建配置注入 shebang banner`}},createOnce(e){return{before(){let t=e.filename;if(!m(t))return!1},Program(t){let r=i(e.filename);if(e.filename.replace(/\\/g,`/`).endsWith(`/${s}`)&&c.some(e=>n(a(r,e))))return;let o=_(r);if(o===null)return;let l=v(o,e.sourceCode.text);l!==null&&e.report({node:t,message:y[l]})}}}}),x=t({meta:{name:`@longzai-intelligence-oxlint/lzi-builder-config-plugin`},rules:{"require-bin-banner":b}});export{x as default,x as lziBuilderConfigPlugin,b as requireBinBannerRule};
1
+ import"./rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import{existsSync as n,readFileSync as r}from"node:fs";import{dirname as i,join as a}from"node:path";const o=/(^|\/)lzi-builder\.config\.(ts|mts)$/,s=[`lzi-builder.config.ts`,`lzi-builder.config.mts`],c=/banner\s*:\s*['"]#!/,l=/banner\s*:\s*\{[^}]*#!/,u=/(^|\/)dist\//,d=/(^|\/)src\//;function f(e){return typeof e==`object`&&!!e}function p(e){let t=e.replace(/\\/g,`/`);return o.test(t)||t.endsWith(`/lzi.config.ts`)}function m(e){let t=e.bin;return typeof t==`string`?[t]:f(t)?Object.values(t).filter(e=>typeof e==`string`):[]}function h(e){return c.test(e)||l.test(e)}function g(e){let t=a(e,`package.json`);if(!n(t))return null;try{let e=JSON.parse(r(t,`utf8`));return f(e)?e:null}catch{return null}}function _(e,t){let n=m(e);return n.length===0?null:n.some(e=>u.test(e.replace(/^\.\//,``)))?h(t)?null:`missingBanner`:e.private===!0?null:n.some(e=>d.test(e.replace(/^\.\//,``)))?`binPointsToSource`:null}const v={missingBanner:`bin 入口指向 dist 产物但构建配置缺少 banner,发布后经 npm 软链直执行会交系统 shell 解析而报语法错误。请配置 "banner: '#!/usr/bin/env bun'",规范见 architecture 仓 "docs/best-practices/build-and-toolchain/guides/cli-bin-shebang.md"。`,binPointsToSource:`可发布包的 bin 入口指向 src 源码,安装链软链直指 TS 源码无法执行。请将 bin 指向 "dist" 产物并配置 banner。`},y=e({meta:{type:`problem`,docs:{description:`要求 bin 指向 dist 产物的包在构建配置注入 shebang banner`}},createOnce(e){return{before(){let t=e.filename;if(!p(t))return!1},Program(t){let r=i(e.filename);if(e.filename.replace(/\\/g,`/`).endsWith(`/lzi.config.ts`)&&s.some(e=>n(a(r,e))))return;let o=g(r);if(o===null)return;let c=_(o,e.sourceCode.text);c!==null&&e.report({node:t,message:v[c]})}}}}),b=/readPackageVersionString/;function x(e){return b.test(e)}function S(e,t){let n=m(e);return n.length===0||!n.some(e=>u.test(e.replace(/^\.\//,``)))||x(t)?null:`missingVersionInjection`}const C={missingVersionInjection:`版本注入未启用,bin 入口指向 dist 产物的包 --version 将回退框架兜底版本而非本包版本。请在 define 声明中以 readPackageVersionString 注入本包版本号,键为 process.env.CLI_VERSION,规范见 architecture 仓 ADR 0049 §3。`},w=e({meta:{type:`problem`,docs:{description:`要求 bin 指向 dist 产物的包在构建配置声明版本注入`}},createOnce(e){return{before(){let t=e.filename;if(!p(t))return!1},Program(t){let r=i(e.filename);if(e.filename.replace(/\\/g,`/`).endsWith(`/lzi.config.ts`)&&s.some(e=>n(a(r,e))))return;let o=g(r);if(o===null)return;let c=S(o,e.sourceCode.text);c!==null&&e.report({node:t,message:C[c]})}}}}),T=t({meta:{name:`@longzai-intelligence-oxlint/lzi-builder-config-plugin`},rules:{"require-bin-banner":y,"require-version-injection":w}});export{T as default,T as lziBuilderConfigPlugin,y as requireBinBannerRule};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-oxlint/lzi-builder-config-plugin",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "Longzai Intelligence oxlint 构建器配置规则插件",
5
5
  "keywords": [
6
6
  "builder",
@@ -43,7 +43,7 @@
43
43
  "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json"
44
44
  },
45
45
  "dependencies": {
46
- "@longzai-intelligence-oxlint/core": "0.1.38",
46
+ "@longzai-intelligence-oxlint/core": "0.1.40",
47
47
  "@oxlint/plugins": "^1.74.0"
48
48
  },
49
49
  "devDependencies": {