@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/README.md
CHANGED
|
@@ -159,9 +159,13 @@ nasl transform files2json [entry] --output [outputPath]
|
|
|
159
159
|
# 默认输出到 ./files.json
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
### 在 IDE
|
|
162
|
+
### 在 IDE 中创建 / 更新应用
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
**注意**:`create-app-in-ide` 与 `update-app-in-ide` 只能在测试环境使用。
|
|
165
|
+
|
|
166
|
+
两个命令都会先按 [入口文件说明](#入口文件说明) 解析本地 NASL(可选 `[entry]`,不传则处理整个 `src`),将源码组合为 fullNaturalTS(含依赖)后调用远程服务。均支持 `--quiet` 跳过确认、`--verbose` 输出依赖分析等详细信息。
|
|
167
|
+
|
|
168
|
+
#### 在 IDE 中创建应用(nasl create-app-in-ide)
|
|
165
169
|
|
|
166
170
|
```bash
|
|
167
171
|
# 会询问确认(默认)
|
|
@@ -174,7 +178,24 @@ nasl create-app-in-ide [entry] --quiet
|
|
|
174
178
|
nasl create-app-in-ide [entry] --verbose
|
|
175
179
|
```
|
|
176
180
|
|
|
177
|
-
|
|
181
|
+
执行前会展示即将使用的**应用名称**、**包名**、IDE 版本与租户。应用名与包名由项目目录推导:若存在 `specs/` 目录,则取其中**第一个子文件夹名**作为基础名;否则使用**项目根目录名**。基础名经清洗(仅保留字母数字、去掉开头数字、最长 12 字符)后,再拼接时间后缀生成最终名称。
|
|
182
|
+
|
|
183
|
+
#### 在 IDE 中更新已有应用(nasl update-app-in-ide)
|
|
184
|
+
|
|
185
|
+
第一个参数为远程应用的 **appId**(必填),其余与创建命令一致。
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# 会询问确认(默认)
|
|
189
|
+
nasl update-app-in-ide <appId> [entry]
|
|
190
|
+
|
|
191
|
+
# 跳过确认
|
|
192
|
+
nasl update-app-in-ide <appId> [entry] --quiet
|
|
193
|
+
|
|
194
|
+
# 显示详细信息
|
|
195
|
+
nasl update-app-in-ide <appId> [entry] --verbose
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
将当前本地 NASL 同步到指定应用,用于在 IDE 中更新已有应用而非新建。
|
|
178
199
|
|
|
179
200
|
## 环境变量配置
|
|
180
201
|
|
package/dist/bin/nasl.mjs
CHANGED
|
@@ -29268,7 +29268,18 @@ async function installDependenciesApi(dependenciesJSON, options) {
|
|
|
29268
29268
|
}
|
|
29269
29269
|
|
|
29270
29270
|
function createSorter() {
|
|
29271
|
-
const priorityOrder = [
|
|
29271
|
+
const priorityOrder = [
|
|
29272
|
+
'extensions',
|
|
29273
|
+
'apis',
|
|
29274
|
+
'connectors',
|
|
29275
|
+
'app.backend.variables',
|
|
29276
|
+
'app.roles',
|
|
29277
|
+
'app.enums',
|
|
29278
|
+
'app.dataSources',
|
|
29279
|
+
'app.structures',
|
|
29280
|
+
'app.logics',
|
|
29281
|
+
'app.frontendTypes',
|
|
29282
|
+
];
|
|
29272
29283
|
// 获取优先级索引
|
|
29273
29284
|
const getPriority = (str) => {
|
|
29274
29285
|
const prefixIndex = priorityOrder.findIndex((p) => str.startsWith(p));
|
|
@@ -29282,13 +29293,11 @@ function createSorter() {
|
|
|
29282
29293
|
return aPriority - bPriority;
|
|
29283
29294
|
}
|
|
29284
29295
|
// 如果是frontendTypes,按字母顺序排序
|
|
29285
|
-
if (
|
|
29296
|
+
if (a.startsWith('app.frontendTypes') && b.startsWith('app.frontendTypes')) {
|
|
29286
29297
|
return a.localeCompare(b);
|
|
29287
29298
|
}
|
|
29288
|
-
|
|
29289
|
-
|
|
29290
|
-
return 0;
|
|
29291
|
-
}
|
|
29299
|
+
// 其他情况保持原顺序
|
|
29300
|
+
return 0;
|
|
29292
29301
|
};
|
|
29293
29302
|
}
|
|
29294
29303
|
const sorter = createSorter();
|
|
@@ -29356,11 +29365,15 @@ function composeToString(files, options) {
|
|
|
29356
29365
|
const isVariablesFile = nameFromPath === 'variables';
|
|
29357
29366
|
const isExtensionsFile = arr[0] === 'extensions';
|
|
29358
29367
|
const isThemeCss = ext === 'css' && nameFromPath === 'theme';
|
|
29359
|
-
const
|
|
29368
|
+
const isRolesJson = file.path === 'app.roles.json';
|
|
29369
|
+
const isSpecialFile = isVariablesFile || isExtensionsFile || isThemeCss || isRolesJson;
|
|
29360
29370
|
// 特殊文件的 namespace ${包含文件名,普通文件不包含
|
|
29361
29371
|
const namespace = isSpecialFile ? [...arr, nameFromPath].join('.') : arr.join('.');
|
|
29362
29372
|
let content = file.content;
|
|
29363
|
-
if (
|
|
29373
|
+
if (isRolesJson) {
|
|
29374
|
+
content = ` $roles(${content});`;
|
|
29375
|
+
}
|
|
29376
|
+
else if (['ts', 'tsx'].includes(ext)) {
|
|
29364
29377
|
if (isVariablesFile) {
|
|
29365
29378
|
validateVariablesFile(file, errors);
|
|
29366
29379
|
}
|
|
@@ -37927,6 +37940,13 @@ var globby = /*@__PURE__*/getDefaultExportFromCjs(globbyExports);
|
|
|
37927
37940
|
* NASL 支持的所有文件类型配置
|
|
37928
37941
|
*/
|
|
37929
37942
|
const NASL_FILE_TYPES = [
|
|
37943
|
+
{
|
|
37944
|
+
name: 'roles',
|
|
37945
|
+
description: '角色',
|
|
37946
|
+
fileNamePattern: 'app\\.roles\\.json',
|
|
37947
|
+
codeRefPattern: '',
|
|
37948
|
+
extension: 'json',
|
|
37949
|
+
},
|
|
37930
37950
|
{
|
|
37931
37951
|
name: 'theme-css',
|
|
37932
37952
|
description: '主题样式',
|
|
@@ -38023,7 +38043,7 @@ const fileNamePatterns = getFileNamePatterns();
|
|
|
38023
38043
|
* 获取用于提取代码引用的正则表达式数组
|
|
38024
38044
|
*/
|
|
38025
38045
|
function getCodeRefPatterns() {
|
|
38026
|
-
return NASL_FILE_TYPES.map((type) => new RegExp(type.codeRefPattern, 'g'));
|
|
38046
|
+
return NASL_FILE_TYPES.filter((type) => type.codeRefPattern).map((type) => new RegExp(type.codeRefPattern, 'g'));
|
|
38027
38047
|
}
|
|
38028
38048
|
const codeRefPatterns = getCodeRefPatterns();
|
|
38029
38049
|
/**
|
|
@@ -38058,7 +38078,7 @@ function shouldSkipDependencyTraversal(depPath) {
|
|
|
38058
38078
|
async function scanNASLFiles(srcDir, representation, logger) {
|
|
38059
38079
|
try {
|
|
38060
38080
|
const pattern = representation === 'NaturalTS' ? '**/*.{ts,tsx}' : '**/*.nasl';
|
|
38061
|
-
const files = await globby([pattern, '
|
|
38081
|
+
const files = await globby([pattern, 'app.frontendTypes.pc.frontends.pc.theme.css', 'app.roles.json'], {
|
|
38062
38082
|
cwd: srcDir,
|
|
38063
38083
|
onlyFiles: true,
|
|
38064
38084
|
absolute: false,
|
|
@@ -38292,9 +38312,9 @@ function buildExternalDependencies(refs, mergedDeps, logger) {
|
|
|
38292
38312
|
function replaceViewAsSignature(content, hasSubViews = false) {
|
|
38293
38313
|
if (hasSubViews) {
|
|
38294
38314
|
// 如果有子页面,替换为返回 ElRouterView 的函数
|
|
38295
|
-
return content.replace(/export function ((\w+)\([
|
|
38315
|
+
return content.replace(/export function ((\w+)\([\s\S]*?\)) \{[\s\S]+$/, 'export function $1 {\n return <ElRouterView />\n}');
|
|
38296
38316
|
}
|
|
38297
|
-
return content.replace(/export function ((\w+)\([
|
|
38317
|
+
return content.replace(/export function ((\w+)\([\s\S]*?\)) \{[\s\S]+$/, 'export declare function $1;');
|
|
38298
38318
|
}
|
|
38299
38319
|
/**
|
|
38300
38320
|
* 处理单个文件的依赖
|
|
@@ -38336,8 +38356,10 @@ function processFileDeps(pathRelativeToSrc, srcDir, matchedFileSet, processedFil
|
|
|
38336
38356
|
processedFileMap.set(pathRelativeToSrc, fileInfo);
|
|
38337
38357
|
// 提取依赖
|
|
38338
38358
|
// extensions/connectors/apis/uilibs 作为叶子节点,不再向下递归查找依赖
|
|
38359
|
+
// JSON 文件(如 app.roles.json)无代码引用,跳过依赖分析
|
|
38339
38360
|
const isExternalDep = shouldSkipDependencyTraversal(pathRelativeToSrc);
|
|
38340
|
-
const
|
|
38361
|
+
const isRolesJson = pathRelativeToSrc === 'app.roles.json';
|
|
38362
|
+
const deps = isExternalDep || isRolesJson ? [] : extractDeps(fileInfo.content);
|
|
38341
38363
|
// 查找依赖文件
|
|
38342
38364
|
if (isView) {
|
|
38343
38365
|
const pathArr = pathRelativeToSrc.split('.');
|
|
@@ -38463,7 +38485,7 @@ async function resolveNASLFiles(entry, logger, depMode, verbose) {
|
|
|
38463
38485
|
}
|
|
38464
38486
|
let externalRefs = null;
|
|
38465
38487
|
if (!entry && depMode)
|
|
38466
|
-
entry = 'src/**/app.*.{ts,tsx,css}';
|
|
38488
|
+
entry = ['src/**/app.*.{ts,tsx,css}', 'src/app.roles.json'];
|
|
38467
38489
|
if (entry) {
|
|
38468
38490
|
// 检查入口路径是否在源代码目录外面
|
|
38469
38491
|
// if (entry.startsWith('..')) throw new Error('入口路径不能在源代码目录外面');
|
|
@@ -39443,7 +39465,7 @@ async function installByJSON(json, options) {
|
|
|
39443
39465
|
logger.success(`成功写入 ${writtenCount} 个依赖文件到 ${config.srcDir} 目录`);
|
|
39444
39466
|
}
|
|
39445
39467
|
|
|
39446
|
-
var version = "0.3.
|
|
39468
|
+
var version = "0.3.5";
|
|
39447
39469
|
var pkg = {
|
|
39448
39470
|
version: version};
|
|
39449
39471
|
|