@nasl/cli 0.2.1 → 0.2.3

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.
@@ -29056,7 +29056,7 @@ async function generateCompleteHeaders(options) {
29056
29056
  async function createAxios(options) {
29057
29057
  // 如果需要鉴权,拼接 /openapi/v3/nasl;否则使用原始 URL
29058
29058
  const serverBaseURL = new URL(options.serverBaseURL).origin;
29059
- const baseURL = options.useOPENAPI ? `${serverBaseURL}/openapi/v3/nasl` : `${serverBaseURL}/api/v1/nasl`;
29059
+ const baseURL = options.serverBaseURL.endsWith('app-ai-creator') ? options.serverBaseURL : options.useOPENAPI ? `${serverBaseURL}/openapi/v3/nasl` : `${serverBaseURL}/api/v1/nasl`;
29060
29060
  // 如果需要鉴权,生成完整的认证头;否则只使用基础 headers
29061
29061
  const headers = options.useOPENAPI ? await generateCompleteHeaders(options) : { 'Content-Type': 'application/json' };
29062
29062
  console.log('本次服务调用方为:', baseURL);
@@ -29069,7 +29069,7 @@ async function createAxios(options) {
29069
29069
  instance.post = async (url, data, config) => {
29070
29070
  return oldPost(url, data, config).then((res) => {
29071
29071
  const data = res.data;
29072
- if (data.code !== 200)
29072
+ if (data.code !== 200 && data.success !== true)
29073
29073
  throw new Error(JSON.stringify(data));
29074
29074
  return res;
29075
29075
  }).catch((err) => {
@@ -29198,7 +29198,10 @@ function validateNormalFile(file, nameFromPath, namespace, errors) {
29198
29198
  function composeToString(files) {
29199
29199
  files.sort((a, b) => sorter(a.path, b.path));
29200
29200
  const errors = [];
29201
+ let currentLine = 1;
29201
29202
  const result = files.map((file) => {
29203
+ // 记录这个文件的开始行号
29204
+ file.startLine = currentLine;
29202
29205
  const arr = file.path.split('.');
29203
29206
  const ext = arr.pop();
29204
29207
  const nameFromPath = arr.pop();
@@ -29224,7 +29227,14 @@ function composeToString(files) {
29224
29227
  else if (isThemeCss) {
29225
29228
  content = ` $theme\`${content}\`;`;
29226
29229
  }
29227
- return `namespace ${namespace} {\n${content}\n}\n`;
29230
+ const fileContent = `namespace ${namespace} {\n${content}\n}\n`;
29231
+ // 计算这个文件占用的行数(末尾 \n 导致 split 多一个空元素,减 1 得到实际行数)
29232
+ const lineCount = fileContent.split('\n').length - 1;
29233
+ // 记录这个文件的结束行号
29234
+ file.endLine = currentLine + lineCount - 1;
29235
+ // +1 是 join('\n') 在文件之间插入的换行符
29236
+ currentLine = file.endLine + 2;
29237
+ return fileContent;
29228
29238
  })
29229
29239
  .join('\n');
29230
29240
  if (errors.length > 0) {
@@ -38182,7 +38192,7 @@ async function tryCompile(entry, options) {
38182
38192
  }
38183
38193
  }
38184
38194
 
38185
- var version = "0.2.1";
38195
+ var version = "0.2.3";
38186
38196
  var pkg = {
38187
38197
  version: version};
38188
38198