feat: 打通 HBuilderX CLI 构建 + 修复文章闭环静态盲区
构建: - 新增 tools/build.js:junction HBuilderX 工具链,CLI 构建 h5/mp-weixin - vue 指向补丁版 @dcloudio/uni-h5-vue(官方 npm vue 不导出 isInSSRComponentSetup) - 设 HX_APP_ROOT 避免退化成 H5 空壳产物;产物完整性校验 校验工具: - 新增 check-cloud-methods.js:acorn 解析云对象方法,比对 94 处调用点 - 新增 check-android-contract.js:Kotlin 侧云对象契约校验 - audit-project.js 修 downloadFile 误报(注释未剥离);tools/ 排除出扫描 - package.json 声明此前隐式依赖的 acorn 功能: - 补 uni-cms-articles.getPublishedArticles(安卓端依赖但此前不存在) - 修 u-parse <audio> 引用已移除组件导致 H5 构建失败
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict'
|
||||
|
||||
const assert = require('assert')
|
||||
const {
|
||||
normalizeCmsList,
|
||||
cmsLstToDelta,
|
||||
createVoteId,
|
||||
getArticleText,
|
||||
getArticleImages,
|
||||
hasRenderableContent
|
||||
} = require('../uniCloud-alipay/cloudfunctions/uni-cms-articles/content-adapter')
|
||||
|
||||
function run() {
|
||||
const list = normalizeCmsList([
|
||||
{ type: 'text', text: '首段', delta: { ops: [{ insert: '首段' }, { insert: '\n' }] } },
|
||||
{ type: 'title', text: '小标题', html: '<p>小标题</p>', delta: { ops: [{ insert: '小标题' }] } },
|
||||
{ type: 'image', image: { src: 'cloud://image-a' } },
|
||||
{ type: 'video', text: '视频说明', video: { src: 'cloud://video-a', poster: 'cloud://poster-a', duration: 12 } },
|
||||
{ type: 'vote', vote: { voteTitle: '投票', voteLst: [{ value: 'A' }, { value: 'B' }] } },
|
||||
{ type: 'text', text: '' },
|
||||
{ type: 'image', image: { src: '' } }
|
||||
])
|
||||
|
||||
assert.strictEqual(list.length, 5)
|
||||
assert.strictEqual(typeof list[2].image.src, 'string')
|
||||
assert.strictEqual(typeof list[3].video.src, 'string')
|
||||
assert.match(list[4].vote.vote_id, /^vote_/)
|
||||
|
||||
const delta = cmsLstToDelta(list)
|
||||
assert.ok(Array.isArray(delta.ops))
|
||||
assert.ok(delta.ops.some(op => op.insert && op.insert.image === 'cloud://image-a'))
|
||||
assert.ok(delta.ops.some(op => op.insert && op.insert.video === 'cloud://video-a'))
|
||||
assert.ok(hasRenderableContent(delta, list))
|
||||
assert.match(getArticleText(delta, list), /首段/)
|
||||
assert.match(getArticleText(delta, list), /小标题/)
|
||||
assert.deepStrictEqual(getArticleImages(delta, list).sort(), ['cloud://image-a', 'cloud://poster-a'])
|
||||
assert.notStrictEqual(createVoteId(), createVoteId())
|
||||
|
||||
console.log('✓ 文章内容适配自测通过(cmsLst / Delta / 媒体 / 投票)')
|
||||
}
|
||||
|
||||
if (require.main === module) run()
|
||||
module.exports = { run }
|
||||
Reference in New Issue
Block a user