@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/index.mjs CHANGED
@@ -34817,7 +34817,7 @@ async function generateCompleteHeaders(options) {
34817
34817
  async function createAxios(options) {
34818
34818
  // 如果需要鉴权,拼接 /openapi/v3/nasl;否则使用原始 URL
34819
34819
  const serverBaseURL = new URL(options.serverBaseURL).origin;
34820
- const baseURL = options.useOPENAPI ? `${serverBaseURL}/openapi/v3/nasl` : `${serverBaseURL}/api/v1/nasl`;
34820
+ const baseURL = options.serverBaseURL.endsWith('app-ai-creator') ? options.serverBaseURL : options.useOPENAPI ? `${serverBaseURL}/openapi/v3/nasl` : `${serverBaseURL}/api/v1/nasl`;
34821
34821
  // 如果需要鉴权,生成完整的认证头;否则只使用基础 headers
34822
34822
  const headers = options.useOPENAPI ? await generateCompleteHeaders(options) : { 'Content-Type': 'application/json' };
34823
34823
  console.log('本次服务调用方为:', baseURL);
@@ -34830,7 +34830,7 @@ async function createAxios(options) {
34830
34830
  instance.post = async (url, data, config) => {
34831
34831
  return oldPost(url, data, config).then((res) => {
34832
34832
  const data = res.data;
34833
- if (data.code !== 200)
34833
+ if (data.code !== 200 && data.success !== true)
34834
34834
  throw new Error(JSON.stringify(data));
34835
34835
  return res;
34836
34836
  }).catch((err) => {
@@ -34895,9 +34895,10 @@ async function checkApi(fullNaturalTS, options) {
34895
34895
  });
34896
34896
  const result = res.data.result;
34897
34897
  const errors = (result.errors || []);
34898
- console.log(`共检查到 ${errors.length} 个错误`);
34899
- if (errors.length > 0)
34898
+ if (errors.length > 0) {
34899
+ result.errorStr = `检查到以下错误(共 ${errors.length} 个):\n` + result.errorStr;
34900
34900
  return truncate(result.errorStr, 10000);
34901
+ }
34901
34902
  return '';
34902
34903
  }
34903
34904
 
@@ -34965,7 +34966,7 @@ async function compile(entry, options) {
34965
34966
  logger.success(`所有文件已输出到: ${outDir}`);
34966
34967
  }
34967
34968
  catch (error) {
34968
- logger.error(`编译失败:\n${error.message}`);
34969
+ logger.error(`编译过程发生错误:\n${error.message}`);
34969
34970
  logger.exit(1);
34970
34971
  }
34971
34972
  return { config, outDir };
@@ -35011,6 +35012,8 @@ async function check(entry, options) {
35011
35012
  fastLogToFile(entry || '*', `check_${checkResult.success ? 'success' : 'error'}.log`, result + '\n================================================\n\n================================================\n' + fullNaturalTS);
35012
35013
  if (!checkResult.success)
35013
35014
  logger.error('\n' + checkResult.result);
35015
+ else
35016
+ logger.success('发现 0 个错误,检查通过!');
35014
35017
  return checkResult;
35015
35018
  }
35016
35019
 
@@ -35299,10 +35302,10 @@ async function createAppInIde(entry, options) {
35299
35302
  const projectRoot = getProjectRoot();
35300
35303
  const firstSpecFolderName = getFirstSpecFolderName(projectRoot);
35301
35304
  const suffix = dayjs().format('MMDDHHmmss');
35302
- const appName = `${firstSpecFolderName}_${suffix}`;
35303
- let cleaned = firstSpecFolderName.replace(/[^a-zA-Z0-9]/g, '').replace(/^\d+/, '');
35305
+ let cleaned = firstSpecFolderName.replace(/[^a-zA-Z0-9]/g, '').replace(/^\d+/, '').slice(0, 12);
35304
35306
  if (!cleaned)
35305
35307
  cleaned = 'app';
35308
+ const appName = `${cleaned}_${suffix}`;
35306
35309
  const packageName = `${cleaned}${suffix}`;
35307
35310
  logger.info(`应用名称: ${appName}`);
35308
35311
  logger.info(`包名: ${packageName}`);