@nlabs/lex 1.48.5 → 1.48.7

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/jest.config.mjs CHANGED
@@ -2,68 +2,65 @@
2
2
  * Copyright (c) 2018-Present, Nitrogen Labs, Inc.
3
3
  * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.
4
4
  */
5
- import {readFileSync} from 'fs';
6
5
  import {fileURLToPath} from 'url';
7
6
  import {dirname, resolve} from 'path';
7
+ import {deepMerge} from './dist/utils/deepMerge.js';
8
+
9
+ import {readFileSync} from 'fs';
8
10
 
9
11
  const __filename = fileURLToPath(import.meta.url);
10
12
  const __dirname = dirname(__filename);
11
13
  const pack = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf8'));
12
14
 
13
- export default {
15
+ let projectJestConfig = null;
16
+ if(process.env.LEX_CONFIG) {
17
+ try {
18
+ const lexConfig = JSON.parse(process.env.LEX_CONFIG);
19
+ projectJestConfig = lexConfig.jest;
20
+ } catch(error) {
21
+ console.warn('Failed to parse LEX_CONFIG:', error.message);
22
+ }
23
+ }
24
+
25
+ const baseConfig = {
26
+ collectCoverage: true,
27
+ coverageDirectory: '<rootDir>/coverage',
28
+ coveragePathIgnorePatterns: [
29
+ '/node_modules/',
30
+ '/dist',
31
+ '/lib',
32
+ '__snapshots__',
33
+ '.d.ts'
34
+ ],
35
+ coverageReporters: ['html', 'text'],
14
36
  displayName: pack.name,
15
- testEnvironment: 'jsdom',
16
37
  moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'node'],
17
- moduleDirectories: ['js', '.', 'node_modules'],
18
38
  moduleNameMapper: {
19
39
  '^(\\.{1,2}/.*)\\.js$': '$1',
20
- '^execa$': resolve(__dirname, '__mocks__/execa.js'),
21
- '^boxen$': resolve(__dirname, '__mocks__/boxen.js'),
22
- '^chalk$': resolve(__dirname, '__mocks__/chalk.js'),
23
- '^ora$': resolve(__dirname, '__mocks__/ora.js'),
24
- '^latest-version$': resolve(__dirname, '__mocks__/latest-version.js'),
25
- '^compare-versions$': resolve(__dirname, '__mocks__/compare-versions.js'),
26
- '.*LexConfig.*': resolve(__dirname, '__mocks__/LexConfig.js'),
27
- '.*build\\.js$': resolve(__dirname, '__mocks__/build.js'),
28
- '.*versions\\.js$': resolve(__dirname, '__mocks__/versions.js'),
29
- '.*compile\\.js$': resolve(__dirname, '__mocks__/compile.js'),
30
- 'utils/file\\.js$': resolve(__dirname, '__mocks__/file.js'),
31
- '.*/utils/file\\.js$': resolve(__dirname, '__mocks__/file.js'),
32
- '^(\\.{1,2}/)*utils/file\\.js$': resolve(__dirname, '__mocks__/file.js'),
33
- // '^(\.{1,2}/.*)\.js$': '$1',
34
- '\.(css|less|scss|sass)$': 'identity-obj-proxy',
35
- '\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': resolve(__dirname, '__mocks__/fileMock.js')
36
40
  },
37
41
  rootDir: process.cwd(),
38
- transformIgnorePatterns: [
39
- 'node_modules/(?!(strip-indent|chalk|@testing-library/jest-dom|zod|@nlabs|@nlabs/arkhamjs|@nlabs/utils|@nlabs/lex|react-markdown|devlop)/.*)'
40
- ],
41
- setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
42
+ testEnvironment: 'node',
43
+ testRegex: '(/__tests__/.*|\\.(test|spec|integration))\\.(ts|tsx)?$',
42
44
  transform: {
43
45
  '^.+\.js$|^.+\.jsx$': ['babel-jest', {
44
46
  presets: [
45
47
  ['@babel/preset-env', {targets: {node: 'current'}}],
46
- '@babel/preset-react'
48
+ '@babel/preset-typescript'
47
49
  ]
48
50
  }],
49
51
  '^.+\.ts$|^.+\.tsx$': ['babel-jest', {
50
52
  presets: [
51
53
  ['@babel/preset-env', {targets: {node: 'current'}}],
52
54
  '@babel/preset-typescript',
53
- '@babel/preset-react'
55
+ ['@babel/preset-react', {runtime: 'automatic'}]
54
56
  ]
55
57
  }]
56
58
  },
57
- testRegex: '(/__tests__/.*|\\.(test|spec|integration))\\.(ts|tsx)?$',
58
- collectCoverage: true,
59
- coverageDirectory: '<rootDir>/coverage',
60
- coveragePathIgnorePatterns: [
61
- '/node_modules/',
62
- '/dist',
63
- '/lib',
64
- '__snapshots__',
65
- '.d.ts'
66
- ],
67
- coverageReporters: ['html', 'text'],
68
59
  verbose: true
69
- };
60
+ };
61
+
62
+ const finalConfig = projectJestConfig && Object.keys(projectJestConfig).length > 0
63
+ ? deepMerge(baseConfig, projectJestConfig)
64
+ : baseConfig;
65
+
66
+ export default finalConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nlabs/lex",
3
- "version": "1.48.5",
3
+ "version": "1.48.7",
4
4
  "description": "Lex",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,7 +15,13 @@
