2022-05-24 14:49:24 +08:00
|
|
|
const fs = require('fs')
|
|
|
|
var child_process = require('child_process')
|
|
|
|
const chalk = require('chalk');
|
|
|
|
const logger = require('./utils/logger.js');
|
|
|
|
const DotEnv = require('dotenv')
|
|
|
|
const parsedEnv = DotEnv.config({
|
|
|
|
path: `.env`
|
|
|
|
}).parsed
|
|
|
|
|
|
|
|
|
|
|
|
function main() {
|
|
|
|
let revRun = child_process.exec('cordova platform add android', function (e, res) {
|
|
|
|
// 修改gradle镜像地址
|
|
|
|
let gradle_cdn = 'https://alicdn.taoya.art/test/gradle-7.1.1-all.zip';
|
|
|
|
console.log(process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL);
|
2022-05-24 14:57:23 +08:00
|
|
|
let gradle_file = fs.readFileSync('./node_modules/cordova-android/lib/builders/ProjectBuilder.js').toString('utf-8');
|
|
|
|
console.log(gradle_file);
|
|
|
|
let replaceFileContent = oldFile.replace('const distributionUrl = process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL || `https://services.gradle.org/distributions/gradle-${config.GRADLE_VERSION}-all.zip`;', `const distributionUrl = ${gradle_cdn};`)
|
|
|
|
fs.writeFileSync('./node_modules/cordova-android/lib/builders/ProjectBuilder.js', replaceFileContent)
|
2022-05-24 14:49:24 +08:00
|
|
|
});
|
|
|
|
revRun.stdout.on('data', function (data) {
|
|
|
|
console.log(chalk.green(data));
|
|
|
|
})
|
|
|
|
}
|
|
|
|
main();
|