@duplojs/server 0.0.0-stage → 0.1.0-beta.10
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/README.md +8 -2
- package/dist/_virtual/_rolldown/runtime.cjs +33 -0
- package/dist/_virtual/_rolldown/runtime.mjs +17 -0
- package/dist/command/argument.cjs +27 -0
- package/dist/command/argument.d.ts +18 -0
- package/dist/command/argument.mjs +24 -0
- package/dist/command/create.cjs +102 -0
- package/dist/command/create.d.ts +47 -0
- package/dist/command/create.mjs +96 -0
- package/dist/command/error.cjs +206 -0
- package/dist/command/error.d.ts +61 -0
- package/dist/command/error.mjs +193 -0
- package/dist/command/exec.cjs +19 -0
- package/dist/command/exec.d.ts +14 -0
- package/dist/command/exec.mjs +17 -0
- package/dist/command/execOptions.cjs +41 -0
- package/dist/command/execOptions.d.ts +14 -0
- package/dist/command/execOptions.mjs +37 -0
- package/dist/command/help.cjs +250 -0
- package/dist/command/help.d.ts +10 -0
- package/dist/command/help.mjs +237 -0
- package/dist/command/index.cjs +82 -0
- package/dist/command/index.d.ts +8 -0
- package/dist/command/index.mjs +47 -0
- package/dist/command/kind.cjs +7 -0
- package/dist/command/kind.d.ts +2 -0
- package/dist/command/kind.mjs +5 -0
- package/dist/command/options/base.cjs +76 -0
- package/dist/command/options/base.d.ts +30 -0
- package/dist/command/options/base.mjs +69 -0
- package/dist/command/options/defaults/array.cjs +35 -0
- package/dist/command/options/defaults/array.d.ts +26 -0
- package/dist/command/options/defaults/array.mjs +29 -0
- package/dist/command/options/defaults/boolean.cjs +28 -0
- package/dist/command/options/defaults/boolean.d.ts +14 -0
- package/dist/command/options/defaults/boolean.mjs +25 -0
- package/dist/command/options/defaults/index.d.ts +3 -0
- package/dist/command/options/defaults/simple.cjs +25 -0
- package/dist/command/options/defaults/simple.d.ts +18 -0
- package/dist/command/options/defaults/simple.mjs +22 -0
- package/dist/command/options/identifier.cjs +7 -0
- package/dist/command/options/identifier.d.ts +4 -0
- package/dist/command/options/identifier.mjs +5 -0
- package/dist/command/options/index.d.ts +4 -0
- package/dist/command/options/types/index.d.ts +1 -0
- package/dist/command/options/types/options.d.ts +9 -0
- package/dist/command/types/eligibleType.d.ts +4 -0
- package/dist/command/types/forbiddenDuplicateName.d.ts +11 -0
- package/dist/command/types/forbiddenInvalidIdentifier.d.ts +6 -0
- package/dist/command/types/index.d.ts +3 -0
- package/dist/common/environmentVariable/expandEnvironmentVariables.cjs +27 -0
- package/dist/common/environmentVariable/expandEnvironmentVariables.d.ts +2 -0
- package/dist/common/environmentVariable/expandEnvironmentVariables.mjs +22 -0
- package/dist/common/environmentVariable/index.cjs +47 -0
- package/dist/common/environmentVariable/index.d.ts +16 -0
- package/dist/common/environmentVariable/index.mjs +41 -0
- package/dist/common/environmentVariable/overrideEnvironmentVariables.cjs +13 -0
- package/dist/common/environmentVariable/overrideEnvironmentVariables.d.ts +3 -0
- package/dist/common/environmentVariable/overrideEnvironmentVariables.mjs +9 -0
- package/dist/common/environmentVariable/parseEnvironmentFiles.cjs +32 -0
- package/dist/common/environmentVariable/parseEnvironmentFiles.d.ts +5 -0
- package/dist/common/environmentVariable/parseEnvironmentFiles.mjs +26 -0
- package/dist/common/environmentVariableOrThrow.cjs +23 -0
- package/dist/common/environmentVariableOrThrow.d.ts +12 -0
- package/dist/common/environmentVariableOrThrow.mjs +19 -0
- package/dist/common/exitProcess.cjs +7 -0
- package/dist/common/exitProcess.d.ts +6 -0
- package/dist/common/exitProcess.mjs +8 -0
- package/dist/common/getCurrentWorkDirectory.cjs +15 -0
- package/dist/common/getCurrentWorkDirectory.d.ts +8 -0
- package/dist/common/getCurrentWorkDirectory.mjs +11 -0
- package/dist/common/getCurrentWorkDirectoryOrThrow.cjs +25 -0
- package/dist/common/getCurrentWorkDirectoryOrThrow.d.ts +8 -0
- package/dist/common/getCurrentWorkDirectoryOrThrow.mjs +20 -0
- package/dist/common/getProcessArguments.cjs +18 -0
- package/dist/common/getProcessArguments.d.ts +6 -0
- package/dist/common/getProcessArguments.mjs +18 -0
- package/dist/common/index.cjs +44 -0
- package/dist/common/index.d.ts +9 -0
- package/dist/common/index.mjs +27 -0
- 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/common/setCurrentWorkingDirectory.cjs +11 -0
- package/dist/common/setCurrentWorkingDirectory.d.ts +8 -0
- package/dist/common/setCurrentWorkingDirectory.mjs +9 -0
- package/dist/common/setCurrentWorkingDirectoryOrThrow.cjs +23 -0
- package/dist/common/setCurrentWorkingDirectoryOrThrow.d.ts +8 -0
- package/dist/common/setCurrentWorkingDirectoryOrThrow.mjs +18 -0
- package/dist/dataStructure/common/codec/defaults/index.d.ts +2 -0
- package/dist/dataStructure/common/codec/defaults/json.cjs +25 -0
- package/dist/dataStructure/common/codec/defaults/json.d.ts +9 -0
- package/dist/dataStructure/common/codec/defaults/json.mjs +22 -0
- package/dist/dataStructure/common/codec/defaults/string.cjs +25 -0
- package/dist/dataStructure/common/codec/defaults/string.d.ts +13 -0
- package/dist/dataStructure/common/codec/defaults/string.mjs +22 -0
- package/dist/dataStructure/common/codec/index.d.ts +1 -0
- package/dist/dataStructure/common/error/defaultInterpreter.cjs +29 -0
- package/dist/dataStructure/common/error/defaultInterpreter.d.ts +69 -0
- package/dist/dataStructure/common/error/defaultInterpreter.mjs +26 -0
- package/dist/dataStructure/common/error/index.d.ts +1 -0
- package/dist/dataStructure/common/index.d.ts +2 -0
- package/dist/dataStructure/constraint/fileExist.cjs +19 -0
- package/dist/dataStructure/constraint/fileExist.d.ts +10 -0
- package/dist/dataStructure/constraint/fileExist.mjs +15 -0
- 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 +5 -0
- package/dist/dataStructure/constraint/mimeType.cjs +18 -0
- package/dist/dataStructure/constraint/mimeType.d.ts +11 -0
- package/dist/dataStructure/constraint/mimeType.mjs +14 -0
- package/dist/dataStructure/constraint/size.cjs +29 -0
- package/dist/dataStructure/constraint/size.d.ts +16 -0
- package/dist/dataStructure/constraint/size.mjs +24 -0
- package/dist/dataStructure/constraint/types/constraints.d.ts +12 -0
- package/dist/dataStructure/constraint/types/index.d.ts +1 -0
- package/dist/dataStructure/fundamentalType/file.cjs +11 -0
- package/dist/dataStructure/fundamentalType/file.d.ts +8 -0
- package/dist/dataStructure/fundamentalType/file.mjs +8 -0
- 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 +3 -0
- package/dist/dataStructure/fundamentalType/types/fundamentalTypes.d.ts +8 -0
- package/dist/dataStructure/fundamentalType/types/index.d.ts +1 -0
- package/dist/dataStructure/helper/file.cjs +10 -0
- package/dist/dataStructure/helper/file.d.ts +3 -0
- package/dist/dataStructure/helper/file.mjs +8 -0
- 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 +6 -0
- package/dist/dataStructure/helper/mimeType.cjs +7 -0
- package/dist/dataStructure/helper/mimeType.d.ts +2 -0
- package/dist/dataStructure/helper/mimeType.mjs +7 -0
- package/dist/dataStructure/helper/size.cjs +7 -0
- package/dist/dataStructure/helper/size.d.ts +2 -0
- package/dist/dataStructure/helper/size.mjs +7 -0
- package/dist/dataStructure/index.cjs +83 -0
- package/dist/dataStructure/index.d.ts +6 -0
- package/dist/dataStructure/index.mjs +51 -0
- package/dist/dataStructure/kind.cjs +7 -0
- package/dist/dataStructure/kind.d.ts +2 -0
- package/dist/dataStructure/kind.mjs +5 -0
- package/dist/dataStructure/type/file.cjs +14 -0
- package/dist/dataStructure/type/file.d.ts +11 -0
- package/dist/dataStructure/type/file.mjs +11 -0
- 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 +3 -0
- package/dist/dataStructure/type/types/index.d.ts +1 -0
- package/dist/dataStructure/type/types/types.d.ts +8 -0
- package/dist/file/appendFile.cjs +67 -0
- package/dist/file/appendFile.d.ts +43 -0
- package/dist/file/appendFile.mjs +54 -0
- package/dist/file/appendTextFile.cjs +67 -0
- package/dist/file/appendTextFile.d.ts +43 -0
- package/dist/file/appendTextFile.mjs +54 -0
- package/dist/file/copy.cjs +53 -0
- package/dist/file/copy.d.ts +43 -0
- package/dist/file/copy.mjs +40 -0
- package/dist/file/createEntryInterface.cjs +19 -0
- package/dist/file/createEntryInterface.d.ts +3 -0
- package/dist/file/createEntryInterface.mjs +15 -0
- package/dist/file/ensureDirectory.cjs +52 -0
- package/dist/file/ensureDirectory.d.ts +36 -0
- package/dist/file/ensureDirectory.mjs +41 -0
- package/dist/file/ensureFile.cjs +60 -0
- package/dist/file/ensureFile.d.ts +39 -0
- package/dist/file/ensureFile.mjs +48 -0
- package/dist/file/exists.cjs +43 -0
- package/dist/file/exists.d.ts +27 -0
- package/dist/file/exists.mjs +35 -0
- package/dist/file/fileInterface.cjs +76 -0
- package/dist/file/fileInterface.d.ts +31 -0
- package/dist/file/fileInterface.mjs +70 -0
- package/dist/file/folderInterface.cjs +76 -0
- package/dist/file/folderInterface.d.ts +33 -0
- package/dist/file/folderInterface.mjs +70 -0
- package/dist/file/index.cjs +634 -0
- package/dist/file/index.d.ts +35 -0
- package/dist/file/index.mjs +335 -0
- package/dist/file/link.cjs +70 -0
- package/dist/file/link.d.ts +46 -0
- package/dist/file/link.mjs +56 -0
- package/dist/file/linkStat.cjs +98 -0
- package/dist/file/linkStat.d.ts +31 -0
- package/dist/file/linkStat.mjs +88 -0
- package/dist/file/makeDirectory.cjs +60 -0
- package/dist/file/makeDirectory.d.ts +45 -0
- package/dist/file/makeDirectory.mjs +47 -0
- package/dist/file/makeTemporaryDirectory.cjs +48 -0
- package/dist/file/makeTemporaryDirectory.d.ts +32 -0
- package/dist/file/makeTemporaryDirectory.mjs +38 -0
- package/dist/file/makeTemporaryFile.cjs +62 -0
- package/dist/file/makeTemporaryFile.d.ts +36 -0
- package/dist/file/makeTemporaryFile.mjs +50 -0
- package/dist/file/move.cjs +71 -0
- package/dist/file/move.d.ts +46 -0
- package/dist/file/move.mjs +57 -0
- package/dist/file/readDirectory.cjs +44 -0
- package/dist/file/readDirectory.d.ts +35 -0
- package/dist/file/readDirectory.mjs +33 -0
- package/dist/file/readFile.cjs +51 -0
- package/dist/file/readFile.d.ts +33 -0
- package/dist/file/readFile.mjs +41 -0
- package/dist/file/readJsonFile.cjs +51 -0
- package/dist/file/readJsonFile.d.ts +33 -0
- package/dist/file/readJsonFile.mjs +41 -0
- package/dist/file/readLink.cjs +46 -0
- package/dist/file/readLink.d.ts +30 -0
- package/dist/file/readLink.mjs +37 -0
- package/dist/file/readTextFile.cjs +51 -0
- package/dist/file/readTextFile.d.ts +33 -0
- package/dist/file/readTextFile.mjs +41 -0
- package/dist/file/realPath.cjs +42 -0
- package/dist/file/realPath.d.ts +27 -0
- package/dist/file/realPath.mjs +34 -0
- package/dist/file/relocate.cjs +83 -0
- package/dist/file/relocate.d.ts +46 -0
- package/dist/file/relocate.mjs +68 -0
- package/dist/file/remove.cjs +60 -0
- package/dist/file/remove.d.ts +42 -0
- package/dist/file/remove.mjs +48 -0
- package/dist/file/rename.cjs +83 -0
- package/dist/file/rename.d.ts +46 -0
- package/dist/file/rename.mjs +68 -0
- package/dist/file/setMode.cjs +65 -0
- package/dist/file/setMode.d.ts +45 -0
- package/dist/file/setMode.mjs +56 -0
- package/dist/file/setOwner.cjs +53 -0
- package/dist/file/setOwner.d.ts +35 -0
- package/dist/file/setOwner.mjs +44 -0
- package/dist/file/setTime.cjs +55 -0
- package/dist/file/setTime.d.ts +36 -0
- package/dist/file/setTime.mjs +45 -0
- package/dist/file/stat.cjs +99 -0
- package/dist/file/stat.d.ts +62 -0
- package/dist/file/stat.mjs +89 -0
- package/dist/file/symlink.cjs +64 -0
- package/dist/file/symlink.d.ts +48 -0
- package/dist/file/symlink.mjs +52 -0
- package/dist/file/truncate.cjs +60 -0
- package/dist/file/truncate.d.ts +42 -0
- package/dist/file/truncate.mjs +47 -0
- package/dist/file/unknownEntryInterface.cjs +40 -0
- package/dist/file/unknownEntryInterface.d.ts +17 -0
- package/dist/file/unknownEntryInterface.mjs +35 -0
- package/dist/file/walkDirectory.cjs +57 -0
- package/dist/file/walkDirectory.d.ts +37 -0
- package/dist/file/walkDirectory.mjs +45 -0
- package/dist/file/writeFile.cjs +68 -0
- package/dist/file/writeFile.d.ts +43 -0
- package/dist/file/writeFile.mjs +55 -0
- package/dist/file/writeJsonFile.cjs +77 -0
- package/dist/file/writeJsonFile.d.ts +46 -0
- package/dist/file/writeJsonFile.mjs +64 -0
- package/dist/file/writeTextFile.cjs +68 -0
- package/dist/file/writeTextFile.d.ts +43 -0
- package/dist/file/writeTextFile.mjs +55 -0
- package/dist/implementor.cjs +67 -0
- package/dist/implementor.d.ts +35 -0
- package/dist/implementor.mjs +55 -0
- package/dist/index.cjs +76 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +15 -0
- package/dist/kind.cjs +7 -0
- package/dist/kind.d.ts +2 -0
- package/dist/kind.mjs +5 -0
- package/dist/override.d.ts +8 -0
- package/package.json +81 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
2
|
+
import * as DEither from "@duplojs/lang/either";
|
|
3
|
+
import type * as DPath from "@duplojs/lang/path";
|
|
4
|
+
export interface SymlinkParams {
|
|
5
|
+
/**
|
|
6
|
+
* @remarks
|
|
7
|
+
* Specify the symbolic link type as file, directory or NTFS junction.
|
|
8
|
+
* This option only applies to Windows and is ignored on other operating systems.
|
|
9
|
+
*/
|
|
10
|
+
type: "file" | "dir" | "junction";
|
|
11
|
+
}
|
|
12
|
+
declare const SymlinkErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-symlink-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-symlink-not-found", unknown>>, unknown>;
|
|
13
|
+
export declare class SymlinkErrorNotFound extends SymlinkErrorNotFound_base {
|
|
14
|
+
}
|
|
15
|
+
declare const SymlinkErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-symlink-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-symlink-permission-denied", unknown>>, unknown>;
|
|
16
|
+
export declare class SymlinkErrorPermissionDenied extends SymlinkErrorPermissionDenied_base {
|
|
17
|
+
}
|
|
18
|
+
declare const SymlinkErrorAlreadyExists_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-symlink-already-exists", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-symlink-already-exists", unknown>>, unknown>;
|
|
19
|
+
export declare class SymlinkErrorAlreadyExists extends SymlinkErrorAlreadyExists_base {
|
|
20
|
+
}
|
|
21
|
+
declare const SymlinkErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-symlink-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-symlink-not-directory", unknown>>, unknown>;
|
|
22
|
+
export declare class SymlinkErrorNotDirectory extends SymlinkErrorNotDirectory_base {
|
|
23
|
+
}
|
|
24
|
+
declare const SymlinkErrorReadOnly_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-symlink-read-only", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-symlink-read-only", unknown>>, unknown>;
|
|
25
|
+
export declare class SymlinkErrorReadOnly extends SymlinkErrorReadOnly_base {
|
|
26
|
+
}
|
|
27
|
+
declare const SymlinkErrorInvalidArgument_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-symlink-invalid-argument", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-symlink-invalid-argument", unknown>>, unknown>;
|
|
28
|
+
export declare class SymlinkErrorInvalidArgument extends SymlinkErrorInvalidArgument_base {
|
|
29
|
+
}
|
|
30
|
+
declare const SymlinkErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-symlink-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-symlink-too-many-open-files", unknown>>, unknown>;
|
|
31
|
+
export declare class SymlinkErrorTooManyOpenFiles extends SymlinkErrorTooManyOpenFiles_base {
|
|
32
|
+
}
|
|
33
|
+
declare const SymlinkErrorBusy_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-symlink-busy", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-symlink-busy", unknown>>, unknown>;
|
|
34
|
+
export declare class SymlinkErrorBusy extends SymlinkErrorBusy_base {
|
|
35
|
+
}
|
|
36
|
+
declare const SymlinkError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-symlink-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-symlink-error", unknown>>, unknown>;
|
|
37
|
+
export declare class SymlinkError extends SymlinkError_base {
|
|
38
|
+
}
|
|
39
|
+
export type SymlinkErrors = (SymlinkErrorNotFound | SymlinkErrorPermissionDenied | SymlinkErrorAlreadyExists | SymlinkErrorNotDirectory | SymlinkErrorReadOnly | SymlinkErrorInvalidArgument | SymlinkErrorTooManyOpenFiles | SymlinkErrorBusy | SymlinkError);
|
|
40
|
+
export type SymlinkResult = (DEither.Right<"file-system-symlink", void> | DEither.Left<"file-system-symlink-error", SymlinkErrors>);
|
|
41
|
+
declare module '../implementor' {
|
|
42
|
+
interface ServerFunction {
|
|
43
|
+
symlink(oldPath: DPath.AnyPath, newPath: DPath.AnyPath, params?: SymlinkParams): Promise<SymlinkResult>;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export declare function symlink(newPath: DPath.AnyPath): (oldPath: DPath.AnyPath) => Promise<SymlinkResult>;
|
|
47
|
+
export declare function symlink(oldPath: DPath.AnyPath, newPath: DPath.AnyPath, params?: SymlinkParams): Promise<SymlinkResult>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { implementFunction, nodeFileSystem } from "../implementor.mjs";
|
|
2
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
3
|
+
import * as DEither from "@duplojs/lang/either";
|
|
4
|
+
//#region scripts/file/symlink.ts
|
|
5
|
+
var SymlinkErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-symlink-not-found", Error) {};
|
|
6
|
+
var SymlinkErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-symlink-permission-denied", Error) {};
|
|
7
|
+
var SymlinkErrorAlreadyExists = class extends DCommon.DuploJSError.parentClass("file-system-symlink-already-exists", Error) {};
|
|
8
|
+
var SymlinkErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-symlink-not-directory", Error) {};
|
|
9
|
+
var SymlinkErrorReadOnly = class extends DCommon.DuploJSError.parentClass("file-system-symlink-read-only", Error) {};
|
|
10
|
+
var SymlinkErrorInvalidArgument = class extends DCommon.DuploJSError.parentClass("file-system-symlink-invalid-argument", Error) {};
|
|
11
|
+
var SymlinkErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-symlink-too-many-open-files", Error) {};
|
|
12
|
+
var SymlinkErrorBusy = class extends DCommon.DuploJSError.parentClass("file-system-symlink-busy", Error) {};
|
|
13
|
+
var SymlinkError = class extends DCommon.DuploJSError.parentClass("file-system-symlink-error", Error) {};
|
|
14
|
+
function handleNodeSymlinkError(error) {
|
|
15
|
+
let symlinkError = void 0;
|
|
16
|
+
if ("code" in error) {
|
|
17
|
+
if (error.code === "ENOENT") symlinkError = new SymlinkErrorNotFound(error);
|
|
18
|
+
else if (error.code === "EACCES" || error.code === "EPERM") symlinkError = new SymlinkErrorPermissionDenied(error);
|
|
19
|
+
else if (error.code === "EEXIST") symlinkError = new SymlinkErrorAlreadyExists(error);
|
|
20
|
+
else if (error.code === "ENOTDIR") symlinkError = new SymlinkErrorNotDirectory(error);
|
|
21
|
+
else if (error.code === "EROFS") symlinkError = new SymlinkErrorReadOnly(error);
|
|
22
|
+
else if (error.code === "EINVAL") symlinkError = new SymlinkErrorInvalidArgument(error);
|
|
23
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") symlinkError = new SymlinkErrorTooManyOpenFiles(error);
|
|
24
|
+
else if (error.code === "EBUSY") symlinkError = new SymlinkErrorBusy(error);
|
|
25
|
+
}
|
|
26
|
+
if (symlinkError === void 0) symlinkError = new SymlinkError(error);
|
|
27
|
+
return DEither.left("file-system-symlink-error", symlinkError);
|
|
28
|
+
}
|
|
29
|
+
function handleDenoSymlinkError(error) {
|
|
30
|
+
let symlinkError = void 0;
|
|
31
|
+
if (error instanceof Deno.errors.NotFound) symlinkError = new SymlinkErrorNotFound(error);
|
|
32
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) symlinkError = new SymlinkErrorPermissionDenied(error);
|
|
33
|
+
else if (error instanceof Deno.errors.AlreadyExists) symlinkError = new SymlinkErrorAlreadyExists(error);
|
|
34
|
+
else if (error instanceof Deno.errors.NotADirectory) symlinkError = new SymlinkErrorNotDirectory(error);
|
|
35
|
+
else if (error instanceof Deno.errors.InvalidData) symlinkError = new SymlinkErrorInvalidArgument(error);
|
|
36
|
+
else if (error instanceof Deno.errors.Busy) symlinkError = new SymlinkErrorBusy(error);
|
|
37
|
+
if (symlinkError === void 0) symlinkError = new SymlinkError(error);
|
|
38
|
+
return DEither.left("file-system-symlink-error", symlinkError);
|
|
39
|
+
}
|
|
40
|
+
const symlinkImplementation = implementFunction("symlink", {
|
|
41
|
+
NODE: async (oldPath, newPath, params) => nodeFileSystem.value.symlink(oldPath, newPath, params?.type).then(() => DEither.right("file-system-symlink")).catch(handleNodeSymlinkError),
|
|
42
|
+
DENO: (oldPath, newPath, params) => Deno.symlink(oldPath, newPath, params).then(() => DEither.right("file-system-symlink")).catch(handleDenoSymlinkError)
|
|
43
|
+
});
|
|
44
|
+
function symlink(...args) {
|
|
45
|
+
if (args.length === 1) {
|
|
46
|
+
const [newPath] = args;
|
|
47
|
+
return (oldPath) => symlinkImplementation(oldPath, newPath);
|
|
48
|
+
}
|
|
49
|
+
return symlinkImplementation(...args);
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { SymlinkError, SymlinkErrorAlreadyExists, SymlinkErrorBusy, SymlinkErrorInvalidArgument, SymlinkErrorNotDirectory, SymlinkErrorNotFound, SymlinkErrorPermissionDenied, SymlinkErrorReadOnly, SymlinkErrorTooManyOpenFiles, symlink };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
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);
|
|
5
|
+
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
6
|
+
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
7
|
+
//#region scripts/file/truncate.ts
|
|
8
|
+
var TruncateErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-truncate-not-found", Error) {};
|
|
9
|
+
var TruncateErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-truncate-permission-denied", Error) {};
|
|
10
|
+
var TruncateErrorIsDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-truncate-is-directory", Error) {};
|
|
11
|
+
var TruncateErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-truncate-not-directory", Error) {};
|
|
12
|
+
var TruncateErrorNoSpace = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-truncate-no-space", Error) {};
|
|
13
|
+
var TruncateErrorReadOnly = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-truncate-read-only", Error) {};
|
|
14
|
+
var TruncateErrorInvalidArgument = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-truncate-invalid-argument", Error) {};
|
|
15
|
+
var TruncateErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-truncate-too-many-open-files", Error) {};
|
|
16
|
+
var TruncateErrorBusy = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-truncate-busy", Error) {};
|
|
17
|
+
var TruncateError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-truncate-error", Error) {};
|
|
18
|
+
function handleNodeTruncateError(error) {
|
|
19
|
+
let truncateError = void 0;
|
|
20
|
+
if ("code" in error) {
|
|
21
|
+
if (error.code === "ENOENT") truncateError = new TruncateErrorNotFound(error);
|
|
22
|
+
else if (error.code === "EACCES" || error.code === "EPERM") truncateError = new TruncateErrorPermissionDenied(error);
|
|
23
|
+
else if (error.code === "EISDIR") truncateError = new TruncateErrorIsDirectory(error);
|
|
24
|
+
else if (error.code === "ENOTDIR") truncateError = new TruncateErrorNotDirectory(error);
|
|
25
|
+
else if (error.code === "ENOSPC") truncateError = new TruncateErrorNoSpace(error);
|
|
26
|
+
else if (error.code === "EROFS") truncateError = new TruncateErrorReadOnly(error);
|
|
27
|
+
else if (error.code === "EINVAL") truncateError = new TruncateErrorInvalidArgument(error);
|
|
28
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") truncateError = new TruncateErrorTooManyOpenFiles(error);
|
|
29
|
+
else if (error.code === "EBUSY") truncateError = new TruncateErrorBusy(error);
|
|
30
|
+
}
|
|
31
|
+
if (truncateError === void 0) truncateError = new TruncateError(error);
|
|
32
|
+
return _duplojs_lang_either.left("file-system-truncate-error", truncateError);
|
|
33
|
+
}
|
|
34
|
+
function handleDenoTruncateError(error) {
|
|
35
|
+
let truncateError = void 0;
|
|
36
|
+
if (error instanceof Deno.errors.NotFound) truncateError = new TruncateErrorNotFound(error);
|
|
37
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) truncateError = new TruncateErrorPermissionDenied(error);
|
|
38
|
+
else if (error instanceof Deno.errors.IsADirectory) truncateError = new TruncateErrorIsDirectory(error);
|
|
39
|
+
else if (error instanceof Deno.errors.NotADirectory) truncateError = new TruncateErrorNotDirectory(error);
|
|
40
|
+
else if (error instanceof Deno.errors.InvalidData) truncateError = new TruncateErrorInvalidArgument(error);
|
|
41
|
+
else if (error instanceof Deno.errors.Busy) truncateError = new TruncateErrorBusy(error);
|
|
42
|
+
if (truncateError === void 0) truncateError = new TruncateError(error);
|
|
43
|
+
return _duplojs_lang_either.left("file-system-truncate-error", truncateError);
|
|
44
|
+
}
|
|
45
|
+
const truncate = require_implementor.implementFunction("truncate", {
|
|
46
|
+
NODE: async (path, size) => require_implementor.nodeFileSystem.value.truncate(path, size).then(() => _duplojs_lang_either.right("file-system-truncate")).catch(handleNodeTruncateError),
|
|
47
|
+
DENO: (path, size) => _duplojs_lang_common.pipe(path, _duplojs_lang_common.when(_duplojs_lang_common.instanceOf(URL), ({ pathname }) => decodeURIComponent(pathname)), (stringPath) => Deno.truncate(stringPath, size).then(() => _duplojs_lang_either.right("file-system-truncate")).catch(handleDenoTruncateError))
|
|
48
|
+
});
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.TruncateError = TruncateError;
|
|
51
|
+
exports.TruncateErrorBusy = TruncateErrorBusy;
|
|
52
|
+
exports.TruncateErrorInvalidArgument = TruncateErrorInvalidArgument;
|
|
53
|
+
exports.TruncateErrorIsDirectory = TruncateErrorIsDirectory;
|
|
54
|
+
exports.TruncateErrorNoSpace = TruncateErrorNoSpace;
|
|
55
|
+
exports.TruncateErrorNotDirectory = TruncateErrorNotDirectory;
|
|
56
|
+
exports.TruncateErrorNotFound = TruncateErrorNotFound;
|
|
57
|
+
exports.TruncateErrorPermissionDenied = TruncateErrorPermissionDenied;
|
|
58
|
+
exports.TruncateErrorReadOnly = TruncateErrorReadOnly;
|
|
59
|
+
exports.TruncateErrorTooManyOpenFiles = TruncateErrorTooManyOpenFiles;
|
|
60
|
+
exports.truncate = truncate;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
2
|
+
import * as DEither from "@duplojs/lang/either";
|
|
3
|
+
import type * as DPath from "@duplojs/lang/path";
|
|
4
|
+
declare const TruncateErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-truncate-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-truncate-not-found", unknown>>, unknown>;
|
|
5
|
+
export declare class TruncateErrorNotFound extends TruncateErrorNotFound_base {
|
|
6
|
+
}
|
|
7
|
+
declare const TruncateErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-truncate-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-truncate-permission-denied", unknown>>, unknown>;
|
|
8
|
+
export declare class TruncateErrorPermissionDenied extends TruncateErrorPermissionDenied_base {
|
|
9
|
+
}
|
|
10
|
+
declare const TruncateErrorIsDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-truncate-is-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-truncate-is-directory", unknown>>, unknown>;
|
|
11
|
+
export declare class TruncateErrorIsDirectory extends TruncateErrorIsDirectory_base {
|
|
12
|
+
}
|
|
13
|
+
declare const TruncateErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-truncate-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-truncate-not-directory", unknown>>, unknown>;
|
|
14
|
+
export declare class TruncateErrorNotDirectory extends TruncateErrorNotDirectory_base {
|
|
15
|
+
}
|
|
16
|
+
declare const TruncateErrorNoSpace_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-truncate-no-space", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-truncate-no-space", unknown>>, unknown>;
|
|
17
|
+
export declare class TruncateErrorNoSpace extends TruncateErrorNoSpace_base {
|
|
18
|
+
}
|
|
19
|
+
declare const TruncateErrorReadOnly_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-truncate-read-only", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-truncate-read-only", unknown>>, unknown>;
|
|
20
|
+
export declare class TruncateErrorReadOnly extends TruncateErrorReadOnly_base {
|
|
21
|
+
}
|
|
22
|
+
declare const TruncateErrorInvalidArgument_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-truncate-invalid-argument", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-truncate-invalid-argument", unknown>>, unknown>;
|
|
23
|
+
export declare class TruncateErrorInvalidArgument extends TruncateErrorInvalidArgument_base {
|
|
24
|
+
}
|
|
25
|
+
declare const TruncateErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-truncate-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-truncate-too-many-open-files", unknown>>, unknown>;
|
|
26
|
+
export declare class TruncateErrorTooManyOpenFiles extends TruncateErrorTooManyOpenFiles_base {
|
|
27
|
+
}
|
|
28
|
+
declare const TruncateErrorBusy_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-truncate-busy", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-truncate-busy", unknown>>, unknown>;
|
|
29
|
+
export declare class TruncateErrorBusy extends TruncateErrorBusy_base {
|
|
30
|
+
}
|
|
31
|
+
declare const TruncateError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-truncate-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-truncate-error", unknown>>, unknown>;
|
|
32
|
+
export declare class TruncateError extends TruncateError_base {
|
|
33
|
+
}
|
|
34
|
+
export type TruncateErrors = (TruncateErrorNotFound | TruncateErrorPermissionDenied | TruncateErrorIsDirectory | TruncateErrorNotDirectory | TruncateErrorNoSpace | TruncateErrorReadOnly | TruncateErrorInvalidArgument | TruncateErrorTooManyOpenFiles | TruncateErrorBusy | TruncateError);
|
|
35
|
+
export type TruncateResult = (DEither.Right<"file-system-truncate", void> | DEither.Left<"file-system-truncate-error", TruncateErrors>);
|
|
36
|
+
declare module '../implementor' {
|
|
37
|
+
interface ServerFunction {
|
|
38
|
+
truncate(path: DPath.AnyPath, size?: number): Promise<TruncateResult>;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export declare const truncate: (path: DPath.AnyPath, size?: number) => Promise<TruncateResult>;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { implementFunction, nodeFileSystem } from "../implementor.mjs";
|
|
2
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
3
|
+
import * as DEither from "@duplojs/lang/either";
|
|
4
|
+
//#region scripts/file/truncate.ts
|
|
5
|
+
var TruncateErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-truncate-not-found", Error) {};
|
|
6
|
+
var TruncateErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-truncate-permission-denied", Error) {};
|
|
7
|
+
var TruncateErrorIsDirectory = class extends DCommon.DuploJSError.parentClass("file-system-truncate-is-directory", Error) {};
|
|
8
|
+
var TruncateErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-truncate-not-directory", Error) {};
|
|
9
|
+
var TruncateErrorNoSpace = class extends DCommon.DuploJSError.parentClass("file-system-truncate-no-space", Error) {};
|
|
10
|
+
var TruncateErrorReadOnly = class extends DCommon.DuploJSError.parentClass("file-system-truncate-read-only", Error) {};
|
|
11
|
+
var TruncateErrorInvalidArgument = class extends DCommon.DuploJSError.parentClass("file-system-truncate-invalid-argument", Error) {};
|
|
12
|
+
var TruncateErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-truncate-too-many-open-files", Error) {};
|
|
13
|
+
var TruncateErrorBusy = class extends DCommon.DuploJSError.parentClass("file-system-truncate-busy", Error) {};
|
|
14
|
+
var TruncateError = class extends DCommon.DuploJSError.parentClass("file-system-truncate-error", Error) {};
|
|
15
|
+
function handleNodeTruncateError(error) {
|
|
16
|
+
let truncateError = void 0;
|
|
17
|
+
if ("code" in error) {
|
|
18
|
+
if (error.code === "ENOENT") truncateError = new TruncateErrorNotFound(error);
|
|
19
|
+
else if (error.code === "EACCES" || error.code === "EPERM") truncateError = new TruncateErrorPermissionDenied(error);
|
|
20
|
+
else if (error.code === "EISDIR") truncateError = new TruncateErrorIsDirectory(error);
|
|
21
|
+
else if (error.code === "ENOTDIR") truncateError = new TruncateErrorNotDirectory(error);
|
|
22
|
+
else if (error.code === "ENOSPC") truncateError = new TruncateErrorNoSpace(error);
|
|
23
|
+
else if (error.code === "EROFS") truncateError = new TruncateErrorReadOnly(error);
|
|
24
|
+
else if (error.code === "EINVAL") truncateError = new TruncateErrorInvalidArgument(error);
|
|
25
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") truncateError = new TruncateErrorTooManyOpenFiles(error);
|
|
26
|
+
else if (error.code === "EBUSY") truncateError = new TruncateErrorBusy(error);
|
|
27
|
+
}
|
|
28
|
+
if (truncateError === void 0) truncateError = new TruncateError(error);
|
|
29
|
+
return DEither.left("file-system-truncate-error", truncateError);
|
|
30
|
+
}
|
|
31
|
+
function handleDenoTruncateError(error) {
|
|
32
|
+
let truncateError = void 0;
|
|
33
|
+
if (error instanceof Deno.errors.NotFound) truncateError = new TruncateErrorNotFound(error);
|
|
34
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) truncateError = new TruncateErrorPermissionDenied(error);
|
|
35
|
+
else if (error instanceof Deno.errors.IsADirectory) truncateError = new TruncateErrorIsDirectory(error);
|
|
36
|
+
else if (error instanceof Deno.errors.NotADirectory) truncateError = new TruncateErrorNotDirectory(error);
|
|
37
|
+
else if (error instanceof Deno.errors.InvalidData) truncateError = new TruncateErrorInvalidArgument(error);
|
|
38
|
+
else if (error instanceof Deno.errors.Busy) truncateError = new TruncateErrorBusy(error);
|
|
39
|
+
if (truncateError === void 0) truncateError = new TruncateError(error);
|
|
40
|
+
return DEither.left("file-system-truncate-error", truncateError);
|
|
41
|
+
}
|
|
42
|
+
const truncate = implementFunction("truncate", {
|
|
43
|
+
NODE: async (path, size) => nodeFileSystem.value.truncate(path, size).then(() => DEither.right("file-system-truncate")).catch(handleNodeTruncateError),
|
|
44
|
+
DENO: (path, size) => DCommon.pipe(path, DCommon.when(DCommon.instanceOf(URL), ({ pathname }) => decodeURIComponent(pathname)), (stringPath) => Deno.truncate(stringPath, size).then(() => DEither.right("file-system-truncate")).catch(handleDenoTruncateError))
|
|
45
|
+
});
|
|
46
|
+
//#endregion
|
|
47
|
+
export { TruncateError, TruncateErrorBusy, TruncateErrorInvalidArgument, TruncateErrorIsDirectory, TruncateErrorNoSpace, TruncateErrorNotDirectory, TruncateErrorNotFound, TruncateErrorPermissionDenied, TruncateErrorReadOnly, TruncateErrorTooManyOpenFiles, truncate };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_kind = require("../kind.cjs");
|
|
3
|
+
const require_stat = require("./stat.cjs");
|
|
4
|
+
const require_exists = require("./exists.cjs");
|
|
5
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
6
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
7
|
+
let _duplojs_lang_path = require("@duplojs/lang/path");
|
|
8
|
+
_duplojs_lang_path = require_runtime.__toESM(_duplojs_lang_path, 1);
|
|
9
|
+
//#region scripts/file/unknownEntryInterface.ts
|
|
10
|
+
const unknownInterfaceKind = require_kind.createKind("unknownInterface");
|
|
11
|
+
function createUnknownEntryInterface(path) {
|
|
12
|
+
function getName() {
|
|
13
|
+
return _duplojs_lang_path.getBaseName(path);
|
|
14
|
+
}
|
|
15
|
+
function getParentPath() {
|
|
16
|
+
return _duplojs_lang_path.getParentFolderPath(path);
|
|
17
|
+
}
|
|
18
|
+
function localStat() {
|
|
19
|
+
return require_stat.stat(path);
|
|
20
|
+
}
|
|
21
|
+
function exist() {
|
|
22
|
+
return require_exists.exists(path);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
path: _duplojs_lang_common.cast(path),
|
|
26
|
+
getName,
|
|
27
|
+
getParentPath,
|
|
28
|
+
stat: localStat,
|
|
29
|
+
exist,
|
|
30
|
+
[unknownInterfaceKind.runTimeKey]: null
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function isUnknownEntryInterface(input) {
|
|
34
|
+
return unknownInterfaceKind.has(input);
|
|
35
|
+
}
|
|
36
|
+
const isUnknownEntryInterfaceFromUnknown = isUnknownEntryInterface;
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.createUnknownEntryInterface = createUnknownEntryInterface;
|
|
39
|
+
exports.isUnknownEntryInterface = isUnknownEntryInterface;
|
|
40
|
+
exports.isUnknownEntryInterfaceFromUnknown = isUnknownEntryInterfaceFromUnknown;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StatResult } from './stat';
|
|
2
|
+
import { ExistsResult } from './exists';
|
|
3
|
+
import type * as DKind from "@duplojs/lang/kind";
|
|
4
|
+
import * as DPath from "@duplojs/lang/path";
|
|
5
|
+
declare const unknownInterfaceKind: DKind.Handler<DKind.Definition<"@DuplojsServer/unknownInterface", unknown>>;
|
|
6
|
+
export type EntryPath = DPath.AnyPath;
|
|
7
|
+
export interface UnknownEntryInterface<GenericPath extends DPath.AnyPath = DPath.AnyPath> extends DKind.Kind<typeof unknownInterfaceKind> {
|
|
8
|
+
path: GenericPath & DPath.Path;
|
|
9
|
+
getName(): (string & DPath.Segment & DPath.Path) | null;
|
|
10
|
+
getParentPath(): ReturnType<typeof DPath.getParentFolderPath<GenericPath>>;
|
|
11
|
+
stat(): Promise<StatResult>;
|
|
12
|
+
exist(): Promise<ExistsResult>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createUnknownEntryInterface<GenericPath extends DPath.AnyPath = DPath.AnyPath>(path: GenericPath): UnknownEntryInterface<GenericPath>;
|
|
15
|
+
export declare function isUnknownEntryInterface<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, UnknownEntryInterface>;
|
|
16
|
+
export declare const isUnknownEntryInterfaceFromUnknown: (input: unknown) => input is UnknownEntryInterface;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createKind } from "../kind.mjs";
|
|
2
|
+
import { stat } from "./stat.mjs";
|
|
3
|
+
import { exists } from "./exists.mjs";
|
|
4
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
5
|
+
import * as DPath from "@duplojs/lang/path";
|
|
6
|
+
//#region scripts/file/unknownEntryInterface.ts
|
|
7
|
+
const unknownInterfaceKind = createKind("unknownInterface");
|
|
8
|
+
function createUnknownEntryInterface(path) {
|
|
9
|
+
function getName() {
|
|
10
|
+
return DPath.getBaseName(path);
|
|
11
|
+
}
|
|
12
|
+
function getParentPath() {
|
|
13
|
+
return DPath.getParentFolderPath(path);
|
|
14
|
+
}
|
|
15
|
+
function localStat() {
|
|
16
|
+
return stat(path);
|
|
17
|
+
}
|
|
18
|
+
function exist() {
|
|
19
|
+
return exists(path);
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
path: DCommon.cast(path),
|
|
23
|
+
getName,
|
|
24
|
+
getParentPath,
|
|
25
|
+
stat: localStat,
|
|
26
|
+
exist,
|
|
27
|
+
[unknownInterfaceKind.runTimeKey]: null
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function isUnknownEntryInterface(input) {
|
|
31
|
+
return unknownInterfaceKind.has(input);
|
|
32
|
+
}
|
|
33
|
+
const isUnknownEntryInterfaceFromUnknown = isUnknownEntryInterface;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { createUnknownEntryInterface, isUnknownEntryInterface, isUnknownEntryInterfaceFromUnknown };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_implementor = require("../implementor.cjs");
|
|
3
|
+
const require_getCurrentWorkDirectoryOrThrow = require("../common/getCurrentWorkDirectoryOrThrow.cjs");
|
|
4
|
+
const require_fileInterface = require("./fileInterface.cjs");
|
|
5
|
+
const require_unknownEntryInterface = require("./unknownEntryInterface.cjs");
|
|
6
|
+
const require_folderInterface = require("./folderInterface.cjs");
|
|
7
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
8
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
9
|
+
let _duplojs_lang_pattern = require("@duplojs/lang/pattern");
|
|
10
|
+
_duplojs_lang_pattern = require_runtime.__toESM(_duplojs_lang_pattern, 1);
|
|
11
|
+
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
12
|
+
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
13
|
+
let _duplojs_lang_path = require("@duplojs/lang/path");
|
|
14
|
+
_duplojs_lang_path = require_runtime.__toESM(_duplojs_lang_path, 1);
|
|
15
|
+
let _duplojs_lang_generator = require("@duplojs/lang/generator");
|
|
16
|
+
_duplojs_lang_generator = require_runtime.__toESM(_duplojs_lang_generator, 1);
|
|
17
|
+
//#region scripts/file/walkDirectory.ts
|
|
18
|
+
var WalkDirectoryErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-walk-directory-not-found", Error) {};
|
|
19
|
+
var WalkDirectoryErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-walk-directory-permission-denied", Error) {};
|
|
20
|
+
var WalkDirectoryErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-walk-directory-not-directory", Error) {};
|
|
21
|
+
var WalkDirectoryErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-walk-directory-too-many-open-files", Error) {};
|
|
22
|
+
var WalkDirectoryErrorBusy = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-walk-directory-busy", Error) {};
|
|
23
|
+
var WalkDirectoryError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-walk-directory-error", Error) {};
|
|
24
|
+
function handleNodeWalkDirectoryError(error) {
|
|
25
|
+
let walkDirectoryError = void 0;
|
|
26
|
+
if ("code" in error) {
|
|
27
|
+
if (error.code === "ENOENT") walkDirectoryError = new WalkDirectoryErrorNotFound(error);
|
|
28
|
+
else if (error.code === "EACCES" || error.code === "EPERM") walkDirectoryError = new WalkDirectoryErrorPermissionDenied(error);
|
|
29
|
+
else if (error.code === "ENOTDIR") walkDirectoryError = new WalkDirectoryErrorNotDirectory(error);
|
|
30
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") walkDirectoryError = new WalkDirectoryErrorTooManyOpenFiles(error);
|
|
31
|
+
else if (error.code === "EBUSY") walkDirectoryError = new WalkDirectoryErrorBusy(error);
|
|
32
|
+
}
|
|
33
|
+
if (walkDirectoryError === void 0) walkDirectoryError = new WalkDirectoryError(error);
|
|
34
|
+
return _duplojs_lang_either.left("file-system-walk-directory-error", walkDirectoryError);
|
|
35
|
+
}
|
|
36
|
+
const walkDirectory = require_implementor.implementFunction("walkDirectory", { NODE: async (path, params) => require_implementor.nodeFileSystem.value.readdir(path, {
|
|
37
|
+
recursive: params?.recursive ?? false,
|
|
38
|
+
withFileTypes: true
|
|
39
|
+
}).then((result) => {
|
|
40
|
+
const currentWorkDirectory = require_getCurrentWorkDirectoryOrThrow.getCurrentWorkDirectoryOrThrow();
|
|
41
|
+
return _duplojs_lang_common.pipe(result, _duplojs_lang_generator.map((dirent) => ({
|
|
42
|
+
dirent,
|
|
43
|
+
path: _duplojs_lang_path.resolveFrom(currentWorkDirectory, [_duplojs_lang_path.normalize(`${dirent.parentPath}/${dirent.name}`)])
|
|
44
|
+
})), (generator) => {
|
|
45
|
+
const matcher = params?.matcher;
|
|
46
|
+
if (!matcher) return generator;
|
|
47
|
+
return _duplojs_lang_generator.filter(generator, ({ path }) => matcher(path));
|
|
48
|
+
}, _duplojs_lang_generator.map(_duplojs_lang_common.innerPipe(_duplojs_lang_pattern.when(({ dirent }) => dirent.isFile(), ({ path }) => require_fileInterface.createFileInterface(path)), _duplojs_lang_pattern.when(({ dirent }) => dirent.isDirectory(), ({ path }) => require_folderInterface.createFolderInterface(path)), _duplojs_lang_pattern.otherwise(({ path }) => require_unknownEntryInterface.createUnknownEntryInterface(path)))), (value) => _duplojs_lang_either.right("file-system-walk-directory", value));
|
|
49
|
+
}).catch(handleNodeWalkDirectoryError) });
|
|
50
|
+
//#endregion
|
|
51
|
+
exports.WalkDirectoryError = WalkDirectoryError;
|
|
52
|
+
exports.WalkDirectoryErrorBusy = WalkDirectoryErrorBusy;
|
|
53
|
+
exports.WalkDirectoryErrorNotDirectory = WalkDirectoryErrorNotDirectory;
|
|
54
|
+
exports.WalkDirectoryErrorNotFound = WalkDirectoryErrorNotFound;
|
|
55
|
+
exports.WalkDirectoryErrorPermissionDenied = WalkDirectoryErrorPermissionDenied;
|
|
56
|
+
exports.WalkDirectoryErrorTooManyOpenFiles = WalkDirectoryErrorTooManyOpenFiles;
|
|
57
|
+
exports.walkDirectory = walkDirectory;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FileInterface } from './fileInterface';
|
|
2
|
+
import { FolderInterface } from './folderInterface';
|
|
3
|
+
import { UnknownEntryInterface } from './unknownEntryInterface';
|
|
4
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
5
|
+
import * as DPath from "@duplojs/lang/path";
|
|
6
|
+
import * as DEither from "@duplojs/lang/either";
|
|
7
|
+
declare const WalkDirectoryErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-walk-directory-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-walk-directory-not-found", unknown>>, unknown>;
|
|
8
|
+
export declare class WalkDirectoryErrorNotFound extends WalkDirectoryErrorNotFound_base {
|
|
9
|
+
}
|
|
10
|
+
declare const WalkDirectoryErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-walk-directory-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-walk-directory-permission-denied", unknown>>, unknown>;
|
|
11
|
+
export declare class WalkDirectoryErrorPermissionDenied extends WalkDirectoryErrorPermissionDenied_base {
|
|
12
|
+
}
|
|
13
|
+
declare const WalkDirectoryErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-walk-directory-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-walk-directory-not-directory", unknown>>, unknown>;
|
|
14
|
+
export declare class WalkDirectoryErrorNotDirectory extends WalkDirectoryErrorNotDirectory_base {
|
|
15
|
+
}
|
|
16
|
+
declare const WalkDirectoryErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-walk-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-walk-directory-too-many-open-files", unknown>>, unknown>;
|
|
17
|
+
export declare class WalkDirectoryErrorTooManyOpenFiles extends WalkDirectoryErrorTooManyOpenFiles_base {
|
|
18
|
+
}
|
|
19
|
+
declare const WalkDirectoryErrorBusy_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-walk-directory-busy", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-walk-directory-busy", unknown>>, unknown>;
|
|
20
|
+
export declare class WalkDirectoryErrorBusy extends WalkDirectoryErrorBusy_base {
|
|
21
|
+
}
|
|
22
|
+
declare const WalkDirectoryError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-walk-directory-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-walk-directory-error", unknown>>, unknown>;
|
|
23
|
+
export declare class WalkDirectoryError extends WalkDirectoryError_base {
|
|
24
|
+
}
|
|
25
|
+
export type WalkDirectoryErrors = (WalkDirectoryErrorNotFound | WalkDirectoryErrorPermissionDenied | WalkDirectoryErrorNotDirectory | WalkDirectoryErrorTooManyOpenFiles | WalkDirectoryErrorBusy | WalkDirectoryError);
|
|
26
|
+
export interface WalkDirectoryParams {
|
|
27
|
+
recursive?: boolean;
|
|
28
|
+
matcher?: DPath.PathMatcher<string & DPath.Absolute>;
|
|
29
|
+
}
|
|
30
|
+
export type WalkDirectoryResult = (DEither.Right<"file-system-walk-directory", Generator<FileInterface<string & DPath.Absolute> | FolderInterface<string & DPath.Absolute> | UnknownEntryInterface<string & DPath.Absolute>>> | DEither.Left<"file-system-walk-directory-error", WalkDirectoryErrors>);
|
|
31
|
+
declare module '../implementor' {
|
|
32
|
+
interface ServerFunction {
|
|
33
|
+
walkDirectory(path: DPath.AnyPath, params?: WalkDirectoryParams): Promise<WalkDirectoryResult>;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export declare const walkDirectory: (path: DPath.AnyPath, params?: WalkDirectoryParams) => Promise<WalkDirectoryResult>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { implementFunction, nodeFileSystem } from "../implementor.mjs";
|
|
2
|
+
import { getCurrentWorkDirectoryOrThrow } from "../common/getCurrentWorkDirectoryOrThrow.mjs";
|
|
3
|
+
import { createFileInterface } from "./fileInterface.mjs";
|
|
4
|
+
import { createUnknownEntryInterface } from "./unknownEntryInterface.mjs";
|
|
5
|
+
import { createFolderInterface } from "./folderInterface.mjs";
|
|
6
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
7
|
+
import * as DPattern from "@duplojs/lang/pattern";
|
|
8
|
+
import * as DEither from "@duplojs/lang/either";
|
|
9
|
+
import * as DPath from "@duplojs/lang/path";
|
|
10
|
+
import * as DGenerator from "@duplojs/lang/generator";
|
|
11
|
+
//#region scripts/file/walkDirectory.ts
|
|
12
|
+
var WalkDirectoryErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-walk-directory-not-found", Error) {};
|
|
13
|
+
var WalkDirectoryErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-walk-directory-permission-denied", Error) {};
|
|
14
|
+
var WalkDirectoryErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-walk-directory-not-directory", Error) {};
|
|
15
|
+
var WalkDirectoryErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-walk-directory-too-many-open-files", Error) {};
|
|
16
|
+
var WalkDirectoryErrorBusy = class extends DCommon.DuploJSError.parentClass("file-system-walk-directory-busy", Error) {};
|
|
17
|
+
var WalkDirectoryError = class extends DCommon.DuploJSError.parentClass("file-system-walk-directory-error", Error) {};
|
|
18
|
+
function handleNodeWalkDirectoryError(error) {
|
|
19
|
+
let walkDirectoryError = void 0;
|
|
20
|
+
if ("code" in error) {
|
|
21
|
+
if (error.code === "ENOENT") walkDirectoryError = new WalkDirectoryErrorNotFound(error);
|
|
22
|
+
else if (error.code === "EACCES" || error.code === "EPERM") walkDirectoryError = new WalkDirectoryErrorPermissionDenied(error);
|
|
23
|
+
else if (error.code === "ENOTDIR") walkDirectoryError = new WalkDirectoryErrorNotDirectory(error);
|
|
24
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") walkDirectoryError = new WalkDirectoryErrorTooManyOpenFiles(error);
|
|
25
|
+
else if (error.code === "EBUSY") walkDirectoryError = new WalkDirectoryErrorBusy(error);
|
|
26
|
+
}
|
|
27
|
+
if (walkDirectoryError === void 0) walkDirectoryError = new WalkDirectoryError(error);
|
|
28
|
+
return DEither.left("file-system-walk-directory-error", walkDirectoryError);
|
|
29
|
+
}
|
|
30
|
+
const walkDirectory = implementFunction("walkDirectory", { NODE: async (path, params) => nodeFileSystem.value.readdir(path, {
|
|
31
|
+
recursive: params?.recursive ?? false,
|
|
32
|
+
withFileTypes: true
|
|
33
|
+
}).then((result) => {
|
|
34
|
+
const currentWorkDirectory = getCurrentWorkDirectoryOrThrow();
|
|
35
|
+
return DCommon.pipe(result, DGenerator.map((dirent) => ({
|
|
36
|
+
dirent,
|
|
37
|
+
path: DPath.resolveFrom(currentWorkDirectory, [DPath.normalize(`${dirent.parentPath}/${dirent.name}`)])
|
|
38
|
+
})), (generator) => {
|
|
39
|
+
const matcher = params?.matcher;
|
|
40
|
+
if (!matcher) return generator;
|
|
41
|
+
return DGenerator.filter(generator, ({ path }) => matcher(path));
|
|
42
|
+
}, DGenerator.map(DCommon.innerPipe(DPattern.when(({ dirent }) => dirent.isFile(), ({ path }) => createFileInterface(path)), DPattern.when(({ dirent }) => dirent.isDirectory(), ({ path }) => createFolderInterface(path)), DPattern.otherwise(({ path }) => createUnknownEntryInterface(path)))), (value) => DEither.right("file-system-walk-directory", value));
|
|
43
|
+
}).catch(handleNodeWalkDirectoryError) });
|
|
44
|
+
//#endregion
|
|
45
|
+
export { WalkDirectoryError, WalkDirectoryErrorBusy, WalkDirectoryErrorNotDirectory, WalkDirectoryErrorNotFound, WalkDirectoryErrorPermissionDenied, WalkDirectoryErrorTooManyOpenFiles, walkDirectory };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
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);
|
|
5
|
+
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
6
|
+
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
7
|
+
//#region scripts/file/writeFile.ts
|
|
8
|
+
var WriteFileErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-write-file-not-found", Error) {};
|
|
9
|
+
var WriteFileErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-write-file-permission-denied", Error) {};
|
|
10
|
+
var WriteFileErrorIsDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-write-file-is-directory", Error) {};
|
|
11
|
+
var WriteFileErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-write-file-not-directory", Error) {};
|
|
12
|
+
var WriteFileErrorNoSpace = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-write-file-no-space", Error) {};
|
|
13
|
+
var WriteFileErrorReadOnly = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-write-file-read-only", Error) {};
|
|
14
|
+
var WriteFileErrorInvalidArgument = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-write-file-invalid-argument", Error) {};
|
|
15
|
+
var WriteFileErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-write-file-too-many-open-files", Error) {};
|
|
16
|
+
var WriteFileErrorBusy = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-write-file-busy", Error) {};
|
|
17
|
+
var WriteFileError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-write-file-error", Error) {};
|
|
18
|
+
function handleNodeWriteFileError(error) {
|
|
19
|
+
let writeFileError = void 0;
|
|
20
|
+
if ("code" in error) {
|
|
21
|
+
if (error.code === "ENOENT") writeFileError = new WriteFileErrorNotFound(error);
|
|
22
|
+
else if (error.code === "EACCES" || error.code === "EPERM") writeFileError = new WriteFileErrorPermissionDenied(error);
|
|
23
|
+
else if (error.code === "EISDIR") writeFileError = new WriteFileErrorIsDirectory(error);
|
|
24
|
+
else if (error.code === "ENOTDIR") writeFileError = new WriteFileErrorNotDirectory(error);
|
|
25
|
+
else if (error.code === "ENOSPC") writeFileError = new WriteFileErrorNoSpace(error);
|
|
26
|
+
else if (error.code === "EROFS") writeFileError = new WriteFileErrorReadOnly(error);
|
|
27
|
+
else if (error.code === "EINVAL") writeFileError = new WriteFileErrorInvalidArgument(error);
|
|
28
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") writeFileError = new WriteFileErrorTooManyOpenFiles(error);
|
|
29
|
+
else if (error.code === "EBUSY") writeFileError = new WriteFileErrorBusy(error);
|
|
30
|
+
}
|
|
31
|
+
if (writeFileError === void 0) writeFileError = new WriteFileError(error);
|
|
32
|
+
return _duplojs_lang_either.left("file-system-write-file-error", writeFileError);
|
|
33
|
+
}
|
|
34
|
+
function handleDenoWriteFileError(error) {
|
|
35
|
+
let writeFileError = void 0;
|
|
36
|
+
if (error instanceof Deno.errors.NotFound) writeFileError = new WriteFileErrorNotFound(error);
|
|
37
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) writeFileError = new WriteFileErrorPermissionDenied(error);
|
|
38
|
+
else if (error instanceof Deno.errors.IsADirectory) writeFileError = new WriteFileErrorIsDirectory(error);
|
|
39
|
+
else if (error instanceof Deno.errors.NotADirectory) writeFileError = new WriteFileErrorNotDirectory(error);
|
|
40
|
+
else if (error instanceof Deno.errors.InvalidData) writeFileError = new WriteFileErrorInvalidArgument(error);
|
|
41
|
+
else if (error instanceof Deno.errors.Busy) writeFileError = new WriteFileErrorBusy(error);
|
|
42
|
+
if (writeFileError === void 0) writeFileError = new WriteFileError(error);
|
|
43
|
+
return _duplojs_lang_either.left("file-system-write-file-error", writeFileError);
|
|
44
|
+
}
|
|
45
|
+
const writeFileImplementation = require_implementor.implementFunction("writeFile", {
|
|
46
|
+
NODE: async (path, data) => require_implementor.nodeFileSystem.value.writeFile(path, data).then(() => _duplojs_lang_either.right("file-system-write-file")).catch(handleNodeWriteFileError),
|
|
47
|
+
DENO: (path, data) => Deno.writeFile(path, data).then(() => _duplojs_lang_either.right("file-system-write-file")).catch(handleDenoWriteFileError),
|
|
48
|
+
BUN: (path, data) => Bun.file(path).write(data).then(() => _duplojs_lang_either.right("file-system-write-file")).catch(handleNodeWriteFileError)
|
|
49
|
+
});
|
|
50
|
+
function writeFile(...args) {
|
|
51
|
+
if (args.length === 1) {
|
|
52
|
+
const [data] = args;
|
|
53
|
+
return (path) => writeFileImplementation(path, data);
|
|
54
|
+
}
|
|
55
|
+
return writeFileImplementation(...args);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
exports.WriteFileError = WriteFileError;
|
|
59
|
+
exports.WriteFileErrorBusy = WriteFileErrorBusy;
|
|
60
|
+
exports.WriteFileErrorInvalidArgument = WriteFileErrorInvalidArgument;
|
|
61
|
+
exports.WriteFileErrorIsDirectory = WriteFileErrorIsDirectory;
|
|
62
|
+
exports.WriteFileErrorNoSpace = WriteFileErrorNoSpace;
|
|
63
|
+
exports.WriteFileErrorNotDirectory = WriteFileErrorNotDirectory;
|
|
64
|
+
exports.WriteFileErrorNotFound = WriteFileErrorNotFound;
|
|
65
|
+
exports.WriteFileErrorPermissionDenied = WriteFileErrorPermissionDenied;
|
|
66
|
+
exports.WriteFileErrorReadOnly = WriteFileErrorReadOnly;
|
|
67
|
+
exports.WriteFileErrorTooManyOpenFiles = WriteFileErrorTooManyOpenFiles;
|
|
68
|
+
exports.writeFile = writeFile;
|