tt-minigame-ide-cli 1.0.2 → 2.0.0-alpha.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.
Files changed (67) hide show
  1. package/README.md +5 -98
  2. package/bin/tmg.js +4 -161
  3. package/dist/cli.js +1 -0
  4. package/dist/index.js +1 -0
  5. package/dist/miniprogram-utils/src/constants/error.d.ts +41 -0
  6. package/dist/miniprogram-utils/src/constants/index.d.ts +217 -0
  7. package/dist/miniprogram-utils/src/constants/project.d.ts +3 -0
  8. package/dist/miniprogram-utils/src/constants/slardar-events/update-events.d.ts +24 -0
  9. package/dist/miniprogram-utils/src/data/app.d.ts +30 -0
  10. package/dist/miniprogram-utils/src/data/ext.d.ts +6 -0
  11. package/dist/miniprogram-utils/src/data/jsons.d.ts +23 -0
  12. package/dist/miniprogram-utils/src/data/project.d.ts +124 -0
  13. package/dist/miniprogram-utils/src/electron-monitor/common/tea-sdk.d.ts +17 -0
  14. package/dist/miniprogram-utils/src/formation.d.ts +17 -0
  15. package/dist/miniprogram-utils/src/network/axios.d.ts +28 -0
  16. package/dist/tt-ide-cli/src/features/audit.d.ts +9 -0
  17. package/dist/tt-ide-cli/src/features/cli-login.d.ts +1 -0
  18. package/dist/tt-ide-cli/src/features/config.d.ts +3 -0
  19. package/dist/tt-ide-cli/src/features/create.d.ts +7 -0
  20. package/dist/tt-ide-cli/src/features/login.d.ts +18 -0
  21. package/dist/tt-ide-cli/src/features/meta.d.ts +23 -0
  22. package/dist/tt-ide-cli/src/features/microgame/cloud-compile.d.ts +75 -0
  23. package/dist/tt-ide-cli/src/features/microgame/index.d.ts +3 -0
  24. package/dist/tt-ide-cli/src/features/microgame/meta.d.ts +1 -0
  25. package/dist/tt-ide-cli/src/features/microgame/utils/file-system.d.ts +13 -0
  26. package/dist/tt-ide-cli/src/features/microgame/utils/package.d.ts +22 -0
  27. package/dist/tt-ide-cli/src/features/microgame/utils/settings.d.ts +48 -0
  28. package/dist/tt-ide-cli/src/features/microgame/utils/source.type.d.ts +35 -0
  29. package/dist/tt-ide-cli/src/features/npm.d.ts +10 -0
  30. package/dist/tt-ide-cli/src/features/open.d.ts +3 -0
  31. package/dist/tt-ide-cli/src/features/packages.d.ts +53 -0
  32. package/dist/tt-ide-cli/src/features/preview.d.ts +80 -0
  33. package/dist/tt-ide-cli/src/features/third-party.d.ts +9 -0
  34. package/dist/tt-ide-cli/src/index.d.ts +22 -0
  35. package/dist/tt-ide-cli/src/monitor/cli-monitor.d.ts +15 -0
  36. package/dist/tt-ide-cli/src/monitor/constants.d.ts +7 -0
  37. package/dist/tt-ide-cli/src/monitor/index.d.ts +2 -0
  38. package/dist/tt-ide-cli/src/types.d.ts +44 -0
  39. package/dist/tt-ide-cli/src/utils/constants.d.ts +3 -0
  40. package/dist/tt-ide-cli/src/utils/cookie.d.ts +6 -0
  41. package/dist/tt-ide-cli/src/utils/logger.d.ts +19 -0
  42. package/dist/tt-ide-cli/src/utils/metrics.d.ts +67 -0
  43. package/dist/tt-ide-cli/src/utils/qrcode.d.ts +64 -0
  44. package/dist/tt-ide-cli/src/utils/util.d.ts +56 -0
  45. package/dist/tt-minigame-ide-cli/src/cli.d.ts +1 -0
  46. package/dist/tt-minigame-ide-cli/src/index.d.ts +1 -0
  47. package/dist/tt-minigame-ide-cli/src/types.d.ts +43 -0
  48. package/package.json +49 -26
  49. package/.yarnrc +0 -1
  50. package/LICENSE +0 -21
  51. package/README.en.md +0 -104
  52. package/lib/auth.js +0 -145
  53. package/lib/build-npm.js +0 -22
  54. package/lib/create.js +0 -106
  55. package/lib/index.d.ts +0 -23
  56. package/lib/index.js +0 -79
  57. package/lib/preview.js +0 -92
  58. package/lib/upload.js +0 -133
  59. package/lib/util/check.js +0 -84
  60. package/lib/util/config.js +0 -41
  61. package/lib/util/cookie.js +0 -36
  62. package/lib/util/helper.js +0 -245
  63. package/lib/util/logger.js +0 -54
  64. package/lib/util/qrcode.js +0 -34
  65. package/lib/util/request.js +0 -396
  66. package/lib/util/version.js +0 -27
  67. package/lib/version.js +0 -44
