@neovici/cfg 2.7.5 → 2.8.0

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.
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable no-console */
3
+ /**
4
+ * Check for duplicate @neovici/cosmoz-* web components in package-lock.json
5
+ *
6
+ * Web components register themselves globally via customElements.define().
7
+ * Having multiple versions of the same component causes runtime errors
8
+ * because the second version fails to register with the same tag name.
9
+ */
10
+
11
+ import { readFileSync, existsSync } from 'fs';
12
+ import { join } from 'path';
13
+
14
+ const LOCKFILE = 'package-lock.json',
15
+ PACKAGE_PATTERN = /^@neovici\/cosmoz-/u,
16
+ PACKAGE_NAME_PATTERN = /node_modules\/(@[^/]+\/[^/]+|[^/]+)$/u;
17
+
18
+ const readLockfile = (lockfilePath) => {
19
+ if (!existsSync(lockfilePath)) {
20
+ console.error(`ERROR: ${lockfilePath} not found`);
21
+ process.exit(1);
22
+ }
23
+
24
+ const lockfile = JSON.parse(readFileSync(lockfilePath, 'utf8'));
25
+
26
+ if (lockfile.lockfileVersion < 2) {
27
+ console.error('ERROR: This script requires lockfileVersion >= 2');
28
+ process.exit(1);
29
+ }
30
+
31
+ return lockfile;
32
+ };
33
+
34
+ const extractPackageName = (path) => {
35
+ const match = path.match(PACKAGE_NAME_PATTERN);
36
+ return match?.[1];
37
+ };
38
+
39
+ const collectComponentVersions = (packages) => {
40
+ const componentVersions = new Map();
41
+
42
+ for (const [path, info] of Object.entries(packages)) {
43
+ if (!path.startsWith('node_modules/')) continue;
44
+
45
+ const packageName = extractPackageName(path);
46
+ if (!packageName || !PACKAGE_PATTERN.test(packageName)) continue;
47
+
48
+ const { version } = info;
49
+ if (!version) continue;
50
+
51
+ if (!componentVersions.has(packageName)) {
52
+ componentVersions.set(packageName, []);
53
+ }
54
+ componentVersions.get(packageName).push({ version, path });
55
+ }
56
+
57
+ return componentVersions;
58
+ };
59
+
60
+ const findDuplicates = (componentVersions) =>
61
+ [...componentVersions.entries()]
62
+ .filter(([, instances]) => {
63
+ const uniqueVersions = new Set(instances.map((i) => i.version));
64
+ return uniqueVersions.size > 1;
65
+ })
66
+ .map(([packageName, instances]) => ({ packageName, instances }));
67
+
68
+ const printDuplicates = (duplicates) => {
69
+ console.error('ERROR: Duplicate web components detected!\n');
70
+ console.error('Web components register themselves globally. Having multiple');
71
+ console.error('versions will cause runtime conflicts and errors.\n');
72
+
73
+ for (const { packageName, instances } of duplicates) {
74
+ console.error(`${packageName}:`);
75
+ for (const { version, path } of instances) {
76
+ console.error(` - ${version} at ${path}`);
77
+ }
78
+ console.error('');
79
+ }
80
+
81
+ console.error('Fix: Update your dependencies to ensure all packages use');
82
+ console.error('compatible version ranges of web components.\n');
83
+ console.error('Run `npm ls <package-name>` to see the dependency tree');
84
+ console.error('and identify which packages need updating.');
85
+ };
86
+
87
+ const main = () => {
88
+ const lockfilePath = join(process.cwd(), LOCKFILE),
89
+ lockfile = readLockfile(lockfilePath),
90
+ componentVersions = collectComponentVersions(lockfile.packages || {}),
91
+ duplicates = findDuplicates(componentVersions);
92
+
93
+ if (duplicates.length === 0) {
94
+ console.log('✓ No duplicate web components found');
95
+ process.exit(0);
96
+ }
97
+
98
+ printDuplicates(duplicates);
99
+ process.exit(1);
100
+ };
101
+
102
+ main();
@@ -1,8 +1,8 @@
1
- import tseslint from 'typescript-eslint';
1
+ import tseslint, { configs } from 'typescript-eslint';
2
2
 
