ava 4.0.0-alpha.1 → 4.0.1

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.
Files changed (70) hide show
  1. package/entrypoints/cli.mjs +4 -0
  2. package/{eslint-plugin-helper.js → entrypoints/eslint-plugin-helper.cjs} +20 -7
  3. package/entrypoints/main.cjs +2 -0
  4. package/entrypoints/main.mjs +1 -0
  5. package/entrypoints/plugin.cjs +2 -0
  6. package/entrypoints/plugin.mjs +4 -0
  7. package/index.d.ts +6 -709
  8. package/lib/api.js +95 -46
  9. package/lib/assert.js +122 -173
  10. package/lib/chalk.js +9 -14
  11. package/lib/cli.js +105 -97
  12. package/lib/code-excerpt.js +12 -17
  13. package/lib/concordance-options.js +30 -31
  14. package/lib/context-ref.js +3 -6
  15. package/lib/create-chain.js +32 -4
  16. package/lib/environment-variables.js +1 -4
  17. package/lib/eslint-plugin-helper-worker.js +16 -26
  18. package/lib/extensions.js +2 -2
  19. package/lib/fork.js +42 -83
  20. package/lib/glob-helpers.cjs +140 -0
  21. package/lib/globs.js +136 -163
  22. package/lib/{ipc-flow-control.js → ipc-flow-control.cjs} +1 -0
  23. package/lib/is-ci.js +4 -2
  24. package/lib/like-selector.js +7 -13
  25. package/lib/line-numbers.js +10 -17
  26. package/lib/load-config.js +62 -56
  27. package/lib/module-types.js +3 -3
  28. package/lib/node-arguments.js +4 -5
  29. package/lib/{now-and-timers.js → now-and-timers.cjs} +0 -0
  30. package/lib/parse-test-args.js +22 -11
  31. package/lib/pkg.cjs +2 -0
  32. package/lib/plugin-support/shared-worker-loader.js +45 -48
  33. package/lib/plugin-support/shared-workers.js +24 -43
  34. package/lib/provider-manager.js +20 -14
  35. package/lib/reporters/beautify-stack.js +6 -11
  36. package/lib/reporters/colors.js +40 -15
  37. package/lib/reporters/default.js +115 -350
  38. package/lib/reporters/format-serialized-error.js +7 -18
  39. package/lib/reporters/improper-usage-messages.js +8 -9
  40. package/lib/reporters/prefix-title.js +17 -15
  41. package/lib/reporters/tap.js +15 -16
  42. package/lib/run-status.js +25 -23
  43. package/lib/runner.js +138 -127
  44. package/lib/scheduler.js +42 -36
  45. package/lib/serialize-error.js +34 -34
  46. package/lib/snapshot-manager.js +83 -76
  47. package/lib/test.js +114 -195
  48. package/lib/watcher.js +65 -40
  49. package/lib/worker/base.js +48 -99
  50. package/lib/worker/channel.cjs +290 -0
  51. package/lib/worker/dependency-tracker.js +22 -22
  52. package/lib/worker/guard-environment.cjs +19 -0
  53. package/lib/worker/line-numbers.js +57 -19
  54. package/lib/worker/main.cjs +12 -0
  55. package/lib/worker/{options.js → options.cjs} +0 -0
  56. package/lib/worker/{plugin.js → plugin.cjs} +31 -16
  57. package/lib/worker/state.cjs +5 -0
  58. package/lib/worker/{utils.js → utils.cjs} +1 -1
  59. package/package.json +60 -68
  60. package/plugin.d.ts +51 -53
  61. package/readme.md +5 -12
  62. package/types/assertions.d.ts +327 -0
  63. package/types/subscribable.ts +6 -0
  64. package/types/test-fn.d.ts +231 -0
  65. package/types/try-fn.d.ts +58 -0
  66. package/cli.js +0 -11
  67. package/index.js +0 -8
  68. package/lib/worker/channel.js +0 -218
  69. package/lib/worker/main.js +0 -20
  70. package/plugin.js +0 -9
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import run from '../lib/cli.js';
3
+
4
+ run();
@@ -1,8 +1,17 @@
1
1
  'use strict';
2
+ const path = require('path');
3
+ const url = require('url');
2
4
  const v8 = require('v8');
3
5
  const {Worker} = require('worker_threads');
4
6
 
5
- const {classify, hasExtension, isHelperish, matches, normalizeFileForMatching, normalizePatterns} = require('./lib/globs');
7
+ const {
8
+ classify,
9
+ hasExtension,
10
+ isHelperish,
11
+ matches,
12
+ normalizeFileForMatching,
13
+ normalizePatterns,
14
+ } = require('../lib/glob-helpers.cjs');
6
15
 
7
16
  const MAX_DATA_LENGTH_EXCLUSIVE = 100 * 1024; // Allocate 100 KiB to exchange globs.
8
17
 
@@ -10,7 +19,7 @@ let data;
10
19
  let sync;
11
20
  let worker;
12
21
 
13
- const resolveGlobsSync = (projectDir, overrideExtensions, overrideFiles) => {
22
+ const resolveGlobsSync = (projectDir, overrideExtensions, overrideFiles) => {
14
23
  if (worker === undefined) {
15
24
  const dataBuffer = new SharedArrayBuffer(MAX_DATA_LENGTH_EXCLUSIVE);
16
25
  data = new Uint8Array(dataBuffer);
@@ -18,19 +27,23 @@ const resolveGlobsSync = (projectDir, overrideExtensions, overrideFiles) => {
18
27
  const syncBuffer = new SharedArrayBuffer(4);
19
28
  sync = new Int32Array(syncBuffer);
20
29
 
21
- worker = new Worker('./lib/eslint-plugin-helper-worker.js', {
30
+ const filename = path.join(__dirname, '../lib/eslint-plugin-helper-worker.js');
31
+ worker = new Worker(url.pathToFileURL(filename), {
22
32
  workerData: {
23
33
  dataBuffer,
24
34
  syncBuffer,
25
- firstMessage: {projectDir, overrideExtensions, overrideFiles}
26
- }
35
+ firstMessage: {projectDir, overrideExtensions, overrideFiles},
36
+ },
27
37
  });
28
38
  worker.unref();
29
39
  } else {
30
40
  worker.postMessage({projectDir, overrideExtensions, overrideFiles});
31
41
  }
32
42
 
33
- Atomics.wait(sync, 0, 0);
43
+ const synchronize = Atomics.wait(sync, 0, 0, 10_000);
44
+ if (synchronize === 'timed-out') {
45
+ throw new Error('Timed out resolving AVA configuration');
46
+ }
34
47
 
35
48
  const byteLength = Atomics.exchange(sync, 0, 0);
36
49
  if (byteLength === MAX_DATA_LENGTH_EXCLUSIVE) {
@@ -87,7 +100,7 @@ function load(projectDir, overrides) {
87
100
  // Add the first extension. If multiple extensions are available, assume
88
101
  // patterns are not biased to any particular extension.
89
102
  return classifyForESLint(`${importPath}.${globs.extensions[0]}`);
90
- }
103
+ },
91
104
  });
92
105
  helperCache.set(cacheKey, helper);
93
106
  return helper;
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ module.exports = require('../lib/worker/main.cjs');
@@ -0,0 +1 @@
1
+ export {default} from '../lib/worker/main.cjs';
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ module.exports = require('../lib/worker/plugin.cjs');
@@ -0,0 +1,4 @@
1
+ import * as plugin from '../lib/worker/plugin.cjs';
2
+
3
+ const {registerSharedWorker} = plugin;
4
+ export {registerSharedWorker};