Compare commits
No commits in common. "d5f4abeeb0740fc7f1b19bcad065905d29afde4a" and "56c278d84e619dd20aa099b9867e610d8964de6d" have entirely different histories.
d5f4abeeb0
...
56c278d84e
@ -1,8 +1,4 @@
|
||||
### 27/07/2023 (1.0.10)
|
||||
|
||||
- Add list profiles
|
||||
|
||||
### 14/07/2023 (1.0.9)
|
||||
### 14/07/2023 (1.0.8)
|
||||
|
||||
- Fixed the start with port unable to start
|
||||
|
||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -178,9 +178,9 @@
|
||||
"devOptional": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.4.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.5.tgz",
|
||||
"integrity": "sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg=="
|
||||
"version": "20.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.1.tgz",
|
||||
"integrity": "sha512-JIzsAvJeA/5iY6Y/OxZbv1lUcc8dNSE77lb2gnBH+/PJ3lFR1Ccvgwl5JWnHAkNHcRsT0TbpVOsiMKZ1F/yyJg=="
|
||||
},
|
||||
"node_modules/@types/qs": {
|
||||
"version": "6.9.7",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cubetiq/hlt",
|
||||
"version": "0.1.10",
|
||||
"version": "0.1.9",
|
||||
"description": "A lightweight http tunnel client using nodejs and socket.io client",
|
||||
"main": "dist/cli.js",
|
||||
"bin": {
|
||||
|
34
src/cli.ts
34
src/cli.ts
@ -4,7 +4,6 @@ import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { initConfigFileClient, startClient } from "./api";
|
||||
import { PROFILE_DEFAULT, PROFILE_PATH, SERVER_DEFAULT_URL, TOKEN_FREE } from "./constant";
|
||||
import { listProfile } from "./manage";
|
||||
import { createProxyServer } from "./proxy";
|
||||
import { createProxyServer as createProxyTCPServer } from "./proxy_tcp";
|
||||
import { getTokenFree } from './sdk';
|
||||
@ -23,20 +22,20 @@ program
|
||||
program
|
||||
.command("init")
|
||||
.description("generate a new client and token with free access")
|
||||
.option("-s, --server <string>", "setting server url", SERVER_DEFAULT_URL)
|
||||
.option("-s --server <string>", "setting server url", SERVER_DEFAULT_URL)
|
||||
.option(
|
||||
"-t, --token <string>",
|
||||
"-t --token <string>",
|
||||
"setting token (default generate FREE access token)",
|
||||
""
|
||||
)
|
||||
.option("-a, --access <string>", "setting token access type", TOKEN_FREE)
|
||||
.option("-c, --client <string>", "setting client (auto generate uuid)")
|
||||
.option("-a --access <string>", "setting token access type", TOKEN_FREE)
|
||||
.option("-c --client <string>", "setting client (auto generate uuid)")
|
||||
.option(
|
||||
"-k, --key <string>",
|
||||
"-k --key <string>",
|
||||
"setting client api key for authentication access"
|
||||
)
|
||||
.option("-p, --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
||||
.option("-f, --force", "force to generate new client and token", false)
|
||||
.option("-p --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
||||
.option("-f --force", "force to generate new client and token", false)
|
||||
.action(async (options) => {
|
||||
initConfigFileClient(options);
|
||||
});
|
||||
@ -92,7 +91,7 @@ program
|
||||
])
|
||||
)
|
||||
.argument("<value>", "config value")
|
||||
.option("-p, --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
||||
.option("-p --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
||||
.action(async (type, value, options) => {
|
||||
if (!type) {
|
||||
console.error("type config is required!");
|
||||
@ -180,7 +179,7 @@ program
|
||||
"key",
|
||||
])
|
||||
)
|
||||
.option("-p, --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
||||
.option("-p --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
||||
.action(async (type, options) => {
|
||||
if (!type) {
|
||||
console.error("type config is required!");
|
||||
@ -272,7 +271,7 @@ program
|
||||
|
||||
throw new InvalidArgumentError("Target is not a url or host with port.");
|
||||
})
|
||||
.option("-p, --profile <string>", "setting profile name for connect with hlt server (proxy with current local port)")
|
||||
.option("-p --profile <string>", "setting profile name for connect with hlt server (proxy with current local port)")
|
||||
.action((port, target, options) => {
|
||||
const isTcp = target.indexOf("tcp") === 0;
|
||||
if (isTcp) {
|
||||
@ -323,17 +322,4 @@ const onConnectProxy = (port: number, options: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
// profile
|
||||
program
|
||||
.command("profile")
|
||||
.description("manage profile")
|
||||
.option("-l, --list", "list all profiles", false)
|
||||
.action((options) => {
|
||||
if (options.list) {
|
||||
listProfile();
|
||||
} else {
|
||||
console.log("profile command is required");
|
||||
}
|
||||
});
|
||||
|
||||
program.parse();
|
||||
|
@ -1,28 +0,0 @@
|
||||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { PROFILE_DEFAULT, PROFILE_PATH } from "./constant";
|
||||
|
||||
export const listProfile = () => {
|
||||
const configDir = path.resolve(os.homedir(), PROFILE_PATH);
|
||||
if (!fs.existsSync(configDir)) {
|
||||
console.log(`config file ${configDir} not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
const configFiles = fs.readdirSync(configDir);
|
||||
if (configFiles.length === 0) {
|
||||
console.log(`config file ${configDir} not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("List of profile:");
|
||||
configFiles.forEach((file) => {
|
||||
const configFilePath = path.resolve(configDir, file);
|
||||
const config = JSON.parse(fs.readFileSync(configFilePath, "utf8"));
|
||||
const name = file.replace(".json", "");
|
||||
console.log(`- ${name} (${config.clientId})`);
|
||||
});
|
||||
|
||||
console.log(`\nCurrent profile: ${PROFILE_DEFAULT}`);
|
||||
}
|
Loading…
Reference in New Issue
Block a user