@nasl/cli 0.1.12 → 0.1.14

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
@@ -13672,7 +13672,11 @@ async function scanEntryFiles(projectRoot, patterns, logger) {
13672
13672
  */
13673
13673
  function extractDeps(content) {
13674
13674
  const deps = new Set();
13675
- const allMatches = content.matchAll(/app\.\w+\.[\w.]+/g); // 起码要2个点
13675
+ // 预处理:移除注释,避免注释影响依赖分析
13676
+ let processedContent = content
13677
+ .replace(/\/\/.*$/gm, '') // 移除单行注释 // ...
13678
+ .replace(/\/\*[\s\S]*?\*\//g, ''); // 移除多行注释 /* ... */
13679
+ const allMatches = processedContent.matchAll(/app\.\w+\.[\w.]+/g); // 起码要2个点
13676
13680
  for (const match of allMatches) {
13677
13681
  let dep = match[0];
13678
13682
  if (/Entity$|Entity\./.test(dep)) {
@@ -13692,9 +13696,14 @@ function extractDeps(content) {
13692
13696
  /**
13693
13697
  * 提取页面文件的签名,移除函数体
13694
13698
  * @param content 页面文件内容
13695
- * @returns 只包含签名的内容
13699
+ * @param hasSubViews 是否有子页面
13700
+ * @returns 只包含签名的内容,或者返回 ElRouterView 的实现
13696
13701
  */
13697
- function replaceViewAsSignature(content) {
13702
+ function replaceViewAsSignature(content, hasSubViews = false) {
13703
+ if (hasSubViews) {
13704
+ // 如果有子页面,替换为返回 ElRouterView 的函数
13705
+ return content.replace(/export function ((\w+)\([^)]*\)) \{[\s\S]+$/, 'export function $1 {\n return <ElRouterView />\n}');
13706
+ }
13698
13707
  return content.replace(/export function ((\w+)\([^)]*\)) \{[\s\S]+$/, 'export declare function $1;');
13699
13708
  }
13700
13709
  /**
@@ -13723,7 +13732,15 @@ function processFileDeps(pathRelativeToSrc, srcDir, matchedFileSet, processedFil
13723
13732
  const pathWithoutExt = pathRelativeToSrc.slice(0, -4);
13724
13733
  const isEntryParent = Array.from(matchedFileSet).some((filePath) => filePath.startsWith(pathWithoutExt));
13725
13734
  if (!isEntryParent) {
13726
- fileInfo.content = replaceViewAsSignature(fileInfo.content);
13735
+ // 检查是否有子页面(路径更长的页面文件)
13736
+ const subViewPattern = `${pathWithoutExt}.views.*.tsx`;
13737
+ const subViews = globby.sync([subViewPattern], {
13738
+ cwd: srcDir,
13739
+ onlyFiles: true,
13740
+ absolute: false,
13741
+ });
13742
+ const hasSubViews = subViews.length > 0;
13743
+ fileInfo.content = replaceViewAsSignature(fileInfo.content, hasSubViews);
13727
13744
  }
13728
13745
  }
13729
13746
  processedFileMap.set(pathRelativeToSrc, fileInfo);