@visulima/fs 4.0.3 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/LICENSE.md +1 -1
- package/dist/eol.js +26 -3
- package/dist/error.js +7 -1
- package/dist/index.js +32 -1
- package/dist/packem_shared/AlreadyExistsError-D5BGeeNR.js +27 -0
- package/dist/packem_shared/DirectoryError-CaUV2Pbk.js +27 -0
- package/dist/packem_shared/F_OK-MldBaGxb.js +8 -0
- package/dist/packem_shared/JSONError-BkHRnInH.js +26 -0
- package/dist/packem_shared/NotEmptyError-mOHWXE0m.js +27 -0
- package/dist/packem_shared/NotFoundError-D4llRgRs.js +27 -0
- package/dist/packem_shared/PermissionError-1qs0skfo.js +27 -0
- package/dist/packem_shared/WalkError-DUdQd6FT.js +24 -0
- package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +7 -0
- package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +7 -0
- package/dist/packem_shared/collect-DcBwsYYd.js +14 -0
- package/dist/packem_shared/collectSync-Bkjf9Dbm.js +14 -0
- package/dist/packem_shared/emptyDir-CYB5Tict.js +43 -0
- package/dist/packem_shared/emptyDirSync-BD8-1Ytl.js +41 -0
- package/dist/packem_shared/ensureDir-C_kuQ5Ik.js +53 -0
- package/dist/packem_shared/ensureDirSync-CI5g-uBI.js +53 -0
- package/dist/packem_shared/ensureFile-BUtXGlGT.js +47 -0
- package/dist/packem_shared/ensureFileSync-C8hASR-1.js +47 -0
- package/dist/packem_shared/ensureLink-BPnAG5-P.js +54 -0
- package/dist/packem_shared/ensureLinkSync-B-Z7X0ub.js +54 -0
- package/dist/packem_shared/ensureSymlink-BGz6W-Wa.js +73 -0
- package/dist/packem_shared/ensureSymlinkSync-C5Gk8QYi.js +74 -0
- package/dist/packem_shared/findUp-BSnyGqer.js +85 -0
- package/dist/packem_shared/findUpSync-jRHbSCMV.js +85 -0
- package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +14 -0
- package/dist/packem_shared/index-CHM-in-V.js +100 -0
- package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +3 -0
- package/dist/packem_shared/isAccessible-DuVrTNFV.js +38 -0
- package/dist/packem_shared/isAccessibleSync-DI8mM0fA.js +38 -0
- package/dist/packem_shared/isFsCaseSensitive-D-ayleCy.js +62 -0
- package/dist/packem_shared/move-DbpW5_vA.js +134 -0
- package/dist/packem_shared/parseJson-CqUuRguZ.js +231 -0
- package/dist/packem_shared/readFile-iHOVXeH-.js +68 -0
- package/dist/packem_shared/readFileSync-BkEj9BQY.js +53 -0
- package/dist/packem_shared/readJson-pdfQBWDR.js +22 -0
- package/dist/packem_shared/readJsonSync-BZqGcA5d.js +22 -0
- package/dist/packem_shared/readYaml-BQXTlR2p.js +10 -0
- package/dist/packem_shared/readYamlSync-BBBQ5ujx.js +10 -0
- package/dist/packem_shared/remove-_oDY3uKo.js +38 -0
- package/dist/packem_shared/removeSync-DETRj7Qn.js +38 -0
- package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +16 -0
- package/dist/packem_shared/stripJsonComments-vo4k0mpF.js +19 -0
- package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +19 -0
- package/dist/packem_shared/walk-BhTbpr3y.js +115 -0
- package/dist/packem_shared/walk-include-CZco7BvN.js +16 -0
- package/dist/packem_shared/walkSync-DDBq95s8.js +114 -0
- package/dist/packem_shared/writeFile-DSHERs0Z.js +83 -0
- package/dist/packem_shared/writeFileSync-CJp1kXQR.js +83 -0
- package/dist/packem_shared/writeJson-C0OfLDbe.js +50 -0
- package/dist/packem_shared/writeJsonSync-Cs21FE7v.js +50 -0
- package/dist/packem_shared/writeYaml-n4xzYN9a.js +24 -0
- package/dist/packem_shared/writeYamlSync-DnOEnP10.js +24 -0
- package/dist/size.js +144 -1
- package/dist/utils.js +6 -1
- package/dist/yaml.js +4 -1
- package/package.json +2 -2
- package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.js +0 -1
- package/dist/packem_shared/DirectoryError-ddlbUV8C.js +0 -1
- package/dist/packem_shared/F_OK-CAwY1qU7.js +0 -1
- package/dist/packem_shared/JSONError-D7h6PNWc.js +0 -4
- package/dist/packem_shared/NotEmptyError-DMh1o7UL.js +0 -1
- package/dist/packem_shared/NotFoundError-BPiW0icm.js +0 -1
- package/dist/packem_shared/PermissionError-B1Emi5a9.js +0 -1
- package/dist/packem_shared/WalkError-BsngoIKJ.js +0 -1
- package/dist/packem_shared/assertValidFileContents-BZFnXa7K.js +0 -1
- package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.js +0 -1
- package/dist/packem_shared/collect-DO31RsLs.js +0 -1
- package/dist/packem_shared/collectSync-Cy7ULmjZ.js +0 -1
- package/dist/packem_shared/emptyDir-zBLHyPsJ.js +0 -1
- package/dist/packem_shared/emptyDirSync-DZ8nTo6g.js +0 -1
- package/dist/packem_shared/ensureDir-CwcwvbZ0.js +0 -1
- package/dist/packem_shared/ensureDirSync-DsFhH5oQ.js +0 -1
- package/dist/packem_shared/ensureFile-DwcEQVDX.js +0 -1
- package/dist/packem_shared/ensureFileSync-KnrH51Ox.js +0 -1
- package/dist/packem_shared/ensureLink-5rjQGEBb.js +0 -1
- package/dist/packem_shared/ensureLinkSync-CYXpscf2.js +0 -1
- package/dist/packem_shared/ensureSymlink-GATTbE5c.js +0 -1
- package/dist/packem_shared/ensureSymlinkSync-CvXgTFrl.js +0 -1
- package/dist/packem_shared/findUp-Di7Az07S.js +0 -1
- package/dist/packem_shared/findUpSync-iV97v14Q.js +0 -1
- package/dist/packem_shared/get-file-info-type-CaWGXRjY.js +0 -1
- package/dist/packem_shared/index-CYIVJA0W.js +0 -1
- package/dist/packem_shared/is-stats-identical-CohsLtWy.js +0 -1
- package/dist/packem_shared/isAccessible-CDFxsAAo.js +0 -1
- package/dist/packem_shared/isAccessibleSync-5nzZWgin.js +0 -1
- package/dist/packem_shared/isFsCaseSensitive-Drl8fHLV.js +0 -1
- package/dist/packem_shared/move-Bz4gSIjp.js +0 -1
- package/dist/packem_shared/parseJson-Cj4v3qzl.js +0 -6
- package/dist/packem_shared/readFile-CbxFM_zp.js +0 -1
- package/dist/packem_shared/readFileSync-B9iv2Sb8.js +0 -1
- package/dist/packem_shared/readJson-BgC3msx-.js +0 -1
- package/dist/packem_shared/readJsonSync-DHO1vjAG.js +0 -1
- package/dist/packem_shared/readYaml-D5mtfANg.js +0 -1
- package/dist/packem_shared/readYamlSync-D0igCVDE.js +0 -1
- package/dist/packem_shared/remove-BUqZUj1W.js +0 -1
- package/dist/packem_shared/removeSync-BbT4vmDi.js +0 -1
- package/dist/packem_shared/resolve-symlink-target-BofZSDIc.js +0 -1
- package/dist/packem_shared/stripJsonComments-DbMjL4qv.js +0 -1
- package/dist/packem_shared/to-uint-8-array-DwgaTasY.js +0 -1
- package/dist/packem_shared/walk-ZrZngpc4.js +0 -1
- package/dist/packem_shared/walk-include-DCiVAwMP.js +0 -1
- package/dist/packem_shared/walkSync-BQa4NKSG.js +0 -1
- package/dist/packem_shared/writeFile-D5OYEMHu.js +0 -1
- package/dist/packem_shared/writeFileSync-CO4ySqUn.js +0 -1
- package/dist/packem_shared/writeJson-DfmgiY_s.js +0 -4
- package/dist/packem_shared/writeJsonSync-Ck1pmmj_.js +0 -4
- package/dist/packem_shared/writeYaml-BJeyUpyY.js +0 -1
- package/dist/packem_shared/writeYamlSync-D87XCS7Y.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## @visulima/fs [4.0.4](https://github.com/visulima/visulima/compare/@visulima/fs@4.0.3...@visulima/fs@4.0.4) (2025-11-07)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* update TypeScript configurations and improve linting across multiple packages ([6f25ec7](https://github.com/visulima/visulima/commit/6f25ec7841da7246f8f9166efc5292a7089d37ee))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* update npm and pnpm configurations for monorepo optimization ([#564](https://github.com/visulima/visulima/issues/564)) ([5512b42](https://github.com/visulima/visulima/commit/5512b42f672c216b6a3c9e39035199a4ebd9a4b8))
|
|
10
|
+
* update package.json files and pnpm-lock.yaml ([95d9f5b](https://github.com/visulima/visulima/commit/95d9f5b607105d05a006deadb4379e89f06dfe99))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Dependencies
|
|
14
|
+
|
|
15
|
+
* **@visulima/path:** upgraded to 2.0.3
|
|
16
|
+
* **@visulima/error:** upgraded to 5.0.4
|
|
17
|
+
|
|
1
18
|
## @visulima/fs [4.0.3](https://github.com/visulima/visulima/compare/@visulima/fs@4.0.2...@visulima/fs@4.0.3) (2025-11-05)
|
|
2
19
|
|
|
3
20
|
### Bug Fixes
|
package/LICENSE.md
CHANGED
|
@@ -68,7 +68,7 @@ Repository: git+https://github.com/visulima/visulima.git
|
|
|
68
68
|
>
|
|
69
69
|
> > MIT License
|
|
70
70
|
> >
|
|
71
|
-
> > Copyright (c)
|
|
71
|
+
> > Copyright (c) 2025 visulima
|
|
72
72
|
> >
|
|
73
73
|
> > Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
74
74
|
> > of this software and associated documentation files (the "Software"), to deal
|
package/dist/eol.js
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
platform
|
|
9
|
+
} = __cjs_getProcess;
|
|
10
|
+
|
|
11
|
+
const regDetect = /\r?\n/g;
|
|
12
|
+
const LF = "\n";
|
|
13
|
+
const CRLF = "\r\n";
|
|
14
|
+
const EOL = platform === "win32" ? CRLF : LF;
|
|
15
|
+
const detect = (content) => {
|
|
16
|
+
const matched = content.match(regDetect);
|
|
17
|
+
if (!matched || matched.length === 0) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const crlf = matched.filter((newline) => newline === CRLF).length;
|
|
21
|
+
const lf = matched.length - crlf;
|
|
22
|
+
return crlf > lf ? CRLF : LF;
|
|
23
|
+
};
|
|
24
|
+
const format = (content, eol) => content.replaceAll(regDetect, eol);
|
|
25
|
+
|
|
26
|
+
export { CRLF, EOL, LF, detect, format };
|
package/dist/error.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
export { default as AlreadyExistsError } from './packem_shared/AlreadyExistsError-D5BGeeNR.js';
|
|
2
|
+
export { default as DirectoryError } from './packem_shared/DirectoryError-CaUV2Pbk.js';
|
|
3
|
+
export { default as JSONError } from './packem_shared/JSONError-BkHRnInH.js';
|
|
4
|
+
export { default as NotEmptyError } from './packem_shared/NotEmptyError-mOHWXE0m.js';
|
|
5
|
+
export { default as NotFoundError } from './packem_shared/NotFoundError-D4llRgRs.js';
|
|
6
|
+
export { default as PermissionError } from './packem_shared/PermissionError-1qs0skfo.js';
|
|
7
|
+
export { default as WalkError } from './packem_shared/WalkError-DUdQd6FT.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
export { FIND_UP_STOP, F_OK, R_OK, W_OK, X_OK } from './packem_shared/F_OK-MldBaGxb.js';
|
|
2
|
+
export { default as ensureDir } from './packem_shared/ensureDir-C_kuQ5Ik.js';
|
|
3
|
+
export { default as ensureDirSync } from './packem_shared/ensureDirSync-CI5g-uBI.js';
|
|
4
|
+
export { default as ensureFile } from './packem_shared/ensureFile-BUtXGlGT.js';
|
|
5
|
+
export { default as ensureFileSync } from './packem_shared/ensureFileSync-C8hASR-1.js';
|
|
6
|
+
export { default as ensureLink } from './packem_shared/ensureLink-BPnAG5-P.js';
|
|
7
|
+
export { default as ensureLinkSync } from './packem_shared/ensureLinkSync-B-Z7X0ub.js';
|
|
8
|
+
export { default as ensureSymlink } from './packem_shared/ensureSymlink-BGz6W-Wa.js';
|
|
9
|
+
export { default as ensureSymlinkSync } from './packem_shared/ensureSymlinkSync-C5Gk8QYi.js';
|
|
10
|
+
export { CRLF, EOL, LF, detect, format } from './eol.js';
|
|
11
|
+
export { default as collect } from './packem_shared/collect-DcBwsYYd.js';
|
|
12
|
+
export { default as collectSync } from './packem_shared/collectSync-Bkjf9Dbm.js';
|
|
13
|
+
export { default as findUp } from './packem_shared/findUp-BSnyGqer.js';
|
|
14
|
+
export { default as findUpSync } from './packem_shared/findUpSync-jRHbSCMV.js';
|
|
15
|
+
export { default as walk } from './packem_shared/walk-BhTbpr3y.js';
|
|
16
|
+
export { default as walkSync } from './packem_shared/walkSync-DDBq95s8.js';
|
|
17
|
+
export { default as isAccessible } from './packem_shared/isAccessible-DuVrTNFV.js';
|
|
18
|
+
export { default as isAccessibleSync } from './packem_shared/isAccessibleSync-DI8mM0fA.js';
|
|
19
|
+
export { move, moveSync, rename, renameSync } from './packem_shared/move-DbpW5_vA.js';
|
|
20
|
+
export { default as readFile } from './packem_shared/readFile-iHOVXeH-.js';
|
|
21
|
+
export { default as readFileSync } from './packem_shared/readFileSync-BkEj9BQY.js';
|
|
22
|
+
export { default as readJson } from './packem_shared/readJson-pdfQBWDR.js';
|
|
23
|
+
export { default as readJsonSync } from './packem_shared/readJsonSync-BZqGcA5d.js';
|
|
24
|
+
export { default as emptyDir } from './packem_shared/emptyDir-CYB5Tict.js';
|
|
25
|
+
export { default as emptyDirSync } from './packem_shared/emptyDirSync-BD8-1Ytl.js';
|
|
26
|
+
export { default as remove } from './packem_shared/remove-_oDY3uKo.js';
|
|
27
|
+
export { default as removeSync } from './packem_shared/removeSync-DETRj7Qn.js';
|
|
28
|
+
export { default as writeFile } from './packem_shared/writeFile-DSHERs0Z.js';
|
|
29
|
+
export { default as writeFileSync } from './packem_shared/writeFileSync-CJp1kXQR.js';
|
|
30
|
+
export { default as writeJson } from './packem_shared/writeJson-C0OfLDbe.js';
|
|
31
|
+
export { default as writeJsonSync } from './packem_shared/writeJsonSync-Cs21FE7v.js';
|
|
32
|
+
export { isFsCaseSensitive } from './packem_shared/isFsCaseSensitive-D-ayleCy.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class AlreadyExistsError extends Error {
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new instance.
|
|
4
|
+
* @param message The error message.
|
|
5
|
+
*/
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(`EEXIST: ${message}`);
|
|
8
|
+
}
|
|
9
|
+
// eslint-disable-next-line class-methods-use-this
|
|
10
|
+
get code() {
|
|
11
|
+
return "EEXIST";
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
14
|
+
set code(_name) {
|
|
15
|
+
throw new Error("Cannot overwrite code EEXIST");
|
|
16
|
+
}
|
|
17
|
+
// eslint-disable-next-line class-methods-use-this
|
|
18
|
+
get name() {
|
|
19
|
+
return "AlreadyExistsError";
|
|
20
|
+
}
|
|
21
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
22
|
+
set name(_name) {
|
|
23
|
+
throw new Error("Cannot overwrite name of AlreadyExistsError");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { AlreadyExistsError as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class DirectoryError extends Error {
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new instance.
|
|
4
|
+
* @param message The error message.
|
|
5
|
+
*/
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(`EISDIR: Illegal operation on a directory, ${message}`);
|
|
8
|
+
}
|
|
9
|
+
// eslint-disable-next-line class-methods-use-this
|
|
10
|
+
get code() {
|
|
11
|
+
return "EISDIR";
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
14
|
+
set code(_name) {
|
|
15
|
+
throw new Error("Cannot overwrite code EISDIR");
|
|
16
|
+
}
|
|
17
|
+
// eslint-disable-next-line class-methods-use-this
|
|
18
|
+
get name() {
|
|
19
|
+
return "DirectoryError";
|
|
20
|
+
}
|
|
21
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
22
|
+
set name(_name) {
|
|
23
|
+
throw new Error("Cannot overwrite name of DirectoryError");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { DirectoryError as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const F_OK = 0;
|
|
2
|
+
const R_OK = 4;
|
|
3
|
+
const W_OK = 2;
|
|
4
|
+
const X_OK = 1;
|
|
5
|
+
const FIND_UP_STOP = /* @__PURE__ */ Symbol("findUpStop");
|
|
6
|
+
const INTERNAL_STRIP_JSON_REGEX = /"(?:[^"\\]|\\.)*"|\/\/[^\r\n]*|\/\*[\s\S]*?\*\//g;
|
|
7
|
+
|
|
8
|
+
export { FIND_UP_STOP, F_OK, INTERNAL_STRIP_JSON_REGEX, R_OK, W_OK, X_OK };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class JSONError extends Error {
|
|
2
|
+
fileName;
|
|
3
|
+
codeFrame;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
5
|
+
name = "JSONError";
|
|
6
|
+
#message;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new JSONError instance.
|
|
9
|
+
* @param message The primary error message.
|
|
10
|
+
*/
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super();
|
|
13
|
+
this.#message = message;
|
|
14
|
+
}
|
|
15
|
+
get message() {
|
|
16
|
+
return `${this.#message}${this.fileName ? ` in ${this.fileName}` : ""}${this.codeFrame ? `
|
|
17
|
+
|
|
18
|
+
${this.codeFrame}
|
|
19
|
+
` : ""}`;
|
|
20
|
+
}
|
|
21
|
+
set message(message) {
|
|
22
|
+
this.#message = message;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { JSONError as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class NotEmptyError extends Error {
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new instance.
|
|
4
|
+
* @param message The error message.
|
|
5
|
+
*/
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(`ENOTEMPTY: Directory not empty, ${message}`);
|
|
8
|
+
}
|
|
9
|
+
// eslint-disable-next-line class-methods-use-this
|
|
10
|
+
get code() {
|
|
11
|
+
return "ENOTEMPTY";
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
14
|
+
set code(_name) {
|
|
15
|
+
throw new Error("Cannot overwrite code ENOTEMPTY");
|
|
16
|
+
}
|
|
17
|
+
// eslint-disable-next-line class-methods-use-this
|
|
18
|
+
get name() {
|
|
19
|
+
return "NotEmptyError";
|
|
20
|
+
}
|
|
21
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
22
|
+
set name(_name) {
|
|
23
|
+
throw new Error("Cannot overwrite name of NotEmptyError");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { NotEmptyError as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class NotFoundError extends Error {
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new instance.
|
|
4
|
+
* @param message The error message.
|
|
5
|
+
*/
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(`ENOENT: ${message}`);
|
|
8
|
+
}
|
|
9
|
+
// eslint-disable-next-line class-methods-use-this
|
|
10
|
+
get code() {
|
|
11
|
+
return "ENOENT";
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
14
|
+
set code(_name) {
|
|
15
|
+
throw new Error("Cannot overwrite code ENOENT");
|
|
16
|
+
}
|
|
17
|
+
// eslint-disable-next-line class-methods-use-this
|
|
18
|
+
get name() {
|
|
19
|
+
return "NotFoundError";
|
|
20
|
+
}
|
|
21
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
22
|
+
set name(_name) {
|
|
23
|
+
throw new Error("Cannot overwrite name of NotFoundError");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { NotFoundError as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class PermissionError extends Error {
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new instance.
|
|
4
|
+
* @param message The error message.
|
|
5
|
+
*/
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(`EPERM: Operation not permitted, ${message}`);
|
|
8
|
+
}
|
|
9
|
+
// eslint-disable-next-line class-methods-use-this
|
|
10
|
+
get code() {
|
|
11
|
+
return "EPERM";
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
14
|
+
set code(_name) {
|
|
15
|
+
throw new Error("Cannot overwrite code EPERM");
|
|
16
|
+
}
|
|
17
|
+
// eslint-disable-next-line class-methods-use-this
|
|
18
|
+
get name() {
|
|
19
|
+
return "PermissionError";
|
|
20
|
+
}
|
|
21
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
22
|
+
set name(_name) {
|
|
23
|
+
throw new Error("Cannot overwrite name of PermissionError");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { PermissionError as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class WalkError extends Error {
|
|
2
|
+
/** File path of the root that's being walked. */
|
|
3
|
+
root;
|
|
4
|
+
/**
|
|
5
|
+
* Constructs a new instance.
|
|
6
|
+
* @param cause The underlying error or reason for the walk failure.
|
|
7
|
+
* @param root The root directory path where the walk operation started or encountered the error.
|
|
8
|
+
*/
|
|
9
|
+
constructor(cause, root) {
|
|
10
|
+
super(`${cause instanceof Error ? cause.message : cause} for path "${root}"`);
|
|
11
|
+
this.cause = cause;
|
|
12
|
+
this.root = root;
|
|
13
|
+
}
|
|
14
|
+
// eslint-disable-next-line class-methods-use-this
|
|
15
|
+
get name() {
|
|
16
|
+
return "WalkError";
|
|
17
|
+
}
|
|
18
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
19
|
+
set name(_name) {
|
|
20
|
+
throw new Error("Cannot overwrite name of WalkError");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { WalkError as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const assertValidFileContents = (contents) => {
|
|
2
|
+
if (typeof contents !== "string" && !(contents instanceof ArrayBuffer) && !ArrayBuffer.isView(contents)) {
|
|
3
|
+
throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.");
|
|
4
|
+
}
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export { assertValidFileContents as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const assertValidFileOrDirectoryPath = (fileOrDirectoryPath) => {
|
|
2
|
+
if (!fileOrDirectoryPath || !(fileOrDirectoryPath instanceof URL) && typeof fileOrDirectoryPath !== "string") {
|
|
3
|
+
throw new TypeError("Path must be a non-empty string or URL.");
|
|
4
|
+
}
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export { assertValidFileOrDirectoryPath as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import walk from './walk-BhTbpr3y.js';
|
|
2
|
+
|
|
3
|
+
const collect = async (directory, options = {}) => {
|
|
4
|
+
if (!Array.isArray(options.extensions)) {
|
|
5
|
+
options.extensions = ["js", "mjs", "cjs", "ts"];
|
|
6
|
+
}
|
|
7
|
+
const entries = [];
|
|
8
|
+
for await (const entry of walk(directory, options)) {
|
|
9
|
+
entries.push(entry.path);
|
|
10
|
+
}
|
|
11
|
+
return entries;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { collect as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import walkSync from './walkSync-DDBq95s8.js';
|
|
2
|
+
|
|
3
|
+
const collectSync = (directory, options = {}) => {
|
|
4
|
+
if (!Array.isArray(options.extensions)) {
|
|
5
|
+
options.extensions = ["js", "mjs", "cjs", "ts"];
|
|
6
|
+
}
|
|
7
|
+
const entries = [];
|
|
8
|
+
for (const entry of walkSync(directory, options)) {
|
|
9
|
+
entries.push(entry.path);
|
|
10
|
+
}
|
|
11
|
+
return entries;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { collectSync as default };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
+
|
|
7
|
+
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
+
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
+
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
+
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
+
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
+
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
+
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// Fallback to createRequire
|
|
17
|
+
return __cjs_require(module);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
existsSync
|
|
22
|
+
} = __cjs_getBuiltinModule("node:fs");
|
|
23
|
+
const {
|
|
24
|
+
mkdir,
|
|
25
|
+
readdir,
|
|
26
|
+
rm
|
|
27
|
+
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
28
|
+
import { join } from '@visulima/path';
|
|
29
|
+
import { toPath } from '@visulima/path/utils';
|
|
30
|
+
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
31
|
+
|
|
32
|
+
const emptyDir = async (dir, options) => {
|
|
33
|
+
assertValidFileOrDirectoryPath(dir);
|
|
34
|
+
if (!existsSync(dir)) {
|
|
35
|
+
await mkdir(dir, { recursive: true });
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
for await (const item of await readdir(dir)) {
|
|
39
|
+
await rm(join(toPath(dir), item), { ...options, force: true, recursive: true });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { emptyDir as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
+
|
|
7
|
+
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
+
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
+
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
+
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
+
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
+
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
+
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// Fallback to createRequire
|
|
17
|
+
return __cjs_require(module);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
existsSync,
|
|
22
|
+
mkdirSync,
|
|
23
|
+
readdirSync,
|
|
24
|
+
rmSync
|
|
25
|
+
} = __cjs_getBuiltinModule("node:fs");
|
|
26
|
+
import { join } from '@visulima/path';
|
|
27
|
+
import { toPath } from '@visulima/path/utils';
|
|
28
|
+
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
29
|
+
|
|
30
|
+
const emptyDirSync = (dir, options) => {
|
|
31
|
+
assertValidFileOrDirectoryPath(dir);
|
|
32
|
+
if (!existsSync(dir)) {
|
|
33
|
+
mkdirSync(dir, { recursive: true });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
for (const item of readdirSync(dir)) {
|
|
37
|
+
rmSync(join(toPath(dir), item), { ...options, force: true, recursive: true });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { emptyDirSync as default };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
+
|
|
7
|
+
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
+
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
+
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
+
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
+
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
+
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
+
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// Fallback to createRequire
|
|
17
|
+
return __cjs_require(module);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
lstat,
|
|
22
|
+
mkdir
|
|
23
|
+
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
24
|
+
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
25
|
+
import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
|
|
26
|
+
|
|
27
|
+
const ensureDir = async (directory) => {
|
|
28
|
+
assertValidFileOrDirectoryPath(directory);
|
|
29
|
+
try {
|
|
30
|
+
const fileInfo = await lstat(directory);
|
|
31
|
+
if (!fileInfo.isDirectory()) {
|
|
32
|
+
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (error.code !== "ENOENT") {
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
await mkdir(directory, { recursive: true });
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error.code !== "EEXIST") {
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
const fileInfo = await lstat(directory);
|
|
47
|
+
if (!fileInfo.isDirectory()) {
|
|
48
|
+
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { ensureDir as default };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
+
|
|
7
|
+
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
+
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
+
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
+
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
+
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
+
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
+
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// Fallback to createRequire
|
|
17
|
+
return __cjs_require(module);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
lstatSync,
|
|
22
|
+
mkdirSync
|
|
23
|
+
} = __cjs_getBuiltinModule("node:fs");
|
|
24
|
+
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
25
|
+
import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
|
|
26
|
+
|
|
27
|
+
const ensureDirSync = (directory) => {
|
|
28
|
+
assertValidFileOrDirectoryPath(directory);
|
|
29
|
+
try {
|
|
30
|
+
const fileInfo = lstatSync(directory);
|
|
31
|
+
if (!fileInfo.isDirectory()) {
|
|
32
|
+
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (error.code !== "ENOENT") {
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
mkdirSync(directory, { recursive: true });
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error.code !== "EEXIST") {
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
const fileInfo = lstatSync(directory);
|
|
47
|
+
if (!fileInfo.isDirectory()) {
|
|
48
|
+
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { ensureDirSync as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
+
|
|
7
|
+
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
+
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
+
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
+
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
+
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
+
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
+
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// Fallback to createRequire
|
|
17
|
+
return __cjs_require(module);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
lstat,
|
|
22
|
+
writeFile
|
|
23
|
+
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
24
|
+
import { dirname } from '@visulima/path';
|
|
25
|
+
import { toPath } from '@visulima/path/utils';
|
|
26
|
+
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
27
|
+
import ensureDir from './ensureDir-C_kuQ5Ik.js';
|
|
28
|
+
import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
|
|
29
|
+
|
|
30
|
+
const ensureFile = async (filePath) => {
|
|
31
|
+
assertValidFileOrDirectoryPath(filePath);
|
|
32
|
+
try {
|
|
33
|
+
const stat = await lstat(filePath);
|
|
34
|
+
if (!stat.isFile()) {
|
|
35
|
+
throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error.code === "ENOENT") {
|
|
39
|
+
await ensureDir(dirname(toPath(filePath)));
|
|
40
|
+
await writeFile(filePath, new Uint8Array());
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { ensureFile as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
+
|
|
7
|
+
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
+
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
+
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
+
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
+
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
+
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
+
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// Fallback to createRequire
|
|
17
|
+
return __cjs_require(module);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
lstatSync,
|
|
22
|
+
writeFileSync
|
|
23
|
+
} = __cjs_getBuiltinModule("node:fs");
|
|
24
|
+
import { dirname } from '@visulima/path';
|
|
25
|
+
import { toPath } from '@visulima/path/utils';
|
|
26
|
+
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
27
|
+
import ensureDirSync from './ensureDirSync-CI5g-uBI.js';
|
|
28
|
+
import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
|
|
29
|
+
|
|
30
|
+
const ensureFileSync = (filePath) => {
|
|
31
|
+
assertValidFileOrDirectoryPath(filePath);
|
|
32
|
+
try {
|
|
33
|
+
const stat = lstatSync(filePath);
|
|
34
|
+
if (!stat.isFile()) {
|
|
35
|
+
throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error.code === "ENOENT") {
|
|
39
|
+
ensureDirSync(dirname(toPath(filePath)));
|
|
40
|
+
writeFileSync(filePath, new Uint8Array());
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { ensureFileSync as default };
|