@nlabs/lex 1.48.3 → 1.48.5

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.
Files changed (63) hide show
  1. package/.storybook/main.ts +25 -4
  2. package/.vscode/settings.json +1 -1
  3. package/README.md +293 -22
  4. package/__mocks__/compare-versions.js +3 -0
  5. package/__mocks__/fileMock.js +1 -0
  6. package/__mocks__/latest-version.js +1 -0
  7. package/__mocks__/react-markdown.js +12 -0
  8. package/babel.config.json +2 -1
  9. package/dist/Button.stories.d.ts +19 -0
  10. package/dist/LexConfig.d.ts +84 -0
  11. package/dist/LexConfig.js +1 -4
  12. package/dist/commands/ai/ai.d.ts +17 -0
  13. package/dist/commands/ai/index.d.ts +8 -0
  14. package/dist/commands/build/build.d.ts +18 -0
  15. package/dist/commands/clean/clean.d.ts +7 -0
  16. package/dist/commands/compile/compile.d.ts +2 -0
  17. package/dist/commands/config/config.d.ts +7 -0
  18. package/dist/commands/config/config.js +2 -2
  19. package/dist/commands/copy/copy.d.ts +6 -0
  20. package/dist/commands/create/create.d.ts +8 -0
  21. package/dist/commands/dev/dev.d.ts +11 -0
  22. package/dist/commands/init/init.d.ts +9 -0
  23. package/dist/commands/link/link.d.ts +6 -0
  24. package/dist/commands/lint/autofix.d.ts +2 -0
  25. package/dist/commands/lint/lint.d.ts +39 -0
  26. package/dist/commands/migrate/migrate.d.ts +7 -0
  27. package/dist/commands/publish/publish.d.ts +12 -0
  28. package/dist/commands/storybook/storybook.d.ts +13 -0
  29. package/dist/commands/storybook/storybook.js +3 -5
  30. package/dist/commands/test/test.d.ts +50 -0
  31. package/dist/commands/test/test.js +80 -10
  32. package/dist/commands/update/update.d.ts +9 -0
  33. package/dist/commands/upgrade/upgrade.d.ts +7 -0
  34. package/dist/commands/versions/versions.d.ts +13 -0
  35. package/dist/create/changelog.d.ts +6 -0
  36. package/dist/index.d.ts +33 -0
  37. package/dist/index.js +2 -1
  38. package/dist/lex.d.ts +2 -0
  39. package/dist/test-react/index.d.ts +8 -0
  40. package/dist/test-react/index.js +86 -0
  41. package/dist/types.d.ts +5 -0
  42. package/dist/utils/aiService.d.ts +9 -0
  43. package/dist/utils/app.d.ts +45 -0
  44. package/dist/utils/file.d.ts +8 -0
  45. package/dist/utils/file.js +9 -3
  46. package/dist/utils/log.d.ts +1 -0
  47. package/dist/utils/reactShim.d.ts +4 -0
  48. package/dist/utils/reactShim.js +82 -2
  49. package/jest.config.d.mts +50 -0
  50. package/jest.config.mjs +69 -0
  51. package/jest.config.template.cjs +63 -0
  52. package/jest.setup.js +18 -15
  53. package/jest.setup.template.js +18 -0
  54. package/package.json +24 -7
  55. package/tsconfig.build.json +8 -10
  56. package/tsconfig.lint.json +2 -2
  57. package/tsconfig.test.json +2 -2
  58. package/dist/dist/LexConfig.d.ts +0 -119
  59. package/dist/dist/utils/file.d.ts +0 -8
  60. package/dist/dist/utils/log.d.ts +0 -1
  61. package/dist/jest.config.lex.d.ts +0 -2
  62. package/jest.config.cjs +0 -43
  63. package/jest.config.lex.js +0 -118
