@dev-blinq/cucumber-js 1.0.107-dev → 1.0.107-stage

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 (42) hide show
  1. package/bin/cucumber.ts +1 -0
  2. package/bin/download-install.js +22 -2
  3. package/lib/api/console_logger.js.map +1 -1
  4. package/lib/cli/run.js +1 -0
  5. package/lib/cli/run.js.map +1 -1
  6. package/lib/cli/validate_node_engine_version.js +3 -1
  7. package/lib/cli/validate_node_engine_version.js.map +1 -1
  8. package/lib/configuration/axios_client.js +1 -1
  9. package/lib/configuration/axios_client.js.map +1 -1
  10. package/lib/formatter/api.js +16 -5
  11. package/lib/formatter/api.js.map +1 -1
  12. package/lib/formatter/builder.js +1 -3
  13. package/lib/formatter/builder.js.map +1 -1
  14. package/lib/formatter/bvt_analysis_formatter.d.ts +13 -1
  15. package/lib/formatter/bvt_analysis_formatter.js +178 -60
  16. package/lib/formatter/bvt_analysis_formatter.js.map +1 -1
  17. package/lib/formatter/feature_data_format.js +12 -3
  18. package/lib/formatter/feature_data_format.js.map +1 -1
  19. package/lib/formatter/helpers/constants.d.ts +50 -0
  20. package/lib/formatter/helpers/constants.js +60 -0
  21. package/lib/formatter/helpers/constants.js.map +1 -0
  22. package/lib/formatter/helpers/report_generator.d.ts +24 -3
  23. package/lib/formatter/helpers/report_generator.js +343 -25
  24. package/lib/formatter/helpers/report_generator.js.map +1 -1
  25. package/lib/formatter/helpers/test_case_attempt_formatter.js +1 -1
  26. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
  27. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
  28. package/lib/formatter/helpers/upload_serivce.d.ts +15 -1
  29. package/lib/formatter/helpers/upload_serivce.js +149 -14
  30. package/lib/formatter/helpers/upload_serivce.js.map +1 -1
  31. package/lib/formatter/helpers/uploader.d.ts +2 -1
  32. package/lib/formatter/helpers/uploader.js +16 -1
  33. package/lib/formatter/helpers/uploader.js.map +1 -1
  34. package/lib/formatter/summary_formatter.js +4 -0
  35. package/lib/formatter/summary_formatter.js.map +1 -1
  36. package/lib/runtime/test_case_runner.d.ts +1 -0
  37. package/lib/runtime/test_case_runner.js +10 -1
  38. package/lib/runtime/test_case_runner.js.map +1 -1
  39. package/lib/version.d.ts +1 -1
  40. package/lib/version.js +1 -1
  41. package/lib/version.js.map +1 -1
  42. package/package.json +5 -2
package/bin/cucumber.ts CHANGED
@@ -1,2 +1,3 @@
1
+ console.log('Loading necessary packages...')
1
2
  import run from "../src/cli/run";
2
3
  run();
@@ -1,3 +1,6 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ /* eslint-disable no-console */
3
+ /* eslint-disable no-undef */
1
4
  const { argv } = require('node:process')
2
5
  const fs = require('fs')
3
6
  const path = require('path')
@@ -16,8 +19,14 @@ const getSSoUrl = () => {
16
19
  return 'https://dev.api.blinq.io/api/auth'
17
20
  case 'stage':
18
21
  return 'https://stage.api.blinq.io/api/auth'
19
- default:
22
+ case 'prod':
23
+ return 'https://api.blinq.io/api/auth'
24
+ case null:
25
+ return 'https://api.blinq.io/api/auth'
26
+ case undefined:
20
27
  return 'https://api.blinq.io/api/auth'
28
+ default:
29
+ return `${process.env.NODE_ENV_BLINQ}/api/auth`
21
30
  }
22
31
  }
23
32
 
@@ -48,8 +57,14 @@ const getWorkSpaceUrl = () => {
48
57
  return 'https://dev.api.blinq.io/api/workspace'
49
58
  case "stage":
50
59
  return 'https://stage.api.blinq.io/api/workspace'
51
- default:
60
+ case 'prod':
61
+ return 'https://api.blinq.io/api/workspace'
62
+ case null:
52
63
  return 'https://api.blinq.io/api/workspace'
64
+ case undefined:
65
+ return 'https://api.blinq.io/api/workspace'
66
+ default:
67
+ return `${process.env.NODE_ENV_BLINQ}/api/workspace`
53
68
  }
54
69
  }
55
70
 
@@ -137,6 +152,11 @@ const downloadAndInstall = async (extractPath, token) => {
137
152
  },
138
153
  })
139
154
 
155
+ if (res.status !== 200) {
156
+ console.error('Error: Unable to fetch workspace')
157
+ process.exit(1)
158
+ }
159
+
140
160
  const zip = await JSZip.loadAsync(res.data)
