@nasl/cli 0.1.9 → 0.1.11

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/index.js CHANGED
@@ -8,6 +8,9 @@ import '@/index.css';
8
8
 
9
9
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
10
10
 
11
+ window.LcapMicro = window.LcapMicro || {};
12
+ window.LcapMicro.routePrefix = __webpack_public_path__;
13
+
11
14
  // 应用初始化
12
15
  class AppHandler {
13
16
  constructor() {}
package/dist/bin/nasl.mjs CHANGED
@@ -8198,7 +8198,7 @@ function fastLogToFile(entry, suffix, content) {
8198
8198
  const hourInDir = parseInt(timeInDir.slice(0, 2), 10);
8199
8199
  // 跨天则累加 24 小时
8200
8200
  const hourStr = (now.hour() >= hourInDir ? now.hour() : Math.ceil(hourInDir / 24) * 24 + now.hour()).toString().padStart(2, '0');
8201
- const entryName = sysPath.basename(Array.isArray(entry) ? entry[0] || '*' : entry).replace(/[\[\]\(\)\{\}\*\+\-\?\|\^\$\,\/\#\:\\\s]+/g, '_');
8201
+ const entryName = sysPath.basename(Array.isArray(entry) ? entry[0] || '*' : entry).replace(/[\[\]\(\)\{\}\+\-\*\?\|\^\$\#\:\,\\\/\s]+/g, '_');
8202
8202
  const filePath = sysPath.resolve(logDir, `${hourStr}${now.format('mmss_SSS')}-${entryName}-${suffix}`);
8203
8203
  libExports.outputFileSync(filePath, content);
8204
8204
  }
@@ -8284,7 +8284,14 @@ class ConsoleLogger extends BaseLogger {
8284
8284
  }
8285
8285
  }
8286
8286
  exit(code) {
8287
- process.exit(code);
8287
+ if (process.argv[1]?.endsWith('/nasl')) { // 添加保险措施,避免在非 CLI 环境下退出
8288
+ process.exit(code);
8289
+ }
8290
+ else {
8291
+ if (code)
8292
+ throw new Error(`Error with code: ${code}`);
8293
+ return undefined;
8294
+ }
8288
8295
  }
8289
8296
  }
8290
8297
  class ConsoleLoggerWithoutExit extends ConsoleLogger {
@@ -37828,7 +37835,7 @@ async function dev(entry, options) {
37828
37835
  // 有 src 目录,先进行一次初始编译
37829
37836
  logger.info('检测到 src 目录,开始初始编译...');
37830
37837
  try {
37831
- await compile(entry);
37838
+ await compile(entry, { logger });
37832
37839
  lastCompileSuccess = true;
37833
37840
  logger.success('初始编译成功!');
37834
37841
  }
@@ -37994,10 +38001,13 @@ async function startWebpackDevServer(outDir, options, logger) {
37994
38001
  webpackArgs += ` --port ${options.port}`;
37995
38002
  if (options?.host)
37996
38003
  webpackArgs += ` --host ${options.host}`;
37997
- if (options?.open)
37998
- webpackArgs += ' --open';
37999
- if (options?.hot)
38000
- webpackArgs += ' --hot';
38004
+ if (options?.open === false)
38005
+ webpackArgs += ' --no-open';
38006
+ if (options?.hot === false)
38007
+ webpackArgs += ' --no-hot';
38008
+ if (options?.publicPath)
38009
+ webpackArgs += ` --output-public-path "${options.publicPath}"`;
38010
+ logger?.info(webpackArgs);
38001
38011
  // 使用 spawn 而不是 spawnSync,以便进程可以常驻
38002
38012
  const webpackProcess = spawn(webpackArgs, {
38003
38013
  shell: true,
@@ -38035,7 +38045,7 @@ async function build(entry, options) {
38035
38045
  await justExecCommandSync(webpackArgs, outDir);
38036
38046
  }
38037
38047
 
38038
- var version = "0.1.9";
38048
+ var version = "0.1.11";
38039
38049
  var pkg = {
38040
38050
  version: version};
38041
38051
 
@@ -38093,8 +38103,9 @@ program
38093
38103
  .description('启动开发服务')
38094
38104
  .option('-p, --port <port>', '指定开发服务器端口号')
38095
38105
  .option('-h, --host <host>', '指定开发服务器主机名')
38096
- .option('--open', '自动在浏览器中打开')
38097
- .option('--hot', '启用热模块替换 (HMR)')
38106
+ .option('--public-path <public-path>', '指定公共路径')
38107
+ .option('--no-open', '不在浏览器中自动打开')
38108
+ .option('--no-hot', '禁用热模块替换 (HMR)')
38098
38109
  .action(async (entry, options) => {
38099
38110
  try {
38100
38111
  await dev(entry, options);