@dev-blinq/cucumber_client 1.0.1247-dev → 1.0.1249-dev
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.
|
@@ -24,7 +24,7 @@ const getMatchingElements = (selector, options = {}) => {
|
|
|
24
24
|
const root = options?.root || window.document;
|
|
25
25
|
const prefix = options?.prefix;
|
|
26
26
|
if (prefix) {
|
|
27
|
-
selector = `${prefix} >> ${selector}`;
|
|
27
|
+
selector = `${prefix} >> ${selector} >> visible=true`;
|
|
28
28
|
}
|
|
29
29
|
return window.__injectedScript.querySelectorAll(window.__injectedScript.parseSelector(selector), root);
|
|
30
30
|
};
|
|
@@ -287,7 +287,39 @@ export function removeUnusedElementsKeys(ast, supportFilePath) {
|
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
|
|
290
|
+
export function getDefaultPrettierConfig() {
|
|
291
|
+
let prettierConfig = {
|
|
292
|
+
parser: "babel",
|
|
293
|
+
trailingComma: "es5",
|
|
294
|
+
tabWidth: 2,
|
|
295
|
+
semi: true,
|
|
296
|
+
singleQuote: false,
|
|
297
|
+
bracketSpacing: true,
|
|
298
|
+
arrowParens: "always",
|
|
299
|
+
embeddedLanguageFormatting: "auto",
|
|
300
|
+
endOfLine: "lf",
|
|
301
|
+
printWidth: 120,
|
|
302
|
+
};
|
|
303
|
+
// check if .prettierrc file exists
|
|
304
|
+
const prettierConfigPath = ".prettierrc";
|
|
305
|
+
if (existsSync(prettierConfigPath)) {
|
|
306
|
+
try {
|
|
307
|
+
const configContent = readFileSync(prettierConfigPath, "utf-8");
|
|
308
|
+
prettierConfig = JSON.parse(configContent);
|
|
309
|
+
} catch (error) {
|
|
310
|
+
console.error(`Error parsing Prettier config file: ${error}`);
|
|
311
|
+
}
|
|
312
|
+
} else {
|
|
313
|
+
// save the default config to .prettierrc
|
|
314
|
+
try {
|
|
315
|
+
writeFileSync(prettierConfigPath, JSON.stringify(prettierConfig, null, 2), "utf-8");
|
|
316
|
+
console.log(`Created default Prettier config at ${prettierConfigPath}`);
|
|
317
|
+
} catch (error) {
|
|
318
|
+
console.error(`Error writing Prettier config file: ${error}`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return prettierConfig;
|
|
322
|
+
}
|
|
291
323
|
/**
|
|
292
324
|
* Remove unused step definitions from a file.
|
|
293
325
|
* @param {string} filePath
|
|
@@ -306,19 +338,10 @@ export async function removeUnusedStepDefinitions(filePath, stepDefinitions) {
|
|
|
306
338
|
// removeUnusedImports(ast);
|
|
307
339
|
let code = generateCode(ast);
|
|
308
340
|
|
|
341
|
+
// configuration object
|
|
342
|
+
const prettierConfig = getDefaultPrettierConfig();
|
|
309
343
|
// Format the code using Prettier
|
|
310
|
-
code = await prettier.format(code,
|
|
311
|
-
parser: "babel",
|
|
312
|
-
trailingComma: "es5",
|
|
313
|
-
tabWidth: 2,
|
|
314
|
-
semi: true,
|
|
315
|
-
singleQuote: false,
|
|
316
|
-
bracketSpacing: true,
|
|
317
|
-
arrowParens: "always",
|
|
318
|
-
embeddedLanguageFormatting: "auto",
|
|
319
|
-
endOfLine: "lf",
|
|
320
|
-
printWidth: 120,
|
|
321
|
-
});
|
|
344
|
+
code = await prettier.format(code, prettierConfig);
|
|
322
345
|
|
|
323
346
|
await fs.writeFile(filePath, code, "utf-8");
|
|
324
347
|
console.log(`Removed unused step definitions from ${filePath}`);
|
|
@@ -6,6 +6,7 @@ import logger from "../../logger.js";
|
|
|
6
6
|
import { convertToIdentifier } from "./utils.js";
|
|
7
7
|
import prettier from "prettier";
|
|
8
8
|
import url from "url";
|
|
9
|
+
import { getDefaultPrettierConfig } from "../code_cleanup/utils.js";
|
|
9
10
|
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
10
11
|
const CodeStatus = {
|
|
11
12
|
ADD: "add",
|
|
@@ -57,18 +58,7 @@ class CodePage {
|
|
|
57
58
|
if (this.sourceFileName !== null) {
|
|
58
59
|
// format the code before saving
|
|
59
60
|
try {
|
|
60
|
-
const fileContentNew = await prettier.format(this.fileContent,
|
|
61
|
-
parser: "babel",
|
|
62
|
-
trailingComma: "es5",
|
|
63
|
-
tabWidth: 2,
|
|
64
|
-
semi: true,
|
|
65
|
-
singleQuote: false,
|
|
66
|
-
bracketSpacing: true,
|
|
67
|
-
arrowParens: "always",
|
|
68
|
-
embeddedLanguageFormatting: "auto",
|
|
69
|
-
endOfLine: "lf",
|
|
70
|
-
printWidth: 120,
|
|
71
|
-
});
|
|
61
|
+
const fileContentNew = await prettier.format(this.fileContent, getDefaultPrettierConfig());
|
|
72
62
|
this._init();
|
|
73
63
|
this.generateModel(fileContentNew);
|
|
74
64
|
} catch (e) {
|