channel-worker 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +10 -6
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -6,6 +6,10 @@ const os = require('os');
|
|
|
6
6
|
|
|
7
7
|
const CONFIG_DIR = path.join(os.homedir(), '.channel-worker');
|
|
8
8
|
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
9
|
+
const DEFAULT_API_URL = 'https://api.channel.tunasm.art';
|
|
10
|
+
const DEFAULT_EXT_PATH = process.platform === 'win32'
|
|
11
|
+
? 'C:\\agents\\channel-manager-ext'
|
|
12
|
+
: path.join(os.homedir(), 'channel-manager-ext');
|
|
9
13
|
|
|
10
14
|
function parseArgs(args) {
|
|
11
15
|
const result = {};
|
|
@@ -40,9 +44,9 @@ const cmd = args._cmd || 'start';
|
|
|
40
44
|
if (cmd === 'pair') {
|
|
41
45
|
// Pair with dashboard using one-time code
|
|
42
46
|
const code = args.code;
|
|
43
|
-
const apiUrl = args.api ||
|
|
47
|
+
const apiUrl = args.api || DEFAULT_API_URL;
|
|
44
48
|
const nstKey = args['nst-key'] || '';
|
|
45
|
-
const extensionPath = args.extension ||
|
|
49
|
+
const extensionPath = args.extension || DEFAULT_EXT_PATH;
|
|
46
50
|
const maxConcurrent = parseInt(args.concurrent || '2', 10);
|
|
47
51
|
|
|
48
52
|
if (!code) {
|
|
@@ -91,10 +95,10 @@ if (cmd === 'pair') {
|
|
|
91
95
|
} else if (cmd === 'init') {
|
|
92
96
|
const config = {
|
|
93
97
|
worker_id: args.id || `worker-${os.hostname()}`,
|
|
94
|
-
api_url: args.api ||
|
|
98
|
+
api_url: args.api || DEFAULT_API_URL,
|
|
95
99
|
max_concurrent: parseInt(args.concurrent || '2', 10),
|
|
96
100
|
nst_api_key: args['nst-key'] || '',
|
|
97
|
-
extension_path: args.extension ||
|
|
101
|
+
extension_path: args.extension || DEFAULT_EXT_PATH,
|
|
98
102
|
worker_token: args.token || '',
|
|
99
103
|
};
|
|
100
104
|
saveConfig(config);
|
|
@@ -108,10 +112,10 @@ if (cmd === 'pair') {
|
|
|
108
112
|
const saved = loadConfig();
|
|
109
113
|
const config = {
|
|
110
114
|
worker_id: args.id || saved.worker_id || `worker-${os.hostname()}`,
|
|
111
|
-
api_url: args.api || saved.api_url ||
|
|
115
|
+
api_url: args.api || saved.api_url || DEFAULT_API_URL,
|
|
112
116
|
max_concurrent: parseInt(args.concurrent || saved.max_concurrent || '2', 10),
|
|
113
117
|
nst_api_key: args['nst-key'] || saved.nst_api_key || '',
|
|
114
|
-
extension_path: args.extension || saved.extension_path ||
|
|
118
|
+
extension_path: args.extension || saved.extension_path || DEFAULT_EXT_PATH,
|
|
115
119
|
worker_token: args.token || saved.worker_token || '',
|
|
116
120
|
verbose: !!args.verbose,
|
|
117
121
|
};
|