added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
/// <reference types="webdriver" />
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="@wdio/cucumber-framework" />
import type { ConfigOptions, Hooks } from '../types';
interface MergeConfig extends Omit<Partial<ConfigOptions>, 'specs' | 'exclude'> {
specs?: string | string[];
exclude?: string | string[];
}
export default class ConfigParser {
private _config;
private _capabilities;
addConfigFile(filename: string): void;
merge(object?: MergeConfig): void;
addService(service: Hooks): void;
getSpecs(capSpecs?: string[], capExclude?: string[]): string[];
setFilePathToFilterOptions(cliArgFileList: string[], config: string[]): string[];
getConfig(): Required<ConfigOptions>;
getCapabilities(i?: number): WebDriver.DesiredCapabilities | WebDriver.W3CCapabilities | import("webdriverio").MultiRemoteCapabilities | (WebDriver.DesiredCapabilities | WebDriver.W3CCapabilities)[];
static getFilePaths(patterns: string[], omitWarnings?: boolean): string[];
}
export {};
//# sourceMappingURL=ConfigParser.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ConfigParser.d.ts","sourceRoot":"","sources":["../../src/lib/ConfigParser.ts"],"names":[],"mappings":";;;;AAWA,OAAO,KAAK,EAAgB,aAAa,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAKlE,UAAU,WAAY,SAAQ,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3E,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC9B;AAED,MAAM,CAAC,OAAO,OAAO,YAAY;IAC7B,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,aAAa,CAAoB;IAMzC,aAAa,CAAE,QAAQ,EAAE,MAAM;IAuD/B,KAAK,CAAE,MAAM,GAAE,WAAgB;IA6C/B,UAAU,CAAE,OAAO,EAAE,KAAK;IAkC1B,QAAQ,CAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE;IA8DpD,0BAA0B,CAAE,cAAc,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IA2BtE,SAAS;IAOT,eAAe,CAAE,CAAC,CAAC,EAAE,MAAM;IAc3B,MAAM,CAAC,YAAY,CAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,YAAY,CAAC,EAAE,OAAO;CAgClE"}
+190
View File
@@ -0,0 +1,190 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const glob_1 = __importDefault(require("glob"));
const deepmerge_1 = __importDefault(require("deepmerge"));
const logger_1 = __importDefault(require("@wdio/logger"));
const utils_1 = require("../utils");
const constants_1 = require("../constants");
const log = logger_1.default('@wdio/config:ConfigParser');
const MERGE_OPTIONS = { clone: false };
class ConfigParser {
constructor() {
this._config = constants_1.DEFAULT_CONFIGS();
this._capabilities = [];
}
addConfigFile(filename) {
if (typeof filename !== 'string') {
throw new Error('addConfigFile requires filepath');
}
const filePath = path_1.default.resolve(process.cwd(), filename);
try {
utils_1.loadTypeScriptCompiler();
const fileConfig = deepmerge_1.default(require(filePath).config, {}, MERGE_OPTIONS);
const defaultTo = Array.isArray(this._capabilities) ? [] : {};
this._capabilities = deepmerge_1.default(this._capabilities, fileConfig.capabilities || defaultTo, MERGE_OPTIONS);
delete fileConfig.capabilities;
this.addService(fileConfig);
for (let hookName of constants_1.SUPPORTED_HOOKS) {
delete fileConfig[hookName];
}
this._config = deepmerge_1.default(this._config, fileConfig, MERGE_OPTIONS);
this._config = deepmerge_1.default(utils_1.detectBackend(this._config), this._config, MERGE_OPTIONS);
delete this._config.watch;
}
catch (e) {
log.error(`Failed loading configuration file: ${filePath}:`, e.message);
throw e;
}
}
merge(object = {}) {
const spec = Array.isArray(object.spec) ? object.spec : [];
const exclude = Array.isArray(object.exclude) ? object.exclude : [];
this._config = deepmerge_1.default(this._config, object, MERGE_OPTIONS);
if (object.specs && object.specs.length > 0) {
this._config.specs = object.specs;
}
else if (object.exclude && object.exclude.length > 0) {
this._config.exclude = object.exclude;
}
this._capabilities = utils_1.validObjectOrArray(this._config.capabilities) ? this._config.capabilities : this._capabilities;
if (this._config.spec && utils_1.isCucumberFeatureWithLineNumber(this._config.spec)) {
this._config.cucumberFeaturesWithLineNumbers = Array.isArray(this._config.spec) ? [...this._config.spec] : [this._config.spec];
}
if (spec.length > 0) {
this._config.specs = this.setFilePathToFilterOptions(spec, this._config.specs);
}
if (exclude.length > 0) {
this._config.exclude = this.setFilePathToFilterOptions(exclude, this._config.exclude);
}
this._config = deepmerge_1.default(utils_1.detectBackend(this._config), this._config, MERGE_OPTIONS);
}
addService(service) {
const addHook = (hookName, hook) => {
const existingHooks = this._config[hookName];
if (!existingHooks) {
this._config[hookName] = hook.bind(service);
}
else if (typeof existingHooks === 'function') {
this._config[hookName] = [existingHooks, hook.bind(service)];
}
else {
this._config[hookName] = [...existingHooks, hook.bind(service)];
}
};
for (const hookName of constants_1.SUPPORTED_HOOKS) {
const hooksToBeAdded = service[hookName];
if (!hooksToBeAdded) {
continue;
}
if (typeof hooksToBeAdded === 'function') {
addHook(hookName, hooksToBeAdded);
}
else if (Array.isArray(hooksToBeAdded)) {
for (const hookToAdd of hooksToBeAdded) {
if (typeof hookToAdd === 'function') {
addHook(hookName, hookToAdd);
}
}
}
}
}
getSpecs(capSpecs, capExclude) {
var _a;
let specs = ConfigParser.getFilePaths(this._config.specs);
let spec = Array.isArray(this._config.spec) ? this._config.spec : [];
let exclude = ConfigParser.getFilePaths(this._config.exclude);
let suites = Array.isArray(this._config.suite) ? this._config.suite : [];
if (suites.length > 0) {
let suiteSpecs = [];
for (let suiteName of suites) {
let suite = (_a = this._config.suites) === null || _a === void 0 ? void 0 : _a[suiteName];
if (!suite) {
log.warn(`No suite was found with name "${suiteName}"`);
}
if (Array.isArray(suite)) {
suiteSpecs = suiteSpecs.concat(ConfigParser.getFilePaths(suite));
}
}
if (suiteSpecs.length === 0) {
throw new Error(`The suite(s) "${suites.join('", "')}" you specified don't exist ` +
'in your config file or doesn\'t contain any files!');
}
let tmpSpecs = spec.length > 0 ? [...specs, ...suiteSpecs] : suiteSpecs;
if (Array.isArray(capSpecs)) {
tmpSpecs = ConfigParser.getFilePaths(capSpecs);
}
if (Array.isArray(capExclude)) {
exclude = ConfigParser.getFilePaths(capExclude);
}
specs = [...new Set(tmpSpecs)];
return specs.filter(spec => !exclude.includes(spec));
}
if (Array.isArray(capSpecs)) {
specs = ConfigParser.getFilePaths(capSpecs);
}
if (Array.isArray(capExclude)) {
exclude = ConfigParser.getFilePaths(capExclude);
}
return specs.filter(spec => !exclude.includes(spec));
}
setFilePathToFilterOptions(cliArgFileList, config) {
const filesToFilter = new Set();
const fileList = ConfigParser.getFilePaths(config);
cliArgFileList.forEach(filteredFile => {
filteredFile = utils_1.removeLineNumbers(filteredFile);
let globMatchedFiles = ConfigParser.getFilePaths(glob_1.default.sync(filteredFile));
if (fs_1.default.existsSync(filteredFile) && fs_1.default.lstatSync(filteredFile).isFile()) {
filesToFilter.add(path_1.default.resolve(process.cwd(), filteredFile));
}
else if (globMatchedFiles.length) {
globMatchedFiles.forEach(file => filesToFilter.add(file));
}
else {
fileList.forEach(file => {
if (file.match(filteredFile)) {
filesToFilter.add(file);
}
});
}
});
if (filesToFilter.size === 0) {
throw new Error(`spec file(s) ${cliArgFileList.join(', ')} not found`);
}
return [...filesToFilter];
}
getConfig() {
return this._config;
}
getCapabilities(i) {
if (typeof i === 'number' && Array.isArray(this._capabilities) && this._capabilities[i]) {
return this._capabilities[i];
}
return this._capabilities;
}
static getFilePaths(patterns, omitWarnings) {
let files = [];
if (typeof patterns === 'string') {
patterns = [patterns];
}
if (!Array.isArray(patterns)) {
throw new Error('specs or exclude property should be an array of strings');
}
patterns = patterns.map(pattern => utils_1.removeLineNumbers(pattern));
for (let pattern of patterns) {
let filenames = glob_1.default.sync(pattern);
filenames = filenames.filter((filename) => constants_1.SUPPORTED_FILE_EXTENSIONS.find((ext) => filename.endsWith(ext)));
filenames = filenames.map(filename => path_1.default.isAbsolute(filename) ? path_1.default.normalize(filename) : path_1.default.resolve(process.cwd(), filename));
if (filenames.length === 0 && !omitWarnings) {
log.warn('pattern', pattern, 'did not match any file');
}
files = deepmerge_1.default(files, filenames, MERGE_OPTIONS);
}
return files;
}
}
exports.default = ConfigParser;