@nasl/cli 0.3.4 → 0.3.5
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 +24 -3
- package/dist/bin/nasl.mjs +37 -15
- package/dist/bin/nasl.mjs.map +1 -1
- package/dist/bin/naslc.mjs +37 -15
- package/dist/bin/naslc.mjs.map +1 -1
- package/dist/index.mjs +36 -14
- package/dist/index.mjs.map +1 -1
- package/out/constants/nasl-file-types.d.ts +1 -1
- package/out/constants/nasl-file-types.d.ts.map +1 -1
- package/out/constants/nasl-file-types.js +8 -1
- package/out/constants/nasl-file-types.js.map +1 -1
- package/out/services/compose.d.ts.map +1 -1
- package/out/services/compose.js +21 -8
- package/out/services/compose.js.map +1 -1
- package/out/services/resolve.d.ts.map +1 -1
- package/out/services/resolve.js +7 -5
- package/out/services/resolve.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/naslc.mjs
CHANGED
|
@@ -29137,7 +29137,18 @@ window.backendApp = app;
|
|
|
29137
29137
|
}
|
|
29138
29138
|
|
|
29139
29139
|
function createSorter() {
|
|
29140
|
-
const priorityOrder = [
|
|
29140
|
+
const priorityOrder = [
|
|
29141
|
+
'extensions',
|
|
29142
|
+
'apis',
|
|
29143
|
+
'connectors',
|
|
29144
|
+
'app.backend.variables',
|
|
29145
|
+
'app.roles',
|
|
29146
|
+
'app.enums',
|
|
29147
|
+
'app.dataSources',
|
|
29148
|
+
'app.structures',
|
|
29149
|
+
'app.logics',
|
|
29150
|
+
'app.frontendTypes',
|
|
29151
|
+
];
|
|
29141
29152
|
// 获取优先级索引
|
|
29142
29153
|
const getPriority = (str) => {
|
|
29143
29154
|
const prefixIndex = priorityOrder.findIndex((p) => str.startsWith(p));
|
|
@@ -29151,13 +29162,11 @@ function createSorter() {
|
|
|
29151
29162
|
return aPriority - bPriority;
|
|
29152
29163
|
}
|
|
29153
29164
|
// 如果是frontendTypes,按字母顺序排序
|
|
29154
|
-
if (
|
|
29165
|
+
if (a.startsWith('app.frontendTypes') && b.startsWith('app.frontendTypes')) {
|
|
29155
29166
|
return a.localeCompare(b);
|
|
29156
29167
|
}
|
|
29157
|
-
|
|
29158
|
-
|
|
29159
|
-
return 0;
|
|
29160
|
-
}
|
|
29168
|
+
// 其他情况保持原顺序
|
|
29169
|
+
return 0;
|
|
29161
29170
|
};
|
|
29162
29171
|
}
|
|
29163
29172
|
const sorter = createSorter();
|
|
@@ -29225,11 +29234,15 @@ function composeToString(files, options) {
|
|
|
29225
29234
|
const isVariablesFile = nameFromPath === 'variables';
|
|
29226
29235
|
const isExtensionsFile = arr[0] === 'extensions';
|
|
29227
29236
|
const isThemeCss = ext === 'css' && nameFromPath === 'theme';
|
|
29228
|
-
const
|
|
29237
|
+
const isRolesJson = file.path === 'app.roles.json';
|
|
29238
|
+
const isSpecialFile = isVariablesFile || isExtensionsFile || isThemeCss || isRolesJson;
|
|
29229
29239
|
// 特殊文件的 namespace ${包含文件名,普通文件不包含
|
|
29230
29240
|
const namespace = isSpecialFile ? [...arr, nameFromPath].join('.') : arr.join('.');
|
|
29231
29241
|
let content = file.content;
|
|
29232
|
-
if (
|
|
29242
|
+
if (isRolesJson) {
|
|
29243
|
+
content = ` $roles(${content});`;
|
|
29244
|
+
}
|
|
29245
|
+
else if (['ts', 'tsx'].includes(ext)) {
|
|
29233
29246
|
if (isVariablesFile) {
|
|
29234
29247
|
validateVariablesFile(file, errors);
|
|
29235
29248
|
}
|
|
@@ -37796,6 +37809,13 @@ var globby = /*@__PURE__*/getDefaultExportFromCjs(globbyExports);
|
|
|
37796
37809
|
* NASL 支持的所有文件类型配置
|
|
37797
37810
|
*/
|
|
37798
37811
|
const NASL_FILE_TYPES = [
|
|
37812
|
+
{
|
|
37813
|
+
name: 'roles',
|
|
37814
|
+
description: '角色',
|
|
37815
|
+
fileNamePattern: 'app\\.roles\\.json',
|
|
37816
|
+
codeRefPattern: '',
|
|
37817
|
+
extension: 'json',
|
|
37818
|
+
},
|
|
37799
37819
|
{
|
|
37800
37820
|
name: 'theme-css',
|
|
37801
37821
|
description: '主题样式',
|
|
@@ -37892,7 +37912,7 @@ const fileNamePatterns = getFileNamePatterns();
|
|
|
37892
37912
|
* 获取用于提取代码引用的正则表达式数组
|
|
37893
37913
|
*/
|
|
37894
37914
|
function getCodeRefPatterns() {
|
|
37895
|
-
return NASL_FILE_TYPES.map((type) => new RegExp(type.codeRefPattern, 'g'));
|
|
37915
|
+
return NASL_FILE_TYPES.filter((type) => type.codeRefPattern).map((type) => new RegExp(type.codeRefPattern, 'g'));
|
|
37896
37916
|
}
|
|
37897
37917
|
const codeRefPatterns = getCodeRefPatterns();
|
|
37898
37918
|
/**
|
|
@@ -37927,7 +37947,7 @@ function shouldSkipDependencyTraversal(depPath) {
|
|
|
37927
37947
|
async function scanNASLFiles(srcDir, representation, logger) {
|
|
37928
37948
|
try {
|
|
37929
37949
|
const pattern = representation === 'NaturalTS' ? '**/*.{ts,tsx}' : '**/*.nasl';
|
|
37930
|
-
const files = await globby([pattern, '
|
|
37950
|
+
const files = await globby([pattern, 'app.frontendTypes.pc.frontends.pc.theme.css', 'app.roles.json'], {
|
|
37931
37951
|
cwd: srcDir,
|
|
37932
37952
|
onlyFiles: true,
|
|
37933
37953
|
absolute: false,
|
|
@@ -38161,9 +38181,9 @@ function buildExternalDependencies(refs, mergedDeps, logger) {
|
|
|
38161
38181
|
function replaceViewAsSignature(content, hasSubViews = false) {
|
|
38162
38182
|
if (hasSubViews) {
|
|
38163
38183
|
// 如果有子页面,替换为返回 ElRouterView 的函数
|
|
38164
|
-
return content.replace(/export function ((\w+)\([
|
|
38184
|
+
return content.replace(/export function ((\w+)\([\s\S]*?\)) \{[\s\S]+$/, 'export function $1 {\n return <ElRouterView />\n}');
|
|
38165
38185
|
}
|
|
38166
|
-
return content.replace(/export function ((\w+)\([
|
|
38186
|
+
return content.replace(/export function ((\w+)\([\s\S]*?\)) \{[\s\S]+$/, 'export declare function $1;');
|
|
38167
38187
|
}
|
|
38168
38188
|
/**
|
|
38169
38189
|
* 处理单个文件的依赖
|
|
@@ -38205,8 +38225,10 @@ function processFileDeps(pathRelativeToSrc, srcDir, matchedFileSet, processedFil
|
|
|
38205
38225
|
processedFileMap.set(pathRelativeToSrc, fileInfo);
|
|
38206
38226
|
// 提取依赖
|
|
38207
38227
|
// extensions/connectors/apis/uilibs 作为叶子节点,不再向下递归查找依赖
|
|
38228
|
+
// JSON 文件(如 app.roles.json)无代码引用,跳过依赖分析
|
|
38208
38229
|
const isExternalDep = shouldSkipDependencyTraversal(pathRelativeToSrc);
|
|
38209
|
-
const
|
|
38230
|
+
const isRolesJson = pathRelativeToSrc === 'app.roles.json';
|
|
38231
|
+
const deps = isExternalDep || isRolesJson ? [] : extractDeps(fileInfo.content);
|
|
38210
38232
|
// 查找依赖文件
|
|
38211
38233
|
if (isView) {
|
|
38212
38234
|
const pathArr = pathRelativeToSrc.split('.');
|
|
@@ -38332,7 +38354,7 @@ async function resolveNASLFiles(entry, logger, depMode, verbose) {
|
|
|
38332
38354
|
}
|
|
38333
38355
|
let externalRefs = null;
|
|
38334
38356
|
if (!entry && depMode)
|
|
38335
|
-
entry = 'src/**/app.*.{ts,tsx,css}';
|
|
38357
|
+
entry = ['src/**/app.*.{ts,tsx,css}', 'src/app.roles.json'];
|
|
38336
38358
|
if (entry) {
|
|
38337
38359
|
// 检查入口路径是否在源代码目录外面
|
|
38338
38360
|
// if (entry.startsWith('..')) throw new Error('入口路径不能在源代码目录外面');
|
|
@@ -38446,7 +38468,7 @@ async function tryCompile(entry, options) {
|
|
|
38446
38468
|
}
|
|
38447
38469
|
}
|
|
38448
38470
|
|
|
38449
|
-
var version = "0.3.
|
|
38471
|
+
var version = "0.3.5";
|
|
38450
38472
|
var pkg = {
|
|
38451
38473
|
version: version};
|
|
38452
38474
|
|