@nasl/cli 0.1.18 → 0.2.0
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 +3 -1
- package/dist/bin/nasl.mjs +243 -54
- package/dist/bin/nasl.mjs.map +1 -1
- package/dist/bin/naslc.mjs +243 -54
- package/dist/bin/naslc.mjs.map +1 -1
- package/dist/index.mjs +242 -53
- package/dist/index.mjs.map +1 -1
- package/out/constants/index.d.ts +2 -0
- package/out/constants/index.d.ts.map +1 -0
- package/out/constants/index.js +18 -0
- package/out/constants/index.js.map +1 -0
- package/out/constants/nasl-file-types.d.ts +47 -0
- package/out/constants/nasl-file-types.d.ts.map +1 -0
- package/out/constants/nasl-file-types.js +143 -0
- package/out/constants/nasl-file-types.js.map +1 -0
- package/out/services/compose.d.ts +1 -1
- package/out/services/compose.d.ts.map +1 -1
- package/out/services/compose.js +72 -19
- package/out/services/compose.js.map +1 -1
- package/out/services/resolve.d.ts.map +1 -1
- package/out/services/resolve.js +52 -21
- package/out/services/resolve.js.map +1 -1
- package/out/utils/config.d.ts.map +1 -1
- package/out/utils/config.js +16 -13
- package/out/utils/config.js.map +1 -1
- package/out/utils/file.d.ts.map +1 -1
- package/out/utils/file.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -164,7 +164,9 @@ nasl create-app-in-ide [entry] --verbose
|
|
|
164
164
|
|
|
165
165
|
## 环境变量配置
|
|
166
166
|
|
|
167
|
-
除了在 `nasl.config.json`
|
|
167
|
+
除了在 `nasl.config.json` 中配置外,也可以通过环境变量来配置部分选项。
|
|
168
|
+
|
|
169
|
+
**环境变量的优先级高于配置文件**,如果同时设置了环境变量和配置文件,将使用环境变量的值。
|
|
168
170
|
|
|
169
171
|
### 支持的环境变量
|
|
170
172
|
|
package/dist/bin/nasl.mjs
CHANGED
|
@@ -8342,26 +8342,29 @@ function loadConfig(configDir) {
|
|
|
8342
8342
|
defaultLogger.error('配置文件格式不正确,缺少必需的 srcDir 或 outDir 字段');
|
|
8343
8343
|
return defaultLogger.exit(1);
|
|
8344
8344
|
}
|
|
8345
|
+
// 环境变量优先级高于配置文件
|
|
8346
|
+
// ideVersion: 环境变量优先,如果都没有则报错
|
|
8347
|
+
if (process.env.NASL_IDE_VERSION)
|
|
8348
|
+
config.ideVersion = process.env.NASL_IDE_VERSION;
|
|
8345
8349
|
if (!config.ideVersion) {
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
defaultLogger.error('缺少配置 ideVersion,请在配置文件中添加,或在环境变量中配置 NASL_IDE_VERSION');
|
|
8349
|
-
return defaultLogger.exit(1);
|
|
8350
|
-
}
|
|
8350
|
+
defaultLogger.error('缺少配置 ideVersion,请在配置文件中添加,或在环境变量中配置 NASL_IDE_VERSION');
|
|
8351
|
+
return defaultLogger.exit(1);
|
|
8351
8352
|
}
|
|
8353
|
+
// serverBaseURL: 环境变量优先,如果都没有则报错
|
|
8354
|
+
if (process.env.NASL_SERVER_BASE_URL)
|
|
8355
|
+
config.serverBaseURL = process.env.NASL_SERVER_BASE_URL;
|
|
8352
8356
|
if (!config.serverBaseURL) {
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
defaultLogger.error('缺少配置 serverBaseURL,请在配置文件中添加,或在环境变量中配置 NASL_SERVER_BASE_URL');
|
|
8356
|
-
return defaultLogger.exit(1);
|
|
8357
|
-
}
|
|
8357
|
+
defaultLogger.error('缺少配置 serverBaseURL,请在配置文件中添加,或在环境变量中配置 NASL_SERVER_BASE_URL');
|
|
8358
|
+
return defaultLogger.exit(1);
|
|
8358
8359
|
}
|
|
8359
|
-
|
|
8360
|
+
// 环境变量优先
|
|
8361
|
+
if (process.env.USE_LCAP_OPENAPI !== undefined)
|
|
8360
8362
|
config.useOPENAPI = process.env.USE_LCAP_OPENAPI === 'true';
|
|
8361
|
-
if (
|
|
8363
|
+
if (process.env.LCAP_OPENAPI_AK)
|
|
8362
8364
|
config.OPENAPI_AK = process.env.LCAP_OPENAPI_AK;
|
|
8363
|
-
if (
|
|
8365
|
+
if (process.env.LCAP_OPENAPI_SK)
|
|
8364
8366
|
config.OPENAPI_SK = process.env.LCAP_OPENAPI_SK;
|
|
8367
|
+
// 如果启用了 OpenAPI,验证必需的 AK 和 SK
|
|
8365
8368
|
if (config.useOPENAPI) {
|
|
8366
8369
|
if (!config.OPENAPI_AK || !config.OPENAPI_SK) {
|
|
8367
8370
|
defaultLogger.error(`配置了 useOPENAPI,但缺少配置 OPENAPI_AK 和 OPENAPI_SK:
|
|
@@ -29269,6 +29272,56 @@ function createSorter() {
|
|
|
29269
29272
|
};
|
|
29270
29273
|
}
|
|
29271
29274
|
const sorter = createSorter();
|
|
29275
|
+
/**
|
|
29276
|
+
* 验证 variables 文件
|
|
29277
|
+
*/
|
|
29278
|
+
function validateVariablesFile(file, errors) {
|
|
29279
|
+
const matchArr = Array.from(file.content.matchAll(/^(export\s+)(declare\s+)?(const|let)\s+(\w+)/gm));
|
|
29280
|
+
if (matchArr.length === 0) {
|
|
29281
|
+
errors.push(`${file.path} (variables文件) 必须包含至少一个 export const 或 export let 声明`);
|
|
29282
|
+
}
|
|
29283
|
+
for (const match of matchArr) {
|
|
29284
|
+
const [, isExport] = match;
|
|
29285
|
+
if (!isExport)
|
|
29286
|
+
errors.push(`${file.path} 所有声明必须使用 export,错误代码:${match[0]}`);
|
|
29287
|
+
}
|
|
29288
|
+
}
|
|
29289
|
+
/**
|
|
29290
|
+
* 验证 extensions 文件
|
|
29291
|
+
*/
|
|
29292
|
+
function validateExtensionsFile(file, errors) {
|
|
29293
|
+
const matchArr = Array.from(file.content.matchAll(/^(export\s+)(namespace)\s+(\w+)/gm));
|
|
29294
|
+
if (matchArr.length === 0) {
|
|
29295
|
+
errors.push(`${file.path} (extensions文件) 必须包含至少一个 export namespace 声明`);
|
|
29296
|
+
}
|
|
29297
|
+
for (const match of matchArr) {
|
|
29298
|
+
const [, isExport] = match;
|
|
29299
|
+
if (!isExport)
|
|
29300
|
+
errors.push(`${file.path} 所有 namespace 必须使用 export,错误代码:${match[0]}`);
|
|
29301
|
+
}
|
|
29302
|
+
}
|
|
29303
|
+
/**
|
|
29304
|
+
* 验证普通文件(枚举、实体、数据结构、逻辑、页面)
|
|
29305
|
+
*/
|
|
29306
|
+
function validateNormalFile(file, nameFromPath, namespace, errors) {
|
|
29307
|
+
const matchArr = Array.from(file.content.matchAll(/^(export\s+)?(declare\s+)?(function|class|interface)\s+(\w+)/gm));
|
|
29308
|
+
if (matchArr.length === 0)
|
|
29309
|
+
errors.push(`${file.path} 必须有一个函数或类,错误代码:${file.content}`);
|
|
29310
|
+
else if (matchArr.length > 1)
|
|
29311
|
+
errors.push(`${file.path} 只能有一个函数或类,错误代码:${matchArr.map((match) => match[0]).join('\n')}
|
|
29312
|
+
你可以将该文件中所有函数合并,或者将其他函数拆到多个文件中。`);
|
|
29313
|
+
for (const match of matchArr) {
|
|
29314
|
+
const [, isExport, isDeclare, type, name] = match;
|
|
29315
|
+
if (!isExport)
|
|
29316
|
+
errors.push(`${file.path} 必须使用 export,错误代码:${match[0]}`);
|
|
29317
|
+
if (name !== nameFromPath)
|
|
29318
|
+
errors.push(`${file.path} 的函数或类名必须与文件名一致,错误代码:${match[0]}`);
|
|
29319
|
+
if (/\.(entities|enums|structures)/.test(namespace) && type !== 'class')
|
|
29320
|
+
errors.push(`${file.path} 实体、数据结构和枚举只能使用 class 定义,错误代码:${match[0]}`);
|
|
29321
|
+
if (/\.(logics|views)/.test(namespace) && type !== 'function')
|
|
29322
|
+
errors.push(`${file.path} 逻辑和页面只能使用 function 定义,错误代码:${match[0]}`);
|
|
29323
|
+
}
|
|
29324
|
+
}
|
|
29272
29325
|
function composeToString(files) {
|
|
29273
29326
|
files.sort((a, b) => sorter(a.path, b.path));
|
|
29274
29327
|
const errors = [];
|
|
@@ -29276,28 +29329,31 @@ function composeToString(files) {
|
|
|
29276
29329
|
const arr = file.path.split('.');
|
|
29277
29330
|
const ext = arr.pop();
|
|
29278
29331
|
const nameFromPath = arr.pop();
|
|
29279
|
-
|
|
29332
|
+
// 判断是否是特殊文件类型(variables 或 extensions)
|
|
29333
|
+
const isVariablesFile = nameFromPath === 'variables';
|
|
29334
|
+
const isExtensionsFile = arr[0] === 'extensions';
|
|
29335
|
+
const isThemeCss = ext === 'css' && nameFromPath === 'theme';
|
|
29336
|
+
const isSpecialFile = isVariablesFile || isExtensionsFile || isThemeCss;
|
|
29337
|
+
// 特殊文件的 namespace 包含文件名,普通文件不包含
|
|
29338
|
+
const namespace = isSpecialFile ? [...arr, nameFromPath].join('.') : arr.join('.');
|
|
29339
|
+
let content = file.content;
|
|
29280
29340
|
if (['ts', 'tsx'].includes(ext)) {
|
|
29281
|
-
|
|
29282
|
-
|
|
29283
|
-
|
|
29284
|
-
else if (
|
|
29285
|
-
|
|
29286
|
-
|
|
29287
|
-
|
|
29288
|
-
|
|
29289
|
-
if (!isExport)
|
|
29290
|
-
errors.push(`${file.path} 必须使用 export,错误代码:${match[0]}`);
|
|
29291
|
-
if (name !== nameFromPath)
|
|
29292
|
-
errors.push(`${file.path} 的函数或类名必须与文件名一致,错误代码:${match[0]}`);
|
|
29293
|
-
if (/\.(entities|enums|structures)/.test(namespace) && type !== 'class')
|
|
29294
|
-
errors.push(`${file.path} 实体、数据结构和枚举只能使用 class 定义,错误代码:${match[0]}`);
|
|
29295
|
-
if (/\.(logics|views)/.test(namespace) && type !== 'function')
|
|
29296
|
-
errors.push(`${file.path} 逻辑和页面只能使用 function 定义,错误代码:${match[0]}`);
|
|
29341
|
+
if (isVariablesFile) {
|
|
29342
|
+
validateVariablesFile(file, errors);
|
|
29343
|
+
}
|
|
29344
|
+
else if (isExtensionsFile) {
|
|
29345
|
+
validateExtensionsFile(file, errors);
|
|
29346
|
+
}
|
|
29347
|
+
else {
|
|
29348
|
+
validateNormalFile(file, nameFromPath, namespace, errors);
|
|
29297
29349
|
}
|
|
29298
29350
|
}
|
|
29299
|
-
|
|
29300
|
-
|
|
29351
|
+
else if (isThemeCss) {
|
|
29352
|
+
content = ` $theme\`${content}\`;`;
|
|
29353
|
+
}
|
|
29354
|
+
return `namespace ${namespace} {\n${content}\n}\n`;
|
|
29355
|
+
})
|
|
29356
|
+
.join('\n');
|
|
29301
29357
|
if (errors.length > 0) {
|
|
29302
29358
|
throw new Error(errors.join('\n============\n'));
|
|
29303
29359
|
}
|
|
@@ -37818,13 +37874,116 @@ function requireGlobby () {
|
|
|
37818
37874
|
var globbyExports = requireGlobby();
|
|
37819
37875
|
var globby = /*@__PURE__*/getDefaultExportFromCjs(globbyExports);
|
|
37820
37876
|
|
|
37877
|
+
/**
|
|
37878
|
+
* NASL 支持的所有文件类型配置
|
|
37879
|
+
*/
|
|
37880
|
+
const NASL_FILE_TYPES = [
|
|
37881
|
+
{
|
|
37882
|
+
name: 'theme-css',
|
|
37883
|
+
description: '主题样式',
|
|
37884
|
+
fileNamePattern: 'app\\.frontendTypes\\.pc\\.frontends\\.pc\\.theme\\.css',
|
|
37885
|
+
codeRefPattern: 'app\\.frontendTypes\\.pc\\.frontends\\.pc\\.theme',
|
|
37886
|
+
extension: 'css',
|
|
37887
|
+
},
|
|
37888
|
+
{
|
|
37889
|
+
name: 'structures',
|
|
37890
|
+
description: '数据结构',
|
|
37891
|
+
fileNamePattern: 'app\\.structures\\.\\w+\\.ts',
|
|
37892
|
+
codeRefPattern: 'app\\.structures\\.\\w+(?:\\.\\w+)*',
|
|
37893
|
+
extension: 'ts',
|
|
37894
|
+
},
|
|
37895
|
+
{
|
|
37896
|
+
name: 'entities',
|
|
37897
|
+
description: '实体',
|
|
37898
|
+
fileNamePattern: 'app\\.dataSources\\.\\w+\\.entities\\.\\w+\\.ts',
|
|
37899
|
+
codeRefPattern: 'app\\.dataSources\\.\\w+\\.entities\\.\\w+(?:Entity)?(?:\\.\\w+)*',
|
|
37900
|
+
extension: 'ts',
|
|
37901
|
+
},
|
|
37902
|
+
{
|
|
37903
|
+
name: 'logics',
|
|
37904
|
+
description: '逻辑',
|
|
37905
|
+
fileNamePattern: 'app\\.logics\\.\\w+\\.ts',
|
|
37906
|
+
codeRefPattern: 'app\\.logics\\.\\w+(?:\\.\\w+)*',
|
|
37907
|
+
extension: 'ts',
|
|
37908
|
+
},
|
|
37909
|
+
{
|
|
37910
|
+
name: 'views',
|
|
37911
|
+
description: '视图',
|
|
37912
|
+
fileNamePattern: 'app\\.frontendTypes\\.\\w+\\.frontends\\.\\w+(?:\\.views\\.\\w+)+\\.tsx',
|
|
37913
|
+
codeRefPattern: 'app\\.frontendTypes\\.\\w+\\.frontends\\.\\w+(?:\\.views\\.\\w+)+(?:\\.\\w+)*',
|
|
37914
|
+
extension: 'tsx',
|
|
37915
|
+
},
|
|
37916
|
+
{
|
|
37917
|
+
name: 'backend-variables',
|
|
37918
|
+
description: '后端全局变量',
|
|
37919
|
+
fileNamePattern: 'app\\.backend\\.variables\\.ts',
|
|
37920
|
+
codeRefPattern: 'app\\.backend\\.variables(?:\\.\\w+)*',
|
|
37921
|
+
extension: 'ts',
|
|
37922
|
+
},
|
|
37923
|
+
{
|
|
37924
|
+
name: 'frontend-variables',
|
|
37925
|
+
description: '前端全局变量',
|
|
37926
|
+
fileNamePattern: 'app\\.frontendTypes\\.\\w+\\.frontends\\.\\w+\\.variables\\.ts',
|
|
37927
|
+
codeRefPattern: 'app\\.frontendTypes\\.\\w+\\.frontends\\.\\w+\\.variables(?:\\.\\w+)*',
|
|
37928
|
+
extension: 'ts',
|
|
37929
|
+
},
|
|
37930
|
+
{
|
|
37931
|
+
name: 'enums',
|
|
37932
|
+
description: '枚举',
|
|
37933
|
+
fileNamePattern: 'app\\.enums\\.\\w+\\.ts',
|
|
37934
|
+
codeRefPattern: 'app\\.enums\\.\\w+(?:\\.\\w+)*',
|
|
37935
|
+
extension: 'ts',
|
|
37936
|
+
},
|
|
37937
|
+
{
|
|
37938
|
+
name: 'extensions',
|
|
37939
|
+
description: '依赖库',
|
|
37940
|
+
fileNamePattern: 'extensions\\.\\w+\\.ts',
|
|
37941
|
+
codeRefPattern: 'extensions\\.\\w+(?:\\.\\w+)*',
|
|
37942
|
+
extension: 'ts',
|
|
37943
|
+
},
|
|
37944
|
+
];
|
|
37945
|
+
/**
|
|
37946
|
+
* 获取用于验证文件名的正则表达式数组
|
|
37947
|
+
*/
|
|
37948
|
+
function getFileNamePatterns() {
|
|
37949
|
+
return NASL_FILE_TYPES.map((type) => new RegExp(`^${type.fileNamePattern}$`));
|
|
37950
|
+
}
|
|
37951
|
+
const fileNamePatterns = getFileNamePatterns();
|
|
37952
|
+
/**
|
|
37953
|
+
* 获取用于提取代码引用的正则表达式数组
|
|
37954
|
+
*/
|
|
37955
|
+
function getCodeRefPatterns() {
|
|
37956
|
+
return NASL_FILE_TYPES.map((type) => new RegExp(type.codeRefPattern, 'g'));
|
|
37957
|
+
}
|
|
37958
|
+
const codeRefPatterns = getCodeRefPatterns();
|
|
37959
|
+
/**
|
|
37960
|
+
* 判断文件路径是否为已知的 NASL 文件类型
|
|
37961
|
+
* 支持的类型:
|
|
37962
|
+
* - 数据结构 (structures): app.structures.{StructureName}.ts
|
|
37963
|
+
* - 实体 (entities): app.dataSources.{dsName}.entities.{EntityName}.ts
|
|
37964
|
+
* - 逻辑 (logics): app.logics.{logicName}.ts
|
|
37965
|
+
* - 视图 (views): app.frontendTypes.{type}.frontends.{name}.views.{viewName}.tsx
|
|
37966
|
+
* - 后端全局变量: app.backend.variables.ts
|
|
37967
|
+
* - 前端全局变量: app.frontendTypes.{type}.frontends.{name}.variables.ts
|
|
37968
|
+
* - 枚举 (enums): app.enums.{EnumName}.ts
|
|
37969
|
+
* - 依赖库 (extensions): extensions.{extensionName}.ts
|
|
37970
|
+
*
|
|
37971
|
+
* @param filePath 文件路径(绝对路径或相对路径)
|
|
37972
|
+
* @returns 是否为已知的 NASL 文件类型
|
|
37973
|
+
*/
|
|
37974
|
+
function isKnownFileType(filePath) {
|
|
37975
|
+
// 提取文件名
|
|
37976
|
+
const fileName = sysPath.basename(filePath);
|
|
37977
|
+
return fileNamePatterns.some((pattern) => pattern.test(fileName));
|
|
37978
|
+
}
|
|
37979
|
+
|
|
37821
37980
|
/**
|
|
37822
37981
|
* 扫描目录下的所有 NASL 文件
|
|
37823
37982
|
*/
|
|
37824
37983
|
async function scanNASLFiles(srcDir, representation, logger) {
|
|
37825
37984
|
try {
|
|
37826
37985
|
const pattern = representation === 'NaturalTS' ? '**/*.{ts,tsx}' : '**/*.nasl';
|
|
37827
|
-
const files = await globby([pattern, '
|
|
37986
|
+
const files = await globby([pattern, '**/app.frontendTypes.pc.frontends.pc.theme.css'], {
|
|
37828
37987
|
cwd: srcDir,
|
|
37829
37988
|
onlyFiles: true,
|
|
37830
37989
|
absolute: false,
|
|
@@ -37838,7 +37997,6 @@ async function scanNASLFiles(srcDir, representation, logger) {
|
|
|
37838
37997
|
}
|
|
37839
37998
|
async function scanEntryFiles(projectRoot, patterns, logger) {
|
|
37840
37999
|
try {
|
|
37841
|
-
patterns.push('!**/*.css');
|
|
37842
38000
|
const files = await globby(patterns, {
|
|
37843
38001
|
cwd: projectRoot,
|
|
37844
38002
|
onlyFiles: true,
|
|
@@ -37852,30 +38010,46 @@ async function scanEntryFiles(projectRoot, patterns, logger) {
|
|
|
37852
38010
|
}
|
|
37853
38011
|
}
|
|
37854
38012
|
/**
|
|
37855
|
-
* 从文件内容中提取
|
|
38013
|
+
* 从文件内容中提取 指定 格式的依赖引用
|
|
37856
38014
|
* @param content 文件内容
|
|
37857
|
-
* @returns 依赖的
|
|
38015
|
+
* @returns 依赖的 指定 路径列表
|
|
37858
38016
|
*/
|
|
37859
38017
|
function extractDeps(content) {
|
|
37860
38018
|
const deps = new Set();
|
|
37861
|
-
//
|
|
38019
|
+
// 预处理:移除注释和字符串字面量,避免它们影响依赖分析
|
|
37862
38020
|
let processedContent = content
|
|
37863
38021
|
.replace(/\/\/.*$/gm, '') // 移除单行注释 // ...
|
|
37864
|
-
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
37865
|
-
|
|
37866
|
-
|
|
37867
|
-
|
|
37868
|
-
|
|
37869
|
-
|
|
37870
|
-
|
|
37871
|
-
|
|
37872
|
-
|
|
37873
|
-
|
|
37874
|
-
|
|
37875
|
-
|
|
38022
|
+
.replace(/\/\*[\s\S]*?\*\//g, '') // 移除多行注释 /* ... */
|
|
38023
|
+
.replace(/'(?:[^'\\]|\\.)*'/g, '') // 移除单引号字符串 'xxx'
|
|
38024
|
+
.replace(/"(?:[^"\\]|\\.)*"/g, ''); // 移除双引号字符串 "xxx"
|
|
38025
|
+
for (const pattern of codeRefPatterns) {
|
|
38026
|
+
const matches = processedContent.matchAll(pattern);
|
|
38027
|
+
for (const match of matches) {
|
|
38028
|
+
let dep = match[0];
|
|
38029
|
+
// 处理 Entity 后缀:app.dataSources.ds.entities.EntityNameEntity -> app.dataSources.ds.entities.EntityName
|
|
38030
|
+
if (/Entity$|Entity\./.test(dep)) {
|
|
38031
|
+
dep = dep.replace(/Entity(\..*)?$/, '');
|
|
38032
|
+
}
|
|
38033
|
+
// 处理枚举:app.enums.EnumName.field -> app.enums.EnumName
|
|
38034
|
+
if (/^app\.enums\.\w+\./.test(dep)) {
|
|
38035
|
+
dep = dep.replace(/^(app\.enums\.\w+).+$/, '$1');
|
|
38036
|
+
}
|
|
38037
|
+
// 处理 variables:app.backend.variables.varName -> app.backend.variables
|
|
38038
|
+
if (/\.variables\.\w+/.test(dep)) {
|
|
38039
|
+
dep = dep.replace(/\.variables\..+$/, '.variables');
|
|
38040
|
+
}
|
|
38041
|
+
// 处理 extensions:extensions.lcap_auth.logics.getUser -> extensions.lcap_auth
|
|
38042
|
+
if (/^extensions\.\w+\./.test(dep)) {
|
|
38043
|
+
dep = dep.replace(/^(extensions\.\w+)\..+$/, '$1');
|
|
38044
|
+
}
|
|
38045
|
+
// 跳过不合法的实体引用(实体后还有字段的情况)
|
|
38046
|
+
if (/app\.dataSources\.\w+\.entities\.\w+\.\w+$/.test(dep)) {
|
|
38047
|
+
continue;
|
|
38048
|
+
}
|
|
38049
|
+
// 添加文件扩展名
|
|
38050
|
+
dep = `${dep}.${dep.includes('.views.') ? 'tsx' : 'ts'}`;
|
|
38051
|
+
deps.add(dep);
|
|
37876
38052
|
}
|
|
37877
|
-
dep = `${dep}.${dep.includes('.views.') ? 'tsx' : 'ts'}`;
|
|
37878
|
-
deps.add(dep);
|
|
37879
38053
|
}
|
|
37880
38054
|
return Array.from(deps);
|
|
37881
38055
|
}
|
|
@@ -37992,7 +38166,12 @@ async function collectDeps(patterns, projectRoot, srcDir, logger, verbose) {
|
|
|
37992
38166
|
while (filesToProcess.length > 0) {
|
|
37993
38167
|
const pathRelativeToSrc = filesToProcess.shift();
|
|
37994
38168
|
if (processedFileMap.has(pathRelativeToSrc))
|
|
37995
|
-
continue; // 跳过已处理的文件
|
|
38169
|
+
continue; // 跳过已处理的文件
|
|
38170
|
+
// 检查文件类型是否支持
|
|
38171
|
+
if (!isKnownFileType(pathRelativeToSrc)) {
|
|
38172
|
+
logger.warn(`跳过不支持的文件类型: ${pathRelativeToSrc}`);
|
|
38173
|
+
continue;
|
|
38174
|
+
}
|
|
37996
38175
|
try {
|
|
37997
38176
|
const { fileInfo, newDeps } = processFileDeps(pathRelativeToSrc, srcDir, matchedFileSet, processedFileMap, depNotFoundList, logger, verbose);
|
|
37998
38177
|
result.push(fileInfo);
|
|
@@ -38072,8 +38251,18 @@ async function resolveNASLFiles(entry, logger, depMode, verbose) {
|
|
|
38072
38251
|
}
|
|
38073
38252
|
logger.info(`找到 ${collectedFiles.length} 个 NASL 文件`);
|
|
38074
38253
|
}
|
|
38254
|
+
// 统一过滤掉不支持的文件类型
|
|
38255
|
+
const filteredFiles = [];
|
|
38256
|
+
collectedFiles.forEach((file) => {
|
|
38257
|
+
if (isKnownFileType(file.path)) {
|
|
38258
|
+
filteredFiles.push(file);
|
|
38259
|
+
}
|
|
38260
|
+
else {
|
|
38261
|
+
logger.warn(`跳过不支持的文件类型: ${file.path}`);
|
|
38262
|
+
}
|
|
38263
|
+
});
|
|
38075
38264
|
return {
|
|
38076
|
-
collectedFiles,
|
|
38265
|
+
collectedFiles: filteredFiles,
|
|
38077
38266
|
config,
|
|
38078
38267
|
projectRoot,
|
|
38079
38268
|
srcDir,
|
|
@@ -38573,7 +38762,7 @@ async function transform(transformType, entry, options) {
|
|
|
38573
38762
|
await transformFn(entry, options);
|
|
38574
38763
|
}
|
|
38575
38764
|
|
|
38576
|
-
var version = "0.
|
|
38765
|
+
var version = "0.2.0";
|
|
38577
38766
|
var pkg = {
|
|
38578
38767
|
version: version};
|
|
38579
38768
|
|