generator-bitloops 0.3.9 → 0.3.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-bitloops",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "Next.js with TypeScript, Tailwind, Storybook and Cypress generator by Bitloops",
5
5
  "license": "MIT",
6
6
  "author": "Bitloops S.A.",
package/setup/index.js CHANGED
@@ -8,11 +8,35 @@ import { fileURLToPath } from 'url';
8
8
  const __filename = fileURLToPath(import.meta.url);
9
9
  const __dirname = path.dirname(__filename);
10
10
 
11
+ function isKebabCase(str) {
12
+ // Check if the string is empty
13
+ if (!str || str.trim().length === 0) {
14
+ return false;
15
+ }
16
+
17
+ // Regular expression to check if a string is kebab-case,
18
+ // ensuring it starts with a lowercase letter or digit, allowing for lowercase letters and digits in the middle or end,
19
+ // and ensuring each new word starts with a lowercase letter or digit
20
+ const kebabCaseRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
21
+
22
+ return kebabCaseRegex.test(str);
23
+ }
24
+
11
25
  function toKebabCase(str) {
12
- return str
13
- .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
14
- .toLowerCase()
15
- .replace(/\s+/g, '-');
26
+ if (isKebabCase(str)) {
27
+ return str;
28
+ }
29
+
30
+ const words = str
31
+ .trim()
32
+ // Split by non-alphanumeric characters and the transition from lowercase to uppercase
33
+ .split(/(?=[A-Z])|[^a-zA-Z0-9]+/)
34
+ .filter((word) => word.length > 0);
35
+
36
+ return words
37
+ .map((word) => word.toLowerCase())
38
+ .filter((word) => word.length > 0) // Remove empty words
39
+ .join('-');
16
40
  }
17
41
 
18
42
  export default class extends Generator {
@@ -11,6 +11,13 @@ export const isOutOfBounds = (inRect: DOMRect, outRect: DOMRect): boolean => {
11
11
  return isOut;
12
12
  };
13
13
 
14
+ export const isOutOfHorizontalBounds = (inRect: DOMRect, outRect: DOMRect): boolean => {
15
+ const isOut =
16
+ inRect.left < outRect.left ||
17
+ inRect.right > outRect.right;
18
+ return isOut;
19
+ };
20
+
14
21
  export const hasHorizontalScroll = (document: Document): boolean => {
15
22
  const scrollingElement = document.scrollingElement;
16
23
  if (!scrollingElement) {
@@ -1,32 +1,25 @@
1
1
  import { defineConfig } from 'cypress';
2
- import * as fs from 'fs';
3
- import * as path from 'path';
4
2
 
5
3
  export default defineConfig({
6
4
  e2e: {
7
5
  specPattern: "**/*.cy.{ts,tsx}",
8
6
  supportFile: false,
9
7
  testIsolation: false,
10
- setupNodeEvents(on) {
11
- on('task', {
12
- saveTestResults(results) {
13
- const resultsPath = path.join(__dirname, '.', 'cypress', 'results', 'results.json');
14
- if (!fs.existsSync(resultsPath)) {
15
- fs.writeFileSync(resultsPath, '[]'); // Create file if it doesn't exist
16
- }
17
- const existingResults = JSON.parse(fs.readFileSync(resultsPath, 'utf8'));
18
- existingResults.push(JSON.parse(results));
19
- fs.writeFileSync(resultsPath, JSON.stringify(existingResults, null, 2));
20
- return null; // Indicate the task was successful
21
- }
22
- });
23
- },
24
8
  },
25
9
  reporter: "mochawesome",
26
- reporterOptions: {
27
- reportDir: "cypress/results",
28
- overwrite: true,
29
- html: true,
30
- json: true,
31
- },
10
+ reporterOptions: {
11
+ reportDir: "cypress/results",
12
+ overwrite: true,
13
+ html: true,
14
+ json: true,
15
+ reportTitle: "Component Testing",
16
+ reportPageTitle: "Bitloops Component Testing",
17
+ charts: true,
18
+ reportFilename: "report",
19
+ code: true,
20
+ showPassed: true,
21
+ showFailed: true,
22
+ showSkipped: true,
23
+ saveJson: true,
24
+ },
32
25
  });