agent-publish-server 1.0.5 → 1.0.6

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/README.md CHANGED
@@ -16,11 +16,30 @@ agent-publish-server
16
16
 
17
17
  ## 配置
18
18
 
19
+ ### 配置文件路径
20
+
21
+ 你可以通过以下方式指定配置文件路径:
22
+
23
+ 1. 使用相对路径(相对于当前工作目录):
24
+
19
25
  ```bash
20
- # 配置文件路径
21
26
  agent-publish-server -c ./agent_config.json
22
27
  ```
23
28
 
29
+ 2. 使用绝对路径:
30
+
31
+ ```bash
32
+ agent-publish-server -c /path/to/agent_config.json
33
+ ```
34
+
35
+ 3. 使用初始化命令创建默认配置:
36
+
37
+ ```bash
38
+ agent-publish-server init
39
+ ```
40
+
41
+ ### 配置文件格式
42
+
24
43
  ```json
25
44
  {
26
45
  "port": 8080, // 端口号
package/dist/config.js CHANGED
@@ -19,14 +19,26 @@ function loadConfig(options) {
19
19
  'agent_config.json';
20
20
  try {
21
21
  const absolutePath = path_1.default.resolve(process.cwd(), configPath);
22
- if (fs_1.default.existsSync(absolutePath)) {
23
- const configContent = fs_1.default.readFileSync(absolutePath, 'utf-8');
24
- const userConfig = JSON.parse(configContent);
25
- return { ...DEFAULT_CONFIG, ...userConfig };
22
+ if (!fs_1.default.existsSync(absolutePath)) {
23
+ console.error(`配置文件不存在: ${absolutePath}`);
24
+ console.log('你可以通过以下方式指定配置文件路径:');
25
+ console.log('1. 使用相对路径:agent-publish-server -c ./agent_config.json');
26
+ console.log('2. 使用绝对路径:agent-publish-server -c /path/to/agent_config.json');
27
+ console.log('3. 使用 agent-publish-server init 命令创建默认配置文件');
28
+ process.exit(1);
26
29
  }
30
+ const configContent = fs_1.default.readFileSync(absolutePath, 'utf-8');
31
+ const userConfig = JSON.parse(configContent);
32
+ return { ...DEFAULT_CONFIG, ...userConfig };
27
33
  }
28
34
  catch (error) {
29
- console.warn(`Failed to load config file: ${error}`);
35
+ if (error instanceof SyntaxError) {
36
+ console.error(`配置文件格式错误: ${configPath}`);
37
+ console.error('请确保配置文件是有效的 JSON 格式');
38
+ }
39
+ else {
40
+ console.error(`加载配置文件失败: ${error.message}`);
41
+ }
42
+ process.exit(1);
30
43
  }
31
- return DEFAULT_CONFIG;
32
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-publish-server",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "基于 nodejs+express+http-proxy-middleware 的前端服务启动插件",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",