tt-minigame-ide-cli 0.0.1-beta.0 → 0.0.1-beta.1
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/bin/tmg.js +2 -0
- package/lib/util/helper.js +8 -4
- package/lib/util/qrcode.js +22 -7
- package/lib/util/request.js +2 -0
- package/package.json +2 -2
package/bin/tmg.js
CHANGED
@@ -105,6 +105,7 @@ program
|
|
105
105
|
.option('-s, --small', 'Use small QR Code, it may fail in some environments')
|
106
106
|
.option('-c, --copy', 'Copy remote url to clipboard')
|
107
107
|
.option('-p, --proxy <proxy>', 'Preview with proxy')
|
108
|
+
.option('-o, --output <path>', 'QRCode image output path')
|
108
109
|
.action((entry, cmd) => {
|
109
110
|
const options = cleanArgs(cmd);
|
110
111
|
checkArgNum(1);
|
@@ -139,6 +140,7 @@ program
|
|
139
140
|
.requiredOption('-c, --app-changelog <log>', 'Changelog for this version')
|
140
141
|
.option('-p, --proxy <proxy>', 'Update request proxy')
|
141
142
|
.option('-cp, --copy', 'Copy remote url to clipboard')
|
143
|
+
.option('-o, --output <path>', 'QRCode image output path')
|
142
144
|
.action((entry, cmd) => {
|
143
145
|
const options = cleanArgs(cmd);
|
144
146
|
checkArgNum(1);
|
package/lib/util/helper.js
CHANGED
@@ -51,8 +51,8 @@ async function verifySubPackageSize(projectConfigJson, isMiniProgram, sourcePath
|
|
51
51
|
// 做大小比较全拿字节数,精确
|
52
52
|
const packageSizeConfig = {
|
53
53
|
mainPackageMaxSize: 4 * 1024 * 1024,
|
54
|
-
subPackageSize:
|
55
|
-
totalSize:
|
54
|
+
subPackageSize: 4 * 1024 * 1024,
|
55
|
+
totalSize: 20 * 1024 * 1024,
|
56
56
|
};
|
57
57
|
// console.log('校验', projectConfigJson, packageSizeConfig);
|
58
58
|
// 开放数据域文件校验,可以认为开放数据域也作为一个子包
|
@@ -72,9 +72,9 @@ async function verifySubPackageSize(projectConfigJson, isMiniProgram, sourcePath
|
|
72
72
|
const totalPackageSize = await getFolderSize(sourcePath);
|
73
73
|
if (totalPackageSize > packageSizeConfig.totalSize) {
|
74
74
|
console.error(
|
75
|
-
|
75
|
+
`小游戏包大小为 ${getFormattedSize(
|
76
76
|
totalPackageSize,
|
77
|
-
)} MB, 超过
|
77
|
+
)} MB, 超过 20 MB,请调整包大小后再进行上传`,
|
78
78
|
);
|
79
79
|
return false;
|
80
80
|
}
|
@@ -205,6 +205,10 @@ function getCachedPreviewResult(type, hash) {
|
|
205
205
|
}
|
206
206
|
|
207
207
|
function getFolderSize(folderPath, options = {}) {
|
208
|
+
const stat = fs.statSync(folderPath);
|
209
|
+
if (stat.isFile()) {
|
210
|
+
return Promise.resolve(stat.size);
|
211
|
+
}
|
208
212
|
return new Promise((resolve, reject) => {
|
209
213
|
glob(
|
210
214
|
'**',
|
package/lib/util/qrcode.js
CHANGED
@@ -1,17 +1,32 @@
|
|
1
|
-
const
|
1
|
+
const QRCode = require('qrcode');
|
2
2
|
const chalk = require('chalk');
|
3
|
+
|
3
4
|
function generateQrCode(url, options) {
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
if (options.small) {
|
6
|
+
console.log(`${chalk.yellow('small QR Code may not work in some environments')}\n`);
|
7
|
+
}
|
8
|
+
|
9
|
+
QRCode.toString(url, { type: 'terminal', small: options.small }, function (err, str) {
|
10
|
+
if (err) {
|
11
|
+
throw Error(err);
|
12
|
+
}
|
13
|
+
console.log(str);
|
14
|
+
})
|
15
|
+
|
7
16
|
if (options.copy) {
|
8
17
|
require('clipboardy').writeSync(url);
|
9
18
|
copied = chalk.dim('(copied to clipboard)');
|
19
|
+
console.log(`${chalk.cyan(JSON.stringify(url))} ${copied}`);
|
10
20
|
}
|
11
|
-
|
12
|
-
|
21
|
+
|
22
|
+
if (options.output) {
|
23
|
+
QRCode.toFile(options.output, url, { type: 'png' }, function (err) {
|
24
|
+
console.log(chalk.yellow(`Save qrcode image to ${options.output}`));
|
25
|
+
if (err) {
|
26
|
+
throw Error(err);
|
27
|
+
}
|
28
|
+
})
|
13
29
|
}
|
14
|
-
console.log(`${chalk.cyan(JSON.stringify(url))} ${copied}`);
|
15
30
|
}
|
16
31
|
|
17
32
|
module.exports = {
|
package/lib/util/request.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "tt-minigame-ide-cli",
|
3
|
-
"version": "0.0.1-beta.
|
3
|
+
"version": "0.0.1-beta.1",
|
4
4
|
"description": "Command line interface for micro app development",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"bin": {
|
@@ -24,7 +24,7 @@
|
|
24
24
|
"glob": "^7.2.0",
|
25
25
|
"inquirer": "^7.0.4",
|
26
26
|
"minimist": "^1.2.0",
|
27
|
-
"qrcode
|
27
|
+
"qrcode": "^1.5.0",
|
28
28
|
"semver": "^7.3.5",
|
29
29
|
"tunnel": "^0.0.6",
|
30
30
|
"unzipper": "^0.10.11"
|