Commit 371c9b5b authored by liujiangnan's avatar liujiangnan
parents c49e73db 96367531
...@@ -5,6 +5,12 @@ ...@@ -5,6 +5,12 @@
/publish/publish/play /publish/publish/play
/publish/publish/form /publish/publish/form
/publish/publish/android /publish/publish/android
/publish/publish/web_desktop
/publish/publish/ios /publish/publish/ios
/publish/publish/*.zip /publish/publish/*.zip
/publish/publish/config.json
/publish/publish/Release*
/node_modules /node_modules
/play/build_android
/play/build_ios
/play/build_web_desktop
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
{ {"ver":"1.1.2","uuid":"d3ad24ed-9c8b-421d-934f-f93f1acf3060","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
"ver": "1.1.2", \ No newline at end of file
"uuid": "d3ad24ed-9c8b-421d-934f-f93f1acf3060",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
...@@ -45,6 +45,9 @@ cc.Class({ ...@@ -45,6 +45,9 @@ cc.Class({
}, },
onTouchStart() { onTouchStart() {
if (g.data_mgr.nodPlayer) {
g.data_mgr.nodPlayer.onStopAudio();
}
if (this._playing) return if (this._playing) return
if (this.audioId) return if (this.audioId) return
if (this.data) { if (this.data) {
...@@ -67,7 +70,8 @@ cc.Class({ ...@@ -67,7 +70,8 @@ cc.Class({
this.quan.active = true this.quan.active = true
if (!this._playing) { if (!this._playing) {
this._playing = true this._playing = true;
g.data_mgr.nodPlayer = this;
cc.systemEvent.once('stopMusic', this.onStopAudio, this) cc.systemEvent.once('stopMusic', this.onStopAudio, this)
// if (onlyOne != this) { // if (onlyOne != this) {
// this._playing = false // this._playing = false
...@@ -124,6 +128,7 @@ cc.Class({ ...@@ -124,6 +128,7 @@ cc.Class({
this.stopAudio() this.stopAudio()
}, },
stopAudio() { stopAudio() {
g.data_mgr.nodPlayer = null;
this._playing = false this._playing = false
if (this.audioId != null) { if (this.audioId != null) {
cc.audioEngine.stop(this.audioId) cc.audioEngine.stop(this.audioId)
......
...@@ -24,6 +24,9 @@ var picNode = cc.Class({ ...@@ -24,6 +24,9 @@ var picNode = cc.Class({
}, },
onTouchStart() { onTouchStart() {
if (g.data_mgr.nodPlayer) {
g.data_mgr.nodPlayer.onStopAudio();
}
g.speaker.inst.playEffect(g.enum.E_Audio.Error); g.speaker.inst.playEffect(g.enum.E_Audio.Error);
}, },
......
{ {
"ver": "1.2.9", "ver": "1.2.9",
"uuid": "57ea7c61-9b8b-498a-b024-c98ee9124beb", "uuid": "14c37636-02d3-4ff8-8d46-32898ddb9a11",
"asyncLoadAssets": false, "asyncLoadAssets": false,
"autoReleaseAssets": true, "autoReleaseAssets": true,
"subMetas": {} "subMetas": {}
......
...@@ -141,7 +141,10 @@ var game = cc.Class({ ...@@ -141,7 +141,10 @@ var game = cc.Class({
//初始化标题 //初始化标题
g.titleType.inst.showTitle(question.title, question.title_audio_url); g.titleType.inst.showTitle(question.title, question.title_audio_url);
if (question.title_audio_url) { if (question.title_audio_url) {
g.data_mgr.gameState = 2;
setTimeout(() => {
g.titleType.inst.onBtnPlayEffect(); g.titleType.inst.onBtnPlayEffect();
}, 500)
} }
//设置中间图片 //设置中间图片
g.picNode.inst.onShow(question); g.picNode.inst.onShow(question);
......
...@@ -102,7 +102,9 @@ cc.Class({ ...@@ -102,7 +102,9 @@ cc.Class({
}, },
onDestroy: function () { onDestroy: function () {
if (g.event_pump) {
g.event_pump.unReg("adjustUI"); g.event_pump.unReg("adjustUI");
}
}, },
settopUI: function (s) { settopUI: function (s) {
if (!g.data_mgr.phoneInfo) { if (!g.data_mgr.phoneInfo) {
......
...@@ -28,8 +28,12 @@ var speaker = cc.Class({ ...@@ -28,8 +28,12 @@ var speaker = cc.Class({
g.speaker = speaker; g.speaker = speaker;
}, },
//播放音效 // //播放音效
// playEffect: function (num, cb) {
// g.snd_mgr.playEffect(this.eff_audio[num], cb);
// },
playEffect: function (num, cb) { playEffect: function (num, cb) {
g.snd_mgr.playEffect(this.eff_audio[num], cb); g.snd_mgr.playMusic(this.eff_audio[num], 1, cb);
}, },
}); });
...@@ -22,6 +22,7 @@ var titleType = cc.Class({ ...@@ -22,6 +22,7 @@ var titleType = cc.Class({
this.unschedule(this.setSndEff); this.unschedule(this.setSndEff);
var nodTitle = this.checkNode(lab, audio); var nodTitle = this.checkNode(lab, audio);
this.lab = lab; this.lab = lab;
this.stopAudio();
this.audio = audio; this.audio = audio;
this.updateUi(nodTitle) this.updateUi(nodTitle)
...@@ -34,6 +35,10 @@ var titleType = cc.Class({ ...@@ -34,6 +35,10 @@ var titleType = cc.Class({
nodTitle.active = true; nodTitle.active = true;
}, },
stopAudio() {
cc.audioEngine.stop(this.audio)
},
//更新界面 //更新界面
updateUi(nodTitle) { updateUi(nodTitle) {
nodTitle.getChildByName("title") && (nodTitle.getChildByName("title").getComponent(cc.Label).string = this.lab) nodTitle.getChildByName("title") && (nodTitle.getChildByName("title").getComponent(cc.Label).string = this.lab)
......
...@@ -10,33 +10,49 @@ g.data_mgr = { ...@@ -10,33 +10,49 @@ g.data_mgr = {
startId: null,//星星id startId: null,//星星id
nowAnsId: null,//当前星星的问题 nowAnsId: null,//当前星星的问题
gameState: 2,//游戏状态1可操作 2不可操作
nodPlayer: null,//当前播放节点
//获得默认数据 //获得默认数据
getDefaultData() { getDefaultData() {
//http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3
const dataJson = { const dataJson = {
"starArr": [{ "starArr": [{
"queArr": [{ "queArr": [{
"bgItem": { "bgItem": {
"url": "http://staging-teach.cdn.ireadabc.com/bb4244d166b6d077617ff089f7fd46c4.png", "rect": { "x": 259.9654545454546, "y": 0, "width": 377.0690909090909, "height": 373 } "url": "http://staging-teach.cdn.ireadabc.com/bb4244d166b6d077617ff089f7fd46c4.png", "rect": { "x": 259.9654545454546, "y": 0, "width": 377.0690909090909, "height": 373 }
}, "hotZoneItemArr": [{ }, "hotZoneItemArr": [{
"audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3",
"index": 0, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": -1.97, "y": 112, "width": 95.01, "height": 95.01 } "index": 0, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": -1.97, "y": 112, "width": 95.01, "height": 95.01 }
}, { }, {
"audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3",
"index": 1, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 311.03, "y": 118, "width": 77.01, "height": 77.01 } "index": 1, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 311.03, "y": 118, "width": 77.01, "height": 77.01 }
}], "title": "3434", "title_audio_url": "" }], "title": "3434", "title_audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3"
}, { }, {
"bgItem": { "bgItem": {
"url": "http://staging-teach.cdn.ireadabc.com/685ead5fe409d20412a38aae23c75ad0.png", "rect": { "x": 116.9444444444444, "y": -2.842170943040401e-14, "width": 663.1111111111112, "height": 373.00000000000006 } "url": "http://staging-teach.cdn.ireadabc.com/685ead5fe409d20412a38aae23c75ad0.png", "rect": { "x": 116.9444444444444, "y": -2.842170943040401e-14, "width": 663.1111111111112, "height": 373.00000000000006 }
}, "hotZoneItemArr": [{ }, "hotZoneItemArr": [{
"audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3",
"index": 0, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 72.06, "y": 52, "width": 133, "height": 49 } "index": 0, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 72.06, "y": 52, "width": 133, "height": 49 }
}, { }, {
"audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3",
"index": 1, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 475.06, "y": 30, "width": 159, "height": 67 } "index": 1, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 475.06, "y": 30, "width": 159, "height": 67 }
}], "title": "666", "title_audio_url": "" }], "title": "666", "title_audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3"
}] }]
}, { }, {
"queArr": [{ "queArr": [{
"bgItem": { "url": "http://staging-teach.cdn.ireadabc.com/6326a8bc4896aaa1834bd35f2dac9fee.png", "rect": { "x": 273.3030303030303, "y": 0, "width": 350.3939393939394, "height": 373 } }, "hotZoneItemArr": [{ "index": 0, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": -5.3, "y": 214, "width": 65, "height": 65 } }, { "index": 1, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 294.7, "y": 148, "width": 71, "height": 71 } }], "title": "455", "title_audio_url": "" "bgItem": { "url": "http://staging-teach.cdn.ireadabc.com/6326a8bc4896aaa1834bd35f2dac9fee.png", "rect": { "x": 273.3030303030303, "y": 0, "width": 350.3939393939394, "height": 373 } },
"hotZoneItemArr": [{
"audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3", "index": 0, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": -5.3, "y": 214, "width": 65, "height": 65 }
}, { "audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3", "index": 1, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 294.7, "y": 148, "width": 71, "height": 71 } }], "title": "455", "title_audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3"
}, {
"bgItem": { "url": "http://staging-teach.cdn.ireadabc.com/942fb8d28620d46d6c77d18909e86806.png", "rect": { "x": 116.9444444444444, "y": -2.842170943040401e-14, "width": 663.1111111111112, "height": 373.00000000000006 } },
"hotZoneItemArr": [{
"audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3", "index": 0, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 247.06, "y": 217, "width": 97, "height": 97 }
}, { }, {
"bgItem": { "url": "http://staging-teach.cdn.ireadabc.com/942fb8d28620d46d6c77d18909e86806.png", "rect": { "x": 116.9444444444444, "y": -2.842170943040401e-14, "width": 663.1111111111112, "height": 373.00000000000006 } }, "hotZoneItemArr": [{ "index": 0, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 247.06, "y": 217, "width": 97, "height": 97 } }, { "index": 1, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 515.06, "y": 108, "width": 57, "height": 57 } }], "title": "7777", "title_audio_url": "" "audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3", "index": 1, "itemType": "rect", "fontSize": 50, "fontName": "BRLNSR_1", "fontColor": "#8f3758", "fontScale": 0.70078125, "imgScale": 1, "mapScale": 0.70078125, "rect": { "x": 515.06, "y": 108, "width": 57, "height": 57 }
}], "title": "7777", "title_audio_url": "http://staging-teach.cdn.ireadabc.com/e3921a16a8313df274d8bc4e3f2bedd8.mp3"
}] }]
}] }]
} }
......
...@@ -5,7 +5,8 @@ g.res_mgr = { ...@@ -5,7 +5,8 @@ g.res_mgr = {
//获得表数据数据 //获得表数据数据
getFormData() { getFormData() {
console.log('初始化数据'); console.log('初始化数据');
try {
if (window && window.courseware) {
window.courseware.getData((res) => { window.courseware.getData((res) => {
//存入数据管理器 //存入数据管理器
g.data_mgr.data = res; g.data_mgr.data = res;
...@@ -13,13 +14,27 @@ g.res_mgr = { ...@@ -13,13 +14,27 @@ g.res_mgr = {
g.data_mgr.proGameData(); g.data_mgr.proGameData();
console.log("获得表单数据:" + res); console.log("获得表单数据:" + res);
}); });
} catch (error) { return;
}
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.getData((res) => {
//存入数据管理器
g.data_mgr.data = res;
//数据处理
g.data_mgr.proGameData();
console.log("获得表单数据:" + res);
});
return;
}
//console.error('没有查找到courseware.getData方法', error); //console.error('没有查找到courseware.getData方法', error);
//获得默认数据 //获得默认数据
g.data_mgr.data = g.data_mgr.getDefaultData(); g.data_mgr.data = g.data_mgr.getDefaultData();
//数据处理 //数据处理
g.data_mgr.proGameData(); g.data_mgr.proGameData();
}
}, },
//得到图片资源 //得到图片资源
......
...@@ -36,6 +36,7 @@ g.snd_mgr = { ...@@ -36,6 +36,7 @@ g.snd_mgr = {
// this.bgmId = cc.audioEngine.play(snd, loop); // this.bgmId = cc.audioEngine.play(snd, loop);
// return; // return;
// } // }
cc.audioEngine.stop()
this.bgmId = cc.audioEngine.playMusic(snd, loop); this.bgmId = cc.audioEngine.playMusic(snd, loop);
// 播放完成回调 // 播放完成回调
if (finishCB) { if (finishCB) {
...@@ -43,7 +44,6 @@ g.snd_mgr = { ...@@ -43,7 +44,6 @@ g.snd_mgr = {
finishCB(); finishCB();
}); });
} }
}, },
playEffect: function (snd, finishCB) { playEffect: function (snd, finishCB) {
if (!snd || this.effVol == 0) return; if (!snd || this.effVol == 0) return;
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
"packages": "packages", "packages": "packages",
"name": "play", "name": "play",
"id": "9af72fd2-44a6-4131-8ea3-3e1b3fa22231", "id": "9af72fd2-44a6-4131-8ea3-3e1b3fa22231",
"version": "2.4.5", "version": "2.4.4",
"isNew": false "isNew": false
} }
\ No newline at end of file
{ {
"title": "play", "title": "play",
"packageName": "org.cocos2d.demo", "packageName": "org.cocos2d.demo",
"startScene": "57ea7c61-9b8b-498a-b024-c98ee9124beb", "startScene": "f5b1b5a9-03b8-4bfd-b791-a1c7e640b256",
"excludeScenes": [], "excludeScenes": [],
"includeSDKBox": false, "includeSDKBox": false,
"orientation": { "orientation": {
......
import express from "express";
import os from "os";
import readline from "readline";
import { build } from "./buildCocos.js";
const networkInfo = os.networkInterfaces();
let host = '';
for (const infos of Object.values(networkInfo)) {
for (const info of infos) {
if (info.family == 'IPv4') {
if (info.address.split('.')[0] != "127") {
host = info.address;
}
}
}
}
var app = express();
app.use('/publish', express.static('publish'));
app.get('/', function (req, res) {
res.send('Hello World');
})
let port = '';
var server = app.listen(8081, function () {
port = server.address().port
console.log("测试服务已启动:%s:%s", host, port)
})
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
rl.on('line', async (str) => {
if (str.trim() == 'build') {
await build();
console.log("测试服务已启动:%s:%s", host, port)
console.log('输入 build 构建。')
} else {
console.log("测试服务已启动:%s:%s", host, port)
console.log('输入 build 构建。')
}
})
cd ../form & npm install & npm run publish & cd ../play & CocosCreator.exe --path "./" --build "platform=web-desktop;debug=true" --force & cd ../publish & node build.js
pause
let fs = require('fs'); import { build } from "./buildCocos.js";
const compressing = require('compressing'); await build();
\ No newline at end of file
function fix2(num) {
if (num >= 10) {
return '' + num;
} else {
return '0' + num;
}
}
async function copyDir(src, dst) {
const exists = await fs.existsSync(dst);
if (!exists) {
await fs.mkdirSync(dst);
}
//读取目录
const paths = await fs.readdirSync(src);
for (let i = 0; i < paths.length; i++) {
let path = paths[i];
const newSrc = `${src}/${path}`;
const newDst = `${dst}/${path}`;
const st = await fs.statSync(newSrc);
if (st.isFile()) {
console.log('copy: ' + newDst);
const data = await fs.readFileSync(newSrc);
await fs.writeFileSync(newDst, data);
} else if (st.isDirectory()) {
copyDir(newSrc, newDst);
}
}
}
async function removeDir(src) {
const exists = await fs.existsSync(src);
if (!exists) {
return;
}
//读取目录
const st = await fs.statSync(src);
console.log(st);
const paths = await fs.readdirSync(src);
for (let i = 0; i < paths.length; i++) {
let path = paths[i];
const newSrc = `${src}/${path}`;
const st = await fs.statSync(newSrc);
if (st.isFile()) {
console.log('remove: ' + newSrc);
await fs.unlinkSync(newSrc);
} else if (st.isDirectory()) {
await removeDir(newSrc);
}
}
await fs.rmdirSync(src);
}
async function main() {
let date = new Date();
let fileName = `Release_${date.getFullYear()}${fix2(date.getMonth() + 1)}${fix2(date.getDate())} `;
fileName += `${fix2(date.getHours())}-${fix2(date.getMinutes())}-${fix2(date.getSeconds())}`;
await removeDir('./publish/play');
await removeDir('./publish/form');
await copyDir('../play/build/web-desktop', './publish/play');
const data = await fs.readFileSync('./index.html');
await fs.writeFileSync('./publish/play/index.html', data);
compressing.zip.uncompress('../form/publish/form.zip', './publish/form')
.then(() => {
const tarStream = new compressing.zip.Stream();
tarStream.addEntry('./publish/play');
tarStream.addEntry('./publish/form');
const destStream = fs.createWriteStream(`publish/${fileName}.zip`);
tarStream.pipe(destStream);
console.log('打包完成!');
});
}
main();
\ No newline at end of file
#!/bin/sh
cd publish
set -e
node build_check.js
set +e
cd ../form
npm install
npm run publish
cd ../publish
node build_step_0.js
cd ../play
/Applications/CocosCreator/Creator/2.4.0/CocosCreator.app/Contents/MacOS/CocosCreator --path "./" --build "platform=web-desktop;debug=true" --force
echo "生成 web desktop 完成~!"
cd ../publish
node build_step_1.js
echo "build_step_1 完成~!"
cd ../play
/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/MacOS/CocosCreator --path "./" --build "platform=ios;debug=false;md5Cache=true;buildPath=build_ios;encryptJs=true;xxteaKey=6bbfce23-28b4-4a;zipCompressJs=true" --force
echo "生成 ios 完成~!"
cd ../publish
node build_step_2.js
echo "build_step_2 完成~!"
cd ../play
/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/MacOS/CocosCreator --path "./" --build "platform=ios;debug=false;md5Cache=true;buildPath=build_android;appABIs=['armeabi-v7a','x86','x86_64','arm64-v8a'];encryptJs=true;xxteaKey=6bbfce23-28b4-4a;zipCompressJs=true" --force
echo "生成 android 完成~!"
cd ../publish
node build_step_3.js
echo "build_step_3 完成~!"
cd ../play
/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/MacOS/CocosCreator --path "./" --build "platform=web-desktop;debug=false;buildPath=build_web_desktop" --force
echo "生成 web-desktop 完成~!"
cd ../publish
node build_step_4.js
echo "build_step_4 完成~!"
\ No newline at end of file
This diff is collapsed.
let fs = require('fs');
const dirNames = __dirname.split('/');
const projectName = dirNames[dirNames.length - 2];
const path = '../play/assets'
let folderName = '';
fs.readdirSync(path).find(fileName => {
const st = fs.statSync(`${path}/${fileName}`);
if (st.isDirectory()) {
folderName = fileName;
}
});
if (projectName != folderName) {
throw (`项目名(${projectName})与bundle文件夹名(${folderName})不相同`);
}
let same = false;
const files = fs.readdirSync(`${path}/${folderName}/scene`);
files.forEach(fileName => {
fileName.split('.').forEach((str, idx, arr) => {
if (str == 'fire') {
const sceneName = arr[idx - 1];
if (folderName == sceneName) {
same = true;
}
}
})
});
if (!same) {
throw (`bundle文件夹名称(${folderName})与scene名称不相同`);
}
\ No newline at end of file
let fs = require('fs');
const path = '../play/assets'
let folderName = '';
fs.readdirSync(path).find(fileName => {
const st = fs.statSync(`${path}/${fileName}`);
if (st.isDirectory()) {
folderName = fileName;
}
});
const metaPath = `${path}/${folderName}.meta`;
const metaDataStr = fs.readFileSync(metaPath);
const metaData = JSON.parse(metaDataStr);
metaData.isBundle = false;
fs.writeFileSync(metaPath, JSON.stringify(metaData));
const { removeDir, copyDir, fix2 } = require('./utils');
const compressing = require('compressing');
let fs = require('fs');
async function main() {
await removeDir('./publish/play');
await removeDir('./publish/form');
await copyDir('../play/build/web-desktop', './publish/play');
compressing.zip.uncompress('../form/publish/form.zip', './publish/form');
const data = await fs.readFileSync('./index.html');
await fs.writeFileSync('./publish/play/index.html', data);
await removeDir('../play/build/web-desktop');
const path = '../play/assets'
let folderName = '';
fs.readdirSync(path).find(fileName => {
const st = fs.statSync(`${path}/${fileName}`);
if (st.isDirectory()) {
folderName = fileName;
}
});
const metaPath = `${path}/${folderName}.meta`;
const metaDataStr = fs.readFileSync(metaPath);
const metaData = JSON.parse(metaDataStr);
metaData.isBundle = true;
metaData.isRemoteBundle = {
ios: true,
android: true
};
fs.writeFileSync(metaPath, JSON.stringify(metaData));
}
main();
\ No newline at end of file
const { removeDir, copyDir, fix2 } = require('./utils');
const compressing = require('compressing');
async function main() {
await removeDir('./publish/ios');
await copyDir('../play/build_ios/jsb-link/remote', './publish/ios');
await removeDir('../play/build_ios/jsb-link');
}
main();
\ No newline at end of file
const { removeDir, copyDir, fix2 } = require('./utils');
const compressing = require('compressing');
let fs = require('fs');
async function main() {
await removeDir('./publish/android');
await copyDir('../play/build_android/jsb-link/remote', './publish/android');
await removeDir('../play/build_android/jsb-link');
}
main();
\ No newline at end of file
const { removeDir, copyDir, fix2 } = require('./utils');
const compressing = require('compressing');
let fs = require('fs');
async function main() {
await removeDir('./publish/web_desktop');
const projectName = await getBundleName('../play/build_web_desktop/web-desktop/assets');
await copyDir(`../play/build_web_desktop/web-desktop/assets/${projectName}`, './publish/web_desktop');
await removeDir('../play/build_web_desktop');
const bundleData = {
ios: await getBundleData('./publish/ios'),
android: await getBundleData('./publish/android'),
}
fs.writeFileSync('./publish/config.json', JSON.stringify(bundleData));
const tarStream = new compressing.zip.Stream();
tarStream.addEntry('./publish/play');
tarStream.addEntry('./publish/form');
tarStream.addEntry('./publish/ios');
tarStream.addEntry('./publish/android');
tarStream.addEntry('./publish/web_desktop');
tarStream.addEntry('./publish/config.json');
const destStream = fs.createWriteStream(`publish/${getReleaseFileName()}.zip`);
tarStream.pipe(destStream);
console.log('打包完成!');
}
async function getBundleName(path) {
const paths = fs.readdirSync(path);
return paths.find(path => path != 'internal' && path !='main');
}
async function getBundleData(path) {
const bundleData = {
sceneName: '',
version: '',
}
const paths = fs.readdirSync(path);
bundleData.sceneName = paths[0];
const files = fs.readdirSync(path + '/' + bundleData.sceneName);
files.forEach(fileName => {
fileName.split('.').forEach((str, idx, arr) => {
if (str == 'config') {
bundleData.version = arr[idx + 1];
}
})
});
return bundleData;
}
function getReleaseFileName() {
let date = new Date();
let fileName = `Release_${date.getFullYear()}${fix2(date.getMonth() + 1)}${fix2(date.getDate())} `;
fileName += `${fix2(date.getHours())}-${fix2(date.getMinutes())}-${fix2(date.getSeconds())}`;
return fileName;
}
main();
\ No newline at end of file
This diff is collapsed.
...@@ -4,11 +4,18 @@ ...@@ -4,11 +4,18 @@
"description": "", "description": "",
"main": "build.js", "main": "build.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1",
"build": "node build.js",
"start": "node app.js"
}, },
"type": "module",
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"compressing": "^1.5.1" "child_process": "^1.0.2",
"compressing": "^1.5.1",
"express": "^4.17.1",
"js-base64": "^3.7.2",
"uuid": "^8.3.2"
} }
} }
let fs = require('fs'); import fs from 'fs';
module.exports = {
fix2: function (num) { export function fix2(num) {
if (num >= 10) { if (num >= 10) {
return '' + num; return '' + num;
} else { } else {
return '0' + num; return '0' + num;
} }
}, }
copyDir: async function (src, dst) { export async function copyDir(src, dst) {
const exists = await fs.existsSync(dst); const exists = await fs.existsSync(dst);
if (!exists) { if (!exists) {
await fs.mkdirSync(dst); await fs.mkdirSync(dst);
...@@ -26,12 +26,12 @@ module.exports = { ...@@ -26,12 +26,12 @@ module.exports = {
const data = await fs.readFileSync(newSrc); const data = await fs.readFileSync(newSrc);
await fs.writeFileSync(newDst, data); await fs.writeFileSync(newDst, data);
} else if (st.isDirectory()) { } else if (st.isDirectory()) {
arguments.callee(newSrc, newDst); await copyDir(newSrc, newDst);
} }
} }
}, }
removeDir: async function (src) { export async function removeDir(src) {
const exists = await fs.existsSync(src); const exists = await fs.existsSync(src);
if (!exists) { if (!exists) {
return; return;
...@@ -48,9 +48,8 @@ module.exports = { ...@@ -48,9 +48,8 @@ module.exports = {
console.log('remove: ' + newSrc); console.log('remove: ' + newSrc);
await fs.unlinkSync(newSrc); await fs.unlinkSync(newSrc);
} else if (st.isDirectory()) { } else if (st.isDirectory()) {
await arguments.callee(newSrc); await removeDir(newSrc);
} }
} }
await fs.rmdirSync(src); await fs.rmdirSync(src);
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment