@nasl/cli 0.1.6 → 0.1.7
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 +12 -0
- package/build/index.js +8 -0
- package/dist/bin/nasl.mjs +1942 -70
- package/dist/bin/nasl.mjs.map +1 -1
- package/dist/bin/naslc.mjs +59 -47
- package/dist/bin/naslc.mjs.map +1 -1
- package/dist/index.mjs +1941 -69
- package/dist/index.mjs.map +1 -1
- package/out/apis/createAxios.d.ts.map +1 -1
- package/out/apis/createAxios.js +13 -0
- package/out/apis/createAxios.js.map +1 -1
- package/out/commands/compile.js +1 -1
- package/out/commands/compile.js.map +1 -1
- package/out/commands/dev.d.ts.map +1 -1
- package/out/commands/dev.js +191 -6
- package/out/commands/dev.js.map +1 -1
- package/out/utils/logger.d.ts +3 -0
- package/out/utils/logger.d.ts.map +1 -1
- package/out/utils/logger.js +9 -1
- package/out/utils/logger.js.map +1 -1
- package/package.json +2 -2
package/dist/bin/naslc.mjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
#!/usr/bin/env node
|
|
3
3
|
import require$$0$1, { EventEmitter } from 'events';
|
|
4
4
|
import require$$1 from 'child_process';
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
5
|
+
import * as sysPath from 'path';
|
|
6
|
+
import sysPath__default from 'path';
|
|
7
7
|
import require$$0$2 from 'fs';
|
|
8
8
|
import require$$4 from 'process';
|
|
9
9
|
import require$$0$5 from 'os';
|
|
@@ -14,7 +14,7 @@ import require$$0$4 from 'util';
|
|
|
14
14
|
import require$$5 from 'assert';
|
|
15
15
|
import require$$3 from 'http';
|
|
16
16
|
import require$$4$1 from 'https';
|
|
17
|
-
import require$$0$6 from 'url';
|
|
17
|
+
import require$$0$6, { URL as URL$1 } from 'url';
|
|
18
18
|
import require$$8 from 'crypto';
|
|
19
19
|
import http2 from 'http2';
|
|
20
20
|
import zlib from 'zlib';
|
|
@@ -1166,7 +1166,7 @@ function requireCommand () {
|
|
|
1166
1166
|
hasRequiredCommand = 1;
|
|
1167
1167
|
const EventEmitter = require$$0$1.EventEmitter;
|
|
1168
1168
|
const childProcess = require$$1;
|
|
1169
|
-
const path =
|
|
1169
|
+
const path = sysPath__default;
|
|
1170
1170
|
const fs = require$$0$2;
|
|
1171
1171
|
const process = require$$4;
|
|
1172
1172
|
|
|
@@ -4576,7 +4576,7 @@ var hasRequiredUtils$5;
|
|
|
4576
4576
|
function requireUtils$5 () {
|
|
4577
4577
|
if (hasRequiredUtils$5) return utils$7;
|
|
4578
4578
|
hasRequiredUtils$5 = 1;
|
|
4579
|
-
const path =
|
|
4579
|
+
const path = sysPath__default;
|
|
4580
4580
|
|
|
4581
4581
|
// https://github.com/nodejs/node/issues/8987
|
|
4582
4582
|
// https://github.com/libuv/libuv/pull/1088
|
|
@@ -4722,7 +4722,7 @@ function requireStat () {
|
|
|
4722
4722
|
hasRequiredStat = 1;
|
|
4723
4723
|
|
|
4724
4724
|
const fs = /*@__PURE__*/ requireFs$4();
|
|
4725
|
-
const path =
|
|
4725
|
+
const path = sysPath__default;
|
|
4726
4726
|
const u = requireUniversalify().fromPromise;
|
|
4727
4727
|
|
|
4728
4728
|
function getStats (src, dest, opts) {
|
|
@@ -4926,7 +4926,7 @@ function requireCopy$1 () {
|
|
|
4926
4926
|
hasRequiredCopy$1 = 1;
|
|
4927
4927
|
|
|
4928
4928
|
const fs = /*@__PURE__*/ requireFs$4();
|
|
4929
|
-
const path =
|
|
4929
|
+
const path = sysPath__default;
|
|
4930
4930
|
const { mkdirs } = /*@__PURE__*/ requireMkdirs();
|
|
4931
4931
|
const { pathExists } = /*@__PURE__*/ requirePathExists();
|
|
4932
4932
|
const { utimesMillis } = /*@__PURE__*/ requireUtimes();
|
|
@@ -5109,7 +5109,7 @@ function requireCopySync () {
|
|
|
5109
5109
|
hasRequiredCopySync = 1;
|
|
5110
5110
|
|
|
5111
5111
|
const fs = requireGracefulFs();
|
|
5112
|
-
const path =
|
|
5112
|
+
const path = sysPath__default;
|
|
5113
5113
|
const mkdirsSync = /*@__PURE__*/ requireMkdirs().mkdirsSync;
|
|
5114
5114
|
const utimesMillisSync = /*@__PURE__*/ requireUtimes().utimesMillisSync;
|
|
5115
5115
|
const stat = /*@__PURE__*/ requireStat();
|
|
@@ -5329,7 +5329,7 @@ function requireEmpty () {
|
|
|
5329
5329
|
|
|
5330
5330
|
const u = requireUniversalify().fromPromise;
|
|
5331
5331
|
const fs = /*@__PURE__*/ requireFs$4();
|
|
5332
|
-
const path =
|
|
5332
|
+
const path = sysPath__default;
|
|
5333
5333
|
const mkdir = /*@__PURE__*/ requireMkdirs();
|
|
5334
5334
|
const remove = /*@__PURE__*/ requireRemove();
|
|
5335
5335
|
|
|
@@ -5375,7 +5375,7 @@ function requireFile () {
|
|
|
5375
5375
|
hasRequiredFile = 1;
|
|
5376
5376
|
|
|
5377
5377
|
const u = requireUniversalify().fromPromise;
|
|
5378
|
-
const path =
|
|
5378
|
+
const path = sysPath__default;
|
|
5379
5379
|
const fs = /*@__PURE__*/ requireFs$4();
|
|
5380
5380
|
const mkdir = /*@__PURE__*/ requireMkdirs();
|
|
5381
5381
|
|
|
@@ -5449,7 +5449,7 @@ function requireLink () {
|
|
|
5449
5449
|
hasRequiredLink = 1;
|
|
5450
5450
|
|
|
5451
5451
|
const u = requireUniversalify().fromPromise;
|
|
5452
|
-
const path =
|
|
5452
|
+
const path = sysPath__default;
|
|
5453
5453
|
const fs = /*@__PURE__*/ requireFs$4();
|
|
5454
5454
|
const mkdir = /*@__PURE__*/ requireMkdirs();
|
|
5455
5455
|
const { pathExists } = /*@__PURE__*/ requirePathExists();
|
|
@@ -5520,7 +5520,7 @@ function requireSymlinkPaths () {
|
|
|
5520
5520
|
if (hasRequiredSymlinkPaths) return symlinkPaths_1;
|
|
5521
5521
|
hasRequiredSymlinkPaths = 1;
|
|
5522
5522
|
|
|
5523
|
-
const path =
|
|
5523
|
+
const path = sysPath__default;
|
|
5524
5524
|
const fs = /*@__PURE__*/ requireFs$4();
|
|
5525
5525
|
const { pathExists } = /*@__PURE__*/ requirePathExists();
|
|
5526
5526
|
|
|
@@ -5672,7 +5672,7 @@ function requireSymlink () {
|
|
|
5672
5672
|
hasRequiredSymlink = 1;
|
|
5673
5673
|
|
|
5674
5674
|
const u = requireUniversalify().fromPromise;
|
|
5675
|
-
const path =
|
|
5675
|
+
const path = sysPath__default;
|
|
5676
5676
|
const fs = /*@__PURE__*/ requireFs$4();
|
|
5677
5677
|
|
|
5678
5678
|
const { mkdirs, mkdirsSync } = /*@__PURE__*/ requireMkdirs();
|
|
@@ -5918,7 +5918,7 @@ function requireOutputFile () {
|
|
|
5918
5918
|
|
|
5919
5919
|
const u = requireUniversalify().fromPromise;
|
|
5920
5920
|
const fs = /*@__PURE__*/ requireFs$4();
|
|
5921
|
-
const path =
|
|
5921
|
+
const path = sysPath__default;
|
|
5922
5922
|
const mkdir = /*@__PURE__*/ requireMkdirs();
|
|
5923
5923
|
const pathExists = /*@__PURE__*/ requirePathExists().pathExists;
|
|
5924
5924
|
|
|
@@ -6020,7 +6020,7 @@ function requireMove$1 () {
|
|
|
6020
6020
|
hasRequiredMove$1 = 1;
|
|
6021
6021
|
|
|
6022
6022
|
const fs = /*@__PURE__*/ requireFs$4();
|
|
6023
|
-
const path =
|
|
6023
|
+
const path = sysPath__default;
|
|
6024
6024
|
const { copy } = /*@__PURE__*/ requireCopy();
|
|
6025
6025
|
const { remove } = /*@__PURE__*/ requireRemove();
|
|
6026
6026
|
const { mkdirp } = /*@__PURE__*/ requireMkdirs();
|
|
@@ -6087,7 +6087,7 @@ function requireMoveSync () {
|
|
|
6087
6087
|
hasRequiredMoveSync = 1;
|
|
6088
6088
|
|
|
6089
6089
|
const fs = requireGracefulFs();
|
|
6090
|
-
const path =
|
|
6090
|
+
const path = sysPath__default;
|
|
6091
6091
|
const copySync = /*@__PURE__*/ requireCopy().copySync;
|
|
6092
6092
|
const removeSync = /*@__PURE__*/ requireRemove().removeSync;
|
|
6093
6093
|
const mkdirpSync = /*@__PURE__*/ requireMkdirs().mkdirpSync;
|
|
@@ -8204,16 +8204,16 @@ class BaseLogger {
|
|
|
8204
8204
|
}
|
|
8205
8205
|
debugToFile(topic, ...args) {
|
|
8206
8206
|
if (process.env.DEBUG_TO_FILE) {
|
|
8207
|
-
const baseDir =
|
|
8207
|
+
const baseDir = sysPath.join(process.cwd(), '.nasl');
|
|
8208
8208
|
const currentHour = dayjs().format('YYYYMMDD_HH');
|
|
8209
8209
|
const prevHour = dayjs().subtract(1, 'hour').format('YYYYMMDD_HH');
|
|
8210
8210
|
let subdir = `${topic}_${currentHour}`;
|
|
8211
8211
|
const prevSubdir = `${topic}_${prevHour}`;
|
|
8212
8212
|
// 判断如果有上一个小时的 subdir,则自己汇聚到上一个小时的 subdir 中
|
|
8213
|
-
if (libExports.existsSync(
|
|
8213
|
+
if (libExports.existsSync(sysPath.join(baseDir, prevSubdir)))
|
|
8214
8214
|
subdir = prevSubdir;
|
|
8215
8215
|
const fileName = `${topic}_${dayjs().format('YYYYMMDD_HHmmss')}.log`;
|
|
8216
|
-
const filePath =
|
|
8216
|
+
const filePath = sysPath.join(baseDir, subdir, fileName);
|
|
8217
8217
|
libExports.outputFileSync(filePath, args.join(' '));
|
|
8218
8218
|
}
|
|
8219
8219
|
}
|
|
@@ -8271,11 +8271,11 @@ function findConfigDir(startDir = process.cwd()) {
|
|
|
8271
8271
|
let currentDir = startDir;
|
|
8272
8272
|
// eslint-disable-next-line no-constant-condition
|
|
8273
8273
|
while (true) {
|
|
8274
|
-
const configPath =
|
|
8274
|
+
const configPath = sysPath.join(currentDir, CONFIG_FILE_NAME);
|
|
8275
8275
|
if (libExports.existsSync(configPath)) {
|
|
8276
8276
|
return currentDir;
|
|
8277
8277
|
}
|
|
8278
|
-
const parentDir =
|
|
8278
|
+
const parentDir = sysPath.dirname(currentDir);
|
|
8279
8279
|
// 已经到达根目录
|
|
8280
8280
|
if (parentDir === currentDir) {
|
|
8281
8281
|
return null;
|
|
@@ -8292,7 +8292,7 @@ function loadConfig(configDir) {
|
|
|
8292
8292
|
defaultLogger.error(`未找到配置文件 ${CONFIG_FILE_NAME},请先运行 nasl-init 初始化配置`);
|
|
8293
8293
|
return defaultLogger.exit(1);
|
|
8294
8294
|
}
|
|
8295
|
-
const configPath =
|
|
8295
|
+
const configPath = sysPath.join(dir, CONFIG_FILE_NAME);
|
|
8296
8296
|
try {
|
|
8297
8297
|
const content = libExports.readFileSync(configPath, 'utf-8');
|
|
8298
8298
|
const config = JSON.parse(content);
|
|
@@ -8337,7 +8337,7 @@ function readFileWithLog(filePath, logger) {
|
|
|
8337
8337
|
*/
|
|
8338
8338
|
function writeFileWithLog(filePath, content, logger) {
|
|
8339
8339
|
try {
|
|
8340
|
-
const dir =
|
|
8340
|
+
const dir = sysPath.dirname(filePath);
|
|
8341
8341
|
libExports.ensureDirSync(dir);
|
|
8342
8342
|
libExports.writeFileSync(filePath, content, 'utf-8');
|
|
8343
8343
|
}
|
|
@@ -20323,7 +20323,7 @@ function requireMimeTypes () {
|
|
|
20323
20323
|
*/
|
|
20324
20324
|
|
|
20325
20325
|
var db = requireMimeDb();
|
|
20326
|
-
var extname =
|
|
20326
|
+
var extname = sysPath__default.extname;
|
|
20327
20327
|
|
|
20328
20328
|
/**
|
|
20329
20329
|
* Module variables.
|
|
@@ -22064,7 +22064,7 @@ function requireForm_data () {
|
|
|
22064
22064
|
|
|
22065
22065
|
var CombinedStream = requireCombined_stream();
|
|
22066
22066
|
var util = require$$0$4;
|
|
22067
|
-
var path =
|
|
22067
|
+
var path = sysPath__default;
|
|
22068
22068
|
var http = require$$3;
|
|
22069
22069
|
var https = require$$4$1;
|
|
22070
22070
|
var parseUrl = require$$0$6.parse;
|
|
@@ -28765,10 +28765,22 @@ const {
|
|
|
28765
28765
|
} = axios;
|
|
28766
28766
|
|
|
28767
28767
|
function createAxios(baseURL) {
|
|
28768
|
+
// 解析 baseURL 提取 hostname 和 port
|
|
28769
|
+
const url = new URL$1(baseURL);
|
|
28770
|
+
const hostname = url.hostname;
|
|
28771
|
+
const protocol = url.protocol;
|
|
28772
|
+
// 确定端口:如果 URL 中没有指定端口,根据协议使用默认端口
|
|
28773
|
+
let port = url.port;
|
|
28774
|
+
if (!port) {
|
|
28775
|
+
port = protocol === 'https:' ? '443' : '80';
|
|
28776
|
+
}
|
|
28777
|
+
// 构建 Host 头:hostname:port
|
|
28778
|
+
const hostHeader = `${hostname}:${port}`;
|
|
28768
28779
|
return axios.create({
|
|
28769
28780
|
baseURL,
|
|
28770
28781
|
headers: {
|
|
28771
28782
|
'Content-Type': 'application/json',
|
|
28783
|
+
'Host': hostHeader,
|
|
28772
28784
|
},
|
|
28773
28785
|
timeout: 120000,
|
|
28774
28786
|
});
|
|
@@ -29127,7 +29139,7 @@ function requirePath () {
|
|
|
29127
29139
|
Object.defineProperty(path, "__esModule", { value: true });
|
|
29128
29140
|
path.convertPosixPathToPattern = path.convertWindowsPathToPattern = path.convertPathToPattern = path.escapePosixPath = path.escapeWindowsPath = path.escape = path.removeLeadingDotSegment = path.makeAbsolute = path.unixify = void 0;
|
|
29129
29141
|
const os = require$$0$5;
|
|
29130
|
-
const path$1 =
|
|
29142
|
+
const path$1 = sysPath__default;
|
|
29131
29143
|
const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
|
|
29132
29144
|
const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
|
|
29133
29145
|
/**
|
|
@@ -29392,7 +29404,7 @@ function requireGlobParent () {
|
|
|
29392
29404
|
hasRequiredGlobParent = 1;
|
|
29393
29405
|
|
|
29394
29406
|
var isGlob = requireIsGlob();
|
|
29395
|
-
var pathPosixDirname =
|
|
29407
|
+
var pathPosixDirname = sysPath__default.posix.dirname;
|
|
29396
29408
|
var isWin32 = require$$0$5.platform() === 'win32';
|
|
29397
29409
|
|
|
29398
29410
|
var slash = '/';
|
|
@@ -30964,7 +30976,7 @@ function requireConstants$1 () {
|
|
|
30964
30976
|
if (hasRequiredConstants$1) return constants$1;
|
|
30965
30977
|
hasRequiredConstants$1 = 1;
|
|
30966
30978
|
|
|
30967
|
-
const path =
|
|
30979
|
+
const path = sysPath__default;
|
|
30968
30980
|
const WIN_SLASH = '\\\\/';
|
|
30969
30981
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
30970
30982
|
|
|
@@ -31151,7 +31163,7 @@ function requireUtils$2 () {
|
|
|
31151
31163
|
hasRequiredUtils$2 = 1;
|
|
31152
31164
|
(function (exports$1) {
|
|
31153
31165
|
|
|
31154
|
-
const path =
|
|
31166
|
+
const path = sysPath__default;
|
|
31155
31167
|
const win32 = process.platform === 'win32';
|
|
31156
31168
|
const {
|
|
31157
31169
|
REGEX_BACKSLASH,
|
|
@@ -32722,7 +32734,7 @@ function requirePicomatch$1 () {
|
|
|
32722
32734
|
if (hasRequiredPicomatch$1) return picomatch_1;
|
|
32723
32735
|
hasRequiredPicomatch$1 = 1;
|
|
32724
32736
|
|
|
32725
|
-
const path =
|
|
32737
|
+
const path = sysPath__default;
|
|
32726
32738
|
const scan = requireScan();
|
|
32727
32739
|
const parse = requireParse();
|
|
32728
32740
|
const utils = requireUtils$2();
|
|
@@ -33565,7 +33577,7 @@ function requirePattern () {
|
|
|
33565
33577
|
hasRequiredPattern = 1;
|
|
33566
33578
|
Object.defineProperty(pattern, "__esModule", { value: true });
|
|
33567
33579
|
pattern.isAbsolute = pattern.partitionAbsoluteAndRelative = pattern.removeDuplicateSlashes = pattern.matchAny = pattern.convertPatternsToRe = pattern.makeRe = pattern.getPatternParts = pattern.expandBraceExpansion = pattern.expandPatternsWithBraceExpansion = pattern.isAffectDepthOfReadingPattern = pattern.endsWithSlashGlobStar = pattern.hasGlobStar = pattern.getBaseDirectory = pattern.isPatternRelatedToParentDirectory = pattern.getPatternsOutsideCurrentDirectory = pattern.getPatternsInsideCurrentDirectory = pattern.getPositivePatterns = pattern.getNegativePatterns = pattern.isPositivePattern = pattern.isNegativePattern = pattern.convertToNegativePattern = pattern.convertToPositivePattern = pattern.isDynamicPattern = pattern.isStaticPattern = void 0;
|
|
33568
|
-
const path =
|
|
33580
|
+
const path = sysPath__default;
|
|
33569
33581
|
const globParent = requireGlobParent();
|
|
33570
33582
|
const micromatch = requireMicromatch();
|
|
33571
33583
|
const GLOBSTAR = '**';
|
|
@@ -34519,7 +34531,7 @@ function requireSettings$2 () {
|
|
|
34519
34531
|
if (hasRequiredSettings$2) return settings$2;
|
|
34520
34532
|
hasRequiredSettings$2 = 1;
|
|
34521
34533
|
Object.defineProperty(settings$2, "__esModule", { value: true });
|
|
34522
|
-
const path =
|
|
34534
|
+
const path = sysPath__default;
|
|
34523
34535
|
const fsStat = requireOut$3();
|
|
34524
34536
|
const fs = requireFs();
|
|
34525
34537
|
class Settings {
|
|
@@ -35281,7 +35293,7 @@ function requireSettings$1 () {
|
|
|
35281
35293
|
if (hasRequiredSettings$1) return settings$1;
|
|
35282
35294
|
hasRequiredSettings$1 = 1;
|
|
35283
35295
|
Object.defineProperty(settings$1, "__esModule", { value: true });
|
|
35284
|
-
const path =
|
|
35296
|
+
const path = sysPath__default;
|
|
35285
35297
|
const fsScandir = requireOut$2();
|
|
35286
35298
|
class Settings {
|
|
35287
35299
|
constructor(_options = {}) {
|
|
@@ -35357,7 +35369,7 @@ function requireReader () {
|
|
|
35357
35369
|
if (hasRequiredReader) return reader;
|
|
35358
35370
|
hasRequiredReader = 1;
|
|
35359
35371
|
Object.defineProperty(reader, "__esModule", { value: true });
|
|
35360
|
-
const path =
|
|
35372
|
+
const path = sysPath__default;
|
|
35361
35373
|
const fsStat = requireOut$3();
|
|
35362
35374
|
const utils = requireUtils$1();
|
|
35363
35375
|
class Reader {
|
|
@@ -35830,7 +35842,7 @@ function requireProvider () {
|
|
|
35830
35842
|
if (hasRequiredProvider) return provider;
|
|
35831
35843
|
hasRequiredProvider = 1;
|
|
35832
35844
|
Object.defineProperty(provider, "__esModule", { value: true });
|
|
35833
|
-
const path =
|
|
35845
|
+
const path = sysPath__default;
|
|
35834
35846
|
const deep_1 = requireDeep();
|
|
35835
35847
|
const entry_1 = requireEntry$1();
|
|
35836
35848
|
const error_1 = requireError();
|
|
@@ -36270,7 +36282,7 @@ var hasRequiredDirGlob;
|
|
|
36270
36282
|
function requireDirGlob () {
|
|
36271
36283
|
if (hasRequiredDirGlob) return dirGlob.exports;
|
|
36272
36284
|
hasRequiredDirGlob = 1;
|
|
36273
|
-
const path =
|
|
36285
|
+
const path = sysPath__default;
|
|
36274
36286
|
const pathType = requirePathType();
|
|
36275
36287
|
|
|
36276
36288
|
const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
|
|
@@ -37020,7 +37032,7 @@ function requireGitignore () {
|
|
|
37020
37032
|
hasRequiredGitignore = 1;
|
|
37021
37033
|
const {promisify} = require$$0$4;
|
|
37022
37034
|
const fs = require$$0$2;
|
|
37023
|
-
const path =
|
|
37035
|
+
const path = sysPath__default;
|
|
37024
37036
|
const fastGlob = requireOut();
|
|
37025
37037
|
const gitIgnore = requireIgnore();
|
|
37026
37038
|
const slash = requireSlash();
|
|
@@ -37456,7 +37468,7 @@ function replaceViewAsSignature(content) {
|
|
|
37456
37468
|
* @returns 文件信息和新发现的依赖文件列表
|
|
37457
37469
|
*/
|
|
37458
37470
|
function processFileDeps(pathRelativeToSrc, srcDir, matchedFileSet, processedFileMap, depNotFoundList, logger, verbose) {
|
|
37459
|
-
const absoluteFilePath =
|
|
37471
|
+
const absoluteFilePath = sysPath.join(srcDir, pathRelativeToSrc);
|
|
37460
37472
|
const fileInfo = { path: pathRelativeToSrc, content: '' };
|
|
37461
37473
|
try {
|
|
37462
37474
|
fileInfo.content = readFileWithLog(absoluteFilePath, logger);
|
|
@@ -37520,15 +37532,15 @@ async function collectDeps(patterns, projectRoot, srcDir, logger, verbose) {
|
|
|
37520
37532
|
throw new Error('未找到匹配的入口文件');
|
|
37521
37533
|
}
|
|
37522
37534
|
logger.info(`找到 ${matchedFiles.length} 个入口文件`);
|
|
37523
|
-
const absoluteSrcDir =
|
|
37535
|
+
const absoluteSrcDir = sysPath.resolve(srcDir);
|
|
37524
37536
|
const matchedFileSet = new Set();
|
|
37525
37537
|
matchedFiles.forEach((pathRelativeToRoot) => {
|
|
37526
37538
|
// 统一使用相对于 src 的路径
|
|
37527
|
-
const absoluteFilePath =
|
|
37539
|
+
const absoluteFilePath = sysPath.resolve(projectRoot, pathRelativeToRoot);
|
|
37528
37540
|
// 判断 file 是否超出 srcDir 目录(支持相对路径和绝对路径)
|
|
37529
37541
|
if (!absoluteFilePath.startsWith(absoluteSrcDir))
|
|
37530
37542
|
throw new Error(`入口文件 ${absoluteFilePath} 超出了源代码目录 ${srcDir}`);
|
|
37531
|
-
const pathRelativeToSrc =
|
|
37543
|
+
const pathRelativeToSrc = sysPath.relative(srcDir, absoluteFilePath);
|
|
37532
37544
|
filesToProcess.push(pathRelativeToSrc);
|
|
37533
37545
|
matchedFileSet.add(pathRelativeToSrc);
|
|
37534
37546
|
});
|
|
@@ -37577,7 +37589,7 @@ async function resolveNASLFiles(entry, logger, depMode, verbose) {
|
|
|
37577
37589
|
const projectRoot = getProjectRoot();
|
|
37578
37590
|
logger.info(`项目根目录: ${projectRoot}`);
|
|
37579
37591
|
logger.info(`源代码目录: ${config.srcDir}`);
|
|
37580
|
-
const srcDir =
|
|
37592
|
+
const srcDir = sysPath.join(projectRoot, config.srcDir);
|
|
37581
37593
|
// 收集需要处理的文件
|
|
37582
37594
|
let collectedFiles = [];
|
|
37583
37595
|
if (Array.isArray(entry) && !entry.length) {
|
|
@@ -37609,7 +37621,7 @@ async function resolveNASLFiles(entry, logger, depMode, verbose) {
|
|
|
37609
37621
|
filePaths.sort(sorter);
|
|
37610
37622
|
collectedFiles = filePaths.map((filePath) => ({
|
|
37611
37623
|
path: filePath,
|
|
37612
|
-
content: readFileWithLog(
|
|
37624
|
+
content: readFileWithLog(sysPath.join(srcDir, filePath), logger),
|
|
37613
37625
|
}));
|
|
37614
37626
|
if (collectedFiles.length === 0) {
|
|
37615
37627
|
logger.warn('未找到 NASL 文件');
|
|
@@ -37634,7 +37646,7 @@ async function compile(entry, options) {
|
|
|
37634
37646
|
// 收集需要编译的文件
|
|
37635
37647
|
const { collectedFiles, config, projectRoot } = await resolveNASLFiles(entry, logger, false, options?.verbose);
|
|
37636
37648
|
logger.info(`输出目录: ${config.outDir}`);
|
|
37637
|
-
const outDir =
|
|
37649
|
+
const outDir = sysPath.join(projectRoot, config.outDir);
|
|
37638
37650
|
// 调用编译 API
|
|
37639
37651
|
logger.newLine();
|
|
37640
37652
|
logger.info('正在调用编译服务...');
|
|
@@ -37647,7 +37659,7 @@ async function compile(entry, options) {
|
|
|
37647
37659
|
logger.success('编译成功!');
|
|
37648
37660
|
// 写入输出文件
|
|
37649
37661
|
for (const file of outputFiles) {
|
|
37650
|
-
const outputPath =
|
|
37662
|
+
const outputPath = sysPath.join(outDir, file.path);
|
|
37651
37663
|
writeFileWithLog(outputPath, file.content, logger);
|
|
37652
37664
|
}
|
|
37653
37665
|
logger.info(`输出 ${outputFiles.length} 个文件`);
|
|
@@ -37660,17 +37672,17 @@ async function compile(entry, options) {
|
|
|
37660
37672
|
return { config, outDir };
|
|
37661
37673
|
}
|
|
37662
37674
|
async function tryCompile(entry, options) {
|
|
37663
|
-
const logger = options?.logger || defaultLogger;
|
|
37664
37675
|
try {
|
|
37665
37676
|
await compile(entry, options);
|
|
37666
37677
|
}
|
|
37667
37678
|
catch (error) {
|
|
37679
|
+
const logger = options?.logger || defaultLogger;
|
|
37668
37680
|
logger.error(`编译过程发生错误:${error.message}`);
|
|
37669
37681
|
logger.exit(1);
|
|
37670
37682
|
}
|
|
37671
37683
|
}
|
|
37672
37684
|
|
|
37673
|
-
var version = "0.1.
|
|
37685
|
+
var version = "0.1.7";
|
|
37674
37686
|
var pkg = {
|
|
37675
37687
|
version: version};
|
|
37676
37688
|
|