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