UNPKG

6.41 kBTypeScriptView Raw
1/// <reference types="node" resolution-mode="require"/>
2import type { SpawnOptions } from 'node:child_process';
3import { SevereServiceError } from 'webdriverio';
4import type { Capabilities, Options, Services } from '@wdio/types';
5import { CompilerOptions } from './constants.js';
6import type { OnCompleteResult, ParsedAnswers, ProjectProps, Questionnair, ReplCommandArguments, SupportedPackage } from './types.js';
7export declare const renderFile: (path: string, data: Record<string, any>) => Promise<string>;
8export declare class HookError extends SevereServiceError {
9 origin: string;
10 constructor(message: string, origin: string);
11}
12/**
13 * run service launch sequences
14 */
15export declare function runServiceHook(launcher: Services.ServiceInstance[], hookName: keyof Services.HookFunctions, ...args: any[]): Promise<undefined>;
16/**
17 * Run hook in service launcher
18 * @param {Array|Function} hook - can be array of functions or single function
19 * @param {object} config
20 * @param {object} capabilities
21 */
22export declare function runLauncherHook(hook: Function | Function[], ...args: any[]): Promise<void | any[]>;
23/**
24 * Run onCompleteHook in Launcher
25 * @param {Array|Function} onCompleteHook - can be array of functions or single function
26 * @param {*} config
27 * @param {*} capabilities
28 * @param {*} exitCode
29 * @param {*} results
30 */
31export declare function runOnCompleteHook(onCompleteHook: Function | Function[], config: Options.Testrunner, capabilities: Capabilities.RemoteCapabilities, exitCode: number, results: OnCompleteResult): Promise<(0 | 1)[]>;
32/**
33 * get runner identification by caps
34 */
35export declare function getRunnerName(caps?: Capabilities.DesiredCapabilities): string;
36export declare function findInConfig(config: string, type: string): RegExpMatchArray | null;
37export declare function replaceConfig(config: string, type: string, name: string): string | undefined;
38export declare function addServiceDeps(names: SupportedPackage[], packages: string[], update?: boolean): void;
39/**
40 * @todo add JSComments
41 */
42export declare function convertPackageHashToObject(pkg: string, hash?: string): SupportedPackage;
43export declare function getSerenityPackages(answers: Questionnair): string[];
44export declare function getCapabilities(arg: ReplCommandArguments): Promise<{
45 capabilities: {
46 deviceName: string;
47 platformVersion: string;
48 udid: string;
49 platformName: string;
50 automationName: string;
51 app: string;
52 browserName?: undefined;
53 };
54} | {
55 capabilities: {
56 deviceName: string;
57 platformVersion: string;
58 udid: string;
59 platformName: string;
60 automationName: string;
61 browserName: string;
62 };
63} | {
64 capabilities: {
65 alwaysMatch: WebdriverIO.Capabilities;
66 firstMatch: WebdriverIO.Capabilities[];
67 browserName?: undefined;
68 };
69} | {
70 capabilities: {
71 browserName: string;
72 };
73}>;
74/**
75 * Checks if certain directory has babel configuration files
76 * @param rootDir directory where this function checks for Babel signs
77 * @returns true, if a babel config was found, otherwise false
78 */
79export declare function hasBabelConfig(rootDir: string): Promise<boolean>;
80/**
81 * detect if project has a compiler file
82 */
83export declare function detectCompiler(answers: Questionnair): Promise<CompilerOptions>;
84/**
85 * Check if package is installed
86 * @param {string} package to check existance for
87 */
88export declare function hasPackage(pkg: string): Promise<boolean>;
89/**
90 * generate test files based on CLI answers
91 */
92export declare function generateTestFiles(answers: ParsedAnswers): Promise<void>;
93export declare function generateBrowserRunnerTestFiles(answers: ParsedAnswers): Promise<void>;
94export declare function getAnswers(yes: boolean): Promise<Questionnair>;
95export declare function getPathForFileGeneration(answers: Questionnair, projectRootDir: string): {
96 destSpecRootPath: string;
97 destStepRootPath: string;
98 destPageObjectRootPath: string;
99 destSerenityLibRootPath: string;
100 relativePath: string;
101};
102export declare function getDefaultFiles(answers: Questionnair, pattern: string): Promise<string>;
103/**
104 * Ensure core WebdriverIO packages have the same version as cli so that if someone
105 * installs `@wdio/cli@next` and runs the wizard, all related packages have the same version.
106 * running `matchAll` to a version like "8.0.0-alpha.249+4bc237701", results in:
107 * ['8.0.0-alpha.249+4bc237701', '8', '0', '0', 'alpha', '249', '4bc237701']
108 */
109export declare function specifyVersionIfNeeded(packagesToInstall: string[], version: string, npmTag: string): string[];
110/**
111 * Receive project properties
112 * @returns {@type ProjectProps} if a package.json can be found in cwd or parent directories, otherwise undefined
113 * which means that a new project can be created
114 */
115export declare function getProjectProps(cwd?: string): Promise<ProjectProps | undefined>;
116export declare function runProgram(command: string, args: string[], options: SpawnOptions): Promise<void>;
117/**
118 * create package.json if not already existing
119 */
120export declare function createPackageJSON(parsedAnswers: ParsedAnswers): Promise<false | undefined>;
121export declare function npmInstall(parsedAnswers: ParsedAnswers, npmTag: string): Promise<void>;
122/**
123 * detect the package manager that was used
124 */
125export declare function detectPackageManager(argv?: string[]): "npm" | "yarn" | "pnpm" | "bun";
126/**
127 * add ts-node if TypeScript is desired but not installed
128 */
129export declare function setupTypeScript(parsedAnswers: ParsedAnswers): Promise<void>;
130/**
131 * add @babel/register package if not installed
132 */
133export declare function setupBabel(parsedAnswers: ParsedAnswers): Promise<void>;
134export declare function createWDIOConfig(parsedAnswers: ParsedAnswers): Promise<void>;
135/**
136 * Get project root directory based on questionair answers
137 * @param answers questionair answers
138 * @param projectProps project properties received via `getProjectProps`
139 * @returns project root path
140 */
141export declare function getProjectRoot(parsedAnswers?: Questionnair): Promise<string>;
142export declare function createWDIOScript(parsedAnswers: ParsedAnswers): Promise<boolean>;
143export declare function runAppiumInstaller(parsedAnswers: ParsedAnswers): Promise<void | import("execa").ExecaReturnValue<string>>;
144//# sourceMappingURL=utils.d.ts.map
\No newline at end of file