postConfig.mjs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { readFileSync, existsSync } from 'node:fs';
  2. import { dirname } from 'node:path';
  3. import { fileURLToPath } from 'node:url';
  4. import { pad } from './utils.mjs';
  5. import path from 'node:path';
  6. import JSON5 from 'json5';
  7. //基础配置
  8. //========================================
  9. const __filename = fileURLToPath(import.meta.url);
  10. const __dirname = dirname(__filename);
  11. const localConfigPath = path.resolve(__dirname, './_localConfig.json');
  12. const localConfig = existsSync(localConfigPath) ? JSON.parse(readFileSync(localConfigPath, 'utf8')) : {};
  13. //提交更新配置
  14. //========================================
  15. export const config = {
  16. server: localConfig.updateServer || 'https://update-server1.imengyu.top/',
  17. submitKey: '',
  18. appId: 2,
  19. uploadWebConfig: {
  20. storageAction: 'override',
  21. storageProps: {
  22. overrideMode: 'overrideAll',
  23. overrideFiles: [ ],
  24. newFolderNameGenerateType: 'hash',
  25. },
  26. deprecateConfig: {
  27. indexFile: 'index.html',
  28. updateHtml: readFileSync(path.resolve(__dirname, './deprecate.html'), 'utf8')
  29. },
  30. },
  31. buildWebCommand: 'npm run nuxt-build', //构建命令
  32. buildWebOutDir: '../../.output', //构建输出目录。相对于当前文件目录
  33. buildWebOptions: {
  34. skipFiles: [
  35. '/server/node_modules',
  36. ],
  37. },
  38. buildWebOutVersionPath: '', //版本号输出目录,输出版本号至文件以供项目使用。相对于当前文件目录
  39. getCustomConfig: async (param, isApp, versionName) => {
  40. return {}//额外的自定义配置
  41. },
  42. /**
  43. * 自定义生成Web版本号的方法。
  44. * @param {Date} now 当前日期
  45. * @param {Number} lastTodaySubVersion 今天上传的之前版本数量
  46. * @returns
  47. */
  48. buildWebVersionGenerateCommand: async (now, lastTodaySubVersion) => {
  49. //生成Web版本号
  50. const version = `${now.getFullYear().toString().substring(2)}${pad(now.getMonth() + 1, 2)}${pad(now.getDate(), 2)}.${pad(lastTodaySubVersion, 2)}`;
  51. return version;
  52. },
  53. buildAppCallback: async (param, versionCode, versionName, lastTodaySubVersion) => {
  54. //构建App
  55. throw new Error('未实现buildAppCallback方法');
  56. },
  57. buildAppGetUploadFile: async (param, versionCode, versionName) => {
  58. //获取上传文件路径
  59. throw new Error('未实现buildAppGetUploadFile方法');
  60. },
  61. buildAppGetOSSFileName: async (param, versionCode, versionName) => {
  62. //生成OSS保存路径
  63. throw new Error('buildAppGetOSSFileName');
  64. },//构建命令
  65. buildAppOutDir: './dist', //构建输出目录。相对于当前文件目录
  66. buildAppGetVersion: async (versionName) => {
  67. //获取版本号
  68. throw new Error('未实现buildAppGetVersion方法');
  69. },
  70. }