@ainias42/wdio-utils 0.0.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/.ctirc ADDED
@@ -0,0 +1,114 @@
1
+ {
2
+ // Stream of cli spinner, you can pass stdout or stderr
3
+ //
4
+ // @mode all
5
+ // @default stdout
6
+ "spinnerStream": "stdout",
7
+ // Stream of cli progress, you can pass stdout or stderr
8
+ //
9
+ // @mode all
10
+ // @default stdout
11
+ "progressStream": "stdout",
12
+ // Stream of cli reasoner. Reasoner show name conflict error and already exist index.ts file error.
13
+ // You can pass stdout or stderr
14
+ //
15
+ // @mode all
16
+ // @default stderr
17
+ "reasonerStream": "stderr",
18
+ "options": [
19
+ {
20
+ // build mode
21
+ // - create: create an `index.ts` file in each directory
22
+ // - bundle: bundle all export information in one `index.ts` file
23
+ "mode": "bundle",
24
+ // tsconfig.json path: you must pass path with filename, like this "./tsconfig.json"
25
+ // only work root directory or cli parameter
26
+ //
27
+ // @mode all
28
+ "project": "tsconfig.json",
29
+ // Export filename, if you not pass this field that use "index.ts" or "index.d.ts"
30
+ //
31
+ // @mode create, bundle, remove
32
+ // @default index.ts
33
+ "exportFilename": "index.ts",
34
+ // add ctix comment at first line of creted index.ts file, that remark created from ctix
35
+ //
36
+ // @mode create, bundle
37
+ // @default false
38
+ "useSemicolon": true,
39
+ // add ctix comment at first line of creted index.ts file, that remark created from ctix
40
+ //
41
+ // @mode create, bundle
42
+ // @default false
43
+ "useBanner": false,
44
+ // If specified as true, adds the created date to the top of the `index.ts` file,
45
+ // this option only works if the `useBanner` option is enabled
46
+ //
47
+ // @mode create, bundle
48
+ // @default false
49
+ "useTimestamp": false,
50
+ // quote mark " or '
51
+ // @mode create, bundle
52
+ //
53
+ // @default '
54
+ "quote": "'",
55
+ // Use to add a literal like `"use strict"` to the top. It will be added before the banner.
56
+ //
57
+ // @mode create, bundle
58
+ "directive": "",
59
+ // keep file extension in export statement path
60
+ //
61
+ // if this option set true that see below
62
+ // export * from './test.ts'
63
+ //
64
+ // @mode create, bundle
65
+ // @default none
66
+ "fileExt": "none",
67
+ // overwrite each index.ts file
68
+ // @mode create, bundle
69
+ // @default false
70
+ "overwrite": true,
71
+ // Create a backup file if the `index.ts` file already exists.
72
+ // This option only works if the `overwrite` option is enabled.
73
+ //
74
+ // @mode create, bundle
75
+ // @default true
76
+ "backup": false,
77
+ // When generating the `index.ts` file, decide how you want to generate it
78
+ //
79
+ // @mode create, bundle
80
+ // @default auto
81
+ "generationStyle": "auto",
82
+ // A list of files to use when generating the index.ts file. If no value is set,
83
+ // the value of the include setting set in the tsconfig.json file will be used
84
+ //
85
+ // @mode create, bundle
86
+ "include": [
87
+ "src/**/*.tsx",
88
+ "src/**/*.ts"
89
+ ],
90
+ // A list of files to exclude when generating the index.ts file. If no value is set,
91
+ // the value of the exclude setting set in the tsconfig.json file is used
92
+ //
93
+ // @mode create, bundle
94
+ "exclude": [
95
+ "../../node_modules",
96
+ "dist/**/*",
97
+ "dist/src/**/*",
98
+ "src/**/*.stories.tsx",
99
+ "src/**/*.stories.ts"
100
+ ],
101
+ // Output directory. Default value is same project directory
102
+ // @mode bundle
103
+ "output": "./src",
104
+ // remove with backup file
105
+ // @mode remove
106
+ // @default false
107
+ "removeBackup": false,
108
+ // answer `yes` to all questions
109
+ // @mode remove
110
+ // @default false
111
+ "forceYes": false
112
+ }
113
+ ]
114
+ }
package/.prettierrc ADDED
@@ -0,0 +1 @@
1
+ "@ainias42/config/prettierrc.js"
package/bin/release.sh ADDED
@@ -0,0 +1,3 @@
1
+ #! /bin/bash
2
+
3
+ ../../bin/release.sh $1 wdio-utils
@@ -0,0 +1,3 @@
1
+ #! /bin/bash
2
+
3
+ ../../bin/updatePackages.sh wdio-utils
@@ -0,0 +1,9 @@
1
+ export declare class ChromeCleanupService {
2
+ private cacheDir;
3
+ constructor(_1: any, _browser: any, config: {
4
+ cacheDir: string;
5
+ });
6
+ private sortByVersion;
7
+ private cleanCache;
8
+ onComplete(): Promise<void>;
9
+ }
@@ -0,0 +1,13 @@
1
+ export declare function createChromeCapability(cacheDir: string, headless: boolean, extraArgs?: string[]): {
2
+ browserName: string;
3
+ browserVersion: string;
4
+ 'goog:chromeOptions': {
5
+ excludeSwitches: string[];
6
+ args: string[];
7
+ prefs: {
8
+ 'intl.accept_languages': string;
9
+ credentials_enable_service: boolean;
10
+ 'profile.password_manager_enabled': boolean;
11
+ };
12
+ };
13
+ };
@@ -0,0 +1,2 @@
1
+ export * from './ChromeCleanupService';
2
+ export * from './createChromeCapability';
package/dist/index.js ADDED
@@ -0,0 +1,118 @@
1
+ import { default as default_0 } from "fs/promises";
2
+ import { default as default_1 } from "path";
3
+ /******/ // The require scope
4
+ /******/ var __webpack_require__ = {};
5
+ /******/
6
+ /************************************************************************/
7
+ /******/ /* webpack/runtime/define property getters */
8
+ /******/ (() => {
9
+ /******/ // define getter functions for harmony exports
10
+ /******/ __webpack_require__.d = (exports, definition) => {
11
+ /******/ for(var key in definition) {
12
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14
+ /******/ }
15
+ /******/ }
16
+ /******/ };
17
+ /******/ })();
18
+ /******/
19
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
20
+ /******/ (() => {
21
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22
+ /******/ })();
23
+ /******/
24
+ /************************************************************************/
25
+ var __webpack_exports__ = {};
26
+
27
+ ;// external "fs/promises"
28
+
29
+ ;// external "path"
30
+
31
+ ;// ./src/ChromeCleanupService.ts
32
+
33
+
34
+ class ChromeCleanupService {
35
+ constructor(_1, _browser, config) {
36
+ this.cacheDir = config.cacheDir;
37
+ }
38
+ // eslint-disable-next-line class-methods-use-this
39
+ sortByVersion(items) {
40
+ return items.sort((a, b) => {
41
+ const aVerMatch = a.match(/((?:\d+\.){3}\d+)/);
42
+ const bVerMatch = b.match(/((?:\d+\.){3}\d+)/);
43
+ const aVer = aVerMatch ? aVerMatch[0] : '0.0.0.0';
44
+ const bVer = bVerMatch ? bVerMatch[0] : '0.0.0.0';
45
+ return bVer.localeCompare(aVer, undefined, {
46
+ numeric: true
47
+ });
48
+ });
49
+ }
50
+ async cleanCache(cachePath) {
51
+ try {
52
+ const exists = await default_0.stat(cachePath).then(() => true).catch(() => false);
53
+ if (!exists) {
54
+ return;
55
+ }
56
+ const entries = await default_0.readdir(cachePath);
57
+ const items = [];
58
+ const itemPromises = entries.map(async entry => {
59
+ const fullPath = default_1.join(cachePath, entry);
60
+ const stat = await default_0.stat(fullPath);
61
+ if (stat.isDirectory()) {
62
+ items.push(fullPath);
63
+ }
64
+ });
65
+ await Promise.all(itemPromises);
66
+ if (items.length <= 1) {
67
+ return;
68
+ }
69
+ const sortedItems = this.sortByVersion(items);
70
+ const [latest, ...oldItems] = sortedItems;
71
+ const deletePromises = oldItems.map(oldItem => default_0.rm(oldItem, {
72
+ recursive: true,
73
+ force: true
74
+ }));
75
+ await Promise.all(deletePromises);
76
+ console.log(`[WDIO Cleanup] Deleted old drivers/binaries, kept: ${latest}`);
77
+ } catch (error) {
78
+ console.error(`[WDIO Cleanup] Error cleaning cache at ${cachePath}:`, error);
79
+ }
80
+ }
81
+ async onComplete() {
82
+ var _a;
83
+ const cacheDir = (_a = this.cacheDir) !== null && _a !== void 0 ? _a : 'test/tmp';
84
+ await this.cleanCache(`${cacheDir}/chrome`);
85
+ await this.cleanCache(`${cacheDir}/chromedriver`);
86
+ await default_0.rm(`${cacheDir}/profiles`, {
87
+ recursive: true,
88
+ force: true
89
+ });
90
+ }
91
+ }
92
+ ;// ./src/createChromeCapability.ts
93
+
94
+ function createChromeCapability(cacheDir, headless, extraArgs = []) {
95
+ const args = ['--disable-infobars', '--enable-automation', '--disable-web-security', '--disable-popup-blocking', '--disable-notifications', '--disable-features=MacAppCodeSignClone', '--disable-blink-features=AutomationControlled', `--user-data-dir=${default_1.join(cacheDir, 'profiles')}`, ...extraArgs];
96
+ if (headless) {
97
+ args.push('--headless=new');
98
+ }
99
+ return {
100
+ browserName: 'chrome',
101
+ browserVersion: 'stable',
102
+ 'goog:chromeOptions': {
103
+ excludeSwitches: ['enable-automation'],
104
+ args,
105
+ prefs: {
106
+ 'intl.accept_languages': 'en',
107
+ credentials_enable_service: false,
108
+ 'profile.password_manager_enabled': false
109
+ }
110
+ }
111
+ };
112
+ }
113
+ ;// ./src/index.ts
114
+
115
+
116
+ export { ChromeCleanupService, createChromeCapability };
117
+
118
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","mappings":"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","sources":["webpack://@ainias42/wdio-utils/webpack/bootstrap","webpack://@ainias42/wdio-utils/webpack/runtime/define property getters","webpack://@ainias42/wdio-utils/webpack/runtime/hasOwnProperty shorthand","webpack://@ainias42/wdio-utils/external module \"fs/promises\"","webpack://@ainias42/wdio-utils/external module \"path\"","webpack://@ainias42/wdio-utils/./src/ChromeCleanupService.ts","webpack://@ainias42/wdio-utils/./src/createChromeCapability.ts","webpack://@ainias42/wdio-utils/./src/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","","","import fs from 'fs/promises';\nimport path from 'path';\n\nexport class ChromeCleanupService {\n private cacheDir: string;\n\n constructor(_1: any, _browser: any, config: { cacheDir: string }) {\n this.cacheDir = config.cacheDir;\n }\n\n // eslint-disable-next-line class-methods-use-this\n private sortByVersion(items: string[]) {\n return items.sort((a, b) => {\n const aVerMatch = a.match(/((?:\\d+\\.){3}\\d+)/);\n const bVerMatch = b.match(/((?:\\d+\\.){3}\\d+)/);\n\n const aVer = aVerMatch ? aVerMatch[0] : '0.0.0.0';\n const bVer = bVerMatch ? bVerMatch[0] : '0.0.0.0';\n\n return bVer.localeCompare(aVer, undefined, { numeric: true });\n });\n }\n\n private async cleanCache(cachePath: string) {\n try {\n const exists = await fs\n .stat(cachePath)\n .then(() => true)\n .catch(() => false);\n if (!exists) {\n return;\n }\n\n const entries = await fs.readdir(cachePath);\n const items: string[] = [];\n\n const itemPromises = entries.map(async (entry) => {\n const fullPath = path.join(cachePath, entry);\n const stat = await fs.stat(fullPath);\n if (stat.isDirectory()) {\n items.push(fullPath);\n }\n });\n await Promise.all(itemPromises);\n\n if (items.length <= 1) {\n return;\n }\n\n const sortedItems = this.sortByVersion(items);\n const [latest, ...oldItems] = sortedItems;\n\n const deletePromises = oldItems.map((oldItem) => fs.rm(oldItem, { recursive: true, force: true }));\n await Promise.all(deletePromises);\n\n console.log(`[WDIO Cleanup] Deleted old drivers/binaries, kept: ${latest}`);\n } catch (error) {\n console.error(`[WDIO Cleanup] Error cleaning cache at ${cachePath}:`, error);\n }\n }\n\n async onComplete() {\n const cacheDir = this.cacheDir ?? 'test/tmp';\n await this.cleanCache(`${cacheDir}/chrome`);\n await this.cleanCache(`${cacheDir}/chromedriver`);\n await fs.rm(`${cacheDir}/profiles`, { recursive: true, force: true });\n }\n}\n","import path from 'path';\n\nexport function createChromeCapability(cacheDir: string, headless: boolean, extraArgs: string[] = []) {\n const args = [\n '--disable-infobars',\n '--enable-automation',\n '--disable-web-security',\n '--disable-popup-blocking',\n '--disable-notifications',\n '--disable-features=MacAppCodeSignClone',\n '--disable-blink-features=AutomationControlled',\n `--user-data-dir=${path.join(cacheDir, 'profiles')}`,\n ...extraArgs,\n ];\n\n if (headless) {\n args.push('--headless=new');\n }\n\n return {\n browserName: 'chrome',\n browserVersion: 'stable',\n 'goog:chromeOptions': {\n excludeSwitches: ['enable-automation'],\n args,\n prefs: {\n 'intl.accept_languages': 'en',\n credentials_enable_service: false,\n 'profile.password_manager_enabled': false,\n },\n },\n };\n}\n","export * from './ChromeCleanupService';\nexport * from './createChromeCapability';\n"],"names":["fs","path","ChromeCleanupService","constructor","_1","_browser","config","cacheDir","sortByVersion","items","sort","a","b","aVerMatch","match","bVerMatch","aVer","bVer","localeCompare","undefined","numeric","cleanCache","cachePath","exists","stat","then","catch","entries","readdir","itemPromises","map","entry","fullPath","join","isDirectory","push","Promise","all","length","sortedItems","latest","oldItems","deletePromises","oldItem","rm","recursive","force","console","log","error","onComplete","_a","createChromeCapability","headless","extraArgs","args","browserName","browserVersion","excludeSwitches","prefs","credentials_enable_service"],"sourceRoot":""}
@@ -0,0 +1,10 @@
1
+ import defaultConfig from '@ainias42/config/eslint.config.js';
2
+
3
+ export default [
4
+ ...defaultConfig,
5
+ {
6
+ rules: {
7
+ "no-relative-import-paths/no-relative-import-paths": "off",
8
+ },
9
+ },
10
+ ];
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@ainias42/wdio-utils",
3
+ "version": "0.0.1",
4
+ "description": "Utils for WDIO",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "license": "MIT",
9
+ "main": "dist/index.js",
10
+ "scripts": {
11
+ "build-postinstall": "npm run build",
12
+ "build": "ctix build && webpack --env production",
13
+ "lint:noCache": "eslint \"{src,.storybook}/{**/*,*}.{js,jsx,tsx,ts}\" --max-warnings 0",
14
+ "lint": "npm run lint:noCache -- --cache",
15
+ "lint:fix": "npm run lint -- --fix",
16
+ "typecheck": "tsc --noEmit",
17
+ "prettier": "npm run prettier:list -- --write",
18
+ "prettier:list": "prettier --list-different \"{src,.storybook}/**/*.{ts,tsx,js,jsx,json}\"",
19
+ "stylelint": "stylelint --allow-empty-input \"{src,.storybook}/**/*.{css,scss}\"",
20
+ "stylelint:fix": "npm run stylelint -- --fix"
21
+ },
22
+ "author": "",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "gitea@git.silas.link:Ainias/libraries.git"
26
+ },
27
+ "peerDependencies": {},
28
+ "dependencies": {
29
+ "@ainias42/config": "*"
30
+ },
31
+ "devDependencies": {
32
+ "@ainias42/webpack-config": "*"
33
+ }
34
+ }
@@ -0,0 +1,68 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+
4
+ export class ChromeCleanupService {
5
+ private cacheDir: string;
6
+
7
+ constructor(_1: any, _browser: any, config: { cacheDir: string }) {
8
+ this.cacheDir = config.cacheDir;
9
+ }
10
+
11
+ // eslint-disable-next-line class-methods-use-this
12
+ private sortByVersion(items: string[]) {
13
+ return items.sort((a, b) => {
14
+ const aVerMatch = a.match(/((?:\d+\.){3}\d+)/);
15
+ const bVerMatch = b.match(/((?:\d+\.){3}\d+)/);
16
+
17
+ const aVer = aVerMatch ? aVerMatch[0] : '0.0.0.0';
18
+ const bVer = bVerMatch ? bVerMatch[0] : '0.0.0.0';
19
+
20
+ return bVer.localeCompare(aVer, undefined, { numeric: true });
21
+ });
22
+ }
23
+
24
+ private async cleanCache(cachePath: string) {
25
+ try {
26
+ const exists = await fs
27
+ .stat(cachePath)
28
+ .then(() => true)
29
+ .catch(() => false);
30
+ if (!exists) {
31
+ return;
32
+ }
33
+
34
+ const entries = await fs.readdir(cachePath);
35
+ const items: string[] = [];
36
+
37
+ const itemPromises = entries.map(async (entry) => {
38
+ const fullPath = path.join(cachePath, entry);
39
+ const stat = await fs.stat(fullPath);
40
+ if (stat.isDirectory()) {
41
+ items.push(fullPath);
42
+ }
43
+ });
44
+ await Promise.all(itemPromises);
45
+
46
+ if (items.length <= 1) {
47
+ return;
48
+ }
49
+
50
+ const sortedItems = this.sortByVersion(items);
51
+ const [latest, ...oldItems] = sortedItems;
52
+
53
+ const deletePromises = oldItems.map((oldItem) => fs.rm(oldItem, { recursive: true, force: true }));
54
+ await Promise.all(deletePromises);
55
+
56
+ console.log(`[WDIO Cleanup] Deleted old drivers/binaries, kept: ${latest}`);
57
+ } catch (error) {
58
+ console.error(`[WDIO Cleanup] Error cleaning cache at ${cachePath}:`, error);
59
+ }
60
+ }
61
+
62
+ async onComplete() {
63
+ const cacheDir = this.cacheDir ?? 'test/tmp';
64
+ await this.cleanCache(`${cacheDir}/chrome`);
65
+ await this.cleanCache(`${cacheDir}/chromedriver`);
66
+ await fs.rm(`${cacheDir}/profiles`, { recursive: true, force: true });
67
+ }
68
+ }
@@ -0,0 +1,33 @@
1
+ import path from 'path';
2
+
3
+ export function createChromeCapability(cacheDir: string, headless: boolean, extraArgs: string[] = []) {
4
+ const args = [
5
+ '--disable-infobars',
6
+ '--enable-automation',
7
+ '--disable-web-security',
8
+ '--disable-popup-blocking',
9
+ '--disable-notifications',
10
+ '--disable-features=MacAppCodeSignClone',
11
+ '--disable-blink-features=AutomationControlled',
12
+ `--user-data-dir=${path.join(cacheDir, 'profiles')}`,
13
+ ...extraArgs,
14
+ ];
15
+
16
+ if (headless) {
17
+ args.push('--headless=new');
18
+ }
19
+
20
+ return {
21
+ browserName: 'chrome',
22
+ browserVersion: 'stable',
23
+ 'goog:chromeOptions': {
24
+ excludeSwitches: ['enable-automation'],
25
+ args,
26
+ prefs: {
27
+ 'intl.accept_languages': 'en',
28
+ credentials_enable_service: false,
29
+ 'profile.password_manager_enabled': false,
30
+ },
31
+ },
32
+ };
33
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './ChromeCleanupService';
2
+ export * from './createChromeCapability';
@@ -0,0 +1,4 @@
1
+ /** @type {import('stylelint').Config} */
2
+ export default {
3
+ extends: ['@ainias42/config/stylelint.config.mjs'],
4
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "@ainias42/config/tsconfig.json",
3
+ "compilerOptions": {
4
+ "jsx": "react",
5
+ "outDir": "./dist",
6
+ "declaration": true
7
+ },
8
+ "exclude": [
9
+ "../../node_modules",
10
+ "dist/**/*",
11
+ "dist/src/**/*"
12
+ ],
13
+ "include": [
14
+ "src/**/*.tsx",
15
+ "src/**/*.ts",
16
+ "src/**/*.d.ts",
17
+ ]
18
+ }
@@ -0,0 +1,3 @@
1
+ import { getDefaultWebpackConfig } from '@ainias42/webpack-config';
2
+
3
+ module.exports = getDefaultWebpackConfig();