Commit 453af711 authored by liujiangnan's avatar liujiangnan

feat: 简化目录

parent 53902fd1
...@@ -5,6 +5,60 @@ ...@@ -5,6 +5,60 @@
/form/publish/*.zip /form/publish/*.zip
/publish/play /publish/play
/node_modules /node_modules
/play/build_android /build_android
/play/build_ios /build_ios
/play/build_web_desktop /build_web_desktop
\ No newline at end of file
#/////////////////////////////////////////////////////////////////////////////
# Fireball Projects
#/////////////////////////////////////////////////////////////////////////////
/library/
/temp/
/local/
/build/
#/////////////////////////////////////////////////////////////////////////////
# npm files
#/////////////////////////////////////////////////////////////////////////////
npm-debug.log
node_modules/
#/////////////////////////////////////////////////////////////////////////////
# Logs and databases
#/////////////////////////////////////////////////////////////////////////////
*.log
*.sql
*.sqlite
#/////////////////////////////////////////////////////////////////////////////
# files for debugger
#/////////////////////////////////////////////////////////////////////////////
*.sln
*.csproj
*.pidb
*.unityproj
*.suo
#/////////////////////////////////////////////////////////////////////////////
# OS generated files
#/////////////////////////////////////////////////////////////////////////////
.DS_Store
ehthumbs.db
Thumbs.db
#/////////////////////////////////////////////////////////////////////////////
# WebStorm files
#/////////////////////////////////////////////////////////////////////////////
.idea/
#//////////////////////////
# VS Code files
#//////////////////////////
.vscode/
...@@ -34,8 +34,7 @@ var server = app.listen(8081, function () { ...@@ -34,8 +34,7 @@ var server = app.listen(8081, function () {
console.log("http://%s:%s/dist/play/index.html", host, port) console.log("http://%s:%s/dist/play/index.html", host, port)
console.log("http://%s:%s/dist/play/index.html", "localhost", port) console.log("http://%s:%s/dist/play/index.html", "localhost", port)
console.log('-----------------'); console.log('-----------------');
console.log(" 输入 build 构建全部脚本"); console.log(" 输入 build 构建安卓脚本");
console.log(" 输入 build android 构建安卓脚本");
console.log(" 输入 build ios 构建IOS脚本"); console.log(" 输入 build ios 构建IOS脚本");
console.log('-----------------'); console.log('-----------------');
...@@ -47,8 +46,6 @@ const rl = readline.createInterface({ ...@@ -47,8 +46,6 @@ const rl = readline.createInterface({
}) })
rl.on('line', async (str) => { rl.on('line', async (str) => {
if (str.trim() == 'build') { if (str.trim() == 'build') {
await build();
} else if (str.trim() == 'build android') {
await buildAndroid(); await buildAndroid();
} else if (str.trim() == 'build ios') { } else if (str.trim() == 'build ios') {
await buildIos(); await buildIos();
......
...@@ -61,7 +61,7 @@ const buildCocos = function (args) { ...@@ -61,7 +61,7 @@ const buildCocos = function (args) {
const buffer = spawn( const buffer = spawn(
creatorBasePath, creatorBasePath,
args, args,
{ cwd: 'play' } { cwd: '.' }
); );
buffer.stdout.on('data', (data) => { buffer.stdout.on('data', (data) => {
...@@ -166,7 +166,7 @@ function compressAll (projectName) { ...@@ -166,7 +166,7 @@ function compressAll (projectName) {
function build_check () { function build_check () {
const dirNames = process.cwd().split(/\/|\\/); const dirNames = process.cwd().split(/\/|\\/);
const projectName = dirNames[dirNames.length - 1]; const projectName = dirNames[dirNames.length - 1];
const path = 'play/assets' const path = 'assets'
let folderName = ''; let folderName = '';
fs.readdirSync(path).find(fileName => { fs.readdirSync(path).find(fileName => {
const st = fs.statSync(`${path}/${fileName}`); const st = fs.statSync(`${path}/${fileName}`);
...@@ -199,13 +199,13 @@ function build_check () { ...@@ -199,13 +199,13 @@ function build_check () {
} }
function changeSettingToWebDesktop () { function changeSettingToWebDesktop () {
const path = 'play/assets' const path = 'assets'
const folderName = getFolderName(path); const folderName = getFolderName(path);
editFolderMeta(path, folderName, false); editFolderMeta(path, folderName, false);
} }
function changeSettingsToBundle () { function changeSettingsToBundle () {
const path = 'play/assets' const path = 'assets'
const folderName = getFolderName(path); const folderName = getFolderName(path);
editFolderMeta(path, folderName, true); editFolderMeta(path, folderName, true);
} }
...@@ -242,15 +242,15 @@ function replaceUuids () { ...@@ -242,15 +242,15 @@ function replaceUuids () {
fs.writeFileSync(path, newFileStr); fs.writeFileSync(path, newFileStr);
} }
const path = 'play/assets' const path = 'assets'
const folderName = getFolderName(path); const folderName = getFolderName(path);
editFolderMeta(path, folderName); editFolderMeta(path, folderName);
const oldFireUuid = '57ea7c61-9b8b-498a-b024-c98ee9124beb'; const oldFireUuid = '57ea7c61-9b8b-498a-b024-c98ee9124beb';
const newFireUuid = v4(); const newFireUuid = v4();
fileReplace(`play/assets/${folderName}/scene/${folderName}.fire.meta`, oldFireUuid, newFireUuid); fileReplace(`assets/${folderName}/scene/${folderName}.fire.meta`, oldFireUuid, newFireUuid);
fileReplace(`play/assets/${folderName}/scene/${folderName}.fire`, oldFireUuid, newFireUuid); fileReplace(`assets/${folderName}/scene/${folderName}.fire`, oldFireUuid, newFireUuid);
fileReplace('play/settings/builder.json', oldFireUuid, newFireUuid); fileReplace('settings/builder.json', oldFireUuid, newFireUuid);
function getShortUuid(uuid) { function getShortUuid(uuid) {
...@@ -264,16 +264,16 @@ function replaceUuids () { ...@@ -264,16 +264,16 @@ function replaceUuids () {
const newJsUuid = v4(); const newJsUuid = v4();
const newJsShortUuid = getShortUuid(newJsUuid); const newJsShortUuid = getShortUuid(newJsUuid);
const newJsId = v4().replace(/-/g, '').substring(0, oldJsId.length); const newJsId = v4().replace(/-/g, '').substring(0, oldJsId.length);
fileReplace(`play/assets/${folderName}/scene/${folderName}.ts.meta`, oldJsUuid, newJsUuid); fileReplace(`assets/${folderName}/scene/${folderName}.ts.meta`, oldJsUuid, newJsUuid);
fileReplace(`play/assets/${folderName}/scene/${folderName}.fire`, oldFireUuid, newFireUuid); fileReplace(`assets/${folderName}/scene/${folderName}.fire`, oldFireUuid, newFireUuid);
fileReplace(`play/assets/${folderName}/scene/${folderName}.fire`, oldJsShortUuid, newJsShortUuid); fileReplace(`assets/${folderName}/scene/${folderName}.fire`, oldJsShortUuid, newJsShortUuid);
fileReplace(`play/assets/${folderName}/scene/${folderName}.fire`, oldJsId, newJsId); fileReplace(`assets/${folderName}/scene/${folderName}.fire`, oldJsId, newJsId);
console.log('build_step_0 完成~!'); console.log('build_step_0 完成~!');
} }
function replaceIndexHtml () { function replaceIndexHtml () {
const data = fs.readFileSync('play/index.html'); const data = fs.readFileSync('index.html');
fs.writeFileSync('dist/play/index.html', data); fs.writeFileSync('dist/play/index.html', data);
} }
...@@ -301,7 +301,7 @@ module.exports = { ...@@ -301,7 +301,7 @@ module.exports = {
// 构建play // 构建play
await removeDir('dist/play'); await removeDir('dist/play');
await buildWebDesktop(); await buildWebDesktop();
await copyDir('play/build/web-desktop', 'dist/play'); await copyDir('build/web-desktop', 'dist/play');
replaceIndexHtml(); replaceIndexHtml();
console.log('构建 web desktop 成功!'); console.log('构建 web desktop 成功!');
...@@ -310,17 +310,17 @@ module.exports = { ...@@ -310,17 +310,17 @@ module.exports = {
await removeDir('dist/android'); await removeDir('dist/android');
await buildAndroidBundle(); await buildAndroidBundle();
await copyDir('play/build_android/jsb-link/remote', 'dist/android'); await copyDir('build_android/jsb-link/remote', 'dist/android');
console.log('构建 android bundle 成功!'); console.log('构建 android bundle 成功!');
await removeDir('dist/ios'); await removeDir('dist/ios');
await buildIosBundle(); await buildIosBundle();
await copyDir('play/build_ios/jsb-link/remote', 'dist/ios'); await copyDir('build_ios/jsb-link/remote', 'dist/ios');
console.log('构建 ios bundle 成功!'); console.log('构建 ios bundle 成功!');
await removeDir('dist/web_desktop'); await removeDir('dist/web_desktop');
await buildWebBundle(); await buildWebBundle();
await copyDir(`play/build_web_desktop/web-desktop/assets/${projectName}`, 'dist/web_desktop'); await copyDir(`build_web_desktop/web-desktop/assets/${projectName}`, 'dist/web_desktop');
console.log('构建 web bundle 成功!'); console.log('构建 web bundle 成功!');
// 改设置为非bundle // 改设置为非bundle
...@@ -329,7 +329,12 @@ module.exports = { ...@@ -329,7 +329,12 @@ module.exports = {
createConfigFile(projectName); createConfigFile(projectName);
compressAll(projectName); compressAll(projectName);
await removeDir('build');
await removeDir('build_android');
await removeDir('build_ios');
await removeDir('build_web_desktop');
const endTime = new Date().getTime(); const endTime = new Date().getTime();
const duration = new Date(endTime - startTime); const duration = new Date(endTime - startTime);
console.log(`打包完成!`); console.log(`打包完成!`);
...@@ -342,11 +347,13 @@ module.exports = { ...@@ -342,11 +347,13 @@ module.exports = {
await removeDir('dist/android'); await removeDir('dist/android');
await buildAndroidBundle(); await buildAndroidBundle();
await copyDir('play/build_android/jsb-link/remote', 'dist/android'); await copyDir('build_android/jsb-link/remote', 'dist/android');
console.log('构建 android bundle 成功!'); console.log('构建 android bundle 成功!');
// 改设置为非bundle // 改设置为非bundle
changeSettingToWebDesktop(); changeSettingToWebDesktop();
await removeDir('build_android');
}, },
buildIos: async function () { buildIos: async function () {
...@@ -355,11 +362,12 @@ module.exports = { ...@@ -355,11 +362,12 @@ module.exports = {
await removeDir('dist/ios'); await removeDir('dist/ios');
await buildIosBundle(); await buildIosBundle();
await copyDir('play/build_ios/jsb-link/remote', 'dist/ios'); await copyDir('build_ios/jsb-link/remote', 'dist/ios');
console.log('构建 ios bundle 成功!'); console.log('构建 ios bundle 成功!');
// 改设置为非bundle // 改设置为非bundle
changeSettingToWebDesktop(); changeSettingToWebDesktop();
await removeDir('build_ios');
} }
}; };
#/////////////////////////////////////////////////////////////////////////////
# Fireball Projects
#/////////////////////////////////////////////////////////////////////////////
/library/
/temp/
/local/
/build/
#/////////////////////////////////////////////////////////////////////////////
# npm files
#/////////////////////////////////////////////////////////////////////////////
npm-debug.log
node_modules/
#/////////////////////////////////////////////////////////////////////////////
# Logs and databases
#/////////////////////////////////////////////////////////////////////////////
*.log
*.sql
*.sqlite
#/////////////////////////////////////////////////////////////////////////////
# files for debugger
#/////////////////////////////////////////////////////////////////////////////
*.sln
*.csproj
*.pidb
*.unityproj
*.suo
#/////////////////////////////////////////////////////////////////////////////
# OS generated files
#/////////////////////////////////////////////////////////////////////////////
.DS_Store
ehthumbs.db
Thumbs.db
#/////////////////////////////////////////////////////////////////////////////
# WebStorm files
#/////////////////////////////////////////////////////////////////////////////
.idea/
#//////////////////////////
# VS Code files
#//////////////////////////
.vscode/
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