@midscene/cli 1.8.8-beta-20260603024013.0 → 1.8.9

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.
@@ -4,7 +4,7 @@ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node
4
4
  import node_path, { basename, dirname, extname, join, relative, resolve as external_node_path_resolve, sep } from "node:path";
5
5
  import { getMidsceneRunSubDir } from "@midscene/shared/common";
6
6
  import { createRequire } from "node:module";
7
- import { runRstestWithVirtualModules } from "@midscene/shared/rstest";
7
+ import { pathToFileURL } from "node:url";
8
8
  import { test } from "@rstest/core";
9
9
  import { ScriptPlayer, parseYamlScript } from "@midscene/core/yaml";
10
10
  import { buildChromeArgs, defaultViewportHeight, defaultViewportWidth, puppeteerAgentForTarget } from "@midscene/web/puppeteer-agent-launcher";
@@ -2541,15 +2541,8 @@ const DEFAULT_YAML_TEST_TIMEOUT = 0;
2541
2541
  const toPosixPath = (value)=>value.split(sep).join('/');
2542
2542
  const toImportLiteral = (value)=>JSON.stringify(toPosixPath(value));
2543
2543
  const toVirtualModuleId = (fileStem)=>`virtual:midscene-yaml/${fileStem}.test.ts`;
2544
- const trimEdgeHyphens = (value)=>{
2545
- let start = 0;
2546
- let end = value.length;
2547
- while(start < end && 45 === value.charCodeAt(start))start += 1;
2548
- while(end > start && 45 === value.charCodeAt(end - 1))end -= 1;
2549
- return value.slice(start, end);
2550
- };
2551
2544
  const safeFileStem = (file, index)=>{
2552
- const base = trimEdgeHyphens(basename(file, extname(file)).replace(/[^a-zA-Z0-9._-]+/g, '-'));
2545
+ const base = basename(file, extname(file)).replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '');
2553
2546
  return `${String(index + 1).padStart(3, '0')}-${base || 'case'}`;
2554
2547
  };
2555
2548
  const resolveTestName = (projectDir, yamlFile)=>{
@@ -2683,20 +2676,41 @@ function resolveRstestCoreImportPath() {
2683
2676
  }
2684
2677
  const formatRunError = (error)=>error.stack || `${error.name}: ${error.message}`;
2685
2678
  async function runRstestYamlProject(options) {
2679
+ const [{ runRstest }, { rspack }] = await Promise.all([
2680
+ import("@rstest/core/api"),
2681
+ import(pathToFileURL(resolvePackageFromRstestCore('@rsbuild/core')).href)
2682
+ ]);
2686
2683
  const { project } = options;
2687
- const result = await runRstestWithVirtualModules({
2688
- cwd: options.cwd || project.projectDir,
2684
+ const maxConcurrency = void 0 !== project.maxConcurrency ? Math.max(1, project.maxConcurrency) : void 0;
2685
+ const inlineConfig = {
2689
2686
  root: project.projectDir,
2690
2687
  include: project.include,
2691
- virtualModules: project.virtualModules,
2692
- rsbuildEntry: resolvePackageFromRstestCore('@rsbuild/core'),
2688
+ testEnvironment: 'node',
2693
2689
  testTimeout: project.testTimeout,
2694
- maxConcurrency: project.maxConcurrency,
2695
- bail: project.bail,
2696
- reporters: []
2690
+ ...void 0 !== maxConcurrency ? {
2691
+ maxConcurrency
2692
+ } : {},
2693
+ ...void 0 !== maxConcurrency ? {
2694
+ pool: {
2695
+ maxWorkers: maxConcurrency,
2696
+ minWorkers: maxConcurrency
2697
+ }
2698
+ } : {},
2699
+ ...void 0 !== project.bail ? {
2700
+ bail: project.bail
2701
+ } : {},
2702
+ reporters: [],
2703
+ tools: {
2704
+ rspack: (_config, { appendPlugins })=>{
2705
+ appendPlugins(new rspack.experiments.VirtualModulesPlugin(project.virtualModules));
2706
+ }
2707
+ }
2708
+ };
2709
+ const result = await runRstest({
2710
+ cwd: options.cwd || project.projectDir,
2711
+ inlineConfig
2697
2712
  });
2698
- const unhandledErrors = result.unhandledErrors ?? [];
2699
- if (!result.ok && 'pipe' !== options.stdio && unhandledErrors.length) console.error(unhandledErrors.map((error)=>formatRunError(error)).join('\n'));
2713
+ if (!result.ok && 'pipe' !== options.stdio && result.unhandledErrors.length) console.error(result.unhandledErrors.map((error)=>formatRunError(error)).join('\n'));
2700
2714
  return result.ok ? 0 : 1;
2701
2715
  }
2702
2716
  const createCaseOptions = (config)=>{