@duplojs/server 0.0.0-stage → 0.1.0-beta.2
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 +9 -0
- package/dist/_virtual/_rolldown/runtime.cjs +33 -0
- package/dist/_virtual/_rolldown/runtime.mjs +13 -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 +94 -0
- package/dist/command/create.d.ts +47 -0
- package/dist/command/create.mjs +88 -0
- package/dist/command/error.cjs +153 -0
- package/dist/command/error.d.ts +53 -0
- package/dist/command/error.mjs +140 -0
- package/dist/command/exec.cjs +19 -0
- package/dist/command/exec.d.ts +13 -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 +257 -0
- package/dist/command/help.d.ts +10 -0
- package/dist/command/help.mjs +244 -0
- package/dist/command/index.cjs +78 -0
- package/dist/command/index.d.ts +8 -0
- package/dist/command/index.mjs +45 -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 +68 -0
- package/dist/command/options/base.d.ts +24 -0
- package/dist/command/options/base.mjs +63 -0
- package/dist/command/options/defaults/array.cjs +35 -0
- package/dist/command/options/defaults/array.d.ts +24 -0
- package/dist/command/options/defaults/array.mjs +29 -0
- package/dist/command/options/defaults/boolean.cjs +14 -0
- package/dist/command/options/defaults/boolean.d.ts +11 -0
- package/dist/command/options/defaults/boolean.mjs +13 -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 +16 -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/index.d.ts +2 -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 +4 -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 +41 -0
- package/dist/common/index.d.ts +8 -0
- package/dist/common/index.mjs +25 -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 +14 -0
- package/dist/dataStructure/common/codec/defaults/json.d.ts +9 -0
- package/dist/dataStructure/common/codec/defaults/json.mjs +11 -0
- package/dist/dataStructure/common/codec/defaults/string.cjs +14 -0
- package/dist/dataStructure/common/codec/defaults/string.d.ts +13 -0
- package/dist/dataStructure/common/codec/defaults/string.mjs +11 -0
- package/dist/dataStructure/common/codec/index.d.ts +1 -0
- package/dist/dataStructure/common/error/defaultInterpreter.cjs +27 -0
- package/dist/dataStructure/common/error/defaultInterpreter.d.ts +64 -0
- package/dist/dataStructure/common/error/defaultInterpreter.mjs +24 -0
- package/dist/dataStructure/common/error/index.d.ts +1 -0
- package/dist/dataStructure/common/index.d.ts +2 -0
- package/dist/dataStructure/constraint/exist.cjs +19 -0
- package/dist/dataStructure/constraint/exist.d.ts +10 -0
- package/dist/dataStructure/constraint/exist.mjs +15 -0
- package/dist/dataStructure/constraint/index.d.ts +4 -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 +10 -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/index.d.ts +2 -0
- package/dist/dataStructure/fundamentalType/types/fundamentalTypes.d.ts +6 -0
- package/dist/dataStructure/fundamentalType/types/index.d.ts +1 -0
- package/dist/dataStructure/helper/exist.cjs +7 -0
- package/dist/dataStructure/helper/exist.d.ts +2 -0
- package/dist/dataStructure/helper/exist.mjs +7 -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/index.d.ts +4 -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 +62 -0
- package/dist/dataStructure/index.d.ts +6 -0
- package/dist/dataStructure/index.mjs +38 -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/index.d.ts +2 -0
- package/dist/dataStructure/type/types/index.d.ts +1 -0
- package/dist/dataStructure/type/types/types.d.ts +6 -0
- package/dist/file/appendFile.cjs +43 -0
- package/dist/file/appendFile.d.ts +11 -0
- package/dist/file/appendFile.mjs +41 -0
- package/dist/file/appendTextFile.cjs +43 -0
- package/dist/file/appendTextFile.d.ts +11 -0
- package/dist/file/appendTextFile.mjs +41 -0
- package/dist/file/copy.cjs +31 -0
- package/dist/file/copy.d.ts +11 -0
- package/dist/file/copy.mjs +29 -0
- package/dist/file/createEntryInterface.cjs +16 -0
- package/dist/file/createEntryInterface.d.ts +3 -0
- package/dist/file/createEntryInterface.mjs +13 -0
- package/dist/file/ensureDirectory.cjs +32 -0
- package/dist/file/ensureDirectory.d.ts +10 -0
- package/dist/file/ensureDirectory.mjs +30 -0
- package/dist/file/ensureFile.cjs +38 -0
- package/dist/file/ensureFile.d.ts +10 -0
- package/dist/file/ensureFile.mjs +36 -0
- package/dist/file/exists.cjs +29 -0
- package/dist/file/exists.d.ts +10 -0
- package/dist/file/exists.mjs +27 -0
- package/dist/file/fileInterface.cjs +74 -0
- package/dist/file/fileInterface.d.ts +30 -0
- package/dist/file/fileInterface.mjs +69 -0
- package/dist/file/folderInterface.cjs +74 -0
- package/dist/file/folderInterface.d.ts +32 -0
- package/dist/file/folderInterface.mjs +69 -0
- package/dist/file/index.cjs +122 -0
- package/dist/file/index.d.ts +36 -0
- package/dist/file/index.mjs +79 -0
- package/dist/file/link.cjs +44 -0
- package/dist/file/link.d.ts +11 -0
- package/dist/file/link.mjs +42 -0
- package/dist/file/linkStat.cjs +84 -0
- package/dist/file/linkStat.d.ts +11 -0
- package/dist/file/linkStat.mjs +80 -0
- package/dist/file/makeDirectory.cjs +36 -0
- package/dist/file/makeDirectory.d.ts +14 -0
- package/dist/file/makeDirectory.mjs +34 -0
- package/dist/file/makeTemporaryDirectory.cjs +30 -0
- package/dist/file/makeTemporaryDirectory.d.ts +9 -0
- package/dist/file/makeTemporaryDirectory.mjs +28 -0
- package/dist/file/makeTemporaryFile.cjs +45 -0
- package/dist/file/makeTemporaryFile.d.ts +10 -0
- package/dist/file/makeTemporaryFile.mjs +41 -0
- package/dist/file/move.cjs +45 -0
- package/dist/file/move.d.ts +11 -0
- package/dist/file/move.mjs +43 -0
- package/dist/file/readDirectory.cjs +20 -0
- package/dist/file/readDirectory.d.ts +14 -0
- package/dist/file/readDirectory.mjs +18 -0
- package/dist/file/readFile.cjs +33 -0
- package/dist/file/readFile.d.ts +10 -0
- package/dist/file/readFile.mjs +31 -0
- package/dist/file/readJsonFile.cjs +33 -0
- package/dist/file/readJsonFile.d.ts +11 -0
- package/dist/file/readJsonFile.mjs +31 -0
- package/dist/file/readLink.cjs +30 -0
- package/dist/file/readLink.d.ts +10 -0
- package/dist/file/readLink.mjs +28 -0
- package/dist/file/readTextFile.cjs +33 -0
- package/dist/file/readTextFile.d.ts +10 -0
- package/dist/file/readTextFile.mjs +31 -0
- package/dist/file/realPath.cjs +28 -0
- package/dist/file/realPath.d.ts +10 -0
- package/dist/file/realPath.mjs +26 -0
- package/dist/file/relocate.cjs +56 -0
- package/dist/file/relocate.d.ts +11 -0
- package/dist/file/relocate.mjs +53 -0
- package/dist/file/remove.cjs +38 -0
- package/dist/file/remove.d.ts +14 -0
- package/dist/file/remove.mjs +36 -0
- package/dist/file/rename.cjs +56 -0
- package/dist/file/rename.d.ts +11 -0
- package/dist/file/rename.mjs +53 -0
- package/dist/file/setMode.cjs +51 -0
- package/dist/file/setMode.d.ts +26 -0
- package/dist/file/setMode.mjs +48 -0
- package/dist/file/setOwner.cjs +37 -0
- package/dist/file/setOwner.d.ts +15 -0
- package/dist/file/setOwner.mjs +35 -0
- package/dist/file/setTime.cjs +39 -0
- package/dist/file/setTime.d.ts +17 -0
- package/dist/file/setTime.mjs +36 -0
- package/dist/file/stat.cjs +85 -0
- package/dist/file/stat.d.ts +42 -0
- package/dist/file/stat.mjs +81 -0
- package/dist/file/symlink.cjs +42 -0
- package/dist/file/symlink.d.ts +19 -0
- package/dist/file/symlink.mjs +40 -0
- package/dist/file/truncate.cjs +38 -0
- package/dist/file/truncate.d.ts +10 -0
- package/dist/file/truncate.mjs +35 -0
- package/dist/file/types/fileSystemEither.d.ts +2 -0
- package/dist/file/types/index.d.ts +1 -0
- package/dist/file/unknownEntryInterface.cjs +36 -0
- package/dist/file/unknownEntryInterface.d.ts +15 -0
- package/dist/file/unknownEntryInterface.mjs +33 -0
- package/dist/file/walkDirectory.cjs +34 -0
- package/dist/file/walkDirectory.d.ts +16 -0
- package/dist/file/walkDirectory.mjs +28 -0
- package/dist/file/writeFile.cjs +44 -0
- package/dist/file/writeFile.d.ts +11 -0
- package/dist/file/writeFile.mjs +42 -0
- package/dist/file/writeJsonFile.cjs +56 -0
- package/dist/file/writeJsonFile.d.ts +15 -0
- package/dist/file/writeJsonFile.mjs +53 -0
- package/dist/file/writeTextFile.cjs +44 -0
- package/dist/file/writeTextFile.d.ts +11 -0
- package/dist/file/writeTextFile.mjs +42 -0
- package/dist/implementor.cjs +64 -0
- package/dist/implementor.d.ts +35 -0
- package/dist/implementor.mjs +52 -0
- package/dist/index.cjs +74 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +14 -0
- package/dist/kind.cjs +7 -0
- package/dist/kind.d.ts +2 -0
- package/dist/kind.mjs +5 -0
- package/package.json +81 -3
- package/README.md +0 -3
|
@@ -0,0 +1,74 @@
|
|
|
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_rename = require("./rename.cjs");
|
|
5
|
+
const require_exists = require("./exists.cjs");
|
|
6
|
+
const require_move = require("./move.cjs");
|
|
7
|
+
const require_remove = require("./remove.cjs");
|
|
8
|
+
const require_relocate = require("./relocate.cjs");
|
|
9
|
+
const require_readDirectory = require("./readDirectory.cjs");
|
|
10
|
+
const require_walkDirectory = require("./walkDirectory.cjs");
|
|
11
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
12
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
13
|
+
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
14
|
+
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
15
|
+
let _duplojs_lang_path = require("@duplojs/lang/path");
|
|
16
|
+
_duplojs_lang_path = require_runtime.__toESM(_duplojs_lang_path, 1);
|
|
17
|
+
//#region scripts/file/folderInterface.ts
|
|
18
|
+
const folderInterfaceKind = require_kind.createKind("folderInterface");
|
|
19
|
+
function createFolderInterface(path) {
|
|
20
|
+
function getName() {
|
|
21
|
+
return _duplojs_lang_path.getBaseName(path);
|
|
22
|
+
}
|
|
23
|
+
function getParentPath() {
|
|
24
|
+
return _duplojs_lang_path.getParentFolderPath(path);
|
|
25
|
+
}
|
|
26
|
+
function localRename(newName) {
|
|
27
|
+
return _duplojs_lang_common.asyncPipe(require_rename.rename(path, newName), _duplojs_lang_either.whenIsRight(_duplojs_lang_common.innerPipe(createFolderInterface, (value) => _duplojs_lang_either.right("file-system-rename", value))));
|
|
28
|
+
}
|
|
29
|
+
function localRelocate(newParentPath) {
|
|
30
|
+
return _duplojs_lang_common.asyncPipe(require_relocate.relocate(path, newParentPath), _duplojs_lang_either.whenIsRight(_duplojs_lang_common.innerPipe(createFolderInterface, (value) => _duplojs_lang_either.right("file-system-relocate", value))));
|
|
31
|
+
}
|
|
32
|
+
function localMove(newPath) {
|
|
33
|
+
return _duplojs_lang_common.asyncPipe(require_move.move(path, newPath), _duplojs_lang_either.whenIsRight(() => _duplojs_lang_either.right("file-system-move", createFolderInterface(newPath))));
|
|
34
|
+
}
|
|
35
|
+
function localExists() {
|
|
36
|
+
return require_exists.exists(path);
|
|
37
|
+
}
|
|
38
|
+
function localRemove() {
|
|
39
|
+
return require_remove.remove(path);
|
|
40
|
+
}
|
|
41
|
+
function localStat() {
|
|
42
|
+
return require_stat.stat(path);
|
|
43
|
+
}
|
|
44
|
+
function getChildren() {
|
|
45
|
+
return require_readDirectory.readDirectory(path);
|
|
46
|
+
}
|
|
47
|
+
function walk(params) {
|
|
48
|
+
return require_walkDirectory.walkDirectory(path, params);
|
|
49
|
+
}
|
|
50
|
+
function isFolder() {
|
|
51
|
+
return _duplojs_lang_common.asyncPipe(localStat(), _duplojs_lang_either.whenHasInformationOtherwise("file-system-stat", ({ isDirectory }) => isDirectory, _duplojs_lang_common.justReturn(false)));
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
path,
|
|
55
|
+
getName,
|
|
56
|
+
getParentPath,
|
|
57
|
+
move: localMove,
|
|
58
|
+
rename: localRename,
|
|
59
|
+
exists: localExists,
|
|
60
|
+
relocate: localRelocate,
|
|
61
|
+
remove: localRemove,
|
|
62
|
+
getChildren,
|
|
63
|
+
stat: localStat,
|
|
64
|
+
walk,
|
|
65
|
+
isFolder,
|
|
66
|
+
[folderInterfaceKind.runTimeKey]: null
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function isFolderInterface(input) {
|
|
70
|
+
return folderInterfaceKind.has(input);
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
exports.createFolderInterface = createFolderInterface;
|
|
74
|
+
exports.isFolderInterface = isFolderInterface;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MoveResult } from './move';
|
|
2
|
+
import { ExistsResult } from './exists';
|
|
3
|
+
import { RenameResult } from './rename';
|
|
4
|
+
import { RemoveResult } from './remove';
|
|
5
|
+
import { ReadDirectoryResult } from './readDirectory';
|
|
6
|
+
import { StatResult } from './stat';
|
|
7
|
+
import { WalkDirectoryParams, WalkDirectoryResult } from './walkDirectory';
|
|
8
|
+
import { RelocateResult } from './relocate';
|
|
9
|
+
import type * as DKind from "@duplojs/lang/kind";
|
|
10
|
+
import * as DPath from "@duplojs/lang/path";
|
|
11
|
+
import * as DEither from "@duplojs/lang/either";
|
|
12
|
+
declare const folderInterfaceKind: DKind.Handler<DKind.Definition<"@DuplojsServer/folderInterface", unknown>>;
|
|
13
|
+
type FolderInterfaceRenameResult = Exclude<RenameResult, DEither.Right> | DEither.Right<"file-system-rename", FolderInterface>;
|
|
14
|
+
type FolderInterfaceRelocateResult = Exclude<RelocateResult, DEither.Right> | DEither.Right<"file-system-relocate", FolderInterface>;
|
|
15
|
+
type FolderInterfaceMoveResult = Exclude<MoveResult, DEither.Right> | DEither.Right<"file-system-move", FolderInterface>;
|
|
16
|
+
export interface FolderInterface extends DKind.Kind<typeof folderInterfaceKind> {
|
|
17
|
+
path: string & DPath.Path;
|
|
18
|
+
getName(): (string & DPath.Segment) | null;
|
|
19
|
+
getParentPath(): (string & DPath.Path) | null;
|
|
20
|
+
rename(newName: (string & DPath.Segment)): Promise<FolderInterfaceRenameResult>;
|
|
21
|
+
exists(): Promise<ExistsResult>;
|
|
22
|
+
relocate(parentPath: string & DPath.Path): Promise<FolderInterfaceRelocateResult>;
|
|
23
|
+
move(newPath: string & DPath.Path): Promise<FolderInterfaceMoveResult>;
|
|
24
|
+
remove(): Promise<RemoveResult>;
|
|
25
|
+
getChildren(): Promise<ReadDirectoryResult>;
|
|
26
|
+
stat(): Promise<StatResult>;
|
|
27
|
+
walk(params?: WalkDirectoryParams): Promise<WalkDirectoryResult>;
|
|
28
|
+
isFolder(): Promise<boolean>;
|
|
29
|
+
}
|
|
30
|
+
export declare function createFolderInterface(path: string & DPath.Path): FolderInterface;
|
|
31
|
+
export declare function isFolderInterface(input: unknown): input is FolderInterface;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createKind } from "../kind.mjs";
|
|
2
|
+
import { stat } from "./stat.mjs";
|
|
3
|
+
import { rename } from "./rename.mjs";
|
|
4
|
+
import { exists } from "./exists.mjs";
|
|
5
|
+
import { move } from "./move.mjs";
|
|
6
|
+
import { remove } from "./remove.mjs";
|
|
7
|
+
import { relocate } from "./relocate.mjs";
|
|
8
|
+
import { readDirectory } from "./readDirectory.mjs";
|
|
9
|
+
import { walkDirectory } from "./walkDirectory.mjs";
|
|
10
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
11
|
+
import * as DEither from "@duplojs/lang/either";
|
|
12
|
+
import * as DPath from "@duplojs/lang/path";
|
|
13
|
+
//#region scripts/file/folderInterface.ts
|
|
14
|
+
const folderInterfaceKind = createKind("folderInterface");
|
|
15
|
+
function createFolderInterface(path) {
|
|
16
|
+
function getName() {
|
|
17
|
+
return DPath.getBaseName(path);
|
|
18
|
+
}
|
|
19
|
+
function getParentPath() {
|
|
20
|
+
return DPath.getParentFolderPath(path);
|
|
21
|
+
}
|
|
22
|
+
function localRename(newName) {
|
|
23
|
+
return DCommon.asyncPipe(rename(path, newName), DEither.whenIsRight(DCommon.innerPipe(createFolderInterface, (value) => DEither.right("file-system-rename", value))));
|
|
24
|
+
}
|
|
25
|
+
function localRelocate(newParentPath) {
|
|
26
|
+
return DCommon.asyncPipe(relocate(path, newParentPath), DEither.whenIsRight(DCommon.innerPipe(createFolderInterface, (value) => DEither.right("file-system-relocate", value))));
|
|
27
|
+
}
|
|
28
|
+
function localMove(newPath) {
|
|
29
|
+
return DCommon.asyncPipe(move(path, newPath), DEither.whenIsRight(() => DEither.right("file-system-move", createFolderInterface(newPath))));
|
|
30
|
+
}
|
|
31
|
+
function localExists() {
|
|
32
|
+
return exists(path);
|
|
33
|
+
}
|
|
34
|
+
function localRemove() {
|
|
35
|
+
return remove(path);
|
|
36
|
+
}
|
|
37
|
+
function localStat() {
|
|
38
|
+
return stat(path);
|
|
39
|
+
}
|
|
40
|
+
function getChildren() {
|
|
41
|
+
return readDirectory(path);
|
|
42
|
+
}
|
|
43
|
+
function walk(params) {
|
|
44
|
+
return walkDirectory(path, params);
|
|
45
|
+
}
|
|
46
|
+
function isFolder() {
|
|
47
|
+
return DCommon.asyncPipe(localStat(), DEither.whenHasInformationOtherwise("file-system-stat", ({ isDirectory }) => isDirectory, DCommon.justReturn(false)));
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
path,
|
|
51
|
+
getName,
|
|
52
|
+
getParentPath,
|
|
53
|
+
move: localMove,
|
|
54
|
+
rename: localRename,
|
|
55
|
+
exists: localExists,
|
|
56
|
+
relocate: localRelocate,
|
|
57
|
+
remove: localRemove,
|
|
58
|
+
getChildren,
|
|
59
|
+
stat: localStat,
|
|
60
|
+
walk,
|
|
61
|
+
isFolder,
|
|
62
|
+
[folderInterfaceKind.runTimeKey]: null
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function isFolderInterface(input) {
|
|
66
|
+
return folderInterfaceKind.has(input);
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { createFolderInterface, isFolderInterface };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_appendFile = require("./appendFile.cjs");
|
|
3
|
+
const require_appendTextFile = require("./appendTextFile.cjs");
|
|
4
|
+
const require_copy = require("./copy.cjs");
|
|
5
|
+
const require_stat = require("./stat.cjs");
|
|
6
|
+
const require_rename = require("./rename.cjs");
|
|
7
|
+
const require_exists = require("./exists.cjs");
|
|
8
|
+
const require_move = require("./move.cjs");
|
|
9
|
+
const require_remove = require("./remove.cjs");
|
|
10
|
+
const require_relocate = require("./relocate.cjs");
|
|
11
|
+
const require_fileInterface = require("./fileInterface.cjs");
|
|
12
|
+
const require_readDirectory = require("./readDirectory.cjs");
|
|
13
|
+
const require_unknownEntryInterface = require("./unknownEntryInterface.cjs");
|
|
14
|
+
const require_walkDirectory = require("./walkDirectory.cjs");
|
|
15
|
+
const require_folderInterface = require("./folderInterface.cjs");
|
|
16
|
+
const require_createEntryInterface = require("./createEntryInterface.cjs");
|
|
17
|
+
const require_ensureDirectory = require("./ensureDirectory.cjs");
|
|
18
|
+
const require_ensureFile = require("./ensureFile.cjs");
|
|
19
|
+
const require_link = require("./link.cjs");
|
|
20
|
+
const require_linkStat = require("./linkStat.cjs");
|
|
21
|
+
const require_makeDirectory = require("./makeDirectory.cjs");
|
|
22
|
+
const require_makeTemporaryDirectory = require("./makeTemporaryDirectory.cjs");
|
|
23
|
+
const require_makeTemporaryFile = require("./makeTemporaryFile.cjs");
|
|
24
|
+
const require_readFile = require("./readFile.cjs");
|
|
25
|
+
const require_readJsonFile = require("./readJsonFile.cjs");
|
|
26
|
+
const require_readLink = require("./readLink.cjs");
|
|
27
|
+
const require_readTextFile = require("./readTextFile.cjs");
|
|
28
|
+
const require_realPath = require("./realPath.cjs");
|
|
29
|
+
const require_setMode = require("./setMode.cjs");
|
|
30
|
+
const require_setOwner = require("./setOwner.cjs");
|
|
31
|
+
const require_setTime = require("./setTime.cjs");
|
|
32
|
+
const require_symlink = require("./symlink.cjs");
|
|
33
|
+
const require_truncate = require("./truncate.cjs");
|
|
34
|
+
const require_writeFile = require("./writeFile.cjs");
|
|
35
|
+
const require_writeJsonFile = require("./writeJsonFile.cjs");
|
|
36
|
+
const require_writeTextFile = require("./writeTextFile.cjs");
|
|
37
|
+
//#region scripts/file/index.ts
|
|
38
|
+
var file_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
39
|
+
appendFile: () => require_appendFile.appendFile,
|
|
40
|
+
appendTextFile: () => require_appendTextFile.appendTextFile,
|
|
41
|
+
copy: () => require_copy.copy,
|
|
42
|
+
createEntryInterface: () => require_createEntryInterface.createEntryInterface,
|
|
43
|
+
createFileInterface: () => require_fileInterface.createFileInterface,
|
|
44
|
+
createFolderInterface: () => require_folderInterface.createFolderInterface,
|
|
45
|
+
createUnknownEntryInterface: () => require_unknownEntryInterface.createUnknownEntryInterface,
|
|
46
|
+
ensureDirectory: () => require_ensureDirectory.ensureDirectory,
|
|
47
|
+
ensureFile: () => require_ensureFile.ensureFile,
|
|
48
|
+
exists: () => require_exists.exists,
|
|
49
|
+
isFileInterface: () => require_fileInterface.isFileInterface,
|
|
50
|
+
isFolderInterface: () => require_folderInterface.isFolderInterface,
|
|
51
|
+
isUnknownEntryInterface: () => require_unknownEntryInterface.isUnknownEntryInterface,
|
|
52
|
+
link: () => require_link.link,
|
|
53
|
+
linkStat: () => require_linkStat.linkStat,
|
|
54
|
+
makeDirectory: () => require_makeDirectory.makeDirectory,
|
|
55
|
+
makeTemporaryDirectory: () => require_makeTemporaryDirectory.makeTemporaryDirectory,
|
|
56
|
+
makeTemporaryFile: () => require_makeTemporaryFile.makeTemporaryFile,
|
|
57
|
+
move: () => require_move.move,
|
|
58
|
+
readDirectory: () => require_readDirectory.readDirectory,
|
|
59
|
+
readFile: () => require_readFile.readFile,
|
|
60
|
+
readJsonFile: () => require_readJsonFile.readJsonFile,
|
|
61
|
+
readLink: () => require_readLink.readLink,
|
|
62
|
+
readTextFile: () => require_readTextFile.readTextFile,
|
|
63
|
+
realPath: () => require_realPath.realPath,
|
|
64
|
+
relocate: () => require_relocate.relocate,
|
|
65
|
+
remove: () => require_remove.remove,
|
|
66
|
+
rename: () => require_rename.rename,
|
|
67
|
+
setMode: () => require_setMode.setMode,
|
|
68
|
+
setOwner: () => require_setOwner.setOwner,
|
|
69
|
+
setTime: () => require_setTime.setTime,
|
|
70
|
+
stat: () => require_stat.stat,
|
|
71
|
+
symlink: () => require_symlink.symlink,
|
|
72
|
+
truncate: () => require_truncate.truncate,
|
|
73
|
+
walkDirectory: () => require_walkDirectory.walkDirectory,
|
|
74
|
+
writeFile: () => require_writeFile.writeFile,
|
|
75
|
+
writeJsonFile: () => require_writeJsonFile.writeJsonFile,
|
|
76
|
+
writeTextFile: () => require_writeTextFile.writeTextFile
|
|
77
|
+
});
|
|
78
|
+
//#endregion
|
|
79
|
+
exports.appendFile = require_appendFile.appendFile;
|
|
80
|
+
exports.appendTextFile = require_appendTextFile.appendTextFile;
|
|
81
|
+
exports.copy = require_copy.copy;
|
|
82
|
+
exports.createEntryInterface = require_createEntryInterface.createEntryInterface;
|
|
83
|
+
exports.createFileInterface = require_fileInterface.createFileInterface;
|
|
84
|
+
exports.createFolderInterface = require_folderInterface.createFolderInterface;
|
|
85
|
+
exports.createUnknownEntryInterface = require_unknownEntryInterface.createUnknownEntryInterface;
|
|
86
|
+
exports.ensureDirectory = require_ensureDirectory.ensureDirectory;
|
|
87
|
+
exports.ensureFile = require_ensureFile.ensureFile;
|
|
88
|
+
exports.exists = require_exists.exists;
|
|
89
|
+
Object.defineProperty(exports, "file_exports", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function() {
|
|
92
|
+
return file_exports;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
exports.isFileInterface = require_fileInterface.isFileInterface;
|
|
96
|
+
exports.isFolderInterface = require_folderInterface.isFolderInterface;
|
|
97
|
+
exports.isUnknownEntryInterface = require_unknownEntryInterface.isUnknownEntryInterface;
|
|
98
|
+
exports.link = require_link.link;
|
|
99
|
+
exports.linkStat = require_linkStat.linkStat;
|
|
100
|
+
exports.makeDirectory = require_makeDirectory.makeDirectory;
|
|
101
|
+
exports.makeTemporaryDirectory = require_makeTemporaryDirectory.makeTemporaryDirectory;
|
|
102
|
+
exports.makeTemporaryFile = require_makeTemporaryFile.makeTemporaryFile;
|
|
103
|
+
exports.move = require_move.move;
|
|
104
|
+
exports.readDirectory = require_readDirectory.readDirectory;
|
|
105
|
+
exports.readFile = require_readFile.readFile;
|
|
106
|
+
exports.readJsonFile = require_readJsonFile.readJsonFile;
|
|
107
|
+
exports.readLink = require_readLink.readLink;
|
|
108
|
+
exports.readTextFile = require_readTextFile.readTextFile;
|
|
109
|
+
exports.realPath = require_realPath.realPath;
|
|
110
|
+
exports.relocate = require_relocate.relocate;
|
|
111
|
+
exports.remove = require_remove.remove;
|
|
112
|
+
exports.rename = require_rename.rename;
|
|
113
|
+
exports.setMode = require_setMode.setMode;
|
|
114
|
+
exports.setOwner = require_setOwner.setOwner;
|
|
115
|
+
exports.setTime = require_setTime.setTime;
|
|
116
|
+
exports.stat = require_stat.stat;
|
|
117
|
+
exports.symlink = require_symlink.symlink;
|
|
118
|
+
exports.truncate = require_truncate.truncate;
|
|
119
|
+
exports.walkDirectory = require_walkDirectory.walkDirectory;
|
|
120
|
+
exports.writeFile = require_writeFile.writeFile;
|
|
121
|
+
exports.writeJsonFile = require_writeJsonFile.writeJsonFile;
|
|
122
|
+
exports.writeTextFile = require_writeTextFile.writeTextFile;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export * from './appendFile';
|
|
2
|
+
export * from './appendTextFile';
|
|
3
|
+
export * from './copy';
|
|
4
|
+
export * from './createEntryInterface';
|
|
5
|
+
export * from './ensureDirectory';
|
|
6
|
+
export * from './ensureFile';
|
|
7
|
+
export * from './exists';
|
|
8
|
+
export * from './fileInterface';
|
|
9
|
+
export * from './folderInterface';
|
|
10
|
+
export * from './link';
|
|
11
|
+
export * from './linkStat';
|
|
12
|
+
export * from './makeDirectory';
|
|
13
|
+
export * from './makeTemporaryDirectory';
|
|
14
|
+
export * from './makeTemporaryFile';
|
|
15
|
+
export * from './move';
|
|
16
|
+
export * from './readDirectory';
|
|
17
|
+
export * from './readFile';
|
|
18
|
+
export * from './readJsonFile';
|
|
19
|
+
export * from './readLink';
|
|
20
|
+
export * from './readTextFile';
|
|
21
|
+
export * from './realPath';
|
|
22
|
+
export * from './relocate';
|
|
23
|
+
export * from './remove';
|
|
24
|
+
export * from './rename';
|
|
25
|
+
export * from './setMode';
|
|
26
|
+
export * from './setOwner';
|
|
27
|
+
export * from './setTime';
|
|
28
|
+
export * from './stat';
|
|
29
|
+
export * from './symlink';
|
|
30
|
+
export * from './truncate';
|
|
31
|
+
export type * from './types';
|
|
32
|
+
export * from './unknownEntryInterface';
|
|
33
|
+
export * from './walkDirectory';
|
|
34
|
+
export * from './writeFile';
|
|
35
|
+
export * from './writeJsonFile';
|
|
36
|
+
export * from './writeTextFile';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { appendFile } from "./appendFile.mjs";
|
|
3
|
+
import { appendTextFile } from "./appendTextFile.mjs";
|
|
4
|
+
import { copy } from "./copy.mjs";
|
|
5
|
+
import { stat } from "./stat.mjs";
|
|
6
|
+
import { rename } from "./rename.mjs";
|
|
7
|
+
import { exists } from "./exists.mjs";
|
|
8
|
+
import { move } from "./move.mjs";
|
|
9
|
+
import { remove } from "./remove.mjs";
|
|
10
|
+
import { relocate } from "./relocate.mjs";
|
|
11
|
+
import { createFileInterface, isFileInterface } from "./fileInterface.mjs";
|
|
12
|
+
import { readDirectory } from "./readDirectory.mjs";
|
|
13
|
+
import { createUnknownEntryInterface, isUnknownEntryInterface } from "./unknownEntryInterface.mjs";
|
|
14
|
+
import { walkDirectory } from "./walkDirectory.mjs";
|
|
15
|
+
import { createFolderInterface, isFolderInterface } from "./folderInterface.mjs";
|
|
16
|
+
import { createEntryInterface } from "./createEntryInterface.mjs";
|
|
17
|
+
import { ensureDirectory } from "./ensureDirectory.mjs";
|
|
18
|
+
import { ensureFile } from "./ensureFile.mjs";
|
|
19
|
+
import { link } from "./link.mjs";
|
|
20
|
+
import { linkStat } from "./linkStat.mjs";
|
|
21
|
+
import { makeDirectory } from "./makeDirectory.mjs";
|
|
22
|
+
import { makeTemporaryDirectory } from "./makeTemporaryDirectory.mjs";
|
|
23
|
+
import { makeTemporaryFile } from "./makeTemporaryFile.mjs";
|
|
24
|
+
import { readFile } from "./readFile.mjs";
|
|
25
|
+
import { readJsonFile } from "./readJsonFile.mjs";
|
|
26
|
+
import { readLink } from "./readLink.mjs";
|
|
27
|
+
import { readTextFile } from "./readTextFile.mjs";
|
|
28
|
+
import { realPath } from "./realPath.mjs";
|
|
29
|
+
import { setMode } from "./setMode.mjs";
|
|
30
|
+
import { setOwner } from "./setOwner.mjs";
|
|
31
|
+
import { setTime } from "./setTime.mjs";
|
|
32
|
+
import { symlink } from "./symlink.mjs";
|
|
33
|
+
import { truncate } from "./truncate.mjs";
|
|
34
|
+
import { writeFile } from "./writeFile.mjs";
|
|
35
|
+
import { writeJsonFile } from "./writeJsonFile.mjs";
|
|
36
|
+
import { writeTextFile } from "./writeTextFile.mjs";
|
|
37
|
+
//#region scripts/file/index.ts
|
|
38
|
+
var file_exports = /* @__PURE__ */ __exportAll({
|
|
39
|
+
appendFile: () => appendFile,
|
|
40
|
+
appendTextFile: () => appendTextFile,
|
|
41
|
+
copy: () => copy,
|
|
42
|
+
createEntryInterface: () => createEntryInterface,
|
|
43
|
+
createFileInterface: () => createFileInterface,
|
|
44
|
+
createFolderInterface: () => createFolderInterface,
|
|
45
|
+
createUnknownEntryInterface: () => createUnknownEntryInterface,
|
|
46
|
+
ensureDirectory: () => ensureDirectory,
|
|
47
|
+
ensureFile: () => ensureFile,
|
|
48
|
+
exists: () => exists,
|
|
49
|
+
isFileInterface: () => isFileInterface,
|
|
50
|
+
isFolderInterface: () => isFolderInterface,
|
|
51
|
+
isUnknownEntryInterface: () => isUnknownEntryInterface,
|
|
52
|
+
link: () => link,
|
|
53
|
+
linkStat: () => linkStat,
|
|
54
|
+
makeDirectory: () => makeDirectory,
|
|
55
|
+
makeTemporaryDirectory: () => makeTemporaryDirectory,
|
|
56
|
+
makeTemporaryFile: () => makeTemporaryFile,
|
|
57
|
+
move: () => move,
|
|
58
|
+
readDirectory: () => readDirectory,
|
|
59
|
+
readFile: () => readFile,
|
|
60
|
+
readJsonFile: () => readJsonFile,
|
|
61
|
+
readLink: () => readLink,
|
|
62
|
+
readTextFile: () => readTextFile,
|
|
63
|
+
realPath: () => realPath,
|
|
64
|
+
relocate: () => relocate,
|
|
65
|
+
remove: () => remove,
|
|
66
|
+
rename: () => rename,
|
|
67
|
+
setMode: () => setMode,
|
|
68
|
+
setOwner: () => setOwner,
|
|
69
|
+
setTime: () => setTime,
|
|
70
|
+
stat: () => stat,
|
|
71
|
+
symlink: () => symlink,
|
|
72
|
+
truncate: () => truncate,
|
|
73
|
+
walkDirectory: () => walkDirectory,
|
|
74
|
+
writeFile: () => writeFile,
|
|
75
|
+
writeJsonFile: () => writeJsonFile,
|
|
76
|
+
writeTextFile: () => writeTextFile
|
|
77
|
+
});
|
|
78
|
+
//#endregion
|
|
79
|
+
export { appendFile, appendTextFile, copy, createEntryInterface, createFileInterface, createFolderInterface, createUnknownEntryInterface, ensureDirectory, ensureFile, exists, file_exports, isFileInterface, isFolderInterface, isUnknownEntryInterface, link, linkStat, makeDirectory, makeTemporaryDirectory, makeTemporaryFile, move, readDirectory, readFile, readJsonFile, readLink, readTextFile, realPath, relocate, remove, rename, setMode, setOwner, setTime, stat, symlink, truncate, walkDirectory, writeFile, writeJsonFile, writeTextFile };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_implementor = require("../implementor.cjs");
|
|
3
|
+
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
4
|
+
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
5
|
+
//#region scripts/file/link.ts
|
|
6
|
+
function handleNodeLinkError(error) {
|
|
7
|
+
if (typeof error === "object" && error !== null && "code" in error) {
|
|
8
|
+
if (error.code === "ENOENT") return _duplojs_lang_either.left("file-system-link-not-found", error);
|
|
9
|
+
else if (error.code === "EACCES" || error.code === "EPERM") return _duplojs_lang_either.left("file-system-link-permission-denied", error);
|
|
10
|
+
else if (error.code === "EEXIST") return _duplojs_lang_either.left("file-system-link-already-exists", error);
|
|
11
|
+
else if (error.code === "ENOTDIR") return _duplojs_lang_either.left("file-system-link-not-directory", error);
|
|
12
|
+
else if (error.code === "ENOSPC") return _duplojs_lang_either.left("file-system-link-no-space", error);
|
|
13
|
+
else if (error.code === "EROFS") return _duplojs_lang_either.left("file-system-link-read-only", error);
|
|
14
|
+
else if (error.code === "EINVAL") return _duplojs_lang_either.left("file-system-link-invalid-argument", error);
|
|
15
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") return _duplojs_lang_either.left("file-system-link-too-many-open-files", error);
|
|
16
|
+
else if (error.code === "EBUSY") return _duplojs_lang_either.left("file-system-link-busy", error);
|
|
17
|
+
else if (error.code === "EXDEV") return _duplojs_lang_either.left("file-system-link-cross-device", error);
|
|
18
|
+
}
|
|
19
|
+
return _duplojs_lang_either.left("file-system-link-error", error);
|
|
20
|
+
}
|
|
21
|
+
function handleDenoLinkError(error) {
|
|
22
|
+
if (error instanceof Deno.errors.NotFound) return _duplojs_lang_either.left("file-system-link-not-found", error);
|
|
23
|
+
if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return _duplojs_lang_either.left("file-system-link-permission-denied", error);
|
|
24
|
+
if (error instanceof Deno.errors.AlreadyExists) return _duplojs_lang_either.left("file-system-link-already-exists", error);
|
|
25
|
+
if (error instanceof Deno.errors.NotADirectory) return _duplojs_lang_either.left("file-system-link-not-directory", error);
|
|
26
|
+
if (error instanceof Deno.errors.InvalidData) return _duplojs_lang_either.left("file-system-link-invalid-argument", error);
|
|
27
|
+
if (error instanceof Deno.errors.Busy) return _duplojs_lang_either.left("file-system-link-busy", error);
|
|
28
|
+
return _duplojs_lang_either.left("file-system-link-error", error);
|
|
29
|
+
}
|
|
30
|
+
const linkImplementation = require_implementor.implementFunction("link", {
|
|
31
|
+
NODE: async (existingPath, newPath) => {
|
|
32
|
+
return (await require_implementor.nodeFileSystem.value).link(existingPath, newPath).then(() => _duplojs_lang_either.right("file-system-link")).catch(handleNodeLinkError);
|
|
33
|
+
},
|
|
34
|
+
DENO: (existingPath, newPath) => Deno.link(existingPath, newPath).then(() => _duplojs_lang_either.right("file-system-link")).catch(handleDenoLinkError)
|
|
35
|
+
});
|
|
36
|
+
function link(...args) {
|
|
37
|
+
if (args.length === 1) {
|
|
38
|
+
const [newPath] = args;
|
|
39
|
+
return (existingPath) => linkImplementation(existingPath, newPath);
|
|
40
|
+
}
|
|
41
|
+
return linkImplementation(...args);
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.link = link;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FileSystemEither } from './types';
|
|
2
|
+
import * as DEither from "@duplojs/lang/either";
|
|
3
|
+
import type * as DPath from "@duplojs/lang/path";
|
|
4
|
+
export type LinkResult = FileSystemEither<DEither.Right<"link", void> | DEither.Left<"link-not-found", unknown> | DEither.Left<"link-permission-denied", unknown> | DEither.Left<"link-already-exists", unknown> | DEither.Left<"link-not-directory", unknown> | DEither.Left<"link-no-space", unknown> | DEither.Left<"link-read-only", unknown> | DEither.Left<"link-invalid-argument", unknown> | DEither.Left<"link-too-many-open-files", unknown> | DEither.Left<"link-busy", unknown> | DEither.Left<"link-cross-device", unknown> | DEither.Left<"link-error", unknown>>;
|
|
5
|
+
declare module '../implementor' {
|
|
6
|
+
interface ServerFunction {
|
|
7
|
+
link(existingPath: string & DPath.Path, newPath: string & DPath.Path): Promise<LinkResult>;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare function link(newPath: string & DPath.Path): (existingPath: string & DPath.Path) => Promise<LinkResult>;
|
|
11
|
+
export declare function link(existingPath: string & DPath.Path, newPath: string & DPath.Path): Promise<LinkResult>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { implementFunction, nodeFileSystem } from "../implementor.mjs";
|
|
2
|
+
import * as DEither from "@duplojs/lang/either";
|
|
3
|
+
//#region scripts/file/link.ts
|
|
4
|
+
function handleNodeLinkError(error) {
|
|
5
|
+
if (typeof error === "object" && error !== null && "code" in error) {
|
|
6
|
+
if (error.code === "ENOENT") return DEither.left("file-system-link-not-found", error);
|
|
7
|
+
else if (error.code === "EACCES" || error.code === "EPERM") return DEither.left("file-system-link-permission-denied", error);
|
|
8
|
+
else if (error.code === "EEXIST") return DEither.left("file-system-link-already-exists", error);
|
|
9
|
+
else if (error.code === "ENOTDIR") return DEither.left("file-system-link-not-directory", error);
|
|
10
|
+
else if (error.code === "ENOSPC") return DEither.left("file-system-link-no-space", error);
|
|
11
|
+
else if (error.code === "EROFS") return DEither.left("file-system-link-read-only", error);
|
|
12
|
+
else if (error.code === "EINVAL") return DEither.left("file-system-link-invalid-argument", error);
|
|
13
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") return DEither.left("file-system-link-too-many-open-files", error);
|
|
14
|
+
else if (error.code === "EBUSY") return DEither.left("file-system-link-busy", error);
|
|
15
|
+
else if (error.code === "EXDEV") return DEither.left("file-system-link-cross-device", error);
|
|
16
|
+
}
|
|
17
|
+
return DEither.left("file-system-link-error", error);
|
|
18
|
+
}
|
|
19
|
+
function handleDenoLinkError(error) {
|
|
20
|
+
if (error instanceof Deno.errors.NotFound) return DEither.left("file-system-link-not-found", error);
|
|
21
|
+
if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return DEither.left("file-system-link-permission-denied", error);
|
|
22
|
+
if (error instanceof Deno.errors.AlreadyExists) return DEither.left("file-system-link-already-exists", error);
|
|
23
|
+
if (error instanceof Deno.errors.NotADirectory) return DEither.left("file-system-link-not-directory", error);
|
|
24
|
+
if (error instanceof Deno.errors.InvalidData) return DEither.left("file-system-link-invalid-argument", error);
|
|
25
|
+
if (error instanceof Deno.errors.Busy) return DEither.left("file-system-link-busy", error);
|
|
26
|
+
return DEither.left("file-system-link-error", error);
|
|
27
|
+
}
|
|
28
|
+
const linkImplementation = implementFunction("link", {
|
|
29
|
+
NODE: async (existingPath, newPath) => {
|
|
30
|
+
return (await nodeFileSystem.value).link(existingPath, newPath).then(() => DEither.right("file-system-link")).catch(handleNodeLinkError);
|
|
31
|
+
},
|
|
32
|
+
DENO: (existingPath, newPath) => Deno.link(existingPath, newPath).then(() => DEither.right("file-system-link")).catch(handleDenoLinkError)
|
|
33
|
+
});
|
|
34
|
+
function link(...args) {
|
|
35
|
+
if (args.length === 1) {
|
|
36
|
+
const [newPath] = args;
|
|
37
|
+
return (existingPath) => linkImplementation(existingPath, newPath);
|
|
38
|
+
}
|
|
39
|
+
return linkImplementation(...args);
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { link };
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
let _duplojs_lang_chrono = require("@duplojs/lang/chrono");
|
|
8
|
+
_duplojs_lang_chrono = require_runtime.__toESM(_duplojs_lang_chrono, 1);
|
|
9
|
+
//#region scripts/file/linkStat.ts
|
|
10
|
+
function handleNodeLinkStatError(error) {
|
|
11
|
+
if (typeof error === "object" && error !== null && "code" in error) {
|
|
12
|
+
if (error.code === "ENOENT") return _duplojs_lang_either.left("file-system-link-stat-not-found", error);
|
|
13
|
+
else if (error.code === "EACCES" || error.code === "EPERM") return _duplojs_lang_either.left("file-system-link-stat-permission-denied", error);
|
|
14
|
+
else if (error.code === "ENOTDIR") return _duplojs_lang_either.left("file-system-link-stat-not-directory", error);
|
|
15
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") return _duplojs_lang_either.left("file-system-link-stat-too-many-open-files", error);
|
|
16
|
+
else if (error.code === "EBUSY") return _duplojs_lang_either.left("file-system-link-stat-busy", error);
|
|
17
|
+
}
|
|
18
|
+
return _duplojs_lang_either.left("file-system-link-stat-error", error);
|
|
19
|
+
}
|
|
20
|
+
function handleDenoLinkStatError(error) {
|
|
21
|
+
if (error instanceof Deno.errors.NotFound) return _duplojs_lang_either.left("file-system-link-stat-not-found", error);
|
|
22
|
+
if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return _duplojs_lang_either.left("file-system-link-stat-permission-denied", error);
|
|
23
|
+
if (error instanceof Deno.errors.NotADirectory) return _duplojs_lang_either.left("file-system-link-stat-not-directory", error);
|
|
24
|
+
if (error instanceof Deno.errors.Busy) return _duplojs_lang_either.left("file-system-link-stat-busy", error);
|
|
25
|
+
return _duplojs_lang_either.left("file-system-link-stat-error", error);
|
|
26
|
+
}
|
|
27
|
+
function createStatInfoWithFsSource(source) {
|
|
28
|
+
return {
|
|
29
|
+
isFile: source.isFile(),
|
|
30
|
+
isDirectory: source.isDirectory(),
|
|
31
|
+
isSymlink: source.isSymbolicLink(),
|
|
32
|
+
sizeBytes: source.size,
|
|
33
|
+
modifiedAt: _duplojs_lang_chrono.isSafeTimestamp(source.mtime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.mtime) : null,
|
|
34
|
+
accessedAt: _duplojs_lang_chrono.isSafeTimestamp(source.atime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.atime) : null,
|
|
35
|
+
createdAt: _duplojs_lang_chrono.isSafeTimestamp(source.birthtime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.birthtime) : null,
|
|
36
|
+
changedAt: _duplojs_lang_chrono.isSafeTimestamp(source.ctime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.ctime) : null,
|
|
37
|
+
deviceId: source.dev,
|
|
38
|
+
inode: source.ino,
|
|
39
|
+
permissionsMode: source.mode,
|
|
40
|
+
hardLinkCount: source.nlink,
|
|
41
|
+
ownerUserId: source.uid,
|
|
42
|
+
ownerGroupId: source.gid,
|
|
43
|
+
specialDeviceId: source.rdev,
|
|
44
|
+
ioBlockSize: source.blksize,
|
|
45
|
+
allocatedBlockCount: source.blocks,
|
|
46
|
+
isBlockDevice: source.isBlockDevice(),
|
|
47
|
+
isCharacterDevice: source.isCharacterDevice(),
|
|
48
|
+
isFifo: source.isFIFO(),
|
|
49
|
+
isSocket: source.isSocket()
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function createStatInfoWithDeno(source) {
|
|
53
|
+
return {
|
|
54
|
+
isFile: source.isFile,
|
|
55
|
+
isDirectory: source.isDirectory,
|
|
56
|
+
isSymlink: source.isSymlink,
|
|
57
|
+
sizeBytes: source.size,
|
|
58
|
+
modifiedAt: source.mtime && _duplojs_lang_chrono.isSafeTimestamp(source.mtime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.mtime) : null,
|
|
59
|
+
accessedAt: source.atime && _duplojs_lang_chrono.isSafeTimestamp(source.atime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.atime) : null,
|
|
60
|
+
createdAt: source.birthtime && _duplojs_lang_chrono.isSafeTimestamp(source.birthtime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.birthtime) : null,
|
|
61
|
+
changedAt: source.ctime && _duplojs_lang_chrono.isSafeTimestamp(source.ctime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.ctime) : null,
|
|
62
|
+
deviceId: source.dev,
|
|
63
|
+
inode: source.ino,
|
|
64
|
+
permissionsMode: source.mode,
|
|
65
|
+
hardLinkCount: source.nlink,
|
|
66
|
+
ownerUserId: source.uid,
|
|
67
|
+
ownerGroupId: source.gid,
|
|
68
|
+
specialDeviceId: source.rdev,
|
|
69
|
+
ioBlockSize: source.blksize,
|
|
70
|
+
allocatedBlockCount: source.blocks,
|
|
71
|
+
isBlockDevice: source.isBlockDevice,
|
|
72
|
+
isCharacterDevice: source.isCharDevice,
|
|
73
|
+
isFifo: source.isFifo,
|
|
74
|
+
isSocket: source.isSocket
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
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
|
+
},
|
|
81
|
+
DENO: (path) => Deno.lstat(path).then(_duplojs_lang_common.innerPipe(createStatInfoWithDeno, (value) => _duplojs_lang_either.right("file-system-link-stat", value))).catch(handleDenoLinkStatError)
|
|
82
|
+
});
|
|
83
|
+
//#endregion
|
|
84
|
+
exports.linkStat = linkStat;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StatInfo } from './stat';
|
|
2
|
+
import { FileSystemEither } from './types';
|
|
3
|
+
import type * as DPath from "@duplojs/lang/path";
|
|
4
|
+
import * as DEither from "@duplojs/lang/either";
|
|
5
|
+
export type LinkStatResult = FileSystemEither<DEither.Right<"link-stat", StatInfo> | DEither.Left<"link-stat-not-found", unknown> | DEither.Left<"link-stat-permission-denied", unknown> | DEither.Left<"link-stat-not-directory", unknown> | DEither.Left<"link-stat-too-many-open-files", unknown> | DEither.Left<"link-stat-busy", unknown> | DEither.Left<"link-stat-error", unknown>>;
|
|
6
|
+
declare module '../implementor' {
|
|
7
|
+
interface ServerFunction {
|
|
8
|
+
linkStat(path: string & DPath.Path): Promise<LinkStatResult>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare const linkStat: (path: string & DPath.Path) => Promise<LinkStatResult>;
|