create-yeow 0.2.123 → 0.2.124

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-yeow",
3
- "version": "0.2.123",
3
+ "version": "0.2.124",
4
4
  "description": "Scaffold a Yeow plugin project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -221,7 +221,7 @@ async function initServer() {
221
221
  const eula = resolve(SERVER, 'eula.txt');
222
222
  if (existsSync(eula) && readFileSync(eula, 'utf-8').includes('eula=true')) return;
223
223
 
224
- if (YES) {
224
+ if (EULA) {
225
225
  if (!existsSync(resolve(SERVER, 'server.properties'))) {
226
226
  info('Initializing...');
227
227
  await new Promise(r => { const p = spawn('java', ['-Xmx4G', '-Xms4G', '-jar', jar, '--nogui'], { cwd: SERVER, stdio: ['pipe', 'inherit', 'inherit'] }); setTimeout(() => { p.kill(); r(); }, 120000); p.on('exit', r); p.on('error', r); });
@@ -429,7 +429,7 @@ async function printFormattedError(err) {
429
429
  }
430
430
 
431
431
  function startServer() {
432
- const jvmArgs = ['-Xmx4G', '-Xms4G', '-Dyeow.dev=true', '-Dyeow.ws.port=' + WS_PORT];
432
+ const jvmArgs = ['-Xmx4G', '-Xms4G', '-Dfile.encoding=UTF-8', '-Dstdout.encoding=UTF-8', '-Dyeow.dev=true', '-Dyeow.ws.port=' + WS_PORT];
433
433
  info(`\nStarting Paper ${PAPER_VERSION} server...`);
434
434
  proc = spawn('java', [...jvmArgs, '-jar', resolve(SERVER, PAPER_JAR), '--nogui'], { cwd: SERVER, stdio: ['pipe', 'inherit', 'inherit'] });
435
435
  proc.on('exit', code => { warn(`Server exited (${code})`); if (wss) wss.close(); process.exit(0); });
@@ -478,17 +478,24 @@ async function runHeadless() {
478
478
  copyToYeowDir(resolve(ROOT, 'dist', 'plugins', `${cfg.name}-${cfg.version}.yeow.zip`), 'Plugin (.yeow.zip → plugins/Yeow/)');
479
479
  copyToPlugins(RUNTIME, 'Runtime');
480
480
 
481
- const jvmArgs = ['-Xmx4G', '-Xms4G', '-Dyeow.dev=true', '-Dyeow.ws.port=' + WS_PORT];
481
+ // 编码:确保子进程 stdout UTF-8 输出(Windows 下避免中文字符乱码)
482
+ const jvmArgs = ['-Xmx4G', '-Xms4G', '-Dfile.encoding=UTF-8', '-Dstdout.encoding=UTF-8',
483
+ '-Dyeow.dev=true', '-Dyeow.ws.port=' + WS_PORT];
482
484
  info(`正在启动 Paper ${PAPER_VERSION}...`);
483
485
  proc = spawn('java', [...jvmArgs, '-jar', resolve(SERVER, PAPER_JAR), '--nogui'], { cwd: SERVER, stdio: ['ignore', 'pipe', 'pipe'] });
484
486
  info(`Server PID: ${proc.pid}`);
485
487
 
486
488
  let started = false, done = false, waitTimer = null;
489
+ const finish = (code) => {
490
+ if (waitTimer) clearTimeout(waitTimer);
491
+ try { if (log) log.end(); } catch {}
492
+ process.exit(code);
493
+ };
487
494
  const failTimer = setTimeout(() => {
488
495
  if (done) return;
489
496
  fail(`服务器在 ${TIMEOUT}s 内未完成加载——请检查网络/依赖下载,或加大超时(--timeout=3m)`);
490
497
  killProc();
491
- process.exit(1);
498
+ finish(1);
492
499
  }, TIMEOUT * 1000);
493
500
 
494
501
  const onLine = (line) => {
@@ -503,20 +510,17 @@ async function runHeadless() {
503
510
  info(`加载完成——等待 ${WAIT}s 后命令结束${KEEP ? '(--keep 保留服务器进程)' : '(关闭服务器进程)'}…`);
504
511
  waitTimer = setTimeout(() => {
505
512
  info(`等待结束。日志${OUTFILE ? ':' + OUTFILE : '输出于上方'};PID=${proc.pid}${KEEP ? '(服务器仍在运行,按需 kill)' : ''}`);
506
- if (log) log.end();
507
- if (KEEP) process.exit(0);
508
- killProc();
509
- process.exit(0);
513
+ if (!KEEP) killProc();
514
+ finish(0);
510
515
  }, WAIT * 1000);
511
516
  }
512
517
  };
513
- readline.createInterface({ input: proc.stdout }).on('line', onLine);
514
- if (proc.stderr) readline.createInterface({ input: proc.stderr }).on('line', (l) => out('[err] ' + l));
518
+ createInterface({ input: proc.stdout }).on('line', onLine);
519
+ if (proc.stderr) createInterface({ input: proc.stderr }).on('line', (l) => out('[err] ' + l));
515
520
 
516
521
  proc.on('exit', (code) => {
517
522
  if (!done) fail(`服务器提前退出(code ${code})——见${OUTFILE ? '日志 ' + OUTFILE : '上方输出'}`);
518
- if (log) log.end();
519
- process.exit(1);
523
+ finish(1);
520
524
  });
521
525
  }
522
526