@nasl/cli 0.1.6 → 0.1.8

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.
@@ -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 path$1 from 'path';
6
- import path__default from 'path';
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';
@@ -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 = path__default;
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 = path__default;
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 = path__default;
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 = path__default;
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 = path__default;
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 = path__default;
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 = path__default;
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 = path__default;
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 = path__default;
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 = path__default;
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 = path__default;
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 = path__default;
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 = path__default;
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 = path$1.join(process.cwd(), '.nasl');
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(path$1.join(baseDir, prevSubdir)))
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 = path$1.join(baseDir, subdir, fileName);
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 = path$1.join(currentDir, CONFIG_FILE_NAME);
8274
+ const configPath = sysPath.join(currentDir, CONFIG_FILE_NAME);
8275
8275
  if (libExports.existsSync(configPath)) {
8276
8276
  return currentDir;
8277
8277
  }
8278
- const parentDir = path$1.dirname(currentDir);
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 = path$1.join(dir, CONFIG_FILE_NAME);
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 = path$1.dirname(filePath);
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 = path__default.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 = path__default;
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;
@@ -26831,7 +26831,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
26831
26831
  } else {
26832
26832
  options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
26833
26833
  options.port = parsed.port;
26834
- setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
26834
+ setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : parsed.protocol === 'https:' ? '443' : '') + options.path);
26835
26835
  }
26836
26836
 
26837
26837
  let transport;
