@qanalyzer/forge-commons 1.1.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 (122) hide show
  1. package/LICENSE +202 -0
  2. package/dist/ci/context.d.ts +6 -0
  3. package/dist/ci/context.js +71 -0
  4. package/dist/ci/frameworks/jest.d.ts +1 -0
  5. package/dist/ci/frameworks/jest.js +6 -0
  6. package/dist/ci/frameworks/reporter.d.ts +41 -0
  7. package/dist/ci/frameworks/reporter.js +184 -0
  8. package/dist/ci/frameworks/upload.d.ts +10 -0
  9. package/dist/ci/frameworks/upload.js +58 -0
  10. package/dist/ci/frameworks/vitest.d.ts +2 -0
  11. package/dist/ci/frameworks/vitest.js +10 -0
  12. package/dist/ci/generate-ci-template.d.ts +7 -0
  13. package/dist/ci/generate-ci-template.js +79 -0
  14. package/dist/ci/index.d.ts +7 -0
  15. package/dist/ci/index.js +36 -0
  16. package/dist/ci/templates/azure-devops.d.ts +5 -0
  17. package/dist/ci/templates/azure-devops.js +142 -0
  18. package/dist/ci/templates/bitbucket.d.ts +5 -0
  19. package/dist/ci/templates/bitbucket.js +113 -0
  20. package/dist/ci/templates/github.d.ts +6 -0
  21. package/dist/ci/templates/github.js +156 -0
  22. package/dist/ci/templates/gitlab.d.ts +5 -0
  23. package/dist/ci/templates/gitlab.js +124 -0
  24. package/dist/ci/templates/jenkins.d.ts +5 -0
  25. package/dist/ci/templates/jenkins.js +125 -0
  26. package/dist/ci/types.d.ts +58 -0
  27. package/dist/ci/types.js +16 -0
  28. package/dist/client/attach-client.d.ts +48 -0
  29. package/dist/client/attach-client.js +122 -0
  30. package/dist/client/index.d.ts +2 -0
  31. package/dist/client/index.js +8 -0
  32. package/dist/client/ingest-client.d.ts +19 -0
  33. package/dist/client/ingest-client.js +66 -0
  34. package/dist/config/config-loader.d.ts +8 -0
  35. package/dist/config/config-loader.js +62 -0
  36. package/dist/config/config-type.d.ts +24 -0
  37. package/dist/config/config-type.js +2 -0
  38. package/dist/config/index.d.ts +2 -0
  39. package/dist/config/index.js +6 -0
  40. package/dist/env/ci-environment.d.ts +10 -0
  41. package/dist/env/ci-environment.js +59 -0
  42. package/dist/env/env-enum.d.ts +21 -0
  43. package/dist/env/env-enum.js +27 -0
  44. package/dist/env/env-to-config.d.ts +3 -0
  45. package/dist/env/env-to-config.js +53 -0
  46. package/dist/env/index.d.ts +4 -0
  47. package/dist/env/index.js +11 -0
  48. package/dist/index.d.ts +12 -0
  49. package/dist/index.js +59 -0
  50. package/dist/models/attachment.d.ts +9 -0
  51. package/dist/models/attachment.js +2 -0
  52. package/dist/models/execution-sum.d.ts +7 -0
  53. package/dist/models/execution-sum.js +2 -0
  54. package/dist/models/host-data.d.ts +13 -0
  55. package/dist/models/host-data.js +2 -0
  56. package/dist/models/index.d.ts +14 -0
  57. package/dist/models/index.js +24 -0
  58. package/dist/models/ingest-payload.d.ts +56 -0
  59. package/dist/models/ingest-payload.js +56 -0
  60. package/dist/models/jest-vitest-report.d.ts +37 -0
  61. package/dist/models/jest-vitest-report.js +2 -0
  62. package/dist/models/meta-qa.d.ts +71 -0
  63. package/dist/models/meta-qa.js +257 -0
  64. package/dist/models/report.d.ts +15 -0
  65. package/dist/models/report.js +2 -0
  66. package/dist/models/short-result.d.ts +8 -0
  67. package/dist/models/short-result.js +2 -0
  68. package/dist/models/stats.d.ts +10 -0
  69. package/dist/models/stats.js +2 -0
  70. package/dist/models/step-data.d.ts +20 -0
  71. package/dist/models/step-data.js +2 -0
  72. package/dist/models/step-execution.d.ts +14 -0
  73. package/dist/models/step-execution.js +24 -0
  74. package/dist/models/test-execution.d.ts +18 -0
  75. package/dist/models/test-execution.js +30 -0
  76. package/dist/models/test-result.d.ts +34 -0
  77. package/dist/models/test-result.js +43 -0
  78. package/dist/models/test-step.d.ts +19 -0
  79. package/dist/models/test-step.js +46 -0
  80. package/dist/options/compose-options.d.ts +2 -0
  81. package/dist/options/compose-options.js +26 -0
  82. package/dist/options/index.d.ts +3 -0
  83. package/dist/options/index.js +7 -0
  84. package/dist/options/mode-enum.d.ts +5 -0
  85. package/dist/options/mode-enum.js +9 -0
  86. package/dist/options/options-type.d.ts +11 -0
  87. package/dist/options/options-type.js +2 -0
  88. package/dist/qanalyzer/index.d.ts +2 -0
  89. package/dist/qanalyzer/index.js +8 -0
  90. package/dist/qanalyzer/options-resolver.d.ts +11 -0
  91. package/dist/qanalyzer/options-resolver.js +31 -0
  92. package/dist/qanalyzer/reporter-factory.d.ts +11 -0
  93. package/dist/qanalyzer/reporter-factory.js +51 -0
  94. package/dist/qanalyzer.d.ts +29 -0
  95. package/dist/qanalyzer.js +96 -0
  96. package/dist/reporters/fallback-coordinator.d.ts +24 -0
  97. package/dist/reporters/fallback-coordinator.js +77 -0
  98. package/dist/reporters/file-reporter.d.ts +10 -0
  99. package/dist/reporters/file-reporter.js +16 -0
  100. package/dist/reporters/index.d.ts +4 -0
  101. package/dist/reporters/index.js +9 -0
  102. package/dist/reporters/ingest-reporter.d.ts +9 -0
  103. package/dist/reporters/ingest-reporter.js +14 -0
  104. package/dist/reporters/reporter-interface.d.ts +4 -0
  105. package/dist/reporters/reporter-interface.js +2 -0
  106. package/dist/utils/disabled-exception.d.ts +2 -0
  107. package/dist/utils/disabled-exception.js +6 -0
  108. package/dist/utils/index.d.ts +5 -0
  109. package/dist/utils/index.js +17 -0
  110. package/dist/utils/issue-keys.d.ts +7 -0
  111. package/dist/utils/issue-keys.js +33 -0
  112. package/dist/utils/logger.d.ts +12 -0
  113. package/dist/utils/logger.js +21 -0
  114. package/dist/utils/token-masker.d.ts +2 -0
  115. package/dist/utils/token-masker.js +17 -0
  116. package/dist/utils/upload-attachment.d.ts +35 -0
  117. package/dist/utils/upload-attachment.js +158 -0
  118. package/dist/writer/fs-writer.d.ts +9 -0
  119. package/dist/writer/fs-writer.js +19 -0
  120. package/dist/writer/index.d.ts +1 -0
  121. package/dist/writer/index.js +5 -0
  122. package/package.json +34 -0
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listCiTemplateVariants = listCiTemplateVariants;
4
+ exports.generateCiTemplate = generateCiTemplate;
5
+ const context_1 = require("./context");
6
+ const azure_devops_1 = require("./templates/azure-devops");
7
+ const bitbucket_1 = require("./templates/bitbucket");
8
+ const github_1 = require("./templates/github");
9
+ const gitlab_1 = require("./templates/gitlab");
10
+ const jenkins_1 = require("./templates/jenkins");
11
+ const types_1 = require("./types");
12
+ const PLATFORMS = [
13
+ 'github',
14
+ 'gitlab',
15
+ 'azure-devops',
16
+ 'jenkins',
17
+ 'bitbucket',
18
+ ];
19
+ const UPLOAD_FRAMEWORKS = ['vitest', 'jest', 'playwright'];
20
+ const REPORTER_FRAMEWORKS = [
21
+ 'vitest',
22
+ 'jest',
23
+ 'mocha',
24
+ 'cucumberjs',
25
+ 'cypress',
26
+ 'playwright',
27
+ 'wdio',
28
+ ];
29
+ /**
30
+ * Upload path: Vitest, Jest, Playwright (JSON + @qanalyzer/forge-api-client).
31
+ * Reporter path: Vitest, Jest, Mocha, CucumberJS, Cypress, Playwright, WebdriverIO.
32
+ * Mocha / CucumberJS / Cypress / WDIO have no upload JSON dual-path — use mode=file via reporter instead.
33
+ */
34
+ const SUPPORTED_VARIANTS = [
35
+ ...PLATFORMS.flatMap((platform) => UPLOAD_FRAMEWORKS.map((framework) => ({
36
+ platform,
37
+ framework,
38
+ ingestPath: 'upload',
39
+ }))),
40
+ ...PLATFORMS.flatMap((platform) => REPORTER_FRAMEWORKS.map((framework) => ({
41
+ platform,
42
+ framework,
43
+ ingestPath: 'reporter',
44
+ }))),
45
+ ];
46
+ function isSupported(ctx) {
47
+ return SUPPORTED_VARIANTS.some((v) => v.platform === ctx.platform &&
48
+ v.framework === ctx.framework &&
49
+ v.ingestPath === ctx.ingestPath);
50
+ }
51
+ function listCiTemplateVariants() {
52
+ return [...SUPPORTED_VARIANTS];
53
+ }
54
+ /**
55
+ * Generate a CI YAML (or equivalent) snippet for the given context.
56
+ * Accepts a partial context — fills platform defaults via buildCiTemplateContext.
57
+ */
58
+ function generateCiTemplate(input) {
59
+ const ctx = (0, context_1.buildCiTemplateContext)(input);
60
+ if (!isSupported(ctx)) {
61
+ throw new types_1.UnsupportedVariantError(ctx.platform, ctx.framework, ctx.ingestPath);
62
+ }
63
+ switch (ctx.platform) {
64
+ case 'github':
65
+ return (0, github_1.renderGithubUpload)(ctx);
66
+ case 'gitlab':
67
+ return (0, gitlab_1.renderGitlabUpload)(ctx);
68
+ case 'azure-devops':
69
+ return (0, azure_devops_1.renderAzureDevOpsUpload)(ctx);
70
+ case 'jenkins':
71
+ return (0, jenkins_1.renderJenkinsUpload)(ctx);
72
+ case 'bitbucket':
73
+ return (0, bitbucket_1.renderBitbucketUpload)(ctx);
74
+ default: {
75
+ const _exhaustive = ctx.platform;
76
+ throw new types_1.UnsupportedVariantError(_exhaustive, ctx.framework, ctx.ingestPath);
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,7 @@
1
+ export { buildCiTemplateContext, } from './context';
2
+ export { generateCiTemplate, listCiTemplateVariants, } from './generate-ci-template';
3
+ export { jestJsonRun, } from './frameworks/jest';
4
+ export { vitestJsonRun, vitestReporterEnv, } from './frameworks/vitest';
5
+ export { vitestReporterRun, jestReporterRun, cypressReporterRun, playwrightReporterRun, wdioReporterRun, mochaReporterRun, cucumberjsReporterRun, frameworkReporterRun, reporterPackageName, reporterFrameworkLabel, reporterConfigHint, reporterIngestEnvLines, planCiVariableHints, versionTagCiVariableHints, assertReporterFramework, } from './frameworks/reporter';
6
+ export { frameworkLabel, frameworkTestCommand, indentUploadCli, uploadCliCommand, } from './frameworks/upload';
7
+ export { UnsupportedVariantError, type CiFramework, type CiIngestPath, type CiPlatform, type CiSecretHint, type CiTemplateContext, type CiTemplatePartial, type CiTemplateResult, type CiTemplateVariant, type CiVariableHint, } from './types';
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnsupportedVariantError = exports.uploadCliCommand = exports.indentUploadCli = exports.frameworkTestCommand = exports.frameworkLabel = exports.assertReporterFramework = exports.versionTagCiVariableHints = exports.planCiVariableHints = exports.reporterIngestEnvLines = exports.reporterConfigHint = exports.reporterFrameworkLabel = exports.reporterPackageName = exports.frameworkReporterRun = exports.cucumberjsReporterRun = exports.mochaReporterRun = exports.wdioReporterRun = exports.playwrightReporterRun = exports.cypressReporterRun = exports.jestReporterRun = exports.vitestReporterRun = exports.vitestReporterEnv = exports.vitestJsonRun = exports.jestJsonRun = exports.listCiTemplateVariants = exports.generateCiTemplate = exports.buildCiTemplateContext = void 0;
4
+ var context_1 = require("./context");
5
+ Object.defineProperty(exports, "buildCiTemplateContext", { enumerable: true, get: function () { return context_1.buildCiTemplateContext; } });
6
+ var generate_ci_template_1 = require("./generate-ci-template");
7
+ Object.defineProperty(exports, "generateCiTemplate", { enumerable: true, get: function () { return generate_ci_template_1.generateCiTemplate; } });
8
+ Object.defineProperty(exports, "listCiTemplateVariants", { enumerable: true, get: function () { return generate_ci_template_1.listCiTemplateVariants; } });
9
+ var jest_1 = require("./frameworks/jest");
10
+ Object.defineProperty(exports, "jestJsonRun", { enumerable: true, get: function () { return jest_1.jestJsonRun; } });
11
+ var vitest_1 = require("./frameworks/vitest");
12
+ Object.defineProperty(exports, "vitestJsonRun", { enumerable: true, get: function () { return vitest_1.vitestJsonRun; } });
13
+ Object.defineProperty(exports, "vitestReporterEnv", { enumerable: true, get: function () { return vitest_1.vitestReporterEnv; } });
14
+ var reporter_1 = require("./frameworks/reporter");
15
+ Object.defineProperty(exports, "vitestReporterRun", { enumerable: true, get: function () { return reporter_1.vitestReporterRun; } });
16
+ Object.defineProperty(exports, "jestReporterRun", { enumerable: true, get: function () { return reporter_1.jestReporterRun; } });
17
+ Object.defineProperty(exports, "cypressReporterRun", { enumerable: true, get: function () { return reporter_1.cypressReporterRun; } });
18
+ Object.defineProperty(exports, "playwrightReporterRun", { enumerable: true, get: function () { return reporter_1.playwrightReporterRun; } });
19
+ Object.defineProperty(exports, "wdioReporterRun", { enumerable: true, get: function () { return reporter_1.wdioReporterRun; } });
20
+ Object.defineProperty(exports, "mochaReporterRun", { enumerable: true, get: function () { return reporter_1.mochaReporterRun; } });
21
+ Object.defineProperty(exports, "cucumberjsReporterRun", { enumerable: true, get: function () { return reporter_1.cucumberjsReporterRun; } });
22
+ Object.defineProperty(exports, "frameworkReporterRun", { enumerable: true, get: function () { return reporter_1.frameworkReporterRun; } });
23
+ Object.defineProperty(exports, "reporterPackageName", { enumerable: true, get: function () { return reporter_1.reporterPackageName; } });
24
+ Object.defineProperty(exports, "reporterFrameworkLabel", { enumerable: true, get: function () { return reporter_1.reporterFrameworkLabel; } });
25
+ Object.defineProperty(exports, "reporterConfigHint", { enumerable: true, get: function () { return reporter_1.reporterConfigHint; } });
26
+ Object.defineProperty(exports, "reporterIngestEnvLines", { enumerable: true, get: function () { return reporter_1.reporterIngestEnvLines; } });
27
+ Object.defineProperty(exports, "planCiVariableHints", { enumerable: true, get: function () { return reporter_1.planCiVariableHints; } });
28
+ Object.defineProperty(exports, "versionTagCiVariableHints", { enumerable: true, get: function () { return reporter_1.versionTagCiVariableHints; } });
29
+ Object.defineProperty(exports, "assertReporterFramework", { enumerable: true, get: function () { return reporter_1.assertReporterFramework; } });
30
+ var upload_1 = require("./frameworks/upload");
31
+ Object.defineProperty(exports, "frameworkLabel", { enumerable: true, get: function () { return upload_1.frameworkLabel; } });
32
+ Object.defineProperty(exports, "frameworkTestCommand", { enumerable: true, get: function () { return upload_1.frameworkTestCommand; } });
33
+ Object.defineProperty(exports, "indentUploadCli", { enumerable: true, get: function () { return upload_1.indentUploadCli; } });
34
+ Object.defineProperty(exports, "uploadCliCommand", { enumerable: true, get: function () { return upload_1.uploadCliCommand; } });
35
+ var types_1 = require("./types");
36
+ Object.defineProperty(exports, "UnsupportedVariantError", { enumerable: true, get: function () { return types_1.UnsupportedVariantError; } });
@@ -0,0 +1,5 @@
1
+ import type { CiTemplateContext, CiTemplateResult } from '../types';
2
+ /**
3
+ * Azure DevOps — upload path or @qanalyzer/forge-vitest / @qanalyzer/forge-jest reporter path.
4
+ */
5
+ export declare function renderAzureDevOpsUpload(ctx: CiTemplateContext): CiTemplateResult;
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderAzureDevOpsUpload = renderAzureDevOpsUpload;
4
+ const upload_1 = require("../frameworks/upload");
5
+ const reporter_1 = require("../frameworks/reporter");
6
+ const types_1 = require("../types");
7
+ function azurePreRunScripts(ctx) {
8
+ return (0, reporter_1.reporterPreRunScripts)(ctx)
9
+ .map((cmd) => ` - script: ${cmd}
10
+ displayName: Install Playwright browsers
11
+ `)
12
+ .join('');
13
+ }
14
+ function azureSecrets() {
15
+ return [
16
+ {
17
+ name: 'QANALYZER_INGEST_URL',
18
+ description: 'Forge web trigger URL (launch ingest + binary attach / screenshots / qa.attach)',
19
+ platformHint: 'Pipelines → Library → Variable group `qanalyzer-secrets` (mark as secret)',
20
+ },
21
+ {
22
+ name: 'QANALYZER_INGEST_TOKEN',
23
+ description: 'Bearer token from QAnalyzer configure page (shown once)',
24
+ platformHint: 'Pipelines → Library → Variable group `qanalyzer-secrets` (mark as secret)',
25
+ },
26
+ ];
27
+ }
28
+ function azureVariables() {
29
+ return [
30
+ {
31
+ name: 'JiraProjectKey',
32
+ description: 'Jira project key allowlisted in QAnalyzer (e.g. AUTH)',
33
+ platformHint: 'Pipeline variable or entry in variable group `qanalyzer-secrets`',
34
+ },
35
+ ];
36
+ }
37
+ function renderAzureReporter(ctx) {
38
+ (0, reporter_1.assertReporterFramework)(ctx);
39
+ const nodeVersion = ctx.nodeVersion ?? '22';
40
+ const urlExpr = ctx.ingestUrlExpr ?? `$(${ctx.ingestUrlSecret})`;
41
+ const tokenExpr = ctx.ingestTokenExpr ?? `$(${ctx.ingestTokenSecret})`;
42
+ const label = (0, reporter_1.reporterFrameworkLabel)(ctx);
43
+ const pkg = (0, reporter_1.reporterPackageName)(ctx);
44
+ const configHint = (0, reporter_1.reporterConfigHint)(ctx);
45
+ const content = `# QAnalyzer fragment — ${label} ${pkg} reporter path
46
+ # Requires ${pkg} in package.json and ${configHint}
47
+ trigger:
48
+ - main
49
+
50
+ pool:
51
+ vmImage: ubuntu-latest
52
+
53
+ variables:
54
+ - group: qanalyzer-secrets
55
+ - name: JiraProjectKey
56
+ value: ${ctx.projectKey}
57
+
58
+ steps:
59
+ - task: NodeTool@0
60
+ inputs:
61
+ versionSpec: '${nodeVersion}.x'
62
+ displayName: Use Node.js ${nodeVersion}
63
+
64
+ - script: npm ci
65
+ displayName: Install dependencies
66
+
67
+ ${azurePreRunScripts(ctx)} - script: ${(0, reporter_1.frameworkReporterRun)(ctx)}
68
+ displayName: Run ${label} with QAnalyzer reporter
69
+ env:
70
+ QANALYZER_MODE: ingest
71
+ QANALYZER_INGEST_URL: ${urlExpr}
72
+ QANALYZER_INGEST_TOKEN: ${tokenExpr}
73
+ QANALYZER_PROJECT_KEY: $(JiraProjectKey)
74
+ `;
75
+ return {
76
+ platform: 'azure-devops',
77
+ framework: ctx.framework,
78
+ ingestPath: 'reporter',
79
+ filename: 'azure-pipelines.yml',
80
+ content,
81
+ secretsSetup: azureSecrets(),
82
+ variablesSetup: [...azureVariables(), ...(0, reporter_1.planCiVariableHints)(), ...(0, reporter_1.versionTagCiVariableHints)()],
83
+ };
84
+ }
85
+ /**
86
+ * Azure DevOps — upload path or @qanalyzer/forge-vitest / @qanalyzer/forge-jest reporter path.
87
+ */
88
+ function renderAzureDevOpsUpload(ctx) {
89
+ if (ctx.ingestPath === 'reporter') {
90
+ return renderAzureReporter(ctx);
91
+ }
92
+ if (ctx.ingestPath !== 'upload') {
93
+ throw new types_1.UnsupportedVariantError(ctx.platform, ctx.framework, ctx.ingestPath);
94
+ }
95
+ const nodeVersion = ctx.nodeVersion ?? '22';
96
+ const testCmd = (0, upload_1.frameworkTestCommand)(ctx);
97
+ const label = (0, upload_1.frameworkLabel)(ctx);
98
+ const uploadBlock = (0, upload_1.indentUploadCli)(ctx, 6);
99
+ const urlExpr = ctx.ingestUrlExpr ?? `$(${ctx.ingestUrlSecret})`;
100
+ const tokenExpr = ctx.ingestTokenExpr ?? `$(${ctx.ingestTokenSecret})`;
101
+ const content = `# QAnalyzer fragment — ${label} upload path
102
+ trigger:
103
+ - main
104
+
105
+ pool:
106
+ vmImage: ubuntu-latest
107
+
108
+ variables:
109
+ - group: qanalyzer-secrets # QANALYZER_INGEST_URL, QANALYZER_INGEST_TOKEN
110
+ - name: JiraProjectKey
111
+ value: ${ctx.projectKey}
112
+
113
+ steps:
114
+ - task: NodeTool@0
115
+ inputs:
116
+ versionSpec: '${nodeVersion}.x'
117
+ displayName: Use Node.js ${nodeVersion}
118
+
119
+ - script: npm ci
120
+ displayName: Install dependencies
121
+
122
+ ${azurePreRunScripts(ctx)} - script: ${testCmd}
123
+ displayName: Run ${label}
124
+
125
+ - script: |
126
+ ${uploadBlock}
127
+ displayName: Upload to QAnalyzer
128
+ condition: always()
129
+ env:
130
+ QANALYZER_INGEST_URL: ${urlExpr}
131
+ QANALYZER_INGEST_TOKEN: ${tokenExpr}
132
+ `;
133
+ return {
134
+ platform: 'azure-devops',
135
+ framework: ctx.framework,
136
+ ingestPath: 'upload',
137
+ filename: 'azure-pipelines.yml',
138
+ content,
139
+ secretsSetup: azureSecrets(),
140
+ variablesSetup: [...azureVariables(), ...(0, reporter_1.planCiVariableHints)(), ...(0, reporter_1.versionTagCiVariableHints)()],
141
+ };
142
+ }
@@ -0,0 +1,5 @@
1
+ import type { CiTemplateContext, CiTemplateResult } from '../types';
2
+ /**
3
+ * Bitbucket Pipelines — upload path or @qanalyzer/forge-vitest / @qanalyzer/forge-jest reporter path.
4
+ */
5
+ export declare function renderBitbucketUpload(ctx: CiTemplateContext): CiTemplateResult;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderBitbucketUpload = renderBitbucketUpload;
4
+ const upload_1 = require("../frameworks/upload");
5
+ const reporter_1 = require("../frameworks/reporter");
6
+ const types_1 = require("../types");
7
+ function bitbucketScriptLines(ctx, ...cmds) {
8
+ return [...(0, reporter_1.reporterPreRunScripts)(ctx), ...cmds]
9
+ .map((c) => ` - ${c}`)
10
+ .join('\n');
11
+ }
12
+ function bitbucketSecrets() {
13
+ return [
14
+ {
15
+ name: 'QANALYZER_INGEST_URL',
16
+ description: 'Forge web trigger URL (launch ingest + binary attach / screenshots / qa.attach)',
17
+ platformHint: 'Repository settings → Pipelines → Repository variables (Secured)',
18
+ },
19
+ {
20
+ name: 'QANALYZER_INGEST_TOKEN',
21
+ description: 'Bearer token from QAnalyzer configure page (shown once)',
22
+ platformHint: 'Repository settings → Pipelines → Repository variables (Secured)',
23
+ },
24
+ ];
25
+ }
26
+ function bitbucketVariables() {
27
+ return [
28
+ {
29
+ name: 'JIRA_PROJECT_KEY',
30
+ description: 'Jira project key allowlisted in QAnalyzer (e.g. AUTH)',
31
+ platformHint: 'Repository settings → Pipelines → Repository variables',
32
+ },
33
+ ];
34
+ }
35
+ function renderBitbucketReporter(ctx) {
36
+ (0, reporter_1.assertReporterFramework)(ctx);
37
+ const nodeVersion = ctx.nodeVersion ?? '22';
38
+ const label = (0, reporter_1.reporterFrameworkLabel)(ctx);
39
+ const pkg = (0, reporter_1.reporterPackageName)(ctx);
40
+ const configHint = (0, reporter_1.reporterConfigHint)(ctx);
41
+ const content = `# QAnalyzer fragment — ${label} ${pkg} reporter path
42
+ # Requires ${pkg} in package.json and ${configHint}
43
+ # Set secured vars QANALYZER_INGEST_URL / QANALYZER_INGEST_TOKEN
44
+ image: node:${nodeVersion}
45
+
46
+ pipelines:
47
+ default:
48
+ - step:
49
+ name: Test with QAnalyzer
50
+ caches:
51
+ - node
52
+ script:
53
+ - export QANALYZER_MODE=ingest
54
+ - export QANALYZER_PROJECT_KEY=$JIRA_PROJECT_KEY
55
+ - npm ci
56
+ ${bitbucketScriptLines(ctx, (0, reporter_1.frameworkReporterRun)(ctx))}
57
+ `;
58
+ return {
59
+ platform: 'bitbucket',
60
+ framework: ctx.framework,
61
+ ingestPath: 'reporter',
62
+ filename: 'bitbucket-pipelines.yml',
63
+ content,
64
+ secretsSetup: bitbucketSecrets(),
65
+ variablesSetup: [...bitbucketVariables(), ...(0, reporter_1.planCiVariableHints)(), ...(0, reporter_1.versionTagCiVariableHints)()],
66
+ };
67
+ }
68
+ /**
69
+ * Bitbucket Pipelines — upload path or @qanalyzer/forge-vitest / @qanalyzer/forge-jest reporter path.
70
+ */
71
+ function renderBitbucketUpload(ctx) {
72
+ if (ctx.ingestPath === 'reporter') {
73
+ return renderBitbucketReporter(ctx);
74
+ }
75
+ if (ctx.ingestPath !== 'upload') {
76
+ throw new types_1.UnsupportedVariantError(ctx.platform, ctx.framework, ctx.ingestPath);
77
+ }
78
+ const nodeVersion = ctx.nodeVersion ?? '22';
79
+ const reportFile = ctx.reportFile ?? 'qanalyzer-results.json';
80
+ const testCmd = (0, upload_1.frameworkTestCommand)(ctx);
81
+ const label = (0, upload_1.frameworkLabel)(ctx);
82
+ const uploadBlock = (0, upload_1.indentUploadCli)(ctx, 12);
83
+ const content = `# QAnalyzer fragment — merge into your bitbucket-pipelines.yml
84
+ # ${label} upload path — set secured vars QANALYZER_INGEST_URL / QANALYZER_INGEST_TOKEN
85
+ image: node:${nodeVersion}
86
+
87
+ pipelines:
88
+ default:
89
+ - step:
90
+ name: Test
91
+ caches:
92
+ - node
93
+ script:
94
+ - npm ci
95
+ ${bitbucketScriptLines(ctx, testCmd)}
96
+ artifacts:
97
+ - ${reportFile}
98
+ - step:
99
+ name: Upload QAnalyzer
100
+ script:
101
+ - |
102
+ ${uploadBlock}
103
+ `;
104
+ return {
105
+ platform: 'bitbucket',
106
+ framework: ctx.framework,
107
+ ingestPath: 'upload',
108
+ filename: 'bitbucket-pipelines.yml',
109
+ content,
110
+ secretsSetup: bitbucketSecrets(),
111
+ variablesSetup: [...bitbucketVariables(), ...(0, reporter_1.planCiVariableHints)(), ...(0, reporter_1.versionTagCiVariableHints)()],
112
+ };
113
+ }
@@ -0,0 +1,6 @@
1
+ import type { CiTemplateContext, CiTemplateResult } from '../types';
2
+ /**
3
+ * GitHub Actions — upload (Vitest/Jest/Playwright) or reporter
4
+ * (@qanalyzer/forge-vitest / @qanalyzer/forge-jest / @qanalyzer/forge-mocha / @qanalyzer/forge-cucumberjs / @qanalyzer/forge-cypress / @qanalyzer/forge-playwright / @qanalyzer/forge-wdio).
5
+ */
6
+ export declare function renderGithubUpload(ctx: CiTemplateContext): CiTemplateResult;
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderGithubUpload = renderGithubUpload;
4
+ const upload_1 = require("../frameworks/upload");
5
+ const reporter_1 = require("../frameworks/reporter");
6
+ const types_1 = require("../types");
7
+ function githubPreRunSteps(ctx) {
8
+ return (0, reporter_1.reporterPreRunScripts)(ctx)
9
+ .map((cmd) => ` - run: ${cmd}`)
10
+ .join('\n');
11
+ }
12
+ function githubSecrets() {
13
+ return [
14
+ {
15
+ name: 'QANALYZER_INGEST_URL',
16
+ description: 'Forge web trigger URL (launch ingest + binary attach / screenshots / qa.attach)',
17
+ platformHint: 'Repository → Settings → Secrets and variables → Actions → New repository secret',
18
+ },
19
+ {
20
+ name: 'QANALYZER_INGEST_TOKEN',
21
+ description: 'Bearer token from QAnalyzer configure page (shown once)',
22
+ platformHint: 'Repository → Settings → Secrets and variables → Actions → New repository secret',
23
+ },
24
+ ];
25
+ }
26
+ function githubVariables() {
27
+ return [
28
+ {
29
+ name: 'JIRA_PROJECT_KEY',
30
+ description: 'Jira project key allowlisted in QAnalyzer (e.g. AUTH)',
31
+ platformHint: 'Repository → Settings → Secrets and variables → Actions → Variables',
32
+ },
33
+ ];
34
+ }
35
+ function githubFilename(framework, ingestPath) {
36
+ const suffix = ingestPath === 'reporter' ? '-reporter' : '';
37
+ return `.github/workflows/qanalyzer-${framework}${suffix}.yml`;
38
+ }
39
+ function renderGithubReporter(ctx) {
40
+ (0, reporter_1.assertReporterFramework)(ctx);
41
+ const nodeVersion = ctx.nodeVersion ?? '22';
42
+ const env = (0, reporter_1.reporterIngestEnvLines)(ctx);
43
+ const urlExpr = ctx.ingestUrlExpr ?? `\${{ secrets.${ctx.ingestUrlSecret} }}`;
44
+ const tokenExpr = ctx.ingestTokenExpr ?? `\${{ secrets.${ctx.ingestTokenSecret} }}`;
45
+ const projectExpr = ctx.projectKeyExpr ?? `\${{ vars.JIRA_PROJECT_KEY }}`;
46
+ const label = (0, reporter_1.reporterFrameworkLabel)(ctx);
47
+ const pkg = (0, reporter_1.reporterPackageName)(ctx);
48
+ const configHint = (0, reporter_1.reporterConfigHint)(ctx);
49
+ const preRun = githubPreRunSteps(ctx);
50
+ const content = `name: QAnalyzer ${label} (${pkg})
51
+
52
+ # Requires ${pkg} in package.json and ${configHint}
53
+ on:
54
+ push:
55
+ branches: [main]
56
+ pull_request:
57
+
58
+ jobs:
59
+ test:
60
+ runs-on: ubuntu-latest
61
+ steps:
62
+ - uses: actions/checkout@v4
63
+ - uses: actions/setup-node@v4
64
+ with:
65
+ node-version: "${nodeVersion}"
66
+ cache: npm
67
+ - run: npm ci
68
+ ${preRun ? `${preRun}\n` : ''} - name: Run ${label} with QAnalyzer reporter
69
+ env:
70
+ QANALYZER_MODE: ${env.mode}
71
+ QANALYZER_INGEST_URL: ${urlExpr}
72
+ QANALYZER_INGEST_TOKEN: ${tokenExpr}
73
+ QANALYZER_PROJECT_KEY: ${projectExpr}
74
+ QANALYZER_LAUNCH_NAME: \${{ github.workflow }} #\${{ github.run_number }}
75
+ # Optional Test Plan (FR158): QANALYZER_PLAN_NAME / QANALYZER_PLAN_ID / QANALYZER_PLAN_KEY
76
+ # QANALYZER_PLAN_NAME: Smoke
77
+ # Optional tags (FR21): QANALYZER_FIX_VERSION / QANALYZER_SPRINT
78
+ # QANALYZER_FIX_VERSION: 2.4.0
79
+ # QANALYZER_SPRINT: Sprint 42
80
+ run: ${(0, reporter_1.frameworkReporterRun)(ctx)}
81
+ `;
82
+ return {
83
+ platform: 'github',
84
+ framework: ctx.framework,
85
+ ingestPath: 'reporter',
86
+ filename: githubFilename(ctx.framework, 'reporter'),
87
+ content,
88
+ secretsSetup: githubSecrets(),
89
+ variablesSetup: [...githubVariables(), ...(0, reporter_1.planCiVariableHints)(), ...(0, reporter_1.versionTagCiVariableHints)()],
90
+ };
91
+ }
92
+ /**
93
+ * GitHub Actions — upload (Vitest/Jest/Playwright) or reporter
94
+ * (@qanalyzer/forge-vitest / @qanalyzer/forge-jest / @qanalyzer/forge-mocha / @qanalyzer/forge-cucumberjs / @qanalyzer/forge-cypress / @qanalyzer/forge-playwright / @qanalyzer/forge-wdio).
95
+ */
96
+ function renderGithubUpload(ctx) {
97
+ if (ctx.ingestPath === 'reporter') {
98
+ return renderGithubReporter(ctx);
99
+ }
100
+ if (ctx.ingestPath !== 'upload') {
101
+ throw new types_1.UnsupportedVariantError(ctx.platform, ctx.framework, ctx.ingestPath);
102
+ }
103
+ if (ctx.framework === 'mocha' ||
104
+ ctx.framework === 'cucumberjs' ||
105
+ ctx.framework === 'cypress' ||
106
+ ctx.framework === 'wdio') {
107
+ throw new types_1.UnsupportedVariantError(ctx.platform, ctx.framework, ctx.ingestPath);
108
+ }
109
+ const nodeVersion = ctx.nodeVersion ?? '22';
110
+ const testCmd = (0, upload_1.frameworkTestCommand)(ctx);
111
+ const uploadCmd = (0, upload_1.uploadCliCommand)(ctx);
112
+ const urlExpr = ctx.ingestUrlExpr ?? `\${{ secrets.${ctx.ingestUrlSecret} }}`;
113
+ const tokenExpr = ctx.ingestTokenExpr ?? `\${{ secrets.${ctx.ingestTokenSecret} }}`;
114
+ const label = (0, upload_1.frameworkLabel)(ctx);
115
+ const preRun = githubPreRunSteps(ctx);
116
+ const testStep = ctx.includeTestStep === false
117
+ ? ''
118
+ : ` - run: ${testCmd}\n`;
119
+ const uploadStep = ctx.includeUploadStep === false
120
+ ? ''
121
+ : ` - name: Upload to QAnalyzer
122
+ if: always()
123
+ env:
124
+ QANALYZER_INGEST_URL: ${urlExpr}
125
+ QANALYZER_INGEST_TOKEN: ${tokenExpr}
126
+ run: |
127
+ ${uploadCmd.split('\n').join('\n ')}
128
+ `;
129
+ const content = `name: QAnalyzer ${label}
130
+
131
+ on:
132
+ push:
133
+ branches: [main]
134
+ pull_request:
135
+
136
+ jobs:
137
+ test:
138
+ runs-on: ubuntu-latest
139
+ steps:
140
+ - uses: actions/checkout@v4
141
+ - uses: actions/setup-node@v4
142
+ with:
143
+ node-version: "${nodeVersion}"
144
+ cache: npm
145
+ - run: npm ci
146
+ ${preRun ? `${preRun}\n` : ''}${testStep}${uploadStep}`;
147
+ return {
148
+ platform: 'github',
149
+ framework: ctx.framework,
150
+ ingestPath: 'upload',
151
+ filename: githubFilename(ctx.framework, 'upload'),
152
+ content,
153
+ secretsSetup: githubSecrets(),
154
+ variablesSetup: [...githubVariables(), ...(0, reporter_1.planCiVariableHints)(), ...(0, reporter_1.versionTagCiVariableHints)()],
155
+ };
156
+ }
@@ -0,0 +1,5 @@
1
+ import type { CiTemplateContext, CiTemplateResult } from '../types';
2
+ /**
3
+ * GitLab CI — upload path or @qanalyzer/forge-vitest / @qanalyzer/forge-jest reporter path.
4
+ */
5
+ export declare function renderGitlabUpload(ctx: CiTemplateContext): CiTemplateResult;