cmvr-wms/mobile-app/scripts/check-installable-config.cjs
lixiaolong 95effeeff2 feat(app): 优化移动端应用配置和功能实现
- 添加生产环境服务器地址配置支持内外网切换
- 实现采购列表只看我创建的功能开关
- 更新构建脚本中的默认生产环境API地址
- 优化采购单表格单元格编辑体验改用自动补全组件
- 调整应用更新检查逻辑增强生产环境兼容性
- 修复开发服务器切换时的一些验证问题
- 增强应用启动时的服务地址配置灵活性
2026-10-29 17:27:46 +08:00

20 lines
1.2 KiB
JavaScript

const { internal } = require('../config/environment.cjs');
function assertInstallableConfig(config) {
const variant = config.extra?.environment;
if (!['dev', 'prod'].includes(variant)) throw Error('Explicit App environment required');
if (!config.updates?.enabled || !config.updates.codeSigningCertificate) throw Error('Installable App requires signed updates');
const url = new URL(config.updates.url);
// Loopback is valid for local preview, never for an APK delivered to phones.
internal(url.origin, false, variant === 'prod');
if (url.pathname !== `/updates/${variant}` || url.search || url.hash) throw Error('Update channel must match App environment');
if (config.updates.codeSigningMetadata?.keyid !== variant) throw Error('Update signing key must match App environment');
if (config.android?.package !== (variant === 'dev' ? 'cn.cmvr.wms.dev' : 'cn.cmvr.wms')) throw Error('App package/environment mismatch');
return url.toString();
}
module.exports = { assertInstallableConfig };
if (require.main === module) {
const config = require('../app.config.js')();
console.log(`Installable ${config.extra.environment} App: ${assertInstallableConfig(config)}`);
}