testomatio-reporter-cli 2.7.2

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 (3) hide show
  1. package/README.md +28 -0
  2. package/bin/cli.js +52 -0
  3. package/package.json +25 -0
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # testomatio-reporter-cli
2
+
3
+ Yarn Berry compatible CLI wrapper around `@testomatio/reporter`.
4
+
5
+ ## Why
6
+
7
+ Yarn 4 rejects bin names containing `/`. This wrapper exposes valid command names:
8
+
9
+ - `testomatio-reporter`
10
+ - `reporter`
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ yarn add -D testomatio-reporter-cli
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```bash
21
+ npx testomatio-reporter run "npx playwright test"
22
+ # or
23
+ npx reporter run "npx playwright test"
24
+ # or
25
+ npx testomatio-reporter-cli run "npx playwright test"
26
+ ```
27
+
28
+ All arguments are forwarded to `@testomatio/reporter` CLI.
package/bin/cli.js ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from 'node:child_process';
4
+ import { createRequire } from 'node:module';
5
+ import { existsSync } from 'node:fs';
6
+ import { readFileSync } from 'node:fs';
7
+ import path from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+
10
+ const require = createRequire(import.meta.url);
11
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
12
+
13
+ let targetCli;
14
+ try {
15
+ const reporterPackageJsonPath = require.resolve('@testomatio/reporter/package.json');
16
+ const reporterPackageJson = JSON.parse(readFileSync(reporterPackageJsonPath, 'utf8'));
17
+ const bin = reporterPackageJson.bin || {};
18
+ const cliRelativePath =
19
+ bin['testomatio/reporter'] ||
20
+ bin['testomatio-reporter'] ||
21
+ Object.values(bin).find(value => typeof value === 'string' && value.includes('cli.js'));
22
+
23
+ if (!cliRelativePath) {
24
+ throw new Error('Cannot detect CLI entry from @testomatio/reporter package.json bin field');
25
+ }
26
+
27
+ targetCli = path.resolve(path.dirname(reporterPackageJsonPath), cliRelativePath);
28
+ } catch (error) {
29
+ const localCliPath = path.resolve(__dirname, '../../../src/bin/cli.js');
30
+ if (existsSync(localCliPath)) {
31
+ targetCli = localCliPath;
32
+ } else {
33
+ console.error('[testomatio-reporter] Cannot resolve @testomatio/reporter CLI entrypoint.');
34
+ console.error(error?.message || error);
35
+ process.exit(1);
36
+ }
37
+ }
38
+
39
+ const child = spawn(process.execPath, [targetCli, ...process.argv.slice(2)], {
40
+ stdio: 'inherit',
41
+ env: process.env,
42
+ });
43
+
44
+ child.on('exit', code => {
45
+ process.exit(code ?? 0);
46
+ });
47
+
48
+ child.on('error', error => {
49
+ console.error('[testomatio-reporter] Failed to start CLI process.');
50
+ console.error(error?.message || error);
51
+ process.exit(1);
52
+ });
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "testomatio-reporter-cli",
3
+ "version": "2.7.2",
4
+ "description": "Yarn Berry compatible CLI wrapper for @testomatio/reporter",
5
+ "type": "module",
6
+ "bin": {
7
+ "testomatio-reporter-cli": "./bin/cli.js",
8
+ "testomatio-reporter": "./bin/cli.js",
9
+ "reporter": "./bin/cli.js"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/testomatio/reporter"
14
+ },
15
+ "files": [
16
+ "bin"
17
+ ],
18
+ "engines": {
19
+ "node": ">=18"
20
+ },
21
+ "dependencies": {
22
+ "@testomatio/reporter": "2.7.2"
23
+ },
24
+ "license": "MIT"
25
+ }