pickety 0.2.3 → 0.4.0
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/.vscodeignore +6 -1
- package/README.md +35 -5
- package/out/cli.js +18 -17
- package/out/extension.js +24 -21
- package/package.json +3 -2
- package/resources/pickety.schema.json +101 -10
package/.vscodeignore
CHANGED
|
@@ -6,6 +6,8 @@ src/**
|
|
|
6
6
|
.yarnrc
|
|
7
7
|
vsc-extension-quickstart.md
|
|
8
8
|
GEMINI.md
|
|
9
|
+
AGENTS.md
|
|
10
|
+
CLAUDE.md
|
|
9
11
|
pickety.json
|
|
10
12
|
node_modules/**
|
|
11
13
|
out/**
|
|
@@ -20,4 +22,7 @@ fix-paths.js
|
|
|
20
22
|
**/*.ts
|
|
21
23
|
**/.vscode-test.*
|
|
22
24
|
picket-boundaries.mermaid
|
|
23
|
-
fixtures/**
|
|
25
|
+
fixtures/**
|
|
26
|
+
|
|
27
|
+
*-debug.log
|
|
28
|
+
*.log
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
Pickety is a VS Code extension that stops architecture erosion before it starts. Define your module boundaries once in a simple JSON file, and every illegal import lights up instantly -- right in your editor,
|
|
13
|
+
Pickety is a VS Code extension that stops architecture erosion before it starts. Define your module boundaries once in a simple JSON file, and every illegal import lights up instantly -- right in your editor, when you save. No more "we don't import that here" comments in code review. No more accidental coupling that quietly rots your codebase over months.
|
|
14
14
|
|
|
15
15
|
Zero runtime dependencies. Zero build steps. Just drop in a config and your entire team — and your AI coding agents — get a **real-time Senior Architect** sitting on their shoulder, enforcing the rules that actually matter.
|
|
16
16
|
|
|
@@ -70,6 +70,8 @@ ESLint's `no-restricted-imports` can block a handful of hard-coded paths. But th
|
|
|
70
70
|
- **On-save enforcement** -- violations appear instantly when you save, keeping feedback fast without noisy mid-keystroke diagnostics
|
|
71
71
|
- **Glob patterns** -- flexible module definitions using [minimatch](https://github.com/isaacs/minimatch) syntax
|
|
72
72
|
- **Interpolation variables** -- enforce scoped relationships like "route X can only import from feature X"
|
|
73
|
+
- **Architecture presets** -- bootstrap configs with built-in presets (`hexagonal`, `feature-modules`, `layered`)
|
|
74
|
+
- **CLI init** -- scaffold `pickety.json` from the terminal, optionally from a preset
|
|
73
75
|
- **Strict enforcement** -- use `only` and `containedTo` to restrict modules to specific consumers
|
|
74
76
|
- **Per-rule severity** -- mark some boundaries as hard errors and others as soft warnings
|
|
75
77
|
- **Debt tracking** -- set a `maxViolations` threshold per rule to adopt boundaries gradually in legacy codebases
|
|
@@ -81,7 +83,7 @@ ESLint's `no-restricted-imports` can block a handful of hard-coded paths. But th
|
|
|
81
83
|
- **Circular dependencies** -- auto-detect feedback loops between your modules
|
|
82
84
|
- **Quick fixes** -- jump directly to the rule in `pickety.json` from any violation
|
|
83
85
|
- **Status bar** -- always know whether Pickety is active and how many violations exist
|
|
84
|
-
- **CLI** -- `pickety check` for CI/CD pipelines,
|
|
86
|
+
- **CLI** -- `pickety check` for CI/CD pipelines, using the same rule logic as the IDE
|
|
85
87
|
- **JSON Schema** -- autocomplete and inline validation for `pickety.json`
|
|
86
88
|
- **No external dependencies** -- self-contained bundle requires zero `npm install` at runtime
|
|
87
89
|
- **Zero config beyond `pickety.json`** -- no build plugins, no complex environment to set up
|
|
@@ -98,6 +100,15 @@ ESLint's `no-restricted-imports` can block a handful of hard-coded paths. But th
|
|
|
98
100
|
|
|
99
101
|
This creates a `pickety.json` in your workspace root and opens it immediately. The generated file includes a starter module map and example rules — edit them to match your project structure.
|
|
100
102
|
|
|
103
|
+
You can also scaffold from the terminal:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pickety init
|
|
107
|
+
pickety init --preset layered
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
You can also set `"preset": "layered"` in `pickety.json` and then override `modules` or `rules`. Preset rules are appended to your own rules.
|
|
111
|
+
|
|
101
112
|
**3. Done.** Pickety activates automatically. Violations appear as red/yellow squiggles in the editor, in the Problems panel, and in the status bar.
|
|
102
113
|
|
|
103
114
|
> **Prefer writing it by hand?** Add a `pickety.json` to your workspace root. The JSON Schema (included via the `$schema` field in the generated file) provides autocomplete and inline validation as you type.
|
|
@@ -153,14 +164,17 @@ Each rule defines an import boundary between modules.
|
|
|
153
164
|
|
|
154
165
|
| Field | Type | Required | Description |
|
|
155
166
|
| ------------- | ------------------- | ----------- | ------------------------------------------------------------------------ |
|
|
156
|
-
| `imports` | `string`
|
|
167
|
+
| `imports` | `string \| string[]` | Yes | Target module name(s), glob(s), or file path pattern(s) |
|
|
157
168
|
| `importer` | `string` | Conditional | Source module name or glob pattern. Required unless using `containedTo`. |
|
|
158
169
|
| `allow` | `boolean` | No | `true` = permit, `false` = forbid. Default: `false` |
|
|
159
170
|
| `only` | `boolean` | No | `true` = the `imports` target can ONLY be used by this `importer`. |
|
|
160
171
|
| `containedTo` | `string \| object` | No | Shortcut for `only: true`. Restricts `imports` to this path pattern. Accepts a plain string or an object with `path` and optional `unless`. |
|
|
172
|
+
| `exports` | `object \| object[]` | No | Allowlist exceptions for `only`/`containedTo` (exported paths and allowed importers) |
|
|
161
173
|
| `message` | `string` | No | Custom diagnostic message shown in the editor |
|
|
162
174
|
| `severity` | `string` | No | `"error"` or `"warn"`. Overrides the global severity |
|
|
163
175
|
| `name` | `string` | No | Rule identifier. Shown in diagnostics and quick fix labels |
|
|
176
|
+
| `group` | `string` | No | Optional group label for diagnostics and CLI summaries |
|
|
177
|
+
| `maxViolations` | `integer` | No | Debt threshold: violations at/below the count are downgraded to warnings |
|
|
164
178
|
|
|
165
179
|
### Glob Patterns
|
|
166
180
|
|
|
@@ -245,11 +259,27 @@ Use `$variable` placeholders to enforce that path segments match between the imp
|
|
|
245
259
|
|
|
246
260
|
With this rule, `routes/auth/index.ts` can import from `features/auth/pages/` but **not** from `features/billing/pages/`.
|
|
247
261
|
|
|
262
|
+
### Export Allowlist (`exports`)
|
|
263
|
+
|
|
264
|
+
Use `exports` to allow specific paths to be imported by specific modules even when `only` or `containedTo` would block them.
|
|
265
|
+
|
|
266
|
+
```json
|
|
267
|
+
{
|
|
268
|
+
"imports": "features/$name/**",
|
|
269
|
+
"containedTo": "features/$name/**",
|
|
270
|
+
"exports": {
|
|
271
|
+
"path": "features/$name/pages/**",
|
|
272
|
+
"to": "app",
|
|
273
|
+
"message": "Only feature pages are public to the app."
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
248
278
|
---
|
|
249
279
|
|
|
250
280
|
## Boundary Diagrams
|
|
251
281
|
|
|
252
|
-
Pickety can auto-generate a [Mermaid](https://mermaid.js.org/) diagram of your module boundaries. Modules are clustered by their top-level path segment, with edges labeled by rule action and name.
|
|
282
|
+
Pickety can auto-generate a [Mermaid](https://mermaid.js.org/) diagram of your module boundaries. Modules are clustered by their top-level path segment, with edges labeled by rule action and name. Diagrams are generated when the config is saved or via the **Pickety: Generate Boundary Diagram** command.
|
|
253
283
|
|
|
254
284
|
Add this to your `pickety.json`:
|
|
255
285
|
|
|
@@ -297,7 +327,7 @@ View these metrics anytime using **Pickety: Show Module Health**, or enforce pro
|
|
|
297
327
|
The Module Health feature provides two interfaces depending on who is using it:
|
|
298
328
|
|
|
299
329
|
- **For Humans:** Running the VS Code command opens a clean, color-coded HTML Webview panel. The table highlights healthy modules in green and unstable or problematic modules in red, making it easy to spot architectural issues at a glance.
|
|
300
|
-
- **For AI Agents:** Running
|
|
330
|
+
- **For AI Agents:** Running `pickety health` outputs a clean, ASCII-formatted table directly to stdout. This allows agents to ingest the current state of your architecture and make informed decisions about where to place new code or when refactoring is needed.
|
|
301
331
|
|
|
302
332
|
```json
|
|
303
333
|
{
|
package/out/cli.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`;break;case 114:m+="\r";break;case 116:m+=" ";break;case 117:let
|
|
4
|
-
`),
|
|
5
|
-
`+" ".repeat(t)),"\r":new Array(
|
|
6
|
-
`+" ".repeat(t))}," ":{"\n":new Array(
|
|
7
|
-
`+" ".repeat(t)),"\r":new Array(
|
|
8
|
-
`+" ".repeat(t))}};var C;(function(e){e.DEFAULT={allowTrailingComma:!1}})(C||(C={}));function Oe(e,t=[],s=C.DEFAULT){let n=null,i=[],r=[];function o(l){Array.isArray(i)?i.push(l):n!==null&&(i[n]=l)}return $e(e,{onObjectBegin:()=>{let l={};o(l),r.push(i),i=l,n=null},onObjectProperty:l=>{n=l},onObjectEnd:()=>{i=r.pop()},onArrayBegin:()=>{let l=[];o(l),r.push(i),i=l,n=null},onArrayEnd:()=>{i=r.pop()},onLiteralValue:o,onError:(l,a,u)=>{t.push({error:l,offset:a,length:u})}},s),i[0]}function $e(e,t,s=C.DEFAULT){let n=K(e,!1),i=[],r=0;function o(k){return k?()=>r===0&&k(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(k){return k?E=>r===0&&k(E,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function l(k){return k?E=>r===0&&k(E,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function a(k){return k?()=>{r>0?r++:k(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(r=1)}:()=>!0}function u(k){return k?()=>{r>0&&r--,r===0&&k(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let f=a(t.onObjectBegin),h=l(t.onObjectProperty),p=u(t.onObjectEnd),g=a(t.onArrayBegin),d=u(t.onArrayEnd),b=l(t.onLiteralValue),T=c(t.onSeparator),O=o(t.onComment),m=c(t.onError),S=s&&s.disallowComments,x=s&&s.allowTrailingComma;function w(){for(;;){let k=n.scan();switch(n.getTokenError()){case 4:y(14);break;case 5:y(15);break;case 3:y(13);break;case 1:S||y(11);break;case 2:y(12);break;case 6:y(16);break}switch(k){case 12:case 13:S?y(10):O();break;case 16:y(1);break;case 15:case 14:break;default:return k}}}function y(k,E=[],Te=[]){if(m(k),E.length+Te.length>0){let Y=n.getToken();for(;Y!==17;){if(E.indexOf(Y)!==-1){w();break}else if(Te.indexOf(Y)!==-1)break;Y=w()}}}function xe(k){let E=n.getTokenValue();return k?b(E):(h(E),i.push(E)),w(),!0}function xt(){switch(n.getToken()){case 11:let k=n.getTokenValue(),E=Number(k);isNaN(E)&&(y(2),E=0),b(E);break;case 7:b(null);break;case 8:b(!0);break;case 9:b(!1);break;default:return!1}return w(),!0}function Tt(){return n.getToken()!==10?(y(3,[],[2,5]),!1):(xe(!1),n.getToken()===6?(T(":"),w(),le()||y(4,[],[2,5])):y(5,[],[2,5]),i.pop(),!0)}function vt(){f(),w();let k=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(k||y(4,[],[]),T(","),w(),n.getToken()===2&&x)break}else k&&y(6,[],[]);Tt()||y(4,[],[2,5]),k=!0}return p(),n.getToken()!==2?y(7,[2],[]):w(),!0}function Et(){g(),w();let k=!0,E=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(E||y(4,[],[]),T(","),w(),n.getToken()===4&&x)break}else E&&y(6,[],[]);k?(i.push(0),k=!1):i[i.length-1]++,le()||y(4,[],[4,5]),E=!0}return d(),k||i.pop(),n.getToken()!==4?y(8,[4],[]):w(),!0}function le(){switch(n.getToken()){case 3:return Et();case 1:return vt();case 10:return xe(!0);default:return xt()}}return w(),n.getToken()===17?s.allowEmptyContent?!0:(y(4,[],[]),!1):le()?(n.getToken()!==17&&y(9,[],[]),!0):(y(4,[],[]),!1)}var Ae;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(Ae||(Ae={}));var Ne;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(Ne||(Ne={}));var ee=Oe;var Re;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Re||(Re={}));var ge=j(require("path"));var ae=(e,t,s)=>{let n=e instanceof RegExp?Ie(e,s):e,i=t instanceof RegExp?Ie(t,s):t,r=n!==null&&i!=null&&Wt(n,i,s);return r&&{start:r[0],end:r[1],pre:s.slice(0,r[0]),body:s.slice(r[0]+n.length,r[1]),post:s.slice(r[1]+i.length)}},Ie=(e,t)=>{let s=t.match(e);return s?s[0]:null},Wt=(e,t,s)=>{let n,i,r,o,c,l=s.indexOf(e),a=s.indexOf(t,l+1),u=l;if(l>=0&&a>0){if(e===t)return[l,a];for(n=[],r=s.length;u>=0&&!c;){if(u===l)n.push(u),l=s.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(c=[f,a])}else i=n.pop(),i!==void 0&&i<r&&(r=i,o=a),a=s.indexOf(t,u+1);u=l<a&&l>=0?l:a}n.length&&o!==void 0&&(c=[r,o])}return c};var Le="\0SLASH"+Math.random()+"\0",Me="\0OPEN"+Math.random()+"\0",ue="\0CLOSE"+Math.random()+"\0",Ve="\0COMMA"+Math.random()+"\0",Be="\0PERIOD"+Math.random()+"\0",zt=new RegExp(Le,"g"),Ut=new RegExp(Me,"g"),Ht=new RegExp(ue,"g"),Gt=new RegExp(Ve,"g"),qt=new RegExp(Be,"g"),Xt=/\\\\/g,Jt=/\\{/g,Zt=/\\}/g,Qt=/\\,/g,Yt=/\\./g,Kt=1e5;function fe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Ct(e){return e.replace(Xt,Le).replace(Jt,Me).replace(Zt,ue).replace(Qt,Ve).replace(Yt,Be)}function en(e){return e.replace(zt,"\\").replace(Ut,"{").replace(Ht,"}").replace(Gt,",").replace(qt,".")}function _e(e){if(!e)return[""];let t=[],s=ae("{","}",e);if(!s)return e.split(",");let{pre:n,body:i,post:r}=s,o=n.split(",");o[o.length-1]+="{"+i+"}";let c=_e(r);return r.length&&(o[o.length-1]+=c.shift(),o.push.apply(o,c)),t.push.apply(t,o),t}function De(e,t={}){if(!e)return[];let{max:s=Kt}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),G(Ct(e),s,!0).map(en)}function tn(e){return"{"+e+"}"}function nn(e){return/^-?0\d/.test(e)}function sn(e,t){return e<=t}function rn(e,t){return e>=t}function G(e,t,s){let n=[],i=ae("{","}",e);if(!i)return[e];let r=i.pre,o=i.post.length?G(i.post,t,!1):[""];if(/\$$/.test(i.pre))for(let c=0;c<o.length&&c<t;c++){let l=r+"{"+i.body+"}"+o[c];n.push(l)}else{let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),a=c||l,u=i.body.indexOf(",")>=0;if(!a&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+"{"+i.body+ue+i.post,G(e,t,!0)):[e];let f;if(a)f=i.body.split(/\.\./);else if(f=_e(i.body),f.length===1&&f[0]!==void 0&&(f=G(f[0],t,!1).map(tn),f.length===1))return o.map(p=>i.pre+f[0]+p);let h;if(a&&f[0]!==void 0&&f[1]!==void 0){let p=fe(f[0]),g=fe(f[1]),d=Math.max(f[0].length,f[1].length),b=f.length===3&&f[2]!==void 0?Math.abs(fe(f[2])):1,T=sn;g<p&&(b*=-1,T=rn);let m=f.some(nn);h=[];for(let S=p;T(S,g);S+=b){let x;if(l)x=String.fromCharCode(S),x==="\\"&&(x="");else if(x=String(S),m){let w=d-x.length;if(w>0){let y=new Array(w+1).join("0");S<0?x="-"+y+x.slice(1):x=y+x}}h.push(x)}}else{h=[];for(let p=0;p<f.length;p++)h.push.apply(h,G(f[p],t,!1))}for(let p=0;p<h.length;p++)for(let g=0;g<o.length&&n.length<t;g++){let d=r+h[p]+o[g];(!s||a||d)&&n.push(d)}}return n}var q=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var on={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},X=e=>e.replace(/[[\]\\-]/g,"\\$&"),ln=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Fe=e=>e.join(""),Pe=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let n=[],i=[],r=s+1,o=!1,c=!1,l=!1,a=!1,u=s,f="";e:for(;r<e.length;){let d=e.charAt(r);if((d==="!"||d==="^")&&r===s+1){a=!0,r++;continue}if(d==="]"&&o&&!l){u=r+1;break}if(o=!0,d==="\\"&&!l){l=!0,r++;continue}if(d==="["&&!l){for(let[b,[T,O,m]]of Object.entries(on))if(e.startsWith(b,r)){if(f)return["$.",!1,e.length-s,!0];r+=b.length,m?i.push(T):n.push(T),c=c||O;continue e}}if(l=!1,f){d>f?n.push(X(f)+"-"+X(d)):d===f&&n.push(X(d)),f="",r++;continue}if(e.startsWith("-]",r+1)){n.push(X(d+"-")),r+=2;continue}if(e.startsWith("-",r+1)){f=d,r+=2;continue}n.push(X(d)),r++}if(u<r)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-s,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!a){let d=n[0].length===2?n[0].slice(-1):n[0];return[ln(d),!1,u-s,!1]}let h="["+(a?"^":"")+Fe(n)+"]",p="["+(a?"":"^")+Fe(i)+"]";return[n.length&&i.length?"("+h+"|"+p+")":n.length?h:p,c,u-s,!0]};var I=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!0}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var cn=new Set(["!","?","+","*","@"]),We=e=>cn.has(e),an="(?!(?:^|/)\\.\\.?(?:$|/))",te="(?!\\.)",fn=new Set(["[","."]),un=new Set(["..","."]),pn=new Set("().*{}+?[]^$\\!"),hn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),pe="[^/]",ze=pe+"*?",Ue=pe+"+?",W=class e{type;#n;#s;#r=!1;#e=[];#t;#o;#c;#l=!1;#i;#a;#u=!1;constructor(t,s,n={}){this.type=t,t&&(this.#s=!0),this.#t=s,this.#n=this.#t?this.#t.#n:this,this.#i=this.#n===this?n:this.#n.#i,this.#c=this.#n===this?[]:this.#n.#c,t==="!"&&!this.#n.#l&&this.#c.push(this),this.#o=this.#t?this.#t.#e.length:0}get hasMagic(){if(this.#s!==void 0)return this.#s;for(let t of this.#e)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#s=!0;return this.#s}toString(){return this.#a!==void 0?this.#a:this.type?this.#a=this.type+"("+this.#e.map(t=>String(t)).join("|")+")":this.#a=this.#e.map(t=>String(t)).join("")}#h(){if(this!==this.#n)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#c.pop();){if(t.type!=="!")continue;let s=t,n=s.#t;for(;n;){for(let i=s.#o+1;!n.type&&i<n.#e.length;i++)for(let r of t.#e){if(typeof r=="string")throw new Error("string part in extglob AST??");r.copyIn(n.#e[i])}s=n,n=s.#t}}return this}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof e&&s.#t===this))throw new Error("invalid part: "+s);this.#e.push(s)}}toJSON(){let t=this.type===null?this.#e.slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...this.#e.map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#n||this.#n.#l&&this.#t?.type==="!")&&t.push({}),t}isStart(){if(this.#n===this)return!0;if(!this.#t?.isStart())return!1;if(this.#o===0)return!0;let t=this.#t;for(let s=0;s<this.#o;s++){let n=t.#e[s];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#n===this||this.#t?.type==="!")return!0;if(!this.#t?.isEnd())return!1;if(!this.type)return this.#t?.isEnd();let t=this.#t?this.#t.#e.length:0;return this.#o===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let s=new e(this.type,t);for(let n of this.#e)s.copyIn(n);return s}static#f(t,s,n,i){let r=!1,o=!1,c=-1,l=!1;if(s.type===null){let p=n,g="";for(;p<t.length;){let d=t.charAt(p++);if(r||d==="\\"){r=!r,g+=d;continue}if(o){p===c+1?(d==="^"||d==="!")&&(l=!0):d==="]"&&!(p===c+2&&l)&&(o=!1),g+=d;continue}else if(d==="["){o=!0,c=p,l=!1,g+=d;continue}if(!i.noext&&We(d)&&t.charAt(p)==="("){s.push(g),g="";let b=new e(d,s);p=e.#f(t,b,p,i),s.push(b);continue}g+=d}return s.push(g),p}let a=n+1,u=new e(null,s),f=[],h="";for(;a<t.length;){let p=t.charAt(a++);if(r||p==="\\"){r=!r,h+=p;continue}if(o){a===c+1?(p==="^"||p==="!")&&(l=!0):p==="]"&&!(a===c+2&&l)&&(o=!1),h+=p;continue}else if(p==="["){o=!0,c=a,l=!1,h+=p;continue}if(We(p)&&t.charAt(a)==="("){u.push(h),h="";let g=new e(p,u);u.push(g),a=e.#f(t,g,a,i);continue}if(p==="|"){u.push(h),h="",f.push(u),u=new e(null,s);continue}if(p===")")return h===""&&s.#e.length===0&&(s.#u=!0),u.push(h),h="",s.push(...f,u),a;h+=p}return s.type=null,s.#s=void 0,s.#e=[t.substring(n-1)],a}static fromGlob(t,s={}){let n=new e(null,void 0,s);return e.#f(t,n,0,s),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let t=this.toString(),[s,n,i,r]=this.toRegExpSource();if(!(i||this.#s||this.#i.nocase&&!this.#i.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let c=(this.#i.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${s}$`,c),{_src:s,_glob:t})}get options(){return this.#i}toRegExpSource(t){let s=t??!!this.#i.dot;if(this.#n===this&&this.#h(),!this.type){let l=this.isStart()&&this.isEnd()&&!this.#e.some(p=>typeof p!="string"),a=this.#e.map(p=>{let[g,d,b,T]=typeof p=="string"?e.#g(p,this.#s,l):p.toRegExpSource(t);return this.#s=this.#s||b,this.#r=this.#r||T,g}).join(""),u="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&un.has(this.#e[0]))){let g=fn,d=s&&g.has(a.charAt(0))||a.startsWith("\\.")&&g.has(a.charAt(2))||a.startsWith("\\.\\.")&&g.has(a.charAt(4)),b=!s&&!t&&g.has(a.charAt(0));u=d?an:b?te:""}let f="";return this.isEnd()&&this.#n.#l&&this.#t?.type==="!"&&(f="(?:$|\\/)"),[u+a+f,I(a),this.#s=!!this.#s,this.#r]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",r=this.#p(s);if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){let l=this.toString();return this.#e=[l],this.type=null,this.#s=void 0,[l,I(this.toString()),!1,!1]}let o=!n||t||s||!te?"":this.#p(!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let c="";if(this.type==="!"&&this.#u)c=(this.isStart()&&!s?te:"")+Ue;else{let l=this.type==="!"?"))"+(this.isStart()&&!s&&!t?te:"")+ze+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;c=i+r+l}return[c,I(r),this.#s=!!this.#s,this.#r]}#p(t){return this.#e.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[n,i,r,o]=s.toRegExpSource(t);return this.#r=this.#r||o,n}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#g(t,s,n=!1){let i=!1,r="",o=!1,c=!1;for(let l=0;l<t.length;l++){let a=t.charAt(l);if(i){i=!1,r+=(pn.has(a)?"\\":"")+a;continue}if(a==="*"){if(c)continue;c=!0,r+=n&&/^[*]+$/.test(t)?Ue:ze,s=!0;continue}else c=!1;if(a==="\\"){l===t.length-1?r+="\\\\":i=!0;continue}if(a==="["){let[u,f,h,p]=Pe(t,l);if(h){r+=u,o=o||f,l+=h-1,s=s||p;continue}}if(a==="?"){r+=pe,s=!0;continue}r+=hn(a)}return[r,I(t),!!s,o]}};var he=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!1}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var v=(e,t,s={})=>(q(t),!s.nocomment&&t.charAt(0)==="#"?!1:new z(t,s).match(e)),gn=/^\*+([^+@!?\*\[\(]*)$/,dn=e=>t=>!t.startsWith(".")&&t.endsWith(e),mn=e=>t=>t.endsWith(e),yn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),bn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),kn=/^\*+\.\*+$/,wn=e=>!e.startsWith(".")&&e.includes("."),Sn=e=>e!=="."&&e!==".."&&e.includes("."),xn=/^\.\*+$/,Tn=e=>e!=="."&&e!==".."&&e.startsWith("."),vn=/^\*+$/,En=e=>e.length!==0&&!e.startsWith("."),On=e=>e.length!==0&&e!=="."&&e!=="..",$n=/^\?+([^+@!?\*\[\(]*)?$/,An=([e,t=""])=>{let s=qe([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},Nn=([e,t=""])=>{let s=Xe([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},Rn=([e,t=""])=>{let s=Xe([e]);return t?n=>s(n)&&n.endsWith(t):s},jn=([e,t=""])=>{let s=qe([e]);return t?n=>s(n)&&n.endsWith(t):s},qe=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},Xe=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Je=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",He={win32:{sep:"\\"},posix:{sep:"/"}},In=Je==="win32"?He.win32.sep:He.posix.sep;v.sep=In;var R=Symbol("globstar **");v.GLOBSTAR=R;var Ln="[^/]",Mn=Ln+"*?",Vn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Bn="(?:(?!(?:\\/|^)\\.).)*?",_n=(e,t={})=>s=>v(s,e,t);v.filter=_n;var N=(e,t={})=>Object.assign({},e,t),Dn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return v;let t=v;return Object.assign((n,i,r={})=>t(n,i,N(e,r)),{Minimatch:class extends t.Minimatch{constructor(i,r={}){super(i,N(e,r))}static defaults(i){return t.defaults(N(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,r,o={}){super(i,r,N(e,o))}static fromGlob(i,r={}){return t.AST.fromGlob(i,N(e,r))}},unescape:(n,i={})=>t.unescape(n,N(e,i)),escape:(n,i={})=>t.escape(n,N(e,i)),filter:(n,i={})=>t.filter(n,N(e,i)),defaults:n=>t.defaults(N(e,n)),makeRe:(n,i={})=>t.makeRe(n,N(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,N(e,i)),match:(n,i,r={})=>t.match(n,i,N(e,r)),sep:t.sep,GLOBSTAR:R})};v.defaults=Dn;var Ze=(e,t={})=>(q(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:De(e,{max:t.braceExpandMax}));v.braceExpand=Ze;var Fn=(e,t={})=>new z(e,t).makeRe();v.makeRe=Fn;var Pn=(e,t,s={})=>{let n=new z(t,s);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};v.match=Pn;var Ge=/[?*]|[+@!]\(.*?\)|\[|\]/,Wn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),z=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,s={}){q(t),s=s||{},this.options=s,this.pattern=t,this.platform=s.platform||Je,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!s.windowsPathsNoEscape||s[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!s.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!s.nonegate,this.comment=!1,this.empty=!1,this.partial=!!s.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=s.windowsNoMagicRoot!==void 0?s.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let s of t)if(typeof s!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,s=this.options;if(!s.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],s.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,o,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=r[0]===""&&r[1]===""&&(r[2]==="?"||!Ge.test(r[2]))&&!Ge.test(r[3]),a=/^[a-z]:/i.test(r[0]);if(l)return[...r.slice(0,4),...r.slice(4).map(u=>this.parse(u))];if(a)return[r[0],...r.slice(1).map(u=>this.parse(u))]}return r.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let i=0;i<t[n].length;i++)t[n][i]==="**"&&(t[n][i]="*");let{optimizationLevel:s=1}=this.options;return s>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):s>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(s=>{let n=-1;for(;(n=s.indexOf("**",n+1))!==-1;){let i=n;for(;s[i+1]==="**";)i++;i!==n&&s.splice(n,i-n)}return s})}levelOneOptimize(t){return t.map(s=>(s=s.reduce((n,i)=>{let r=n[n.length-1];return i==="**"&&r==="**"?n:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(n.pop(),n):(n.push(i),n)},[]),s.length===0?[""]:s))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let s=!1;do{if(s=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let r=t[i];i===1&&r===""&&t[0]===""||(r==="."||r==="")&&(s=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(s=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(s=!0,t.splice(n-1,2),n-=2)}}while(s);return t.length===0?[""]:t}firstPhasePreProcess(t){let s=!1;do{s=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let c=n[i+1],l=n[i+2],a=n[i+3];if(c!==".."||!l||l==="."||l===".."||!a||a==="."||a==="..")continue;s=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let c=n[o];o===1&&c===""&&n[0]===""||(c==="."||c==="")&&(s=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(s=!0,n.pop())}let r=0;for(;(r=n.indexOf("..",r+1))!==-1;){let o=n[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){s=!0;let l=r===1&&n[r+1]==="**"?["."]:[];n.splice(r-1,2,...l),n.length===0&&n.push(""),r-=2}}}}while(s);return t}secondPhasePreProcess(t){for(let s=0;s<t.length-1;s++)for(let n=s+1;n<t.length;n++){let i=this.partsMatch(t[s],t[n],!this.preserveMultipleSlashes);if(i){t[s]=[],t[n]=i;break}}return t.filter(s=>s.length)}partsMatch(t,s,n=!1){let i=0,r=0,o=[],c="";for(;i<t.length&&r<s.length;)if(t[i]===s[r])o.push(c==="b"?s[r]:t[i]),i++,r++;else if(n&&t[i]==="**"&&s[r]===t[i+1])o.push(t[i]),i++;else if(n&&s[r]==="**"&&t[i]===s[r+1])o.push(s[r]),r++;else if(t[i]==="*"&&s[r]&&(this.options.dot||!s[r].startsWith("."))&&s[r]!=="**"){if(c==="b")return!1;c="a",o.push(t[i]),i++,r++}else if(s[r]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(c==="a")return!1;c="b",o.push(s[r]),i++,r++}else return!1;return t.length===s.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,s=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)s=!s,n++;n&&(this.pattern=t.slice(n)),this.negate=s}matchOne(t,s,n=!1){let i=this.options;if(this.isWindows){let d=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),b=!d&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),T=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),O=!T&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),m=b?3:d?0:void 0,S=O?3:T?0:void 0;if(typeof m=="number"&&typeof S=="number"){let[x,w]=[t[m],s[S]];x.toLowerCase()===w.toLowerCase()&&(s[S]=x,S>m?s=s.slice(S):m>S&&(t=t.slice(m)))}}let{optimizationLevel:r=1}=this.options;r>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:s}),this.debug("matchOne",t.length,s.length);for(var o=0,c=0,l=t.length,a=s.length;o<l&&c<a;o++,c++){this.debug("matchOne loop");var u=s[c],f=t[o];if(this.debug(s,u,f),u===!1)return!1;if(u===R){this.debug("GLOBSTAR",[s,u,f]);var h=o,p=c+1;if(p===a){for(this.debug("** at the end");o<l;o++)if(t[o]==="."||t[o]===".."||!i.dot&&t[o].charAt(0)===".")return!1;return!0}for(;h<l;){var g=t[h];if(this.debug(`
|
|
9
|
-
globstar while`,t,
|
|
10
|
-
>>> no match, partial?`,t,h,s,p),h===l))}let d;if(typeof u=="string"?(d=f===u,this.debug("string match",u,f,d)):(d=u.test(f),this.debug("pattern match",u,f,d)),!d)return!1}if(o===l&&c===a)return!0;if(o===l)return n;if(c===a)return o===l-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return Ze(this.pattern,this.options)}parse(t){q(t);let s=this.options;if(t==="**")return R;if(t==="")return"";let n,i=null;(n=t.match(vn))?i=s.dot?On:En:(n=t.match(gn))?i=(s.nocase?s.dot?bn:yn:s.dot?mn:dn)(n[1]):(n=t.match($n))?i=(s.nocase?s.dot?Nn:An:s.dot?Rn:jn)(n):(n=t.match(kn))?i=s.dot?Sn:wn:(n=t.match(xn))&&(i=Tn);let r=W.fromGlob(t,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let s=this.options,n=s.noglobstar?Mn:s.dot?Vn:Bn,i=new Set(s.nocase?["i"]:[]),r=t.map(l=>{let a=l.map(f=>{if(f instanceof RegExp)for(let h of f.flags.split(""))i.add(h);return typeof f=="string"?Wn(f):f===R?R:f._src});a.forEach((f,h)=>{let p=a[h+1],g=a[h-1];f!==R||g===R||(g===void 0?p!==void 0&&p!==R?a[h+1]="(?:\\/|"+n+"\\/)?"+p:a[h]=n:p===void 0?a[h-1]=g+"(?:\\/|\\/"+n+")?":p!==R&&(a[h-1]=g+"(?:\\/|\\/"+n+"\\/)"+p,a[h+1]=R))});let u=a.filter(f=>f!==R);if(this.partial&&u.length>=1){let f=[];for(let h=1;h<=u.length;h++)f.push(u.slice(0,h).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[o,c]=t.length>1?["(?:",")"]:["",""];r="^"+o+r+c+"$",this.partial&&(r="^(?:\\/|"+o+r.slice(1,-1)+c+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,s=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&s)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let o=i[i.length-1];if(!o)for(let c=i.length-2;!o&&c>=0;c--)o=i[c];for(let c=0;c<r.length;c++){let l=r[c],a=i;if(n.matchBase&&l.length===1&&(a=[o]),this.matchOne(a,l,s))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return v.defaults(t).Minimatch}};v.AST=W;v.Minimatch=z;v.escape=he;v.unescape=I;var de="pickety.json",U=["ts","tsx","js","jsx","mjs","cjs"],zn=`**/*.{${U.join(",")}}`,ne=new Set(["node_modules",".git",".next","dist","out","build",".turbo",".cache",".nx","coverage"]);function $(e){let t=e.replace(/\\/g,"/");return/^[a-zA-Z]:/.test(t)&&(t=t[0].toLowerCase()+t.slice(1)),t}function J(e,t){return ge.relative(e,t).replace(/\\/g,"/")}function Qe(e,t){return v(e,t)||e===t}function se(e,t){return e==="instability"?t.toFixed(2):String(t)}function Ye(e,t,s){let n=me(e);return{allow:e.allow??!1,severity:e.severity??s,name:e.name??`rule[${t}]`,effectiveImporter:n?.path||e.importer||"*",isOnly:e.only||!!e.containedTo,isAllowStyle:(e.allow??!1)||!!e.containedTo||e.only}}function L(e,t,s){return!!(Qe(e,s)||s.includes("/")&&(v(t,s)||v(t,`**/${s}`)||v(t,`**/${s}/**`)))}function me(e){if(e.containedTo)return typeof e.containedTo=="object"?e.containedTo:{path:e.containedTo}}function B(e,t,s,n,i,r,o){return{file:e,line:t.line,character:t.character,length:t.length,message:`[${s}] ${n} (importing "${t.specifier}")`,severity:i,ruleName:s,sourceModule:r,targetModule:o}}function Ke(e){let t=[],s=new Set,n=new Set,i=[];function r(o){s.add(o),n.add(o),i.push(o);let c=e.get(o);if(c){for(let l of c)if(!s.has(l))r(l);else if(n.has(l)){let a=i.indexOf(l);a!==-1&&t.push([...i.slice(a),l])}}n.delete(o),i.pop()}for(let o of e.keys())s.has(o)||r(o);return t}function Ce(e,t,s,n){if(typeof e.containedTo=="object"&&e.containedTo!==null){let i=e.containedTo;if(typeof i.path!="string"&&n.push({message:`Rule #${t}: "containedTo.path" is required and must be a string`,path:`${s}.containedTo.path`}),i.unless!==void 0)if(typeof i.unless!="object"||i.unless===null||Array.isArray(i.unless))n.push({message:`Rule #${t}: "containedTo.unless" must be an object`,path:`${s}.containedTo.unless`});else{let r=i.unless;Object.keys(r).length===0&&n.push({message:`Rule #${t}: "containedTo.unless" must not be empty`,path:`${s}.containedTo.unless`}),typeof e.imports=="string"&&!e.imports.match(/\$[\w-]+/)&&n.push({message:`Rule #${t}: "containedTo.unless" requires "imports" to contain at least one $variable`,path:`${s}.containedTo.unless`});for(let[c,l]of Object.entries(r))c.startsWith("$")||n.push({message:`Rule #${t}: "containedTo.unless" key "${c}" must start with $`,path:`${s}.containedTo.unless`}),typeof l!="string"&&n.push({message:`Rule #${t}: "containedTo.unless.${c}" must be a string`,path:`${s}.containedTo.unless.${c}`})}}else typeof e.containedTo!="string"&&n.push({message:`Rule #${t}: "containedTo" must be a string or object with a "path" property`,path:`${s}.containedTo`})}function et(e,t){if(e===void 0){t.push({message:'"rules" is required and must be an object',path:"rules"});return}if(typeof e!="object"||e===null){t.push({message:'"rules" must be an object',path:"rules"});return}let n=e["module-boundaries"];if(n===void 0){t.push({message:'"rules.module-boundaries" is required and must be an object',path:"rules.module-boundaries"});return}if(typeof n!="object"||n===null){t.push({message:'"rules.module-boundaries" must be an object',path:"rules.module-boundaries"});return}let i=n,r="error";if(i.severity!==void 0&&(i.severity!=="error"&&i.severity!=="warn"?t.push({message:`"rules.module-boundaries.severity" must be "error" or "warn", got "${i.severity}"`,path:"rules.module-boundaries.severity"}):r=i.severity),i.rules===void 0){t.push({message:'"rules.module-boundaries.rules" is required and must be an array',path:"rules.module-boundaries.rules"});return}if(!Array.isArray(i.rules)){t.push({message:'"rules.module-boundaries.rules" must be an array',path:"rules.module-boundaries.rules"});return}let o=[];return i.rules.forEach((c,l)=>{let a=`rules.module-boundaries.rules[${l}]`;if(typeof c!="object"||c===null){t.push({message:`Rule #${l} must be an object`,path:a});return}let u=c,f=typeof u.containedTo=="string"||typeof u.containedTo=="object"&&u.containedTo!==null;typeof u.importer!="string"&&!f&&t.push({message:`Rule #${l}: "importer" or "containedTo" is required`,path:a}),u.importer!==void 0&&typeof u.importer!="string"&&t.push({message:`Rule #${l}: "importer" must be a string`,path:`${a}.importer`}),typeof u.imports!="string"&&t.push({message:`Rule #${l}: "imports" is required and must be a string`,path:`${a}.imports`}),u.allow!==void 0&&typeof u.allow!="boolean"&&t.push({message:`Rule #${l}: "allow" must be a boolean`,path:`${a}.allow`}),u.only!==void 0&&typeof u.only!="boolean"&&t.push({message:`Rule #${l}: "only" must be a boolean`,path:`${a}.only`}),u.containedTo!==void 0&&Ce(u,l,a,t),u.message!==void 0&&typeof u.message!="string"&&t.push({message:`Rule #${l}: "message" must be a string`,path:`${a}.message`}),u.severity!==void 0&&u.severity!=="error"&&u.severity!=="warn"&&t.push({message:`Rule #${l}: "severity" must be "error" or "warn", got "${u.severity}"`,path:`${a}.severity`}),u.name!==void 0&&typeof u.name!="string"&&t.push({message:`Rule #${l}: "name" must be a string`,path:`${a}.name`}),u.maxViolations!==void 0&&(typeof u.maxViolations!="number"||!Number.isInteger(u.maxViolations)||u.maxViolations<0)&&t.push({message:`Rule #${l}: "maxViolations" must be a non-negative integer`,path:`${a}.maxViolations`}),o.push(u)}),{severity:r,rules:o}}function tt(e,t){if(e===void 0)return;if(typeof e!="object"||e===null){t.push({message:'"health" must be an object',path:"health"});return}let s=e,n={},i=[{key:"maxAfferentCoupling",label:"maxAfferentCoupling"},{key:"maxEfferentCoupling",label:"maxEfferentCoupling"},{key:"maxDepth",label:"maxDepth"}];for(let{key:r,label:o}of i){let c=s[r];c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<1?t.push({message:`"health.${o}" must be a positive integer`,path:`health.${o}`}):n[r]=c)}if(s.maxInstability!==void 0){let r=s.maxInstability;typeof r!="number"||r<0||r>1?t.push({message:'"health.maxInstability" must be a number between 0 and 1',path:"health.maxInstability"}):n.maxInstability=r}return Object.keys(n).length>0?n:void 0}function nt(e){let t=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let s=e,n=Un(s.modules,t),i=et(s.rules,t),r=Hn(s["boundary-diagrams"],t),o=tt(s.health,t);return t.length>0||!n||!i?{ok:!1,errors:t}:{ok:!0,config:{modules:n,rules:{"module-boundaries":i},"boundary-diagrams":r,health:o}}}function Un(e,t){if(e===void 0){t.push({message:'"modules" is required and must be an object',path:"modules"});return}if(typeof e!="object"||e===null){t.push({message:'"modules" must be an object mapping module names to patterns',path:"modules"});return}let s={};for(let[n,i]of Object.entries(e))typeof i!="string"?t.push({message:`Module "${n}" pattern must be a string, got ${typeof i}`,path:`modules.${n}`}):s[n]=i;return s}function Hn(e,t){if(e!==void 0){if(typeof e!="boolean"&&typeof e!="string"){t.push({message:'"boundary-diagrams" must be a boolean or a string',path:"boundary-diagrams"});return}return e}}function it(e){let t=st.join(e,de);if(!ie.existsSync(t))return{ok:!0,config:void 0};try{let s=ie.readFileSync(t,"utf-8"),n;try{n=ee(s)}catch(i){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${i instanceof Error?i.message:String(i)}`}]}}return nt(n)}catch(s){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${s instanceof Error?s.message:String(s)}`}]}}}var re=j(require("fs")),M=j(require("path"));function rt(e,t){if(t<0)return[];let s=[],n;try{n=re.readdirSync(e,{withFileTypes:!0})}catch{return s}for(let i of n)!ne.has(i.name)&&i.isFile()&&/^tsconfig(\..+)?\.json$/.test(i.name)&&s.push(M.join(e,i.name));for(let i of n)!ne.has(i.name)&&i.isDirectory()&&s.push(...rt(M.join(e,i.name),t-1));return s}function ot(e){let t={},s=rt(e,4);for(let n of s)try{let i=re.readFileSync(n,"utf-8"),o=ee(i).compilerOptions;if(!o?.paths)continue;let c=M.dirname(n),l=M.relative(e,c),a=o.baseUrl||".";for(let[u,f]of Object.entries(o.paths))if(Array.isArray(f)&&f.length>0){let h=f[0];t[u]||(t[u]=$(M.join(l,a,h)))}}catch{}return t}var ke=j(require("path"));var V=j(require("path"));var ct=U.map(e=>`.${e}`),Gn=ct.map(e=>`index${e}`),lt=/(\/\*[\s\S]*?\*\/|\/\/.*)|(['"`](?:\\.|[^'"`])*['"`])|((?:import|export)\s+(?:[\s\S]*?from\s+)?['"`]([^'"`]+)['"`])|(import\s*\(\s*['"`]([^'"`]+)['"`]\s*\))/gm;function qn(e){let t=[],s=e.split(`
|
|
11
|
-
`),n=[],
|
|
12
|
-
`),r.
|
|
13
|
-
`)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
${r.length}
|
|
18
|
-
|
|
2
|
+
"use strict";var zt=Object.create;var je=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var qt=Object.getOwnPropertyNames;var Jt=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty;var Zt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of qt(t))!Xt.call(e,s)&&s!==r&&je(e,s,{get:()=>t[s],enumerable:!(n=Ht(t,s))||n.enumerable});return e};var j=(e,t,r)=>(r=e!=null?zt(Jt(e)):{},Zt(t||!e||!e.__esModule?je(r,"default",{value:e,enumerable:!0}):r,e));var I=j(require("fs")),U=j(require("path"));var kt=j(require("path")),pe=j(require("fs"));function re(e,t=!1){let r=e.length,n=0,s="",o=0,i=16,a=0,l=0,u=0,c=0,f=0;function p(m,k){let w=0,v=0;for(;w<m||!k;){let b=e.charCodeAt(n);if(b>=48&&b<=57)v=v*16+b-48;else if(b>=65&&b<=70)v=v*16+b-65+10;else if(b>=97&&b<=102)v=v*16+b-97+10;else break;n++,w++}return w<m&&(v=-1),v}function d(m){n=m,s="",o=0,i=16,f=0}function g(){let m=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&G(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&G(e.charCodeAt(n)))for(n++;n<e.length&&G(e.charCodeAt(n));)n++;else return f=3,e.substring(m,n);let k=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&G(e.charCodeAt(n))){for(n++;n<e.length&&G(e.charCodeAt(n));)n++;k=n}else f=3;return e.substring(m,k)}function h(){let m="",k=n;for(;;){if(n>=r){m+=e.substring(k,n),f=2;break}let w=e.charCodeAt(n);if(w===34){m+=e.substring(k,n),n++;break}if(w===92){if(m+=e.substring(k,n),n++,n>=r){f=2;break}switch(e.charCodeAt(n++)){case 34:m+='"';break;case 92:m+="\\";break;case 47:m+="/";break;case 98:m+="\b";break;case 102:m+="\f";break;case 110:m+=`
|
|
3
|
+
`;break;case 114:m+="\r";break;case 116:m+=" ";break;case 117:let b=p(4,!0);b>=0?m+=String.fromCharCode(b):f=4;break;default:f=5}k=n;continue}if(w>=0&&w<=31)if(Z(w)){m+=e.substring(k,n),f=2;break}else f=6;n++}return m}function y(){if(s="",f=0,o=n,l=a,c=u,n>=r)return o=r,i=17;let m=e.charCodeAt(n);if(me(m)){do n++,s+=String.fromCharCode(m),m=e.charCodeAt(n);while(me(m));return i=15}if(Z(m))return n++,s+=String.fromCharCode(m),m===13&&e.charCodeAt(n)===10&&(n++,s+=`
|
|
4
|
+
`),a++,u=n,i=14;switch(m){case 123:return n++,i=1;case 125:return n++,i=2;case 91:return n++,i=3;case 93:return n++,i=4;case 58:return n++,i=6;case 44:return n++,i=5;case 34:return n++,s=h(),i=10;case 47:let k=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<r&&!Z(e.charCodeAt(n));)n++;return s=e.substring(k,n),i=12}if(e.charCodeAt(n+1)===42){n+=2;let w=r-1,v=!1;for(;n<w;){let b=e.charCodeAt(n);if(b===42&&e.charCodeAt(n+1)===47){n+=2,v=!0;break}n++,Z(b)&&(b===13&&e.charCodeAt(n)===10&&n++,a++,u=n)}return v||(n++,f=1),s=e.substring(k,n),i=13}return s+=String.fromCharCode(m),n++,i=16;case 45:if(s+=String.fromCharCode(m),n++,n===r||!G(e.charCodeAt(n)))return i=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return s+=g(),i=11;default:for(;n<r&&S(m);)n++,m=e.charCodeAt(n);if(o!==n){switch(s=e.substring(o,n),s){case"true":return i=8;case"false":return i=9;case"null":return i=7}return i=16}return s+=String.fromCharCode(m),n++,i=16}}function S(m){if(me(m)||Z(m))return!1;switch(m){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function E(){let m;do m=y();while(m>=12&&m<=15);return m}return{setPosition:d,getPosition:()=>n,scan:t?E:y,getToken:()=>i,getTokenValue:()=>s,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>l,getTokenStartCharacter:()=>o-c,getTokenError:()=>f}}function me(e){return e===32||e===9}function Z(e){return e===10||e===13}function G(e){return e>=48&&e<=57}var Le;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(Le||(Le={}));var Yt=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),z=200,Ct={" ":{"\n":new Array(z).fill(0).map((e,t)=>`
|
|
5
|
+
`+" ".repeat(t)),"\r":new Array(z).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(z).fill(0).map((e,t)=>`\r
|
|
6
|
+
`+" ".repeat(t))}," ":{"\n":new Array(z).fill(0).map((e,t)=>`
|
|
7
|
+
`+" ".repeat(t)),"\r":new Array(z).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(z).fill(0).map((e,t)=>`\r
|
|
8
|
+
`+" ".repeat(t))}};var se;(function(e){e.DEFAULT={allowTrailingComma:!1}})(se||(se={}));function Ve(e,t=[],r=se.DEFAULT){let n=null,s=[],o=[];function i(l){Array.isArray(s)?s.push(l):n!==null&&(s[n]=l)}return Be(e,{onObjectBegin:()=>{let l={};i(l),o.push(s),s=l,n=null},onObjectProperty:l=>{n=l},onObjectEnd:()=>{s=o.pop()},onArrayBegin:()=>{let l=[];i(l),o.push(s),s=l,n=null},onArrayEnd:()=>{s=o.pop()},onLiteralValue:i,onError:(l,u,c)=>{t.push({error:l,offset:u,length:c})}},r),s[0]}function Be(e,t,r=se.DEFAULT){let n=re(e,!1),s=[],o=0;function i(x){return x?()=>o===0&&x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function a(x){return x?O=>o===0&&x(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function l(x){return x?O=>o===0&&x(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice()):()=>!0}function u(x){return x?()=>{o>0?o++:x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice())===!1&&(o=1)}:()=>!0}function c(x){return x?()=>{o>0&&o--,o===0&&x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let f=u(t.onObjectBegin),p=l(t.onObjectProperty),d=c(t.onObjectEnd),g=u(t.onArrayBegin),h=c(t.onArrayEnd),y=l(t.onLiteralValue),S=a(t.onSeparator),E=i(t.onComment),m=a(t.onError),k=r&&r.disallowComments,w=r&&r.allowTrailingComma;function v(){for(;;){let x=n.scan();switch(n.getTokenError()){case 4:b(14);break;case 5:b(15);break;case 3:b(13);break;case 1:k||b(11);break;case 2:b(12);break;case 6:b(16);break}switch(x){case 12:case 13:k?b(10):E();break;case 16:b(1);break;case 15:case 14:break;default:return x}}}function b(x,O=[],Ie=[]){if(m(x),O.length+Ie.length>0){let ne=n.getToken();for(;ne!==17;){if(O.indexOf(ne)!==-1){v();break}else if(Ie.indexOf(ne)!==-1)break;ne=v()}}}function Ne(x){let O=n.getTokenValue();return x?y(O):(p(O),s.push(O)),v(),!0}function Dt(){switch(n.getToken()){case 11:let x=n.getTokenValue(),O=Number(x);isNaN(O)&&(b(2),O=0),y(O);break;case 7:y(null);break;case 8:y(!0);break;case 9:y(!1);break;default:return!1}return v(),!0}function Wt(){return n.getToken()!==10?(b(3,[],[2,5]),!1):(Ne(!1),n.getToken()===6?(S(":"),v(),he()||b(4,[],[2,5])):b(5,[],[2,5]),s.pop(),!0)}function Ut(){f(),v();let x=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(x||b(4,[],[]),S(","),v(),n.getToken()===2&&w)break}else x&&b(6,[],[]);Wt()||b(4,[],[2,5]),x=!0}return d(),n.getToken()!==2?b(7,[2],[]):v(),!0}function Gt(){g(),v();let x=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||b(4,[],[]),S(","),v(),n.getToken()===4&&w)break}else O&&b(6,[],[]);x?(s.push(0),x=!1):s[s.length-1]++,he()||b(4,[],[4,5]),O=!0}return h(),x||s.pop(),n.getToken()!==4?b(8,[4],[]):v(),!0}function he(){switch(n.getToken()){case 3:return Gt();case 1:return Ut();case 10:return Ne(!0);default:return Dt()}}return v(),n.getToken()===17?r.allowEmptyContent?!0:(b(4,[],[]),!1):he()?(n.getToken()!==17&&b(9,[],[]),!0):(b(4,[],[]),!1)}var Fe;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(Fe||(Fe={}));var _e;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(_e||(_e={}));var oe=Ve;var De;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(De||(De={}));var F=j(require("path"));var ye=(e,t,r)=>{let n=e instanceof RegExp?Ue(e,r):e,s=t instanceof RegExp?Ue(t,r):t,o=n!==null&&s!=null&&on(n,s,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+s.length)}},Ue=(e,t)=>{let r=t.match(e);return r?r[0]:null},on=(e,t,r)=>{let n,s,o,i,a,l=r.indexOf(e),u=r.indexOf(t,l+1),c=l;if(l>=0&&u>0){if(e===t)return[l,u];for(n=[],o=r.length;c>=0&&!a;){if(c===l)n.push(c),l=r.indexOf(e,c+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,u])}else s=n.pop(),s!==void 0&&s<o&&(o=s,i=u),u=r.indexOf(t,c+1);c=l<u&&l>=0?l:u}n.length&&i!==void 0&&(a=[o,i])}return a};var Ge="\0SLASH"+Math.random()+"\0",ze="\0OPEN"+Math.random()+"\0",ke="\0CLOSE"+Math.random()+"\0",He="\0COMMA"+Math.random()+"\0",qe="\0PERIOD"+Math.random()+"\0",an=new RegExp(Ge,"g"),ln=new RegExp(ze,"g"),un=new RegExp(ke,"g"),cn=new RegExp(He,"g"),fn=new RegExp(qe,"g"),pn=/\\\\/g,dn=/\\{/g,gn=/\\}/g,hn=/\\,/g,mn=/\\./g,yn=1e5;function be(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function bn(e){return e.replace(pn,Ge).replace(dn,ze).replace(gn,ke).replace(hn,He).replace(mn,qe)}function kn(e){return e.replace(an,"\\").replace(ln,"{").replace(un,"}").replace(cn,",").replace(fn,".")}function Je(e){if(!e)return[""];let t=[],r=ye("{","}",e);if(!r)return e.split(",");let{pre:n,body:s,post:o}=r,i=n.split(",");i[i.length-1]+="{"+s+"}";let a=Je(o);return o.length&&(i[i.length-1]+=a.shift(),i.push.apply(i,a)),t.push.apply(t,i),t}function Xe(e,t={}){if(!e)return[];let{max:r=yn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),Q(bn(e),r,!0).map(kn)}function wn(e){return"{"+e+"}"}function xn(e){return/^-?0\d/.test(e)}function vn(e,t){return e<=t}function Sn(e,t){return e>=t}function Q(e,t,r){let n=[],s=ye("{","}",e);if(!s)return[e];let o=s.pre,i=s.post.length?Q(s.post,t,!1):[""];if(/\$$/.test(s.pre))for(let a=0;a<i.length&&a<t;a++){let l=o+"{"+s.body+"}"+i[a];n.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),u=a||l,c=s.body.indexOf(",")>=0;if(!u&&!c)return s.post.match(/,(?!,).*\}/)?(e=s.pre+"{"+s.body+ke+s.post,Q(e,t,!0)):[e];let f;if(u)f=s.body.split(/\.\./);else if(f=Je(s.body),f.length===1&&f[0]!==void 0&&(f=Q(f[0],t,!1).map(wn),f.length===1))return i.map(d=>s.pre+f[0]+d);let p;if(u&&f[0]!==void 0&&f[1]!==void 0){let d=be(f[0]),g=be(f[1]),h=Math.max(f[0].length,f[1].length),y=f.length===3&&f[2]!==void 0?Math.abs(be(f[2])):1,S=vn;g<d&&(y*=-1,S=Sn);let m=f.some(xn);p=[];for(let k=d;S(k,g);k+=y){let w;if(l)w=String.fromCharCode(k),w==="\\"&&(w="");else if(w=String(k),m){let v=h-w.length;if(v>0){let b=new Array(v+1).join("0");k<0?w="-"+b+w.slice(1):w=b+w}}p.push(w)}}else{p=[];for(let d=0;d<f.length;d++)p.push.apply(p,Q(f[d],t,!1))}for(let d=0;d<p.length;d++)for(let g=0;g<i.length&&n.length<t;g++){let h=o+p[d]+i[g];(!r||u||h)&&n.push(h)}}return n}var Y=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Rn={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},C=e=>e.replace(/[[\]\\-]/g,"\\$&"),On=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ze=e=>e.join(""),Qe=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],s=[],o=r+1,i=!1,a=!1,l=!1,u=!1,c=r,f="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){u=!0,o++;continue}if(h==="]"&&i&&!l){c=o+1;break}if(i=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[y,[S,E,m]]of Object.entries(Rn))if(e.startsWith(y,o)){if(f)return["$.",!1,e.length-r,!0];o+=y.length,m?s.push(S):n.push(S),a=a||E;continue e}}if(l=!1,f){h>f?n.push(C(f)+"-"+C(h)):h===f&&n.push(C(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(C(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(C(h)),o++}if(c<o)return["",!1,0,!1];if(!n.length&&!s.length)return["$.",!1,e.length-r,!0];if(s.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let h=n[0].length===2?n[0].slice(-1):n[0];return[On(h),!1,c-r,!1]}let p="["+(u?"^":"")+Ze(n)+"]",d="["+(u?"":"^")+Ze(s)+"]";return[n.length&&s.length?"("+p+"|"+d+")":n.length?p:d,a,c-r,!0]};var L=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var Tn=new Set(["!","?","+","*","@"]),Ye=e=>Tn.has(e),En="(?!(?:^|/)\\.\\.?(?:$|/))",ie="(?!\\.)",$n=new Set(["[","."]),Mn=new Set(["..","."]),An=new Set("().*{}+?[]^$\\!"),Pn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),we="[^/]",Ce=we+"*?",Ke=we+"+?",H=class e{type;#n;#r;#o=!1;#e=[];#t;#i;#l;#a=!1;#s;#u;#f=!1;constructor(t,r,n={}){this.type=t,t&&(this.#r=!0),this.#t=r,this.#n=this.#t?this.#t.#n:this,this.#s=this.#n===this?n:this.#n.#s,this.#l=this.#n===this?[]:this.#n.#l,t==="!"&&!this.#n.#a&&this.#l.push(this),this.#i=this.#t?this.#t.#e.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#e)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#u!==void 0?this.#u:this.type?this.#u=this.type+"("+this.#e.map(t=>String(t)).join("|")+")":this.#u=this.#e.map(t=>String(t)).join("")}#d(){if(this!==this.#n)throw new Error("should only call on root");if(this.#a)return this;this.toString(),this.#a=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#t;for(;n;){for(let s=r.#i+1;!n.type&&s<n.#e.length;s++)for(let o of t.#e){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#e[s])}r=n,n=r.#t}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof e&&r.#t===this))throw new Error("invalid part: "+r);this.#e.push(r)}}toJSON(){let t=this.type===null?this.#e.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#e.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#n||this.#n.#a&&this.#t?.type==="!")&&t.push({}),t}isStart(){if(this.#n===this)return!0;if(!this.#t?.isStart())return!1;if(this.#i===0)return!0;let t=this.#t;for(let r=0;r<this.#i;r++){let n=t.#e[r];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#n===this||this.#t?.type==="!")return!0;if(!this.#t?.isEnd())return!1;if(!this.type)return this.#t?.isEnd();let t=this.#t?this.#t.#e.length:0;return this.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new e(this.type,t);for(let n of this.#e)r.copyIn(n);return r}static#c(t,r,n,s){let o=!1,i=!1,a=-1,l=!1;if(r.type===null){let d=n,g="";for(;d<t.length;){let h=t.charAt(d++);if(o||h==="\\"){o=!o,g+=h;continue}if(i){d===a+1?(h==="^"||h==="!")&&(l=!0):h==="]"&&!(d===a+2&&l)&&(i=!1),g+=h;continue}else if(h==="["){i=!0,a=d,l=!1,g+=h;continue}if(!s.noext&&Ye(h)&&t.charAt(d)==="("){r.push(g),g="";let y=new e(h,r);d=e.#c(t,y,d,s),r.push(y);continue}g+=h}return r.push(g),d}let u=n+1,c=new e(null,r),f=[],p="";for(;u<t.length;){let d=t.charAt(u++);if(o||d==="\\"){o=!o,p+=d;continue}if(i){u===a+1?(d==="^"||d==="!")&&(l=!0):d==="]"&&!(u===a+2&&l)&&(i=!1),p+=d;continue}else if(d==="["){i=!0,a=u,l=!1,p+=d;continue}if(Ye(d)&&t.charAt(u)==="("){c.push(p),p="";let g=new e(d,c);c.push(g),u=e.#c(t,g,u,s);continue}if(d==="|"){c.push(p),p="",f.push(c),c=new e(null,r);continue}if(d===")")return p===""&&r.#e.length===0&&(r.#f=!0),c.push(p),p="",r.push(...f,c),u;p+=d}return r.type=null,r.#r=void 0,r.#e=[t.substring(n-1)],u}static fromGlob(t,r={}){let n=new e(null,void 0,r);return e.#c(t,n,0,r),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let t=this.toString(),[r,n,s,o]=this.toRegExpSource();if(!(s||this.#r||this.#s.nocase&&!this.#s.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#s.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#s}toRegExpSource(t){let r=t??!!this.#s.dot;if(this.#n===this&&this.#d(),!this.type){let l=this.isStart()&&this.isEnd()&&!this.#e.some(d=>typeof d!="string"),u=this.#e.map(d=>{let[g,h,y,S]=typeof d=="string"?e.#g(d,this.#r,l):d.toRegExpSource(t);return this.#r=this.#r||y,this.#o=this.#o||S,g}).join(""),c="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Mn.has(this.#e[0]))){let g=$n,h=r&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),y=!r&&!t&&g.has(u.charAt(0));c=h?En:y?ie:""}let f="";return this.isEnd()&&this.#n.#a&&this.#t?.type==="!"&&(f="(?:$|\\/)"),[c+u+f,L(u),this.#r=!!this.#r,this.#o]}let n=this.type==="*"||this.type==="+",s=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#p(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString();return this.#e=[l],this.type=null,this.#r=void 0,[l,L(this.toString()),!1,!1]}let i=!n||t||r||!ie?"":this.#p(!0);i===o&&(i=""),i&&(o=`(?:${o})(?:${i})*?`);let a="";if(this.type==="!"&&this.#f)a=(this.isStart()&&!r?ie:"")+Ke;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?ie:"")+Ce+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&i?")":this.type==="*"&&i?")?":`)${this.type}`;a=s+o+l}return[a,L(o),this.#r=!!this.#r,this.#o]}#p(t){return this.#e.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,s,o,i]=r.toRegExpSource(t);return this.#o=this.#o||i,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#g(t,r,n=!1){let s=!1,o="",i=!1,a=!1;for(let l=0;l<t.length;l++){let u=t.charAt(l);if(s){s=!1,o+=(An.has(u)?"\\":"")+u;continue}if(u==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?Ke:Ce,r=!0;continue}else a=!1;if(u==="\\"){l===t.length-1?o+="\\\\":s=!0;continue}if(u==="["){let[c,f,p,d]=Qe(t,l);if(p){o+=c,i=i||f,l+=p-1,r=r||d;continue}}if(u==="?"){o+=we,r=!0;continue}o+=Pn(u)}return[o,L(t),!!r,i]}};var xe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var R=(e,t,r={})=>(Y(t),!r.nocomment&&t.charAt(0)==="#"?!1:new q(t,r).match(e)),Nn=/^\*+([^+@!?\*\[\(]*)$/,In=e=>t=>!t.startsWith(".")&&t.endsWith(e),jn=e=>t=>t.endsWith(e),Ln=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Vn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Bn=/^\*+\.\*+$/,Fn=e=>!e.startsWith(".")&&e.includes("."),_n=e=>e!=="."&&e!==".."&&e.includes("."),Dn=/^\.\*+$/,Wn=e=>e!=="."&&e!==".."&&e.startsWith("."),Un=/^\*+$/,Gn=e=>e.length!==0&&!e.startsWith("."),zn=e=>e.length!==0&&e!=="."&&e!=="..",Hn=/^\?+([^+@!?\*\[\(]*)?$/,qn=([e,t=""])=>{let r=nt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Jn=([e,t=""])=>{let r=rt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Xn=([e,t=""])=>{let r=rt([e]);return t?n=>r(n)&&n.endsWith(t):r},Zn=([e,t=""])=>{let r=nt([e]);return t?n=>r(n)&&n.endsWith(t):r},nt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},rt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},st=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",et={win32:{sep:"\\"},posix:{sep:"/"}},Qn=st==="win32"?et.win32.sep:et.posix.sep;R.sep=Qn;var A=Symbol("globstar **");R.GLOBSTAR=A;var Yn="[^/]",Cn=Yn+"*?",Kn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",er="(?:(?!(?:\\/|^)\\.).)*?",tr=(e,t={})=>r=>R(r,e,t);R.filter=tr;var M=(e,t={})=>Object.assign({},e,t),nr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return R;let t=R;return Object.assign((n,s,o={})=>t(n,s,M(e,o)),{Minimatch:class extends t.Minimatch{constructor(s,o={}){super(s,M(e,o))}static defaults(s){return t.defaults(M(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,o,i={}){super(s,o,M(e,i))}static fromGlob(s,o={}){return t.AST.fromGlob(s,M(e,o))}},unescape:(n,s={})=>t.unescape(n,M(e,s)),escape:(n,s={})=>t.escape(n,M(e,s)),filter:(n,s={})=>t.filter(n,M(e,s)),defaults:n=>t.defaults(M(e,n)),makeRe:(n,s={})=>t.makeRe(n,M(e,s)),braceExpand:(n,s={})=>t.braceExpand(n,M(e,s)),match:(n,s,o={})=>t.match(n,s,M(e,o)),sep:t.sep,GLOBSTAR:A})};R.defaults=nr;var ot=(e,t={})=>(Y(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Xe(e,{max:t.braceExpandMax}));R.braceExpand=ot;var rr=(e,t={})=>new q(e,t).makeRe();R.makeRe=rr;var sr=(e,t,r={})=>{let n=new q(t,r);return e=e.filter(s=>n.match(s)),n.options.nonull&&!e.length&&e.push(t),e};R.match=sr;var tt=/[?*]|[+@!]\(.*?\)|\[|\]/,or=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),q=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){Y(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||st,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let s=this.globParts.map((o,i,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!tt.test(o[2]))&&!tt.test(o[3]),u=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(c=>this.parse(c))];if(u)return[o[0],...o.slice(1).map(c=>this.parse(c))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,s),this.set=s.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let i=this.set[o];i[0]===""&&i[1]===""&&this.globParts[o][2]==="?"&&typeof i[3]=="string"&&/^[a-z]:$/i.test(i[3])&&(i[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let s=0;s<t[n].length;s++)t[n][s]==="**"&&(t[n][s]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let s=n;for(;r[s+1]==="**";)s++;s!==n&&r.splice(n,s-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,s)=>{let o=n[n.length-1];return s==="**"&&o==="**"?n:s===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(s),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let s=1;s<t.length-1;s++){let o=t[s];s===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(s,1),s--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let s=t[n-1];s&&s!=="."&&s!==".."&&s!=="**"&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let s=-1;for(;(s=n.indexOf("**",s+1))!==-1;){let i=s;for(;n[i+1]==="**";)i++;i>s&&n.splice(s+1,i-s);let a=n[s+1],l=n[s+2],u=n[s+3];if(a!==".."||!l||l==="."||l===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(s,1);let c=n.slice(0);c[s]="**",t.push(c),s--}if(!this.preserveMultipleSlashes){for(let i=1;i<n.length-1;i++){let a=n[i];i===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(i,1),i--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let i=n[o-1];if(i&&i!=="."&&i!==".."&&i!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let s=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(s){t[r]=[],t[n]=s;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let s=0,o=0,i=[],a="";for(;s<t.length&&o<r.length;)if(t[s]===r[o])i.push(a==="b"?r[o]:t[s]),s++,o++;else if(n&&t[s]==="**"&&r[o]===t[s+1])i.push(t[s]),s++;else if(n&&r[o]==="**"&&t[s]===r[o+1])i.push(r[o]),o++;else if(t[s]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",i.push(t[s]),s++,o++}else if(r[o]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(a==="a")return!1;a="b",i.push(r[o]),s++,o++}else return!1;return t.length===r.length&&i}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let s=0;s<t.length&&t.charAt(s)==="!";s++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let s=this.options;if(this.isWindows){let h=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),y=!h&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),S=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),E=!S&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),m=y?3:h?0:void 0,k=E?3:S?0:void 0;if(typeof m=="number"&&typeof k=="number"){let[w,v]=[t[m],r[k]];w.toLowerCase()===v.toLowerCase()&&(r[k]=w,k>m?r=r.slice(k):m>k&&(t=t.slice(m)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:r}),this.debug("matchOne",t.length,r.length);for(var i=0,a=0,l=t.length,u=r.length;i<l&&a<u;i++,a++){this.debug("matchOne loop");var c=r[a],f=t[i];if(this.debug(r,c,f),c===!1)return!1;if(c===A){this.debug("GLOBSTAR",[r,c,f]);var p=i,d=a+1;if(d===u){for(this.debug("** at the end");i<l;i++)if(t[i]==="."||t[i]===".."||!s.dot&&t[i].charAt(0)===".")return!1;return!0}for(;p<l;){var g=t[p];if(this.debug(`
|
|
9
|
+
globstar while`,t,p,r,d,g),this.matchOne(t.slice(p),r.slice(d),n))return this.debug("globstar found match!",p,l,g),!0;if(g==="."||g===".."||!s.dot&&g.charAt(0)==="."){this.debug("dot detected!",t,p,r,d);break}this.debug("globstar swallow a segment, and continue"),p++}return!!(n&&(this.debug(`
|
|
10
|
+
>>> no match, partial?`,t,p,r,d),p===l))}let h;if(typeof c=="string"?(h=f===c,this.debug("string match",c,f,h)):(h=c.test(f),this.debug("pattern match",c,f,h)),!h)return!1}if(i===l&&a===u)return!0;if(i===l)return n;if(a===u)return i===l-1&&t[i]==="";throw new Error("wtf?")}braceExpand(){return ot(this.pattern,this.options)}parse(t){Y(t);let r=this.options;if(t==="**")return A;if(t==="")return"";let n,s=null;(n=t.match(Un))?s=r.dot?zn:Gn:(n=t.match(Nn))?s=(r.nocase?r.dot?Vn:Ln:r.dot?jn:In)(n[1]):(n=t.match(Hn))?s=(r.nocase?r.dot?Jn:qn:r.dot?Xn:Zn)(n):(n=t.match(Bn))?s=r.dot?_n:Fn:(n=t.match(Dn))&&(s=Wn);let o=H.fromGlob(t,this.options).toMMPattern();return s&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:s}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Cn:r.dot?Kn:er,s=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let u=l.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))s.add(p);return typeof f=="string"?or(f):f===A?A:f._src});u.forEach((f,p)=>{let d=u[p+1],g=u[p-1];f!==A||g===A||(g===void 0?d!==void 0&&d!==A?u[p+1]="(?:\\/|"+n+"\\/)?"+d:u[p]=n:d===void 0?u[p-1]=g+"(?:\\/|\\/"+n+")?":d!==A&&(u[p-1]=g+"(?:\\/|\\/"+n+"\\/)"+d,u[p+1]=A))});let c=u.filter(f=>f!==A);if(this.partial&&c.length>=1){let f=[];for(let p=1;p<=c.length;p++)f.push(c.slice(0,p).join("/"));return"(?:"+f.join("|")+")"}return c.join("/")}).join("|"),[i,a]=t.length>1?["(?:",")"]:["",""];o="^"+i+o+a+"$",this.partial&&(o="^(?:\\/|"+i+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...s].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let s=this.slashSplit(t);this.debug(this.pattern,"split",s);let o=this.set;this.debug(this.pattern,"set",o);let i=s[s.length-1];if(!i)for(let a=s.length-2;!i&&a>=0;a--)i=s[a];for(let a=0;a<o.length;a++){let l=o[a],u=s;if(n.matchBase&&l.length===1&&(u=[i]),this.matchOne(u,l,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return R.defaults(t).Minimatch}};R.AST=H;R.Minimatch=q;R.escape=xe;R.unescape=L;var _="pickety.json",J=["ts","tsx","js","jsx","mjs","cjs"],ir=`**/*.{${J.join(",")}}`,ae=new Set(["node_modules",".git",".next","dist","out","build",".turbo",".cache",".nx","coverage"]);function T(e){let t=e.replace(/\\/g,"/");return/^[a-zA-Z]:/.test(t)&&(t=t[0].toLowerCase()+t.slice(1)),t}function X(e,t){return F.relative(e,t).replace(/\\/g,"/")}function ve(e,t){return R(e,t)||e===t}function ar(e){return["*","?","[","]","{","}","(",")","!","+","@"].some(r=>e.includes(r))}function Se(e,t,r){if(!r||r.length===0)return!1;let n=T(F.relative(t,F.resolve(e)));return n===""||n.startsWith("..")?!1:r.some(s=>{let o=s.trim();if(!o)return!1;let i=T(o).replace(/^\.?\//,"").replace(/^\/+/,"");return(ar(i)?[i]:[i,`${i}/**`]).some(l=>R(n,l)||R(n,`**/${l}`))})}function Re(e){return F.join(e,_)}function le(e,t){return e==="instability"?t.toFixed(2):String(t)}function ue(e){let t=0,r=0,n=0;for(let s of e)s.severity==="error"?t+=1:s.severity==="warn"?r+=1:n+=1;return{errors:t,warnings:r,info:n}}function lr(e,t,r){let n=Oe(e),s=e.name??`rule[${t}]`,o=e.group,i=o?`${o}: ${s}`:s;return{allow:e.allow??!1,severity:e.severity??r,name:s,group:o,label:i,effectiveImporter:n?.path||e.importer||"*",isOnly:e.only||!!e.containedTo,isAllowStyle:(e.allow??!1)||!!e.containedTo||!!e.only}}function it(e,t,r){let n=lr(e,t,r),s=Array.isArray(e.imports)?e.imports:[e.imports];return{rule:e,...n,importPatterns:s.filter(o=>typeof o=="string")}}function P(e,t,r){let n=e.includes("[")?e.slice(0,e.indexOf("[")):e;return!!(ve(e,r)||ve(n,r)||r.includes("/")&&(R(t,r)||R(t,`**/${r}`)||R(t,`**/${r}/**`)))}function Oe(e){if(e.containedTo)return typeof e.containedTo=="object"?e.containedTo:{path:e.containedTo}}function D(e){let{filePath:t,importStmt:r,ruleName:n,ruleLabel:s,message:o,severity:i,sourceModule:a,targetModule:l,ruleGroup:u}=e;return{file:t,line:r.line,character:r.character,length:r.length,message:`[${s}] ${o} (importing "${r.specifier}")`,severity:i,ruleName:n,ruleGroup:u,sourceModule:a,targetModule:l}}function at(e){let t=[],r=new Set,n=new Set,s=[];function o(i){r.add(i),n.add(i),s.push(i);let a=e.get(i);if(a){for(let l of a)if(!r.has(l))o(l);else if(n.has(l)){let u=s.indexOf(l);u!==-1&&t.push([...s.slice(u),l])}}n.delete(i),s.pop()}for(let i of e.keys())r.has(i)||o(i);return t}var lt={modules:{app:"src/app/**",features:"src/features/**",shared:"src/shared/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"shared",imports:["app","features"],allow:!1,message:"Shared code should stay independent of app and feature modules."},{importer:"features",imports:"app",allow:!1,message:"Feature modules should not depend on the app layer."}]}}};var ut={modules:{domain:"src/domain/**",application:"src/application/**",ports:"src/ports/**",adapters:"src/adapters/**",infrastructure:"src/infrastructure/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"domain",imports:["application","ports","adapters","infrastructure"],allow:!1,message:"Domain should not depend on outer layers."},{importer:"application",imports:["adapters","infrastructure"],allow:!1,message:"Application should not depend on adapters or infrastructure."},{importer:"ports",imports:["adapters","infrastructure"],allow:!1,message:"Ports should remain independent of adapters and infrastructure."},{importer:"adapters",imports:"infrastructure",allow:!1,message:"Adapters should not depend on infrastructure."}]}}};var ct={modules:{presentation:"src/presentation/**",application:"src/application/**",domain:"src/domain/**",infrastructure:"src/infrastructure/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"domain",imports:["application","presentation","infrastructure"],allow:!1,message:"Domain should not depend on outer layers."},{importer:"application",imports:["presentation","infrastructure"],allow:!1,message:"Application should not depend on presentation or infrastructure."},{importer:"presentation",imports:"infrastructure",allow:!1,message:"Presentation should not depend directly on infrastructure."}]}}};var ft={hexagonal:ut,"feature-modules":lt,layered:ct};function ce(e){return ft[e]}function K(){return Object.keys(ft)}function pt(e){let{ruleRecord:t,index:r,rulePath:n,errors:s}=e;if(typeof t.containedTo=="object"&&t.containedTo!==null){let o=t.containedTo;if(typeof o.path!="string"&&s.push({message:`Rule #${r}: "containedTo.path" is required and must be a string`,path:`${n}.containedTo.path`}),o.unless!==void 0)if(typeof o.unless!="object"||o.unless===null||Array.isArray(o.unless))s.push({message:`Rule #${r}: "containedTo.unless" must be an object`,path:`${n}.containedTo.unless`});else{let i=o.unless;Object.keys(i).length===0&&s.push({message:`Rule #${r}: "containedTo.unless" must not be empty`,path:`${n}.containedTo.unless`}),(Array.isArray(t.imports)?t.imports.filter(c=>typeof c=="string"):typeof t.imports=="string"?[t.imports]:[]).some(c=>c.match(/\$[\w-]+/))||s.push({message:`Rule #${r}: "containedTo.unless" requires "imports" to contain at least one $variable`,path:`${n}.containedTo.unless`});for(let[c,f]of Object.entries(i))c.startsWith("$")||s.push({message:`Rule #${r}: "containedTo.unless" key "${c}" must start with $`,path:`${n}.containedTo.unless`}),typeof f!="string"&&s.push({message:`Rule #${r}: "containedTo.unless.${c}" must be a string`,path:`${n}.containedTo.unless.${c}`})}}else typeof t.containedTo!="string"&&s.push({message:`Rule #${r}: "containedTo" must be a string or object with a "path" property`,path:`${n}.containedTo`})}function N(e){return e.match(/\$[\w-]+/g)||[]}function dt(e){let t=new Set;for(let r of e)for(let n of N(r))t.add(n);return[...t]}function ee(e,t,r){let n=e.split("/"),s=t.split("/"),o=0,i=n.filter(l=>l!=="**").length,a=s.length-i;for(let l=o;l<=a;l++){let u=gt({patternSegments:n,pathSegments:s,startOffset:l,variables:r});if(u)return u}}function gt(e){let{patternSegments:t,pathSegments:r,startOffset:n,variables:s}=e,o={},i=n;for(let a=0;a<t.length;a++){let l=t[a];if(l==="**"){let p=t.slice(a+1);if(p.length===0)return o;for(let d=i;d<=r.length-p.length;d++){let g=gt({patternSegments:p,pathSegments:r,startOffset:d,variables:s});if(g)return{...o,...g}}return}if(i>=r.length)return;let u=l,c=[];for(let p of s)u.includes(p)&&(u=u.replace(p,`__VAR_${c.length}__`),c.push(p));u=u.replace(/[.+?^{}()|[\]\\]/g,"\\$&"),u=u.replace(/\*/g,"[^/]*");for(let p=0;p<c.length;p++)u=u.replace(`__VAR_${p}__`,"([^/]+)");let f=r[i].match(new RegExp(`^${u}$`));if(!f)return;for(let p=0;p<c.length;p++)o[c[p]]=f[p+1];i++}return o}function W(e,t,r){let n=e;for(let s of t){let o=typeof r=="string"?r:r[s];n=n.replaceAll(s,o)}return n}function mt(e,t,r){if(e===void 0){t.push({message:'"rules" is required and must be an object',path:"rules"});return}if(typeof e!="object"||e===null){t.push({message:'"rules" must be an object',path:"rules"});return}let s=e["module-boundaries"];if(s===void 0){t.push({message:'"rules.module-boundaries" is required and must be an object',path:"rules.module-boundaries"});return}if(typeof s!="object"||s===null){t.push({message:'"rules.module-boundaries" must be an object',path:"rules.module-boundaries"});return}let o=s,i="error";if(o.severity!==void 0&&(o.severity!=="error"&&o.severity!=="warn"?t.push({message:`"rules.module-boundaries.severity" must be "error" or "warn", got "${o.severity}"`,path:"rules.module-boundaries.severity"}):i=o.severity),o.rules===void 0){t.push({message:'"rules.module-boundaries.rules" is required and must be an array',path:"rules.module-boundaries.rules"});return}if(!Array.isArray(o.rules)){t.push({message:'"rules.module-boundaries.rules" must be an array',path:"rules.module-boundaries.rules"});return}let a=[];return o.rules.forEach((l,u)=>{let c=ur({rule:l,index:u,errors:t,warnings:r});c&&a.push(c)}),{severity:i,rules:a}}function ur(e){let{rule:t,index:r,errors:n,warnings:s}=e,o=`rules.module-boundaries.rules[${r}]`;if(typeof t!="object"||t===null){n.push({message:`Rule #${r} must be an object`,path:o});return}let i=t,a=cr({r:i,index:r,rulePath:o,errors:n}),l=fr({r:i,index:r,rulePath:o,errors:n});if(!l)return;let u={imports:l};a!==void 0&&(u.importer=a),typeof i.allow=="boolean"&&(u.allow=i.allow),typeof i.only=="boolean"&&(u.only=i.only),i.containedTo!==void 0&&(pt({ruleRecord:i,index:r,rulePath:o,errors:n}),u.containedTo=i.containedTo),pr({r:i,index:r,rulePath:o,errors:n,result:u});let c=dr(i,o,n);return c&&(u.exports=c),gr({r:i,index:r,rulePath:o,imports:l,warnings:s}),u}function cr(e){let{r:t,index:r,rulePath:n,errors:s}=e,o=typeof t.containedTo=="string"||typeof t.containedTo=="object"&&t.containedTo!==null;if(typeof t.importer!="string"&&!o&&s.push({message:`Rule #${r}: "importer" or "containedTo" is required`,path:n}),t.importer!==void 0){if(typeof t.importer!="string"){s.push({message:`Rule #${r}: "importer" must be a string`,path:`${n}.importer`});return}return t.importer}}function fr(e){let{r:t,index:r,rulePath:n,errors:s}=e;if(typeof t.imports=="string")return t.imports;if(Array.isArray(t.imports)){let o=t.imports.findIndex(i=>typeof i!="string");if(o!==-1){s.push({message:`Rule #${r}: "imports" entries must be strings`,path:`${n}.imports[${o}]`});return}return t.imports}s.push({message:`Rule #${r}: "imports" is required and must be a string or string[]`,path:`${n}.imports`})}function pr(e){let{r:t,index:r,rulePath:n,errors:s,result:o}=e;t.allow!==void 0&&typeof t.allow!="boolean"&&s.push({message:`Rule #${r}: "allow" must be a boolean`,path:`${n}.allow`}),t.only!==void 0&&typeof t.only!="boolean"&&s.push({message:`Rule #${r}: "only" must be a boolean`,path:`${n}.only`}),t.message!==void 0&&(typeof t.message!="string"?s.push({message:`Rule #${r}: "message" must be a string`,path:`${n}.message`}):o.message=t.message),t.severity!==void 0&&(t.severity!=="error"&&t.severity!=="warn"?s.push({message:`Rule #${r}: "severity" must be "error" or "warn", got "${t.severity}"`,path:`${n}.severity`}):o.severity=t.severity),t.name!==void 0&&(typeof t.name!="string"?s.push({message:`Rule #${r}: "name" must be a string`,path:`${n}.name`}):o.name=t.name),t.group!==void 0&&(typeof t.group!="string"?s.push({message:`Rule #${r}: "group" must be a string`,path:`${n}.group`}):o.group=t.group),t.maxViolations!==void 0&&(typeof t.maxViolations!="number"||!Number.isInteger(t.maxViolations)||t.maxViolations<0?s.push({message:`Rule #${r}: "maxViolations" must be a non-negative integer`,path:`${n}.maxViolations`}):o.maxViolations=t.maxViolations)}function dr(e,t,r){if(e.exports!==void 0){if(Array.isArray(e.exports)){let n=[];return e.exports.forEach((s,o)=>{let i=ht(s,`${t}.exports[${o}]`,r);i&&n.push(i)}),n.length>0?n:void 0}return ht(e.exports,`${t}.exports`,r)}}function gr(e){let{r:t,index:r,rulePath:n,imports:s,warnings:o}=e,i=Array.isArray(s)?s:[s],a=new Set(dt(i)),l=(u,c,f)=>{let d=N(u).filter(g=>!a.has(g));if(d.length>0){let g=Array.from(new Set(d));o.push({message:`Rule #${r}: ${f} references variables not present in "imports": ${g.join(", ")}`,path:c})}};typeof t.importer=="string"&&l(t.importer,`${n}.importer`,'"importer"'),typeof t.containedTo=="string"?l(t.containedTo,`${n}.containedTo`,'"containedTo"'):typeof t.containedTo=="object"&&t.containedTo!==null&&typeof t.containedTo.path=="string"&&l(t.containedTo.path,`${n}.containedTo.path`,'"containedTo.path"')}function ht(e,t,r){if(typeof e!="object"||e===null){r.push({message:`"${t}" must be an object`,path:t});return}let n=e,s=!1;if(typeof n.path!="string"&&(r.push({message:`"${t}.path" is required and must be a string`,path:`${t}.path`}),s=!0),typeof n.to!="string"&&(r.push({message:`"${t}.to" is required and must be a string`,path:`${t}.to`}),s=!0),n.message!==void 0&&typeof n.message!="string"&&(r.push({message:`"${t}.message" must be a string`,path:`${t}.message`}),s=!0),!s)return{path:n.path,to:n.to,message:typeof n.message=="string"?n.message:void 0}}function yt(e,t){if(e===void 0)return;if(typeof e!="object"||e===null){t.push({message:'"health" must be an object',path:"health"});return}let r=e,n={},s=[{key:"maxAfferentCoupling",label:"maxAfferentCoupling"},{key:"maxEfferentCoupling",label:"maxEfferentCoupling"},{key:"maxDepth",label:"maxDepth"}];for(let{key:o,label:i}of s){let a=r[o];a!==void 0&&(typeof a!="number"||!Number.isInteger(a)||a<1?t.push({message:`"health.${i}" must be a positive integer`,path:`health.${i}`}):n[o]=a)}if(r.maxInstability!==void 0){let o=r.maxInstability;typeof o!="number"||o<0||o>1?t.push({message:'"health.maxInstability" must be a number between 0 and 1',path:"health.maxInstability"}):n.maxInstability=o}return Object.keys(n).length>0?n:void 0}function bt(e){let t=[],r=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let n=e,s=hr(n.modules,t),o=mt(n.rules,t,r),i=mr(n["boundary-diagrams"],t),a=yt(n.health,t),l=yr(n.warnOnUntrackedImporters,t),u=br(n.ignore,t);return t.length>0||!s||!o?r.length>0?{ok:!1,errors:t,warnings:r}:{ok:!1,errors:t}:{ok:!0,config:{modules:s,rules:{"module-boundaries":o},ignore:u,warnOnUntrackedImporters:l,"boundary-diagrams":i,health:a},warnings:r.length>0?r:void 0}}function hr(e,t){if(e===void 0){t.push({message:'"modules" is required and must be an object',path:"modules"});return}if(typeof e!="object"||e===null){t.push({message:'"modules" must be an object mapping module names to patterns',path:"modules"});return}let r={};for(let[n,s]of Object.entries(e))typeof s!="string"?t.push({message:`Module "${n}" pattern must be a string, got ${typeof s}`,path:`modules.${n}`}):r[n]=s;return r}function mr(e,t){if(e!==void 0){if(typeof e!="boolean"&&typeof e!="string"){t.push({message:'"boundary-diagrams" must be a boolean or a string',path:"boundary-diagrams"});return}return e}}function yr(e,t){return e===void 0?!0:typeof e!="boolean"?(t.push({message:'"warnOnUntrackedImporters" must be a boolean',path:"warnOnUntrackedImporters"}),!0):e}function br(e,t){if(e===void 0)return;if(!Array.isArray(e)){t.push({message:'"ignore" must be an array of glob patterns',path:"ignore"});return}if(e.find(n=>typeof n!="string")!==void 0){t.push({message:'"ignore" entries must be strings',path:"ignore"});return}return e}function wt(e){let t=kt.join(e,_);if(!pe.existsSync(t))return{ok:!0,config:void 0};try{let r=pe.readFileSync(t,"utf-8"),n;try{n=oe(r)}catch(s){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${s instanceof Error?s.message:String(s)}`}]}}if(typeof n=="object"&&n!==null){let s=n;if(s.preset!==void 0&&typeof s.preset!="string")return{ok:!1,errors:[{message:'"preset" must be a string',path:"preset"}]};if(typeof s.preset=="string"){let o=ce(s.preset);if(!o)return{ok:!1,errors:[{message:`Unknown preset "${s.preset}". Available presets: ${K().join(", ")}`,path:"preset"}]};n=Sr(o,s)}}return bt(n)}catch(r){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${r instanceof Error?r.message:String(r)}`}]}}}function fe(e){return typeof e=="object"&&e!==null}function kr(e,t){return t===void 0?e:!fe(t)||!e?t:{...e,...t}}function wr(e){let{merged:t,preset:r,override:n,keys:s}=e;for(let o of s)n[o]!==void 0?t[o]=n[o]:r[o]!==void 0&&(t[o]=r[o])}function xr(e,t){return t===void 0?e:fe(t)?{...e,...t}:t}function vr(e,t){if(t===void 0)return e;if(!fe(t))return t;let r=t["module-boundaries"];if(!fe(r))return t;let n={...e,...t},s=e["module-boundaries"],o={...s,...r},i=Array.isArray(s.rules)?s.rules:[];return r.rules===void 0?o.rules=i:Array.isArray(r.rules)?o.rules=[...i,...r.rules]:o.rules=r.rules,n["module-boundaries"]=o,n}function Sr(e,t){let r={...e,...t};return r.modules=xr(e.modules,t.modules),r.rules=vr(e.rules,t.rules),wr({merged:r,preset:e,override:t,keys:["warnOnUntrackedImporters","boundary-diagrams","ignore","version"]}),r.health=kr(e.health,t.health),r}var de=j(require("fs")),V=j(require("path"));function xt(e,t){if(t<0)return[];let r=[],n;try{n=de.readdirSync(e,{withFileTypes:!0})}catch{return r}for(let s of n)!ae.has(s.name)&&s.isFile()&&/^tsconfig(\..+)?\.json$/.test(s.name)&&r.push(V.join(e,s.name));for(let s of n)!ae.has(s.name)&&s.isDirectory()&&r.push(...xt(V.join(e,s.name),t-1));return r}function vt(e){let t={},r=xt(e,4);for(let n of r)try{let s=de.readFileSync(n,"utf-8"),i=oe(s).compilerOptions;if(!i?.paths)continue;let a=V.dirname(n),l=V.relative(e,a),u=i.baseUrl||".";for(let[c,f]of Object.entries(i.paths))if(Array.isArray(f)&&f.length>0){let p=f[0];t[c]||(t[c]=T(V.join(l,u,p)))}}catch{}return t}var Me=j(require("path"));var B=j(require("path"));var Rt=J.map(e=>`.${e}`),Rr=Rt.map(e=>`index${e}`),St=/(\/\*[\s\S]*?\*\/|\/\/.*)|(['"`](?:\\.|[^'"`])*['"`])|((?:import|export)\s+(?:[\s\S]*?from\s+)?['"`]([^'"`]+)['"`])|(import\s*\(\s*['"`]([^'"`]+)['"`]\s*\))/gm;function Or(e){let t=[],r=e.split(`
|
|
11
|
+
`),n=[],s=0;for(let a of r)n.push(s),s+=a.length+1;let o=a=>{let l=0;for(let u=1;u<n.length&&!(n[u]>a);u++)l=u;return{line:l,character:a-n[l]}},i;for(St.lastIndex=0;(i=St.exec(e))!==null;){let[a,l,u,c,f,p,d]=i;if(!(l||u)){if(c&&f){let g=o(i.index);t.push({specifier:f,line:g.line,character:g.character,length:c.length})}else if(p&&d){let g=o(i.index);t.push({specifier:d,line:g.line,character:g.character,length:p.length})}}}return t}function Tr(e,t,r){let{knownFiles:n,root:s,aliases:o}=r;for(let[i,a]of Object.entries(o))if(i.endsWith("/*")){let l=i.slice(0,-2),u=a.endsWith("/*")?a.slice(0,-2):a==="*"?"./":a;if(e.startsWith(l)){let c=e.replace(l,u);return Te(B.resolve(s,c),n)}}else if(e===i)return Te(B.resolve(s,a),n);if(e.startsWith(".")){let i=B.dirname(t),a=B.resolve(i,e);return Te(a,n)}}function Te(e,t){let r=T(e);if(t.has(r))return r;for(let n of Rt){let s=r+n;if(t.has(s))return s}for(let n of Rr){let s=r+"/"+n;if(t.has(s))return s}}function Er(e){return e.endsWith("/*")?e.slice(0,-2)+"/**/*":e}function $r(e,t,r){if(t.length===0)return e;let n=t.map(s=>r[s]);return`${e}[${n.join(",")}]`}function Mr(e,t,r){let n=T(B.relative(r,e));for(let[s,o]of Object.entries(t)){let i=Er(o),a=N(o);if(a.length>0){let l=ee(i,n,a)||(i!==o?ee(o,n,a):void 0);if(l)return{name:$r(s,a,l),pattern:o,relativePath:n,variables:l};continue}if(R(n,i)||R(n,o))return{name:s,pattern:o,relativePath:n}}}function $(e,t,r){return Mr(e,t,r)?.name}function ge(e,t,r){let n=Or(t),s=[];for(let o of n){let i=Tr(o.specifier,e,r);i&&s.push({statement:o,resolvedPath:i})}return s}function Et(e){return e.isOnly?Ar(e):Pr(e)}function Ee(e){let{pattern:t,variables:r,moduleName:n,relativePath:s}=e,o=t.includes("/")?s:n;return ee(t,o,r)}function Ar(e){let{rule:t,importsPattern:r,variables:n,effectiveImporter:s,ruleSeverity:o,ruleName:i,ruleLabel:a,ruleGroup:l,ctx:u}=e,c=Ee({pattern:r,variables:n,moduleName:u.targetModule,relativePath:u.targetRelativePath});if(!c||Lr(t,c))return;let f=W(s,n,c);if(!P(u.sourceModule,u.sourceRelativePath,f)){if($e(t,u,c))return;let d=t.message||`Module "${u.sourceModule}" is not allowed to import from "${u.targetModule}" (contained to "${f}")`;return D({filePath:u.filePath,importStmt:u.importStmt,ruleName:i,ruleLabel:a,message:d,severity:o,sourceModule:u.sourceModule,targetModule:u.targetModule,ruleGroup:l})}}function Pr(e){let{rule:t,importsPattern:r,variables:n,allow:s,effectiveImporter:o,ruleSeverity:i,ruleName:a,ruleLabel:l,ruleGroup:u,ctx:c}=e,f=Ee({pattern:o,variables:n,moduleName:c.sourceModule,relativePath:c.sourceRelativePath});if(f)if(s){let p=W(r,n,"*"),d=W(r,n,f),g=P(c.targetModule,c.targetRelativePath,p),h=P(c.targetModule,c.targetRelativePath,d);if(g&&!h){let y=t.message||`Import must match scoped pattern "${d}"`;return D({filePath:c.filePath,importStmt:c.importStmt,ruleName:a,ruleLabel:l,message:y,severity:i,sourceModule:c.sourceModule,targetModule:c.targetModule,ruleGroup:u})}}else{let p=W(r,n,f);if(P(c.targetModule,c.targetRelativePath,p)){let g=t.message||`Module "${c.sourceModule}" cannot import from "${c.targetModule}"`;return D({filePath:c.filePath,importStmt:c.importStmt,ruleName:a,ruleLabel:l,message:g,severity:i,sourceModule:c.sourceModule,targetModule:c.targetModule,ruleGroup:u})}}}function Nr(e){return e?Array.isArray(e)?e:[e]:[]}var Ot=new WeakMap;function Ir(e){let t=Ot.get(e);if(t)return t;let n=Nr(e.exports).map(s=>({entry:s,pathVars:N(s.path),toVars:N(s.to)}));return Ot.set(e,n),n}function $e(e,t,r){let n=Ir(e);if(n.length===0)return!1;for(let{entry:s,pathVars:o,toVars:i}of n){let a=o.length>0?Tt({pattern:s.path,variables:o,preferred:r,moduleName:t.targetModule,relativePath:t.targetRelativePath}):{};if(o.length>0&&!a)continue;let l=i.length>0?Tt({pattern:s.to,variables:i,preferred:void 0,moduleName:t.sourceModule,relativePath:t.sourceRelativePath}):{};if(i.length>0&&!l)continue;let u=jr(a??{},l??{});if(!u)continue;let c=o.length>0?W(s.path,o,u):s.path;if(!P(t.targetModule,t.targetRelativePath,c))continue;let f=i.length>0?W(s.to,i,u):s.to;if(P(t.sourceModule,t.sourceRelativePath,f))return!0}return!1}function Tt(e){let{pattern:t,variables:r,preferred:n,moduleName:s,relativePath:o}=e;return n&&r.every(i=>n[i]!==void 0)?n:Ee({pattern:t,variables:r,moduleName:s,relativePath:o})}function jr(e,t){let r={...e};for(let[n,s]of Object.entries(t)){if(r[n]!==void 0&&r[n]!==s)return;r[n]=s}return r}function Lr(e,t){let r=Oe(e);if(r&&r.unless){let n=Object.entries(r.unless);return n.length>0&&n.every(([s,o])=>t[s]===o)}return!1}function $t(e,t){let{rule:r,allow:n,severity:s,name:o,label:i,group:a,effectiveImporter:l,isOnly:u,importPatterns:c}=e;for(let f of c){let p=N(u?f:l);if(p.length>0){let h=Et({rule:r,importsPattern:f,variables:p,isOnly:u,allow:n,effectiveImporter:l,ruleSeverity:s,ruleName:o,ruleLabel:i,ruleGroup:a,ctx:t});if(h)return h;continue}let d=P(t.sourceModule,t.sourceRelativePath,l),g=P(t.targetModule,t.targetRelativePath,f);if(u){if(g&&!d){if($e(r,t))return;let h=r.message||(r.containedTo?`Import is restricted: "${t.targetModule}" is contained to "${l}"`:`Module "${t.targetModule}" can only be imported by "${l}"`);return D({filePath:t.filePath,importStmt:t.importStmt,ruleName:o,ruleLabel:i,message:h,severity:s,sourceModule:t.sourceModule,targetModule:t.targetModule,ruleGroup:a})}}else if(d&&g&&!n){let h=r.message||`Module "${t.sourceModule}" cannot import from "${t.targetModule}"`;return D({filePath:t.filePath,importStmt:t.importStmt,ruleName:o,ruleLabel:i,message:h,severity:s,sourceModule:t.sourceModule,targetModule:t.targetModule,ruleGroup:a})}}}function Mt(e){let{filePath:t,content:r,config:n,ctx:s}=e,o=[],{modules:i}=n,{severity:a,rules:l}=n.rules["module-boundaries"],{root:u}=s,c=n.warnOnUntrackedImporters??!0,f=l.map((h,y)=>it(h,y,a)),p=$(t,i,u);if(!p)return c&&o.push({file:t,line:0,character:0,length:1,message:"This file is not covered by any declared module. Import rules will not be enforced here.",severity:"info"}),o;let d=T(Me.relative(u,t)),g=ge(t,r,s);for(let{statement:h,resolvedPath:y}of g){let S=$(y,i,u);if(!S)continue;let E=T(Me.relative(u,y)),m={sourceModule:p,sourceRelativePath:d,targetModule:S,targetRelativePath:E,filePath:t,importStmt:h};for(let k of f){let w=$t(k,m);w&&o.push(w)}}return o}function At(e,t){let r=t.rules["module-boundaries"].rules,n=new Map;if(r.forEach((o,i)=>{if(o.maxViolations!==void 0){let a=o.name??`rule[${i}]`;n.set(a,o.maxViolations)}}),n.size===0)return e;let s=new Map;for(let o of e)o.ruleName&&n.has(o.ruleName)&&s.set(o.ruleName,(s.get(o.ruleName)??0)+1);return e.map(o=>{if(!o.ruleName||!n.has(o.ruleName))return o;let i=s.get(o.ruleName)??0,a=n.get(o.ruleName),l=i<=a?"warn":"error";return l===o.severity?o:{...o,severity:l}})}function Ae(e,t,r){let n=new Set,s=ge(e,t,r),o=T(e);for(let{resolvedPath:i}of s)i&&i!==o&&n.add(i);return n}var te=class{dependents=new Map;dependencies=new Map;updateFile(t,r){let n=this.dependencies.get(t);if(n)for(let s of n)this.dependents.get(s)?.delete(t);this.dependencies.set(t,new Set(r));for(let s of r)this.dependents.has(s)||this.dependents.set(s,new Set),this.dependents.get(s).add(t)}removeFile(t){let r=this.dependencies.get(t);if(r)for(let s of r)this.dependents.get(s)?.delete(t);this.dependencies.delete(t);let n=this.dependents.get(t);if(n)for(let s of n)this.dependencies.get(s)?.delete(t);this.dependents.delete(t)}getDependents(t){return this.dependents.get(t)??new Set}getDependencies(t){return this.dependencies.get(t)??new Set}getTransitiveDependents(t){let r=new Set,n=[t],s=0;for(;s<n.length;){let o=n[s++],i=this.dependents.get(o);if(i)for(let a of i)!r.has(a)&&a!==t&&(r.add(a),n.push(a))}return r}getModuleSummary(t,r,n){let s=this.getDependents(t),o=this.getDependencies(t),i=new Set;for(let l of s){let u=$(l,r,n);u&&i.add(u)}let a=new Set;for(let l of o){let u=$(l,r,n);u&&a.add(u)}return{dependentCount:s.size,dependentModules:[...i],dependencyCount:o.size,dependencyModules:[...a]}}getModuleLevelGraph(t,r){let n=new Map;for(let[s,o]of this.dependencies){let i=$(s,t,r);if(i){n.has(i)||n.set(i,new Set);for(let a of o){let l=$(a,t,r);l&&l!==i&&n.get(i).add(l)}}}return n}clear(){this.dependents.clear(),this.dependencies.clear()}};function Pt(e,t,r){let{root:n,knownFiles:s}=r,o=e.getModuleLevelGraph(t,n),i=Object.keys(t),a=new Map;for(let f of i)a.set(f,0);for(let f of s){let p=$(f,t,n);p&&a.set(p,(a.get(p)??0)+1)}let l=new Map;for(let f of i)l.set(f,0);for(let[,f]of o)for(let p of f)l.set(p,(l.get(p)??0)+1);let u=Vr(o,i),c=i.map(f=>{let p=l.get(f)??0,d=o.get(f)?.size??0,g=p+d;return{moduleName:f,fileCount:a.get(f)??0,afferentCoupling:p,efferentCoupling:d,instability:g===0?0:d/g,dependencyDepth:u.get(f)??0}});return c.sort((f,p)=>f.instability-p.instability),c}function Vr(e,t){let r=new Map,n=new Set;function s(o){if(r.has(o))return r.get(o);if(n.has(o))return 0;n.add(o);let i=e.get(o),a=0;if(i&&i.size>0)for(let l of i)a=Math.max(a,1+s(l));return n.delete(o),r.set(o,a),a}for(let o of t)s(o);return r}function Nt(e,t){let r=[],n=[{key:"maxAfferentCoupling",label:"afferent coupling",getValue:s=>s.afferentCoupling},{key:"maxEfferentCoupling",label:"efferent coupling",getValue:s=>s.efferentCoupling},{key:"maxInstability",label:"instability",getValue:s=>s.instability},{key:"maxDepth",label:"dependency depth",getValue:s=>s.dependencyDepth}];for(let s of e)for(let o of n){let i=t[o.key],a=o.getValue(s);i!==void 0&&a>i&&r.push({moduleName:s.moduleName,metric:o.label,value:a,threshold:i})}return r}function It(e,t){let r=X(t,e.file),n=e.line+1,s=e.character+1,o=e.severity==="error"?"error":e.severity==="info"?"info":"warning";return`${r}:${n}:${s}: ${o} ${e.message}`}function jt(e){let t=new Map,r=0,n=!1;for(let o of e)o.ruleGroup?(n=!0,t.set(o.ruleGroup,(t.get(o.ruleGroup)??0)+1)):r+=1;if(!n)return;let s=[];s.push(""),s.push("Groups:");for(let[o,i]of t.entries())s.push(` ${o}: ${i}`);return r>0&&s.push(` (ungrouped): ${r}`),s.join(`
|
|
12
|
+
`)}function Lt(e,t,r){let n=e.map(c=>({file:X(r,c.file),line:c.line+1,column:c.character+1,length:c.length,message:c.message,severity:c.severity,ruleName:c.ruleName,ruleGroup:c.ruleGroup,sourceModule:c.sourceModule,targetModule:c.targetModule})),s=ue(e),o=s.errors+t.length,i=s.warnings,a=s.info,l={},u=0;for(let c of e)c.ruleGroup?l[c.ruleGroup]=(l[c.ruleGroup]??0)+1:u+=1;return u>0&&(l.ungrouped=u),{violations:n,cycles:t,summary:{violations:e.length,cycles:t.length,errors:o,warnings:i,info:a},groups:l}}function Vt(e){let{filePath:t,graph:r,config:n,root:s}=e,o=X(s,t),i=r.getDependents(t),a=r.getTransitiveDependents(t);if(console.log(`Impact analysis for ${o}:
|
|
13
|
+
`),i.size===0){console.log(` No dependents found.
|
|
14
|
+
`);return}console.log(` Direct dependents (${i.size} file${i.size===1?"":"s"}):`);for(let u of i){let c=$(u,n.modules,s)??"(unmatched)",f=X(s,u);console.log(` ${f} (${c})`)}let l=new Set;for(let u of a){let c=$(u,n.modules,s);c&&l.add(c)}a.size>i.size&&(console.log(`
|
|
15
|
+
Transitive dependents (${a.size} file${a.size===1?"":"s"} across ${l.size} module${l.size===1?"":"s"}):`),console.log(` ${[...l].join(", ")}`)),console.log(`
|
|
16
|
+
Affected modules: ${[...l].join(", ")||"none"}`),console.log("")}function Bt(e,t){console.log(`Module Health Report:
|
|
17
|
+
`);let r=["Module","Files","Ca","Ce","Instability","Depth"],n=[Math.max(r[0].length,...e.map(i=>i.moduleName.length)),Math.max(r[1].length,...e.map(i=>String(i.fileCount).length)),Math.max(r[2].length,...e.map(i=>String(i.afferentCoupling).length)),Math.max(r[3].length,...e.map(i=>String(i.efferentCoupling).length)),Math.max(r[4].length,11),Math.max(r[5].length,...e.map(i=>String(i.dependencyDepth).length))],s=(i,a)=>i.padEnd(a),o=(i,a)=>i.padStart(a);console.log(" "+r.map((i,a)=>s(i,n[a])).join(" ")),console.log(" "+n.map(i=>"\u2500".repeat(i)).join(" "));for(let i of e){let l=" "+[s(i.moduleName,n[0]),o(String(i.fileCount),n[1]),o(String(i.afferentCoupling),n[2]),o(String(i.efferentCoupling),n[3]),o(le("instability",i.instability),n[4]),o(String(i.dependencyDepth),n[5])].join(" "),u=t.filter(c=>c.moduleName===i.moduleName);if(u.length>0){let c=u.map(f=>{let p=le(f.metric,f.threshold);return`exceeds max${f.metric.charAt(0).toUpperCase()+f.metric.slice(1)} (${p})`});l+=" \u2190 "+c.join(", ")}console.log(l)}}function Br(e){let t=e.slice(2),r=t[0],n=process.cwd(),s="text",o,i=!1,a=t.indexOf("--root");a!==-1&&t[a+1]&&(n=U.resolve(t[a+1]));let l=t.indexOf("--format");if(l!==-1){let f=t[l+1];if(!f||f.startsWith("--"))return console.error('Missing value for "--format". Use "text" or "json".'),{ok:!1,exitCode:1};if(f!=="text"&&f!=="json")return console.error(`Invalid format "${f}". Use "text" or "json".`),{ok:!1,exitCode:1};s=f}let u=t.indexOf("--preset");if(u!==-1){let f=t[u+1];if(!f||f.startsWith("--"))return console.error('Missing value for "--preset".'),{ok:!1,exitCode:1};o=f}t.includes("--verbose")&&(i=!0);let c=r==="impact"&&t[1]&&!t[1].startsWith("--")?U.resolve(n,t[1]):void 0;return{ok:!0,command:r,root:n,target:c,format:s,preset:o,verbose:i}}var Fr=new Set(J.map(e=>`.${e}`));function _r(e,t){let r=I.readdirSync(e,{recursive:!0,withFileTypes:!0}),n=new Set;for(let s of r){if(!s.isFile())continue;let o=s.parentPath??s.path??e,i=U.join(o,s.name);i.includes("node_modules")||Se(i,e,t)||Fr.has(U.extname(s.name))&&n.add(T(i))}return n}function Ft(){console.log("Usage: pickety <command> [options]"),console.log(""),console.log("Commands:"),console.log(" check Check all files for boundary violations"),console.log(" impact <file> Show which files and modules depend on a file"),console.log(" health Show module health metrics and check thresholds"),console.log(" init Create a starter pickety.json"),console.log(""),console.log("Options:"),console.log(" --root <path> Workspace root (defaults to current directory)"),console.log(" --format <text|json> Output format for check (defaults to text)"),console.log(` --preset <name> Preset name for init (${K().join(", ")})`),console.log(" --verbose Log file read errors")}function Pe(e){let t=wt(e);if(!t.ok){console.error("Configuration errors:");for(let s of t.errors)console.error(` ${s.message}${s.path?` (at ${s.path})`:""}`);if(t.warnings&&t.warnings.length>0){console.warn("Configuration warnings:");for(let s of t.warnings)console.warn(` ${s.message}${s.path?` (at ${s.path})`:""}`)}return{ok:!1,exitCode:1}}if(!t.config)return console.log("No pickety.json found. Skipping check."),{ok:!1,exitCode:0};if(t.warnings&&t.warnings.length>0){console.warn("Configuration warnings:");for(let s of t.warnings)console.warn(` ${s.message}${s.path?` (at ${s.path})`:""}`)}let r=_r(e,t.config.ignore),n=vt(e);return{ok:!0,config:t.config,ctx:{root:e,knownFiles:r,aliases:n}}}function _t(e,t){let r=new te;for(let n of e.knownFiles)try{let s=I.readFileSync(n,"utf-8"),o=Ae(n,s,e);r.updateFile(n,o)}catch(s){let o=s instanceof Error?s.message:String(s);console.warn(`warning: Skipping unreadable file: ${n} (${o})`)}return r}function Dr(e,t,r){let n=Pe(e);if(!n.ok)return n.exitCode;let{config:s,ctx:o}=n,i=new te,a=[];for(let y of o.knownFiles)try{let S=I.readFileSync(y,"utf-8"),E=Mt({filePath:y,content:S,config:s,ctx:o});a.push(...E);let m=Ae(y,S,o);i.updateFile(y,m)}catch(S){let E=S instanceof Error?S.message:String(S);console.warn(`warning: Skipping unreadable file: ${y} (${E})`)}let l=At(a,s),u=i.getModuleLevelGraph(s.modules,e),c=at(u);if(t==="json"){let y=Lt(l,c,e);return console.log(JSON.stringify(y,null,2)),y.summary.errors>0?1:0}if(l.length===0&&c.length===0)return console.log("No boundary violations found."),0;for(let y of l)console.log(It(y,e));for(let y of c)console.log(`error: Circular dependency detected: ${y.join(" -> ")}`);let f=ue(l),p=f.errors+c.length,d=f.warnings,g=f.info,h=jt(l);return h&&console.log(h),console.log(""),console.log(`Found ${l.length} violation(s): ${p} error(s), ${d} warning(s), ${g} info(s)`),p>0?1:0}function Wr(e,t,r){if(!t)return console.error("Usage: pickety impact <file> [--root <path>]"),1;if(!I.existsSync(t))return console.error(`File not found: ${t}`),1;let n=Pe(e);if(!n.ok)return n.exitCode;let{config:s,ctx:o}=n,i=_t(o,r);return Vt({filePath:t,graph:i,config:s,root:e}),0}function Ur(e,t){let r=Pe(e);if(!r.ok)return r.exitCode;let{config:n,ctx:s}=r,o=_t(s,t),i=Pt(o,n.modules,s),a=n.health?Nt(i,n.health):[];return Bt(i,a),a.length>0?(console.log(`
|
|
18
|
+
${a.length} threshold violation(s) found.`),1):(console.log(`
|
|
19
|
+
All modules within configured thresholds.`),0)}function Gr(e,t){let r=Re(e);if(I.existsSync(r))return console.error(`${_} already exists at ${r}.`),1;if(t&&!ce(t))return console.error(`Unknown preset "${t}". Available presets: ${K().join(", ")}`),1;let n={$schema:"https://raw.githubusercontent.com/DanielSerio/pickety/main/resources/pickety.schema.json",modules:{features:"src/features/*",components:"src/components/**/*",utils:"src/utils/**/*"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"features",imports:"features",allow:!0,message:"Features can import from their own module."},{importer:"features",imports:"components",allow:!0},{importer:"features",imports:"utils",allow:!0}]}},"boundary-diagrams":!0},s=t?{$schema:n.$schema,preset:t}:n;return I.writeFileSync(r,JSON.stringify(s,null,2)),console.log(`Created ${_} at ${r}`),0}function zr(){let e=Br(process.argv);e.ok||process.exit(e.exitCode);let{command:t,root:r,target:n,format:s,preset:o,verbose:i}=e;(!t||t==="--help"||t==="-h")&&(Ft(),process.exit(0));let a=0;switch(t){case"check":a=Dr(r,s,i);break;case"impact":a=Wr(r,n,i);break;case"health":a=Ur(r,i);break;case"init":a=Gr(r,o);break;default:console.error(`Unknown command: "${t}"`),Ft(),a=1}process.exit(a)}zr();
|