@ttmg/cli 0.1.3-beta.1 → 0.1.3-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/CHANGELOG.md +7 -0
- package/dist/index.js +38 -19
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -913,15 +913,11 @@ async function createServer() {
|
|
|
913
913
|
*/
|
|
914
914
|
const outputDir = getOutputDir();
|
|
915
915
|
/**
|
|
916
|
-
*
|
|
916
|
+
* 支持静态资源
|
|
917
917
|
*/
|
|
918
|
-
app.use(express.static(outputDir));
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
*/
|
|
922
|
-
app.get('/game/files/:fileName', async (req, res) => {
|
|
923
|
-
const { fileName } = req.params;
|
|
924
|
-
res.sendFile(path.join(outputDir, fileName));
|
|
918
|
+
app.use('/game/files', express.static(outputDir));
|
|
919
|
+
app.get('/game/qrcode', async (req, res) => {
|
|
920
|
+
res.sendFile(path.join(OUTPUT_DIR, `dev-qrcode.png`));
|
|
925
921
|
});
|
|
926
922
|
/**
|
|
927
923
|
* 支持文件访问
|
|
@@ -1269,18 +1265,41 @@ async function watchChange() {
|
|
|
1269
1265
|
});
|
|
1270
1266
|
}
|
|
1271
1267
|
|
|
1268
|
+
// 保持你原来的 import
|
|
1269
|
+
// 你的静态服务器运行的端口
|
|
1270
|
+
// --- 修改结束 ---
|
|
1272
1271
|
async function showSchema() {
|
|
1272
|
+
if (!fs.existsSync(OUTPUT_DIR)) {
|
|
1273
|
+
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
1274
|
+
}
|
|
1273
1275
|
const clientKey = getClientKey();
|
|
1274
|
-
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1276
|
+
// 2. 定义二维码图片的文件名和完整路径
|
|
1277
|
+
const qrCodeFileName = 'dev-qrcode.png';
|
|
1278
|
+
const qrCodeImagePath = path.join(OUTPUT_DIR, qrCodeFileName);
|
|
1279
|
+
const schema = `https://www.tiktok.com/ttmg/dev/${clientKey}?host=${getLocalIP()}&port=${DEV_WS_PORT}`;
|
|
1280
|
+
try {
|
|
1281
|
+
// 3. 使用 QRCode.toFile 生成图片到你的静态目录
|
|
1282
|
+
await QRCode.toFile(qrCodeImagePath, schema, {
|
|
1283
|
+
type: 'png',
|
|
1284
|
+
width: 200,
|
|
1285
|
+
margin: 1,
|
|
1286
|
+
});
|
|
1287
|
+
// 4. 构建可通过静态服务器访问的 URL
|
|
1288
|
+
const qrCodeUrl = `http://localhost:${DEV_PORT}/game/qrcode`;
|
|
1289
|
+
// 5. 打印更新后的提示信息
|
|
1290
|
+
console.log(chalk.green.bold('Tips:'));
|
|
1291
|
+
console.log(` 1. ${chalk.yellow.bold('Open the link below in your browser to see the QR code, then scan it.')}`);
|
|
1292
|
+
console.log(` ${chalk.cyan.underline(qrCodeUrl)}`);
|
|
1293
|
+
console.log(` 2. ${chalk.yellow.bold('Will auto upload compiled resource to client.')}`);
|
|
1294
|
+
console.log(` 3. ${chalk.yellow.bold('Debug your game in the browser.')}\n`);
|
|
1295
|
+
/**
|
|
1296
|
+
* 自动打开浏览器
|
|
1297
|
+
*/
|
|
1298
|
+
openUrl(qrCodeUrl);
|
|
1299
|
+
}
|
|
1300
|
+
catch (err) {
|
|
1301
|
+
console.error(chalk.red('Failed to generate QR code image.'), err);
|
|
1302
|
+
}
|
|
1284
1303
|
}
|
|
1285
1304
|
|
|
1286
1305
|
async function dev() {
|
|
@@ -1302,7 +1321,7 @@ async function dev() {
|
|
|
1302
1321
|
await watchChange();
|
|
1303
1322
|
}
|
|
1304
1323
|
|
|
1305
|
-
var version = "0.1.3-beta.
|
|
1324
|
+
var version = "0.1.3-beta.3";
|
|
1306
1325
|
var pkg = {
|
|
1307
1326
|
version: version};
|
|
1308
1327
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttmg/cli",
|
|
3
|
-
"version": "0.1.3-beta.
|
|
3
|
+
"version": "0.1.3-beta.3",
|
|
4
4
|
"description": "TikTok Mini Game Command Line Tool",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"bin": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"prettier": "^3.6.2",
|
|
44
44
|
"qrcode": "^1.5.4",
|
|
45
45
|
"semver": "^7.7.2",
|
|
46
|
-
"ttmg-pack": "0.0.
|
|
46
|
+
"ttmg-pack": "0.0.27",
|
|
47
47
|
"ws": "^8.18.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|