tt-minigame-ide-cli 0.0.1-beta.4 → 0.0.1-beta.5
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/README.en.md +2 -2
- package/README.md +2 -2
- package/bin/tmg.js +2 -2
- package/lib/upload.js +13 -1
- package/lib/util/request.js +27 -2
- package/package.json +2 -1
package/README.en.md
CHANGED
@@ -96,7 +96,7 @@ Options:
|
|
96
96
|
-f, --force Preview project without local cache(deprecated)
|
97
97
|
--disable-cache Preview project without local cache
|
98
98
|
-s, --small Use small QR Code, but it does not take effect in some environments
|
99
|
-
-
|
99
|
+
-u, --copy Copy remote url to clipboard
|
100
100
|
-p, --proxy <proxy> Preview with proxy
|
101
101
|
-h, --help output usage information
|
102
102
|
-o, --output <path> QRCode image output path
|
@@ -115,7 +115,7 @@ Options:
|
|
115
115
|
-v, --app-version <version> App version (eg: [major].[minor].[patch])
|
116
116
|
-c, --app-changelog <log> Changelog for this version
|
117
117
|
-p, --proxy <proxy> Update request proxy
|
118
|
-
-
|
118
|
+
-u, --copy Copy remote url to clipboard
|
119
119
|
-h, --help output usage information
|
120
120
|
-o, --output <path> QRCode image output path
|
121
121
|
```
|
package/README.md
CHANGED
@@ -97,7 +97,7 @@ Options:
|
|
97
97
|
-f, --force Preview project without local cache(deprecated)
|
98
98
|
--disable-cache Preview project without local cache
|
99
99
|
-s, --small Use small QR Code, but it does not take effect in some environments
|
100
|
-
-
|
100
|
+
-u, --copy Copy remote url to clipboard
|
101
101
|
-p, --proxy <proxy> Preview with proxy
|
102
102
|
-h, --help output usage information
|
103
103
|
-o, --output <path> QRCode image output path
|
@@ -116,7 +116,7 @@ Options:
|
|
116
116
|
-v, --app-version <version> App version (eg: [major].[minor].[patch])
|
117
117
|
-c, --app-changelog <log> Changelog for this version
|
118
118
|
-p, --proxy <proxy> Update request proxy
|
119
|
-
-
|
119
|
+
-u, --copy Copy remote url to clipboard
|
120
120
|
-h, --help output usage information
|
121
121
|
-o, --output <path> QRCode image output path
|
122
122
|
```
|
package/bin/tmg.js
CHANGED
@@ -103,7 +103,7 @@ program
|
|
103
103
|
.option('-f, --force', 'Preview project without local cache(deprecated)')
|
104
104
|
.option('--disable-cache', 'Preview project without local cache')
|
105
105
|
.option('-s, --small', 'Use small QR Code, it may fail in some environments')
|
106
|
-
.option('-
|
106
|
+
.option('-u, --copy', 'Copy remote url to clipboard')
|
107
107
|
.option('-p, --proxy <proxy>', 'Preview with proxy')
|
108
108
|
.option('-o, --output <path>', 'QRCode image output path')
|
109
109
|
.action((entry, cmd) => {
|
@@ -139,7 +139,7 @@ program
|
|
139
139
|
)
|
140
140
|
.requiredOption('-c, --app-changelog <log>', 'Changelog for this version')
|
141
141
|
.option('-p, --proxy <proxy>', 'Update request proxy')
|
142
|
-
.option('-
|
142
|
+
.option('-u, --copy', 'Copy remote url to clipboard')
|
143
143
|
.option('-o, --output <path>', 'QRCode image output path')
|
144
144
|
.action((entry, cmd) => {
|
145
145
|
const options = cleanArgs(cmd);
|
package/lib/upload.js
CHANGED
@@ -17,7 +17,8 @@ const {
|
|
17
17
|
uploadProject,
|
18
18
|
getCompileProgress,
|
19
19
|
checkUserPermissions,
|
20
|
-
getQrCode
|
20
|
+
getQrCode,
|
21
|
+
checkUploadVersion,
|
21
22
|
} = require('./util/request');
|
22
23
|
const {
|
23
24
|
generateQrCode
|
@@ -50,6 +51,17 @@ async function upload(entry, options) {
|
|
50
51
|
console.log(chalk.red(errMsg));
|
51
52
|
throw new Error(errMsg);
|
52
53
|
}
|
54
|
+
|
55
|
+
const {
|
56
|
+
success: checkVersionSuccess,
|
57
|
+
msg: checkVersionMsg,
|
58
|
+
} = await checkUploadVersion(appId, options.appVersion);
|
59
|
+
if (!checkVersionSuccess) {
|
60
|
+
const errMsg = `[CLI UPLOAD ERROR]: ${checkVersionMsg}`;
|
61
|
+
console.log(chalk.red(errMsg));
|
62
|
+
throw new Error(errMsg);
|
63
|
+
}
|
64
|
+
|
53
65
|
const tempDir = options.tempDir || path.join(__dirname, '../temp');
|
54
66
|
await fs.emptyDir(tempDir);
|
55
67
|
|
package/lib/util/request.js
CHANGED
@@ -4,6 +4,7 @@ const querystring = require('querystring');
|
|
4
4
|
const url = require('url');
|
5
5
|
const fs = require('fs');
|
6
6
|
const execa = require('execa');
|
7
|
+
const compareVersions = require('compare-versions');
|
7
8
|
const {
|
8
9
|
getUserCookies
|
9
10
|
} = require('./cookie');
|
@@ -32,8 +33,8 @@ axios.interceptors.request.use(config => {
|
|
32
33
|
config.headers.Referer = REFERER;
|
33
34
|
if (config.data instanceof FormData) {
|
34
35
|
Object.assign(config.headers, config.data.getHeaders());
|
35
|
-
|
36
|
-
if(config.proxy) {
|
36
|
+
}
|
37
|
+
if (config.proxy) {
|
37
38
|
const parseURL = URL.parse(config.proxy.host);
|
38
39
|
config.httpsAgent = require('tunnel').httpsOverHttp({
|
39
40
|
proxy: {
|
@@ -340,6 +341,7 @@ exports.checkUserPermissions = function (appId, proxy) {
|
|
340
341
|
}
|
341
342
|
});
|
342
343
|
}
|
344
|
+
|
343
345
|
// 该方法暂无调用
|
344
346
|
exports.checkRemoteVersion = async function () {
|
345
347
|
const registry = (await execa('npm', ['config', 'get', 'registry'])).stdout;
|
@@ -359,4 +361,27 @@ exports.checkRemoteVersion = async function () {
|
|
359
361
|
msg: err.message
|
360
362
|
}
|
361
363
|
});
|
364
|
+
}
|
365
|
+
|
366
|
+
// 获取远程版本号
|
367
|
+
exports.checkUploadVersion = async function (appId, version) {
|
368
|
+
try {
|
369
|
+
const res = await axios.get(`/api/apps/v3/meta?appid=${appId}&aid=13&version=current&ttcode=OVCNW/U0UREwv0sHdY9Rm16vBgGrCQIBOWurUCmJ1H6d/2XHLKeOYTYfEJIEeC0AOCwBZAR2j34C4tFN7Nqfq9tHVEpM4OuJM2b8qz0INtUs1qLhKFOtnGa9/Ey0WW86GGocJk074eP72MMhzNmePzaTQzXwn/eqEq4GHwyF2Tg=&t=${new Date().getTime()}`)
|
370
|
+
const current = res.data.data.version;
|
371
|
+
if (compareVersions(version, current) > 0) {
|
372
|
+
return {
|
373
|
+
success: true,
|
374
|
+
}
|
375
|
+
} else {
|
376
|
+
return {
|
377
|
+
success: false,
|
378
|
+
msg: `The version you uploaded must be greater than the current version ${current}.`,
|
379
|
+
}
|
380
|
+
}
|
381
|
+
} catch (err) {
|
382
|
+
return {
|
383
|
+
success: false,
|
384
|
+
msg: err.message
|
385
|
+
}
|
386
|
+
}
|
362
387
|
}
|
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.5",
|
4
4
|
"description": "Command line interface for micro app development",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"bin": {
|
@@ -17,6 +17,7 @@
|
|
17
17
|
"chalk": "^3.0.0",
|
18
18
|
"clipboardy": "^2.2.0",
|
19
19
|
"commander": "^4.1.1",
|
20
|
+
"compare-versions": "^4.1.3",
|
20
21
|
"execa": "^4.0.0",
|
21
22
|
"folder-hash": "^3.3.0",
|
22
23
|
"form-data": "^3.0.0",
|