qase-javascript-commons 2.5.4 → 2.5.6
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/changelog.md +22 -0
- package/dist/client/clientV2.d.ts +1 -0
- package/dist/client/clientV2.js +11 -1
- package/dist/config/config-validation-schema.d.ts +24 -0
- package/dist/config/config-validation-schema.js +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/step-data.d.ts +9 -0
- package/dist/models/test-step.d.ts +4 -3
- package/dist/models/test-step.js +13 -1
- package/dist/options/options-type.d.ts +5 -0
- package/dist/profilers/abstract-profiler.d.ts +5 -0
- package/dist/profilers/abstract-profiler.js +6 -0
- package/dist/profilers/fetch-interceptor.d.ts +60 -0
- package/dist/profilers/fetch-interceptor.js +277 -0
- package/dist/profilers/http-interceptor.d.ts +69 -0
- package/dist/profilers/http-interceptor.js +245 -0
- package/dist/profilers/index.d.ts +5 -0
- package/dist/profilers/index.js +11 -0
- package/dist/profilers/network-profiler.d.ts +61 -0
- package/dist/profilers/network-profiler.js +98 -0
- package/dist/qase.js +2 -8
- package/dist/reporters/report-reporter.d.ts +4 -1
- package/dist/reporters/report-reporter.js +9 -2
- package/dist/utils/hostData.d.ts +0 -6
- package/dist/utils/hostData.js +19 -107
- package/package.json +1 -1
package/dist/utils/hostData.js
CHANGED
|
@@ -33,13 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getMinimalHostData = getMinimalHostData;
|
|
37
36
|
exports.getHostInfo = getHostInfo;
|
|
38
37
|
const os = __importStar(require("os"));
|
|
39
38
|
const cp = __importStar(require("child_process"));
|
|
40
39
|
const fs = __importStar(require("fs"));
|
|
41
|
-
const
|
|
42
|
-
const child_process_1 = require("child_process");
|
|
40
|
+
const get_package_version_1 = require("./get-package-version");
|
|
43
41
|
/**
|
|
44
42
|
* Gets detailed OS information based on the platform
|
|
45
43
|
* @returns {string} Detailed OS information
|
|
@@ -76,110 +74,24 @@ function getDetailedOSInfo() {
|
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @
|
|
81
|
-
* @param {string} defaultValue Default value if command fails
|
|
82
|
-
* @returns {string} Command output or default value
|
|
77
|
+
* Gets npm version from environment or by executing npm command
|
|
78
|
+
* @returns {string} npm version string
|
|
83
79
|
*/
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return defaultValue;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Recursively searches for a package in dependencies tree
|
|
95
|
-
* @param {Record<string, PackageInfo>} dependencies The dependencies object to search in
|
|
96
|
-
* @param {string} packageName The name of the package to find
|
|
97
|
-
* @returns {string | null} The package version or null if not found
|
|
98
|
-
*/
|
|
99
|
-
function findPackageInDependencies(dependencies, packageName) {
|
|
100
|
-
// If no dependencies, return null
|
|
101
|
-
if (!dependencies)
|
|
102
|
-
return null;
|
|
103
|
-
// Check if the package exists at the current level
|
|
104
|
-
if (packageName in dependencies) {
|
|
105
|
-
return dependencies[packageName]?.version ?? null;
|
|
106
|
-
}
|
|
107
|
-
// Recursively search in nested dependencies
|
|
108
|
-
for (const dep of Object.values(dependencies)) {
|
|
109
|
-
if (dep.dependencies) {
|
|
110
|
-
const foundVersion = findPackageInDependencies(dep.dependencies, packageName);
|
|
111
|
-
if (foundVersion) {
|
|
112
|
-
return foundVersion;
|
|
113
|
-
}
|
|
80
|
+
function getNpmVersion() {
|
|
81
|
+
const userAgent = process.env['npm_config_user_agent'];
|
|
82
|
+
if (userAgent) {
|
|
83
|
+
const match = userAgent.match(/^npm\/(\S+)/);
|
|
84
|
+
if (match?.[1]) {
|
|
85
|
+
return match[1];
|
|
114
86
|
}
|
|
115
87
|
}
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Gets the version of a Node.js package
|
|
120
|
-
* @param {string} packageName The name of the package
|
|
121
|
-
* @returns {string | null} The package version or null if not found
|
|
122
|
-
*/
|
|
123
|
-
function getPackageVersion(packageName) {
|
|
124
|
-
if (!packageName)
|
|
125
|
-
return null;
|
|
126
88
|
try {
|
|
127
|
-
|
|
128
|
-
const packagePath = path.resolve(process.cwd(), 'node_modules', packageName, 'package.json');
|
|
129
|
-
if (fs.existsSync(packagePath)) {
|
|
130
|
-
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
|
131
|
-
return packageJson.version;
|
|
132
|
-
}
|
|
133
|
-
// Try using npm list as fallback with recursive search
|
|
134
|
-
let output = null;
|
|
135
|
-
try {
|
|
136
|
-
output = (0, child_process_1.execSync)(`npm list --depth=10 --json`, { stdio: "pipe" }).toString();
|
|
137
|
-
if (!output)
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
try {
|
|
144
|
-
const npmList = JSON.parse(output);
|
|
145
|
-
// Try direct dependency
|
|
146
|
-
const directVersion = npmList.dependencies?.[packageName]?.version;
|
|
147
|
-
if (directVersion)
|
|
148
|
-
return directVersion;
|
|
149
|
-
// Try recursive search
|
|
150
|
-
return findPackageInDependencies(npmList.dependencies, packageName);
|
|
151
|
-
}
|
|
152
|
-
catch (parseError) {
|
|
153
|
-
console.error('Error parsing npm list output:', parseError);
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
89
|
+
return cp.execSync('npm --version', { stdio: 'pipe' }).toString().trim();
|
|
156
90
|
}
|
|
157
|
-
catch
|
|
158
|
-
|
|
159
|
-
return null;
|
|
91
|
+
catch {
|
|
92
|
+
return '';
|
|
160
93
|
}
|
|
161
94
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Returns minimal host data without slow operations (no npm list, no execSync for node/npm).
|
|
164
|
-
* Use when reporter mode is "off" to avoid startup delay.
|
|
165
|
-
* @returns {HostData} Minimal host information object
|
|
166
|
-
*/
|
|
167
|
-
function getMinimalHostData() {
|
|
168
|
-
return {
|
|
169
|
-
system: os.platform(),
|
|
170
|
-
machineName: os.hostname(),
|
|
171
|
-
release: os.release(),
|
|
172
|
-
version: '',
|
|
173
|
-
arch: os.arch(),
|
|
174
|
-
node: '',
|
|
175
|
-
npm: '',
|
|
176
|
-
framework: '',
|
|
177
|
-
reporter: '',
|
|
178
|
-
commons: '',
|
|
179
|
-
apiClientV1: '',
|
|
180
|
-
apiClientV2: '',
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
95
|
/**
|
|
184
96
|
* Gets information about the current host environment
|
|
185
97
|
* @param {string} framework The framework name to check version for
|
|
@@ -194,13 +106,13 @@ function getHostInfo(framework, reporterName) {
|
|
|
194
106
|
release: os.release(),
|
|
195
107
|
version: getDetailedOSInfo(),
|
|
196
108
|
arch: os.arch(),
|
|
197
|
-
node:
|
|
198
|
-
npm:
|
|
199
|
-
framework: getPackageVersion(framework) ?? '',
|
|
200
|
-
reporter: getPackageVersion(reporterName) ?? '',
|
|
201
|
-
commons: getPackageVersion('qase-javascript-commons') ?? '',
|
|
202
|
-
apiClientV1: getPackageVersion('qase-api-client') ?? '',
|
|
203
|
-
apiClientV2: getPackageVersion('qase-api-v2-client') ?? '',
|
|
109
|
+
node: process.version,
|
|
110
|
+
npm: getNpmVersion(),
|
|
111
|
+
framework: (0, get_package_version_1.getPackageVersion)(framework) ?? '',
|
|
112
|
+
reporter: (0, get_package_version_1.getPackageVersion)(reporterName) ?? '',
|
|
113
|
+
commons: (0, get_package_version_1.getPackageVersion)('qase-javascript-commons') ?? '',
|
|
114
|
+
apiClientV1: (0, get_package_version_1.getPackageVersion)('qase-api-client') ?? '',
|
|
115
|
+
apiClientV2: (0, get_package_version_1.getPackageVersion)('qase-api-v2-client') ?? '',
|
|
204
116
|
};
|
|
205
117
|
}
|
|
206
118
|
catch (error) {
|