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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # tmg-cli
2
2
 
3
- > `tmg` cli is the official tool for bytedance microapp development.
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
- - [预览小程序](#%E9%A2%84%E8%A7%88%E5%B0%8F%E7%A8%8B%E5%BA%8F)
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
- .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
- });
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
- .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
- });
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
 
@@ -24,21 +24,19 @@ function mixEncode(data) {
24
24
  }
25
25
 
26
26
  async function zipFile(sourcePath, targetPath) {
27
- const appJsonPath = path.join(sourcePath, 'app.json');
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, isMiniProgram, sourcePath);
34
+ const ifSubPackageUploadable = await verifySubPackageSize(projectConfigJson, sourcePath);
37
35
  if (ifSubPackageUploadable) {
38
- zipFileRet.filePath = await normalZipFile(sourcePath, targetPath, isMiniProgram, true);
36
+ zipFileRet.filePath = await normalZipFile(sourcePath, targetPath, true);
39
37
  }
40
38
  } else {
41
- zipFileRet.filePath = await normalZipFile(sourcePath, targetPath, isMiniProgram, false);
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, isMiniProgram, sourcePath) {
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: 4 * 1024 * 1024,
52
+ subPackageSize: Infinity,
55
53
  totalSize: 20 * 1024 * 1024,
56
54
  };
57
55
  // console.log('校验', projectConfigJson, packageSizeConfig);
58
56
  // 开放数据域文件校验,可以认为开放数据域也作为一个子包
59
- if (isMiniProgram && projectConfigJson.openDataContext) {
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, isMiniProgram, isSubPackage) {
112
+ async function normalZipFile(sourcePath, targetPath, isSubPackage) {
115
113
 
116
- const packageSize = isMiniProgram ? 4 : 8;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-minigame-ide-cli",
3
- "version": "0.0.1-beta.1",
3
+ "version": "0.0.1-beta.4",
4
4
  "description": "Command line interface for micro app development",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
package/template/app.js DELETED
@@ -1,5 +0,0 @@
1
- App({
2
- onLaunch: function () {
3
-
4
- }
5
- })
package/template/app.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "pages":[
3
- "pages/index/index"
4
- ],
5
- "window":{
6
- "backgroundTextStyle":"light",
7
- "navigationBarBackgroundColor": "#fff",
8
- "navigationBarTitleText": "Mini Program",
9
- "navigationBarTextStyle":"black"
10
- }
11
- }
package/template/app.ttss DELETED
File without changes
@@ -1,10 +0,0 @@
1
- const app = getApp()
2
-
3
- Page({
4
- data: {
5
-
6
- },
7
- onLoad: function () {
8
- console.log('Welcome to Mini Program')
9
- },
10
- })
@@ -1 +0,0 @@
1
- <view class="intro">Welcome to Mini Program</view>
@@ -1,4 +0,0 @@
1
- .intro {
2
- margin: 30px;
3
- text-align: center;
4
- }