Compare commits

..

No commits in common. "master" and "script-cicd" have entirely different histories.

6 changed files with 18 additions and 95 deletions

View File

@ -44,10 +44,7 @@ zip文件的默认打包方式是根据以下不同渠道操作后将web-m
### 2. 打包
将web-mobile文件内容压缩成zip包。注意zip包的第一层级需要包含index.html。
## vungle
vungle 和 liftoff 的渠道包需要使用mraid_support.js
1. 把networks/mraid_support.js 复制到web-mobile下
2. 编辑复制的mraid_support.js, 在前几行填入对应的iosUrl和androidUrl
3. 编辑index.html在body最后加上
@ -72,15 +69,10 @@ vungle 和 liftoff 的渠道包需要使用mraid_support.js
`
## 3.渠道处理
###
下面四个渠道是使用 mraid_support.js
applovin
### applovin
unity
appier
ironsource 需要单独加入mraid.js
(zip) liftoff
appier
1. 把networks/mraid_support.js 复制到web-mobile下
2. 编辑复制的mraid_support.js, 在前几行填入对应的iosUrl和androidUrl
3. 编辑index.html在body最后加上

View File

@ -5,6 +5,11 @@ const do_task = require("./single-html/build");
const outputPrefix = '';
const htmlChannel = ['applovin', 'unity', 'appier', 'ironsource', 'mintegral', 'moloco'];
// 延时函数
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// 创建 dist 目录
if (!fs.existsSync('dist')) {
fs.mkdirSync('dist');
@ -73,9 +78,7 @@ async function processHtmlChannels() {
// 替换包含 window.vConsole = new VConsole 的 <script> 标签
const vConsoleScriptRegex = /<script type="text\/javascript">[\s\S]*?window\.vConsole = new VConsole\(\);[\s\S]*?<\/script>/;
// @TODO cocos的名称需要从web-mobile文件夹中获取找到
const cocosFileName = fs.readdirSync('web-mobile').find(file => file.startsWith('cocos2d-js-min') && file.endsWith('.js'));
const cocosScriptTag = `<script src="${cocosFileName}" charset="utf-8"></script>\n`;
const cocosScriptTag = `<script src="cocos2d-js-min.ce58b.js" charset="utf-8"></script>\n`;
htmlContent = htmlContent.replace(vConsoleScriptRegex, cocosScriptTag);
// 额外引入 loader-and-starter.js 和 asset-map.js 到 body 中

View File

@ -1,6 +1,6 @@
// 填入对应的商店地址
var iosUrl = "https://apps.apple.com/app/legend-of-mushroom/id6475333787"
var androidUrl = "https://play.google.com/store/apps/details?id=com.mxdzzus.google"
var iosUrl = "https://play.google.com/store/apps/details?id=com.wwv.global"
var androidUrl = "https://apps.apple.com/app/id6621220868"
class SoyooLifecyle {

View File

@ -3,7 +3,7 @@
"build": "node single-html/build.js",
"build:zip": "node zipChannelScript.js",
"build:h5": "node htmlChannelScript.js",
"build:allChannels": "node scriptBefore.js && npm run build:zip && npm run build:h5"
"build:allChannels": "npm run build:zip && npm run build:h5"
},
"devDependencies": {
"clean-css": "^5.3.3",

View File

@ -1,77 +0,0 @@
const fs = require('fs')
const path = require('path')
// 脚本执行之前的操作
var iosUrl = "https://apps.apple.com/kr/app/id6467117398"
var androidUrl = "https://play.google.com/store/apps/details?id=com.mxdzzus.google"
// 版本一(英文版)
// 安卓https://play.google.com/store/apps/details?id=com.mxdzzus.google
// iOShttps://apps.apple.com/app/legend-of-mushroom/id6475333787
// 版本二(韩语)
// 安卓https://play.google.com/store/apps/details?id=com.mxdzzkr.google
// iOShttps://apps.apple.com/kr/app/id6467117398
function removeDist() {
const isExists = fs.existsSync(path.join(__dirname, 'dist'))
if (isExists) {
fs.rmdirSync(path.join(__dirname, 'dist'), { recursive: true })
}
if (!isExists) {
fs.mkdirSync(path.join(__dirname, 'dist'))
}
}
function replaceAppStoreUrl() {
// 1. 替换mraid_support.js文件中的iosUrl和androidUrl
var mraid_support_js = fs.readFileSync(path.join(__dirname, 'networks', 'mraid_support.js'), 'utf8')
mraid_support_js = mraid_support_js.replace(/var iosurl\s*=\s*".*"/g, `var iosUrl = "${iosUrl}"`)
mraid_support_js = mraid_support_js.replace(/var androidUrl\s*=\s*".*"/g, `var androidUrl = "${androidUrl}"`);
fs.writeFileSync(path.join(__dirname, 'networks', 'mraid_support.js'), mraid_support_js, 'utf8')
}
function replaceCss() {
// 获取 web-mobile 目录中的 splash 开头的 png 文件
const splashFile = fs.readdirSync('web-mobile').find(file => file.startsWith('splash') && file.endsWith('.png'));
if (!splashFile) return;
// 读取并转换为 base64
const splashFilePath = path.join('web-mobile', splashFile);
const splashBase64 = fs.readFileSync(splashFilePath, 'base64');
const splashBase64Url = `url(data:image/png;base64,${splashBase64})`;
// 使用正则表达式查找带有哈希值的 CSS 文件
const cssFiles = fs.readdirSync('web-mobile').filter(file => {
return /style-(mobile|desktop)\.[a-f0-9]+\.css$/.test(file)
});
cssFiles.forEach(cssFile => {
const cssFilePath = path.join('web-mobile', cssFile);
let cssContent = fs.readFileSync(cssFilePath, 'utf8');
const splashRegex = /url\(\.\/splash\.\w+\.png\)/g;
if (splashRegex.test(cssContent)) {
cssContent = cssContent.replace(splashRegex, splashBase64Url);
}
if (cssFile.includes('desktop') && !cssContent.includes('orientation: landscape')) {
const mediaRule = '\n@media (orientation: landscape) {#splash {background-size: 15% !important;}}';
cssContent += mediaRule;
}
fs.writeFileSync(cssFilePath, cssContent, 'utf8');
});
}
function startScript() {
removeDist()
replaceCss()
replaceAppStoreUrl()
console.log('脚本执行完毕')
}
startScript()

View File

@ -4,6 +4,11 @@ const archiver = require("archiver");
const zipChannel = ['facebook', 'google', 'tiktok', 'vungle', 'liftoff'];
// 延时函数
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
const outputPrefix = '';
// 创建 dist 目录
@ -105,11 +110,11 @@ async function processChannels() {
zlib: { level: 9 } // 设置压缩级别
});
output.on('close', function () {
output.on('close', function() {
console.log(`已创建 ${channelName}.zip大小为 ${archive.pointer()} 字节`);
});
archive.on('error', function (err) {
archive.on('error', function(err) {
throw err;
});