@@ -29127,7 +29127,7 @@ function requirePath () {
29127
29127
  Object.defineProperty(path, "__esModule", { value: true });
29128
29128
  path.convertPosixPathToPattern = path.convertWindowsPathToPattern = path.convertPathToPattern = path.escapePosixPath = path.escapeWindowsPath = path.escape = path.removeLeadingDotSegment = path.makeAbsolute = path.unixify = void 0;
29129
29129
  const os = require$$0$5;
29130
- const path$1 = path__default;
29130
+ const path$1 = sysPath__default;
29131
29131
  const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
29132
29132
  const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
29133
29133
  /**
@@ -29392,7 +29392,7 @@ function requireGlobParent () {
29392
29392
  hasRequiredGlobParent = 1;
29393
29393
 
29394
29394
  var isGlob = requireIsGlob();
29395
- var pathPosixDirname = path__default.posix.dirname;
29395
+ var pathPosixDirname = sysPath__default.posix.dirname;
29396
29396
  var isWin32 = require$$0$5.platform() === 'win32';
29397
29397
 
29398
29398
  var slash = '/';
@@ -30964,7 +30964,7 @@ function requireConstants$1 () {
30964
30964
  if (hasRequiredConstants$1) return constants$1;
30965
30965
  hasRequiredConstants$1 = 1;
30966
30966
 
30967
- const path = path__default;
30967
+ const path = sysPath__default;
30968
30968
  const WIN_SLASH = '\\\\/';
30969
30969
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
30970
30970
 
@@ -31151,7 +31151,7 @@ function requireUtils$2 () {
31151
31151
  hasRequiredUtils$2 = 1;
31152
31152
  (function (exports$1) {
31153
31153
 
31154
- const path = path__default;
31154
+ const path = sysPath__default;
31155
31155
  const win32 = process.platform === 'win32';
31156
31156
  const {
31157
31157
  REGEX_BACKSLASH,
@@ -32722,7 +32722,7 @@ function requirePicomatch$1 () {
32722
32722
  if (hasRequiredPicomatch$1) return picomatch_1;
32723
32723
  hasRequiredPicomatch$1 = 1;
32724
32724
 
32725
- const path = path__default;
32725
+ const path = sysPath__default;
32726
32726
  const scan = requireScan();
32727
32727
  const parse = requireParse();
32728
32728
  const utils = requireUtils$2();
@@ -33565,7 +33565,7 @@ function requirePattern () {
33565
33565
  hasRequiredPattern = 1;
33566
33566
  Object.defineProperty(pattern, "__esModule", { value: true });
33567
33567
  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 = path__default;
33568
+ const path = sysPath__default;
33569
33569
  const globParent = requireGlobParent();
33570
33570
  const micromatch = requireMicromatch();
33571
33571
  const GLOBSTAR = '**';
@@ -34519,7 +34519,7 @@ function requireSettings$2 () {
34519
34519
  if (hasRequiredSettings$2) return settings$2;
34520
34520
  hasRequiredSettings$2 = 1;
34521
34521
  Object.defineProperty(settings$2, "__esModule", { value: true });
34522
- const path = path__default;
34522
+ const path = sysPath__default;
34523
34523
  const fsStat = requireOut$3();
34524
34524
  const fs = requireFs();
34525
34525
  class Settings {
@@ -35281,7 +35281,7 @@ function requireSettings$1 () {
35281
35281
  if (hasRequiredSettings$1) return settings$1;
35282
35282
  hasRequiredSettings$1 = 1;
35283
35283
  Object.defineProperty(settings$1, "__esModule", { value: true });
35284
- const path = path__default;
35284
+ const path = sysPath__default;
35285
35285
  const fsScandir = requireOut$2();
35286
35286
  class Settings {
35287
35287
  constructor(_options = {}) {
@@ -35357,7 +35357,7 @@ function requireReader () {
35357
35357
  if (hasRequiredReader) return reader;
35358
35358
  hasRequiredReader = 1;
35359
35359
  Object.defineProperty(reader, "__esModule", { value: true });
35360
- const path = path__default;
35360
+ const path = sysPath__default;
35361
35361
  const fsStat = requireOut$3();
35362
35362
  const utils = requireUtils$1();
35363
35363
  class Reader {
@@ -35830,7 +35830,7 @@ function requireProvider () {
35830
35830
  if (hasRequiredProvider) return provider;
35831
35831
  hasRequiredProvider = 1;
35832
35832
  Object.defineProperty(provider, "__esModule", { value: true });
35833
- const path = path__default;
35833
+ const path = sysPath__default;
35834
35834
  const deep_1 = requireDeep();
35835
35835
  const entry_1 = requireEntry$1();
35836
35836
  const error_1 = requireError();
@@ -36270,7 +36270,7 @@ var hasRequiredDirGlob;
36270
36270
  function requireDirGlob () {
36271
36271
  if (hasRequiredDirGlob) return dirGlob.exports;
36272
36272
  hasRequiredDirGlob = 1;
36273
- const path = path__default;
36273
+ const path = sysPath__default;
36274
36274
  const pathType = requirePathType();
36275
36275
 
36276
36276
  const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
@@ -37020,7 +37020,7 @@ function requireGitignore () {
37020
37020
  hasRequiredGitignore = 1;
37021
37021
  const {promisify} = require$$0$4;
37022
37022
  const fs = require$$0$2;
37023
- const path = path__default;
37023
+ const path = sysPath__default;
37024
37024
  const fastGlob = requireOut();
37025
37025
  const gitIgnore = requireIgnore();
37026
37026
  const slash = requireSlash();
@@ -37456,7 +37456,7 @@ function replaceViewAsSignature(content) {
37456
37456
  * @returns 文件信息和新发现的依赖文件列表
37457
37457
  */
37458
37458
  function processFileDeps(pathRelativeToSrc, srcDir, matchedFileSet, processedFileMap, depNotFoundList, logger, verbose) {
37459
- const absoluteFilePath = path$1.join(srcDir, pathRelativeToSrc);
37459
+ const absoluteFilePath = sysPath.join(srcDir, pathRelativeToSrc);
37460
37460
  const fileInfo = { path: pathRelativeToSrc, content: '' };
37461
37461
  try {
37462
37462
  fileInfo.content = readFileWithLog(absoluteFilePath, logger);
@@ -37520,15 +37520,15 @@ async function collectDeps(patterns, projectRoot, srcDir, logger, verbose) {
37520
37520
  throw new Error('未找到匹配的入口文件');
37521
37521
  }
37522
37522
  logger.info(`找到 ${matchedFiles.length} 个入口文件`);
37523
- const absoluteSrcDir = path$1.resolve(srcDir);
37523
+ const absoluteSrcDir = sysPath.resolve(srcDir);
37524
37524
  const matchedFileSet = new Set();
37525
37525
  matchedFiles.forEach((pathRelativeToRoot) => {
37526
37526
  // 统一使用相对于 src 的路径
37527
- const absoluteFilePath = path$1.resolve(projectRoot, pathRelativeToRoot);
37527
+ const absoluteFilePath = sysPath.resolve(projectRoot, pathRelativeToRoot);
37528
37528
  // 判断 file 是否超出 srcDir 目录(支持相对路径和绝对路径)
37529
37529
  if (!absoluteFilePath.startsWith(absoluteSrcDir))
37530
37530
  throw new Error(`入口文件 ${absoluteFilePath} 超出了源代码目录 ${srcDir}`);
37531
- const pathRelativeToSrc = path$1.relative(srcDir, absoluteFilePath);
37531
+ const pathRelativeToSrc = sysPath.relative(srcDir, absoluteFilePath);
37532
37532
  filesToProcess.push(pathRelativeToSrc);
37533
37533
  matchedFileSet.add(pathRelativeToSrc);
37534
37534
  });
@@ -37577,7 +37577,7 @@ async function resolveNASLFiles(entry, logger, depMode, verbose) {
37577
37577
  const projectRoot = getProjectRoot();
37578
37578
  logger.info(`项目根目录: ${projectRoot}`);
37579
37579
  logger.info(`源代码目录: ${config.srcDir}`);
37580
- const srcDir = path$1.join(projectRoot, config.srcDir);
37580
+ const srcDir = sysPath.join(projectRoot, config.srcDir);
37581
37581
  // 收集需要处理的文件
37582
37582
  let collectedFiles = [];
37583
37583
  if (Array.isArray(entry) && !entry.length) {
@@ -37609,7 +37609,7 @@ async function resolveNASLFiles(entry, logger, depMode, verbose) {
37609
37609
  filePaths.sort(sorter);
37610
37610
  collectedFiles = filePaths.map((filePath) => ({
37611
37611
  path: filePath,
37612
- content: readFileWithLog(path$1.join(srcDir, filePath), logger),
37612
+ content: readFileWithLog(sysPath.join(srcDir, filePath), logger),
37613
37613
  }));
37614
37614
  if (collectedFiles.length === 0) {
37615
37615
  logger.warn('未找到 NASL 文件');
@@ -37634,7 +37634,7 @@ async function compile(entry, options) {
37634
37634
  // 收集需要编译的文件
37635
37635
  const { collectedFiles, config, projectRoot } = await resolveNASLFiles(entry, logger, false, options?.verbose);
37636
37636
  logger.info(`输出目录: ${config.outDir}`);
37637
- const outDir = path$1.join(projectRoot, config.outDir);
37637
+ const outDir = sysPath.join(projectRoot, config.outDir);
37638
37638
  // 调用编译 API
37639
37639
  logger.newLine();
37640
37640
  logger.info('正在调用编译服务...');
@@ -37647,7 +37647,7 @@ async function compile(entry, options) {
37647
37647
  logger.success('编译成功!');
37648
37648
  // 写入输出文件
37649
37649
  for (const file of outputFiles) {
37650
- const outputPath = path$1.join(outDir, file.path);
37650
+ const outputPath = sysPath.join(outDir, file.path);
37651
37651
  writeFileWithLog(outputPath, file.content, logger);
37652
37652
  }
37653
37653
  logger.info(`输出 ${outputFiles.length} 个文件`);
@@ -37660,17 +37660,17 @@ async function compile(entry, options) {
37660
37660
  return { config, outDir };
37661
37661
  }
37662
37662
  async function tryCompile(entry, options) {
37663
- const logger = options?.logger || defaultLogger;
37664
37663
  try {
37665
37664
  await compile(entry, options);
37666
37665
  }
37667
37666
  catch (error) {
37667
+ const logger = options?.logger || defaultLogger;
37668
37668
  logger.error(`编译过程发生错误:${error.message}`);
37669
37669
  logger.exit(1);
37670
37670
  }
37671
37671
  }
37672
37672
 
37673
- var version = "0.1.6";
37673
+ var version = "0.1.8";
37674
37674
  var pkg = {
37675
37675
  version: version};
37676
37676