-
Notifications
You must be signed in to change notification settings - Fork 0
/
netstat.ts
39 lines (33 loc) · 1.08 KB
/
netstat.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
#!/usr/bin/env node
import path from "path";
import { URL } from 'url'
import { Command } from 'commander'
import NetStatArgs from './src/importData/NetStatArgs.js'
import ImportMap from './src/importData/ImportMap.js'
import netStatImportMap from './src/utils/netStatImportMap.js'
const cli = new Command()
cli
.requiredOption(
'-p, --pathToFile [type]',
'<string> path to package.importmap.json',
path.join(process.cwd(), 'package.importmap.json')
)
.option('-u, --baseUrl [type]', '<string> base url to server with modules')
.parse()
const opts = cli.opts()
const pathToFile = opts['pathToFile']
const baseUrl = opts['baseUrl']
const parsedBaseUrl = new URL(baseUrl)
const netStatArgs: NetStatArgs = {
pathToPackageImportmapJson: pathToFile,
protocol: parsedBaseUrl.protocol,
hostname: parsedBaseUrl.hostname,
pathname: parsedBaseUrl.pathname,
port: parsedBaseUrl.port,
}
const importMap = ImportMap.fromFile(pathToFile)
if (importMap === undefined) {
console.error(`import map not found`)
process.exit(1)
}
await netStatImportMap(netStatArgs, importMap)