@rstest/core 0.1.3 → 0.2.0

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/LICENSE.md CHANGED
@@ -592,6 +592,32 @@ Licensed under MIT license.
592
592
  >
593
593
  > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
594
594
 
595
+ ### chokidar
596
+
597
+ Licensed under MIT license in the repository at git+https://github.com/paulmillr/chokidar.git.
598
+
599
+ > The MIT License (MIT)
600
+ >
601
+ > Copyright (c) 2012 Paul Miller (https://paulmillr.com), Elan Shanker
602
+ >
603
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
604
+ > of this software and associated documentation files (the “Software”), to deal
605
+ > in the Software without restriction, including without limitation the rights
606
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
607
+ > copies of the Software, and to permit persons to whom the Software is
608
+ > furnished to do so, subject to the following conditions:
609
+ >
610
+ > The above copyright notice and this permission notice shall be included in
611
+ > all copies or substantial portions of the Software.
612
+ >
613
+ > THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
614
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
615
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
616
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
617
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
618
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
619
+ > THE SOFTWARE.
620
+
595
621
  ### color-convert
596
622
 
597
623
  Licensed under MIT license.
package/bin/rstest.js CHANGED
@@ -13,7 +13,7 @@ if (enableCompileCache) {
13
13
  }
14
14
 
15
15
  async function main() {
16
- const { runCLI } = await import('../dist/cli.js');
16
+ const { runCLI } = await import('../dist/index.js');
17
17
  runCLI();
18
18
  }
19
19
 
package/dist/208.js CHANGED
@@ -8174,7 +8174,7 @@ ${printReceived(actual)}`
8174
8174
  for (let [r, t] of h)u[r] = e ? g(d(t[0]), d(t[1]), t[2]) : a;
8175
8175
  return u;
8176
8176
  }
8177
- var external_node_tty_ = __webpack_require__("node:tty");
8177
+ var external_node_tty_ = __webpack_require__("tty");
8178
8178
  var node_r = void 0 !== process.env.FORCE_TTY || (0, external_node_tty_.isatty)(1);
8179
8179
  var node_u = p(node_r);
8180
8180
  },
package/dist/25.js ADDED
@@ -0,0 +1,91 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ export const __webpack_ids__ = [
4
+ "25"
5
+ ];
6
+ export const __webpack_modules__ = {
7
+ "./src/core/restart.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
8
+ __webpack_require__.d(__webpack_exports__, {
9
+ onBeforeRestart: ()=>onBeforeRestart,
10
+ watchFilesForRestart: ()=>watchFilesForRestart
11
+ });
12
+ var external_node_path_ = __webpack_require__("node:path");
13
+ var commands = __webpack_require__("./src/cli/commands.ts");
14
+ var utils = __webpack_require__("./src/utils/index.ts");
15
+ const GLOB_REGEX = /[*?{}[\]()!@+|]/;
16
+ const isGlob = (str)=>GLOB_REGEX.test(str);
17
+ async function createChokidar(pathOrGlobs, root, options) {
18
+ const chokidar = await __webpack_require__.e("668").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js"));
19
+ const watchFiles = new Set();
20
+ const globPatterns = pathOrGlobs.filter((pathOrGlob)=>{
21
+ if (isGlob(pathOrGlob)) return true;
22
+ watchFiles.add(pathOrGlob);
23
+ return false;
24
+ });
25
+ if (globPatterns.length) {
26
+ const { glob } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/tinyglobby@0.2.14/node_modules/tinyglobby/dist/index.mjs"));
27
+ const files = await glob(globPatterns, {
28
+ cwd: root,
29
+ absolute: true
30
+ });
31
+ for (const file of files)watchFiles.add(file);
32
+ }
33
+ return chokidar.watch(Array.from(watchFiles), options);
34
+ }
35
+ let cleaners = [];
36
+ const onBeforeRestart = (cleaner)=>{
37
+ cleaners.push(cleaner);
38
+ };
39
+ const clearConsole = ()=>{
40
+ if ((0, utils._l)() && !process.env.DEBUG) process.stdout.write('\x1B[H\x1B[2J');
41
+ };
42
+ const beforeRestart = async ({ filePath, clear = true })=>{
43
+ if (clear) clearConsole();
44
+ if (filePath) {
45
+ const filename = external_node_path_["default"].basename(filePath);
46
+ utils.kg.info(`restarting Rstest as ${utils.$_.yellow(filename)} changed\n`);
47
+ } else utils.kg.info('restarting Rstest...\n');
48
+ for (const cleaner of cleaners)await cleaner();
49
+ cleaners = [];
50
+ };
51
+ const restart = async ({ filePath, clear = true, options, filters })=>{
52
+ await beforeRestart({
53
+ filePath,
54
+ clear
55
+ });
56
+ await (0, commands.mR)({
57
+ options,
58
+ filters,
59
+ command: 'watch'
60
+ });
61
+ return true;
62
+ };
63
+ async function watchFilesForRestart({ rstest, watchOptions, options, filters }) {
64
+ if (!rstest.context.configFilePath) return;
65
+ const root = rstest.context.rootPath;
66
+ const watcher = await createChokidar([
67
+ rstest.context.configFilePath
68
+ ], root, {
69
+ ignoreInitial: true,
70
+ ignorePermissionErrors: true,
71
+ ...watchOptions
72
+ });
73
+ let restarting = false;
74
+ const onChange = async (filePath)=>{
75
+ if (restarting) return;
76
+ restarting = true;
77
+ const restarted = await restart({
78
+ options,
79
+ filters,
80
+ filePath
81
+ });
82
+ if (restarted) await watcher.close();
83
+ else utils.kg.error('Restart failed');
84
+ restarting = false;
85
+ };
86
+ watcher.on('add', onChange);
87
+ watcher.on('change', onChange);
88
+ watcher.on('unlink', onChange);
89
+ }
90
+ }
91
+ };
package/dist/285.js CHANGED
@@ -8,18 +8,18 @@ export const __webpack_modules__ = {
8
8
  __webpack_require__.d(__webpack_exports__, {
9
9
  listTests: ()=>listTests
10
10
  });
11
- var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
11
+ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
12
12
  var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
13
13
  var _pool__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/pool/index.ts");
14
14
  var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
15
15
  var _rsbuild__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/core/rsbuild.ts");
16
- async function listTests(context, fileFilters, { filesOnly, json }) {
16
+ async function listTests(context, { filesOnly, json }) {
17
17
  const { normalizedConfig: { include, exclude, root, name, setupFiles: setups, includeSource }, rootPath } = context;
18
18
  const testEntries = await (0, _utils__WEBPACK_IMPORTED_MODULE_3__.GL)({
19
19
  include,
20
20
  exclude,
21
21
  root,
22
- fileFilters,
22
+ fileFilters: context.fileFilters || [],
23
23
  includeSource
24
24
  });
25
25
  const globTestSourceEntries = async ()=>testEntries;
@@ -38,6 +38,7 @@ export const __webpack_modules__ = {
38
38
  context
39
39
  });
40
40
  const list = await pool.collectTests({
41
+ context,
41
42
  entries,
42
43
  sourceMaps,
43
44
  setupEntries,
package/dist/355.js CHANGED
@@ -9,7 +9,7 @@ export const __webpack_modules__ = {
9
9
  parseErrorStacktrace: ()=>parseErrorStacktrace,
10
10
  printError: ()=>printError
11
11
  });
12
- var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
12
+ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
13
13
  var _jridgewell_trace_mapping__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.29/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs");
14
14
  var stacktrace_parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js");
15
15
  var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
package/dist/359.js CHANGED
@@ -569,7 +569,7 @@ export const __webpack_modules__ = {
569
569
  return result;
570
570
  }
571
571
  function createContext(options, userConfig) {
572
- const { cwd, command } = options;
572
+ const { cwd, command, fileFilters, configFilePath } = options;
573
573
  const rootPath = userConfig.root ? (0, helper.ZY)(cwd, userConfig.root) : cwd;
574
574
  const rstestConfig = (0, src_config.hY)(userConfig);
575
575
  const reporters = 'list' !== command ? createReporters(rstestConfig.reporters, {
@@ -580,33 +580,37 @@ export const __webpack_modules__ = {
580
580
  updateSnapshot: rstestConfig.update ? 'all' : external_std_env_.isCI ? 'none' : 'new'
581
581
  });
582
582
  return {
583
+ configFilePath,
583
584
  command,
584
- version: "0.1.3",
585
+ version: "0.2.0",
585
586
  rootPath,
586
587
  reporters,
588
+ fileFilters,
587
589
  snapshotManager,
588
590
  originalConfig: userConfig,
589
591
  normalizedConfig: rstestConfig
590
592
  };
591
593
  }
592
- function createRstest(config, command, fileFilters) {
594
+ function createRstest({ config, configFilePath }, command, fileFilters) {
593
595
  const context = createContext({
594
596
  cwd: process.cwd(),
595
- command
597
+ command,
598
+ fileFilters,
599
+ configFilePath
596
600
  }, config);
597
601
  const runTests = async ()=>{
598
602
  const { runTests } = await Promise.all([
599
603
  __webpack_require__.e("854"),
600
604
  __webpack_require__.e("920")
601
605
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/core/runTests.ts"));
602
- await runTests(context, fileFilters);
606
+ await runTests(context);
603
607
  };
604
608
  const listTests = async (options)=>{
605
609
  const { listTests } = await Promise.all([
606
610
  __webpack_require__.e("854"),
607
611
  __webpack_require__.e("285")
608
612
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/core/listTests.ts"));
609
- await listTests(context, fileFilters, options);
613
+ await listTests(context, options);
610
614
  };
611
615
  return {
612
616
  context,
package/dist/64.js CHANGED
@@ -40,7 +40,7 @@ export const __webpack_modules__ = {
40
40
  var path = __webpack_require__("node:path");
41
41
  var fs;
42
42
  try {
43
- fs = __webpack_require__("fs");
43
+ fs = __webpack_require__("node:fs");
44
44
  if (!fs.existsSync || !fs.readFileSync) fs = null;
45
45
  } catch (err) {}
46
46
  var bufferFrom = __webpack_require__("../../node_modules/.pnpm/buffer-from@1.1.2/node_modules/buffer-from/index.js");