hytopia 0.10.46 → 0.10.47
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/bin/scripts.js +0 -54
- package/package.json +1 -1
- package/server.mjs +2 -2
package/bin/scripts.js
CHANGED
|
@@ -41,15 +41,11 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
41
41
|
'init-mcp': initMcp,
|
|
42
42
|
'package': packageProject,
|
|
43
43
|
'start': start,
|
|
44
|
-
'update-hosts': () => checkHostsConfiguration(true),
|
|
45
44
|
'upgrade-cli': () => upgradeCli(process.argv[3] || 'latest'),
|
|
46
45
|
'upgrade-project': () => upgradeProject(process.argv[3] || 'latest'),
|
|
47
46
|
'version': displayVersion,
|
|
48
47
|
};
|
|
49
48
|
|
|
50
|
-
// Check that hosts is properly configured
|
|
51
|
-
checkHostsConfiguration(false);
|
|
52
|
-
|
|
53
49
|
const handler = commandHandlers[command];
|
|
54
50
|
|
|
55
51
|
if (handler) {
|
|
@@ -481,55 +477,6 @@ async function build(devMode = false) {
|
|
|
481
477
|
execSync(`npx --yes bun build --target=node --env=disable --format=esm ${envFlags} --outfile=index.mjs index.ts`, { stdio: 'inherit' });
|
|
482
478
|
}
|
|
483
479
|
|
|
484
|
-
/**
|
|
485
|
-
* Checks the hosts files and makes sure that dev-local.hytopia.com points to localhost.
|
|
486
|
-
*/
|
|
487
|
-
function checkHostsConfiguration(verbose = false) {
|
|
488
|
-
const DOMAIN = 'dev-local.hytopia.com';
|
|
489
|
-
const isWindows = process.platform === 'win32';
|
|
490
|
-
const hostsPath = isWindows
|
|
491
|
-
? path.join(process.env.SystemRoot || 'C://Windows', 'System32', 'drivers', 'etc', 'hosts')
|
|
492
|
-
: '/etc/hosts';
|
|
493
|
-
|
|
494
|
-
let content = '';
|
|
495
|
-
try {
|
|
496
|
-
content = fs.existsSync(hostsPath) ? fs.readFileSync(hostsPath, 'utf8') : '';
|
|
497
|
-
} catch {
|
|
498
|
-
console.warn(`⚠️ Unable to check hosts configuration. If you can connect to your local server you can ignore this. Otherwise, run 'sudo hytopia update-hosts' to fix connectivity issues.`);
|
|
499
|
-
return; // no read access; skip silently
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
const managedBegin = '# HYTOPIA DEV-LOCAL BEGIN';
|
|
503
|
-
const managedEnd = '# HYTOPIA DEV-LOCAL END';
|
|
504
|
-
|
|
505
|
-
if (content.includes(managedBegin) && content.includes(managedEnd)) {
|
|
506
|
-
if (verbose) {
|
|
507
|
-
console.log(`✅ Hosts already configured: ${DOMAIN} -> 127.0.0.1, ::1`);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
return; // already configured by us, skip
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
const EOL = content.includes('\r\n') ? '\r\n' : '\n';
|
|
514
|
-
const block = [
|
|
515
|
-
managedBegin,
|
|
516
|
-
`127.0.0.1 ${DOMAIN}`,
|
|
517
|
-
`::1 ${DOMAIN}`,
|
|
518
|
-
managedEnd,
|
|
519
|
-
'', '' // double empty line to give spacing in hosts for nicer formatting
|
|
520
|
-
].join(EOL);
|
|
521
|
-
|
|
522
|
-
const newContent = block + content;
|
|
523
|
-
|
|
524
|
-
try {
|
|
525
|
-
fs.writeFileSync(hostsPath, newContent, { encoding: 'utf8' });
|
|
526
|
-
console.log(`✅ Hosts updated: ${DOMAIN} -> 127.0.0.1, ::1`);
|
|
527
|
-
console.log(`🎉 You can now run your server with 'hytopia start' - While running, you can test & play it at: https://hytopia.com/play`);
|
|
528
|
-
} catch {
|
|
529
|
-
console.error(`🚨 Could not modify hosts file (${hostsPath}) to add the dev-local.hytopia.com. You MUST run 'sudo hytopia update-hosts' to fix connections to your local server.`);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
|
|
533
480
|
/**
|
|
534
481
|
* Parses command-line flags in the format --flag value
|
|
535
482
|
*/
|
|
@@ -666,7 +613,6 @@ function displayHelp() {
|
|
|
666
613
|
console.log(' init [--template NAME] Initialize a new project');
|
|
667
614
|
console.log(' init-mcp Setup MCP integrations');
|
|
668
615
|
console.log(' package Create a zip of the project for uploading to the HYTOPIA create portal.');
|
|
669
|
-
console.log(' update-hosts Update the hosts file to add the dev-local.hytopia.com domain (MUST RUN WITH SUDO: sudo hytopia update-hosts)');
|
|
670
616
|
console.log(' upgrade-cli Upgrade the HYTOPIA CLI');
|
|
671
617
|
console.log(' upgrade-project [VERSION] Upgrade project SDK dep (default: latest)');
|
|
672
618
|
console.log('');
|
package/package.json
CHANGED