tt-minigame-ide-cli 0.0.1-beta.5 → 1.0.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/README.en.md CHANGED
@@ -9,12 +9,11 @@
9
9
 
10
10
  - [Installation](#installation)
11
11
  - [Usage](#usage)
12
- <!-- - [Create Project](#create-project)
13
- - [Open existing project](#open-existing-project) -->
14
12
  - [Login](#login)
15
13
  - [Login by email](#login-by-email)
16
14
  - [Preview project](#preview-project)
17
15
  - [Upload project](#upload-project)
16
+ - [Get project version](#get-project-version)
18
17
 
19
18
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
20
19
 
@@ -28,33 +27,6 @@ npm install -g tt-minigame-ide-cli
28
27
 
29
28
  ## Usage
30
29
 
31
- <!-- ### Create Project
32
-
33
- Create a new blank miniprogram project with given name in current folder.
34
-
35
- ```
36
- Usage: tmg create <project-name>
37
-
38
- Create a new project with given name in current folder
39
-
40
- Options:
41
-
42
- -f, --force Overwrite target directory if it exists
43
- -h, --help Output usage information
44
- ``` -->
45
-
46
- <!-- ### Open existing project
47
-
48
- Open existing project with given path in microapp IDE.
49
-
50
- If the path is not available, start up the IDE only.
51
-
52
- ```
53
- Usage: tmg open <project-path>
54
-
55
- Open target project by path
56
- ``` -->
57
-
58
30
  ### Login
59
31
 
60
32
  Login to the developer Platform. Proxy is supported.
@@ -119,3 +91,14 @@ Options:
119
91
  -h, --help output usage information
120
92
  -o, --output <path> QRCode image output path
121
93
  ```
94
+
95
+ ### Get project version
96
+
97
+ Get latest released version of project.
98
+
99
+ ```
100
+ Usage: tmg version [entry]
101
+
102
+ Get latest released version of project
103
+ ```
104
+
package/README.md CHANGED
@@ -9,12 +9,11 @@
9
9
 
10
10
  - [安装](#%E5%AE%89%E8%A3%85)
11
11
  - [使用](#%E4%BD%BF%E7%94%A8)
12
- <!-- - [创建新项目](#%E5%88%9B%E5%BB%BA%E6%96%B0%E9%A1%B9%E7%9B%AE)
13
- - [打开已有项目](#%E6%89%93%E5%BC%80%E5%B7%B2%E6%9C%89%E9%A1%B9%E7%9B%AE) -->
14
12
  - [登录](#%E7%99%BB%E5%BD%95)
15
13
  - [通过 email 登录](#%E9%80%9A%E8%BF%87-email-%E7%99%BB%E5%BD%95)
16
- - [预览小游戏](#%E9%A2%84%E8%A7%88%E5%B0%8F%E7%A8%8B%E5%BA%8F)
14
+ - [预览小游戏](#%E9%A2%84%E8%A7%88%E5%B0%8F%E6%B8%B8%E6%88%8F)
17
15
  - [上传项目](#%E4%B8%8A%E4%BC%A0%E9%A1%B9%E7%9B%AE)
16
+ - [获取项目版本](#%E8%8E%B7%E5%8F%96%E9%A1%B9%E7%9B%AE%E7%89%88%E6%9C%AC)
18
17
 
19
18
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
20
19
 
@@ -28,33 +27,6 @@ npm install -g tt-minigame-ide-cli
28
27
 
29
28
  ## 使用
30
29
 
31
- <!-- ### 创建新项目
32
-
33
- 在当前目录下,以给定的项目名字创建一个空白的小程序项目。
34
-
35
- ```
36
- Usage: tmg create <project-name>
37
-
38
- Create a new project with given name in current folder
39
-
40
- Options:
41
-
42
- -f, --force Overwrite target directory if it exists
43
- -h, --help Output usage information
44
- ``` -->
45
-
46
- <!-- ### 打开已有项目
47
-
48
- 在小程序开发者工具中打开给定目录的项目。
49
-
50
- 如果给定的目录不存在,则仅打开开发者工具。
51
-
52
- ```
53
- Usage: tmg open <project-path>
54
-
55
- Open target project by path
56
- ``` -->
57
-
58
30
  ### 登录
59
31
 
60
32
  登录到开发者平台。支持代理设置。
@@ -120,3 +92,13 @@ Options:
120
92
  -h, --help output usage information
121
93
  -o, --output <path> QRCode image output path
122
94
  ```
95
+
96
+ ### 获取项目版本
97
+
98
+ 获取项目线上版本号。
99
+
100
+ ```
101
+ Usage: tmg version [entry]
102
+
103
+ Get latest released version of project
104
+ ```
package/bin/tmg.js CHANGED
@@ -13,55 +13,6 @@ checkNodeVersion(requiredVersion);
13
13
  // Get version
14
14
  program.version(getVersion(), '-V, --version', 'Output the current version');
15
15
 
16
- //#region open project
17
-
18
- // program
19
- // .command('open <project-path>')
20
- // .description('Open target project by path')
21
- // .action((projectPath) => {
22
- // const isMac = process.platform === 'darwin',
23
- // IDE_SCHEMA = 'bytedanceide:';
24
- // const openCmd = isMac ? `open ${IDE_SCHEMA}` : `explorer ${IDE_SCHEMA}`;
25
- // let openPath;
26
- // if (!path.isAbsolute(projectPath)) {
27
- // projectPath = path.join(process.cwd(), projectPath);
28
- // }
29
- // if (fs.existsSync(projectPath)) {
30
- // // open project with existing path
31
- // console.log(chalk.green(`open projectPath: ${projectPath}`));
32
- // openPath = `${openCmd}?path=${projectPath}`;
33
- // } else {
34
- // // project folder not exist,
35
- // // open IDE
36
- // console.log(chalk.green(`open IDE`));
37
- // openPath = openCmd;
38
- // }
39
-
40
- // cp.exec(openPath, (error) => {
41
- // if (!error) {
42
- // console.log('打开IDE成功');
43
- // } else {
44
- // console.log(chalk.red('打开IDE失败', error));
45
- // }
46
- // });
47
- // });
48
-
49
- //#endregion
50
-
51
- //#region create new project
52
-
53
- // program
54
- // .command('create <project-name>')
55
- // .description('Create a new project with given name in current folder')
56
- // .option('-f, --force', 'Overwrite target directory if it exists')
57
- // .action((name, cmd) => {
58
- // const options = cleanArgs(cmd);
59
- // checkArgNum(1);
60
- // require('../lib/create')(name, options);
61
- // });
62
-
63
- //#endregion
64
-
65
16
  //#region Login by mobile or email
66
17
 
67
18
  program
@@ -150,6 +101,17 @@ program
150
101
 
151
102
  //#endregion
152
103
 
104
+ //#region version
105
+ program
106
+ .command('version [entry]')
107
+ .description('Get latest released version of project')
108
+ .action((entry, cmd) => {
109
+ const options = cleanArgs(cmd);
110
+ checkArgNum(1);
111
+ require('../lib/version')(entry, options);
112
+ });
113
+ //#endregion
114
+
153
115
  program.parse(process.argv);
154
116
 
155
117
  //#region helpers
@@ -366,16 +366,17 @@ exports.checkRemoteVersion = async function () {
366
366
  // 获取远程版本号
367
367
  exports.checkUploadVersion = async function (appId, version) {
368
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;
369
+ const current = await getProjectReleaseVersion(appId);
371
370
  if (compareVersions(version, current) > 0) {
372
371
  return {
372
+ current,
373
373
  success: true,
374
374
  }
375
375
  } else {
376
376
  return {
377
+ current,
377
378
  success: false,
378
- msg: `The version you uploaded must be greater than the current version ${current}.`,
379
+ msg: `The version you uploaded must be greater than ${current}.`,
379
380
  }
380
381
  }
381
382
  } catch (err) {
@@ -384,4 +385,10 @@ exports.checkUploadVersion = async function (appId, version) {
384
385
  msg: err.message
385
386
  }
386
387
  }
387
- }
388
+ }
389
+
390
+ const getProjectReleaseVersion = async function (appId) {
391
+ 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()}`)
392
+ return res.data.data.version;
393
+ }
394
+ exports.getProjectReleaseVersion = getProjectReleaseVersion;
package/lib/version.js ADDED
@@ -0,0 +1,44 @@
1
+ // Get project version
2
+ const path = require('path');
3
+ const chalk = require('chalk');
4
+ const {
5
+ checkBeforeUpload,
6
+ isValidAppVersion,
7
+ } = require('./util/check');
8
+ const {
9
+ getProjectReleaseVersion
10
+ } = require('./util/request');
11
+
12
+ async function version(entry, options) {
13
+ const cwd = options.cwd || process.cwd();
14
+ if (!entry) {
15
+ entry = cwd
16
+ } else if (path.isAbsolute(entry)) {
17
+ // skip if entry if absolute path
18
+ } else {
19
+ // resolve the relative entry with cwd
20
+ entry = path.resolve(cwd, entry);
21
+ }
22
+
23
+ const {
24
+ success: beforeSuccess,
25
+ msg: beforeMsg,
26
+ appId
27
+ } = await checkBeforeUpload(entry);
28
+ if (!beforeSuccess) {
29
+ const errMsg = `[CLI VERSION ERROR]: ${beforeMsg}`;
30
+ console.log(chalk.red(errMsg));
31
+ throw new Error(errMsg);
32
+ }
33
+
34
+ const version = await getProjectReleaseVersion(appId);
35
+ console.log(version);
36
+ }
37
+
38
+ module.exports = (...args) => {
39
+ return version(...args).catch(err => {
40
+ const errMsg = `[CLI VERSION ERROR]: ${err}`;
41
+ console.log(chalk.red(errMsg));
42
+ throw new Error(errMsg);
43
+ });
44
+ }
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "tt-minigame-ide-cli",
3
- "version": "0.0.1-beta.5",
3
+ "version": "1.0.1",
4
4
  "description": "Command line interface for micro app development",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
7
7
  "tmg": "bin/tmg.js"
8
8
  },
9
- "scripts": {},
9
+ "scripts": {
10
+ "doctoc": "doctoc README.md README.en.md"
11
+ },
10
12
  "author": "liubowen.howard@bytedance.com",
11
13
  "license": "ISC",
12
14
  "dependencies": {
@@ -32,5 +34,8 @@
32
34
  },
33
35
  "engines": {
34
36
  "node": ">=8.9"
37
+ },
38
+ "devDependencies": {
39
+ "doctoc": "^2.2.0"
35
40
  }
36
41
  }