@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.
- package/LICENSE +202 -0
- package/dist/ci/context.d.ts +6 -0
- package/dist/ci/context.js +71 -0
- package/dist/ci/frameworks/jest.d.ts +1 -0
- package/dist/ci/frameworks/jest.js +6 -0
- package/dist/ci/frameworks/reporter.d.ts +41 -0
- package/dist/ci/frameworks/reporter.js +184 -0
- package/dist/ci/frameworks/upload.d.ts +10 -0
- package/dist/ci/frameworks/upload.js +58 -0
- package/dist/ci/frameworks/vitest.d.ts +2 -0
- package/dist/ci/frameworks/vitest.js +10 -0
- package/dist/ci/generate-ci-template.d.ts +7 -0
- package/dist/ci/generate-ci-template.js +79 -0
- package/dist/ci/index.d.ts +7 -0
- package/dist/ci/index.js +36 -0
- package/dist/ci/templates/azure-devops.d.ts +5 -0
- package/dist/ci/templates/azure-devops.js +142 -0
- package/dist/ci/templates/bitbucket.d.ts +5 -0
- package/dist/ci/templates/bitbucket.js +113 -0
- package/dist/ci/templates/github.d.ts +6 -0
- package/dist/ci/templates/github.js +156 -0
- package/dist/ci/templates/gitlab.d.ts +5 -0
- package/dist/ci/templates/gitlab.js +124 -0
- package/dist/ci/templates/jenkins.d.ts +5 -0
- package/dist/ci/templates/jenkins.js +125 -0
- package/dist/ci/types.d.ts +58 -0
- package/dist/ci/types.js +16 -0
- package/dist/client/attach-client.d.ts +48 -0
- package/dist/client/attach-client.js +122 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +8 -0
- package/dist/client/ingest-client.d.ts +19 -0
- package/dist/client/ingest-client.js +66 -0
- package/dist/config/config-loader.d.ts +8 -0
- package/dist/config/config-loader.js +62 -0
- package/dist/config/config-type.d.ts +24 -0
- package/dist/config/config-type.js +2 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +6 -0
- package/dist/env/ci-environment.d.ts +10 -0
- package/dist/env/ci-environment.js +59 -0
- package/dist/env/env-enum.d.ts +21 -0
- package/dist/env/env-enum.js +27 -0
- package/dist/env/env-to-config.d.ts +3 -0
- package/dist/env/env-to-config.js +53 -0
- package/dist/env/index.d.ts +4 -0
- package/dist/env/index.js +11 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +59 -0
- package/dist/models/attachment.d.ts +9 -0
- package/dist/models/attachment.js +2 -0
- package/dist/models/execution-sum.d.ts +7 -0
- package/dist/models/execution-sum.js +2 -0
- package/dist/models/host-data.d.ts +13 -0
- package/dist/models/host-data.js +2 -0
- package/dist/models/index.d.ts +14 -0
- package/dist/models/index.js +24 -0
- package/dist/models/ingest-payload.d.ts +56 -0
- package/dist/models/ingest-payload.js +56 -0
- package/dist/models/jest-vitest-report.d.ts +37 -0
- package/dist/models/jest-vitest-report.js +2 -0
- package/dist/models/meta-qa.d.ts +71 -0
- package/dist/models/meta-qa.js +257 -0
- package/dist/models/report.d.ts +15 -0
- package/dist/models/report.js +2 -0
- package/dist/models/short-result.d.ts +8 -0
- package/dist/models/short-result.js +2 -0
- package/dist/models/stats.d.ts +10 -0
- package/dist/models/stats.js +2 -0
- package/dist/models/step-data.d.ts +20 -0
- package/dist/models/step-data.js +2 -0
- package/dist/models/step-execution.d.ts +14 -0
- package/dist/models/step-execution.js +24 -0
- package/dist/models/test-execution.d.ts +18 -0
- package/dist/models/test-execution.js +30 -0
- package/dist/models/test-result.d.ts +34 -0
- package/dist/models/test-result.js +43 -0
- package/dist/models/test-step.d.ts +19 -0
- package/dist/models/test-step.js +46 -0
- package/dist/options/compose-options.d.ts +2 -0
- package/dist/options/compose-options.js +26 -0
- package/dist/options/index.d.ts +3 -0
- package/dist/options/index.js +7 -0
- package/dist/options/mode-enum.d.ts +5 -0
- package/dist/options/mode-enum.js +9 -0
- package/dist/options/options-type.d.ts +11 -0
- package/dist/options/options-type.js +2 -0
- package/dist/qanalyzer/index.d.ts +2 -0
- package/dist/qanalyzer/index.js +8 -0
- package/dist/qanalyzer/options-resolver.d.ts +11 -0
- package/dist/qanalyzer/options-resolver.js +31 -0
- package/dist/qanalyzer/reporter-factory.d.ts +11 -0
- package/dist/qanalyzer/reporter-factory.js +51 -0
- package/dist/qanalyzer.d.ts +29 -0
- package/dist/qanalyzer.js +96 -0
- package/dist/reporters/fallback-coordinator.d.ts +24 -0
- package/dist/reporters/fallback-coordinator.js +77 -0
- package/dist/reporters/file-reporter.d.ts +10 -0
- package/dist/reporters/file-reporter.js +16 -0
- package/dist/reporters/index.d.ts +4 -0
- package/dist/reporters/index.js +9 -0
- package/dist/reporters/ingest-reporter.d.ts +9 -0
- package/dist/reporters/ingest-reporter.js +14 -0
- package/dist/reporters/reporter-interface.d.ts +4 -0
- package/dist/reporters/reporter-interface.js +2 -0
- package/dist/utils/disabled-exception.d.ts +2 -0
- package/dist/utils/disabled-exception.js +6 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/issue-keys.d.ts +7 -0
- package/dist/utils/issue-keys.js +33 -0
- package/dist/utils/logger.d.ts +12 -0
- package/dist/utils/logger.js +21 -0
- package/dist/utils/token-masker.d.ts +2 -0
- package/dist/utils/token-masker.js +17 -0
- package/dist/utils/upload-attachment.d.ts +35 -0
- package/dist/utils/upload-attachment.js +158 -0
- package/dist/writer/fs-writer.d.ts +9 -0
- package/dist/writer/fs-writer.js +19 -0
- package/dist/writer/index.d.ts +1 -0
- package/dist/writer/index.js +5 -0
- package/package.json +34 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.EnvAttachEnum = void 0;
|
|
37
|
+
exports.uploadAttachmentForQa = uploadAttachmentForQa;
|
|
38
|
+
/**
|
|
39
|
+
* Upload `qa.attach` binary via Forge proxy and return wire metadata (no content in FR41).
|
|
40
|
+
*/
|
|
41
|
+
const attach_client_1 = require("../client/attach-client");
|
|
42
|
+
const env_enum_1 = require("../env/env-enum");
|
|
43
|
+
const issue_keys_1 = require("./issue-keys");
|
|
44
|
+
exports.EnvAttachEnum = {
|
|
45
|
+
/** @deprecated Prefer QANALYZER_INGEST_URL — attach uses the shared ingest webtrigger. */
|
|
46
|
+
url: 'QANALYZER_ATTACH_URL',
|
|
47
|
+
maxBytes: 'QANALYZER_ATTACH_MAX_BYTES',
|
|
48
|
+
};
|
|
49
|
+
function readEnv(name) {
|
|
50
|
+
const value = process.env[name];
|
|
51
|
+
return value === '' ? undefined : value;
|
|
52
|
+
}
|
|
53
|
+
async function readPathContent(path) {
|
|
54
|
+
const { readFile } = await Promise.resolve().then(() => __importStar(require('node:fs/promises')));
|
|
55
|
+
return readFile(path);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Attempt Forge→Jira upload. On missing config/key/content, returns metadata-only (never throws
|
|
59
|
+
* unless you want callers to catch — this helper swallows upload errors into `uploaded: false`).
|
|
60
|
+
*/
|
|
61
|
+
async function uploadAttachmentForQa(params) {
|
|
62
|
+
const fileName = params.fileName ?? (params.path ? params.path.split(/[/\\]/).pop() : undefined) ?? 'attachment.bin';
|
|
63
|
+
const mimeType = params.mimeType ?? 'application/octet-stream';
|
|
64
|
+
let content = params.content;
|
|
65
|
+
if (content === undefined && params.path) {
|
|
66
|
+
try {
|
|
67
|
+
content = await readPathContent(params.path);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
return {
|
|
71
|
+
uploaded: false,
|
|
72
|
+
attachment: { file_name: fileName, mime_type: mimeType },
|
|
73
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const baseMeta = {
|
|
78
|
+
file_name: fileName,
|
|
79
|
+
mime_type: mimeType,
|
|
80
|
+
size: content === undefined
|
|
81
|
+
? undefined
|
|
82
|
+
: typeof content === 'string'
|
|
83
|
+
? Buffer.byteLength(content)
|
|
84
|
+
: content.byteLength,
|
|
85
|
+
};
|
|
86
|
+
if (content === undefined) {
|
|
87
|
+
return {
|
|
88
|
+
uploaded: false,
|
|
89
|
+
attachment: baseMeta,
|
|
90
|
+
reason: 'No content or path provided — metadata only',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const issueKey = params.issueKey?.trim() ||
|
|
94
|
+
(0, issue_keys_1.firstIssueKey)(...(params.issueKeySources ?? [])) ||
|
|
95
|
+
null;
|
|
96
|
+
if (!issueKey) {
|
|
97
|
+
return {
|
|
98
|
+
uploaded: false,
|
|
99
|
+
attachment: baseMeta,
|
|
100
|
+
reason: 'No issue key on test title/tags — skip upload',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const projectKey = params.projectKey?.trim() ||
|
|
104
|
+
readEnv(env_enum_1.EnvEnum.projectKey) ||
|
|
105
|
+
(0, issue_keys_1.projectKeyFromIssueKey)(issueKey) ||
|
|
106
|
+
'';
|
|
107
|
+
if (!projectKey) {
|
|
108
|
+
return {
|
|
109
|
+
uploaded: false,
|
|
110
|
+
attachment: baseMeta,
|
|
111
|
+
reason: 'projectKey required for attach upload',
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const url = params.attachUrl ??
|
|
115
|
+
readEnv(exports.EnvAttachEnum.url) ??
|
|
116
|
+
readEnv(env_enum_1.EnvIngestEnum.url);
|
|
117
|
+
const token = params.token ?? readEnv(env_enum_1.EnvIngestEnum.token);
|
|
118
|
+
if (!url || !token) {
|
|
119
|
+
return {
|
|
120
|
+
uploaded: false,
|
|
121
|
+
attachment: baseMeta,
|
|
122
|
+
reason: 'QANALYZER_INGEST_URL and QANALYZER_INGEST_TOKEN required for upload',
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const maxBytesRaw = params.maxBytes ?? Number(readEnv(exports.EnvAttachEnum.maxBytes));
|
|
126
|
+
const maxBytes = Number.isFinite(maxBytesRaw) && maxBytesRaw > 0
|
|
127
|
+
? maxBytesRaw
|
|
128
|
+
: attach_client_1.DEFAULT_MAX_ATTACH_BYTES;
|
|
129
|
+
try {
|
|
130
|
+
const client = new attach_client_1.AttachClient({ url, token, maxBytes });
|
|
131
|
+
const result = await client.upload({
|
|
132
|
+
projectKey,
|
|
133
|
+
issueKey,
|
|
134
|
+
fileName,
|
|
135
|
+
mimeType,
|
|
136
|
+
content,
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
uploaded: true,
|
|
140
|
+
issueKey: result.issueKey,
|
|
141
|
+
attachment: {
|
|
142
|
+
file_name: result.filename,
|
|
143
|
+
mime_type: result.mimeType,
|
|
144
|
+
size: result.size,
|
|
145
|
+
// Static attach webtrigger returns fixed `{"ok":true}` — no Jira attachment id.
|
|
146
|
+
// Prefer id when present; otherwise correlate via issue + filename on the Jira issue.
|
|
147
|
+
content_ref: result.id ?? `${result.issueKey}/${result.filename}`,
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
return {
|
|
153
|
+
uploaded: false,
|
|
154
|
+
attachment: baseMeta,
|
|
155
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FsWriter = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const fs_2 = require("fs");
|
|
7
|
+
class FsWriter {
|
|
8
|
+
path;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.path = options?.path ?? './qanalyzer-results.json';
|
|
11
|
+
}
|
|
12
|
+
writePayload(payload) {
|
|
13
|
+
const target = (0, path_1.resolve)(process.cwd(), this.path);
|
|
14
|
+
(0, fs_2.mkdirSync)((0, path_1.dirname)(target), { recursive: true });
|
|
15
|
+
(0, fs_1.writeFileSync)(target, `${JSON.stringify(payload, null, 2)}\n`, 'utf8');
|
|
16
|
+
return target;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.FsWriter = FsWriter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FsWriter, type FsWriterOptions } from './fs-writer';
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qanalyzer/forge-commons",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Shared config, models, and Forge ingest client for QAnalyzer JS reporters",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"qanalyzer",
|
|
7
|
+
"testing",
|
|
8
|
+
"reporter",
|
|
9
|
+
"jira"
|
|
10
|
+
],
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"!dist/__tests__"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "npm run clean && npx tsc --project tsconfig.build.json",
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"test": "npm run build && node --test dist/__tests__/**/*.test.js",
|
|
31
|
+
"prepublishOnly": "npm test"
|
|
32
|
+
},
|
|
33
|
+
"license": "Apache-2.0"
|
|
34
|
+
}
|