@longzai-intelligence-git/gitignore-formatter 0.1.3 → 0.1.4

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 CHANGED
@@ -161,7 +161,7 @@ declare function resolveEnabledPresets(presets: Record<string, boolean> | undefi
161
161
  * (`isRoot: true`),其余子目录 `.gitignore` 为非根文件(`isRoot: false`)。
162
162
  * 直接调用格式化器不传时按根文件处理,以保持单文件格式化的向后兼容。
163
163
  */
164
- interface GitignoreFileContext {
164
+ type GitignoreFileContext = {
165
165
  /**
166
166
  * 当前文件是否为配置根 `.gitignore`。
167
167
  *
@@ -169,7 +169,7 @@ interface GitignoreFileContext {
169
169
  * 非根文件只做分类归组不注入。
170
170
  */
171
171
  readonly isRoot?: boolean;
172
- }
172
+ };
173
173
  /**
174
174
  * .gitignore 格式化入口。
175
175
  *
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import{DEFAULT_GITIGNORE_OPTIONS as e,GITIGNORE_PRESETS as t}from"@longzai-intelligence-git/config";function n(e){return e.trim().length===0}function r(e){let t=e.trimStart();return t.length!==0&&t[0]===`#`}function i(e){let t=e.trimStart();return t.length!==0&&t[0]===`!`}function a(e){return e.trimStart().slice(1)}function o(e,t){return e===t||(e.endsWith(`/`)?e.slice(0,-1):e)===(t.endsWith(`/`)?t.slice(0,-1):t)}function s(e,t){let n=e;for(let e=0;e<t.length;e+=1){let r=t[e];if(r!==void 0&&r.patterns.some(e=>o(n,e)))return e}return null}function c(e){if(r(e))return e;let t=e.length;for(;t>0;){let n=e[t-1];if(n===void 0)break;if(n===` `||n===` `){if(e[t-2]===`\\`)break;--t}else break}return e.slice(0,t)}function l(e){return e.replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
3
  `).split(`
4
- `).map(e=>c(e))}function u(e,t){if(!t)return e;let i=new Set,a=[];for(let t of e){if(n(t)||r(t)){a.push(t);continue}i.has(t)||(i.add(t),a.push(t))}return a}function d(e){let t=[];for(let r of e){if(n(r)){t.length>0&&!n(t[t.length-1]??``)&&t.push(``);continue}t.push(r)}for(;t.length>0&&n(t[t.length-1]??``);)t.pop();return t}function f(e,t=!0){let n=d(u(l(e),t));return n.length===0?``:`${n.join(`
5
- `)}\n`}function p(t){return{...e,...t}}function m(e,t){return e<t?-1:+(e>t)}function h(e){let t=f(e,!0);return t===``?[]:t.split(`
4
+ `).map(e=>c(e))}function u(e,t){if(!t)return e;let i=/* @__PURE__ */ new Set,a=[];for(let t of e){if(n(t)||r(t)){a.push(t);continue}i.has(t)||(i.add(t),a.push(t))}return a}function d(e){let t=[];for(let r of e){if(n(r)){t.length>0&&!n(t[t.length-1]??``)&&t.push(``);continue}t.push(r)}for(;t.length>0&&n(t[t.length-1]??``);)t.pop();return t}function f(e,t=!0){let n=d(u(l(e),t));return n.length===0?``:`${n.join(`
5
+ `)}\n`}function p(t){return{...e,...t}}function m(e,t){let n=i(e)?a(e):e,r=i(t)?a(t):t;if(n!==r)return n<r?-1:1;let o=i(e);return o===i(t)?e<t?-1:+(e>t):o?1:-1}function h(e){let t=f(e,!0);return t===``?[]:t.split(`
6
6
  `).filter(e=>!n(e)&&!r(e))}function g(e){let t=e.trim();return t.startsWith(`#`)?t:`# ${t}`}function _(e){if(e===void 0)return[];let n=Object.keys(t),r=[];for(let i of n){let n=t[i];n!==void 0&&(e[i]??n.default)&&r.push({comment:n.comment,patterns:[...n.patterns]})}return r}function v(e,t){return t===void 0||t.length===0?e:[...e,...t]}function y(e,t,n,r){let i=`
7
- `.repeat(Math.max(0,n.blankLinesBetweenGroups)+1),a=[],s=new Set;for(let i of t){if(i===void 0)continue;let t=[];for(let n of e)s.has(n)||i.patterns.some(e=>o(n,e))&&(t.push(n),s.add(n));if(r)for(let n of i.patterns)e.some(e=>o(e,n))||t.push(n);if(t.length===0){r&&a.push(g(i.comment));continue}n.sortWithinGroup&&t.sort(m),a.push([g(i.comment),...t].join(`
7
+ `.repeat(Math.max(0,n.blankLinesBetweenGroups)+1),a=[],s=/* @__PURE__ */ new Set;for(let i of t){if(i===void 0)continue;let t=[];for(let n of e)s.has(n)||i.patterns.some(e=>o(n,e))&&(t.push(n),s.add(n));if(r)for(let n of i.patterns)e.some(e=>o(e,n))||t.push(n);if(t.length===0){r&&a.push(g(i.comment));continue}n.sortWithinGroup&&t.sort(m),a.push([g(i.comment),...t].join(`
8
8
  `))}let c=e.filter(e=>!s.has(e));return c.length>0&&(n.sortWithinGroup&&c.sort(m),a.push([g(n.miscGroupComment),...c].join(`
9
9
  `))),a.length===0?``:`${a.join(i)}\n`}function b(e,t){let i=f(e,t.dedupe);if(i===``)return``;let a=i.split(`
10
10
  `),o=[],s={header:null,patterns:[]},c=!1;for(let e of a)n(e)||(r(e)?(c&&o.push(s),s={header:e,patterns:[]},c=!0):(s.patterns.push(e),c=!0));if(c&&o.push(s),t.sortWithinGroup)for(let e of o)e.patterns.sort(m);let l=`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-git/gitignore-formatter",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Longzai Intelligence Git - .gitignore 格式化业务逻辑",
5
5
  "files": [
6
6
  "dist"
@@ -30,7 +30,7 @@
30
30
  "clean": "lzi-dev-cli clean"
31
31
  },
32
32
  "dependencies": {
33
- "@longzai-intelligence-git/config": "0.1.3"
33
+ "@longzai-intelligence-git/config": "0.1.4"
34
34
  },
35
35
  "devDependencies": {},
36
36
  "peerDependencies": {}