git-dlp 0.2.0
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 +290 -0
- package/dist/git-dl.js +43 -0
- package/dist/git-dl.js.map +1 -0
- package/dist/package.json +138 -0
- package/dist/src/TaggedErrorVerifyingCause.js +27 -0
- package/dist/src/TaggedErrorVerifyingCause.js.map +1 -0
- package/dist/src/castToReadableStream.js +28 -0
- package/dist/src/castToReadableStream.js.map +1 -0
- package/dist/src/cli.js +8 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commandLineParams.js +172 -0
- package/dist/src/commandLineParams.js.map +1 -0
- package/dist/src/commonErrors.js +60 -0
- package/dist/src/commonErrors.js.map +1 -0
- package/dist/src/configContext.js +12 -0
- package/dist/src/configContext.js.map +1 -0
- package/dist/src/downloadEntityFromRepo.js +21 -0
- package/dist/src/downloadEntityFromRepo.js.map +1 -0
- package/dist/src/errors.js +10 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/getPathContents/ParsedMetaInfoAboutPathContentsFromGitHubAPI.js +43 -0
- package/dist/src/getPathContents/ParsedMetaInfoAboutPathContentsFromGitHubAPI.js.map +1 -0
- package/dist/src/getPathContents/PathContentsMetaInfo.js +71 -0
- package/dist/src/getPathContents/PathContentsMetaInfo.js.map +1 -0
- package/dist/src/getPathContents/RawStreamOfRepoPathContentsFromGitHubAPI.js +4 -0
- package/dist/src/getPathContents/RawStreamOfRepoPathContentsFromGitHubAPI.js.map +1 -0
- package/dist/src/getPathContents/RepoPathContentsFromGitHubAPI.js +51 -0
- package/dist/src/getPathContents/RepoPathContentsFromGitHubAPI.js.map +1 -0
- package/dist/src/getPathContents/index.js +5 -0
- package/dist/src/getPathContents/index.js.map +1 -0
- package/dist/src/getPathContents/parseGitLFSObjectEither.js +70 -0
- package/dist/src/getPathContents/parseGitLFSObjectEither.js.map +1 -0
- package/dist/src/getReadableTarGzStreamOfRepoDirectory.js +39 -0
- package/dist/src/getReadableTarGzStreamOfRepoDirectory.js.map +1 -0
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/octokit.js +6 -0
- package/dist/src/octokit.js.map +1 -0
- package/dist/src/unpackRepoFolderTarGzStreamToFs.js +31 -0
- package/dist/src/unpackRepoFolderTarGzStreamToFs.js.map +1 -0
- package/dist/src/writeFileStreamToDestinationPath.js +22 -0
- package/dist/src/writeFileStreamToDestinationPath.js.map +1 -0
- package/dist-types/git-dl.d.ts +3 -0
- package/dist-types/git-dl.d.ts.map +1 -0
- package/dist-types/src/TaggedErrorVerifyingCause.d.ts +38 -0
- package/dist-types/src/TaggedErrorVerifyingCause.d.ts.map +1 -0
- package/dist-types/src/castToReadableStream.d.ts +11 -0
- package/dist-types/src/castToReadableStream.d.ts.map +1 -0
- package/dist-types/src/cli.d.ts +8 -0
- package/dist-types/src/cli.d.ts.map +1 -0
- package/dist-types/src/commandLineParams.d.ts +108 -0
- package/dist-types/src/commandLineParams.d.ts.map +1 -0
- package/dist-types/src/commonErrors.d.ts +60 -0
- package/dist-types/src/commonErrors.d.ts.map +1 -0
- package/dist-types/src/configContext.d.ts +44 -0
- package/dist-types/src/configContext.d.ts.map +1 -0
- package/dist-types/src/downloadEntityFromRepo.d.ts +11 -0
- package/dist-types/src/downloadEntityFromRepo.d.ts.map +1 -0
- package/dist-types/src/errors.d.ts +10 -0
- package/dist-types/src/errors.d.ts.map +1 -0
- package/dist-types/src/getPathContents/ParsedMetaInfoAboutPathContentsFromGitHubAPI.d.ts +141 -0
- package/dist-types/src/getPathContents/ParsedMetaInfoAboutPathContentsFromGitHubAPI.d.ts.map +1 -0
- package/dist-types/src/getPathContents/PathContentsMetaInfo.d.ts +66 -0
- package/dist-types/src/getPathContents/PathContentsMetaInfo.d.ts.map +1 -0
- package/dist-types/src/getPathContents/RawStreamOfRepoPathContentsFromGitHubAPI.d.ts +9 -0
- package/dist-types/src/getPathContents/RawStreamOfRepoPathContentsFromGitHubAPI.d.ts.map +1 -0
- package/dist-types/src/getPathContents/RepoPathContentsFromGitHubAPI.d.ts +81 -0
- package/dist-types/src/getPathContents/RepoPathContentsFromGitHubAPI.d.ts.map +1 -0
- package/dist-types/src/getPathContents/index.d.ts +5 -0
- package/dist-types/src/getPathContents/index.d.ts.map +1 -0
- package/dist-types/src/getPathContents/parseGitLFSObjectEither.d.ts +40 -0
- package/dist-types/src/getPathContents/parseGitLFSObjectEither.d.ts.map +1 -0
- package/dist-types/src/getReadableTarGzStreamOfRepoDirectory.d.ts +13 -0
- package/dist-types/src/getReadableTarGzStreamOfRepoDirectory.d.ts.map +1 -0
- package/dist-types/src/index.d.ts +9 -0
- package/dist-types/src/index.d.ts.map +1 -0
- package/dist-types/src/octokit.d.ts +8 -0
- package/dist-types/src/octokit.d.ts.map +1 -0
- package/dist-types/src/unpackRepoFolderTarGzStreamToFs.d.ts +16 -0
- package/dist-types/src/unpackRepoFolderTarGzStreamToFs.d.ts.map +1 -0
- package/dist-types/src/writeFileStreamToDestinationPath.d.ts +16 -0
- package/dist-types/src/writeFileStreamToDestinationPath.d.ts.map +1 -0
- package/package.json +139 -0
- package/src/TaggedErrorVerifyingCause.ts +142 -0
- package/src/castToReadableStream.ts +44 -0
- package/src/cli.ts +14 -0
- package/src/commandLineParams.ts +257 -0
- package/src/commonErrors.ts +139 -0
- package/src/configContext.ts +46 -0
- package/src/downloadEntityFromRepo.ts +86 -0
- package/src/errors.ts +24 -0
- package/src/getPathContents/ParsedMetaInfoAboutPathContentsFromGitHubAPI.ts +76 -0
- package/src/getPathContents/PathContentsMetaInfo.ts +85 -0
- package/src/getPathContents/RawStreamOfRepoPathContentsFromGitHubAPI.ts +6 -0
- package/src/getPathContents/RepoPathContentsFromGitHubAPI.ts +82 -0
- package/src/getPathContents/index.ts +7 -0
- package/src/getPathContents/parseGitLFSObjectEither.ts +143 -0
- package/src/getReadableTarGzStreamOfRepoDirectory.ts +65 -0
- package/src/index.ts +13 -0
- package/src/octokit.ts +15 -0
- package/src/unpackRepoFolderTarGzStreamToFs.ts +61 -0
- package/src/writeFileStreamToDestinationPath.ts +45 -0
- package/template.env +13 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as Effect from 'effect/Effect';
|
|
2
|
+
export declare const PathContentsMetaInfo: Effect.Effect<{
|
|
3
|
+
readonly type: "dir";
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly treeSha: string;
|
|
7
|
+
readonly entries: readonly {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly sha: string;
|
|
11
|
+
readonly type: "dir" | "file" | "submodule" | "symlink";
|
|
12
|
+
readonly size: number;
|
|
13
|
+
}[];
|
|
14
|
+
readonly meta: "This nested directory can be downloaded as a git tree";
|
|
15
|
+
} | {
|
|
16
|
+
readonly type: "dir";
|
|
17
|
+
readonly treeSha: string;
|
|
18
|
+
readonly entries: readonly {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly sha: string;
|
|
22
|
+
readonly type: "dir" | "file" | "submodule" | "symlink";
|
|
23
|
+
readonly size: number;
|
|
24
|
+
}[];
|
|
25
|
+
readonly meta: "This root directory of the repo can be downloaded as a git tree";
|
|
26
|
+
readonly name?: never;
|
|
27
|
+
readonly path?: never;
|
|
28
|
+
} | {
|
|
29
|
+
readonly meta: "This file can be downloaded as a blob";
|
|
30
|
+
readonly blobSha: string;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly path: string;
|
|
33
|
+
readonly type: "file";
|
|
34
|
+
readonly size: number;
|
|
35
|
+
readonly treeSha?: never;
|
|
36
|
+
readonly entries?: never;
|
|
37
|
+
} | {
|
|
38
|
+
readonly meta: "This file can be downloaded as a git-LFS object";
|
|
39
|
+
readonly gitLFSObjectIdSha256: string;
|
|
40
|
+
readonly gitLFSVersion: string;
|
|
41
|
+
readonly blobSha: string;
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly path: string;
|
|
44
|
+
readonly type: "file";
|
|
45
|
+
readonly size: number;
|
|
46
|
+
readonly treeSha?: never;
|
|
47
|
+
readonly entries?: never;
|
|
48
|
+
} | {
|
|
49
|
+
readonly contentStream: Effect.Effect<import("node:stream").Readable, import("../castToReadableStream.ts").FailedToCastDataToReadableStreamError, never>;
|
|
50
|
+
readonly meta: "This file is small enough that GitHub API decided to inline it";
|
|
51
|
+
readonly blobSha: string;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly path: string;
|
|
54
|
+
readonly type: "file";
|
|
55
|
+
readonly size: number;
|
|
56
|
+
readonly treeSha?: never;
|
|
57
|
+
readonly entries?: never;
|
|
58
|
+
}, import("@octokit/request-error").RequestError | import("../commonErrors.ts").GitHubApiGeneralServerError | import("../commonErrors.ts").GitHubApiGeneralUserError | import("../commonErrors.ts").GitHubApiThingNotExistsOrYouDontHaveAccessError | import("../commonErrors.ts").GitHubApiRepoIsEmptyError | import("../commonErrors.ts").GitHubApiNoCommitFoundForGitRefError | import("../commonErrors.ts").GitHubApiBadCredentialsError | import("../commonErrors.ts").GitHubApiAuthRatelimitedError | import("../commonErrors.ts").GitHubApiRatelimitedError | import("effect/Cause").UnknownException | import("./ParsedMetaInfoAboutPathContentsFromGitHubAPI.ts").FailedToParseResponseFromRepoPathContentsMetaInfoAPIError | import("./parseGitLFSObjectEither.ts").InconsistentExpectedAndRealContentSizeError, Readonly<{
|
|
59
|
+
repo: Readonly<{
|
|
60
|
+
owner: string;
|
|
61
|
+
name: string;
|
|
62
|
+
}>;
|
|
63
|
+
pathToEntityInRepo: string;
|
|
64
|
+
gitRef: string;
|
|
65
|
+
}> | import("@octokit/core").Octokit>;
|
|
66
|
+
//# sourceMappingURL=PathContentsMetaInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PathContentsMetaInfo.d.ts","sourceRoot":"","sources":["../../../src/getPathContents/PathContentsMetaInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAMvC,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA8E/B,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const RawStreamOfRepoPathContentsFromGitHubAPI: import("effect/Effect").Effect<import("node:stream").Readable, import("../castToReadableStream.ts").FailedToCastDataToReadableStreamError | import("@octokit/request-error").RequestError | import("../commonErrors.ts").GitHubApiGeneralServerError | import("../commonErrors.ts").GitHubApiGeneralUserError | import("../commonErrors.ts").GitHubApiThingNotExistsOrYouDontHaveAccessError | import("../commonErrors.ts").GitHubApiRepoIsEmptyError | import("../commonErrors.ts").GitHubApiNoCommitFoundForGitRefError | import("../commonErrors.ts").GitHubApiBadCredentialsError | import("../commonErrors.ts").GitHubApiAuthRatelimitedError | import("../commonErrors.ts").GitHubApiRatelimitedError | import("effect/Cause").UnknownException, Readonly<{
|
|
2
|
+
repo: Readonly<{
|
|
3
|
+
owner: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}>;
|
|
6
|
+
pathToEntityInRepo: string;
|
|
7
|
+
gitRef: string;
|
|
8
|
+
}> | import("@octokit/core").Octokit>;
|
|
9
|
+
//# sourceMappingURL=RawStreamOfRepoPathContentsFromGitHubAPI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RawStreamOfRepoPathContentsFromGitHubAPI.d.ts","sourceRoot":"","sources":["../../../src/getPathContents/RawStreamOfRepoPathContentsFromGitHubAPI.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wCAAwC;;;;;;;qCAEpD,CAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { RequestError } from '@octokit/request-error';
|
|
2
|
+
import type { OctokitResponse } from '@octokit/types';
|
|
3
|
+
import * as Cause from 'effect/Cause';
|
|
4
|
+
import * as Effect from 'effect/Effect';
|
|
5
|
+
import { GitHubApiNoCommitFoundForGitRefError, GitHubApiRepoIsEmptyError, GitHubApiThingNotExistsOrYouDontHaveAccessError } from '../commonErrors.ts';
|
|
6
|
+
export declare const RepoPathContentsFromGitHubAPI: (format: "object" | "raw", streamBody?: boolean | undefined) => Effect.Effect<OctokitResponse<{
|
|
7
|
+
type: "dir" | "file" | "submodule" | "symlink";
|
|
8
|
+
size: number;
|
|
9
|
+
name: string;
|
|
10
|
+
path: string;
|
|
11
|
+
content?: string;
|
|
12
|
+
sha: string;
|
|
13
|
+
url: string;
|
|
14
|
+
git_url: string | null;
|
|
15
|
+
html_url: string | null;
|
|
16
|
+
download_url: string | null;
|
|
17
|
+
_links: {
|
|
18
|
+
git: string | null;
|
|
19
|
+
html: string | null;
|
|
20
|
+
self: string;
|
|
21
|
+
};
|
|
22
|
+
}[] | {
|
|
23
|
+
type: "file";
|
|
24
|
+
encoding: string;
|
|
25
|
+
size: number;
|
|
26
|
+
name: string;
|
|
27
|
+
path: string;
|
|
28
|
+
content: string;
|
|
29
|
+
sha: string;
|
|
30
|
+
url: string;
|
|
31
|
+
git_url: string | null;
|
|
32
|
+
html_url: string | null;
|
|
33
|
+
download_url: string | null;
|
|
34
|
+
_links: {
|
|
35
|
+
git: string | null;
|
|
36
|
+
html: string | null;
|
|
37
|
+
self: string;
|
|
38
|
+
};
|
|
39
|
+
target?: string;
|
|
40
|
+
submodule_git_url?: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: "symlink";
|
|
43
|
+
target: string;
|
|
44
|
+
size: number;
|
|
45
|
+
name: string;
|
|
46
|
+
path: string;
|
|
47
|
+
sha: string;
|
|
48
|
+
url: string;
|
|
49
|
+
git_url: string | null;
|
|
50
|
+
html_url: string | null;
|
|
51
|
+
download_url: string | null;
|
|
52
|
+
_links: {
|
|
53
|
+
git: string | null;
|
|
54
|
+
html: string | null;
|
|
55
|
+
self: string;
|
|
56
|
+
};
|
|
57
|
+
} | {
|
|
58
|
+
type: "submodule";
|
|
59
|
+
submodule_git_url: string;
|
|
60
|
+
size: number;
|
|
61
|
+
name: string;
|
|
62
|
+
path: string;
|
|
63
|
+
sha: string;
|
|
64
|
+
url: string;
|
|
65
|
+
git_url: string | null;
|
|
66
|
+
html_url: string | null;
|
|
67
|
+
download_url: string | null;
|
|
68
|
+
_links: {
|
|
69
|
+
git: string | null;
|
|
70
|
+
html: string | null;
|
|
71
|
+
self: string;
|
|
72
|
+
};
|
|
73
|
+
}, 200>, RequestError | import("../commonErrors.ts").GitHubApiGeneralServerError | import("../commonErrors.ts").GitHubApiGeneralUserError | GitHubApiThingNotExistsOrYouDontHaveAccessError | GitHubApiRepoIsEmptyError | GitHubApiNoCommitFoundForGitRefError | import("../commonErrors.ts").GitHubApiBadCredentialsError | import("../commonErrors.ts").GitHubApiAuthRatelimitedError | import("../commonErrors.ts").GitHubApiRatelimitedError | Cause.UnknownException, Readonly<{
|
|
74
|
+
repo: Readonly<{
|
|
75
|
+
owner: string;
|
|
76
|
+
name: string;
|
|
77
|
+
}>;
|
|
78
|
+
pathToEntityInRepo: string;
|
|
79
|
+
gitRef: string;
|
|
80
|
+
}> | import("@octokit/core").Octokit>;
|
|
81
|
+
//# sourceMappingURL=RepoPathContentsFromGitHubAPI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepoPathContentsFromGitHubAPI.d.ts","sourceRoot":"","sources":["../../../src/getPathContents/RepoPathContentsFromGitHubAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EACL,oCAAoC,EACpC,yBAAyB,EACzB,+CAA+C,EAEhD,MAAM,oBAAoB,CAAA;AAO3B,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA4CxC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FailedToParseResponseFromRepoPathContentsMetaInfoAPIError } from './ParsedMetaInfoAboutPathContentsFromGitHubAPI.ts';
|
|
2
|
+
export { PathContentsMetaInfo } from './PathContentsMetaInfo.ts';
|
|
3
|
+
export { FailedToParseGitLFSInfoError, InconsistentExpectedAndRealContentSizeError, } from './parseGitLFSObjectEither.ts';
|
|
4
|
+
export { RawStreamOfRepoPathContentsFromGitHubAPI } from './RawStreamOfRepoPathContentsFromGitHubAPI.ts';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/getPathContents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yDAAyD,EAAE,MAAM,mDAAmD,CAAA;AAC7H,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EACL,4BAA4B,EAC5B,2CAA2C,GAC5C,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,wCAAwC,EAAE,MAAM,+CAA+C,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as Either from 'effect/Either';
|
|
2
|
+
import * as ParseResult from 'effect/ParseResult';
|
|
3
|
+
import { type TaggedErrorClass } from '../TaggedErrorVerifyingCause.ts';
|
|
4
|
+
export declare const parseGitLFSObjectEither: ({ contentAsBuffer, expectedContentSize, }: {
|
|
5
|
+
contentAsBuffer: Buffer<ArrayBuffer>;
|
|
6
|
+
expectedContentSize: number;
|
|
7
|
+
}) => Either.Either<"This is not a git LFS object" | {
|
|
8
|
+
readonly gitLFSObjectIdSha256: string;
|
|
9
|
+
readonly gitLFSVersion: string;
|
|
10
|
+
}, InconsistentExpectedAndRealContentSizeError>;
|
|
11
|
+
export type FailedToParseGitLFSInfoErrorClass = TaggedErrorClass<{
|
|
12
|
+
ErrorName: 'FailedToParseGitLFSInfoError';
|
|
13
|
+
ExpectedCauseClass: typeof ParseResult.ParseError;
|
|
14
|
+
DynamicContext: {
|
|
15
|
+
partOfContentThatCouldBeGitLFSInfo: string;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
declare const _1: FailedToParseGitLFSInfoErrorClass;
|
|
19
|
+
export declare class FailedToParseGitLFSInfoError extends _1 {
|
|
20
|
+
}
|
|
21
|
+
type InconsistentSizesDynamicContext = {
|
|
22
|
+
actual: number;
|
|
23
|
+
expected: number;
|
|
24
|
+
gitLFSInfo: Either.Either<Readonly<{
|
|
25
|
+
version: string;
|
|
26
|
+
oidSha256: string;
|
|
27
|
+
size: number;
|
|
28
|
+
}>, InstanceType<FailedToParseGitLFSInfoErrorClass>>;
|
|
29
|
+
};
|
|
30
|
+
declare const _2: TaggedErrorClass<{
|
|
31
|
+
ErrorName: 'InconsistentExpectedAndRealContentSizeError';
|
|
32
|
+
StaticContext: {
|
|
33
|
+
comment: string;
|
|
34
|
+
};
|
|
35
|
+
DynamicContext: InconsistentSizesDynamicContext;
|
|
36
|
+
}>;
|
|
37
|
+
export declare class InconsistentExpectedAndRealContentSizeError extends _2 {
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=parseGitLFSObjectEither.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseGitLFSObjectEither.d.ts","sourceRoot":"","sources":["../../../src/getPathContents/parseGitLFSObjectEither.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AAGjD,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,iCAAiC,CAAA;AAExC,eAAO,MAAM,uBAAuB,GAAI,2CAGrC;IACD,eAAe,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;IACpC,mBAAmB,EAAE,MAAM,CAAA;CAC5B;;;+CA2CG,CAAA;AA0BJ,MAAM,MAAM,iCAAiC,GAAG,gBAAgB,CAAC;IAC/D,SAAS,EAAE,8BAA8B,CAAA;IACzC,kBAAkB,EAAE,OAAO,WAAW,CAAC,UAAU,CAAA;IACjD,cAAc,EAAE;QAAE,kCAAkC,EAAE,MAAM,CAAA;KAAE,CAAA;CAC/D,CAAC,CAAA;AAEF,QAAA,MAAM,EAAE,EAAE,iCAOP,CAAA;AAEH,qBAAa,4BAA6B,SAAQ,EAAE;CAAG;AAEvD,KAAK,+BAA+B,GAAG;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAC,MAAM,CACvB,QAAQ,CAAC;QACP,OAAO,EAAE,MAAM,CAAA;QACf,SAAS,EAAE,MAAM,CAAA;QACjB,IAAI,EAAE,MAAM,CAAA;KACb,CAAC,EACF,YAAY,CAAC,iCAAiC,CAAC,CAChD,CAAA;CACF,CAAA;AAKD,QAAA,MAAM,EAAE,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,6CAA6C,CAAA;IACxD,aAAa,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;IAClC,cAAc,EAAE,+BAA+B,CAAA;CAChD,CAiBA,CAAA;AAED,qBAAa,2CAA4C,SAAQ,EAAE;CAAG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RequestError } from '@octokit/request-error';
|
|
2
|
+
import * as Cause from 'effect/Cause';
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
import { GitHubApiGeneralUserError } from './commonErrors.ts';
|
|
5
|
+
export declare const getReadableTarGzStreamOfRepoDirectory: (gitRefWhichWillBeUsedToIdentifyGitTree?: string) => Effect.Effect<import("node:stream").Readable, import("./castToReadableStream.ts").FailedToCastDataToReadableStreamError | RequestError | import("./commonErrors.ts").GitHubApiGeneralServerError | GitHubApiGeneralUserError | import("./commonErrors.ts").GitHubApiThingNotExistsOrYouDontHaveAccessError | import("./commonErrors.ts").GitHubApiBadCredentialsError | import("./commonErrors.ts").GitHubApiAuthRatelimitedError | import("./commonErrors.ts").GitHubApiRatelimitedError | Cause.UnknownException, Readonly<{
|
|
6
|
+
repo: Readonly<{
|
|
7
|
+
owner: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}>;
|
|
10
|
+
pathToEntityInRepo: string;
|
|
11
|
+
gitRef: string;
|
|
12
|
+
}> | import("@octokit/core").Octokit>;
|
|
13
|
+
//# sourceMappingURL=getReadableTarGzStreamOfRepoDirectory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getReadableTarGzStreamOfRepoDirectory.d.ts","sourceRoot":"","sources":["../../src/getReadableTarGzStreamOfRepoDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAErD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,OAAO,EACL,yBAAyB,EAE1B,MAAM,mBAAmB,CAAA;AAI1B,eAAO,MAAM,qCAAqC,GAChD,yCAAyC,MAAM;;;;;;;qCAM9C,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
*/
|
|
4
|
+
export * from './cli.ts';
|
|
5
|
+
export type { InputConfig, OutputConfig, SingleTargetConfig, } from './configContext.ts';
|
|
6
|
+
export { downloadEntityFromRepo } from './downloadEntityFromRepo.ts';
|
|
7
|
+
export * from './errors.ts';
|
|
8
|
+
export { OctokitLayer } from './octokit.ts';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAA;AACxB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,kBAAkB,GACnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Octokit, type OctokitOptions } from '@octokit/core';
|
|
2
|
+
import * as Context from 'effect/Context';
|
|
3
|
+
import * as Layer from 'effect/Layer';
|
|
4
|
+
type OctokitTag = Context.Tag<Octokit, Octokit>;
|
|
5
|
+
export declare const OctokitTag: OctokitTag;
|
|
6
|
+
export declare const OctokitLayer: (options?: OctokitOptions) => Layer.Layer<Octokit, never, never>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=octokit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"octokit.d.ts","sourceRoot":"","sources":["../../src/octokit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAE5D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAIrC,KAAK,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAE/C,eAAO,MAAM,UAAU,EAAE,UAAsD,CAAA;AAE/E,eAAO,MAAM,YAAY,EAAE,CACzB,OAAO,CAAC,EAAE,cAAc,KACrB,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAC0B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import { type TaggedErrorClass } from './TaggedErrorVerifyingCause.ts';
|
|
4
|
+
export declare const unpackRepoFolderTarGzStreamToFs: <E, R>(self: Effect.Effect<Readable, E, R>) => Effect.Effect<void, E | FailedToUnpackRepoFolderTarGzStreamToFsError, Readonly<{
|
|
5
|
+
localPathAtWhichEntityFromRepoWillBeAvailable: string;
|
|
6
|
+
}> | R>;
|
|
7
|
+
declare const _1: TaggedErrorClass<{
|
|
8
|
+
ErrorName: 'FailedToUnpackRepoFolderTarGzStreamToFsError';
|
|
9
|
+
DynamicContext: {
|
|
10
|
+
cause: unknown;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export declare class FailedToUnpackRepoFolderTarGzStreamToFsError extends _1 {
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=unpackRepoFolderTarGzStreamToFs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpackRepoFolderTarGzStreamToFs.d.ts","sourceRoot":"","sources":["../../src/unpackRepoFolderTarGzStreamToFs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAM3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,gCAAgC,CAAA;AAMvC,eAAO,MAAM,+BAA+B,GAAI,CAAC,EAAE,CAAC,EAClD,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;;OA6BjC,CAAA;AAIJ,QAAA,MAAM,EAAE,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,8CAA8C,CAAA;IACzD,cAAc,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAA;CACnC,CAGA,CAAA;AAED,qBAAa,4CAA6C,SAAQ,EAAE;CAAG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import { type TaggedErrorClass } from './TaggedErrorVerifyingCause.ts';
|
|
4
|
+
export declare const writeFileStreamToDestinationPath: <E, R>(self: Effect.Effect<Readable, E, R>) => Effect.Effect<void, E | FailedToWriteFileStreamToDestinationPathError, Readonly<{
|
|
5
|
+
localPathAtWhichEntityFromRepoWillBeAvailable: string;
|
|
6
|
+
}> | R>;
|
|
7
|
+
declare const _1: TaggedErrorClass<{
|
|
8
|
+
ErrorName: 'FailedToWriteFileStreamToDestinationPathError';
|
|
9
|
+
DynamicContext: {
|
|
10
|
+
cause: unknown;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export declare class FailedToWriteFileStreamToDestinationPathError extends _1 {
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=writeFileStreamToDestinationPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeFileStreamToDestinationPath.d.ts","sourceRoot":"","sources":["../../src/writeFileStreamToDestinationPath.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAG3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,gCAAgC,CAAA;AAIvC,eAAO,MAAM,gCAAgC,GAAI,CAAC,EAAE,CAAC,EACnD,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;;OAiBjC,CAAA;AAIJ,QAAA,MAAM,EAAE,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,+CAA+C,CAAA;IAC1D,cAAc,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAA;CACnC,CAGA,CAAA;AAED,qBAAa,6CAA8C,SAAQ,EAAE;CAAG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "git-dlp",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"description": "Download any directory at any depth from any repo on GitHub on any git ref",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@effect/language-service": "^0.86.2",
|
|
8
|
+
"@effect/vitest": "^0.29.0",
|
|
9
|
+
"@evadev/tsconfig": "1.0.0",
|
|
10
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
11
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
12
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
13
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
14
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
15
|
+
"rollup": "^4.60.4",
|
|
16
|
+
"rollup-plugin-visualizer": "^7.0.1",
|
|
17
|
+
"ts-namespace-import": "nounder/ts-namespace-import",
|
|
18
|
+
"ts-patch": "^4.0.1",
|
|
19
|
+
"typescript": "^6.0.3",
|
|
20
|
+
"vitest": "^4.1.7"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@effect/cli": "^0.75.1",
|
|
24
|
+
"@effect/platform": "^0.96.1",
|
|
25
|
+
"@effect/platform-node": "^0.106.0",
|
|
26
|
+
"effect": "^3.19.16"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@evadev/effect-helpers": "0.1.2",
|
|
30
|
+
"@octokit/core": "^7.0.6",
|
|
31
|
+
"@octokit/request-error": "^7.1.0",
|
|
32
|
+
"@octokit/types": "^16.0.0",
|
|
33
|
+
"@total-typescript/ts-reset": "^0.6.1",
|
|
34
|
+
"@types/tar-fs": "^2.0.4",
|
|
35
|
+
"effect-errors": "^1.10.22",
|
|
36
|
+
"outdent": "^0.8.0",
|
|
37
|
+
"tar-fs": "^3.0.8",
|
|
38
|
+
"tsafe": "^1.8.5"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/nikelborm/effect-garden/tree/main/packages/git-dl#readme",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/nikelborm/effect-garden/issues",
|
|
43
|
+
"email": "evadev@duck.com"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"github",
|
|
47
|
+
"git",
|
|
48
|
+
"octokit",
|
|
49
|
+
"github-api",
|
|
50
|
+
"folder",
|
|
51
|
+
"scraper",
|
|
52
|
+
"downloader",
|
|
53
|
+
"download",
|
|
54
|
+
"extract",
|
|
55
|
+
"tarball",
|
|
56
|
+
"targz",
|
|
57
|
+
"directory"
|
|
58
|
+
],
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "git+ssh://git@github.com/nikelborm/effect-garden.git",
|
|
62
|
+
"directory": "packages/git-dl"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "./scripts/build.sh",
|
|
66
|
+
"coverage": "vitest run --coverage",
|
|
67
|
+
"doc": "./scripts/generate_docs.sh",
|
|
68
|
+
"docs": "./scripts/generate_docs.sh",
|
|
69
|
+
"print-important-ts-files": "find . -type f -name '*.ts' |grep -vE '^./(node_modules|tmp|dist|(vite\\.config|.*\\.spec|scratchpad)\\.ts)'",
|
|
70
|
+
"scratchpad": "node --use-strict --env-file=.env ./scratchpad.ts",
|
|
71
|
+
"start": "node --env-file=.env ./git-dl.ts",
|
|
72
|
+
"test": "vitest --typecheck --watch",
|
|
73
|
+
"test-jsr": "tspc && jsr publish --dry-run",
|
|
74
|
+
"test-once": "vitest --run",
|
|
75
|
+
"watch-docs": "find src/ cli.ts index.ts errors.ts ./scripts/generate_docs.sh | entr -can ./scripts/generate_docs.sh"
|
|
76
|
+
},
|
|
77
|
+
"author": {
|
|
78
|
+
"name": "nikelborm",
|
|
79
|
+
"email": "evadev@duck.com",
|
|
80
|
+
"url": "https://github.com/nikelborm"
|
|
81
|
+
},
|
|
82
|
+
"contributors": [
|
|
83
|
+
{
|
|
84
|
+
"name": "nikelborm",
|
|
85
|
+
"email": "evadev@duck.com",
|
|
86
|
+
"url": "https://github.com/nikelborm"
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"maintainers": [
|
|
90
|
+
{
|
|
91
|
+
"name": "nikelborm",
|
|
92
|
+
"email": "evadev@duck.com",
|
|
93
|
+
"url": "https://github.com/nikelborm"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"license": "MIT",
|
|
97
|
+
"private": false,
|
|
98
|
+
"publishConfig": {
|
|
99
|
+
"access": "public",
|
|
100
|
+
"provenance": false
|
|
101
|
+
},
|
|
102
|
+
"exports": {
|
|
103
|
+
".": {
|
|
104
|
+
"types": "./dist-types/index.d.ts",
|
|
105
|
+
"default": "./dist/index.js"
|
|
106
|
+
},
|
|
107
|
+
"./*.js": {
|
|
108
|
+
"types": "./dist-types/src/*.d.ts",
|
|
109
|
+
"default": "./dist/src/*.js"
|
|
110
|
+
},
|
|
111
|
+
"./*.ts": "./src/*.ts",
|
|
112
|
+
"./*": {
|
|
113
|
+
"types": "./dist-types/src/*.d.ts",
|
|
114
|
+
"default": "./dist/src/*.js"
|
|
115
|
+
},
|
|
116
|
+
"./internal/*": null,
|
|
117
|
+
"./package.json": "./package.json"
|
|
118
|
+
},
|
|
119
|
+
"main": "./dist/index.js",
|
|
120
|
+
"module": "./dist/index.js",
|
|
121
|
+
"types": "./dist-types/index.d.ts",
|
|
122
|
+
"bin": {
|
|
123
|
+
"gdl": "dist/git-dl.js",
|
|
124
|
+
"git-dl": "dist/git-dl.js"
|
|
125
|
+
},
|
|
126
|
+
"files": [
|
|
127
|
+
"dist",
|
|
128
|
+
"dist-types",
|
|
129
|
+
"index.ts",
|
|
130
|
+
"cli.ts",
|
|
131
|
+
"errors.ts",
|
|
132
|
+
"template.env",
|
|
133
|
+
"src",
|
|
134
|
+
"!dist/minified",
|
|
135
|
+
"!**/*.tsbuildinfo",
|
|
136
|
+
"!**/*.spec.*",
|
|
137
|
+
"!**/scratchpad.*"
|
|
138
|
+
]
|
|
139
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { Equals } from 'tsafe'
|
|
2
|
+
|
|
3
|
+
import type * as Cause from 'effect/Cause'
|
|
4
|
+
import * as Data from 'effect/Data'
|
|
5
|
+
import * as Predicate from 'effect/Predicate'
|
|
6
|
+
|
|
7
|
+
const removeLastIfItIsEmptyObject = (arr: Array<unknown>) =>
|
|
8
|
+
Object.keys(arr.at(-1) ?? {}).length ? arr : arr.slice(0, -1)
|
|
9
|
+
|
|
10
|
+
export const buildTaggedErrorClassVerifyingCause =
|
|
11
|
+
<const DynamicContext extends Record<string, unknown> = {}>() =>
|
|
12
|
+
<
|
|
13
|
+
const ErrorName extends string,
|
|
14
|
+
Config extends {
|
|
15
|
+
ErrorName: ErrorName
|
|
16
|
+
ExpectedCauseClass: ExpectedCauseClass
|
|
17
|
+
StaticContext: StaticContext
|
|
18
|
+
DynamicContext: DynamicContext
|
|
19
|
+
},
|
|
20
|
+
const StaticContext extends Record<string, unknown> = {},
|
|
21
|
+
ExpectedCauseClass extends WideErrorConstructor | undefined = undefined,
|
|
22
|
+
>(
|
|
23
|
+
errorName: ErrorName,
|
|
24
|
+
customMessage: string | ((...args: MessageRendererArgs<Config>) => string),
|
|
25
|
+
expectedCauseClass?: ExpectedCauseClass,
|
|
26
|
+
staticContext?: StaticContext,
|
|
27
|
+
): TaggedErrorClass<Config> => {
|
|
28
|
+
// TODO: Consider using Schema.TaggedError instead of Data.TaggedError
|
|
29
|
+
const CustomTaggedErrorClass = Data.TaggedError(errorName)<
|
|
30
|
+
Record<'message' | '_tag' | 'name', unknown>
|
|
31
|
+
>
|
|
32
|
+
|
|
33
|
+
class Base extends CustomTaggedErrorClass {
|
|
34
|
+
constructor(...args: ConstructorArgs<Config>) {
|
|
35
|
+
if (expectedCauseClass && !(args[0] instanceof expectedCauseClass))
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Provided cause of incorrect type to "${
|
|
38
|
+
errorName
|
|
39
|
+
}" class. Expected cause class: "${expectedCauseClass.name}"`,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
const customMessageRendererArgs = removeLastIfItIsEmptyObject(
|
|
43
|
+
expectedCauseClass
|
|
44
|
+
? [args[0], { ...(args[1] ?? {}), ...staticContext }]
|
|
45
|
+
: [{ ...(args[0] ?? {}), ...staticContext }],
|
|
46
|
+
) as MessageRendererArgs<Config>
|
|
47
|
+
|
|
48
|
+
super({
|
|
49
|
+
name: errorName,
|
|
50
|
+
message: Predicate.isFunction(customMessage)
|
|
51
|
+
? customMessage(...customMessageRendererArgs)
|
|
52
|
+
: customMessage,
|
|
53
|
+
...(!!expectedCauseClass && { cause: args[0] }),
|
|
54
|
+
...staticContext,
|
|
55
|
+
...(args[+!!expectedCauseClass] ?? {}), // dynamic context
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return Base as TaggedErrorClass<Config>
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type TaggedErrorClass<Config extends ConfigTemplate> = [string] extends [
|
|
64
|
+
Config['ErrorName'],
|
|
65
|
+
]
|
|
66
|
+
? 'ErrorName should be a string literal'
|
|
67
|
+
: new (
|
|
68
|
+
...args: ConstructorArgs<Config>
|
|
69
|
+
) => Cause.YieldableError &
|
|
70
|
+
Readonly<
|
|
71
|
+
{
|
|
72
|
+
message: string
|
|
73
|
+
_tag: Config['ErrorName']
|
|
74
|
+
name: Config['ErrorName']
|
|
75
|
+
} & GetValueByKey<Config, 'DynamicContext', {}> &
|
|
76
|
+
GetValueByKey<Config, 'StaticContext', {}> &
|
|
77
|
+
IsExpectedCauseClassManuallySpecified<
|
|
78
|
+
Config,
|
|
79
|
+
{ cause: GetCauseInstance<Config> },
|
|
80
|
+
{}
|
|
81
|
+
>
|
|
82
|
+
>
|
|
83
|
+
|
|
84
|
+
type ConstructorArgs<Config extends ConfigTemplate> = CauseArgTuple<
|
|
85
|
+
Config,
|
|
86
|
+
GetValueByKey<Config, 'DynamicContext', {}>
|
|
87
|
+
>
|
|
88
|
+
|
|
89
|
+
type MessageRendererArgs<Config extends ConfigTemplate> = CauseArgTuple<
|
|
90
|
+
Config,
|
|
91
|
+
GetValueByKey<Config, 'DynamicContext', {}> &
|
|
92
|
+
GetValueByKey<Config, 'StaticContext', {}>
|
|
93
|
+
>
|
|
94
|
+
|
|
95
|
+
type ConfigTemplate = {
|
|
96
|
+
ErrorName: string
|
|
97
|
+
ExpectedCauseClass?: WideErrorConstructor | undefined
|
|
98
|
+
StaticContext?: Record<string, unknown> | undefined
|
|
99
|
+
DynamicContext?: Record<string, unknown> | undefined
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
type CauseArgTuple<Config extends ConfigTemplate, Context> = [
|
|
103
|
+
...IsExpectedCauseClassManuallySpecified<
|
|
104
|
+
Config,
|
|
105
|
+
[cause: GetCauseInstance<Config>],
|
|
106
|
+
[]
|
|
107
|
+
>,
|
|
108
|
+
...(Equals<Context, {}> extends true ? [] : [context: Readonly<Context>]),
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
type IsExpectedCauseClassManuallySpecified<
|
|
112
|
+
Config extends ConfigTemplate,
|
|
113
|
+
IfTrue,
|
|
114
|
+
IfFalse,
|
|
115
|
+
> =
|
|
116
|
+
GetValueByKey<
|
|
117
|
+
Config,
|
|
118
|
+
'ExpectedCauseClass',
|
|
119
|
+
WideErrorConstructor | undefined
|
|
120
|
+
> extends infer ExpectedCauseClass
|
|
121
|
+
? [ExpectedCauseClass] extends [WideErrorConstructor]
|
|
122
|
+
? IfTrue
|
|
123
|
+
: IfFalse
|
|
124
|
+
: never
|
|
125
|
+
|
|
126
|
+
type GetCauseInstance<Config extends ConfigTemplate> = InstanceType<
|
|
127
|
+
Exclude<Config['ExpectedCauseClass'], undefined>
|
|
128
|
+
>
|
|
129
|
+
|
|
130
|
+
export type GetValueByKey<
|
|
131
|
+
Config extends Record<string, unknown>,
|
|
132
|
+
Key extends string,
|
|
133
|
+
Default,
|
|
134
|
+
> = [Key] extends [keyof Config]
|
|
135
|
+
? Exclude<Config[Key], undefined> extends infer TargetValue
|
|
136
|
+
? [TargetValue] extends [never]
|
|
137
|
+
? Default
|
|
138
|
+
: TargetValue
|
|
139
|
+
: Default
|
|
140
|
+
: Default
|
|
141
|
+
|
|
142
|
+
type WideErrorConstructor = new (...args: any[]) => Error
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Readable } from 'node:stream'
|
|
2
|
+
import { ReadableStream } from 'node:stream/web'
|
|
3
|
+
|
|
4
|
+
import * as Effect from 'effect/Effect'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
buildTaggedErrorClassVerifyingCause,
|
|
8
|
+
type TaggedErrorClass,
|
|
9
|
+
} from './TaggedErrorVerifyingCause.ts'
|
|
10
|
+
|
|
11
|
+
// TODO: should eventually delete this shit because:
|
|
12
|
+
// 1. Effect has streams and I now know them well
|
|
13
|
+
// 2. Effect has Platform's utilities like BunSink and BunStream
|
|
14
|
+
export const CastToReadableStream = <E, R>(
|
|
15
|
+
self: Effect.Effect<unknown, E, R>,
|
|
16
|
+
) =>
|
|
17
|
+
Effect.gen(function* () {
|
|
18
|
+
const data = yield* self
|
|
19
|
+
|
|
20
|
+
if (data instanceof ArrayBuffer || data instanceof Buffer)
|
|
21
|
+
return new Readable({
|
|
22
|
+
read() {
|
|
23
|
+
this.push(data)
|
|
24
|
+
this.push(null)
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
if (data instanceof ReadableStream) return Readable.fromWeb(data)
|
|
29
|
+
|
|
30
|
+
if (data instanceof Readable) return data
|
|
31
|
+
|
|
32
|
+
return yield* new FailedToCastDataToReadableStreamError()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
// Extracting to a separate type is required by JSR, so that consumers of the
|
|
36
|
+
// library will have much faster type inference
|
|
37
|
+
const _1: TaggedErrorClass<{
|
|
38
|
+
ErrorName: 'FailedToCastDataToReadableStreamError'
|
|
39
|
+
}> = buildTaggedErrorClassVerifyingCause()(
|
|
40
|
+
'FailedToCastDataToReadableStreamError',
|
|
41
|
+
'Error: Failed to cast data to Readable stream, type of argument is not familiar',
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
export class FailedToCastDataToReadableStreamError extends _1 {}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable in {@link https://effect.website/ Effect} applications CLI Options
|
|
3
|
+
* backed by ENV variables
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
destinationPathCLIOptionBackedByEnv,
|
|
10
|
+
gitRefCLIOptionBackedByEnv,
|
|
11
|
+
pathToEntityInRepoCLIOptionBackedByEnv,
|
|
12
|
+
repoNameCLIOptionBackedByEnv,
|
|
13
|
+
repoOwnerCLIOptionBackedByEnv,
|
|
14
|
+
} from './commandLineParams.ts'
|