@dev-blinq/cucumber_client 1.0.1246-dev → 1.0.1248-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.
@@ -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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1246-dev",
3
+ "version": "1.0.1248-dev",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "@cucumber/tag-expressions": "^6.1.1",
29
29
  "@dev-blinq/cucumber-js": "1.0.173-dev",
30
30
  "@faker-js/faker": "^8.1.0",
31
- "automation_model": "1.0.744-dev",
31
+ "automation_model": "1.0.745-dev",
32
32
  "axios": "^1.7.4",
33
33
  "chokidar": "^3.6.0",
34
34
  "create-require": "^1.1.1",