15
15
  "types": "./dist/test-react/index.d.ts",
16
16
  "import": "./dist/test-react/index.js",
17
17
  "require": "./dist/test-react/index.js"
18
- }
18
+ },
19
+ "./storybook": {
20
+ "types": "./dist/storybook/index.d.ts",
21
+ "import": "./dist/storybook/index.js",
22
+ "require": "./dist/storybook/index.js"
23
+ },
24
+ "./eslint.config.js": "./eslint.config.js"
19
25
  },
20
26
  "types": "./dist/index.d.ts",
21
27
  "keywords": [
@@ -48,7 +54,7 @@
48
54
  "clean": "rm -rf dist node_modules package-lock.json *.log coverage",
49
55
  "compile": "tsc -p tsconfig.build.json",
50
56
  "env": "LEX_CONFIG='{\"useTypescript\":true}'",
51
- "lint": "eslint ./src --fix",
57
+ "lint": "eslint ./src --fix --no-warn-ignored",
52
58
  "lint:ai": "node ./dist/lex.js lint --fix",
53
59
  "lint:rebuild": "npm run build && npm run lint:ai",
54
60
  "prepublishOnly": "npm run build",
@@ -106,7 +112,7 @@
106
112
  "ajv": "^8.17.1",
107
113
  "assert": "^2.1.0",
108
114
  "autoprefixer": "^10.4.21",
109
- "babel-jest": "^30.0.4",
115
+ "babel-jest": "^29.7.0",
110
116
  "babel-loader": "^10.0.0",
111
117
  "babel-plugin-module-resolver": "^5.0.2",
112
118
  "babel-plugin-transform-import-meta": "^2.3.3",
@@ -124,12 +130,13 @@
124
130
  "css-loader": "^7.1.2",
125
131
  "cssnano": "^7.1.0",
126
132
  "dotenv-webpack": "^8.1.1",
127
- "download-npm-package": "^3.1.12",
133
+ "download-npm-package": "^3.1.5",
128
134
  "esbuild": "0.25.6",
129
135
  "esbuild-loader": "4.3.0",
130
136
  "eslint": "^9.31.0",
131
137
  "eslint-config-styleguidejs": "^4.0.22",
132
138
  "execa": "9.6.0",
139
+ "expect": "^29.7.0",
133
140
  "exports-loader": "^5.0.0",
134
141
  "favicons-webpack-plugin": "^6.0.1",
135
142
  "file-loader": "^6.2.0",
@@ -179,7 +186,7 @@
179
186
  "rimraf": "^6.0.1",
180
187
  "semver": "^7.7.2",
181
188
  "speed-measure-webpack-plugin": "^1.5.0",
182
- "static-site-generator-webpack-plugin": "^3.4.2",
189
+ "static-site-generator-webpack-plugin": "^3.3.0",
183
190
  "storybook": "^9.0.17",
184
191
  "stream-browserify": "^3.0.0",
185
192
  "stream-http": "^3.2.0",
@@ -187,7 +194,6 @@
187
194
  "svg-spritemap-webpack-plugin": "^4.7.0",
188
195
  "svgo": "4.0.0",
189
196
  "tls": "^0.0.1",
190
- "ts-jest": "^29.4.0",
191
197
  "ts-node": "^10.9.2",
192
198
  "tsconfig-paths-webpack-plugin": "^4.2.0",
193
199
  "typescript": "5.8.3",
@@ -203,7 +209,10 @@
203
209
  "webpack-plugin-serve": "^1.6.0"
204
210
  },
