@duplojs/server 0.1.0-beta.2 → 0.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.mjs +5 -1
- package/dist/command/create.cjs +11 -9
- package/dist/command/create.mjs +11 -9
- package/dist/command/error.cjs +2 -2
- package/dist/command/error.mjs +1 -1
- package/dist/command/help.cjs +11 -9
- package/dist/command/help.mjs +10 -8
- package/dist/common/environmentVariable/parseEnvironmentFiles.d.ts +2 -1
- package/dist/common/index.cjs +3 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.mjs +3 -1
- package/dist/common/meta/getCurrentDirectoryName.cjs +10 -0
- package/dist/common/meta/getCurrentDirectoryName.d.ts +7 -0
- package/dist/common/meta/getCurrentDirectoryName.mjs +7 -0
- package/dist/common/meta/index.d.ts +7 -0
- package/dist/dataStructure/common/codec/defaults/json.cjs +12 -1
- package/dist/dataStructure/common/codec/defaults/json.d.ts +2 -2
- package/dist/dataStructure/common/codec/defaults/json.mjs +12 -1
- package/dist/dataStructure/common/codec/defaults/string.cjs +12 -1
- package/dist/dataStructure/common/codec/defaults/string.d.ts +2 -2
- package/dist/dataStructure/common/codec/defaults/string.mjs +12 -1
- package/dist/dataStructure/common/error/defaultInterpreter.cjs +3 -1
- package/dist/dataStructure/common/error/defaultInterpreter.d.ts +7 -2
- package/dist/dataStructure/common/error/defaultInterpreter.mjs +3 -1
- package/dist/dataStructure/constraint/{exist.cjs → fileExist.cjs} +5 -5
- package/dist/dataStructure/constraint/fileExist.d.ts +10 -0
- package/dist/dataStructure/constraint/{exist.mjs → fileExist.mjs} +4 -4
- package/dist/dataStructure/constraint/folderExist.cjs +19 -0
- package/dist/dataStructure/constraint/folderExist.d.ts +10 -0
- package/dist/dataStructure/constraint/folderExist.mjs +15 -0
- package/dist/dataStructure/constraint/index.d.ts +2 -1
- package/dist/dataStructure/constraint/mimeType.cjs +1 -1
- package/dist/dataStructure/constraint/mimeType.mjs +1 -1
- package/dist/dataStructure/constraint/types/constraints.d.ts +4 -2
- package/dist/dataStructure/fundamentalType/folder.cjs +11 -0
- package/dist/dataStructure/fundamentalType/folder.d.ts +8 -0
- package/dist/dataStructure/fundamentalType/folder.mjs +8 -0
- package/dist/dataStructure/fundamentalType/index.d.ts +1 -0
- package/dist/dataStructure/fundamentalType/types/fundamentalTypes.d.ts +2 -0
- package/dist/dataStructure/helper/file.d.ts +1 -1
- package/dist/dataStructure/helper/fileExist.cjs +7 -0
- package/dist/dataStructure/helper/fileExist.d.ts +2 -0
- package/dist/dataStructure/helper/fileExist.mjs +7 -0
- package/dist/dataStructure/helper/folder.cjs +10 -0
- package/dist/dataStructure/helper/folder.d.ts +3 -0
- package/dist/dataStructure/helper/folder.mjs +8 -0
- package/dist/dataStructure/helper/folderExist.cjs +7 -0
- package/dist/dataStructure/helper/folderExist.d.ts +2 -0
- package/dist/dataStructure/helper/folderExist.mjs +7 -0
- package/dist/dataStructure/helper/index.d.ts +3 -1
- package/dist/dataStructure/index.cjs +29 -8
- package/dist/dataStructure/index.mjs +19 -6
- package/dist/dataStructure/type/folder.cjs +14 -0
- package/dist/dataStructure/type/folder.d.ts +11 -0
- package/dist/dataStructure/type/folder.mjs +11 -0
- package/dist/dataStructure/type/index.d.ts +1 -0
- package/dist/dataStructure/type/types/types.d.ts +2 -0
- package/dist/file/appendFile.cjs +36 -22
- package/dist/file/appendFile.d.ts +34 -2
- package/dist/file/appendFile.mjs +35 -22
- package/dist/file/appendTextFile.cjs +34 -20
- package/dist/file/appendTextFile.d.ts +34 -2
- package/dist/file/appendTextFile.mjs +33 -20
- package/dist/file/copy.cjs +26 -14
- package/dist/file/copy.d.ts +34 -2
- package/dist/file/copy.mjs +25 -14
- package/dist/file/createEntryInterface.cjs +2 -2
- package/dist/file/createEntryInterface.d.ts +1 -1
- package/dist/file/createEntryInterface.mjs +1 -1
- package/dist/file/ensureDirectory.cjs +29 -17
- package/dist/file/ensureDirectory.d.ts +28 -2
- package/dist/file/ensureDirectory.mjs +28 -17
- package/dist/file/ensureFile.cjs +32 -19
- package/dist/file/ensureFile.d.ts +31 -2
- package/dist/file/ensureFile.mjs +31 -19
- package/dist/file/exists.cjs +23 -14
- package/dist/file/exists.d.ts +19 -2
- package/dist/file/exists.mjs +22 -14
- package/dist/file/fileInterface.cjs +2 -0
- package/dist/file/fileInterface.d.ts +8 -6
- package/dist/file/fileInterface.mjs +2 -1
- package/dist/file/folderInterface.cjs +2 -0
- package/dist/file/folderInterface.d.ts +7 -5
- package/dist/file/folderInterface.mjs +2 -1
- package/dist/file/index.cjs +6 -0
- package/dist/file/index.d.ts +0 -1
- package/dist/file/index.mjs +7 -4
- package/dist/file/link.cjs +37 -22
- package/dist/file/link.d.ts +37 -2
- package/dist/file/link.mjs +36 -22
- package/dist/file/linkStat.cjs +23 -15
- package/dist/file/linkStat.d.ts +22 -2
- package/dist/file/linkStat.mjs +23 -15
- package/dist/file/makeDirectory.cjs +35 -21
- package/dist/file/makeDirectory.d.ts +33 -2
- package/dist/file/makeDirectory.mjs +34 -21
- package/dist/file/makeTemporaryDirectory.cjs +26 -15
- package/dist/file/makeTemporaryDirectory.d.ts +25 -2
- package/dist/file/makeTemporaryDirectory.mjs +25 -15
- package/dist/file/makeTemporaryFile.cjs +29 -20
- package/dist/file/makeTemporaryFile.d.ts +28 -2
- package/dist/file/makeTemporaryFile.mjs +29 -20
- package/dist/file/move.cjs +38 -23
- package/dist/file/move.d.ts +37 -2
- package/dist/file/move.mjs +37 -23
- package/dist/file/readDirectory.cjs +27 -9
- package/dist/file/readDirectory.d.ts +26 -5
- package/dist/file/readDirectory.mjs +24 -9
- package/dist/file/readFile.cjs +28 -17
- package/dist/file/readFile.d.ts +25 -2
- package/dist/file/readFile.mjs +27 -17
- package/dist/file/readJsonFile.cjs +28 -17
- package/dist/file/readJsonFile.d.ts +25 -3
- package/dist/file/readJsonFile.mjs +27 -17
- package/dist/file/readLink.cjs +25 -15
- package/dist/file/readLink.d.ts +22 -2
- package/dist/file/readLink.mjs +24 -15
- package/dist/file/readTextFile.cjs +28 -17
- package/dist/file/readTextFile.d.ts +25 -2
- package/dist/file/readTextFile.mjs +27 -17
- package/dist/file/realPath.cjs +22 -13
- package/dist/file/realPath.d.ts +19 -2
- package/dist/file/realPath.mjs +21 -13
- package/dist/file/relocate.cjs +41 -25
- package/dist/file/relocate.d.ts +37 -2
- package/dist/file/relocate.mjs +40 -25
- package/dist/file/remove.cjs +36 -23
- package/dist/file/remove.d.ts +30 -2
- package/dist/file/remove.mjs +35 -23
- package/dist/file/rename.cjs +41 -25
- package/dist/file/rename.d.ts +37 -2
- package/dist/file/rename.mjs +40 -25
- package/dist/file/setMode.cjs +23 -15
- package/dist/file/setMode.d.ts +21 -2
- package/dist/file/setMode.mjs +23 -15
- package/dist/file/setOwner.cjs +25 -15
- package/dist/file/setOwner.d.ts +22 -2
- package/dist/file/setOwner.mjs +24 -15
- package/dist/file/setTime.cjs +25 -15
- package/dist/file/setTime.d.ts +21 -2
- package/dist/file/setTime.mjs +24 -15
- package/dist/file/stat.cjs +23 -15
- package/dist/file/stat.d.ts +22 -2
- package/dist/file/stat.mjs +23 -15
- package/dist/file/symlink.cjs +33 -20
- package/dist/file/symlink.d.ts +31 -2
- package/dist/file/symlink.mjs +32 -20
- package/dist/file/truncate.cjs +33 -21
- package/dist/file/truncate.d.ts +34 -2
- package/dist/file/truncate.mjs +33 -21
- package/dist/file/unknownEntryInterface.cjs +2 -0
- package/dist/file/unknownEntryInterface.d.ts +7 -5
- package/dist/file/unknownEntryInterface.mjs +2 -1
- package/dist/file/walkDirectory.cjs +28 -15
- package/dist/file/walkDirectory.d.ts +23 -2
- package/dist/file/walkDirectory.mjs +27 -14
- package/dist/file/writeFile.cjs +35 -21
- package/dist/file/writeFile.d.ts +34 -2
- package/dist/file/writeFile.mjs +34 -21
- package/dist/file/writeJsonFile.cjs +38 -27
- package/dist/file/writeJsonFile.d.ts +36 -5
- package/dist/file/writeJsonFile.mjs +38 -27
- package/dist/file/writeTextFile.cjs +35 -21
- package/dist/file/writeTextFile.d.ts +34 -2
- package/dist/file/writeTextFile.mjs +34 -21
- package/dist/implementor.cjs +8 -5
- package/dist/implementor.d.ts +4 -4
- package/dist/implementor.mjs +8 -5
- package/dist/index.cjs +2 -0
- package/dist/index.mjs +2 -1
- package/package.json +4 -4
- package/dist/dataStructure/constraint/exist.d.ts +0 -10
- package/dist/dataStructure/helper/exist.cjs +0 -7
- package/dist/dataStructure/helper/exist.d.ts +0 -2
- package/dist/dataStructure/helper/exist.mjs +0 -7
- package/dist/file/types/fileSystemEither.d.ts +0 -2
- package/dist/file/types/index.d.ts +0 -1
- /package/{README → README.md} +0 -0
package/dist/file/readLink.cjs
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_implementor = require("../implementor.cjs");
|
|
3
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
4
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
3
5
|
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
4
6
|
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
5
7
|
//#region scripts/file/readLink.ts
|
|
8
|
+
var ReadLinkErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-link-not-found", Error) {};
|
|
9
|
+
var ReadLinkErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-link-permission-denied", Error) {};
|
|
10
|
+
var ReadLinkErrorInvalidArgument = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-link-invalid-argument", Error) {};
|
|
11
|
+
var ReadLinkErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-link-not-directory", Error) {};
|
|
12
|
+
var ReadLinkErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-link-too-many-open-files", Error) {};
|
|
13
|
+
var ReadLinkError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-link-error", Error) {};
|
|
6
14
|
function handleNodeReadLinkError(error) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
else if (error.code === "
|
|
11
|
-
else if (error.code === "
|
|
12
|
-
else if (error.code === "
|
|
15
|
+
let readLinkError = void 0;
|
|
16
|
+
if ("code" in error) {
|
|
17
|
+
if (error.code === "ENOENT") readLinkError = new ReadLinkErrorNotFound(error);
|
|
18
|
+
else if (error.code === "EACCES" || error.code === "EPERM") readLinkError = new ReadLinkErrorPermissionDenied(error);
|
|
19
|
+
else if (error.code === "EINVAL") readLinkError = new ReadLinkErrorInvalidArgument(error);
|
|
20
|
+
else if (error.code === "ENOTDIR") readLinkError = new ReadLinkErrorNotDirectory(error);
|
|
21
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") readLinkError = new ReadLinkErrorTooManyOpenFiles(error);
|
|
13
22
|
}
|
|
14
|
-
|
|
23
|
+
if (readLinkError === void 0) readLinkError = new ReadLinkError(error);
|
|
24
|
+
return _duplojs_lang_either.left("file-system-read-link-error", readLinkError);
|
|
15
25
|
}
|
|
16
26
|
function handleDenoReadLinkError(error) {
|
|
17
|
-
|
|
18
|
-
if (error instanceof Deno.errors.
|
|
19
|
-
if (error instanceof Deno.errors.
|
|
20
|
-
if (error instanceof Deno.errors.
|
|
21
|
-
|
|
27
|
+
let readLinkError = void 0;
|
|
28
|
+
if (error instanceof Deno.errors.NotFound) readLinkError = new ReadLinkErrorNotFound(error);
|
|
29
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) readLinkError = new ReadLinkErrorPermissionDenied(error);
|
|
30
|
+
else if (error instanceof Deno.errors.InvalidData) readLinkError = new ReadLinkErrorInvalidArgument(error);
|
|
31
|
+
else if (error instanceof Deno.errors.NotADirectory) readLinkError = new ReadLinkErrorNotDirectory(error);
|
|
32
|
+
if (readLinkError === void 0) readLinkError = new ReadLinkError(error);
|
|
33
|
+
return _duplojs_lang_either.left("file-system-read-link-error", readLinkError);
|
|
22
34
|
}
|
|
23
35
|
const readLink = require_implementor.implementFunction("readLink", {
|
|
24
|
-
NODE: async (path) => {
|
|
25
|
-
return (await require_implementor.nodeFileSystem.value).readlink(path, { encoding: "utf-8" }).then((value) => _duplojs_lang_either.right("file-system-read-link", value)).catch(handleNodeReadLinkError);
|
|
26
|
-
},
|
|
36
|
+
NODE: async (path) => require_implementor.nodeFileSystem.value.readlink(path, { encoding: "utf-8" }).then((value) => _duplojs_lang_either.right("file-system-read-link", value)).catch(handleNodeReadLinkError),
|
|
27
37
|
DENO: (path) => Deno.readLink(path).then((value) => _duplojs_lang_either.right("file-system-read-link", value)).catch(handleDenoReadLinkError)
|
|
28
38
|
});
|
|
29
39
|
//#endregion
|
package/dist/file/readLink.d.ts
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
|
-
import { FileSystemEither } from './types';
|
|
2
1
|
import * as DEither from "@duplojs/lang/either";
|
|
3
2
|
import type * as DPath from "@duplojs/lang/path";
|
|
4
|
-
|
|
3
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
4
|
+
declare const ReadLinkErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-link-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-link-not-found", unknown>>, unknown>;
|
|
5
|
+
declare class ReadLinkErrorNotFound extends ReadLinkErrorNotFound_base {
|
|
6
|
+
}
|
|
7
|
+
declare const ReadLinkErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-link-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-link-permission-denied", unknown>>, unknown>;
|
|
8
|
+
declare class ReadLinkErrorPermissionDenied extends ReadLinkErrorPermissionDenied_base {
|
|
9
|
+
}
|
|
10
|
+
declare const ReadLinkErrorInvalidArgument_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-link-invalid-argument", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-link-invalid-argument", unknown>>, unknown>;
|
|
11
|
+
declare class ReadLinkErrorInvalidArgument extends ReadLinkErrorInvalidArgument_base {
|
|
12
|
+
}
|
|
13
|
+
declare const ReadLinkErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-link-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-link-not-directory", unknown>>, unknown>;
|
|
14
|
+
declare class ReadLinkErrorNotDirectory extends ReadLinkErrorNotDirectory_base {
|
|
15
|
+
}
|
|
16
|
+
declare const ReadLinkErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-link-too-many-open-files", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-link-too-many-open-files", unknown>>, unknown>;
|
|
17
|
+
declare class ReadLinkErrorTooManyOpenFiles extends ReadLinkErrorTooManyOpenFiles_base {
|
|
18
|
+
}
|
|
19
|
+
declare const ReadLinkError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-link-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-link-error", unknown>>, unknown>;
|
|
20
|
+
declare class ReadLinkError extends ReadLinkError_base {
|
|
21
|
+
}
|
|
22
|
+
export type ReadLinkErrors = (ReadLinkErrorNotFound | ReadLinkErrorPermissionDenied | ReadLinkErrorInvalidArgument | ReadLinkErrorNotDirectory | ReadLinkErrorTooManyOpenFiles | ReadLinkError);
|
|
23
|
+
export type ReadLinkResult = (DEither.Right<"file-system-read-link", string> | DEither.Left<"file-system-read-link-error", ReadLinkErrors>);
|
|
5
24
|
declare module '../implementor' {
|
|
6
25
|
interface ServerFunction {
|
|
7
26
|
readLink(path: string & DPath.Path): Promise<ReadLinkResult>;
|
|
8
27
|
}
|
|
9
28
|
}
|
|
10
29
|
export declare const readLink: (path: string & DPath.Path) => Promise<ReadLinkResult>;
|
|
30
|
+
export {};
|
package/dist/file/readLink.mjs
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
import { implementFunction, nodeFileSystem } from "../implementor.mjs";
|
|
2
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
2
3
|
import * as DEither from "@duplojs/lang/either";
|
|
3
4
|
//#region scripts/file/readLink.ts
|
|
5
|
+
var ReadLinkErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-read-link-not-found", Error) {};
|
|
6
|
+
var ReadLinkErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-read-link-permission-denied", Error) {};
|
|
7
|
+
var ReadLinkErrorInvalidArgument = class extends DCommon.DuploJSError.parentClass("file-system-read-link-invalid-argument", Error) {};
|
|
8
|
+
var ReadLinkErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-read-link-not-directory", Error) {};
|
|
9
|
+
var ReadLinkErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-read-link-too-many-open-files", Error) {};
|
|
10
|
+
var ReadLinkError = class extends DCommon.DuploJSError.parentClass("file-system-read-link-error", Error) {};
|
|
4
11
|
function handleNodeReadLinkError(error) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
else if (error.code === "
|
|
9
|
-
else if (error.code === "
|
|
10
|
-
else if (error.code === "
|
|
12
|
+
let readLinkError = void 0;
|
|
13
|
+
if ("code" in error) {
|
|
14
|
+
if (error.code === "ENOENT") readLinkError = new ReadLinkErrorNotFound(error);
|
|
15
|
+
else if (error.code === "EACCES" || error.code === "EPERM") readLinkError = new ReadLinkErrorPermissionDenied(error);
|
|
16
|
+
else if (error.code === "EINVAL") readLinkError = new ReadLinkErrorInvalidArgument(error);
|
|
17
|
+
else if (error.code === "ENOTDIR") readLinkError = new ReadLinkErrorNotDirectory(error);
|
|
18
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") readLinkError = new ReadLinkErrorTooManyOpenFiles(error);
|
|
11
19
|
}
|
|
12
|
-
|
|
20
|
+
if (readLinkError === void 0) readLinkError = new ReadLinkError(error);
|
|
21
|
+
return DEither.left("file-system-read-link-error", readLinkError);
|
|
13
22
|
}
|
|
14
23
|
function handleDenoReadLinkError(error) {
|
|
15
|
-
|
|
16
|
-
if (error instanceof Deno.errors.
|
|
17
|
-
if (error instanceof Deno.errors.
|
|
18
|
-
if (error instanceof Deno.errors.
|
|
19
|
-
|
|
24
|
+
let readLinkError = void 0;
|
|
25
|
+
if (error instanceof Deno.errors.NotFound) readLinkError = new ReadLinkErrorNotFound(error);
|
|
26
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) readLinkError = new ReadLinkErrorPermissionDenied(error);
|
|
27
|
+
else if (error instanceof Deno.errors.InvalidData) readLinkError = new ReadLinkErrorInvalidArgument(error);
|
|
28
|
+
else if (error instanceof Deno.errors.NotADirectory) readLinkError = new ReadLinkErrorNotDirectory(error);
|
|
29
|
+
if (readLinkError === void 0) readLinkError = new ReadLinkError(error);
|
|
30
|
+
return DEither.left("file-system-read-link-error", readLinkError);
|
|
20
31
|
}
|
|
21
32
|
const readLink = implementFunction("readLink", {
|
|
22
|
-
NODE: async (path) => {
|
|
23
|
-
return (await nodeFileSystem.value).readlink(path, { encoding: "utf-8" }).then((value) => DEither.right("file-system-read-link", value)).catch(handleNodeReadLinkError);
|
|
24
|
-
},
|
|
33
|
+
NODE: async (path) => nodeFileSystem.value.readlink(path, { encoding: "utf-8" }).then((value) => DEither.right("file-system-read-link", value)).catch(handleNodeReadLinkError),
|
|
25
34
|
DENO: (path) => Deno.readLink(path).then((value) => DEither.right("file-system-read-link", value)).catch(handleDenoReadLinkError)
|
|
26
35
|
});
|
|
27
36
|
//#endregion
|
|
@@ -1,31 +1,42 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_implementor = require("../implementor.cjs");
|
|
3
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
4
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
3
5
|
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
4
6
|
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
5
7
|
//#region scripts/file/readTextFile.ts
|
|
8
|
+
var ReadTextFileErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-text-file-not-found", Error) {};
|
|
9
|
+
var ReadTextFileErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-text-file-permission-denied", Error) {};
|
|
10
|
+
var ReadTextFileErrorIsDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-text-file-is-directory", Error) {};
|
|
11
|
+
var ReadTextFileErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-text-file-not-directory", Error) {};
|
|
12
|
+
var ReadTextFileErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-text-file-too-many-open-files", Error) {};
|
|
13
|
+
var ReadTextFileErrorBusy = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-text-file-busy", Error) {};
|
|
14
|
+
var ReadTextFileError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-read-text-file-error", Error) {};
|
|
6
15
|
function handleNodeReadTextFileError(error) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
else if (error.code === "
|
|
11
|
-
else if (error.code === "
|
|
12
|
-
else if (error.code === "
|
|
13
|
-
else if (error.code === "
|
|
16
|
+
let readTextFileError = void 0;
|
|
17
|
+
if ("code" in error) {
|
|
18
|
+
if (error.code === "ENOENT") readTextFileError = new ReadTextFileErrorNotFound(error);
|
|
19
|
+
else if (error.code === "EACCES" || error.code === "EPERM") readTextFileError = new ReadTextFileErrorPermissionDenied(error);
|
|
20
|
+
else if (error.code === "EISDIR") readTextFileError = new ReadTextFileErrorIsDirectory(error);
|
|
21
|
+
else if (error.code === "ENOTDIR") readTextFileError = new ReadTextFileErrorNotDirectory(error);
|
|
22
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") readTextFileError = new ReadTextFileErrorTooManyOpenFiles(error);
|
|
23
|
+
else if (error.code === "EBUSY") readTextFileError = new ReadTextFileErrorBusy(error);
|
|
14
24
|
}
|
|
15
|
-
|
|
25
|
+
if (readTextFileError === void 0) readTextFileError = new ReadTextFileError(error);
|
|
26
|
+
return _duplojs_lang_either.left("file-system-read-text-file-error", readTextFileError);
|
|
16
27
|
}
|
|
17
28
|
function handleDenoReadTextFileError(error) {
|
|
18
|
-
|
|
19
|
-
if (error instanceof Deno.errors.
|
|
20
|
-
if (error instanceof Deno.errors.
|
|
21
|
-
if (error instanceof Deno.errors.
|
|
22
|
-
if (error instanceof Deno.errors.
|
|
23
|
-
|
|
29
|
+
let readTextFileError = void 0;
|
|
30
|
+
if (error instanceof Deno.errors.NotFound) readTextFileError = new ReadTextFileErrorNotFound(error);
|
|
31
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) readTextFileError = new ReadTextFileErrorPermissionDenied(error);
|
|
32
|
+
else if (error instanceof Deno.errors.IsADirectory) readTextFileError = new ReadTextFileErrorIsDirectory(error);
|
|
33
|
+
else if (error instanceof Deno.errors.NotADirectory) readTextFileError = new ReadTextFileErrorNotDirectory(error);
|
|
34
|
+
else if (error instanceof Deno.errors.Busy) readTextFileError = new ReadTextFileErrorBusy(error);
|
|
35
|
+
if (readTextFileError === void 0) readTextFileError = new ReadTextFileError(error);
|
|
36
|
+
return _duplojs_lang_either.left("file-system-read-text-file-error", readTextFileError);
|
|
24
37
|
}
|
|
25
38
|
const readTextFile = require_implementor.implementFunction("readTextFile", {
|
|
26
|
-
NODE: async (path) => {
|
|
27
|
-
return (await require_implementor.nodeFileSystem.value).readFile(path, { encoding: "utf-8" }).then((value) => _duplojs_lang_either.right("file-system-read-text-file", value)).catch(handleNodeReadTextFileError);
|
|
28
|
-
},
|
|
39
|
+
NODE: async (path) => require_implementor.nodeFileSystem.value.readFile(path, { encoding: "utf-8" }).then((value) => _duplojs_lang_either.right("file-system-read-text-file", value)).catch(handleNodeReadTextFileError),
|
|
29
40
|
DENO: (path) => Deno.readTextFile(path).then((value) => _duplojs_lang_either.right("file-system-read-text-file", value)).catch(handleDenoReadTextFileError),
|
|
30
41
|
BUN: (path) => Bun.file(path).text().then((value) => _duplojs_lang_either.right("file-system-read-text-file", value)).catch(handleNodeReadTextFileError)
|
|
31
42
|
});
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
2
2
|
import * as DEither from "@duplojs/lang/either";
|
|
3
3
|
import type * as DPath from "@duplojs/lang/path";
|
|
4
|
-
|
|
4
|
+
declare const ReadTextFileErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-text-file-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-text-file-not-found", unknown>>, unknown>;
|
|
5
|
+
declare class ReadTextFileErrorNotFound extends ReadTextFileErrorNotFound_base {
|
|
6
|
+
}
|
|
7
|
+
declare const ReadTextFileErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-text-file-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-text-file-permission-denied", unknown>>, unknown>;
|
|
8
|
+
declare class ReadTextFileErrorPermissionDenied extends ReadTextFileErrorPermissionDenied_base {
|
|
9
|
+
}
|
|
10
|
+
declare const ReadTextFileErrorIsDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-text-file-is-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-text-file-is-directory", unknown>>, unknown>;
|
|
11
|
+
declare class ReadTextFileErrorIsDirectory extends ReadTextFileErrorIsDirectory_base {
|
|
12
|
+
}
|
|
13
|
+
declare const ReadTextFileErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-text-file-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-text-file-not-directory", unknown>>, unknown>;
|
|
14
|
+
declare class ReadTextFileErrorNotDirectory extends ReadTextFileErrorNotDirectory_base {
|
|
15
|
+
}
|
|
16
|
+
declare const ReadTextFileErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-text-file-too-many-open-files", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-text-file-too-many-open-files", unknown>>, unknown>;
|
|
17
|
+
declare class ReadTextFileErrorTooManyOpenFiles extends ReadTextFileErrorTooManyOpenFiles_base {
|
|
18
|
+
}
|
|
19
|
+
declare const ReadTextFileErrorBusy_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-text-file-busy", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-text-file-busy", unknown>>, unknown>;
|
|
20
|
+
declare class ReadTextFileErrorBusy extends ReadTextFileErrorBusy_base {
|
|
21
|
+
}
|
|
22
|
+
declare const ReadTextFileError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-read-text-file-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-read-text-file-error", unknown>>, unknown>;
|
|
23
|
+
declare class ReadTextFileError extends ReadTextFileError_base {
|
|
24
|
+
}
|
|
25
|
+
export type ReadTextFileErrors = (ReadTextFileErrorNotFound | ReadTextFileErrorPermissionDenied | ReadTextFileErrorIsDirectory | ReadTextFileErrorNotDirectory | ReadTextFileErrorTooManyOpenFiles | ReadTextFileErrorBusy | ReadTextFileError);
|
|
26
|
+
export type ReadTextFileResult = (DEither.Right<"file-system-read-text-file", string> | DEither.Left<"file-system-read-text-file-error", ReadTextFileErrors>);
|
|
5
27
|
declare module '../implementor' {
|
|
6
28
|
interface ServerFunction {
|
|
7
29
|
readTextFile(path: string & DPath.Path): Promise<ReadTextFileResult>;
|
|
8
30
|
}
|
|
9
31
|
}
|
|
10
32
|
export declare const readTextFile: (path: string & DPath.Path) => Promise<ReadTextFileResult>;
|
|
33
|
+
export {};
|
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
import { implementFunction, nodeFileSystem } from "../implementor.mjs";
|
|
2
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
2
3
|
import * as DEither from "@duplojs/lang/either";
|
|
3
4
|
//#region scripts/file/readTextFile.ts
|
|
5
|
+
var ReadTextFileErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-read-text-file-not-found", Error) {};
|
|
6
|
+
var ReadTextFileErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-read-text-file-permission-denied", Error) {};
|
|
7
|
+
var ReadTextFileErrorIsDirectory = class extends DCommon.DuploJSError.parentClass("file-system-read-text-file-is-directory", Error) {};
|
|
8
|
+
var ReadTextFileErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-read-text-file-not-directory", Error) {};
|
|
9
|
+
var ReadTextFileErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-read-text-file-too-many-open-files", Error) {};
|
|
10
|
+
var ReadTextFileErrorBusy = class extends DCommon.DuploJSError.parentClass("file-system-read-text-file-busy", Error) {};
|
|
11
|
+
var ReadTextFileError = class extends DCommon.DuploJSError.parentClass("file-system-read-text-file-error", Error) {};
|
|
4
12
|
function handleNodeReadTextFileError(error) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
else if (error.code === "
|
|
9
|
-
else if (error.code === "
|
|
10
|
-
else if (error.code === "
|
|
11
|
-
else if (error.code === "
|
|
13
|
+
let readTextFileError = void 0;
|
|
14
|
+
if ("code" in error) {
|
|
15
|
+
if (error.code === "ENOENT") readTextFileError = new ReadTextFileErrorNotFound(error);
|
|
16
|
+
else if (error.code === "EACCES" || error.code === "EPERM") readTextFileError = new ReadTextFileErrorPermissionDenied(error);
|
|
17
|
+
else if (error.code === "EISDIR") readTextFileError = new ReadTextFileErrorIsDirectory(error);
|
|
18
|
+
else if (error.code === "ENOTDIR") readTextFileError = new ReadTextFileErrorNotDirectory(error);
|
|
19
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") readTextFileError = new ReadTextFileErrorTooManyOpenFiles(error);
|
|
20
|
+
else if (error.code === "EBUSY") readTextFileError = new ReadTextFileErrorBusy(error);
|
|
12
21
|
}
|
|
13
|
-
|
|
22
|
+
if (readTextFileError === void 0) readTextFileError = new ReadTextFileError(error);
|
|
23
|
+
return DEither.left("file-system-read-text-file-error", readTextFileError);
|
|
14
24
|
}
|
|
15
25
|
function handleDenoReadTextFileError(error) {
|
|
16
|
-
|
|
17
|
-
if (error instanceof Deno.errors.
|
|
18
|
-
if (error instanceof Deno.errors.
|
|
19
|
-
if (error instanceof Deno.errors.
|
|
20
|
-
if (error instanceof Deno.errors.
|
|
21
|
-
|
|
26
|
+
let readTextFileError = void 0;
|
|
27
|
+
if (error instanceof Deno.errors.NotFound) readTextFileError = new ReadTextFileErrorNotFound(error);
|
|
28
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) readTextFileError = new ReadTextFileErrorPermissionDenied(error);
|
|
29
|
+
else if (error instanceof Deno.errors.IsADirectory) readTextFileError = new ReadTextFileErrorIsDirectory(error);
|
|
30
|
+
else if (error instanceof Deno.errors.NotADirectory) readTextFileError = new ReadTextFileErrorNotDirectory(error);
|
|
31
|
+
else if (error instanceof Deno.errors.Busy) readTextFileError = new ReadTextFileErrorBusy(error);
|
|
32
|
+
if (readTextFileError === void 0) readTextFileError = new ReadTextFileError(error);
|
|
33
|
+
return DEither.left("file-system-read-text-file-error", readTextFileError);
|
|
22
34
|
}
|
|
23
35
|
const readTextFile = implementFunction("readTextFile", {
|
|
24
|
-
NODE: async (path) => {
|
|
25
|
-
return (await nodeFileSystem.value).readFile(path, { encoding: "utf-8" }).then((value) => DEither.right("file-system-read-text-file", value)).catch(handleNodeReadTextFileError);
|
|
26
|
-
},
|
|
36
|
+
NODE: async (path) => nodeFileSystem.value.readFile(path, { encoding: "utf-8" }).then((value) => DEither.right("file-system-read-text-file", value)).catch(handleNodeReadTextFileError),
|
|
27
37
|
DENO: (path) => Deno.readTextFile(path).then((value) => DEither.right("file-system-read-text-file", value)).catch(handleDenoReadTextFileError),
|
|
28
38
|
BUN: (path) => Bun.file(path).text().then((value) => DEither.right("file-system-read-text-file", value)).catch(handleNodeReadTextFileError)
|
|
29
39
|
});
|
package/dist/file/realPath.cjs
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_implementor = require("../implementor.cjs");
|
|
3
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
4
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
3
5
|
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
4
6
|
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
5
7
|
//#region scripts/file/realPath.ts
|
|
8
|
+
var RealPathErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-real-path-not-found", Error) {};
|
|
9
|
+
var RealPathErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-real-path-permission-denied", Error) {};
|
|
10
|
+
var RealPathErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-real-path-not-directory", Error) {};
|
|
11
|
+
var RealPathErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-real-path-too-many-open-files", Error) {};
|
|
12
|
+
var RealPathError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-real-path-error", Error) {};
|
|
6
13
|
function handleNodeRealPathError(error) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
else if (error.code === "
|
|
11
|
-
else if (error.code === "
|
|
14
|
+
let realPathError = void 0;
|
|
15
|
+
if ("code" in error) {
|
|
16
|
+
if (error.code === "ENOENT") realPathError = new RealPathErrorNotFound(error);
|
|
17
|
+
else if (error.code === "EACCES" || error.code === "EPERM") realPathError = new RealPathErrorPermissionDenied(error);
|
|
18
|
+
else if (error.code === "ENOTDIR") realPathError = new RealPathErrorNotDirectory(error);
|
|
19
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") realPathError = new RealPathErrorTooManyOpenFiles(error);
|
|
12
20
|
}
|
|
13
|
-
|
|
21
|
+
if (realPathError === void 0) realPathError = new RealPathError(error);
|
|
22
|
+
return _duplojs_lang_either.left("file-system-real-path-error", realPathError);
|
|
14
23
|
}
|
|
15
24
|
function handleDenoRealPathError(error) {
|
|
16
|
-
|
|
17
|
-
if (error instanceof Deno.errors.
|
|
18
|
-
if (error instanceof Deno.errors.
|
|
19
|
-
|
|
25
|
+
let realPathError = void 0;
|
|
26
|
+
if (error instanceof Deno.errors.NotFound) realPathError = new RealPathErrorNotFound(error);
|
|
27
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) realPathError = new RealPathErrorPermissionDenied(error);
|
|
28
|
+
else if (error instanceof Deno.errors.NotADirectory) realPathError = new RealPathErrorNotDirectory(error);
|
|
29
|
+
if (realPathError === void 0) realPathError = new RealPathError(error);
|
|
30
|
+
return _duplojs_lang_either.left("file-system-real-path-error", realPathError);
|
|
20
31
|
}
|
|
21
32
|
const realPath = require_implementor.implementFunction("realPath", {
|
|
22
|
-
NODE: async (path) =>
|
|
23
|
-
return (await require_implementor.nodeFileSystem.value).realpath(path).then((value) => _duplojs_lang_either.right("file-system-real-path", value)).catch(handleNodeRealPathError);
|
|
24
|
-
},
|
|
33
|
+
NODE: async (path) => require_implementor.nodeFileSystem.value.realpath(path).then((value) => _duplojs_lang_either.right("file-system-real-path", value)).catch(handleNodeRealPathError),
|
|
25
34
|
DENO: (path) => Deno.realPath(path).then((value) => _duplojs_lang_either.right("file-system-real-path", value)).catch(handleDenoRealPathError)
|
|
26
35
|
});
|
|
27
36
|
//#endregion
|
package/dist/file/realPath.d.ts
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
2
2
|
import * as DEither from "@duplojs/lang/either";
|
|
3
3
|
import type * as DPath from "@duplojs/lang/path";
|
|
4
|
-
|
|
4
|
+
declare const RealPathErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-real-path-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-real-path-not-found", unknown>>, unknown>;
|
|
5
|
+
declare class RealPathErrorNotFound extends RealPathErrorNotFound_base {
|
|
6
|
+
}
|
|
7
|
+
declare const RealPathErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-real-path-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-real-path-permission-denied", unknown>>, unknown>;
|
|
8
|
+
declare class RealPathErrorPermissionDenied extends RealPathErrorPermissionDenied_base {
|
|
9
|
+
}
|
|
10
|
+
declare const RealPathErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-real-path-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-real-path-not-directory", unknown>>, unknown>;
|
|
11
|
+
declare class RealPathErrorNotDirectory extends RealPathErrorNotDirectory_base {
|
|
12
|
+
}
|
|
13
|
+
declare const RealPathErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-real-path-too-many-open-files", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-real-path-too-many-open-files", unknown>>, unknown>;
|
|
14
|
+
declare class RealPathErrorTooManyOpenFiles extends RealPathErrorTooManyOpenFiles_base {
|
|
15
|
+
}
|
|
16
|
+
declare const RealPathError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-real-path-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-real-path-error", unknown>>, unknown>;
|
|
17
|
+
declare class RealPathError extends RealPathError_base {
|
|
18
|
+
}
|
|
19
|
+
export type RealPathErrors = (RealPathErrorNotFound | RealPathErrorPermissionDenied | RealPathErrorNotDirectory | RealPathErrorTooManyOpenFiles | RealPathError);
|
|
20
|
+
export type RealPathResult = (DEither.Right<"file-system-real-path", string> | DEither.Left<"file-system-real-path-error", RealPathErrors>);
|
|
5
21
|
declare module '../implementor' {
|
|
6
22
|
interface ServerFunction {
|
|
7
23
|
realPath(path: string & DPath.Path): Promise<RealPathResult>;
|
|
8
24
|
}
|
|
9
25
|
}
|
|
10
26
|
export declare const realPath: (path: string & DPath.Path) => Promise<RealPathResult>;
|
|
27
|
+
export {};
|
package/dist/file/realPath.mjs
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { implementFunction, nodeFileSystem } from "../implementor.mjs";
|
|
2
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
2
3
|
import * as DEither from "@duplojs/lang/either";
|
|
3
4
|
//#region scripts/file/realPath.ts
|
|
5
|
+
var RealPathErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-real-path-not-found", Error) {};
|
|
6
|
+
var RealPathErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-real-path-permission-denied", Error) {};
|
|
7
|
+
var RealPathErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-real-path-not-directory", Error) {};
|
|
8
|
+
var RealPathErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-real-path-too-many-open-files", Error) {};
|
|
9
|
+
var RealPathError = class extends DCommon.DuploJSError.parentClass("file-system-real-path-error", Error) {};
|
|
4
10
|
function handleNodeRealPathError(error) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
else if (error.code === "
|
|
9
|
-
else if (error.code === "
|
|
11
|
+
let realPathError = void 0;
|
|
12
|
+
if ("code" in error) {
|
|
13
|
+
if (error.code === "ENOENT") realPathError = new RealPathErrorNotFound(error);
|
|
14
|
+
else if (error.code === "EACCES" || error.code === "EPERM") realPathError = new RealPathErrorPermissionDenied(error);
|
|
15
|
+
else if (error.code === "ENOTDIR") realPathError = new RealPathErrorNotDirectory(error);
|
|
16
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") realPathError = new RealPathErrorTooManyOpenFiles(error);
|
|
10
17
|
}
|
|
11
|
-
|
|
18
|
+
if (realPathError === void 0) realPathError = new RealPathError(error);
|
|
19
|
+
return DEither.left("file-system-real-path-error", realPathError);
|
|
12
20
|
}
|
|
13
21
|
function handleDenoRealPathError(error) {
|
|
14
|
-
|
|
15
|
-
if (error instanceof Deno.errors.
|
|
16
|
-
if (error instanceof Deno.errors.
|
|
17
|
-
|
|
22
|
+
let realPathError = void 0;
|
|
23
|
+
if (error instanceof Deno.errors.NotFound) realPathError = new RealPathErrorNotFound(error);
|
|
24
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) realPathError = new RealPathErrorPermissionDenied(error);
|
|
25
|
+
else if (error instanceof Deno.errors.NotADirectory) realPathError = new RealPathErrorNotDirectory(error);
|
|
26
|
+
if (realPathError === void 0) realPathError = new RealPathError(error);
|
|
27
|
+
return DEither.left("file-system-real-path-error", realPathError);
|
|
18
28
|
}
|
|
19
29
|
const realPath = implementFunction("realPath", {
|
|
20
|
-
NODE: async (path) =>
|
|
21
|
-
return (await nodeFileSystem.value).realpath(path).then((value) => DEither.right("file-system-real-path", value)).catch(handleNodeRealPathError);
|
|
22
|
-
},
|
|
30
|
+
NODE: async (path) => nodeFileSystem.value.realpath(path).then((value) => DEither.right("file-system-real-path", value)).catch(handleNodeRealPathError),
|
|
23
31
|
DENO: (path) => Deno.realPath(path).then((value) => DEither.right("file-system-real-path", value)).catch(handleDenoRealPathError)
|
|
24
32
|
});
|
|
25
33
|
//#endregion
|
package/dist/file/relocate.cjs
CHANGED
|
@@ -1,46 +1,62 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_implementor = require("../implementor.cjs");
|
|
3
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
4
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
3
5
|
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
4
6
|
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
5
7
|
let _duplojs_lang_path = require("@duplojs/lang/path");
|
|
6
8
|
_duplojs_lang_path = require_runtime.__toESM(_duplojs_lang_path, 1);
|
|
7
9
|
//#region scripts/file/relocate.ts
|
|
10
|
+
var RelocateErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-relocate-not-found", Error) {};
|
|
11
|
+
var RelocateErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-relocate-permission-denied", Error) {};
|
|
12
|
+
var RelocateErrorAlreadyExists = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-relocate-already-exists", Error) {};
|
|
13
|
+
var RelocateErrorIsDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-relocate-is-directory", Error) {};
|
|
14
|
+
var RelocateErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-relocate-not-directory", Error) {};
|
|
15
|
+
var RelocateErrorDirectoryNotEmpty = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-relocate-directory-not-empty", Error) {};
|
|
16
|
+
var RelocateErrorReadOnly = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-relocate-read-only", Error) {};
|
|
17
|
+
var RelocateErrorInvalidArgument = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-relocate-invalid-argument", Error) {};
|
|
18
|
+
var RelocateErrorBusy = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-relocate-busy", Error) {};
|
|
19
|
+
var RelocateErrorCrossDevice = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-relocate-cross-device", Error) {};
|
|
20
|
+
var RelocateError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-relocate-error", Error) {};
|
|
8
21
|
function handleNodeRelocateError(error) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
else if (error.code === "
|
|
13
|
-
else if (error.code === "
|
|
14
|
-
else if (error.code === "
|
|
15
|
-
else if (error.code === "
|
|
16
|
-
else if (error.code === "
|
|
17
|
-
else if (error.code === "
|
|
18
|
-
else if (error.code === "
|
|
19
|
-
else if (error.code === "
|
|
22
|
+
let relocateError = void 0;
|
|
23
|
+
if ("code" in error) {
|
|
24
|
+
if (error.code === "ENOENT") relocateError = new RelocateErrorNotFound(error);
|
|
25
|
+
else if (error.code === "EACCES" || error.code === "EPERM") relocateError = new RelocateErrorPermissionDenied(error);
|
|
26
|
+
else if (error.code === "EEXIST") relocateError = new RelocateErrorAlreadyExists(error);
|
|
27
|
+
else if (error.code === "EISDIR") relocateError = new RelocateErrorIsDirectory(error);
|
|
28
|
+
else if (error.code === "ENOTDIR") relocateError = new RelocateErrorNotDirectory(error);
|
|
29
|
+
else if (error.code === "ENOTEMPTY") relocateError = new RelocateErrorDirectoryNotEmpty(error);
|
|
30
|
+
else if (error.code === "EROFS") relocateError = new RelocateErrorReadOnly(error);
|
|
31
|
+
else if (error.code === "EINVAL") relocateError = new RelocateErrorInvalidArgument(error);
|
|
32
|
+
else if (error.code === "EBUSY") relocateError = new RelocateErrorBusy(error);
|
|
33
|
+
else if (error.code === "EXDEV") relocateError = new RelocateErrorCrossDevice(error);
|
|
20
34
|
}
|
|
21
|
-
|
|
35
|
+
if (relocateError === void 0) relocateError = new RelocateError(error);
|
|
36
|
+
return _duplojs_lang_either.left("file-system-relocate-error", relocateError);
|
|
22
37
|
}
|
|
23
38
|
function handleDenoRelocateError(error) {
|
|
24
|
-
|
|
25
|
-
if (error instanceof Deno.errors.
|
|
26
|
-
if (error instanceof Deno.errors.
|
|
27
|
-
if (error instanceof Deno.errors.
|
|
28
|
-
if (error instanceof Deno.errors.
|
|
29
|
-
if (error instanceof Deno.errors.
|
|
30
|
-
if (error instanceof Deno.errors.
|
|
31
|
-
|
|
39
|
+
let relocateError = void 0;
|
|
40
|
+
if (error instanceof Deno.errors.NotFound) relocateError = new RelocateErrorNotFound(error);
|
|
41
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) relocateError = new RelocateErrorPermissionDenied(error);
|
|
42
|
+
else if (error instanceof Deno.errors.AlreadyExists) relocateError = new RelocateErrorAlreadyExists(error);
|
|
43
|
+
else if (error instanceof Deno.errors.IsADirectory) relocateError = new RelocateErrorIsDirectory(error);
|
|
44
|
+
else if (error instanceof Deno.errors.NotADirectory) relocateError = new RelocateErrorNotDirectory(error);
|
|
45
|
+
else if (error instanceof Deno.errors.InvalidData) relocateError = new RelocateErrorInvalidArgument(error);
|
|
46
|
+
else if (error instanceof Deno.errors.Busy) relocateError = new RelocateErrorBusy(error);
|
|
47
|
+
if (relocateError === void 0) relocateError = new RelocateError(error);
|
|
48
|
+
return _duplojs_lang_either.left("file-system-relocate-error", relocateError);
|
|
32
49
|
}
|
|
33
50
|
const relocateImplementation = require_implementor.implementFunction("relocate", {
|
|
34
51
|
NODE: async (fromPath, newParentPath) => {
|
|
35
|
-
const fs = await require_implementor.nodeFileSystem.value;
|
|
36
52
|
const baseName = _duplojs_lang_path.getBaseName(fromPath);
|
|
37
|
-
if (!baseName) return _duplojs_lang_either.left("file-system-relocate-
|
|
53
|
+
if (!baseName) return _duplojs_lang_either.left("file-system-relocate-error", new RelocateErrorInvalidArgument(/* @__PURE__ */ new Error(`Invalid base name ${fromPath}`)));
|
|
38
54
|
const newPath = _duplojs_lang_path.resolveRelative([newParentPath, baseName]);
|
|
39
|
-
return
|
|
55
|
+
return require_implementor.nodeFileSystem.value.rename(fromPath, newPath).then(() => _duplojs_lang_either.right("file-system-relocate", newPath)).catch(handleNodeRelocateError);
|
|
40
56
|
},
|
|
41
|
-
DENO: (fromPath, newParentPath) => {
|
|
57
|
+
DENO: async (fromPath, newParentPath) => {
|
|
42
58
|
const baseName = _duplojs_lang_path.getBaseName(fromPath);
|
|
43
|
-
if (!baseName) return Promise.resolve(_duplojs_lang_either.left("file-system-relocate-
|
|
59
|
+
if (!baseName) return Promise.resolve(_duplojs_lang_either.left("file-system-relocate-error", new RelocateErrorInvalidArgument(/* @__PURE__ */ new Error(`Invalid base name ${fromPath}`))));
|
|
44
60
|
const newPath = _duplojs_lang_path.resolveRelative([newParentPath, baseName]);
|
|
45
61
|
return Deno.rename(fromPath, newPath).then(() => _duplojs_lang_either.right("file-system-relocate", newPath)).catch(handleDenoRelocateError);
|
|
46
62
|
}
|