tt-minigame-ide-cli 0.0.1-beta.3 → 0.0.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/util/helper.js +8 -10
- package/package.json +1 -1
package/lib/util/helper.js
CHANGED
@@ -24,21 +24,19 @@ function mixEncode(data) {
|
|
24
24
|
}
|
25
25
|
|
26
26
|
async function zipFile(sourcePath, targetPath) {
|
27
|
-
const
|
28
|
-
const isMiniProgram = await fs.pathExists(appJsonPath);
|
29
|
-
const subpackageInfoPath = path.join(sourcePath, `${isMiniProgram ? 'app.json' : 'game.json'}`);
|
27
|
+
const subpackageInfoPath = path.join(sourcePath, 'game.json');
|
30
28
|
const projectConfigJson = fs.readJSONSync(subpackageInfoPath);
|
31
29
|
const subPackagesArr = projectConfigJson.subPackages || projectConfigJson.subpackages;
|
32
30
|
const zipFileRet = {
|
33
31
|
filePath: null,
|
34
32
|
};
|
35
33
|
if (subPackagesArr && subPackagesArr.length > 0) {
|
36
|
-
const ifSubPackageUploadable = await verifySubPackageSize(projectConfigJson,
|
34
|
+
const ifSubPackageUploadable = await verifySubPackageSize(projectConfigJson, sourcePath);
|
37
35
|
if (ifSubPackageUploadable) {
|
38
|
-
zipFileRet.filePath = await normalZipFile(sourcePath, targetPath,
|
36
|
+
zipFileRet.filePath = await normalZipFile(sourcePath, targetPath, true);
|
39
37
|
}
|
40
38
|
} else {
|
41
|
-
zipFileRet.filePath = await normalZipFile(sourcePath, targetPath,
|
39
|
+
zipFileRet.filePath = await normalZipFile(sourcePath, targetPath, false);
|
42
40
|
}
|
43
41
|
return zipFileRet;
|
44
42
|
}
|
@@ -46,7 +44,7 @@ async function zipFile(sourcePath, targetPath) {
|
|
46
44
|
/**
|
47
45
|
* @description 校验分包大小, 小游戏和小程序的不同在于子包不同
|
48
46
|
*/
|
49
|
-
async function verifySubPackageSize(projectConfigJson,
|
47
|
+
async function verifySubPackageSize(projectConfigJson, sourcePath) {
|
50
48
|
let subPackageTotalSize = 0; // 子包+主包
|
51
49
|
// 做大小比较全拿字节数,精确
|
52
50
|
const packageSizeConfig = {
|
@@ -56,7 +54,7 @@ async function verifySubPackageSize(projectConfigJson, isMiniProgram, sourcePath
|
|
56
54
|
};
|
57
55
|
// console.log('校验', projectConfigJson, packageSizeConfig);
|
58
56
|
// 开放数据域文件校验,可以认为开放数据域也作为一个子包
|
59
|
-
if (
|
57
|
+
if (projectConfigJson.openDataContext) {
|
60
58
|
const openDataContextPath = path.join(sourcePath, projectConfigJson.openDataContext);
|
61
59
|
const openDataContextSize = await getFolderSize(openDataContextPath);
|
62
60
|
if (openDataContextSize > packageSizeConfig.subPackageSize) {
|
@@ -111,9 +109,9 @@ async function verifySubPackageSize(projectConfigJson, isMiniProgram, sourcePath
|
|
111
109
|
return true;
|
112
110
|
}
|
113
111
|
|
114
|
-
async function normalZipFile(sourcePath, targetPath,
|
112
|
+
async function normalZipFile(sourcePath, targetPath, isSubPackage) {
|
115
113
|
|
116
|
-
const packageSize =
|
114
|
+
const packageSize = 8;
|
117
115
|
const zipPath = path.join(targetPath, `${path.basename(sourcePath)}.zip`);
|
118
116
|
return new Promise(function (resolve, reject) {
|
119
117
|
const output = fs.createWriteStream(zipPath);
|