package/README.md CHANGED
@@ -1,104 +1,11 @@
1
- # tmg-cli
1
+ # `tt-minigame-ide-cli`
2
2
 
3
- > `tmg` 是字节跳动小小游戏官方提供的命令行工具。
3
+ > TODO: description
4
4
 
5
- [English](./README.en.md)
6
-
7
- <!-- START doctoc generated TOC please keep comment here to allow auto update -->
8
- <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
9
-
10
- - [安装](#%E5%AE%89%E8%A3%85)
11
- - [使用](#%E4%BD%BF%E7%94%A8)
12
- - [登录](#%E7%99%BB%E5%BD%95)
13
- - [通过 email 登录](#%E9%80%9A%E8%BF%87-email-%E7%99%BB%E5%BD%95)
14
- - [预览小游戏](#%E9%A2%84%E8%A7%88%E5%B0%8F%E6%B8%B8%E6%88%8F)
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)
17
-
18
- <!-- END doctoc generated TOC please keep comment here to allow auto update -->
19
-
20
- ## 安装
21
-
22
- 建议在全局安装 `tmg` 。
23
-
24
- ```
25
- npm install -g tt-minigame-ide-cli
26
- ```
27
-
28
- ## 使用
29
-
30
- ### 登录
31
-
32
- 登录到开发者平台。支持代理设置。
33
-
34
- ```
35
- Usage: tmg login [options]
36
-
37
- Login to the developer platform
38
-
39
- Options:
40
- -m, --mobile Login by mobile
41
- -e, --email Login by email
42
- -p, --proxy <proxy> Login with proxy
43
- -h, --help output usage information
44
- ```
45
-
46
- ### 通过 email 登录
47
-
48
- ```
49
- Usage: login-e [email] [password]
50
-
51
- Login to the developer platform by E-mail
52
-
53
- Options:
54
- -p, --proxy <proxy> Login with proxy
55
- -h, --help Output usage information
56
-
57
- ```
58
-
59
- ### 预览小游戏
60
-
61
- 将项目上传后,扫码二维码来预览小游戏。
62
-
63
- ```
64
- Usage: tmg preview [options] [entry]
65
-
66
- preview project by remote
67
-
68
- Options:
69
- -f, --force Preview project without local cache(deprecated)
70
- --disable-cache Preview project without local cache
71
- -s, --small Use small QR Code, but it does not take effect in some environments
72
- -u, --copy Copy remote url to clipboard
73
- -p, --proxy <proxy> Preview with proxy
74
- -h, --help output usage information
75
- -o, --output <path> QRCode image output path
76
- ```
77
-
78
- ### 上传项目
79
-
80
- 把项目上传到开发者平台进行发布。
81
-
82
- ```
83
- Usage: tmg upload [options] [entry]
84
-
85
- upload project to the developer platform
86
-
87
- Options:
88
- -v, --app-version <version> App version (eg: [major].[minor].[patch])
89
- -c, --app-changelog <log> Changelog for this version
90
- -p, --proxy <proxy> Update request proxy
91
- -u, --copy Copy remote url to clipboard
92
- -h, --help output usage information
93
- -o, --output <path> QRCode image output path
94
- ```
95
-
96
- ### 获取项目版本
97
-
98
- 获取项目线上版本号。
5
+ ## Usage
99
6
 
100
7
  ```
101
- Usage: tmg version [entry]
8
+ const ttMinigameIdeCli = require('tt-minigame-ide-cli');
102
9
 
103
- Get latest released version of project
10
+ // TODO: DEMONSTRATE API
104
11
  ```
package/bin/tmg.js CHANGED
@@ -1,163 +1,6 @@
1
1
  #!/usr/bin/env node
2
- const fs = require('fs');
3
- const path = require('path');
4
- const chalk = require('chalk');
5
- const program = require('commander');
6
- const cp = require('child_process');
7
- const semver = require('semver');
8
- const minimist = require('minimist');
9
- const { getVersion } = require('../lib/util/version');
10
- const requiredVersion = require('../package.json').engines.node;
11
- checkNodeVersion(requiredVersion);
2
+ process.env.isCli = 'true';
3
+ process.noDeprecation = true;
4
+ process.env.isMiniGameCli = 'true';
12
5
 
13
- // Get version
14
- program.version(getVersion(), '-V, --version', 'Output the current version');
15
-
16
- //#region Login by mobile or email
17
-
18
- program
19
- .command('login')
20
- .description('Login to the developer platform')
21
- .option('-m, --mobile', 'Login by mobile')
22
- .option('-e, --email', 'Login by email')
23
- .option('-p, --proxy <proxy>', 'Login with proxy')
24
- .action((cmd) => {
25
- const options = cleanArgs(cmd);
26
- require('../lib/auth')(options);
27
- });
28
-
29
- //#endregion
30
-
31
- //#region tmg login by Email
32
-
33
- program
34
- .command('login-e [email] [password]')
35
- .description('Login to the developer platform by E-mail')
36
- .option('-p, --proxy <proxy>', 'Login with proxy')
37
- .action((email, password, cmd) => {
38
- const options = {
39
- type: 'direct',
40
- email,
41
- password,
42
- cmd,
43
- };
44
- require('../lib/auth')(options);
45
- });
46
-
47
- //#endregion
48
-
49
- //#region preview project
50
-
51
- program
52
- .command('preview [entry]')
53
- .description('Preview project by remote')
54
- .option('-f, --force', 'Preview project without local cache(deprecated)')
55
- .option('--disable-cache', 'Preview project without local cache')
56
- .option('-s, --small', 'Use small QR Code, it may fail in some environments')
57
- .option('-u, --copy', 'Copy remote url to clipboard')
58
- .option('-p, --proxy <proxy>', 'Preview with proxy')
59
- .option('-o, --output <path>', 'QRCode image output path')
60
- .action((entry, cmd) => {
61
- const options = cleanArgs(cmd);
62
- checkArgNum(1);
63
- require('../lib/preview')(entry, options);
64
- });
65
-
66
- //#endregion
67
-
68
- program
69
- .command('build-npm [projectPath]')
70
- .description('build npm packages in node_modules')
71
- // 后面需要支持一下下方的两个选项
72
- // .option('--package-json-path');
73
- // .options('-i, --ignores', 'npm packages to be ignored')
74
- .action((projectPath, cmd) => {
75
- const options = cleanArgs(cmd);
76
- require('../lib/index').buildNpm({
77
- projectPath,
78
- ...options,
79
- });
80
- });
81
-
82
- //#region upload project
83
-
84
- program
85
- .command('upload [entry]')
86
- .description('Upload project to the developer platform')
87
- .requiredOption(
88
- '-v, --app-version <version>',
89
- 'App version (eg: [major].[minor].[patch])'
90
- )
91
- .requiredOption('-c, --app-changelog <log>', 'Changelog for this version')
92
- .option('-p, --proxy <proxy>', 'Update request proxy')
93
- .option('-u, --copy', 'Copy remote url to clipboard')
94
- .option('-o, --output <path>', 'QRCode image output path')
95
- .action((entry, cmd) => {
96
- const options = cleanArgs(cmd);
97
- checkArgNum(1);
98
- // console.log(entry, options)
99
- require('../lib/upload')(entry, options);
100
- });
101
-
102
- //#endregion
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
-
115
- program.parse(process.argv);
116
-
117
- //#region helpers
118
-
119
- function camelize(str) {
120
- return str.replace(/-(\w)/g, (_, c) => (c ? c.toUpperCase() : ''));
121
- }
122
-
123
- function checkArgNum(num) {
124
- if (minimist(process.argv.slice(3))._.length > num) {
125
- console.log(
126
- chalk.yellow(
127
- '\n Info: You provided more than one argument. The first one will be used, the rest are ignored.'
128
- )
129
- );
130
- }
131
- }
132
-
133
- function checkNodeVersion(wanted) {
134
- if (!semver.satisfies(process.version, wanted)) {
135
- console.log(
136
- chalk.red(
137
- 'You are using Node ' +
138
- process.version +
139
- ', but this version of `tmg`' +
140
- ' requires Node ' +
141
- wanted +
142
- '.\nPlease upgrade your Node version.'
143
- )
144
- );
145
- process.exit(1);
146
- }
147
- }
148
-
149
- // commander passes the Command object itself as options,
150
- // extract only actual options into a fresh object.
151
- function cleanArgs(cmd) {
152
- return cmd.options.reduce((args, o) => {
153
- const key = camelize(o.long.replace(/^--/, ''));
154
- // if an option is not present and Command has a method with the same name
155
- // it should not be copied
156
- if (typeof cmd[key] !== 'function' && typeof cmd[key] !== 'undefined') {
157
- args[key] = cmd[key];
158
- }
159
- return args;
160
- }, {});
161
- }
162
-
163
- //#endregion
6
+ require('../dist/cli.js');