-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcli.js
executable file
·43 lines (37 loc) · 1.29 KB
/
cli.js
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
#!/usr/bin/env node
import dotenv from 'dotenv';
import path from 'path';
import { fileURLToPath } from 'url';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
dotenv.config();
// Parse command-line arguments
const argv = yargs(hideBin(process.argv))
.option('indexerBaseUrl', {
alias: 'b',
type: 'string',
description: 'The base URL for the indexer API',
default: process.env.PUBLIC_INDEXER_BASE_URL || 'http://localhost:8080/api/v1'
})
.option('indexerWsUrl', {
alias: 'w',
type: 'string',
description: 'The WebSocket URL for live updates',
default: process.env.PUBLIC_INDEXER_WS_URL || 'ws://localhost:8080/ws/liveblocks'
})
.argv;
// Set environment variables
process.env.PUBLIC_INDEXER_BASE_URL = argv.indexerBaseUrl;
process.env.PUBLIC_INDEXER_WS_URL = argv.indexerWsUrl;
// Resolve the correct path to build/index.js
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const appPath = path.resolve(__dirname, 'build', 'index.js');
// Dynamically import the build/index.js file
import(appPath)
.then(() => {
console.log('Yaci Viewer started successfully!');
})
.catch((err) => {
console.error('Error starting Yaci Viewer:', err);
process.exit(1);
});