-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch-github-folder.ts
executable file
·60 lines (55 loc) · 1.75 KB
/
fetch-github-folder.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env node
import { CliConfig } from '@effect/cli';
import { make, run } from '@effect/cli/Command';
import { layer as NodeFileSystemLayer } from '@effect/platform-node-shared/NodeFileSystem';
import { layer as NodePathLayer } from '@effect/platform-node-shared/NodePath';
import { runMain } from '@effect/platform-node-shared/NodeRuntime';
import { layer as NodeTerminalLayer } from '@effect/platform-node-shared/NodeTerminal';
import { provide } from 'effect/Effect';
import { pipe } from 'effect/Function';
import {
destinationPathCLIOptionBackedByEnv,
downloadEntityFromRepo,
gitRefCLIOptionBackedByEnv,
OctokitLayer,
pathToEntityInRepoCLIOptionBackedByEnv,
repoNameCLIOptionBackedByEnv,
repoOwnerCLIOptionBackedByEnv,
} from './src/index.js';
// Those values updated automatically. If you edit names of constants or
// move them to a different file, update ./scripts/build.sh
const PACKAGE_VERSION = '0.1.20';
const PACKAGE_NAME = 'fetch-github-folder';
const appCommand = make(
PACKAGE_NAME,
{
repo: {
owner: repoOwnerCLIOptionBackedByEnv,
name: repoNameCLIOptionBackedByEnv,
},
pathToEntityInRepo: pathToEntityInRepoCLIOptionBackedByEnv,
localPathAtWhichEntityFromRepoWillBeAvailable:
destinationPathCLIOptionBackedByEnv,
gitRef: gitRefCLIOptionBackedByEnv,
},
downloadEntityFromRepo,
);
const cli = run(appCommand, {
// those values will be filled automatically from package.json
name: PACKAGE_NAME,
version: PACKAGE_VERSION,
});
pipe(
process.argv,
cli,
provide(NodeFileSystemLayer),
provide(NodePathLayer),
provide(NodeTerminalLayer),
provide(CliConfig.layer({ showTypes: false })),
provide(
OctokitLayer({
// auth: getEnvVarOrFail('GITHUB_ACCESS_TOKEN'),
}),
),
runMain,
);