重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const root = path.join(__dirname, '..')
|
||||
const appWxss = fs.readFileSync(path.join(root, 'app.wxss'), 'utf8')
|
||||
const productCardWxss = fs.readFileSync(path.join(root, 'components', 'product-card', 'product-card.wxss'), 'utf8')
|
||||
const navigationBarWxss = fs.readFileSync(path.join(root, 'components', 'navigation-bar', 'navigation-bar.wxss'), 'utf8')
|
||||
const pageRoot = path.join(root, 'pages')
|
||||
const legacyThemeColorPattern = /#(?:2d2430|1f1b17|8d7a84|7a5262|c6597d|C6597D|FFF7F9|FFF8F4)\b/
|
||||
|
||||
function readPageSources(dir) {
|
||||
return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
||||
const fullPath = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) {
|
||||
return readPageSources(fullPath)
|
||||
}
|
||||
if (!/\.(?:wxml|wxss)$/.test(entry.name)) {
|
||||
return []
|
||||
}
|
||||
return [{ file: path.relative(root, fullPath), source: fs.readFileSync(fullPath, 'utf8') }]
|
||||
})
|
||||
}
|
||||
|
||||
assert.ok(appWxss.includes('--theme-neutral: #4A443F;'))
|
||||
assert.ok(appWxss.includes('--theme-tertiary: #FDFBF9;'))
|
||||
assert.ok(appWxss.includes('.yumi-page'))
|
||||
assert.ok(appWxss.includes('.yumi-glass-card'))
|
||||
assert.ok(appWxss.includes('.yumi-status-chip'))
|
||||
assert.ok(appWxss.includes('.yumi-bottom-action'))
|
||||
assert.ok(!/--theme-primary:\s*#7c5357/i.test(appWxss))
|
||||
|
||||
assert.ok(productCardWxss.includes('background: rgba(255, 255, 255, 0.86);'))
|
||||
assert.ok(productCardWxss.includes('color: var(--text-primary);'))
|
||||
assert.ok(productCardWxss.includes('color: var(--text-secondary);'))
|
||||
assert.ok(navigationBarWxss.includes('backdrop-filter: blur(20rpx);'))
|
||||
assert.ok(navigationBarWxss.includes('color: var(--theme-neutral);'))
|
||||
|
||||
for (const { file, source } of [{ file: 'app.wxss', source: appWxss }, ...readPageSources(pageRoot)]) {
|
||||
assert.ok(!legacyThemeColorPattern.test(source), `${file} should use Luminous theme variables instead of legacy hardcoded theme colors`)
|
||||
}
|
||||
Reference in New Issue
Block a user