@ttmg/cli 0.1.3-beta.1 → 0.1.3-beta.2
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 +4 -0
- package/dist/index.js +37 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -923,6 +923,9 @@ async function createServer() {
|
|
|
923
923
|
const { fileName } = req.params;
|
|
924
924
|
res.sendFile(path.join(outputDir, fileName));
|
|
925
925
|
});
|
|
926
|
+
app.get('/game/qrcode', async (req, res) => {
|
|
927
|
+
res.sendFile(path.join(OUTPUT_DIR, `dev-qrcode.png`));
|
|
928
|
+
});
|
|
926
929
|
/**
|
|
927
930
|
* 支持文件访问
|
|
928
931
|
*/
|
|
@@ -1269,18 +1272,41 @@ async function watchChange() {
|
|
|
1269
1272
|
});
|
|
1270
1273
|
}
|
|
1271
1274
|
|
|
1275
|
+
// 保持你原来的 import
|
|
1276
|
+
// 你的静态服务器运行的端口
|
|
1277
|
+
// --- 修改结束 ---
|
|
1272
1278
|
async function showSchema() {
|
|
1279
|
+
if (!fs.existsSync(OUTPUT_DIR)) {
|
|
1280
|
+
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
1281
|
+
}
|
|
1273
1282
|
const clientKey = getClientKey();
|
|
1274
|
-
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1283
|
+
// 2. 定义二维码图片的文件名和完整路径
|
|
1284
|
+
const qrCodeFileName = 'dev-qrcode.png';
|
|
1285
|
+
const qrCodeImagePath = path.join(OUTPUT_DIR, qrCodeFileName);
|
|
1286
|
+
const schema = `https://www.tiktok.com/ttmg/dev/${clientKey}?host=${getLocalIP()}&port=${DEV_WS_PORT}`;
|
|
1287
|
+
try {
|
|
1288
|
+
// 3. 使用 QRCode.toFile 生成图片到你的静态目录
|
|
1289
|
+
await QRCode.toFile(qrCodeImagePath, schema, {
|
|
1290
|
+
type: 'png',
|
|
1291
|
+
width: 200,
|
|
1292
|
+
margin: 1,
|
|
1293
|
+
});
|
|
1294
|
+
// 4. 构建可通过静态服务器访问的 URL
|
|
1295
|
+
const qrCodeUrl = `http://localhost:${DEV_PORT}/game/qrcode`;
|
|
1296
|
+
// 5. 打印更新后的提示信息
|
|
1297
|
+
console.log(chalk.green.bold('Tips:'));
|
|
1298
|
+
console.log(` 1. ${chalk.yellow.bold('Open the link below in your browser to see the QR code, then scan it.')}`);
|
|
1299
|
+
console.log(` ${chalk.cyan.underline(qrCodeUrl)}`);
|
|
1300
|
+
console.log(` 2. ${chalk.yellow.bold('Will auto upload compiled resource to client.')}`);
|
|
1301
|
+
console.log(` 3. ${chalk.yellow.bold('Debug your game in the browser.')}\n`);
|
|
1302
|
+
/**
|
|
1303
|
+
* 自动打开浏览器
|
|
1304
|
+
*/
|
|
1305
|
+
openUrl(qrCodeUrl);
|
|
1306
|
+
}
|
|
1307
|
+
catch (err) {
|
|
1308
|
+
console.error(chalk.red('Failed to generate QR code image.'), err);
|
|
1309
|
+
}
|
|
1284
1310
|
}
|
|
1285
1311
|
|
|
1286
1312
|
async function dev() {
|
|
@@ -1302,7 +1328,7 @@ async function dev() {
|
|
|
1302
1328
|
await watchChange();
|
|
1303
1329
|
}
|
|
1304
1330
|
|
|
1305
|
-
var version = "0.1.3-beta.
|
|
1331
|
+
var version = "0.1.3-beta.2";
|
|
1306
1332
|
var pkg = {
|
|
1307
1333
|
version: version};
|
|
1308
1334
|
|