mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2026-11-18 22:00:30 +00:00
1. 云编译任务系统的全面升级。 整个云编译服务器使用高性能开发语言GO全面重建整个的任务,排队体系。框架的用户,全面引入了任务管理系统设计架构。把云编译,在线升级,插件打包,构建发布版本,小程序一键上传同步等流程,高度抽象为任务系统。整个任务的执行过程会详细记录下来,支持每个过程的原始执行情况回溯。每个步骤,执行错误,加入重试与取消机制。对于网络拥堵,网络暂时断开造成的上传下载过程中不可预测的中断开始支持断点续传重续。同时,云编译支持前端驱动,与后端Redis队列驱动两种模式。前端驱动模式为轻量模式,需要页面的持续保持任务的进行。Redis队列驱动模式,支持任务后台运行,在任务后台运行的同时,同步进行业务系统的正常使用 2. 多端口,自定义扩展端口的真正支持。历史版本中,在addon.info中,已经设计有自定义端口功能,但是在整个的云编译服务器,没有真正支持自定义端口的编译与部署。在本次版本中,服务器端,以及框架已经全部支持自定义端口使能。addon.info 文件中定义的端口,会在编译端口自动枚举展示。云编译过程,会按照设定的命令自动执行,并完成部署。同时,云编译支持框架独立编译,插件组合编译等,方便开发者使用。 3. 环境检测与数据库修复,在本版本中全面引入。数据库修复,支持全量比对,表比对,插件比对,字符集编码比对,数据库修复功能,可以按照插件比对出缺失字段,并通过一键修复按钮完成数据库的修复。对于第三方插件中数据库表与框架自身不同的情况,系统会自动修正并正确执行SQL脚本。 4. 补丁管理也在本版本中实现,对于小问题,及时问题的处理,会发布小版本补丁。用户可以及时下载补丁,实时完成系统缺漏的修复。 5. 菜单系统,加入了导入菜单,导出菜单功能。niucloud开发团队全力为开发者考虑,本版本导入导出菜单可以按照插件,或者整个框架把菜单结构导出为json格式。 6. 构建版本在本次升级新加入。构建版本可以把云编译及版本构建的版本发布过程保留下来。 7. 插件校验和框架系统校验。在本版本中全面引入。支持对插件和框架进行全面校验比对。支持一键修复二开或者异常代码修复。 8. 存储设置在本版本全面优化,支持新增多种不同存储厂商的配置,并支持在不同配置中切换使用。 9. 运营面板在本次升级中植入。运营面板相当于为应用和插件加入了admin端的管理入口。本次版本开放此功能,为开发者开发admin端口功能提供了基础。我们官方在本次版本中同步发布官方客服插件,在admin端加入了平台客服的演示案例,供大家感受学习。 10. 全面优化了admin端的界面风格,加入了新的站点端默认风格。框架内置Vben Admin 前端框架。其实niucloud优秀的架构设计,运行速度并不慢,加入Vben Admin后,页面的切换效果会让用户感受到更加的丝滑与现代。 11. 前端顶部轮播组件,加入了返回首页按钮。 装修后,完美支持美团,饿了么那种模块与主模块的完美切换。 12. 小程序编译结构进行了优化,整个运行的速度更加快速。
133 lines
4.7 KiB
JavaScript
133 lines
4.7 KiB
JavaScript
/**
|
||
* 编译一个或多个 addon(H5 lib 模式)
|
||
*
|
||
* 用法:
|
||
* node scripts/build-addon.cjs shop
|
||
* node scripts/build-addon.cjs shop cms pintuan
|
||
* ADDON_KEY=shop node scripts/build-addon.cjs
|
||
*/
|
||
const { spawnSync } = require('child_process')
|
||
const fs = require('fs')
|
||
const path = require('path')
|
||
const { ROOT, listAddonKeys } = require('./addon-utils.cjs')
|
||
const { stripAddonStyleImport } = require('./inject-addon-style-import.cjs')
|
||
const { injectChunkScopedCss } = require('./inject-addon-chunk-scoped-css.cjs')
|
||
const { injectChunkWindiCss } = require('./inject-addon-chunk-windi.cjs')
|
||
const { patchAddonDir: patchAddonLocaleLeak } = require('./patch-addon-locale-leak.cjs')
|
||
const { patchAddonDir: patchAddonDiyLeak } = require('./patch-addon-diy-leak.cjs')
|
||
const { validateAddonDir: validateAddonChunkExports } = require('./validate-addon-chunk-exports.cjs')
|
||
|
||
// 支持一次编译多个插件:node scripts/build-addon.cjs shop cms
|
||
const argvKeys = process.argv.slice(2).filter(Boolean)
|
||
const keys = [...new Set(argvKeys.length ? argvKeys : process.env.ADDON_KEY ? [process.env.ADDON_KEY] : [])]
|
||
|
||
if (!keys.length) {
|
||
console.error('Usage: node build-addon.cjs <addon-key> [addon-key ...]')
|
||
process.exit(1)
|
||
}
|
||
|
||
function buildOne(key) {
|
||
console.log(`\n========== [build-addon] "${key}" ==========`)
|
||
|
||
spawnSync('node', [path.join(__dirname, 'generate-addon-entry.cjs'), key], {
|
||
cwd: ROOT,
|
||
stdio: 'inherit',
|
||
shell: process.platform === 'win32'
|
||
})
|
||
spawnSync('node', [path.join(__dirname, 'generate-diy-registry.cjs')], {
|
||
cwd: ROOT,
|
||
stdio: 'inherit',
|
||
shell: process.platform === 'win32'
|
||
})
|
||
|
||
const env = {
|
||
...process.env,
|
||
ADDON_KEY: key,
|
||
UNI_PLATFORM: 'h5',
|
||
NODE_OPTIONS: process.env.NODE_OPTIONS || '--max-old-space-size=4096'
|
||
}
|
||
|
||
console.log(`[build-addon] building "${key}" ...`)
|
||
const r = spawnSync('npx', ['vite', 'build', '--config', 'vite.config.addon.ts'], {
|
||
cwd: ROOT,
|
||
env,
|
||
stdio: 'inherit',
|
||
shell: process.platform === 'win32'
|
||
})
|
||
if (r.status !== 0) {
|
||
console.error(`[build-addon] FAILED: ${key}`)
|
||
process.exit(r.status ?? 1)
|
||
}
|
||
|
||
const stagingDir = path.join(ROOT, 'dist', '.addons', key)
|
||
patchAddonLocaleLeak(stagingDir)
|
||
patchAddonDiyLeak(stagingDir)
|
||
|
||
const exportCheck = validateAddonChunkExports(stagingDir)
|
||
if (!exportCheck.ok) {
|
||
console.error(`[build-addon] shared chunk export validation failed for "${key}"`)
|
||
for (const err of exportCheck.errors) {
|
||
console.error(` ${err.file}: missing ${err.total} binding(s), e.g. ${err.missing.join(', ')}`)
|
||
}
|
||
process.exit(1)
|
||
}
|
||
|
||
stripAddonStyleImport(stagingDir)
|
||
|
||
const chunkCss = injectChunkScopedCss(stagingDir)
|
||
if (chunkCss.injected) {
|
||
console.log(`[build-addon] injected descoped CSS into ${chunkCss.injected} page chunks`)
|
||
}
|
||
|
||
const windi = spawnSync('node', [path.join(__dirname, 'generate-addon-windi-css.cjs'), stagingDir, key], {
|
||
cwd: ROOT,
|
||
stdio: 'inherit',
|
||
shell: process.platform === 'win32'
|
||
})
|
||
if (windi.status !== 0) {
|
||
console.error(`[build-addon] Windi CSS generation failed for ${key}`)
|
||
process.exit(windi.status ?? 1)
|
||
}
|
||
|
||
const chunkWindi = injectChunkWindiCss(stagingDir)
|
||
if (chunkWindi.injected) {
|
||
console.log(`[build-addon] injected Windi CSS into ${chunkWindi.injected} page chunks`)
|
||
}
|
||
|
||
spawnSync('node', [path.join(__dirname, 'patch-addon-uni-h5.cjs'), key], {
|
||
cwd: ROOT,
|
||
stdio: 'inherit',
|
||
shell: process.platform === 'win32'
|
||
})
|
||
|
||
// 清理其他插件的 locale chunk(i18n 自动收集导致被误打进当前插件包)
|
||
const assetsDir = path.join(stagingDir, 'assets')
|
||
if (fs.existsSync(assetsDir)) {
|
||
const otherKeys = listAddonKeys().filter((k) => k !== key)
|
||
const appRe = /^app-locale-/
|
||
let removed = 0
|
||
for (const name of fs.readdirSync(assetsDir)) {
|
||
const isOtherAddonChunk = otherKeys.some((k) => name.startsWith(`addon-${k}-`))
|
||
if (isOtherAddonChunk || appRe.test(name)) {
|
||
fs.unlinkSync(path.join(assetsDir, name))
|
||
removed++
|
||
}
|
||
}
|
||
if (removed) console.log(`[build-addon] cleaned ${removed} other-addon locale chunks`)
|
||
}
|
||
|
||
const sync = spawnSync('node', [path.join(__dirname, 'sync-addon.cjs'), key], {
|
||
cwd: ROOT,
|
||
stdio: 'inherit',
|
||
shell: process.platform === 'win32'
|
||
})
|
||
if (sync.status !== 0) {
|
||
process.exit(sync.status ?? 1)
|
||
}
|
||
|
||
console.log(`[build-addon] OK: ${key}`)
|
||
}
|
||
|
||
keys.forEach(buildOne)
|
||
console.log(`\n[build-addon] ALL DONE: ${keys.join(', ')}`)
|