sks-maximo-utils 1.0.4 → 1.0.5
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/cli.js +41 -25
- package/nodeutils/maximoTools.js +9 -9
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -5,34 +5,50 @@ import { checkAndCreateConfig, getConfigDir, loadConfig } from './nodeutils/conf
|
|
|
5
5
|
const args = process.argv.slice(2);
|
|
6
6
|
const env = args[0];
|
|
7
7
|
|
|
8
|
-
if (!env) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
if (!env || ['-h', '--help', '-?', '--version', '-v'].includes(env)) {
|
|
9
|
+
console.log(`sks-maximo v${require('./package.json').version}`);
|
|
10
|
+
console.log('');
|
|
11
|
+
console.log('用法:');
|
|
12
|
+
console.log(' sks-maximo # 检查配置文件并打开配置目录');
|
|
13
|
+
console.log(' sks-maximo <env> # 加载指定环境配置');
|
|
14
|
+
console.log('');
|
|
15
|
+
console.log('环境:');
|
|
16
|
+
console.log(' local # 使用本地环境配置');
|
|
17
|
+
console.log(' dev # 使用开发环境配置');
|
|
18
|
+
console.log(' hd # 使用测试环境配置');
|
|
19
|
+
console.log('');
|
|
20
|
+
console.log('选项:');
|
|
21
|
+
console.log(' -h, --help # 显示帮助信息');
|
|
22
|
+
console.log(' -v, --version # 显示版本信息');
|
|
23
|
+
console.log('');
|
|
24
|
+
console.log('配置文件位置: ~/.sks/nodeutils/config.json');
|
|
12
25
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
command
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (error) {
|
|
30
|
-
console.error(`打开目录失败: ${error.message}`);
|
|
31
|
-
console.log(`请手动打开: ${configDir}`);
|
|
26
|
+
if (!env) {
|
|
27
|
+
const configPath = checkAndCreateConfig();
|
|
28
|
+
const configDir = getConfigDir();
|
|
29
|
+
|
|
30
|
+
console.log(`\n配置文件位置: ${configPath}`);
|
|
31
|
+
console.log(`正在打开配置目录...`);
|
|
32
|
+
|
|
33
|
+
const platform = process.platform;
|
|
34
|
+
let command;
|
|
35
|
+
|
|
36
|
+
if (platform === 'win32') {
|
|
37
|
+
command = `explorer "${configDir}"`;
|
|
38
|
+
} else if (platform === 'darwin') {
|
|
39
|
+
command = `open "${configDir}"`;
|
|
40
|
+
} else {
|
|
41
|
+
command = `xdg-open "${configDir}"`;
|
|
32
42
|
}
|
|
33
|
-
|
|
43
|
+
|
|
44
|
+
exec(command, (error) => {
|
|
45
|
+
if (error) {
|
|
46
|
+
console.error(`打开目录失败: ${error.message}`);
|
|
47
|
+
console.log(`请手动打开: ${configDir}`);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
34
51
|
} else {
|
|
35
|
-
// 带参数:加载配置
|
|
36
52
|
loadConfig(env);
|
|
37
53
|
}
|
|
38
54
|
|
package/nodeutils/maximoTools.js
CHANGED
|
@@ -44,7 +44,7 @@ export async function importMaxObject({fileName, logname}) {
|
|
|
44
44
|
|
|
45
45
|
logger.info(`[${logname}]收到响应`);
|
|
46
46
|
logger.info(`[${logname}]响应类型:`, typeof response);
|
|
47
|
-
logger.
|
|
47
|
+
logger.debug(`[${logname}]响应内容:`, response);
|
|
48
48
|
|
|
49
49
|
// 检查响应 - requestHttp的响应拦截器已返回res.data
|
|
50
50
|
if (response !== null && response !== undefined) {
|
|
@@ -113,7 +113,7 @@ export async function importMaxPresentation({fileName, logname}) {
|
|
|
113
113
|
|
|
114
114
|
logger.info(`[${logname}]收到响应`);
|
|
115
115
|
logger.info(`[${logname}]响应类型:`, typeof response);
|
|
116
|
-
logger.
|
|
116
|
+
logger.debug(`[${logname}]响应内容:`, response);
|
|
117
117
|
|
|
118
118
|
if (response !== null && response !== undefined) {
|
|
119
119
|
logger.warn(`[${logname}]导入成功`)
|
|
@@ -175,9 +175,9 @@ export async function importMaxDomain({fileName, logname}) {
|
|
|
175
175
|
data: fileContent // 将文件内容作为请求体发送
|
|
176
176
|
})
|
|
177
177
|
|
|
178
|
-
logger.
|
|
179
|
-
logger.
|
|
180
|
-
logger.
|
|
178
|
+
logger.warn(`[${logname}]收到响应`);
|
|
179
|
+
logger.warn(`[${logname}]响应类型:`, typeof response);
|
|
180
|
+
logger.debug(`[${logname}]响应内容:`, response);
|
|
181
181
|
|
|
182
182
|
// 检查响应 - requestHttp的响应拦截器已返回res.data
|
|
183
183
|
if (response !== null && response !== undefined) {
|
|
@@ -237,7 +237,7 @@ export async function saveScriptHistory({autoscript, source, version = '', alias
|
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
-
logger.
|
|
240
|
+
logger.warn(`[${autoscript}]脚本历史记录保存成功`);
|
|
241
241
|
return response !== null && response !== undefined;
|
|
242
242
|
} catch (error) {
|
|
243
243
|
logger.error(`[${autoscript}]保存脚本历史记录失败:`, error.message);
|
|
@@ -276,8 +276,8 @@ export async function importMaxScript({fileName, logname}) {
|
|
|
276
276
|
|
|
277
277
|
const actualLogname = logname || autoscript;
|
|
278
278
|
logger.info(`[${actualLogname}]成功读取配置文件: ${fileName}`);
|
|
279
|
-
logger.
|
|
280
|
-
logger.
|
|
279
|
+
logger.warn(`[${actualLogname}]脚本名称: ${autoscript}`);
|
|
280
|
+
logger.warn(`[${actualLogname}]脚本语言: ${scriptLanguage}`);
|
|
281
281
|
|
|
282
282
|
const dirname = fileName.substring(0, fileName.lastIndexOf('/')) || fileName.substring(0, fileName.lastIndexOf('\\')) || '';
|
|
283
283
|
const scriptFileName = dirname ? `${dirname}/${autoscript}${scriptExt}` : `${autoscript}${scriptExt}`;
|
|
@@ -525,7 +525,7 @@ export async function importMaxAutoKey({fileName, logname}) {
|
|
|
525
525
|
|
|
526
526
|
logger.info(`[${logname}]收到响应`);
|
|
527
527
|
logger.info(`[${logname}]响应类型:`, typeof response);
|
|
528
|
-
logger.
|
|
528
|
+
logger.debug(`[${logname}]响应内容:`, response);
|
|
529
529
|
|
|
530
530
|
if (response !== null && response !== undefined) {
|
|
531
531
|
logger.warn(`[${logname}]导入成功`)
|