205
211
  "devDependencies": {
206
- "@types/jest": "^30.0.0",
212
+ "@babel/plugin-transform-react-jsx": "^7.27.1",
213
+ "@babel/runtime": "^7.27.6",
214
+ "@babel/runtime-corejs3": "^7.28.0",
215
+ "@types/jest": "^29.5.14",
207
216
  "@types/luxon": "^3.6.2",
208
217
  "@types/node": "^24.0.14",
209
218
  "@types/ora": "^3.2.0",
@@ -8,7 +8,7 @@
8
8
  "esModuleInterop": true,
9
9
  "inlineSourceMap": true,
10
10
  "isolatedModules": true,
11
- "jsx": "react",
11
+ "jsx": "react-jsx",
12
12
  "lib": [
13
13
  "dom",
14
14
  "ESNext"
package/tsconfig.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "esModuleInterop": true,
8
8
  "inlineSourceMap": true,
9
9
  "isolatedModules": true,
10
- "jsx": "react",
10
+ "jsx": "react-jsx",
11
11
  "lib": [
12
12
  "dom",
13
13
  "ESNext"
@@ -11,7 +11,7 @@
11
11
  "forceConsistentCasingInFileNames": true,
12
12
  "inlineSourceMap": false,
13
13
  "isolatedModules": true,
14
- "jsx": "react",
14
+ "jsx": "react-jsx",
15
15
  "lib": [
16
16
  "ESNext",
17
17
  "DOM"
@@ -5,7 +5,7 @@
5
5
  "emitDeclarationOnly": true,
6
6
  "esModuleInterop": true,
7
7
  "inlineSourceMap": true,
8
- "jsx": "react",
8
+ "jsx": "react-jsx",
9
9
  "lib": [
10
10
  "ESNext",
11
11
  "dom"
@@ -32,4 +32,4 @@
32
32
  "./lib",
33
33
  "./node_modules"
34
34
  ]
35
- }
35
+ }
@@ -10,7 +10,7 @@
10
10
  "forceConsistentCasingInFileNames": true,
11
11
  "inlineSourceMap": true,
12
12
  "isolatedModules": true,
13
- "jsx": "react",
13
+ "jsx": "react-jsx",
14
14
  "lib": [
15
15
  "ESNext",
16
16
  "DOM"
@@ -1,103 +0,0 @@
1
- # TypeScript Configurations in Lex
2
-
3
- Lex now uses specialized TypeScript configurations for different commands to optimize performance and functionality.
4
-
5
- ## Configuration Files
6
-
7
- ### 1. `tsconfig.build.json` - For Compilation and Building
8
-
9
- Used by: `lex compile`, `lex build`
10
-
11
- **Purpose:** Optimized for compilation and bundling with ESM output.
12
-
13
- **Key Features:**
14
-
15
- - ESM module format (`"module": "ESNext"`)
16
- - Declaration file generation (`"declaration": true`)
17
- - Source maps for debugging (`"inlineSourceMap": true`)
18
- - Strict type checking (`"strict": true`)
19
- - Excludes test files for faster compilation
20
-
21
- **Use Cases:**
22
-
23
- - Building production bundles
24
- - Generating type declarations
25
- - Compiling source code for distribution
26
-
27
- ### 2. `tsconfig.lint.json` - For Static Analysis
28
-
29
- Used by: `lex lint`
30
-
31
- **Purpose:** Optimized for static analysis and linting.
32
-
33
- **Key Features:**
34
-
35
- - No emission (`"noEmit": true`)
36
- - Strict unused variable checking (`"noUnusedLocals": true`)
37
- - Disabled pretty printing for faster analysis
38
- - Excludes test files to focus on source code
39
- - ESLint-friendly settings
40
-
41
- **Use Cases:**
42
-
43
- - Static type checking
44
- - Code quality analysis
45
- - Linting with ESLint + TypeScript
46
-
47
- ### 3. `tsconfig.test.json` - For Testing
48
-
49
- Used by: `lex test`
50
-
51
- **Purpose:** Optimized for testing environment.
52
-
53
- **Key Features:**
54
-
55
- - Includes test files (`**/*.test.*`, `**/*.spec.*`)
56
- - Jest types included (`"types": ["jest", "node"]`)
57
- - Relaxed strict mode for test flexibility (`"strict": false`)
58
- - Source maps for debugging tests
59
- - Coverage reporting support
60
-
61
- **Use Cases:**
62
-
63
- - Running unit tests
64
- - Integration testing
65
- - Test debugging and coverage
66
-
67
- ## Automatic Configuration
68
-
69
- Lex automatically creates these configuration files when needed:
70
-
71
- 1. **First run:** If no specialized config exists, Lex creates it from templates
72
- 2. **Fallback:** If specialized config doesn't exist, falls back to default `tsconfig.json`
73
- 3. **Custom configs:** You can override any config by creating your own version
74
-
75
- ## Migration from Single Config
76
-
77
- If you're migrating from a single `tsconfig.json`:
78
-
79
- 1. **Keep your existing config:** It will be used as a fallback
80
- 2. **Customize specialized configs:** Modify the generated configs for your needs
81
- 3. **Gradual adoption:** Commands will automatically use the appropriate config
82
-
83
- ## Customization
84
-
85
- You can customize any of these configurations:
86
-
87
- ```json
88
- // tsconfig.build.json - Customize for your build needs
89
- {
90
- "extends": "../../tsconfig.base.json",
91
- "compilerOptions": {
92
- "outDir": "./lib", // Custom output directory
93
- "target": "ES2020" // Custom target
94
- }
95
- }
96
- ```
97
-
98
- ## Benefits
99
-
100
- 1. **Performance:** Each config is optimized for its specific use case
101
- 2. **Clarity:** Clear separation of concerns between compilation, linting, and testing
102
- 3. **Flexibility:** Easy to customize each workflow independently
103
- 4. **Compatibility:** Maintains backward compatibility with existing setups
package/jest.setup.js DELETED
@@ -1,34 +0,0 @@
1
- require('@testing-library/jest-dom');
2
-
3
- const originalReadFileSync = require('fs').readFileSync;
4
- require('fs').readFileSync = jest.fn((path, encoding) => {
5
- if (path && path.toString().includes('package.json')) {
6
- return JSON.stringify({
7
- version: '1.0.0',
8
- dependencies: {
9
- esbuild: '^0.19.0',
10
- jest: '^29.0.0',
11
- typescript: '^5.0.0',
12
- webpack: '^5.0.0'
13
- }
14
- });
15
- }
16
- return originalReadFileSync(path, encoding);
17
- });
18
-
19
- global.ResizeObserver = jest.fn().mockImplementation(() => ({
20
- observe: jest.fn(),
21
- unobserve: jest.fn(),
22
- disconnect: jest.fn(),
23
- }));
24
-
25
- global.matchMedia = jest.fn().mockImplementation(query => ({
26
- matches: false,
27
- media: query,
28
- onchange: null,
29
- addListener: jest.fn(),
30
- removeListener: jest.fn(),
31
- addEventListener: jest.fn(),
32
- removeEventListener: jest.fn(),
33
- dispatchEvent: jest.fn(),
34
- }));