@open-mercato/ui 0.6.8-develop.6881.1.8ea75912f2 → 0.6.8-develop.6889.1.af4501ca97
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.cjs
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
/** @type {import('jest').Config} */
|
|
2
2
|
const base = require('../../jest.config.base.cjs')
|
|
3
3
|
|
|
4
|
+
const transformer = [
|
|
5
|
+
'<rootDir>/../../scripts/jest-mikroorm-transformer.cjs',
|
|
6
|
+
{
|
|
7
|
+
tsconfig: {
|
|
8
|
+
jsx: 'react-jsx',
|
|
9
|
+
rootDir: '.',
|
|
10
|
+
ignoreDeprecations: '6.0',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
// Jest does not interpolate `<rootDir>` in transform *keys* (only in the transformer
|
|
16
|
+
// path), so the repo's own `scripts/*.cjs` emitters are selected by requiring a
|
|
17
|
+
// `scripts/` segment and excluding `node_modules` outright — third-party `.cjs` inside
|
|
18
|
+
// the allowlisted ESM packages stays untransformed.
|
|
19
|
+
const SCRIPTS_CJS_PATTERN = '^(?!.*[\\\\/]node_modules[\\\\/]).*[\\\\/]scripts[\\\\/].+\\.cjs$'
|
|
20
|
+
|
|
4
21
|
module.exports = {
|
|
5
22
|
...base,
|
|
6
23
|
testEnvironment: 'jsdom',
|
|
@@ -16,17 +33,9 @@ module.exports = {
|
|
|
16
33
|
'^remark-gfm$': '<rootDir>/jest.markdown-mock.tsx',
|
|
17
34
|
},
|
|
18
35
|
transform: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
tsconfig: {
|
|
24
|
-
jsx: 'react-jsx',
|
|
25
|
-
rootDir: '.',
|
|
26
|
-
ignoreDeprecations: '6.0',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
],
|
|
36
|
+
'^.+\\.(t|j)sx?$': transformer,
|
|
37
|
+
// Keeps the build-time source emitters under scripts/ testable.
|
|
38
|
+
[SCRIPTS_CJS_PATTERN]: transformer,
|
|
30
39
|
},
|
|
31
40
|
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
|
|
32
41
|
transformIgnorePatterns: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/ui",
|
|
3
|
-
"version": "0.6.8-develop.
|
|
3
|
+
"version": "0.6.8-develop.6889.1.af4501ca97",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -155,14 +155,14 @@
|
|
|
155
155
|
"remark-gfm": "^4.0.1"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
|
-
"@open-mercato/shared": "0.6.8-develop.
|
|
158
|
+
"@open-mercato/shared": "0.6.8-develop.6889.1.af4501ca97",
|
|
159
159
|
"react": ">=18.0.0",
|
|
160
160
|
"react-dom": ">=18.0.0",
|
|
161
161
|
"react-is": ">=18.0.0"
|
|
162
162
|
},
|
|
163
163
|
"devDependencies": {
|
|
164
164
|
"@figma/code-connect": "^1.3.4",
|
|
165
|
-
"@open-mercato/shared": "0.6.8-develop.
|
|
165
|
+
"@open-mercato/shared": "0.6.8-develop.6889.1.af4501ca97",
|
|
166
166
|
"@testing-library/dom": "^10.4.1",
|
|
167
167
|
"@testing-library/jest-dom": "^7.0.0",
|
|
168
168
|
"@testing-library/react": "^16.3.1",
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process'
|
|
2
2
|
import { readFileSync } from 'node:fs'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
3
4
|
import { join } from 'node:path'
|
|
4
5
|
import { Project, ScriptKind, SyntaxKind, type ObjectLiteralExpression, type SourceFile } from 'ts-morph'
|
|
5
6
|
import { buildLucideRegistrySource } from '../../../../scripts/lucideRegistrySource.cjs'
|
|
7
|
+
import jestConfig from '../../../../jest.config.cjs'
|
|
6
8
|
|
|
7
9
|
const packageDir = join(__dirname, '..', '..', '..', '..')
|
|
8
10
|
const iconsDir = join(packageDir, 'src', 'backend', 'icons')
|
|
@@ -152,9 +154,43 @@ describe('lucideRegistry barrel', () => {
|
|
|
152
154
|
})
|
|
153
155
|
})
|
|
154
156
|
|
|
157
|
+
type GitWorkTreeProbe = { available: true } | { available: false; reason: string }
|
|
158
|
+
|
|
159
|
+
function gitProbeFailureReason(error: unknown, cwd: string): string {
|
|
160
|
+
const { code, status } = error as { code?: string; status?: number }
|
|
161
|
+
if (code === 'ENOENT') return `git could not be executed for ${cwd} (no git executable, or the directory is missing)`
|
|
162
|
+
if (typeof status === 'number') return `git exited with status ${status} for ${cwd}`
|
|
163
|
+
return `git could not be executed for ${cwd}`
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function detectGitWorkTree(cwd: string): GitWorkTreeProbe {
|
|
167
|
+
try {
|
|
168
|
+
const output = execFileSync('git', ['rev-parse', '--is-inside-work-tree'], {
|
|
169
|
+
cwd,
|
|
170
|
+
encoding: 'utf-8',
|
|
171
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
172
|
+
})
|
|
173
|
+
if (output.trim() === 'true') return { available: true }
|
|
174
|
+
return { available: false, reason: `git reported no work tree for ${cwd}` }
|
|
175
|
+
} catch (error) {
|
|
176
|
+
return { available: false, reason: gitProbeFailureReason(error, cwd) }
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function importersOutsideIconsFolder(matches: string[]): string[] {
|
|
181
|
+
return matches.filter((path) => !path.startsWith('packages/ui/src/backend/icons/'))
|
|
182
|
+
}
|
|
183
|
+
|
|
155
184
|
describe('lucideRegistry.generated importers', () => {
|
|
156
|
-
|
|
157
|
-
|
|
185
|
+
const repoRoot = join(packageDir, '..', '..')
|
|
186
|
+
const workTree = detectGitWorkTree(repoRoot)
|
|
187
|
+
// `git grep` reads the index, so the guard can only run inside a checkout. Outside
|
|
188
|
+
// one (a source tarball, or no git binary) it degrades to a skip that states why,
|
|
189
|
+
// instead of failing an invariant it cannot evaluate.
|
|
190
|
+
const itInsideWorkTree = workTree.available ? it : it.skip
|
|
191
|
+
const skipReason = workTree.available ? '' : ` — skipped: ${workTree.reason}`
|
|
192
|
+
|
|
193
|
+
itInsideWorkTree(`is imported only from within src/backend/icons${skipReason}`, () => {
|
|
158
194
|
let matches: string[] = []
|
|
159
195
|
try {
|
|
160
196
|
matches = execFileSync(
|
|
@@ -169,9 +205,36 @@ describe('lucideRegistry.generated importers', () => {
|
|
|
169
205
|
if (status !== 1) throw error
|
|
170
206
|
}
|
|
171
207
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
208
|
+
expect(importersOutsideIconsFolder(matches)).toEqual([])
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
it('flags an importer that lives outside the icons folder', () => {
|
|
212
|
+
expect(
|
|
213
|
+
importersOutsideIconsFolder([
|
|
214
|
+
'packages/ui/src/backend/icons/lucideRegistry.ts',
|
|
215
|
+
'packages/core/src/modules/catalog/backend/products/page.tsx',
|
|
216
|
+
])
|
|
217
|
+
).toEqual(['packages/core/src/modules/catalog/backend/products/page.tsx'])
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
it('states a reason instead of throwing when git cannot resolve a work tree', () => {
|
|
221
|
+
const absentDir = join(tmpdir(), 'lucide-registry-absent-work-tree')
|
|
222
|
+
const probe = detectGitWorkTree(absentDir)
|
|
223
|
+
expect(probe.available).toBe(false)
|
|
224
|
+
expect(probe.available ? '' : probe.reason).toContain(absentDir)
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
describe('jest transform scope', () => {
|
|
229
|
+
const transformPatterns = Object.keys(jestConfig.transform).map((key) => new RegExp(key))
|
|
230
|
+
|
|
231
|
+
it('transforms the build-time emitter under scripts/', () => {
|
|
232
|
+
const emitterPath = join(packageDir, 'scripts', 'lucideRegistrySource.cjs')
|
|
233
|
+
expect(transformPatterns.some((pattern) => pattern.test(emitterPath))).toBe(true)
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
it('leaves .cjs files inside node_modules untransformed', () => {
|
|
237
|
+
const vendorPath = join(packageDir, 'node_modules', '@mikro-orm', 'core', 'dist', 'index.cjs')
|
|
238
|
+
expect(transformPatterns.some((pattern) => pattern.test(vendorPath))).toBe(false)
|
|
176
239
|
})
|
|
177
240
|
})
|