3
3
  export default tseslint.config({
4
4
  files: ['**/*.+(ts|tsx)'],
5
- extends: [tseslint.configs.recommended],
5
+ extends: [configs.recommended],
6
6
  rules: {
7
7
  'import/named': 'off',
8
8
  'no-unused-vars': 'off',
@@ -0,0 +1,11 @@
1
+ import cfg from './eslint/index.mjs';
2
+ import globals from 'globals';
3
+
4
+ export default [
5
+ ...cfg,
6
+ {
7
+ languageOptions: {
8
+ globals: { ...globals.node },
9
+ },
10
+ },
11
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cfg",
3
- "version": "2.7.5",
3
+ "version": "2.8.0",
4
4
  "description": "Configuration for Neovici packages",
5
5
  "homepage": "https://github.com/Neovici/cfg#readme",
6
6
  "bugs": {
@@ -13,6 +13,9 @@
13
13
  "license": "Apache-2.0",
14
14
  "author": "Neovici dev",
15
15
  "main": "index.js",
16
+ "bin": {
17
+ "check-duplicate-components": "./check-duplicate-components.mjs"
18
+ },
16
19
  "files": [
17
20
  "eslint/*.js",
18
21
  "eslint/*.mjs",
@@ -20,7 +23,8 @@
20
23
  "prettier/*.mjs",
21
24
  "web/*.js",
22
25
  "web/*.mjs",
23
- "*.js"
26
+ "*.js",
27
+ "*.mjs"
24
28
  ],
25
29
  "scripts": {
26
30
  "lint": "eslint --cache .",
@@ -45,26 +49,26 @@
45
49
  ]
46
50
  },
47
51
  "dependencies": {
48
- "@eslint/eslintrc": "^3.2.0",
49
- "@eslint/js": "^9.18.0",
52
+ "@eslint/eslintrc": "^3.3.3",
53
+ "@eslint/js": "^9.39.2",
50
54
  "@playwright/test": "^1.40.1",
51
55
  "@web/dev-server": "^0.4.0",
52
56
  "@web/dev-server-esbuild": "^1.0.0",
53
57
  "@web/test-runner": "^0.20.0",
54
58
  "@web/test-runner-commands": "^0.9.0",
55
59
  "@web/test-runner-playwright": "^0.11.0",
56
- "eslint": "^9.0.0",
57
- "eslint-config-prettier": "^10.0.0",
58
- "eslint-import-resolver-alias": "^1.0.0",
59
- "eslint-import-resolver-typescript": "^4.0.0",
60
- "eslint-plugin-html": "^8.0.0",
61
- "eslint-plugin-import": "^2.0.0",
62
- "eslint-plugin-mocha": "^11.0.0",
63
- "globals": "^16.0.0",
60
+ "eslint": "^9.39.2",
61
+ "eslint-config-prettier": "^10.1.8",
62
+ "eslint-import-resolver-alias": "^1.1.2",
63
+ "eslint-import-resolver-typescript": "^4.4.4",
64
+ "eslint-plugin-html": "^8.1.3",
65
+ "eslint-plugin-import": "^2.32.0",
66
+ "eslint-plugin-mocha": "^11.2.0",
67
+ "globals": "^17.0.0",
64
68
  "prettier": "^3.0.0",
65
69
  "prettier-plugin-organize-imports": "^4.3.0",
66
70
  "typescript": "^5.1.0",
67
- "typescript-eslint": "^8.20.0"
71
+ "typescript-eslint": "^8.53.0"
68
72
  },
69
73
  "devDependencies": {
70
74
  "@commitlint/cli": "^20.0.0",
package/web/performer.mjs CHANGED
@@ -13,7 +13,6 @@ const perform = async (payload, context) => {
13
13
 
14
14
  export const performer = () => ({
15
15
  name: 'cz-performer',
16
- // eslint-disable-next-line max-statements
17
16
  async executeCommand({ command, payload, session }) {
18
17
  if (command !== 'cz-perform') return;
19
18
  if (session.browser.type !== 'playwright') return;