tt-minigame-ide-cli 0.0.1-beta.0 → 0.0.1-beta.3

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
 
@@ -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);
@@ -51,8 +51,8 @@ async function verifySubPackageSize(projectConfigJson, isMiniProgram, sourcePath
51
51
  // 做大小比较全拿字节数,精确
52
52
  const packageSizeConfig = {
53
53
  mainPackageMaxSize: 4 * 1024 * 1024,
54
- subPackageSize: (this.isGame ? 4 : 2) * 1024 * 1024,
55
- totalSize: 16 * 1024 * 1024,
54
+ subPackageSize: Infinity,
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
- `小${this.isGame ? '游戏' : '程序'}包大小为 ${getFormattedSize(
75
+ `小游戏包大小为 ${getFormattedSize(
76
76
  totalPackageSize,
77
- )} MB, 超过 16 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
  '**',
@@ -1,17 +1,32 @@
1
- const qrcode = require('qrcode-terminal');
1
+ const QRCode = require('qrcode');
2
2
  const chalk = require('chalk');
3
+
3
4
  function generateQrCode(url, options) {
4
- // sometimes can not use small type, see: https://github.com/gtanner/qrcode-terminal/issues/21
5
- qrcode.generate(url, { small: options.small });
6
- let copied = '';
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
- if (options.small) {
12
- console.log(`${chalk.yellow('small QR Code may not work in some environments')}\n`);
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 = {
@@ -191,6 +191,8 @@ exports.uploadProject = function ({
191
191
  },
192
192
  url: path,
193
193
  form,
194
+ maxBodyLength: Infinity,
195
+ maxContentLength: Infinity,
194
196
  }
195
197
  if (proxy && proxy.indexOf(':') > -1) {
196
198
  const proxySplitArr = proxy.split(':');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-minigame-ide-cli",
3
- "version": "0.0.1-beta.0",
3
+ "version": "0.0.1-beta.3",
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-terminal": "^0.12.0",
27
+ "qrcode": "^1.5.0",
28
28
  "semver": "^7.3.5",
29
29
  "tunnel": "^0.0.6",
30
30
  "unzipper": "^0.10.11"
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
- }