@@ -1,118 +0,0 @@
1
- import {existsSync} from 'fs';
2
- import {resolve as pathResolve} from 'path';
3
- import {URL} from 'url';
4
-
5
- import {getNodePath} from './dist/utils/file.js';
6
-
7
- const rootDir = process.cwd();
8
- const { jest, sourceFullPath, targetEnvironment, useTypescript } = JSON.parse(
9
- process.env.LEX_CONFIG || '{}'
10
- );
11
-
12
- const dirName = new URL('.', import.meta.url).pathname;
13
- const nodePath = pathResolve(dirName, './node_modules');
14
- const lexSetupFile = pathResolve(dirName, './jest.setup.js');
15
- const projectSetupFile = pathResolve(rootDir, './jest.setup.js');
16
- const setupFilesAfterEnv = [];
17
-
18
- setupFilesAfterEnv.push(lexSetupFile);
19
-
20
- if(existsSync(projectSetupFile)) {
21
- setupFilesAfterEnv.push(projectSetupFile);
22
- }
23
-
24
- let testEnvironment = 'node';
25
- let testEnvironmentOptions = {};
26
-
27
- if(targetEnvironment === 'web') {
28
- testEnvironment = 'jsdom';
29
- testEnvironmentOptions = {
30
- url: 'http://localhost'
31
- };
32
- }
33
-
34
- let moduleFileExtensions = ['js', 'json', 'cjs', 'mjs'];
35
- let testRegex = '(/__tests__/.*|\\.(test|spec|integration))\\.(js)?$';
36
- let transformIgnorePatterns = [];
37
-
38
- if(useTypescript) {
39
- moduleFileExtensions = ['js', 'ts', 'tsx', 'json', 'cjs', 'mjs'];
40
- testRegex = '(/__tests__/.*|\\.(test|spec|integration))\\.(ts|tsx)?$';
41
- transformIgnorePatterns = [];
42
- }
43
-
44
- const baseConfig = {
45
- collectCoverage: true,
46
- coverageDirectory: '<rootDir>/coverage',
47
- coveragePathIgnorePatterns: [
48
- '/node_modules/',
49
- '/dist',
50
- '/lib',
51
- '__snapshots__',
52
- '.d.ts'
53
- ],
54
- coverageReporters: ['html', 'text'],
55
- extensionsToTreatAsEsm: ['.ts', '.tsx'],
56
- moduleDirectories: ['node_modules', nodePath],
57
- moduleFileExtensions,
58
- moduleNameMapper: {
59
- '^chalk$': getNodePath('chalk/source/index.js'),
60
- '^#ansi-styles$': getNodePath('chalk/node_modules/ansi-styles/index.js'),
61
- '^#supports-color$': getNodePath('chalk/node_modules/supports-color/index.js'),
62
- '\\.(css|jpg|png|svg|txt)$': pathResolve(dirName, './emptyModule')
63
- },
64
- modulePaths: [rootDir, `${rootDir}/node_modules`, nodePath, sourceFullPath],
65
- resolver: pathResolve(dirName, './resolver.cjs'),
66
- rootDir,
67
- setupFiles: [
68
- getNodePath('core-js'),
69
- getNodePath('regenerator-runtime/runtime.js')
70
- ],
71
- setupFilesAfterEnv,
72
- testEnvironment,
73
- testEnvironmentOptions,
74
- testPathIgnorePatterns: ['/node_modules/', `${nodePath}/`],
75
- testRegex,
76
- transform: {
77
- ...(useTypescript ? {
78
- '\\.tsx?$': [getNodePath('ts-jest/dist/index.js'), {
79
- useESM: true,
80
- tsconfig: {
81
- useDefineForClassFields: true,
82
- esModuleInterop: true,
83
- allowSyntheticDefaultImports: true
84
- }
85
- }]
86
- } : {
87
- '\\.[jt]sx?$': getNodePath('babel-jest')
88
- }),
89
- '\\.(gql|graphql)$': getNodePath('jest-transform-graphql'),
90
- '\\.mjs$': [getNodePath('ts-jest/dist/index.js'), {
91
- useESM: true
92
- }],
93
- '\\.cjs$': getNodePath('babel-jest')
94
- },
95
- transformIgnorePatterns: [
96
- 'node_modules/(?!(chalk|@testing-library/jest-dom|zod|@nlabs)/)'
97
- ],
98
- verbose: true
99
- };
100
-
101
- const deepMerge = (target, source) => {
102
- if(!source) return target;
103
- const output = { ...target };
104
-
105
- Object.keys(source).forEach(key => {
106
- if(source[key] instanceof Object && key in target && target[key] instanceof Object && !Array.isArray(source[key]) && !Array.isArray(target[key])) {
107
- output[key] = {...target[key], ...source[key]};
108
- } else if(Array.isArray(source[key]) && Array.isArray(target[key])) {
109
- output[key] = [...target[key], ...source[key]];
110
- } else {
111
- output[key] = source[key];
112
- }
113
- });
114
-
115
- return output;
116
- };
117
-
118
- export default deepMerge(baseConfig, jest);