@duplojs/server 0.1.0-beta.2 → 0.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.mjs +5 -1
- package/dist/command/argument.d.ts +2 -2
- package/dist/command/create.cjs +18 -10
- package/dist/command/create.d.ts +3 -3
- package/dist/command/create.mjs +18 -10
- package/dist/command/error.cjs +26 -2
- package/dist/command/error.d.ts +9 -1
- package/dist/command/error.mjs +25 -1
- package/dist/command/exec.d.ts +4 -3
- package/dist/command/help.cjs +11 -9
- package/dist/command/help.d.ts +1 -1
- package/dist/command/help.mjs +10 -8
- package/dist/command/index.cjs +4 -0
- package/dist/command/index.mjs +4 -2
- package/dist/command/options/base.cjs +21 -13
- package/dist/command/options/base.d.ts +6 -0
- package/dist/command/options/base.mjs +20 -14
- package/dist/command/options/defaults/array.d.ts +6 -4
- package/dist/command/options/defaults/boolean.cjs +21 -7
- package/dist/command/options/defaults/boolean.d.ts +6 -3
- package/dist/command/options/defaults/boolean.mjs +20 -8
- package/dist/command/options/defaults/simple.d.ts +6 -4
- package/dist/command/types/forbiddenInvalidIdentifier.d.ts +6 -0
- package/dist/command/types/index.d.ts +1 -0
- package/dist/common/environmentVariable/index.d.ts +1 -1
- package/dist/common/environmentVariable/overrideEnvironmentVariables.d.ts +1 -1
- 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 +46 -22
- package/dist/file/appendFile.d.ts +37 -5
- package/dist/file/appendFile.mjs +36 -23
- package/dist/file/appendTextFile.cjs +44 -20
- package/dist/file/appendTextFile.d.ts +37 -5
- package/dist/file/appendTextFile.mjs +34 -21
- package/dist/file/copy.cjs +36 -14
- package/dist/file/copy.d.ts +37 -5
- package/dist/file/copy.mjs +26 -15
- package/dist/file/createEntryInterface.cjs +6 -3
- package/dist/file/createEntryInterface.d.ts +1 -1
- package/dist/file/createEntryInterface.mjs +4 -2
- package/dist/file/ensureDirectory.cjs +37 -17
- package/dist/file/ensureDirectory.d.ts +30 -4
- package/dist/file/ensureDirectory.mjs +29 -18
- package/dist/file/ensureFile.cjs +41 -19
- package/dist/file/ensureFile.d.ts +33 -4
- package/dist/file/ensureFile.mjs +32 -20
- package/dist/file/exists.cjs +28 -14
- package/dist/file/exists.d.ts +21 -4
- package/dist/file/exists.mjs +23 -15
- package/dist/file/fileInterface.cjs +3 -1
- package/dist/file/fileInterface.d.ts +10 -9
- package/dist/file/fileInterface.mjs +3 -2
- package/dist/file/folderInterface.cjs +3 -1
- package/dist/file/folderInterface.d.ts +9 -8
- package/dist/file/folderInterface.mjs +3 -2
- package/dist/file/index.cjs +512 -0
- package/dist/file/index.d.ts +0 -1
- package/dist/file/index.mjs +291 -35
- package/dist/file/link.cjs +48 -22
- package/dist/file/link.d.ts +40 -5
- package/dist/file/link.mjs +37 -23
- package/dist/file/linkStat.cjs +29 -15
- package/dist/file/linkStat.d.ts +24 -4
- package/dist/file/linkStat.mjs +24 -16
- package/dist/file/makeDirectory.cjs +45 -21
- package/dist/file/makeDirectory.d.ts +35 -4
- package/dist/file/makeDirectory.mjs +35 -22
- package/dist/file/makeTemporaryDirectory.cjs +33 -15
- package/dist/file/makeTemporaryDirectory.d.ts +25 -2
- package/dist/file/makeTemporaryDirectory.mjs +26 -16
- package/dist/file/makeTemporaryFile.cjs +37 -20
- package/dist/file/makeTemporaryFile.d.ts +28 -2
- package/dist/file/makeTemporaryFile.mjs +30 -21
- package/dist/file/move.cjs +49 -23
- package/dist/file/move.d.ts +40 -5
- package/dist/file/move.mjs +38 -24
- package/dist/file/readDirectory.cjs +33 -9
- package/dist/file/readDirectory.d.ts +26 -5
- package/dist/file/readDirectory.mjs +25 -10
- package/dist/file/readFile.cjs +35 -17
- package/dist/file/readFile.d.ts +27 -4
- package/dist/file/readFile.mjs +28 -18
- package/dist/file/readJsonFile.cjs +35 -17
- package/dist/file/readJsonFile.d.ts +27 -5
- package/dist/file/readJsonFile.mjs +28 -18
- package/dist/file/readLink.cjs +31 -15
- package/dist/file/readLink.d.ts +24 -4
- package/dist/file/readLink.mjs +25 -16
- package/dist/file/readTextFile.cjs +35 -17
- package/dist/file/readTextFile.d.ts +27 -4
- package/dist/file/readTextFile.mjs +28 -18
- package/dist/file/realPath.cjs +27 -13
- package/dist/file/realPath.d.ts +21 -4
- package/dist/file/realPath.mjs +22 -14
- package/dist/file/relocate.cjs +52 -25
- package/dist/file/relocate.d.ts +40 -5
- package/dist/file/relocate.mjs +41 -26
- package/dist/file/remove.cjs +45 -23
- package/dist/file/remove.d.ts +32 -4
- package/dist/file/remove.mjs +36 -24
- package/dist/file/rename.cjs +52 -25
- package/dist/file/rename.d.ts +40 -5
- package/dist/file/rename.mjs +41 -26
- package/dist/file/setMode.cjs +29 -15
- package/dist/file/setMode.d.ts +24 -5
- package/dist/file/setMode.mjs +24 -16
- package/dist/file/setOwner.cjs +31 -15
- package/dist/file/setOwner.d.ts +25 -5
- package/dist/file/setOwner.mjs +25 -16
- package/dist/file/setTime.cjs +31 -15
- package/dist/file/setTime.d.ts +24 -5
- package/dist/file/setTime.mjs +25 -16
- package/dist/file/stat.cjs +29 -15
- package/dist/file/stat.d.ts +24 -4
- package/dist/file/stat.mjs +24 -16
- package/dist/file/symlink.cjs +42 -20
- package/dist/file/symlink.d.ts +34 -5
- package/dist/file/symlink.mjs +33 -21
- package/dist/file/truncate.cjs +43 -21
- package/dist/file/truncate.d.ts +36 -4
- package/dist/file/truncate.mjs +34 -22
- package/dist/file/unknownEntryInterface.cjs +5 -1
- package/dist/file/unknownEntryInterface.d.ts +8 -6
- package/dist/file/unknownEntryInterface.mjs +4 -2
- package/dist/file/walkDirectory.cjs +38 -15
- package/dist/file/walkDirectory.d.ts +25 -4
- package/dist/file/walkDirectory.mjs +32 -15
- package/dist/file/writeFile.cjs +45 -21
- package/dist/file/writeFile.d.ts +37 -5
- package/dist/file/writeFile.mjs +35 -22
- package/dist/file/writeJsonFile.cjs +48 -27
- package/dist/file/writeJsonFile.d.ts +37 -6
- package/dist/file/writeJsonFile.mjs +39 -28
- package/dist/file/writeTextFile.cjs +45 -21
- package/dist/file/writeTextFile.d.ts +37 -5
- package/dist/file/writeTextFile.mjs +35 -22
- 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/dist/override.d.ts +8 -0
- 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/linkStat.cjs
CHANGED
|
@@ -7,22 +7,32 @@ _duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
|
7
7
|
let _duplojs_lang_chrono = require("@duplojs/lang/chrono");
|
|
8
8
|
_duplojs_lang_chrono = require_runtime.__toESM(_duplojs_lang_chrono, 1);
|
|
9
9
|
//#region scripts/file/linkStat.ts
|
|
10
|
+
var LinkStatErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-link-stat-not-found", Error) {};
|
|
11
|
+
var LinkStatErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-link-stat-permission-denied", Error) {};
|
|
12
|
+
var LinkStatErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-link-stat-not-directory", Error) {};
|
|
13
|
+
var LinkStatErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-link-stat-too-many-open-files", Error) {};
|
|
14
|
+
var LinkStatErrorBusy = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-link-stat-busy", Error) {};
|
|
15
|
+
var LinkStatError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-link-stat-error", Error) {};
|
|
10
16
|
function handleNodeLinkStatError(error) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
else if (error.code === "
|
|
15
|
-
else if (error.code === "
|
|
16
|
-
else if (error.code === "
|
|
17
|
+
let linkStatError = void 0;
|
|
18
|
+
if ("code" in error) {
|
|
19
|
+
if (error.code === "ENOENT") linkStatError = new LinkStatErrorNotFound(error);
|
|
20
|
+
else if (error.code === "EACCES" || error.code === "EPERM") linkStatError = new LinkStatErrorPermissionDenied(error);
|
|
21
|
+
else if (error.code === "ENOTDIR") linkStatError = new LinkStatErrorNotDirectory(error);
|
|
22
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") linkStatError = new LinkStatErrorTooManyOpenFiles(error);
|
|
23
|
+
else if (error.code === "EBUSY") linkStatError = new LinkStatErrorBusy(error);
|
|
17
24
|
}
|
|
18
|
-
|
|
25
|
+
if (linkStatError === void 0) linkStatError = new LinkStatError(error);
|
|
26
|
+
return _duplojs_lang_either.left("file-system-link-stat-error", linkStatError);
|
|
19
27
|
}
|
|
20
28
|
function handleDenoLinkStatError(error) {
|
|
21
|
-
|
|
22
|
-
if (error instanceof Deno.errors.
|
|
23
|
-
if (error instanceof Deno.errors.
|
|
24
|
-
if (error instanceof Deno.errors.
|
|
25
|
-
|
|
29
|
+
let linkStatError = void 0;
|
|
30
|
+
if (error instanceof Deno.errors.NotFound) linkStatError = new LinkStatErrorNotFound(error);
|
|
31
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) linkStatError = new LinkStatErrorPermissionDenied(error);
|
|
32
|
+
else if (error instanceof Deno.errors.NotADirectory) linkStatError = new LinkStatErrorNotDirectory(error);
|
|
33
|
+
else if (error instanceof Deno.errors.Busy) linkStatError = new LinkStatErrorBusy(error);
|
|
34
|
+
if (linkStatError === void 0) linkStatError = new LinkStatError(error);
|
|
35
|
+
return _duplojs_lang_either.left("file-system-link-stat-error", linkStatError);
|
|
26
36
|
}
|
|
27
37
|
function createStatInfoWithFsSource(source) {
|
|
28
38
|
return {
|
|
@@ -75,10 +85,14 @@ function createStatInfoWithDeno(source) {
|
|
|
75
85
|
};
|
|
76
86
|
}
|
|
77
87
|
const linkStat = require_implementor.implementFunction("linkStat", {
|
|
78
|
-
NODE: async (path) =>
|
|
79
|
-
return (await require_implementor.nodeFileSystem.value).lstat(path).then(_duplojs_lang_common.innerPipe(createStatInfoWithFsSource, (value) => _duplojs_lang_either.right("file-system-link-stat", value))).catch(handleNodeLinkStatError);
|
|
80
|
-
},
|
|
88
|
+
NODE: async (path) => require_implementor.nodeFileSystem.value.lstat(path).then(_duplojs_lang_common.innerPipe(createStatInfoWithFsSource, (value) => _duplojs_lang_either.right("file-system-link-stat", value))).catch(handleNodeLinkStatError),
|
|
81
89
|
DENO: (path) => Deno.lstat(path).then(_duplojs_lang_common.innerPipe(createStatInfoWithDeno, (value) => _duplojs_lang_either.right("file-system-link-stat", value))).catch(handleDenoLinkStatError)
|
|
82
90
|
});
|
|
83
91
|
//#endregion
|
|
92
|
+
exports.LinkStatError = LinkStatError;
|
|
93
|
+
exports.LinkStatErrorBusy = LinkStatErrorBusy;
|
|
94
|
+
exports.LinkStatErrorNotDirectory = LinkStatErrorNotDirectory;
|
|
95
|
+
exports.LinkStatErrorNotFound = LinkStatErrorNotFound;
|
|
96
|
+
exports.LinkStatErrorPermissionDenied = LinkStatErrorPermissionDenied;
|
|
97
|
+
exports.LinkStatErrorTooManyOpenFiles = LinkStatErrorTooManyOpenFiles;
|
|
84
98
|
exports.linkStat = linkStat;
|
package/dist/file/linkStat.d.ts
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { StatInfo } from './stat';
|
|
2
|
-
import
|
|
2
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
3
3
|
import type * as DPath from "@duplojs/lang/path";
|
|
4
4
|
import * as DEither from "@duplojs/lang/either";
|
|
5
|
-
|
|
5
|
+
declare const LinkStatErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-link-stat-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-link-stat-not-found", unknown>>, unknown>;
|
|
6
|
+
export declare class LinkStatErrorNotFound extends LinkStatErrorNotFound_base {
|
|
7
|
+
}
|
|
8
|
+
declare const LinkStatErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-link-stat-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-link-stat-permission-denied", unknown>>, unknown>;
|
|
9
|
+
export declare class LinkStatErrorPermissionDenied extends LinkStatErrorPermissionDenied_base {
|
|
10
|
+
}
|
|
11
|
+
declare const LinkStatErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-link-stat-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-link-stat-not-directory", unknown>>, unknown>;
|
|
12
|
+
export declare class LinkStatErrorNotDirectory extends LinkStatErrorNotDirectory_base {
|
|
13
|
+
}
|
|
14
|
+
declare const LinkStatErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-link-stat-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-link-stat-too-many-open-files", unknown>>, unknown>;
|
|
15
|
+
export declare class LinkStatErrorTooManyOpenFiles extends LinkStatErrorTooManyOpenFiles_base {
|
|
16
|
+
}
|
|
17
|
+
declare const LinkStatErrorBusy_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-link-stat-busy", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-link-stat-busy", unknown>>, unknown>;
|
|
18
|
+
export declare class LinkStatErrorBusy extends LinkStatErrorBusy_base {
|
|
19
|
+
}
|
|
20
|
+
declare const LinkStatError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-link-stat-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-link-stat-error", unknown>>, unknown>;
|
|
21
|
+
export declare class LinkStatError extends LinkStatError_base {
|
|
22
|
+
}
|
|
23
|
+
export type LinkStatErrors = (LinkStatErrorNotFound | LinkStatErrorPermissionDenied | LinkStatErrorNotDirectory | LinkStatErrorTooManyOpenFiles | LinkStatErrorBusy | LinkStatError);
|
|
24
|
+
export type LinkStatResult = (DEither.Right<"file-system-link-stat", StatInfo> | DEither.Left<"file-system-link-stat-error", LinkStatErrors>);
|
|
6
25
|
declare module '../implementor' {
|
|
7
26
|
interface ServerFunction {
|
|
8
|
-
linkStat(path:
|
|
27
|
+
linkStat(path: DPath.AnyPath): Promise<LinkStatResult>;
|
|
9
28
|
}
|
|
10
29
|
}
|
|
11
|
-
export declare const linkStat: (path:
|
|
30
|
+
export declare const linkStat: (path: DPath.AnyPath) => Promise<LinkStatResult>;
|
|
31
|
+
export {};
|
package/dist/file/linkStat.mjs
CHANGED
|
@@ -3,22 +3,32 @@ import * as DCommon from "@duplojs/lang/common";
|
|
|
3
3
|
import * as DEither from "@duplojs/lang/either";
|
|
4
4
|
import * as DChrono from "@duplojs/lang/chrono";
|
|
5
5
|
//#region scripts/file/linkStat.ts
|
|
6
|
+
var LinkStatErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-link-stat-not-found", Error) {};
|
|
7
|
+
var LinkStatErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-link-stat-permission-denied", Error) {};
|
|
8
|
+
var LinkStatErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-link-stat-not-directory", Error) {};
|
|
9
|
+
var LinkStatErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-link-stat-too-many-open-files", Error) {};
|
|
10
|
+
var LinkStatErrorBusy = class extends DCommon.DuploJSError.parentClass("file-system-link-stat-busy", Error) {};
|
|
11
|
+
var LinkStatError = class extends DCommon.DuploJSError.parentClass("file-system-link-stat-error", Error) {};
|
|
6
12
|
function handleNodeLinkStatError(error) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
else if (error.code === "
|
|
11
|
-
else if (error.code === "
|
|
12
|
-
else if (error.code === "
|
|
13
|
+
let linkStatError = void 0;
|
|
14
|
+
if ("code" in error) {
|
|
15
|
+
if (error.code === "ENOENT") linkStatError = new LinkStatErrorNotFound(error);
|
|
16
|
+
else if (error.code === "EACCES" || error.code === "EPERM") linkStatError = new LinkStatErrorPermissionDenied(error);
|
|
17
|
+
else if (error.code === "ENOTDIR") linkStatError = new LinkStatErrorNotDirectory(error);
|
|
18
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") linkStatError = new LinkStatErrorTooManyOpenFiles(error);
|
|
19
|
+
else if (error.code === "EBUSY") linkStatError = new LinkStatErrorBusy(error);
|
|
13
20
|
}
|
|
14
|
-
|
|
21
|
+
if (linkStatError === void 0) linkStatError = new LinkStatError(error);
|
|
22
|
+
return DEither.left("file-system-link-stat-error", linkStatError);
|
|
15
23
|
}
|
|
16
24
|
function handleDenoLinkStatError(error) {
|
|
17
|
-
|
|
18
|
-
if (error instanceof Deno.errors.
|
|
19
|
-
if (error instanceof Deno.errors.
|
|
20
|
-
if (error instanceof Deno.errors.
|
|
21
|
-
|
|
25
|
+
let linkStatError = void 0;
|
|
26
|
+
if (error instanceof Deno.errors.NotFound) linkStatError = new LinkStatErrorNotFound(error);
|
|
27
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) linkStatError = new LinkStatErrorPermissionDenied(error);
|
|
28
|
+
else if (error instanceof Deno.errors.NotADirectory) linkStatError = new LinkStatErrorNotDirectory(error);
|
|
29
|
+
else if (error instanceof Deno.errors.Busy) linkStatError = new LinkStatErrorBusy(error);
|
|
30
|
+
if (linkStatError === void 0) linkStatError = new LinkStatError(error);
|
|
31
|
+
return DEither.left("file-system-link-stat-error", linkStatError);
|
|
22
32
|
}
|
|
23
33
|
function createStatInfoWithFsSource(source) {
|
|
24
34
|
return {
|
|
@@ -71,10 +81,8 @@ function createStatInfoWithDeno(source) {
|
|
|
71
81
|
};
|
|
72
82
|
}
|
|
73
83
|
const linkStat = implementFunction("linkStat", {
|
|
74
|
-
NODE: async (path) =>
|
|
75
|
-
return (await nodeFileSystem.value).lstat(path).then(DCommon.innerPipe(createStatInfoWithFsSource, (value) => DEither.right("file-system-link-stat", value))).catch(handleNodeLinkStatError);
|
|
76
|
-
},
|
|
84
|
+
NODE: async (path) => nodeFileSystem.value.lstat(path).then(DCommon.innerPipe(createStatInfoWithFsSource, (value) => DEither.right("file-system-link-stat", value))).catch(handleNodeLinkStatError),
|
|
77
85
|
DENO: (path) => Deno.lstat(path).then(DCommon.innerPipe(createStatInfoWithDeno, (value) => DEither.right("file-system-link-stat", value))).catch(handleDenoLinkStatError)
|
|
78
86
|
});
|
|
79
87
|
//#endregion
|
|
80
|
-
export { linkStat };
|
|
88
|
+
export { LinkStatError, LinkStatErrorBusy, LinkStatErrorNotDirectory, LinkStatErrorNotFound, LinkStatErrorPermissionDenied, LinkStatErrorTooManyOpenFiles, linkStat };
|
|
@@ -1,36 +1,60 @@
|
|
|
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/makeDirectory.ts
|
|
8
|
+
var MakeDirectoryErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-directory-not-found", Error) {};
|
|
9
|
+
var MakeDirectoryErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-directory-permission-denied", Error) {};
|
|
10
|
+
var MakeDirectoryErrorAlreadyExists = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-directory-already-exists", Error) {};
|
|
11
|
+
var MakeDirectoryErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-directory-not-directory", Error) {};
|
|
12
|
+
var MakeDirectoryErrorNoSpace = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-directory-no-space", Error) {};
|
|
13
|
+
var MakeDirectoryErrorReadOnly = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-directory-read-only", Error) {};
|
|
14
|
+
var MakeDirectoryErrorInvalidArgument = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-directory-invalid-argument", Error) {};
|
|
15
|
+
var MakeDirectoryErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-directory-too-many-open-files", Error) {};
|
|
16
|
+
var MakeDirectoryErrorBusy = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-directory-busy", Error) {};
|
|
17
|
+
var MakeDirectoryError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-directory-error", Error) {};
|
|
6
18
|
function handleNodeMakeDirectoryError(error) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
else if (error.code === "
|
|
11
|
-
else if (error.code === "
|
|
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 === "
|
|
19
|
+
let makeDirectoryError = void 0;
|
|
20
|
+
if ("code" in error) {
|
|
21
|
+
if (error.code === "ENOENT") makeDirectoryError = new MakeDirectoryErrorNotFound(error);
|
|
22
|
+
else if (error.code === "EACCES" || error.code === "EPERM") makeDirectoryError = new MakeDirectoryErrorPermissionDenied(error);
|
|
23
|
+
else if (error.code === "EEXIST") makeDirectoryError = new MakeDirectoryErrorAlreadyExists(error);
|
|
24
|
+
else if (error.code === "ENOTDIR") makeDirectoryError = new MakeDirectoryErrorNotDirectory(error);
|
|
25
|
+
else if (error.code === "ENOSPC") makeDirectoryError = new MakeDirectoryErrorNoSpace(error);
|
|
26
|
+
else if (error.code === "EROFS") makeDirectoryError = new MakeDirectoryErrorReadOnly(error);
|
|
27
|
+
else if (error.code === "EINVAL") makeDirectoryError = new MakeDirectoryErrorInvalidArgument(error);
|
|
28
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") makeDirectoryError = new MakeDirectoryErrorTooManyOpenFiles(error);
|
|
29
|
+
else if (error.code === "EBUSY") makeDirectoryError = new MakeDirectoryErrorBusy(error);
|
|
17
30
|
}
|
|
18
|
-
|
|
31
|
+
if (makeDirectoryError === void 0) makeDirectoryError = new MakeDirectoryError(error);
|
|
32
|
+
return _duplojs_lang_either.left("file-system-make-directory-error", makeDirectoryError);
|
|
19
33
|
}
|
|
20
34
|
function handleDenoMakeDirectoryError(error) {
|
|
21
|
-
|
|
22
|
-
if (error instanceof Deno.errors.
|
|
23
|
-
if (error instanceof Deno.errors.
|
|
24
|
-
if (error instanceof Deno.errors.
|
|
25
|
-
if (error instanceof Deno.errors.
|
|
26
|
-
if (error instanceof Deno.errors.
|
|
27
|
-
|
|
35
|
+
let makeDirectoryError = void 0;
|
|
36
|
+
if (error instanceof Deno.errors.NotFound) makeDirectoryError = new MakeDirectoryErrorNotFound(error);
|
|
37
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) makeDirectoryError = new MakeDirectoryErrorPermissionDenied(error);
|
|
38
|
+
else if (error instanceof Deno.errors.AlreadyExists) makeDirectoryError = new MakeDirectoryErrorAlreadyExists(error);
|
|
39
|
+
else if (error instanceof Deno.errors.NotADirectory) makeDirectoryError = new MakeDirectoryErrorNotDirectory(error);
|
|
40
|
+
else if (error instanceof Deno.errors.InvalidData) makeDirectoryError = new MakeDirectoryErrorInvalidArgument(error);
|
|
41
|
+
else if (error instanceof Deno.errors.Busy) makeDirectoryError = new MakeDirectoryErrorBusy(error);
|
|
42
|
+
if (makeDirectoryError === void 0) makeDirectoryError = new MakeDirectoryError(error);
|
|
43
|
+
return _duplojs_lang_either.left("file-system-make-directory-error", makeDirectoryError);
|
|
28
44
|
}
|
|
29
45
|
const makeDirectory = require_implementor.implementFunction("makeDirectory", {
|
|
30
|
-
NODE: async (path, params) => {
|
|
31
|
-
return (await require_implementor.nodeFileSystem.value).mkdir(path, { recursive: params?.recursive }).then(() => _duplojs_lang_either.right("file-system-make-directory")).catch(handleNodeMakeDirectoryError);
|
|
32
|
-
},
|
|
46
|
+
NODE: async (path, params) => require_implementor.nodeFileSystem.value.mkdir(path, { recursive: params?.recursive }).then(() => _duplojs_lang_either.right("file-system-make-directory")).catch(handleNodeMakeDirectoryError),
|
|
33
47
|
DENO: (path, params) => Deno.mkdir(path, { recursive: params?.recursive }).then(() => _duplojs_lang_either.right("file-system-make-directory")).catch(handleDenoMakeDirectoryError)
|
|
34
48
|
});
|
|
35
49
|
//#endregion
|
|
50
|
+
exports.MakeDirectoryError = MakeDirectoryError;
|
|
51
|
+
exports.MakeDirectoryErrorAlreadyExists = MakeDirectoryErrorAlreadyExists;
|
|
52
|
+
exports.MakeDirectoryErrorBusy = MakeDirectoryErrorBusy;
|
|
53
|
+
exports.MakeDirectoryErrorInvalidArgument = MakeDirectoryErrorInvalidArgument;
|
|
54
|
+
exports.MakeDirectoryErrorNoSpace = MakeDirectoryErrorNoSpace;
|
|
55
|
+
exports.MakeDirectoryErrorNotDirectory = MakeDirectoryErrorNotDirectory;
|
|
56
|
+
exports.MakeDirectoryErrorNotFound = MakeDirectoryErrorNotFound;
|
|
57
|
+
exports.MakeDirectoryErrorPermissionDenied = MakeDirectoryErrorPermissionDenied;
|
|
58
|
+
exports.MakeDirectoryErrorReadOnly = MakeDirectoryErrorReadOnly;
|
|
59
|
+
exports.MakeDirectoryErrorTooManyOpenFiles = MakeDirectoryErrorTooManyOpenFiles;
|
|
36
60
|
exports.makeDirectory = makeDirectory;
|
|
@@ -1,14 +1,45 @@
|
|
|
1
|
-
import { FileSystemEither } from './types';
|
|
2
1
|
import * as DEither from "@duplojs/lang/either";
|
|
3
2
|
import type * as DPath from "@duplojs/lang/path";
|
|
3
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
4
4
|
interface MakeDirectoryParams {
|
|
5
5
|
recursive?: boolean;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
declare const MakeDirectoryErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-directory-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-directory-not-found", unknown>>, unknown>;
|
|
8
|
+
export declare class MakeDirectoryErrorNotFound extends MakeDirectoryErrorNotFound_base {
|
|
9
|
+
}
|
|
10
|
+
declare const MakeDirectoryErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-directory-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-directory-permission-denied", unknown>>, unknown>;
|
|
11
|
+
export declare class MakeDirectoryErrorPermissionDenied extends MakeDirectoryErrorPermissionDenied_base {
|
|
12
|
+
}
|
|
13
|
+
declare const MakeDirectoryErrorAlreadyExists_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-directory-already-exists", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-directory-already-exists", unknown>>, unknown>;
|
|
14
|
+
export declare class MakeDirectoryErrorAlreadyExists extends MakeDirectoryErrorAlreadyExists_base {
|
|
15
|
+
}
|
|
16
|
+
declare const MakeDirectoryErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-directory-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-directory-not-directory", unknown>>, unknown>;
|
|
17
|
+
export declare class MakeDirectoryErrorNotDirectory extends MakeDirectoryErrorNotDirectory_base {
|
|
18
|
+
}
|
|
19
|
+
declare const MakeDirectoryErrorNoSpace_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-directory-no-space", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-directory-no-space", unknown>>, unknown>;
|
|
20
|
+
export declare class MakeDirectoryErrorNoSpace extends MakeDirectoryErrorNoSpace_base {
|
|
21
|
+
}
|
|
22
|
+
declare const MakeDirectoryErrorReadOnly_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-directory-read-only", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-directory-read-only", unknown>>, unknown>;
|
|
23
|
+
export declare class MakeDirectoryErrorReadOnly extends MakeDirectoryErrorReadOnly_base {
|
|
24
|
+
}
|
|
25
|
+
declare const MakeDirectoryErrorInvalidArgument_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-directory-invalid-argument", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-directory-invalid-argument", unknown>>, unknown>;
|
|
26
|
+
export declare class MakeDirectoryErrorInvalidArgument extends MakeDirectoryErrorInvalidArgument_base {
|
|
27
|
+
}
|
|
28
|
+
declare const MakeDirectoryErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-directory-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-make-directory-too-many-open-files", unknown>>, unknown>;
|
|
29
|
+
export declare class MakeDirectoryErrorTooManyOpenFiles extends MakeDirectoryErrorTooManyOpenFiles_base {
|
|
30
|
+
}
|
|
31
|
+
declare const MakeDirectoryErrorBusy_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-directory-busy", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-directory-busy", unknown>>, unknown>;
|
|
32
|
+
export declare class MakeDirectoryErrorBusy extends MakeDirectoryErrorBusy_base {
|
|
33
|
+
}
|
|
34
|
+
declare const MakeDirectoryError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-directory-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-directory-error", unknown>>, unknown>;
|
|
35
|
+
export declare class MakeDirectoryError extends MakeDirectoryError_base {
|
|
36
|
+
}
|
|
37
|
+
export type MakeDirectoryErrors = (MakeDirectoryErrorNotFound | MakeDirectoryErrorPermissionDenied | MakeDirectoryErrorAlreadyExists | MakeDirectoryErrorNotDirectory | MakeDirectoryErrorNoSpace | MakeDirectoryErrorReadOnly | MakeDirectoryErrorInvalidArgument | MakeDirectoryErrorTooManyOpenFiles | MakeDirectoryErrorBusy | MakeDirectoryError);
|
|
38
|
+
export type MakeDirectoryResult = (DEither.Right<"file-system-make-directory", void> | DEither.Left<"file-system-make-directory-error", MakeDirectoryErrors>);
|
|
8
39
|
declare module '../implementor' {
|
|
9
40
|
interface ServerFunction {
|
|
10
|
-
makeDirectory(path:
|
|
41
|
+
makeDirectory(path: DPath.AnyPath, params?: MakeDirectoryParams): Promise<MakeDirectoryResult>;
|
|
11
42
|
}
|
|
12
43
|
}
|
|
13
|
-
export declare const makeDirectory: (path:
|
|
44
|
+
export declare const makeDirectory: (path: DPath.AnyPath, params?: MakeDirectoryParams) => Promise<MakeDirectoryResult>;
|
|
14
45
|
export {};
|
|
@@ -1,34 +1,47 @@
|
|
|
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/makeDirectory.ts
|
|
5
|
+
var MakeDirectoryErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-make-directory-not-found", Error) {};
|
|
6
|
+
var MakeDirectoryErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-make-directory-permission-denied", Error) {};
|
|
7
|
+
var MakeDirectoryErrorAlreadyExists = class extends DCommon.DuploJSError.parentClass("file-system-make-directory-already-exists", Error) {};
|
|
8
|
+
var MakeDirectoryErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-make-directory-not-directory", Error) {};
|
|
9
|
+
var MakeDirectoryErrorNoSpace = class extends DCommon.DuploJSError.parentClass("file-system-make-directory-no-space", Error) {};
|
|
10
|
+
var MakeDirectoryErrorReadOnly = class extends DCommon.DuploJSError.parentClass("file-system-make-directory-read-only", Error) {};
|
|
11
|
+
var MakeDirectoryErrorInvalidArgument = class extends DCommon.DuploJSError.parentClass("file-system-make-directory-invalid-argument", Error) {};
|
|
12
|
+
var MakeDirectoryErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-make-directory-too-many-open-files", Error) {};
|
|
13
|
+
var MakeDirectoryErrorBusy = class extends DCommon.DuploJSError.parentClass("file-system-make-directory-busy", Error) {};
|
|
14
|
+
var MakeDirectoryError = class extends DCommon.DuploJSError.parentClass("file-system-make-directory-error", Error) {};
|
|
4
15
|
function handleNodeMakeDirectoryError(error) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
else if (error.code === "
|
|
9
|
-
else if (error.code === "
|
|
10
|
-
else if (error.code === "
|
|
11
|
-
else if (error.code === "
|
|
12
|
-
else if (error.code === "
|
|
13
|
-
else if (error.code === "
|
|
14
|
-
else if (error.code === "
|
|
16
|
+
let makeDirectoryError = void 0;
|
|
17
|
+
if ("code" in error) {
|
|
18
|
+
if (error.code === "ENOENT") makeDirectoryError = new MakeDirectoryErrorNotFound(error);
|
|
19
|
+
else if (error.code === "EACCES" || error.code === "EPERM") makeDirectoryError = new MakeDirectoryErrorPermissionDenied(error);
|
|
20
|
+
else if (error.code === "EEXIST") makeDirectoryError = new MakeDirectoryErrorAlreadyExists(error);
|
|
21
|
+
else if (error.code === "ENOTDIR") makeDirectoryError = new MakeDirectoryErrorNotDirectory(error);
|
|
22
|
+
else if (error.code === "ENOSPC") makeDirectoryError = new MakeDirectoryErrorNoSpace(error);
|
|
23
|
+
else if (error.code === "EROFS") makeDirectoryError = new MakeDirectoryErrorReadOnly(error);
|
|
24
|
+
else if (error.code === "EINVAL") makeDirectoryError = new MakeDirectoryErrorInvalidArgument(error);
|
|
25
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") makeDirectoryError = new MakeDirectoryErrorTooManyOpenFiles(error);
|
|
26
|
+
else if (error.code === "EBUSY") makeDirectoryError = new MakeDirectoryErrorBusy(error);
|
|
15
27
|
}
|
|
16
|
-
|
|
28
|
+
if (makeDirectoryError === void 0) makeDirectoryError = new MakeDirectoryError(error);
|
|
29
|
+
return DEither.left("file-system-make-directory-error", makeDirectoryError);
|
|
17
30
|
}
|
|
18
31
|
function handleDenoMakeDirectoryError(error) {
|
|
19
|
-
|
|
20
|
-
if (error instanceof Deno.errors.
|
|
21
|
-
if (error instanceof Deno.errors.
|
|
22
|
-
if (error instanceof Deno.errors.
|
|
23
|
-
if (error instanceof Deno.errors.
|
|
24
|
-
if (error instanceof Deno.errors.
|
|
25
|
-
|
|
32
|
+
let makeDirectoryError = void 0;
|
|
33
|
+
if (error instanceof Deno.errors.NotFound) makeDirectoryError = new MakeDirectoryErrorNotFound(error);
|
|
34
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) makeDirectoryError = new MakeDirectoryErrorPermissionDenied(error);
|
|
35
|
+
else if (error instanceof Deno.errors.AlreadyExists) makeDirectoryError = new MakeDirectoryErrorAlreadyExists(error);
|
|
36
|
+
else if (error instanceof Deno.errors.NotADirectory) makeDirectoryError = new MakeDirectoryErrorNotDirectory(error);
|
|
37
|
+
else if (error instanceof Deno.errors.InvalidData) makeDirectoryError = new MakeDirectoryErrorInvalidArgument(error);
|
|
38
|
+
else if (error instanceof Deno.errors.Busy) makeDirectoryError = new MakeDirectoryErrorBusy(error);
|
|
39
|
+
if (makeDirectoryError === void 0) makeDirectoryError = new MakeDirectoryError(error);
|
|
40
|
+
return DEither.left("file-system-make-directory-error", makeDirectoryError);
|
|
26
41
|
}
|
|
27
42
|
const makeDirectory = implementFunction("makeDirectory", {
|
|
28
|
-
NODE: async (path, params) => {
|
|
29
|
-
return (await nodeFileSystem.value).mkdir(path, { recursive: params?.recursive }).then(() => DEither.right("file-system-make-directory")).catch(handleNodeMakeDirectoryError);
|
|
30
|
-
},
|
|
43
|
+
NODE: async (path, params) => nodeFileSystem.value.mkdir(path, { recursive: params?.recursive }).then(() => DEither.right("file-system-make-directory")).catch(handleNodeMakeDirectoryError),
|
|
31
44
|
DENO: (path, params) => Deno.mkdir(path, { recursive: params?.recursive }).then(() => DEither.right("file-system-make-directory")).catch(handleDenoMakeDirectoryError)
|
|
32
45
|
});
|
|
33
46
|
//#endregion
|
|
34
|
-
export { makeDirectory };
|
|
47
|
+
export { MakeDirectoryError, MakeDirectoryErrorAlreadyExists, MakeDirectoryErrorBusy, MakeDirectoryErrorInvalidArgument, MakeDirectoryErrorNoSpace, MakeDirectoryErrorNotDirectory, MakeDirectoryErrorNotFound, MakeDirectoryErrorPermissionDenied, MakeDirectoryErrorReadOnly, MakeDirectoryErrorTooManyOpenFiles, makeDirectory };
|
|
@@ -1,30 +1,48 @@
|
|
|
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/makeTemporaryDirectory.ts
|
|
8
|
+
var MakeTemporaryDirectoryErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-temporary-directory-permission-denied", Error) {};
|
|
9
|
+
var MakeTemporaryDirectoryErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-temporary-directory-not-directory", Error) {};
|
|
10
|
+
var MakeTemporaryDirectoryErrorNoSpace = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-temporary-directory-no-space", Error) {};
|
|
11
|
+
var MakeTemporaryDirectoryErrorReadOnly = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-temporary-directory-read-only", Error) {};
|
|
12
|
+
var MakeTemporaryDirectoryErrorInvalidArgument = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-temporary-directory-invalid-argument", Error) {};
|
|
13
|
+
var MakeTemporaryDirectoryErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-temporary-directory-too-many-open-files", Error) {};
|
|
14
|
+
var MakeTemporaryDirectoryError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-make-temporary-directory-error", Error) {};
|
|
6
15
|
function handleNodeMakeTemporaryDirectoryError(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 makeTemporaryDirectoryError = void 0;
|
|
17
|
+
if ("code" in error) {
|
|
18
|
+
if (error.code === "EACCES" || error.code === "EPERM") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorPermissionDenied(error);
|
|
19
|
+
else if (error.code === "ENOTDIR") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorNotDirectory(error);
|
|
20
|
+
else if (error.code === "ENOSPC") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorNoSpace(error);
|
|
21
|
+
else if (error.code === "EROFS") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorReadOnly(error);
|
|
22
|
+
else if (error.code === "EINVAL") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorInvalidArgument(error);
|
|
23
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorTooManyOpenFiles(error);
|
|
14
24
|
}
|
|
15
|
-
|
|
25
|
+
if (makeTemporaryDirectoryError === void 0) makeTemporaryDirectoryError = new MakeTemporaryDirectoryError(error);
|
|
26
|
+
return _duplojs_lang_either.left("file-system-make-temporary-directory-error", makeTemporaryDirectoryError);
|
|
16
27
|
}
|
|
17
28
|
function handleDenoMakeTemporaryDirectoryError(error) {
|
|
18
|
-
|
|
19
|
-
if (error instanceof Deno.errors.
|
|
20
|
-
if (error instanceof Deno.errors.
|
|
21
|
-
|
|
29
|
+
let makeTemporaryDirectoryError = void 0;
|
|
30
|
+
if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorPermissionDenied(error);
|
|
31
|
+
else if (error instanceof Deno.errors.NotADirectory) makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorNotDirectory(error);
|
|
32
|
+
else if (error instanceof Deno.errors.InvalidData) makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorInvalidArgument(error);
|
|
33
|
+
if (makeTemporaryDirectoryError === void 0) makeTemporaryDirectoryError = new MakeTemporaryDirectoryError(error);
|
|
34
|
+
return _duplojs_lang_either.left("file-system-make-temporary-directory-error", makeTemporaryDirectoryError);
|
|
22
35
|
}
|
|
23
36
|
const makeTemporaryDirectory = require_implementor.implementFunction("makeTemporaryDirectory", {
|
|
24
|
-
NODE: async (prefix) =>
|
|
25
|
-
return (await require_implementor.nodeFileSystem.value).mkdtemp(prefix).then((value) => _duplojs_lang_either.right("file-system-make-temporary-directory", value)).catch(handleNodeMakeTemporaryDirectoryError);
|
|
26
|
-
},
|
|
37
|
+
NODE: async (prefix) => require_implementor.nodeFileSystem.value.mkdtemp(prefix).then((value) => _duplojs_lang_either.right("file-system-make-temporary-directory", value)).catch(handleNodeMakeTemporaryDirectoryError),
|
|
27
38
|
DENO: (prefix) => Deno.makeTempDir({ prefix }).then((value) => _duplojs_lang_either.right("file-system-make-temporary-directory", value)).catch(handleDenoMakeTemporaryDirectoryError)
|
|
28
39
|
});
|
|
29
40
|
//#endregion
|
|
41
|
+
exports.MakeTemporaryDirectoryError = MakeTemporaryDirectoryError;
|
|
42
|
+
exports.MakeTemporaryDirectoryErrorInvalidArgument = MakeTemporaryDirectoryErrorInvalidArgument;
|
|
43
|
+
exports.MakeTemporaryDirectoryErrorNoSpace = MakeTemporaryDirectoryErrorNoSpace;
|
|
44
|
+
exports.MakeTemporaryDirectoryErrorNotDirectory = MakeTemporaryDirectoryErrorNotDirectory;
|
|
45
|
+
exports.MakeTemporaryDirectoryErrorPermissionDenied = MakeTemporaryDirectoryErrorPermissionDenied;
|
|
46
|
+
exports.MakeTemporaryDirectoryErrorReadOnly = MakeTemporaryDirectoryErrorReadOnly;
|
|
47
|
+
exports.MakeTemporaryDirectoryErrorTooManyOpenFiles = MakeTemporaryDirectoryErrorTooManyOpenFiles;
|
|
30
48
|
exports.makeTemporaryDirectory = makeTemporaryDirectory;
|
|
@@ -1,9 +1,32 @@
|
|
|
1
|
-
import { FileSystemEither } from './types';
|
|
2
1
|
import * as DEither from "@duplojs/lang/either";
|
|
3
|
-
|
|
2
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
3
|
+
declare const MakeTemporaryDirectoryErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-temporary-directory-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-temporary-directory-permission-denied", unknown>>, unknown>;
|
|
4
|
+
export declare class MakeTemporaryDirectoryErrorPermissionDenied extends MakeTemporaryDirectoryErrorPermissionDenied_base {
|
|
5
|
+
}
|
|
6
|
+
declare const MakeTemporaryDirectoryErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-temporary-directory-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-temporary-directory-not-directory", unknown>>, unknown>;
|
|
7
|
+
export declare class MakeTemporaryDirectoryErrorNotDirectory extends MakeTemporaryDirectoryErrorNotDirectory_base {
|
|
8
|
+
}
|
|
9
|
+
declare const MakeTemporaryDirectoryErrorNoSpace_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-temporary-directory-no-space", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-temporary-directory-no-space", unknown>>, unknown>;
|
|
10
|
+
export declare class MakeTemporaryDirectoryErrorNoSpace extends MakeTemporaryDirectoryErrorNoSpace_base {
|
|
11
|
+
}
|
|
12
|
+
declare const MakeTemporaryDirectoryErrorReadOnly_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-temporary-directory-read-only", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-temporary-directory-read-only", unknown>>, unknown>;
|
|
13
|
+
export declare class MakeTemporaryDirectoryErrorReadOnly extends MakeTemporaryDirectoryErrorReadOnly_base {
|
|
14
|
+
}
|
|
15
|
+
declare const MakeTemporaryDirectoryErrorInvalidArgument_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-temporary-directory-invalid-argument", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-temporary-directory-invalid-argument", unknown>>, unknown>;
|
|
16
|
+
export declare class MakeTemporaryDirectoryErrorInvalidArgument extends MakeTemporaryDirectoryErrorInvalidArgument_base {
|
|
17
|
+
}
|
|
18
|
+
declare const MakeTemporaryDirectoryErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-temporary-directory-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-make-temporary-directory-too-many-open-files", unknown>>, unknown>;
|
|
19
|
+
export declare class MakeTemporaryDirectoryErrorTooManyOpenFiles extends MakeTemporaryDirectoryErrorTooManyOpenFiles_base {
|
|
20
|
+
}
|
|
21
|
+
declare const MakeTemporaryDirectoryError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-make-temporary-directory-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-make-temporary-directory-error", unknown>>, unknown>;
|
|
22
|
+
export declare class MakeTemporaryDirectoryError extends MakeTemporaryDirectoryError_base {
|
|
23
|
+
}
|
|
24
|
+
export type MakeTemporaryDirectoryErrors = (MakeTemporaryDirectoryErrorPermissionDenied | MakeTemporaryDirectoryErrorNotDirectory | MakeTemporaryDirectoryErrorNoSpace | MakeTemporaryDirectoryErrorReadOnly | MakeTemporaryDirectoryErrorInvalidArgument | MakeTemporaryDirectoryErrorTooManyOpenFiles | MakeTemporaryDirectoryError);
|
|
25
|
+
export type MakeTemporaryDirectoryResult = (DEither.Right<"file-system-make-temporary-directory", string> | DEither.Left<"file-system-make-temporary-directory-error", MakeTemporaryDirectoryErrors>);
|
|
4
26
|
declare module '../implementor' {
|
|
5
27
|
interface ServerFunction {
|
|
6
28
|
makeTemporaryDirectory(prefix: string): Promise<MakeTemporaryDirectoryResult>;
|
|
7
29
|
}
|
|
8
30
|
}
|
|
9
31
|
export declare const makeTemporaryDirectory: (prefix: string) => Promise<MakeTemporaryDirectoryResult>;
|
|
32
|
+
export {};
|
|
@@ -1,28 +1,38 @@
|
|
|
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/makeTemporaryDirectory.ts
|
|
5
|
+
var MakeTemporaryDirectoryErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-make-temporary-directory-permission-denied", Error) {};
|
|
6
|
+
var MakeTemporaryDirectoryErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-make-temporary-directory-not-directory", Error) {};
|
|
7
|
+
var MakeTemporaryDirectoryErrorNoSpace = class extends DCommon.DuploJSError.parentClass("file-system-make-temporary-directory-no-space", Error) {};
|
|
8
|
+
var MakeTemporaryDirectoryErrorReadOnly = class extends DCommon.DuploJSError.parentClass("file-system-make-temporary-directory-read-only", Error) {};
|
|
9
|
+
var MakeTemporaryDirectoryErrorInvalidArgument = class extends DCommon.DuploJSError.parentClass("file-system-make-temporary-directory-invalid-argument", Error) {};
|
|
10
|
+
var MakeTemporaryDirectoryErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-make-temporary-directory-too-many-open-files", Error) {};
|
|
11
|
+
var MakeTemporaryDirectoryError = class extends DCommon.DuploJSError.parentClass("file-system-make-temporary-directory-error", Error) {};
|
|
4
12
|
function handleNodeMakeTemporaryDirectoryError(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 makeTemporaryDirectoryError = void 0;
|
|
14
|
+
if ("code" in error) {
|
|
15
|
+
if (error.code === "EACCES" || error.code === "EPERM") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorPermissionDenied(error);
|
|
16
|
+
else if (error.code === "ENOTDIR") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorNotDirectory(error);
|
|
17
|
+
else if (error.code === "ENOSPC") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorNoSpace(error);
|
|
18
|
+
else if (error.code === "EROFS") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorReadOnly(error);
|
|
19
|
+
else if (error.code === "EINVAL") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorInvalidArgument(error);
|
|
20
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorTooManyOpenFiles(error);
|
|
12
21
|
}
|
|
13
|
-
|
|
22
|
+
if (makeTemporaryDirectoryError === void 0) makeTemporaryDirectoryError = new MakeTemporaryDirectoryError(error);
|
|
23
|
+
return DEither.left("file-system-make-temporary-directory-error", makeTemporaryDirectoryError);
|
|
14
24
|
}
|
|
15
25
|
function handleDenoMakeTemporaryDirectoryError(error) {
|
|
16
|
-
|
|
17
|
-
if (error instanceof Deno.errors.
|
|
18
|
-
if (error instanceof Deno.errors.
|
|
19
|
-
|
|
26
|
+
let makeTemporaryDirectoryError = void 0;
|
|
27
|
+
if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorPermissionDenied(error);
|
|
28
|
+
else if (error instanceof Deno.errors.NotADirectory) makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorNotDirectory(error);
|
|
29
|
+
else if (error instanceof Deno.errors.InvalidData) makeTemporaryDirectoryError = new MakeTemporaryDirectoryErrorInvalidArgument(error);
|
|
30
|
+
if (makeTemporaryDirectoryError === void 0) makeTemporaryDirectoryError = new MakeTemporaryDirectoryError(error);
|
|
31
|
+
return DEither.left("file-system-make-temporary-directory-error", makeTemporaryDirectoryError);
|
|
20
32
|
}
|
|
21
33
|
const makeTemporaryDirectory = implementFunction("makeTemporaryDirectory", {
|
|
22
|
-
NODE: async (prefix) =>
|
|
23
|
-
return (await nodeFileSystem.value).mkdtemp(prefix).then((value) => DEither.right("file-system-make-temporary-directory", value)).catch(handleNodeMakeTemporaryDirectoryError);
|
|
24
|
-
},
|
|
34
|
+
NODE: async (prefix) => nodeFileSystem.value.mkdtemp(prefix).then((value) => DEither.right("file-system-make-temporary-directory", value)).catch(handleNodeMakeTemporaryDirectoryError),
|
|
25
35
|
DENO: (prefix) => Deno.makeTempDir({ prefix }).then((value) => DEither.right("file-system-make-temporary-directory", value)).catch(handleDenoMakeTemporaryDirectoryError)
|
|
26
36
|
});
|
|
27
37
|
//#endregion
|
|
28
|
-
export { makeTemporaryDirectory };
|
|
38
|
+
export { MakeTemporaryDirectoryError, MakeTemporaryDirectoryErrorInvalidArgument, MakeTemporaryDirectoryErrorNoSpace, MakeTemporaryDirectoryErrorNotDirectory, MakeTemporaryDirectoryErrorPermissionDenied, MakeTemporaryDirectoryErrorReadOnly, MakeTemporaryDirectoryErrorTooManyOpenFiles, makeTemporaryDirectory };
|