@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/dist/bin/naslc.mjs
CHANGED
|
@@ -8308,26 +8308,29 @@ function loadConfig(configDir) {
|
|
|
8308
8308
|
defaultLogger.error('配置文件格式不正确,缺少必需的 srcDir 或 outDir 字段');
|
|
8309
8309
|
return defaultLogger.exit(1);
|
|
8310
8310
|
}
|
|
8311
|
+
// 环境变量优先级高于配置文件
|
|
8312
|
+
// ideVersion: 环境变量优先,如果都没有则报错
|
|
8313
|
+
if (process.env.NASL_IDE_VERSION)
|
|
8314
|
+
config.ideVersion = process.env.NASL_IDE_VERSION;
|
|
8311
8315
|
if (!config.ideVersion) {
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
defaultLogger.error('缺少配置 ideVersion,请在配置文件中添加,或在环境变量中配置 NASL_IDE_VERSION');
|
|
8315
|
-
return defaultLogger.exit(1);
|
|
8316
|
-
}
|
|
8316
|
+
defaultLogger.error('缺少配置 ideVersion,请在配置文件中添加,或在环境变量中配置 NASL_IDE_VERSION');
|
|
8317
|
+
return defaultLogger.exit(1);
|
|
8317
8318
|
}
|
|
8319
|
+
// serverBaseURL: 环境变量优先,如果都没有则报错
|
|
8320
|
+
if (process.env.NASL_SERVER_BASE_URL)
|
|
8321
|
+
config.serverBaseURL = process.env.NASL_SERVER_BASE_URL;
|
|
8318
8322
|
if (!config.serverBaseURL) {
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
defaultLogger.error('缺少配置 serverBaseURL,请在配置文件中添加,或在环境变量中配置 NASL_SERVER_BASE_URL');
|
|
8322
|
-
return defaultLogger.exit(1);
|
|
8323
|
-
}
|
|
8323
|
+
defaultLogger.error('缺少配置 serverBaseURL,请在配置文件中添加,或在环境变量中配置 NASL_SERVER_BASE_URL');
|
|
8324
|
+
return defaultLogger.exit(1);
|
|
8324
8325
|
}
|
|
8325
|
-
|
|
8326
|
+
// 环境变量优先
|
|
8327
|
+
if (process.env.USE_LCAP_OPENAPI !== undefined)
|
|
8326
8328
|
config.useOPENAPI = process.env.USE_LCAP_OPENAPI === 'true';
|
|
8327
|
-
if (
|
|
8329
|
+
if (process.env.LCAP_OPENAPI_AK)
|
|
8328
8330
|
config.OPENAPI_AK = process.env.LCAP_OPENAPI_AK;
|
|
8329
|
-
if (
|
|
8331
|
+
if (process.env.LCAP_OPENAPI_SK)
|
|
8330
8332
|
config.OPENAPI_SK = process.env.LCAP_OPENAPI_SK;
|
|
8333
|
+
// 如果启用了 OpenAPI,验证必需的 AK 和 SK
|
|
8331
8334
|
if (config.useOPENAPI) {
|
|
8332
8335
|
if (!config.OPENAPI_AK || !config.OPENAPI_SK) {
|
|
8333
8336
|
defaultLogger.error(`配置了 useOPENAPI,但缺少配置 OPENAPI_AK 和 OPENAPI_SK:
|
|
@@ -29142,6 +29145,56 @@ function createSorter() {
|
|
|
29142
29145
|
};
|
|
29143
29146
|
}
|
|
29144
29147
|
const sorter = createSorter();
|
|
29148
|
+
/**
|
|
29149
|
+
* 验证 variables 文件
|
|
29150
|
+
*/
|
|
29151
|
+
function validateVariablesFile(file, errors) {
|
|
29152
|
+
const matchArr = Array.from(file.content.matchAll(/^(export\s+)(declare\s+)?(const|let)\s+(\w+)/gm));
|
|
29153
|
+
if (matchArr.length === 0) {
|
|
29154
|
+
errors.push(`${file.path} (variables文件) 必须包含至少一个 export const 或 export let 声明`);
|
|
29155
|
+
}
|
|
29156
|
+
for (const match of matchArr) {
|
|
29157
|
+
const [, isExport] = match;
|
|
29158
|
+
if (!isExport)
|
|
29159
|
+
errors.push(`${file.path} 所有声明必须使用 export,错误代码:${match[0]}`);
|
|
29160
|
+
}
|
|
29161
|
+
}
|
|
29162
|
+
/**
|
|
29163
|
+
* 验证 extensions 文件
|
|
29164
|
+
*/
|
|
29165
|
+
function validateExtensionsFile(file, errors) {
|
|
29166
|
+
const matchArr = Array.from(file.content.matchAll(/^(export\s+)(namespace)\s+(\w+)/gm));
|
|
29167
|
+
if (matchArr.length === 0) {
|
|
29168
|
+
errors.push(`${file.path} (extensions文件) 必须包含至少一个 export namespace 声明`);
|
|
29169
|
+
}
|
|
29170
|
+
for (const match of matchArr) {
|
|
29171
|
+
const [, isExport] = match;
|
|
29172
|
+
if (!isExport)
|
|
29173
|
+
errors.push(`${file.path} 所有 namespace 必须使用 export,错误代码:${match[0]}`);
|
|
29174
|
+
}
|
|
29175
|
+
}
|
|
29176
|
+
/**
|
|
29177
|
+
* 验证普通文件(枚举、实体、数据结构、逻辑、页面)
|
|
29178
|
+
*/
|
|
29179
|
+
function validateNormalFile(file, nameFromPath, namespace, errors) {
|
|
29180
|
+
const matchArr = Array.from(file.content.matchAll(/^(export\s+)?(declare\s+)?(function|class|interface)\s+(\w+)/gm));
|
|
29181
|
+
if (matchArr.length === 0)
|
|
29182
|
+
errors.push(`${file.path} 必须有一个函数或类,错误代码:${file.content}`);
|
|
29183
|
+
else if (matchArr.length > 1)
|
|
29184
|
+
errors.push(`${file.path} 只能有一个函数或类,错误代码:${matchArr.map((match) => match[0]).join('\n')}
|
|
29185
|
+
你可以将该文件中所有函数合并,或者将其他函数拆到多个文件中。`);
|
|
29186
|
+
for (const match of matchArr) {
|
|
29187
|
+
const [, isExport, isDeclare, type, name] = match;
|
|
29188
|
+
if (!isExport)
|
|
29189
|
+
errors.push(`${file.path} 必须使用 export,错误代码:${match[0]}`);
|
|
29190
|
+
if (name !== nameFromPath)
|
|
29191
|
+
errors.push(`${file.path} 的函数或类名必须与文件名一致,错误代码:${match[0]}`);
|
|
29192
|
+
if (/\.(entities|enums|structures)/.test(namespace) && type !== 'class')
|
|
29193
|
+
errors.push(`${file.path} 实体、数据结构和枚举只能使用 class 定义,错误代码:${match[0]}`);
|
|
29194
|
+
if (/\.(logics|views)/.test(namespace) && type !== 'function')
|
|
29195
|
+
errors.push(`${file.path} 逻辑和页面只能使用 function 定义,错误代码:${match[0]}`);
|
|
29196
|
+
}
|
|
29197
|
+
}
|
|
29145
29198
|
function composeToString(files) {
|
|
29146
29199
|
files.sort((a, b) => sorter(a.path, b.path));
|
|
29147
29200
|
const errors = [];
|
|
@@ -29149,28 +29202,31 @@ function composeToString(files) {
|
|
|
29149
29202
|
const arr = file.path.split('.');
|
|
29150
29203
|
const ext = arr.pop();
|
|
29151
29204
|
const nameFromPath = arr.pop();
|
|
29152
|
-
|
|
29205
|
+
// 判断是否是特殊文件类型(variables 或 extensions)
|
|
29206
|
+
const isVariablesFile = nameFromPath === 'variables';
|
|
29207
|
+
const isExtensionsFile = arr[0] === 'extensions';
|
|
29208
|
+
const isThemeCss = ext === 'css' && nameFromPath === 'theme';
|
|
29209
|
+
const isSpecialFile = isVariablesFile || isExtensionsFile || isThemeCss;
|
|
29210
|
+
// 特殊文件的 namespace 包含文件名,普通文件不包含
|
|
29211
|
+
const namespace = isSpecialFile ? [...arr, nameFromPath].join('.') : arr.join('.');
|
|
29212
|
+
let content = file.content;
|
|
29153
29213
|
if (['ts', 'tsx'].includes(ext)) {
|
|
29154
|
-
|
|
29155
|
-
|
|
29156
|
-
errors.push(`${file.path} 必须有一个函数或类,错误代码:${file.content}`);
|
|
29157
|
-
else if (matchArr.length > 1)
|
|
29158
|
-
errors.push(`${file.path} 只能有一个函数或类,错误代码:${matchArr.map((match) => match[0]).join('\n')}
|
|
29159
|
-
你可以将该文件中所有函数合并,或者将其他函数拆到多个文件中。`);
|
|
29160
|
-
for (const match of matchArr) {
|
|
29161
|
-
const [, isExport, isDeclare, type, name] = match;
|
|
29162
|
-
if (!isExport)
|
|
29163
|
-
errors.push(`${file.path} 必须使用 export,错误代码:${match[0]}`);
|
|
29164
|
-
if (name !== nameFromPath)
|
|
29165
|
-
errors.push(`${file.path} 的函数或类名必须与文件名一致,错误代码:${match[0]}`);
|
|
29166
|
-
if (/\.(entities|enums|structures)/.test(namespace) && type !== 'class')
|
|
29167
|
-
errors.push(`${file.path} 实体、数据结构和枚举只能使用 class 定义,错误代码:${match[0]}`);
|
|
29168
|
-
if (/\.(logics|views)/.test(namespace) && type !== 'function')
|
|
29169
|
-
errors.push(`${file.path} 逻辑和页面只能使用 function 定义,错误代码:${match[0]}`);
|
|
29214
|
+
if (isVariablesFile) {
|
|
29215
|
+
validateVariablesFile(file, errors);
|
|
29170
29216
|
}
|
|
29217
|
+
else if (isExtensionsFile) {
|
|
29218
|
+
validateExtensionsFile(file, errors);
|
|
29219
|
+
}
|
|
29220
|
+
else {
|
|
29221
|
+
validateNormalFile(file, nameFromPath, namespace, errors);
|
|
29222
|
+
}
|
|
29223
|
+
}
|
|
29224
|
+
else if (isThemeCss) {
|
|
29225
|
+
content = ` $theme\`${content}\`;`;
|
|
29171
29226
|
}
|
|
29172
|
-
return `namespace ${namespace} {\n${
|
|
29173
|
-
})
|
|
29227
|
+
return `namespace ${namespace} {\n${content}\n}\n`;
|
|
29228
|
+
})
|
|
29229
|
+
.join('\n');
|
|
29174
29230
|
if (errors.length > 0) {
|
|
29175
29231
|
throw new Error(errors.join('\n============\n'));
|
|
29176
29232
|
}
|
|
@@ -37691,13 +37747,116 @@ function requireGlobby () {
|
|
|
37691
37747
|
var globbyExports = requireGlobby();
|
|
37692
37748
|
var globby = /*@__PURE__*/getDefaultExportFromCjs(globbyExports);
|
|
37693
37749
|
|
|
37750
|
+
/**
|
|
37751
|
+
* NASL 支持的所有文件类型配置
|
|
37752
|
+
*/
|
|
37753
|
+
const NASL_FILE_TYPES = [
|
|
37754
|
+
{
|
|
37755
|
+
name: 'theme-css',
|
|
37756
|
+
description: '主题样式',
|
|
37757
|
+
fileNamePattern: 'app\\.frontendTypes\\.pc\\.frontends\\.pc\\.theme\\.css',
|
|
37758
|
+
codeRefPattern: 'app\\.frontendTypes\\.pc\\.frontends\\.pc\\.theme',
|
|
37759
|
+
extension: 'css',
|
|
37760
|
+
},
|
|
37761
|
+
{
|
|
37762
|
+
name: 'structures',
|
|
37763
|
+
description: '数据结构',
|
|
37764
|
+
fileNamePattern: 'app\\.structures\\.\\w+\\.ts',
|
|
37765
|
+
codeRefPattern: 'app\\.structures\\.\\w+(?:\\.\\w+)*',
|
|
37766
|
+
extension: 'ts',
|
|
37767
|
+
},
|
|
37768
|
+
{
|
|
37769
|
+
name: 'entities',
|
|
37770
|
+
description: '实体',
|
|
37771
|
+
fileNamePattern: 'app\\.dataSources\\.\\w+\\.entities\\.\\w+\\.ts',
|
|
37772
|
+
codeRefPattern: 'app\\.dataSources\\.\\w+\\.entities\\.\\w+(?:Entity)?(?:\\.\\w+)*',
|
|
37773
|
+
extension: 'ts',
|
|
37774
|
+
},
|
|
37775
|
+
{
|
|
37776
|
+
name: 'logics',
|
|
37777
|
+
description: '逻辑',
|
|
37778
|
+
fileNamePattern: 'app\\.logics\\.\\w+\\.ts',
|
|
37779
|
+
codeRefPattern: 'app\\.logics\\.\\w+(?:\\.\\w+)*',
|
|
37780
|
+
extension: 'ts',
|
|
37781
|
+
},
|
|
37782
|
+
{
|
|
37783
|
+
name: 'views',
|
|
37784
|
+
description: '视图',
|
|
37785
|
+
fileNamePattern: 'app\\.frontendTypes\\.\\w+\\.frontends\\.\\w+(?:\\.views\\.\\w+)+\\.tsx',
|
|
37786
|
+
codeRefPattern: 'app\\.frontendTypes\\.\\w+\\.frontends\\.\\w+(?:\\.views\\.\\w+)+(?:\\.\\w+)*',
|
|
37787
|
+
extension: 'tsx',
|
|
37788
|
+
},
|
|
37789
|
+
{
|
|
37790
|
+
name: 'backend-variables',
|
|
37791
|
+
description: '后端全局变量',
|
|
37792
|
+
fileNamePattern: 'app\\.backend\\.variables\\.ts',
|
|
37793
|
+
codeRefPattern: 'app\\.backend\\.variables(?:\\.\\w+)*',
|
|
37794
|
+
extension: 'ts',
|
|
37795
|
+
},
|
|
37796
|
+
{
|
|
37797
|
+
name: 'frontend-variables',
|
|
37798
|
+
description: '前端全局变量',
|
|
37799
|
+
fileNamePattern: 'app\\.frontendTypes\\.\\w+\\.frontends\\.\\w+\\.variables\\.ts',
|
|
37800
|
+
codeRefPattern: 'app\\.frontendTypes\\.\\w+\\.frontends\\.\\w+\\.variables(?:\\.\\w+)*',
|
|
37801
|
+
extension: 'ts',
|
|
37802
|
+
},
|
|
37803
|
+
{
|
|
37804
|
+
name: 'enums',
|
|
37805
|
+
description: '枚举',
|
|
37806
|
+
fileNamePattern: 'app\\.enums\\.\\w+\\.ts',
|
|
37807
|
+
codeRefPattern: 'app\\.enums\\.\\w+(?:\\.\\w+)*',
|
|
37808
|
+
extension: 'ts',
|
|
37809
|
+
},
|
|
37810
|
+
{
|
|
37811
|
+
name: 'extensions',
|
|
37812
|
+
description: '依赖库',
|
|
37813
|
+
fileNamePattern: 'extensions\\.\\w+\\.ts',
|
|
37814
|
+
codeRefPattern: 'extensions\\.\\w+(?:\\.\\w+)*',
|
|
37815
|
+
extension: 'ts',
|
|
37816
|
+
},
|
|
37817
|
+
];
|
|
37818
|
+
/**
|
|
37819
|
+
* 获取用于验证文件名的正则表达式数组
|
|
37820
|
+
*/
|
|
37821
|
+
function getFileNamePatterns() {
|
|
37822
|
+
return NASL_FILE_TYPES.map((type) => new RegExp(`^${type.fileNamePattern}$`));
|
|
37823
|
+
}
|
|
37824
|
+
const fileNamePatterns = getFileNamePatterns();
|
|
37825
|
+
/**
|
|
37826
|
+
* 获取用于提取代码引用的正则表达式数组
|
|
37827
|
+
*/
|
|
37828
|
+
function getCodeRefPatterns() {
|
|
37829
|
+
return NASL_FILE_TYPES.map((type) => new RegExp(type.codeRefPattern, 'g'));
|
|
37830
|
+
}
|
|
37831
|
+
const codeRefPatterns = getCodeRefPatterns();
|
|
37832
|
+
/**
|
|
37833
|
+
* 判断文件路径是否为已知的 NASL 文件类型
|
|
37834
|
+
* 支持的类型:
|
|
37835
|
+
* - 数据结构 (structures): app.structures.{StructureName}.ts
|
|
37836
|
+
* - 实体 (entities): app.dataSources.{dsName}.entities.{EntityName}.ts
|
|
37837
|
+
* - 逻辑 (logics): app.logics.{logicName}.ts
|
|
37838
|
+
* - 视图 (views): app.frontendTypes.{type}.frontends.{name}.views.{viewName}.tsx
|
|
37839
|
+
* - 后端全局变量: app.backend.variables.ts
|
|
37840
|
+
* - 前端全局变量: app.frontendTypes.{type}.frontends.{name}.variables.ts
|
|
37841
|
+
* - 枚举 (enums): app.enums.{EnumName}.ts
|
|
37842
|
+
* - 依赖库 (extensions): extensions.{extensionName}.ts
|
|
37843
|
+
*
|
|
37844
|
+
* @param filePath 文件路径(绝对路径或相对路径)
|
|
37845
|
+
* @returns 是否为已知的 NASL 文件类型
|
|
37846
|
+
*/
|
|
37847
|
+
function isKnownFileType(filePath) {
|
|
37848
|
+
// 提取文件名
|
|
37849
|
+
const fileName = sysPath.basename(filePath);
|
|
37850
|
+
return fileNamePatterns.some((pattern) => pattern.test(fileName));
|
|
37851
|
+
}
|
|
37852
|
+
|
|
37694
37853
|
/**
|
|
37695
37854
|
* 扫描目录下的所有 NASL 文件
|
|
37696
37855
|
*/
|
|
37697
37856
|
async function scanNASLFiles(srcDir, representation, logger) {
|
|
37698
37857
|
try {
|
|
37699
37858
|
const pattern = representation === 'NaturalTS' ? '**/*.{ts,tsx}' : '**/*.nasl';
|
|
37700
|
-
const files = await globby([pattern, '
|
|
37859
|
+
const files = await globby([pattern, '**/app.frontendTypes.pc.frontends.pc.theme.css'], {
|
|
37701
37860
|
cwd: srcDir,
|
|
37702
37861
|
onlyFiles: true,
|
|
37703
37862
|
absolute: false,
|
|
@@ -37711,7 +37870,6 @@ async function scanNASLFiles(srcDir, representation, logger) {
|
|
|
37711
37870
|
}
|
|
37712
37871
|
async function scanEntryFiles(projectRoot, patterns, logger) {
|
|
37713
37872
|
try {
|
|
37714
|
-
patterns.push('!**/*.css');
|
|
37715
37873
|
const files = await globby(patterns, {
|
|
37716
37874
|
cwd: projectRoot,
|
|
37717
37875
|
onlyFiles: true,
|
|
@@ -37725,30 +37883,46 @@ async function scanEntryFiles(projectRoot, patterns, logger) {
|
|
|
37725
37883
|
}
|
|
37726
37884
|
}
|
|
37727
37885
|
/**
|
|
37728
|
-
* 从文件内容中提取
|
|
37886
|
+
* 从文件内容中提取 指定 格式的依赖引用
|
|
37729
37887
|
* @param content 文件内容
|
|
37730
|
-
* @returns 依赖的
|
|
37888
|
+
* @returns 依赖的 指定 路径列表
|
|
37731
37889
|
*/
|
|
37732
37890
|
function extractDeps(content) {
|
|
37733
37891
|
const deps = new Set();
|
|
37734
|
-
//
|
|
37892
|
+
// 预处理:移除注释和字符串字面量,避免它们影响依赖分析
|
|
37735
37893
|
let processedContent = content
|
|
37736
37894
|
.replace(/\/\/.*$/gm, '') // 移除单行注释 // ...
|
|
37737
|
-
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
37738
|
-
|
|
37739
|
-
|
|
37740
|
-
|
|
37741
|
-
|
|
37742
|
-
|
|
37743
|
-
|
|
37744
|
-
|
|
37745
|
-
|
|
37746
|
-
|
|
37747
|
-
|
|
37748
|
-
|
|
37895
|
+
.replace(/\/\*[\s\S]*?\*\//g, '') // 移除多行注释 /* ... */
|
|
37896
|
+
.replace(/'(?:[^'\\]|\\.)*'/g, '') // 移除单引号字符串 'xxx'
|
|
37897
|
+
.replace(/"(?:[^"\\]|\\.)*"/g, ''); // 移除双引号字符串 "xxx"
|
|
37898
|
+
for (const pattern of codeRefPatterns) {
|
|
37899
|
+
const matches = processedContent.matchAll(pattern);
|
|
37900
|
+
for (const match of matches) {
|
|
37901
|
+
let dep = match[0];
|
|
37902
|
+
// 处理 Entity 后缀:app.dataSources.ds.entities.EntityNameEntity -> app.dataSources.ds.entities.EntityName
|
|
37903
|
+
if (/Entity$|Entity\./.test(dep)) {
|
|
37904
|
+
dep = dep.replace(/Entity(\..*)?$/, '');
|
|
37905
|
+
}
|
|
37906
|
+
// 处理枚举:app.enums.EnumName.field -> app.enums.EnumName
|
|
37907
|
+
if (/^app\.enums\.\w+\./.test(dep)) {
|
|
37908
|
+
dep = dep.replace(/^(app\.enums\.\w+).+$/, '$1');
|
|
37909
|
+
}
|
|
37910
|
+
// 处理 variables:app.backend.variables.varName -> app.backend.variables
|
|
37911
|
+
if (/\.variables\.\w+/.test(dep)) {
|
|
37912
|
+
dep = dep.replace(/\.variables\..+$/, '.variables');
|
|
37913
|
+
}
|
|
37914
|
+
// 处理 extensions:extensions.lcap_auth.logics.getUser -> extensions.lcap_auth
|
|
37915
|
+
if (/^extensions\.\w+\./.test(dep)) {
|
|
37916
|
+
dep = dep.replace(/^(extensions\.\w+)\..+$/, '$1');
|
|
37917
|
+
}
|
|
37918
|
+
// 跳过不合法的实体引用(实体后还有字段的情况)
|
|
37919
|
+
if (/app\.dataSources\.\w+\.entities\.\w+\.\w+$/.test(dep)) {
|
|
37920
|
+
continue;
|
|
37921
|
+
}
|
|
37922
|
+
// 添加文件扩展名
|
|
37923
|
+
dep = `${dep}.${dep.includes('.views.') ? 'tsx' : 'ts'}`;
|
|
37924
|
+
deps.add(dep);
|
|
37749
37925
|
}
|
|
37750
|
-
dep = `${dep}.${dep.includes('.views.') ? 'tsx' : 'ts'}`;
|
|
37751
|
-
deps.add(dep);
|
|
37752
37926
|
}
|
|
37753
37927
|
return Array.from(deps);
|
|
37754
37928
|
}
|
|
@@ -37865,7 +38039,12 @@ async function collectDeps(patterns, projectRoot, srcDir, logger, verbose) {
|
|
|
37865
38039
|
while (filesToProcess.length > 0) {
|
|
37866
38040
|
const pathRelativeToSrc = filesToProcess.shift();
|
|
37867
38041
|
if (processedFileMap.has(pathRelativeToSrc))
|
|
37868
|
-
continue; // 跳过已处理的文件
|
|
38042
|
+
continue; // 跳过已处理的文件
|
|
38043
|
+
// 检查文件类型是否支持
|
|
38044
|
+
if (!isKnownFileType(pathRelativeToSrc)) {
|
|
38045
|
+
logger.warn(`跳过不支持的文件类型: ${pathRelativeToSrc}`);
|
|
38046
|
+
continue;
|
|
38047
|
+
}
|
|
37869
38048
|
try {
|
|
37870
38049
|
const { fileInfo, newDeps } = processFileDeps(pathRelativeToSrc, srcDir, matchedFileSet, processedFileMap, depNotFoundList, logger, verbose);
|
|
37871
38050
|
result.push(fileInfo);
|
|
@@ -37943,8 +38122,18 @@ async function resolveNASLFiles(entry, logger, depMode, verbose) {
|
|
|
37943
38122
|
}
|
|
37944
38123
|
logger.info(`找到 ${collectedFiles.length} 个 NASL 文件`);
|
|
37945
38124
|
}
|
|
38125
|
+
// 统一过滤掉不支持的文件类型
|
|
38126
|
+
const filteredFiles = [];
|
|
38127
|
+
collectedFiles.forEach((file) => {
|
|
38128
|
+
if (isKnownFileType(file.path)) {
|
|
38129
|
+
filteredFiles.push(file);
|
|
38130
|
+
}
|
|
38131
|
+
else {
|
|
38132
|
+
logger.warn(`跳过不支持的文件类型: ${file.path}`);
|
|
38133
|
+
}
|
|
38134
|
+
});
|
|
37946
38135
|
return {
|
|
37947
|
-
collectedFiles,
|
|
38136
|
+
collectedFiles: filteredFiles,
|
|
37948
38137
|
config,
|
|
37949
38138
|
projectRoot,
|
|
37950
38139
|
srcDir,
|
|
@@ -37993,7 +38182,7 @@ async function tryCompile(entry, options) {
|
|
|
37993
38182
|
}
|
|
37994
38183
|
}
|
|
37995
38184
|
|
|
37996
|
-
var version = "0.
|
|
38185
|
+
var version = "0.2.0";
|
|
37997
38186
|
var pkg = {
|
|
37998
38187
|
version: version};
|
|
37999
38188
|
|