141
161
  for (const filename of Object.keys(zip.files)) {
142
162
  const fileData = zip.files[filename]
@@ -1 +1 @@
1
- {"version":3,"file":"console_logger.js","sourceRoot":"","sources":["../../src/api/console_logger.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAIjC,MAAa,aAAa;IAExB,YAAoB,MAAgB,EAAU,YAAqB;QAA/C,WAAM,GAAN,MAAM,CAAU;QAAU,iBAAY,GAAZ,YAAY,CAAS;QAD3D,YAAO,GAAY,IAAI,iBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACmB,CAAC;IAEvE,KAAK,CAAC,GAAG,OAAc;QACrB,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAA;SAC/B;IACH,CAAC;IAED,KAAK,CAAC,GAAG,OAAc;QACrB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAA;IAChC,CAAC;IAED,IAAI,CAAC,GAAG,OAAc;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAA;IAC/B,CAAC;CACF;AAjBD,sCAiBC","sourcesContent":["import { Console } from 'console'\nimport { Writable } from 'stream'\nimport { ILogger } from '../logger'\n\nexport class ConsoleLogger implements ILogger {\n private console: Console = new Console(this.stream)\n constructor(private stream: Writable, private debugEnabled: boolean) {}\n\n debug(...content: any[]): void {\n if (this.debugEnabled) {\n this.console.debug(...content)\n }\n }\n\n error(...content: any[]): void {\n this.console.error(...content)\n }\n\n warn(...content: any[]): void {\n this.console.warn(...content)\n }\n}\n"]}
1
+ {"version":3,"file":"console_logger.js","sourceRoot":"","sources":["../../src/api/console_logger.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAIjC,MAAa,aAAa;IAExB,YACU,MAAgB,EAChB,YAAqB;QADrB,WAAM,GAAN,MAAM,CAAU;QAChB,iBAAY,GAAZ,YAAY,CAAS;QAHvB,YAAO,GAAY,IAAI,iBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAIhD,CAAC;IAEJ,KAAK,CAAC,GAAG,OAAc;QACrB,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAA;SAC/B;IACH,CAAC;IAED,KAAK,CAAC,GAAG,OAAc;QACrB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAA;IAChC,CAAC;IAED,IAAI,CAAC,GAAG,OAAc;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAA;IAC/B,CAAC;CACF;AApBD,sCAoBC","sourcesContent":["import { Console } from 'console'\nimport { Writable } from 'stream'\nimport { ILogger } from '../logger'\n\nexport class ConsoleLogger implements ILogger {\n private console: Console = new Console(this.stream)\n constructor(\n private stream: Writable,\n private debugEnabled: boolean\n ) {}\n\n debug(...content: any[]): void {\n if (this.debugEnabled) {\n this.console.debug(...content)\n }\n }\n\n error(...content: any[]): void {\n this.console.error(...content)\n }\n\n warn(...content: any[]): void {\n this.console.warn(...content)\n }\n}\n"]}
package/lib/cli/run.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  /* eslint-disable no-console */
7
7
  /* This is one rare place where we're fine to use process/console directly,
8
8
  * but other code abstracts those to remain composable and testable. */
9
+ console.log('Loading necessary packages...');
9
10
  const _1 = __importDefault(require("./"));
10
11
  const verror_1 = __importDefault(require("verror"));
11
12
  const validate_node_engine_version_1 = require("./validate_node_engine_version");
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAC/B;uEACuE;AACvE,0CAAuC;AACvC,oDAA2B;AAC3B,iFAA0E;AAE1E,SAAS,sBAAsB,CAAC,OAAe;IAC7C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAEc,KAAK,UAAU,GAAG;IAC/B,IAAA,wDAAyB,EACvB,OAAO,CAAC,OAAO,EACf,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,EACD,OAAO,CAAC,IAAI,CACb,CAAA;IAED,MAAM,GAAG,GAAG,IAAI,UAAG,CAAC;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,CAAA;IAEF,IAAI,MAAqB,CAAA;IACzB,IAAI;QACF,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,CAAA;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,sBAAsB,CAAC,gBAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;KAChD;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,IAAI,MAAM,CAAC,qBAAqB,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KACvB;SAAM;QACL,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;KAC5B;AACH,CAAC;AA/BD,sBA+BC","sourcesContent":["/* eslint-disable no-console */\n/* This is one rare place where we're fine to use process/console directly,\n * but other code abstracts those to remain composable and testable. */\nimport Cli, { ICliRunResult } from './'\nimport VError from 'verror'\nimport { validateNodeEngineVersion } from './validate_node_engine_version'\n\nfunction logErrorMessageAndExit(message: string): void {\n console.error(message)\n process.exit(1)\n}\n\nexport default async function run(): Promise<void> {\n validateNodeEngineVersion(\n process.version,\n (error) => {\n console.error(error)\n process.exit(1)\n },\n console.warn\n )\n\n const cli = new Cli({\n argv: process.argv,\n cwd: process.cwd(),\n stdout: process.stdout,\n stderr: process.stderr,\n env: process.env,\n })\n\n let result: ICliRunResult\n try {\n result = await cli.run()\n } catch (error) {\n logErrorMessageAndExit(VError.fullStack(error))\n }\n\n const exitCode = result.success ? 0 : 1\n if (result.shouldExitImmediately) {\n process.exit(exitCode)\n } else {\n process.exitCode = exitCode\n }\n}\n"]}
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAC/B;uEACuE;AACvE,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;AAC5C,0CAAuC;AACvC,oDAA2B;AAC3B,iFAA0E;AAE1E,SAAS,sBAAsB,CAAC,OAAe;IAC7C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAEc,KAAK,UAAU,GAAG;IAC/B,IAAA,wDAAyB,EACvB,OAAO,CAAC,OAAO,EACf,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,EACD,OAAO,CAAC,IAAI,CACb,CAAA;IAED,MAAM,GAAG,GAAG,IAAI,UAAG,CAAC;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,CAAA;IAEF,IAAI,MAAqB,CAAA;IACzB,IAAI;QACF,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,CAAA;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,sBAAsB,CAAC,gBAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;KAChD;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,IAAI,MAAM,CAAC,qBAAqB,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KACvB;SAAM;QACL,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;KAC5B;AACH,CAAC;AA/BD,sBA+BC","sourcesContent":["/* eslint-disable no-console */\n/* This is one rare place where we're fine to use process/console directly,\n * but other code abstracts those to remain composable and testable. */\nconsole.log('Loading necessary packages...')\nimport Cli, { ICliRunResult } from './'\nimport VError from 'verror'\nimport { validateNodeEngineVersion } from './validate_node_engine_version'\n\nfunction logErrorMessageAndExit(message: string): void {\n console.error(message)\n process.exit(1)\n}\n\nexport default async function run(): Promise<void> {\n validateNodeEngineVersion(\n process.version,\n (error) => {\n console.error(error)\n process.exit(1)\n },\n console.warn\n )\n\n const cli = new Cli({\n argv: process.argv,\n cwd: process.cwd(),\n stdout: process.stdout,\n stderr: process.stderr,\n env: process.env,\n })\n\n let result: ICliRunResult\n try {\n result = await cli.run()\n } catch (error) {\n logErrorMessageAndExit(VError.fullStack(error))\n }\n\n const exitCode = result.success ? 0 : 1\n if (result.shouldExitImmediately) {\n process.exit(exitCode)\n } else {\n process.exitCode = exitCode\n }\n}\n"]}
@@ -17,7 +17,9 @@ function validateNodeEngineVersion(currentVersion, onError, onWarning, readPacka
17
17
  onError(`Cucumber can only run on Node.js versions ${requiredVersions}. This Node.js version is ${currentVersion}`);
18
18
  }
19
19
  else if (!semver_1.default.satisfies(currentVersion, testedVersions)) {
20
- onWarning(`This Node.js version (${currentVersion}) has not been tested with this version of Cucumber; it should work normally, but please raise an issue if you see anything unexpected.`);
20
+ // onWarning(
21
+ // `This Node.js version (${currentVersion}) has not been tested with this version of Cucumber; it should work normally, but please raise an issue if you see anything unexpected.`
22
+ // )
21
23
  }
22
24
  }
23
25
  exports.validateNodeEngineVersion = validateNodeEngineVersion;
@@ -1 +1 @@
1
- {"version":3,"file":"validate_node_engine_version.js","sourceRoot":"","sources":["../../src/cli/validate_node_engine_version.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,oDAA2B;AAO3B,MAAM,qBAAqB,GAAsB,GAAG,EAAE,CACpD,IAAI,CAAC,KAAK,CACR,YAAE;KACC,YAAY,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;KACjE,QAAQ,EAAE,CACd,CAAA;AAEH,SAAgB,yBAAyB,CACvC,cAAsB,EACtB,OAAkC,EAClC,SAAoC,EACpC,kBAAqC,qBAAqB;IAE1D,MAAM,gBAAgB,GAAG,eAAe,EAAE,CAAC,OAAO,CAAC,IAAI,CAAA;IACvD,MAAM,cAAc,GAAG,eAAe,EAAE,CAAC,aAAa,CAAC,IAAI,CAAA;IAC3D,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,gBAAgB,CAAC,EAAE;QACvD,OAAO,CACL,6CAA6C,gBAAgB,6BAA6B,cAAc,EAAE,CAC3G,CAAA;KACF;SAAM,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE;QAC5D,SAAS,CACP,yBAAyB,cAAc,yIAAyI,CACjL,CAAA;KACF;AACH,CAAC;AAjBD,8DAiBC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport semver from 'semver'\n\ntype PackageJSON = {\n engines: { node: string }\n enginesTested: { node: string }\n}\n\nconst readActualPackageJSON: () => PackageJSON = () =>\n JSON.parse(\n fs\n .readFileSync(path.resolve(__dirname, '..', '..', 'package.json'))\n .toString()\n )\n\nexport function validateNodeEngineVersion(\n currentVersion: string,\n onError: (message: string) => void,\n onWarning: (message: string) => void,\n readPackageJSON: () => PackageJSON = readActualPackageJSON\n): void {\n const requiredVersions = readPackageJSON().engines.node\n const testedVersions = readPackageJSON().enginesTested.node\n if (!semver.satisfies(currentVersion, requiredVersions)) {\n onError(\n `Cucumber can only run on Node.js versions ${requiredVersions}. This Node.js version is ${currentVersion}`\n )\n } else if (!semver.satisfies(currentVersion, testedVersions)) {\n onWarning(\n `This Node.js version (${currentVersion}) has not been tested with this version of Cucumber; it should work normally, but please raise an issue if you see anything unexpected.`\n )\n }\n}\n"]}
1
+ {"version":3,"file":"validate_node_engine_version.js","sourceRoot":"","sources":["../../src/cli/validate_node_engine_version.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,oDAA2B;AAO3B,MAAM,qBAAqB,GAAsB,GAAG,EAAE,CACpD,IAAI,CAAC,KAAK,CACR,YAAE;KACC,YAAY,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;KACjE,QAAQ,EAAE,CACd,CAAA;AAEH,SAAgB,yBAAyB,CACvC,cAAsB,EACtB,OAAkC,EAClC,SAAoC,EACpC,kBAAqC,qBAAqB;IAE1D,MAAM,gBAAgB,GAAG,eAAe,EAAE,CAAC,OAAO,CAAC,IAAI,CAAA;IACvD,MAAM,cAAc,GAAG,eAAe,EAAE,CAAC,aAAa,CAAC,IAAI,CAAA;IAC3D,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,gBAAgB,CAAC,EAAE;QACvD,OAAO,CACL,6CAA6C,gBAAgB,6BAA6B,cAAc,EAAE,CAC3G,CAAA;KACF;SAAM,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE;QAC5D,aAAa;QACb,qLAAqL;QACrL,IAAI;KACL;AACH,CAAC;AAjBD,8DAiBC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport semver from 'semver'\n\ntype PackageJSON = {\n engines: { node: string }\n enginesTested: { node: string }\n}\n\nconst readActualPackageJSON: () => PackageJSON = () =>\n JSON.parse(\n fs\n .readFileSync(path.resolve(__dirname, '..', '..', 'package.json'))\n .toString()\n )\n\nexport function validateNodeEngineVersion(\n currentVersion: string,\n onError: (message: string) => void,\n onWarning: (message: string) => void,\n readPackageJSON: () => PackageJSON = readActualPackageJSON\n): void {\n const requiredVersions = readPackageJSON().engines.node\n const testedVersions = readPackageJSON().enginesTested.node\n if (!semver.satisfies(currentVersion, requiredVersions)) {\n onError(\n `Cucumber can only run on Node.js versions ${requiredVersions}. This Node.js version is ${currentVersion}`\n )\n } else if (!semver.satisfies(currentVersion, testedVersions)) {\n // onWarning(\n // `This Node.js version (${currentVersion}) has not been tested with this version of Cucumber; it should work normally, but please raise an issue if you see anything unexpected.`\n // )\n }\n}\n"]}
@@ -27,7 +27,7 @@ const createAxiosClient = () => {
27
27
  try {
28
28
  const agent = getProxy();
29
29
  return axios_1.default.create({
30
- httpAgent: agent,
30
+ httpsAgent: agent,
31
31
  proxy: false,
32
32
  });
33
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"axios_client.js","sourceRoot":"","sources":["../../src/configuration/axios_client.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,kDAAyB;AACzB,oDAA6C;AAG7C,MAAM,QAAQ,GAAG,GAAiB,EAAE;IAClC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE;QACtB,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,KAAK,GAAkB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;IAC9C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1B,MAAM,WAAW,GAAiB;QAChC,IAAI,EAAE,GAAG,CAAC,QAAQ;QAClB,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;KACvB,CAAA;IAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;IAElC,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,WAAW,CAAC,SAAS,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAA;KAClD;IACD,OAAO,gBAAM,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;AACrD,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,IAAI;QACF,MAAM,KAAK,GAAmB,QAAQ,EAAE,CAAA;QACxC,OAAO,eAAK,CAAC,MAAM,CAAC;YAClB,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,KAAK;SACb,CAAC,CAAA;KACH;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC1B,MAAM,IAAI,KAAK,CACb,+BACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAC1D,EAAE,CACH,CAAA;KACF;AACH,CAAC,CAAA;AAEY,QAAA,WAAW,GAAG,iBAAiB,EAAE,CAAA","sourcesContent":["/* eslint-disable no-console */\nimport axios from 'axios'\nimport tunnel, { ProxyOptions } from 'tunnel'\nimport { Agent } from 'http'\n\nconst getProxy = (): Agent | null => {\n if (!process.env.PROXY) {\n return null\n }\n\n const proxy: string | null = process.env.PROXY\n const url = new URL(proxy)\n const proxyObject: ProxyOptions = {\n host: url.hostname,\n port: Number(url.port),\n }\n\n const { username, password } = url\n\n if (username && password) {\n proxyObject.proxyAuth = `${username}:${password}`\n }\n return tunnel.httpsOverHttp({ proxy: proxyObject })\n}\n\nconst createAxiosClient = () => {\n try {\n const agent: string | Agent = getProxy()\n return axios.create({\n httpAgent: agent,\n proxy: false,\n })\n } catch (error) {\n console.log(error.message)\n throw new Error(\n `Error creating axios client ${\n error instanceof Error ? error.message : error.response.data\n }`\n )\n }\n}\n\nexport const axiosClient = createAxiosClient()\n"]}
1
+ {"version":3,"file":"axios_client.js","sourceRoot":"","sources":["../../src/configuration/axios_client.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,kDAAyB;AACzB,oDAA6C;AAG7C,MAAM,QAAQ,GAAG,GAAiB,EAAE;IAClC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE;QACtB,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,KAAK,GAAkB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;IAC9C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1B,MAAM,WAAW,GAAiB;QAChC,IAAI,EAAE,GAAG,CAAC,QAAQ;QAClB,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;KACvB,CAAA;IAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;IAElC,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,WAAW,CAAC,SAAS,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAA;KAClD;IACD,OAAO,gBAAM,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;AACrD,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,IAAI;QACF,MAAM,KAAK,GAAmB,QAAQ,EAAE,CAAA;QACxC,OAAO,eAAK,CAAC,MAAM,CAAC;YAClB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE,KAAK;SACb,CAAC,CAAA;KACH;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC1B,MAAM,IAAI,KAAK,CACb,+BACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAC1D,EAAE,CACH,CAAA;KACF;AACH,CAAC,CAAA;AAEY,QAAA,WAAW,GAAG,iBAAiB,EAAE,CAAA","sourcesContent":["/* eslint-disable no-console */\nimport axios from 'axios'\nimport tunnel, { ProxyOptions } from 'tunnel'\nimport { Agent } from 'http'\n\nconst getProxy = (): Agent | null => {\n if (!process.env.PROXY) {\n return null\n }\n\n const proxy: string | null = process.env.PROXY\n const url = new URL(proxy)\n const proxyObject: ProxyOptions = {\n host: url.hostname,\n port: Number(url.port),\n }\n\n const { username, password } = url\n\n if (username && password) {\n proxyObject.proxyAuth = `${username}:${password}`\n }\n return tunnel.httpsOverHttp({ proxy: proxyObject })\n}\n\nconst createAxiosClient = () => {\n try {\n const agent: string | Agent = getProxy()\n return axios.create({\n httpsAgent: agent,\n proxy: false,\n })\n } catch (error) {\n console.log(error.message)\n throw new Error(\n `Error creating axios client ${\n error instanceof Error ? error.message : error.response.data\n }`\n )\n }\n}\n\nexport const axiosClient = createAxiosClient()\n"]}
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getProjectByAccessKey = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
7
  const tunnel_1 = __importDefault(require("tunnel"));
8
+ const axios_client_1 = require("../configuration/axios_client");
9
9
  const getSSoUrl = () => {
10
10
  switch (process.env.NODE_ENV_BLINQ) {
11
11
  case 'local':
@@ -14,8 +14,14 @@ const getSSoUrl = () => {
14
14
  return 'https://dev.api.blinq.io/api/auth';
15
15
  case 'stage':
16
16
  return 'https://stage.api.blinq.io/api/auth';
17
- default:
17
+ case 'prod':
18
+ return 'https://api.blinq.io/api/auth';
19
+ case null:
18
20
  return 'https://api.blinq.io/api/auth';
21
+ case undefined:
22
+ return 'https://api.blinq.io/api/auth';
23
+ default:
24
+ return `${process.env.NODE_ENV_BLINQ}/api/auth`;
19
25
  }
20
26
  };
21
27
  const getProxy = () => {
@@ -38,11 +44,16 @@ const getProxy = () => {
38
44
  const getProjectByAccessKey = async (access_key) => {
39
45
  const ssoUrl = getSSoUrl();
40
46
  const accessKeyUrl = `${ssoUrl}/getProjectByAccessKey`;
41
- const response = await axios_1.default.post(accessKeyUrl, {
47
+ const response = await axios_client_1.axiosClient.post(accessKeyUrl, {
42
48
  access_key,
43
- httpAgent: getProxy(),
44
- proxy: false,
45
49
  });
50
+ /*
51
+ const response = await axios.post(accessKeyUrl, {
52
+ access_key,
53
+ httpAgent: getProxy(),
54
+ proxy: false,
55
+ })
56
+ */
46
57
  if (response.status !== 200) {
47
58
  console.error('Error: Invalid access key');
48
59
  process.exit(1);
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/formatter/api.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,oDAA2B;AAE3B,MAAM,SAAS,GAAG,GAAG,EAAE;IACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QAClC,KAAK,OAAO;YACV,OAAO,gCAAgC,CAAA;QACzC,KAAK,KAAK;YACR,OAAO,mCAAmC,CAAA;QAC5C,KAAK,OAAO;YACV,OAAO,qCAAqC,CAAA;QAC9C;YACE,OAAO,+BAA+B,CAAA;KACzC;AACH,CAAC,CAAA;AACD,MAAM,QAAQ,GAAG,GAAG,EAAE;IACpB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE;QACtB,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;IAC/B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1B,MAAM,WAAW,GAAG;QAClB,IAAI,EAAE,GAAG,CAAC,QAAQ;QAClB,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;KACvB,CAAA;IAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;IAElC,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,YAAY;QACZ,WAAW,CAAC,SAAS,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAA;KAClD;IACD,OAAO,gBAAM,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;AACrD,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,KAAK,EAAE,UAAiB,EAAE,EAAE;IACxD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,YAAY,GAAG,GAAG,MAAM,wBAAwB,CAAA;IACtD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE;QAC9C,UAAU;QACV,SAAS,EAAE,QAAQ,EAAE;QACrB,KAAK,EAAE,KAAK;KACb,CAAC,CAAA;IACF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;QAC3B,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;IACD,OAAO,QAAQ,CAAC,IAAI,CAAA;AACtB,CAAC,CAAC;AAEO,sDAAqB","sourcesContent":["import axios from 'axios'\nimport tunnel from 'tunnel'\n\nconst getSSoUrl = () => {\n switch (process.env.NODE_ENV_BLINQ) {\n case 'local':\n return 'http://localhost:5000/api/auth'\n case 'dev':\n return 'https://dev.api.blinq.io/api/auth'\n case 'stage':\n return 'https://stage.api.blinq.io/api/auth'\n default:\n return 'https://api.blinq.io/api/auth'\n }\n }\n const getProxy = () => {\n if (!process.env.PROXY) {\n return null\n }\n \n const proxy = process.env.PROXY\n const url = new URL(proxy)\n const proxyObject = {\n host: url.hostname,\n port: Number(url.port),\n }\n \n const { username, password } = url\n \n if (username && password) {\n //@ts-ignore\n proxyObject.proxyAuth = `${username}:${password}`\n }\n return tunnel.httpsOverHttp({ proxy: proxyObject })\n }\n \n const getProjectByAccessKey = async (access_key:string) => {\n const ssoUrl = getSSoUrl()\n const accessKeyUrl = `${ssoUrl}/getProjectByAccessKey`\n const response = await axios.post(accessKeyUrl, {\n access_key,\n httpAgent: getProxy(),\n proxy: false,\n })\n if (response.status !== 200) {\n console.error('Error: Invalid access key')\n process.exit(1)\n }\n return response.data\n };\n\n export { getProjectByAccessKey };"]}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/formatter/api.ts"],"names":[],"mappings":";;;;;;AACA,oDAA2B;AAC3B,gEAA2D;AAE3D,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QAClC,KAAK,OAAO;YACV,OAAO,gCAAgC,CAAA;QACzC,KAAK,KAAK;YACR,OAAO,mCAAmC,CAAA;QAC5C,KAAK,OAAO;YACV,OAAO,qCAAqC,CAAA;QAC9C,KAAK,MAAM;YACT,OAAO,+BAA+B,CAAA;QACxC,KAAK,IAAI;YACP,OAAO,+BAA+B,CAAA;QACxC,KAAK,SAAS;YACZ,OAAO,+BAA+B,CAAA;QACxC;YACE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,WAAW,CAAA;KAClD;AACH,CAAC,CAAA;AACD,MAAM,QAAQ,GAAG,GAAG,EAAE;IACpB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE;QACtB,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;IAC/B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1B,MAAM,WAAW,GAAG;QAClB,IAAI,EAAE,GAAG,CAAC,QAAQ;QAClB,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;KACvB,CAAA;IAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;IAElC,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,YAAY;QACZ,WAAW,CAAC,SAAS,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAA;KAClD;IACD,OAAO,gBAAM,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;AACrD,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,KAAK,EAAE,UAAkB,EAAE,EAAE;IACzD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,YAAY,GAAG,GAAG,MAAM,wBAAwB,CAAA;IAEtD,MAAM,QAAQ,GAAG,MAAM,0BAAW,CAAC,IAAI,CAAC,YAAY,EAAE;QACpD,UAAU;KACX,CAAC,CAAA;IAEF;;;;;;MAME;IAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;QAC3B,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;IACD,OAAO,QAAQ,CAAC,IAAI,CAAA;AACtB,CAAC,CAAA;AAEQ,sDAAqB","sourcesContent":["import axios from 'axios'\nimport tunnel from 'tunnel'\nimport { axiosClient } from '../configuration/axios_client'\n\nconst getSSoUrl = () => {\n switch (process.env.NODE_ENV_BLINQ) {\n case 'local':\n return 'http://localhost:5000/api/auth'\n case 'dev':\n return 'https://dev.api.blinq.io/api/auth'\n case 'stage':\n return 'https://stage.api.blinq.io/api/auth'\n case 'prod':\n return 'https://api.blinq.io/api/auth'\n case null:\n return 'https://api.blinq.io/api/auth'\n case undefined:\n return 'https://api.blinq.io/api/auth'\n default:\n return `${process.env.NODE_ENV_BLINQ}/api/auth`\n }\n}\nconst getProxy = () => {\n if (!process.env.PROXY) {\n return null\n }\n\n const proxy = process.env.PROXY\n const url = new URL(proxy)\n const proxyObject = {\n host: url.hostname,\n port: Number(url.port),\n }\n\n const { username, password } = url\n\n if (username && password) {\n //@ts-ignore\n proxyObject.proxyAuth = `${username}:${password}`\n }\n return tunnel.httpsOverHttp({ proxy: proxyObject })\n}\n\nconst getProjectByAccessKey = async (access_key: string) => {\n const ssoUrl = getSSoUrl()\n const accessKeyUrl = `${ssoUrl}/getProjectByAccessKey`\n\n const response = await axiosClient.post(accessKeyUrl, {\n access_key,\n })\n\n /*\n const response = await axios.post(accessKeyUrl, {\n access_key,\n httpAgent: getProxy(),\n proxy: false,\n })\n */\n\n if (response.status !== 200) {\n console.error('Error: Invalid access key')\n process.exit(1)\n }\n return response.data\n}\n\nexport { getProjectByAccessKey }\n"]}
@@ -69,9 +69,7 @@ const FormatterBuilder = {
69
69
  let result;
70
70
  try {
71
71
  // eslint-disable-next-line @typescript-eslint/no-var-requires
72
- result = require(typeof urlOrName === 'string'
73
- ? urlOrName
74
- : (0, url_1.fileURLToPath)(urlOrName));
72
+ result = require(typeof urlOrName === 'string' ? urlOrName : (0, url_1.fileURLToPath)(urlOrName));
75
73
  }
76
74
  catch (error) {
77
75
  if (error.code === 'ERR_REQUIRE_ESM') {
@@ -1 +1 @@
1
- {"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/formatter/builder.ts"],"names":[],"mappings":";;;;;AAAA,oEAAyC;AACzC,4HAAiG;AACjG,gDAAuB;AACvB,wGAA4E;AAO5E,oDAAkE;AAIlE,qFAAmF;AACnF,6BAAkD;AAClD,sEAA6C;AAC7C,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAqB3C,MAAM,gBAAgB,GAAG;IACvB,KAAK,CAAC,KAAK,CAAC,IAAY,EAAE,OAAsB;QAC9C,MAAM,oBAAoB,GAAG,MAAM,gBAAgB,CAAC,oBAAoB,CACtE,IAAI,EACJ,OAAO,CAAC,GAAG,CACZ,CAAA;QACD,MAAM,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CAAC,YAAiB;QAClC,IAAI,IAAA,gCAAgB,EAAC,YAAY,CAAC,EAAE;YAClC,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,OAAO,YAAY,KAAK,UAAU,EAAE;YACtC,OAAO,YAAY,CAAA;SACpB;aAAM,IACL,OAAO,YAAY,KAAK,QAAQ;YAChC,OAAO,YAAY,CAAC,OAAO,KAAK,UAAU,EAC1C;YACA,OAAO,YAAY,CAAC,OAAO,CAAA;SAC5B;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AAED,kBAAe,gBAAgB,CAAA","sourcesContent":["import getColorFns from './get_color_fns'\nimport JavascriptSnippetSyntax from './step_definition_snippet_builder/javascript_snippet_syntax'\nimport path from 'path'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport Formatter, {\n FormatOptions,\n IFormatterCleanupFn,\n IFormatterLogFn,\n} from '.'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { EventEmitter } from 'events'\nimport EventDataCollector from './helpers/event_data_collector'\nimport { Writable as WritableStream } from 'stream'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\nimport { fileURLToPath, pathToFileURL } from 'url'\nimport Formatters from './helpers/formatters'\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\n\ninterface IGetStepDefinitionSnippetBuilderOptions {\n cwd: string\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IBuildOptions {\n env: NodeJS.ProcessEnv\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: FormatOptions\n stream: WritableStream\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nconst FormatterBuilder = {\n async build(type: string, options: IBuildOptions): Promise<Formatter> {\n const FormatterConstructor = await FormatterBuilder.getConstructorByType(\n type,\n options.cwd\n )\n const colorFns = getColorFns(\n options.stream,\n options.env,\n options.parsedArgvOptions.colorsEnabled\n )\n const snippetBuilder =\n await FormatterBuilder.getStepDefinitionSnippetBuilder({\n cwd: options.cwd,\n snippetInterface: options.parsedArgvOptions.snippetInterface,\n snippetSyntax: options.parsedArgvOptions.snippetSyntax,\n supportCodeLibrary: options.supportCodeLibrary,\n })\n return new FormatterConstructor({\n colorFns,\n snippetBuilder,\n ...options,\n })\n },\n\n async getConstructorByType(\n type: string,\n cwd: string\n ): Promise<typeof Formatter> {\n const formatters: Record<string, typeof Formatter> =\n Formatters.getFormatters()\n\n return formatters[type]\n ? formatters[type]\n : await FormatterBuilder.loadCustomClass('formatter', type, cwd)\n },\n\n async getStepDefinitionSnippetBuilder({\n cwd,\n snippetInterface,\n snippetSyntax,\n supportCodeLibrary,\n }: IGetStepDefinitionSnippetBuilderOptions) {\n if (doesNotHaveValue(snippetInterface)) {\n snippetInterface = SnippetInterface.Synchronous\n }\n let Syntax = JavascriptSnippetSyntax\n if (doesHaveValue(snippetSyntax)) {\n Syntax = await FormatterBuilder.loadCustomClass(\n 'syntax',\n snippetSyntax,\n cwd\n )\n }\n return new StepDefinitionSnippetBuilder({\n snippetSyntax: new Syntax(snippetInterface),\n parameterTypeRegistry: supportCodeLibrary.parameterTypeRegistry,\n })\n },\n\n async loadCustomClass(\n type: 'formatter' | 'syntax',\n descriptor: string,\n cwd: string\n ) {\n let normalized: URL | string = descriptor\n if (descriptor.startsWith('.')) {\n normalized = pathToFileURL(path.resolve(cwd, descriptor))\n } else if (descriptor.startsWith('file://')) {\n normalized = new URL(descriptor)\n }\n let CustomClass = await FormatterBuilder.loadFile(normalized)\n CustomClass = FormatterBuilder.resolveConstructor(CustomClass)\n if (doesHaveValue(CustomClass)) {\n return CustomClass\n } else {\n throw new Error(\n `Custom ${type} (${descriptor}) does not export a function/class`\n )\n }\n },\n\n async loadFile(urlOrName: URL | string) {\n let result\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n result = require(typeof urlOrName === 'string'\n ? urlOrName\n : fileURLToPath(urlOrName))\n } catch (error) {\n if (error.code === 'ERR_REQUIRE_ESM') {\n result = await importer(urlOrName)\n } else {\n throw error\n }\n }\n return result\n },\n\n resolveConstructor(ImportedCode: any) {\n if (doesNotHaveValue(ImportedCode)) {\n return null\n }\n if (typeof ImportedCode === 'function') {\n return ImportedCode\n } else if (\n typeof ImportedCode === 'object' &&\n typeof ImportedCode.default === 'function'\n ) {\n return ImportedCode.default\n }\n return null\n },\n}\n\nexport default FormatterBuilder\n"]}
1
+ {"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/formatter/builder.ts"],"names":[],"mappings":";;;;;AAAA,oEAAyC;AACzC,4HAAiG;AACjG,gDAAuB;AACvB,wGAA4E;AAO5E,oDAAkE;AAIlE,qFAAmF;AACnF,6BAAkD;AAClD,sEAA6C;AAC7C,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAqB3C,MAAM,gBAAgB,GAAG;IACvB,KAAK,CAAC,KAAK,CAAC,IAAY,EAAE,OAAsB;QAC9C,MAAM,oBAAoB,GAAG,MAAM,gBAAgB,CAAC,oBAAoB,CACtE,IAAI,EACJ,OAAO,CAAC,GAAG,CACZ,CAAA;QACD,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAC1B,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,GAAG,EACX,OAAO,CAAC,iBAAiB,CAAC,aAAa,CACxC,CAAA;QACD,MAAM,cAAc,GAClB,MAAM,gBAAgB,CAAC,+BAA+B,CAAC;YACrD,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,gBAAgB,EAAE,OAAO,CAAC,iBAAiB,CAAC,gBAAgB;YAC5D,aAAa,EAAE,OAAO,CAAC,iBAAiB,CAAC,aAAa;YACtD,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;SAC/C,CAAC,CAAA;QAC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import JavascriptSnippetSyntax from './step_definition_snippet_builder/javascript_snippet_syntax'\nimport path from 'path'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport Formatter, {\n FormatOptions,\n IFormatterCleanupFn,\n IFormatterLogFn,\n} from '.'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { EventEmitter } from 'events'\nimport EventDataCollector from './helpers/event_data_collector'\nimport { Writable as WritableStream } from 'stream'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\nimport { fileURLToPath, pathToFileURL } from 'url'\nimport Formatters from './helpers/formatters'\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\n\ninterface IGetStepDefinitionSnippetBuilderOptions {\n cwd: string\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IBuildOptions {\n env: NodeJS.ProcessEnv\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: FormatOptions\n stream: WritableStream\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nconst FormatterBuilder = {\n async build(type: string, options: IBuildOptions): Promise<Formatter> {\n const FormatterConstructor = await FormatterBuilder.getConstructorByType(\n type,\n options.cwd\n )\n const colorFns = getColorFns(\n options.stream,\n options.env,\n options.parsedArgvOptions.colorsEnabled\n )\n const snippetBuilder =\n await FormatterBuilder.getStepDefinitionSnippetBuilder({\n cwd: options.cwd,\n snippetInterface: options.parsedArgvOptions.snippetInterface,\n snippetSyntax: options.parsedArgvOptions.snippetSyntax,\n supportCodeLibrary: options.supportCodeLibrary,\n })\n return new FormatterConstructor({\n colorFns,\n snippetBuilder,\n ...options,\n })\n },\n\n async getConstructorByType(\n type: string,\n cwd: string\n ): Promise<typeof Formatter> {\n const formatters: Record<string, typeof Formatter> =\n Formatters.getFormatters()\n\n return formatters[type]\n ? formatters[type]\n : await FormatterBuilder.loadCustomClass('formatter', type, cwd)\n },\n\n async getStepDefinitionSnippetBuilder({\n cwd,\n snippetInterface,\n snippetSyntax,\n supportCodeLibrary,\n }: IGetStepDefinitionSnippetBuilderOptions) {\n if (doesNotHaveValue(snippetInterface)) {\n snippetInterface = SnippetInterface.Synchronous\n }\n let Syntax = JavascriptSnippetSyntax\n if (doesHaveValue(snippetSyntax)) {\n Syntax = await FormatterBuilder.loadCustomClass(\n 'syntax',\n snippetSyntax,\n cwd\n )\n }\n return new StepDefinitionSnippetBuilder({\n snippetSyntax: new Syntax(snippetInterface),\n parameterTypeRegistry: supportCodeLibrary.parameterTypeRegistry,\n })\n },\n\n async loadCustomClass(\n type: 'formatter' | 'syntax',\n descriptor: string,\n cwd: string\n ) {\n let normalized: URL | string = descriptor\n if (descriptor.startsWith('.')) {\n normalized = pathToFileURL(path.resolve(cwd, descriptor))\n } else if (descriptor.startsWith('file://')) {\n normalized = new URL(descriptor)\n }\n let CustomClass = await FormatterBuilder.loadFile(normalized)\n CustomClass = FormatterBuilder.resolveConstructor(CustomClass)\n if (doesHaveValue(CustomClass)) {\n return CustomClass\n } else {\n throw new Error(\n `Custom ${type} (${descriptor}) does not export a function/class`\n )\n }\n },\n\n async loadFile(urlOrName: URL | string) {\n let result\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n result = require(\n typeof urlOrName === 'string' ? urlOrName : fileURLToPath(urlOrName)\n )\n } catch (error) {\n if (error.code === 'ERR_REQUIRE_ESM') {\n result = await importer(urlOrName)\n } else {\n throw error\n }\n }\n return result\n },\n\n resolveConstructor(ImportedCode: any) {\n if (doesNotHaveValue(ImportedCode)) {\n return null\n }\n if (typeof ImportedCode === 'function') {\n return ImportedCode\n } else if (\n typeof ImportedCode === 'object' &&\n typeof ImportedCode.default === 'function'\n ) {\n return ImportedCode.default\n }\n return null\n },\n}\n\nexport default FormatterBuilder\n"]}
@@ -1,11 +1,22 @@
1
1
  import Formatter, { IFormatterOptions } from '.';
2
+ import ReportGenerator, { JsonTestResult } from './helpers/report_generator';
3
+ export declare let globalReportLink: string;
2
4
  export default class BVTAnalysisFormatter extends Formatter {
5
+ static reportGenerator: ReportGenerator;
6
+ static reRunFailedStepsIndex: {
7
+ testCaseId: string;
8
+ failedStepIndex: number;
9
+ }[] | null;
3
10
  private reportGenerator;
4
11
  private uploader;
5
12
  private exit;
6
13
  private START;
7
14
  private runName;
15
+ private failedStepsIndex;
16
+ private summaryFormatter;
17
+ private rootCauseArray;
8
18
  constructor(options: IFormatterOptions);
19
+ private sendEvent;
9
20
  private uploadReport;
10
21
  finished(): Promise<any>;
11
22
  private analyzeReport;
@@ -13,7 +24,8 @@ export default class BVTAnalysisFormatter extends Formatter {
13
24
  private processTestCase;
14
25
  private uploadFinalReport;
15
26
  private retrain;
27
+ private rerun;
16
28
  private call_cucumber_client;
17
29
  private getAppDataDir;
18
30
  }
19
- export declare function logReportLink(runId: string, projectId: string): void;
31
+ export declare function logReportLink(runId: string, projectId: string, status: JsonTestResult): string;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.logReportLink = void 0;
6
+ exports.logReportLink = exports.globalReportLink = void 0;
7
7
  const child_process_1 = require("child_process");
8
8
  const fs_1 = require("fs");
9
9
  const promises_1 = require("fs/promises");
@@ -15,28 +15,54 @@ const report_generator_1 = __importDefault(require("./helpers/report_generator")
15
15
  const uploader_1 = __importDefault(require("./helpers/uploader"));
16
16
  const os_1 = __importDefault(require("os"));
17
17
  const api_1 = require("./api");
18
+ const summary_formatter_1 = __importDefault(require("./summary_formatter"));
19
+ const constants_1 = require("./helpers/constants");
20
+ const axios_client_1 = require("../configuration/axios_client");
21
+ const util_1 = require("util");
22
+ const child_process_2 = require("child_process");
18
23
  //User token
19
24
  const TOKEN = process.env.TOKEN;
25
+ exports.globalReportLink = '';
20
26
  class BVTAnalysisFormatter extends _1.default {
21
27
  constructor(options) {
22
28
  super(options);
23
29
  this.reportGenerator = new report_generator_1.default();
24
30
  this.uploader = new uploader_1.default(this.reportGenerator);
25
31
  this.exit = false;
32
+ this.rootCauseArray = [];
33
+ this.summaryFormatter = new summary_formatter_1.default(options);
34
+ BVTAnalysisFormatter.reportGenerator = this.reportGenerator;
35
+ this.rootCauseArray = [];
36
+ this.failedStepsIndex = [];
37
+ BVTAnalysisFormatter.reRunFailedStepsIndex = process.env.RERUN
38
+ ? JSON.parse(process.env.RERUN)
39
+ : null;
26
40
  if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {
27
41
  throw new Error('TOKEN must be set');
28
42
  }
29
- options.eventBroadcaster.on('envelope', async (envelope) => {
43
+ this.sendEvent(constants_1.ActionEvents.cli_run_tests);
44
+ options.eventBroadcaster.on('envelope', async (envelope, data) => {
45
+ if ((0, value_checker_1.doesHaveValue)(envelope.testCaseFinished) && data) {
46
+ const { rootCause, report } = data;
47
+ if (!rootCause.status) {
48
+ console.error(`Root cause: ${rootCause.failClass}\n, ${rootCause.analysis}\nfailing step: ${rootCause.failedStep}`);
49
+ this.rootCauseArray.push({ rootCause, report });
50
+ this.failedStepsIndex.push({
51
+ testCaseId: report.id,
52
+ failedStepIndex: rootCause.failedStep,
53
+ });
54
+ }
55
+ return;
56
+ }
30
57
  await this.reportGenerator.handleMessage(envelope);
31
58
  if ((0, value_checker_1.doesHaveValue)(envelope.meta) &&
32
59
  (0, value_checker_1.doesHaveValue)(envelope.meta.runName)) {
33
60
  this.runName = envelope.meta.runName;
34
61
  }
35
62
  if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
36
- const report = this.reportGenerator.getReport();
37
63
  this.START = Date.now();
38
64
  if (process.env.BVT_FORMATTER === 'ANALYSIS') {
39
- await this.analyzeReport(report);
65
+ await this.analyzeReport();
40
66
  }
41
67
  else {
42
68
  // await this.uploadReport(report)
@@ -45,6 +71,20 @@ class BVTAnalysisFormatter extends _1.default {
45
71
  }
46
72
  });
47
73
  }
74
+ sendEvent(event) {
75
+ axios_client_1.axiosClient
76
+ .post(`${constants_1.SERVICES_URI.STORAGE}/event`, {
77
+ event,
78
+ }, {
79
+ headers: {
80
+ Authorization: `Bearer ${TOKEN}`,
81
+ 'x-source': 'cucumber_js',
82
+ },
83
+ })
84
+ .catch((err) => {
85
+ // Error with events, ignoring
86
+ });
87
+ }
48
88
  async uploadReport(report) {
49
89
  const uploadSuccessful = await this.uploadFinalReport(report);
50
90
  if (uploadSuccessful && report.result.status !== 'FAILED') {
@@ -63,79 +103,72 @@ class BVTAnalysisFormatter extends _1.default {
63
103
  anyRem = undefined;
64
104
  }
65
105
  if (this.exit && (!anyRem || anyRem.length === 0)) {
66
- clearInterval(checkInterval);
67
- resolve(null);
106
+ // clearInterval(checkInterval)
107
+ // resolve(null)
108
+ if (this.reportGenerator.getReport().result.status === 'FAILED') {
109
+ process.exit(1);
110
+ }
111
+ else {
112
+ process.exit(0);
113
+ }
68
114
  }
69
- }, 1000); // check every 100ms
115
+ }, 100); // check every 100ms
70
116
  });
71
117
  }
72
- async analyzeReport(report) {
73
- if (report.result.status === 'PASSED' ||
118
+ async analyzeReport() {
119
+ if (this.rootCauseArray.length === 0 ||
74
120
  process.env.NO_RETRAIN === 'false') {
75
- if (report.result.status === 'PASSED') {
121
+ if (this.rootCauseArray.length === 0) {
76
122
  this.log('No test failed. No need to retrain\n');
77
123
  }
78
124
  if (process.env.NO_RETRAIN === 'false') {
79
125
  this.log('Retraining is skipped since the failed step contains an API request\n');
80
126
  }
81
127
  // const uploadSuccessful = await this.uploadFinalReport(report)
82
- process.exit(0);
128
+ // process.exit(0)
129
+ this.exit = true;
130
+ return;
83
131
  }
84
132
  //checking if the type of report.result is JsonResultFailed or not
85
133
  this.log('Some tests failed, starting the retraining...\n');
86
- if (!('startTime' in report.result) || !('endTime' in report.result)) {
87
- this.log('Unknown error occured,not retraining\n');
88
- await this.uploadFinalReport(report);
89
- return;
90
- }
91
- const finalReport = await this.processTestCases(report);
92
- const uploadSuccessful = await this.uploadFinalReport(finalReport);
93
- if (finalReport.result.status !== 'FAILED' && uploadSuccessful) {
94
- process.exit(0);
95
- }
96
- else {
134
+ await this.processTestCases();
135
+ if (this.reportGenerator.getReport().result.status === 'FAILED') {
97
136
  process.exit(1);
98
137
  }
138
+ process.exit(0);
99
139
  }
100
- async processTestCases(report) {
101
- const finalTestCases = [];
102
- for (const testCase of report.testCases) {
103
- const modifiedTestCase = await this.processTestCase(testCase, report);
104
- finalTestCases.push(modifiedTestCase);
140
+ async processTestCases() {
141
+ for (const { rootCause, report } of this.rootCauseArray) {
142
+ await this.processTestCase(rootCause, report);
105
143
  }
106
- const finalResult = finalTestCases.some((tc) => tc.result.status !== 'PASSED')
107
- ? report.result
108
- : {
109
- ...report.result,
110
- status: 'PASSED',
111
- };
112
- return {
113
- result: finalResult,
114
- testCases: finalTestCases,
115
- env: report.env,
116
- };
117
- }
118
- async processTestCase(testCase, report) {
119
- if (testCase.result.status === 'PASSED') {
120
- return testCase;
144
+ }
145
+ async processTestCase(rootCause, report) {
146
+ const failedTestSteps = rootCause.failedStep;
147
+ if (BVTAnalysisFormatter.reRunFailedStepsIndex &&
148
+ BVTAnalysisFormatter.reRunFailedStepsIndex.length > 0) {
149
+ const previousRun = BVTAnalysisFormatter.reRunFailedStepsIndex[0];
150
+ if (previousRun.failedStepIndex === failedTestSteps) {
151
+ console.log('Same step has failed again, skipping retraining');
152
+ BVTAnalysisFormatter.reRunFailedStepsIndex.shift();
153
+ return;
154
+ }
155
+ BVTAnalysisFormatter.reRunFailedStepsIndex.shift();
121
156
  }
122
- const failedTestSteps = testCase.steps
123
- .map((step, i) => (step.result.status === 'FAILED' ? i : null))
124
- .filter((i) => i !== null);
125
- const retrainStats = await this.retrain(failedTestSteps, testCase);
157
+ const retrainStats = await this.retrain(failedTestSteps, report);
126
158
  if (!retrainStats) {
127
- return testCase;
159
+ return;
128
160
  }
129
- return {
130
- ...testCase,
161
+ await this.uploader.modifyTestCase({
162
+ ...report,
131
163
  retrainStats,
132
- };
164
+ });
165
+ await this.rerun(report);
133
166
  }
134
167
  async uploadFinalReport(finalReport) {
135
168
  let success = true;
136
169
  try {
137
170
  const { projectId, runId } = await this.uploader.uploadRun(finalReport, this.runName);
138
- logReportLink(runId, projectId);
171
+ logReportLink(runId, projectId, finalReport.result);
139
172
  }
140
173
  catch (err) {
141
174
  this.log('Error uploading report\n');
@@ -164,6 +197,49 @@ class BVTAnalysisFormatter extends _1.default {
164
197
  }
165
198
  return await this.call_cucumber_client(failedTestCases, testCase);
166
199
  }
200
+ async rerun(report) {
201
+ await new Promise((resolve) => {
202
+ // Default to system Node.js
203
+ let node_path = process.argv.shift();
204
+ // Use bundled Node if running from recorder app on macOS or Windows
205
+ const isFromRecorderApp = process.env.FROM_RECORDER_APP === 'true';
206
+ const isSupportedPlatform = process.platform === 'darwin' || process.platform === 'win32';
207
+ if (isFromRecorderApp && isSupportedPlatform) {
208
+ node_path = process.execPath;
209
+ }
210
+ const args = [
211
+ path_1.default.join(process.cwd(), 'node_modules', '@dev-blinq', 'cucumber-js', 'bin', 'cucumber.js'),
212
+ '--name',
213
+ `^${report.scenarioName}$`,
214
+ '--exit',
215
+ '--format',
216
+ 'bvt',
217
+ '--run-name',
218
+ `${report.scenarioName}@debug`,
219
+ path_1.default.join(process.cwd(), report.uri),
220
+ ];
221
+ const envVars = {
222
+ ...process.env,
223
+ RERUN: JSON.stringify(this.failedStepsIndex),
224
+ };
225
+ // Inject Electron node env only if using bundled node
226
+ if (node_path === process.execPath) {
227
+ envVars.ELECTRON_RUN_AS_NODE = '1';
228
+ }
229
+ const cucumberClient = (0, child_process_1.spawn)(node_path, args, {
230
+ env: envVars,
231
+ });
232
+ cucumberClient.stdout.on('data', (data) => {
233
+ console.log(data.toString());
234
+ });
235
+ cucumberClient.stderr.on('data', (data) => {
236
+ console.error(data.toString());
237
+ });
238
+ cucumberClient.on('close', () => {
239
+ resolve();
240
+ });
241
+ });
242
+ }
167
243
  async call_cucumber_client(stepsToRetrain, testCase) {
168
244
  return new Promise((resolve, reject) => {
169
245
  const cucumber_client_path = path_1.default.resolve(process.cwd(), 'node_modules', '@dev-blinq', 'cucumber_client', 'bin', 'client', 'cucumber.js');
@@ -172,7 +248,7 @@ class BVTAnalysisFormatter extends _1.default {
172
248
  path_1.default.join(process.cwd(), testCase.uri),
173
249
  `${testCase.scenarioName}`,
174
250
  'undefined',
175
- `${stepsToRetrain.join(',')}`,
251
+ `${stepsToRetrain},`,
176
252
  ];
177
253
  if (process.env.BLINQ_ENV) {
178
254
  args.push(`--env=${process.env.BLINQ_ENV}`);
@@ -185,13 +261,24 @@ class BVTAnalysisFormatter extends _1.default {
185
261
  (0, tmp_1.tmpName)(async (err, name) => {
186
262
  const tempFile = path_1.default.join(this.getAppDataDir(), 'blinq.io', '.temp', path_1.default.basename(name));
187
263
  console.log('File path: ', tempFile);
264
+ if (!(0, fs_1.existsSync)(path_1.default.dirname(tempFile))) {
265
+ await (0, promises_1.mkdir)(path_1.default.dirname(tempFile), { recursive: true });
266
+ }
188
267
  await (0, promises_1.writeFile)(tempFile, '', 'utf-8');
189
268
  args.push(`--temp-file=${tempFile}`);
190
- const cucumberClient = (0, child_process_1.spawn)('node', [cucumber_client_path, ...args], {
191
- env: {
192
- ...process.env,
193
- TEMP_FILE_PATH: tempFile,
194
- },
269
+ // Determine node path
270
+ const isFromRecorderApp = process.env.FROM_RECORDER_APP === 'true';
271
+ const isSupportedPlatform = process.platform === 'darwin' || process.platform === 'win32';
272
+ const node_path = isFromRecorderApp && isSupportedPlatform ? process.execPath : 'node';
273
+ const envVars = {
274
+ ...process.env,
275
+ TEMP_FILE_PATH: tempFile,
276
+ };
277
+ if (node_path === process.execPath) {
278
+ envVars.ELECTRON_RUN_AS_NODE = '1';
279
+ }
280
+ const cucumberClient = (0, child_process_1.spawn)(node_path, [cucumber_client_path, ...args], {
281
+ env: envVars,
195
282
  });
196
283
  cucumberClient.stdout.on('data', (data) => {
197
284
  console.log(data.toString());
@@ -208,7 +295,16 @@ class BVTAnalysisFormatter extends _1.default {
208
295
  }
209
296
  else {
210
297
  this.log('Error retraining\n');
211
- resolve(null);
298
+ try {
299
+ const reportData = (0, fs_1.readFileSync)(tempFile, 'utf-8');
300
+ const retrainStats = JSON.parse(reportData);
301
+ await (0, promises_1.unlink)(tempFile);
302
+ resolve(retrainStats);
303
+ }
304
+ catch (e) {
305
+ this.log('Error reading scenario report\n ' + e);
306
+ resolve(null);
307
+ }
212
308
  }
213
309
  });
214
310
  });
@@ -234,7 +330,7 @@ class BVTAnalysisFormatter extends _1.default {
234
330
  }
235
331
  }
236
332
  exports.default = BVTAnalysisFormatter;
237
- function logReportLink(runId, projectId) {
333
+ function logReportLink(runId, projectId, status) {
238
334
  let reportLinkBaseUrl = 'https://app.blinq.io';
239
335
  if (process.env.NODE_ENV_BLINQ === 'local') {
240
336
  reportLinkBaseUrl = 'http://localhost:3000';
@@ -245,8 +341,30 @@ function logReportLink(runId, projectId) {
245
341
  else if (process.env.NODE_ENV_BLINQ === 'stage') {
246
342
  reportLinkBaseUrl = 'https://stage.app.blinq.io';
247
343
  }
344
+ else if (process.env.NODE_ENV_BLINQ === 'prod') {
345
+ reportLinkBaseUrl = 'https://app.blinq.io';
346
+ }
347
+ else if (!process.env.NODE_ENV_BLINQ) {
348
+ reportLinkBaseUrl = 'https://app.blinq.io';
349
+ }
350
+ else {
351
+ reportLinkBaseUrl = process.env.NODE_ENV_BLINQ.replace('api', 'app');
352
+ }
248
353
  const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`;
249
- console.log(`Report link: ${reportLink}\n`);
354
+ exports.globalReportLink = reportLink;
355
+ try {
356
+ publishReportLinkToGuacServer(reportLink, status.status === 'PASSED');
357
+ }
358
+ catch (err) {
359
+ // Error with events, ignoring
360
+ }
361
+ return reportLink;
250
362
  }
251
363
  exports.logReportLink = logReportLink;
364
+ function publishReportLinkToGuacServer(reportLink, result) {
365
+ if ((0, fs_1.existsSync)('/tmp/report_publish.sh')) {
366
+ const execAsync = (0, util_1.promisify)(child_process_2.exec);
367
+ execAsync('sh /tmp/report_publish.sh ' + reportLink + ' ' + result);
368
+ }
369
+ }
252
370
  //# sourceMappingURL=bvt_analysis_formatter.js.map