create-base-files.js 855 B

12345678910111213141516171819202122232425262728293031
  1. // 生成 src/manifest.json 和 src/pages.json
  2. import fs from 'node:fs'
  3. import path from 'node:path'
  4. import { fileURLToPath } from 'node:url'
  5. // 获取当前文件的目录路径(替代 CommonJS 中的 __dirname)
  6. const __filename = fileURLToPath(import.meta.url)
  7. const __dirname = path.dirname(__filename)
  8. const manifest = {
  9. name: 'unibest',
  10. description: 'unibest - 最好的 uniapp 开发模板',
  11. versionName: '1.0.0',
  12. versionCode: '100',
  13. }
  14. const pages = {
  15. pages: [
  16. {
  17. path: 'pages/index/index',
  18. style: {
  19. navigationBarTitleText: 'uni-app',
  20. },
  21. },
  22. ],
  23. }
  24. // 使用修复后的 __dirname 来解析文件路径
  25. fs.writeFileSync(path.resolve(__dirname, '../src/manifest.json'), JSON.stringify(manifest, null, 2))
  26. fs.writeFileSync(path.resolve(__dirname, '../src/pages.json'), JSON.stringify(pages, null, 2))