Commit 795a4873 authored by huoshizhe's avatar huoshizhe

feat: 自动化打包完成

parent 8cd992fe
/publish/form
/publish/play
/publish/node_modules
/publish/publish/play
/publish/publish/form
/publish/publish/*.zip
......@@ -69,7 +69,8 @@ const runSpawn = async function (){
let zippath = path.resolve(__dirname,"../dist", pkg.name);
//压缩包的存放目录
let date = new Date();
let zipname = pkg.name+"_"+date.Format("yyyyMMdd hh-mm-ss");
// let zipname = pkg.name+"_"+date.Format("yyyyMMdd hh-mm-ss");
let zipname = 'form';
let zipdir = path.resolve(__dirname,"../publish/"+zipname+".zip");
clean(zipdir); //删除原有的包
......
/****
* 批量编译打包模板工具
* 运行 npm run publish T_01 命令来打包T_01模板
* 运行 npm run publish T_01,T_02,T_03,T_04 命令来分别打包 T_01,T_02,T_03,T_04 这四个模板,注意逗号要用英文的
* 运行 npm run publish all 命令来打包所有模板
*/
const spawn = require('child_process').spawn;
const path = require("path");
const fs = require("fs");
const os = require('os');
const compressing = require("compressing");
//Linux系统上'Linux'
//macOS 系统上'Darwin'
//Windows系统上'Windows_NT'
let sysType = os.type();
Date.prototype.Format = function(fmt) {
var o = {
"M+" : this.getMonth() + 1,
"d+" : this.getDate(),
"h+" : this.getHours(),
"m+" : this.getMinutes(),
"s+" : this.getSeconds(),
"q+" : Math.floor((this.getMonth() + 3) / 3),
"S" : this.getMilliseconds()
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
function clean(zipPath){
if(fs.existsSync(zipPath)){
fs.unlinkSync(zipPath);
}
}
const runSpawn = async function (){
await new Promise(function(resolve,reject){
let pkg = require("../package.json");
let ls;
if(sysType==="Windows_NT"){
//ng build --prod --build--optimizer --base-href /ng-one/
ls = spawn("cmd.exe", ['/c', 'ng', 'build', '--prod', '--build--optimizer', '--base-href', '/template-base-href/'] );
}else{
ls = spawn("ng", ['build', '--prod', '--build--optimizer', '--base-href', '/template-base-href/'] );
}
ls.stdout.on('data', (data) => {
console.log(` ${data}`);
});
ls.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
reject();
});
ls.on('close', (code) => {
console.log(`child process exited with code ${code}`);
//要压缩的目录
let zippath = path.resolve(__dirname,"../dist", pkg.name);
//压缩包的存放目录
let date = new Date();
// let zipname = pkg.name+"_"+date.Format("yyyyMMdd hh-mm-ss");
let zipname = 'form';
let zipdir = path.resolve(__dirname,"../publish/"+zipname+".zip");
clean(zipdir); //删除原有的包
const tarStream = new compressing.zip.Stream();
fs.readdir(zippath,function(err,files){
if(err){
console.log("======文件打开异常======");
console.log(err);
reject();
}
for(let i=0;i<files.length;i++){
tarStream.addEntry(zippath+"/"+files[i]);
}
let writeStream = fs.createWriteStream(zipdir);
tarStream.pipe(writeStream);
writeStream.on('close', () => {
console.log(`模板 ${pkg.name} 打包已完成!`);
resolve();
})
});
});
});
}
// let projects = "";
// if(process.argv.length<3){
// console.log("缺少参数");
// return;
// }
// projects = process.argv[2];
let exec = async function(){
//压缩模板
await runSpawn();
}
exec();
......@@ -78,22 +78,22 @@
"__id__": 8
},
{
"__id__": 48
"__id__": 50
}
],
"_active": true,
"_components": [
{
"__id__": 50
"__id__": 52
},
{
"__id__": 51
"__id__": 53
},
{
"__id__": 52
"__id__": 54
},
{
"__id__": 53
"__id__": 55
}
],
"_prefab": null,
......@@ -183,7 +183,7 @@
"array": [
0,
0,
530.3187749955615,
530.8735725198609,
0,
0,
0,
......@@ -384,31 +384,34 @@
"__id__": 14
},
{
"__id__": 15
"__id__": 16
},
{
"__id__": 19
"__id__": 17
},
{
"__id__": 22
"__id__": 21
},
{
"__id__": 33
"__id__": 24
},
{
"__id__": 40
"__id__": 35
},
{
"__id__": 44
"__id__": 42
},
{
"__id__": 46
}
],
"_active": true,
"_components": [
{
"__id__": 46
"__id__": 48
},
{
"__id__": 47
"__id__": 49
}
],
"_prefab": null,
......@@ -718,6 +721,136 @@
"_N$target": null,
"_id": "18UTk0lXJDAqsdv+mOBQkG"
},
{
"__type__": "cc.Node",
"_name": "BtnWheel",
"_objFlags": 0,
"_parent": {
"__id__": 8
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 15
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 250,
"height": 300
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-453.613,
248.796,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "94qRkJLitFTKW165CylmUA"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "b0yXRAUxRPNanaC5goUhJV"
},
{
"__type__": "cc.Node",
"_name": "NodeBubblePos",
......@@ -785,13 +918,13 @@
},
"_children": [
{
"__id__": 16
"__id__": 18
}
],
"_active": true,
"_components": [
{
"__id__": 18
"__id__": 20
}
],
"_prefab": null,
......@@ -847,13 +980,13 @@
"_name": "NodeTree",
"_objFlags": 0,
"_parent": {
"__id__": 15
"__id__": 17
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 17
"__id__": 19
}
],
"_prefab": null,
......@@ -909,7 +1042,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 16
"__id__": 18
},
"_enabled": true,
"_materials": [
......@@ -941,7 +1074,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
"__id__": 17
},
"_enabled": true,
"_materials": [
......@@ -967,10 +1100,10 @@
"_active": true,
"_components": [
{
"__id__": 20
"__id__": 22
},
{
"__id__": 21
"__id__": 23
}
],
"_prefab": null,
......@@ -1026,7 +1159,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 19
"__id__": 21
},
"_enabled": true,
"_materials": [
......@@ -1058,7 +1191,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 19
"__id__": 21
},
"_enabled": true,
"alignMode": 1,
......@@ -1088,9 +1221,6 @@
"__id__": 8
},
"_children": [
{
"__id__": 23
},
{
"__id__": 25
},
......@@ -1102,6 +1232,9 @@
},
{
"__id__": 31
},
{
"__id__": 33
}
],
"_active": true,
......@@ -1159,13 +1292,13 @@
"_name": "NodeFishPos_0",
"_objFlags": 0,
"_parent": {
"__id__": 22
"__id__": 24
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 24
"__id__": 26
}
],
"_prefab": null,
......@@ -1221,7 +1354,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 23
"__id__": 25
},
"_enabled": true,
"_materials": [
......@@ -1253,13 +1386,13 @@
"_name": "NodeFishPos_1",
"_objFlags": 0,
"_parent": {
"__id__": 22
"__id__": 24
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 26
"__id__": 28
}
],
"_prefab": null,
......@@ -1315,7 +1448,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 25
"__id__": 27
},
"_enabled": true,
"_materials": [
......@@ -1347,13 +1480,13 @@
"_name": "NodeFishPos_2",
"_objFlags": 0,
"_parent": {
"__id__": 22
"__id__": 24
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 28
"__id__": 30
}
],
"_prefab": null,
......@@ -1409,7 +1542,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 27
"__id__": 29
},
"_enabled": true,
"_materials": [
......@@ -1441,13 +1574,13 @@
"_name": "NodeFishPos_3",
"_objFlags": 0,
"_parent": {
"__id__": 22
"__id__": 24
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 30
"__id__": 32
}
],
"_prefab": null,
......@@ -1503,7 +1636,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 29
"__id__": 31
},
"_enabled": true,
"_materials": [
......@@ -1535,13 +1668,13 @@
"_name": "NodeFishPos_4",
"_objFlags": 0,
"_parent": {
"__id__": 22
"__id__": 24
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 32
"__id__": 34
}
],
"_prefab": null,
......@@ -1597,7 +1730,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 31
"__id__": 33
},
"_enabled": true,
"_materials": [
......@@ -1632,14 +1765,14 @@
"__id__": 8
},
"_children": [
{
"__id__": 34
},
{
"__id__": 36
},
{
"__id__": 38
},
{
"__id__": 40
}
],
"_active": true,
......@@ -1697,13 +1830,13 @@
"_name": "NodeCharacterNormal",
"_objFlags": 0,
"_parent": {
"__id__": 33
"__id__": 35
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 35
"__id__": 37
}
],
"_prefab": null,
......@@ -1759,7 +1892,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 34
"__id__": 36
},
"_enabled": true,
"_materials": [
......@@ -1799,13 +1932,13 @@
"_name": "NodeCharacterWalk",
"_objFlags": 0,
"_parent": {
"__id__": 33
"__id__": 35
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 37
"__id__": 39
}
],
"_prefab": null,
......@@ -1861,7 +1994,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 36
"__id__": 38
},
"_enabled": true,
"_materials": [
......@@ -1901,13 +2034,13 @@
"_name": "NodeCharacterWater",
"_objFlags": 0,
"_parent": {
"__id__": 33
"__id__": 35
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 39
"__id__": 41
}
],
"_prefab": null,
......@@ -1963,7 +2096,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 38
"__id__": 40
},
"_enabled": true,
"_materials": [
......@@ -2007,13 +2140,13 @@
},
"_children": [
{
"__id__": 41
"__id__": 43
}
],
"_active": true,
"_components": [
{
"__id__": 43
"__id__": 45
}
],
"_prefab": null,
......@@ -2069,13 +2202,13 @@
"_name": "NodeKnock",
"_objFlags": 0,
"_parent": {
"__id__": 40
"__id__": 42
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 42
"__id__": 44
}
],
"_prefab": null,
......@@ -2131,7 +2264,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 41
"__id__": 43
},
"_enabled": true,
"_materials": [
......@@ -2163,7 +2296,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 40
"__id__": 42
},
"_enabled": true,
"_materials": [
......@@ -2189,7 +2322,7 @@
"_active": false,
"_components": [
{
"__id__": 45
"__id__": 47
}
],
"_prefab": null,
......@@ -2245,7 +2378,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 44
"__id__": 46
},
"_enabled": true,
"_materials": [
......@@ -2342,7 +2475,7 @@
"_active": true,
"_components": [
{
"__id__": 49
"__id__": 51
}
],
"_prefab": null,
......@@ -2398,7 +2531,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 48
"__id__": 50
},
"_enabled": true,
"开门": {
......
......@@ -103,8 +103,8 @@ cc.Class({
},
initListeners() {
const nodeWheel = cc.find('Canvas/NodeBg/NodeWheel');
nodeWheel.on('click', () => {
const btnWheel = cc.find('Canvas/NodeBg/BtnWheel');
btnWheel.on('click', () => {
this.onClickWheel();
});
},
......
......@@ -8,6 +8,7 @@
]
],
"excluded-modules": [
"3D Physics/cannon.js",
"3D Physics/Builtin"
],
"preview-port": 7456,
......
cd ../play
CocosCreator.exe --path "./" --build "configPath=../publish/buildConfig.json" --force
cd ../form
npm run publish_2
cd ../publish
node build.js
pause
cd ../form & npm run publish & cd ../play & CocosCreator.exe --path "./" --build "configPath=../publish/buildConfig.json" --force & cd ../publish & node build.js
pause
......@@ -16,54 +16,50 @@ async function initFiles() {
}
}
async function copyDir(src, dst) {
// fs.fileex
const exists = await fs.existsSync(dst);
if (!exists) {
await fs.mkdirSync(dst);
}
//读取目录
const paths = await fs.readdirSync(src);
paths.forEach(async function (path) {
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 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 initFiles();
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('../play/build/web-desktop');
tarStream.addEntry('./publish/play');
tarStream.addEntry('./publish/form');
const destStream = fs.createWriteStream(`publish/${fileName}.zip`);
tarStream.pipe(destStream);
console.log('打包完成!');
});
}
main();
// var copy = async function (src, dst) {
// //读取目录
// const paths = await fs.readdirSync(src);
// paths.forEach(async function (path) {
// const newSrc = `${src}/${path}`;
// const newDst = `${dst}/${path}`;
// const st = await fs.statSync(newSrc);
// if (st.isFile()) {
// const data = await fs.readFileSync(newSrc);
// await fs.writeFileSync(newDst, data);
// } else if (st.isDirectory()) {
// exists(newSrc, newDst, copy);
// }
// });
// }
// var exists = function (src, dst, callback) {
// //测试某个路径下文件是否存在
// fs.exists(dst, function (exists) {
// if (exists) {//不存在
// callback(src, dst);
// } else {//存在
// fs.mkdir(dst, function () {//创建目录
// callback(src, dst)
// })
// }
// })
// }
// exists('../from', '../to', copy)
\ No newline at end of file
main();
\ 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