tt-minigame-ide-cli 0.0.1-beta.1 → 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/README.en.md +10 -8
- package/README.md +13 -11
- package/bin/tmg.js +39 -39
- package/lib/util/helper.js +9 -11
- package/package.json +1 -1
- package/template/app.js +0 -5
- package/template/app.json +0 -11
- package/template/app.ttss +0 -0
- package/template/pages/index/index.js +0 -10
- package/template/pages/index/index.ttml +0 -1
- package/template/pages/index/index.ttss +0 -4
package/README.en.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# tmg-cli
|
2
2
|
|
3
|
-
> `tmg` cli is the official tool for bytedance
|
3
|
+
> `tmg` cli is the official tool for bytedance minigame development.
|
4
4
|
|
5
5
|
[中文](./README.md)
|
6
6
|
|
@@ -9,8 +9,8 @@
|
|
9
9
|
|
10
10
|
- [Installation](#installation)
|
11
11
|
- [Usage](#usage)
|
12
|
-
- [Create Project](#create-project)
|
13
|
-
- [Open existing project](#open-existing-project)
|
12
|
+
<!-- - [Create Project](#create-project)
|
13
|
+
- [Open existing project](#open-existing-project) -->
|
14
14
|
- [Login](#login)
|
15
15
|
- [Login by email](#login-by-email)
|
16
16
|
- [Preview project](#preview-project)
|
@@ -23,12 +23,12 @@
|
|
23
23
|
It's recommended to install `tmg` globally.
|
24
24
|
|
25
25
|
```
|
26
|
-
npm install -g tt-ide-cli
|
26
|
+
npm install -g tt-minigame-ide-cli
|
27
27
|
```
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
### Create Project
|
31
|
+
<!-- ### Create Project
|
32
32
|
|
33
33
|
Create a new blank miniprogram project with given name in current folder.
|
34
34
|
|
@@ -41,9 +41,9 @@ Options:
|
|
41
41
|
|
42
42
|
-f, --force Overwrite target directory if it exists
|
43
43
|
-h, --help Output usage information
|
44
|
-
```
|
44
|
+
``` -->
|
45
45
|
|
46
|
-
### Open existing project
|
46
|
+
<!-- ### Open existing project
|
47
47
|
|
48
48
|
Open existing project with given path in microapp IDE.
|
49
49
|
|
@@ -53,7 +53,7 @@ If the path is not available, start up the IDE only.
|
|
53
53
|
Usage: tmg open <project-path>
|
54
54
|
|
55
55
|
Open target project by path
|
56
|
-
```
|
56
|
+
``` -->
|
57
57
|
|
58
58
|
### Login
|
59
59
|
|
@@ -99,6 +99,7 @@ Options:
|
|
99
99
|
-c, --copy Copy remote url to clipboard
|
100
100
|
-p, --proxy <proxy> Preview with proxy
|
101
101
|
-h, --help output usage information
|
102
|
+
-o, --output <path> QRCode image output path
|
102
103
|
```
|
103
104
|
|
104
105
|
### Upload project
|
@@ -116,4 +117,5 @@ Options:
|
|
116
117
|
-p, --proxy <proxy> Update request proxy
|
117
118
|
-cp, --copy Copy remote url to clipboard
|
118
119
|
-h, --help output usage information
|
120
|
+
-o, --output <path> QRCode image output path
|
119
121
|
```
|
package/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# tmg-cli
|
2
2
|
|
3
|
-
> `tmg`
|
3
|
+
> `tmg` 是字节跳动小小游戏官方提供的命令行工具。
|
4
4
|
|
5
5
|
[English](./README.en.md)
|
6
6
|
|
@@ -9,11 +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)
|
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
14
|
- [登录](#%E7%99%BB%E5%BD%95)
|
15
15
|
- [通过 email 登录](#%E9%80%9A%E8%BF%87-email-%E7%99%BB%E5%BD%95)
|
16
|
-
- [
|
16
|
+
- [预览小游戏](#%E9%A2%84%E8%A7%88%E5%B0%8F%E7%A8%8B%E5%BA%8F)
|
17
17
|
- [上传项目](#%E4%B8%8A%E4%BC%A0%E9%A1%B9%E7%9B%AE)
|
18
18
|
|
19
19
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
@@ -23,12 +23,12 @@
|
|
23
23
|
建议在全局安装 `tmg` 。
|
24
24
|
|
25
25
|
```
|
26
|
-
npm install -g tt-ide-cli
|
26
|
+
npm install -g tt-minigame-ide-cli
|
27
27
|
```
|
28
28
|
|
29
29
|
## 使用
|
30
30
|
|
31
|
-
### 创建新项目
|
31
|
+
<!-- ### 创建新项目
|
32
32
|
|
33
33
|
在当前目录下,以给定的项目名字创建一个空白的小程序项目。
|
34
34
|
|
@@ -41,9 +41,9 @@ Options:
|
|
41
41
|
|
42
42
|
-f, --force Overwrite target directory if it exists
|
43
43
|
-h, --help Output usage information
|
44
|
-
```
|
44
|
+
``` -->
|
45
45
|
|
46
|
-
### 打开已有项目
|
46
|
+
<!-- ### 打开已有项目
|
47
47
|
|
48
48
|
在小程序开发者工具中打开给定目录的项目。
|
49
49
|
|
@@ -53,7 +53,7 @@ Options:
|
|
53
53
|
Usage: tmg open <project-path>
|
54
54
|
|
55
55
|
Open target project by path
|
56
|
-
```
|
56
|
+
``` -->
|
57
57
|
|
58
58
|
### 登录
|
59
59
|
|
@@ -84,9 +84,9 @@ Options:
|
|
84
84
|
|
85
85
|
```
|
86
86
|
|
87
|
-
###
|
87
|
+
### 预览小游戏
|
88
88
|
|
89
|
-
|
89
|
+
将项目上传后,扫码二维码来预览小游戏。
|
90
90
|
|
91
91
|
```
|
92
92
|
Usage: tmg preview [options] [entry]
|
@@ -100,6 +100,7 @@ Options:
|
|
100
100
|
-c, --copy Copy remote url to clipboard
|
101
101
|
-p, --proxy <proxy> Preview with proxy
|
102
102
|
-h, --help output usage information
|
103
|
+
-o, --output <path> QRCode image output path
|
103
104
|
```
|
104
105
|
|
105
106
|
### 上传项目
|
@@ -117,4 +118,5 @@ Options:
|
|
117
118
|
-p, --proxy <proxy> Update request proxy
|
118
119
|
-cp, --copy Copy remote url to clipboard
|
119
120
|
-h, --help output usage information
|
121
|
+
-o, --output <path> QRCode image output path
|
120
122
|
```
|
package/bin/tmg.js
CHANGED
@@ -15,50 +15,50 @@ program.version(getVersion(), '-V, --version', 'Output the current version');
|
|
15
15
|
|
16
16
|
//#region open project
|
17
17
|
|
18
|
-
program
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
48
|
|
49
49
|
//#endregion
|
50
50
|
|
51
51
|
//#region create new project
|
52
52
|
|
53
|
-
program
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
62
|
|
63
63
|
//#endregion
|
64
64
|
|
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,17 +44,17 @@ 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 = {
|
53
51
|
mainPackageMaxSize: 4 * 1024 * 1024,
|
54
|
-
subPackageSize:
|
52
|
+
subPackageSize: Infinity,
|
55
53
|
totalSize: 20 * 1024 * 1024,
|
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);
|
package/package.json
CHANGED
package/template/app.js
DELETED
package/template/app.json
DELETED
package/template/app.ttss
DELETED
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
<view class="intro">Welcome to Mini Program</view>
|