@nasl/cli 0.2.0 → 0.2.2
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/dist/bin/nasl.mjs +13 -10
- package/dist/bin/nasl.mjs.map +1 -1
- package/dist/bin/naslc.mjs +4 -4
- package/dist/bin/naslc.mjs.map +1 -1
- package/dist/index.mjs +10 -7
- package/dist/index.mjs.map +1 -1
- package/out/apis/compileApi.d.ts.map +1 -1
- package/out/apis/compileApi.js +3 -2
- package/out/apis/compileApi.js.map +1 -1
- package/out/apis/createAxios.js +2 -2
- package/out/apis/createAxios.js.map +1 -1
- package/out/bin/nasl.js +2 -2
- package/out/bin/nasl.js.map +1 -1
- package/out/commands/check.d.ts.map +1 -1
- package/out/commands/check.js +2 -0
- package/out/commands/check.js.map +1 -1
- package/out/commands/compile.js +1 -1
- package/out/commands/compile.js.map +1 -1
- package/out/commands/createAppInIde.js +2 -2
- package/out/commands/createAppInIde.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/nasl.mjs
CHANGED
|
@@ -29125,7 +29125,7 @@ async function generateCompleteHeaders(options) {
|
|
|
29125
29125
|
async function createAxios(options) {
|
|
29126
29126
|
// 如果需要鉴权,拼接 /openapi/v3/nasl;否则使用原始 URL
|
|
29127
29127
|
const serverBaseURL = new URL(options.serverBaseURL).origin;
|
|
29128
|
-
const baseURL = options.useOPENAPI ? `${serverBaseURL}/openapi/v3/nasl` : `${serverBaseURL}/api/v1/nasl`;
|
|
29128
|
+
const baseURL = options.serverBaseURL.endsWith('app-ai-creator') ? options.serverBaseURL : options.useOPENAPI ? `${serverBaseURL}/openapi/v3/nasl` : `${serverBaseURL}/api/v1/nasl`;
|
|
29129
29129
|
// 如果需要鉴权,生成完整的认证头;否则只使用基础 headers
|
|
29130
29130
|
const headers = options.useOPENAPI ? await generateCompleteHeaders(options) : { 'Content-Type': 'application/json' };
|
|
29131
29131
|
console.log('本次服务调用方为:', baseURL);
|
|
@@ -29138,7 +29138,7 @@ async function createAxios(options) {
|
|
|
29138
29138
|
instance.post = async (url, data, config) => {
|
|
29139
29139
|
return oldPost(url, data, config).then((res) => {
|
|
29140
29140
|
const data = res.data;
|
|
29141
|
-
if (data.code !== 200)
|
|
29141
|
+
if (data.code !== 200 && data.success !== true)
|
|
29142
29142
|
throw new Error(JSON.stringify(data));
|
|
29143
29143
|
return res;
|
|
29144
29144
|
}).catch((err) => {
|
|
@@ -29203,9 +29203,10 @@ async function checkApi(fullNaturalTS, options) {
|
|
|
29203
29203
|
});
|
|
29204
29204
|
const result = res.data.result;
|
|
29205
29205
|
const errors = (result.errors || []);
|
|
29206
|
-
|
|
29207
|
-
|
|
29206
|
+
if (errors.length > 0) {
|
|
29207
|
+
result.errorStr = `检查到以下错误(共 ${errors.length} 个):\n` + result.errorStr;
|
|
29208
29208
|
return truncate(result.errorStr, 10000);
|
|
29209
|
+
}
|
|
29209
29210
|
return '';
|
|
29210
29211
|
}
|
|
29211
29212
|
|
|
@@ -38295,7 +38296,7 @@ async function compile(entry, options) {
|
|
|
38295
38296
|
logger.success(`所有文件已输出到: ${outDir}`);
|
|
38296
38297
|
}
|
|
38297
38298
|
catch (error) {
|
|
38298
|
-
logger.error(
|
|
38299
|
+
logger.error(`编译过程发生错误:\n${error.message}`);
|
|
38299
38300
|
logger.exit(1);
|
|
38300
38301
|
}
|
|
38301
38302
|
return { config, outDir };
|
|
@@ -38341,6 +38342,8 @@ async function check(entry, options) {
|
|
|
38341
38342
|
fastLogToFile(entry || '*', `check_${checkResult.success ? 'success' : 'error'}.log`, result + '\n================================================\n\n================================================\n' + fullNaturalTS);
|
|
38342
38343
|
if (!checkResult.success)
|
|
38343
38344
|
logger.error('\n' + checkResult.result);
|
|
38345
|
+
else
|
|
38346
|
+
logger.success('发现 0 个错误,检查通过!');
|
|
38344
38347
|
return checkResult;
|
|
38345
38348
|
}
|
|
38346
38349
|
|
|
@@ -38629,10 +38632,10 @@ async function createAppInIde(entry, options) {
|
|
|
38629
38632
|
const projectRoot = getProjectRoot();
|
|
38630
38633
|
const firstSpecFolderName = getFirstSpecFolderName(projectRoot);
|
|
38631
38634
|
const suffix = dayjs().format('MMDDHHmmss');
|
|
38632
|
-
|
|
38633
|
-
let cleaned = firstSpecFolderName.replace(/[^a-zA-Z0-9]/g, '').replace(/^\d+/, '');
|
|
38635
|
+
let cleaned = firstSpecFolderName.replace(/[^a-zA-Z0-9]/g, '').replace(/^\d+/, '').slice(0, 12);
|
|
38634
38636
|
if (!cleaned)
|
|
38635
38637
|
cleaned = 'app';
|
|
38638
|
+
const appName = `${cleaned}_${suffix}`;
|
|
38636
38639
|
const packageName = `${cleaned}${suffix}`;
|
|
38637
38640
|
logger.info(`应用名称: ${appName}`);
|
|
38638
38641
|
logger.info(`包名: ${packageName}`);
|
|
@@ -38762,7 +38765,7 @@ async function transform(transformType, entry, options) {
|
|
|
38762
38765
|
await transformFn(entry, options);
|
|
38763
38766
|
}
|
|
38764
38767
|
|
|
38765
|
-
var version = "0.2.
|
|
38768
|
+
var version = "0.2.2";
|
|
38766
38769
|
var pkg = {
|
|
38767
38770
|
version: version};
|
|
38768
38771
|
|
|
@@ -38779,7 +38782,7 @@ function askForConfirmation(question) {
|
|
|
38779
38782
|
rl.question(question, (answer) => {
|
|
38780
38783
|
rl.close();
|
|
38781
38784
|
const normalizedAnswer = answer.trim().toLowerCase();
|
|
38782
|
-
resolve(normalizedAnswer === 'y' || normalizedAnswer === 'yes' || normalizedAnswer === '是');
|
|
38785
|
+
resolve(!normalizedAnswer || normalizedAnswer === 'y' || normalizedAnswer === 'yes' || normalizedAnswer === '是');
|
|
38783
38786
|
});
|
|
38784
38787
|
});
|
|
38785
38788
|
}
|
|
@@ -38872,7 +38875,7 @@ program
|
|
|
38872
38875
|
if (!options?.quiet) {
|
|
38873
38876
|
defaultLogger.newLine();
|
|
38874
38877
|
defaultLogger.info('即将在 IDE 中创建新的应用,此操作将调用远程接口。');
|
|
38875
|
-
const confirmed = await askForConfirmation('请确认是否继续?(
|
|
38878
|
+
const confirmed = await askForConfirmation('请确认是否继续?(Y/n): ');
|
|
38876
38879
|
if (!confirmed) {
|
|
38877
38880
|
defaultLogger.info('已取消操作');
|
|
38878
38881
|
process.exit(0);
|