@visulima/fs 1.2.1 → 1.3.1
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/CHANGELOG.md +14 -0
- package/README.md +87 -0
- package/dist/chunk-3EHZOWRU.js +5 -0
- package/dist/chunk-3EHZOWRU.js.map +1 -0
- package/dist/chunk-7UNFLLNN.js +12 -0
- package/dist/chunk-7UNFLLNN.js.map +1 -0
- package/dist/chunk-C4ULY5SU.cjs +14 -0
- package/dist/chunk-C4ULY5SU.cjs.map +1 -0
- package/dist/chunk-KXYI7M76.cjs +8 -0
- package/dist/chunk-KXYI7M76.cjs.map +1 -0
- package/dist/chunk-N5NZURYL.cjs +10 -0
- package/dist/chunk-N5NZURYL.cjs.map +1 -0
- package/dist/chunk-UPN3Y5W3.js +8 -0
- package/dist/chunk-UPN3Y5W3.js.map +1 -0
- package/dist/error.cjs +24 -0
- package/dist/error.cjs.map +1 -0
- package/dist/error.d.cts +32 -0
- package/dist/error.d.ts +32 -0
- package/dist/error.js +8 -0
- package/dist/error.js.map +1 -0
- package/dist/index.cjs +26 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -41
- package/dist/index.d.ts +25 -41
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/json-error-UVjLdb7z.d.cts +11 -0
- package/dist/json-error-UVjLdb7z.d.ts +11 -0
- package/dist/types-N1z19UH2.d.cts +65 -0
- package/dist/types-N1z19UH2.d.ts +65 -0
- package/dist/utils.cjs +18 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +13 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.js +8 -0
- package/dist/utils.js.map +1 -0
- package/package.json +37 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## @visulima/fs [1.3.1](https://github.com/visulima/visulima/compare/@visulima/fs@1.3.0...@visulima/fs@1.3.1) (2024-03-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **fs:** exported the find-up options as type ([f8b2321](https://github.com/visulima/visulima/commit/f8b2321cead794003f5100d2aa8b30b31d42cc64))
|
|
7
|
+
|
|
8
|
+
## @visulima/fs [1.3.0](https://github.com/visulima/visulima/compare/@visulima/fs@1.2.1...@visulima/fs@1.3.0) (2024-03-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **fs:** add read and write for file and json ([#341](https://github.com/visulima/visulima/issues/341)) ([a2e16d8](https://github.com/visulima/visulima/commit/a2e16d88ea6b14cef1b55ff7ee5d6a9e4afe262f))
|
|
14
|
+
|
|
1
15
|
## @visulima/fs [1.2.1](https://github.com/visulima/visulima/compare/@visulima/fs@1.2.0...@visulima/fs@1.2.1) (2024-03-09)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -341,6 +341,84 @@ Optional: `true`
|
|
|
341
341
|
|
|
342
342
|
Description: The accessibility mode.
|
|
343
343
|
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
# Utilities
|
|
347
|
+
|
|
348
|
+
## parseJson
|
|
349
|
+
|
|
350
|
+
Parse JSON with more helpful errors.
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
import { parseJson, JSONError } from "@visulima/fs/utils";
|
|
354
|
+
|
|
355
|
+
const json = '{\n\t"foo": true,\n}';
|
|
356
|
+
|
|
357
|
+
JSON.parse(json);
|
|
358
|
+
/*
|
|
359
|
+
undefined:3
|
|
360
|
+
}
|
|
361
|
+
^
|
|
362
|
+
SyntaxError: Unexpected token }
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
parseJson(json);
|
|
366
|
+
/*
|
|
367
|
+
JSONError: Unexpected token } in JSON at position 16 while parsing near '{ "foo": true,}'
|
|
368
|
+
|
|
369
|
+
1 | {
|
|
370
|
+
2 | "foo": true,
|
|
371
|
+
> 3 | }
|
|
372
|
+
| ^
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
parseJson(json, "foo.json");
|
|
376
|
+
/*
|
|
377
|
+
JSONError: Unexpected token } in JSON at position 16 while parsing near '{ "foo": true,}' in foo.json
|
|
378
|
+
|
|
379
|
+
1 | {
|
|
380
|
+
2 | "foo": true,
|
|
381
|
+
> 3 | }
|
|
382
|
+
| ^
|
|
383
|
+
*/
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### API for `parseJson`
|
|
387
|
+
|
|
388
|
+
#### json
|
|
389
|
+
|
|
390
|
+
Type: `string`
|
|
391
|
+
|
|
392
|
+
The JSON string to parse.
|
|
393
|
+
|
|
394
|
+
#### reviver
|
|
395
|
+
|
|
396
|
+
Type: `Function`
|
|
397
|
+
|
|
398
|
+
Prescribes how the value originally produced by parsing is transformed, before being returned. See [JSON.parse docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more.
|
|
399
|
+
|
|
400
|
+
#### filename
|
|
401
|
+
|
|
402
|
+
Type: `string`
|
|
403
|
+
|
|
404
|
+
The filename to use in error messages.
|
|
405
|
+
|
|
406
|
+
### API for `JSONError`
|
|
407
|
+
|
|
408
|
+
Exposed for use in `instanceof` checks.
|
|
409
|
+
|
|
410
|
+
#### fileName
|
|
411
|
+
|
|
412
|
+
Type: `string`
|
|
413
|
+
|
|
414
|
+
The filename displayed in the error message.
|
|
415
|
+
|
|
416
|
+
#### codeFrame
|
|
417
|
+
|
|
418
|
+
Type: `string`
|
|
419
|
+
|
|
420
|
+
The printable section of the JSON which produces the error.
|
|
421
|
+
|
|
344
422
|
## Supported Node.js Versions
|
|
345
423
|
|
|
346
424
|
Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
|
|
@@ -357,6 +435,15 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
357
435
|
- [Daniel Bannert](https://github.com/prisis)
|
|
358
436
|
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
359
437
|
|
|
438
|
+
## About
|
|
439
|
+
|
|
440
|
+
### Related Projects
|
|
441
|
+
|
|
442
|
+
- [strip-json-comments](https://github.com/sindresorhus/strip-json-comments) - Strip comments from JSON. Lets you use comments in your JSON files!
|
|
443
|
+
- [parse-json](https://github.com/sindresorhus/parse-json) - Parse JSON with more helpful errors.
|
|
444
|
+
- [find-up](https://github.com/sindresorhus/find-up) - Find a file or directory by walking up parent directories.
|
|
445
|
+
- [walk](https://deno.land/std/fs/walk.ts) - Walk a directory recursively and yield all files and directories.
|
|
446
|
+
|
|
360
447
|
## License
|
|
361
448
|
|
|
362
449
|
The visulima fs is open-sourced software licensed under the [MIT][license-url]
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var t=class extends Error{root;constructor(r,o){super(`${r instanceof Error?r.message:r} for path "${o}"`),this.cause=r,this.name="WalkError",this.root=o;}},p=t;var e=class extends Error{name="PermissionError";code="EPERM";constructor(r){super(`EPERM: Operation not permitted, ${r}`);}},l=e;
|
|
2
|
+
|
|
3
|
+
export { p as a, l as b };
|
|
4
|
+
//# sourceMappingURL=out.js.map
|
|
5
|
+
//# sourceMappingURL=chunk-3EHZOWRU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error/walk-error.ts","../src/error/permission-error.ts"],"names":["WalkError","cause","root","walk_error_default","PermissionError","message","permission_error_default"],"mappings":"AAMA,IAAMA,EAAN,cAAwB,KAAM,CAEnB,KAGA,YAAYC,EAAgBC,EAAc,CAE7C,MAAM,GAAGD,aAAiB,MAAQA,EAAM,QAAUA,CAAK,cAAcC,CAAI,GAAG,EAE5E,KAAK,MAAQD,EACb,KAAK,KAAO,YACZ,KAAK,KAAOC,CAChB,CACJ,EAEOC,EAAQH,EClBf,IAAMI,EAAN,cAA8B,KAAM,CAMd,KAAO,kBAMlB,KAAO,QAMP,YAAYC,EAAiB,CAChC,MAAM,mCAAmCA,CAAO,EAAE,CACtD,CACJ,EAEOC,EAAQF","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\n/** Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration. */\nclass WalkError extends Error {\n /** File path of the root that's being walked. */\n public root: string;\n\n /** Constructs a new instance. */\n public constructor(cause: unknown, root: string) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n super(`${cause instanceof Error ? cause.message : cause} for path \"${root}\"`);\n\n this.cause = cause;\n this.name = \"WalkError\";\n this.root = root;\n }\n}\n\nexport default WalkError;\n","/**\n * Error thrown when an operation is not permitted.\n */\nclass PermissionError extends Error {\n /**\n * Name of the error class.\n * @type {string}\n */\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"PermissionError\";\n\n /**\n * Error code.\n * @type {string}\n */\n public code = \"EPERM\";\n\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`EPERM: Operation not permitted, ${message}`);\n }\n}\n\nexport default PermissionError;\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { a } from './chunk-UPN3Y5W3.js';
|
|
2
|
+
|
|
3
|
+
var N=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
4
|
+
`),P=N,j=globalThis.process||Object.create(null),A={versions:{}},M=new Proxy(j,{get(e,t){if(t in e)return e[t];if(t in A)return A[t]}}),$=M,V=(e,t,o,n)=>{let r={column:0,line:-1,...e.start},s={...r,...e.end},a=r.line,l=r.column,c=s.line,p=s.column,d=Math.max(a-(o+1),0),f=Math.min(t.length,c+n);a===-1&&(d=0),c===-1&&(f=t.length);let h=c-a,m={};if(h)for(let i=0;i<=h;i++){let u=i+a;if(!l)m[u]=!0;else if(i===0){let g=t[u-1]?.length;m[u]=[l,(g??0)-l+1];}else if(i===h)m[u]=[0,p];else {let g=t[u-i]?.length;m[u]=[0,g];}}else l===p?m[a]=l?[l,0]:!0:m[a]=[l,(p??0)-(l??0)];return {end:f,markerLines:m,start:d}},W=V,T=$.platform==="win32"&&!$.env?.WT_SESSION?">":"\u276F",F=(e,t,o)=>{let n={linesAbove:2,linesBelow:3,showGutter:!0,showLineNumbers:!0,tabWidth:4,...o,color:{gutter:i=>i,marker:i=>i,message:i=>i,...o?.color}},r=t.start&&typeof t.start.column=="number",s=P(e).split(`
|
|
5
|
+
`);typeof n?.tabWidth=="number"&&(s=s.map(i=>i.replaceAll(" "," ".repeat(n.tabWidth))));let{end:a,markerLines:l,start:c}=W(t,s,n.linesAbove,n.linesBelow),p=String(a).length,{gutter:d,marker:f,message:h}=n.color,m=s.slice(c,a).map((i,u)=>{let g=c+1+u,y=l[g],w=` ${g}`.slice(-p),E=!l[g+1],b=` ${w}${n.showGutter?" |":""}`;if(y){let x="";if(Array.isArray(y)){let S=i.replaceAll(/[^\t]/g," ").slice(0,Math.max(y[0]-1,0)),L=y[1]||1;x=[`
|
|
6
|
+
`,d(b.replaceAll(/\d/g," "))," ",S,f("^").repeat(L)].join(""),E&&n.message&&(x+=` ${h(n.message)}`);}return [f(T),d(b),i.length>0?` ${i}`:"",x].join("")}return ` ${d(b)}${i.length>0?` ${i}`:""}`}).join(`
|
|
7
|
+
`);return n.message&&!r&&(m=`${" ".repeat(p+1)}${n.message}
|
|
8
|
+
${m}`),m};var v=(e,t)=>{let o=0,n=t.length-2;for(;o<n;){let r=o+(n-o>>1);if(e<t[r])n=r-1;else if(e>=t[r+1])o=r+1;else {o=r;break}}return o},R=e=>e.split(/\n|\r(?!\n)/).reduce((t,o)=>(t.push(t.at(-1)+o.length+1),t),[0]),_=(e,t,o)=>{let n=o?.skipChecks??!1;if(!n&&(!Array.isArray(e)&&typeof e!="string"||(typeof e=="string"||Array.isArray(e))&&e.length===0))return {column:0,line:0};if(!n&&(typeof t!="number"||typeof e=="string"&&t>=e.length||Array.isArray(e)&&t+1>=e.at(-1)))return {column:0,line:0};if(typeof e=="string"){let s=R(e),a=v(t,s);return {column:t-s[a]+1,line:a+1}}let r=v(t,e);return {column:t-e[r]+1,line:r+1}},k=_;var q=e=>`\\u{${e.codePointAt(0).toString(16)}}`,B=(e,t,o)=>F(e,{start:t},{tabWidth:!1,...o}),G=(e,t)=>{let o=/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/.exec(t);if(!o)return;let{column:n,index:r,line:s}=o.groups;return s&&n?{column:Number(n),line:Number(s)}:(r=Number(r),r===e.length&&(r=e.length-1),k(e,r))},I=e=>e.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,o,n)=>`"${n}"(${q(n)})`);function U(e,t,o,n){typeof t=="string"&&(typeof o=="object"&&(n=o),o=t,t=void 0);let r;try{return JSON.parse(e,t)}catch(l){r=l.message;}let s;e?(s=G(e,r),r=I(r)):r+=" while parsing empty string";let a$1=new a(r);throw a$1.fileName=o,s&&(a$1.codeFrame=B(e,s,n)),a$1}var Z=U;
|
|
9
|
+
|
|
10
|
+
export { Z as a };
|
|
11
|
+
//# sourceMappingURL=out.js.map
|
|
12
|
+
//# sourceMappingURL=chunk-7UNFLLNN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../error/src/util/normalize-lf.ts","../../error/src/util/process.ts","../../error/src/code-frame/get-marker-lines.ts","../../error/src/code-frame/index.ts","../src/utils/parse-json.ts"],"names":["normalizeLF","code","normalize_lf_default","_process","processShims","process","target","property","process_default","getMarkerLines","loc","source","linesAbove","linesBelow","startLoc","endLoc","startLine","startColumn","endLine","endColumn","start","end","lineDiff","markerLines","index","lineNumber","sourceLength","a","u","e","m","o","n","i","get_marker_lines_default","$","S","W","M","options","L","config","t","value","hasColumns","g","r","x","s","lines","ln","numberMaxWidth","colorizeGutter","colorizeMarker","colorizeMessage","frame","line","number","hasMarker","paddedNumber","lastMarkerLine","gutter","markerLine","markerSpacing","numberOfMarkers","CODE_FRAME_POINTER","h","k","getCodePoint","character","generateCodeFrame","location","q","getErrorLocation","message","match","column","F","addCodePointToUnexpectedToken","_","_quote","token","parseJson","string","reviver","fileName","error","jsonError","json_error_default","parse_json_default"],"mappings":"wCAAA,IAAMA,EAAeC,GAAyBA,EAAK,WAAW,qBAAsB;CAAI,EAEjFC,EAAQF,ECGTG,EAAY,WAAW,SAAW,OAAO,OAAO,IAAI,EAEpDC,EAAiC,CACnC,SAAU,CAAC,CACf,EAEMC,EAAU,IAAI,MAAeF,EAAU,CACzC,IAAIG,EAAQC,EAAyB,CACjC,GAAIA,KAAYD,EAEZ,OAAOA,EAAOC,CAAQ,EAG1B,GAAIA,KAAYH,EAEZ,OAAOA,EAAaG,CAAQ,CAIpC,CACJ,CAAC,EAEMC,EAAQH,ECVTI,EAAiB,CACnBC,EACAC,EACAC,EACAC,IAMC,CACD,IAAMC,EAA8B,CAChC,OAAQ,EAER,KAAM,GACN,GAAGJ,EAAI,KACX,EACMK,EAA4B,CAC9B,GAAGD,EACH,GAAGJ,EAAI,GACX,EACMM,EAAYF,EAAS,KACrBG,EAAcH,EAAS,OACvBI,EAAUH,EAAO,KACjBI,EAAYJ,EAAO,OAErBK,EAAQ,KAAK,IAAIJ,GAAaJ,EAAa,GAAI,CAAC,EAChDS,EAAM,KAAK,IAAIV,EAAO,OAAQO,EAAUL,CAAU,EAElDG,IAAc,KACdI,EAAQ,GAGRF,IAAY,KACZG,EAAMV,EAAO,QAGjB,IAAMW,EAAWJ,EAAUF,EACrBO,EAA2B,CAAC,EAElC,GAAID,EAEA,QAASE,EAAQ,EAAGA,GAASF,EAAUE,IAAS,CAC5C,IAAMC,EAAaD,EAAQR,EAE3B,GAAI,CAACC,EAEDM,EAAYE,CAAU,EAAI,WACnBD,IAAU,EAAG,CACpB,IAAME,EAAef,EAAOc,EAAa,CAAC,GAAG,OAG7CF,EAAYE,CAAU,EAAI,CAACR,GAAcS,GA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EpEiC,EACI7D,EACA,CAAE,MAAO4D,CAAS,EAClB,CACI,SAAU,GACV,GAAGhC,CACP,CACJ,EAEEkC,EAAmB,CAAC9D,EAAgB+D,IAAmD,CAEzF,IAAMC,EAAQ,sFAAsF,KAAKD,CAAO,EAEhH,GAAI,CAACC,EACD,OAIJ,GAAI,CAAE,OAAAC,EAAQ,MAAApD,EAAO,KAAAgC,CAAK,EAAImB,EAAM,OAEpC,OAAInB,GAAQoB,EACD,CAAE,OAAQ,OAAOA,CAAM,EAAG,KAAM,OAAOpB,CAAI,CAAE,GAGxDhC,EAAQ,OAAOA,CAAK,EAGhBA,IAAUb,EAAO,SACjBa,EAAQb,EAAO,OAAS,GAIrBkE,EAAkBlE,EAAQa,CAAK,EAC1C,EAEMsD,EAAiCJ,GACnCA,EAAQ,QAGJ,kDAEA,CAACK,EAAGC,EAAQC,IAAU,IAAIA,CAAK,KAAKb,EAAaa,CAAK,CAAC,GAC3D,EAKJ,SAASC,EAAyBC,EAAgBC,EAAgCC,EAAsC9C,EAA+B,CAC/I,OAAO6C,GAAY,WACf,OAAOC,GAAa,WAEpB9C,EAAU8C,GAIdA,EAAWD,EAEXA,EAAU,QAGd,IAAIV,EAEJ,GAAI,CAEA,OAAO,KAAK,MAAMS,EAAQC,CAAO,CAErC,OAASE,EAAY,CAEjBZ,EAAUY,EAAM,OACpB,CAEA,IAAIf,EAEAY,GACAZ,EAAWE,EAAiBU,EAAQT,CAAO,EAC3CA,EAAUI,EAA8BJ,CAAO,GAE/CA,GAAW,8BAGf,IAAMa,EAAY,IAAIC,EAAUd,CAAO,EAEvC,MAAAa,EAAU,SAAWF,EAEjBd,IAEAgB,EAAU,UAAYjB,EAAkBa,EAAQZ,EAAUhC,CAAO,GAG/DgD,CACV,CAEA,IAAOE,EAAQP","sourcesContent":["const normalizeLF = (code: string): string => code.replaceAll(/\\r\\n|\\r(?!\\n)|\\n/gu, \"\\n\");\n\nexport default normalizeLF;\n","interface Process extends Partial<Omit<typeof globalThis.process, \"versions\">> {\n versions: Record<string, string>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-unnecessary-condition,no-underscore-dangle\nconst _process = (globalThis.process || Object.create(null)) as unknown as Process;\n\nconst processShims: Partial<Process> = {\n versions: {},\n};\n\nconst process = new Proxy<Process>(_process, {\n get(target, property: keyof Process) {\n if (property in target) {\n // eslint-disable-next-line security/detect-object-injection\n return target[property];\n }\n\n if (property in processShims) {\n // eslint-disable-next-line security/detect-object-injection\n return processShims[property];\n }\n\n return undefined;\n },\n});\n\nexport default process;\n","// eslint-disable-next-line no-secrets/no-secrets\n/**\n * This is a copy of the codeFrame function from Babel\n * @see https://github.com/babel/babel/blob/85e649203b61b7c908eb04c05511a0d35f893e8e/packages/babel-code-frame/src/index.ts#L68-L143\n *\n * MIT License\n *\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors\n */\n\n/**\n * Extract what lines should be marked and highlighted.\n */\nimport type { CodeFrameLocation, CodeFrameNodeLocation } from \"./types\";\n\ntype MarkerLines = Record<number, true | [number | undefined, number | undefined]>;\n\nconst getMarkerLines = (\n loc: CodeFrameNodeLocation,\n source: string[],\n linesAbove: number,\n linesBelow: number,\n): {\n end: number;\n markerLines: MarkerLines;\n start: number;\n // eslint-disable-next-line sonarjs/cognitive-complexity\n} => {\n const startLoc: CodeFrameLocation = {\n column: 0,\n // @ts-expect-error Can be overwritten\n line: -1,\n ...loc.start,\n };\n const endLoc: CodeFrameLocation = {\n ...startLoc,\n ...loc.end,\n };\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines: MarkerLines = {};\n\n if (lineDiff) {\n // eslint-disable-next-line no-plusplus,no-loops/no-loops\n for (let index = 0; index <= lineDiff; index++) {\n const lineNumber = index + startLine;\n\n if (!startColumn) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = true;\n } else if (index === 0) {\n const sourceLength = source[lineNumber - 1]?.length;\n\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [startColumn, (sourceLength ?? 0) - startColumn + 1];\n } else if (index === lineDiff) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - index]?.length;\n\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else if (startColumn === endColumn) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[startLine] = startColumn ? [startColumn, 0] : true;\n } else {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[startLine] = [startColumn, (endColumn ?? 0) - (startColumn ?? 0)];\n }\n\n return { end, markerLines, start };\n};\n\nexport default getMarkerLines;\n","// eslint-disable-next-line no-secrets/no-secrets\n/**\n * This is a modified copy of the codeFrameColumns function from Babel\n * @see https://github.com/babel/babel/blob/85e649203b61b7c908eb04c05511a0d35f893e8e/packages/babel-code-frame/src/index.ts#L145-L217\n *\n * MIT License\n *\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors\n */\n\nimport normalizeLF from \"../util/normalize-lf\";\nimport process from \"../util/process\";\nimport getMarkerLines from \"./get-marker-lines\";\nimport type { CodeFrameNodeLocation, CodeFrameOptions } from \"./types\";\n\nexport const CODE_FRAME_POINTER = process.platform === \"win32\" && !process.env?.[\"WT_SESSION\"] ? \">\" : \"❯\";\n\n/** Generate a code frame from string and an error location */\nexport const codeFrame = (\n source: string,\n loc: CodeFrameNodeLocation,\n options?: CodeFrameOptions,\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): string => {\n // grab 2 lines before, and 3 lines after focused line\n const config = {\n linesAbove: 2,\n linesBelow: 3,\n showGutter: true,\n showLineNumbers: true,\n tabWidth: 4,\n ...options,\n color: {\n gutter: (value: string) => value,\n marker: (value: string) => value,\n message: (value: string) => value,\n ...options?.color,\n },\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const hasColumns = loc.start && typeof loc.start.column === \"number\";\n\n let lines = normalizeLF(source).split(\"\\n\");\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof config?.tabWidth === \"number\") {\n lines = lines.map((ln) => ln.replaceAll(\"\\t\", \" \".repeat(config.tabWidth as number)));\n }\n\n const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);\n\n const numberMaxWidth = String(end).length;\n const { gutter: colorizeGutter, marker: colorizeMarker, message: colorizeMessage } = config.color;\n\n let frame = lines\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n // eslint-disable-next-line security/detect-object-injection\n const hasMarker = markerLines[number];\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const lastMarkerLine = !markerLines[number + 1];\n\n const gutter = ` ${paddedNumber}${config.showGutter ? ` |` : \"\"}`;\n\n if (hasMarker) {\n let markerLine = \"\";\n\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line.replaceAll(/[^\\t]/g, \" \").slice(0, Math.max((hasMarker[0] as number) - 1, 0));\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = [\"\\n \", colorizeGutter(gutter.replaceAll(/\\d/g, \" \")), \" \", markerSpacing, colorizeMarker(\"^\").repeat(numberOfMarkers)].join(\n \"\",\n );\n\n if (lastMarkerLine && config.message) {\n markerLine += ` ${colorizeMessage(config.message)}`;\n }\n }\n\n return [colorizeMarker(CODE_FRAME_POINTER), colorizeGutter(gutter), line.length > 0 ? ` ${line}` : \"\", markerLine].join(\"\");\n }\n\n return ` ${colorizeGutter(gutter)}${line.length > 0 ? ` ${line}` : \"\"}`;\n })\n .join(\"\\n\");\n\n if (config.message && !hasColumns) {\n frame = `${\" \".repeat(numberMaxWidth + 1)}${config.message}\\n${frame}`;\n }\n\n return frame;\n};\n\nexport type { CodeFrameLocation, CodeFrameNodeLocation, CodeFrameOptions, ColorizeMethod } from \"./types\";\n","/**\n * A modified version of `parse-json` from `https://github.com/sindresorhus/parse-json/blob/main/index.js`\n *\n * MIT License\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n */\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { codeFrame, indexToLineColumn } from \"@visulima/error\";\nimport type { JsonValue } from \"type-fest\";\n\nimport JsonError from \"../error/json-error\";\nimport type { CodeFrameLocation, CodeFrameOptions, JsonReviver } from \"../types\";\n\nconst getCodePoint = (character: string): string => `\\\\u{${(character.codePointAt(0) as number).toString(16)}}`;\n\nconst generateCodeFrame = (source: string, location: CodeFrameLocation, options?: CodeFrameOptions) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return\n codeFrame(\n source,\n { start: location },\n {\n tabWidth: false,\n ...options,\n },\n );\n\nconst getErrorLocation = (source: string, message: string): CodeFrameLocation | undefined => {\n // eslint-disable-next-line security/detect-unsafe-regex\n const match = /in JSON at position (?<index>\\d+)(?: \\(line (?<line>\\d+) column (?<column>\\d+)\\))?$/.exec(message);\n\n if (!match) {\n return undefined;\n }\n\n // eslint-disable-next-line prefer-const\n let { column, index, line } = match.groups as { column?: string; index: number | string; line?: string };\n\n if (line && column) {\n return { column: Number(column), line: Number(line) };\n }\n\n index = Number(index);\n\n // The error location can be out of bounds.\n if (index === source.length) {\n index = source.length - 1;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return\n return indexToLineColumn(source, index);\n};\n\nconst addCodePointToUnexpectedToken = (message: string): string =>\n message.replace(\n // TODO[engine:node@>=20]: The token always quoted after Node.js 20\n // eslint-disable-next-line regexp/no-potentially-useless-backreference\n /(?<=^Unexpected token )(?<quote>')?(.)\\k<quote>/,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n (_, _quote, token) => `\"${token}\"(${getCodePoint(token)})`,\n );\n\nfunction parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;\nfunction parseJson<T = JsonValue>(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): T;\n// eslint-disable-next-line func-style\nfunction parseJson<T = JsonValue>(string: string, reviver?: JsonReviver | string, fileName?: CodeFrameOptions | string, options?: CodeFrameOptions): T {\n if (typeof reviver === \"string\") {\n if (typeof fileName === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = fileName;\n }\n\n // eslint-disable-next-line no-param-reassign\n fileName = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n let message: string;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(string, reviver);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n message = error.message;\n }\n\n let location: CodeFrameLocation | undefined;\n\n if (string) {\n location = getErrorLocation(string, message);\n message = addCodePointToUnexpectedToken(message);\n } else {\n message += \" while parsing empty string\";\n }\n\n const jsonError = new JsonError(message);\n\n jsonError.fileName = fileName as string;\n\n if (location) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n jsonError.codeFrame = generateCodeFrame(string, location, options);\n }\n\n throw jsonError;\n}\n\nexport default parseJson;\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkN5NZURYL_cjs = require('./chunk-N5NZURYL.cjs');
|
|
4
|
+
|
|
5
|
+
var L=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
6
|
+
`),N=L,P=globalThis.process||Object.create(null),A={versions:{}},j=new Proxy(P,{get(e,t){if(t in e)return e[t];if(t in A)return A[t]}}),$=j,M=(e,t,o,n)=>{let r={column:0,line:-1,...e.start},s={...r,...e.end},a=r.line,l=r.column,c=s.line,p=s.column,d=Math.max(a-(o+1),0),f=Math.min(t.length,c+n);a===-1&&(d=0),c===-1&&(f=t.length);let h=c-a,m={};if(h)for(let i=0;i<=h;i++){let u=i+a;if(!l)m[u]=!0;else if(i===0){let g=t[u-1]?.length;m[u]=[l,(g??0)-l+1];}else if(i===h)m[u]=[0,p];else {let g=t[u-i]?.length;m[u]=[0,g];}}else l===p?m[a]=l?[l,0]:!0:m[a]=[l,(p??0)-(l??0)];return {end:f,markerLines:m,start:d}},V=M,O=$.platform==="win32"&&!$.env?.WT_SESSION?">":"\u276F",F=(e,t,o)=>{let n={linesAbove:2,linesBelow:3,showGutter:!0,showLineNumbers:!0,tabWidth:4,...o,color:{gutter:i=>i,marker:i=>i,message:i=>i,...o?.color}},r=t.start&&typeof t.start.column=="number",s=N(e).split(`
|
|
7
|
+
`);typeof n?.tabWidth=="number"&&(s=s.map(i=>i.replaceAll(" "," ".repeat(n.tabWidth))));let{end:a,markerLines:l,start:c}=V(t,s,n.linesAbove,n.linesBelow),p=String(a).length,{gutter:d,marker:f,message:h}=n.color,m=s.slice(c,a).map((i,u)=>{let g=c+1+u,y=l[g],k=` ${g}`.slice(-p),w=!l[g+1],b=` ${k}${n.showGutter?" |":""}`;if(y){let x="";if(Array.isArray(y)){let E=i.replaceAll(/[^\t]/g," ").slice(0,Math.max(y[0]-1,0)),S=y[1]||1;x=[`
|
|
8
|
+
`,d(b.replaceAll(/\d/g," "))," ",E,f("^").repeat(S)].join(""),w&&n.message&&(x+=` ${h(n.message)}`);}return [f(O),d(b),i.length>0?` ${i}`:"",x].join("")}return ` ${d(b)}${i.length>0?` ${i}`:""}`}).join(`
|
|
9
|
+
`);return n.message&&!r&&(m=`${" ".repeat(p+1)}${n.message}
|
|
10
|
+
${m}`),m};var T=(e,t)=>{let o=0,n=t.length-2;for(;o<n;){let r=o+(n-o>>1);if(e<t[r])n=r-1;else if(e>=t[r+1])o=r+1;else {o=r;break}}return o},W=e=>e.split(/\n|\r(?!\n)/).reduce((t,o)=>(t.push(t.at(-1)+o.length+1),t),[0]),R=(e,t,o)=>{let n=o?.skipChecks??!1;if(!n&&(!Array.isArray(e)&&typeof e!="string"||(typeof e=="string"||Array.isArray(e))&&e.length===0))return {column:0,line:0};if(!n&&(typeof t!="number"||typeof e=="string"&&t>=e.length||Array.isArray(e)&&t+1>=e.at(-1)))return {column:0,line:0};if(typeof e=="string"){let s=W(e),a=T(t,s);return {column:t-s[a]+1,line:a+1}}let r=T(t,e);return {column:t-e[r]+1,line:r+1}},v=R;var _=e=>`\\u{${e.codePointAt(0).toString(16)}}`,q=(e,t,o)=>F(e,{start:t},{tabWidth:!1,...o}),B=(e,t)=>{let o=/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/.exec(t);if(!o)return;let{column:n,index:r,line:s}=o.groups;return s&&n?{column:Number(n),line:Number(s)}:(r=Number(r),r===e.length&&(r=e.length-1),v(e,r))},G=e=>e.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,o,n)=>`"${n}"(${_(n)})`);function I(e,t,o,n){typeof t=="string"&&(typeof o=="object"&&(n=o),o=t,t=void 0);let r;try{return JSON.parse(e,t)}catch(l){r=l.message;}let s;e?(s=B(e,r),r=G(r)):r+=" while parsing empty string";let a=new chunkN5NZURYL_cjs.a(r);throw a.fileName=o,s&&(a.codeFrame=q(e,s,n)),a}var Y=I;
|
|
11
|
+
|
|
12
|
+
exports.a = Y;
|
|
13
|
+
//# sourceMappingURL=out.js.map
|
|
14
|
+
//# sourceMappingURL=chunk-C4ULY5SU.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../error/src/util/normalize-lf.ts","../../error/src/util/process.ts","../../error/src/code-frame/get-marker-lines.ts","../../error/src/code-frame/index.ts","../src/utils/parse-json.ts"],"names":["normalizeLF","code","normalize_lf_default","_process","processShims","process","target","property","process_default","getMarkerLines","loc","source","linesAbove","linesBelow","startLoc","endLoc","startLine","startColumn","endLine","endColumn","start","end","lineDiff","markerLines","index","lineNumber","sourceLength","a","u","e","m","o","n","i","get_marker_lines_default","$","S","W","M","options","L","config","t","value","hasColumns","g","r","x","s","lines","ln","numberMaxWidth","colorizeGutter","colorizeMarker","colorizeMessage","frame","line","number","hasMarker","paddedNumber","lastMarkerLine","gutter","markerLine","markerSpacing","numberOfMarkers","CODE_FRAME_POINTER","h","k","getCodePoint","character","generateCodeFrame","location","q","getErrorLocation","message","match","column","F","addCodePointToUnexpectedToken","_","_quote","token","parseJson","string","reviver","fileName","error","jsonError","json_error_default","parse_json_default"],"mappings":"yCAAA,IAAMA,EAAeC,GAAyBA,EAAK,WAAW,qBAAsB;CAAI,EAEjFC,EAAQF,ECGTG,EAAY,WAAW,SAAW,OAAO,OAAO,IAAI,EAEpDC,EAAiC,CACnC,SAAU,CAAC,CACf,EAEMC,EAAU,IAAI,MAAeF,EAAU,CACzC,IAAIG,EAAQC,EAAyB,CACjC,GAAIA,KAAYD,EAEZ,OAAOA,EAAOC,CAAQ,EAG1B,GAAIA,KAAYH,EAEZ,OAAOA,EAAaG,CAAQ,CAIpC,CACJ,CAAC,EAEMC,EAAQH,ECVTI,EAAiB,CACnBC,EACAC,EACAC,EACAC,IAMC,CACD,IAAMC,EAA8B,CAChC,OAAQ,EAER,KAAM,GACN,GAAGJ,EAAI,KACX,EACMK,EAA4B,CAC9B,GAAGD,EACH,GAAGJ,EAAI,GACX,EACMM,EAAYF,EAAS,KACrBG,EAAcH,EAAS,OACvBI,EAAUH,EAAO,KACjBI,EAAYJ,EAAO,OAErBK,EAAQ,KAAK,IAAIJ,GAAaJ,EAAa,GAAI,CAAC,EAChDS,EAAM,KAAK,IAAIV,EAAO,OAAQO,EAAUL,CAAU,EAElDG,IAAc,KACdI,EAAQ,GAGRF,IAAY,KACZG,EAAMV,EAAO,QAGjB,IAAMW,EAAWJ,EAAUF,EACrBO,EAA2B,CAA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MAAAa,EAAU,SAAWF,EAEjBd,IAEAgB,EAAU,UAAYjB,EAAkBa,EAAQZ,EAAUhC,CAAO,GAG/DgD,CACV,CAEA,IAAOE,EAAQP","sourcesContent":["const normalizeLF = (code: string): string => code.replaceAll(/\\r\\n|\\r(?!\\n)|\\n/gu, \"\\n\");\n\nexport default normalizeLF;\n","interface Process extends Partial<Omit<typeof globalThis.process, \"versions\">> {\n versions: Record<string, string>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-unnecessary-condition,no-underscore-dangle\nconst _process = (globalThis.process || Object.create(null)) as unknown as Process;\n\nconst processShims: Partial<Process> = {\n versions: {},\n};\n\nconst process = new Proxy<Process>(_process, {\n get(target, property: keyof Process) {\n if (property in target) {\n // eslint-disable-next-line security/detect-object-injection\n return target[property];\n }\n\n if (property in processShims) {\n // eslint-disable-next-line security/detect-object-injection\n return processShims[property];\n }\n\n return undefined;\n },\n});\n\nexport default process;\n","// eslint-disable-next-line no-secrets/no-secrets\n/**\n * This is a copy of the codeFrame function from Babel\n * @see https://github.com/babel/babel/blob/85e649203b61b7c908eb04c05511a0d35f893e8e/packages/babel-code-frame/src/index.ts#L68-L143\n *\n * MIT License\n *\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors\n */\n\n/**\n * Extract what lines should be marked and highlighted.\n */\nimport type { CodeFrameLocation, CodeFrameNodeLocation } from \"./types\";\n\ntype MarkerLines = Record<number, true | [number | undefined, number | undefined]>;\n\nconst getMarkerLines = (\n loc: CodeFrameNodeLocation,\n source: string[],\n linesAbove: number,\n linesBelow: number,\n): {\n end: number;\n markerLines: MarkerLines;\n start: number;\n // eslint-disable-next-line sonarjs/cognitive-complexity\n} => {\n const startLoc: CodeFrameLocation = {\n column: 0,\n // @ts-expect-error Can be overwritten\n line: -1,\n ...loc.start,\n };\n const endLoc: CodeFrameLocation = {\n ...startLoc,\n ...loc.end,\n };\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines: MarkerLines = {};\n\n if (lineDiff) {\n // eslint-disable-next-line no-plusplus,no-loops/no-loops\n for (let index = 0; index <= lineDiff; index++) {\n const lineNumber = index + startLine;\n\n if (!startColumn) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = true;\n } else if (index === 0) {\n const sourceLength = source[lineNumber - 1]?.length;\n\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [startColumn, (sourceLength ?? 0) - startColumn + 1];\n } else if (index === lineDiff) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - index]?.length;\n\n // eslint-disable-next-line security/detect-object-injection\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else if (startColumn === endColumn) {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[startLine] = startColumn ? [startColumn, 0] : true;\n } else {\n // eslint-disable-next-line security/detect-object-injection\n markerLines[startLine] = [startColumn, (endColumn ?? 0) - (startColumn ?? 0)];\n }\n\n return { end, markerLines, start };\n};\n\nexport default getMarkerLines;\n","// eslint-disable-next-line no-secrets/no-secrets\n/**\n * This is a modified copy of the codeFrameColumns function from Babel\n * @see https://github.com/babel/babel/blob/85e649203b61b7c908eb04c05511a0d35f893e8e/packages/babel-code-frame/src/index.ts#L145-L217\n *\n * MIT License\n *\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors\n */\n\nimport normalizeLF from \"../util/normalize-lf\";\nimport process from \"../util/process\";\nimport getMarkerLines from \"./get-marker-lines\";\nimport type { CodeFrameNodeLocation, CodeFrameOptions } from \"./types\";\n\nexport const CODE_FRAME_POINTER = process.platform === \"win32\" && !process.env?.[\"WT_SESSION\"] ? \">\" : \"❯\";\n\n/** Generate a code frame from string and an error location */\nexport const codeFrame = (\n source: string,\n loc: CodeFrameNodeLocation,\n options?: CodeFrameOptions,\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): string => {\n // grab 2 lines before, and 3 lines after focused line\n const config = {\n linesAbove: 2,\n linesBelow: 3,\n showGutter: true,\n showLineNumbers: true,\n tabWidth: 4,\n ...options,\n color: {\n gutter: (value: string) => value,\n marker: (value: string) => value,\n message: (value: string) => value,\n ...options?.color,\n },\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const hasColumns = loc.start && typeof loc.start.column === \"number\";\n\n let lines = normalizeLF(source).split(\"\\n\");\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof config?.tabWidth === \"number\") {\n lines = lines.map((ln) => ln.replaceAll(\"\\t\", \" \".repeat(config.tabWidth as number)));\n }\n\n const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);\n\n const numberMaxWidth = String(end).length;\n const { gutter: colorizeGutter, marker: colorizeMarker, message: colorizeMessage } = config.color;\n\n let frame = lines\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n // eslint-disable-next-line security/detect-object-injection\n const hasMarker = markerLines[number];\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const lastMarkerLine = !markerLines[number + 1];\n\n const gutter = ` ${paddedNumber}${config.showGutter ? ` |` : \"\"}`;\n\n if (hasMarker) {\n let markerLine = \"\";\n\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line.replaceAll(/[^\\t]/g, \" \").slice(0, Math.max((hasMarker[0] as number) - 1, 0));\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = [\"\\n \", colorizeGutter(gutter.replaceAll(/\\d/g, \" \")), \" \", markerSpacing, colorizeMarker(\"^\").repeat(numberOfMarkers)].join(\n \"\",\n );\n\n if (lastMarkerLine && config.message) {\n markerLine += ` ${colorizeMessage(config.message)}`;\n }\n }\n\n return [colorizeMarker(CODE_FRAME_POINTER), colorizeGutter(gutter), line.length > 0 ? ` ${line}` : \"\", markerLine].join(\"\");\n }\n\n return ` ${colorizeGutter(gutter)}${line.length > 0 ? ` ${line}` : \"\"}`;\n })\n .join(\"\\n\");\n\n if (config.message && !hasColumns) {\n frame = `${\" \".repeat(numberMaxWidth + 1)}${config.message}\\n${frame}`;\n }\n\n return frame;\n};\n\nexport type { CodeFrameLocation, CodeFrameNodeLocation, CodeFrameOptions, ColorizeMethod } from \"./types\";\n","/**\n * A modified version of `parse-json` from `https://github.com/sindresorhus/parse-json/blob/main/index.js`\n *\n * MIT License\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n */\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { codeFrame, indexToLineColumn } from \"@visulima/error\";\nimport type { JsonValue } from \"type-fest\";\n\nimport JsonError from \"../error/json-error\";\nimport type { CodeFrameLocation, CodeFrameOptions, JsonReviver } from \"../types\";\n\nconst getCodePoint = (character: string): string => `\\\\u{${(character.codePointAt(0) as number).toString(16)}}`;\n\nconst generateCodeFrame = (source: string, location: CodeFrameLocation, options?: CodeFrameOptions) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return\n codeFrame(\n source,\n { start: location },\n {\n tabWidth: false,\n ...options,\n },\n );\n\nconst getErrorLocation = (source: string, message: string): CodeFrameLocation | undefined => {\n // eslint-disable-next-line security/detect-unsafe-regex\n const match = /in JSON at position (?<index>\\d+)(?: \\(line (?<line>\\d+) column (?<column>\\d+)\\))?$/.exec(message);\n\n if (!match) {\n return undefined;\n }\n\n // eslint-disable-next-line prefer-const\n let { column, index, line } = match.groups as { column?: string; index: number | string; line?: string };\n\n if (line && column) {\n return { column: Number(column), line: Number(line) };\n }\n\n index = Number(index);\n\n // The error location can be out of bounds.\n if (index === source.length) {\n index = source.length - 1;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return\n return indexToLineColumn(source, index);\n};\n\nconst addCodePointToUnexpectedToken = (message: string): string =>\n message.replace(\n // TODO[engine:node@>=20]: The token always quoted after Node.js 20\n // eslint-disable-next-line regexp/no-potentially-useless-backreference\n /(?<=^Unexpected token )(?<quote>')?(.)\\k<quote>/,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n (_, _quote, token) => `\"${token}\"(${getCodePoint(token)})`,\n );\n\nfunction parseJson<T = JsonValue>(string: string, filename?: string, options?: CodeFrameOptions): T;\nfunction parseJson<T = JsonValue>(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): T;\n// eslint-disable-next-line func-style\nfunction parseJson<T = JsonValue>(string: string, reviver?: JsonReviver | string, fileName?: CodeFrameOptions | string, options?: CodeFrameOptions): T {\n if (typeof reviver === \"string\") {\n if (typeof fileName === \"object\") {\n // eslint-disable-next-line no-param-reassign\n options = fileName;\n }\n\n // eslint-disable-next-line no-param-reassign\n fileName = reviver;\n // eslint-disable-next-line no-param-reassign\n reviver = undefined;\n }\n\n let message: string;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(string, reviver);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n message = error.message;\n }\n\n let location: CodeFrameLocation | undefined;\n\n if (string) {\n location = getErrorLocation(string, message);\n message = addCodePointToUnexpectedToken(message);\n } else {\n message += \" while parsing empty string\";\n }\n\n const jsonError = new JsonError(message);\n\n jsonError.fileName = fileName as string;\n\n if (location) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n jsonError.codeFrame = generateCodeFrame(string, location, options);\n }\n\n throw jsonError;\n}\n\nexport default parseJson;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var t=class extends Error{root;constructor(r,o){super(`${r instanceof Error?r.message:r} for path "${o}"`),this.cause=r,this.name="WalkError",this.root=o;}},i=t;var e=class extends Error{name="PermissionError";code="EPERM";constructor(r){super(`EPERM: Operation not permitted, ${r}`);}},a=e;
|
|
4
|
+
|
|
5
|
+
exports.a = i;
|
|
6
|
+
exports.b = a;
|
|
7
|
+
//# sourceMappingURL=out.js.map
|
|
8
|
+
//# sourceMappingURL=chunk-KXYI7M76.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error/walk-error.ts","../src/error/permission-error.ts"],"names":["WalkError","cause","root","walk_error_default","PermissionError","message","permission_error_default"],"mappings":"AAMA,IAAMA,EAAN,cAAwB,KAAM,CAEnB,KAGA,YAAYC,EAAgBC,EAAc,CAE7C,MAAM,GAAGD,aAAiB,MAAQA,EAAM,QAAUA,CAAK,cAAcC,CAAI,GAAG,EAE5E,KAAK,MAAQD,EACb,KAAK,KAAO,YACZ,KAAK,KAAOC,CAChB,CACJ,EAEOC,EAAQH,EClBf,IAAMI,EAAN,cAA8B,KAAM,CAMd,KAAO,kBAMlB,KAAO,QAMP,YAAYC,EAAiB,CAChC,MAAM,mCAAmCA,CAAO,EAAE,CACtD,CACJ,EAEOC,EAAQF","sourcesContent":["// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// Documentation and interface for walk were adapted from Go\n// https://golang.org/pkg/path/filepath/#Walk\n// Copyright 2009 The Go Authors. All rights reserved. BSD license.\n\n/** Error thrown in {@linkcode walk} or {@linkcode walkSync} during iteration. */\nclass WalkError extends Error {\n /** File path of the root that's being walked. */\n public root: string;\n\n /** Constructs a new instance. */\n public constructor(cause: unknown, root: string) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n super(`${cause instanceof Error ? cause.message : cause} for path \"${root}\"`);\n\n this.cause = cause;\n this.name = \"WalkError\";\n this.root = root;\n }\n}\n\nexport default WalkError;\n","/**\n * Error thrown when an operation is not permitted.\n */\nclass PermissionError extends Error {\n /**\n * Name of the error class.\n * @type {string}\n */\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"PermissionError\";\n\n /**\n * Error code.\n * @type {string}\n */\n public code = \"EPERM\";\n\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`EPERM: Operation not permitted, ${message}`);\n }\n}\n\nexport default PermissionError;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var r=class i extends Error{fileName;codeFrame;name="JSONError";#e;constructor(e){super(),this.#e=e,Error.captureStackTrace(this,i);}get message(){return `${this.#e}${this.fileName?` in ${this.fileName}`:""}${this.codeFrame?`
|
|
4
|
+
|
|
5
|
+
${this.codeFrame}
|
|
6
|
+
`:""}`}set message(e){this.#e=e;}},t=r;
|
|
7
|
+
|
|
8
|
+
exports.a = t;
|
|
9
|
+
//# sourceMappingURL=out.js.map
|
|
10
|
+
//# sourceMappingURL=chunk-N5NZURYL.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error/json-error.ts"],"names":["JSONError","_JSONError","#message","message","json_error_default"],"mappings":"AAAA,IAAMA,EAAN,MAAMC,UAAkB,KAAM,CACnB,SAEA,UAGW,KAAO,YAEzBC,GAEO,YAAYC,EAAiB,CAGhC,MAAM,EAEN,KAAKD,GAAWC,EAEhB,MAAM,kBAAkB,KAAMF,CAAS,CAC3C,CAEA,IAAoB,SAAkB,CAClC,MAAO,GAAG,KAAKC,EAAQ,GAAG,KAAK,SAAW,OAAO,KAAK,QAAQ,GAAK,EAAE,GAAG,KAAK,UAAY;AAAA;AAAA,EAAO,KAAK,SAAS;AAAA,EAAO,EAAE,EAC3H,CAEA,IAAoB,QAAQC,EAAiB,CACzC,KAAKD,GAAWC,CACpB,CACJ,EAEOC,EAAQJ","sourcesContent":["class JSONError extends Error {\n public fileName: string | undefined;\n\n public codeFrame: string | undefined;\n\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"JSONError\";\n\n #message;\n\n public constructor(message: string) {\n // We cannot pass message to `super()`, otherwise the message accessor will be overridden.\n // https://262.ecma-international.org/14.0/#sec-error-message\n super();\n\n this.#message = message;\n\n Error.captureStackTrace(this, JSONError);\n }\n\n public override get message(): string {\n return `${this.#message}${this.fileName ? ` in ${this.fileName}` : \"\"}${this.codeFrame ? `\\n\\n${this.codeFrame}\\n` : \"\"}`;\n }\n\n public override set message(message: string) {\n this.#message = message;\n }\n}\n\nexport default JSONError;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var r=class i extends Error{fileName;codeFrame;name="JSONError";#e;constructor(e){super(),this.#e=e,Error.captureStackTrace(this,i);}get message(){return `${this.#e}${this.fileName?` in ${this.fileName}`:""}${this.codeFrame?`
|
|
2
|
+
|
|
3
|
+
${this.codeFrame}
|
|
4
|
+
`:""}`}set message(e){this.#e=e;}},n=r;
|
|
5
|
+
|
|
6
|
+
export { n as a };
|
|
7
|
+
//# sourceMappingURL=out.js.map
|
|
8
|
+
//# sourceMappingURL=chunk-UPN3Y5W3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error/json-error.ts"],"names":["JSONError","_JSONError","#message","message","json_error_default"],"mappings":"AAAA,IAAMA,EAAN,MAAMC,UAAkB,KAAM,CACnB,SAEA,UAGW,KAAO,YAEzBC,GAEO,YAAYC,EAAiB,CAGhC,MAAM,EAEN,KAAKD,GAAWC,EAEhB,MAAM,kBAAkB,KAAMF,CAAS,CAC3C,CAEA,IAAoB,SAAkB,CAClC,MAAO,GAAG,KAAKC,EAAQ,GAAG,KAAK,SAAW,OAAO,KAAK,QAAQ,GAAK,EAAE,GAAG,KAAK,UAAY;AAAA;AAAA,EAAO,KAAK,SAAS;AAAA,EAAO,EAAE,EAC3H,CAEA,IAAoB,QAAQC,EAAiB,CACzC,KAAKD,GAAWC,CACpB,CACJ,EAEOC,EAAQJ","sourcesContent":["class JSONError extends Error {\n public fileName: string | undefined;\n\n public codeFrame: string | undefined;\n\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"JSONError\";\n\n #message;\n\n public constructor(message: string) {\n // We cannot pass message to `super()`, otherwise the message accessor will be overridden.\n // https://262.ecma-international.org/14.0/#sec-error-message\n super();\n\n this.#message = message;\n\n Error.captureStackTrace(this, JSONError);\n }\n\n public override get message(): string {\n return `${this.#message}${this.fileName ? ` in ${this.fileName}` : \"\"}${this.codeFrame ? `\\n\\n${this.codeFrame}\\n` : \"\"}`;\n }\n\n public override set message(message: string) {\n this.#message = message;\n }\n}\n\nexport default JSONError;\n"]}
|
package/dist/error.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkKXYI7M76_cjs = require('./chunk-KXYI7M76.cjs');
|
|
4
|
+
var chunkN5NZURYL_cjs = require('./chunk-N5NZURYL.cjs');
|
|
5
|
+
|
|
6
|
+
var o=class extends Error{name="DirectoryError";code="EISDIR";constructor(r){super(`EISDIR: Illegal operation on a directory, ${r}`);}},u=o;var t=class extends Error{code="ENOTEMPTY";name="NotEmptyError";constructor(r){super(`ENOTEMPTY: Directory not empty, ${r}`);}},p=t;var a=class extends Error{name="NotFoundError";code="ENOENT";constructor(r){super(`ENOENT: No such file or directory, ${r}`);}},i=a;
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, 'PermissionError', {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkKXYI7M76_cjs.b; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, 'WalkError', {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkKXYI7M76_cjs.a; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, 'JSONError', {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkN5NZURYL_cjs.a; }
|
|
19
|
+
});
|
|
20
|
+
exports.DirectoryError = u;
|
|
21
|
+
exports.NotEmptyError = p;
|
|
22
|
+
exports.NotFoundError = i;
|
|
23
|
+
//# sourceMappingURL=out.js.map
|
|
24
|
+
//# sourceMappingURL=error.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error/directory-error.ts","../src/error/not-empty-error.ts","../src/error/not-found-error.ts"],"names":["DirectoryError","message","directory_error_default","NotEmptyError","not_empty_error_default","NotFoundError","not_found_error_default"],"mappings":"yFAGA,IAAMA,EAAN,cAA6B,KAAM,CAMb,KAAO,iBAMlB,KAAO,SAMP,YAAYC,EAAiB,CAChC,MAAM,6CAA6CA,CAAO,EAAE,CAChE,CACJ,EAEOC,EAAQF,ECvBf,IAAMG,EAAN,cAA4B,KAAM,CAKvB,KAAO,YAOI,KAAO,gBAMlB,YAAYF,EAAiB,CAChC,MAAM,mCAAmCA,CAAO,EAAE,CACtD,CACJ,EAEOG,EAAQD,ECvBf,IAAME,EAAN,cAA4B,KAAM,CAMZ,KAAO,gBAMlB,KAAO,SAMP,YAAYJ,EAAiB,CAChC,MAAM,sCAAsCA,CAAO,EAAE,CACzD,CACJ,EAEOK,EAAQD","sourcesContent":["/**\n * Error thrown when an operation is not allowed on a directory.\n */\nclass DirectoryError extends Error {\n /**\n * Name of the error class.\n * @type {string}\n */\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"DirectoryError\";\n\n /**\n * Error code.\n * @type {string}\n */\n public code = \"EISDIR\";\n\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`EISDIR: Illegal operation on a directory, ${message}`);\n }\n}\n\nexport default DirectoryError;\n","/**\n * Error thrown when a directory is not empty.\n */\nclass NotEmptyError extends Error {\n /**\n * Error code.\n * @type {string}\n */\n public code = \"ENOTEMPTY\";\n\n /**\n * Name of the error class.\n * @type {string}\n */\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"NotEmptyError\";\n\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`ENOTEMPTY: Directory not empty, ${message}`);\n }\n}\n\nexport default NotEmptyError;\n","/**\n * Error thrown when a file or directory is not found.\n */\nclass NotFoundError extends Error {\n /**\n * Name of the error class.\n * @type {string}\n */\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"NotFoundError\";\n\n /**\n * Error code.\n * @type {string}\n */\n public code = \"ENOENT\";\n\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`ENOENT: No such file or directory, ${message}`);\n }\n}\n\nexport default NotFoundError;\n"]}
|
package/dist/error.d.cts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export { J as JSONError } from './json-error-UVjLdb7z.cjs';
|
|
2
|
+
|
|
3
|
+
declare class DirectoryError extends Error {
|
|
4
|
+
readonly name = "DirectoryError";
|
|
5
|
+
code: string;
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare class NotEmptyError extends Error {
|
|
10
|
+
code: string;
|
|
11
|
+
readonly name = "NotEmptyError";
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare class NotFoundError extends Error {
|
|
16
|
+
readonly name = "NotFoundError";
|
|
17
|
+
code: string;
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare class PermissionError extends Error {
|
|
22
|
+
readonly name = "PermissionError";
|
|
23
|
+
code: string;
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare class WalkError extends Error {
|
|
28
|
+
root: string;
|
|
29
|
+
constructor(cause: unknown, root: string);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { DirectoryError, NotEmptyError, NotFoundError, PermissionError, WalkError };
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export { J as JSONError } from './json-error-UVjLdb7z.js';
|
|
2
|
+
|
|
3
|
+
declare class DirectoryError extends Error {
|
|
4
|
+
readonly name = "DirectoryError";
|
|
5
|
+
code: string;
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare class NotEmptyError extends Error {
|
|
10
|
+
code: string;
|
|
11
|
+
readonly name = "NotEmptyError";
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare class NotFoundError extends Error {
|
|
16
|
+
readonly name = "NotFoundError";
|
|
17
|
+
code: string;
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare class PermissionError extends Error {
|
|
22
|
+
readonly name = "PermissionError";
|
|
23
|
+
code: string;
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare class WalkError extends Error {
|
|
28
|
+
root: string;
|
|
29
|
+
constructor(cause: unknown, root: string);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { DirectoryError, NotEmptyError, NotFoundError, PermissionError, WalkError };
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { b as PermissionError, a as WalkError } from './chunk-3EHZOWRU.js';
|
|
2
|
+
export { a as JSONError } from './chunk-UPN3Y5W3.js';
|
|
3
|
+
|
|
4
|
+
var o=class extends Error{name="DirectoryError";code="EISDIR";constructor(r){super(`EISDIR: Illegal operation on a directory, ${r}`);}},p=o;var a=class extends Error{code="ENOTEMPTY";name="NotEmptyError";constructor(r){super(`ENOTEMPTY: Directory not empty, ${r}`);}},i=a;var s=class extends Error{name="NotFoundError";code="ENOENT";constructor(r){super(`ENOENT: No such file or directory, ${r}`);}},n=s;
|
|
5
|
+
|
|
6
|
+
export { p as DirectoryError, i as NotEmptyError, n as NotFoundError };
|
|
7
|
+
//# sourceMappingURL=out.js.map
|
|
8
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error/directory-error.ts","../src/error/not-empty-error.ts","../src/error/not-found-error.ts"],"names":["DirectoryError","message","directory_error_default","NotEmptyError","not_empty_error_default","NotFoundError","not_found_error_default"],"mappings":"uFAGA,IAAMA,EAAN,cAA6B,KAAM,CAMb,KAAO,iBAMlB,KAAO,SAMP,YAAYC,EAAiB,CAChC,MAAM,6CAA6CA,CAAO,EAAE,CAChE,CACJ,EAEOC,EAAQF,ECvBf,IAAMG,EAAN,cAA4B,KAAM,CAKvB,KAAO,YAOI,KAAO,gBAMlB,YAAYF,EAAiB,CAChC,MAAM,mCAAmCA,CAAO,EAAE,CACtD,CACJ,EAEOG,EAAQD,ECvBf,IAAME,EAAN,cAA4B,KAAM,CAMZ,KAAO,gBAMlB,KAAO,SAMP,YAAYJ,EAAiB,CAChC,MAAM,sCAAsCA,CAAO,EAAE,CACzD,CACJ,EAEOK,EAAQD","sourcesContent":["/**\n * Error thrown when an operation is not allowed on a directory.\n */\nclass DirectoryError extends Error {\n /**\n * Name of the error class.\n * @type {string}\n */\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"DirectoryError\";\n\n /**\n * Error code.\n * @type {string}\n */\n public code = \"EISDIR\";\n\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`EISDIR: Illegal operation on a directory, ${message}`);\n }\n}\n\nexport default DirectoryError;\n","/**\n * Error thrown when a directory is not empty.\n */\nclass NotEmptyError extends Error {\n /**\n * Error code.\n * @type {string}\n */\n public code = \"ENOTEMPTY\";\n\n /**\n * Name of the error class.\n * @type {string}\n */\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"NotEmptyError\";\n\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`ENOTEMPTY: Directory not empty, ${message}`);\n }\n}\n\nexport default NotEmptyError;\n","/**\n * Error thrown when a file or directory is not found.\n */\nclass NotFoundError extends Error {\n /**\n * Name of the error class.\n * @type {string}\n */\n // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility\n override readonly name = \"NotFoundError\";\n\n /**\n * Error code.\n * @type {string}\n */\n public code = \"ENOENT\";\n\n /**\n * Creates a new instance.\n * @param {string} message The error message.\n */\n public constructor(message: string) {\n super(`ENOENT: No such file or directory, ${message}`);\n }\n}\n\nexport default NotFoundError;\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,22 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkKXYI7M76_cjs = require('./chunk-KXYI7M76.cjs');
|
|
4
|
+
var chunkC4ULY5SU_cjs = require('./chunk-C4ULY5SU.cjs');
|
|
5
|
+
require('./chunk-N5NZURYL.cjs');
|
|
3
6
|
var promises = require('fs/promises');
|
|
4
7
|
var path = require('path');
|
|
5
8
|
var url = require('url');
|
|
6
9
|
var fs = require('fs');
|
|
7
10
|
var zlib = require('zlib');
|
|
8
11
|
|
|
9
|
-
var
|
|
12
|
+
var j=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},y=j;var z=e=>{let t=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${t}$`)},F=z;var M=e=>e instanceof URL?url.fileURLToPath(e):e,m=M;var Y=(e,t,r,i)=>t&&!t.some(n=>e.endsWith(n))||r&&!r.some(n=>n.test(e))?!1:!(i&&i.some(n=>n.test(e))),w=Y;var te=async e=>{let t=path.normalize(e),r=path.basename(t),i=await promises.stat(t);return {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:r,path:t}};async function*R(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a,maxDepth:c=Number.POSITIVE_INFINITY,skip:d}={}){if(y(e),c<0)return;let l=a?a.map(o=>typeof o=="string"?F(o):o):void 0,f=d?d.map(o=>typeof o=="string"?F(o):o):void 0;if(e=path.resolve(m(e)),i&&w(e,t,l,f)&&(yield await te(e)),!(c<1||!w(e,void 0,void 0,f)))try{for await(let o of await promises.readdir(e,{withFileTypes:!0})){let u=path.join(e,o.name);if(o.isSymbolicLink())if(r)u=await promises.realpath(u);else if(s&&w(u,t,l,f))yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:u};else continue;o.isSymbolicLink()||o.isDirectory()?yield*R(u,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:s,match:l,maxDepth:c-1,skip:f}):o.isFile()&&n&&w(u,t,l,f)&&(yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:u});}}catch(o){throw o instanceof chunkKXYI7M76_cjs.a?o:new chunkKXYI7M76_cjs.a(o,e)}}var re=async(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},i=[];for await(let n of R(e,r))i.push(n.path);return i},ie=re;var me=e=>{let t=path.normalize(e),r=path.basename(t),i=fs.statSync(t);return {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:r,path:t}};function*k(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a,maxDepth:c=Number.POSITIVE_INFINITY,skip:d}={}){if(y(e),c<0)return;let l=a?a.map(o=>typeof o=="string"?F(o):o):void 0,f=d?d.map(o=>typeof o=="string"?F(o):o):void 0;if(e=path.resolve(m(e)),i&&w(e,t,l,f)&&(yield me(e)),!(c<1||!w(e,void 0,void 0,f)))try{for(let o of fs.readdirSync(e,{withFileTypes:!0})){let u=path.join(e,o.name);if(o.isSymbolicLink())if(r)u=fs.realpathSync(u);else if(s&&w(u,t,l,f))yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:u};else continue;o.isSymbolicLink()||o.isDirectory()?yield*k(u,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:s,match:l,maxDepth:c-1,skip:f}):o.isFile()&&n&&w(u,t,l,f)&&(yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:u});}}catch(o){throw o instanceof chunkKXYI7M76_cjs.a?o:new chunkKXYI7M76_cjs.a(o,e)}}var de=(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},i=[];for(let n of k(e,r))i.push(n.path);return i},pe=de;var Oe=async(e,t={})=>{let r=t.cwd?m(t.cwd):process.cwd();y(r);let i=path.resolve(r),{root:n}=path.parse(i),s=m(t.stopAt??n);y(s);let a=path.resolve(i,s),c=t.type??"file";for(;i&&i!==a&&i!==n;){let d=path.isAbsolute(e)?e:path.join(i,e);try{let l=await promises.stat(d);if(c==="file"&&l.isFile()||c==="directory"&&l.isDirectory())return d}catch{}i=path.dirname(i);}},Fe=Oe;var Ee=(e,t={})=>{let r=t.cwd?m(t.cwd):process.cwd();y(r);let i=path.resolve(r),{root:n}=path.parse(i),s=m(t.stopAt??n);y(s);let a=path.resolve(i,s),c=t.type??"file";for(;i&&i!==a&&i!==n;){let d=path.isAbsolute(e)?e:path.join(i,e);try{let l=fs.statSync(d);if(c==="file"&&l.isFile()||c==="directory"&&l.isDirectory())return d}catch{}i=path.dirname(i);}},Pe=Ee;async function Je(e,t=0){y(e),e=m(e);try{return await promises.access(e,t),!0}catch{return !1}}var g=Je;function Ue(e,t=0){y(e),e=m(e);try{return fs.accessSync(e,t),!0}catch{return !1}}var b=Ue;var De={brotli:zlib.brotliDecompress,gzip:zlib.unzip,none:(e,t)=>{t(null,e);}},ve=async(e,t)=>{if(y(e),e=m(e),!await g(e))throw new chunkKXYI7M76_cjs.b(`unable to read the non-accessible file: ${e}`);if(!await g(e,4))throw new Error(`Unable to read the non-readable file: ${e}`);let{buffer:r,compression:i,encoding:n,flag:s}=t??{};return await promises.readFile(e,s?{encoding:n,flag:s}:{encoding:n}).then(async a=>await new Promise((c,d)=>{De[i??"none"](a,(l,f)=>{l?d(l):c(r?f:f.toString());});})).catch(a=>{throw a})},W=ve;var Ce={brotli:zlib.brotliDecompressSync,gzip:zlib.unzipSync,none:e=>e},_e=(e,t)=>{if(y(e),e=m(e),!b(e))throw new chunkKXYI7M76_cjs.b(`unable to read the non-accessible file: ${e}`);if(!b(e,4))throw new chunkKXYI7M76_cjs.b(`invalid access to read file at: ${e}`);let{buffer:r,compression:i,encoding:n,flag:s}=t??{},a=fs.readFileSync(e,s?{encoding:n,flag:s}:{encoding:n}),c=Ce[i??"none"](a);return r?c:c.toString()},A=_e;async function Be(e,t,r){typeof t=="object"&&(r=t,t=void 0);let i=await W(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(i),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(n=s(n)),chunkC4ULY5SU_cjs.a(n,t,m(e),{color:a})}var je=Be;function ze(e,t,r){typeof t=="object"&&(r=t,t=void 0);let i=A(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(i),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(n=s(n)),chunkC4ULY5SU_cjs.a(n,t,m(e),{color:a})}var Ke=ze;var Me=e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},J=Me;var Ye=new TextEncoder,He=e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return Ye.encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e)){let t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},L=He;var rt=async(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},y(e),J(t),e=m(e);try{let i=await g(e,0);if(!i&&r.recursive){let a=path.dirname(e);await g(a,0)||await promises.mkdir(a,{recursive:!0});}let n;await promises.writeFile(`${e}.tmp`,L(t),{encoding:r.encoding,flag:r.flag}),i&&!r.overwrite&&(n=await promises.stat(e),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),await promises.rename(e,`${e}.bak`));let s=`${e}.tmp`;if(r.chown)try{await promises.chown(s,r.chown.uid,r.chown.gid);}catch{}await promises.chmod(s,n&&!r.mode?n.mode:r.mode??438),await promises.rename(s,e);}catch(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{await g(`${e}.tmp`)&&await promises.unlink(`${e}.tmp`);}},I=rt;var lt=(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},y(e),J(t),e=m(e);try{let i=b(e,0);if(!i&&r.recursive){let a=path.dirname(e);b(a,0)||fs.mkdirSync(a,{recursive:!0});}let n;fs.writeFileSync(`${e}.tmp`,L(t),{encoding:r.encoding,flag:r.flag}),i&&!r.overwrite&&(n=fs.statSync(e),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),fs.renameSync(e,`${e}.bak`));let s=`${e}.tmp`;if(r.chown)try{fs.chownSync(s,r.chown.uid,r.chown.gid);}catch{}fs.chmodSync(s,n&&!r.mode?n.mode:r.mode??438),fs.renameSync(s,e);}catch(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{b(`${e}.tmp`)&&fs.unlinkSync(`${e}.tmp`);}},D=lt;var mt=/^(?:( )+|\t+)/,x="space",_="tab";function C(e,t){let r=new Map,i=0,n,s;for(let a of e.split(/\n/g)){if(!a)continue;let c,d,l,f,o,u=a.match(mt);if(u===null)i=0,n="";else {if(c=u[0].length,d=u[1]?x:_,t&&d===x&&c===1)continue;d!==n&&(i=0),n=d,l=1,f=0;let P=c-i;if(i=c,P===0)l=0,f=1;else {let B=P>0?P:-P;s=dt(d,B);}o=r.get(s),o=o===void 0?[1,0]:[o[0]+l,o[1]+f],r.set(s,o);}}return r}function dt(e,t){return (e===x?"s":"t")+String(t)}function pt(e){let r=e[0]==="s"?x:_,i=Number(e.slice(1));return {type:r,amount:i}}function yt(e){let t,r=0,i=0;for(let[n,[s,a]]of e)(s>r||s===r&&a>i)&&(r=s,i=a,t=n);return t}function ut(e,t){return (e===x?" ":" ").repeat(t)}function E(e){if(typeof e!="string")throw new TypeError("Expected a string");let t=C(e,!0);t.size===0&&(t=C(e,!1));let r=yt(t),i,n=0,s="";return r!==void 0&&({type:i,amount:n}=pt(r),s=ut(i,n)),{amount:n,type:i,indent:s}}var gt=async(e,t,r={})=>{let{detectIndent:i,indent:n,replacer:s,...a}={indent:" ",...r},c=n,d=`
|
|
13
|
+
`;if(await g(e,4))try{let f=await promises.readFile(e,"utf8");if(i){let{indent:o}=E(f);c=o;}d=f.endsWith(`
|
|
14
|
+
`)?`
|
|
15
|
+
`:"";}catch(f){if(f.code!=="ENOENT")throw f}let l=JSON.stringify(t,s,c);await I(e,`${l}${d}`,a);},bt=gt;var Ft=(e,t,r={})=>{let{detectIndent:i,indent:n,replacer:s,...a}={indent:" ",...r},c=n,d=`
|
|
16
|
+
`;if(b(e,4))try{let f=fs.readFileSync(e,"utf8");if(i){let{indent:o}=E(f);c=o;}d=f.endsWith(`
|
|
17
|
+
`)?`
|
|
18
|
+
`:"";}catch(f){if(f.code!=="ENOENT")throw f}let l=JSON.stringify(t,s,c);D(e,`${l}${d}`,a);},St=Ft;
|
|
10
19
|
|
|
11
|
-
exports.collect =
|
|
12
|
-
exports.collectSync =
|
|
13
|
-
exports.findUp =
|
|
14
|
-
exports.findUpSync =
|
|
15
|
-
exports.isAccessible =
|
|
16
|
-
exports.isAccessibleSync =
|
|
17
|
-
exports.readFile =
|
|
18
|
-
exports.readFileSync =
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
20
|
+
exports.collect = ie;
|
|
21
|
+
exports.collectSync = pe;
|
|
22
|
+
exports.findUp = Fe;
|
|
23
|
+
exports.findUpSync = Pe;
|
|
24
|
+
exports.isAccessible = g;
|
|
25
|
+
exports.isAccessibleSync = b;
|
|
26
|
+
exports.readFile = W;
|
|
27
|
+
exports.readFileSync = A;
|
|
28
|
+
exports.readJson = je;
|
|
29
|
+
exports.readJsonSync = Ke;
|
|
30
|
+
exports.walk = R;
|
|
31
|
+
exports.walkSync = k;
|
|
32
|
+
exports.writeFile = I;
|
|
33
|
+
exports.writeFileSync = D;
|
|
34
|
+
exports.writeJson = bt;
|
|
35
|
+
exports.writeJsonSync = St;
|
|
21
36
|
//# sourceMappingURL=out.js.map
|
|
22
37
|
//# sourceMappingURL=index.cjs.map
|