| 12345678910111213141516171819202122232425262728293031323334 |
- const fs = require("fs");
- const path = require("path");
- module.exports = function (context) {
- const projectRoot = context.opts.projectRoot;
- const cordovaCommon = context.requireCordovaModule("cordova-common");
- const { ConfigParser } = cordovaCommon;
- const appConfig = new ConfigParser(path.resolve(projectRoot, "config.xml"));
- let baseUrl = "https://www.raex.vip";
- if (context.cmdLine.includes("--test")) {
- baseUrl = "https://test.raex.vip";
- }
- if (context.cmdLine.includes("--dev")) {
- baseUrl = "http://192.168.6.116:8082/";
- }
- let channel = "default";
- let match = context.cmdLine.match(/channel=(.+?)(\s|$)/);
- if (match) {
- channel = match[1];
- console.log("channel: " + channel);
- }
- fs.writeFileSync(
- path.resolve(projectRoot, "www", "index.html"),
- fs
- .readFileSync(path.resolve(projectRoot, "www", "template.html"))
- .toString()
- .replace("${version}", appConfig.version())
- .replace("${iosCFBundleVersion}", appConfig.ios_CFBundleVersion())
- .replace("${androidVersionCode}", appConfig.android_versionCode())
- .replace(/\$\{baseUrl\}/g, baseUrl)
- .replaceAll('$channel', channel)
- );
- };
|