-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmod.ts
More file actions
65 lines (61 loc) · 2.28 KB
/
mod.ts
File metadata and controls
65 lines (61 loc) · 2.28 KB
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
61
62
63
64
65
import * as path from "https://deno.land/x/std/path/mod.ts";
import { bootstrap } from "./src/bootstrap.ts";
import { buildSpec } from "./src/openapi.ts";
import { Command, HelpCommand, CompletionsCommand, UpgradeCommand, GithubProvider, DenoLandProvider } from "https://deno.land/x/cliffy/command/mod.ts";
import packageFile from "./package.json" with { type: "json" };
import {ModIoFsLocalService} from "./src/mod/io/fs/local/service.ts";
const fs = new ModIoFsLocalService();
//const home = Deno.env.get('HOME') ? Deno.env.get('HOME') as string : Deno.cwd();
// if(path.join(home,'Lethean') !== Deno.cwd()){
// Deno.chdir(path.join(home,'Lethean'))
// }
const cmds = await new Command()
.name('lthn')
.version(`v${packageFile.version}`)
.command(
"openapi",
"Creates OpenAPI definition json file.",
)
.action(async (_) => {
// Disable console.log to avoid printing the entire spec to the console
const origLog = console.log;
console.log = function() {
return;
};
Deno.writeTextFileSync("openapi.json", JSON.stringify(await buildSpec()));
console.log = origLog;
console.log(`openapi.json created in dir: ${Deno.cwd()}`);
Deno.exit(0);
})
.command(
"start",
"Starts the server.",
)
.option("-u, --ui <path:string>", "UI HTML files.")
.action(async (options) => {
const application = await bootstrap();
if(options['ui']){
const staticAssetsPath = path.dirname(path.fromFileUrl(import.meta.url)) +'/'+ options['ui'];
console.log('Static Assets Path:', staticAssetsPath)
application.useStaticAssets(staticAssetsPath);
}
await application.listen(Number(Deno.env.get("PORT") || 36911));
})
.command("help", new HelpCommand().global())
.command("completions", new CompletionsCommand())
.command(
"upgrade",
new UpgradeCommand({
main: "mod.ts",
args: ["--allow-all", "--unstable"],
provider: [
new DenoLandProvider({ name: "lthn"}),
new GithubProvider({ repository: "dappserver/server" }),
],
}),
)
.parse(Deno.args);
if(Deno.args.length === 0){
console.log('No command provided, use --help for more information')
Deno.exit(0)
}