@nasl/cli 0.1.15 → 0.1.16
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/build/nasl.bundle.js +4970 -4941
- package/dist/bin/nasl.mjs +32 -20
- package/dist/bin/nasl.mjs.map +1 -1
- package/dist/bin/naslc.mjs +1 -1
- package/dist/index.mjs +2 -19
- package/dist/index.mjs.map +1 -1
- package/out/bin/nasl.js +62 -0
- package/out/bin/nasl.js.map +1 -1
- package/out/commands/transform.d.ts.map +1 -1
- package/out/commands/transform.js +1 -18
- package/out/commands/transform.js.map +1 -1
- package/out/types/command.d.ts +1 -0
- package/out/types/command.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bin/nasl.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import require$$0$6 from 'url';
|
|
|
18
18
|
import require$$8 from 'crypto';
|
|
19
19
|
import http2 from 'http2';
|
|
20
20
|
import zlib from 'zlib';
|
|
21
|
+
import * as readline from 'readline';
|
|
21
22
|
import { realpath as realpath$1, stat as stat$2, lstat as lstat$1, open, readdir as readdir$1 } from 'fs/promises';
|
|
22
23
|
import { lstat, stat as stat$1, readdir, realpath } from 'node:fs/promises';
|
|
23
24
|
import { Readable as Readable$1 } from 'node:stream';
|
|
@@ -38257,25 +38258,8 @@ const transformFns = {
|
|
|
38257
38258
|
* 将 src 中的文件转换成一个 JSON
|
|
38258
38259
|
*/
|
|
38259
38260
|
async files2json(entry, options) {
|
|
38260
|
-
|
|
38261
|
-
|
|
38262
|
-
const { collectedFiles, projectRoot } = await resolveNASLFiles(entry, logger, false, options?.verbose);
|
|
38263
|
-
if (collectedFiles.length === 0) {
|
|
38264
|
-
logger.error('未找到需要转换的文件');
|
|
38265
|
-
logger.exit(1);
|
|
38266
|
-
}
|
|
38267
|
-
logger.info(`找到 ${collectedFiles.length} 个文件`);
|
|
38268
|
-
// 转换为 JSON
|
|
38269
|
-
logger.newLine();
|
|
38270
|
-
logger.info('正在转换为 JSON...');
|
|
38271
|
-
const jsonContent = JSON.stringify(collectedFiles, null, 2);
|
|
38272
|
-
// 确定输出路径
|
|
38273
|
-
const outputPath = options?.output
|
|
38274
|
-
? sysPath.resolve(projectRoot, options.output)
|
|
38275
|
-
: sysPath.join(projectRoot, './files.json');
|
|
38276
|
-
// 写入文件
|
|
38277
|
-
writeFileWithLog(outputPath, jsonContent, logger);
|
|
38278
|
-
logger.success(`JSON 文件已输出到: ${outputPath}`);
|
|
38261
|
+
options?.logger || defaultLogger;
|
|
38262
|
+
throw new Error('files2json 转换类型尚未实现');
|
|
38279
38263
|
},
|
|
38280
38264
|
};
|
|
38281
38265
|
/**
|
|
@@ -38292,11 +38276,27 @@ async function transform(transformType, entry, options) {
|
|
|
38292
38276
|
await transformFn(entry, options);
|
|
38293
38277
|
}
|
|
38294
38278
|
|
|
38295
|
-
var version = "0.1.
|
|
38279
|
+
var version = "0.1.16";
|
|
38296
38280
|
var pkg = {
|
|
38297
38281
|
version: version};
|
|
38298
38282
|
|
|
38299
38283
|
const program = new Command();
|
|
38284
|
+
/**
|
|
38285
|
+
* 使用 readline 询问用户确认
|
|
38286
|
+
*/
|
|
38287
|
+
function askForConfirmation(question) {
|
|
38288
|
+
const rl = readline.createInterface({
|
|
38289
|
+
input: process.stdin,
|
|
38290
|
+
output: process.stdout,
|
|
38291
|
+
});
|
|
38292
|
+
return new Promise((resolve) => {
|
|
38293
|
+
rl.question(question, (answer) => {
|
|
38294
|
+
rl.close();
|
|
38295
|
+
const normalizedAnswer = answer.trim().toLowerCase();
|
|
38296
|
+
resolve(normalizedAnswer === 'y' || normalizedAnswer === 'yes' || normalizedAnswer === '是');
|
|
38297
|
+
});
|
|
38298
|
+
});
|
|
38299
|
+
}
|
|
38300
38300
|
const entryDescription = `是相对于项目根目录的路径,支持 glob 模式(注意要用引号包裹),例如:
|
|
38301
38301
|
- src/app.enums.Status.ts 支持具体文件
|
|
38302
38302
|
- "src/app.enums.*.ts" 表示所有枚举
|
|
@@ -38379,8 +38379,20 @@ program
|
|
|
38379
38379
|
.command('create-app-in-ide [entry]')
|
|
38380
38380
|
.description('在 IDE 中创建应用')
|
|
38381
38381
|
.option('-v, --verbose', '显示详细信息,如依赖分析树')
|
|
38382
|
+
.option('-q, --quiet', '不询问问题')
|
|
38382
38383
|
.action(async (entry, options) => {
|
|
38383
38384
|
try {
|
|
38385
|
+
// 如果不是 quiet 模式,询问用户确认
|
|
38386
|
+
if (!options?.quiet) {
|
|
38387
|
+
defaultLogger.newLine();
|
|
38388
|
+
defaultLogger.info('即将在 IDE 中创建应用,此操作将调用远程服务。');
|
|
38389
|
+
const confirmed = await askForConfirmation('是否继续?(y/n): ');
|
|
38390
|
+
if (!confirmed) {
|
|
38391
|
+
defaultLogger.info('已取消操作');
|
|
38392
|
+
process.exit(0);
|
|
38393
|
+
}
|
|
38394
|
+
defaultLogger.newLine();
|
|
38395
|
+
}
|
|
38384
38396
|
await createAppInIde(entry, options);
|
|
38385
38397
|
}
|
|
38386
38398
|
catch (error) {
|